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