#ifndef Analysis_h #define Analysis_h #include #include #include #include #include #include #include "MyEvent.h" #include using namespace std; class TH1F; //class TRandom; class Analysis : public TSelector { public : // Declaration of the tree TTree *chain; // the loaded chain depends on the arguments passed to the constructor // Declaration of the objects MyEvent *fEvent; MyEventHeader *fHeader; MyTrack *fTracks; TClonesArray* Tracks; // Declaration of variables Int_t trcksNo; // Declaration of of branches TBranch *b_fEvent; //! TBranch *b_Tracks; //! TBranch *b_fHeader; //! //Declaration of the output TH1F *fHisto; Analysis() : fEvent(0), fHeader(0), fTracks(0), Tracks(0), fHisto(0), trcksNo(0) {} virtual ~Analysis() { } /// === TSelector methods virtual Int_t Version() const {return 1;} virtual void Begin(TTree *); virtual void SlaveBegin(TTree *tree); virtual void Init(TTree *tree); virtual Bool_t Notify(); virtual Bool_t Process(Long64_t entry); virtual void SetOption(const char *option) { fOption = option; } // virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return chain ? chain->GetTree()->GetEntry(entry, getall) : 0; } virtual void SetObject(TObject *obj) { fObject = obj; } virtual void SetInputList(TList *input) {fInput = input;} virtual TList *GetOutputList() const { return fOutput; } virtual void SlaveTerminate(); virtual void Terminate(); ClassDef(Analysis,0); }; #endif //#ifdef Analysis_cxx void Analysis::Init(TTree *tree) { trcksNo = 0; fEvent = 0; fHeader = 0; fTracks = 0; Tracks = 0; fHeader = new MyEventHeader(); // Set branch addresses and branch pointers if (tree == 0) return; chain = tree; chain->SetMakeClass(1); chain->SetBranchAddress("MyEvent",&fEvent); chain->SetBranchAddress("EvtHdr",&fHeader); chain->SetBranchAddress("Tracks",&fTracks); } Bool_t Analysis::Notify() { // The Notify() function is called when a new file is opened. This // can be either for a new TTree in a TChain or when when a new TTree // is started when using PROOF. Typically here the branch pointers // will be retrieved. It is normaly not necessary to make changes // to the generated code, but the routine can be extended by the // user if needed. TString fn; if (chain) { fn = chain->GetCurrentFile()->GetName(); Info("Notify", "processing file: %s", fn.Data()); } // Get branch pointers b_fEvent = chain->GetBranch("Event"); b_fHeader = chain->GetBranch("EvtHdr"); b_Tracks = chain->GetBranch("Tracks"); return kTRUE; } //#endif //idef Analysis_cxx