fmssim
|
00001 //PythiaEventReader.h 00002 //M.L. Miller (Yale Software) 00003 //07/02 00004 00005 #ifndef PythiaEventReader_HH 00006 #define PythiaEventReader_HH 00007 00008 #include "TObject.h" 00009 #include <iostream> 00010 00011 #include <map> 00012 using std::map; 00013 #include <vector> 00014 using std::vector; 00015 #include <string> 00016 using std::string; 00017 00018 class pythiaEvent; 00019 class TTree; 00020 class TFile; 00021 00022 //helper structs for book-keeping: 00023 struct PythiaEventSummary 00024 { 00025 PythiaEventSummary(pythiaEvent*); 00026 int subprocessType; 00027 int nParticle; 00028 int nFinalState; 00029 double shat; 00030 double that; 00031 double Q2; 00032 double costheta; 00033 }; 00034 00035 struct SummaryValue 00036 { 00037 string fileName; //the file that it came from 00038 int eventNumber; //the event number 00039 }; 00040 00041 struct PythiaEventSummaryLessThan 00042 { 00043 bool operator()(const PythiaEventSummary& lhs, const PythiaEventSummary& rhs) const; 00044 }; 00045 00046 class PythiaEventReader 00047 { 00048 public: 00049 PythiaEventReader(); 00050 virtual ~PythiaEventReader(); 00051 00052 //close current file (if any) and open a new one 00053 void openFile(const char*); 00054 void setTree(TTree* chain); //someone's created a chain for us, we just set the pointer + branch 00055 void closeFile(); 00056 00057 //event logging 00058 void setLog(bool v) {mDoLog=v;} 00059 bool log() const {return mDoLog;} 00060 void checkLog(bool verbose=false); 00061 00062 //Event access 00063 int numberOfEvents() const; 00064 pythiaEvent* getEvent(int event_number); 00065 00066 protected: 00067 TFile* mFile; 00068 pythiaEvent* mEvent; 00069 TTree* mTree; 00070 00071 bool mDoLog; 00072 00073 typedef vector<SummaryValue> SummaryVec; 00074 typedef map<PythiaEventSummary, SummaryVec, PythiaEventSummaryLessThan> EventSumMap; 00075 EventSumMap* mEventSumMap; 00076 00077 private: 00078 ClassDef(PythiaEventReader,1) 00079 }; 00080 00081 //inlines 00082 inline ostream& operator<<(ostream& os, const PythiaEventSummary& s) 00083 { 00084 return os<<"spt: "<<s.subprocessType<<"\tnP: "<<s.nParticle<<"\tnFS: "<<s.nFinalState 00085 <<"\ts: "<<s.shat<<"\tt: "<<s.that<<"\tQ2: "<<s.Q2<<"\tcos(t*): "<<s.costheta; 00086 } 00087 #endif