4 #include <Event/EventTypes.h>
5 #include <calobase/RawTowerContainer.h>
7 #include <pdbcalbase/PdbParameterMap.h>
8 #include <phparameter/PHParameters.h>
9 #include <prototype4/RawTower_Prototype4.h>
10 #include <prototype4/RawTower_Temperature.h>
29 #include <TLorentzVector.h>
69 for (
int row = 0; row <
n_size; ++row)
88 <<
"Proto4ShowerCalib::get_HistoManager - Making Fun4AllHistoManager Proto4ShowerCalib_HISTOS"
102 cout <<
"Proto4ShowerCalib::InitRun" << endl;
108 "PHCompositeNode",
"DST"));
111 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
113 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
121 cout <<
"Proto4ShowerCalib::End - write to " <<
_filename << endl;
126 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
141 cout <<
"Proto4ShowerCalib::get_HistoManager - Making PHTFileServer "
150 TH2F *hCheck_Cherenkov =
new TH2F(
"hCheck_Cherenkov",
"hCheck_Cherenkov",
151 1000, -2000, 2000, 5, .5, 5.5);
152 hCheck_Cherenkov->GetYaxis()->SetBinLabel(1,
"C1");
153 hCheck_Cherenkov->GetYaxis()->SetBinLabel(2,
"C2 in");
154 hCheck_Cherenkov->GetYaxis()->SetBinLabel(3,
"C2 out");
155 hCheck_Cherenkov->GetYaxis()->SetBinLabel(4,
"C2 sum");
158 TH1F *
hNormalization =
new TH1F(
"hNormalization",
"hNormalization", 10, .5,
160 hCheck_Cherenkov->GetXaxis()->SetBinLabel(1,
"ALL");
161 hCheck_Cherenkov->GetXaxis()->SetBinLabel(2,
"C2-e");
162 hCheck_Cherenkov->GetXaxis()->SetBinLabel(3,
"trigger_veto_pass");
163 hCheck_Cherenkov->GetXaxis()->SetBinLabel(4,
"valid_hodo_h");
164 hCheck_Cherenkov->GetXaxis()->SetBinLabel(5,
"valid_hodo_v");
165 hCheck_Cherenkov->GetXaxis()->SetBinLabel(6,
"good_e");
166 hCheck_Cherenkov->GetXaxis()->SetBinLabel(7,
"good_data");
169 hm->
registerHisto(
new TH1F(
"hCheck_Veto",
"hCheck_Veto", 1000, -10, 510));
171 new TH1F(
"hCheck_Hodo_H",
"hCheck_Hodo_H", 1000, -10, 10));
173 new TH1F(
"hCheck_Hodo_V",
"hCheck_Hodo_V", 1000, -10, 10));
175 hm->
registerHisto(
new TH1F(
"hBeam_Mom",
"hBeam_Mom", 1200, -120, 120));
177 hm->
registerHisto(
new TH2F(
"hEoP",
"hEoP", 1000, 0, 1.5, 120, .5, 120.5));
179 hm->
registerHisto(
new TH1F(
"hTemperature",
"hTemperature", 500, 0, 50));
182 TTree *
T =
new TTree(
"T",
"T");
203 cout <<
"Proto4ShowerCalib::process_event() entered" << endl;
232 TH1F *hBeam_Mom =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hBeam_Mom"));
242 EventHeader *eventheader = findNode::getClass<EventHeader>(topNode,
256 cout << __PRETTY_FUNCTION__
257 <<
" disgard this event: " << endl;
301 hNormalization->Fill(
"ALL", 1);
304 topNode, _is_sim ?
"TOWER_RAW_LG_CEMC" :
"TOWER_RAW_CEMC");
307 topNode, _is_sim ?
"TOWER_CALIB_LG_CEMC" :
"TOWER_CALIB_CEMC");
315 assert(TOWER_CALIB_TRIGGER_VETO);
322 assert(TOWER_CALIB_HODO_HORIZONTAL);
328 assert(TOWER_CALIB_HODO_VERTICAL);
339 topNode,
"TOWER_CALIB_C1");
345 topNode,
"TOWER_CALIB_C2");
352 bool cherekov_e =
false;
360 t_c2_in = TOWER_CALIB_C2->
getTower(0);
361 t_c2_out = TOWER_CALIB_C2->
getTower(1);
372 hNormalization->Fill(
"C2-e", cherekov_e);
374 TH2F *hCheck_Cherenkov =
dynamic_cast<TH2F *
>(hm->
getHisto(
375 "hCheck_Cherenkov"));
377 hCheck_Cherenkov->Fill(c1,
"C1", 1);
378 hCheck_Cherenkov->Fill(c2_in,
"C2 in", 1);
379 hCheck_Cherenkov->Fill(c2_out,
"C2 out", 1);
380 hCheck_Cherenkov->Fill(c2_in + c2_out,
"C2 sum", 1);
384 TH1F *hCheck_Veto =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Veto"));
386 bool trigger_veto_pass =
true;
389 auto range = TOWER_CALIB_TRIGGER_VETO->
getTowers();
390 for (
auto it = range.first;
it != range.second; ++
it)
398 trigger_veto_pass =
false;
401 hNormalization->Fill(
"trigger_veto_pass", trigger_veto_pass);
405 TH1F *hCheck_Hodo_H =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_H"));
407 int hodo_h_count = 0;
410 auto range = TOWER_CALIB_HODO_HORIZONTAL->
getTowers();
411 for (
auto it = range.first;
it != range.second; ++
it)
425 const bool valid_hodo_h = hodo_h_count == 1;
426 hNormalization->Fill(
"valid_hodo_h", valid_hodo_h);
429 TH1F *hCheck_Hodo_V =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hCheck_Hodo_V"));
431 int hodo_v_count = 0;
434 auto range = TOWER_CALIB_HODO_VERTICAL->
getTowers();
435 for (
auto it = range.first;
it != range.second; ++
it)
449 const bool valid_hodo_v = hodo_v_count == 1;
451 hNormalization->Fill(
"valid_hodo_v", valid_hodo_v);
453 const bool good_e = (valid_hodo_v and valid_hodo_h and cherekov_e and trigger_veto_pass) and (not _is_sim);
454 hNormalization->Fill(
"good_e", good_e);
461 pair<int, int> max_1x1 =
find_max(TOWER_CALIB_CEMC, 1);
462 pair<int, int> max_3x3 =
find_max(TOWER_CALIB_CEMC, 1);
463 pair<int, int> max_5x5 =
find_max(TOWER_CALIB_CEMC, 1);
487 bool good_temp =
true;
488 double sum_energy_calib = 0;
489 double sum_energy_T = 0;
490 TH1F *hTemperature =
dynamic_cast<TH1F *
>(hm->
getHisto(
"hTemperature"));
500 auto range = TOWER_CALIB_CEMC->
getTowers();
501 for (
auto it = range.first;
it != range.second; ++
it)
510 if (col < 0 or col >= 8)
512 if (row < 0 or row >= 8)
515 const double energy_calib = tower->
get_energy();
516 sum_energy_calib += energy_calib;
521 double energy_T = energy_calib;
542 const double energy_recalib = energy_T *
_recalib_const[make_pair(col, row)];
545 sum_energy_T += energy_T;
547 if (col == max_1x1.first)
548 if (row == max_1x1.second)
556 if (col >= max_3x3.first - 1 and col <= max_3x3.first + 1)
557 if (row >= max_3x3.second - 1 and row <= max_3x3.second + 1)
579 if (col >= max_5x5.first - 2 and col <= max_5x5.first + 2)
580 if (row >= max_5x5.second - 2 and row <= max_5x5.second + 2)
613 hNormalization->Fill(
"good_temp", good_temp);
618 hNormalization->Fill(
"good_data", good_data);
630 cout << __PRETTY_FUNCTION__ <<
" sum_energy_calib = "
631 << sum_energy_calib <<
" sum_energy_T = " << sum_energy_T
634 TH2F *hEoP =
dynamic_cast<TH2F *
>(hm->
getHisto(
"hEoP"));
647 auto range = TOWER_RAW_CEMC->
getTowers();
648 for (
auto it = range.first;
it != range.second; ++
it)
654 const int row = tower->
get_row();
656 if (col < 0 or col >= 8)
658 if (row < 0 or row >= 8)
672 fdata << sdata.str();
677 if (valid_hodo_v and valid_hodo_h and cherekov_e and trigger_veto_pass)
681 TTree *
T =
dynamic_cast<TTree *
>(hm->
getHisto(
"T"));
695 const int clus_edge_size = (cluster_size - 1) / 2;
696 assert(clus_edge_size >= 0);
698 pair<int, int> max(-1000, -1000);
702 for (
int row = 0; row <
n_size; ++row)
706 for (
int dcol =
col - clus_edge_size; dcol <=
col + clus_edge_size;
708 for (
int drow = row - clus_edge_size; drow <= row + clus_edge_size;
711 if (dcol < 0 or drow < 0)
721 max = make_pair(
col, row);
733 cout << __PRETTY_FUNCTION__ <<
" - input recalibration constant from "
737 ifstream fcalib(file);
743 while (not fcalib.eof())
745 getline(fcalib, line);
749 cout << __PRETTY_FUNCTION__ <<
" get line " << line << endl;
751 istringstream sline(line);
757 sline >> col >> row >> calib;
759 if (not sline.fail())
763 cout << __PRETTY_FUNCTION__ <<
" - recalibration constant "
764 << col <<
"," << row <<
" = " << calib << endl;