ATLAS Offline Software
METSoftTermsTool.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 // 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 
33 namespace met {
34 
35  using std::vector;
36  //
37  using xAOD::IParticle;
38  //
39  using xAOD::TrackParticle;
42  //
43  using xAOD::CaloCluster;
45  //
46  using xAOD::MissingET;
50 
51  // Constructors
54  AsgTool(name),
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  }
145  else if( m_st_objtype == xAOD::Type::TrackParticle ) {
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 
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 
CaloVertexedClusterBase.h
Base class to evaluate cluster kinematics with a different vertex / signal state.
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::MissingETComponentMap_v1
Definition: MissingETComponentMap_v1.h:25
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
met::METSoftTermsTool::m_inputType
Gaudi::Property< std::string > m_inputType
Definition: METSoftTermsTool.h:77
LArConditions2Ntuple.objects
objects
Definition: LArConditions2Ntuple.py:56
met::METSoftTermsTool::m_cl_onlyNegE
Gaudi::Property< bool > m_cl_onlyNegE
Definition: METSoftTermsTool.h:81
met::METBuilderTool
Definition: METBuilderTool.h:39
met::METSoftTermsTool::resolveOverlap
virtual bool resolveOverlap(const xAOD::IParticle *object, xAOD::MissingETComponentMap *metMap, std::vector< const xAOD::IParticle * > &acceptedSignals, MissingETBase::Types::weight_t &objWeight) const override
Definition: METSoftTermsTool.cxx:133
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
met::METBuilderTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: METBuilderTool.cxx:45
xAOD::MissingETComposition::find
static MissingETComponentMap::const_iterator find(const MissingETComponentMap *pMap, const MissingET *pmetObj)
Find non-modifiable contribution for a given MET object.
Definition: Event/xAOD/xAODMissingET/Root/MissingETComposition.cxx:82
MissingETAuxComponentMap.h
xAOD::TrackParticleContainer
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticleContainer.h:14
xAOD::MissingET
MissingET_v1 MissingET
Version control by type defintion.
Definition: Event/xAOD/xAODMissingET/xAODMissingET/MissingET.h:15
MissingETComposition
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current MissingETComposition
Definition: RecTPCnv.cxx:86
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MissingETBase::Types::bitmask_t
uint64_t bitmask_t
Type for status word bit mask.
Definition: MissingETBase.h:39
MissingETBase::UsageHandler::OnlyCluster
@ OnlyCluster
CaloCluster based only.
Definition: MissingETCompositionBase.h:184
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition: VertexContainer.h:14
xAOD::MissingET_v1::setSource
void setSource(MissingETBase::Types::bitmask_t src)
Set the source of the MET object.
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
MissingETBase::Source::idTrack
static Types::bitmask_t idTrack(Region reg=Region::FullAcceptance)
Bit pattern indicating a ID Track MET term.
Definition: MissingETBase.h:366
MissingETBase::Source::Type::SoftEvent
@ SoftEvent
Indicator for the MET term from reconstructed soft event signals (tracks, clusters) or MC truth parti...
xAOD::MissingETComponent_v1::setStatusWord
bool setStatusWord(MissingETBase::Types::bitmask_t sw=MissingETBase::Status::clearedStatus())
Set the statusword of a MET term.
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
met::METSoftTermsTool::m_caloClusterKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClusterKey
Definition: METSoftTermsTool.h:82
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
met::METSoftTermsTool::METSoftTermsTool
METSoftTermsTool()
met
Definition: IMETSignificance.h:24
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MissingETAuxContainer.h
met::METBuilderTool::addToMET
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
Definition: METBuilderTool.cxx:77
xAOD::MissingET_v1
Principal data object for Missing ET.
Definition: MissingET_v1.h:25
METSoftTermsTool.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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::METSoftTermsTool::accept
virtual bool accept(const xAOD::IParticle *object) const override
Definition: METSoftTermsTool.cxx:81
met::METSoftTermsTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: METSoftTermsTool.cxx:61
met::METSoftTermsTool::m_cl_vetoNegE
Gaudi::Property< bool > m_cl_vetoNegE
Definition: METSoftTermsTool.h:80
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
met::METSoftTermsTool::m_st_objtype
xAOD::Type::ObjectType m_st_objtype
Definition: METSoftTermsTool.h:78
met::METSoftTermsTool::executeTool
virtual StatusCode executeTool(xAOD::MissingET *metTerm, xAOD::MissingETComponentMap *metMap) const override
Definition: METSoftTermsTool.cxx:167
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
MissingETBase::UsageHandler::OnlyTrack
@ OnlyTrack
Track based only.
Definition: MissingETCompositionBase.h:185
xAOD::MissingETComponentMap_v1::checkUsage
bool checkUsage(const IParticle *pPart, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const
Check if a given object is already used in MET.
Definition: MissingETComponentMap_v1.cxx:187
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
VertexContainer.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::MissingETComponentMap
MissingETComponentMap_v1 MissingETComponentMap
Version control by type definition.
Definition: MissingETComponentMap.h:16
CaloClusterContainer.h
xAOD::MissingETComponent_v1::Weight
Kinematic weight descriptor.
Definition: MissingETComponent_v1.h:28
pickleTool.object
object
Definition: pickleTool.py:30
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
MissingETBase::Status::contributedSoftTerm
static Types::bitmask_t contributedSoftTerm()
General soft term contribution tag accessor.
Definition: MissingETCompositionBase.h:119
xAOD::MissingETComponent
MissingETComponent_v1 MissingETComponent
Version control by type definition.
Definition: MissingETComponent.h:15
MissingETBase::Source::softEvent
static Types::bitmask_t softEvent(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed soft event.
Definition: MissingETBase.h:264
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MissingETComposition.h
MissingETBase::Source::cluster
static Types::bitmask_t cluster(Region reg=Region::FullAcceptance)
Bit mask for MET term from any cluster signal objects.
Definition: MissingETBase.h:312
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
met::METSoftTermsTool::m_trackParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleKey
Definition: METSoftTermsTool.h:83
TrackParticleContainer.h
xAOD::MissingETComponent_v1
MET component descriptor contains object links and corresponding parameters.
Definition: MissingETComponent_v1.h:24