3 #include <prototype3/RawTower_Prototype3.h>
4 #include <calobase/RawTowerContainer.h>
5 #include <pdbcalbase/PdbParameterMap.h>
6 #include <phparameter/PHParameters.h>
28 #include <TLorentzVector.h>
47 SubsysReco(
"Proto3ShowerCalib"), _filename(filename), _ievent(0)
73 smearing =
new TF1(
"smearing",
"gaus(0)", 0, 2);
113 <<
"Proto3ShowerCalib::get_HistoManager - Making Fun4AllHistoManager Proto3ShowerCalib_HISTOS"
128 cout <<
"Proto3ShowerCalib::InitRun" << endl;
134 "PHCompositeNode",
"DST"));
137 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
139 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
148 cout <<
"Proto3ShowerCalib::End - write to " <<
_filename << endl;
153 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
170 cout <<
"Proto3ShowerCalib::get_HistoManager - Making PHTFileServer "
179 TH2F * hCheck_Cherenkov =
new TH2F(
"hCheck_Cherenkov",
"hCheck_Cherenkov",
180 1000, -2000, 2000, 5, .5, 5.5);
181 hCheck_Cherenkov->GetYaxis()->SetBinLabel(1,
"C1");
182 hCheck_Cherenkov->GetYaxis()->SetBinLabel(2,
"C2 in");
183 hCheck_Cherenkov->GetYaxis()->SetBinLabel(3,
"C2 out");
184 hCheck_Cherenkov->GetYaxis()->SetBinLabel(4,
"C2 sum");
187 TH1F *
hNormalization =
new TH1F(
"hNormalization",
"hNormalization", 10, .5,
189 hCheck_Cherenkov->GetXaxis()->SetBinLabel(1,
"ALL");
190 hCheck_Cherenkov->GetXaxis()->SetBinLabel(2,
"C2-e");
191 hCheck_Cherenkov->GetXaxis()->SetBinLabel(3,
"C2-h");
192 hCheck_Cherenkov->GetXaxis()->SetBinLabel(4,
"trigger_veto_pass");
193 hCheck_Cherenkov->GetXaxis()->SetBinLabel(5,
"valid_hodo_h");
194 hCheck_Cherenkov->GetXaxis()->SetBinLabel(6,
"valid_hodo_v");
195 hCheck_Cherenkov->GetXaxis()->SetBinLabel(7,
"good_e");
196 hCheck_Cherenkov->GetXaxis()->SetBinLabel(8,
"good_h");
199 hm->
registerHisto(
new TH1F(
"hCheck_Veto",
"hCheck_Veto", 1000, -500, 500));
201 new TH1F(
"hCheck_Hodo_H",
"hCheck_Hodo_H", 1000, -500, 500));
203 new TH1F(
"hCheck_Hodo_V",
"hCheck_Hodo_V", 1000, -500, 500));
205 hm->
registerHisto(
new TH1F(
"hBeam_Mom",
"hBeam_Mom", 1200, -120, 120));
207 hm->
registerHisto(
new TH2F(
"hEoP",
"hEoP", 1000, 0, 1.5, 120, .5, 120.5));
209 hm->
registerHisto(
new TH1F(
"hTemperature",
"hTemperature", 500, 0, 50));
212 TTree *
T =
new TTree(
"T",
"T");
230 cout <<
"Proto3ShowerCalib::process_event() entered" << endl;
247 run_info_copy.FillFrom(info);
251 TH1F * hBeam_Mom =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hBeam_Mom"));
257 EventHeader* eventheader = findNode::getClass<EventHeader>(topNode,
270 TH1F * hNormalization =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hNormalization"));
273 hNormalization->Fill(
"ALL", 1);
293 hcalin_slats = findNode::getClass<PHG4ScintillatorSlatContainer>(topNode, cellnodename.c_str());
294 if(!hcalin_slats) cout <<
"HCALIN slats not found" << endl;
296 cellnodename =
"G4CELL_HCALOUT";
297 hcalout_slats = findNode::getClass<PHG4ScintillatorSlatContainer>(topNode, cellnodename.c_str());
298 if(!hcalout_slats) cout <<
"HCALOUT slats not found" << endl;
302 TOWER_RAW_CEMC = findNode::getClass<RawTowerContainer>(
303 topNode,
"TOWER_RAW_CEMC");
309 TOWER_CALIB_CEMC = findNode::getClass<RawTowerContainer>(
310 topNode,
"TOWER_CALIB_CEMC");
312 TOWER_CALIB_CEMC = findNode::getClass<RawTowerContainer>(
313 topNode,
"TOWER_SIM_CEMC");
321 TOWER_RAW_LG_HCALIN = findNode::getClass<RawTowerContainer>(
322 topNode,
"TOWER_RAW_LG_HCALIN");
323 TOWER_RAW_HG_HCALIN= findNode::getClass<RawTowerContainer>(
324 topNode,
"TOWER_RAW_HG_HCALIN");
325 assert(TOWER_RAW_LG_HCALIN);
326 assert(TOWER_RAW_HG_HCALIN);
332 TOWER_CALIB_HCALIN = findNode::getClass<RawTowerContainer>(
333 topNode,
"TOWER_CALIB_LG_HCALIN");
335 TOWER_CALIB_HCALIN = findNode::getClass<RawTowerContainer>(
336 topNode,
"TOWER_SIM_HCALIN");
338 assert(TOWER_CALIB_HCALIN);
344 TOWER_RAW_LG_HCALOUT = findNode::getClass<RawTowerContainer>(
345 topNode,
"TOWER_RAW_LG_HCALOUT");
346 TOWER_RAW_HG_HCALOUT = findNode::getClass<RawTowerContainer>(
347 topNode,
"TOWER_RAW_HG_HCALOUT");
348 assert(TOWER_RAW_LG_HCALOUT);
349 assert(TOWER_RAW_HG_HCALOUT);
355 TOWER_CALIB_HCALOUT = findNode::getClass<RawTowerContainer>(
356 topNode,
"TOWER_CALIB_LG_HCALOUT");
358 TOWER_CALIB_HCALOUT = findNode::getClass<RawTowerContainer>(
359 topNode,
"TOWER_SIM_HCALOUT");
361 assert(TOWER_CALIB_HCALOUT);
368 topNode,
"TOWER_CALIB_C1");
371 topNode,
"TOWER_CALIB_C2");
374 if(!
_is_sim && TOWER_CALIB_C2 && TOWER_CALIB_C1 && eventheader)
382 t_c2_in = TOWER_CALIB_C2->getTower(10);
383 t_c2_out = TOWER_CALIB_C2->getTower(11);
387 t_c2_in = TOWER_CALIB_C2->getTower(0);
388 t_c2_out = TOWER_CALIB_C2->getTower(1);
400 hNormalization->Fill(
"C2-e", cherekov_e);
403 hNormalization->Fill(
"C2-h", cherekov_h);
405 TH2F * hCheck_Cherenkov =
dynamic_cast<TH2F *
>(hm->
getHisto(
406 "hCheck_Cherenkov"));
408 hCheck_Cherenkov->Fill(c1,
"C1", 1);
409 hCheck_Cherenkov->Fill(c2_in,
"C2 in", 1);
410 hCheck_Cherenkov->Fill(c2_out,
"C2 out", 1);
411 hCheck_Cherenkov->Fill(c2_in + c2_out,
"C2 sum", 1);
414 TH1F * hCheck_Veto =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Veto"));
416 bool trigger_veto_pass =
true;
418 auto range = TOWER_CALIB_TRIGGER_VETO->
getTowers();
419 for (
auto it = range.first;
it != range.second; ++
it)
427 trigger_veto_pass =
false;
430 hNormalization->Fill(
"trigger_veto_pass", trigger_veto_pass);
434 TH1F * hCheck_Hodo_H =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_H"));
436 int hodo_h_count = 0;
438 auto range = TOWER_CALIB_HODO_HORIZONTAL->getTowers();
439 for (
auto it = range.first;
it != range.second; ++
it)
453 const bool valid_hodo_h = hodo_h_count == 1;
454 hNormalization->Fill(
"valid_hodo_h", valid_hodo_h);
457 TH1F * hCheck_Hodo_V =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_V"));
459 int hodo_v_count = 0;
461 auto range = TOWER_CALIB_HODO_VERTICAL->getTowers();
462 for (
auto it = range.first;
it != range.second; ++
it)
476 const bool valid_hodo_v = hodo_v_count == 1;
478 hNormalization->Fill(
"valid_hodo_v", valid_hodo_v);
480 const bool good_e = valid_hodo_v and valid_hodo_h and cherekov_e and trigger_veto_pass;
482 const bool good_h = valid_hodo_v and valid_hodo_h and cherekov_h and trigger_veto_pass;
484 hNormalization->Fill(
"good_e", good_e);
485 hNormalization->Fill(
"good_h", good_h);
493 double emcal_sum_energy_calib = 0;
494 double emcal_sum_energy_recalib = 0;
496 double hcalin_sum_energy_calib = 0;
497 double hcalin_sum_energy_recalib = 0;
499 double hcalout_sum_energy_calib = 0;
500 double hcalout_sum_energy_recalib = 0;
506 auto range = TOWER_CALIB_CEMC->
getTowers();
507 for (
auto it = range.first;
it != range.second; ++
it)
514 const double energy_calib = tower->
get_energy();
515 emcal_sum_energy_calib += energy_calib;
519 const int row = tower->
get_row();
524 const double energy_recalib = energy_calib
528 emcal_sum_energy_recalib += energy_recalib;
535 double hcalin_slats_edep = 0.;
536 double hcalin_slats_ly = 0.;
537 double hcalout_slats_edep = 0.;
538 double hcalout_slats_ly = 0.;
540 auto range = hcalin_slats->getScintillatorSlats();
541 for(
auto it=range.first;
it!=range.second; ++
it)
549 for(
auto it=range.first;
it!=range.second; ++
it)
564 auto range = TOWER_CALIB_HCALIN->
getTowers();
565 for (
auto it = range.first;
it != range.second; ++
it)
570 const double energy_calib = tower->
get_energy();
571 hcalin_sum_energy_calib += energy_calib;
575 const int row = tower->
get_row();
580 const double energy_recalib = energy_calib
583 hcalin_sum_energy_recalib += energy_recalib;
589 auto range = TOWER_CALIB_HCALOUT->
getTowers();
590 for (
auto it = range.first;
it != range.second; ++
it)
595 const double energy_calib = tower->
get_energy();
596 hcalout_sum_energy_calib += energy_calib;
600 const int row = tower->
get_row();
605 const double energy_recalib = energy_calib
608 hcalout_sum_energy_recalib += energy_recalib;
620 cout << __PRETTY_FUNCTION__ <<
" sum_energy_calib = "
621 << emcal_sum_energy_calib <<
" sum_energy_recalib = " << emcal_sum_energy_recalib
624 TH2F * hEoP =
dynamic_cast<TH2F *
>(hm->
getHisto(
"hEoP"));
632 sdata << emcal_sum_energy_calib <<
"; " << hcalin_sum_energy_calib <<
"; " << hcalout_sum_energy_calib <<
"; " <<
_eval_run.
good_e <<
"; " <<
_eval_run.
good_h;
633 fdata << sdata.str();
639 _shower.
sum_e = emcal_sum_energy_calib + hcalin_sum_energy_calib + hcalout_sum_energy_calib ;
640 _shower.
hcal_asym = (hcalin_sum_energy_calib - hcalout_sum_energy_calib)/(hcalin_sum_energy_calib + hcalout_sum_energy_calib);
645 _shower.
sum_e_recal = emcal_sum_energy_recalib + hcalin_sum_energy_recalib + hcalout_sum_energy_recalib ;
652 auto range = TOWER_RAW_LG_HCALIN->
getTowers();
653 for (
auto it = range.first;
it != range.second; ++
it)
661 for(
int isample=0; isample<24; isample++)
670 auto range = TOWER_RAW_LG_HCALOUT->
getTowers();
671 for (
auto it = range.first;
it != range.second; ++
it)
679 for(
int isample=0; isample<24; isample++)
688 auto range = TOWER_RAW_CEMC->
getTowers();
689 for (
auto it = range.first;
it != range.second; ++
it)
697 for(
int isample=0; isample<24; isample++)
705 TTree * T =
dynamic_cast<TTree *
>(hm->
getHisto(
"T"));
717 cout << __PRETTY_FUNCTION__ <<
" - input recalibration constant from "
721 ifstream fcalib(file);
727 while (not fcalib.eof())
729 getline(fcalib, line);
733 cout << __PRETTY_FUNCTION__ <<
" get line " << line << endl;
735 istringstream sline(line);
741 sline >> col >> row >> calib;
743 if (not sline.fail())
747 cout << __PRETTY_FUNCTION__ <<
" - recalibration constant "
748 << col <<
"," << row <<
" = " << calib << endl;