15 #include "GaudiKernel/IInterface.h"
16 #include "GaudiKernel/StatusCode.h"
28 #include "CLHEP/Units/SystemOfUnits.h"
35 #include "TProfile2D.h"
45 static const std::map<std::string, std::pair<std::string, std::string> > key2SubSkeyMap( {
46 {
"MET_RefFinal", {
"MET_Reference_AntiKt4LCTopo",
"FinalClus" } },
47 {
"MET_RefEle", {
"MET_Reference_AntiKt4LCTopo",
"RefEle" } },
48 {
"MET_RefGamma", {
"MET_Reference_AntiKt4LCTopo",
"RefGamma" } } ,
49 {
"MET_RefTau", {
"MET_Reference_AntiKt4LCTopo",
"RefTau" } },
50 {
"MET_SoftClus", {
"MET_Reference_AntiKt4LCTopo",
"SoftClus" } },
51 {
"MET_SoftTrk", {
"MET_Reference_AntiKt4LCTopo",
"FinalTrk" } },
52 {
"MET_PVSoftTrk", {
"MET_Reference_AntiKt4LCTopo",
"PVSoftTrk" } },
53 {
"MET_RefJet_JVFCut", {
"MET_Reference_AntiKt4LCTopo",
"RefJet" } },
54 {
"MET_RefJet", {
"MET_Reference_AntiKt4LCTopo",
"RefJet" } },
55 {
"MET_Muon", {
"MET_Reference_AntiKt4LCTopo",
"Muons" } },
56 {
"MET_PFlow_RefFinal", {
"MET_Reference_AntiKt4EMPFlow",
"FinalClus" } },
57 {
"MET_PFlow_RefEle", {
"MET_Reference_AntiKt4EMPFlow",
"RefEle" } },
58 {
"MET_PFlow_RefGamma", {
"MET_Reference_AntiKt4EMPFlow",
"RefGamma" } },
59 {
"MET_PFlow_RefTau", {
"MET_Reference_AntiKt4EMPFlow",
"RefTau" } },
60 {
"MET_PFlow_SoftClus", {
"MET_Reference_AntiKt4EMPFlow",
"SoftClus" } },
61 {
"MET_PFlow_SoftTrk", {
"MET_Reference_AntiKt4EMPFlow",
"FinalTrk" } },
62 {
"MET_PFlow_PVSoftTrk", {
"MET_Reference_AntiKt4EMPFlow",
"PVSoftTrk" } },
63 {
"MET_PFlow_RefJet_JVFCut", {
"MET_Reference_AntiKt4EMPFlow",
"RefJet" } },
64 {
"MET_PFlow_RefJet", {
"MET_Reference_AntiKt4EMPFlow",
"RefJet" } },
65 {
"MET_PFlow_Muon", {
"MET_Reference_AntiKt4EMPFlow",
"Muons" } },
66 {
"MET_LocalHadTopo", {
"MET_LocHadTopo",
"LocHadTopo" } },
67 {
"MET_LocHadTopo", {
"MET_LocHadTopo",
"LocHadTopo" } },
68 {
"MET_Topo", {
"MET_EMTopo",
"EMTopo" } },
69 {
"MET_Track", {
"MET_Track",
"Track" } },
70 {
"MET_PFlow", {
"MET_Reference_AntiKt4EMPFlow",
"FinalClus" } }
110 std::unordered_set<std::string> realSGKeys;
112 const auto itr = key2SubSkeyMap.find(
k);
113 if (itr != key2SubSkeyMap.end()) {
114 realSGKeys.insert(itr->second.first);
118 const auto itr = key2SubSkeyMap.find(
k);
119 if (itr != key2SubSkeyMap.end()) {
120 realSGKeys.insert(itr->second.first);
123 for (
const auto&
k : realSGKeys) {
136 if (!service(
"THistSvc",
m_thistSvc).isSuccess()) {
138 return StatusCode::FAILURE;
146 ATH_MSG_ERROR(
"JetSelTool is configured even if is not required");
147 return StatusCode::FAILURE;
168 ATH_MSG_DEBUG(
"Vector of Et ranges for calorimeter subsystems is incomplete: filling with 1's");
180 ATH_MSG_DEBUG(
"Vector of Et ranges for regions is incomplete: filling with 1's");
209 unsigned int nSources =
m_metKeys.size();
210 for (
unsigned int i = 0;
i < nSources;
i++)
229 return StatusCode::SUCCESS;
266 return StatusCode::SUCCESS;
273 ATH_MSG_DEBUG(
"in bookSourcesHistograms(" << metName.c_str() <<
")");
277 std::ostringstream hTitle;
278 std::ostringstream hxTitle;
279 std::ostringstream hyTitle;
291 if ((
m_suffix.value().find(
"EF_xe20_noMu") != std::string::npos))
298 hName =
"et_" + metName;
299 hTitle <<
"Et Distribution (" << metName <<
")";
300 hxTitle <<
"MET Et (GeV)";
302 h =
new TH1F( hName.c_str(), hTitle.str().c_str(),
m_etbin, etmin, etmax);
303 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
304 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
309 hxTitle.str(
""); hyTitle.str(
"");
311 hName =
"ex_" + metName;
312 hTitle <<
"Ex Distribution (" << metName <<
")";
313 hxTitle <<
"MET Etx (GeV)";
315 h =
new TH1F( hName.c_str(), hTitle.str().c_str(),
m_etbin, -etmax, etmax);
316 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
317 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
322 hxTitle.str(
""); hyTitle.str(
"");
324 hName =
"ey_" + metName;
325 hTitle <<
"Ey Distribution (" << metName <<
")";
326 hxTitle <<
"MET Ety (GeV)";
328 h =
new TH1F( hName.c_str(), hTitle.str().c_str(),
m_etbin, -etmax, etmax);
329 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
330 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
335 hxTitle.str(
""); hyTitle.str(
"");
337 hName =
"phi_" + metName;
338 hTitle <<
"Phi Distribution (" << metName <<
")";
339 hxTitle <<
"MET Phi (radian)";
342 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
343 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
348 hxTitle.str(
""); hyTitle.str(
"");
350 hName =
"sumet_" + metName;
351 hTitle <<
"SumEt Distribution (" << metName <<
")";
352 hxTitle <<
"SumEt (GeV)";
354 if (metName ==
"MET_Cryo" || metName ==
"MET_MuonBoy" || metName ==
"MET_CellOut_em")
356 h =
new TH1F(hName.c_str(), hTitle.str().c_str(),
m_etbin, sumetmin, sumetmax);
357 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
358 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
363 hxTitle.str(
""); hyTitle.str(
"");
368 hName =
"metVsSumEt_" + metName;
369 hTitle <<
"MET Vs SumEt Distribution (" << metName <<
")";
370 hxTitle <<
"SumEt (GeV)";
371 hyTitle <<
"MET Et (GeV)";
373 m_metVsSumEt->GetXaxis()->SetTitle(hxTitle.str().c_str());
378 hxTitle.str(
""); hyTitle.str(
"");
381 hName =
"metVsMetPhi_" + metName;
382 hTitle <<
"MET Vs MetPhi Distribution (" << metName <<
")";
383 hxTitle <<
"MET Phi (radian)";
384 hyTitle <<
"MET Et (GeV)";
391 hxTitle.str(
""); hyTitle.str(
"");
394 return StatusCode::SUCCESS;
402 std::ostringstream hName;
403 std::ostringstream hTitle;
404 std::ostringstream hxTitle;
405 std::ostringstream hyTitle;
422 hxTitle <<
"MET Et (GeV)";
424 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, etmin, etmax);
425 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
426 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
431 hxTitle.str(
""); hyTitle.str(
"");
435 hxTitle <<
"MET Etx (GeV)";
437 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, -etmax, etmax);
438 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
439 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
444 hxTitle.str(
""); hyTitle.str(
"");
448 hxTitle <<
"MET Ety (GeV)";
450 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, -etmax, etmax);
451 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
452 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
457 hxTitle.str(
""); hyTitle.str(
"");
461 hxTitle <<
"MET Phi (radian)";
464 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
465 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
470 hxTitle.str(
""); hyTitle.str(
"");
474 hxTitle <<
"SumEt (GeV)";
476 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, sumetmin, sumetmax);
477 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
478 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
483 hxTitle.str(
""); hyTitle.str(
"");
486 return StatusCode::SUCCESS;
495 std::ostringstream hName;
496 std::ostringstream hTitle;
497 std::ostringstream hxTitle;
498 std::ostringstream hyTitle;
515 hxTitle <<
"MET Et (GeV)";
517 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, etmin, etmax);
518 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
519 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
524 hxTitle.str(
""); hyTitle.str(
"");
528 hxTitle <<
"MET Etx (GeV)";
530 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, -etmax, etmax);
531 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
532 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
537 hxTitle.str(
""); hyTitle.str(
"");
541 hxTitle <<
"MET Ety (GeV)";
543 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, -etmax, etmax);
544 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
545 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
550 hxTitle.str(
""); hyTitle.str(
"");
554 hxTitle <<
"MET Phi (radian)";
557 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
558 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
563 hxTitle.str(
""); hyTitle.str(
"");
567 hxTitle <<
"SumEt (GeV)";
569 h =
new TH1F(hName.str().c_str(), hTitle.str().c_str(),
m_etbin, sumetmin, sumetmax);
570 h->GetXaxis()->SetTitle(hxTitle.str().c_str());
571 h->GetYaxis()->SetTitle(hyTitle.str().c_str());
h->GetYaxis()->SetTitleOffset(
m_tos);
576 hxTitle.str(
""); hyTitle.str(
"");
579 return StatusCode::SUCCESS;
588 std::ostringstream exTitle;
589 std::ostringstream eyTitle;
590 std::ostringstream phiTitle;
592 exTitle <<
"MET <etx> (GeV)";
593 eyTitle <<
"MET <ety> (GeV)";
594 phiTitle <<
"MET <phi> (radian)";
600 unsigned int nSources =
m_metKeys.size();
606 m_exMean =
new TProfile(
"exMean",
"Means of the Ex Sources", nSources, 0., nSources);
607 m_eyMean =
new TProfile(
"eyMean",
"Means of the Ey Sources", nSources, 0., nSources);
608 m_phiMean =
new TProfile(
"phiMean",
"Means of the Phi Sources", nSources, 0., nSources);
612 for (
unsigned int i = 0;
i < nSources;
i++)
625 m_exCalMean =
new TProfile(
"exCalMean",
"Means of the Ex Calorimeters", nCalos, 0., nCalos);
626 m_eyCalMean =
new TProfile(
"eyCalMean",
"Means of the Ey Calorimeters", nCalos, 0., nCalos);
631 for (
unsigned int i = 0;
i < nCalos;
i++)
644 m_exRegMean =
new TProfile(
"exRegMean",
"Means of the Ex Regions", nRegions, 0., nRegions);
645 m_eyRegMean =
new TProfile(
"eyRegMean",
"Means of the Ey Regions", nRegions, 0., nRegions);
650 for (
unsigned int i = 0;
i < nRegions;
i++)
661 return StatusCode::SUCCESS;
667 ATH_MSG_DEBUG(
"in bookProfileHistograms(" << metName.c_str() <<
", " << objName <<
")");
673 std::ostringstream hName;
674 std::ostringstream hTitle;
675 std::ostringstream hxTitle;
676 std::ostringstream hyTitle;
681 hName <<
"metVs" << objName <<
"Eta_" << metName;
682 hTitle <<
"MET Vs " << objName <<
" Eta Distribution (" << metName <<
")";
683 hxTitle << objName <<
" Eta";
684 hyTitle <<
"MET Et (GeV)";
685 hp =
new TProfile(hName.str().c_str(), hTitle.str().c_str(),
m_etabin, -5., +5.);
686 hp->GetXaxis()->SetTitle(hxTitle.str().c_str());
687 hp->GetYaxis()->SetTitle(hyTitle.str().c_str()); hp->GetYaxis()->SetTitleOffset(
m_tos);
688 met_mongroup.
regHist(hp).ignore();
692 hxTitle.str(
""); hyTitle.str(
"");
694 hName <<
"dphiVs" << objName <<
"Eta_" << metName;
695 hTitle <<
"DeltaPhi Vs " << objName <<
" Eta Distribution (" << metName <<
")";
696 hxTitle << objName <<
" Eta";
697 hyTitle <<
"deltaPhi (MET, " << objName <<
")";
698 hp =
new TProfile(hName.str().c_str(), hTitle.str().c_str(),
m_etabin, -5., +5.);
699 hp->GetXaxis()->SetTitle(hxTitle.str().c_str());
700 hp->GetYaxis()->SetTitle(hyTitle.str().c_str()); hp->GetYaxis()->SetTitleOffset(
m_tos);
701 met_mongroup.
regHist(hp).ignore();
705 hxTitle.str(
""); hyTitle.str(
"");
707 hName <<
"metVs" << objName <<
"Phi_" << metName;
708 hTitle <<
"MET Vs " << objName <<
" Phi Distribution (" << metName <<
")";
709 hxTitle << objName <<
" Phi (radian)";
710 hyTitle <<
"MET Et (GeV)";
712 hp->GetXaxis()->SetTitle(hxTitle.str().c_str());
713 hp->GetYaxis()->SetTitle(hyTitle.str().c_str()); hp->GetYaxis()->SetTitleOffset(
m_tos);
714 met_mongroup.
regHist(hp).ignore();
718 hxTitle.str(
""); hyTitle.str(
"");
748 hName <<
"dphiVs" << objName <<
"Phi_" << metName;
749 hTitle <<
"DeltaPhi Vs " << objName <<
" Phi Distribution (" << metName <<
")";
750 hxTitle << objName <<
" Phi (radian)";
751 hyTitle <<
"deltaPhi (MET, " << objName <<
")";
753 hp->GetXaxis()->SetTitle(hxTitle.str().c_str());
754 hp->GetYaxis()->SetTitle(hyTitle.str().c_str()); hp->GetYaxis()->SetTitleOffset(
m_tos);
755 met_mongroup.
regHist(hp).ignore();
759 hxTitle.str(
""); hyTitle.str(
"");
761 hName <<
"metVs" << objName <<
"EtaPhi_" << metName;
762 hTitle <<
"MET Vs " << objName <<
" EtaPhi Distribution (" << metName <<
")";
763 hxTitle << objName <<
" Eta";
764 hyTitle << objName <<
" Phi (radian)";
766 hp2->GetXaxis()->SetTitle(hxTitle.str().c_str());
767 hp2->GetYaxis()->SetTitle(hyTitle.str().c_str()); hp2->GetYaxis()->SetTitleOffset(
m_tos);
768 met_mongroup.
regHist(hp2).ignore();
772 hxTitle.str(
""); hyTitle.str(
"");
776 return StatusCode::SUCCESS;
789 if (!thisEventInfo.isValid())
790 ATH_MSG_DEBUG(
"No EventInfo object found! Can't access LAr event info status!");
795 return StatusCode::SUCCESS;
805 return StatusCode::SUCCESS;
819 xJetCollection = xhJetCollection.
get();
830 return StatusCode::SUCCESS;
833 if (xJetCollection->
size() > 0)
838 int counterbadjets = 0;
842 for (; jetItr != jetItrE; ++jetItr)
850 if (counterbadjets == 0)
852 return StatusCode::SUCCESS;
869 xElectrons = rhElectrons.
get();
878 if (xElectrons->
size() > 0)
880 auto eleItr = xElectrons->
begin();
893 xMuons = rhMuons.
get();
903 if (xMuons->
size() > 0)
905 auto muonItr = xMuons->
begin();
920 if (xMissEt_forCut.isValid()) {
921 float et_RefFinal = (*xMissEt_forCut)[
"FinalClus"]->met() /
CLHEP::GeV;
922 if (et_RefFinal <
m_met_cut)
return StatusCode::SUCCESS;
928 if (xJetCollection->
size() > 0){
932 for (; jetItr != jetItrE; ++jetItr)
937 if(! isgoodjet )
return StatusCode::SUCCESS;
946 auto foundIterator = key2SubSkeyMap.find(
m_metKeys[
i] );
947 if ( foundIterator == key2SubSkeyMap.end() )
continue;
948 std::string xaod_key = foundIterator->second.first;
949 std::string xaod_subkey = foundIterator->second.second;
955 if (xhMissEt.isValid()) {
956 xMissEt = xhMissEt.
get();
961 ATH_MSG_DEBUG(
"Unable to retrieve MissingETContainer: " << xaod_key);
967 if ((*xMissEt)[xaod_subkey]) {
968 float ex = (*xMissEt)[xaod_subkey]->mpx() /
CLHEP::GeV;
969 float ey = (*xMissEt)[xaod_subkey]->mpy() /
CLHEP::GeV;
971 float phi = (*xMissEt)[xaod_subkey]->phi();
972 float sumet = (*xMissEt)[xaod_subkey]->sumet() /
CLHEP::GeV;
995 if (xJetCollection != 0) {
996 for (
const xAOD::Jet* xjet : *xJetCollection ) {
1023 ATH_MSG_DEBUG(
"Unable to retrieve MissingETContainer: " << xaod_key);
1027 return StatusCode::SUCCESS;
1044 if (! xhmetCal.isValid()) {
1046 return StatusCode::SUCCESS;
1049 xmetCal = xhmetCal.
get();
1054 if (xMissEt_forCut.isValid()) {
1055 float et_RefFinal = (*xMissEt_forCut)[
"FinalClus"]->met() /
CLHEP::GeV;
1056 if (et_RefFinal <
m_met_cut)
return StatusCode::SUCCESS;
1064 xJetCollection = xhJetCollection.
get();
1065 if ( xJetCollection == 0 ) {
1070 for (
const xAOD::Jet* xjet: *xJetCollection ) {
1071 if(
m_selTool->keep(*xjet) ==
false )
return StatusCode::SUCCESS;
1080 float et = sqrt(ex*ex + ey*ey);
1081 float phi = atan2(ey, ex);
1102 return StatusCode::SUCCESS;
1117 if (xmetReg.isValid()) {
1121 std::string xaod_truth_region =
"";
1122 if (
i == 0) xaod_truth_region =
"Int_Central";
1123 else if (
i == 1) xaod_truth_region =
"Int_EndCap";
1124 else if (
i == 2) xaod_truth_region =
"Int_Forward";
1125 else xaod_truth_region =
"Int_Central";
1127 float ex = (*xmetReg)[xaod_truth_region]->mpx() /
CLHEP::GeV;
1128 float ey = (*xmetReg)[xaod_truth_region]->mpy() /
CLHEP::GeV;
1129 float et = sqrt(ex*ex + ey*ey);
1130 float phi = atan2(ey, ex);
1131 float sumet = (*xmetReg)[xaod_truth_region]->sumet() /
CLHEP::GeV;
1151 return StatusCode::SUCCESS;
1160 float dphi =
phi - objPhi;
1161 if (dphi > +
M_PI) dphi = dphi - 2.*
M_PI;
1162 if (dphi < -
M_PI) dphi = dphi + 2.*
M_PI;
1173 return StatusCode::SUCCESS;
1187 return StatusCode::SUCCESS;