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;
24
25 // Constructors
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() << "...");
49 ATH_CHECK( m_lcmodclus_key.initialize());
50 ATH_CHECK( m_emmodclus_key.initialize());
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) {
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}
#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.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
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
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
METAssociator(const std::string &name)
bool isGoodEoverP(const xAOD::TrackParticle *trk) const
StatusCode retrieveConstituents(met::METAssociator::ConstitHolder &constits) 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
StatusCode executeTool(xAOD::MissingETContainer *metCont, xAOD::MissingETAssociationMap *metMap) const final
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_lcmodclus_key
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.
static const SG::AuxElement::Decorator< std::vector< ElementLink< IParticleContainer > > > dec_softConst("softConstituents")
static const SG::ConstAccessor< char > PVMatchedAcc("matchedToPV")
@ 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