AliPhysics  7dff9e1 (7dff9e1)
 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 #include "TLorentzVector.h"
11 
12 #include "AliClusterContainer.h"
13 
15 
16 //________________________________________________________________________
19  fClusPtCut(0.),
20  fClusECut(0.15),
21  fClusTimeCutLow(-10),
22  fClusTimeCutUp(10),
23  fClusterBitMap(0),
24  fMCClusterBitMap(0),
25  fMinMCLabel(0),
26  fExoticCut(kTRUE),
27  fDefaultClusterEnergy(-1)
28 {
29  // Default constructor.
30 
31  fClassName = "AliVCluster";
32 
33  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
34  fUserDefEnergyCut[i] = 0.;
35  }
36 }
37 
38 //________________________________________________________________________
40  AliEmcalContainer(name),
41  fClusPtCut(0.),
42  fClusECut(0.15),
43  fClusTimeCutLow(-10),
44  fClusTimeCutUp(10),
45  fClusterBitMap(0),
46  fMCClusterBitMap(0),
47  fMinMCLabel(0),
48  fExoticCut(kTRUE),
49  fDefaultClusterEnergy(-1)
50 {
51  // Standard constructor.
52 
53  fClassName = "AliVCluster";
54 
55  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
56  fUserDefEnergyCut[i] = 0.;
57  }
58 }
59 
60 //________________________________________________________________________
61 AliVCluster* AliClusterContainer::GetLeadingCluster(const char* opt)
62 {
63  // Get the leading cluster; use e if "e" is contained in opt (otherwise et)
64 
65  TString option(opt);
66  option.ToLower();
67 
68  Int_t tempID = fCurrentID;
69 
70  AliVCluster *clusterMax = GetNextAcceptCluster(0);
71  AliVCluster *cluster = 0;
72 
73  if (option.Contains("e")) {
74  while ((cluster = GetNextAcceptCluster())) {
75  if (cluster->E() > clusterMax->E()) clusterMax = cluster;
76  }
77  }
78  else {
79  Double_t et = 0;
80  Double_t etmax = 0;
81  while ((cluster = GetNextAcceptCluster())) {
82  TLorentzVector mom;
83  cluster->GetMomentum(mom,const_cast<Double_t*>(fVertex));
84  et = mom.Et();
85  if (et > etmax) {
86  clusterMax = cluster;
87  etmax = et;
88  }
89  }
90  }
91 
92  fCurrentID = tempID;
93 
94  return clusterMax;
95 }
96 
97 //________________________________________________________________________
98 AliVCluster* AliClusterContainer::GetCluster(Int_t i) const
99 {
100  //Get i^th cluster in array
101 
102  if(i<0 || i>fClArray->GetEntriesFast()) return 0;
103  AliVCluster *vp = static_cast<AliVCluster*>(fClArray->At(i));
104  return vp;
105 
106 }
107 
108 //________________________________________________________________________
110 {
111  //Return pointer to cluster if cluster is accepted
112 
113  AliVCluster *vc = GetCluster(i);
114  if (!vc) return 0;
115 
116  if (AcceptCluster(vc))
117  return vc;
118  else {
119  AliDebug(2,"Cluster not accepted.");
120  return 0;
121  }
122 }
123 
124 //________________________________________________________________________
125 AliVCluster* AliClusterContainer::GetClusterWithLabel(Int_t lab) const
126 {
127  //Get particle with label lab in array
128 
129  Int_t i = GetIndexFromLabel(lab);
130  return GetCluster(i);
131 }
132 
133 //________________________________________________________________________
135 {
136  //Get particle with label lab in array
137 
138  Int_t i = GetIndexFromLabel(lab);
139  return GetAcceptCluster(i);
140 }
141 
142 //________________________________________________________________________
144 {
145  //Get next accepted cluster; if i >= 0 (re)start counter from i; return 0 if no accepted cluster could be found
146 
147  if (i>=0) fCurrentID = i;
148 
149  const Int_t n = GetNEntries();
150  AliVCluster *c = 0;
151  do {
152  fCurrentID++;
153  if (fCurrentID >= n) break;
155  } while (!c);
156 
157  return c;
158 }
159 
160 //________________________________________________________________________
162 {
163  //Get next cluster; if i >= 0 (re)start counter from i; return 0 if no cluster could be found
164 
165  if (i>=0) fCurrentID = i;
166 
167  const Int_t n = GetNEntries();
168  AliVCluster *c = 0;
169  do {
170  fCurrentID++;
171  if (fCurrentID >= n) break;
172  c = GetCluster(fCurrentID);
173  } while (!c);
174 
175  return c;
176 }
177 
178 //________________________________________________________________________
179 Bool_t AliClusterContainer::GetMomentum(TLorentzVector &mom, Int_t i)
180 {
181  //Get momentum of the i^th particle in array
182 
183  AliVCluster *vc = GetCluster(i);
184  if (vc) {
185  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
186  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
187  }
188  else {
189  vc->GetMomentum(mom, fVertex);
190  }
191  return kTRUE;
192  }
193  else {
194  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
195  return kFALSE;
196  }
197 }
198 
199 //________________________________________________________________________
200 Bool_t AliClusterContainer::GetNextMomentum(TLorentzVector &mom, Int_t i)
201 {
202  //Get momentum of the i^th particle in array
203 
204  AliVCluster *vc = GetNextCluster(i);
205  if (vc) {
206  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
207  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
208  }
209  else {
210  vc->GetMomentum(mom, fVertex);
211  }
212  return kTRUE;
213  }
214  else {
215  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
216  return kFALSE;
217  }
218 }
219 
220 //________________________________________________________________________
221 Bool_t AliClusterContainer::GetAcceptMomentum(TLorentzVector &mom, Int_t i)
222 {
223  //Get momentum of the i^th particle in array
224 
225  AliVCluster *vc = GetAcceptCluster(i);
226  if (vc) {
227  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
228  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
229  }
230  else {
231  vc->GetMomentum(mom, fVertex);
232  }
233 
234  return kTRUE;
235  }
236  else {
237  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
238  return kFALSE;
239  }
240 }
241 
242 //________________________________________________________________________
243 Bool_t AliClusterContainer::GetNextAcceptMomentum(TLorentzVector &mom, Int_t i)
244 {
245  //Get momentum of the i^th particle in array
246 
247  AliVCluster *vc = GetNextAcceptCluster(i);
248  if (vc) {
249  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
250  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
251  }
252  else {
253  vc->GetMomentum(mom, fVertex);
254  }
255 
256  return kTRUE;
257  }
258  else {
259  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
260  return kFALSE;
261  }
262 }
263 
264 //________________________________________________________________________
265 Bool_t AliClusterContainer::AcceptCluster(AliVCluster *clus)
266 {
267  // Return true if cluster is accepted.
268 
269  fRejectionReason = 0;
270 
271  if (!clus) {
273  return kFALSE;
274  }
275 
276  if (!clus->IsEMCAL()) {
278  return kFALSE;
279  }
280 
281  if (clus->GetLabel() > fMinMCLabel) {
282  if (clus->TestBits(fMCClusterBitMap) != (Int_t)fMCClusterBitMap) {
283  AliDebug(2,"MC Cluster not accepted because of MC bit map.");
285  return kFALSE;
286  }
287  }
288  else {
289  if (clus->TestBits(fClusterBitMap) != (Int_t)fClusterBitMap) {
290  AliDebug(2,"Cluster not accepted because of bit map.");
292  return kFALSE;
293  }
294  }
295 
296  if (clus->GetTOF() > fClusTimeCutUp || clus->GetTOF() < fClusTimeCutLow) {
298  return kFALSE;
299  }
300 
301  if (clus->E()<fClusECut) {
303  return kFALSE;
304  }
305 
306  TLorentzVector nPart;
307  clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
308 
309  if (nPart.Et() < fClusPtCut) {
311  return kFALSE;
312  }
313 
314  if (fExoticCut && clus->GetIsExotic()) {
316  return kFALSE;
317  }
318 
319  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
320  if (clus->GetUserDefEnergy((VCluUserDefEnergy_t)i) < fUserDefEnergyCut[i]) {
322  return kFALSE;
323  }
324  }
325 
326  return kTRUE;
327 }
328 
329 //________________________________________________________________________
331 {
332  // Get number of accepted particles
333 
334  Int_t nClus = 0;
335 
336  AliVCluster *clus = GetNextAcceptCluster(0);
337  if(clus) nClus = 1;
338  while (GetNextAcceptCluster())
339  nClus++;
340 
341  return nClus;
342 }
343 
344 //________________________________________________________________________
345 void AliClusterContainer::SetClassName(const char *clname)
346 {
347  // Set the class name
348 
349  TClass cls(clname);
350  if (cls.InheritsFrom("AliVCluster")) fClassName = clname;
351  else AliError(Form("Unable to set class name %s for a AliClusterContainer, it must inherits from AliVCluster!",clname));
352 }
Bool_t AcceptCluster(AliVCluster *vp)
Int_t GetIndexFromLabel(Int_t lab) const
AliVCluster * GetAcceptClusterWithLabel(Int_t lab)
Double_t fUserDefEnergyCut[AliVCluster::kLastUserDefEnergy+1]
AliVCluster * GetNextAcceptCluster(Int_t i=-1)
AliVCluster * GetLeadingCluster(const char *opt="")
Bool_t GetNextAcceptMomentum(TLorentzVector &mom, Int_t i=-1)
enum AliVCluster::VCluUserDefEnergy_t VCluUserDefEnergy_t
UInt_t fRejectionReason
event vertex array
AliVCluster * GetAcceptCluster(Int_t i)
Bool_t GetNextMomentum(TLorentzVector &mom, Int_t i=-1)
AliVCluster * GetNextCluster(Int_t i=-1)
ClassImp(AliClusterContainer) AliClusterContainer
AliVCluster * GetCluster(Int_t i) const
void SetClassName(const char *clname)
Bool_t GetAcceptMomentum(TLorentzVector &mom, Int_t i)
Double_t fVertex[3]
Label-Index map.
AliVCluster * GetClusterWithLabel(Int_t lab) const
TClonesArray * fClArray
Int_t GetNEntries() const
Int_t fCurrentID
TClonesArray.
Bool_t GetMomentum(TLorentzVector &mom, Int_t i)