7 #include <sio/io_device.h>
8 #include <sio/version.h>
21 SIO_PTAG( device , dynamic_cast<EVENT::MCParticle*>(particle) ) ;
23 SIO_SDATA( device , numberOfParents ) ;
24 particle->_parents.resize( numberOfParents ) ;
25 for(
int i=0 ; i<numberOfParents ; i++ ) {
26 SIO_PNTR( device , &(particle->_parents[i] ) ) ;
28 SIO_DATA( device , &(particle->_pdg) , 1 ) ;
29 SIO_DATA( device , &(particle->_genstatus) , 1 ) ;
31 SIO_DATA( device , &simstatus , 1 ) ;
32 particle->_simstatus = simstatus ;
33 SIO_DATA( device , particle->_vertex , 3 ) ;
34 if( vers > SIO_VERSION_ENCODE( 1, 2 ) ) {
35 SIO_DATA( device , &(particle->_time) , 1 ) ;
38 SIO_DATA( device , momentum , 3 ) ;
39 particle->setMomentum( momentum ) ;
41 SIO_DATA( device , &mass , 1 ) ;
42 particle->setMass( mass ) ;
43 SIO_DATA( device , &(particle->_charge) , 1 ) ;
45 SIO_DATA( device , particle->_endpoint , 3 ) ;
46 if( vers > SIO_VERSION_ENCODE( 2, 6 ) ) {
48 SIO_DATA( device , mom , 3 ) ;
49 particle->setMomentumAtEndpoint( mom ) ;
52 if( vers > SIO_VERSION_ENCODE( 1, 51 ) ) {
53 SIO_DATA( device , particle->_spin , 3 ) ;
54 SIO_DATA( device , particle->_colorFlow , 2 ) ;
62 SIO_PTAG( device , particle ) ;
63 int numberOfParents = particle->getParents().size() ;
64 SIO_DATA( device , &numberOfParents , 1 ) ;
65 for(
int i=0;i<numberOfParents;i++){
66 auto part = particle->getParents()[i] ;
67 SIO_PNTR( device , &part );
69 SIO_SDATA( device, particle->getPDG() ) ;
70 SIO_SDATA( device, particle->getGeneratorStatus() ) ;
71 SIO_SDATA( device, particle->getSimulatorStatus() ) ;
72 SIO_DATA( device, particle->getVertex(), 3 ) ;
73 SIO_SDATA( device, particle->getTime() ) ;
74 SIO_SDATA( device, static_cast<float>(particle->getMomentum()[0]) ) ;
75 SIO_SDATA( device, static_cast<float>(particle->getMomentum()[1]) ) ;
76 SIO_SDATA( device, static_cast<float>(particle->getMomentum()[2]) ) ;
77 SIO_SDATA( device, static_cast<float>(particle->getMass() ) ) ;
78 SIO_SDATA( device, particle->getCharge() ) ;
80 SIO_DATA( device, particle->getEndpoint() , 3 ) ;
81 SIO_SDATA( device, static_cast<float>(particle->getMomentumAtEndpoint()[0]) ) ;
82 SIO_SDATA( device, static_cast<float>(particle->getMomentumAtEndpoint()[1]) ) ;
83 SIO_SDATA( device, static_cast<float>(particle->getMomentumAtEndpoint()[2]) ) ;
85 SIO_SDATA( device, (
float) particle->getSpin()[0] ) ;
86 SIO_SDATA( device, (
float) particle->getSpin()[1] ) ;
87 SIO_SDATA( device, (
float) particle->getSpin()[2] ) ;
88 SIO_SDATA( device, (
int) particle->getColorFlow()[0] ) ;
89 SIO_SDATA( device, (
int) particle->getColorFlow()[1] ) ;
102 for(
auto name = strVec->begin() ; name != strVec->end() ; name++ ) {
106 int nDaughtersTotal = 0 ;
107 int nParentsTotal = 0 ;
111 nParentsTotal += mcp->getParents().size() ;
116 if ( nParentsTotal == 0 && nDaughtersTotal > 0 ) {
118 for(
int j=0; j<nDaughters; j++) {
123 else if ( nParentsTotal > 0 && nDaughtersTotal == 0 ) {
124 int nParents = mcp->getParents().size() ;
125 for(
int j=0; j<nParents; j++){
The generic object that is held in an LCCollection.
EVENT::MCParticleVec _daughters
void write(sio::write_device &device, const EVENT::LCObject *obj) override
Writes lcio objects to an SIO stream.
static void restoreParentDaughterRelations(EVENT::LCEvent *evt)
Restore the MCParticle parent <-> daughter relations.
SIOParticleHandler()
Constructor.
virtual const std::vector< std::string > * getCollectionNames() const =0
Returns the names of the collections in the event.
Interface for all lcio object SIO-handlers, has to be implemented for all event entities (hits...
virtual LCObject * getElementAt(int index) const =0
Returns pointer to element at index - no range check, use getNumberOfEntries().
virtual int getFlag() const =0
Returns flag word for collection.
virtual LCCollection * getCollection(const std::string &name) const =0
Returns the collection for the given name.
virtual const std::string & getTypeName() const =0
Returns the type name of the collection - valid names are defined in LCIO.
void read(sio::read_device &device, EVENT::LCObject *objP, sio::version_type vers) override
Reads lcio objects from an SIO stream.
virtual const EVENT::MCParticleVec & getDaughters() const
Returns the daughters of this particle.
The LCIO Monte Carlo particle.
virtual int getNumberOfElements() const =0
Returns the number of elements in the collection.
The main event interface.
The generic collection used in LCIO.
Adding stuff needed for io (friend declarations, etc.)
EVENT::MCParticleVec _parents
EVENT::LCObject * create() const override
Factory method to create an object of the type of the collection.
static const int BITSubset
static const int BITEndpoint