]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/AliDxHFEParticleSelection.h
Correct backward incompatible change (R.Romita)
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / AliDxHFEParticleSelection.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 //* This file is property of and copyright by the ALICE Project        * 
5 //* ALICE Experiment at CERN, All rights reserved.                     *
6 //* See cxx source for full Copyright notice                           *
7
8 /// @file   AliDxHFEParticleSelection.h
9 /// @author Sedat Altinpinar, Hege Erdal, Matthias Richter
10 /// @date   2012-03-19
11 /// @brief  Base class for particle selection
12 ///
13
14 #ifndef ALIDXHFEPARTICLESELECTION_H
15 #define ALIDXHFEPARTICLESELECTION_H
16
17 #include "TNamed.h"
18 #include "TString.h"
19 class AliVEvent;
20 class AliVParticle;
21 class AliPIDResponse;
22 class TObjArray;
23 class TH1;
24 class TH2;
25 class THnSparse;
26
27 /**
28  * @class AliDxHFEParticleSelection
29  * This is the base class for particle selections for the D0 - HFE
30  * correlation studies.
31  *
32  * Ideas:
33  * - configurable particle selection
34  * - eventually histogramming of particle properties before vs. after
35  *   selection
36  *
37  * Might be that there is already something similar, then this class
38  * can be merged with some other class.
39  */
40 class AliDxHFEParticleSelection : public TNamed {
41   public:
42   /// constructor
43   AliDxHFEParticleSelection(const char* name=NULL, const char* opt="");
44   /// destructor
45   virtual ~AliDxHFEParticleSelection();
46
47   enum {
48     kEventsAll = 0,
49     kEventsSel,
50     kEventsWithParticle,
51     kNEventPropertyLabels
52   };
53   
54   enum {
55     kTrackAll = 0,
56     kTrackSel,
57     kNTrackPropertyLabels
58   };
59
60   enum {
61     kHistoEvent=0,
62     kHistoNrTracksPrEvent
63   };
64
65   /// set options
66   void SetOption(const char* opt) { fOption = opt; }
67   /// overloaded from TObject: get option
68   virtual Option_t* GetOption() const { return fOption;}
69
70   /// init the control objects
71   virtual int Init();
72   virtual int InitControlObjects();
73
74   /// create selection from 'Tracks' member of the event,
75   /// array contains only pointers but does not own the objects
76   /// object array needs to be deleted by caller
77   virtual TObjArray* Select(const AliVEvent* pEvent);
78   /// create selection from the array of particles,
79   /// array contains only pointers but does not own the objects
80   /// object array needs to be deleted by caller
81   virtual TObjArray* Select(TObjArray* particles, const AliVEvent* pEvent);
82
83   virtual void SetPIDResponse(const AliPIDResponse* /*const pidresp*/){}
84
85   // Get the list fControlObjects. 
86   const TList* GetControlObjects() const {return fControlObjects;}
87
88   /// histogram event properties
89   virtual int HistogramEventProperties(int histonr, int bin);
90   virtual int HistogramEventProperties(int bin){
91     return HistogramEventProperties(kHistoEvent,bin);
92   }
93   
94   virtual int FillParticleProperties(AliVParticle* p, Double_t* date, int dimension) const;
95   virtual AliVParticle* CreateParticle(AliVParticle* track);
96
97   /// check and add track to internal array
98   int CheckAndAdd(AliVParticle* p);
99
100   /// set cuts object: general TObject pointer is used as argument to support
101   // different types; a type cast check is implemented in the method
102   virtual void SetCuts(TObject* /*cuts*/, int /*level*/=0) {}
103
104   // TODO: check whether that is needed, should be covered by the specific
105   // child implementation
106   Bool_t GetUseMC() const {return fUseMC;}
107
108   /// get selected tracks
109   const TObjArray* GetSelected() const {return fSelectedTracks;}
110
111   /// check particle if it passes the selection criteria
112   virtual int IsSelected(AliVParticle* p, const AliVEvent *pEvent=NULL);
113
114   /// inherited from TObject: cleanup
115   virtual void Clear(Option_t * option ="");
116   /// inherited from TObject: print info
117   virtual void Print(Option_t *option="") const;
118   /// inherited from TObject: safe selection criteria
119   virtual void SaveAs(const char *filename="", Option_t *option="") const;
120   /// inherited from TObject: draw content
121   virtual void Draw(Option_t *option="");
122   /// inherited from TObject: find object by name
123   virtual TObject* FindObject(const char *name) const;
124   /// inherited from TObject: find object by pointer
125   virtual TObject* FindObject(const TObject *obj) const;
126
127   /// set verbosity
128   void SetVerbosity(int verbosity) {fVerbosity=verbosity;}
129
130   /// get verbosity
131   inline int GetVerbosity() const {return fVerbosity;}
132
133   /// get the dimension of THn, fixed
134   inline int GetDimTHnSparse() const {return fDimThn;}
135
136   /// create 2D control histogram
137   TH2* CreateControl2DHistogram(const char* name,
138                                 const char* title,
139                                 double* nBins,
140                                 const char* xaxis,
141                                 const char* yaxis) const;
142
143   /// create control histogram
144   TH1* CreateControlHistogram(const char* name,
145                               const char* title,
146                               int nBins,
147                               double min,
148                               double max,
149                               const char** binLabels=NULL) const;
150
151   /// create control histogram
152   TH1* CreateControlHistogram(const char* name,
153                               const char* title,
154                               int nBins,
155                               const char** binLabels=NULL) const {
156     return CreateControlHistogram(name, title, nBins, -0.5, nBins-0.5, binLabels);
157   }
158   
159   /// create control THnSparse
160   THnSparse* CreateControlTHnSparse(const char* name,
161                                     int thnSize,
162                                     int* thnBins,
163                                     double* thnMin,
164                                     double* thnMax,
165                                     const char** binLabels) const;
166
167   // define and create the THnSparse object
168   // initializes also the dimension to be used further
169   virtual THnSparse* DefineTHnSparse();
170   
171   Int_t GetSystem() const {return fSystem;}
172
173  protected:
174   /// add control object to list, the base class becomes owner of the object
175   int AddControlObject(TObject* pObj);
176
177   /// histogram particle properties
178   virtual int HistogramParticleProperties(AliVParticle* p, int selected=1);
179
180   /// set the dimension of THn and allocate filling array
181   void InitTHnSparseArray(int dimension) {
182     fDimThn=dimension; 
183     if (fParticleProperties) delete[] fParticleProperties; fParticleProperties=NULL;
184     if (dimension>0) fParticleProperties=new Double_t[dimension];
185   }
186
187   inline Double_t* ParticleProperties() const {return fParticleProperties;}
188
189   virtual int ParseArguments(const char* arguments);
190
191  private:
192   /// copy contructor prohibited
193   AliDxHFEParticleSelection(const AliDxHFEParticleSelection&);
194   /// assignment operator prohibited
195   AliDxHFEParticleSelection& operator=(const AliDxHFEParticleSelection&);
196
197   TString fOption; // option
198   TObjArray* fSelectedTracks; //! array of selected tracks
199
200   // control histograms, note: only the list is saved, pointers only used for fast access
201   TList* fControlObjects; // list of control objects
202   TH1* fhEventControl; //! event control histogram
203   TH1* fhTrackControl; //! track control histogram
204   TH1* fhNrTracksPerEvent; //! Control histo for nr particles pr event
205   bool fUseMC;         // specific implementation for MC selection
206   int fVerbosity;      //! verbosity
207   int fDimThn;         //  dim of thnsparse
208   Double_t* fParticleProperties;  //! filling array for THnSparse
209   Int_t     fSystem;            // whether running on pp(0,default), PbPb(1) or pPb(2, not used yet) 
210
211   static const char* fgkEventControlBinNames[]; //! bin labels for event control histogram
212   static const char* fgkTrackControlBinNames[]; //! bin labels for track control histogram
213
214   ClassDef(AliDxHFEParticleSelection, 5);
215
216 };
217
218 #endif