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 |
|
usepl18x = false; |
40 |
simulation = false; |
simulation = false; |
41 |
|
withtrk = true; |
42 |
|
rigdefault = 50.; |
43 |
|
nox = false; |
44 |
|
noy = false; |
45 |
|
forcecalo = false; |
46 |
|
forcefitmode = -1; |
47 |
|
memset(mask,0,2*22*sizeof(Int_t)); |
48 |
// |
// |
49 |
Clear(); |
Clear(); |
50 |
// |
// |
71 |
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()); |
72 |
trk->LoadField(q4->PATH+q4->NAME); |
trk->LoadField(q4->PATH+q4->NAME); |
73 |
// |
// |
74 |
}; |
} |
75 |
|
|
76 |
|
CaloTrkVar* CaloPreSampler::GetCaloTrack(Int_t t){ |
77 |
|
this->Process(); |
78 |
|
if ( t < 0 ) return pcalo->GetCaloStoredTrack(t); |
79 |
|
if ( L2->GetTrack(t) ){ |
80 |
|
return pcalo->GetCaloStoredTrack(L2->GetTrack(t)->GetTrkTrack()->GetSeqNo()); |
81 |
|
}; |
82 |
|
return NULL; |
83 |
|
} |
84 |
|
|
85 |
|
void CaloPreSampler::SetNoWpreSampler(Int_t n){ |
86 |
|
if ( NC+n < 23 ){ |
87 |
|
N = n; |
88 |
|
} else { |
89 |
|
printf(" ERROR! Calorimeter is made of 22 W planes\n"); |
90 |
|
printf(" you are giving N presampler = %i and N calo = %i \n",n,NC); |
91 |
|
printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n"); |
92 |
|
NC = 18; |
93 |
|
N = 4; |
94 |
|
}; |
95 |
|
} |
96 |
|
|
97 |
|
void CaloPreSampler::SetNoWcalo(Int_t n){ |
98 |
|
if ( N+n < 23 ){ |
99 |
|
NC = n; |
100 |
|
} else { |
101 |
|
printf(" ERROR! Calorimeter is made of 22 W planes\n"); |
102 |
|
printf(" you are giving N W presampler = %i and N W calo = %i \n",N,n); |
103 |
|
printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n"); |
104 |
|
NC = 18; |
105 |
|
N = 4; |
106 |
|
}; |
107 |
|
} |
108 |
|
|
109 |
|
void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){ |
110 |
|
this->SetNoWcalo(0); |
111 |
|
this->SetNoWpreSampler(0); |
112 |
|
if ( NoWpreSampler < NoWcalo ){ |
113 |
|
this->SetNoWpreSampler(NoWpreSampler); |
114 |
|
this->SetNoWcalo(NoWcalo); |
115 |
|
} else { |
116 |
|
this->SetNoWcalo(NoWcalo); |
117 |
|
this->SetNoWpreSampler(NoWpreSampler); |
118 |
|
}; |
119 |
|
} |
120 |
|
|
121 |
void CaloPreSampler::Clear(){ |
void CaloPreSampler::Clear(){ |
122 |
// |
// |
123 |
pcalo->Clear(); |
pcalo->Clear(); |
124 |
// |
// |
125 |
}; |
} |
126 |
|
|
127 |
void CaloPreSampler::Print(){ |
void CaloPreSampler::Print(){ |
128 |
// |
// |
144 |
}; |
}; |
145 |
printf("========================================================================\n"); |
printf("========================================================================\n"); |
146 |
// |
// |
147 |
}; |
} |
148 |
|
|
149 |
void CaloPreSampler::Delete(){ |
void CaloPreSampler::Delete(){ |
150 |
Clear(); |
Clear(); |
151 |
delete pcalo; |
delete pcalo; |
152 |
//delete this; |
//delete this; |
153 |
}; |
} |
154 |
|
|
155 |
|
|
156 |
void CaloPreSampler::Process(){ |
void CaloPreSampler::Process(){ |
161 |
return; |
return; |
162 |
}; |
}; |
163 |
// |
// |
164 |
|
// Clear structures used to communicate with fortran |
165 |
|
// |
166 |
|
event->ClearStructs();//ELENA |
167 |
|
if ( forcefitmode > 0 ){ |
168 |
|
if ( forcefitmode != 1000 && forcefitmode != 1001 && forcefitmode != 1002 ){ |
169 |
|
printf(" ERROR! forcefitmode=%i \n Use forcefitmode = 1000 for fit mode 0, 1001 fit mode 1, 1002 fit mode 3\n",forcefitmode); |
170 |
|
forcefitmode = -1; |
171 |
|
} else { |
172 |
|
event->clevel2->fmode[0] = forcefitmode; |
173 |
|
event->clevel2->fmode[1] = forcefitmode; |
174 |
|
}; |
175 |
|
}; |
176 |
|
// |
177 |
Bool_t newentry = false; |
Bool_t newentry = false; |
178 |
// |
// |
179 |
if ( L2->IsORB() ){ |
if ( L2->IsORB() ){ |
180 |
|
if ( debug ) printf(" I am here, we have orbital infos \n"); |
181 |
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 ){ |
182 |
newentry = true; |
newentry = true; |
183 |
OBT = L2->GetOrbitalInfo()->OBT; |
OBT = L2->GetOrbitalInfo()->OBT; |
199 |
Int_t S11 = 0; |
Int_t S11 = 0; |
200 |
Float_t tmptrigty = -1.; |
Float_t tmptrigty = -1.; |
201 |
Bool_t trackanyway = true; |
Bool_t trackanyway = true; |
202 |
Float_t rigdefault = 50.; |
// Float_t rigdefault = 50.; |
203 |
Bool_t hZn = true; |
Bool_t hZn = true; |
204 |
Bool_t withtrk = true; |
// Bool_t withtrk = true; |
205 |
Bool_t st = true; |
Bool_t st = true; |
206 |
Int_t ntrkentry = 0; |
Int_t ntrkentry = 0; |
207 |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
221 |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true; |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true; |
222 |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true; |
if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true; |
223 |
}; |
}; |
224 |
|
if ( !withtrk ) m3 = true; |
225 |
// |
// |
226 |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
227 |
// |
// |
236 |
// |
// |
237 |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
238 |
// |
// |
239 |
|
if ( !usepl18x && view==0 && plane==18 ) mip = 0.; |
240 |
|
// |
241 |
|
// Mask x or y view if nox and/or noy are true (default false) |
242 |
|
// |
243 |
|
if ( mask[view][plane] ) mip = 0.; |
244 |
|
if ( nox && view == 0 ) mip = 0.; |
245 |
|
if ( noy && view == 1 ) mip = 0.; |
246 |
|
// |
247 |
|
if ( emulate18 && view == 0 && plane == 18 ) mip = 0.; |
248 |
|
// |
249 |
// 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 |
250 |
// included so plane < (22 - 2) |
// included so plane < (22 - 2) |
251 |
// |
// |
252 |
if ( sel ){ |
if ( sel ){ |
253 |
if ( plane < (22 - N) ){ |
if ( plane < (22 - N) ){ |
254 |
// |
// |
255 |
if ( emulate18 && plane == (18 - N) ) mip = 0.; |
if ( emulate18 && plane == (18 - N) && view == 0 ) mip = 0.; |
256 |
|
if ( plane >= NC ) mip = 0.; |
257 |
event->clevel1->estrip[strip][plane][view] = mip; |
event->clevel1->estrip[strip][plane][view] = mip; |
258 |
// |
// |
259 |
}; |
}; |
264 |
if ( cont ){ |
if ( cont ){ |
265 |
if ( plane >= N ){ |
if ( plane >= N ){ |
266 |
// |
// |
267 |
if ( emulate18 && plane == (18 + N) ) mip = 0.; |
if ( emulate18 && plane == (18 + N) && view == 0 ) mip = 0.; |
268 |
|
if ( (plane-N) >= NC ) mip = 0.; |
269 |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
270 |
// |
// |
271 |
}; |
}; |
309 |
// |
// |
310 |
// use only N W planes |
// use only N W planes |
311 |
// |
// |
312 |
event->clevel1->npla = 22-N; |
// event->clevel1->npla = 22-N; |
313 |
|
event->clevel1->npla = NC; |
314 |
// |
// |
315 |
S3 = 0; |
S3 = 0; |
316 |
S2 = 0; |
S2 = 0; |
330 |
// |
// |
331 |
event->clevel1->good2 = 1; |
event->clevel1->good2 = 1; |
332 |
// |
// |
333 |
|
// copy variables calculated during calibration process which is skipped here... |
334 |
|
// |
335 |
|
event->clevel2->good = L2->GetCaloLevel2()->good; |
336 |
|
memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); |
337 |
|
memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); |
338 |
|
memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); |
339 |
|
event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; |
340 |
|
// |
341 |
// Calculate variables common to all tracks (qtot, nstrip, etc.) |
// Calculate variables common to all tracks (qtot, nstrip, etc.) |
342 |
// |
// |
343 |
if ( debug ) printf("1 Call GetCommonVar() \n"); |
if ( debug ) printf("1 Call GetCommonVar() \n"); |
401 |
// 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 |
402 |
// |
// |
403 |
// 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. ){ |
404 |
if ( trackanyway && m3 ){ |
if ( (trackanyway && m3) || forcecalo ){ |
405 |
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"); |
406 |
// |
// |
407 |
// Disable "track mode" in the fortran routine |
// Disable "track mode" in the fortran routine |
533 |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
534 |
}; |
}; |
535 |
}; |
}; |
536 |
// |
// // |
537 |
// Clear structures used to communicate with fortran |
// // Clear structures used to communicate with fortran |
538 |
// |
// // |
539 |
event->ClearStructs(); |
// event->ClearStructs(); |
540 |
|
// ELENA: moved @ beginning |
541 |
// |
// |
542 |
// |
// |
543 |
// |
// |
544 |
if ( debug ) this->Print(); |
if ( debug ) this->Print(); |
545 |
if ( debug ) printf(" exit \n"); |
if ( debug ) printf(" exit \n"); |
546 |
// |
// |
547 |
}; |
} |
548 |
|
|
549 |
|
// |
550 |
|
// Method to add a calorimeter track, evaluated around a tracker track defined by a status vector. |
551 |
|
// (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection ) |
552 |
|
// |
553 |
|
// |
554 |
|
CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){ |
555 |
|
|
556 |
|
int ntrkentry = pcalo->ntrk(); |
557 |
|
// |
558 |
|
for (Int_t nt=0; nt < ntrkentry; nt++){ |
559 |
|
if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){ |
560 |
|
cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"<<endl; |
561 |
|
cout << " --> trktag = "<<trktag<<" already defined "<<endl; |
562 |
|
return NULL; |
563 |
|
} |
564 |
|
} |
565 |
|
// |
566 |
|
event->clevel1->good2 = 1; //is a trk track |
567 |
|
event->clevel1->trkchi2 = 0; |
568 |
|
event->clevel1->hzn = 0; |
569 |
|
// |
570 |
|
// Copy the alpha vector in the input structure |
571 |
|
// |
572 |
|
for (Int_t e = 0; e < 5 ; e++){ |
573 |
|
event->clevel1->al_p[e][0] = al[e]; |
574 |
|
}; |
575 |
|
// |
576 |
|
// Get tracker related variables for this track |
577 |
|
// |
578 |
|
if ( debug ) printf("track %i Call GetTrkVar() \n",trktag); |
579 |
|
event->GetTrkVar(); |
580 |
|
if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l); |
581 |
|
// |
582 |
|
// Save tracker track sequence number |
583 |
|
// |
584 |
|
event->trkseqno = trktag; |
585 |
|
// |
586 |
|
// Copy values in the class ca from the structure clevel2 |
587 |
|
// |
588 |
|
if ( debug ) printf("track %i Call FillTrkVar() \n",trktag); |
589 |
|
event->FillTrkVar(pcalo,ntrkentry); |
590 |
|
|
591 |
|
return pcalo->GetCaloTrkVar(ntrkentry); |
592 |
|
|
593 |
|
|
594 |
|
};//ELENA |