4 #include <prototype2/RawTower_Temperature.h>
5 #include <prototype2/RawTower_Prototype2.h>
6 #include <calobase/RawTowerContainer.h>
7 #include <pdbcalbase/PdbParameterMap.h>
8 #include <phparameter/PHParameters.h>
30 #include <TLorentzVector.h>
48 SubsysReco(
"Proto2ShowerCalib"), _is_sim(
false), _filename(filename), _ievent(
65 for (
int row = 0; row <
n_size; ++row)
86 <<
"Proto2ShowerCalib::get_HistoManager - Making Fun4AllHistoManager Proto2ShowerCalib_HISTOS"
101 cout <<
"Proto2ShowerCalib::InitRun" << endl;
107 "PHCompositeNode",
"DST"));
110 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
112 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
121 cout <<
"Proto2ShowerCalib::End - write to " <<
_filename << endl;
126 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
143 cout <<
"Proto2ShowerCalib::get_HistoManager - Making PHTFileServer "
152 TH2F * hCheck_Cherenkov =
new TH2F(
"hCheck_Cherenkov",
"hCheck_Cherenkov",
153 1000, -2000, 2000, 5, .5, 5.5);
154 hCheck_Cherenkov->GetYaxis()->SetBinLabel(1,
"C1");
155 hCheck_Cherenkov->GetYaxis()->SetBinLabel(2,
"C2 in");
156 hCheck_Cherenkov->GetYaxis()->SetBinLabel(3,
"C2 out");
157 hCheck_Cherenkov->GetYaxis()->SetBinLabel(4,
"C2 sum");
160 TH1F *
hNormalization =
new TH1F(
"hNormalization",
"hNormalization", 10, .5,
162 hCheck_Cherenkov->GetXaxis()->SetBinLabel(1,
"ALL");
163 hCheck_Cherenkov->GetXaxis()->SetBinLabel(2,
"C2-e");
164 hCheck_Cherenkov->GetXaxis()->SetBinLabel(3,
"trigger_veto_pass");
165 hCheck_Cherenkov->GetXaxis()->SetBinLabel(4,
"valid_hodo_h");
166 hCheck_Cherenkov->GetXaxis()->SetBinLabel(5,
"valid_hodo_v");
167 hCheck_Cherenkov->GetXaxis()->SetBinLabel(6,
"good_e");
168 hCheck_Cherenkov->GetXaxis()->SetBinLabel(7,
"good_data");
171 hm->
registerHisto(
new TH1F(
"hCheck_Veto",
"hCheck_Veto", 1000, -500, 500));
173 new TH1F(
"hCheck_Hodo_H",
"hCheck_Hodo_H", 1000, -500, 500));
175 new TH1F(
"hCheck_Hodo_V",
"hCheck_Hodo_V", 1000, -500, 500));
177 hm->
registerHisto(
new TH1F(
"hBeam_Mom",
"hBeam_Mom", 1200, -120, 120));
179 hm->
registerHisto(
new TH2F(
"hEoP",
"hEoP", 1000, 0, 1.5, 120, .5, 120.5));
181 hm->
registerHisto(
new TH1F(
"hTemperature",
"hTemperature", 500, 0, 50));
184 TTree *
T =
new TTree(
"T",
"T");
206 cout <<
"Proto2ShowerCalib::process_event() entered" << endl;
234 TH1F * hBeam_Mom =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hBeam_Mom"));
240 EventHeader* eventheader = findNode::getClass<EventHeader>(topNode,
281 hNormalization->Fill(
"ALL", 1);
284 topNode, _is_sim ?
"TOWER_RAW_LG_CEMC" :
"TOWER_RAW_CEMC");
287 topNode, _is_sim ?
"TOWER_CALIB_LG_CEMC" :
"TOWER_CALIB_CEMC");
295 assert(TOWER_CALIB_TRIGGER_VETO);
302 assert(TOWER_CALIB_HODO_HORIZONTAL);
308 assert(TOWER_CALIB_HODO_VERTICAL);
315 assert(TOWER_TEMPERATURE_EMCAL);
319 topNode,
"TOWER_CALIB_C1");
325 topNode,
"TOWER_CALIB_C2");
332 bool cherekov_e =
false;
341 t_c2_in = TOWER_CALIB_C2->
getTower(10);
342 t_c2_out = TOWER_CALIB_C2->
getTower(11);
346 t_c2_in = TOWER_CALIB_C2->
getTower(0);
347 t_c2_out = TOWER_CALIB_C2->
getTower(1);
358 hNormalization->Fill(
"C2-e", cherekov_e);
360 TH2F * hCheck_Cherenkov =
dynamic_cast<TH2F *
>(hm->
getHisto(
361 "hCheck_Cherenkov"));
363 hCheck_Cherenkov->Fill(c1,
"C1", 1);
364 hCheck_Cherenkov->Fill(c2_in,
"C2 in", 1);
365 hCheck_Cherenkov->Fill(c2_out,
"C2 out", 1);
366 hCheck_Cherenkov->Fill(c2_in + c2_out,
"C2 sum", 1);
370 TH1F * hCheck_Veto =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Veto"));
372 bool trigger_veto_pass =
true;
375 auto range = TOWER_CALIB_TRIGGER_VETO->
getTowers();
376 for (
auto it = range.first;
it != range.second; ++
it)
384 trigger_veto_pass =
false;
387 hNormalization->Fill(
"trigger_veto_pass", trigger_veto_pass);
391 TH1F * hCheck_Hodo_H =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_H"));
393 int hodo_h_count = 0;
396 auto range = TOWER_CALIB_HODO_HORIZONTAL->
getTowers();
397 for (
auto it = range.first;
it != range.second; ++
it)
411 const bool valid_hodo_h = hodo_h_count == 1;
412 hNormalization->Fill(
"valid_hodo_h", valid_hodo_h);
415 TH1F * hCheck_Hodo_V =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_V"));
417 int hodo_v_count = 0;
420 auto range = TOWER_CALIB_HODO_VERTICAL->
getTowers();
421 for (
auto it = range.first;
it != range.second; ++
it)
435 const bool valid_hodo_v = hodo_v_count == 1;
437 hNormalization->Fill(
"valid_hodo_v", valid_hodo_v);
439 const bool good_e = (valid_hodo_v and valid_hodo_h and cherekov_e
440 and trigger_veto_pass) and (not _is_sim);
441 hNormalization->Fill(
"good_e", good_e);
444 pair<int, int> max_3x3 =
find_max(TOWER_CALIB_CEMC, 3);
445 pair<int, int> max_5x5 =
find_max(TOWER_CALIB_CEMC, 5);
466 bool good_temp =
true;
467 double sum_energy_calib = 0;
468 double sum_energy_T = 0;
469 TH1F * hTemperature =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hTemperature"));
479 auto range = TOWER_CALIB_CEMC->
getTowers();
480 for (
auto it = range.first;
it != range.second; ++
it)
490 if (col < 0 or col >= 8)
492 if (row < 0 or row >= 8)
495 const double energy_calib = tower->
get_energy();
496 sum_energy_calib += energy_calib;
511 hTemperature->Fill(T);
513 if (T < 25 or T > 35)
522 const double energy_recalib = energy_T
526 sum_energy_T += energy_T;
531 if (col >= max_5x5.first - 2 and col <= max_5x5.first + 2
532 and row >= max_5x5.second - 2 and row <= max_5x5.second + 2)
542 if (col >= max_3x3.first - 1 and col <= max_3x3.first + 1)
543 if (row >= max_3x3.second - 1 and row <= max_3x3.second + 1)
565 if (col >= max_5x5.first - 2 and col <= max_5x5.first + 2)
566 if (row >= max_5x5.second - 2 and row <= max_5x5.second + 2)
599 hNormalization->Fill(
"good_temp", good_temp);
601 bool good_data = good_e and good_temp;
602 hNormalization->Fill(
"good_data", good_data);
614 cout << __PRETTY_FUNCTION__ <<
" sum_energy_calib = "
615 << sum_energy_calib <<
" sum_energy_T = " << sum_energy_T
618 TH2F * hEoP =
dynamic_cast<TH2F *
>(hm->
getHisto(
"hEoP"));
630 fdata << sdata.str();
635 TTree *
T =
dynamic_cast<TTree *
>(hm->
getHisto(
"T"));
645 const int clus_edge_size = (cluster_size - 1) / 2;
646 assert(clus_edge_size >= 0);
648 pair<int, int> max(-1000, -1000);
652 for (
int row = 0; row <
n_size; ++row)
656 for (
int dcol =
col - clus_edge_size; dcol <=
col + clus_edge_size;
658 for (
int drow = row - clus_edge_size; drow <= row + clus_edge_size;
661 if (dcol < 0 or drow < 0)
671 max = make_pair(
col, row);
684 cout << __PRETTY_FUNCTION__ <<
" - input recalibration constant from "
688 ifstream fcalib(file);
694 while (not fcalib.eof())
696 getline(fcalib, line);
700 cout << __PRETTY_FUNCTION__ <<
" get line " << line << endl;
702 istringstream sline(line);
708 sline >> col >> row >> calib;
710 if (not sline.fail())
714 cout << __PRETTY_FUNCTION__ <<
" - recalibration constant "
715 << col <<
"," << row <<
" = " << calib << endl;