ATLAS Offline Software
METSoftAssociator.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // METSoftAssociator.cxx
8 // Implementation file for class METSoftAssociator
9 //
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
11 //
12 // Author: P Loch, S Resconi, TJ Khoo, AS Mete
14 
15 // METReconstruction includes
19 
20 namespace met {
21 
22  using namespace xAOD;
23  static const SG::AuxElement::Decorator<std::vector<ElementLink<IParticleContainer> > > dec_softConst("softConstituents");
24 
25  // Constructors
28  AsgTool(name),
30  m_lcmodclus_key("LCOriginTopoClusters"),
31  m_emmodclus_key("EMOriginTopoClusters")
32  {
33  declareProperty("DecorateSoftConst", m_decorateSoftTermConst=false);
34  declareProperty("LCModClusterKey", m_lcmodclus_key);
35  declareProperty("EMModClusterKey", m_emmodclus_key);
36  }
37 
38  // Destructor
41  = default;
42 
43  // Athena algtool's Hooks
46  {
48  ATH_MSG_VERBOSE ("Initializing " << name() << "...");
51 
52  return StatusCode::SUCCESS;
53  }
54 
56  {
57  ATH_MSG_VERBOSE ("Finalizing " << name() << "...");
58  return StatusCode::SUCCESS;
59  }
60 
61  // executeTool
64  {
65 
66  // Add MET terms to the container
67  // Always do this in order that the terms exist even if the method fails
68  MissingET* metCoreCl = new MissingET(0.,0.,0.,"SoftClusCore",MissingETBase::Source::softEvent() | MissingETBase::Source::clusterLC());
69  metCont->push_back(metCoreCl);
70  MissingET* metCoreTrk = new MissingET(0.,0.,0.,"PVSoftTrkCore",MissingETBase::Source::softEvent() | MissingETBase::Source::track());
71  metCont->push_back(metCoreTrk);
72 
73  ATH_MSG_VERBOSE ("In execute: " << name() << "...");
75  if (retrieveConstituents(constits).isFailure()) {
76  ATH_MSG_WARNING("Unable to retrieve constituent containers");
77  return StatusCode::FAILURE;
78  }
79 
80  if(m_pflow){
81  if(!m_fecollKey.key().empty()){
82  // PFOs have been provided as FlowElements
85  dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >();
86  dec_softConst(*metCoreTrk).reserve(uniquePFOs->size());
87  dec_softConst(*metCoreCl) = std::vector<ElementLink<IParticleContainer> >();
88  dec_softConst(*metCoreCl).reserve(uniquePFOs->size());
89  }
90  for(const IParticle* sig : *uniquePFOs) {
91  const xAOD::FlowElement *pfo = static_cast<const xAOD::FlowElement*>(sig);
92  if (pfo->isCharged()) { // Charged PFOs
93  // We set a small -ve pt for cPFOs that were rejected
94  // by the ChargedHadronSubtractionTool
95  const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV");
96  if (PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(pfo->chargedObject(0))) ) ) {
97  // For the TST, we add the track pt, as this need not be
98  // corrected for nearby energy in the calo
99  *metCoreTrk += pfo->chargedObject(0);
100  // For CST we add the PFO pt, which is weighted down
101  // to account for energy in the calo that may not have
102  // been subtracted
103  *metCoreCl += sig;
105  dec_softConst(*metCoreTrk).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
106  dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
107  }
108  }
109  } else { // Neutral PFOs
110  if (pfo->e()>FLT_MIN) {
111  // This is a non-issue; just add the four-vector
112  *metCoreCl += sig;
113  if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
114  }
115  }
116  }
117  delete uniquePFOs;
118  }
119  else{
122  dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >();
123  dec_softConst(*metCoreTrk).reserve(uniquePFOs->size());
124  dec_softConst(*metCoreCl) = std::vector<ElementLink<IParticleContainer> >();
125  dec_softConst(*metCoreCl).reserve(uniquePFOs->size());
126  }
127  for(const auto *const sig : *uniquePFOs) {
128  const PFO *pfo = static_cast<const PFO*>(sig);
129  if (pfo->isCharged()) { // Charged PFOs
130  // We set a small -ve pt for cPFOs that were rejected
131  // by the ChargedHadronSubtractionTool
132  const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV");
133  if (PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfo->track(0)) ) ) {
134  // For the TST, we add the track pt, as this need not be
135  // corrected for nearby energy in the calo
136  *metCoreTrk += pfo->track(0);
137  // For CST we add the PFO pt, which is weighted down
138  // to account for energy in the calo that may not have
139  // been subtracted
140  *metCoreCl += sig;
142  dec_softConst(*metCoreTrk).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
143  dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
144  }
145  }
146  } else { // Neutral PFOs
147  if (pfo->e()>FLT_MIN) {
148  // This is a non-issue; just add the four-vector
149  *metCoreCl += sig;
150  if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
151  }
152  }
153  }
154  delete uniquePFOs;
155  }
156  }
157  else {
158  MissingET* metCoreEMCl = new MissingET(0.,0.,0.,"SoftClusEMCore",MissingETBase::Source::softEvent() | MissingETBase::Source::clusterEM());
159  metCont->push_back(metCoreEMCl);
160  const IParticleContainer* uniqueClusters = metMap->getUniqueSignals(constits.tcCont,MissingETBase::UsageHandler::AllCalo);
161  const IParticleContainer* uniqueTracks = constits.trkCont == nullptr ? new const IParticleContainer() : metMap->getUniqueSignals(constits.trkCont);
163  dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >();
164  dec_softConst(*metCoreTrk).reserve(uniqueTracks->size());
165  dec_softConst(*metCoreCl) = std::vector<ElementLink<IParticleContainer> >();
166  dec_softConst(*metCoreCl).reserve(uniqueClusters->size());
167  }
170 
171  for(const auto *const cl : *uniqueClusters) {
172  if (cl->e()>FLT_MIN) {
173  if(m_useModifiedClus) {
174  if(lctc.isValid() && emtc.isValid()) {
175  size_t cl_idx(cl->index());
176  // clusters at LC scale
177  *metCoreCl += (*lctc)[cl_idx];
178  if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(lctc.cptr()),cl->index());
179  // clusters at EM scale
180  *metCoreEMCl += (*emtc)[cl_idx];
181  } else {
182  ATH_MSG_WARNING("Invalid LC/EM modified cluster collections -- cannot add cluster to soft term!");
183  }
184  } else {
185  // clusters at LC scale
186  if (cl->type()==xAOD::Type::CaloCluster) {
187  CaloVertexedClusterBase stateClLC(*(static_cast<const CaloCluster*>(cl)),xAOD::CaloCluster::CALIBRATED);
188  *metCoreCl += (&stateClLC);
189  } else *metCoreCl += cl;
190  if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(cl->container()),cl->index());
191  // clusters at EM scale
192  if (cl->type()==xAOD::Type::CaloCluster) {
193  CaloVertexedClusterBase stateClEM( *(static_cast<const CaloCluster*>(cl)),xAOD::CaloCluster::UNCALIBRATED);
194  *metCoreEMCl += (&stateClEM);
195  } else *metCoreEMCl += cl;
196  }
197  }
198  }
199 
200  if(constits.pv) {
201  for(const auto *const trk : *uniqueTracks) {
202  ATH_MSG_VERBOSE("Test core track with pt " << trk->pt());
203  if(acceptTrack(static_cast<const TrackParticle*>(trk),constits.pv) && isGoodEoverP(static_cast<const TrackParticle*>(trk))) {
204  ATH_MSG_VERBOSE("Add core track with pt " << trk->pt());
205  *metCoreTrk += trk;
206  if(m_decorateSoftTermConst) dec_softConst(*metCoreTrk).emplace_back(*static_cast<const IParticleContainer*>(trk->container()),trk->index());
207 
208  }
209  }
210  }
211  delete uniqueClusters;
212  delete uniqueTracks;
213  }
214  return StatusCode::SUCCESS;
215  }
216 }
CaloVertexedClusterBase.h
Base class to evaluate cluster kinematics with a different vertex / signal state.
met::METAssociator::m_useModifiedClus
bool m_useModifiedClus
Definition: METAssociator.h:107
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::PFO_v1::track
const TrackParticle * track(unsigned int index) const
Retrieve a const pointer to a Rec::TrackParticle.
Definition: PFO_v1.cxx:691
met::METAssociator::retrieveConstituents
StatusCode retrieveConstituents(met::METAssociator::ConstitHolder &constits) const
Definition: METAssociator.cxx:161
MissingETBase::Source::track
static Types::bitmask_t track(Region reg=Region::FullAcceptance)
Bit mask for MET term from Track signal objects.
Definition: MissingETBase.h:291
met::METAssociator::ConstitHolder::pfoCont
const xAOD::PFOContainer * pfoCont
Definition: METAssociator.h:66
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
met::METAssociator::ConstitHolder::feCont
const xAOD::FlowElementContainer * feCont
Definition: METAssociator.h:67
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
met::METAssociator::m_fecollKey
SG::ReadHandleKey< xAOD::FlowElementContainer > m_fecollKey
Definition: METAssociator.h:100
xAOD::MissingETAssociationMap_v1
Definition: MissingETAssociationMap_v1.h:29
met::METAssociator::ConstitHolder::pv
const xAOD::Vertex * pv
Definition: METAssociator.h:68
xAOD::PFO_v1::e
virtual double e() const
The total energy of the particle.
Definition: PFO_v1.cxx:81
xAOD::FlowElement_v1::isCharged
bool isCharged() const
Definition: FlowElement_v1.cxx:56
met::METAssociator::ConstitHolder::tcCont
const xAOD::IParticleContainer * tcCont
Definition: METAssociator.h:65
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
met
Definition: IMETSignificance.h:24
met::METAssociator::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: METAssociator.cxx:85
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
METSoftAssociator.h
xAOD::CaloCluster_v1::CALIBRATED
@ CALIBRATED
Definition: CaloCluster_v1.h:307
met::METSoftAssociator::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: METSoftAssociator.cxx:45
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::MissingETAssociationMap_v1::getUniqueSignals
const IParticleContainer * getUniqueSignals(const IParticleContainer *signals, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::TrackCluster) const
Extract a container of constituents that are not in jets.
Definition: MissingETAssociationMap_v1.cxx:218
python.BuildSignatureFlags.sig
sig
Definition: BuildSignatureFlags.py:218
xAOD::MissingET_v1
Principal data object for Missing ET.
Definition: MissingET_v1.h:25
MissingETBase::Source::clusterLC
static Types::bitmask_t clusterLC(Region reg=Region::FullAcceptance)
Bit mask for MET term from LCTopo (locally calibrated calorimeter cell clusters) signal objects.
Definition: MissingETBase.h:298
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAODType::ParticleFlow
@ ParticleFlow
The object is a particle-flow object.
Definition: ObjectType.h:41
met::METSoftAssociator::executeTool
StatusCode executeTool(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap) const final
Definition: METSoftAssociator.cxx:63
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
met::METSoftAssociator::finalize
StatusCode finalize()
Definition: METSoftAssociator.cxx:55
MissingET
Athena::TPCnvVers::Old Athena::TPCnvVers::Old MissingET
Definition: RecTPCnv.cxx:64
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::PFO_v1::isCharged
bool isCharged() const
is a charged PFO
Definition: PFO_v1.cxx:251
PFO
Definition: ClusterMomentPlots.h:13
met::METAssociator
Definition: METAssociator.h:55
IParticleContainer
DataVector< IParticle > IParticleContainer
Definition: NavFourMom/NavFourMom/IParticleContainer.h:29
xAOD::CaloCluster_v1::UNCALIBRATED
@ UNCALIBRATED
Definition: CaloCluster_v1.h:306
xAOD::FlowElement_v1::chargedObject
const xAOD::IParticle * chargedObject(std::size_t i) const
Definition: FlowElement_v1.cxx:127
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
MissingETBase::UsageHandler::AllCalo
@ AllCalo
Inclusive except tracks.
Definition: MissingETCompositionBase.h:183
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
met::METSoftAssociator::m_decorateSoftTermConst
bool m_decorateSoftTermConst
Definition: METSoftAssociator.h:72
xAOD::FlowElement_v1::e
virtual double e() const override
The total energy of the particle.
Definition: FlowElement_v1.cxx:25
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::CaloVertexedClusterBase
Evaluate cluster kinematics with a different vertex / signal state.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedClusterBase.h:41
met::METAssociator::isGoodEoverP
bool isGoodEoverP(const xAOD::TrackParticle *trk) const
Definition: METAssociator.cxx:367
met::METAssociator::acceptTrack
bool acceptTrack(const xAOD::TrackParticle *trk, const xAOD::Vertex *pv) const
Definition: METAssociator.cxx:359
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
met::METSoftAssociator::METSoftAssociator
METSoftAssociator()
Default constructor:
met::METSoftAssociator::m_lcmodclus_key
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_lcmodclus_key
Definition: METSoftAssociator.h:75
MissingETBase::Source::clusterEM
static Types::bitmask_t clusterEM(Region reg=Region::FullAcceptance)
Bit mask for MET term from EMTopo signal objects.
Definition: MissingETBase.h:305
met::METAssociator::m_pflow
bool m_pflow
Definition: METAssociator.h:103
CaloClusterContainer.h
met::METSoftAssociator::m_emmodclus_key
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_emmodclus_key
Definition: METSoftAssociator.h:76
met::METAssociator::ConstitHolder::trkCont
const xAOD::TrackParticleContainer * trkCont
Definition: METAssociator.h:63
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
met::METSoftAssociator::~METSoftAssociator
~METSoftAssociator()
met::METAssociator::m_cleanChargedPFO
bool m_cleanChargedPFO
Definition: METAssociator.h:109
MissingETBase::Source::softEvent
static Types::bitmask_t softEvent(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed soft event.
Definition: MissingETBase.h:264
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
met::METAssociator::ConstitHolder
Definition: METAssociator.h:62
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25