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 |
223 |
for (Int_t k = 0; k < 22; k++ ){ |
for (Int_t k = 0; k < 22; k++ ){ |
224 |
for (Int_t l = 0; l < 96; l++ ){ |
for (Int_t l = 0; l < 96; l++ ){ |
225 |
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
226 |
|
if ( verbose ) printf(" %f \n",mip[m][k][l]); |
227 |
}; |
}; |
228 |
}; |
}; |
229 |
}; |
}; |
231 |
}; |
}; |
232 |
// |
// |
233 |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
if ( calopar2 || ( ttcalopar2 != 0 && ttcalopar2 < runheader ) ){ |
234 |
|
if ( debug ) printf(" calopar2 %i ftcalopar2 %u ttcalopar2 %u runheader %u \n",calopar2,ftcalopar2,ttcalopar2,runheader); |
235 |
calopar2 = false; |
calopar2 = false; |
236 |
// |
// |
237 |
// determine where I can find calorimeter alignment file |
// determine where I can find calorimeter alignment file |
247 |
ftcalopar2 = glparam->FROM_TIME; |
ftcalopar2 = glparam->FROM_TIME; |
248 |
ttcalopar2 = glparam->TO_TIME; |
ttcalopar2 = glparam->TO_TIME; |
249 |
// |
// |
250 |
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()); |
251 |
f = fopen(aligfile.str().c_str(),"rb"); |
f = fopen(aligfile.str().c_str(),"rb"); |
252 |
if ( !f ){ |
if ( !f ){ |
253 |
if ( verbose ) printf(" CALORIMETER - ERROR: no alignement file!\n"); |
if ( verbose ) printf(" CALORIMETER - ERROR: no parameter file!\n"); |
254 |
return(-106); |
return(-106); |
255 |
}; |
}; |
256 |
// |
// |
257 |
fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); |
if ( !mechal ){ |
258 |
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
// |
259 |
fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); |
fread(&clevel1->xalig,sizeof(clevel1->xalig),1,f); |
260 |
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
261 |
fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); |
fread(&clevel1->yalig,sizeof(clevel1->yalig),1,f); |
262 |
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
263 |
|
fread(&clevel1->zalig,sizeof(clevel1->zalig),1,f); |
264 |
|
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
265 |
|
} else { |
266 |
|
if ( verbose ) printf("\n Using MECHANICAL alignement parameters \n"); |
267 |
|
// |
268 |
|
CaloStrip cs = CaloStrip(); |
269 |
|
cs.UseMechanicalAlig(); |
270 |
|
clevel1->xalig = cs.GetXalig(); |
271 |
|
if ( debug ) printf(" xalig = %f \n",clevel1->xalig); |
272 |
|
clevel1->yalig = cs.GetYalig(); |
273 |
|
if ( debug ) printf(" yalig = %f \n",clevel1->yalig); |
274 |
|
clevel1->zalig = cs.GetZalig(); |
275 |
|
if ( debug ) printf(" zalig = %f \n",clevel1->zalig); |
276 |
|
// |
277 |
|
Float_t tmp = 0; |
278 |
|
fread(&tmp,sizeof(clevel1->xalig),1,f); |
279 |
|
fread(&tmp,sizeof(clevel1->yalig),1,f); |
280 |
|
fread(&tmp,sizeof(clevel1->zalig),1,f); |
281 |
|
// |
282 |
|
}; |
283 |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
fread(&clevel1->emin,sizeof(clevel1->emin),1,f); |
284 |
if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); |
if ( debug ) printf(" signal threshold = %f \n",clevel1->emin); |
285 |
// |
// |
289 |
// Load offline bad strip mask |
// Load offline bad strip mask |
290 |
// |
// |
291 |
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
if ( calopar3 || ( ttcalopar3 != 0 && ttcalopar3 < runheader ) ){ |
292 |
|
if ( debug ) printf(" calopar3 %i ftcalopar3 %u ttcalopar3 %u runheader %u \n",calopar3,ftcalopar3,ttcalopar3,runheader); |
293 |
calopar3 = false; |
calopar3 = false; |
294 |
// |
// |
295 |
// determine where I can find calorimeter alignment file |
// determine where I can find calorimeter alignment file |
460 |
for (Int_t l = 0; l < 2; l++){ |
for (Int_t l = 0; l < 2; l++){ |
461 |
for (Int_t m = 0; m < 22; m++){ |
for (Int_t m = 0; m < 22; m++){ |
462 |
// |
// |
463 |
// determine the section number |
// determine the section number |
464 |
// |
// |
465 |
se = 5; |
se = 5; |
466 |
if (l == 0 && m%2 == 0) se = 3; |
if (l == 0 && m%2 == 0) se = 3; |
467 |
if (l == 0 && m%2 != 0) se = 2; |
if (l == 0 && m%2 != 0) se = 2; |
468 |
if (l == 1 && m%2 == 0) se = 1; |
if (l == 1 && m%2 != 0) se = 1; |
469 |
if (l == 1 && m%2 != 0) se = 0; |
if (l == 1 && m%2 == 0) se = 0; |
470 |
// |
// |
471 |
// determine what kind of event we are going to analyze |
// determine what kind of event we are going to analyze |
472 |
// |
// |
560 |
} else { |
} else { |
561 |
ip[i] = pre - 1; |
ip[i] = pre - 1; |
562 |
}; |
}; |
563 |
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 ) ){ |
564 |
// |
// |
565 |
ck = 2; |
ck = 2; |
566 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
574 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
575 |
// |
// |
576 |
if ( !doneb ){ |
if ( !doneb ){ |
577 |
|
if ( debug ) printf(" ck is %i \n",ck); |
578 |
switch (ck) { |
switch (ck) { |
579 |
case 0: |
case 0: |
580 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
581 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
582 |
|
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
583 |
break; |
break; |
584 |
case 1: |
case 1: |
585 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
586 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
587 |
|
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]]); |
588 |
break; |
break; |
589 |
case 2: |
case 2: |
590 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
591 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
592 |
|
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
593 |
break; |
break; |
594 |
case 3: |
case 3: |
595 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
596 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
597 |
|
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
598 |
break; |
break; |
599 |
}; |
}; |
600 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
604 |
ener0 += ener; |
ener0 += ener; |
605 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
606 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
607 |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
// if ( !donec && (base0 - base1 + base2) != 0. ){ |
608 |
sbase[l][m][pre] = base0 - base1 + base2; |
// sbase[l][m][pre] = base0 - base1 + base2; |
609 |
|
if ( !donec && (base0 + base1 - base2) != 0. ){ |
610 |
|
sbase[l][m][pre] = base0 + base1 - base2; |
611 |
donec = 1; |
donec = 1; |
612 |
}; |
}; |
613 |
if ( ener > 0. ){ |
if ( ener > 0. ){ |
616 |
// 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) |
617 |
// |
// |
618 |
qpre[pre] += clevel1->estrip[n][m][l]; |
qpre[pre] += clevel1->estrip[n][m][l]; |
619 |
|
// |
620 |
|
// |
621 |
}; |
}; |
622 |
}; |
}; |
623 |
}; |
}; |