181 |
return(sgnl); |
return(sgnl); |
182 |
} |
} |
183 |
|
|
184 |
Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader){ |
Int_t CaloLevel0::ChkParam(TSQLServer *dbc, UInt_t runheader, Bool_t mechal){ |
185 |
stringstream calfile; |
stringstream calfile; |
186 |
stringstream bmfile; |
stringstream bmfile; |
187 |
stringstream aligfile; |
stringstream aligfile; |
191 |
GL_PARAM *glparam = new GL_PARAM(); |
GL_PARAM *glparam = new GL_PARAM(); |
192 |
// |
// |
193 |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
if ( calopar1 || ( ttcalopar1 != 0 && ttcalopar1 < runheader ) ){ |
194 |
|
// |
195 |
|
// |
196 |
|
// |
197 |
|
if ( debug ) printf(" calopar1 %i ftcalopar1 %u ttcalopar1 %u runheader %u \n",calopar1,ftcalopar1,ttcalopar1,runheader); |
198 |
|
// |
199 |
calopar1 = false; |
calopar1 = false; |
200 |
// |
// |
201 |
// determine where I can find calorimeter ADC to MIP conversion file |
// determine where I can find calorimeter ADC to MIP conversion file |
230 |
}; |
}; |
231 |
// |
// |
232 |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
233 |
|
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
234 |
calopar2 = false; |
calopar2 = false; |
235 |
// |
// |
236 |
// determine where I can find calorimeter alignment file |
// determine where I can find calorimeter alignment file |
246 |
ftcalopar2 = glparam->FROM_TIME; |
ftcalopar2 = glparam->FROM_TIME; |
247 |
ttcalopar2 = glparam->TO_TIME; |
ttcalopar2 = glparam->TO_TIME; |
248 |
// |
// |
249 |
if ( verbose ) printf("\n Using alignment file: \n %s \n",aligfile.str().c_str()); |
if ( verbose ) printf("\n Using parameter file: \n %s \n",aligfile.str().c_str()); |
250 |
f = fopen(aligfile.str().c_str(),"rb"); |
f = fopen(aligfile.str().c_str(),"rb"); |
251 |
if ( !f ){ |
if ( !f ){ |
252 |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: no parameter file!\n"); |
253 |
return(-106); |
return(-106); |
254 |
}; |
}; |
255 |
// |
// |
256 |
fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); |
if ( !mechal ){ |
257 |
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
// |
258 |
fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); |
fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); |
259 |
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
260 |
fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); |
fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); |
261 |
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
262 |
|
fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); |
263 |
|
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
264 |
|
} else { |
265 |
|
if ( verbose ) printf("\n Using MECHANICAL alignement parameters \n"); |
266 |
|
// |
267 |
|
CaloStrip cs = CaloStrip(); |
268 |
|
cs.UseMechanicalAlig(); |
269 |
|
clevel1->xalig = cs.GetXalig(); |
270 |
|
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
271 |
|
clevel1->yalig = cs.GetYalig(); |
272 |
|
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
273 |
|
clevel1->zalig = cs.GetZalig(); |
274 |
|
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
275 |
|
// |
276 |
|
Float_t tmp = 0; |
277 |
|
fread(&tmp,sizeof(clevel1->xalig),1,f); |
278 |
|
fread(&tmp,sizeof(clevel1->yalig),1,f); |
279 |
|
fread(&tmp,sizeof(clevel1->zalig),1,f); |
280 |
|
// |
281 |
|
}; |
282 |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
283 |
if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); |
if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); |
284 |
// |
// |
288 |
// Load offline bad strip mask |
// Load offline bad strip mask |
289 |
// |
// |
290 |
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
291 |
|
if ( debug ) printf(" calopar3 %i ftcalopar3 %u ttcalopar3 %u runheader %u \n",calopar3,ftcalopar3,ttcalopar3,runheader); |
292 |
calopar3 = false; |
calopar3 = false; |
293 |
// |
// |
294 |
// determine where I can find calorimeter alignment file |
// determine where I can find calorimeter alignment file |
459 |
for (Int_t l = 0; l < 2; l++){ |
for (Int_t l = 0; l < 2; l++){ |
460 |
for (Int_t m = 0; m < 22; m++){ |
for (Int_t m = 0; m < 22; m++){ |
461 |
// |
// |
462 |
// determine the section number |
// determine the section number |
463 |
// |
// |
464 |
se = 5; |
se = 5; |
465 |
if (l == 0 && m%2 == 0) se = 3; |
if (l == 0 && m%2 == 0) se = 3; |
466 |
if (l == 0 && m%2 != 0) se = 2; |
if (l == 0 && m%2 != 0) se = 2; |
467 |
if (l == 1 && m%2 == 0) se = 1; |
if (l == 1 && m%2 != 0) se = 1; |
468 |
if (l == 1 && m%2 != 0) se = 0; |
if (l == 1 && m%2 == 0) se = 0; |
469 |
// |
// |
470 |
// determine what kind of event we are going to analyze |
// determine what kind of event we are going to analyze |
471 |
// |
// |
559 |
} else { |
} else { |
560 |
ip[i] = pre - 1; |
ip[i] = pre - 1; |
561 |
}; |
}; |
562 |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0.) ){ |
if ( (base[l][m][ip[i]] == 31000. || base[l][m][ip[i]] == 0. || !crosst ) ){ |
563 |
// |
// |
564 |
ck = 2; |
ck = 2; |
565 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
573 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
574 |
// |
// |
575 |
if ( !doneb ){ |
if ( !doneb ){ |
576 |
|
if ( debug ) printf(" ck is %i \n",ck); |
577 |
switch (ck) { |
switch (ck) { |
578 |
case 0: |
case 0: |
579 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
580 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
581 |
|
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
582 |
break; |
break; |
583 |
case 1: |
case 1: |
584 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
585 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
586 |
|
if ( debug ) printf(" base0 = base l m ip(i) = %f base2 = calbase l m ip(i) = %f \n",base[l][m][ip[i]],calbase[l][m][ip[i]]); |
587 |
break; |
break; |
588 |
case 2: |
case 2: |
589 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
590 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
591 |
|
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
592 |
break; |
break; |
593 |
case 3: |
case 3: |
594 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
595 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
596 |
|
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
597 |
break; |
break; |
598 |
}; |
}; |
599 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
603 |
ener0 += ener; |
ener0 += ener; |
604 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
605 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
606 |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
// if ( !donec && (base0 - base1 + base2) != 0. ){ |
607 |
sbase[l][m][pre] = base0 - base1 + base2; |
// sbase[l][m][pre] = base0 - base1 + base2; |
608 |
|
if ( !donec && (base0 + base1 - base2) != 0. ){ |
609 |
|
sbase[l][m][pre] = base0 + base1 - base2; |
610 |
donec = 1; |
donec = 1; |
611 |
}; |
}; |
612 |
if ( ener > 0. ){ |
if ( ener > 0. ){ |
615 |
// 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) |
616 |
// |
// |
617 |
qpre[pre] += clevel1->estrip[n][m][l]; |
qpre[pre] += clevel1->estrip[n][m][l]; |
618 |
|
// |
619 |
|
// |
620 |
}; |
}; |
621 |
}; |
}; |
622 |
}; |
}; |