18 #include <g4hough/SvtxVertexMap.h>
20 #include <calobase/RawTowerContainer.h>
21 #include <calobase/RawTowerGeomContainer.h>
22 #include <calobase/RawTower.h>
23 #include <calobase/RawClusterContainer.h>
24 #include <calobase/RawCluster.h>
37 #include <TLorentzVector.h>
51 SubsysReco(
"EMCalCalib"), _eval_stack(NULL), _T_EMCalTrk(NULL), _mc_photon(
54 _filename(filename), _flags(flags), _ievent(0)
91 "PHCompositeNode",
"DST"));
94 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
96 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
109 "G4HIT_ABSORBER_HCALOUT");
112 "G4HIT_ABSORBER_HCALIN");
115 "G4HIT_ABSORBER_CEMC");
135 _mc_photon = findNode::getClass<MCPhoton>(dstNode,
"MCPhoton");
142 "MCPhoton",
"PHObject");
143 dstNode->addNode(node);
155 cout <<
"EMCalCalib::End - write to " <<
_filename << endl;
160 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
167 TTree * T_Index =
new TTree(
"T_Index",
"T_Index");
180 cout <<
"EMCalCalib::get_HistoManager - Making PHTFileServer " <<
_filename
186 cout <<
"EMCalCalib::Init - Process sampling fraction" << endl;
191 cout <<
"EMCalCalib::Init - Process tower occupancies" << endl;
196 cout <<
"EMCalCalib::Init - Process trakcs" << endl;
201 cout <<
"EMCalCalib::Init - Process kProcessUpslisonTrig" << endl;
213 cout <<
"EMCalCalib::process_event() entered" << endl;
246 cout <<
"EMCalCalib::process_event_UpslisonTrig() entered" << endl;
383 findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
386 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
393 std::set<PHG4Hit*> g4hits = trutheval->
all_truth_hits(g4particle);
400 float gvx = vtx->
get_x();
401 float gvy = vtx->
get_y();
402 float gvz = vtx->
get_z();
414 gfpx = outerhit->
get_px(1);
415 gfpy = outerhit->
get_py(1);
416 gfpz = outerhit->
get_pz(1);
417 gfx = outerhit->
get_x(1);
418 gfy = outerhit->
get_y(1);
419 gfz = outerhit->
get_z(1);
422 int gembed = trutheval->
get_embed(g4particle);
432 unsigned int layers = 0x0;
435 float dca2dsigma = NAN;
447 trackID = track->
get_id();
457 unsigned int cluster_id = *iter;
458 SvtxCluster* cluster = clustermap->get(cluster_id);
459 unsigned int layer = cluster->get_layer();
461 layers |= (0x1 <<
layer);
470 pcax = track->
get_x();
471 pcay = track->
get_y();
472 pcaz = track->
get_z();
522 mc_photon.
gfpx = gfpx;
523 mc_photon.
gfpy = gfpy;
524 mc_photon.
gfpz = gfpz;
528 mc_photon.
gembed = gembed;
536 mc_photon.
chisq = chisq;
538 mc_photon.
nhits = nhits;
539 mc_photon.
layers = layers;
540 mc_photon.
dca2d = dca2d;
542 mc_photon.
pcax = pcax;
543 mc_photon.
pcay = pcay;
544 mc_photon.
pcaz = pcaz;
558 string detector =
"InvalidDetector";
560 if (calo_id ==
kCEMC)
578 string towergeonodename =
"TOWERGEOM_" +
detector;
588 string towernodename =
"TOWER_CALIB_" +
detector;
590 topNode, towernodename.c_str());
595 std::vector<double>
point;
599 const double pt = sqrt(
603 double x = g4particle->
get_px() / pt * radius;
604 double y = g4particle->
get_py() / pt * radius;
605 double z = g4particle->
get_pz() / pt * radius + gvz;
607 double phi = atan2(y, x);
608 double eta = asinh(z / sqrt(x * x + y * y));
614 double etabin_width = cemc_towergeo->
get_etabounds(bineta).second
616 if (bineta > 1 and bineta < cemc_towergeo->get_etabins() - 1)
620 double phibin_width = cemc_towergeo->
get_phibounds(binphi).second
628 const double phibin_shift = (fmod(
629 cemc_towergeo->
get_phicenter(binphi) - phi + 5 * M_PI, 2 * M_PI) - M_PI)
633 cout << __PRETTY_FUNCTION__ <<
" - info - handling track proj. (" << x
634 <<
", " << y <<
", " << z <<
")" <<
", eta " << eta <<
", phi" << phi
635 <<
", bineta " << bineta <<
" - ["
637 << cemc_towergeo->
get_etabounds(bineta).second <<
"], etabin_shift = "
638 << etabin_shift <<
", binphi " << binphi <<
" - ["
640 << cemc_towergeo->
get_phibounds(binphi).second <<
"], phibin_shift = "
641 << phibin_shift << endl;
643 const int bin_search_range = (trk.
Max_N_Tower - 1) / 2;
644 for (
int iphi = binphi - bin_search_range; iphi <= binphi + bin_search_range;
647 for (
int ieta = bineta - bin_search_range;
648 ieta <= bineta + bin_search_range; ++ieta)
669 cout << __PRETTY_FUNCTION__ <<
" - info - processing tower"
670 <<
", bineta " << ieta <<
" - ["
672 << cemc_towergeo->
get_etabounds(ieta).second <<
"]" <<
", binphi "
675 << cemc_towergeo->
get_phibounds(wrapphi).second <<
"]" << endl;
682 cout << __PRETTY_FUNCTION__ <<
" - info - tower " << ieta <<
" "
683 << wrapphi <<
" energy = " << tower->
get_energy() << endl;
688 if (calo_id ==
kCEMC)
691 [ieta - (bineta - bin_search_range)]
692 [iphi - (binphi - bin_search_range)]
693 = ieta - bineta + etabin_shift;
695 [ieta - (bineta - bin_search_range)]
696 [iphi - (binphi - bin_search_range)]
697 = iphi - binphi + phibin_shift;
699 [ieta - (bineta - bin_search_range)]
700 [iphi - (binphi - bin_search_range)]
706 [ieta - (bineta - bin_search_range)]
707 [iphi - (binphi - bin_search_range)]
708 = ieta - bineta + etabin_shift;
710 [ieta - (bineta - bin_search_range)]
711 [iphi - (binphi - bin_search_range)]
712 = iphi - binphi + phibin_shift;
714 [ieta - (bineta - bin_search_range)]
715 [iphi - (binphi - bin_search_range)]
740 cout <<
"EMCalCalib::process_event_MCPhoton() entered" << endl;
748 _mc_photon = findNode::getClass<MCPhoton>(topNode,
"MCPhoton");
752 findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
757 assert(range.first != range.second);
775 <<
"EMCalCalib::get_HistoManager - Making Fun4AllHistoManager EMCalAna_HISTOS"
794 "_h_CEMC_SF", 1000, 0, .2));
796 "_h_HCALIN_SF", 1000, 0, .2));
798 "_h_HCALOUT_SF", 1000, 0, .2));
800 "_h_CEMC_VSF", 1000, 0, .2));
802 "_h_HCALIN_VSF", 1000, 0, .2));
804 "_h_HCALOUT_VSF", 1000, 0, .2));
807 "EMCalAna_h_CEMC_RZ;Z (cm);R (cm)", 1200, -300, 300, 600, -000, 300));
809 "EMCalAna_h_HCALIN_RZ;Z (cm);R (cm)", 1200, -300, 300, 600, -000, 300));
811 "EMCalAna_h_HCALOUT_RZ;Z (cm);R (cm)", 1200, -300, 300, 600, -000, 300));
814 "EMCalAna_h_CEMC_XY;X (cm);Y (cm)", 1200, -300, 300, 1200, -300, 300));
816 "EMCalAna_h_HCALIN_XY;X (cm);Y (cm)", 1200, -300, 300, 1200, -300, 300));
818 "EMCalAna_h_HCALOUT_XY;X (cm);Y (cm)", 1200, -300, 300, 1200, -300, 300));
828 cout <<
"EMCalCalib::process_event_SF() entered" << endl;
835 double e_hcin = 0.0, e_hcout = 0.0, e_cemc = 0.0;
836 double ev_hcin = 0.0, ev_hcout = 0.0, ev_cemc = 0.0;
837 double ea_hcin = 0.0, ea_hcout = 0.0, ea_cemc = 0.0;
841 TH2F * hrz = (TH2F*) hm->
getHisto(
"EMCalAna_h_HCALOUT_RZ");
843 TH2F * hxy = (TH2F*) hm->
getHisto(
"EMCalAna_h_HCALOUT_XY");
849 hit_iter != hcalout_hit_range.second; hit_iter++)
852 PHG4Hit *this_hit = hit_iter->second;
867 TH2F * hrz = (TH2F*) hm->
getHisto(
"EMCalAna_h_HCALIN_RZ");
869 TH2F * hxy = (TH2F*) hm->
getHisto(
"EMCalAna_h_HCALIN_XY");
875 hit_iter != hcalin_hit_range.second; hit_iter++)
878 PHG4Hit *this_hit = hit_iter->second;
894 TH2F * hrz = (TH2F*) hm->
getHisto(
"EMCalAna_h_CEMC_RZ");
896 TH2F * hxy = (TH2F*) hm->
getHisto(
"EMCalAna_h_CEMC_XY");
902 hit_iter != cemc_hit_range.second; hit_iter++)
905 PHG4Hit *this_hit = hit_iter->second;
923 hcalout_abs_hit_range.first; hit_iter != hcalout_abs_hit_range.second;
927 PHG4Hit *this_hit = hit_iter->second;
940 hit_iter != hcalin_abs_hit_range.second; hit_iter++)
943 PHG4Hit *this_hit = hit_iter->second;
955 hit_iter != cemc_abs_hit_range.second; hit_iter++)
958 PHG4Hit *this_hit = hit_iter->second;
966 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_CEMC_SF");
968 h->Fill(e_cemc / (e_cemc + ea_cemc) + 1
e-9);
969 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_CEMC_VSF");
971 h->Fill(ev_cemc / (e_cemc + ea_cemc) + 1
e-9);
973 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_HCALOUT_SF");
975 h->Fill(e_hcout / (e_hcout + ea_hcout) + 1
e-9);
976 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_HCALOUT_VSF");
978 h->Fill(ev_hcout / (e_hcout + ea_hcout) + 1
e-9);
980 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_HCALIN_SF");
982 h->Fill(e_hcin / (e_hcin + ea_hcin) + 1
e-9);
983 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_HCALIN_VSF");
985 h->Fill(ev_hcin / (e_hcin + ea_hcin) + 1
e-9);
998 "h_CEMC_TOWER_1x1", 5000, 0, 50));
1000 "EMCalAna_h_CEMC_TOWER_1x1_max", 5000, 0, 50));
1001 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_1x1_max_trigger_ADC",
1002 "EMCalAna_h_CEMC_TOWER_1x1_max_trigger_ADC", 5000, 0, 50));
1005 "h_CEMC_TOWER_2x2", 5000, 0, 50));
1007 "EMCalAna_h_CEMC_TOWER_2x2_max", 5000, 0, 50));
1008 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_2x2_max_trigger_ADC",
1009 "EMCalAna_h_CEMC_TOWER_2x2_max_trigger_ADC", 5000, 0, 50));
1010 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_2x2_slide2_max_trigger_ADC",
1011 "EMCalAna_h_CEMC_TOWER_2x2_slide2_max_trigger_ADC", 5000, 0, 50));
1014 "h_CEMC_TOWER_3x3", 5000, 0, 50));
1016 "EMCalAna_h_CEMC_TOWER_3x3_max", 5000, 0, 50));
1017 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_3x3_max_trigger_ADC",
1018 "EMCalAna_h_CEMC_TOWER_3x3_max_trigger_ADC", 5000, 0, 50));
1021 "h_CEMC_TOWER_4x4", 5000, 0, 50));
1023 "EMCalAna_h_CEMC_TOWER_4x4_max", 5000, 0, 50));
1024 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC",
1025 "EMCalAna_h_CEMC_TOWER_4x4_max_trigger_ADC", 5000, 0, 50));
1026 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC",
1027 "EMCalAna_h_CEMC_TOWER_4x4_slide2_max_trigger_ADC", 5000, 0, 50));
1030 "h_CEMC_TOWER_4x4", 5000, 0, 50));
1032 "EMCalAna_h_CEMC_TOWER_5x5_max", 5000, 0, 50));
1033 hm->
registerHisto(
new TH1F(
"EMCalAna_h_CEMC_TOWER_5x5_max_trigger_ADC",
1034 "EMCalAna_h_CEMC_TOWER_5x5_max_trigger_ADC", 5000, 0, 50));
1045 cout <<
"EMCalCalib::process_event_SF() entered" << endl;
1047 string towernodename =
"TOWER_CALIB_" +
detector;
1050 towernodename.c_str());
1053 std::cout <<
PHWHERE <<
": Could not find node " << towernodename.c_str()
1057 string towergeomnodename =
"TOWERGEOM_" +
detector;
1059 topNode, towergeomnodename.c_str());
1062 cout <<
PHWHERE <<
": Could not find node " << towergeomnodename.c_str()
1067 static const double trigger_ADC_bin = 45. / 256.;
1068 static const int max_size = 5;
1069 map<int, string> size_label;
1070 size_label[1] =
"1x1";
1071 size_label[2] =
"2x2";
1072 size_label[3] =
"3x3";
1073 size_label[4] =
"4x4";
1074 size_label[5] =
"5x5";
1075 map<int, double> max_energy;
1076 map<int, double> max_energy_trigger_ADC;
1077 map<int, double> slide2_max_energy_trigger_ADC;
1078 map<int, TH1F*> energy_hist_list;
1079 map<int, TH1F*> max_energy_hist_list;
1080 map<int, TH1F*> max_energy_trigger_ADC_hist_list;
1081 map<int, TH1F*> slide2_max_energy_trigger_ADC_hist_list;
1087 max_energy[
size] = 0;
1088 max_energy_trigger_ADC[
size] = 0;
1092 h = (TH1F*) hm->
getHisto(
"EMCalAna_h_CEMC_TOWER_" + size_label[
size]);
1094 energy_hist_list[
size] =
h;
1096 "EMCalAna_h_CEMC_TOWER_" + size_label[size] +
"_max");
1098 max_energy_hist_list[
size] =
h;
1101 "EMCalAna_h_CEMC_TOWER_" + size_label[size] +
"_max_trigger_ADC");
1103 max_energy_trigger_ADC_hist_list[
size] =
h;
1105 if (size == 2 or size == 4)
1108 slide2_max_energy_trigger_ADC[
size] = 0;
1111 "EMCalAna_h_CEMC_TOWER_" + size_label[size]
1112 +
"_slide2_max_trigger_ADC");
1114 slide2_max_energy_trigger_ADC_hist_list[
size] =
h;
1120 for (
int binphi = 0; binphi < towergeom->
get_phibins(); ++binphi)
1122 for (
int bineta = 0; bineta < towergeom->
get_etabins(); ++bineta)
1127 double energy_trigger_ADC = 0;
1128 double slide2_energy_trigger_ADC = 0;
1130 for (
int iphi = binphi; iphi < binphi +
size; ++iphi)
1132 for (
int ieta = bineta; ieta < bineta +
size; ++ieta)
1151 const double e_trigger_ADC =
round(
1152 e_intput / trigger_ADC_bin) * trigger_ADC_bin;
1155 energy_trigger_ADC += e_trigger_ADC;
1157 if ((size == 2 or size == 4) and (binphi % 2 == 0)
1158 and (bineta % 2 == 0))
1162 slide2_energy_trigger_ADC += e_trigger_ADC;
1168 energy_hist_list[
size]->Fill(energy);
1170 if (energy > max_energy[size])
1172 if (energy_trigger_ADC > max_energy_trigger_ADC[size])
1173 max_energy_trigger_ADC[
size] = energy_trigger_ADC;
1175 if ((size == 2 or size == 4) and (binphi % 2 == 0)
1176 and (bineta % 2 == 0))
1180 if (slide2_energy_trigger_ADC
1181 > slide2_max_energy_trigger_ADC[size])
1182 slide2_max_energy_trigger_ADC[
size] =
1183 slide2_energy_trigger_ADC;
1192 max_energy_hist_list[
size]->Fill(max_energy[
size]);
1193 max_energy_trigger_ADC_hist_list[
size]->Fill(
1194 max_energy_trigger_ADC[size]);
1196 if (size == 2 or size == 4)
1199 slide2_max_energy_trigger_ADC_hist_list[
size]->Fill(
1200 slide2_max_energy_trigger_ADC[size]);