5 cout<<
"<hcalHelper::hcalHelper> Wrong instantiation sequence - hLabHelper already exists. EXITING"<<endl;
33 for(
int istk = 0; istk<
CALSTACKS; istk++) {
38 for(
int ich = 0; ich < chtocp; ich++) {
49 cout<<
"<hcalHelper::hcalHelper>: "<<ACTIVECHANNELS<<
" Channels Initialized"<<endl;
50 rdata =
new TH2F(
"rdata",
"Raw Peak Values for all active channels",ACTIVECHANNELS, 0, ACTIVECHANNELS, 1024, -2048., 2048.);
80 hlHelper -> setPRDFRun(
runnumber, kFALSE);
81 hlHelper -> makeCanvasDirectory();
90 cout <<
"<evLoop> Couldn't open input file " << hlHelper->
prdfName << endl;
98 t1044 -> readyForEvent = kFALSE;
112 if(sp21101&&sp21102){
122 delete sp21101;
delete sp21102;
124 cout <<
"EventSeq " <<
eventseq <<
" type = " << evt->
getEvtType() <<
" Missing packets " <<(int)sp21101<<
"/"<<(
int)sp21102<<endl;
131 for (
int istk = 0; istk<
CALSTACKS; istk++){
138 adc[iadc][is] =
adc[iadc][is]-2048.;
140 adc[iadc][is] = (
activeCh[iadc]%2? -(
adc[iadc][is]-2048.) :
adc[iadc][is]-2048.);
158 eventReject = rejectST*1000 + rejectCR*100 + rejectCL;
167 if(std::cin.
get()==113)
break;
179 hlHelper -> thcl ->
Write();
180 hlHelper -> fhcl ->
Write();
197 cout<<
"<hcalHelper::setDisplayMode> Mode is set to "<<
displayMode<<endl;
204 cout<<
"<hcalHelper::setCTriggerOn> triggerOn is set to "<<
triggerOn<<endl;
212 cout<<
"<hcalHelper::setDCTriggerGRange> Gaine is set to "<<
triggerGain<<endl;
232 for(
int istk = 0; istk<
CALSTACKS; istk++){
240 Int_t iss = max((fTime-2), 1);
241 Double_t psum(0.);
float sUsed(0.);
242 for (
int is = 0; is<iss; is++) {
if(
adc[ich][is]>=
undflow&&
adc[ich][is]<=
ovrflow) {psum +=
adc[ich][is]; sUsed += 1.;}}
244 if(sUsed) psum /= sUsed;
else psum=0.;
245 Double_t rVal =
adc[ich][fTime] - psum;
343 for(
int istk = 0; istk<
CALSTACKS; istk++) {
350 TString totaN =
"tota";
351 TString totaT =
"Total Amplitude in Calorimeter System";
352 totalamp =
new TH1F(totaN, totaT, 10000, 0., 10000.);
353 TString toteN =
"tote";
354 TString toteT =
"Total Energy in Calorimeter System";
355 totale =
new TH1F(toteN, toteT, 1000, 0., 60.);
356 TString tlcgN =
"tlcg";
357 TString tlcgT =
"Shower Center of gravity (units of Stacks)";
358 totallcg =
new TH1F(tlcgN, tlcgT, 200, 0., 2.);
359 TString sclcgN =
"sclcg";
360 TString sclcgT =
"Shower Center in scintillators (units of Stacks)";
361 scintlcg =
new TH1F(sclcgN, sclcgT, 200, 0., 2.);
368 for(
int istk = 0; istk<
CALSTACKS; istk++){
369 if(!
alive[istk])
continue;
372 if(stacks[istk]->stackKind ==
CALOR) {
373 for (
int itw=0; itw< stacks[istk]->twrsInStack; itw++) {
374 stacks[istk]->towers[itw]->twrECalib =
stECalib[stacks[istk]->stackId];
376 stacks[istk]->towers[itw]->twrEScale = 1.;
395 for(
int istk = 0; istk<
CALSTACKS; istk++){
396 if(!
stacks[istk])
continue;
410 for(
int istk = 0; istk<
CALSTACKS; istk++){
411 if(!
stacks[istk])
continue;
415 accept += triggerFlag*pow(100,
stacks[istk]->stackId);
426 for(
int istk = 0; istk<
CALSTACKS; istk++){
427 if(!
stacks[istk])
continue;
434 for(
int istk = 0; istk<
CALSTACKS; istk++){
446 if(!
alive[SCINT])
return 0;
448 for (
int sc = 0; sc<3; sc++){
459 if(!mode || mode>2)
return;
460 for(
int istk = 0; istk<
CALSTACKS; istk++){
461 if(!
stacks[istk])
continue;
464 if(mode==1||(mode==2&&
stacks[istk]->stackKind==
CALOR)) {
477 for(
int istk = 0; istk<
CALSTACKS; istk++){
478 if(!
stacks[istk])
continue;
483 TString csN =
"csSum";
484 TString csT =
"Calorimeter Summary for Run "; csT += hHelper->
runnumber;
485 calSum = (TCanvas *)(gROOT->FindObject(csN));
486 if(!calSum) calSum =
new TCanvas(csN, csT, 50, 50, 500, 250);
487 else calSum->Clear();
488 calSum -> SetEditable(kTRUE);
489 calSum -> Divide(4,1);
501 TString satsN =
"satsum";
502 TString satsT =
"Saturation in Calorimeters Run "; satsT += hHelper->
runnumber;
503 satSum = (TCanvas *)(gROOT->FindObject(satsN));
504 if(!satSum) satSum =
new TCanvas(satsN, satsT, 50, 50, 600, 400);
505 else satSum->Clear();
507 for(
int istk=0; istk<
CALSTACKS; istk++) {
509 if(
stacks[istk]->stackId==EMC) {
511 satSum -> GetPad(1)->SetLogy();
516 if(
stacks[istk]->stackId==HINNER) {
518 satSum -> GetPad(3)->SetLogy();
521 satSum -> GetPad(4)->SetLogy();
524 if(
stacks[istk]->stackId==HOUTER) {
526 satSum -> GetPad(5)->SetLogy();
529 satSum -> GetPad(6)->SetLogy();
536 cName +=
"calSum_"; cName += hHelper->
runnumber; cName +=
".gif";
537 calSum->SaveAs(cName);
538 cName = hlHelper->
cDirectory; cName +=
"satSum_"; cName += hHelper->
runnumber; cName +=
".gif";
539 satSum->SaveAs(cName);
545 for(
int istk = 0; istk<
CALSTACKS; istk++){
546 if(!
stacks[istk])
continue;
584 for (
int ig = 0; ig<
gains; ig++){
587 TString gT =
"Stack "; gT +=
stackId; gT += (ig==0?
" HIGH " :
" LOW "); gT +=
"gain";
590 TString
sum =
"adcsum_"; sum += (ig==
HIGH)?
"HG" :
"LG";
591 TString sig =
"signal_"; sig += (ig==
HIGH)?
"HG" :
"LG";
604 Float_t maxPedSum = 400.;
605 Float_t maxAmpSum = 16000.;
606 TString stfpN =
"st_fped"; stfpN +=
stackId;
607 TString stfpT =
"Stack "; stfpT +=
stackId; stfpT +=
" Pedestals - Fit [LG]";
608 stFPed =
new TH1F(stfpN, stfpT, 100, -maxPedSum, maxPedSum);
609 TString stfaN =
"st_famp"; stfaN +=
stackId;
610 TString stfaT =
"Stack "; stfaT +=
stackId; stfaT +=
" Amplitudes - Fit [LG]";
611 stFAmpl =
new TH1F(stfaN, stfaT, 550, -0.1*maxAmpSum, maxAmpSum);
612 TString stftN =
"st_ftime"; stftN +=
stackId;
613 TString stftT =
"Stack "; stftT +=
stackId; stftT +=
" Time - Fit [ADC ticks]";
615 TString stc2N =
"st_c2"; stc2N +=
stackId;
616 TString stc2T =
"Stack "; stc2T +=
stackId; stc2T +=
" Fit Chi2 ";
617 stChi2 =
new TH1F(stc2N, stc2T, 100, 0., 200.);
618 TString stgrN =
"st_gr"; stgrN +=
stackId;
619 TString stgrT =
"Stack "; stgrT +=
stackId; stgrT +=
" Ratio HG/LG ";
620 stFGR =
new TH1F(stgrN, stgrT, 100, -20., 20.);
624 TString stspN =
"st_sped"; stspN +=
stackId;
625 TString stspT =
"Stack "; stspT +=
stackId; stspT +=
" Stack Pedestals Sum [LG]";
626 stSPed =
new TH1F(stspN, stspT, 100, -maxPedSum, maxPedSum);
627 TString stsaN =
"st_samp"; stsaN +=
stackId;
628 TString stsaT =
"Stack "; stsaT +=
stackId; stsaT +=
" Stack Amplitude Sum [LG]";
629 stSAmpl =
new TH1F(stsaN, stsaT, 550, -0.1*maxAmpSum, maxAmpSum);
630 TString stseN =
"st_sen"; stseN +=
stackId;
631 TString stseT =
"Stack "; stseT +=
stackId; stseT +=
" Stack Energy Sum [MeV]";
632 stSE =
new TH1F(stseN, stseT, 1100, -5., 50.);
633 TString ststN =
"st_stime"; ststN +=
stackId;
634 TString ststT =
"Stack "; ststT +=
stackId; ststT +=
" <Stack Time> [clock ticks]";
636 TString ststsN =
"st_stsig"; ststsN +=
stackId;
637 TString ststsT =
"Stack "; ststsT +=
stackId; ststsT +=
" Time - RMS [clock ticks]";
640 TString hitCGN =
"hitSt"; hitCGN +=
stackId;
641 TString hitCGT =
"Stack "; hitCGT +=
stackId; hitCGT +=
" Impact X vs Y [towers]";
645 for(
int ig=0; ig<
gains; ig++) {
646 TString satN =
"stsat"; satN +=
stackId; satN += ig;
647 TString satT =
"Stack "; satT +=
stackId; satT += ig==0?
" HG " :
" LG "; satT +=
"saturation probability vs # of sat. samples";
648 satProb[ig] =
new TH1F(satN, satT, 25, 0., 25.);
654 TString trAmpN =
"trAmp"; trAmpN +=
stackId;
655 TString trAmpT =
"Stack "; trAmpT +=
stackId; trAmpT +=
" Track Amplitude";
656 trAmp =
new TH1F(trAmpN, trAmpT, 300, 0., 300.);
657 TString trCh2N =
"trCh2"; trCh2N +=
stackId;
658 TString trCh2T =
"Stack "; trCh2T +=
stackId; trCh2T +=
" Track Chi2";
659 trChi2 =
new TH1F(trCh2N, trCh2T, 100, 0., 10.);
660 TString trCrN =
"trCr"; trCrN +=
stackId;
661 TString trCrT =
"Stack "; trCrT +=
stackId; trAmpT +=
" Track Crossing";
662 trCr =
new TH1F(trCrN, trCrT, 40, 0., 4.);
663 TString trSlN =
"trSl"; trSlN +=
stackId;
664 TString trSlT =
"Stack "; trSlT +=
stackId; trAmpT +=
" Track Slope";
665 trSl =
new TH1F(trSlN, trSlT, 50, -1., 1.);
666 TString trACh2N =
"trACh2"; trACh2N +=
stackId;
667 TString trACh2T =
"Stack "; trACh2T +=
stackId; trACh2T +=
" Track Amplitude vs Chi2";
668 trAmpCh2 =
new TH2F(trACh2N, trACh2T, 300, 0, 300, 100, 0., 2.);
669 TString trAstHN =
"trAstH"; trAstHN +=
stackId;
670 TString trAstHT =
"Stack "; trAstHT +=
stackId; trAstHT +=
" Track Amplitude vs # of Hits in Stack";
671 trAstH =
new TH2F(trAstHN, trAstHT,300, 0, 300, 100, 0., 16.);
672 TString trASlN =
"trASl"; trASlN +=
stackId;
673 TString trASlT =
"Stack "; trASlT +=
stackId; trASlT +=
" Track Amplitude vs # Track Slope";
674 trASl =
new TH2F(trASlN, trASlT, 300, 0, 300, 100, 0., 1.);
680 Float_t amplimit = 100;
682 TString trATwrN =
"trATwrN"; trATwrN +=
stackId;
683 TString trATwrT =
"Stack "; trATwrT +=
stackId; trATwrT +=
" Tagged Twr Amplitude vs Twr # ";
684 trATwr =
new TH2F(trATwrN, trATwrT, nx, 0, 100, twrsInStack, 0., twrsInStack);
722 if(!mode || mode>2)
return;
724 TCanvas * pattern[2];
725 for(
int ig = 0; ig <
gains; ig++){
726 TString stckN =
"StPat"; stckN +=
stackId; stckN +=
"_G_"; stckN += ig;
727 TString stckT =
"Stack "; stckT +=
stackId; stckT += (ig==
HIGH)?
" HGain" :
" LGain"; stckT +=
" Event Pattern Display Run "; stckT += hHelper->
runnumber;
728 pattern[ig] = (TCanvas *)(gROOT->FindObject(stckN));
730 else pattern[ig]->Clear();
731 pattern[ig] -> SetEditable(kTRUE);
737 pattern[ig] ->
cd(ipad);
744 pattern[ig]->Update();
748 TString slN =
"st"; slN +=
stackId; slN +=
"_G_"; slN += ig;
749 TString slT =
"Mixed Amplitudes [LG] in Stack "; slT +=
stackId;
750 if(!(stackLego = (TH2F*) (gROOT->FindObject(slN)))) stackLego =
new TH2F(slN, slT,
nTwrsX, 0,
nTwrsX,
nTwrsY, 0,
nTwrsY);
756 stackLego ->
Draw(
"lego");
757 pattern[ig]->Update();
770 TString cTAN =
"rtA_st"; cTAN +=
stackId;
771 TString cTAT =
"Stack "; cTAT +=
stackId; cTAT +=
" Hit Amplitudes in Towers [LG units] Run "; cTAT += hHelper->
runnumber;
772 corTwrsA = (TCanvas *)(gROOT->FindObject(cTAN));
774 else corTwrsA->Clear();
775 corTwrsA -> SetEditable(kTRUE);
779 corTwrsA ->
cd(ipad);
780 corTwrsA -> GetPad(ipad)->SetLogy();
793 cName +=
"corTwrsA_"; cName += hHelper->
runnumber; cName +=
".gif";
794 corTwrsA->SaveAs(cName);
805 TCanvas * stackSum(NULL), * muTracks(NULL);
806 TString stN =
"stSum"; stN +=
stackId;
807 TString stT =
"Stack "; stT +=
stackId; stT +=
" Summary for Run "; stT += hHelper->
runnumber;
808 stackSum = (TCanvas *)(gROOT->FindObject(stN));
809 if(!stackSum) stackSum =
new TCanvas(stN, stT, 50*
stackId, 50*
stackId, 400, 400);
810 else stackSum->Clear();
811 stackSum -> SetEditable(kTRUE);
812 stackSum -> Divide(4,2);
818 stackSum -> GetPad(6)->SetLogy();
823 stackSum -> GetPad(8)->SetLogy();
829 stackSum -> GetPad(2)->SetLogy();
839 for (
int ig=0; ig<
gains; ig++) {
847 cName +=
"stackSum_"; cName +=
stackId; cName +=
"_"; cName += hHelper->
runnumber; cName +=
".gif";
848 stackSum->SaveAs(cName);
850 if(hlHelper->
runKind ==
"cosmics"){
851 TString muN =
"muTr"; muN +=
stackId;
852 TString muT =
"Stack "; muT +=
stackId; muT +=
" Cosmic Muons in Run "; muT += hHelper->
runnumber;
853 muTracks = (TCanvas *)(gROOT->FindObject(muN));
854 if(!muTracks) muTracks =
new TCanvas(muN, muT, 50*
stackId, 50*
stackId, 400, 400);
855 else muTracks->Clear();
856 muTracks -> SetEditable(kTRUE);
857 muTracks -> Divide(3,2);
871 muTracks -> Update();
875 cName +=
"muTracks_"; cName +=
stackId; cName +=
"_"; cName += hHelper->
runnumber; cName +=
".gif";
876 muTracks->SaveAs(cName);
886 TString stckN =
"StEvS"; stckN +=
stackId;
887 TString stckT =
"Stack "; stckT +=
stackId; stckT +=
" Stack Event Sum Display Run "; stckT += hHelper->
runnumber;
888 TCanvas * stckEvSumDisplay = (TCanvas *)(gROOT->FindObject(stckN));
889 if(!stckEvSumDisplay) stckEvSumDisplay =
new TCanvas(stckN, stckT, 25*
stackId, 25*
stackId, 600, 400);
890 else stckEvSumDisplay->Clear();
891 stckEvSumDisplay -> Divide(1,
gains);
892 for(
int ig = 0; ig <
gains; ig++){
893 stckEvSumDisplay->cd(ig+1);
899 graph[ig]->SetMarkerStyle(20);
900 graph[ig]->SetMarkerSize(0.4);
901 graph[ig]->Draw(
"acp");
903 shape[ig]->Draw(
"same");
908 stckEvSumDisplay->Update();
911 cName +=
"stackEvSum_"; cName +=
stackId; cName +=
"_"; cName += hHelper->
runnumber; cName +=
".gif";
912 stckEvSumDisplay->SaveAs(cName);
933 cout<<
"<stack::updateMap> Already updated - EXIT"<<endl;
965 for(
int ig = 0; ig<
gains; ig++){
998 for(
int ig = 0; ig <
gains; ig++){
1003 if(
towers[itw]->satFlag[ig]>2)
continue;
1005 for(
int is = 0; is <
NSAMPLES; is++)
1009 for (
int is = 0; is <
NSAMPLES; is++)
1016 Double_t rVal, rTime;
1018 Int_t rMaxVal =
adcsum[ig][iss]; Int_t maxsmpl = iss;
1019 Int_t rMinVal =
adcsum[ig][iss]; Int_t minsmpl = iss;
1021 for (
int is = iss; is<=ise; is++) {
1022 if(
adcsum[ig][is]>rMaxVal) {
1023 rMaxVal =
adcsum[ig][is];
1026 if(
adcsum[ig][is]<rMinVal) {
1027 rMinVal =
adcsum[ig][is];
1031 if(abs(rMinVal) > abs(rMaxVal)) {
1032 rVal = rMinVal; rTime = minsmpl;
1034 rVal = rMaxVal; rTime = maxsmpl;
1045 shape[ig]->SetParameters(par0);
1048 shape[ig]->SetParLimits(4, -256., 256.);
1049 shape[ig]->SetParLimits(5, -0.5, 0.5);
1055 signal[ig]->SetParameter(4, 0.);
1056 signal[ig]->SetParameter(5, 0.);
1109 double sxw(0.), syw(0.), sw(0.);
1124 return twrsInStack - used;
1133 double ixs(0.), iys(0.), ix2s(0.), iy2s(0.), ixys(0.);
1140 hits[
r] = 0; Double_t hitAmpl = 0.;
1142 int itw = nTwrsX*
r+
c;
1152 Float_t
x = (Float_t)
towers[hits[
r]]->x;
1153 Float_t
y = (Float_t)
towers[hits[
r]]->y;
1175 Float_t
x = (Float_t)
towers[itw]->x;
1176 Float_t
y = (Float_t)
towers[itw]->y;
1177 float est(0.), estx(0.), esty(0.);
1179 est = abs((y - x/slope+
crossing/slope)/sqrt(pow(1./slope,2)+1.));
1186 est = sqrt(estx*estx+esty*esty)/2;
1198 if(abs(slope)<0.45||abs(slope)>0.55) {
1227 for (
int ig = 0; ig<
gains; ig++){
1228 for (
int is=0; is<
NSAMPLES; is++) {
1273 for(
int ig = 0; ig <
gains; ig++) {
1276 title +=
"("; title +=
x; title +=
"/"; title +=
y; title +=
") ";
1277 title += (ig==
HIGH)?
" HGain" :
" LGain";
1278 TString sig =
"sig_"; sig += (ig==
HIGH)?
"HG_" :
"LG_";
1280 TString shp =
"shp_"; shp += (ig==
HIGH)?
"HG_" :
"LG_";
1282 graph[ig]->SetTitle(title);
1288 TString cpT =
"Stack "; cpT +=
stackId; cpT +=
" Tower "; cpT +=
index; cpT +=
" Mixed pedestals [LG]";
1289 twrPed =
new TH1F(cpN, cpT, 100, -5., 5.);
1291 TString caT =
"Stack "; caT +=
stackId; caT +=
" Tower "; caT +=
index; caT +=
" Mixed Amplitudes [LG]";
1292 twrAmpl =
new TH1F(caN, caT, 250, -50., 200.);
1293 TString ctN =
"twr_time"; ctN +=
stackId; ctN +=
index;
1294 TString ctT =
"Stack "; ctT +=
stackId; ctT +=
" Tower "; ctT +=
index; ctT +=
" Time [ADC ticks]";
1297 TString ceT =
"Stack "; ceT +=
stackId; ceT +=
" Tower "; ceT +=
index; ceT +=
" Energy [MeV]";
1298 twrE =
new TH1F(ceN, ceT, 250, -500., 20000.);
1374 TString twrT =
"Stack "; twrT +=
stackId; twrT +=
" Tower "; twrT +=
index; twrT +=
"Run "; twrT += hHelper->
runnumber;
1375 TCanvas * twrDisplay = (TCanvas *)(gROOT->FindObject(twrN));
1376 if(!twrDisplay) twrDisplay =
new TCanvas(twrN, twrT, 0, 0, 400, 400);
1377 else twrDisplay->Clear();
1378 twrDisplay -> Divide(2,2);
1379 for(
int ig=0; ig<
gains;ig++){
1380 twrDisplay ->
cd(ig*2+1);
1381 graph[ig]->SetMarkerStyle(20);
1382 graph[ig]->SetMarkerSize(0.4);
1383 graph[ig]->Draw(
"acp");
1384 twrDisplay ->
cd(ig*2+2);
1387 twrDisplay->Update();