14 |
Clear(); |
Clear(); |
15 |
} |
} |
16 |
|
|
17 |
|
void CaloPreSampler::SetCaloLevel2Pointer(CaloLevel2 *cl2p){ |
18 |
|
if ( pcalo ) delete pcalo; |
19 |
|
pcalo = cl2p; |
20 |
|
} |
21 |
|
|
22 |
CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){ |
CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){ |
23 |
// |
// |
24 |
L2 = l2p; |
L2 = l2p; |
41 |
sel = true; |
sel = true; |
42 |
cont = false; |
cont = false; |
43 |
emulate18 = true; |
emulate18 = true; |
44 |
|
usepl18x = false; |
45 |
simulation = false; |
simulation = false; |
46 |
withtrk = true; |
withtrk = true; |
47 |
rigdefault = 50.; |
rigdefault = 50.; |
48 |
nox = false; |
nox = false; |
49 |
noy = false; |
noy = false; |
50 |
|
forcecalo = false; |
51 |
|
forcefitmode = -1; |
52 |
|
memset(mask,0,2*22*sizeof(Int_t)); |
53 |
// |
// |
54 |
Clear(); |
Clear(); |
55 |
// |
// |
78 |
// |
// |
79 |
} |
} |
80 |
|
|
81 |
|
CaloTrkVar* CaloPreSampler::GetCaloTrack(Int_t t){ |
82 |
|
this->Process(); |
83 |
|
if ( t < 0 ) return pcalo->GetCaloStoredTrack(t); |
84 |
|
if ( L2->GetTrack(t) ){ |
85 |
|
return pcalo->GetCaloStoredTrack(L2->GetTrack(t)->GetTrkTrack()->GetSeqNo()); |
86 |
|
}; |
87 |
|
return NULL; |
88 |
|
} |
89 |
|
|
90 |
void CaloPreSampler::SetNoWpreSampler(Int_t n){ |
void CaloPreSampler::SetNoWpreSampler(Int_t n){ |
91 |
if ( NC+n < 23 ){ |
if ( NC+n < 23 ){ |
92 |
N = n; |
N = n; |
111 |
}; |
}; |
112 |
} |
} |
113 |
|
|
114 |
|
void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){ |
115 |
|
this->SetNoWcalo(0); |
116 |
|
this->SetNoWpreSampler(0); |
117 |
|
if ( NoWpreSampler < NoWcalo ){ |
118 |
|
this->SetNoWpreSampler(NoWpreSampler); |
119 |
|
this->SetNoWcalo(NoWcalo); |
120 |
|
} else { |
121 |
|
this->SetNoWcalo(NoWcalo); |
122 |
|
this->SetNoWpreSampler(NoWpreSampler); |
123 |
|
}; |
124 |
|
} |
125 |
|
|
126 |
void CaloPreSampler::Clear(){ |
void CaloPreSampler::Clear(){ |
127 |
// |
// |
128 |
pcalo->Clear(); |
pcalo->Clear(); |
166 |
return; |
return; |
167 |
}; |
}; |
168 |
// |
// |
169 |
|
// Clear structures used to communicate with fortran |
170 |
|
// |
171 |
|
event->ClearStructs();//ELENA |
172 |
|
if ( forcefitmode > 0 ){ |
173 |
|
if ( forcefitmode != 1000 && forcefitmode != 1001 && forcefitmode != 1002 ){ |
174 |
|
printf(" ERROR! forcefitmode=%i \n Use forcefitmode = 1000 for fit mode 0, 1001 fit mode 1, 1002 fit mode 3\n",forcefitmode); |
175 |
|
forcefitmode = -1; |
176 |
|
} else { |
177 |
|
event->clevel2->fmode[0] = forcefitmode; |
178 |
|
event->clevel2->fmode[1] = forcefitmode; |
179 |
|
}; |
180 |
|
}; |
181 |
|
// |
182 |
Bool_t newentry = false; |
Bool_t newentry = false; |
183 |
// |
// |
184 |
if ( L2->IsORB() ){ |
if ( L2->IsORB() ){ |
185 |
|
if ( debug ) printf(" I am here, we have orbital infos \n"); |
186 |
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 ){ |
187 |
newentry = true; |
newentry = true; |
188 |
OBT = L2->GetOrbitalInfo()->OBT; |
OBT = L2->GetOrbitalInfo()->OBT; |
210 |
Bool_t st = true; |
Bool_t st = true; |
211 |
Int_t ntrkentry = 0; |
Int_t ntrkentry = 0; |
212 |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
TrkLevel2 *trk = L2->GetTrkLevel2(); |
213 |
Bool_t filled = false; |
// Bool_t filled = false; |
214 |
// |
// |
215 |
if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); |
if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); |
216 |
// |
// |
|
this->Clear(); |
|
|
// |
|
217 |
// find out if we have trkseqno = -1, -2 or -3 |
// find out if we have trkseqno = -1, -2 or -3 |
218 |
// |
// |
219 |
Bool_t m1 = false; |
Bool_t m1 = false; |
226 |
}; |
}; |
227 |
if ( !withtrk ) m3 = true; |
if ( !withtrk ) m3 = true; |
228 |
// |
// |
229 |
|
// copy variables calculated during calibration process which is skipped here... this has been moved before this->Clear() for reprocessing purpose |
230 |
|
// |
231 |
|
event->clevel2->good = L2->GetCaloLevel2()->good; |
232 |
|
memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); |
233 |
|
memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); |
234 |
|
memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); |
235 |
|
event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; |
236 |
|
// |
237 |
|
// |
238 |
|
this->Clear(); // moved after all calls to L2->GetCaloLevel2() since pcalo could be the same as L2->GetCaloLevel2() !!! |
239 |
|
// |
240 |
|
// |
241 |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); |
242 |
// |
// |
243 |
// Fill the estrip matrix |
// Fill the estrip matrix |
251 |
// |
// |
252 |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); |
253 |
// |
// |
254 |
|
if ( !usepl18x && view==0 && plane==18 ) mip = 0.; |
255 |
|
// |
256 |
// Mask x or y view if nox and/or noy are true (default false) |
// Mask x or y view if nox and/or noy are true (default false) |
257 |
// |
// |
258 |
|
if ( mask[view][plane] ) mip = 0.; |
259 |
if ( nox && view == 0 ) mip = 0.; |
if ( nox && view == 0 ) mip = 0.; |
260 |
if ( noy && view == 1 ) mip = 0.; |
if ( noy && view == 1 ) mip = 0.; |
261 |
// |
// |
262 |
|
if ( emulate18 && view == 0 && plane == 18 ) mip = 0.; |
263 |
|
// |
264 |
// 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 |
265 |
// included so plane < (22 - 2) |
// included so plane < (22 - 2) |
266 |
// |
// |
267 |
if ( sel ){ |
if ( sel ){ |
268 |
if ( plane < (22 - N) ){ |
if ( plane < (22 - N) ){ |
269 |
// |
// |
270 |
if ( emulate18 && plane == (18 - N) ) mip = 0.; |
if ( emulate18 && plane == (18 - N) && view == 0 ) mip = 0.; |
271 |
if ( plane >= NC ) mip = 0.; |
if ( plane >= NC ) mip = 0.; |
272 |
event->clevel1->estrip[strip][plane][view] = mip; |
event->clevel1->estrip[strip][plane][view] = mip; |
273 |
// |
// |
279 |
if ( cont ){ |
if ( cont ){ |
280 |
if ( plane >= N ){ |
if ( plane >= N ){ |
281 |
// |
// |
282 |
if ( emulate18 && plane == (18 + N) ) mip = 0.; |
if ( emulate18 && plane == (18 + N) && view == 0 ) mip = 0.; |
283 |
if ( (plane-N) >= NC ) mip = 0.; |
if ( (plane-N) >= NC ) mip = 0.; |
284 |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
event->clevel1->estrip[strip][(plane-N)][view] = mip; |
285 |
// |
// |
345 |
// |
// |
346 |
event->clevel1->good2 = 1; |
event->clevel1->good2 = 1; |
347 |
// |
// |
348 |
// copy variables calculated during calibration process which is skipped here... |
// copy variables calculated during calibration process which is skipped here... this has to be moved before this->Clear() for reprocessing purpose |
349 |
// |
// |
350 |
event->clevel2->good = L2->GetCaloLevel2()->good; |
// event->clevel2->good = L2->GetCaloLevel2()->good; |
351 |
memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); |
// memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); |
352 |
memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); |
// memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); |
353 |
memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); |
// memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); |
354 |
event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; |
// event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; |
355 |
// |
// |
356 |
// Calculate variables common to all tracks (qtot, nstrip, etc.) |
// Calculate variables common to all tracks (qtot, nstrip, etc.) |
357 |
// |
// |
367 |
// |
// |
368 |
ntrkentry = 0; |
ntrkentry = 0; |
369 |
// |
// |
370 |
filled = false; |
// filled = false; |
371 |
// |
// |
372 |
// Run over tracks (tracker or calorimeter ) |
// Run over tracks (tracker or calorimeter ) |
373 |
// |
// |
404 |
|
|
405 |
|
|
406 |
ntrkentry++; |
ntrkentry++; |
407 |
filled = true; |
// filled = true; |
408 |
// |
// |
409 |
}; // loop on all the tracks |
}; // loop on all the tracks |
410 |
}; |
}; |
416 |
// 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 |
417 |
// |
// |
418 |
// 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. ){ |
419 |
if ( trackanyway && m3 ){ |
if ( (trackanyway && m3) || forcecalo ){ |
420 |
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"); |
421 |
// |
// |
422 |
// Disable "track mode" in the fortran routine |
// Disable "track mode" in the fortran routine |
449 |
if ( debug ) printf("-3 a Call FillTrkVar() \n"); |
if ( debug ) printf("-3 a Call FillTrkVar() \n"); |
450 |
event->FillTrkVar(pcalo,ntrkentry); |
event->FillTrkVar(pcalo,ntrkentry); |
451 |
ntrkentry++; |
ntrkentry++; |
452 |
filled = true; |
// filled = true; |
453 |
// |
// |
454 |
} else { |
} else { |
455 |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
496 |
if ( debug ) printf("-2 a Call FillTrkVar() \n"); |
if ( debug ) printf("-2 a Call FillTrkVar() \n"); |
497 |
event->FillTrkVar(pcalo,ntrkentry); |
event->FillTrkVar(pcalo,ntrkentry); |
498 |
ntrkentry++; |
ntrkentry++; |
499 |
filled = true; |
// filled = true; |
500 |
// |
// |
501 |
} else { |
} else { |
502 |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
542 |
if ( debug ) printf("-1 a Call FillTrkVar() \n"); |
if ( debug ) printf("-1 a Call FillTrkVar() \n"); |
543 |
event->FillTrkVar(pcalo,ntrkentry); |
event->FillTrkVar(pcalo,ntrkentry); |
544 |
ntrkentry++; |
ntrkentry++; |
545 |
filled = true; |
// filled = true; |
546 |
// |
// |
547 |
} else { |
} else { |
548 |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
if ( debug ) printf(" Selftrigger: problems with event \n"); |
549 |
}; |
}; |
550 |
}; |
}; |
551 |
// |
// // |
552 |
// Clear structures used to communicate with fortran |
// // Clear structures used to communicate with fortran |
553 |
// |
// // |
554 |
event->ClearStructs(); |
// event->ClearStructs(); |
555 |
|
// ELENA: moved @ beginning |
556 |
// |
// |
557 |
// |
// |
558 |
// |
// |
560 |
if ( debug ) printf(" exit \n"); |
if ( debug ) printf(" exit \n"); |
561 |
// |
// |
562 |
} |
} |
563 |
|
|
564 |
|
// |
565 |
|
// Method to add a calorimeter track, evaluated around a tracker track defined by a status vector. |
566 |
|
// (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection ) |
567 |
|
// |
568 |
|
// |
569 |
|
CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){ |
570 |
|
|
571 |
|
int ntrkentry = pcalo->ntrk(); |
572 |
|
// |
573 |
|
for (Int_t nt=0; nt < ntrkentry; nt++){ |
574 |
|
if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){ |
575 |
|
cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"<<endl; |
576 |
|
cout << " --> trktag = "<<trktag<<" already defined "<<endl; |
577 |
|
return NULL; |
578 |
|
} |
579 |
|
} |
580 |
|
// |
581 |
|
event->clevel1->good2 = 1; //is a trk track |
582 |
|
event->clevel1->trkchi2 = 0; |
583 |
|
event->clevel1->hzn = 0; |
584 |
|
// |
585 |
|
// Copy the alpha vector in the input structure |
586 |
|
// |
587 |
|
for (Int_t e = 0; e < 5 ; e++){ |
588 |
|
event->clevel1->al_p[e][0] = al[e]; |
589 |
|
}; |
590 |
|
// |
591 |
|
// Get tracker related variables for this track |
592 |
|
// |
593 |
|
if ( debug ) printf("track %i Call GetTrkVar() \n",trktag); |
594 |
|
event->GetTrkVar(); |
595 |
|
if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l); |
596 |
|
// |
597 |
|
// Save tracker track sequence number |
598 |
|
// |
599 |
|
event->trkseqno = trktag; |
600 |
|
// |
601 |
|
// Copy values in the class ca from the structure clevel2 |
602 |
|
// |
603 |
|
if ( debug ) printf("track %i Call FillTrkVar() \n",trktag); |
604 |
|
event->FillTrkVar(pcalo,ntrkentry); |
605 |
|
|
606 |
|
return pcalo->GetCaloTrkVar(ntrkentry); |
607 |
|
|
608 |
|
|
609 |
|
};//ELENA |