28 #include "GaudiKernel/ISvcLocator.h"
29 #include "GaudiKernel/StatusCode.h"
37 #include <CLHEP/Vector/LorentzVector.h>
45 #include "TProfile2D.h"
52 using CLHEP::HepLorentzVector;
63 m_caloDmDescrManager(nullptr),
64 m_outputFileName(
"CheckSinglePionsReco.root"),
65 m_outputFile(nullptr),
67 m_netabin(25), m_etamin(0.0), m_etamax(5.0),
69 m_nphibin(1), m_phimin(-
M_PI), m_phimax(
M_PI),
71 m_nlogenerbin(22), m_logenermin(2.0), m_logenermax(6.4),
79 m_truthPiEngFraction(0.1),
80 m_doEngRecOverTruth(true),
82 m_doEngRecSpect(true),
83 m_doEngNoiseClus(true),
84 m_doClusMoments(true),
85 m_doRecoEfficiency(true),
86 m_useRecoEfficiency(false),
88 m_doCalibHitsValidation(true),
188 float h_eta_min = -5.0;
196 double *
xbins =
new double[n_logener_bins+1];
197 const double inv_n_logener_bins = 1. /
static_cast<double> (n_logener_bins);
198 for(
int i_bin=0; i_bin<=n_logener_bins; i_bin++) {
212 sprintf(
hname,
"hp_engTag_vs_eta_tag%d_ener%d",i_tag, i_ener);
214 hp->GetXaxis()->SetTitle(
"#eta");
215 hp->GetYaxis()->SetTitle(
"E_{class}/E_{tot}");
223 for(
int i_eta=0; i_eta<
m_netabin; i_eta++) {
224 sprintf(
hname,
"hp_engTag_vs_ebeam_tag%d_eta%d",i_tag, i_eta);
226 hp->GetXaxis()->SetTitle(
"E_{#pi}, MeV");
227 hp->GetYaxis()->SetTitle(
"E_{class}/E_{tot}");
247 double ylow(0), yup(0);
252 sprintf(
hname,
"hp_engRecOverTruth_vs_eta_coll%d_norm%d_ener%d",i_coll, i_norm, i_ener);
254 hp->GetXaxis()->SetTitle(
"#eta");
256 hp->GetYaxis()->SetTitle(
"E_{reco}/E_{#pi}");
258 hp->GetYaxis()->SetTitle(
"E_{reco}/E_{calib}");
270 for(
int i_eta=0; i_eta<
m_netabin; i_eta++) {
271 double ylow(0), yup(0);
276 sprintf(
hname,
"hp_m_engRecOverTruth_vs_ebeam_coll%d_norm%d_eta%d",i_coll, i_norm, i_eta);
278 hp->GetXaxis()->SetTitle(
"E_{#pi}, MeV");
280 hp->GetYaxis()->SetTitle(
"E_{reco}/E_{#pi}");
282 hp->GetYaxis()->SetTitle(
"E_{reco}/E_{calib}");
300 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
301 sprintf(
hname,
"hp_engRecSpect_coll%d_ener%d_eta%d",i_coll, i_ener, i_eta);
303 h1->GetXaxis()->SetTitle(
"E_{reco}/E_{#pi}");
312 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
313 sprintf(
hname,
"hp_engPionSpect_ener%d_eta%d",i_ener, i_eta);
317 h1->GetXaxis()->SetTitle(
"E_{#pi}, MeV");
331 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
332 sprintf(
hname,
"hp_engNoiseClusSpect_coll%d_eta%d",i_coll, i_eta);
334 h1->GetXaxis()->SetTitle(
"E_{clus}, MeV");
341 sprintf(
hname,
"hp_engNoiseClus_vs_eta_coll%d",i_coll);
343 hp->GetXaxis()->SetTitle(
"#eta");
344 hp->GetYaxis()->SetTitle(
"E_{clus}, MeV");
360 sprintf(
hname,
"hp_clusMoment_vs_eta_mom%d_sum%d_ener%d",i_mom, i_sum, i_ener);
362 hp->GetXaxis()->SetTitle(
"#eta");
363 hp->GetYaxis()->SetTitle(
"Mom_{cls}/Mom_{sum}");
375 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
376 sprintf(
hname,
"hp_clusMoment_vs_ebeam_mom%d_sum%d_eta%d",i_mom, i_sum, i_eta);
378 hp->GetXaxis()->SetTitle(
"E_{#pi}");
379 hp->GetYaxis()->SetTitle(
"Mom_{cls}/Mom_{sum}");
394 for(
int i_eff=0; i_eff<2; i_eff++){
397 sprintf(
hname,
"hp_m_RecoEfficiency_eff%d_ener%d", i_eff, i_ener);
399 h1->GetXaxis()->SetTitle(
"#eta");
400 h1->GetYaxis()->SetTitle(
"Efficiency");
405 for(
int i_eff=0; i_eff<2; i_eff++){
407 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
408 sprintf(
hname,
"hp_m_RecoEfficiency_eff%d_eta%d", i_eff, i_eta);
410 h1->GetXaxis()->SetTitle(
"E_{#pi}, MeV");
411 h1->GetYaxis()->SetTitle(
"Efficiency");
426 sprintf(
hname,
"hp_SumCalibHitOverEbeam_vs_eta_ener%d", i_ener);
428 hp->GetXaxis()->SetTitle(
"#eta");
429 hp->GetYaxis()->SetTitle(
"#sum E_{calib}/E_{#pi}");
431 sprintf(
hname,
"hp_DefaultCalculatorOverEbeam_vs_eta_ener%d", i_ener);
433 hp->GetXaxis()->SetTitle(
"#eta");
434 hp->GetYaxis()->SetTitle(
"#sum E_{DefCalc}/E_{#pi}");
436 sprintf(
hname,
"hp_SumCalibHitAssignedOverEbeam_vs_eta_ener%d", i_ener);
438 hp->GetXaxis()->SetTitle(
"#eta");
439 hp->GetYaxis()->SetTitle(
"#sum E_{assigned}/E_{#pi}");
441 sprintf(
hname,
"hp_SumCalibHitAssignedOverEbeam_vs_etaphi_ener%d", i_ener);
442 TProfile2D *hp2 =
new TProfile2D(
hname,
hname, 25, h_eta_min, h_eta_max, 25, -
M_PI,
M_PI);
443 hp2->GetXaxis()->SetTitle(
"#eta");
444 hp2->GetYaxis()->SetTitle(
"#phi");
445 hp2->GetZaxis()->SetTitle(
"#sum E_{assigned}/E_{#pi}");
473 return StatusCode::SUCCESS;
500 for(
int i_eta=0; i_eta<
m_netabin; i_eta++) {
519 for(
int i_eta=0; i_eta<
m_netabin; i_eta++) {
532 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
539 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
551 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
574 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
592 for(
int i_eta=0; i_eta<
m_netabin; i_eta++){
626 TTree *
tree =
new TTree(
"ParamTree",
"ParamTree");
646 return StatusCode::SUCCESS;
656 const EventContext& ctx = getContext();
664 if( truthEvent->
at(0)->particles_empty() ){
666 return StatusCode::FAILURE;
671 HepMC::GenEvent::particle_const_iterator pit = truthEvent->
at(0)->particles_begin();
686 if(clusColl->
empty()) {
688 return StatusCode::SUCCESS;
693 bool PionWasReconstructed =
false;
694 float engClusCalibThs = 1.0*
MeV;
695 HepLorentzVector hlv_pion(1,0,0,1);
702 double mx_dens, mx_center_lambda;
704 mx_center_lambda = 0;
708 HepLorentzVector hlv_cls(1,0,0,1);
709 hlv_cls.setREtaPhi(1./cosh(theCluster->eta()), theCluster->eta(), theCluster->phi());
710 double r = hlv_pion.angle(hlv_cls.vect());
712 && mx_calib_tot > engClusCalibThs
713 && theCluster->size() > 1
715 && mx_center_lambda != 0.0 ) {
716 PionWasReconstructed =
true;
720 if(PionWasReconstructed){
745 return StatusCode::SUCCESS;
756 const EventContext& ctx)
761 std::vector<const xAOD::CaloClusterContainer *> clusCollVector;
764 clusCollVector.push_back(pColl.
cptr());
767 HepLorentzVector hlv_pion(1,0,0,1);
770 std::vector<double > engClusSum;
772 std::vector<double > engClusSumPresOnly;
775 double engClusSumCalib(0);
776 double engClusSumCalibPresOnly(0);
777 double engClusSumTrueOOC(0);
778 double engClusSumTrueDM(0);
779 std::vector<double> engClusSumCalibTagged;
783 unsigned int iClus = -1;
790 double mx_calib_emb0 = 0;
791 double mx_calib_eme0 = 0;
792 double mx_calib_tileg3 = 0;
796 ATH_MSG_ERROR(
"One of the moment ENG_CALIB_EMB0, ENG_CALIB_EME0, ENG_CALIB_TILEG3 is absent" );
798 double mx_calib_out = 0;
799 double mx_calib_dead_tot = 0;
802 ATH_MSG_ERROR(
"One of the moment ENG_CALIB_OUT_L, ENG_CALIB_DEAD_TOT is absent" );
805 double mx_dens, mx_center_lambda;
807 mx_center_lambda = 0;
811 bool clusIsGood(
true);
818 HepLorentzVector hlv_cls(1,0,0,1);
819 hlv_cls.setREtaPhi(1./cosh(theCluster->eta()), theCluster->eta(), theCluster->phi());
820 double r = hlv_pion.angle(hlv_cls.vect());
825 theCluster = clusCollVector[
kTOPO]->at(iClus);
829 engClusSumCalibTagged[
kTAGEM] += mx_calib_tot;
831 engClusSumCalibTagged[
kTAGHAD] += mx_calib_tot;
833 engClusSumCalibTagged[
kTAGUNK] += mx_calib_tot;
840 engClusSumCalib += mx_calib_tot;
841 engClusSumCalibPresOnly += (mx_calib_emb0+mx_calib_eme0+mx_calib_tileg3);
842 engClusSumTrueOOC += mx_calib_out;
843 engClusSumTrueDM += mx_calib_dead_tot;
845 theCluster = clusCollVector[i_coll]->at(iClus);
846 engClusSum[i_coll] += theCluster->e();
855 theCluster = clusCollVector[i_coll]->at(iClus);
864 if(nGoodClus == 0)
return 0;
873 double enom = engClusSum[i_coll];
874 if(i_coll !=
kTOPO) {
875 enom = enom - engClusSumPresOnly[i_coll];
883 double edenom = engClusSumCalib - engClusSumCalibPresOnly;
885 edenom += engClusSumTrueOOC;
886 }
else if(i_coll ==
kTOPO){
887 edenom += (engClusSumTrueOOC + engClusSumTrueDM);
895 enom = engClusSum[i_coll] - engClusSumPresOnly[i_coll];
898 enom = engClusSumCalib - engClusSumCalibPresOnly + engClusSumRecoOOC;
899 }
else if(i_coll ==
kTOPO){
901 enom = (engClusSumCalib - engClusSumCalibPresOnly) + engClusSumTrueOOC + engClusSumRecoDM;
914 if(engClusSumCalib!=0.0) {
915 const double inv_engClusSumCalib = 1. / engClusSumCalib;
928 double enom = engClusSum[i_coll];
929 if(i_coll !=
kTOPO) {
930 enom = enom - engClusSumPresOnly[i_coll];
945 const EventContext& ctx)
947 ATH_MSG_DEBUG(
"GetLCSinglePionsPerf::fill_moments got cont. size: "<<clusColl.
size());
951 std::vector<const CaloCalibrationHitContainer *> v_cchc;
954 v_cchc.push_back(cchc.
cptr());
957 std::vector<const CaloCalibrationHitContainer *> v_dmcchc;
960 v_dmcchc.push_back(cchc.
cptr());
964 double engCalibTot = 0.0;
965 std::vector<double > engCalibTotSmp;
972 ATH_MSG_WARNING(
"Error! Bad identifier " << myId <<
" in container '" << cchc->Name() <<
"',"
977 ATH_MSG_WARNING(
"Error! Bad identifier (nor lar or tile) " << myId <<
" in container '" << cchc->Name() <<
"',"
983 engCalibTot += hit->energyTotal();
984 engCalibTotSmp[nsmp] += hit->energyTotal();
989 double engCalibDeadTot = 0.0;
990 std::vector<double > engCalibDeadTotInArea;
997 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1002 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier (nor lar_dm or tile_dm) " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1006 engCalibDeadTot += hit->energyTotal();
1011 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Absent DM description element!");
1015 engCalibDeadTotInArea[nDmArea] += hit->energyTotal();
1026 double engClusSumCalib(0);
1027 double engClusSumCalibPresOnly(0);
1028 std::vector<std::vector<double > > clsMoments;
1029 clsMoments.resize(clusColl.
size());
1030 std::vector<double > clsMomentsSum;
1034 unsigned int iClus = -1;
1041 if( theCluster->retrieveMoment((*im).second,
mx) ) {
1042 clsMoments[iClus][iMoment] =
mx;
1044 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Can't retrieve moment " << (*im).first <<
" " << (*im).second);
1046 clsMomentsSum[iMoment] += clsMoments[iClus][iMoment];
1050 engClusSumCalib +=
mx;
1052 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Can't retrieve moment xAOD::CaloCluster::ENG_CALIB_TOT ");
1054 double mx_calib_emb0, mx_calib_eme0, mx_calib_tileg3;
1058 ATH_MSG_WARNING(
"One of the moment ENG_CALIB_EMB0, ENG_CALIB_EME0, ENG_CALIB_TILEG3 is absent");
1060 engClusSumCalibPresOnly += (mx_calib_emb0+mx_calib_eme0+mx_calib_tileg3);
1064 double engCalibDeadTotWithPres = engCalibDeadTot + engClusSumCalibPresOnly;
1087 double eng_calib_dead_unclass = engCalibDeadTotWithPres - eng_calib_dead_emb0 - eng_calib_dead_tile0
1088 - eng_calib_dead_tileg3 - eng_calib_dead_eme0 - eng_calib_dead_hec0 - eng_calib_dead_fcal
1089 - eng_calib_dead_leakage;
1095 switch ( (*im).second ) {
1097 xnorm = clsMomentsSum[iMoment];
1100 xnorm = engCalibTot - engClusSumCalib;
1103 xnorm = engCalibTot - engClusSumCalib;
1106 xnorm = engCalibTot - engClusSumCalib;
1109 xnorm = engCalibDeadTotWithPres;
1112 xnorm = eng_calib_dead_emb0;
1115 xnorm = eng_calib_dead_tile0;
1118 xnorm = eng_calib_dead_tileg3;
1121 xnorm = eng_calib_dead_eme0;
1124 xnorm = eng_calib_dead_hec0;
1127 xnorm = eng_calib_dead_fcal;
1130 xnorm = eng_calib_dead_leakage;
1133 xnorm = eng_calib_dead_unclass;
1136 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Not implemented for " << (*im).first <<
" " << (*im).second);
1141 const double inv_xnorm = 1. / xnorm;
1142 for(
unsigned int i_cls=0; i_cls<clusColl.size(); i_cls++){
1168 const EventContext& ctx)
1173 std::vector<const CaloCalibrationHitContainer *> v_cchc;
1176 v_cchc.push_back(cchc.
cptr());
1179 std::vector<const CaloCalibrationHitContainer *> v_dmcchc;
1182 v_dmcchc.push_back(cchc.
cptr());
1186 double engCalibTot = 0.0;
1192 ATH_MSG_ERROR(
"Error! Bad identifier " << myId <<
" in container '" << cchc->Name() <<
"',"
1197 ATH_MSG_ERROR(
"Error! Bad identifier (nor lar or tile) " << myId <<
" in container '" << cchc->Name() <<
"',"
1201 engCalibTot += hit->energyTotal();
1206 double engCalibDeadTot = 0.0;
1207 double engDefaultCalculator = 0.0;
1213 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1218 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier (nor lar_dm or tile_dm) " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1222 engCalibDeadTot += hit->energyTotal();
1227 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Absent DM description element!");
1237 double engCalibAssigned = 0.0;
1238 double engClusSumCalibPresOnly = 0.0;
1240 double mx_calib_tot, mx_calib_ooc, mx_calib_dm;
1255 engCalibAssigned += (mx_calib_tot + mx_calib_ooc + mx_calib_dm);
1257 double mx_calib_emb0, mx_calib_eme0, mx_calib_tileg3;
1261 ATH_MSG_WARNING(
"One of the moment ENG_CALIB_EMB0, ENG_CALIB_EME0, ENG_CALIB_TILEG3 is absent");
1263 engClusSumCalibPresOnly += (mx_calib_emb0+mx_calib_eme0+mx_calib_tileg3);
1268 engCalibAssigned -= engClusSumCalibPresOnly;
1290 double eta = fabs(
x);
1299 return ff*(1./
atan(5.0*1.7/200.0));