12 |
*/ |
*/ |
13 |
CaloPreSampler::CaloPreSampler(){ |
CaloPreSampler::CaloPreSampler(){ |
14 |
Clear(); |
Clear(); |
15 |
}; |
} |
16 |
|
|
17 |
CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){ |
CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){ |
18 |
// |
// |
30 |
cstrip = new CaloStrip(false); |
cstrip = new CaloStrip(false); |
31 |
// c1 = new CaloLevel1(); |
// c1 = new CaloLevel1(); |
32 |
pcalo = new CaloLevel2(); |
pcalo = new CaloLevel2(); |
33 |
N = 3; |
N = 4; |
34 |
|
NC = 22-N; |
35 |
debug = false; |
debug = false; |
36 |
sel = true; |
sel = true; |
37 |
cont = false; |
cont = false; |
38 |
emulate18 = true; |
emulate18 = true; |
39 |
simulation = false; |
simulation = false; |
40 |
|
withtrk = true; |
41 |
|
rigdefault = 50.; |
42 |
|
nox = false; |
43 |
|
noy = false; |
44 |
|
forcecalo = false; |
45 |
|
forcefitmode = -1; |
46 |
|
memset(mask,0,2*22*sizeof(Int_t)); |
47 |
// |
// |
48 |
Clear(); |
Clear(); |
49 |
// |
// |
70 |
printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data()); |
printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data()); |
71 |
trk->LoadField(q4->PATH+q4->NAME); |
trk->LoadField(q4->PATH+q4->NAME); |
72 |
// |
// |
73 |
}; |
} |
74 |
|
|
75 |
|
void CaloPreSampler::SetNoWpreSampler(Int_t n){ |
76 |
|
if ( NC+n < 23 ){ |
77 |
|
N = n; |
78 |
|
} else { |
79 |
|
printf(" ERROR! Calorimeter is made of 22 W planes\n"); |
80 |
|
printf(" you are giving N presampler = %i and N calo = %i \n",n,NC); |
81 |
|
printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n"); |
82 |
|
NC = 18; |
83 |
|
N = 4; |
84 |
|
}; |
85 |
|
} |
86 |
|
|
87 |
|
void CaloPreSampler::SetNoWcalo(Int_t n){ |
88 |
|
if ( N+n < 23 ){ |
89 |
|
NC = n; |
90 |
|
} else { |
91 |
|
printf(" ERROR! Calorimeter is made of 22 W planes\n"); |
92 |
|
printf(" you are giving N W presampler = %i and N W calo = %i \n",N,n); |
93 |
|
printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n"); |
94 |
|
NC = 18; |
95 |
|
N = 4; |
96 |
|
}; |
97 |
|
} |
98 |
|
|
99 |
|
void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){ |
100 |
|
this->SetNoWcalo(0); |
101 |
|
this->SetNoWpreSampler(0); |
102 |
|
if ( NoWpreSampler < NoWcalo ){ |
103 |
|
this->SetNoWpreSampler(NoWpreSampler); |
104 |
|
this->SetNoWcalo(NoWcalo); |
105 |
|
} else { |
106 |
|
this->SetNoWcalo(NoWcalo); |
107 |
|
this->SetNoWpreSampler(NoWpreSampler); |
108 |
|
}; |
109 |
|
} |
110 |
|
|
111 |
void CaloPreSampler::Clear(){ |
void CaloPreSampler::Clear(){ |
112 |
// |
// |
113 |
pcalo->Clear(); |
pcalo->Clear(); |
114 |
// |
// |
115 |
}; |
} |
116 |
|
|
117 |
void CaloPreSampler::Print(){ |
void CaloPreSampler::Print(){ |
118 |
// |
// |
134 |
}; |
}; |
135 |
printf("========================================================================\n"); |
printf("========================================================================\n"); |
136 |
// |
// |
137 |
}; |
} |
138 |
|
|
139 |
void CaloPreSampler::Delete(){ |
void CaloPreSampler::Delete(){ |
140 |
Clear(); |
Clear(); |
141 |
delete pcalo; |
delete pcalo; |
142 |
//delete this; |
//delete this; |
143 |
}; |
} |
144 |
|
|
145 |
|
|
146 |
void CaloPreSampler::Process(){ |
void CaloPreSampler::Process(){ |
151 |
return; |
return; |
152 |
}; |
}; |
153 |
// |
// |
154 |
|
// Clear structures used to communicate with fortran |
155 |
|
// |
156 |
|
event->ClearStructs();//ELENA |
157 |
|
if ( forcefitmode > 0 ){ |
158 |
|
if ( forcefitmode != 1000 && forcefitmode != 1001 && forcefitmode != 1002 ){ |
159 |
|
printf(" ERROR! forcefitmode=%i \n Use forcefitmode = 1000 for fit mode 0, 1001 fit mode 1, 1002 fit mode 3\n",forcefitmode); |
160 |
|
forcefitmode = -1; |
161 |
|
} else { |
162 |
|
event->clevel2->fmode[0] = forcefitmode; |
163 |
|
event->clevel2->fmode[1] = forcefitmode; |
164 |
|
}; |
165 |
|
}; |
166 |
|
// |
167 |
Bool_t newentry = false; |
Bool_t newentry = false; |
168 |
// |
// |
169 |
if ( L2->IsORB() ){ |
if ( L2->IsORB() ){ |
170 |
|
if ( debug ) printf(" I am here, we have orbital infos \n"); |
171 |
if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || sel != ssel ){ |
if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || sel != ssel ){ |
172 |
newentry = true; |
newentry = true; |
173 |
OBT = L2->GetOrbitalInfo()->OBT; |
OBT = L2->GetOrbitalInfo()->OBT; |
189 |
Int_t S11 = 0; |
Int_t S11 = 0; |
190 |
Float_t tmptrigty = -1.; |
Float_t tmptrigty = -1.; |
191 |
Bool_t trackanyway = true; |
Bool_t trackanyway = true; |
192 |
Float_t rigdefault = 50.; |
// Float_t rigdefault = 50.; |
193 |
Bool_t hZn = true; |
Bool_t hZn = true; |
194 |
Bool_t withtrk = true; |
// Bool_t withtrk = true; |
195 |
Bool_t st = true; |
Bool_t st = true; |
196 |
Int_t ntrkentry = 0; |
Int_t ntrkentry = 0; |
197 |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
211 |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true; |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true; |
212 |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true; |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true; |
213 |
}; |
}; |
214 |
|
if ( !withtrk ) m3 = true; |
215 |
// |
// |
216 |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
217 |
// |
// |
226 |
// |
// |
227 |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
228 |
// |
// |
229 |
|
// Mask x or y view if nox and/or noy are true (default false) |
230 |
|
// |
231 |
|
if ( mask[view][plane] ) mip = 0.; |
232 |
|
if ( nox && view == 0 ) mip = 0.; |
233 |
|
if ( noy && view == 1 ) mip = 0.; |
234 |
|
// |
235 |
|
if ( emulate18 && view == 0 && plane == 18 ) mip = 0.; |
236 |
|
// |
237 |
// Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19 |
// Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19 |
238 |
// included so plane < (22 - 2) |
// included so plane < (22 - 2) |
239 |
// |
// |
240 |
if ( sel ){ |
if ( sel ){ |
241 |
if ( plane < (22 - N) ){ |
if ( plane < (22 - N) ){ |
242 |
// |
// |
243 |
if ( emulate18 && plane == (18 - N) ) mip = 0.; |
if ( emulate18 && plane == (18 - N) && view == 0 ) mip = 0.; |
244 |
|
if ( plane >= NC ) mip = 0.; |
245 |
event->clevel1->estrip[strip][plane][view] = mip; |
event->clevel1->estrip[strip][plane][view] = mip; |
246 |
// |
// |
247 |
}; |
}; |
252 |
if ( cont ){ |
if ( cont ){ |
253 |
if ( plane >= N ){ |
if ( plane >= N ){ |
254 |
// |
// |
255 |
if ( emulate18 && plane == (18 + N) ) mip = 0.; |
if ( emulate18 && plane == (18 + N) && view == 0 ) mip = 0.; |
256 |
|
if ( (plane-N) >= NC ) mip = 0.; |
257 |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
258 |
// |
// |
259 |
}; |
}; |
297 |
// |
// |
298 |
// use only N W planes |
// use only N W planes |
299 |
// |
// |
300 |
event->clevel1->npla = 22-N; |
// event->clevel1->npla = 22-N; |
301 |
|
event->clevel1->npla = NC; |
302 |
// |
// |
303 |
S3 = 0; |
S3 = 0; |
304 |
S2 = 0; |
S2 = 0; |
318 |
// |
// |
319 |
event->clevel1->good2 = 1; |
event->clevel1->good2 = 1; |
320 |
// |
// |
321 |
|
// copy variables calculated during calibration process which is skipped here... |
322 |
|
// |
323 |
|
event->clevel2->good = L2->GetCaloLevel2()->good; |
324 |
|
memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); |
325 |
|
memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); |
326 |
|
memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); |
327 |
|
event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; |
328 |
|
// |
329 |
// Calculate variables common to all tracks (qtot, nstrip, etc.) |
// Calculate variables common to all tracks (qtot, nstrip, etc.) |
330 |
// |
// |
331 |
if ( debug ) printf("1 Call GetCommonVar() \n"); |
if ( debug ) printf("1 Call GetCommonVar() \n"); |
389 |
// conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event |
// conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event |
390 |
// |
// |
391 |
// if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){ |
// if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){ |
392 |
if ( trackanyway && m3 ){ |
if ( (trackanyway && m3) || forcecalo ){ |
393 |
if ( debug ) printf(" Event with a track not fitted by the tracker \n"); |
if ( debug ) printf(" Event with a track not fitted by the tracker \n"); |
394 |
// |
// |
395 |
// Disable "track mode" in the fortran routine |
// Disable "track mode" in the fortran routine |
521 |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
522 |
}; |
}; |
523 |
}; |
}; |
524 |
// |
// // |
525 |
// Clear structures used to communicate with fortran |
// // Clear structures used to communicate with fortran |
526 |
// |
// // |
527 |
event->ClearStructs(); |
// event->ClearStructs(); |
528 |
|
// ELENA: moved @ beginning |
529 |
// |
// |
530 |
// |
// |
531 |
// |
// |
532 |
if ( debug ) this->Print(); |
if ( debug ) this->Print(); |
533 |
if ( debug ) printf(" exit \n"); |
if ( debug ) printf(" exit \n"); |
534 |
// |
// |
535 |
}; |
} |
536 |
|
|
537 |
|
// |
538 |
|
// Method to add a calorimeter track, evaluated around a tracker track defined by a status vector. |
539 |
|
// (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection ) |
540 |
|
// |
541 |
|
// |
542 |
|
CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){ |
543 |
|
|
544 |
|
int ntrkentry = pcalo->ntrk(); |
545 |
|
// |
546 |
|
for (Int_t nt=0; nt < ntrkentry; nt++){ |
547 |
|
if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){ |
548 |
|
cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"<<endl; |
549 |
|
cout << " --> trktag = "<<trktag<<" already defined "<<endl; |
550 |
|
return NULL; |
551 |
|
} |
552 |
|
} |
553 |
|
// |
554 |
|
event->clevel1->good2 = 1; //is a trk track |
555 |
|
event->clevel1->trkchi2 = 0; |
556 |
|
event->clevel1->hzn = 0; |
557 |
|
// |
558 |
|
// Copy the alpha vector in the input structure |
559 |
|
// |
560 |
|
for (Int_t e = 0; e < 5 ; e++){ |
561 |
|
event->clevel1->al_p[e][0] = al[e]; |
562 |
|
}; |
563 |
|
// |
564 |
|
// Get tracker related variables for this track |
565 |
|
// |
566 |
|
if ( debug ) printf("track %i Call GetTrkVar() \n",trktag); |
567 |
|
event->GetTrkVar(); |
568 |
|
if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l); |
569 |
|
// |
570 |
|
// Save tracker track sequence number |
571 |
|
// |
572 |
|
event->trkseqno = trktag; |
573 |
|
// |
574 |
|
// Copy values in the class ca from the structure clevel2 |
575 |
|
// |
576 |
|
if ( debug ) printf("track %i Call FillTrkVar() \n",trktag); |
577 |
|
event->FillTrkVar(pcalo,ntrkentry); |
578 |
|
|
579 |
|
return pcalo->GetCaloTrkVar(ntrkentry); |
580 |
|
|
581 |
|
|
582 |
|
};//ELENA |