00001 #ifndef madchain_h
00002 #define madchain_h
00003 #include <iostream>
00004 #include <string>
00005 #include <map>
00006 #include <utility>
00007 #include "TROOT.h"
00008 #include "TChain.h"
00009 #include "TFile.h"
00010 #include "CandNtupleSR/NtpSRRecord.h"
00011 #include "MCNtuple/NtpMCRecord.h"
00012 #include "TruthHelperNtuple/NtpTHRecord.h"
00013 #include "CandNtupleEM/NtpEMRecord.h"
00014 #include "StandardNtuple/NtpStRecord.h"
00015
00016 class MadChain
00017 {
00018 protected :
00019
00020 TChain *fChainSR;
00021 Int_t fCurrentSR;
00022
00023 TChain *fChainMC;
00024 Int_t fCurrentMC;
00025
00026 TChain *fChainTH;
00027 Int_t fCurrentTH;
00028
00029 TChain *fChainEM;
00030 Int_t fCurrentEM;
00031
00032 void Zero();
00033
00034 public:
00035 MadChain(TChain *chainSR=0,TChain *chainMC=0,
00036 TChain *chainTH=0,TChain *chainEM=0, bool build_index=false);
00037 ~MadChain();
00038 Int_t GetEntryNumber(Int_t run,Int_t snarl);
00039 Int_t Get(Int_t entry);
00040 void Init(TChain *chainSR,TChain *chainMC,
00041 TChain *chainTH,TChain *chainEM);
00042 void Show(Int_t entry = -1);
00043
00044 Bool_t isMC;
00045 Bool_t isTH;
00046 Bool_t isEM;
00047 Bool_t isST;
00048 Int_t Nentries;
00049
00050 NtpSRRecord *Record;
00051 NtpStRecord *stRecord;
00052 NtpMCRecord *mcRecord;
00053 NtpTHRecord *thRecord;
00054 NtpEMRecord *emRecord;
00055
00056 private:
00057
00058 void BuildLookup();
00059 bool fLookupBuilt;
00060
00061
00062 #ifndef __MAKECINT__
00063 #ifndef __CINT__
00064
00065
00066 struct first_then_second
00067 {
00068 bool operator()(const std::pair<Int_t,Int_t>& s1,
00069 const std::pair<Int_t,Int_t>& s2) const
00070 {
00071 if(s1.first < s2.first) return true;
00072 else if(s1.first > s2.first) return false;
00073 else {
00074 if(s1.second<s2.second) return true;
00075 else return false;
00076 }
00077 }
00078 };
00079 std::map< std::pair<Int_t,Int_t> , Long64_t, first_then_second > fLookUp;
00080
00081 #endif
00082 #endif
00083
00084
00085
00086 };
00087
00088 #endif // #ifdef madchain_h