]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/AliDxHFEParticleSelection.h
adding checks and debugging information
[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 TObjArray;
22 class TH1;
23 class THnSparse;
24
25 /**
26  * @class AliDxHFEParticleSelection
27  * This is the base class for particle selections for the D0 - HFE
28  * correlation studies.
29  *
30  * Ideas:
31  * - configurable particle selection
32  * - eventually histogramming of particle properties before vs. after
33  *   selection
34  *
35  * Might be that there is already something similar, then this class
36  * can be merged with some other class.
37  */
38 class AliDxHFEParticleSelection : public TNamed {
39   public:
40   /// constructor
41   AliDxHFEParticleSelection(const char* name=NULL, const char* opt="");
42   /// destructor
43   virtual ~AliDxHFEParticleSelection();
44
45   enum {
46     kEventsAll = 0,
47     kEventsSel,
48     kEventsWithParticle,
49     kNEventPropertyLabels
50   };
51   
52   enum {
53     kTrackAll = 0,
54     kTrackSel,
55     kNTrackPropertyLabels
56   };
57
58   /// set options
59   void SetOption(const char* opt) { fOption = opt; }
60   /// overloaded from TObject: get option
61   virtual Option_t* GetOption() const { return fOption;}
62
63   /// init the control objects
64   virtual int Init();
65   virtual int InitControlObjects();
66
67   /// create selection from 'Tracks' member of the event,
68   /// array contains only pointers but does not own the objects
69   /// object array needs to be deleted by caller
70   virtual TObjArray* Select(const AliVEvent* pEvent);
71   /// create selection from the array of particles,
72   /// array contains only pointers but does not own the objects
73   /// object array needs to be deleted by caller
74   virtual TObjArray* Select(TObjArray* particles, const AliVEvent* pEvent);
75
76   // Get the list fControlObjects. 
77   const TList* GetControlObjects() const {return fControlObjects;}
78
79   /// histogram event properties
80   virtual int HistogramEventProperties(int bin);
81
82   virtual int FillParticleProperties(AliVParticle* p, Double_t* date, int dimension) const;
83   virtual AliVParticle* CreateParticle(AliVParticle* track);
84
85   /// check and add track to internal array
86   int CheckAndAdd(AliVParticle* p);
87
88   /// set cuts object: general TObject pointer is used as argument to support
89   // different types; a type cast check is implemented in the method
90   virtual void SetCuts(TObject* /*cuts*/, int /*level*/=0) {}
91
92   // TODO: check whether that is needed, should be covered by the specific
93   // child implementation
94   Bool_t GetUseMC() const {return fUseMC;}
95
96   /// get selected tracks
97   const TObjArray* GetSelected() const {return fSelectedTracks;}
98
99   /// check particle if it passes the selection criteria
100   virtual int IsSelected(AliVParticle* p, const AliVEvent *pEvent=NULL);
101
102   /// inherited from TObject: cleanup
103   virtual void Clear(Option_t * option ="");
104   /// inherited from TObject: print info
105   virtual void Print(Option_t *option="") const;
106   /// inherited from TObject: safe selection criteria
107   virtual void SaveAs(const char *filename="", Option_t *option="") const;
108   /// inherited from TObject: draw content
109   virtual void Draw(Option_t *option="");
110   /// inherited from TObject: find object by name
111   virtual TObject* FindObject(const char *name) const;
112   /// inherited from TObject: find object by pointer
113   virtual TObject* FindObject(const TObject *obj) const;
114
115   /// set verbosity
116   void SetVerbosity(int verbosity) {fVerbosity=verbosity;}
117
118   /// get verbosity
119   inline int GetVerbosity() const {return fVerbosity;}
120
121   /// get the dimension of THn, fixed
122   inline int GetDimTHnSparse() const {return fDimThn;}
123   
124   /// create control THnSparse
125   THnSparse* CreateControlTHnSparse(const char* name,
126                                     int thnSize,
127                                     int* thnBins,
128                                     double* thnMin,
129                                     double* thnMax,
130                                     const char** binLabels) const;
131
132   // define and create the THnSparse object
133   // initializes also the dimension to be used further
134   virtual THnSparse* DefineTHnSparse();
135
136  protected:
137   /// add control object to list, the base class becomes owner of the object
138   int AddControlObject(TObject* pObj);
139
140   /// histogram particle properties
141   virtual int HistogramParticleProperties(AliVParticle* p, int selected=1);
142
143   /// set the dimension of THn and allocate filling array
144   void InitTHnSparseArray(int dimension) {
145     fDimThn=dimension; 
146     if (fParticleProperties) delete[] fParticleProperties; fParticleProperties=NULL;
147     if (dimension>0) fParticleProperties=new Double_t[dimension];
148   }
149
150   inline Double_t* ParticleProperties() const {return fParticleProperties;}
151
152  private:
153   /// copy contructor prohibited
154   AliDxHFEParticleSelection(const AliDxHFEParticleSelection&);
155   /// assignment operator prohibited
156   AliDxHFEParticleSelection& operator=(const AliDxHFEParticleSelection&);
157
158   TString fOption; // option
159   TObjArray* fSelectedTracks; //! array of selected tracks
160
161   // control histograms, note: only the list is saved, pointers only used for fast access
162   TList* fControlObjects; // list of control objects
163   TH1* fhEventControl; //! event control histogram
164   TH1* fhTrackControl; //! track control histogram
165   bool fUseMC;         // specific implementation for MC selection
166   int fVerbosity;      //! verbosity
167   int fDimThn;         //  dim of thnsparse
168   Double_t* fParticleProperties;  //! filling array for THnSparse
169
170   static const char* fgkEventControlBinNames[]; //! bin labels for event control histogram
171   static const char* fgkTrackControlBinNames[]; //! bin labels for track control histogram
172
173   ClassDef(AliDxHFEParticleSelection, 3);
174
175 };
176
177 #endif