ProofEventProc.h

Go to the documentation of this file.
00001 #ifndef ProofEventProc_h
00002 #define ProofEventProc_h
00003 
00004 //////////////////////////////////////////////////////////
00005 //
00006 // Example of TSelector implementation to process trees
00007 // containing 'Event' structures, e.g. the files under
00008 // http://root.cern.ch/files/data .
00009 // See tutorials/proof/runProof.C, option "eventproc", for
00010 // an example of how to run this selector.
00011 //
00012 //////////////////////////////////////////////////////////
00013 
00014 #include <TROOT.h>
00015 #include <TChain.h>
00016 #include <TFile.h>
00017 #include <TSelector.h>
00018 #include "Event.h"
00019 
00020 class TH1F;
00021 class TH2F;
00022 
00023 class ProofEventProc : public TSelector {
00024 public :
00025    TTree          *fChain;   //!pointer to the analyzed TTree or TChain
00026 
00027    // Declaration of leave types
00028    Event           *event;
00029    Char_t          fType[20];
00030    Char_t          *fEventName;
00031    Int_t           fNtrack;
00032    Int_t           fNseg;
00033    Int_t           fNvertex;
00034    UInt_t          fFlag;
00035    Double32_t      fTemperature;
00036    Int_t           fMeasures[10];
00037    Double32_t      fMatrix[4][4];
00038    Double32_t      fClosestDistance[21];   //[fNvertex]
00039    EventHeader     fEvtHdr;
00040    TClonesArray    *fTracks;
00041    TRefArray       *fHighPt;
00042    TRefArray       *fMuons;
00043    TRef            fLastTrack;
00044    TRef            fWebHistogram;
00045    TH1F            *fH;
00046    TBits           fTriggerBits;
00047    Bool_t          fIsValid;
00048 
00049    // Read controller
00050    Bool_t          fFullRead;
00051 
00052    //Output hist
00053    TH1F* fPtHist;
00054    TH1F* fPzHist;
00055    TH2F* fPxPyHist;
00056 
00057    // List of branches
00058    TBranch        *b_event_fType;   //!
00059    TBranch        *b_fEventName;   //!
00060    TBranch        *b_event_fNtrack;   //!
00061    TBranch        *b_event_fNseg;   //!
00062    TBranch        *b_event_fNvertex;   //!
00063    TBranch        *b_event_fFlag;   //!
00064    TBranch        *b_event_fTemperature;   //!
00065    TBranch        *b_event_fMeasures;   //!
00066    TBranch        *b_event_fMatrix;   //!
00067    TBranch        *b_fClosestDistance;   //!
00068    TBranch        *b_event_fEvtHdr;   //!
00069    TBranch        *b_fTracks;   //!
00070    TBranch        *b_fHighPt;   //!
00071    TBranch        *b_fMuons;   //!
00072    TBranch        *b_event_fLastTrack;   //!
00073    TBranch        *b_event_fWebHistogram;   //!
00074    TBranch        *b_fH;   //!
00075    TBranch        *b_event_fTriggerBits;   //!
00076    TBranch        *b_event_fIsValid;   //!
00077 
00078    ProofEventProc(TTree *) { fFullRead = kTRUE; }
00079    ProofEventProc() { }
00080    virtual ~ProofEventProc() { }
00081    virtual Int_t   Version() const {return 1;}
00082    virtual void    Begin(TTree *);
00083    virtual void    SlaveBegin(TTree *tree);
00084    virtual void    Init(TTree *tree);
00085    virtual Bool_t  Notify();
00086    virtual Bool_t  Process(Long64_t entry);
00087    virtual void    SetOption(const char *option) { fOption = option; }
00088    virtual void    SetObject(TObject *obj) { fObject = obj; }
00089    virtual void    SetInputList(TList *input) {fInput = input;}
00090    virtual TList  *GetOutputList() const { return fOutput; }
00091    virtual void    SlaveTerminate();
00092    virtual void    Terminate();
00093 
00094    ClassDef(ProofEventProc,0);
00095 };
00096 
00097 #endif
00098 
00099 #ifdef ProofEventProc_cxx
00100 void ProofEventProc::Init(TTree *tree)
00101 {
00102    // The Init() function is called when the selector needs to initialize
00103    // a new tree or chain. Typically here the branch addresses of the tree
00104    // will be set. It is normaly not necessary to make changes to the
00105    // generated code, but the routine can be extended by the user if needed.
00106    // Init() will be called many times when running with PROOF.
00107 
00108    // Set branch addresses
00109    fEventName=0;
00110    fTracks=0;
00111    fHighPt=0;
00112    fMuons=0;
00113    fH=0;
00114    if (tree == 0) return;
00115    fChain = tree;
00116    fChain->SetMakeClass(1);
00117 
00118    fChain->SetBranchAddress("fType[20]",fType);
00119    fChain->SetBranchAddress("fEventName",fEventName);
00120    fChain->SetBranchAddress("fNtrack",&fNtrack);
00121    fChain->SetBranchAddress("fNseg",&fNseg);
00122    fChain->SetBranchAddress("fNvertex",&fNvertex);
00123    fChain->SetBranchAddress("fFlag",&fFlag);
00124    fChain->SetBranchAddress("fTemperature",&fTemperature);
00125    fChain->SetBranchAddress("fMeasures[10]",fMeasures);
00126    fChain->SetBranchAddress("fMatrix[4][4]",fMatrix);
00127    fChain->SetBranchAddress("fClosestDistance",fClosestDistance);
00128    fChain->SetBranchAddress("fEvtHdr",&fEvtHdr);
00129    fChain->SetBranchAddress("fTracks",&fTracks);
00130    fChain->SetBranchAddress("fHighPt",&fHighPt);
00131    fChain->SetBranchAddress("fMuons",&fMuons);
00132    fChain->SetBranchAddress("fLastTrack",&fLastTrack);
00133    fChain->SetBranchAddress("fWebHistogram",&fWebHistogram);
00134    fChain->SetBranchAddress("fH",&fH);
00135    fChain->SetBranchAddress("fTriggerBits",&fTriggerBits);
00136    fChain->SetBranchAddress("fIsValid",&fIsValid);
00137 }
00138 
00139 Bool_t ProofEventProc::Notify()
00140 {
00141    // The Notify() function is called when a new file is opened. This
00142    // can be either for a new TTree in a TChain or when when a new TTree
00143    // is started when using PROOF. Typically here the branch pointers
00144    // will be retrieved. It is normaly not necessary to make changes
00145    // to the generated code, but the routine can be extended by the
00146    // user if needed.
00147 
00148    // Get branch pointers
00149    b_event_fType = fChain->GetBranch("fType[20]");
00150    b_fEventName = fChain->GetBranch("fEventName");
00151    b_event_fNtrack = fChain->GetBranch("fNtrack");
00152    b_event_fNseg = fChain->GetBranch("fNseg");
00153    b_event_fNvertex = fChain->GetBranch("fNvertex");
00154    b_event_fFlag = fChain->GetBranch("fFlag");
00155    b_event_fTemperature = fChain->GetBranch("fTemperature");
00156    b_event_fMeasures = fChain->GetBranch("fMeasures[10]");
00157    b_event_fMatrix = fChain->GetBranch("fMatrix[4][4]");
00158    b_fClosestDistance = fChain->GetBranch("fClosestDistance");
00159    b_event_fEvtHdr = fChain->GetBranch("fEvtHdr");
00160    b_fTracks = fChain->GetBranch("fTracks");
00161    b_fHighPt = fChain->GetBranch("fHighPt");
00162    b_fMuons = fChain->GetBranch("fMuons");
00163    b_event_fLastTrack = fChain->GetBranch("fLastTrack");
00164    b_event_fWebHistogram = fChain->GetBranch("fWebHistogram");
00165    b_fH = fChain->GetBranch("fH");
00166    b_event_fTriggerBits = fChain->GetBranch("fTriggerBits");
00167    b_event_fIsValid = fChain->GetBranch("fIsValid");
00168 
00169    return kTRUE;
00170 }
00171 
00172 #endif // #ifdef ProofEventProc_cxx

Generated on Tue Jul 5 15:44:53 2011 for ROOT_528-00b_version by  doxygen 1.5.1