]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMCEventHandler.h
I improved (by a factor 2.5) the speed of the MatchToMC method
[u/mrichter/AliRoot.git] / STEER / AliMCEventHandler.h
1 // -*- mode: C++ -*-
2 #ifndef ALIMCEVENTHANDLER_H
3 #define ALIMCEVENTHANDLER_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7
8 /* $Id$ */
9
10 //-------------------------------------------------------------------------
11 //                          Class AliMCEvent
12 // This class gives access to MC truth during the analysis.
13 // Monte Carlo truth is contained in the kinematics tree (produced particles) and 
14 // the tree of reference hits.
15 //      
16 // Origin: Andreas Morsch, CERN, andreas.morsch@cern.ch 
17 //-------------------------------------------------------------------------
18 #include "AliVEventHandler.h"
19 #include "AliHeader.h"
20 #include <TExMap.h>
21
22 class TFile;
23 class TTree;
24 class TList;
25
26 class TParticle;
27 class TString;
28 class TClonesArray;
29 class TDirectoryFile;
30
31 class AliMCEvent;
32
33
34
35 class AliMCEventHandler : public AliVEventHandler
36 {
37 public:
38     AliMCEventHandler();
39     AliMCEventHandler(const char* name, const char* title);
40     virtual ~AliMCEventHandler();
41     virtual void         SetOutputFileName(const char* /* fname */) {;}
42     virtual const char*  GetOutputFileName() {return 0;}
43     virtual void         SetInputPath(const char* fname); 
44     virtual void         SetInputTree(TTree* /*tree*/) {;}
45     virtual TString*     GetInputPath() const {return fPathName;}
46     virtual Bool_t       Init(Option_t* opt);
47     virtual Bool_t       InitIO(Option_t* opt) {return Init(opt);};
48     virtual Bool_t       Init(TTree* /*tree*/, Option_t* /*opt*/) {return kTRUE;}
49     virtual Bool_t       BeginEvent(Long64_t entry);
50     virtual Bool_t       Notify() { return AliVEventHandler::Notify(); };
51     virtual Bool_t       Notify(const char* path);
52     virtual Bool_t       FinishEvent();
53     virtual Bool_t       Terminate();
54     virtual Bool_t       TerminateIO();
55     virtual void         ResetIO();
56     virtual Bool_t       GetEvent(Int_t iev);
57     virtual void         SetReadTR(Bool_t flag) { fReadTR = flag; }
58     virtual void         AddSubsidiaryHandler(AliMCEventHandler* handler);
59     virtual void         SetNumberOfEventsInContainer(Int_t nev) {fEventsInContainer = nev;}
60     //
61     AliMCEvent* MCEvent() const {return fMCEvent;} 
62     TTree*      TreeTR()  const {return fTreeTR;}
63     TTree*      TreeK()   const {return fTreeK;}
64     Int_t       GetParticleAndTR(Int_t i, TParticle*& particle, TClonesArray*& trefs);
65     void        DrawCheck(Int_t i, Int_t search=0);
66     Bool_t      InitOk() {return fInitOk;}
67     // Label manipulation
68     void   SelectParticle(Int_t i);
69     Bool_t IsParticleSelected(Int_t i);
70     void   CreateLabelMap();
71     Int_t  GetNewLabel(Int_t i);
72
73 private:
74     Bool_t      OpenFile(Int_t i);
75     void  VerifySelectedParticles();
76     AliMCEventHandler(const AliMCEventHandler& handler);             
77     AliMCEventHandler& operator=(const AliMCEventHandler& handler);  
78 private:
79     AliMCEvent            *fMCEvent;            //! MC Event
80     TFile                 *fFileE;              //! File with TreeE
81     TFile                 *fFileK;              //! File with TreeK
82     TFile                 *fFileTR;             //! File with TreeTR
83     TTree                 *fTreeE;              //! TreeE  (Event Headers)
84     TTree                 *fTreeK;              //! TreeK  (kinematics tree)
85     TTree                 *fTreeTR;             //! TreeTR (track references tree)
86     TDirectoryFile        *fDirK;               //! Directory for Kine Tree
87     TDirectoryFile        *fDirTR;              //! Directory for TR Tree
88     TExMap                 fParticleSelected;   //! List of selected MC particles for t
89     TExMap                 fLabelMap;           //! Stores the Map of MC (ESDLabel,AODlabel)  
90     Int_t                  fNEvent;             //! Number of events
91     Int_t                  fEvent;              //! Current event
92     TString               *fPathName;           //! Input file path 
93     const Char_t          *fExtension;          //! File name extension 
94     Int_t                  fFileNumber;         //! Input file number
95     Int_t                  fEventsPerFile;      //! Number of events per file
96     Bool_t                 fReadTR;             // determines if TR shall be read
97     Bool_t                 fInitOk;             // Initialization ok
98     TList                 *fSubsidiaryHandlers; //! List of subsidiary MC handlers (for example for Background)
99     Int_t                  fEventsInContainer;  //! Number of events in container class 
100     ClassDef(AliMCEventHandler,1)  //MC Truth EventHandler class
101 };
102 #endif 
103