ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
TruthParticleCnvTool Class Reference

#include <TruthParticleCnvTool.h>

Inheritance diagram for TruthParticleCnvTool:
Collaboration diagram for TruthParticleCnvTool:

Public Member Functions

 TruthParticleCnvTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters: More...
 
virtual ~TruthParticleCnvTool ()
 Destructor: More...
 
virtual StatusCode initialize () override
 Athena Algorithm's Hooks. More...
 
virtual StatusCode execute () const override
 
virtual StatusCode execute (const EventContext &ctx) const override
 
StatusCode convert (const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor) const override
 Converts a McEventCollection into an TruthParticleContainer (ie: converts it into an AOD compliant collection). More...
 
void setDataType (const int type)
 Inline methods:
More...
 
void setVxCandidateName (const std::string &name)
 
StatusCode convert (const McEventCollection *mcCollection, TruthParticleContainer *container) const
 Convert the first element of a McEventCollection into a TruthParticleContainer. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
StatusCode convertMcEventCollection (const McEventCollection *mcCollection, TruthParticleContainer *container) const
 Convert a McEventCollection into an TruthParticleContainer. More...
 
StatusCode convertMcEventCollection (const McEventCollection *mcCollection, TruthParticleContainer *container) const
 Convert a McEventCollection into an TruthParticleContainer. More...
 
StatusCode convertMcEventCollection (const McEventCollection *mcCollection, TruthParticleContainer *container) const
 Convert a McEventCollection into an TruthParticleContainer. More...
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Inline methods:
More...
 

Protected Types

typedef ToolHandle< ITruthIsolationToolIsolTool_t
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Protected Attributes

BooleanProperty m_doEtIsolation
 Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle). More...
 
IsolTool_t m_isolationTool
 Pointer to the ITruthIsolationTool to be able to retrieve the previously computed transverse energy isolations. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

ParticleDataType::DataType m_dataType
 Type of data we are dealing with (Full/Fast/Truth/...) More...
 
int m_dataType_int
 
std::string m_vxCandidatesName
 
SG::ReadHandleKey< McEventCollectionm_mcEventsReadHandleKey {this,"McEvents","GEN_AOD","ReadHandleKey for the input McEventCollection, from which the TruthParticles will be made from"}
 ReadHandleKey for the McEventCollection the TruthParticles will be made from. More...
 
SG::WriteHandleKey< TruthParticleContainerm_mcPartsOutputWriteHandleKey {this,"TruthParticlesOutput","SpclMC","WriteHandleKey for the output truth particles (built from the McEventCollection)"}
 Output TruthParticle WriteHandleKey (built from the McEventCollection) More...
 
const HepPDT::ParticleDataTable * m_pdt
 Particle Property service. More...
 
PileUpClassification::PileuType_t m_selectSignalType
 Type of truth particle we want to create. More...
 
int m_selectSignalTypeProp
 Type of truth particle we want to create (property to be set by jobO) More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

AlgTool that converts, on the fly, on demand, each GenParticle to a TruthParticle and builds the TruthParticleContainer. So the GEN_AOD and TruthParticleContainer are identical in contents, only the interfaces are different: the TruthParticle class has the same interface as other AOD particles. Hence the analysis tools can operate on all the AOD particles (ie: including Mc Truth). When the AOD is created, the TruthParticleContainer is empty. When the user requests the TruthParticleContainer in his/her analysis code, a custom converter is triggered where by the GEN_AOD is convertered into the TruthParticleContainer using the TruthParticleCnvTool.

In pile-up events, the many GenEvent are grouped into 5 TruthParticleContainer according to the classification of : https://twiki.cern.ch/twiki/bin/viewauth/Atlas/PileupDigitization#Arrangement_of_Truth_Information

Definition at line 59 of file TruthParticleCnvTool.h.

Member Typedef Documentation

◆ IsolTool_t

Definition at line 150 of file TruthParticleCnvTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TruthParticleCnvTool()

TruthParticleCnvTool::TruthParticleCnvTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Constructor with parameters:

Public methods:

Constructors

Definition at line 48 of file TruthParticleCnvTool.cxx.

