ATLAS Offline Software
Loading...
Searching...
No Matches
TauCombineMuonRMTausAlg.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
7
9
11
12// unnamed namespace for helpers
13namespace {
14 const static SG::ConstAuxElement::Decorator<char> decSelection("SelectedByMuonRemovalCombination");
15 const static SG::ConstAccessor<ElementLink<xAOD::TauJetContainer>> linkAcc("originalTauJet");
16}
17
18namespace CP
19{
20
22 {
23 ATH_MSG_INFO("Initializing " << name() << "...");
27 ANA_CHECK (m_systematicsList.initialize());
28 return StatusCode::SUCCESS;
29 }
30
31
33 {
34 for (const auto& sys : m_systematicsList.systematicsVector())
35 {
36 const xAOD::TauJetContainer *taus = nullptr;
37 const xAOD::TauJetContainer *muonrm_taus = nullptr;
38 ANA_CHECK (m_tauHandle.retrieve (taus, sys));
39 ANA_CHECK (m_MuonRMtauHandle.retrieve (muonrm_taus, sys));
40 for (const xAOD::TauJet* tau : *taus) decSelection(*tau) = false;
41 for (const xAOD::TauJet* tau : *muonrm_taus) decSelection(*tau) = false;
42 std::vector<const xAOD::TauJet*> combined_taus_vec = TauAnalysisTools::combineTauJetsWithMuonRM (taus, muonrm_taus);
43 // !shallow copy seems to break the subsequent algorithms. Deep copy is needed.
44 xAOD::TauJetContainer* outputTauCont = new xAOD::TauJetContainer();
45 xAOD::TauJetAuxContainer* outputTauContAux = new xAOD::TauJetAuxContainer();
46 outputTauCont->setStore(outputTauContAux);
47 for (const xAOD::TauJet* tau : combined_taus_vec){
48 if(linkAcc.isAvailable(*tau) && !linkAcc(*tau).isValid()){
49 ATH_MSG_WARNING("Invalid originalTauJet link for tau with pT="<<tau->pt());
50 continue;
51 }
52 decSelection(*tau) = true;
53 xAOD::TauJet* newTau = new xAOD::TauJet();
54 newTau->makePrivateStore(*tau);
55 if(linkAcc.isAvailable(*tau)){
56 auto link = linkAcc(*tau);
57 setOriginalObjectLink(**link, *newTau);
58 }
59 else setOriginalObjectLink(*tau, *newTau);
60 outputTauCont->push_back(newTau);
61 }
62 ANA_CHECK (evtStore()->record (outputTauCont, m_outputTauHandle.getName (sys)));
63 ANA_CHECK (evtStore()->record (outputTauContAux, m_outputTauHandle.getName (sys) + "Aux."));
64
65 // auto viewCopy = std::make_unique<ConstDataVector<xAOD::TauJetContainer>> (SG::VIEW_ELEMENTS);
66 // for (const xAOD::TauJet* tau : combined_taus_vec){
67 // decSelection(*tau) = true;
68 // viewCopy->push_back (tau);
69 // }
70 // ANA_CHECK (evtStore()->record (viewCopy.release(), m_outputTauHandle.getName (sys)));
71 }
72 return StatusCode::SUCCESS;
73 }
74}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ANA_CHECK(EXP)
check whether the given expression was successful
static Double_t taus
SysReadHandle< xAOD::TauJetContainer > m_MuonRMtauHandle
SysWriteHandle< xAOD::TauJetContainer > m_outputTauHandle
SysReadHandle< xAOD::TauJetContainer > m_tauHandle
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void makePrivateStore()
Create a new (empty) private store for this object.
Helper class to provide constant type-safe access to aux data.
SG::Decorator< T, ALLOC > Decorator
class to provide type-safe access to aux data.
Definition AuxElement.h:135
Select isolated Photons, Electrons and Muons.
std::vector< const xAOD::TauJet * > combineTauJetsWithMuonRM(const xAOD::TauJetContainer *taus_std, const xAOD::TauJetContainer *taus_muonRM)
combine the standard taujets container with the muon removal container
TauJet_v3 TauJet
Definition of the current "tau version".
TauJetAuxContainer_v3 TauJetAuxContainer
Definition of the current taujet auxiliary container.
bool setOriginalObjectLink(const IParticle &original, IParticle &copy)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
static const SG::AuxElement::Accessor< std::vector< ElementLink< EventInfoContainer_v1 > > > linkAcc("subEventLink")