]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/AliDxHFEToolsMC.h
Fix (AndreaR)
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / AliDxHFEToolsMC.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   AliDxHFEToolsMC.h
9 /// @author Hege Erdal, Matthias Richter
10 /// @date   2012-07-19
11 /// @brief  Common Tools for MC particle selection
12 ///
13
14 #ifndef ALIDXHFETOOLSMC_H
15 #define ALIDXHFETOOLSMC_H
16
17 #include "TObject.h"
18 #include <vector>
19
20 class AliVEvent;
21 class AliVParticle;
22 class TH1;
23
24 using std::vector;
25
26 /**
27  * @class AliDxHFEToolsMC
28  * Common Tools for MC particle selection.
29  */
30 class AliDxHFEToolsMC {
31   public:
32   /// constructor
33   AliDxHFEToolsMC(const char* options="");
34   /// destructor
35   virtual ~AliDxHFEToolsMC();
36
37   // different pdgs
38   enum{
39     kPDGnone=0,
40     kPDGd=1,
41     kPDGu=2,
42     kPDGs=3,
43     kPDGc=4,
44     kPDGb=5,
45     kPDGelectron=11,
46     kPDGmuon=13,
47     kPDGgluon=21,
48     kPDGgamma=22,
49     kPDGpi0=111,
50     kPDGpion=211,
51     kPDGeta=221,
52     kPDGkaon=321,
53     kPDGD0=421,
54     kPDGJpsi=443,
55     kPDGproton=2212
56   };
57
58   enum {
59     kPDGLabelPositron,
60     kPDGLabelElectron,
61     kPDGLabelMuPlus,
62     kPDGLabelMuMinus,
63     kPDGLabelPiPlus,
64     kPDGLabelPiMinus,
65     kPDGLabelKPlus,
66     kPDGLabelKMinus,
67     kPDGLabelProton,
68     kPDGLabelAntiproton,
69     kPDGLabelOthers,
70     kNofPDGLabels
71   };
72
73   enum {
74     kPDGMotherLabelD,
75     kPDGMotherLabelU,
76     kPDGMotherLabelS,
77     kPDGMotherLabelC,
78     kPDGMotherLabelB,
79     kPDGMotherLabelGluon,
80     kPDGMotherLabelGamma,
81     kPDGMotherLabelPi0,
82     kPDGMotherLabelEta,
83     kPDGMotherLabelProton,
84     kPDGMotherLabelOthers,
85     kNofPDGMotherLabels
86   };
87
88   enum {
89     kMCFirst = 0,
90     kMCLast
91   };
92
93   enum {
94     kOriginNone=0,
95     kOriginDown,
96     kOriginUp,
97     kOriginStrange,
98     kOriginCharm,
99     kOriginBeauty,
100     kOriginGluon,
101     kOriginGluonCharm,
102     kOriginGluonBeauty,
103     kNrOrginMother
104   };
105
106   enum {
107     kGetOriginMother=0,
108     kGetFirstMother
109   };
110
111   /// initialize according to options
112   int Init(const char* /*option*/);
113
114   /// init MC info from event object
115   int InitMCParticles(const AliVEvent* pEvent);
116
117   /// Returning MC Array
118   TObjArray* GetMCArray() const {return fMCParticles;} 
119   
120   /// check state
121   bool IsInitialized() const {return fMCParticles!=NULL;}
122
123   /// clear internal memory
124   virtual void Clear(const char* option="");
125
126   /// flag indicating to do the selection on MC first
127   bool MCFirst() const {return fSequence==kMCFirst;}
128   /// flag indicating to do the selection on MC last
129   bool MCLast() const {return fSequence==kMCLast;}
130
131   /// Return the result on check on initial quark
132   int GetOriginMother() const {return fOriginMother;}
133
134   /// check if pdg should be rejected
135   /// always false if pdg list is not initialized
136   bool RejectByPDG(AliVParticle* p, bool doStatistics=true, int* pdgParticleResult=NULL);
137   bool RejectByPDG(AliVParticle* p, int* pdgParticleResult) {
138     return RejectByPDG(p, true, pdgParticleResult);
139   }
140
141   /// check if pdg should be rejected by mother
142   /// always false if mother pdg list is not initialized
143   bool RejectByMotherPDG(AliVParticle* p, bool doStatistics=true);
144
145   /// Finds pdg of first or origin mother and returns value
146   int FindMotherPDG(AliVParticle* p, bool bReturnFirstMother=false);
147
148   /// step through tree and find the original mother particle
149   /// TODO: this can possibly be const, however, a member is set inside
150   /// check whether this is really necessary
151   int FindPdgOriginMother(AliVParticle* p,bool bReturnFirstMother=false);
152
153   // Compare pdg to quark and gluon
154   void CheckOriginMother(int pdg);
155   // Tests if particle have been marked as HF quark 
156   Bool_t TestIfHFquark(int origin);
157
158   //Tests of pdg corresponds to HF meson
159   Bool_t TestMotherHFMeson(int pdg);
160
161   // Setting MC label from outside
162   void SetMClabel(int mclab){fMClabel=mclab;}
163
164   /// TODO: want to have this function to be private again, currently
165   /// used with an external vector
166   /// check if pdg should be rejected, particle is not rejected
167   /// if it is in the list, returns always false if list is empty
168   bool RejectByPDG(int pdg, const vector<int> &list) const;
169
170   int GetNrMCParticles() const {return fNrMCParticles;}
171   int CheckMCParticle(AliVParticle* p);
172
173   /// mapping of pdg code to enum
174   int MapPDGLabel(int pdg) const;
175   /// mapping of pdg code to enum
176   int MapPDGMotherLabel(int pdg) const;
177
178  protected:
179
180  private:
181   /// copy contructor prohibited
182   AliDxHFEToolsMC(const AliDxHFEToolsMC&);
183   /// assignment operator prohibited
184   AliDxHFEToolsMC& operator=(const AliDxHFEToolsMC&);
185
186   /// create control histogram
187   TH1* CreateControlHistogram(const char* name,
188                               const char* title,
189                               int nBins,
190                               const char** binLabels) const;
191
192   static const char* fgkPDGBinLabels[];
193   static const char* fgkPDGMotherBinLabels[];
194   static const char* fgkStatisticsBinLabels[];
195
196   int fSequence;           //  sequence of checks
197   TObjArray* fMCParticles; //! pointer to external array of MC particles
198   vector<int> fPDGs;       //  PDGs to be selected
199   vector<int> fMotherPDGs; //  mother PDGs to be selected
200   TH1* fHistPDG;           //  control histogram pdg of selected particle
201   TH1* fHistPDGMother;     //  control histogram pdg of selected particle
202   int fOriginMother;       //  Holds the origin motherquark (process)
203   int fMClabel;            //  MClabel passed from outside (default =-1)
204   int fNrMCParticles;      //  number of MC particles 
205   bool fUseKine;           //  For looping over stack directly
206
207   ClassDef(AliDxHFEToolsMC, 3);
208 };
209 #endif