ATLAS Offline Software
DiTauMassCalculatorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 namespace CP {
11  using ROOT::Math::PtEtaPhiMVector;
12 
14  {
15 
16  // the Missing Mass Calculator tool
17  ANA_CHECK(m_mmc.retrieve());
18 
19  // input handles
22 
25 
28 
31 
35 
36  // output handles
51 
53 
54  return StatusCode::SUCCESS;
55  }
56 
58  {
59  for (const auto &sys : m_systematicsList.systematicsVector())
60  {
61  // retrieve the EventInfo
62  const xAOD::EventInfo *evtInfo = nullptr;
63  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
64 
65  // check the preselection
66  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
67  continue;
68 
69  // retrieve objects
70  const xAOD::ElectronContainer *electrons = nullptr;
72  const xAOD::MuonContainer *muons = nullptr;
74  const xAOD::TauJetContainer *taus = nullptr;
76  const xAOD::JetContainer *jets = nullptr;
78  const xAOD::MissingETContainer *met = nullptr;
79  ANA_CHECK(m_metHandle.retrieve(met, sys));
80 
81  // apply object-wise selection
86 
87  for (const xAOD::Electron *el : *electrons)
88  {
90  selected_electrons.push_back(el);
91  }
92 
93  for (const xAOD::Muon *mu : *muons)
94  {
96  selected_muons.push_back(mu);
97  }
98 
99  for (const xAOD::TauJet *tau : *taus)
100  {
101  if (m_tauSelection.getBool(*tau, sys))
102  selected_taus.push_back(tau);
103  }
104 
105  for (const xAOD::Jet *jet : *jets)
106  {
107  if (m_jetSelection.getBool(*jet, sys))
108  selected_jets.push_back(jet);
109  }
110 
111  int nJets = selected_jets.size();
112 
113  const xAOD::IParticle *vis1 = 0, *vis2 = 0;
114  // to assign the visible particles on which to run the MMC, we assume that the user would prefer
115  // 1) tau_had + tau_had
116  // 2) tau_had + e
117  // 3) tau_had + mu
118  // 4) e + mu
119  // 5) mu + mu
120  // 6) e + e
121  // To force a custom ordering, simply decorate your desired selection onto the particles before running this algorithm.
122  // e.g. you could "book" an OSSF pair of light leptons as originating from a Z boson, and remove them from consideration here.
123 
124  if (selected_taus.size() >= 2)
125  {
126  vis1 = selected_taus.at(0);
127  vis2 = selected_taus.at(1);
128  }
129  else if (selected_taus.size() == 1 && selected_electrons.size() >= 1)
130  {
131  vis1 = selected_taus.at(0);
132  vis2 = selected_electrons.at(0);
133  }
134  else if (selected_taus.size() == 1 && selected_muons.size() >= 1)
135  {
136  vis1 = selected_taus.at(0);
137  vis2 = selected_muons.at(0);
138  }
139  else if (selected_electrons.size() >= 1 && selected_muons.size() >= 1)
140  {
141  vis1 = selected_electrons.at(0);
142  vis2 = selected_muons.at(0);
143  }
144  else if (selected_muons.size() >= 2)
145  {
146  vis1 = selected_muons.at(0);
147  vis2 = selected_muons.at(1);
148  }
149  else if (selected_electrons.size() >= 2)
150  {
151  vis1 = selected_electrons.at(0);
152  vis2 = selected_electrons.at(1);
153  }
154  else
155  {
156  ANA_MSG_WARNING("Not enough charged leptons in the event to run the MMC!");
157  }
158 
159  if ((*met)["Final"] == nullptr) {
160  ANA_MSG_ERROR("The MET term " << "Final" << " doesn't exist! Aborting.");
161  return StatusCode::FAILURE;
162  }
163 
164  ANA_CHECK(m_mmc->apply(*evtInfo, vis1, vis2, (*met)["Final"], nJets));
165 
166  // retrieve the output variables and decorate them
167  PtEtaPhiMVector null4V(0.0, 0.0, 0.0, 0.0);
168  int fitStatus = m_mmc->GetFitStatus(0);
169  double mlm_mass = fitStatus == 1 ? m_mmc->GetFittedMass(DiTauMassTools::MMCFitMethod::MLM) : -1;
170  if (m_doMAXW) {
171  double maxw_mass = fitStatus == 1 ? m_mmc->GetFittedMass(DiTauMassTools::MMCFitMethod::MAXW) : -1;
172  PtEtaPhiMVector maxw_res_4vect = fitStatus == 1 ? m_mmc->GetResonanceVec(DiTauMassTools::MMCFitMethod::MAXW) : null4V;
173  PtEtaPhiMVector maxw_nu1_4vect = fitStatus == 1 ? m_mmc->GetNeutrino4vec(DiTauMassTools::MMCFitMethod::MAXW, 0) : null4V;
174  PtEtaPhiMVector maxw_nu2_4vect = fitStatus == 1 ? m_mmc->GetNeutrino4vec(DiTauMassTools::MMCFitMethod::MAXW, 1) : null4V;
175  PtEtaPhiMVector maxw_tau1_4vect = fitStatus == 1 ? m_mmc->GetTau4vec(DiTauMassTools::MMCFitMethod::MAXW, 0) : null4V;
176  PtEtaPhiMVector maxw_tau2_4vect = fitStatus == 1 ? m_mmc->GetTau4vec(DiTauMassTools::MMCFitMethod::MAXW, 1) : null4V;
177  m_maxw_mass_decor.set(*evtInfo, maxw_mass, sys);
178  m_maxw_res_4vect_decor.set(*evtInfo, maxw_res_4vect, sys);
179  m_maxw_nu1_4vect_decor.set(*evtInfo, maxw_nu1_4vect, sys);
180  m_maxw_nu2_4vect_decor.set(*evtInfo, maxw_nu2_4vect, sys);
181  m_maxw_tau1_4vect_decor.set(*evtInfo, maxw_tau1_4vect, sys);
182  m_maxw_tau2_4vect_decor.set(*evtInfo, maxw_tau2_4vect, sys);
183  }
184  if (m_doMLNU3P) {
185  double mlnu3p_mass = fitStatus == 1 ? m_mmc->GetFittedMass(DiTauMassTools::MMCFitMethod::MLNU3P) : -1;
186  PtEtaPhiMVector mlnu3p_res_4vect = fitStatus == 1 ? m_mmc->GetResonanceVec(DiTauMassTools::MMCFitMethod::MLNU3P) : null4V;
187  PtEtaPhiMVector mlnu3p_nu1_4vect = fitStatus == 1 ? m_mmc->GetNeutrino4vec(DiTauMassTools::MMCFitMethod::MLNU3P, 0) : null4V;
188  PtEtaPhiMVector mlnu3p_nu2_4vect = fitStatus == 1 ? m_mmc->GetNeutrino4vec(DiTauMassTools::MMCFitMethod::MLNU3P, 1) : null4V;
189  PtEtaPhiMVector mlnu3p_tau1_4vect = fitStatus == 1 ? m_mmc->GetTau4vec(DiTauMassTools::MMCFitMethod::MLNU3P, 0) : null4V;
190  PtEtaPhiMVector mlnu3p_tau2_4vect = fitStatus == 1 ? m_mmc->GetTau4vec(DiTauMassTools::MMCFitMethod::MLNU3P, 1) : null4V;
191  m_mlnu3p_mass_decor.set(*evtInfo, mlnu3p_mass, sys);
192  m_mlnu3p_res_4vect_decor.set(*evtInfo, mlnu3p_res_4vect, sys);
193  m_mlnu3p_nu1_4vect_decor.set(*evtInfo, mlnu3p_nu1_4vect, sys);
194  m_mlnu3p_nu2_4vect_decor.set(*evtInfo, mlnu3p_nu2_4vect, sys);
195  m_mlnu3p_tau1_4vect_decor.set(*evtInfo, mlnu3p_tau1_4vect, sys);
196  m_mlnu3p_tau2_4vect_decor.set(*evtInfo, mlnu3p_tau2_4vect, sys);
197  }
198  m_fitStatus_decor.set(*evtInfo, fitStatus, sys);
199  m_mlm_mass_decor.set(*evtInfo, mlm_mass, sys);
200  }
201 
202  return StatusCode::SUCCESS;
203  }
204 
206  {
207  ANA_CHECK(m_mmc->finalize());
208 
209  return StatusCode::SUCCESS;
210  }
211 
212 } // namespace
CP::DiTauMassCalculatorAlg::m_jetsHandle
SysReadHandle< xAOD::JetContainer > m_jetsHandle
Definition: DiTauMassCalculatorAlg.h:58
CP::DiTauMassCalculatorAlg::m_maxw_nu2_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_maxw_nu2_4vect_decor
Definition: DiTauMassCalculatorAlg.h:82
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
CP::DiTauMassCalculatorAlg::m_doMAXW
Gaudi::Property< bool > m_doMAXW
Definition: DiTauMassCalculatorAlg.h:42
ConstDataVector::at
ElementProxy at(size_type n)
Access an element, as an lvalue.
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
DiTauMassTools::MMCFitMethod::MLM
@ MLM
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:46
CP::DiTauMassCalculatorAlg::m_maxw_tau2_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_maxw_tau2_4vect_decor
Definition: DiTauMassCalculatorAlg.h:84
CP::DiTauMassCalculatorAlg::initialize
virtual StatusCode initialize() override
Definition: DiTauMassCalculatorAlg.cxx:13
CP::DiTauMassCalculatorAlg::m_mlnu3p_tau1_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_mlnu3p_tau1_4vect_decor
Definition: DiTauMassCalculatorAlg.h:78
CP::DiTauMassCalculatorAlg::m_muonsHandle
SysReadHandle< xAOD::MuonContainer > m_muonsHandle
Definition: DiTauMassCalculatorAlg.h:55
CP::DiTauMassCalculatorAlg::m_metHandle
SysReadHandle< xAOD::MissingETContainer > m_metHandle
Definition: DiTauMassCalculatorAlg.h:64
CP::DiTauMassCalculatorAlg::m_fitStatus_decor
SysWriteDecorHandle< int > m_fitStatus_decor
Definition: DiTauMassCalculatorAlg.h:71
CP::DiTauMassCalculatorAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
Definition: DiTauMassCalculatorAlg.h:66
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::DiTauMassCalculatorAlg::m_mlnu3p_nu1_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_mlnu3p_nu1_4vect_decor
Definition: DiTauMassCalculatorAlg.h:76
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
DiTauMassCalculatorAlg.h
CP::DiTauMassCalculatorAlg::m_tausHandle
SysReadHandle< xAOD::TauJetContainer > m_tausHandle
Definition: DiTauMassCalculatorAlg.h:61
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::DiTauMassCalculatorAlg::m_maxw_res_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_maxw_res_4vect_decor
Definition: DiTauMassCalculatorAlg.h:80
CP::DiTauMassCalculatorAlg::m_muonSelection
SysReadSelectionHandle m_muonSelection
Definition: DiTauMassCalculatorAlg.h:56
CP::DiTauMassCalculatorAlg::m_electronsHandle
SysReadHandle< xAOD::ElectronContainer > m_electronsHandle
Definition: DiTauMassCalculatorAlg.h:52
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
met
Definition: IMETSignificance.h:24
CP::DiTauMassCalculatorAlg::m_tauSelection
SysReadSelectionHandle m_tauSelection
Definition: DiTauMassCalculatorAlg.h:62
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
CP::DiTauMassCalculatorAlg::m_electronSelection
SysReadSelectionHandle m_electronSelection
Definition: DiTauMassCalculatorAlg.h:53
CP::DiTauMassCalculatorAlg::m_mlnu3p_mass_decor
SysWriteDecorHandle< double > m_mlnu3p_mass_decor
Definition: DiTauMassCalculatorAlg.h:74
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::DiTauMassCalculatorAlg::m_mmc
ToolHandle< DiTauMassTools::MissingMassTool > m_mmc
Definition: DiTauMassCalculatorAlg.h:46
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
CP::DiTauMassCalculatorAlg::m_maxw_nu1_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_maxw_nu1_4vect_decor
Definition: DiTauMassCalculatorAlg.h:81
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::DiTauMassCalculatorAlg::finalize
virtual StatusCode finalize() override
Definition: DiTauMassCalculatorAlg.cxx:205
CP::DiTauMassCalculatorAlg::m_doMLNU3P
Gaudi::Property< bool > m_doMLNU3P
Definition: DiTauMassCalculatorAlg.h:43
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
CP::DiTauMassCalculatorAlg::m_jetSelection
SysReadSelectionHandle m_jetSelection
Definition: DiTauMassCalculatorAlg.h:59
CP::DiTauMassCalculatorAlg::m_mlnu3p_nu2_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_mlnu3p_nu2_4vect_decor
Definition: DiTauMassCalculatorAlg.h:77
CP::DiTauMassCalculatorAlg::m_preselection
SysReadSelectionHandle m_preselection
Definition: DiTauMassCalculatorAlg.h:68
CP::DiTauMassCalculatorAlg::m_mlnu3p_res_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_mlnu3p_res_4vect_decor
Definition: DiTauMassCalculatorAlg.h:75
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CP::DiTauMassCalculatorAlg::m_maxw_tau1_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_maxw_tau1_4vect_decor
Definition: DiTauMassCalculatorAlg.h:83
xAOD::Electron_v1
Definition: Electron_v1.h:34
CP::DiTauMassCalculatorAlg::execute
virtual StatusCode execute() override
Definition: DiTauMassCalculatorAlg.cxx:57
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::DiTauMassCalculatorAlg::m_maxw_mass_decor
SysWriteDecorHandle< double > m_maxw_mass_decor
Definition: DiTauMassCalculatorAlg.h:72
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
DiTauMassTools::MMCFitMethod::MAXW
@ MAXW
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:46
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
DiTauMassTools::MMCFitMethod::MLNU3P
@ MLNU3P
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:46
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
CP::DiTauMassCalculatorAlg::m_systematicsList
SysListHandle m_systematicsList
Definition: DiTauMassCalculatorAlg.h:49
CP::DiTauMassCalculatorAlg::m_mlnu3p_tau2_4vect_decor
SysWriteDecorHandle< PtEtaPhiMVector > m_mlnu3p_tau2_4vect_decor
Definition: DiTauMassCalculatorAlg.h:79
CP::DiTauMassCalculatorAlg::m_mlm_mass_decor
SysWriteDecorHandle< double > m_mlm_mass_decor
Definition: DiTauMassCalculatorAlg.h:73
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17