Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:20:02

0001 
0002 /***********************************************************************
0003 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
0004 *                                                                      *
0005 * This file is part of EvtGen.                                         *
0006 *                                                                      *
0007 * EvtGen is free software: you can redistribute it and/or modify       *
0008 * it under the terms of the GNU General Public License as published by *
0009 * the Free Software Foundation, either version 3 of the License, or    *
0010 * (at your option) any later version.                                  *
0011 *                                                                      *
0012 * EvtGen is distributed in the hope that it will be useful,            *
0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
0015 * GNU General Public License for more details.                         *
0016 *                                                                      *
0017 * You should have received a copy of the GNU General Public License    *
0018 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
0019 ***********************************************************************/
0020 
0021 #ifndef EVTHEPMCEVENT_HH
0022 #define EVTHEPMCEVENT_HH
0023 
0024 #include "EvtGenBase/EvtVector4R.hh"
0025 
0026 #ifdef EVTGEN_HEPMC3
0027 #include "HepMC3/GenEvent.h"
0028 #include "HepMC3/GenParticle.h"
0029 #include "HepMC3/GenVertex.h"
0030 #include "HepMC3/Print.h"
0031 #include "HepMC3/Units.h"
0032 typedef HepMC3::GenParticlePtr GenParticlePtr;
0033 typedef HepMC3::GenVertexPtr GenVertexPtr;
0034 typedef HepMC3::GenEvent GenEvent;
0035 typedef HepMC3::FourVector FourVector;
0036 typedef HepMC3::Units Units;
0037 inline GenParticlePtr newGenParticlePtr(
0038     const FourVector& mom = FourVector::ZERO_VECTOR(), int pid = 0,
0039     int status = 0 )
0040 {
0041     return std::make_shared<HepMC3::GenParticle>( mom, pid, status );
0042 }
0043 inline GenVertexPtr newGenVertexPtr(
0044     const FourVector& pos = FourVector::ZERO_VECTOR() )
0045 {
0046     return std::make_shared<HepMC3::GenVertex>( pos );
0047 }
0048 #else
0049 #include "HepMC/GenEvent.h"
0050 #include "HepMC/GenParticle.h"
0051 #include "HepMC/GenVertex.h"
0052 #include "HepMC/SimpleVector.h"
0053 #include "HepMC/Units.h"
0054 typedef HepMC::GenParticle* GenParticlePtr;
0055 typedef HepMC::GenVertex* GenVertexPtr;
0056 typedef HepMC::GenEvent GenEvent;
0057 typedef HepMC::FourVector FourVector;
0058 #define Units HepMC::Units
0059 inline GenParticlePtr newGenParticlePtr(
0060     const FourVector& mom = FourVector( 0.0, 0.0, 0.0, 0.0 ), int pid = 0,
0061     int status = 0 )
0062 {
0063     return new HepMC::GenParticle( mom, pid, status );
0064 }
0065 inline GenVertexPtr newGenVertexPtr(
0066     const FourVector& pos = FourVector( 0.0, 0.0, 0.0, 0.0 ) )
0067 {
0068     return new HepMC::GenVertex( pos );
0069 }
0070 #endif
0071 
0072 class EvtParticle;
0073 
0074 class EvtHepMCEvent {
0075   public:
0076     EvtHepMCEvent();
0077     virtual ~EvtHepMCEvent();
0078 
0079     // Select what frame a given GenParticle is in:
0080     // its own restframe, the lab frame (first mother), or its mother's frame
0081     enum HepMCFrame
0082     {
0083         RESTFRAME = 1,
0084         LAB = 2,
0085         MOTHER = 3
0086     };
0087     // Select the GenParticle status
0088     enum HepMCStatus
0089     {
0090         STABLE = 1,
0091         DECAYED = 2,
0092         HISTORY = 3
0093     };
0094 
0095     void constructEvent( EvtParticle* baseParticle );
0096     void constructEvent( EvtParticle* baseParticle, EvtVector4R& translation );
0097 
0098     GenEvent* getEvent() { return _theEvent; }
0099 
0100     // Methods used to create GenParticles and FourVectors of vertices.
0101     // Make these public so that other classes may call them if they use EvtHepMCEvent.
0102 
0103     // Create a GenParticle using info from the EvtParticle, specifying what frame
0104     // the 4-momentum is from.
0105     GenParticlePtr createGenParticle( EvtParticle* theParticle, int frameType );
0106 
0107     // Find out the decay vertex position for the given EvtParticle.
0108     FourVector getVertexCoord( EvtParticle* theParticle );
0109 
0110   protected:
0111   private:
0112     // Delete the event structure (called by destructor)
0113     void deleteEvent();
0114 
0115     // Add a vertex to the event. This is called by the constructEvent function
0116     // and is recursive, i.e. it loops through all possible daughter particles and
0117     // their descendents.
0118     void addVertex( EvtParticle* inEvtParticle, GenParticlePtr inGenParticle );
0119 
0120     GenEvent* _theEvent;
0121     EvtVector4R _translation;
0122 };
0123 
0124 #endif