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;
669 for (
auto p: *truthEvent->
at(0)) {
671 if (std::abs(
p->pdg_id()) == MC::PIPLUS ||
672 std::abs(
p->pdg_id()) == MC::PI0) {
679 ATH_MSG_ERROR(
"No final stable pion in McEventCollection" );
680 return StatusCode::FAILURE;
694 if(clusColl->
empty()) {
696 return StatusCode::SUCCESS;
701 bool PionWasReconstructed =
false;
702 float engClusCalibThs = 1.0*
MeV;
703 HepLorentzVector hlv_pion(1,0,0,1);
710 double mx_dens, mx_center_lambda;
712 mx_center_lambda = 0;
716 HepLorentzVector hlv_cls(1,0,0,1);
717 hlv_cls.setREtaPhi(1./cosh(theCluster->eta()), theCluster->eta(), theCluster->phi());
718 double r = hlv_pion.angle(hlv_cls.vect());
720 && mx_calib_tot > engClusCalibThs
721 && theCluster->size() > 1
723 && mx_center_lambda != 0.0 ) {
724 PionWasReconstructed =
true;
728 if(PionWasReconstructed){
753 return StatusCode::SUCCESS;
764 const EventContext& ctx)
769 std::vector<const xAOD::CaloClusterContainer *> clusCollVector;
772 clusCollVector.push_back(pColl.
cptr());
775 HepLorentzVector hlv_pion(1,0,0,1);
778 std::vector<double > engClusSum;
780 std::vector<double > engClusSumPresOnly;
783 double engClusSumCalib(0);
784 double engClusSumCalibPresOnly(0);
785 double engClusSumTrueOOC(0);
786 double engClusSumTrueDM(0);
787 std::vector<double> engClusSumCalibTagged;
791 unsigned int iClus = -1;
798 double mx_calib_emb0 = 0;
799 double mx_calib_eme0 = 0;
800 double mx_calib_tileg3 = 0;
804 ATH_MSG_ERROR(
"One of the moment ENG_CALIB_EMB0, ENG_CALIB_EME0, ENG_CALIB_TILEG3 is absent" );
806 double mx_calib_out = 0;
807 double mx_calib_dead_tot = 0;
810 ATH_MSG_ERROR(
"One of the moment ENG_CALIB_OUT_L, ENG_CALIB_DEAD_TOT is absent" );
813 double mx_dens, mx_center_lambda;
815 mx_center_lambda = 0;
819 bool clusIsGood(
true);
826 HepLorentzVector hlv_cls(1,0,0,1);
827 hlv_cls.setREtaPhi(1./cosh(theCluster->eta()), theCluster->eta(), theCluster->phi());
828 double r = hlv_pion.angle(hlv_cls.vect());
833 theCluster = clusCollVector[
kTOPO]->at(iClus);
837 engClusSumCalibTagged[
kTAGEM] += mx_calib_tot;
839 engClusSumCalibTagged[
kTAGHAD] += mx_calib_tot;
841 engClusSumCalibTagged[
kTAGUNK] += mx_calib_tot;
848 engClusSumCalib += mx_calib_tot;
849 engClusSumCalibPresOnly += (mx_calib_emb0+mx_calib_eme0+mx_calib_tileg3);
850 engClusSumTrueOOC += mx_calib_out;
851 engClusSumTrueDM += mx_calib_dead_tot;
853 theCluster = clusCollVector[i_coll]->at(iClus);
854 engClusSum[i_coll] += theCluster->e();
863 theCluster = clusCollVector[i_coll]->at(iClus);
872 if(nGoodClus == 0)
return 0;
881 double enom = engClusSum[i_coll];
882 if(i_coll !=
kTOPO) {
883 enom = enom - engClusSumPresOnly[i_coll];
891 double edenom = engClusSumCalib - engClusSumCalibPresOnly;
893 edenom += engClusSumTrueOOC;
894 }
else if(i_coll ==
kTOPO){
895 edenom += (engClusSumTrueOOC + engClusSumTrueDM);
903 enom = engClusSum[i_coll] - engClusSumPresOnly[i_coll];
906 enom = engClusSumCalib - engClusSumCalibPresOnly + engClusSumRecoOOC;
907 }
else if(i_coll ==
kTOPO){
909 enom = (engClusSumCalib - engClusSumCalibPresOnly) + engClusSumTrueOOC + engClusSumRecoDM;
922 if(engClusSumCalib!=0.0) {
923 const double inv_engClusSumCalib = 1. / engClusSumCalib;
936 double enom = engClusSum[i_coll];
937 if(i_coll !=
kTOPO) {
938 enom = enom - engClusSumPresOnly[i_coll];
953 const EventContext& ctx)
955 ATH_MSG_DEBUG(
"GetLCSinglePionsPerf::fill_moments got cont. size: "<<clusColl.
size());
959 std::vector<const CaloCalibrationHitContainer *> v_cchc;
962 v_cchc.push_back(cchc.
cptr());
965 std::vector<const CaloCalibrationHitContainer *> v_dmcchc;
968 v_dmcchc.push_back(cchc.
cptr());
972 double engCalibTot = 0.0;
973 std::vector<double > engCalibTotSmp;
980 ATH_MSG_WARNING(
"Error! Bad identifier " << myId <<
" in container '" << cchc->Name() <<
"',"
985 ATH_MSG_WARNING(
"Error! Bad identifier (nor lar or tile) " << myId <<
" in container '" << cchc->Name() <<
"',"
991 engCalibTot += hit->energyTotal();
992 engCalibTotSmp[nsmp] += hit->energyTotal();
997 double engCalibDeadTot = 0.0;
998 std::vector<double > engCalibDeadTotInArea;
1005 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1010 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier (nor lar_dm or tile_dm) " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1014 engCalibDeadTot += hit->energyTotal();
1019 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Absent DM description element!");
1023 engCalibDeadTotInArea[nDmArea] += hit->energyTotal();
1034 double engClusSumCalib(0);
1035 double engClusSumCalibPresOnly(0);
1036 std::vector<std::vector<double > > clsMoments;
1037 clsMoments.resize(clusColl.
size());
1038 std::vector<double > clsMomentsSum;
1042 unsigned int iClus = -1;
1049 if( theCluster->retrieveMoment((*im).second,
mx) ) {
1050 clsMoments[iClus][iMoment] =
mx;
1052 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Can't retrieve moment " << (*im).first <<
" " << (*im).second);
1054 clsMomentsSum[iMoment] += clsMoments[iClus][iMoment];
1058 engClusSumCalib +=
mx;
1060 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Can't retrieve moment xAOD::CaloCluster::ENG_CALIB_TOT ");
1062 double mx_calib_emb0, mx_calib_eme0, mx_calib_tileg3;
1066 ATH_MSG_WARNING(
"One of the moment ENG_CALIB_EMB0, ENG_CALIB_EME0, ENG_CALIB_TILEG3 is absent");
1068 engClusSumCalibPresOnly += (mx_calib_emb0+mx_calib_eme0+mx_calib_tileg3);
1072 double engCalibDeadTotWithPres = engCalibDeadTot + engClusSumCalibPresOnly;
1095 double eng_calib_dead_unclass = engCalibDeadTotWithPres - eng_calib_dead_emb0 - eng_calib_dead_tile0
1096 - eng_calib_dead_tileg3 - eng_calib_dead_eme0 - eng_calib_dead_hec0 - eng_calib_dead_fcal
1097 - eng_calib_dead_leakage;
1103 switch ( (*im).second ) {
1105 xnorm = clsMomentsSum[iMoment];
1108 xnorm = engCalibTot - engClusSumCalib;
1111 xnorm = engCalibTot - engClusSumCalib;
1114 xnorm = engCalibTot - engClusSumCalib;
1117 xnorm = engCalibDeadTotWithPres;
1120 xnorm = eng_calib_dead_emb0;
1123 xnorm = eng_calib_dead_tile0;
1126 xnorm = eng_calib_dead_tileg3;
1129 xnorm = eng_calib_dead_eme0;
1132 xnorm = eng_calib_dead_hec0;
1135 xnorm = eng_calib_dead_fcal;
1138 xnorm = eng_calib_dead_leakage;
1141 xnorm = eng_calib_dead_unclass;
1144 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Not implemented for " << (*im).first <<
" " << (*im).second);
1149 const double inv_xnorm = 1. / xnorm;
1150 for(
unsigned int i_cls=0; i_cls<clusColl.size(); i_cls++){
1176 const EventContext& ctx)
1181 std::vector<const CaloCalibrationHitContainer *> v_cchc;
1184 v_cchc.push_back(cchc.
cptr());
1187 std::vector<const CaloCalibrationHitContainer *> v_dmcchc;
1190 v_dmcchc.push_back(cchc.
cptr());
1194 double engCalibTot = 0.0;
1200 ATH_MSG_ERROR(
"Error! Bad identifier " << myId <<
" in container '" << cchc->Name() <<
"',"
1205 ATH_MSG_ERROR(
"Error! Bad identifier (nor lar or tile) " << myId <<
" in container '" << cchc->Name() <<
"',"
1209 engCalibTot += hit->energyTotal();
1214 double engCalibDeadTot = 0.0;
1215 double engDefaultCalculator = 0.0;
1221 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1226 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Bad dead material identifier (nor lar_dm or tile_dm) " << myId <<
" in container '" << dmcchc->Name() <<
"',"
1230 engCalibDeadTot += hit->energyTotal();
1235 ATH_MSG_ERROR(
"GetLCSinglePionsPerf::fill_moments() -> Error! Absent DM description element!");
1245 double engCalibAssigned = 0.0;
1246 double engClusSumCalibPresOnly = 0.0;
1248 double mx_calib_tot, mx_calib_ooc, mx_calib_dm;
1263 engCalibAssigned += (mx_calib_tot + mx_calib_ooc + mx_calib_dm);
1265 double mx_calib_emb0, mx_calib_eme0, mx_calib_tileg3;
1269 ATH_MSG_WARNING(
"One of the moment ENG_CALIB_EMB0, ENG_CALIB_EME0, ENG_CALIB_TILEG3 is absent");
1271 engClusSumCalibPresOnly += (mx_calib_emb0+mx_calib_eme0+mx_calib_tileg3);
1276 engCalibAssigned -= engClusSumCalibPresOnly;
1298 double eta = fabs(
x);
1307 return ff*(1./
atan(5.0*1.7/200.0));