File indexing completed on 2024-04-06 12:19:01
0001 #ifndef Input_HepMCFileReader_h
0002 #define Input_HepMCFileReader_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <vector>
0017 #include <map>
0018
0019 #include "FWCore/Utilities/interface/get_underlying_safe.h"
0020
0021 namespace HepMC {
0022 class IO_BaseClass;
0023 class GenEvent;
0024 class GenParticle;
0025 }
0026
0027 class HepMCFileReader {
0028 protected:
0029 HepMCFileReader();
0030
0031 public:
0032 virtual ~HepMCFileReader();
0033 virtual void initialize(const std::string &filename);
0034 inline bool isInitialized() const;
0035
0036 virtual bool setEvent(int event);
0037 virtual bool readCurrentEvent();
0038 virtual bool printHepMcEvent() const;
0039 HepMC::GenEvent *fillCurrentEventData();
0040
0041
0042
0043 void printEvent() const;
0044
0045
0046
0047 virtual void getStatsFromTuple(int &mo1, int &mo2, int &da1, int &da2, int &status, int &pid, int j) const;
0048 virtual void ReadStats();
0049
0050 static HepMCFileReader *instance();
0051
0052 private:
0053 HepMC::IO_BaseClass const *input() const { return get_underlying_safe(input_); }
0054 HepMC::IO_BaseClass *&input() { return get_underlying_safe(input_); }
0055
0056
0057 edm::propagate_const<HepMC::GenEvent *> evt_;
0058 edm::propagate_const<HepMC::IO_BaseClass *> input_;
0059
0060 static HepMCFileReader *instance_;
0061
0062 int rdstate() const;
0063
0064
0065 std::vector<HepMC::GenParticle *> index_to_particle;
0066 std::map<HepMC::GenParticle *, int> particle_to_index;
0067
0068 int find_in_map(const std::map<HepMC::GenParticle *, int> &m, HepMC::GenParticle *p) const;
0069 };
0070
0071 bool HepMCFileReader::isInitialized() const { return input_ != nullptr; }
0072
0073 #endif