66 |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
memset(sbase, 0, 2*22*6*sizeof(Float_t)); |
67 |
calopar1 = true; |
calopar1 = true; |
68 |
calopar2 = true; |
calopar2 = true; |
69 |
|
calopar3 = true; |
70 |
ftcalopar1 = 0; |
ftcalopar1 = 0; |
71 |
ttcalopar1 = 0; |
ttcalopar1 = 0; |
72 |
ftcalopar2 = 0; |
ftcalopar2 = 0; |
73 |
ttcalopar2 = 0; |
ttcalopar2 = 0; |
74 |
|
ftcalopar3 = 0; |
75 |
|
ttcalopar3 = 0; |
76 |
} |
} |
77 |
|
|
78 |
/** |
/** |
164 |
Int_t sgnl = 0; |
Int_t sgnl = 0; |
165 |
for ( Int_t s = 0; s < 4; s++){ |
for ( Int_t s = 0; s < 4; s++){ |
166 |
if ( atime > totime[s] ){ |
if ( atime > totime[s] ){ |
167 |
|
if ( !dbc->IsConnected() ) throw -116; |
168 |
sgnl = Update(dbc,atime,s); |
sgnl = Update(dbc,atime,s); |
169 |
if ( sgnl < 0 ) return(sgnl); |
if ( sgnl < 0 ) return(sgnl); |
170 |
}; |
}; |
174 |
|
|
175 |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
Int_t CaloProcessing::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
176 |
stringstream calfile; |
stringstream calfile; |
177 |
|
stringstream bmfile; |
178 |
stringstream aligfile; |
stringstream aligfile; |
179 |
Int_t error = 0; |
Int_t error = 0; |
180 |
FILE *f = 0; |
FILE *f = 0; |
181 |
|
ifstream badfile; |
182 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
183 |
// |
// |
184 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
231 |
ftcalopar2 = glparam->FROM_TIME; |
ftcalopar2 = glparam->FROM_TIME; |
232 |
ttcalopar2 = glparam->TO_TIME; |
ttcalopar2 = glparam->TO_TIME; |
233 |
// |
// |
234 |
if ( verbose ) printf("\n Using alignment file: \n %s \n\n",aligfile.str().c_str()); |
if ( verbose ) printf("\n Using alignment file: \n %s \n",aligfile.str().c_str()); |
235 |
f = fopen(aligfile.str().c_str(),"rb"); |
f = fopen(aligfile.str().c_str(),"rb"); |
236 |
if ( !f ){ |
if ( !f ){ |
237 |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
250 |
fclose(f); |
fclose(f); |
251 |
}; |
}; |
252 |
// |
// |
253 |
|
// Load offline bad strip mask |
254 |
|
// |
255 |
|
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
256 |
|
calopar3 = false; |
257 |
|
// |
258 |
|
// determine where I can find calorimeter alignment file |
259 |
|
// |
260 |
|
// |
261 |
|
error = 0; |
262 |
|
error = glparam->Query_GL_PARAM(runheader,103,dbc); |
263 |
|
if ( error < 0 ) return(error); |
264 |
|
// |
265 |
|
bmfile.str(""); |
266 |
|
bmfile << glparam->PATH.Data() << "/"; |
267 |
|
bmfile << glparam->NAME.Data(); |
268 |
|
ftcalopar3 = glparam->FROM_TIME; |
269 |
|
ttcalopar3 = glparam->TO_TIME; |
270 |
|
// |
271 |
|
if ( verbose ) printf("\n Using bad strip offline mask file: \n %s \n\n",bmfile.str().c_str()); |
272 |
|
badfile.open(bmfile.str().c_str()); |
273 |
|
if ( !badfile ){ |
274 |
|
if ( verbose ) printf(" CALORIMETER - ERROR: no bad strip offline mask file!\n"); |
275 |
|
return(-115); |
276 |
|
}; |
277 |
|
// |
278 |
|
Bool_t isdone = false; |
279 |
|
Int_t bad = 0; |
280 |
|
Int_t view = 1; |
281 |
|
Int_t strip = 0; |
282 |
|
Int_t plane = 21; |
283 |
|
while ( !isdone ) { |
284 |
|
badfile >> bad; |
285 |
|
obadmask[view][plane][strip] = bad; |
286 |
|
if ( debug && bad ) printf(" SETTING view %i plane %i strip %i BAD = %i \n",view,plane,strip,bad); |
287 |
|
strip++; |
288 |
|
if ( strip > 95 ){ |
289 |
|
strip = 0; |
290 |
|
plane--; |
291 |
|
if ( plane < 0 ){ |
292 |
|
plane = 21; |
293 |
|
view--; |
294 |
|
}; |
295 |
|
if ( view < 0 ) isdone = true; |
296 |
|
}; |
297 |
|
}; |
298 |
|
// |
299 |
|
badfile.close(); |
300 |
|
}; |
301 |
|
// |
302 |
delete glparam; |
delete glparam; |
303 |
// |
// |
304 |
return(0); |
return(0); |
311 |
Float_t rms = 0.; |
Float_t rms = 0.; |
312 |
base[l][m][pre] = 0.; |
base[l][m][pre] = 0.; |
313 |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
for (Int_t e = pre*16; e < (pre+1)*16 ; e++){ |
314 |
if ( calgood[l][m][e] == 0. && dexy[l][m][e]-calped[l][m][e] < minstrip && dexy[l][m][e] > 0.) { |
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.) { |
315 |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
minstrip = dexy[l][m][e]-calped[l][m][e]; |
316 |
rms = calthr[l][m][pre]; |
rms = calthr[l][m][pre]; |
317 |
}; |
}; |
394 |
Int_t chdone[4] = {0,0,0,0}; |
Int_t chdone[4] = {0,0,0,0}; |
395 |
Int_t pe = 0; |
Int_t pe = 0; |
396 |
// |
// |
397 |
|
Float_t ener0 = 0.; |
398 |
|
Float_t cbase0 = 0.; |
399 |
|
Bool_t pproblem = false; |
400 |
|
// |
401 |
|
Float_t tim = 0.; |
402 |
|
Int_t plo = 0; |
403 |
|
Int_t fbi = 0; |
404 |
|
Int_t cle = 0; |
405 |
|
// |
406 |
// run over views and planes |
// run over views and planes |
407 |
// |
// |
408 |
for (Int_t l = 0; l < 2; l++){ |
for (Int_t l = 0; l < 2; l++){ |
459 |
// run over preamplifiers |
// run over preamplifiers |
460 |
// |
// |
461 |
pre = -1; |
pre = -1; |
462 |
|
cbase0 = 0.; |
463 |
for (Int_t i = 0; i < 3; i++){ |
for (Int_t i = 0; i < 3; i++){ |
464 |
for (Int_t j = 0; j < 2; j++){ |
for (Int_t j = 0; j < 2; j++){ |
465 |
pre = j + i*2; |
pre = j + i*2; |
468 |
// |
// |
469 |
if ( !isRAW ) { |
if ( !isRAW ) { |
470 |
base[l][m][pre] = de->base[l][m][pre] ; |
base[l][m][pre] = de->base[l][m][pre] ; |
471 |
|
cbase0 += base[l][m][pre]; |
472 |
} else { |
} else { |
473 |
// |
// |
474 |
// if it is a raw event and we haven't checked |
// if it is a raw event and we haven't checked |
475 |
// yet, calculate the baseline. |
// yet, calculate the baseline. |
476 |
// |
// |
477 |
FindBaseRaw(l,m,pre); |
FindBaseRaw(l,m,pre); |
478 |
|
cbase0 += base[l][m][pre]; |
479 |
}; |
}; |
480 |
}; |
}; |
481 |
}; |
}; |
483 |
// run over strips |
// run over strips |
484 |
// |
// |
485 |
pre = -1; |
pre = -1; |
486 |
|
ener0 = 0.; |
487 |
for (Int_t i = 0 ; i < 3 ; i++){ |
for (Int_t i = 0 ; i < 3 ; i++){ |
488 |
ip[i] = 0; |
ip[i] = 0; |
489 |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
for (Int_t n = i*32 ; n < (i+1)*32 ; n++){ |
544 |
doneb = 1; |
doneb = 1; |
545 |
}; |
}; |
546 |
ener = dexyc[l][m][n]; |
ener = dexyc[l][m][n]; |
547 |
|
ener0 += ener; |
548 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
549 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
550 |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
576 |
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
clevel1->estrip[j][m][l] += qpre[ipre] * 0.00478; |
577 |
}; |
}; |
578 |
}; |
}; |
579 |
}; |
}; |
580 |
|
// |
581 |
|
if ( ener0 == 0. && cbase0 == 0. && !pproblem ){ |
582 |
|
if ( verbose ) printf(" Calorimeter power problems! event marked as bad \n"); |
583 |
|
pproblem = true; |
584 |
|
pe++; |
585 |
|
}; |
586 |
// |
// |
587 |
Int_t j4 = -4; |
Int_t j4 = -4; |
588 |
Int_t jjj = -3; |
Int_t jjj = -3; |
602 |
}; |
}; |
603 |
if ( j4 >= 0 && j4 < 96 ){ |
if ( j4 >= 0 && j4 < 96 ){ |
604 |
// |
// |
605 |
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <===V============ IMPORTANT! =================> |
// NOTICE: THE FOLLOWING LINE EXCLUDE ALL STRIPS FOR WHICH THE RMS*4 IS GREATER THAN 26 !!! <=============== IMPORTANT! =================> |
606 |
// |
// |
607 |
if ( clevel1->estrip[j4][m][l]!=0. && ( clevel1->estrip[j4][m][l] < clevel1->emin || calrms[l][m][j4] > 26 )){ |
if ( obadmask[l][m][j4] == 1 || clevel1->estrip[j4][m][l] <= clevel1->emin || calrms[l][m][j4] > 26 ){ |
608 |
clevel1->estrip[j4][m][l] = 0.; |
clevel1->estrip[j4][m][l] = 0.; |
609 |
}; |
}; |
610 |
|
// |
611 |
|
// code and save the energy for each strip in svstrip |
612 |
|
// |
613 |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
if ( clevel1->estrip[j4][m][l] > clevel1->emin ){ |
614 |
|
// |
615 |
|
tim = 100000.; |
616 |
|
plo = m; |
617 |
|
fbi = 0; |
618 |
|
if ( clevel1->estrip[j4][m][l] > 0.99995 ){ |
619 |
|
tim = 10000.; |
620 |
|
plo = m; |
621 |
|
fbi = 1; |
622 |
|
}; |
623 |
|
if ( clevel1->estrip[j4][m][l] > 9.9995 ){ |
624 |
|
tim = 1000.; |
625 |
|
plo = 22 + m; |
626 |
|
fbi = 1; |
627 |
|
}; |
628 |
|
if ( clevel1->estrip[j4][m][l] > 99.995 ){ |
629 |
|
tim = 100.; |
630 |
|
plo = 22 + m; |
631 |
|
fbi = 0; |
632 |
|
}; |
633 |
|
if ( clevel1->estrip[j4][m][l] > 999.95 ){ |
634 |
|
tim = 10.; |
635 |
|
plo = 44 + m; |
636 |
|
fbi = 0; |
637 |
|
}; |
638 |
|
if ( clevel1->estrip[j4][m][l] > 9999.5 ){ |
639 |
|
tim = 1.; |
640 |
|
plo = 66 + m; |
641 |
|
fbi = 0; |
642 |
|
}; |
643 |
|
// |
644 |
|
cle = (Int_t)lroundf(tim*clevel1->estrip[j4][m][l]); |
645 |
|
// |
646 |
if ( l == 0 ){ |
if ( l == 0 ){ |
647 |
// |
// |
648 |
// +-PPSSmmmm.mmmm |
// +-PPSSmmmm.mmmm |
649 |
// |
// |
650 |
svstrip[istrip] = ((Float_t)m)*1000000. + ((Float_t)j4)*10000. + clevel1->estrip[j4][m][l]; |
svstrip[istrip] = fbi*1000000000 + plo*10000000 + j4*100000 + cle; |
651 |
} else { |
} else { |
652 |
svstrip[istrip] = -(((Float_t)m)*1000000. + ((Float_t)j4)*10000. + clevel1->estrip[j4][m][l]); |
svstrip[istrip] = -(fbi*1000000000 + plo*10000000 + j4*100000 + cle); |
653 |
}; |
}; |
654 |
|
// |
655 |
|
// if ( ei >= -770 ) printf(" j %i l %i m %i estrip %f \n",j4,l,m,clevel1->estrip[j4][m][l]); |
656 |
|
// 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); |
657 |
|
// if ( ei >= -770 ) printf(" svstrip %i \n",svstrip[istrip]); |
658 |
|
// |
659 |
istrip++; |
istrip++; |
660 |
}; |
}; |
661 |
}; |
}; |
726 |
memcpy(ca->npcfit,clevel2->npcfit,sizeof(clevel2->npcfit)); |
memcpy(ca->npcfit,clevel2->npcfit,sizeof(clevel2->npcfit)); |
727 |
}; |
}; |
728 |
// |
// |
729 |
|
if(!(ca->CaloTrk))ca->CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
730 |
TClonesArray &t = *ca->CaloTrk; |
TClonesArray &t = *ca->CaloTrk; |
731 |
new(t[nutrk]) CaloTrkVar(*t_ca); |
new(t[nutrk]) CaloTrkVar(*t_ca); |
732 |
// |
// |
739 |
calol2cm(); |
calol2cm(); |
740 |
} |
} |
741 |
|
|
742 |
void CaloProcessing::FillCommonVar(CaloLevel2 *ca){ |
void CaloProcessing::FillCommonVar(CaloLevel1 *c1, CaloLevel2 *ca){ |
743 |
// |
// |
744 |
ca->good = clevel2->good; |
ca->good = clevel2->good; |
745 |
if ( clevel2->trigty == 2. ){ |
if ( clevel2->trigty == 2. ){ |
750 |
memcpy(ca->perr,clevel2->perr,sizeof(clevel2->perr)); |
memcpy(ca->perr,clevel2->perr,sizeof(clevel2->perr)); |
751 |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
memcpy(ca->swerr,clevel2->swerr,sizeof(clevel2->swerr)); |
752 |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
memcpy(ca->crc,clevel2->crc,sizeof(clevel2->crc)); |
|
ca->estrip = TArrayF(0,svstrip); |
|
753 |
ca->nstrip = (Int_t)clevel2->nstrip; |
ca->nstrip = (Int_t)clevel2->nstrip; |
754 |
ca->qtot = clevel2->qtot; |
ca->qtot = clevel2->qtot; |
755 |
ca->impx = clevel2->impx; |
ca->impx = clevel2->impx; |
761 |
ca->qmax = clevel2->qmax; |
ca->qmax = clevel2->qmax; |
762 |
ca->elen = clevel2->elen; |
ca->elen = clevel2->elen; |
763 |
ca->selen = clevel2->selen; |
ca->selen = clevel2->selen; |
|
ca->estrip = TArrayF(ca->nstrip,svstrip); |
|
764 |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
765 |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
766 |
memcpy(ca->varcfit,clevel2->varcfit,sizeof(clevel2->varcfit)); |
memcpy(ca->varcfit,clevel2->varcfit,sizeof(clevel2->varcfit)); |
768 |
memcpy(ca->cibar,clevel2->cibar,sizeof(clevel2->cibar)); |
memcpy(ca->cibar,clevel2->cibar,sizeof(clevel2->cibar)); |
769 |
memcpy(ca->cbar,clevel2->cbar,sizeof(clevel2->cbar)); |
memcpy(ca->cbar,clevel2->cbar,sizeof(clevel2->cbar)); |
770 |
// |
// |
771 |
|
if ( c1 ){ |
772 |
|
c1->istrip = istrip; |
773 |
|
c1->estrip = TArrayI(istrip,svstrip); |
774 |
|
}; |
775 |
|
// |
776 |
} |
} |
777 |
|
|
778 |
void CaloProcessing::ClearStructs(){ |
void CaloProcessing::ClearStructs(){ |