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 ( debug ) 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 |
399 |
// |
// |
400 |
Int_t val = 0; |
Int_t val = 0; |
401 |
Int_t del = 1100; |
Int_t del = 1100; |
402 |
|
for (Int_t sec = 0; sec < 4; sec++){ |
403 |
|
for (Int_t dsec = 0; dsec < 7; dsec++){ |
404 |
|
val = (Int_t)de->calselftrig[sec][dsec]; |
405 |
|
del = delay(val); |
406 |
|
clevel2->selfdelay[sec][dsec] = del; |
407 |
|
}; |
408 |
|
}; |
409 |
|
val = 0; |
410 |
|
del = 1100; |
411 |
if ( clevel2->trigty != 2. ){ |
if ( clevel2->trigty != 2. ){ |
412 |
Bool_t ck = false; |
Bool_t ck = false; |
413 |
for (Int_t sec = 0; sec < 4; sec++){ |
for (Int_t sec = 0; sec < 4; sec++){ |
469 |
for (Int_t l = 0; l < 2; l++){ |
for (Int_t l = 0; l < 2; l++){ |
470 |
for (Int_t m = 0; m < 22; m++){ |
for (Int_t m = 0; m < 22; m++){ |
471 |
// |
// |
472 |
// determine the section number |
// determine the section number |
473 |
// |
// |
474 |
se = 5; |
se = 5; |
475 |
if (l == 0 && m%2 == 0) se = 3; |
if (l == 0 && m%2 == 0) se = 3; |
476 |
if (l == 0 && m%2 != 0) se = 2; |
if (l == 0 && m%2 != 0) se = 2; |
477 |
if (l == 1 && m%2 == 0) se = 1; |
if (l == 1 && m%2 != 0) se = 1; |
478 |
if (l == 1 && m%2 != 0) se = 0; |
if (l == 1 && m%2 == 0) se = 0; |
479 |
// |
// |
480 |
// determine what kind of event we are going to analyze |
// determine what kind of event we are going to analyze |
481 |
// |
// |
569 |
} else { |
} else { |
570 |
ip[i] = pre - 1; |
ip[i] = pre - 1; |
571 |
}; |
}; |
572 |
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 ) ){ |
573 |
// |
// |
574 |
ck = 2; |
ck = 2; |
575 |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
if ( sbase[l][m][pre] == 31000. || sbase[l][m][pre] == 0. ) { |
583 |
// CALIBRATION ALGORITHM |
// CALIBRATION ALGORITHM |
584 |
// |
// |
585 |
if ( !doneb ){ |
if ( !doneb ){ |
586 |
|
if ( debug ) printf(" ck is %i \n",ck); |
587 |
switch (ck) { |
switch (ck) { |
588 |
case 0: |
case 0: |
589 |
base0 = base[l][m][pre]; |
base0 = base[l][m][pre]; |
590 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
591 |
|
if ( debug ) printf(" base0 = base l m pre = %f base2 = calbase l m pre = %f \n",base[l][m][pre],calbase[l][m][pre]); |
592 |
break; |
break; |
593 |
case 1: |
case 1: |
594 |
base0 = base[l][m][ip[i]]; |
base0 = base[l][m][ip[i]]; |
595 |
base2 = calbase[l][m][ip[i]]; |
base2 = calbase[l][m][ip[i]]; |
596 |
|
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]]); |
597 |
break; |
break; |
598 |
case 2: |
case 2: |
599 |
base0 = sbase[l][m][pre]; |
base0 = sbase[l][m][pre]; |
600 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
601 |
|
if ( debug ) printf(" base0 = sbase l m pre = %f base2 = calbase l m pre = %f \n",sbase[l][m][pre],calbase[l][m][pre]); |
602 |
break; |
break; |
603 |
case 3: |
case 3: |
604 |
base0 = calbase[l][m][pre]; |
base0 = calbase[l][m][pre]; |
605 |
base2 = calbase[l][m][pre]; |
base2 = calbase[l][m][pre]; |
606 |
|
if ( debug ) printf(" base0 = calbase l m pre = %f base2 = calbase l m pre = %f \n",calbase[l][m][pre],calbase[l][m][pre]); |
607 |
break; |
break; |
608 |
}; |
}; |
609 |
base1 = calbase[l][m][pre]; |
base1 = calbase[l][m][pre]; |
613 |
ener0 += ener; |
ener0 += ener; |
614 |
clevel1->estrip[n][m][l] = 0.; |
clevel1->estrip[n][m][l] = 0.; |
615 |
if ( base0>0 && base0 < 30000. ){ |
if ( base0>0 && base0 < 30000. ){ |
616 |
if ( !donec && (base0 - base1 + base2) != 0. ){ |
// if ( !donec && (base0 - base1 + base2) != 0. ){ |
617 |
sbase[l][m][pre] = base0 - base1 + base2; |
// sbase[l][m][pre] = base0 - base1 + base2; |
618 |
|
if ( !donec && (base0 + base1 - base2) != 0. ){ |
619 |
|
sbase[l][m][pre] = base0 + base1 - base2; |
620 |
donec = 1; |
donec = 1; |
621 |
}; |
}; |
622 |
if ( ener > 0. ){ |
if ( ener > 0. ){ |
625 |
// 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) |
626 |
// |
// |
627 |
qpre[pre] += clevel1->estrip[n][m][l]; |
qpre[pre] += clevel1->estrip[n][m][l]; |
628 |
|
// |
629 |
|
// |
630 |
}; |
}; |
631 |
}; |
}; |
632 |
}; |
}; |
795 |
memcpy(t_ca->tibar,clevel2->cibar,sizeof(clevel2->cibar)); |
memcpy(t_ca->tibar,clevel2->cibar,sizeof(clevel2->cibar)); |
796 |
memcpy(t_ca->tbar,clevel2->cbar,sizeof(clevel2->cbar)); |
memcpy(t_ca->tbar,clevel2->cbar,sizeof(clevel2->cbar)); |
797 |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
798 |
|
memcpy(ca->selfdelay,clevel2->selfdelay,sizeof(clevel2->selfdelay)); |
799 |
ca->varcfit[2] = clevel2->varcfit[0]; |
ca->varcfit[2] = clevel2->varcfit[0]; |
800 |
ca->varcfit[3] = clevel2->varcfit[1]; |
ca->varcfit[3] = clevel2->varcfit[1]; |
801 |
ca->npcfit[2] = clevel2->npcfit[0]; |
ca->npcfit[2] = clevel2->npcfit[0]; |
848 |
ca->selen = clevel2->selen; |
ca->selen = clevel2->selen; |
849 |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
memcpy(ca->qq,clevel2->qq,sizeof(clevel2->qq)); |
850 |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
memcpy(ca->planemax,clevel2->planemax,sizeof(clevel2->planemax)); |
851 |
|
memcpy(ca->selfdelay,clevel2->selfdelay,sizeof(clevel2->selfdelay)); |
852 |
ca->varcfit[0] = clevel2->varcfit[0]; |
ca->varcfit[0] = clevel2->varcfit[0]; |
853 |
ca->varcfit[1] = clevel2->varcfit[1]; |
ca->varcfit[1] = clevel2->varcfit[1]; |
854 |
ca->npcfit[0] = clevel2->npcfit[0]; |
ca->npcfit[0] = clevel2->npcfit[0]; |
939 |
memset(clevel2->varcfit, 0, 4*sizeof(Float_t)); |
memset(clevel2->varcfit, 0, 4*sizeof(Float_t)); |
940 |
memset(clevel2->npcfit, 0, 4*sizeof(Int_t)); |
memset(clevel2->npcfit, 0, 4*sizeof(Int_t)); |
941 |
memset(clevel2->planemax, 0, 2*sizeof(Int_t)); |
memset(clevel2->planemax, 0, 2*sizeof(Int_t)); |
942 |
|
memset(clevel2->selfdelay, 0, 4*7*sizeof(Int_t)); |
943 |
memset(clevel2->fmode, 0, 2*sizeof(Int_t)); |
memset(clevel2->fmode, 0, 2*sizeof(Int_t)); |
944 |
memset(clevel2->cibar, 0, 2*22*sizeof(Int_t)); |
memset(clevel2->cibar, 0, 2*22*sizeof(Int_t)); |
945 |
memset(clevel2->cbar, 0, 2*22*sizeof(Float_t)); |
memset(clevel2->cbar, 0, 2*22*sizeof(Float_t)); |