50  :
54  m_pdt ( nullptr ),
56 {
57  //
58  // Property declaration
59  //
60 
61  declareProperty( "DataType",
62  m_dataType_int = 4,
63  "Type of data we are dealing with (Full/Fast/Truth...)" );
64 
65  declareProperty( "TruthIsolationTool",
66  m_isolationTool = IsolTool_t( "TruthIsolationTool" ),
67  "Pointer to the TruthIsolationTool to be able to compute "
68  "transverse energy isolations for various isolation cones cuts. "
69  "See McParticleEvent/TruthParticleParameters.h for cone cuts." );
70 
71 
72  declareProperty( "DoEtIsolations",
73  m_doEtIsolation = false,
74  "Switch to compute or not the Et-isolations for TruthParticle "
75  "(and their underlying @c HepMC::GenParticle).\n"
76  "Default is to not compute these Et-isolations (and save CPU)." );
77 
79 
80  declareProperty( "SelectSignalType",
82  "Switch to select different type of signal\n"
83  " hard scatter 0\n"
84  " hard scatter plus minbias 1\n"
85  " only minbias -1\n"
86  "Default is hard scatter only." );
87 
88  declareInterface<ITruthParticleCnvTool>(this);
89 }

◆ ~TruthParticleCnvTool()

TruthParticleCnvTool::~TruthParticleCnvTool ( )
virtual

Destructor:

Destructor.

Definition at line 93 of file TruthParticleCnvTool.cxx.

94 {
95  ATH_MSG_DEBUG("Calling destructor");
96 }

Member Function Documentation

◆ convert() [1/2]

StatusCode ITruthParticleCnvTool::convert ( const McEventCollection mcCollection,
TruthParticleContainer container 
) const
inlineinherited

Convert the first element of a McEventCollection into a TruthParticleContainer.

Definition at line 112 of file ITruthParticleCnvTool.h.

114 {
115  const unsigned int genEvtIndex = 0;
116  const ITruthParticleVisitor* dummyVisitor = 0;
117  return this->convert( mcCollection, genEvtIndex, container, dummyVisitor );
118 }

◆ convert() [2/2]

StatusCode TruthParticleCnvTool::convert ( const McEventCollection mcEvts,
const unsigned int  genEvtIndex,
TruthParticleContainer mcParts,
const ITruthParticleVisitor visitor 
) const
overridevirtual

Converts a McEventCollection into an TruthParticleContainer (ie: converts it into an AOD compliant collection).

Const methods:

@in mcEvts the McEventCollection holding the HepMC::GenEvent we want to convert into a TruthParticleContainer @in genEvtIndex the index to the HepMC::GenEvent to be converted @out mcParts a valid pointer to a TruthParticleContainer which will be filled with adaptors to HepMC::GenParticles.

Get GenEvent from McEventCollection

Create a map to enhance access between GenParticles and TruthParticles

Implements ITruthParticleCnvTool.

Definition at line 224 of file TruthParticleCnvTool.cxx.

