]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/AliMCInfoCuts.cxx
Absolute path removed.
[u/mrichter/AliRoot.git] / PWG1 / AliMCInfoCuts.cxx
1 //------------------------------------------------------------------------------
2 // Impementation of AliMCInfoCuts class. It keeps selection cuts for MC tracks. 
3 // 
4 // 
5 // Author: J.Otwinowski 04/02/2008 
6 //------------------------------------------------------------------------------
7
8 #include <iostream>
9 #include <TArrayI.h>
10 #include <TList.h>
11
12 #include "AliLog.h"
13 #include "AliMCInfoCuts.h"
14
15 using namespace std;
16
17 ClassImp(AliMCInfoCuts)
18
19 //_____________________________________________________________________________
20 AliMCInfoCuts::AliMCInfoCuts(const Char_t* name,const Char_t *title) : 
21 AliAnalysisCuts(name, title)
22 , fMinRowsWithDigits(0)
23 , fMaxR(0)
24 , fMaxVz(0)
25 , fMinTPCSignal(0)
26 , fMaxTPCSignal(0)
27 , aTrackParticles(0)
28 {
29   // default constructor 
30   
31   // init data members with defaults
32   Init();
33 }
34
35 //_____________________________________________________________________________
36 AliMCInfoCuts::~AliMCInfoCuts()  
37 {
38   // destructor
39   if(aTrackParticles != 0) 
40   {
41     delete aTrackParticles;
42         aTrackParticles = 0;
43   }
44 }
45
46 //_____________________________________________________________________________
47 void AliMCInfoCuts::Init()  
48 {
49   // set default values
50   SetMinRowsWithDigits();
51   SetMaxR();
52   SetMaxVz();
53   SetRangeTPCSignal();
54
55   // create aTrackParticles array
56   aTrackParticles = new TArrayI(kNParticles); // max nb. of particles
57   aTrackParticles->Reset(0);
58
59   // create an array of track particles: e, muons, pions, kaons, protons
60   if(aTrackParticles != 0)
61   {
62      // keep order adding a new particles
63      AddPdgParticle(0,ep);   // e+
64      AddPdgParticle(1,em);   // e-
65      AddPdgParticle(2,mup);  // mu+
66      AddPdgParticle(3,mum);  // mu-
67      AddPdgParticle(4,pip);  // pi+ 
68      AddPdgParticle(5,pim);  // pi-
69      AddPdgParticle(6,kp);   // K+ 
70      AddPdgParticle(7,km);   // K-
71      AddPdgParticle(8,prot);    // p 
72      AddPdgParticle(9,protbar); // p_bar
73   }
74 }
75
76 //_____________________________________________________________________________
77 void AliMCInfoCuts::AddPdgParticle(Int_t idx, Int_t pdgcode) const
78 {
79   // add particle to the array
80   if(aTrackParticles != 0) aTrackParticles->AddAt(pdgcode,idx);
81   else AliDebug(AliLog::kError, "ERROR: Cannot add particle to the array");
82 }
83
84 //_____________________________________________________________________________
85 Bool_t AliMCInfoCuts::IsPdgParticle(Int_t pdgcode) const
86 {
87   // check PDG particle 
88   if(aTrackParticles == 0) { 
89     AliDebug(AliLog::kError, "ERROR: Cannot get particle array");
90     return kFALSE;
91   }
92
93   Int_t size = aTrackParticles->GetSize();
94   for(int i=0; i<size; ++i) {
95     if(pdgcode == aTrackParticles->At(i)) return kTRUE;
96   }
97   return kFALSE;
98 }
99
100 //_____________________________________________________________________________
101 Long64_t AliMCInfoCuts::Merge(TCollection* list) 
102 {
103   // Merge list of objects (needed by PROOF)
104   if (!list)
105   return 0;
106
107   if (list->IsEmpty())
108   return 1;
109
110   TIterator* iter = list->MakeIterator();
111   TObject* obj = 0;
112
113   Int_t count=0;
114   while((obj = iter->Next()) != 0) 
115   {
116     AliMCInfoCuts* entry = dynamic_cast<AliMCInfoCuts*>(obj);
117     if (entry == 0)  
118       continue; 
119
120   count++;
121   }
122
123 return count;
124 }