67 |
memset(obadmask, 0, 2*22*96*sizeof(Int_t)); |
memset(obadmask, 0, 2*22*96*sizeof(Int_t)); |
68 |
memset(obadpulsemask, 0, 2*22*6*sizeof(Int_t)); |
memset(obadpulsemask, 0, 2*22*6*sizeof(Int_t)); |
69 |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
70 |
|
memset(ctsicor, 0, 2*22*9*sizeof(Float_t)); |
71 |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
72 |
calopar1 = true; |
calopar1 = true; |
73 |
calopar2 = true; |
calopar2 = true; |
74 |
calopar3 = true; |
calopar3 = true; |
75 |
|
calopar4 = true; |
76 |
|
calopar5 = true; |
77 |
crosst = true; |
crosst = true; |
78 |
ftcalopar1 = 0; |
ftcalopar1 = 0; |
79 |
ttcalopar1 = 0; |
ttcalopar1 = 0; |
81 |
ttcalopar2 = 0; |
ttcalopar2 = 0; |
82 |
ftcalopar3 = 0; |
ftcalopar3 = 0; |
83 |
ttcalopar3 = 0; |
ttcalopar3 = 0; |
84 |
|
ftcalopar4 = 0; |
85 |
|
ttcalopar4 = 0; |
86 |
|
ftcalopar5 = 0; |
87 |
|
ttcalopar5 = 0; |
88 |
} |
} |
89 |
|
|
90 |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
void CaloLevel0::SetCrossTalk(Bool_t ct){ |
95 |
ctground = ct; |
ctground = ct; |
96 |
} |
} |
97 |
|
|
98 |
|
void CaloLevel0::SetCrossTalkType(Int_t ct){ |
99 |
|
if ( ct == 0 ) ctground = true; |
100 |
|
if ( ct == 1 ){ |
101 |
|
ctground = false; |
102 |
|
noselfct = false; |
103 |
|
}; |
104 |
|
if ( ct == 2 ){ |
105 |
|
ctground = false; |
106 |
|
noselfct = true; |
107 |
|
}; |
108 |
|
} |
109 |
|
|
110 |
void CaloLevel0::SetVerbose(Bool_t ct){ |
void CaloLevel0::SetVerbose(Bool_t ct){ |
111 |
verbose = ct; |
verbose = ct; |
112 |
} |
} |
114 |
/** |
/** |
115 |
* Initialize CaloLevel0 object |
* Initialize CaloLevel0 object |
116 |
**/ |
**/ |
117 |
|
void CaloLevel0::ProcessingInit(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
118 |
|
if ( !dbc->IsConnected() ) throw -116; |
119 |
|
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
120 |
|
} |
121 |
|
|
122 |
|
/** |
123 |
|
* Initialize CaloLevel0 object |
124 |
|
**/ |
125 |
void CaloLevel0::ProcessingInit(GL_TABLES *glt, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
void CaloLevel0::ProcessingInit(GL_TABLES *glt, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
126 |
// |
// |
127 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
129 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
130 |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
131 |
if ( !dbc->IsConnected() ) throw -116; |
if ( !dbc->IsConnected() ) throw -116; |
132 |
|
this->InitDo(dbc,hs,sgnl,l0tree,isdeb,isverb); |
133 |
|
dbc->Close(); |
134 |
|
delete dbc; |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
void CaloLevel0::InitDo(TSQLServer *dbc, UInt_t hs, Int_t &sgnl, TTree *l0tree, Bool_t isdeb, Bool_t isverb){ |
139 |
stringstream myquery; |
stringstream myquery; |
140 |
myquery.str(""); |
myquery.str(""); |
141 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
216 |
// |
// |
217 |
delete glcalo; |
delete glcalo; |
218 |
delete glroot; |
delete glroot; |
|
dbc->Close(); |
|
|
delete dbc; |
|
219 |
// |
// |
220 |
return; |
return; |
221 |
// |
// |
232 |
return(sgnl); |
return(sgnl); |
233 |
} |
} |
234 |
|
|
235 |
|
Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
236 |
|
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
237 |
|
return(sig); |
238 |
|
} |
239 |
|
|
240 |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
Int_t CaloLevel0::ChkParam(GL_TABLES *glt, UInt_t runheader, Bool_t mechal){ |
241 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
242 |
const TString user = glt->CGetUser(); |
const TString user = glt->CGetUser(); |
248 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
249 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
250 |
// |
// |
251 |
|
Int_t sig = this->ChkParamDo(dbc,runheader,mechal); |
252 |
|
dbc->Close(); |
253 |
|
delete dbc; |
254 |
|
return(sig); |
255 |
|
} |
256 |
|
|
257 |
|
Int_t CaloLevel0::ChkParamDo(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
258 |
|
// |
259 |
stringstream calfile; |
stringstream calfile; |
260 |
stringstream bmfile; |
stringstream bmfile; |
261 |
stringstream aligfile; |
stringstream aligfile; |
266 |
// |
// |
267 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
268 |
// |
// |
|
// |
|
|
// |
|
269 |
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
270 |
// |
// |
271 |
|
if ( calopar1 ){ |
272 |
|
// |
273 |
|
// determine where I can find calorimeter ADC to MIP conversion file |
274 |
|
// |
275 |
|
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
276 |
|
// |
277 |
|
error = 0; |
278 |
|
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
279 |
|
if ( error < 0 ) return(error); |
280 |
|
// |
281 |
|
calfile.str(""); |
282 |
|
calfile << glparam->PATH.Data() << "/"; |
283 |
|
calfile << glparam->NAME.Data(); |
284 |
|
// |
285 |
|
if ( verbose ) printf("\n Using ADC to MIP conversion file: \n %s \n",calfile.str().c_str()); |
286 |
|
f = fopen(calfile.str().c_str(),"rb"); |
287 |
|
if ( !f ){ |
288 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no ADC to MIP file!\n"); |
289 |
|
return(-105); |
290 |
|
}; |
291 |
|
// |
292 |
|
for (Int_t m = 0; m < 2 ; m++ ){ |
293 |
|
for (Int_t k = 0; k < 22; k++ ){ |
294 |
|
for (Int_t l = 0; l < 96; l++ ){ |
295 |
|
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
296 |
|
if ( debug ) printf(" %f \n",mip[m][k][l]); |
297 |
|
}; |
298 |
|
}; |
299 |
|
}; |
300 |
|
fclose(f); |
301 |
|
}; |
302 |
|
// |
303 |
calopar1 = false; |
calopar1 = false; |
304 |
// |
// |
305 |
// determine where I can find calorimeter ADC to MIP conversion file |
// flight extra corrections: |
306 |
// |
// |
307 |
if ( verbose ) printf(" Querying DB for calorimeter parameters files...\n"); |
if ( verbose ) printf(" Querying DB for calorimeter flight ADC to MIP files...\n"); |
308 |
// |
// |
309 |
error = 0; |
error = 0; |
310 |
error = glparam->Query_GL_PARAM(runheader,101,dbc); |
error = glparam->Query_GL_PARAM(runheader,110,dbc); |
311 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
312 |
// |
// |
313 |
calfile.str(""); |
calfile.str(""); |
316 |
ftcalopar1 = glparam->FROM_TIME; |
ftcalopar1 = glparam->FROM_TIME; |
317 |
ttcalopar1 = glparam->TO_TIME; |
ttcalopar1 = glparam->TO_TIME; |
318 |
// |
// |
319 |
if ( verbose ) printf("\n Using ADC to MIP conversion file: \n %s \n",calfile.str().c_str()); |
if ( verbose ) printf("\n Using ADC to MIP special conversion file: \n %s \n",calfile.str().c_str()); |
320 |
f = fopen(calfile.str().c_str(),"rb"); |
ifstream spfile; |
321 |
if ( !f ){ |
spfile.open(calfile.str().c_str()); |
322 |
if ( verbose ) printf(" CALORIMETER - ERROR: no ADC to MIP file!\n"); |
if ( !spfile ){ |
323 |
return(-105); |
if ( verbose ) printf(" CALORIMETER - ERROR: no special calibration file!\n"); |
324 |
|
return(-123); |
325 |
}; |
}; |
326 |
|
// |
327 |
|
Int_t vview = 0; |
328 |
|
Int_t vplane = 0; |
329 |
|
Int_t vstrip = 0; |
330 |
|
Float_t vval = 0.; |
331 |
|
while ( spfile >> vview && spfile >> vplane && spfile >> vstrip && spfile >> vval){ |
332 |
|
if ( debug ) printf(" Setting ADC to MIP conversion factor: view %i plane %i strip %i mip %f \n",vview,vplane,vstrip,vval); |
333 |
|
mip[vview][vplane][vstrip] = vval; |
334 |
|
}; |
335 |
// |
// |
|
for (Int_t m = 0; m < 2 ; m++ ){ |
|
|
for (Int_t k = 0; k < 22; k++ ){ |
|
|
for (Int_t l = 0; l < 96; l++ ){ |
|
|
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
|
|
if ( debug ) printf(" %f \n",mip[m][k][l]); |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
fclose(f); |
|
336 |
}; |
}; |
337 |
// |
// |
338 |
|
// |
339 |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
340 |
|
// |
341 |
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
342 |
calopar2 = false; |
calopar2 = false; |
343 |
// |
// |
444 |
badfile.close(); |
badfile.close(); |
445 |
}; |
}; |
446 |
// |
// |
447 |
|
// calopar4 |
448 |
|
// |
449 |
|
if ( calopar4 || ( ttcalopar4 != 0 && ttcalopar4 < runheader ) ){ |
450 |
|
// |
451 |
|
if ( debug ) printf(" calopar4 %i ftcalopar4 %u ttcalopar4 %u runheader %u \n",calopar4,ftcalopar4,ttcalopar4,runheader); |
452 |
|
// |
453 |
|
calopar4 = false; |
454 |
|
// |
455 |
|
// flight extra corrections: |
456 |
|
// |
457 |
|
if ( verbose ) printf(" Querying DB for calorimeter max rms file...\n"); |
458 |
|
// |
459 |
|
error = 0; |
460 |
|
error = glparam->Query_GL_PARAM(runheader,109,dbc); |
461 |
|
if ( error < 0 ) return(error); |
462 |
|
// |
463 |
|
calfile.str(""); |
464 |
|
calfile << glparam->PATH.Data() << "/"; |
465 |
|
calfile << glparam->NAME.Data(); |
466 |
|
ftcalopar4 = glparam->FROM_TIME; |
467 |
|
ttcalopar4 = glparam->TO_TIME; |
468 |
|
// |
469 |
|
if ( verbose ) printf("\n Using calorimeter max rms file: \n %s \n",calfile.str().c_str()); |
470 |
|
ifstream spfile; |
471 |
|
spfile.open(calfile.str().c_str()); |
472 |
|
if ( !spfile ){ |
473 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no max rms file!\n"); |
474 |
|
return(-124); |
475 |
|
}; |
476 |
|
// |
477 |
|
Int_t vview = 0; |
478 |
|
Int_t vplane = 0; |
479 |
|
Int_t vval = 0; |
480 |
|
for (Int_t l=0; l<2; l++){ |
481 |
|
for (Int_t m=0; m<22; m++){ |
482 |
|
maxrms[l][m] = 26; |
483 |
|
}; |
484 |
|
}; |
485 |
|
while ( spfile >> vview && spfile >> vplane && spfile >> vval){ |
486 |
|
if ( debug ) printf(" Setting view %i plane %i max rms %i \n",vview,vplane,vval); |
487 |
|
maxrms[vview][vplane] = vval; |
488 |
|
}; |
489 |
|
spfile.close(); |
490 |
|
// |
491 |
|
}; |
492 |
|
// |
493 |
|
// calopar5 |
494 |
|
// |
495 |
|
if ( calopar5 || ( ttcalopar5 != 0 && ttcalopar5 < runheader ) ){ |
496 |
|
// |
497 |
|
if ( debug ) printf(" calopar5 %i ftcalopar5 %u ttcalopar5 %u runheader %u \n",calopar5,ftcalopar5,ttcalopar5,runheader); |
498 |
|
// |
499 |
|
calopar5 = false; |
500 |
|
// |
501 |
|
// flight extra corrections: |
502 |
|
// |
503 |
|
if ( verbose ) printf(" Querying DB for calorimeter noise to signal threshold file...\n"); |
504 |
|
// |
505 |
|
error = 0; |
506 |
|
error = glparam->Query_GL_PARAM(runheader,111,dbc); |
507 |
|
if ( error < 0 ) return(error); |
508 |
|
// |
509 |
|
calfile.str(""); |
510 |
|
calfile << glparam->PATH.Data() << "/"; |
511 |
|
calfile << glparam->NAME.Data(); |
512 |
|
ftcalopar5 = glparam->FROM_TIME; |
513 |
|
ttcalopar5 = glparam->TO_TIME; |
514 |
|
// |
515 |
|
if ( verbose ) printf("\n Using calorimeter noise to signal threshold file: \n %s \n",calfile.str().c_str()); |
516 |
|
ifstream spfile; |
517 |
|
spfile.open(calfile.str().c_str()); |
518 |
|
if ( !spfile ){ |
519 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no noise to signal threshold file!\n"); |
520 |
|
return(-125); |
521 |
|
}; |
522 |
|
// |
523 |
|
Int_t vview = 0; |
524 |
|
Int_t vplane = 0; |
525 |
|
Int_t vstrip = 0; |
526 |
|
Float_t vval = 0.; |
527 |
|
for (Int_t l=0; l<2; l++){ |
528 |
|
for (Int_t m=0; m<22; m++){ |
529 |
|
for (Int_t n=0; n<96; n++){ |
530 |
|
memin[l][m][n] = 0.7; |
531 |
|
}; |
532 |
|
}; |
533 |
|
}; |
534 |
|
while ( spfile >> vview && spfile >> vplane && spfile >> vstrip && spfile >> vval){ |
535 |
|
if ( vstrip == -1 ){ |
536 |
|
for (Int_t ll=0; ll<96; ll++){ |
537 |
|
if ( debug ) printf(" Setting view %i plane %i strip %i noise to signal ratio %f \n",vview,vplane,ll,vval); |
538 |
|
memin[vview][vplane][ll] = vval; |
539 |
|
}; |
540 |
|
} else { |
541 |
|
if ( debug ) printf(" Setting view %i plane %i strip %i noise to signal ratio %f \n",vview,vplane,vstrip,vval); |
542 |
|
memin[vview][vplane][vstrip] = vval; |
543 |
|
}; |
544 |
|
}; |
545 |
|
spfile.close(); |
546 |
|
// |
547 |
|
}; |
548 |
|
// |
549 |
|
// |
550 |
delete glparam; |
delete glparam; |
|
dbc->Close(); |
|
|
delete dbc; |
|
551 |
// |
// |
552 |
return(0); |
return(0); |
553 |
} |
} |
554 |
|
|
555 |
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader){ |
Int_t CaloLevel0::CalcCrossTalkCorr(TSQLServer *dbc, UInt_t runheader, Bool_t ctusetable){ |
556 |
|
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,ctusetable); |
557 |
|
return(sig); |
558 |
|
}; |
559 |
|
|
560 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(TSQLServer *dbc, UInt_t runheader){ |
561 |
|
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
562 |
|
return(sig); |
563 |
|
} |
564 |
|
|
565 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader, Bool_t usetable){ |
566 |
|
const TString host = glt->CGetHost(); |
567 |
|
const TString user = glt->CGetUser(); |
568 |
|
const TString psw = glt->CGetPsw(); |
569 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
570 |
|
if ( !dbc->IsConnected() ) throw -116; |
571 |
|
stringstream myquery; |
572 |
|
myquery.str(""); |
573 |
|
myquery << "SET time_zone='+0:00'"; |
574 |
|
dbc->Query(myquery.str().c_str()); |
575 |
// |
// |
576 |
if ( ctground ) return(0); |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,usetable); |
577 |
|
dbc->Close(); |
578 |
|
delete dbc; |
579 |
// |
// |
580 |
|
return(sig); |
581 |
|
// |
582 |
|
}; |
583 |
|
|
584 |
|
Int_t CaloLevel0::CalcCrossTalkCorr(GL_TABLES *glt, UInt_t runheader){ |
585 |
const TString host = glt->CGetHost(); |
const TString host = glt->CGetHost(); |
586 |
const TString user = glt->CGetUser(); |
const TString user = glt->CGetUser(); |
587 |
const TString psw = glt->CGetPsw(); |
const TString psw = glt->CGetPsw(); |
592 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
593 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
594 |
// |
// |
595 |
stringstream bmfile; |
Int_t sig = CalcCrossTalkCorrDo(dbc,runheader,true); |
596 |
|
dbc->Close(); |
597 |
|
delete dbc; |
598 |
|
// |
599 |
|
return(sig); |
600 |
|
// |
601 |
|
} |
602 |
|
|
603 |
|
Int_t CaloLevel0::CalcCrossTalkCorrDo(TSQLServer *dbc, UInt_t runheader, Bool_t usetable){ |
604 |
|
// |
605 |
|
if ( ctground ) return(0); |
606 |
|
// |
607 |
Int_t error = 0; |
Int_t error = 0; |
608 |
ifstream badfile; |
GL_PARAM *glparam = new GL_PARAM(); |
|
GL_PARAM *glparam = new GL_PARAM(); |
|
609 |
// |
// |
610 |
// determine where I can find file with offline bad pulser mask |
// determine where I can find file with offline bad pulser mask |
611 |
// |
// |
612 |
|
stringstream bmfile; |
613 |
error = 0; |
error = 0; |
614 |
error = glparam->Query_GL_PARAM(runheader,105,dbc); |
error = glparam->Query_GL_PARAM(runheader,105,dbc); |
615 |
if ( error < 0 ) return(error); |
if ( error < 0 ) return(error); |
618 |
bmfile << glparam->PATH.Data() << "/"; |
bmfile << glparam->PATH.Data() << "/"; |
619 |
bmfile << glparam->NAME.Data(); |
bmfile << glparam->NAME.Data(); |
620 |
// |
// |
621 |
|
ifstream badfile; |
622 |
if ( verbose ) printf("\n Using bad pulser offline mask file: \n %s \n\n",bmfile.str().c_str()); |
if ( verbose ) printf("\n Using bad pulser offline mask file: \n %s \n\n",bmfile.str().c_str()); |
623 |
badfile.open(bmfile.str().c_str()); |
badfile.open(bmfile.str().c_str()); |
624 |
if ( !badfile ){ |
if ( !badfile ){ |
647 |
}; |
}; |
648 |
}; |
}; |
649 |
// |
// |
|
delete glparam; |
|
650 |
badfile.close(); |
badfile.close(); |
651 |
// |
if ( !usetable ){ |
|
// Let's start with cross-talk correction calculation |
|
|
// |
|
|
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
|
|
Float_t adcp[2][22][96]; |
|
|
Float_t adcpcal[2][22][96]; |
|
|
memset(adcp , 0, 2*22*96*sizeof(Float_t)); |
|
|
memset(adcpcal , 0, 2*22*96*sizeof(Float_t)); |
|
|
// |
|
|
UInt_t pampli = 0; |
|
|
for (Int_t s=0; s<4; s++){ |
|
652 |
// |
// |
653 |
// Save into matrix adcp the values of the highest pulse calibration (pulse amplitude = 2) |
// Let's start with cross-talk correction calculation |
654 |
// |
// |
655 |
pampli = 2; |
GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); |
656 |
error = 0; |
Float_t adcp[2][22][96]; |
657 |
error = glp->Query_GL_CALOPULSE_CALIB(runheader,s,pampli,dbc); |
Float_t adcpcal[2][22][96]; |
658 |
if ( error < 0 ){ |
memset(adcp , 0, 2*22*96*sizeof(Float_t)); |
659 |
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
memset(adcpcal , 0, 2*22*96*sizeof(Float_t)); |
|
return(error); |
|
|
}; |
|
|
// |
|
|
UInt_t idcalib = glp->ID_ROOT_L0; |
|
|
UInt_t fromtime = glp->FROM_TIME; |
|
|
UInt_t calibno = glp->EV_ROOT; |
|
|
// |
|
|
// determine path and name and entry of the calibration file |
|
|
// |
|
|
GL_ROOT *glroot = new GL_ROOT(); |
|
|
if ( verbose ) printf("\n"); |
|
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
|
|
// |
|
|
error = 0; |
|
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
|
|
if ( error < 0 ){ |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
stringstream name; |
|
|
name.str(""); |
|
|
name << glroot->PATH.Data() << "/"; |
|
|
name << glroot->NAME.Data(); |
|
|
// |
|
|
TString fcalname = (TString)name.str().c_str(); |
|
|
ifstream myfile; |
|
|
myfile.open(fcalname.Data()); |
|
|
if ( !myfile ){ |
|
|
return(-107); |
|
|
}; |
|
|
myfile.close(); |
|
|
// |
|
|
TFile *File = new TFile(fcalname.Data()); |
|
|
if ( !File ) return(-108); |
|
|
TTree *tr = (TTree*)File->Get("CalibCalPulse2"); |
|
|
if ( !tr ) return(-119); |
|
660 |
// |
// |
661 |
TBranch *calo = tr->GetBranch("CalibCalPulse2"); |
UInt_t pampli = 0; |
662 |
// |
for (Int_t s=0; s<4; s++){ |
663 |
pamela::CalibCalPulse2Event *ce = 0; |
// |
664 |
tr->SetBranchAddress("CalibCalPulse2", &ce); |
// Save into matrix adcp the values of the highest pulse calibration (pulse amplitude = 2) |
665 |
// |
// |
666 |
Long64_t ncalibs = calo->GetEntries(); |
pampli = 2; |
667 |
|
error = 0; |
668 |
|
error = glp->Query_GL_CALOPULSE_CALIB(runheader,s,pampli,dbc); |
669 |
|
if ( error < 0 ){ |
670 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
671 |
|
return(error); |
672 |
|
}; |
673 |
|
// |
674 |
|
UInt_t idcalib = glp->ID_ROOT_L0; |
675 |
|
UInt_t fromtime = glp->FROM_TIME; |
676 |
|
UInt_t calibno = glp->EV_ROOT; |
677 |
|
// |
678 |
|
// determine path and name and entry of the calibration file |
679 |
|
// |
680 |
|
GL_ROOT *glroot = new GL_ROOT(); |
681 |
|
if ( verbose ) printf("\n"); |
682 |
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
683 |
|
// |
684 |
|
error = 0; |
685 |
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
686 |
|
if ( error < 0 ){ |
687 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
688 |
|
return(error); |
689 |
|
}; |
690 |
|
// |
691 |
|
stringstream name; |
692 |
|
name.str(""); |
693 |
|
name << glroot->PATH.Data() << "/"; |
694 |
|
name << glroot->NAME.Data(); |
695 |
|
// |
696 |
|
TString fcalname = (TString)name.str().c_str(); |
697 |
|
ifstream myfile; |
698 |
|
myfile.open(fcalname.Data()); |
699 |
|
if ( !myfile ){ |
700 |
|
return(-107); |
701 |
|
}; |
702 |
|
myfile.close(); |
703 |
|
// |
704 |
|
TFile *File = new TFile(fcalname.Data()); |
705 |
|
if ( !File ) return(-108); |
706 |
|
TTree *tr = (TTree*)File->Get("CalibCalPulse2"); |
707 |
|
if ( !tr ) return(-119); |
708 |
|
// |
709 |
|
TBranch *calo = tr->GetBranch("CalibCalPulse2"); |
710 |
|
// |
711 |
|
pamela::CalibCalPulse2Event *ce = 0; |
712 |
|
tr->SetBranchAddress("CalibCalPulse2", &ce); |
713 |
|
// |
714 |
|
Long64_t ncalibs = calo->GetEntries(); |
715 |
|
// |
716 |
|
if ( !ncalibs ) return(-110); |
717 |
|
// |
718 |
|
calo->GetEntry(calibno); |
719 |
|
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
720 |
|
// |
721 |
|
// retrieve calibration table |
722 |
|
// |
723 |
|
if ( ce->pstwerr[s] && ce->pperror[s] == 0 && ce->unpackError == 0 ){ |
724 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
725 |
|
for ( Int_t j=0; j<96 ;j++){ |
726 |
|
if ( s == 2 ){ |
727 |
|
adcp[0][2*d+1][j] = ce->calpuls[3][d][j]; |
728 |
|
}; |
729 |
|
if ( s == 3 ){ |
730 |
|
adcp[0][2*d][j] = ce->calpuls[1][d][j]; |
731 |
|
}; |
732 |
|
if ( s == 0 ){ |
733 |
|
adcp[1][2*d][j] = ce->calpuls[0][d][j]; |
734 |
|
}; |
735 |
|
if ( s == 1 ){ |
736 |
|
adcp[1][2*d+1][j] = ce->calpuls[2][d][j]; |
737 |
|
}; |
738 |
|
}; |
739 |
|
}; |
740 |
|
} else { |
741 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
742 |
|
return(-111); |
743 |
|
}; |
744 |
|
// |
745 |
|
File->Close(); |
746 |
|
delete glroot; |
747 |
|
// |
748 |
|
// Save into matrix adcpcal the calibrated values of the pulse calibration (subtraction of pulse amplitude = 0 relative to the pulse2 calibration used) |
749 |
|
// |
750 |
|
pampli = 0; |
751 |
|
error = 0; |
752 |
|
error = glp->Query_GL_CALOPULSE_CALIB(fromtime,s,pampli,dbc); |
753 |
|
if ( error < 0 ){ |
754 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
755 |
|
return(error); |
756 |
|
}; |
757 |
|
// |
758 |
|
idcalib = glp->ID_ROOT_L0; |
759 |
|
calibno = glp->EV_ROOT; |
760 |
|
// |
761 |
|
// determine path and name and entry of the calibration file |
762 |
|
// |
763 |
|
glroot = new GL_ROOT(); |
764 |
|
if ( verbose ) printf("\n"); |
765 |
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
766 |
|
// |
767 |
|
error = 0; |
768 |
|
error = glroot->Query_GL_ROOT(idcalib,dbc); |
769 |
|
if ( error < 0 ){ |
770 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
771 |
|
return(error); |
772 |
|
}; |
773 |
|
// |
774 |
|
name.str(""); |
775 |
|
name << glroot->PATH.Data() << "/"; |
776 |
|
name << glroot->NAME.Data(); |
777 |
|
// |
778 |
|
fcalname = (TString)name.str().c_str(); |
779 |
|
myfile.open(fcalname.Data()); |
780 |
|
if ( !myfile ){ |
781 |
|
return(-107); |
782 |
|
}; |
783 |
|
myfile.close(); |
784 |
|
// |
785 |
|
TFile *File1 = new TFile(fcalname.Data()); |
786 |
|
if ( !File1 ) return(-108); |
787 |
|
TTree *tr1 = (TTree*)File1->Get("CalibCalPulse1"); |
788 |
|
if ( !tr1 ) return(-120); |
789 |
|
// |
790 |
|
TBranch *calo1 = tr1->GetBranch("CalibCalPulse1"); |
791 |
|
// |
792 |
|
pamela::CalibCalPulse1Event *ce1 = 0; |
793 |
|
tr1->SetBranchAddress("CalibCalPulse1", &ce1); |
794 |
|
// |
795 |
|
ncalibs = calo1->GetEntries(); |
796 |
|
// |
797 |
|
if ( !ncalibs ) return(-110); |
798 |
|
// |
799 |
|
calo1->GetEntry(calibno); |
800 |
|
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
801 |
|
// |
802 |
|
// retrieve calibration table |
803 |
|
// |
804 |
|
if ( ce1->pstwerr[s] && ce1->pperror[s] == 0 && ce1->unpackError == 0 ){ |
805 |
|
for ( Int_t d=0 ; d<11 ;d++ ){ |
806 |
|
for ( Int_t j=0; j<96 ;j++){ |
807 |
|
if ( s == 2 ){ |
808 |
|
adcpcal[0][2*d+1][j] = adcp[0][2*d+1][j] - ce1->calpuls[3][d][j]; |
809 |
|
}; |
810 |
|
if ( s == 3 ){ |
811 |
|
adcpcal[0][2*d][j] = adcp[0][2*d][j] - ce1->calpuls[1][d][j]; |
812 |
|
}; |
813 |
|
if ( s == 0 ){ |
814 |
|
adcpcal[1][2*d][j] = adcp[1][2*d][j] - ce1->calpuls[0][d][j]; |
815 |
|
}; |
816 |
|
if ( s == 1 ){ |
817 |
|
adcpcal[1][2*d+1][j] = adcp[1][2*d+1][j] - ce1->calpuls[2][d][j]; |
818 |
|
}; |
819 |
|
}; |
820 |
|
}; |
821 |
|
} else { |
822 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
823 |
|
return(-111); |
824 |
|
}; |
825 |
|
// |
826 |
|
File1->Close(); |
827 |
|
// |
828 |
|
delete glroot; |
829 |
|
// |
830 |
|
};// loop on the four sections |
831 |
// |
// |
|
if ( !ncalibs ) return(-110); |
|
832 |
// |
// |
833 |
calo->GetEntry(calibno); |
delete glp; |
|
if ( verbose ) printf(" PULSE2 using entry %u from file %s",calibno,fcalname.Data()); |
|
834 |
// |
// |
835 |
// retrieve calibration table |
// Ok, now we can try to calculate the cross-talk correction for each pre-amplifier |
836 |
// |
// |
837 |
if ( ce->pstwerr[s] && ce->pperror[s] == 0 && ce->unpackError == 0 ){ |
for ( Int_t v=0; v<2; v++){ |
838 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
if ( debug ) printf(" \n\n NEW VIEW \n"); |
839 |
for ( Int_t j=0; j<96 ;j++){ |
for ( Int_t p=0; p<22; p++){ |
840 |
if ( s == 2 ){ |
for ( Int_t npre=0; npre<6; npre++){ |
841 |
adcp[0][2*d+1][j] = ce->calpuls[3][d][j]; |
ctprecor[v][p][npre] = 1000.; |
842 |
}; |
ctneigcor[v][p][npre] = 1000.; |
843 |
if ( s == 3 ){ |
Int_t str0=npre*16; |
844 |
adcp[0][2*d][j] = ce->calpuls[1][d][j]; |
Int_t str16= -1 + (1+npre)*16; |
845 |
}; |
// |
846 |
if ( s == 0 ){ |
UInt_t neigc = 0; |
847 |
adcp[1][2*d][j] = ce->calpuls[0][d][j]; |
UInt_t farc = 0; |
848 |
|
UInt_t pulsc = 0; |
849 |
|
Float_t sigpulsed = 0.; |
850 |
|
Float_t neigbase = 0.; |
851 |
|
Float_t farbase = 0.; |
852 |
|
// |
853 |
|
// Loop over the strip of the pre and sum all signal far away from pulsed strip, signal in the neighbour(s) strip(s) and save the pulsed signal |
854 |
|
// moreover count the number of strips in each case |
855 |
|
// |
856 |
|
for (Int_t s=str0; s<=str16; s++){ |
857 |
|
if ( adcpcal[v][p][s] > 10000.){ |
858 |
|
sigpulsed = adcpcal[v][p][s]; |
859 |
|
pulsc++; |
860 |
|
if ( s > str0 ){ |
861 |
|
neigbase += adcpcal[v][p][s-1]; |
862 |
|
neigc++; |
863 |
|
farbase -= adcpcal[v][p][s-1]; |
864 |
|
farc--; |
865 |
|
}; |
866 |
|
if ( s < str16 ){ |
867 |
|
neigbase += adcpcal[v][p][s+1]; |
868 |
|
neigc++; |
869 |
|
farbase -= adcpcal[v][p][s+1]; |
870 |
|
farc--; |
871 |
|
}; |
872 |
|
} else { |
873 |
|
farc++; |
874 |
|
farbase += adcpcal[v][p][s]; |
875 |
|
}; |
876 |
}; |
}; |
877 |
if ( s == 1 ){ |
// |
878 |
adcp[1][2*d+1][j] = ce->calpuls[2][d][j]; |
// Now calculate the corrections |
879 |
|
// |
880 |
|
Float_t avefarbase = 0.; |
881 |
|
if ( farc ) avefarbase = farbase/(Float_t)farc; |
882 |
|
Float_t aveneigbase = 0.; |
883 |
|
if ( neigc ) aveneigbase = neigbase/(Float_t)neigc; |
884 |
|
// |
885 |
|
if ( pulsc == 1 && farc && neigc ){ |
886 |
|
ctprecor[v][p][npre] = -avefarbase/(sigpulsed+fabs(avefarbase)); |
887 |
|
ctneigcor[v][p][npre] = fabs(aveneigbase-avefarbase)/(sigpulsed+fabs(avefarbase)); |
888 |
|
if ( debug ) printf(" Cross-talk correction View %i Plane %i Pre %i : pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
889 |
|
} else { |
890 |
|
// |
891 |
|
// did not find the pulsed strip or more than one pulsed strip found! |
892 |
|
// |
893 |
|
if ( debug ) printf(" Problems finding the cross-talk corrections: \n View %i Plane %i Pre %i number of pulsed strip %i \n Average faraway baseline %f number of strips %i Average neighbour baseline %f number of neighbour strips %i \n",v,p,npre,pulsc,avefarbase,farc,aveneigbase,neigc); |
894 |
|
// |
895 |
}; |
}; |
896 |
}; |
}; |
897 |
|
if ( debug ) printf(" \n ==================== \n"); |
898 |
}; |
}; |
|
} else { |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
|
|
return(-111); |
|
899 |
}; |
}; |
900 |
|
} else { |
901 |
// |
// |
902 |
File->Close(); |
// use pre-amply table |
903 |
delete glroot; |
// |
904 |
// |
// |
905 |
// Save into matrix adcpcal the calibrated values of the pulse calibration (subtraction of pulse amplitude = 0 relative to the pulse2 calibration used) |
// determine where I can find file with offline neighbour correction table |
906 |
// |
// |
907 |
pampli = 0; |
stringstream bmfile2; |
908 |
error = 0; |
error = 0; |
909 |
error = glp->Query_GL_CALOPULSE_CALIB(fromtime,s,pampli,dbc); |
error = glparam->Query_GL_PARAM(runheader,106,dbc); |
910 |
if ( error < 0 ){ |
if ( error < 0 ) return(error); |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
idcalib = glp->ID_ROOT_L0; |
|
|
calibno = glp->EV_ROOT; |
|
911 |
// |
// |
912 |
// determine path and name and entry of the calibration file |
bmfile2.str(""); |
913 |
|
bmfile2 << glparam->PATH.Data() << "/"; |
914 |
|
bmfile2 << glparam->NAME.Data(); |
915 |
|
// |
916 |
|
ifstream badfile2; |
917 |
|
if ( verbose ) printf("\n Using pre-amply neighbour crosstalk table file: \n %s \n\n",bmfile2.str().c_str()); |
918 |
|
badfile2.open(bmfile2.str().c_str()); |
919 |
|
if ( !badfile2 ){ |
920 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no pre-amply neighbour crosstalk table file!\n"); |
921 |
|
return(-121); |
922 |
|
}; |
923 |
|
// |
924 |
|
Int_t vview = 0; |
925 |
|
Int_t vplane = 0; |
926 |
|
Int_t vpre = 0; |
927 |
|
Float_t vcorr = 0.; |
928 |
|
while ( badfile2 >> vview && badfile2 >> vplane && badfile2 >> vpre && badfile2 >> vcorr){ |
929 |
|
if ( debug ) printf(" Pre-amply neighbour correction: view %i plane %i pre %i correction %f \n",vview,vplane,vpre,vcorr); |
930 |
|
ctneigcor[vview][vplane][vpre] = vcorr; |
931 |
|
}; |
932 |
// |
// |
933 |
glroot = new GL_ROOT(); |
// determine where I can find file with offline SECOND neighbour correction table |
|
if ( verbose ) printf("\n"); |
|
|
if ( verbose ) printf(" ** SECTION %i **\n",s); |
|
934 |
// |
// |
935 |
|
stringstream bmfile3; |
936 |
error = 0; |
error = 0; |
937 |
error = glroot->Query_GL_ROOT(idcalib,dbc); |
error = glparam->Query_GL_PARAM(runheader,107,dbc); |
938 |
if ( error < 0 ){ |
if ( error < 0 ) return(error); |
|
if ( verbose ) printf(" CALORIMETER - ERROR: error from GLTables\n"); |
|
|
return(error); |
|
|
}; |
|
|
// |
|
|
name.str(""); |
|
|
name << glroot->PATH.Data() << "/"; |
|
|
name << glroot->NAME.Data(); |
|
939 |
// |
// |
940 |
fcalname = (TString)name.str().c_str(); |
bmfile3.str(""); |
941 |
myfile.open(fcalname.Data()); |
bmfile3 << glparam->PATH.Data() << "/"; |
942 |
if ( !myfile ){ |
bmfile3 << glparam->NAME.Data(); |
943 |
return(-107); |
// |
944 |
|
ifstream badfile3; |
945 |
|
if ( verbose ) printf("\n Using pre-amply second neighbour crosstalk table file: \n %s \n\n",bmfile3.str().c_str()); |
946 |
|
badfile3.open(bmfile3.str().c_str()); |
947 |
|
if ( !badfile3 ){ |
948 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no pre-amply second neighbour crosstalk table file!\n"); |
949 |
|
return(-122); |
950 |
}; |
}; |
951 |
myfile.close(); |
// |
952 |
// |
Int_t pview = 0; |
953 |
TFile *File1 = new TFile(fcalname.Data()); |
Int_t pplane = 0; |
954 |
if ( !File1 ) return(-108); |
Int_t ppre = 0; |
955 |
TTree *tr1 = (TTree*)File1->Get("CalibCalPulse1"); |
Float_t pcorr = 0.; |
956 |
if ( !tr1 ) return(-120); |
while ( badfile3 >> pview && badfile3 >> pplane && badfile3 >> ppre && badfile3 >> pcorr){ |
957 |
// |
if ( debug ) printf(" Pre-amply second neighbour correction: view %i plane %i pre %i correction %f \n",pview,pplane,ppre,-pcorr); |
958 |
TBranch *calo1 = tr1->GetBranch("CalibCalPulse1"); |
ctprecor[pview][pplane][ppre] = -pcorr; // data are saved as negatives in the file |
959 |
// |
}; |
|
pamela::CalibCalPulse1Event *ce1 = 0; |
|
|
tr1->SetBranchAddress("CalibCalPulse1", &ce1); |
|
|
// |
|
|
ncalibs = calo1->GetEntries(); |
|
|
// |
|
|
if ( !ncalibs ) return(-110); |
|
960 |
// |
// |
961 |
calo1->GetEntry(calibno); |
// determine where to find the file containing the Silicon crosstalk correction table |
|
if ( verbose ) printf(" PULSE1 using entry %u from file %s",calibno,fcalname.Data()); |
|
962 |
// |
// |
963 |
// retrieve calibration table |
stringstream bmfile4; |
964 |
|
error = 0; |
965 |
|
error = glparam->Query_GL_PARAM(runheader,108,dbc); |
966 |
|
if ( error < 0 ) return(error); |
967 |
// |
// |
968 |
if ( ce1->pstwerr[s] && ce1->pperror[s] == 0 && ce1->unpackError == 0 ){ |
bmfile4.str(""); |
969 |
for ( Int_t d=0 ; d<11 ;d++ ){ |
bmfile4 << glparam->PATH.Data() << "/"; |
970 |
for ( Int_t j=0; j<96 ;j++){ |
bmfile4 << glparam->NAME.Data(); |
971 |
if ( s == 2 ){ |
// |
972 |
adcpcal[0][2*d+1][j] = adcp[0][2*d+1][j] - ce1->calpuls[3][d][j]; |
ifstream badfile4; |
973 |
}; |
if ( verbose ) printf("\n Using Silicon crosstalk table file: \n %s \n\n",bmfile4.str().c_str()); |
974 |
if ( s == 3 ){ |
badfile4.open(bmfile4.str().c_str()); |
975 |
adcpcal[0][2*d][j] = adcp[0][2*d][j] - ce1->calpuls[1][d][j]; |
if ( !badfile4 ){ |
976 |
}; |
if ( verbose ) printf(" CALORIMETER - ERROR: no Silicon crosstalk table file!\n"); |
977 |
if ( s == 0 ){ |
return(-125); |
|
adcpcal[1][2*d][j] = adcp[1][2*d][j] - ce1->calpuls[0][d][j]; |
|
|
}; |
|
|
if ( s == 1 ){ |
|
|
adcpcal[1][2*d+1][j] = adcp[1][2*d+1][j] - ce1->calpuls[2][d][j]; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
} else { |
|
|
if ( verbose ) printf(" CALORIMETER - ERROR: problems finding a good calibration in this file! \n\n "); |
|
|
return(-111); |
|
978 |
}; |
}; |
979 |
|
// |
980 |
|
Int_t spview = 0; |
981 |
|
Int_t spplane = 0; |
982 |
|
Int_t psil = 0; |
983 |
|
Float_t spcorr = 0.; |
984 |
|
memset(ctsicor, 0, 2*22*9*sizeof(Float_t)); |
985 |
|
while ( badfile4 >> spview && badfile4 >> spplane && badfile4 >> psil && badfile4 >> spcorr){ |
986 |
|
if ( debug ) printf(" Silicon correction: view %i plane %i silicon %i correction %f \n",spview,spplane,psil,-spcorr); |
987 |
|
ctsicor[spview][spplane][psil] = -spcorr; // data are saved as negatives in the file |
988 |
|
}; |
989 |
// |
// |
|
File1->Close(); |
|
|
// |
|
|
delete glroot; |
|
|
// |
|
|
};// loop on the four sections |
|
|
// |
|
|
// |
|
|
delete glp; |
|
|
dbc->Close(); |
|
|
delete dbc; |
|
|
// |
|
|
// Ok, now we can try to calculate the cross-talk correction for each pre-amplifier |
|
|
// |
|
|
for ( Int_t v=0; v<2; v++){ |
|
|
if ( debug ) printf(" \n\n NEW VIEW \n"); |
|
|
for ( Int_t p=0; p<22; p++){ |
|
|
for ( Int_t npre=0; npre<6; npre++){ |
|
|
ctprecor[v][p][npre] = 1000.; |
|
|
ctneigcor[v][p][npre] = 1000.; |
|
|
Int_t str0=npre*16; |
|
|
Int_t str16= -1 + (1+npre)*16; |
|
|
// |
|
|
UInt_t neigc = 0; |
|
|
UInt_t farc = 0; |
|
|
UInt_t pulsc = 0; |
|
|
Float_t sigpulsed = 0.; |
|
|
Float_t neigbase = 0.; |
|
|
Float_t farbase = 0.; |
|
|
// |
|
|
// Loop over the strip of the pre and sum all signal far away from pulsed strip, signal in the neighbour(s) strip(s) and save the pulsed signal |
|
|
// moreover count the number of strips in each case |
|
|
// |
|
|
for (Int_t s=str0; s<=str16; s++){ |
|
|
if ( adcpcal[v][p][s] > 10000.){ |
|
|
sigpulsed = adcpcal[v][p][s]; |
|
|
pulsc++; |
|
|
if ( s > str0 ){ |
|
|
neigbase += adcpcal[v][p][s-1]; |
|
|
neigc++; |
|
|
farbase -= adcpcal[v][p][s-1]; |
|
|
farc--; |
|
|
}; |
|
|
if ( s < str16 ){ |
|
|
neigbase += adcpcal[v][p][s+1]; |
|
|
neigc++; |
|
|
farbase -= adcpcal[v][p][s+1]; |
|
|
farc--; |
|
|
}; |
|
|
} else { |
|
|
farc++; |
|
|
farbase += adcpcal[v][p][s]; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
// Now calculate the corrections |
|
|
// |
|
|
Float_t avefarbase = 0.; |
|
|
if ( farc ) avefarbase = farbase/(Float_t)farc; |
|
|
Float_t aveneigbase = 0.; |
|
|
if ( neigc ) aveneigbase = neigbase/(Float_t)neigc; |
|
|
// |
|
|
if ( pulsc == 1 && farc && neigc ){ |
|
|
ctprecor[v][p][npre] = -avefarbase/(sigpulsed+fabs(avefarbase)); |
|
|
ctneigcor[v][p][npre] = fabs(aveneigbase-avefarbase)/(sigpulsed+fabs(avefarbase)); |
|
|
if ( debug ) printf(" Cross-talk correction View %i Plane %i Pre %i : pre-correction: %f neighbour strips correction %f \n",v,p,npre,ctprecor[v][p][npre],ctneigcor[v][p][npre]); |
|
|
} else { |
|
|
// |
|
|
// did not find the pulsed strip or more than one pulsed strip found! |
|
|
// |
|
|
if ( debug ) printf(" Problems finding the cross-talk corrections: \n View %i Plane %i Pre %i number of pulsed strip %i \n Average faraway baseline %f number of strips %i Average neighbour baseline %f number of neighbour strips %i \n",v,p,npre,pulsc,avefarbase,farc,aveneigbase,neigc); |
|
|
// |
|
|
}; |
|
|
}; |
|
|
if ( debug ) printf(" \n ==================== \n"); |
|
|
}; |
|
990 |
}; |
}; |
991 |
// |
// |
992 |
|
delete glparam; |
993 |
|
// |
994 |
// Check the calculated corrections |
// Check the calculated corrections |
995 |
// |
// |
996 |
Int_t opre=0; |
Int_t opre=0; |
1031 |
}; |
}; |
1032 |
}; |
}; |
1033 |
}; |
}; |
1034 |
}; |
}; |
1035 |
// |
// |
1036 |
return(0); |
return(0); |
1037 |
} |
} |
1059 |
// |
// |
1060 |
Float_t minstrip = 100000.; |
Float_t minstrip = 100000.; |
1061 |
Float_t rms = 0.; |
Float_t rms = 0.; |
1062 |
base[l][m][pre] = 0.; |
Int_t process = 0; |
1063 |
qp = 0.; |
Int_t onlmask[16]; |
1064 |
// |
memset(onlmask, 0, 16*sizeof(Int_t)); |
1065 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
// |
1066 |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0.) { |
while ( process < 2 ){ |
1067 |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
// |
1068 |
rms = calthr[l][m][pre]; |
minstrip = 100000.; |
1069 |
}; |
rms = 0.; |
1070 |
qp += (dexy[l][m][e]-calped[l][m][e]-sbase[l][m][e]); |
base[l][m][pre] = 0.; |
1071 |
}; |
qp = 0.; |
1072 |
// |
// |
1073 |
if ( debug && l==1 ){ |
Int_t spos = -1; |
1074 |
printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n => qp = %f \n",l,m,pre,minstrip,rms,qp); |
Int_t ee = 0; |
|
}; |
|
|
if ( minstrip != 100000. ) { |
|
|
Float_t strip6s = 0.; |
|
1075 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1076 |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
if ( calgood[l][m][e] == 0. && obadmask[l][m][e] == 0 && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0. && onlmask[ee] == 0 ) { |
1077 |
strip6s += 1.; |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
1078 |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
rms = calthr[l][m][pre]; |
1079 |
}; |
spos = ee; |
|
// |
|
|
// compression |
|
|
// |
|
|
if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
|
|
dexyc[l][m][e] = 0.; |
|
|
} else { |
|
|
dexyc[l][m][e] = dexy[l][m][e]; |
|
1080 |
}; |
}; |
1081 |
|
ee++; |
1082 |
|
qp += (dexy[l][m][e]-calped[l][m][e]-sbase[l][m][e]); |
1083 |
}; |
}; |
1084 |
// |
// |
1085 |
nst = (Int_t)strip6s; |
if ( debug && l==0 ){ |
1086 |
// |
printf("\n BASELINE CALCULATION for view %i pl %i pre %i: \n => minstrip %f rms %f \n => qp = %f \n",l,m,pre,minstrip,rms,qp); |
|
if ( debug && l==1 ){ |
|
|
printf(" strip6s %f \n",strip6s); |
|
1087 |
}; |
}; |
1088 |
// if ( strip6s >= 9. ){ |
if ( minstrip != 100000. ) { |
1089 |
if ( strip6s >= 2. ){ |
Float_t strip6s = 0.; |
1090 |
Double_t arro = base[l][m][pre]/strip6s; |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1091 |
Float_t deci = 1000.*((float)arro - float(int(arro))); |
if ( (dexy[l][m][e]-calped[l][m][e]) >= minstrip && (dexy[l][m][e]-calped[l][m][e]) <= (minstrip+rms) ) { |
1092 |
if ( deci < 500. ) { |
strip6s += 1.; |
1093 |
arro = double(int(arro)); |
base[l][m][pre] += (dexy[l][m][e] - calped[l][m][e]); |
1094 |
} else { |
}; |
1095 |
arro = 1. + double(int(arro)); |
// |
1096 |
|
// compression |
1097 |
|
// |
1098 |
|
// if ( abs((int)(dexy[l][m][e]-calped[l][m][e])) <= (minstrip+rms) ) { |
1099 |
|
// dexyc[l][m][e] = 0.; |
1100 |
|
// } else { |
1101 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
1102 |
|
// }; |
1103 |
}; |
}; |
|
base[l][m][pre] = arro; |
|
1104 |
// |
// |
1105 |
// if too few strips were used to determine the baseline check if it is comparable with the previous event, if not mark it as bad |
if ( strip6s == 1. && process < 1 ){ |
1106 |
// |
onlmask[spos] = 1; |
1107 |
if ( debug && l==1 ) printf(" Calculated baseline: base %f sbase*1.02 %f \n",base[l][m][pre],1.02*sbase[l][m][pre]); |
process++; |
1108 |
|
if ( debug ) printf(" Warning, only one strip to calculate baseline: minstrip %f rms %f spos %i l %i m %i pre %i \n",minstrip,rms,spos,l,m,pre); |
1109 |
|
continue; |
1110 |
|
}; |
1111 |
|
process += 2; |
1112 |
|
nst = (Int_t)strip6s; |
1113 |
// |
// |
1114 |
if ( strip6s < 4 && base[l][m][pre] > 1.02*sbase[l][m][pre] && sbase[l][m][pre] > 0. ){ |
if ( debug ){ |
1115 |
if ( debug ) printf(" Suspicious calculated baseline: base %f sbase*1.02 %f strip6s %i \n",base[l][m][pre],1.02*sbase[l][m][pre],(Int_t)strip6s); |
printf(" strip6s %f \n",strip6s); |
1116 |
base[l][m][pre] = 31000.; |
}; |
1117 |
|
// if ( strip6s >= 9. ){ |
1118 |
|
if ( (strip6s >= 2. && process == 2) || (strip6s >= 9. && process > 2) ){ |
1119 |
|
//if ( (strip6s >= 4. && process == 2) || (strip6s >= 9. && process > 2) ){ |
1120 |
|
Double_t arro = base[l][m][pre]/strip6s; |
1121 |
|
Float_t deci = 1000.*((float)arro - float(int(arro))); |
1122 |
|
if ( deci < 500. ) { |
1123 |
|
arro = double(int(arro)); |
1124 |
|
} else { |
1125 |
|
arro = 1. + double(int(arro)); |
1126 |
|
}; |
1127 |
|
base[l][m][pre] = arro; |
1128 |
|
// |
1129 |
|
// if too few strips were used to determine the baseline check if it is comparable with the previous event, if not mark it as bad |
1130 |
|
// |
1131 |
|
if ( debug && process > 2 ) printf(" AGH low strip value was discarded process %i strip6s %f minstrip %f rms %f spos %i\n",process,strip6s,minstrip,rms,spos); |
1132 |
|
if ( debug ) printf(" Calculated baseline: base %f sbase-0.02*qp %f \n",base[l][m][pre],(-qp*0.02+sbase[l][m][pre])); |
1133 |
|
// |
1134 |
|
if ( strip6s < 4 && base[l][m][pre] > (-0.015*qp+sbase[l][m][pre]) && sbase[l][m][pre] > 0. ){ |
1135 |
|
if ( debug ) printf(" Suspicious calculated baseline: base %f sbase-0.02*qp %f strip6s %i \n",base[l][m][pre],(-qp*0.02+sbase[l][m][pre]),(Int_t)strip6s); |
1136 |
|
base[l][m][pre] = 31000.; |
1137 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1138 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
1139 |
|
}; |
1140 |
|
}; |
1141 |
|
} else { |
1142 |
|
base[l][m][pre] = 31000.; |
1143 |
|
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1144 |
|
dexyc[l][m][e] = dexy[l][m][e]; |
1145 |
|
}; |
1146 |
}; |
}; |
1147 |
} else { |
} else { |
1148 |
|
process += 2; |
1149 |
base[l][m][pre] = 31000.; |
base[l][m][pre] = 31000.; |
1150 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
1151 |
dexyc[l][m][e] = dexy[l][m][e]; |
dexyc[l][m][e] = dexy[l][m][e]; |
1152 |
}; |
}; |
1153 |
}; |
}; |
|
} else { |
|
|
base[l][m][pre] = 31000.; |
|
1154 |
}; |
}; |
1155 |
} |
} |
1156 |
|
|
1209 |
Float_t ener; |
Float_t ener; |
1210 |
Int_t doneb = 0; |
Int_t doneb = 0; |
1211 |
Int_t donec = 0; |
Int_t donec = 0; |
1212 |
Int_t ck = 0; |
Int_t ck[2][22][6]; |
1213 |
|
memset(ck, 0, 2*22*6*sizeof(Int_t)); |
1214 |
Int_t ipre = 0; |
Int_t ipre = 0; |
1215 |
Int_t ip[3] = {0}; |
// Int_t ip[3] = {0}; |
1216 |
|
Int_t ip[3] = {0,0,0}; |
1217 |
|
Int_t ipp = 0; |
1218 |
Float_t base0, base1, base2; |
Float_t base0, base1, base2; |
1219 |
base0 = 0.; |
base0 = 0.; |
1220 |
base1 = 0.; |
base1 = 0.; |
1221 |
base2 = 0.; |
base2 = 0.; |
1222 |
Float_t qpre[6] = {0.,0.,0.,0.,0.,0.}; |
Float_t qpre[2][22][6]; |
1223 |
|
memset(qpre, 0, 2*22*6*sizeof(Float_t)); |
1224 |
Float_t ene[96]; |
Float_t ene[96]; |
1225 |
Int_t chdone[4] = {0,0,0,0}; |
Int_t chdone[4] = {0,0,0,0}; |
1226 |
Int_t pe = 0; |
Int_t pe = 0; |
1228 |
Float_t ener0 = 0.; |
Float_t ener0 = 0.; |
1229 |
Float_t cbase0 = 0.; |
Float_t cbase0 = 0.; |
1230 |
Bool_t pproblem = false; |
Bool_t pproblem = false; |
1231 |
|
Bool_t negbase = false; |
1232 |
// |
// |
1233 |
Float_t tim = 0.; |
Float_t tim = 0.; |
1234 |
Int_t plo = 0; |
Int_t plo = 0; |
1242 |
// |
// |
1243 |
// determine the section number |
// determine the section number |
1244 |
// |
// |
1245 |
|
negbase = false; |
1246 |
se = 5; |
se = 5; |
1247 |
if (l == 0 && m%2 == 0) se = 3; |
if (l == 0 && m%2 == 0) se = 3; |
1248 |
if (l == 0 && m%2 != 0) se = 2; |
if (l == 0 && m%2 != 0) se = 2; |
1268 |
}; |
}; |
1269 |
clevel2->perr[se] = 0; |
clevel2->perr[se] = 0; |
1270 |
if ( de->perror[se] != 0 ){ |
if ( de->perror[se] != 0 ){ |
1271 |
clevel2->perr[se] = 1; |
clevel2->perr[se] = de->perror[se]; |
1272 |
pe++; |
pe++; |
1273 |
}; |
}; |
1274 |
clevel2->swerr[se] = 0; |
clevel2->swerr[se] = 0; |
1284 |
pre = -1; |
pre = -1; |
1285 |
// |
// |
1286 |
for (Int_t nn = 0; nn < 96; nn++){ |
for (Int_t nn = 0; nn < 96; nn++){ |
1287 |
ene[nn] = 0.; |
// ene[nn] = 0.; |
1288 |
dexy[l][m][nn] = de->dexy[l][m][nn] ; |
dexy[l][m][nn] = de->dexy[l][m][nn] ; |
1289 |
dexyc[l][m][nn] = de->dexyc[l][m][nn] ; |
dexyc[l][m][nn] = de->dexyc[l][m][nn] ; |
1290 |
}; |
}; |
1296 |
Int_t nstt[2]; |
Int_t nstt[2]; |
1297 |
Float_t rqp[2]; |
Float_t rqp[2]; |
1298 |
for (Int_t i = 0; i < 3; i++){ |
for (Int_t i = 0; i < 3; i++){ |
1299 |
nstt[0] = 0; |
nstt[0] = 1000; |
1300 |
nstt[1] = 0; |
nstt[1] = 1000; |
1301 |
rqp[0] = 0.; |
rqp[0] = 0.; |
1302 |
rqp[1] = 0.; |
rqp[1] = 0.; |
1303 |
for (Int_t j = 0; j < 2; j++){ |
for (Int_t j = 0; j < 2; j++){ |
1326 |
// |
// |
1327 |
// if we are able to calculate the baseline with more than 3 strips on one pre and not in the other one choose the pre with more calculated strips |
// if we are able to calculate the baseline with more than 3 strips on one pre and not in the other one choose the pre with more calculated strips |
1328 |
// |
// |
1329 |
if ( nstt[0] < 4 && nstt[1] >= 4 ) base[l][m][pre-1] = 31000.; |
if ( nstt[0] < 4 && nstt[1] >= 4 && nstt[0] != 1000 && nstt[1] != 1000 ) base[l][m][pre-1] = 31000.; |
1330 |
if ( nstt[0] >= 4 && nstt[1] < 4 ) base[l][m][pre] = 31000.; |
if ( nstt[0] >= 4 && nstt[1] < 4 && nstt[0] != 1000 && nstt[1] != 1000 ) base[l][m][pre] = 31000.; |
1331 |
// // |
// // |
1332 |
// // if we are NOT able to calculate the baseline with more than 3 strips on both pres take the baseline (if any) of the one which has less energy |
// // if we are NOT able to calculate the baseline with more than 3 strips on both pres take the baseline (if any) of the one which has less energy |
1333 |
// // |
// // |
1334 |
// if ( nstt[0] < 4 && nstt[1] < 4 ){ |
// if ( nstt[0] < 4 && nstt[1] < 4 ){ |
1335 |
// if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; |
// if ( rqp[0] >= rqp[1] ) base[l][m][pre-1] = 31000.; |
1336 |
// if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; |
// if ( rqp[0] < rqp[1] ) base[l][m][pre] = 31000.; |
1337 |
// }; |
// }; |
1338 |
}; |
}; |
1339 |
// |
// |
1340 |
// run over strips |
// run over strips |
1345 |
ip[i] = 0; |
ip[i] = 0; |
1346 |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
1347 |
if (n%16 == 0) { |
if (n%16 == 0) { |
|
ck = 0; |
|
1348 |
done = 0; |
done = 0; |
1349 |
doneb = 0; |
doneb = 0; |
1350 |
donec = 0; |
donec = 0; |
1351 |
pre++; |
pre++; |
1352 |
qpre[pre] = 0.; |
ck[l][m][pre] = 0; |
1353 |
|
qpre[l][m][pre] = 0.; |
1354 |
}; |
}; |
1355 |
// |
// |
1356 |
// baseline check and calculation |
// baseline check and calculation |
1359 |
// |
// |
1360 |
if ( !done ){ |
if ( !done ){ |
1361 |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
if ( (base[l][m][pre] == 31000. || base[l][m][pre] == 0.) ){ |
1362 |
ck = 1; |
ck[l][m][pre] = 1; |
1363 |
if (pre%2 == 0) { |
if (pre%2 == 0) { |
1364 |
ip[i] = pre + 1; |
ip[i] = pre + 1; |
1365 |
} else { |
} else { |
1367 |
}; |
}; |
1368 |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
1369 |
// |
// |
1370 |
ck = 2; |
ck[l][m][pre] = 2; |
1371 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
1372 |
ck = 3; |
ck[l][m][pre] = 3; |
1373 |
}; |
}; |
1374 |
}; |
}; |
|
done = 1; |
|
1375 |
}; |
}; |
1376 |
|
done = 1; |
1377 |
}; |
}; |
1378 |
// |
// |
1379 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
1380 |
// |
// |
1381 |
if ( !doneb ){ |
if ( !doneb ){ |
1382 |
if ( debug ) printf(" ck is %i \n",ck); |
if ( debug ) printf(" ck[l][m][pre] is %i \n",ck[l][m][pre]); |
1383 |
switch (ck) { |
switch (ck[l][m][pre]) { |
1384 |
case 0: |
case 0: |
1385 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
1386 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
1408 |
ener = dexyc[l][m][n]; |
ener = dexyc[l][m][n]; |
1409 |
ener0 += ener; |
ener0 += ener; |
1410 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
1411 |
|
if ( de->base[l][m][pre] < 0 ) negbase = true; |
1412 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
1413 |
// if ( !donec && (base0 - base1 + base2) != 0. ){ |
// |
1414 |
// sbase[l][m][pre] = base0 - base1 + base2; |
// save the baseline only if the energy release is "small" |
1415 |
if ( !donec && (base0 + base1 - base2) != 0. ){ |
// |
1416 |
sbase[l][m][pre] = base0 + base1 - base2; |
if ( !donec && (base0 + base1 - base2) != 0. && (n+1)%16==0 ){ |
1417 |
|
if ( qpre[l][m][pre] < 200. ) sbase[l][m][pre] = base0 + base1 - base2; |
1418 |
donec = 1; |
donec = 1; |
1419 |
}; |
}; |
1420 |
if ( ener > 0. ){ |
if ( ener > 0. ){ |
1422 |
// |
// |
1423 |
// OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) |
// OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) |
1424 |
// |
// |
1425 |
qpre[pre] += clevel1->estrip[n][m][l]; |
if ( clevel1->estrip[n][m][l] > 0. ) qpre[l][m][pre] += clevel1->estrip[n][m][l]; |
1426 |
// |
// |
1427 |
// |
// |
1428 |
}; |
}; |
1429 |
}; |
}; |
1430 |
}; |
}; |
|
if ( crosst ){ |
|
|
if (ck == 1){ |
|
|
if (ip[i]%2 == 0) { |
|
|
ipre = ip[i] + 1; |
|
|
} else { |
|
|
ipre = ip[i] - 1; |
|
|
}; |
|
|
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
|
|
if ( !ctground ){ |
|
|
clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * ctprecor[l][m][ipre]; |
|
|
} else { |
|
|
clevel1->estrip[j][m][l] += (qpre[ipre] - qpre[ip[i]]) * 0.00478; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
if (ck == 2){ |
|
|
for (Int_t j = i*32 ; j < (i+1)*32 ; j++){ |
|
|
ipre = j/16 + 1; |
|
|
if ( !ctground ){ |
|
|
clevel1->estrip[j][m][l] += qpre[ipre] * ctprecor[l][m][ipre]; |
|
|
} else { |
|
|
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
1431 |
}; |
}; |
1432 |
// |
// |
1433 |
if ( ener0 == 0. && cbase0 == 0. && !pproblem && clevel2->perr[se] == 0){ |
// check if there were problems with 5.7 or glitches in the power supply |
1434 |
|
// |
1435 |
|
if ( ((ener0 == 0. && cbase0 == 0.) || negbase ) && !pproblem && clevel2->perr[se] == 0){ |
1436 |
if ( verbose ) printf(" L0 entry %i : calorimeter power problems! event marked as bad perr %f swerr %X view %i plane %i \n",ei,de->perror[se],de->stwerr[se],l,m); |
if ( verbose ) printf(" L0 entry %i : calorimeter power problems! event marked as bad perr %f swerr %X view %i plane %i \n",ei,de->perror[se],de->stwerr[se],l,m); |
1437 |
pproblem = true; |
pproblem = true; |
1438 |
pe++; |
pe++; |
1439 |
}; |
}; |
1440 |
// |
// |
1441 |
Int_t j4 = -4; |
} else { |
1442 |
Int_t jjj = -3; |
for (Int_t nn = 0; nn < 96; nn++){ |
1443 |
Int_t jj = -2; |
clevel1->estrip[nn][m][l] = 0.; |
1444 |
Int_t jjpre = -1; |
}; |
1445 |
Int_t jjjpre = -1; |
}; |
1446 |
for (Int_t j = 0 ; j < 100 ; j++){ |
}; |
1447 |
jj++; |
}; |
1448 |
jjj++; |
// |
1449 |
j4++; |
// run over views and planes to apply crosstalk corrections |
1450 |
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
// |
1451 |
if ( crosst ){ |
for (Int_t l = 0; l < 2; l++){ |
1452 |
if ( jj >= 0 && jj < 96 ){ |
for (Int_t m = 0; m < 22; m++){ |
1453 |
if ( !ctground ){ |
// |
1454 |
if ( jj%16 == 0 ) jjpre++; |
// determine the section number |
1455 |
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
// |
1456 |
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
se = 5; |
1457 |
} else { |
if (l == 0 && m%2 == 0) se = 3; |
1458 |
if ( jj != 0 && jj != 32 && jj != 64 ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; |
if (l == 0 && m%2 != 0) se = 2; |
1459 |
if ( jj != 31 && jj != 63 && jj != 95 ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581; |
if (l == 1 && m%2 != 0) se = 1; |
1460 |
}; |
if (l == 1 && m%2 == 0) se = 0; |
1461 |
}; |
// |
1462 |
if ( jjj >= 0 && jjj < 96 ){ |
// check for any error in the event |
1463 |
if ( !ctground ){ |
// |
1464 |
if ( jjj%16 == 0 ) jjjpre++; |
if ( clevel2->crc[se] == 0 && (clevel1->good2 == 1 || clevel2->trigty >= 2) ){ |
1465 |
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
// |
1466 |
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
// Cross-talk corrections |
1467 |
} else { |
// |
1468 |
if ( jjj != 0 && jjj != 32 && jjj != 64 ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * 0.01581; |
if ( crosst ){ |
1469 |
if ( jjj != 31 && jjj != 63 && jjj != 95 ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * 0.01581; |
// |
1470 |
}; |
// energy on silicon ladders |
1471 |
}; |
// |
1472 |
}; |
Float_t qsi[3]; |
1473 |
if ( j4 >= 0 && j4 < 96 ){ |
qsi[0] = qpre[l][m][0]+qpre[l][m][1]; |
1474 |
|
qsi[1] = qpre[l][m][2]+qpre[l][m][3]; |
1475 |
|
qsi[2] = qpre[l][m][4]+qpre[l][m][5]; |
1476 |
|
// |
1477 |
|
for ( pre = 1; pre < 6; pre += 2 ){ |
1478 |
|
Int_t ladder = (pre - 1)/2; |
1479 |
// |
// |
1480 |
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <=============== IMPORTANT! =================> |
// If the noselfct flag is set the strip doesn't suffer the self crosstalk due to electronics so we must subtract some energy |
1481 |
// |
// |
1482 |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
if ( noselfct ){ |
1483 |
clevel1->estrip[j4][m][l] = 0.; |
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
1484 |
|
ipre = j/16 ; |
1485 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] -= clevel1->estrip[j][m][l] * ctprecor[l][m][ipre]; |
1486 |
|
}; |
1487 |
}; |
}; |
|
// |
|
|
// code and save the energy for each strip in svstrip |
|
1488 |
// |
// |
1489 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
// Using the neighbour pre baseline |
1490 |
|
// |
1491 |
|
if (ck[l][m][pre] == 1 || ck[l][m][pre-1] == 1){ |
1492 |
// |
// |
1493 |
Float_t savel1 = clevel1->estrip[j4][m][l]; |
// pre-amplifier effect on baseline when using the neighbour pre (ck=1) |
|
if ( dexyc[l][m][j4] == 32767. ){ |
|
|
savel1 += 5000.; |
|
|
clevel2->nsatstrip += 1.; |
|
|
}; |
|
1494 |
// |
// |
1495 |
tim = 100000.; |
if (ck[l][m][pre] == 1){ |
1496 |
plo = m; |
ipre = pre; |
1497 |
fbi = 0; |
ipp = pre - 1; |
1498 |
if ( savel1 > 0.99995 ){ |
} else { |
1499 |
tim = 10000.; |
ipre = pre - 1; |
1500 |
plo = m; |
ipp = pre; |
|
fbi = 1; |
|
|
}; |
|
|
if ( savel1 > 9.9995 ){ |
|
|
tim = 1000.; |
|
|
plo = 22 + m; |
|
|
fbi = 1; |
|
|
}; |
|
|
if ( savel1 > 99.995 ){ |
|
|
tim = 100.; |
|
|
plo = 22 + m; |
|
|
fbi = 0; |
|
1501 |
}; |
}; |
1502 |
if ( savel1 > 999.95 ){ |
Int_t it = 0; |
1503 |
tim = 10.; |
Float_t nqpre = 0.; |
1504 |
plo = 44 + m; |
// |
1505 |
fbi = 0; |
if ( debug ) printf(" CK1 Limit for while: 0.07 \n"); |
1506 |
|
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
1507 |
|
if ( !ctground ){ |
1508 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * ctprecor[l][m][ipp]; |
1509 |
|
} else { |
1510 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += - qpre[l][m][ipp] * 0.00478; |
1511 |
|
}; |
1512 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
1513 |
}; |
}; |
1514 |
if ( savel1 > 9999.5 ){ |
qpre[l][m][ipre] = nqpre; |
1515 |
tim = 1.; |
nqpre = 0.; |
1516 |
plo = 66 + m; |
Float_t deltaqpre = qpre[l][m][ipre]; |
1517 |
fbi = 0; |
// |
1518 |
|
// these values are empirically determined, usually the routine converge due to deltaqsi and the latest applied correction is based on less than 1 mip |
1519 |
|
// |
1520 |
|
while ( it < 10 && deltaqpre > 0.07 ){ |
1521 |
|
nqpre = 0.; |
1522 |
|
for (Int_t j = ipre*16 ; j < (ipre+1)*16 ; j++){ |
1523 |
|
if ( !ctground ){ |
1524 |
|
if ( debug ) printf(" CK1 pre correction: iteration %i deltaqpre %f ctprecor %f TOTAL CORRECTION %f \n",it,deltaqpre,ctprecor[l][m][ipre],deltaqpre * ctprecor[l][m][ipre]); |
1525 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * ctprecor[l][m][ipre]; |
1526 |
|
} else { |
1527 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += deltaqpre * 0.00478; |
1528 |
|
}; |
1529 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqpre += clevel1->estrip[j][m][l] ; |
1530 |
|
}; |
1531 |
|
if ( ctground ) it = 100; |
1532 |
|
it++; |
1533 |
|
deltaqpre = nqpre - qpre[l][m][ipre]; |
1534 |
|
if ( debug ) printf(" CK1 BEFORE: qpre %f \n",qpre[l][m][ipre]); |
1535 |
|
qpre[l][m][ipre] = nqpre; |
1536 |
|
if ( debug ) printf(" CK1 AFTER: qpre %f \n",qpre[l][m][ipre]); |
1537 |
}; |
}; |
1538 |
// |
// |
1539 |
cle = (Int_t)lroundf(tim*savel1); |
}; |
1540 |
|
// |
1541 |
|
// No baseline calculation due to high energy release |
1542 |
|
// |
1543 |
|
if (ck[l][m][pre] == 2 && ck[l][m][pre-1] == 2){ |
1544 |
|
// |
1545 |
|
// y^ |
1546 |
|
// | |
1547 |
|
// | 6 7 8 |
1548 |
|
// | 3 4 5 |
1549 |
|
// | 0 1 2 |
1550 |
|
// | --------------------------------------> x |
1551 |
// |
// |
1552 |
|
Int_t si1 = 0; |
1553 |
|
Int_t si2 = 0; |
1554 |
|
Int_t si3 = 0; |
1555 |
if ( l == 0 ){ |
if ( l == 0 ){ |
1556 |
// |
if ( ladder == 0 ){ |
1557 |
// +-PPSSmmmm.mmmm |
si1 = 0; |
1558 |
// |
si2 = 3; |
1559 |
svstrip[istrip] = fbi*1000000000 + plo*10000000 + j4*100000 + cle; |
si3 = 6; |
1560 |
|
}; |
1561 |
|
if ( ladder == 1 ){ |
1562 |
|
si1 = 1; |
1563 |
|
si2 = 4; |
1564 |
|
si3 = 7; |
1565 |
|
}; |
1566 |
|
if ( ladder == 2 ){ |
1567 |
|
si1 = 2; |
1568 |
|
si2 = 5; |
1569 |
|
si3 = 8; |
1570 |
|
}; |
1571 |
} else { |
} else { |
1572 |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
if ( ladder == 0 ){ |
1573 |
|
si1 = 0; |
1574 |
|
si2 = 1; |
1575 |
|
si3 = 2; |
1576 |
|
}; |
1577 |
|
if ( ladder == 1 ){ |
1578 |
|
si1 = 3; |
1579 |
|
si2 = 4; |
1580 |
|
si3 = 5; |
1581 |
|
}; |
1582 |
|
if ( ladder == 2 ){ |
1583 |
|
si1 = 6; |
1584 |
|
si2 = 7; |
1585 |
|
si3 = 8; |
1586 |
|
}; |
1587 |
|
}; |
1588 |
|
// |
1589 |
|
// Find the energy distribution along the considered plane looking at the two sandwiching plane of the other view. |
1590 |
|
// |
1591 |
|
Float_t sied[3] = {0.,0.,0.}; |
1592 |
|
Int_t othv = !l; |
1593 |
|
Int_t othpl1 = m - 1; |
1594 |
|
Int_t othpl2 = m + 1; |
1595 |
|
Float_t oprof[3] = {0.,0.,0.}; |
1596 |
|
for(Int_t s=0; s<3; s++){ |
1597 |
|
for(Int_t t=(s*32); t<32*(s + 1); t++){ |
1598 |
|
if ( othpl1 > -1 ) { |
1599 |
|
oprof[s] += clevel1->estrip[othv][othpl1][t]; |
1600 |
|
}; |
1601 |
|
if ( othpl2 < 22 ) { |
1602 |
|
oprof[s] += clevel1->estrip[othv][othpl2][t]; |
1603 |
|
}; |
1604 |
|
}; |
1605 |
|
}; |
1606 |
|
Float_t otote = fabs(oprof[0]) + fabs(oprof[1]) + fabs(oprof[2]); |
1607 |
|
for(Int_t g=0; g<3; g++){ |
1608 |
|
if ( otote > 0. ){ |
1609 |
|
sied[g] = fabs(oprof[g])/otote; |
1610 |
|
} else { |
1611 |
|
sied[g] = 1./3.; |
1612 |
|
}; |
1613 |
}; |
}; |
1614 |
// |
// |
|
// if ( ei >= -770 ) printf(" j %i l %i m %i estrip %f \n",j4,l,m,clevel1->estrip[j4][m][l]); |
|
|
// if ( ei >= -770 ) printf(" num lim %i fbi %i tim %f plo %i cle %i \n",numeric_limits<Int_t>::max(),fbi,tim,plo,cle); |
|
|
// if ( ei >= -770 ) printf(" svstrip %i \n",svstrip[istrip]); |
|
1615 |
// |
// |
1616 |
istrip++; |
// |
1617 |
|
Int_t it = 0; |
1618 |
|
Int_t jpre = 0; |
1619 |
|
Float_t nqsi = 0.; |
1620 |
|
Float_t snqsi = qsi[ladder]; |
1621 |
|
Float_t nqpre[2] = {0.,0.}; |
1622 |
|
Float_t deltaqsi = qsi[ladder]; |
1623 |
|
Float_t deltaqpre[2]; |
1624 |
|
deltaqpre[0] = qpre[l][m][pre-1]; |
1625 |
|
deltaqpre[1] = qpre[l][m][pre]; |
1626 |
|
// |
1627 |
|
if ( debug ) printf(" Limit for while: 0.07 it < 10 \n"); |
1628 |
|
// |
1629 |
|
// these values are empirically determined, usually the routine converge due to deltaqsi and the latest applied correction is based on less than 1 mip |
1630 |
|
// |
1631 |
|
while ( it < 10 && (deltaqsi > 0.07 || deltaqpre[0] > 0.07 || deltaqpre[1] > 0.07) ){ |
1632 |
|
nqsi = 0.; |
1633 |
|
nqpre[0] = 0.; |
1634 |
|
nqpre[1] = 0.; |
1635 |
|
for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
1636 |
|
ipre = 0; |
1637 |
|
if ( j > (ladder*32)+15 ) ipre = 1; |
1638 |
|
jpre = j/16 ; |
1639 |
|
// |
1640 |
|
// Silicon effect on the baseline when using the same pre previous baseline (ck = 2) + pre-amply effect |
1641 |
|
// |
1642 |
|
if ( !ctground ){ |
1643 |
|
if ( debug ) printf(" silicon correction: iteration %i deltaqsi[%i] %f ctsicor %f %f %f sied %f %f %f si %i %i %i TOTAL CORRECTION %f \n",it,ladder,deltaqsi,ctsicor[l][m][si1],ctsicor[l][m][si2],ctsicor[l][m][si3],sied[0],sied[1],sied[2],si1,si2,si3,deltaqsi * (ctsicor[l][m][si1] * sied[0] + ctsicor[l][m][si2] * sied[1] + ctsicor[l][m][si3] * sied[2])); |
1644 |
|
if ( debug ) printf(" pre correction: iteration %i deltaqpre[0] %f deltaqpre[1] %f ctprecor %f TOTAL CORRECTION %f \n",it,deltaqpre[0],deltaqpre[1],ctprecor[l][m][jpre],deltaqpre[ipre] * ctprecor[l][m][jpre]); |
1645 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += (deltaqsi * (ctsicor[l][m][si1] * sied[0] + ctsicor[l][m][si2] * sied[1] + ctsicor[l][m][si3] * sied[2])/mip[l][m][j]) + deltaqpre[ipre] * ctprecor[l][m][jpre]; |
1646 |
|
} else { |
1647 |
|
if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += 0. + qpre[l][m][jpre] * 0.00478; // no correction |
1648 |
|
}; |
1649 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqsi += clevel1->estrip[j][m][l] ; |
1650 |
|
if ( clevel1->estrip[j][m][l] > 0. ) nqpre[ipre] += clevel1->estrip[j][m][l] ; |
1651 |
|
}; |
1652 |
|
if ( ctground ) it = 100; |
1653 |
|
deltaqsi = nqsi-snqsi; |
1654 |
|
snqsi = nqsi; |
1655 |
|
it++; |
1656 |
|
deltaqpre[0] = nqpre[0] - qpre[l][m][pre-1]; |
1657 |
|
deltaqpre[1] = nqpre[1] - qpre[l][m][pre]; |
1658 |
|
if ( debug ) printf(" BEFORE: qpre 0 %f qpre 1 %f \n",qpre[l][m][pre-1],qpre[l][m][pre]); |
1659 |
|
qpre[l][m][pre-1] = nqpre[0]; |
1660 |
|
qpre[l][m][pre] = nqpre[1]; |
1661 |
|
if ( debug ) printf(" AFTER: qpre 0 %f qpre 1 %f \n",qpre[l][m][pre-1],qpre[l][m][pre]); |
1662 |
|
}; |
1663 |
|
// |
1664 |
|
// |
1665 |
|
// |
1666 |
|
// for (Int_t j = ladder*32 ; j < (ladder+1)*32 ; j++){ |
1667 |
|
// ipre = j/16 ; |
1668 |
|
// // |
1669 |
|
// // pre-amplifier effect on baseline when using the same pre previous event baseline (ck=2) |
1670 |
|
// // |
1671 |
|
// if ( !ctground ){ |
1672 |
|
// if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += qpre[l][m][ipre] * ctprecor[l][m][ipre]; |
1673 |
|
// } else { |
1674 |
|
// if ( clevel1->estrip[j][m][l] != 0. ) clevel1->estrip[j][m][l] += qpre[l][m][ipre] * 0.00478; |
1675 |
|
// }; |
1676 |
|
// }; |
1677 |
}; |
}; |
1678 |
}; |
}; |
1679 |
}; |
}; |
1680 |
// |
}; |
1681 |
} else { |
// |
1682 |
for (Int_t nn = 0; nn < 96; nn++){ |
Int_t j4 = -4; |
1683 |
clevel1->estrip[nn][m][l] = 0.; |
Int_t jjj = -3; |
1684 |
|
Int_t jj = -2; |
1685 |
|
Int_t jjpre = -1; |
1686 |
|
Int_t jjjpre = -1; |
1687 |
|
memset(ene, 0, 96*sizeof(Float_t)); |
1688 |
|
for (Int_t j = 0 ; j < 100 ; j++){ |
1689 |
|
jj++; |
1690 |
|
jjj++; |
1691 |
|
j4++; |
1692 |
|
if ( j < 96 ) ene[j] = clevel1->estrip[j][m][l]; |
1693 |
|
if ( crosst ){ |
1694 |
|
// |
1695 |
|
// "Real" crosstalk effect on the neighbour strips respect to the one which have seen the energy deposit |
1696 |
|
// |
1697 |
|
if ( jj >= 0 && jj < 96 ){ |
1698 |
|
if ( !ctground ){ |
1699 |
|
if ( jj%16 == 0 ) jjpre++; |
1700 |
|
if ( jj != 0 && jj != 32 && jj != 64 && ene[jj-1] != 0. ) ene[jj-1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
1701 |
|
if ( jj != 31 && jj != 63 && jj != 95 && ene[jj+1] != 0. ) ene[jj+1] += -clevel1->estrip[jj][m][l] * ctneigcor[l][m][jjpre]; |
1702 |
|
} else { |
1703 |
|
if ( jj != 0 && jj != 32 && jj != 64 && ene[jj-1] != 0. ) ene[jj-1] += -clevel1->estrip[jj][m][l] * 0.01581; |
1704 |
|
if ( jj != 31 && jj != 63 && jj != 95 && ene[jj+1] != 0. ) ene[jj+1] += -clevel1->estrip[jj][m][l] * 0.01581; |
1705 |
|
}; |
1706 |
|
}; |
1707 |
|
if ( jjj >= 0 && jjj < 96 ){ |
1708 |
|
if ( !ctground ){ |
1709 |
|
if ( jjj%16 == 0 ) jjjpre++; |
1710 |
|
if ( jjj != 0 && jjj != 32 && jjj != 64 && clevel1->estrip[jjj-1][m][l] != 0. ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
1711 |
|
if ( jjj != 31 && jjj != 63 && jjj != 95 && clevel1->estrip[jjj+1][m][l] !=0. ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * ctneigcor[l][m][jjjpre]; |
1712 |
|
} else { |
1713 |
|
if ( jjj != 0 && jjj != 32 && jjj != 64 && clevel1->estrip[jjj-1][m][l] != 0. ) clevel1->estrip[jjj-1][m][l] += -ene[jjj] * 0.01581; |
1714 |
|
if ( jjj != 31 && jjj != 63 && jjj != 95 && clevel1->estrip[jjj+1][m][l] != 0. ) clevel1->estrip[jjj+1][m][l] += -ene[jjj] * 0.01581; |
1715 |
|
}; |
1716 |
|
}; |
1717 |
|
}; |
1718 |
|
if ( j4 >= 0 && j4 < 96 ){ |
1719 |
|
// |
1720 |
|
// CALOLEVEL1 CODING AND FILLING |
1721 |
|
// |
1722 |
|
// |
1723 |
|
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <=============== IMPORTANT! =================> |
1724 |
|
// |
1725 |
|
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || clevel1->estrip[j4][m][l] <= memin[l][m][j4] || calrms[l][m][j4] > maxrms[l][m] ){ |
1726 |
|
clevel1->estrip[j4][m][l] = 0.; |
1727 |
|
}; |
1728 |
|
// |
1729 |
|
// code and save the energy for each strip in svstrip |
1730 |
|
// |
1731 |
|
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
1732 |
|
// |
1733 |
|
Float_t savel1 = clevel1->estrip[j4][m][l]; |
1734 |
|
// if ( dexyc[l][m][j4] == 32767. ){ |
1735 |
|
if ( dexyc[l][m][j4] > 32000. ){ |
1736 |
|
savel1 += 5000.; |
1737 |
|
clevel2->nsatstrip += 1.; |
1738 |
|
}; |
1739 |
|
// |
1740 |
|
tim = 100000.; |
1741 |
|
plo = m; |
1742 |
|
fbi = 0; |
1743 |
|
if ( savel1 > 0.99995 ){ |
1744 |
|
tim = 10000.; |
1745 |
|
plo = m; |
1746 |
|
fbi = 1; |
1747 |
|
}; |
1748 |
|
if ( savel1 > 9.9995 ){ |
1749 |
|
tim = 1000.; |
1750 |
|
plo = 22 + m; |
1751 |
|
fbi = 1; |
1752 |
|
}; |
1753 |
|
if ( savel1 > 99.995 ){ |
1754 |
|
tim = 100.; |
1755 |
|
plo = 22 + m; |
1756 |
|
fbi = 0; |
1757 |
|
}; |
1758 |
|
if ( savel1 > 999.95 ){ |
1759 |
|
tim = 10.; |
1760 |
|
plo = 44 + m; |
1761 |
|
fbi = 0; |
1762 |
|
}; |
1763 |
|
if ( savel1 > 9999.5 ){ |
1764 |
|
tim = 1.; |
1765 |
|
plo = 66 + m; |
1766 |
|
fbi = 0; |
1767 |
|
}; |
1768 |
|
// |
1769 |
|
cle = (Int_t)lroundf(tim*savel1); |
1770 |
|
// |
1771 |
|
if ( l == 0 ){ |
1772 |
|
// |
1773 |
|
// +-PPSSmmmm.mmmm |
1774 |
|
// |
1775 |
|
svstrip[istrip] = fbi*1000000000 + plo*10000000 + j4*100000 + cle; |
1776 |
|
} else { |
1777 |
|
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
1778 |
|
}; |
1779 |
|
// |
1780 |
|
istrip++; |
1781 |
|
}; |
1782 |
}; |
}; |
1783 |
}; |
}; |
1784 |
|
// |
1785 |
}; |
}; |
1786 |
}; |
}; |
1787 |
|
// |
1788 |
|
// store goodness flag |
1789 |
|
// |
1790 |
if ( !pe ){ |
if ( !pe ){ |
1791 |
clevel2->good = 1; |
clevel2->good = 1; |
1792 |
} else { |
} else { |
1793 |
clevel2->good = 0; |
clevel2->good = 0; |
1794 |
}; |
}; |
1795 |
|
// |
1796 |
|
// done |
1797 |
|
// |
1798 |
return(0); |
return(0); |
1799 |
} |
} |
1800 |
|
|
1921 |
ClearCommonVar(); |
ClearCommonVar(); |
1922 |
} |
} |
1923 |
|
|
1924 |
|
void CaloLevel0::Delete(Option_t *t){ |
1925 |
|
if ( de ) delete de; |
1926 |
|
delete this; |
1927 |
|
} |
1928 |
|
|
1929 |
|
|
1930 |
void CaloLevel0::RunClose(){ |
void CaloLevel0::RunClose(){ |
1931 |
l0tr->Delete(); |
l0tr->Delete(); |
1932 |
ClearStructs(); |
ClearStructs(); |
1936 |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
memset(base, 0, 2*22*6*sizeof(Float_t)); |
1937 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
1938 |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctprecor, 0, 2*22*6*sizeof(Float_t)); |
1939 |
|
memset(ctsicor, 0, 2*22*9*sizeof(Float_t)); |
1940 |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
memset(ctneigcor, 0, 2*22*6*sizeof(Float_t)); |
1941 |
// |
// |
1942 |
} |
} |