![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
#include <TruthParticleCnvTool.h>
|
| 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...
|
|
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.
◆ IsolTool_t
◆ StoreGateSvc_t
◆ 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.
63 "Type of data we are dealing with (Full/Fast/Truth...)" );
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." );
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)." );
82 "Switch to select different type of signal\n"
84 " hard scatter plus minbias 1\n"
86 "Default is hard scatter only." );
88 declareInterface<ITruthParticleCnvTool>(
this);
◆ ~TruthParticleCnvTool()
TruthParticleCnvTool::~TruthParticleCnvTool |
( |
| ) |
|
|
virtual |
◆ convert() [1/2]
◆ convert() [2/2]
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.
229 ATH_MSG_DEBUG(
"Converting McEventCollection to TruthParticleContainer");
231 if (
nullptr ==
m_pdt ) {
233 "TruthParticleContainer if NO ParticleDataTable is "\
235 return StatusCode::FAILURE;
238 if (
nullptr == mcCollection ) {
240 return StatusCode::RECOVERABLE;
243 if ( mcCollection->size() <= genEventIndex ) {
246 <<
"Requested element nbr : " << genEventIndex <<
" !!");
247 return StatusCode::RECOVERABLE;
253 ATH_MSG_DEBUG(
"Retrieve the GenEvent from given McEventCollection");
254 const HepMC::GenEvent *
evt = (*mcCollection)[genEventIndex];
255 container->setGenEvent( mcCollection, genEventIndex, sg );
258 container->reserve( container->size() +
evt->particles_size() );
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) {
271 for (
auto hepMcPart: *
evt) {
276 container->push_back( mcPart );
279 visitor->
visit( mcPart );
286 ATH_MSG_ERROR(
"TruthParticle is not wrapping the GenParticle : "
287 << hepMcPart <<
" !!");
290 bcToMcPart[ mcLink.compress() ] = mcPart;
296 container->setParticles( bcToMcPart );
301 const std::string& etIsolName
303 if ( etIsolName.empty() ) {
305 "TruthEtIsolations container (requested: ["
306 << container->genEventName() <<
"])");
307 return StatusCode::RECOVERABLE;
312 ATH_MSG_WARNING(
"Could not retrieve the TruthEtIsolations container at ["
313 << etIsolName <<
"] !!");
314 return StatusCode::RECOVERABLE;
319 container->setEtIsolations( etIsols, genEventIndex );
322 return StatusCode::SUCCESS;
◆ convertMcEventCollection()
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation 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.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation 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.
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation 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.
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation 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.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute() [1/2]
StatusCode TruthParticleCnvTool::execute |
( |
| ) |
const |
|
overridevirtual |
◆ execute() [2/2]
StatusCode TruthParticleCnvTool::execute |
( |
const EventContext & |
ctx | ) |
const |
|
overridevirtual |
Implements ITruthParticleCnvTool.
Definition at line 152 of file TruthParticleCnvTool.cxx.
158 ATH_CHECK(mcPartsOutputWriteHandle.record(std::make_unique<TruthParticleContainer>()));
160 if (!mcPartsOutputWriteHandle.isValid()){
162 return StatusCode::FAILURE;
168 if (!mcEventsReadHandle.isValid()){
173 <<
"] will be EMPTY !!");
174 return StatusCode::RECOVERABLE;
177 ATH_MSG_DEBUG(
" Found McEventCollection of size = "<< mcEventsReadHandle->size() );
181 std::size_t genEventIndex = 0;
183 bool all_good =
true;
189 ATH_MSG_DEBUG(
" Found McEventCollection iterators : "<< (fEvt-mcEventsReadHandle->begin()) <<
" to "<< (lEvt-mcEventsReadHandle->begin()) );
192 const HepMC::GenEvent*
evt = *
it;
195 if (
nullptr ==
evt) {
198 genEventIndex = (
it - mcEventsReadHandle->begin());
202 if (!this->
convert( mcEventsReadHandle.ptr(), genEventIndex, mcPartsOutputWriteHandle.ptr(), dummyVisitor ).isSuccess()) {
210 mcPartsOutputWriteHandle->setGenEvent( mcEventsReadHandle.ptr(), (fEvt - mcEventsReadHandle->begin() ) );
214 ? StatusCode::SUCCESS
215 : StatusCode::RECOVERABLE;
◆ extraDeps_update_handler()
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.
106 if ( !partPropSvc.retrieve().isSuccess() ) {
107 ATH_MSG_ERROR(
" Could not initialize Particle Properties Service");
108 return StatusCode::FAILURE;
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;
136 (
" DoEtIsolations: [" << std::boolalpha
143 return StatusCode::SUCCESS;
◆ inputHandles()
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 |
◆ msg() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ outputHandles()
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()
◆ renounceArray()
◆ setDataType()
void TruthParticleCnvTool::setDataType |
( |
const int |
type | ) |
|
|
inline |
◆ setVxCandidateName()
void TruthParticleCnvTool::setVxCandidateName |
( |
const std::string & |
name | ) |
|
|
inline |
◆ sysInitialize()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ m_dataType
◆ m_dataType_int
int TruthParticleCnvTool::m_dataType_int |
|
private |
◆ m_detStore
◆ m_doEtIsolation
BooleanProperty TruthParticleCnvTool::m_doEtIsolation |
|
protected |
◆ m_evtStore
◆ m_isolationTool
◆ m_mcEventsReadHandleKey
◆ m_mcPartsOutputWriteHandleKey
◆ m_pdt
const HepPDT::ParticleDataTable* TruthParticleCnvTool::m_pdt |
|
private |
◆ m_selectSignalType
◆ m_selectSignalTypeProp
int TruthParticleCnvTool::m_selectSignalTypeProp |
|
private |
◆ m_varHandleArraysDeclared
◆ m_vhka
◆ m_vxCandidatesName
std::string TruthParticleCnvTool::m_vxCandidatesName |
|
private |
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
virtual StatusCode convert(const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor=0) const =0
Convert a McEventCollection into an TruthParticleContainer.
SG::ReadHandleKey< McEventCollection > m_mcEventsReadHandleKey
ReadHandleKey for the McEventCollection the TruthParticles will be made from.
Const iterator class for DataVector/DataList.
virtual int pdgId() const
Return enum indicating particle id the enum file is available in Event/EventKernel/PdtPdg....
const HepPDT::ParticleDataTable * m_pdt
Particle Property service.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
int signal_process_id(const GenEvent &e)
ToolHandle< ITruthIsolationTool > IsolTool_t
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
PileuType_t
define some Pile-up classification Important : this classification is copied in McParticleAlgs/python...
std::vector< SG::VarHandleKeyArray * > m_vhka
ParticleDataType::DataType m_dataType
Type of data we are dealing with (Full/Fast/Truth/...)
std::string m_vxCandidatesName
static IProxyDict * store()
Fetch the current store.
IsolTool_t m_isolationTool
Pointer to the ITruthIsolationTool to be able to retrieve the previously computed transverse energy i...
const std::string & key() const
Return the StoreGate ID for the referenced object.
HepMC::ConstGenParticlePtr genParticle() const
Retrieve the GenParticle this TruthParticle has been made from (if any)
void setGenEventIndex(size_t index)
set the GenEvent index
virtual void setOwner(IDataHandleHolder *o)=0
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
a link optimized in size for a GenParticle in a McEventCollection
BooleanProperty m_doEtIsolation
Switch to compute or not the Et-isolations for TruthParticle (and their underlying HepMC::GenParticle...
virtual StatusCode execute() const override
PileUpClassification::PileuType_t m_selectSignalType
Type of truth particle we want to create.
TruthParticle_v1 TruthParticle
Typedef to implementation.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
std::unordered_map< long, const TruthParticle * > Map_t
barcode to TruthParticle dictionary
double charge(const T &p)
int m_selectSignalTypeProp
Type of truth particle we want to create (property to be set by jobO)
virtual void visit(TruthParticle *truthParticle) const =0
The method to visit a TruthParticle to apply further modifications to the instance at hand.
#define ATH_MSG_WARNING(x)
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
SG::WriteHandleKey< TruthParticleContainer > m_mcPartsOutputWriteHandleKey
Output TruthParticle WriteHandleKey (built from the McEventCollection)
void setDataType(const int type)
Inline methods:
void setCharge(const ChargeType charge)
Set the charge of this TruthParticle.
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
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...
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.