ATLAS Offline Software
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
13 namespace {
14  const static SG::ConstAuxElement::Decorator<char> decSelection("SelectedByMuonRemovalCombination");
15  const static SG::ConstAccessor<ElementLink<xAOD::TauJetContainer>> linkAcc("originalTauJet");
16 }
17 
18 namespace CP
19 {
20 
22  {
23  ATH_MSG_INFO("Initializing " << name() << "...");
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;
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 }
CP::TauCombineMuonRMTausAlg::initialize
StatusCode initialize() override
Definition: TauCombineMuonRMTausAlg.cxx:21
CP::TauCombineMuonRMTausAlg::m_systematicsList
SysListHandle m_systematicsList
Definition: TauCombineMuonRMTausAlg.h:28
xAOD::TauJetAuxContainer_v3
Temporary container used until we have I/O for AuxStoreInternal.
Definition: TauJetAuxContainer_v3.h:39
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::TauJetAuxContainer
TauJetAuxContainer_v3 TauJetAuxContainer
Definition of the current taujet auxiliary container.
Definition: TauJetAuxContainer.h:22
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::TauCombineMuonRMTausAlg::m_outputTauHandle
SysWriteHandle< xAOD::TauJetContainer > m_outputTauHandle
Definition: TauCombineMuonRMTausAlg.h:37
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
xAOD::TauJet
TauJet_v3 TauJet
Definition of the current "tau version".
Definition: Event/xAOD/xAODTau/xAODTau/TauJet.h:17
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CP::TauCombineMuonRMTausAlg::m_tauHandle
SysReadHandle< xAOD::TauJetContainer > m_tauHandle
Definition: TauCombineMuonRMTausAlg.h:29
xAOD::TauJetContainer
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
Definition: Event/xAOD/xAODTau/xAODTau/TauJetContainer.h:17
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::setOriginalObjectLink
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...
Definition: IParticleHelpers.cxx:30
CP::TauCombineMuonRMTausAlg::m_MuonRMtauHandle
SysReadHandle< xAOD::TauJetContainer > m_MuonRMtauHandle
Definition: TauCombineMuonRMTausAlg.h:33
TauCombineMuonRMTausAlg.h
CP::TauCombineMuonRMTausAlg::execute
StatusCode execute() override
Definition: TauCombineMuonRMTausAlg.cxx:32
IParticleHelpers.h
TauAnalysisTools::combineTauJetsWithMuonRM
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
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:620