CMS 3D CMS Logo

Public Member Functions | Protected Attributes

G4SimEvent Class Reference

#include <G4SimEvent.h>

List of all members.

Public Member Functions

void add (G4SimTrack *t)
void add (G4SimVertex *v)
void collisionPoint (const math::XYZTLorentzVectorD &v)
const math::XYZTLorentzVectorDcollisionPoint () const
 G4SimEvent ()
const G4SimTrackg4track (int i) const
const G4SimVertexg4vertex (int i) const
void hepEvent (const HepMC::GenEvent *r)
const HepMC::GenEvent * hepEvent () const
void load (edm::SimVertexContainer &c) const
void load (edm::SimTrackContainer &c) const
unsigned int nGenParts () const
void nparam (int n)
const int nparam () const
unsigned int nTracks () const
unsigned int nVertices () const
void param (const std::vector< float > &p)
const std::vector< float > & param () const
void weight (float w)
const float weight () const
virtual ~G4SimEvent ()

Protected Attributes

math::XYZTLorentzVectorD collisionPoint_
std::vector< G4SimTrack * > g4tracks
std::vector< G4SimVertex * > g4vertices
const HepMC::GenEvent * hepMCEvent
int nparam_
std::vector< float > param_
float weight_

Detailed Description

Definition at line 15 of file G4SimEvent.h.


Constructor & Destructor Documentation

G4SimEvent::G4SimEvent ( )

Definition at line 14 of file G4SimEvent.cc.

G4SimEvent::~G4SimEvent ( ) [virtual]

Definition at line 19 of file G4SimEvent.cc.

References g4tracks, g4vertices, and i.

{

/*
   while ( !g4tracks.empty() )
   {
      delete g4tracks.back() ;
      g4tracks.pop_back() ;
   }
   while ( !g4vertices.empty() )
   {
      delete g4vertices.back() ;
      g4vertices.pop_back() ;
   }
*/

   // per suggestion by Chris Jones, it's faster 
   // that delete back() and pop_back() 
   //
   unsigned int i = 0 ;
   
   for ( i=0; i<g4tracks.size(); i++ )
   {
      delete g4tracks[i] ;
      g4tracks[i] = 0 ;
   }
   g4tracks.clear() ;
   
   for ( i=0; i<g4vertices.size(); i++ )
   {
      delete g4vertices[i] ;
      g4vertices[i] = 0 ;
   }
   g4vertices.clear();
}

Member Function Documentation

void G4SimEvent::add ( G4SimTrack t) [inline]

Definition at line 35 of file G4SimEvent.h.

References g4tracks.

Referenced by SimTrackManager::getOrCreateVertex(), and SimTrackManager::reallyStoreTracks().

{ g4tracks.push_back(t); }
void G4SimEvent::add ( G4SimVertex v) [inline]

Definition at line 36 of file G4SimEvent.h.

References g4vertices.

{ g4vertices.push_back(v); }
void G4SimEvent::collisionPoint ( const math::XYZTLorentzVectorD v) [inline]

Definition at line 29 of file G4SimEvent.h.

References collisionPoint_, and findQualityFiles::v.

Referenced by RunManager::produce().

const math::XYZTLorentzVectorD& G4SimEvent::collisionPoint ( ) const [inline]

Definition at line 30 of file G4SimEvent.h.

References collisionPoint_.

{ return collisionPoint_; }
const G4SimTrack& G4SimEvent::g4track ( int  i) const [inline]

Definition at line 37 of file G4SimEvent.h.

References g4tracks.

{ return *g4tracks[i-1]; }
const G4SimVertex& G4SimEvent::g4vertex ( int  i) const [inline]

Definition at line 38 of file G4SimEvent.h.

References g4vertices.

{ return *g4vertices[i-1]; }
void G4SimEvent::hepEvent ( const HepMC::GenEvent *  r) [inline]

Definition at line 25 of file G4SimEvent.h.

References hepMCEvent, and alignCSCRings::r.

Referenced by RunManager::produce().

{ hepMCEvent = r; }
const HepMC::GenEvent* G4SimEvent::hepEvent ( ) const [inline]

Definition at line 26 of file G4SimEvent.h.

References hepMCEvent.

{ return hepMCEvent; }
void G4SimEvent::load ( edm::SimVertexContainer c) const

Definition at line 88 of file G4SimEvent.cc.

References g4vertices, i, G4SimVertex::parentIndex(), edm::second(), CoreSimVertex::setEventId(), lumiQTWidget::t, findQualityFiles::v, G4SimVertex::vertexGlobalTime(), and G4SimVertex::vertexPosition().

{
    for (unsigned int i=0; i<g4vertices.size(); i++)
    {
        G4SimVertex * vtx   = g4vertices[i];
        //
        // starting 1_1_0_pre3, SimVertex stores in cm !!!
        // 
        math::XYZVectorD v3( vtx->vertexPosition().x()/cm, 
                             vtx->vertexPosition().y()/cm,
                             vtx->vertexPosition().z()/cm ) ;
        float t             = vtx->vertexGlobalTime()/second;
        int iv              = vtx->parentIndex();
        // vv = position
        // t  = global time
        // iv = index of the parent in the SimEvent SimTrack container (-1 if no parent)
        SimVertex v = SimVertex(v3,t,iv,i);
        v.setEventId(EncodedEventId(0));
        c.push_back(v);
    }
}
void G4SimEvent::load ( edm::SimTrackContainer c) const

