ATLAS Offline Software
Loading...
Searching...
No Matches
METSoftTermsTool.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// METSoftTermsTool.cxx
8// Implementation file for class METSoftTermsTool
9//
10// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
11//
12// Author: P Loch, S Resconi, TJ Khoo
14
15// METReconstruction includes
17
18// MET EDM
22
23// Tracking EDM
26
27// Calo EDM
29
30// Calo helpers
32
33namespace met {
34
35 using std::vector;
36 //
37 using xAOD::IParticle;
38 //
42 //
45 //
46 using xAOD::MissingET;
50
51 // Constructors
56 {
57 }
58
59 // Athena algtool's Hooks
62 {
64 ATH_MSG_VERBOSE ("Initializing " << name() << "...");
65
66 // use string property and convert to int?
67 if(m_inputType.value() == "Clusters") m_st_objtype = xAOD::Type::CaloCluster;
68 else if(m_inputType.value() == "Tracks") m_st_objtype = xAOD::Type::TrackParticle;
69 else {
70 ATH_MSG_FATAL("Invalid input collection type " << m_inputType.value() << " supplied!");
71 }
72
73 // ReadHandleKey(s)
76
77 return StatusCode::SUCCESS;
78 }
79
80 // Will need to have different treatments here for clusters and tracks
81 bool METSoftTermsTool::accept(const xAOD::IParticle* object) const
82 {
83
84 if(object->type() != m_st_objtype){
85 ATH_MSG_WARNING("Type mismatch: Expected " << m_st_objtype << ", given " << object->type());
86 return false;
87 }
88
89 // Apply cuts
91 ATH_MSG_VERBOSE("Check if cluster is accepted");
92
93 const xAOD::CaloCluster* clus = static_cast<const xAOD::CaloCluster*>(object);
94 return (clus) ? accept(clus) : false;
95
96 } // end of if using clusters
98 ATH_MSG_VERBOSE("Check if track is accepted");
99
100 const xAOD::TrackParticle* track = static_cast<const xAOD::TrackParticle*>(object);
101 return (track) ? accept(track) : false;
102
103 } // end of if using tracks
104
105 return false; // Default
106 }
107
109 {
110 if(!clus) return false;
111 if(m_cl_vetoNegE && clus->e()<0) return false;
112 if(m_cl_onlyNegE && clus->e()>0) return false;
113
114 return true;
115 }
116
118 {
119 // if(!trk) return false;
120
121// if(fabs(trk->pt())<500/*MeV*/ || fabs(trk->eta())>2.5) return false;
122//
123// // could add some error checking to make sure we successfully read the details
124// uint8_t nPixHits(0), nSctHits(0);
125// trk->summaryValue(nPixHits,xAOD::numberOfPixelHits);
126// if(nPixHits<1) return false;
127// trk->summaryValue(nSctHits,xAOD::numberOfSCTHits);
128// if(nSctHits<6) return false;
129
130 return true;
131 }
132
135 std::vector<const xAOD::IParticle*>& acceptedSignals,
136 MissingETBase::Types::weight_t& /*objWeight*/) const
137 {
138
139 // Check/Resolve overlap
140 bool objsused = false;
142 ATH_MSG_DEBUG("Check for used clusters");
143 objsused = metMap->checkUsage(acceptedSignals,MissingETBase::UsageHandler::OnlyCluster);
144 }
146 ATH_MSG_DEBUG("Check for used tracks");
147 objsused = metMap->checkUsage(acceptedSignals,MissingETBase::UsageHandler::OnlyTrack);
148 }
149 if(!objsused) {
150 ATH_MSG_DEBUG("No objects used.");
151 }
152
153 ATH_MSG_DEBUG( acceptedSignals.size() << " retained after overlap removal");
154
155 return acceptedSignals.empty();
156 }
157
158 // overload for convenience
160 std::vector<const xAOD::IParticle*>& acceptedSignals) const
161 {
162 const xAOD::IParticle* dummyObject = nullptr; // Just a dummy object
163 MissingETBase::Types::weight_t dummyObjWeight(1.,1.,1.); // Currently use a default value
164 return resolveOverlap(dummyObject, metMap, acceptedSignals, dummyObjWeight);
165 }
166
168 {
169
170 ATH_MSG_DEBUG ("In execute: " << name() << "...");
171
172 vector<const IParticle*> signalList;
174 // Retrieve the calo container
176 if (!caloClusCont.isValid()) {
177 ATH_MSG_WARNING("Unable to retrieve input calo cluster container");
178 }
179
180 signalList.reserve(caloClusCont->size());
181 //stateHelperList.reserve(caloClusCont->size());
182
184 metTerm->setSource(source);
185
187 if(iter==metMap->end()) {
188 ATH_MSG_WARNING("Could not find current METComponent in MET Map!");
189 return StatusCode::SUCCESS;
190 }
191 MissingETComponent* newComp = *iter;
193
194 // Loop over all clusters
195 for(const auto *iClus : *caloClusCont) {
196 // Check if cluster satisfies the requirements
197 if( this->accept(iClus)) {
198 // Add the selected clusters to the list
199 signalList.push_back(iClus);
200 }
201 } // end loop over clusters
202
203 ATH_MSG_DEBUG("Selected " << signalList.size() << " topoclusters for soft MET");
204
205 } // end if Clusters
207
208 // Retrieve the track container
210 if (!trackParCont.isValid()) {
211 ATH_MSG_WARNING("Unable to retrieve input track particle container");
212 }
213 signalList.reserve(trackParCont->size());
214
215 MissingETBase::Types::bitmask_t source = MissingETBase::Source::Type::SoftEvent | MissingETBase::Source::idTrack();
216 metTerm->setSource(source);
217
219 if(iter==metMap->end()) {
220 ATH_MSG_WARNING("Could not find current METComponent in MET Map!");
221 return StatusCode::SUCCESS;
222 }
223 MissingETComponent* newComp = *iter;
225
226 // Loop over all tracks
227 for(const auto *iTrk : *trackParCont) {
228 // Check if track satisfies the requirements
229 if( this->accept(iTrk) ) {
230 // Add the selected track particles to the list
231 signalList.push_back(iTrk);
232 }
233 } // end loop over tracks
234
235 ATH_MSG_DEBUG("Selected " << signalList.size() << " tracks for soft MET");
236
237 } // end if Tracks
238
239 // Resolve overlap: signalList is accessed by reference and updated w/ content that is not
240 // associated to any object. True if signalList size 0, i.e. nothing to add to MET
241 if( this->resolveOverlap(metMap,signalList) ) return StatusCode::SUCCESS;
242
243 // Loop over the content and add to MET
244 vector<const IParticle*> dummyList;
245 MissingETBase::Types::weight_t unitWeight(1.,1.,1.);
246
247 for(const IParticle* part : signalList) this->addToMET(part,dummyList,metTerm,metMap,unitWeight);
248
249 ATH_MSG_DEBUG( "Map contains " << (*MissingETComposition::find(metMap,metTerm))->objects().size() << " soft signals" );
250
251 return StatusCode::SUCCESS;
252 }
253
254}
255
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Base class to evaluate cluster kinematics with a different vertex / signal state.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
METBuilderTool(const std::string &name)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual bool addToMET(const xAOD::IParticle *object, const std::vector< const xAOD::IParticle * > &acceptedSignals, xAOD::MissingET *metTerm, xAOD::MissingETComponentMap *metMap, MissingETBase::Types::weight_t &objWeight, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::TrackCluster) const
Gaudi::Property< bool > m_cl_onlyNegE
virtual bool resolveOverlap(const xAOD::IParticle *object, xAOD::MissingETComponentMap *metMap, std::vector< const xAOD::IParticle * > &acceptedSignals, MissingETBase::Types::weight_t &objWeight) const override
virtual bool accept(const xAOD::IParticle *object) const override
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusterKey
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< bool > m_cl_vetoNegE
xAOD::Type::ObjectType m_st_objtype
Gaudi::Property< std::string > m_inputType
virtual StatusCode executeTool(xAOD::MissingET *metTerm, xAOD::MissingETComponentMap *metMap) const override
virtual double e() const
The total energy of the particle.
Class providing the definition of the 4-vector interface.
bool checkUsage(const IParticle *pPart, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const
Check if a given object is already used in MET.
bool setStatusWord(MissingETBase::Types::bitmask_t sw=MissingETBase::Status::clearedStatus())
Set the statusword of a MET term.
void setSource(MissingETBase::Types::bitmask_t src)
Set the source of the MET object.
uint64_t bitmask_t
Type for status word bit mask.
xAOD::MissingETComponent_v1::Weight weight_t
Type for kinematic weight.
@ OnlyCluster
CaloCluster based only.
@ TrackParticle
The object is a charged track particle.
Definition ObjectType.h:43
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
MissingETComponent_v1 MissingETComponent
Version control by type definition.
MissingETComponentMap_v1 MissingETComponentMap
Version control by type definition.
MissingET_v1 MissingET
Version control by type defintion.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
static Types::bitmask_t idTrack(Region reg=Region::FullAcceptance)
Bit pattern indicating a ID Track MET term.
static Types::bitmask_t cluster(Region reg=Region::FullAcceptance)
Bit mask for MET term from any cluster signal objects.
static Types::bitmask_t softEvent(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed soft event.
static Types::bitmask_t contributedSoftTerm()
General soft term contribution tag accessor.
static MissingETComponentMap::const_iterator find(const MissingETComponentMap *pMap, const MissingET *pmetObj)
Find non-modifiable contribution for a given MET object.
Collection of functions managing the MET composition map and association map.