AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliClusterContainer.cxx
Go to the documentation of this file.
1 //
2 // Container with name, TClonesArray and cuts for calo clusters
3 //
4 // Author: M. Verweij, S. Aiola
5 
6 #include <TClonesArray.h>
7 
8 #include "AliVEvent.h"
9 #include "AliLog.h"
10 
11 #include "AliClusterContainer.h"
12 
14 
15 //________________________________________________________________________
18  fClusPtCut(0.),
19  fClusECut(0.15),
20  fClusTimeCutLow(-10),
21  fClusTimeCutUp(10),
22  fClusterBitMap(0),
23  fMCClusterBitMap(0),
24  fMinMCLabel(0),
25  fExoticCut(kTRUE)
26 {
27  // Default constructor.
28 
29  fClassName = "AliVCluster";
30 
31  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
32  fUserDefEnergyCut[i] = 0.;
33  }
34 }
35 
36 //________________________________________________________________________
38  AliEmcalContainer(name),
39  fClusPtCut(0.),
40  fClusECut(0.15),
41  fClusTimeCutLow(-10),
42  fClusTimeCutUp(10),
43  fClusterBitMap(0),
44  fMCClusterBitMap(0),
45  fMinMCLabel(0),
46  fExoticCut(kTRUE)
47 {
48  // Standard constructor.
49 
50  fClassName = "AliVCluster";
51 
52  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
53  fUserDefEnergyCut[i] = 0.;
54  }
55 }
56 
57 //________________________________________________________________________
58 AliVCluster* AliClusterContainer::GetLeadingCluster(const char* opt)
59 {
60  // Get the leading cluster; use e if "e" is contained in opt (otherwise et)
61 
62  TString option(opt);
63  option.ToLower();
64 
65  Int_t tempID = fCurrentID;
66 
67  AliVCluster *clusterMax = GetNextAcceptCluster(0);
68  AliVCluster *cluster = 0;
69 
70  if (option.Contains("e")) {
71  while ((cluster = GetNextAcceptCluster())) {
72  if (cluster->E() > clusterMax->E()) clusterMax = cluster;
73  }
74  }
75  else {
76  Double_t et = 0;
77  Double_t etmax = 0;
78  while ((cluster = GetNextAcceptCluster())) {
79  TLorentzVector mom;
80  cluster->GetMomentum(mom,const_cast<Double_t*>(fVertex));
81  et = mom.Et();
82  if (et > etmax) {
83  clusterMax = cluster;
84  etmax = et;
85  }
86  }
87  }
88 
89  fCurrentID = tempID;
90 
91  return clusterMax;
92 }
93 
94 //________________________________________________________________________
95 AliVCluster* AliClusterContainer::GetCluster(Int_t i) const
96 {
97  //Get i^th cluster in array
98 
99  if(i<0 || i>fClArray->GetEntriesFast()) return 0;
100  AliVCluster *vp = static_cast<AliVCluster*>(fClArray->At(i));
101  return vp;
102 
103 }
104 
105 //________________________________________________________________________
107 {
108  //Return pointer to cluster if cluster is accepted
109 
110  AliVCluster *vc = GetCluster(i);
111  if (!vc) return 0;
112 
113  if (AcceptCluster(vc))
114  return vc;
115  else {
116  AliDebug(2,"Cluster not accepted.");
117  return 0;
118  }
119 }
120 
121 //________________________________________________________________________
122 AliVCluster* AliClusterContainer::GetClusterWithLabel(Int_t lab) const
123 {
124  //Get particle with label lab in array
125 
126  Int_t i = GetIndexFromLabel(lab);
127  return GetCluster(i);
128 }
129 
130 //________________________________________________________________________
132 {
133  //Get particle with label lab in array
134 
135  Int_t i = GetIndexFromLabel(lab);
136  return GetAcceptCluster(i);
137 }
138 
139 //________________________________________________________________________
141 {
142  //Get next accepted cluster; if i >= 0 (re)start counter from i; return 0 if no accepted cluster could be found
143 
144  if (i>=0) fCurrentID = i;
145 
146  const Int_t n = GetNEntries();
147  AliVCluster *c = 0;
148  while (fCurrentID < n && !c) {
150  fCurrentID++;
151  }
152 
153  return c;
154 }
155 
156 //________________________________________________________________________
158 {
159  //Get next cluster; if i >= 0 (re)start counter from i; return 0 if no cluster could be found
160 
161  if (i>=0) fCurrentID = i;
162 
163  const Int_t n = GetNEntries();
164  AliVCluster *c = 0;
165  while (fCurrentID < n && !c) {
166  c = GetCluster(fCurrentID);
167  fCurrentID++;
168  }
169 
170  return c;
171 }
172 
173 //________________________________________________________________________
174 void AliClusterContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
175 {
176  //Get momentum of the i^th cluster in array
177 
178  AliVCluster *vc = GetCluster(i);
179  if(vc) vc->GetMomentum(mom,const_cast<Double_t*>(fVertex));
180 }
181 
182 //________________________________________________________________________
183 Bool_t AliClusterContainer::AcceptCluster(AliVCluster *clus)
184 {
185  // Return true if cluster is accepted.
186 
187  fRejectionReason = 0;
188 
189  if (!clus) {
191  return kFALSE;
192  }
193 
194  if (!clus->IsEMCAL()) {
196  return kFALSE;
197  }
198 
199  if (clus->GetLabel() > fMinMCLabel) {
200  if (clus->TestBits(fMCClusterBitMap) != (Int_t)fMCClusterBitMap) {
201  AliDebug(2,"MC Cluster not accepted because of MC bit map.");
203  return kFALSE;
204  }
205  }
206  else {
207  if (clus->TestBits(fClusterBitMap) != (Int_t)fClusterBitMap) {
208  AliDebug(2,"Cluster not accepted because of bit map.");
210  return kFALSE;
211  }
212  }
213 
214  if (clus->GetTOF() > fClusTimeCutUp || clus->GetTOF() < fClusTimeCutLow) {
216  return kFALSE;
217  }
218 
219  if (clus->E()<fClusECut) {
221  return kFALSE;
222  }
223 
224  TLorentzVector nPart;
225  clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
226 
227  if (nPart.Et() < fClusPtCut) {
229  return kFALSE;
230  }
231 
232  if (fExoticCut && clus->GetIsExotic()) {
234  return kFALSE;
235  }
236 
237  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
238  if (clus->GetUserDefEnergy((VCluUserDefEnergy_t)i) < fUserDefEnergyCut[i]) {
240  return kFALSE;
241  }
242  }
243 
244  return kTRUE;
245 }
246 
247 //________________________________________________________________________
249 {
250  // Get number of accepted particles
251 
252  Int_t nClus = 0;
253 
254  AliVCluster *clus = GetNextAcceptCluster(0);
255  if(clus) nClus = 1;
256  while (GetNextAcceptCluster())
257  nClus++;
258 
259  return nClus;
260 }
261 
262 //________________________________________________________________________
263 void AliClusterContainer::SetClassName(const char *clname)
264 {
265  // Set the class name
266 
267  TClass cls(clname);
268  if (cls.InheritsFrom("AliVCluster")) fClassName = clname;
269  else AliError(Form("Unable to set class name %s for a AliClusterContainer, it must inherits from AliVCluster!",clname));
270 }
Bool_t AcceptCluster(AliVCluster *vp)
Int_t GetIndexFromLabel(Int_t lab) const
AliVCluster * GetAcceptClusterWithLabel(Int_t lab)
void GetMomentum(TLorentzVector &mom, Int_t i) const
Double_t fUserDefEnergyCut[AliVCluster::kLastUserDefEnergy+1]
AliVCluster * GetNextAcceptCluster(Int_t i=-1)
AliVCluster * GetLeadingCluster(const char *opt="")
enum AliVCluster::VCluUserDefEnergy_t VCluUserDefEnergy_t
UInt_t fRejectionReason
event vertex array
AliVCluster * GetAcceptCluster(Int_t i)
AliVCluster * GetNextCluster(Int_t i=-1)
ClassImp(AliClusterContainer) AliClusterContainer
AliVCluster * GetCluster(Int_t i) const
void SetClassName(const char *clname)
Double_t fVertex[3]
Label-Index map.
AliVCluster * GetClusterWithLabel(Int_t lab) const
TClonesArray * fClArray
Int_t GetNEntries() const
Int_t fCurrentID
TClonesArray.