CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/IOMC/Input/interface/HepMCFileReader.h

Go to the documentation of this file.
00001 #ifndef Input_HepMCFileReader_h
00002 #define Input_HepMCFileReader_h
00003 
00004 // $Id: HepMCFileReader.h,v 1.5 2009/12/01 19:23:11 fabstoec Exp $
00005 
00020 #include <vector>
00021 #include <map>
00022 
00023 
00024 namespace HepMC {
00025   class IO_BaseClass;
00026   class GenEvent;
00027   class GenParticle;
00028 }
00029 
00030 
00031 class HepMCFileReader {
00032   
00033   protected:
00034   HepMCFileReader();
00035   
00036   public: 
00037   virtual ~HepMCFileReader(); 
00038   virtual void initialize(const std::string &filename);  
00039   inline bool isInitialized() const;
00040 
00041   virtual bool setEvent(int event);
00042   virtual bool readCurrentEvent();
00043   virtual bool printHepMcEvent() const; 
00044   HepMC::GenEvent *fillCurrentEventData();
00045   //  virtual bool fillEventData(HepMC::GenEvent *event);
00046   // this method prints the event information as 
00047   // obtained by the input file in HepEvt style
00048   void printEvent() const;
00049   // get all the 'integer' properties of a particle 
00050   // like mother, daughter, pid and status
00051   // 'j' is the number of the particle in the HepMc
00052   virtual void getStatsFromTuple(int &mo1, int &mo2, int &da1, int &da2,
00053                                  int &status, int &pid, int j) const;
00054   virtual void ReadStats();
00055 
00056   static HepMCFileReader *instance();
00057 
00058   private:
00059   // current  HepMC evt
00060   HepMC::GenEvent *evt_;
00061   HepMC::IO_BaseClass *input_;
00062 
00063   static HepMCFileReader *instance_;
00064 
00065   int rdstate() const;
00066   //maps to convert HepMC::GenParticle to particles # and vice versa
00067   // -> needed for HepEvt like output
00068   std::vector<HepMC::GenParticle*> index_to_particle;  
00069   std::map<HepMC::GenParticle*,int> particle_to_index;    
00070   // find index to HepMC::GenParticle* p in map m
00071   int find_in_map(const std::map<HepMC::GenParticle*,int>& m,
00072                   HepMC::GenParticle *p) const;
00073 };
00074 
00075 
00076 bool HepMCFileReader::isInitialized() const
00077 {
00078   return input_ != 0;
00079 }
00080 
00081 #endif