Definition at line 55 of file G4SimEvent.cc.

References G4SimTrack::energy(), g4tracks, i, G4SimTrack::id(), G4SimTrack::igenpart(), G4SimTrack::ivert(), G4SimTrack::momentum(), AlCaHLTBitMon_ParallelJobs::p, G4SimTrack::part(), lumiQTWidget::t, G4SimTrack::trackerSurfaceMomentum(), and G4SimTrack::trackerSurfacePosition().

Referenced by OscarProducer::produce().

{
    for (unsigned int i=0; i<g4tracks.size(); i++)
    {
        G4SimTrack * trk    = g4tracks[i];
        int ip              = trk->part();
        math::XYZTLorentzVectorD p( trk->momentum().x()/GeV,
                                    trk->momentum().y()/GeV,
                                    trk->momentum().z()/GeV,
                                    trk->energy()/GeV ) ;
        int iv              = trk->ivert();
        int ig              = trk->igenpart();
        int id              = trk->id();
        math::XYZVectorD tkpos( trk->trackerSurfacePosition().x()/cm,
                                trk->trackerSurfacePosition().y()/cm,
                                trk->trackerSurfacePosition().z()/cm ) ;
        math::XYZTLorentzVectorD tkmom( trk->trackerSurfaceMomentum().x()/GeV,
                                        trk->trackerSurfaceMomentum().y()/GeV,
                                        trk->trackerSurfaceMomentum().z()/GeV,
                                        trk->trackerSurfaceMomentum().e()/GeV ) ;
        // ip = particle ID as PDG
        // pp = 4-momentum
        // iv = corresponding G4SimVertex index
        // ig = corresponding GenParticle index
        SimTrack t = SimTrack(ip,p,iv,ig,tkpos,tkmom);
        t.setTrackId(id);
        t.setEventId(EncodedEventId(0));
        c.push_back(t);
    }
    std::stable_sort(c.begin(),c.end(),IdSort());
    
}
unsigned int G4SimEvent::nGenParts ( ) const [inline]

Definition at line 24 of file G4SimEvent.h.

References hepMCEvent.

Referenced by RunManager::produce().

{ return hepMCEvent->particles_size(); }
void G4SimEvent::nparam ( int  n) [inline]

Definition at line 31 of file G4SimEvent.h.

References n, and nparam_.

{ nparam_ = n; }
const int G4SimEvent::nparam ( ) const [inline]

Definition at line 32 of file G4SimEvent.h.

References nparam_.

{ return nparam_; }
unsigned int G4SimEvent::nTracks ( ) const [inline]

Definition at line 22 of file G4SimEvent.h.

References g4tracks.

Referenced by RunManager::produce().

{ return g4tracks.size(); }
unsigned int G4SimEvent::nVertices ( ) const [inline]

Definition at line 23 of file G4SimEvent.h.

References g4vertices.

Referenced by RunManager::produce().

{ return g4vertices.size(); }
void G4SimEvent::param ( const std::vector< float > &  p) [inline]

Definition at line 33 of file G4SimEvent.h.

References AlCaHLTBitMon_ParallelJobs::p, and param_.

{ param_ = p; }
const std::vector<float>& G4SimEvent::param ( ) const [inline]

Definition at line 34 of file G4SimEvent.h.

References param_.

{ return param_; }
const float G4SimEvent::weight ( void  ) const [inline]

Definition at line 28 of file G4SimEvent.h.

References weight_.

{ return weight_; }
void G4SimEvent::weight ( float  w) [inline]

Definition at line 27 of file G4SimEvent.h.

References w(), and weight_.

Referenced by RunManager::produce().

{ weight_ = w; }

Member Data Documentation

Definition at line 42 of file G4SimEvent.h.

Referenced by collisionPoint().

std::vector<G4SimTrack *> G4SimEvent::g4tracks [protected]

Definition at line 45 of file G4SimEvent.h.

Referenced by add(), g4track(), load(), nTracks(), and ~G4SimEvent().

std::vector<G4SimVertex *> G4SimEvent::g4vertices [protected]

Definition at line 46 of file G4SimEvent.h.

Referenced by add(), g4vertex(), load(), nVertices(), and ~G4SimEvent().

const HepMC::GenEvent* G4SimEvent::hepMCEvent [protected]

Definition at line 40 of file G4SimEvent.h.

Referenced by hepEvent(), and nGenParts().

int G4SimEvent::nparam_ [protected]

Definition at line 43 of file G4SimEvent.h.

Referenced by nparam().

std::vector<float> G4SimEvent::param_ [protected]

Definition at line 44 of file G4SimEvent.h.

Referenced by param().

float G4SimEvent::weight_ [protected]

Definition at line 41 of file G4SimEvent.h.

Referenced by weight().