4 #include <prototype3/RawTower_Temperature.h>
5 #include <prototype3/RawTower_Prototype3.h>
6 #include <calobase/RawTowerContainer.h>
7 #include <pdbcalbase/PdbParameterMap.h>
8 #include <phparameter/PHParameters.h>
30 #include <TLorentzVector.h>
48 SubsysReco(
"Proto3ShowerCalib"), _is_sim(
false), _filename(filename), _ievent(
65 for (
int row = 0; row <
n_size; ++row)
86 <<
"Proto3ShowerCalib::get_HistoManager - Making Fun4AllHistoManager Proto3ShowerCalib_HISTOS"
101 cout <<
"Proto3ShowerCalib::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 <<
"Proto3ShowerCalib::End - write to " <<
_filename << endl;
126 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
143 cout <<
"Proto3ShowerCalib::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 <<
"Proto3ShowerCalib::process_event() entered" << endl;
234 TH1F * hBeam_Mom =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hBeam_Mom"));
244 EventHeader* eventheader = findNode::getClass<EventHeader>(topNode,
286 hNormalization->Fill(
"ALL", 1);
289 topNode, _is_sim ?
"TOWER_RAW_LG_CEMC" :
"TOWER_RAW_CEMC");
292 topNode, _is_sim ?
"TOWER_CALIB_LG_CEMC" :
"TOWER_CALIB_CEMC");
300 assert(TOWER_CALIB_TRIGGER_VETO);
307 assert(TOWER_CALIB_HODO_HORIZONTAL);
313 assert(TOWER_CALIB_HODO_VERTICAL);
320 assert(TOWER_TEMPERATURE_EMCAL);
324 topNode,
"TOWER_CALIB_C1");
330 topNode,
"TOWER_CALIB_C2");
337 bool cherekov_e =
false;
346 t_c2_in = TOWER_CALIB_C2->
getTower(10);
347 t_c2_out = TOWER_CALIB_C2->
getTower(11);
351 t_c2_in = TOWER_CALIB_C2->
getTower(0);
352 t_c2_out = TOWER_CALIB_C2->
getTower(1);
364 hNormalization->Fill(
"C2-e", cherekov_e);
366 TH2F * hCheck_Cherenkov =
dynamic_cast<TH2F *
>(hm->
getHisto(
367 "hCheck_Cherenkov"));
369 hCheck_Cherenkov->Fill(c1,
"C1", 1);
370 hCheck_Cherenkov->Fill(c2_in,
"C2 in", 1);
371 hCheck_Cherenkov->Fill(c2_out,
"C2 out", 1);
372 hCheck_Cherenkov->Fill(c2_in + c2_out,
"C2 sum", 1);
376 TH1F * hCheck_Veto =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Veto"));
378 bool trigger_veto_pass =
true;
381 auto range = TOWER_CALIB_TRIGGER_VETO->
getTowers();
382 for (
auto it = range.first;
it != range.second; ++
it)
390 trigger_veto_pass =
false;
393 hNormalization->Fill(
"trigger_veto_pass", trigger_veto_pass);
397 TH1F * hCheck_Hodo_H =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_H"));
399 int hodo_h_count = 0;
402 auto range = TOWER_CALIB_HODO_HORIZONTAL->
getTowers();
403 for (
auto it = range.first;
it != range.second; ++
it)
417 const bool valid_hodo_h = hodo_h_count == 1;
418 hNormalization->Fill(
"valid_hodo_h", valid_hodo_h);
421 TH1F * hCheck_Hodo_V =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_V"));
423 int hodo_v_count = 0;
426 auto range = TOWER_CALIB_HODO_VERTICAL->
getTowers();
427 for (
auto it = range.first;
it != range.second; ++
it)
441 const bool valid_hodo_v = hodo_v_count == 1;
443 hNormalization->Fill(
"valid_hodo_v", valid_hodo_v);
445 const bool good_e = (valid_hodo_v and valid_hodo_h and cherekov_e
446 and trigger_veto_pass) and (not _is_sim);
447 hNormalization->Fill(
"good_e", good_e);
450 pair<int, int> max_3x3 =
find_max(TOWER_CALIB_CEMC, 3);
451 pair<int, int> max_5x5 =
find_max(TOWER_CALIB_CEMC, 5);
472 bool good_temp =
true;
473 double sum_energy_calib = 0;
474 double sum_energy_T = 0;
475 TH1F * hTemperature =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hTemperature"));
485 auto range = TOWER_CALIB_CEMC->
getTowers();
486 for (
auto it = range.first;
it != range.second; ++
it)
496 if (col < 0 or col >= 8)
498 if (row < 0 or row >= 8)
501 const double energy_calib = tower->
get_energy();
502 sum_energy_calib += energy_calib;
507 double energy_T = energy_calib;
528 const double energy_recalib = energy_T
532 sum_energy_T += energy_T;
537 if (col >= max_5x5.first - 1 and col <= max_5x5.first + 1
538 and row >= max_5x5.second - 1 and row <= max_5x5.second + 1)
548 if (col >= max_3x3.first - 1 and col <= max_3x3.first + 1)
549 if (row >= max_3x3.second - 1 and row <= max_3x3.second + 1)
571 if (col >= max_5x5.first - 2 and col <= max_5x5.first + 2)
572 if (row >= max_5x5.second - 2 and row <= max_5x5.second + 2)
605 hNormalization->Fill(
"good_temp", good_temp);
608 bool good_data = good_e;
609 hNormalization->Fill(
"good_data", good_data);
621 cout << __PRETTY_FUNCTION__ <<
" sum_energy_calib = "
622 << sum_energy_calib <<
" sum_energy_T = " << sum_energy_T
625 TH2F * hEoP =
dynamic_cast<TH2F *
>(hm->
getHisto(
"hEoP"));
641 fdata << sdata.str();
646 TTree *
T =
dynamic_cast<TTree *
>(hm->
getHisto(
"T"));
656 const int clus_edge_size = (cluster_size - 1) / 2;
657 assert(clus_edge_size >= 0);
659 pair<int, int> max(-1000, -1000);
663 for (
int row = 0; row <
n_size; ++row)
667 for (
int dcol =
col - clus_edge_size; dcol <=
col + clus_edge_size;
669 for (
int drow = row - clus_edge_size; drow <= row + clus_edge_size;
672 if (dcol < 0 or drow < 0)
682 max = make_pair(
col, row);
695 cout << __PRETTY_FUNCTION__ <<
" - input recalibration constant from "
699 ifstream fcalib(file);
705 while (not fcalib.eof())
707 getline(fcalib, line);
711 cout << __PRETTY_FUNCTION__ <<
" get line " << line << endl;
713 istringstream sline(line);
719 sline >> col >> row >> calib;
721 if (not sline.fail())
725 cout << __PRETTY_FUNCTION__ <<
" - recalibration constant "
726 << col <<
"," << row <<
" = " << calib << endl;