BmnRoot
Loading...
Searching...
No Matches
L1Algo.cxx
Go to the documentation of this file.
1#include "L1Algo.h"
2
3void L1Algo::Init( const fscal geo[] )
4{
5 int ind=0;
6 {
7 L1FieldValue B[3];
8 fvec z[3];
9 for( int i=0; i<3; i++){
10 z[i] = geo[ind++]; B[i].x = geo[ind++]; B[i].y = geo[ind++]; B[i].z = geo[ind++];
11#ifndef TBB2
12 //std::cout<<"L1Algo Input Magnetic field:"<<z[i][0]<<" "<<B[i].x[0]<<" "<<B[i].y[0]<<" "<<B[i].z[0]<<std::endl;
13#endif // TBB2
14 }
15 vtxFieldRegion.Set(B[0], z[0], B[1], z[1], B[2], z[2] );
16 vtxFieldValue = B[0];
17 }
18 //vStations.clear();
19 NStations = static_cast<int>(geo[ind++]);
20 NMvdStations = static_cast<int>(geo[ind++]);
21
22 // cout << "N MVD & STS stations: " << NMvdStations << " " << NStations-NMvdStations << endl;
23#ifndef TBB2
24 //std::cout<<"L1Algo Input "<<NStations<<" Stations:"<<std::endl;
25#endif // TBB2
26 for( int i=0; i<NStations; i++ ){
27 L1Station &st = vStations[i];
28 st.z = geo[ind++];
29 st.materialInfo.thick = geo[ind++];
30 st.Rmin = geo[ind++];
31 st.Rmax = geo[ind++];
32 st.materialInfo.RL = geo[ind++];
35
36 double f_phi = geo[ind++];
37 double f_sigma = geo[ind++];
38 //f_sigma = 0.008; //AZ
39 double b_phi = geo[ind++];
40 double b_sigma = geo[ind++];
41 //b_sigma = 0.008; //AZ
42 double c_f = cos(f_phi);
43 double s_f = sin(f_phi);
44 double c_b = cos(b_phi);
45 double s_b = sin(b_phi);
46
47 st.frontInfo.cos_phi = c_f;
48 st.frontInfo.sin_phi = s_f;
49 st.frontInfo.sigma2 = f_sigma*f_sigma;
50
51 st.backInfo.cos_phi = c_b;
52 st.backInfo.sin_phi = s_b;
53 st.backInfo.sigma2 = b_sigma*b_sigma;
54 //cout << " Sigmas: " << f_sigma << " " << b_sigma << endl; //AZ
55
56 if( fabs(b_phi-f_phi)<.1 ){
57 double th = b_phi-f_phi;
58 double det = cos(th);
59 det *=det;
60 st.XYInfo.C00 = ( s_b*s_b*f_sigma*f_sigma + s_f*s_f*b_sigma*b_sigma )/det;
61 st.XYInfo.C10 =-( s_b*c_b*f_sigma*f_sigma + s_f*c_f*b_sigma*b_sigma )/det;
62 st.XYInfo.C11 = ( c_b*c_b*f_sigma*f_sigma + c_f*c_f*b_sigma*b_sigma )/det;
63//std::cout << "!!! det "<< det<<std::endl;
64 //cout << " Here1 " << st.XYInfo.C11 << endl; //AZ
65 }
66 else{
67 double det = c_f*s_b - s_f*c_b;
68 det *=det;
69 st.XYInfo.C00 = ( s_b*s_b*f_sigma*f_sigma + s_f*s_f*b_sigma*b_sigma )/det;
70 st.XYInfo.C10 =-( s_b*c_b*f_sigma*f_sigma + s_f*c_f*b_sigma*b_sigma )/det;
71 st.XYInfo.C11 = ( c_b*c_b*f_sigma*f_sigma + c_f*c_f*b_sigma*b_sigma )/det;
72 //cout << " Here2 " << st.XYInfo.C11 << endl; //AZ
73 //cout << " Cos_phi: " << st.frontInfo.cos_phi << endl; //AZ
74//std::cout << "!!! det "<< det<<std::endl;
75 }
76//std::cout.precision(10);
77//std::cout << "Station "<<i<<" " << st.XYInfo.C00[0]<<" "<<st.XYInfo.C11[0]<<" "<<st.XYInfo.C10[0]<<std::endl;
78//std::cout << " "<< i<<" fsigma " << f_sigma<<" bsigma "<<b_sigma<<std::endl;
79
80// st.xInfo.cos_phi = c_f/(c_f*s_b - c_b*s_f);
81// st.xInfo.sin_phi =-c_b/(c_f*s_b - c_b*s_f);
82 st.xInfo.cos_phi = -s_f/(c_f*s_b - c_b*s_f);
83 st.xInfo.sin_phi = s_b/(c_f*s_b - c_b*s_f);
84 st.xInfo.sigma2 = st.XYInfo.C00;
85
86 st.yInfo.cos_phi = c_b/(c_b*s_f - c_f*s_b);
87 st.yInfo.sin_phi =-c_f/(c_b*s_f - c_f*s_b);
88 st.yInfo.sigma2 = st.XYInfo.C11;
89//std::cout << "st.xInfo.cos_phi "<<st.xInfo.cos_phi<< " st.yInfo.cos_phi " << st.yInfo.cos_phi << std::endl;
90//std::cout << "st.xInfo.sin_phi "<<st.xInfo.sin_phi<< " st.yInfo.sin_phi " << st.yInfo.sin_phi << std::endl;
91
92//std::cout << "cos_b "<<c_b<< " sin_b " << s_b << std::endl;
93//std::cout << "cos_f "<<c_f<< " sin_f " << s_f << std::endl;
94
95
96 int N= static_cast<int>( geo[ind++] );
97 for( int iC=0; iC<N; iC++ ) st.fieldSlice.cx[iC] = geo[ind++];
98 for( int iC=0; iC<N; iC++ ) st.fieldSlice.cy[iC] = geo[ind++];
99 for( int iC=0; iC<N; iC++ ) st.fieldSlice.cz[iC] = geo[ind++];
100#ifndef TBB2
101 //std::cout<<" "<<st.z[0] <<" "<<st.materialInfo.thick[0]<<" "<<st.materialInfo.RL[0]<<", "
102 // <<N<<" field coeff."<<std::endl;
103 //std::cout<<" "<<f_phi<<" "<<f_sigma <<" "<<b_phi<<" "<<b_sigma <<std::endl;
104#endif // TBB2
105 }
106
107 fTrackingLevel = static_cast<int>( geo[ind++] );
108 fMomentumCutOff = geo[ind++];
109 fGhostSuppression = static_cast<int>( geo[ind++] );
110
111 {
112 //fvec By0 = vStations[NStations-1].fieldSlice.cy[0];
113 fvec z0 = vStations[NStations-1].z;
114 fvec sy = 0., Sy = 0.;
115 for( int i=NStations-1; i>=0; i-- ){
116 L1Station &st = vStations[i];
117 fvec dz = st.z-z0;
118 fvec By = vStations[i].fieldSlice.cy[0];
119 Sy += dz*sy + dz*dz*By/2.;
120 sy += dz*By;
121 st.Sy = Sy;
122 z0 = st.z;
123 }
124 }
125#ifndef TBB2
126 //std::cout<<"L1Algo initialized"<<std::endl;
127#endif // TBB2
128}
129
130#ifdef TBB2
131void L1Algo::SetData( const vector< L1StsHit > & StsHits_,
132 const vector< L1Strip > & StsStrips_,
133 const vector< L1Strip > & StsStripsB_,
134 const vector< fscal > & StsZPos_,
135 const vector< unsigned char > & SFlag_,
136 const vector< unsigned char > & SFlagB_,
137 const THitI* StsHitsStartIndex_,
138 const THitI* StsHitsStopIndex_ )
139{
140 vStsHits.resize(StsHits_.size());
141 vStsStrips.resize(StsStrips_.size());
142 vStsStripsB.resize(StsStripsB_.size());
143 vStsZPos.resize(StsZPos_.size());
144 vSFlag.resize(SFlag_.size());
145 vSFlagB.resize(SFlagB_.size());
146
147 for(unsigned int i=0; i<StsHits_.size(); ++i ) vStsHits[i] = StsHits_[i];
148 for(unsigned int i=0; i<StsStrips_.size(); ++i ) vStsStrips[i] = StsStrips_[i];
149 for(unsigned int i=0; i<StsStripsB_.size(); ++i ) vStsStripsB[i] = StsStripsB_[i];
150 for(unsigned int i=0; i<StsZPos_.size(); ++i ) vStsZPos[i] = StsZPos_[i];
151 for(unsigned int i=0; i<SFlag_.size(); ++i ) vSFlag[i] = SFlag_[i];
152 for(unsigned int i=0; i<SFlagB_.size(); ++i ) vSFlagB[i] = SFlagB_[i];
153
154 for(unsigned int i=0; i<MaxNStations+1; ++i) StsHitsStartIndex[i] = StsHitsStartIndex_[i];
155 for(unsigned int i=0; i<MaxNStations+1; ++i) StsHitsStopIndex[i] = StsHitsStopIndex_[i];
156}
157#endif
158
159void L1Algo::GetHitCoor(const L1StsHit& _h, fscal &_x, fscal &_y, fscal &_z, const L1Station &sta)
160{
161 fscal u = vStsStrips[_h.f];
162 fscal v = vStsStripsB[_h.b];
163 fscal x,y;
164 StripsToCoor(u,v,x,y,sta);
165 _x = x;
166 _y = y;
167 _z = vStsZPos[_h.iz];
168}
169
171void L1Algo::StripsToCoor(const fscal &u, const fscal &v, fscal &_x, fscal &_y, const L1Station &sta) const// TODO: Actually sta.yInfo.sin_phi is same for all stations, so ...
172{
173 fvec x,y;
174 StripsToCoor(u,v,x,y,sta);
175 _x = x[0];
176 _y = y[0];
177}
178
179void L1Algo::StripsToCoor(const fvec &u, const fvec &v, fvec &x, fvec &y, const L1Station &sta) const// TODO: Actually sta.yInfo.sin_phi is same for all stations, so ...
180{
181 // only for same-z
182// x = u;
183// y = (sta.yInfo.cos_phi*u + sta.yInfo.sin_phi*v);
184 x = sta.xInfo.sin_phi*u + sta.xInfo.cos_phi*v;
185 y = sta.yInfo.cos_phi*u + sta.yInfo.sin_phi*v;
186 //cout << sta.xInfo.sin_phi << " " << sta.xInfo.cos_phi << endl; //AZ
187 //cout << " y " << sta.yInfo.sin_phi << " " << sta.yInfo.cos_phi << endl; //AZ
188 //cout << x << " " << y << " " << sta.z << endl; //AZ
189 //cout << sta.XYInfo.C00 << " " << sta.XYInfo.C10 << " " << sta.XYInfo.C11 << endl; //AZ
190}
191
193L1HitPoint L1Algo::CreateHitPoint(const L1StsHit &hit, char ista)
194{
195 L1Station &sta = vStations[int(ista)];
196 L1Strip &u = vStsStrips[hit.f];
197 L1Strip &v = vStsStripsB[hit.b];
198 fscal x, y;
199 StripsToCoor( u, v, x, y, sta);
200 fscal z = vStsZPos[hit.iz];
201
202 //return L1HitPoint(x,y,z,v,u,hit.n);
203 fscal du = u.errf(), dv = v.errf(); // AZ
204 return L1HitPoint(x,y,z,v,u,dv,du,hit.n); //AZ - with errors
205}
206
const Float_t z0
Definition BmnMwpcHit.cxx:6
unsigned int THitI
Definition L1StsHit.h:6
float fscal
Definition P4_F32vec4.h:232
friend F32vec4 sin(const F32vec4 &a)
Definition P4_F32vec4.h:124
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
__m128 v
Definition P4_F32vec4.h:1
friend F32vec4 cos(const F32vec4 &a)
Definition P4_F32vec4.h:125
int i
Definition P4_F32vec4.h:22
friend F32vec4 log(const F32vec4 &a)
Definition P4_F32vec4.h:123
vector< unsigned char > vSFlag
Definition L1Algo.h:134
int NStations
Definition L1Algo.h:123
THitI StsHitsStopIndex[MaxNStations+1]
Definition L1Algo.h:136
vector< L1Strip > vStsStrips
Definition L1Algo.h:129
@ MaxNStations
Definition L1Algo.h:122
vector< unsigned char > vSFlagB
Definition L1Algo.h:135
THitI StsHitsStartIndex[MaxNStations+1]
Definition L1Algo.h:136
int NMvdStations
Definition L1Algo.h:124
vector< L1StsHit > vStsHits
Definition L1Algo.h:132
vector< L1Strip > vStsStripsB
Definition L1Algo.h:130
vector< fscal > vStsZPos
Definition L1Algo.h:131
void Init(const fscal geo[])
Definition L1Algo.cxx:3
fvec cy[21]
Definition L1Field.h:37
fvec cx[21]
Definition L1Field.h:37
fvec cz[21]
Definition L1Field.h:37
L1XYMeasurementInfo XYInfo
Definition L1Station.h:23
fvec Rmin
Definition L1Station.h:19
L1UMeasurementInfo backInfo
Definition L1Station.h:22
L1UMeasurementInfo xInfo
Definition L1Station.h:22
L1UMeasurementInfo yInfo
Definition L1Station.h:22
fvec Rmax
Definition L1Station.h:19
L1FieldSlice fieldSlice
Definition L1Station.h:21
L1MaterialInfo materialInfo
Definition L1Station.h:20
L1UMeasurementInfo frontInfo
Definition L1Station.h:22
fvec Sy
Definition L1Station.h:19
TZPosI iz
Definition L1StsHit.h:13
unsigned short int n
Definition L1StsHit.h:15
TStripI f
Definition L1StsHit.h:12
TStripI b
Definition L1StsHit.h:12
contain strips positions and coordinates of hit
Definition L1HitPoint.h:6
fscal errf()
Definition L1Strip.h:13