228 {
229  ATH_MSG_DEBUG("Converting McEventCollection to TruthParticleContainer");
230 
231  if ( nullptr == m_pdt ) {
232  ATH_MSG_ERROR("Could not convert McEventCollection into "\
233  "TruthParticleContainer if NO ParticleDataTable is "\
234  "available !!");
235  return StatusCode::FAILURE;
236  }
237 
238  if ( nullptr == mcCollection ) {
239  ATH_MSG_WARNING("Null pointer to McEventCollection !");
240  return StatusCode::RECOVERABLE;
241  }
242 
243  if ( mcCollection->size() <= genEventIndex ) {
244  ATH_MSG_WARNING("McEventCollection size: " << mcCollection->size()
245  << endmsg
246  << "Requested element nbr : " << genEventIndex << " !!");
247  return StatusCode::RECOVERABLE;
248  }
249 
251 
253  ATH_MSG_DEBUG("Retrieve the GenEvent from given McEventCollection");
254  const HepMC::GenEvent * evt = (*mcCollection)[genEventIndex];
255  container->setGenEvent( mcCollection, genEventIndex, sg );
256 
257  // reserve enough space for the container so we don't have to relocate it
258  container->reserve( container->size() + evt->particles_size() );
259 
261  TruthParticleContainer::Map_t bcToMcPart = container->m_particles;
262 
263 
264 #ifdef HEPMC3
265  // Process particles in barcode order.
266  auto bcmapatt = evt->attribute<HepMC::GenEventBarcodes>("barcodes");
267  if (!bcmapatt) ATH_MSG_ERROR("TruthParticleCnvTool.cxx: Event does not contain barcodes attribute");
268  std::map<int, HepMC3::ConstGenParticlePtr> bcmap = bcmapatt->barcode_to_particle_map();
269  for (const auto &[bc,hepMcPart]: bcmap) {
270 #else
271  for (auto hepMcPart: *evt) {
272  int bc = HepMC::barcode(hepMcPart);
273 #endif
274 
275  TruthParticle * mcPart = new TruthParticle( hepMcPart, container );
276  container->push_back( mcPart );
277 
278  if ( visitor ) {
279  visitor->visit( mcPart );
280  }
281 
282  mcPart->setCharge( MC::charge( int(mcPart->pdgId())) );
283  mcPart->setGenEventIndex( genEventIndex);
284 
285  if ( hepMcPart != mcPart->genParticle() ) {
286  ATH_MSG_ERROR("TruthParticle is not wrapping the GenParticle : "
287  << hepMcPart << " !!");
288  }
289  HepMcParticleLink mcLink( bc, genEventIndex, HepMcParticleLink::IS_POSITION, HepMcParticleLink::IS_BARCODE, sg ); // FIXME barcode-based
290  bcToMcPart[ mcLink.compress() ] = mcPart;
291 
292  }//> end loop over particles
293 
294  // at this point the whole GenEvent has been proxied.
295  // so we can setup its VectorMap
296  container->setParticles( bcToMcPart );
297 
298  // connect the TruthParticleContainer to the container of TruthEtIsolations
299  // if it exists and if we are asked for
300  if ( m_doEtIsolation.value() ) {
301  const std::string& etIsolName
302  = m_isolationTool->etIsolationsName( container->genEventName() );
303  if ( etIsolName.empty() ) {
304  ATH_MSG_WARNING("Could not retrieve the name of the "
305  "TruthEtIsolations container (requested: ["
306  << container->genEventName() << "])");
307  return StatusCode::RECOVERABLE;
308  }
309 
310  const TruthEtIsolationsContainer* etIsols = nullptr;
311  if ( !evtStore()->retrieve( etIsols, etIsolName ).isSuccess() ) {
312  ATH_MSG_WARNING("Could not retrieve the TruthEtIsolations container at ["
313  << etIsolName << "] !!");
314  return StatusCode::RECOVERABLE;
315  }
316 
317  // index of HepMC::GenEvent within the McEventCollection is the same
318  // than the one of the TruthEtIsolations within the TruthEtIsolationsCont.
319  container->setEtIsolations( etIsols, genEventIndex );
320  }
321 
322  return StatusCode::SUCCESS;
323 }

◆ convertMcEventCollection()

StatusCode ITruthParticleCnvTool::convertMcEventCollection ( const McEventCollection mcCollection,
TruthParticleContainer container 
) const
inlineinherited

Convert a McEventCollection into an TruthParticleContainer.

deprecated Note that the pointer to the TruthParticleContainer MUST be valid.

Definition at line 121 of file ITruthParticleCnvTool.h.

123 {
124  const unsigned int genEvtIndex = 0;
125  const ITruthParticleVisitor* dummyVisitor = 0;
126  return this->convert( mcCollection, genEvtIndex, container, dummyVisitor );
127 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute() [1/2]

StatusCode TruthParticleCnvTool::execute ( ) const
overridevirtual

Implements ITruthParticleCnvTool.

Definition at line 146 of file TruthParticleCnvTool.cxx.

147 {
148  return execute (Gaudi::Hive::currentContext());
149 }

◆ execute() [2/2]

StatusCode TruthParticleCnvTool::execute ( const EventContext &  ctx) const
overridevirtual

Implements ITruthParticleCnvTool.

Definition at line 152 of file TruthParticleCnvTool.cxx.

153 {
154  ATH_MSG_DEBUG("Executing " << name() << "...");
155 
156  //Setup WriteHandle, and record new TruthParticleContainer
158  ATH_CHECK(mcPartsOutputWriteHandle.record(std::make_unique<TruthParticleContainer>()));
159 
160  if (!mcPartsOutputWriteHandle.isValid()){
161  ATH_MSG_ERROR("Invalid WriteHandle for TruthParticleContainer with key: " << m_mcPartsOutputWriteHandleKey.key());
162  return StatusCode::FAILURE;
163  }
164 
165  //Setup ReadHandle for input McEventCollection
167 
168  if (!mcEventsReadHandle.isValid()){
169  ATH_MSG_WARNING("Invalid ReadHandle for McEventCollection with key ["
170  << m_mcEventsReadHandleKey.key() << "] !!"
171  << endmsg
172  << "TruthParticleContainer [" << m_mcPartsOutputWriteHandleKey.key()
173  << "] will be EMPTY !!");
174  return StatusCode::RECOVERABLE;
175  }
176 
177  ATH_MSG_DEBUG(" Found McEventCollection of size = "<< mcEventsReadHandle->size() );
178  // do the actual convertion (it is merely an interface adaptation now...)
179  // selection for particles from minbias copied from the JetsFromTruthTool
180 
181  std::size_t genEventIndex = 0;
182  const ITruthParticleVisitor* dummyVisitor = nullptr;
183  bool all_good = true;
184 
185  McEventCollection::const_iterator fEvt = mcEventsReadHandle->begin();
186  McEventCollection::const_iterator lEvt = mcEventsReadHandle->end();
188 
189  ATH_MSG_DEBUG(" Found McEventCollection iterators : "<< (fEvt-mcEventsReadHandle->begin()) << " to "<< (lEvt-mcEventsReadHandle->begin()) );
190 
191  for(McEventCollection::const_iterator it=fEvt ; it != lEvt; ++it){
192  const HepMC::GenEvent* evt = *it;
193  // there are holes in a McEventCollection when pile-up is enabled
194  // so deal with it
195  if (nullptr == evt) {
196  continue;
197  }
198  genEventIndex = (it - mcEventsReadHandle->begin());
199  ATH_MSG_DEBUG(" adding event id="<< HepMC::signal_process_id(evt)<<" genEventIndex="<< genEventIndex );
200 
201  if( HepMC::signal_process_id(evt) == 0 ) continue;
202  if (!this->convert( mcEventsReadHandle.ptr(), genEventIndex, mcPartsOutputWriteHandle.ptr(), dummyVisitor ).isSuccess()) {
203  ATH_MSG_DEBUG("Failed to convert an event...");
204  all_good = false;
205  }
206  }
207 
208  // VERY IMPORTANT ! Reset the index to the first GenEvent included
209  // in this TruthParticleContainer. This will be used when read back from disk.
210  mcPartsOutputWriteHandle->setGenEvent( mcEventsReadHandle.ptr(), (fEvt - mcEventsReadHandle->begin() ) );
211 
212 
213  return all_good
214  ? StatusCode::SUCCESS
215  : StatusCode::RECOVERABLE;
216 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode TruthParticleCnvTool::initialize ( )
overridevirtual

Athena Algorithm's Hooks.

Definition at line 100 of file TruthParticleCnvTool.cxx.

101 {
102  ATH_MSG_INFO("Initializing " << name() << "...");
103 
104  // Get the Particle Properties Service
105  ServiceHandle<IPartPropSvc> partPropSvc("PartPropSvc", name());
106  if ( !partPropSvc.retrieve().isSuccess() ) {
107  ATH_MSG_ERROR(" Could not initialize Particle Properties Service");
108  return StatusCode::FAILURE;
109  }
110 
111  m_pdt = partPropSvc->PDT();
112  if ( nullptr == m_pdt ) {
113  ATH_MSG_ERROR("Could not retrieve HepPDT::ParticleDataTable from "\
114  "ParticleProperties Service !!");
115  return StatusCode::FAILURE;
116  }
117 
118  // retrieve the TruthIsolation tool only if asked for.
119  if ( m_doEtIsolation.value() ) {
120  ATH_CHECK(m_isolationTool.retrieve());
121  }
122  else {
123  m_isolationTool.disable();
124  }
125 
126  //initialize DataHandleKeys
129 
130  // for compatibility with earlier version we accept <0 values :
133 
134 
136  (" DoEtIsolations: [" << std::boolalpha
137  << m_doEtIsolation.value() << "]" << endmsg
138  << " McEvents: [" << m_mcEventsReadHandleKey.key() << "]" << endmsg
139  << " TruthParticlesOutput: [" << m_mcPartsOutputWriteHandleKey.key() << "]"
140  << endmsg
141  << " SelectSignalType: [" << m_selectSignalType << "]");
142 
143  return StatusCode::SUCCESS;
144 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITruthParticleCnvTool::interfaceID ( )
inlinestaticinherited

Inline methods:

Definition at line 106 of file ITruthParticleCnvTool.h.

107 {
108  return IID_ITruthParticleCnvTool;
109 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ setDataType()

void TruthParticleCnvTool::setDataType ( const int  type)
inline

Inline methods:

Definition at line 162 of file TruthParticleCnvTool.h.

163 {
165 }

◆ setVxCandidateName()

void TruthParticleCnvTool::setVxCandidateName ( const std::string &  name)
inline

Definition at line 167 of file TruthParticleCnvTool.h.

168 {
170 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_dataType

ParticleDataType::DataType TruthParticleCnvTool::m_dataType
private

Type of data we are dealing with (Full/Fast/Truth/...)

Definition at line 111 of file TruthParticleCnvTool.h.

◆ m_dataType_int

int TruthParticleCnvTool::m_dataType_int
private

Definition at line 112 of file TruthParticleCnvTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doEtIsolation

BooleanProperty TruthParticleCnvTool::m_doEtIsolation
protected

Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle).

Default is to not compute these Et-isolations (and save CPU)

Definition at line 148 of file TruthParticleCnvTool.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_isolationTool

IsolTool_t TruthParticleCnvTool::m_isolationTool
protected

Pointer to the ITruthIsolationTool to be able to retrieve the previously computed transverse energy isolations.

Definition at line 155 of file TruthParticleCnvTool.h.

◆ m_mcEventsReadHandleKey

SG::ReadHandleKey<McEventCollection> TruthParticleCnvTool::m_mcEventsReadHandleKey {this,"McEvents","GEN_AOD","ReadHandleKey for the input McEventCollection, from which the TruthParticles will be made from"}
private

ReadHandleKey for the McEventCollection the TruthParticles will be made from.

Definition at line 118 of file TruthParticleCnvTool.h.

◆ m_mcPartsOutputWriteHandleKey

SG::WriteHandleKey<TruthParticleContainer> TruthParticleCnvTool::m_mcPartsOutputWriteHandleKey {this,"TruthParticlesOutput","SpclMC","WriteHandleKey for the output truth particles (built from the McEventCollection)"}
private

Output TruthParticle WriteHandleKey (built from the McEventCollection)

Definition at line 122 of file TruthParticleCnvTool.h.

◆ m_pdt

const HepPDT::ParticleDataTable* TruthParticleCnvTool::m_pdt
private

Particle Property service.

Definition at line 126 of file TruthParticleCnvTool.h.

◆ m_selectSignalType

PileUpClassification::PileuType_t TruthParticleCnvTool::m_selectSignalType
private

Type of truth particle we want to create.

Definition at line 130 of file TruthParticleCnvTool.h.

◆ m_selectSignalTypeProp

int TruthParticleCnvTool::m_selectSignalTypeProp
private

Type of truth particle we want to create (property to be set by jobO)

Definition at line 134 of file TruthParticleCnvTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_vxCandidatesName

std::string TruthParticleCnvTool::m_vxCandidatesName
private

Definition at line 114 of file TruthParticleCnvTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ITruthParticleCnvTool::convert
virtual StatusCode convert(const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor=0) const =0
Convert a McEventCollection into an TruthParticleContainer.
TruthParticleCnvTool::m_mcEventsReadHandleKey
SG::ReadHandleKey< McEventCollection > m_mcEventsReadHandleKey
ReadHandleKey for the McEventCollection the TruthParticles will be made from.
Definition: TruthParticleCnvTool.h:118
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ParticleImpl::pdgId
virtual int pdgId() const
Return enum indicating particle id the enum file is available in Event/EventKernel/PdtPdg....
Definition: ParticleImpl.h:738
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TruthParticleCnvTool::m_pdt
const HepPDT::ParticleDataTable * m_pdt
Particle Property service.
Definition: TruthParticleCnvTool.h:126
SG::ReadHandle< McEventCollection >
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
HepMC::signal_process_id
int signal_process_id(const GenEvent &e)
Definition: GenEvent.h:513
TruthEtIsolationsContainer
Definition: TruthEtIsolationsContainer.h:26
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TruthParticle
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:58
TruthParticleCnvTool::IsolTool_t
ToolHandle< ITruthIsolationTool > IsolTool_t
Definition: TruthParticleCnvTool.h:150
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
PileUpClassification::PileuType_t
PileuType_t
define some Pile-up classification Important : this classification is copied in McParticleAlgs/python...
Definition: PileUpClassification.h:29
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
TruthParticleCnvTool::m_dataType
ParticleDataType::DataType m_dataType
Type of data we are dealing with (Full/Fast/Truth/...)
Definition: TruthParticleCnvTool.h:111
TruthParticleCnvTool::m_vxCandidatesName
std::string m_vxCandidatesName
Definition: TruthParticleCnvTool.h:114
SG::CurrentEventStore::store
static IProxyDict * store()
Fetch the current store.
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
TruthParticleCnvTool::m_isolationTool
IsolTool_t m_isolationTool
Pointer to the ITruthIsolationTool to be able to retrieve the previously computed transverse energy i...
Definition: TruthParticleCnvTool.h:155
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
TruthParticle::genParticle
HepMC::ConstGenParticlePtr genParticle() const
Retrieve the GenParticle this TruthParticle has been made from (if any)
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:279
ParticleDataType::DataType
DataType
Definition: Event/EventKernel/EventKernel/IParticle.h:36
TruthParticle::setGenEventIndex
void setGenEventIndex(size_t index)
set the GenEvent index
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:338
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TruthParticleCnvTool::m_doEtIsolation
BooleanProperty m_doEtIsolation
Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle...
Definition: TruthParticleCnvTool.h:148
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ITruthParticleVisitor
Definition: ITruthParticleVisitor.h:30
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TruthParticleCnvTool::execute
virtual StatusCode execute() const override
Definition: TruthParticleCnvTool.cxx:146
TruthParticleCnvTool::m_selectSignalType
PileUpClassification::PileuType_t m_selectSignalType
Type of truth particle we want to create.
Definition: TruthParticleCnvTool.h:130
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition: Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
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
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
TruthParticleContainer::Map_t
std::unordered_map< long, const TruthParticle * > Map_t
barcode to TruthParticle dictionary
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:59
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ParticleDataType::True
@ True
Definition: Event/EventKernel/EventKernel/IParticle.h:36
charge
double charge(const T &p)
Definition: AtlasPID.h:494
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TruthParticleCnvTool::m_selectSignalTypeProp
int m_selectSignalTypeProp
Type of truth particle we want to create (property to be set by jobO)
Definition: TruthParticleCnvTool.h:134
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ITruthParticleVisitor::visit
virtual void visit(TruthParticle *truthParticle) const =0
The method to visit a TruthParticle to apply further modifications to the instance at hand.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
PileUpClassification::ALLMINBIAS
@ ALLMINBIAS
Definition: PileUpClassification.h:31
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
TruthParticleCnvTool::m_mcPartsOutputWriteHandleKey
SG::WriteHandleKey< TruthParticleContainer > m_mcPartsOutputWriteHandleKey
Output TruthParticle WriteHandleKey (built from the McEventCollection)
Definition: TruthParticleCnvTool.h:122
TruthParticleCnvTool::setDataType
void setDataType(const int type)
Inline methods:
Definition: TruthParticleCnvTool.h:162
TruthParticle::setCharge
void setCharge(const ChargeType charge)
Set the charge of this TruthParticle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:327
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
TruthParticleCnvTool::convert
StatusCode convert(const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor) const override
Converts a McEventCollection into an TruthParticleContainer (ie: converts it into an AOD compliant co...
Definition: TruthParticleCnvTool.cxx:224
fitman.k
k
Definition: fitman.py:528
PileUpClassification::findEventIterators
static void findEventIterators(PileuType_t putype, McEventCollection::const_iterator &fEvt, McEventCollection::const_iterator &lEvt)
Find interval [fEvt,lEvt] containing all GenEvents of type putype from the McEventCollection.
Definition: PileUpClassification.cxx:8
ServiceHandle< IPartPropSvc >
TruthParticleCnvTool::m_dataType_int
int m_dataType_int
Definition: TruthParticleCnvTool.h:112