Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MadBase.h

Go to the documentation of this file.
00001 #ifndef madbase_h
00002 #define madbase_h
00003 #include <iostream>
00004 #include <string>
00005 #include "TROOT.h"
00006 #include "TChain.h"
00007 #include "TFile.h"
00008 #include "CandNtupleSR/NtpSRRecord.h"
00009 #include "CandNtupleSR/NtpSREvent.h"
00010 #include "CandNtupleSR/NtpSRTrack.h"
00011 #include "CandNtupleSR/NtpSRShower.h"
00012 #include "CandNtupleSR/NtpSRCluster.h"
00013 #include "CandNtupleSR/NtpSRSlice.h"
00014 #include "CandNtupleSR/NtpSRShieldStrip.h"
00015 #include "CandNtupleSR/NtpSRStrip.h"
00016 #include "CandNtupleSR/NtpSRDmxStatus.h"
00017 #include "CandNtupleSR/NtpSRDetStatus.h"
00018 #include "StandardNtuple/NtpStRecord.h"
00019 #include "MCNtuple/NtpMCRecord.h"
00020 #include "MCNtuple/NtpMCSummary.h"
00021 #include "MCNtuple/NtpMCTruth.h"
00022 #include "MCNtuple/NtpMCStdHep.h"
00023 #include "TruthHelperNtuple/NtpTHRecord.h"
00024 #include "TruthHelperNtuple/NtpTHSlice.h"
00025 #include "TruthHelperNtuple/NtpTHShower.h"
00026 #include "TruthHelperNtuple/NtpTHTrack.h"
00027 #include "TruthHelperNtuple/NtpTHEvent.h"
00028 #include "CandNtupleSR/NtpSRShieldSummary.h"
00029 #include "CandNtupleSR/NtpSREventSummary.h"
00030 #include "Record/RecCandHeader.h"
00031 #include "CandNtupleEM/NtpEMShower.h"
00032 #include "CandNtupleEM/NtpEMRecord.h"
00033 #include "CandNtupleEM/NtpEMSummary.h"
00034 #include "JobControl/JobC.h"
00035 #include "JobControl/JobCInput.h"
00036 #include "JobControl/JobCPath.h"
00037 #include "MinosObjectMap/MomNavigator.h"
00038 #include "MadChain.h"
00039 
00040 class MadBase 
00041 {
00042   protected :
00043 
00044   MadChain *fChain;  //allows for either ntuple or candidate file
00045   JobC *fJC;          //access to data members
00046   string jcPath;     //path name
00047   int fCurRun;       //current run
00048   int lastEntry;     //last entry from tree/snarl form Cand file accessed
00049 
00050   int whichSource;  // 0==> chain, 1==> candidate file, -1==> problem
00051 
00052   NtpStRecord *strecord;
00053   NtpSRRecord *record;
00054   const RecCandHeader *ntpHeader;
00055   NtpSRShieldSummary *shieldSummary;
00056   NtpSREventSummary *eventSummary;
00057   NtpSRDmxStatus *dmxStatus;
00058   NtpSRDetStatus *detStatus;
00059 
00060   NtpSREvent *ntpEvent;
00061   NtpSRTrack *ntpTrack;
00062   NtpSRShower *ntpShower;
00063   NtpSRCluster *ntpCluster;
00064   NtpSRSlice *ntpSlice;
00065   NtpSRShieldStrip *ntpShieldStrip;
00066   NtpSRStrip *ntpStrip;
00067   
00068   NtpMCRecord *mcrecord;
00069   NtpMCSummary *mcHeader;
00070   NtpMCTruth *ntpTruth;
00071   NtpMCStdHep *ntpStdHep;
00072 
00073   NtpTHRecord *threcord;
00074   NtpTHSlice *ntpTHSlice;
00075   NtpTHEvent *ntpTHEvent;
00076   NtpTHTrack *ntpTHTrack;
00077   NtpTHShower *ntpTHShower;
00078 
00079   NtpEMRecord *emrecord;
00080   NtpEMSummary *ntpEMSummary;
00081   NtpEMShower *ntpEMShower;
00082 
00083   Bool_t isMC;
00084   Bool_t isTH;
00085   Bool_t isEM;
00086   Bool_t isST;
00087   Int_t Nentries; //number of entries for fChainSR
00088 
00090   //
00091   // Usage examples. Code not inheriting from MadBase should substitute 
00092   // Get<-->Load in function names and pickup the pointer the Get routines
00093   // give back rather than using the pointers here in MadBase. The Get 
00094   // routines call the Load routines when they operate.
00095   //
00097   //
00098   // To loop over all events in the record, you do:
00099   //
00100   // for(int i=0; i<eventSummary->nevent; i++){
00101   //    LoadEvent(i);
00102   //    ntpEvent->.....
00103   // }
00104   //
00105   //
00106   // To loop over all tracks in an event you do:
00107   //
00108   // LoadEvent(event);
00109   // for(int i=0; i<ntpEvent->ntrack; i++){
00110   //     int trkidx=ntpEvent->trk[i]; // get track index in track array
00111   //     LoadTrack(trkidx); // pull track from track array
00112   //     ntpTrack->.....
00113   // }
00114   //
00115   // To loop over all *MC* events you do:
00116   //
00117   // for(int i=0; i<mcHeader->nmc; i++){
00118   //     LoadTruth(i);
00119   //     ntpTruth->....;
00120   // }
00121   //
00122   // To loop over all particles in an mc event you do:
00123   //
00124   // LoadTruth(mcevent);
00125   // for(int i=ntpTruth->stdhep[0]; i<=ntpTruth->stdhep[1]; i++){
00126   //     LoadStdHep(i);
00127   //     ntpStdHep->....;
00128   // }
00129   //
00130   // To loop over all particles in the stdhep block most closely associated
00131   // with a given reconstructed event, you do:
00132   //
00133   // LoadTruthForRecoTH(event, mcevent);//point ntpTruth at best mc event
00134   // for(int i=ntpTruth->stdhep[0]; i<=ntpTruth->stdhep[1]; i++){
00135   //     LoadStdHep(i);
00136   //     ntpStdHep->.....;
00137   // }
00138   //
00140 
00141 
00142 
00144   //
00145   // these routines load the reconstructed object stored at index position 
00146   // in the arrays contained in this record(i.e. snarl, i.e. spill)
00147   //
00148   // !!NOTE!!: ONE IS ACCESSING ALL THE RECONSTRUCTED OBJECTS, 
00149   //           NOT JUST THOSE IN THE LOADED EVENT!!!! 
00150   //
00152 
00153   //load one track from the "trk" array
00154   Bool_t LoadTrack(Int_t idx); 
00155   //load one shower from the "shw" array
00156   Bool_t LoadShower(Int_t idx); 
00157   //load one cluster from the "clu" array
00158   Bool_t LoadCluster(Int_t idx);
00159   //load one event from the event array "evt"
00160   Bool_t LoadEvent(Int_t idx); // here idx==event
00161   //load one slice from the slice array "slc"
00162   Bool_t LoadSlice(Int_t idx); 
00163   //load one strip from the shield strip array "vetostp"
00164   Bool_t LoadShieldStrip(Int_t idx);
00165   //load one strip from the strip array "stp"
00166   Bool_t LoadStrip(Int_t idx); 
00167   //load one entry from the mc array "mc"
00168   Bool_t LoadTruth(Int_t idx);//here idx==mcevent 
00169   //load one entry from the stdhep array "stdhep"
00170   Bool_t LoadStdHep(Int_t idx); 
00171   // load one entry from the 
00172   Bool_t LoadTHTrack(Int_t); //load a thtrack
00173   Bool_t LoadTHEvent(Int_t); //load a thevent
00174   Bool_t LoadTHShower(Int_t); //load a thshower
00175   Bool_t LoadTHSlice(Int_t); //load a thslice
00176 
00177   Bool_t LoadEMShower(Int_t); //load an EM shower
00178 
00179 
00180 
00181   // load largest trk or shower associated with event
00182   // return the index postion or -1 if no track or shower was found
00183   Bool_t LoadLargestTrackFromEvent(Int_t event, Int_t& trkidx);
00184   Bool_t LoadShower_Jim(Int_t event, Int_t& shwidx, Int_t detector);
00185   Bool_t LoadLargestShowerFromEvent(Int_t event, Int_t& shwidx);
00186   //load the shower in this event that is nearest track vertex
00187   Bool_t LoadShowerAtTrackVertex(Int_t event, Int_t track, Int_t& shwidx);
00188 
00189   // load one mc entry (i.e. event) corresponding to specified reco event
00190   // mc<-->reco association is done by event vertices
00191   // !!NOTE:!! PREFER LoadTruthForRecoTH() OVER THIS ROUTINE
00192   Bool_t LoadTruthForReco(Int_t,Int_t&); 
00193 
00194   // load one mc entry (i.e. event) corresponding to specified reco event
00195   // mc<-->reco association is done by truth helper
00196   // !!NOTE!!: PREFER THIS ROUTINE OVER LoadTruthForReco()
00197   Bool_t LoadTruthForRecoTH(Int_t,Int_t&);
00198   Bool_t LoadSliceForRecoTH(Int_t,Int_t&); 
00199   Float_t RecoShwEnergy(Int_t ishw=0,Int_t opt=-1, Int_t det=1); //from SR
00200 
00201 
00202 
00203  
00204  public:
00205   MadBase(TChain *chainSR=0,TChain *chainMC=0,
00206           TChain *chainTH=0,TChain *chainEM=0);
00207   MadBase(JobC *,string,int);
00208   ~MadBase();
00209   Int_t  GetEntry(Int_t run,Int_t snarl);
00210   Int_t  GetEntry(Int_t entry);
00211   void   InitChain(TChain *chainSR,TChain *chainMC,
00212                    TChain *chainTH,TChain *chainEM, bool build_index=false);
00213   void   Clear();  
00214 
00215 
00216  public:
00217   // functions allowing external manipulation of this object
00218   // motivation:  algorithms can look like : MyAlg(MadBase*)
00219   //              and be called like:  myobj.MyAlg(this)
00220   //              from inside a MadBase derived class (e.g. in a MadAnalysis)
00221   //
00222   const NtpSREventSummary* GetEventSummary(){return eventSummary;}
00223   const RecCandHeader* GetHeader() {return ntpHeader;}
00224   const NtpSRTrack* GetTrack(Int_t); 
00225   const NtpSRTrack* GetLargestTrackFromEvent(Int_t,Int_t&);
00226   const NtpSRShower* GetShower(Int_t);
00227   const NtpSRCluster* GetCluster(Int_t);
00228   const NtpSRShower* GetLargestShowerFromEvent(Int_t,Int_t&);
00229   const NtpSRShower* GetShowerAtTrackVertex(Int_t,Int_t,Int_t&);
00230   const NtpSREvent* GetEvent(Int_t);
00231   const NtpSRSlice* GetSlice(Int_t);
00232   const NtpSRShieldStrip* GetShieldStrip(Int_t);
00233   const NtpSRStrip* GetStrip(Int_t);
00234   
00235   const NtpMCTruth* GetTruth(Int_t);
00236   const NtpMCStdHep* GetStdHep(Int_t);
00237   const NtpMCTruth* GetTruthForReco(Int_t,Int_t&);
00238   const NtpTHSlice* GetSliceForRecoTH(Int_t,Int_t&);
00239   const NtpMCTruth* GetTruthForRecoTH(Int_t,Int_t&);
00240   const NtpTHTrack* GetTHTrack(Int_t);
00241   const NtpTHEvent* GetTHEvent(Int_t);
00242   const NtpTHShower* GetTHShower(Int_t);
00243   const NtpTHSlice* GetTHSlice(Int_t);
00244 
00245   const NtpEMShower* GetEMShower(Int_t);
00246  
00247 
00248 };
00249 
00250 #endif // #ifdef madbase_h

Generated on Mon Feb 15 11:06:54 2010 for loon by  doxygen 1.3.9.1