ATLAS Offline Software
Loading...
Searching...
No Matches
METSoftAssociator.cxx
Go to the documentation of this file.
1
2
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
20namespace met {
21
22 using namespace xAOD;
23 static const SG::Decorator<std::vector<ElementLink<IParticleContainer> > > dec_softConst("softConstituents"); // TODO Should this be a set of WriteDecorHandles?
24
25 // Constructors
30 {
31 }
32
33 // Destructor
36 = default;
37
38 // Athena algtool's Hooks
41 {
43 ATH_MSG_VERBOSE ("Initializing " << name() << "...");
44 ATH_CHECK( m_lcmodclus_key.initialize());
45 ATH_CHECK( m_emmodclus_key.initialize());
46
47 return StatusCode::SUCCESS;
48 }
49
51 {
52 ATH_MSG_VERBOSE ("Finalizing " << name() << "...");
53 return StatusCode::SUCCESS;
54 }
55
56 // executeTool
58 StatusCode METSoftAssociator::executeTool(xAOD::MissingETContainer* metCont, xAOD::MissingETAssociationMap* metMap, const EventContext& ctx) const
59 {
60
61 // Add MET terms to the container
62 // Always do this in order that the terms exist even if the method fails
63 MissingET* metCoreCl = new MissingET(0.,0.,0.,"SoftClusCore",MissingETBase::Source::softEvent() | MissingETBase::Source::clusterLC());
64 metCont->push_back(metCoreCl);
65 MissingET* metCoreTrk = new MissingET(0.,0.,0.,"PVSoftTrkCore",MissingETBase::Source::softEvent() | MissingETBase::Source::track());
66 metCont->push_back(metCoreTrk);
67
68 ATH_MSG_VERBOSE ("In execute: " << name() << "...");
70 if (retrieveConstituents(constits, ctx).isFailure()) {
71 ATH_MSG_WARNING("Unable to retrieve constituent containers");
72 return StatusCode::FAILURE;
73 }
74
75 if(m_pflow){
76 if(!m_fecollKey.key().empty()){
77 // PFOs have been provided as FlowElements
80 dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >();
81 dec_softConst(*metCoreTrk).reserve(uniquePFOs->size());
82 dec_softConst(*metCoreCl) = std::vector<ElementLink<IParticleContainer> >();
83 dec_softConst(*metCoreCl).reserve(uniquePFOs->size());
84 }
85 for(const IParticle* sig : *uniquePFOs) {
86 const xAOD::FlowElement *pfo = static_cast<const xAOD::FlowElement*>(sig);
87 if (pfo->isCharged()) { // Charged PFOs
88 // We set a small -ve pt for cPFOs that were rejected
89 // by the ChargedHadronSubtractionTool
90 const static SG::ConstAccessor<char> PVMatchedAcc("matchedToPV");
91 if (PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(pfo->chargedObject(0))) ) ) {
92 // For the TST, we add the track pt, as this need not be
93 // corrected for nearby energy in the calo
94 *metCoreTrk += pfo->chargedObject(0);
95 // For CST we add the PFO pt, which is weighted down
96 // to account for energy in the calo that may not have
97 // been subtracted
98 *metCoreCl += sig;
100 dec_softConst(*metCoreTrk).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
101 dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
102 }
103 }
104 } else { // Neutral PFOs
105 if (pfo->e()>FLT_MIN) {
106 // This is a non-issue; just add the four-vector
107 *metCoreCl += sig;
108 if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
109 }
110 }
111 }
112 delete uniquePFOs;
113 }
114 else{
117 dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >();
118 dec_softConst(*metCoreTrk).reserve(uniquePFOs->size());
119 dec_softConst(*metCoreCl) = std::vector<ElementLink<IParticleContainer> >();
120 dec_softConst(*metCoreCl).reserve(uniquePFOs->size());
121 }
122 for(const auto *const sig : *uniquePFOs) {
123 const PFO *pfo = static_cast<const PFO*>(sig);
124 if (pfo->isCharged()) { // Charged PFOs
125 // We set a small -ve pt for cPFOs that were rejected
126 // by the ChargedHadronSubtractionTool
127 const static SG::ConstAccessor<char> PVMatchedAcc("matchedToPV");
128 if (PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfo->track(0)) ) ) {
129 // For the TST, we add the track pt, as this need not be
130 // corrected for nearby energy in the calo
131 *metCoreTrk += pfo->track(0);
132 // For CST we add the PFO pt, which is weighted down
133 // to account for energy in the calo that may not have
134 // been subtracted
135 *metCoreCl += sig;
137 dec_softConst(*metCoreTrk).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
138 dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
139 }
140 }
141 } else { // Neutral PFOs
142 if (pfo->e()>FLT_MIN) {
143 // This is a non-issue; just add the four-vector
144 *metCoreCl += sig;
145 if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(sig->container()),sig->index());
146 }
147 }
148 }
149 delete uniquePFOs;
150 }
151 }
152 else {
153 MissingET* metCoreEMCl = new MissingET(0.,0.,0.,"SoftClusEMCore",MissingETBase::Source::softEvent() | MissingETBase::Source::clusterEM());
154 metCont->push_back(metCoreEMCl);
155 const IParticleContainer* uniqueClusters = metMap->getUniqueSignals(constits.tcCont,MissingETBase::UsageHandler::AllCalo);
156 const IParticleContainer* uniqueTracks = constits.trkCont == nullptr ? new const IParticleContainer() : metMap->getUniqueSignals(constits.trkCont);
158 dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >();
159 dec_softConst(*metCoreTrk).reserve(uniqueTracks->size());
160 dec_softConst(*metCoreCl) = std::vector<ElementLink<IParticleContainer> >();
161 dec_softConst(*metCoreCl).reserve(uniqueClusters->size());
162 }
165
166 for(const auto *const cl : *uniqueClusters) {
167 if (cl->e()>FLT_MIN) {
169 if(lctc.isValid() && emtc.isValid()) {
170 size_t cl_idx(cl->index());
171 // clusters at LC scale
172 *metCoreCl += (*lctc)[cl_idx];
173 if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(lctc.cptr()),cl->index());
174 // clusters at EM scale
175 *metCoreEMCl += (*emtc)[cl_idx];
176 } else {
177 ATH_MSG_WARNING("Invalid LC/EM modified cluster collections -- cannot add cluster to soft term!");
178 }
179 } else {
180 // clusters at LC scale
181 if (cl->type()==xAOD::Type::CaloCluster) {
182 CaloVertexedClusterBase stateClLC(*(static_cast<const CaloCluster*>(cl)),xAOD::CaloCluster::CALIBRATED);
183 *metCoreCl += (&stateClLC);
184 } else *metCoreCl += cl;
185 if(m_decorateSoftTermConst) dec_softConst(*metCoreCl).emplace_back(*static_cast<const IParticleContainer*>(cl->container()),cl->index());
186 // clusters at EM scale
187 if (cl->type()==xAOD::Type::CaloCluster) {
188 CaloVertexedClusterBase stateClEM( *(static_cast<const CaloCluster*>(cl)),xAOD::CaloCluster::UNCALIBRATED);
189 *metCoreEMCl += (&stateClEM);
190 } else *metCoreEMCl += cl;
191 }
192 }
193 }
194
195 if(constits.pv) {
196 for(const auto *const trk : *uniqueTracks) {
197 ATH_MSG_VERBOSE("Test core track with pt " << trk->pt());
198 if(acceptTrack(static_cast<const TrackParticle*>(trk),constits.pv) && isGoodEoverP(static_cast<const TrackParticle*>(trk))) {
199 ATH_MSG_VERBOSE("Add core track with pt " << trk->pt());
200 *metCoreTrk += trk;
201 if(m_decorateSoftTermConst) dec_softConst(*metCoreTrk).emplace_back(*static_cast<const IParticleContainer*>(trk->container()),trk->index());
202
203 }
204 }
205 }
206 delete uniqueClusters;
207 delete uniqueTracks;
208 }
209 return StatusCode::SUCCESS;
210 }
211}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Base class to evaluate cluster kinematics with a different vertex / signal state.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Helper class to provide constant type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Gaudi::Property< bool > m_pflow
StatusCode retrieveConstituents(met::METAssociator::ConstitHolder &constits, const EventContext &ctx) const
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< bool > m_useModifiedClus
Gaudi::Property< bool > m_cleanChargedPFO
METAssociator(const std::string &name)
bool isGoodEoverP(const xAOD::TrackParticle *trk) const
SG::ReadHandleKey< xAOD::FlowElementContainer > m_fecollKey
bool acceptTrack(const xAOD::TrackParticle *trk, const xAOD::Vertex *pv) const
METSoftAssociator()
Default constructor:
StatusCode initialize()
Dummy implementation of the initialisation function.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_emmodclus_key
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_lcmodclus_key
Gaudi::Property< bool > m_decorateSoftTermConst
StatusCode executeTool(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap, const EventContext &ctx) const final
Evaluate cluster kinematics with a different vertex / signal state.
const xAOD::IParticle * chargedObject(std::size_t i) const
virtual double e() const override
The total energy of the particle.
Class providing the definition of the 4-vector interface.
const IParticleContainer * getUniqueSignals(const IParticleContainer *signals, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::TrackCluster) const
Extract a container of constituents that are not in jets.
bool isCharged() const
is a charged PFO
Definition PFO_v1.cxx:251
const TrackParticle * track(unsigned int index) const
Retrieve a const pointer to a Rec::TrackParticle.
Definition PFO_v1.cxx:691
virtual double e() const
The total energy of the particle.
Definition PFO_v1.cxx:81
@ AllCalo
Inclusive except tracks.
@ ParticleFlow
Particle Flow Object based.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
static const SG::ConstAccessor< char > PVMatchedAcc("matchedToPV")
static const SG::Decorator< std::vector< ElementLink< IParticleContainer > > > dec_softConst("softConstituents")
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
MissingET_v1 MissingET
Version control by type defintion.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16
TrackParticle_v1 TrackParticle
Reference the current persistent version:
MissingETAssociationMap_v1 MissingETAssociationMap
Version control by type defintion.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
static Types::bitmask_t clusterEM(Region reg=Region::FullAcceptance)
Bit mask for MET term from EMTopo signal objects.
static Types::bitmask_t track(Region reg=Region::FullAcceptance)
Bit mask for MET term from Track signal objects.
static Types::bitmask_t softEvent(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed soft event.
static Types::bitmask_t clusterLC(Region reg=Region::FullAcceptance)
Bit mask for MET term from LCTopo (locally calibrated calorimeter cell clusters) signal objects.
const xAOD::IParticleContainer * tcCont
const xAOD::FlowElementContainer * feCont
const xAOD::PFOContainer * pfoCont
const xAOD::TrackParticleContainer * trkCont