]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/AliMCInfoCuts.cxx
Changed AliRunLoader::GetRunLoader() into AliRunLoader::Instance()
[u/mrichter/AliRoot.git] / PWG1 / AliMCInfoCuts.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 //------------------------------------------------------------------------------
17 // Impementation of AliMCInfoCuts class. It keeps selection cuts for MC tracks. 
18 // 
19 // 
20 // Author: J.Otwinowski 04/02/2008 
21 //------------------------------------------------------------------------------
22
23 #include <iostream>
24 #include <TArrayI.h>
25 #include <TList.h>
26
27 #include "AliLog.h"
28 #include "AliMCInfoCuts.h"
29
30 using namespace std;
31
32 ClassImp(AliMCInfoCuts)
33
34 //_____________________________________________________________________________
35 AliMCInfoCuts::AliMCInfoCuts(const Char_t* name,const Char_t *title) : 
36 AliAnalysisCuts(name, title)
37 , fMinRowsWithDigits(0)
38 , fMaxR(0)
39 , fMaxVz(0)
40 , fMinTPCSignal(0)
41 , fMaxTPCSignal(0)
42 , aTrackParticles(0)
43 {
44   // default constructor 
45   
46   // init data members with defaults
47   Init();
48 }
49
50 //_____________________________________________________________________________
51 AliMCInfoCuts::~AliMCInfoCuts()  
52 {
53   // destructor
54   if(aTrackParticles != 0) 
55   {
56     delete aTrackParticles;
57         aTrackParticles = 0;
58   }
59 }
60
61 //_____________________________________________________________________________
62 void AliMCInfoCuts::Init()  
63 {
64   // set default values
65   SetMinRowsWithDigits();
66   SetMaxR();
67   SetMaxVz();
68   SetRangeTPCSignal();
69
70   // create aTrackParticles array
71   aTrackParticles = new TArrayI(kNParticles); // max nb. of particles
72   aTrackParticles->Reset(0);
73
74   // create an array of track particles: e, muons, pions, kaons, protons
75   if(aTrackParticles != 0)
76   {
77      // keep order adding a new particles
78      AddPdgParticle(0,ep);   // e+
79      AddPdgParticle(1,em);   // e-
80      AddPdgParticle(2,mup);  // mu+
81      AddPdgParticle(3,mum);  // mu-
82      AddPdgParticle(4,pip);  // pi+ 
83      AddPdgParticle(5,pim);  // pi-
84      AddPdgParticle(6,kp);   // K+ 
85      AddPdgParticle(7,km);   // K-
86      AddPdgParticle(8,prot);    // p 
87      AddPdgParticle(9,protbar); // p_bar
88   }
89 }
90
91 //_____________________________________________________________________________
92 void AliMCInfoCuts::AddPdgParticle(Int_t idx, Int_t pdgcode) const
93 {
94   // add particle to the array
95   if(aTrackParticles != 0) aTrackParticles->AddAt(pdgcode,idx);
96   else AliDebug(AliLog::kError, "ERROR: Cannot add particle to the array");
97 }
98
99 //_____________________________________________________________________________
100 Bool_t AliMCInfoCuts::IsPdgParticle(Int_t pdgcode) const
101 {
102   // check PDG particle 
103   if(aTrackParticles == 0) { 
104     AliDebug(AliLog::kError, "ERROR: Cannot get particle array");
105     return kFALSE;
106   }
107
108   Int_t size = aTrackParticles->GetSize();
109   for(int i=0; i<size; ++i) {
110     if(pdgcode == aTrackParticles->At(i)) return kTRUE;
111   }
112   return kFALSE;
113 }
114
115 //_____________________________________________________________________________
116 Bool_t AliMCInfoCuts::IsPosPdgParticle(Int_t pdgcode) const
117 {
118   // check PDG particle (only positive charged) 
119   if(aTrackParticles == 0) { 
120     AliDebug(AliLog::kError, "ERROR: Cannot get particle array");
121     return kFALSE;
122   }
123
124   Int_t size = aTrackParticles->GetSize();
125   for(int i=0; i<size; ++i) {
126     // leptons have oposite pdg convension from hadrons (e+/e- = -11/11)
127     if(pdgcode > 0 && (pdgcode == 11 || pdgcode == 13)) return kFALSE; 
128     if(pdgcode < 0 && (pdgcode != -11 || pdgcode != -13) ) return kFALSE; 
129         // 
130     if(pdgcode == aTrackParticles->At(i)) return kTRUE;
131   }
132   return kFALSE;
133 }
134
135
136 //_____________________________________________________________________________
137 Long64_t AliMCInfoCuts::Merge(TCollection* list) 
138 {
139   // Merge list of objects (needed by PROOF)
140   if (!list)
141   return 0;
142
143   if (list->IsEmpty())
144   return 1;
145
146   TIterator* iter = list->MakeIterator();
147   TObject* obj = 0;
148
149   Int_t count=0;
150   while((obj = iter->Next()) != 0) 
151   {
152     AliMCInfoCuts* entry = dynamic_cast<AliMCInfoCuts*>(obj);
153     if (entry == 0)  
154       continue; 
155
156   count++;
157   }
158
159 return count;
160 }