]>
Commit | Line | Data |
---|---|---|
a5556ea5 | 1 | #ifndef ALIREADER_H |
2 | #define ALIREADER_H | |
3 | //_________________________________________________________________________ | |
4 | /////////////////////////////////////////////////////////////////////////// | |
5 | // | |
6 | // class AliReader | |
7 | // | |
8 | // Reader Base class | |
9 | // Reads particles and tracks and | |
e6b229c6 | 10 | // puts them to the AliAOD objects and eventually, if needed, buffers AliAODs in AliAODRun(s) |
a5556ea5 | 11 | // |
e6b229c6 | 12 | // User loops over events calling method Next. In case of success this method returns 0. |
13 | // In case of error or if there is no more events to read, non-0 value is returned | |
14 | // | |
15 | // Reading can be rewound to the beginning using method Rewind. | |
16 | // | |
17 | // Tracks are read to the fEventRec (contains reconstructed tracks) | |
18 | // and fEventSim (corresponding MC simulated data) data members, | |
19 | // that are of the type AliAOD. | |
20 | // | |
21 | // If a given reader has ability of reading both, reconstructed and simulated data, | |
22 | // these are structured in AODs so a "n'th" simulated particle | |
23 | // (the one stored in the fEventSim at slot n) | |
24 | // corresponds to the n'th reconstructed track (the one stored in the fEventRec at slot n). | |
25 | // | |
26 | // The same reconstructed track can be present more than ones in the AOD, | |
27 | // but with a different PID. In this case | |
28 | // pointer to the corresponding MC simulated particles is also present more than ones. | |
29 | // This situation happens if you want to read all particles | |
30 | // with PID probability of being , e.g., pion higher than 60% | |
31 | // and being kaon higher than 40%. Than, if a given track has probability Ppid(pi)=52% and Ppid(K)=48% | |
32 | // than it is read twise. | |
33 | // | |
34 | // Provides functionality for both buffering and non-buffering reading | |
35 | // This can be switched on/off via method SetEventBuffering(bool) | |
36 | // The main method that inheriting classes need to implement is ReadNext() | |
37 | // that read next event in queue. | |
38 | // | |
39 | // The others are: | |
40 | // Bool_t ReadsRec() const; specifies if reader is able to read simulated particles | |
41 | // Bool_t ReadsSim() const; specifies if reader is able to read reconstructed tracks | |
42 | // void Rewind(); rewind reading to the beginning | |
43 | // | |
44 | // This class provides full functionality for reading from many sources | |
45 | // User can provide TObjArray of TObjStrings (SetDirs method or via parameter | |
46 | // in the constructor) which desribes paths of directories to search data in. | |
47 | // If none specified current directory is searched. | |
48 | // | |
a5556ea5 | 49 | // Piotr.Skowronski@cern.ch |
50 | // | |
51 | /////////////////////////////////////////////////////////////////////////// | |
52 | ||
53 | #include <TNamed.h> | |
54 | #include <TObjArray.h> | |
55 | ||
56 | class AliAODRun; | |
57 | class AliAOD; | |
58 | class AliAODParticleCut; | |
afa8b37b | 59 | class AliVAODParticle; |
a5556ea5 | 60 | class TString; |
61 | class TH1I; | |
62 | ||
63 | class AliReader: public TNamed | |
64 | { | |
65 | public: | |
66 | AliReader(); | |
67 | AliReader(TObjArray*); | |
68 | AliReader(const AliReader& in); | |
69 | virtual ~AliReader(); | |
70 | ||
71 | AliReader& operator=(const AliReader& in); | |
72 | ||
73 | virtual Int_t Next(); | |
74 | virtual void Rewind() = 0; // | |
75 | ||
76 | virtual Bool_t ReadsSim() const = 0; //specifies if reader is able to read simulated particles | |
77 | virtual Bool_t ReadsRec() const = 0;//specifies if reader is able to read reconstructed tracks | |
e6b229c6 | 78 | |
79 | void AddParticleCut(AliAODParticleCut* cut);//adds a particle cut to the list of cuts | |
a5556ea5 | 80 | |
e6b229c6 | 81 | virtual AliAOD* GetEventRec() const {return fEventRec;}//returns current event with reconstructed tracks |
82 | virtual AliAOD* GetEventSim() const {return fEventSim;}//returns current event with simulated particles | |
a5556ea5 | 83 | |
e6b229c6 | 84 | virtual AliAOD* GetEventRec(Int_t n);//returns event number n |
a5556ea5 | 85 | virtual AliAOD* GetEventSim(Int_t n); |
86 | ||
e6b229c6 | 87 | virtual Int_t Read(AliAODRun* particles, AliAODRun *tracks);//Reads all available evenets and stores them in 'particles' and 'tracks' |
88 | ||
89 | virtual Int_t GetNumberOfRecEvents();//Returns number of available events -> usually conncected with reading all events | |
90 | //may be time consuming | |
91 | virtual Int_t GetNumberOfSimEvents();// | |
a5556ea5 | 92 | |
93 | void SetDirs(TObjArray* dirs){fDirs = dirs;} //sets array directories names | |
94 | void SetEventBuffering(Bool_t flag){fBufferEvents = flag;}//switches on/off buffering - read data are kept in local buffer | |
95 | void SetBlend(Bool_t flag = kTRUE){fBlend=flag;} //set blending - randomizing particle order | |
96 | virtual Int_t GetNumberOfDirs() const {return (fDirs)?fDirs->GetEntries():0;} | |
97 | void ReadEventsFromTo(Int_t first,Int_t last){fFirst = first; fLast = last;} | |
98 | virtual TH1I* GetTrackCounter() const {return fTrackCounter;} | |
e6b229c6 | 99 | virtual void WriteTrackCounter() const;//Writes the track counting histigram |
a5556ea5 | 100 | |
101 | protected: | |
102 | ||
103 | TObjArray* fCuts;//array with particle cuts | |
104 | TObjArray* fDirs;//arry with directories to read data from | |
105 | ||
106 | Int_t fCurrentEvent;//! number of current event in current directory | |
107 | Int_t fCurrentDir;//! number of current directory | |
108 | ||
109 | Int_t fNEventsRead;//!total | |
110 | ||
111 | AliAOD* fEventRec; //! tracks read from current event | |
112 | AliAOD* fEventSim; //! particles read from current event | |
113 | ||
114 | AliAODRun* fRunSim; //!simulated particles | |
115 | AliAODRun* fRunRec; //!reconstructed tracks | |
116 | ||
117 | Bool_t fIsRead;//!flag indicating if the data are already read | |
118 | Bool_t fBufferEvents;//flag indicating if the data should be bufferred | |
119 | ||
120 | Bool_t fBlend;// flag indicating if randomly change positions of the particles after reading | |
121 | ||
e6b229c6 | 122 | Int_t fFirst;//first event to return (all before are skipped) |
123 | Int_t fLast;//the last one | |
a5556ea5 | 124 | |
125 | TH1I* fTrackCounter; //histogram with number of tracks read | |
126 | ||
127 | virtual Int_t ReadNext() = 0; //this methods reads next event and put result in fTracksEvent and/or fParticlesEvent | |
e6b229c6 | 128 | Bool_t Pass(AliVAODParticle* p);//Checks if a given particle agains cuts |
129 | Bool_t Pass(Int_t pid);//Checks if a given pid passes cuts | |
130 | void Blend();//Mixes current events in a symmetric way so after mixing thy are consistent | |
a5556ea5 | 131 | |
132 | TString& GetDirName(Int_t entry); | |
133 | ||
134 | private: | |
135 | ||
136 | ClassDef(AliReader,1)// | |
137 | }; | |
138 | ||
139 | #endif |