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 |
|
memset(mask,0,2*22*sizeof(Int_t)); |
46 |
// |
// |
47 |
Clear(); |
Clear(); |
48 |
// |
// |
69 |
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()); |
70 |
trk->LoadField(q4->PATH+q4->NAME); |
trk->LoadField(q4->PATH+q4->NAME); |
71 |
// |
// |
72 |
}; |
} |
73 |
|
|
74 |
|
void CaloPreSampler::SetNoWpreSampler(Int_t n){ |
75 |
|
if ( NC+n < 23 ){ |
76 |
|
N = n; |
77 |
|
} else { |
78 |
|
printf(" ERROR! Calorimeter is made of 22 W planes\n"); |
79 |
|
printf(" you are giving N presampler = %i and N calo = %i \n",n,NC); |
80 |
|
printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n"); |
81 |
|
NC = 18; |
82 |
|
N = 4; |
83 |
|
}; |
84 |
|
} |
85 |
|
|
86 |
|
void CaloPreSampler::SetNoWcalo(Int_t n){ |
87 |
|
if ( N+n < 23 ){ |
88 |
|
NC = n; |
89 |
|
} else { |
90 |
|
printf(" ERROR! Calorimeter is made of 22 W planes\n"); |
91 |
|
printf(" you are giving N W presampler = %i and N W calo = %i \n",N,n); |
92 |
|
printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n"); |
93 |
|
NC = 18; |
94 |
|
N = 4; |
95 |
|
}; |
96 |
|
} |
97 |
|
|
98 |
|
void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){ |
99 |
|
this->SetNoWcalo(0); |
100 |
|
this->SetNoWpreSampler(0); |
101 |
|
if ( NoWpreSampler < NoWcalo ){ |
102 |
|
this->SetNoWpreSampler(NoWpreSampler); |
103 |
|
this->SetNoWcalo(NoWcalo); |
104 |
|
} else { |
105 |
|
this->SetNoWcalo(NoWcalo); |
106 |
|
this->SetNoWpreSampler(NoWpreSampler); |
107 |
|
}; |
108 |
|
} |
109 |
|
|
110 |
void CaloPreSampler::Clear(){ |
void CaloPreSampler::Clear(){ |
111 |
// |
// |
112 |
pcalo->Clear(); |
pcalo->Clear(); |
113 |
// |
// |
114 |
}; |
} |
115 |
|
|
116 |
void CaloPreSampler::Print(){ |
void CaloPreSampler::Print(){ |
117 |
// |
// |
133 |
}; |
}; |
134 |
printf("========================================================================\n"); |
printf("========================================================================\n"); |
135 |
// |
// |
136 |
}; |
} |
137 |
|
|
138 |
void CaloPreSampler::Delete(){ |
void CaloPreSampler::Delete(){ |
139 |
Clear(); |
Clear(); |
140 |
delete pcalo; |
delete pcalo; |
141 |
//delete this; |
//delete this; |
142 |
}; |
} |
143 |
|
|
144 |
|
|
145 |
void CaloPreSampler::Process(){ |
void CaloPreSampler::Process(){ |
150 |
return; |
return; |
151 |
}; |
}; |
152 |
// |
// |
153 |
|
// Clear structures used to communicate with fortran |
154 |
|
// |
155 |
|
event->ClearStructs();//ELENA |
156 |
|
// |
157 |
Bool_t newentry = false; |
Bool_t newentry = false; |
158 |
// |
// |
159 |
if ( L2->IsORB() ){ |
if ( L2->IsORB() ){ |
178 |
Int_t S11 = 0; |
Int_t S11 = 0; |
179 |
Float_t tmptrigty = -1.; |
Float_t tmptrigty = -1.; |
180 |
Bool_t trackanyway = true; |
Bool_t trackanyway = true; |
181 |
Float_t rigdefault = 50.; |
// Float_t rigdefault = 50.; |
182 |
Bool_t hZn = true; |
Bool_t hZn = true; |
183 |
Bool_t withtrk = true; |
// Bool_t withtrk = true; |
184 |
Bool_t st = true; |
Bool_t st = true; |
185 |
Int_t ntrkentry = 0; |
Int_t ntrkentry = 0; |
186 |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
200 |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true; |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true; |
201 |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true; |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true; |
202 |
}; |
}; |
203 |
|
if ( !withtrk ) m3 = true; |
204 |
// |
// |
205 |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
206 |
// |
// |
215 |
// |
// |
216 |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
217 |
// |
// |
218 |
|
// Mask x or y view if nox and/or noy are true (default false) |
219 |
|
// |
220 |
|
if ( mask[view][plane] ) mip = 0.; |
221 |
|
if ( nox && view == 0 ) mip = 0.; |
222 |
|
if ( noy && view == 1 ) mip = 0.; |
223 |
|
// |
224 |
|
if ( emulate18 && view == 0 && plane == 18 ) mip = 0.; |
225 |
|
// |
226 |
// 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 |
227 |
// included so plane < (22 - 2) |
// included so plane < (22 - 2) |
228 |
// |
// |
229 |
if ( sel ){ |
if ( sel ){ |
230 |
if ( plane < (22 - N) ){ |
if ( plane < (22 - N) ){ |
231 |
// |
// |
232 |
if ( emulate18 && plane == (18 - N) ) mip = 0.; |
if ( emulate18 && plane == (18 - N) && view == 0 ) mip = 0.; |
233 |
|
if ( plane >= NC ) mip = 0.; |
234 |
event->clevel1->estrip[strip][plane][view] = mip; |
event->clevel1->estrip[strip][plane][view] = mip; |
235 |
// |
// |
236 |
}; |
}; |
241 |
if ( cont ){ |
if ( cont ){ |
242 |
if ( plane >= N ){ |
if ( plane >= N ){ |
243 |
// |
// |
244 |
if ( emulate18 && plane == (18 + N) ) mip = 0.; |
if ( emulate18 && plane == (18 + N) && view == 0 ) mip = 0.; |
245 |
|
if ( (plane-N) >= NC ) mip = 0.; |
246 |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
247 |
// |
// |
248 |
}; |
}; |
286 |
// |
// |
287 |
// use only N W planes |
// use only N W planes |
288 |
// |
// |
289 |
event->clevel1->npla = 22-N; |
// event->clevel1->npla = 22-N; |
290 |
|
event->clevel1->npla = NC; |
291 |
// |
// |
292 |
S3 = 0; |
S3 = 0; |
293 |
S2 = 0; |
S2 = 0; |
378 |
// 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 |
379 |
// |
// |
380 |
// 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. ){ |
381 |
if ( trackanyway && m3 ){ |
if ( (trackanyway && m3) || forcecalo ){ |
382 |
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"); |
383 |
// |
// |
384 |
// Disable "track mode" in the fortran routine |
// Disable "track mode" in the fortran routine |
510 |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
511 |
}; |
}; |
512 |
}; |
}; |
513 |
// |
// // |
514 |
// Clear structures used to communicate with fortran |
// // Clear structures used to communicate with fortran |
515 |
// |
// // |
516 |
event->ClearStructs(); |
// event->ClearStructs(); |
517 |
|
// ELENA: moved @ beginning |
518 |
// |
// |
519 |
// |
// |
520 |
// |
// |
521 |
if ( debug ) this->Print(); |
if ( debug ) this->Print(); |
522 |
if ( debug ) printf(" exit \n"); |
if ( debug ) printf(" exit \n"); |
523 |
// |
// |
524 |
}; |
} |
525 |
|
|
526 |
|
// |
527 |
|
// Method to add a calorimeter track, evaluated around a tracker track defined by a status vector. |
528 |
|
// (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection ) |
529 |
|
// |
530 |
|
// |
531 |
|
CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){ |
532 |
|
|
533 |
|
int ntrkentry = pcalo->ntrk(); |
534 |
|
// |
535 |
|
for (Int_t nt=0; nt < ntrkentry; nt++){ |
536 |
|
if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){ |
537 |
|
cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"<<endl; |
538 |
|
cout << " --> trktag = "<<trktag<<" already defined "<<endl; |
539 |
|
return NULL; |
540 |
|
} |
541 |
|
} |
542 |
|
// |
543 |
|
event->clevel1->good2 = 1; //is a trk track |
544 |
|
event->clevel1->trkchi2 = 0; |
545 |
|
event->clevel1->hzn = 0; |
546 |
|
// |
547 |
|
// Copy the alpha vector in the input structure |
548 |
|
// |
549 |
|
for (Int_t e = 0; e < 5 ; e++){ |
550 |
|
event->clevel1->al_p[e][0] = al[e]; |
551 |
|
}; |
552 |
|
// |
553 |
|
// Get tracker related variables for this track |
554 |
|
// |
555 |
|
if ( debug ) printf("track %i Call GetTrkVar() \n",trktag); |
556 |
|
event->GetTrkVar(); |
557 |
|
if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l); |
558 |
|
// |
559 |
|
// Save tracker track sequence number |
560 |
|
// |
561 |
|
event->trkseqno = trktag; |
562 |
|
// |
563 |
|
// Copy values in the class ca from the structure clevel2 |
564 |
|
// |
565 |
|
if ( debug ) printf("track %i Call FillTrkVar() \n",trktag); |
566 |
|
event->FillTrkVar(pcalo,ntrkentry); |
567 |
|
|
568 |
|
return pcalo->GetCaloTrkVar(ntrkentry); |
569 |
|
|
570 |
|
|
571 |
|
};//ELENA |