3 #include <prototype2/RawTower_Prototype2.h>
4 #include <calobase/RawTowerContainer.h>
5 #include <pdbcalbase/PdbParameterMap.h>
6 #include <phparameter/PHParameters.h>
24 #include <TLorentzVector.h>
43 SubsysReco(
"Proto2ShowerCalib"), _filename(filename), _ievent(0)
89 <<
"Proto2ShowerCalib::get_HistoManager - Making Fun4AllHistoManager Proto2ShowerCalib_HISTOS"
104 cout <<
"Proto2ShowerCalib::InitRun" << endl;
110 "PHCompositeNode",
"DST"));
113 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
115 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
124 cout <<
"Proto2ShowerCalib::End - write to " <<
_filename << endl;
129 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
146 cout <<
"Proto2ShowerCalib::get_HistoManager - Making PHTFileServer "
155 TH2F * hCheck_Cherenkov =
new TH2F(
"hCheck_Cherenkov",
"hCheck_Cherenkov",
156 1000, -2000, 2000, 5, .5, 5.5);
157 hCheck_Cherenkov->GetYaxis()->SetBinLabel(1,
"C1");
158 hCheck_Cherenkov->GetYaxis()->SetBinLabel(2,
"C2 in");
159 hCheck_Cherenkov->GetYaxis()->SetBinLabel(3,
"C2 out");
160 hCheck_Cherenkov->GetYaxis()->SetBinLabel(4,
"C2 sum");
163 TH1F *
hNormalization =
new TH1F(
"hNormalization",
"hNormalization", 10, .5,
165 hCheck_Cherenkov->GetXaxis()->SetBinLabel(1,
"ALL");
166 hCheck_Cherenkov->GetXaxis()->SetBinLabel(2,
"C2-e");
167 hCheck_Cherenkov->GetXaxis()->SetBinLabel(3,
"C2-h");
168 hCheck_Cherenkov->GetXaxis()->SetBinLabel(4,
"trigger_veto_pass");
169 hCheck_Cherenkov->GetXaxis()->SetBinLabel(5,
"valid_hodo_h");
170 hCheck_Cherenkov->GetXaxis()->SetBinLabel(6,
"valid_hodo_v");
171 hCheck_Cherenkov->GetXaxis()->SetBinLabel(7,
"good_e");
172 hCheck_Cherenkov->GetXaxis()->SetBinLabel(8,
"good_h");
175 hm->
registerHisto(
new TH1F(
"hCheck_Veto",
"hCheck_Veto", 1000, -500, 500));
177 new TH1F(
"hCheck_Hodo_H",
"hCheck_Hodo_H", 1000, -500, 500));
179 new TH1F(
"hCheck_Hodo_V",
"hCheck_Hodo_V", 1000, -500, 500));
181 hm->
registerHisto(
new TH1F(
"hBeam_Mom",
"hBeam_Mom", 1200, -120, 120));
183 hm->
registerHisto(
new TH2F(
"hEoP",
"hEoP", 1000, 0, 1.5, 120, .5, 120.5));
185 hm->
registerHisto(
new TH1F(
"hTemperature",
"hTemperature", 500, 0, 50));
188 TTree *
T =
new TTree(
"T",
"T");
204 cout <<
"Proto2ShowerCalib::process_event() entered" << endl;
221 run_info_copy.FillFrom(info);
225 TH1F * hBeam_Mom =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hBeam_Mom"));
231 EventHeader* eventheader = findNode::getClass<EventHeader>(topNode,
244 TH1F * hNormalization =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hNormalization"));
247 hNormalization->Fill(
"ALL", 1);
265 TOWER_RAW_CEMC = findNode::getClass<RawTowerContainer>(
266 topNode,
"TOWER_RAW_CEMC");
268 TOWER_RAW_CEMC = findNode::getClass<RawTowerContainer>(
269 topNode,
"TOWER_RAW_LG_CEMC");
276 TOWER_CALIB_CEMC = findNode::getClass<RawTowerContainer>(
277 topNode,
"TOWER_CALIB_CEMC");
279 TOWER_CALIB_CEMC = findNode::getClass<RawTowerContainer>(
280 topNode,
"TOWER_CALIB_LG_CEMC");
288 TOWER_RAW_LG_HCALIN = findNode::getClass<RawTowerContainer>(
289 topNode,
"TOWER_RAW_LG_HCALIN");
290 TOWER_RAW_HG_HCALIN= findNode::getClass<RawTowerContainer>(
291 topNode,
"TOWER_RAW_HG_HCALIN");
292 assert(TOWER_RAW_LG_HCALIN);
293 assert(TOWER_RAW_HG_HCALIN);
299 TOWER_CALIB_HCALIN = findNode::getClass<RawTowerContainer>(
300 topNode,
"TOWER_CALIB_LG_HCALIN");
302 TOWER_CALIB_HCALIN = findNode::getClass<RawTowerContainer>(
303 topNode,
"TOWER_CALIB_LG_HCALIN");
305 assert(TOWER_CALIB_HCALIN);
311 TOWER_RAW_LG_HCALOUT = findNode::getClass<RawTowerContainer>(
312 topNode,
"TOWER_RAW_LG_HCALOUT");
313 TOWER_RAW_HG_HCALOUT = findNode::getClass<RawTowerContainer>(
314 topNode,
"TOWER_RAW_HG_HCALOUT");
315 assert(TOWER_RAW_LG_HCALOUT);
316 assert(TOWER_RAW_HG_HCALOUT);
320 topNode,
"TOWER_CALIB_LG_HCALOUT");
321 assert(TOWER_CALIB_HCALOUT);
328 topNode,
"TOWER_CALIB_C1");
331 topNode,
"TOWER_CALIB_C2");
334 if(!
_is_sim && TOWER_CALIB_C2 && TOWER_CALIB_C1 && eventheader)
342 t_c2_in = TOWER_CALIB_C2->getTower(10);
343 t_c2_out = TOWER_CALIB_C2->getTower(11);
347 t_c2_in = TOWER_CALIB_C2->getTower(0);
348 t_c2_out = TOWER_CALIB_C2->getTower(1);
360 hNormalization->Fill(
"C2-e", cherekov_e);
363 hNormalization->Fill(
"C2-h", cherekov_h);
365 TH2F * hCheck_Cherenkov =
dynamic_cast<TH2F *
>(hm->
getHisto(
366 "hCheck_Cherenkov"));
368 hCheck_Cherenkov->Fill(c1,
"C1", 1);
369 hCheck_Cherenkov->Fill(c2_in,
"C2 in", 1);
370 hCheck_Cherenkov->Fill(c2_out,
"C2 out", 1);
371 hCheck_Cherenkov->Fill(c2_in + c2_out,
"C2 sum", 1);
374 TH1F * hCheck_Veto =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Veto"));
376 bool trigger_veto_pass =
true;
378 auto range = TOWER_CALIB_TRIGGER_VETO->
getTowers();
379 for (
auto it = range.first;
it != range.second; ++
it)
387 trigger_veto_pass =
false;
390 hNormalization->Fill(
"trigger_veto_pass", trigger_veto_pass);
394 TH1F * hCheck_Hodo_H =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_H"));
396 int hodo_h_count = 0;
398 auto range = TOWER_CALIB_HODO_HORIZONTAL->getTowers();
399 for (
auto it = range.first;
it != range.second; ++
it)
413 const bool valid_hodo_h = hodo_h_count == 1;
414 hNormalization->Fill(
"valid_hodo_h", valid_hodo_h);
417 TH1F * hCheck_Hodo_V =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_V"));
419 int hodo_v_count = 0;
421 auto range = TOWER_CALIB_HODO_VERTICAL->getTowers();
422 for (
auto it = range.first;
it != range.second; ++
it)
436 const bool valid_hodo_v = hodo_v_count == 1;
438 hNormalization->Fill(
"valid_hodo_v", valid_hodo_v);
440 const bool good_e = valid_hodo_v and valid_hodo_h and cherekov_e and trigger_veto_pass;
442 const bool good_h = valid_hodo_v and valid_hodo_h and cherekov_h and trigger_veto_pass;
444 hNormalization->Fill(
"good_e", good_e);
445 hNormalization->Fill(
"good_h", good_h);
453 double emcal_sum_energy_calib = 0;
454 double emcal_sum_energy_recalib = 0;
456 double hcalin_sum_energy_calib = 0;
457 double hcalin_sum_energy_recalib = 0;
459 double hcalout_sum_energy_calib = 0;
460 double hcalout_sum_energy_recalib = 0;
466 auto range = TOWER_CALIB_CEMC->
getTowers();
467 for (
auto it = range.first;
it != range.second; ++
it)
474 const double energy_calib = tower->
get_energy();
475 emcal_sum_energy_calib += energy_calib;
479 const int row = tower->
get_row();
484 const double energy_recalib = energy_calib
488 emcal_sum_energy_recalib += energy_recalib;
494 auto range = TOWER_CALIB_HCALIN->
getTowers();
495 for (
auto it = range.first;
it != range.second; ++
it)
500 const double energy_calib = tower->
get_energy();
501 hcalin_sum_energy_calib += energy_calib;
505 const int row = tower->
get_row();
509 const double energy_recalib = energy_calib
512 hcalin_sum_energy_recalib += energy_recalib;
518 auto range = TOWER_CALIB_HCALOUT->
getTowers();
519 for (
auto it = range.first;
it != range.second; ++
it)
524 const double energy_calib = tower->
get_energy();
525 hcalout_sum_energy_calib += energy_calib;
529 const int row = tower->
get_row();
533 const double energy_recalib = energy_calib
536 hcalout_sum_energy_recalib += energy_recalib;
547 cout << __PRETTY_FUNCTION__ <<
" sum_energy_calib = "
548 << emcal_sum_energy_calib <<
" sum_energy_recalib = " << emcal_sum_energy_recalib
551 TH2F * hEoP =
dynamic_cast<TH2F *
>(hm->
getHisto(
"hEoP"));
559 fdata << sdata.str();
565 _shower.
sum_e = emcal_sum_energy_calib + hcalin_sum_energy_calib + hcalout_sum_energy_calib ;
566 _shower.
hcal_asym = (hcalin_sum_energy_calib - hcalout_sum_energy_calib)/(hcalin_sum_energy_calib + hcalout_sum_energy_calib);
571 _shower.
sum_e_recal = emcal_sum_energy_recalib + hcalin_sum_energy_recalib + hcalout_sum_energy_recalib ;
578 auto range = TOWER_RAW_LG_HCALIN->
getTowers();
579 for (
auto it = range.first;
it != range.second; ++
it)
587 for(
int isample=0; isample<24; isample++)
596 auto range = TOWER_RAW_LG_HCALOUT->
getTowers();
597 for (
auto it = range.first;
it != range.second; ++
it)
605 for(
int isample=0; isample<24; isample++)
614 auto range = TOWER_RAW_CEMC->getTowers();
615 for (
auto it = range.first;
it != range.second; ++
it)
623 for(
int isample=0; isample<24; isample++)
631 TTree * T =
dynamic_cast<TTree *
>(hm->
getHisto(
"T"));
643 cout << __PRETTY_FUNCTION__ <<
" - input recalibration constant from "
647 ifstream fcalib(file);
653 while (not fcalib.eof())
655 getline(fcalib, line);
659 cout << __PRETTY_FUNCTION__ <<
" get line " << line << endl;
661 istringstream sline(line);
667 sline >> col >> row >> calib;
669 if (not sline.fail())
673 cout << __PRETTY_FUNCTION__ <<
" - recalibration constant "
674 << col <<
"," << row <<
" = " << calib << endl;