18 #include <g4hough/SvtxVertexMap.h>
20 #include <calobase/RawTowerContainer.h>
21 #include <calobase/RawTowerGeom.h>
22 #include <calobase/RawTower.h>
23 #include <calobase/RawClusterContainer.h>
24 #include <calobase/RawCluster.h>
37 #include <TLorentzVector.h>
51 SubsysReco(
"EMCalLikelihood"), _filename(filename), _ievent(0), _trk(NULL)
52 , center_cemc_iphi(NAN), center_cemc_ieta(NAN),
53 center_hcalin_iphi(NAN), center_hcalin_ieta(NAN),
54 width_cemc_iphi(NAN), width_cemc_ieta(NAN),
55 width_hcalin_iphi(NAN), width_hcalin_ieta(NAN),
56 h2_Edep_Distribution_e(NULL), h2_Edep_Distribution_pi(NULL),
57 h1_ep_Distribution_e(NULL), h1_ep_Distribution_pi(NULL),
58 _do_ganging(
false), _ganging_size(1, 1)
75 "PHCompositeNode",
"DST"));
78 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
80 "Failed to find DST node in EmcRawTowerBuilder::CreateNodes");
84 _trk = findNode::getClass<EMCalTrk>(dstNode,
"EMCalTrk");
89 cout << __PRETTY_FUNCTION__ <<
"::" <<
Name() <<
" - Error - "
90 <<
"Can not find the EMCalTrk node" << endl;
106 cout <<
"EMCalLikelihood::End - write to " <<
_filename << endl;
111 for (
unsigned int i = 0;
i < hm->
nHistos();
i++)
121 cout <<
"EMCalLikelihood::Init - Making PHTFileServer " <<
_filename << endl;
127 TH2F * h_merge_direction =
new TH2F(
"h_merge_direction",
128 "h_merge_direction;merge eta shift;merge phi shift", 10, -.5, 9.5, 10,
136 "h2_Edep_Distribution_e"));
140 "h1_ep_Distribution_e");
152 if (binc > 0 and binc < min_prob)
178 "h2_Edep_Distribution_pi"));
182 "h1_ep_Distribution_pi");
194 if (binc > 0 and binc < min_prob)
250 <<
"EMCalLikelihood::get_HistoManager - Making Fun4AllHistoManager EMCalLikelihood_HISTOS"
268 static bool once =
true;
273 cout <<
"EMCalLikelihood::ApplyEMCalGanging - apply EMCal ganging "
280 const double radius = 100;
281 const double eta_bin_cm = 2.5;
282 const double phi_bin_rad = 0.025;
284 assert(momentum.Pt() > 0);
286 TVector3
proj = vertex + radius / momentum.Pt() *
momentum;
287 const int eta_bin = floor(proj.Z() / eta_bin_cm);
288 const int phi_bin = floor(proj.Phi() / phi_bin_rad);
291 const bool merge_plus_phi = (phi_bin %
_ganging_size.second);
296 TH2F * h_merge_direction = (TH2F *) hm->
getHisto(
"h_merge_direction");
297 assert(h_merge_direction);
299 h_merge_direction->Fill(merge_plus_eta, merge_plus_phi);
301 for (
int ieta = 0; ieta < trk->
Max_N_Tower; ++ieta)
303 for (
int iphi = 0; iphi < trk->
Max_N_Tower; ++iphi)
305 bool out_of_edge =
false;
307 double cemc_ieta = 0;
308 double cemc_iphi = 0;
309 double cemc_energy = 0;
311 for (
unsigned int dieta = 0; dieta <
_ganging_size.first; ++dieta)
313 const unsigned int fetch_eta =
_ganging_size.first * ieta + dieta + merge_plus_eta;
321 for (
unsigned int diphi = 0; diphi <
_ganging_size.second; ++diphi)
323 const unsigned int fetch_phi =
_ganging_size.first * iphi + diphi + merge_plus_phi;
331 cemc_ieta += trk->
cemc_ieta[fetch_eta][fetch_phi];
332 cemc_iphi += trk->
cemc_iphi[fetch_eta][fetch_phi];
333 cemc_energy += trk->
cemc_energy[fetch_eta][fetch_phi];
365 for (
int ieta = 0; ieta < trk->
Max_N_Tower; ++ieta)
367 for (
int iphi = 0; iphi < trk->
Max_N_Tower; ++iphi)
371 const double cemc_radius2 = pow(
379 if (cemc_radius2 <= 1.0)
386 const double hcalin_radius2 = pow(
394 if (hcalin_radius2 <= 1.0)
429 cout << __PRETTY_FUNCTION__ <<
Name()
430 <<
" - Error - invalid likelihood value prob_e = " << prob_e
431 <<
" @ bin " << binx <<
", " << biny << endl;
438 cout << __PRETTY_FUNCTION__ <<
Name()
439 <<
" - Error - invalid likelihood value prob_pi = " << prob_pi
440 <<
" @ bin " << binx <<
", " << biny << endl;