Temporary: do not link AliHLTMUON.so
[u/mrichter/AliRoot.git] / ANALYSIS / AliReader.h
a5556ea5 1#ifndef ALIREADER_H
2#define ALIREADER_H
6// class AliReader
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
15// Reading can be rewound to the beginning using method Rewind.
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.
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).
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.
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.
39// The others are:
895cf35c 40// Bool_t ReadsSim() const; specifies if reader is able to read simulated particles
41// Bool_t ReadsRec() const; specifies if reader is able to read reconstructed tracks
e6b229c6 42// void Rewind(); rewind reading to the beginning
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.
a5556ea5 49// Piotr.Skowronski@cern.ch
53#include <TNamed.h>
54#include <TObjArray.h>
b002433a 56class TGliteXmlEventlist;
a5556ea5 58class AliAODRun;
59class AliAOD;
60class AliAODParticleCut;
afa8b37b 61class AliVAODParticle;
a5556ea5 62class TString;
63class TH1I;
65class AliReader: public TNamed
67 public:
68 AliReader();
69 AliReader(TObjArray*);
70 AliReader(const AliReader& in);
71 virtual ~AliReader();
73 AliReader& operator=(const AliReader& in);
75 virtual Int_t Next();
76 virtual void Rewind() = 0; //
78 virtual Bool_t ReadsSim() const = 0; //specifies if reader is able to read simulated particles
79 virtual Bool_t ReadsRec() const = 0;//specifies if reader is able to read reconstructed tracks
e6b229c6 80
81 void AddParticleCut(AliAODParticleCut* cut);//adds a particle cut to the list of cuts
a5556ea5 82
e6b229c6 83 virtual AliAOD* GetEventRec() const {return fEventRec;}//returns current event with reconstructed tracks
84 virtual AliAOD* GetEventSim() const {return fEventSim;}//returns current event with simulated particles
a5556ea5 85
e6b229c6 86 virtual AliAOD* GetEventRec(Int_t n);//returns event number n
a5556ea5 87 virtual AliAOD* GetEventSim(Int_t n);
201c7e13 89 virtual Int_t Read(const char * name) {return TObject::Read(name);}
e6b229c6 90 virtual Int_t Read(AliAODRun* particles, AliAODRun *tracks);//Reads all available evenets and stores them in 'particles' and 'tracks'
92 virtual Int_t GetNumberOfRecEvents();//Returns number of available events -> usually conncected with reading all events
93 //may be time consuming
94 virtual Int_t GetNumberOfSimEvents();//
b002433a 95
96 void SetEventList(TGliteXmlEventlist* evl){fEventList = evl;}
a5556ea5 98 void SetDirs(TObjArray* dirs){fDirs = dirs;} //sets array directories names
99 void SetEventBuffering(Bool_t flag){fBufferEvents = flag;}//switches on/off buffering - read data are kept in local buffer
100 void SetBlend(Bool_t flag = kTRUE){fBlend=flag;} //set blending - randomizing particle order
101 virtual Int_t GetNumberOfDirs() const {return (fDirs)?fDirs->GetEntries():0;}
102 void ReadEventsFromTo(Int_t first,Int_t last){fFirst = first; fLast = last;}
103 virtual TH1I* GetTrackCounter() const {return fTrackCounter;}
e6b229c6 104 virtual void WriteTrackCounter() const;//Writes the track counting histigram
a5556ea5 105
106 protected:
b002433a 108 TGliteXmlEventlist* fEventList;//Event list delivered by GLite/AliEn
a5556ea5 110 TObjArray* fCuts;//array with particle cuts
111 TObjArray* fDirs;//arry with directories to read data from
113 Int_t fCurrentEvent;//! number of current event in current directory
114 Int_t fCurrentDir;//! number of current directory
116 Int_t fNEventsRead;//!total
118 AliAOD* fEventRec; //! tracks read from current event
119 AliAOD* fEventSim; //! particles read from current event
121 AliAODRun* fRunSim; //!simulated particles
122 AliAODRun* fRunRec; //!reconstructed tracks
124 Bool_t fIsRead;//!flag indicating if the data are already read
125 Bool_t fBufferEvents;//flag indicating if the data should be bufferred
127 Bool_t fBlend;// flag indicating if randomly change positions of the particles after reading
e6b229c6 129 Int_t fFirst;//first event to return (all before are skipped)
130 Int_t fLast;//the last one
a5556ea5 131
132 TH1I* fTrackCounter; //histogram with number of tracks read
134 virtual Int_t ReadNext() = 0; //this methods reads next event and put result in fTracksEvent and/or fParticlesEvent
cea0a066 135 Bool_t Rejected(AliVAODParticle* p);//Checks if a given particle agains cuts
136 Bool_t Rejected(Int_t pid);//Checks if a given pid passes cuts
e6b229c6 137 void Blend();//Mixes current events in a symmetric way so after mixing thy are consistent
a5556ea5 138
efdb0cc9 139 TString GetDirName(Int_t entry);
a5556ea5 140
141 private:
143 ClassDef(AliReader,1)//