AliPhysics  f2694b8 (f2694b8)
 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  fMinMCLabel(-1),
24  fMaxMCLabel(-1),
25  fExoticCut(kTRUE),
26  fDefaultClusterEnergy(-1)
27 {
28  // Default constructor.
29 
30  fClassName = "AliVCluster";
31 
32  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
33  fUserDefEnergyCut[i] = 0.;
34  }
35 }
36 
37 //________________________________________________________________________
39  AliEmcalContainer(name),
40  fClusPtCut(0.),
41  fClusECut(0.15),
42  fClusTimeCutLow(-10),
43  fClusTimeCutUp(10),
44  fMinMCLabel(-1),
45  fMaxMCLabel(-1),
46  fExoticCut(kTRUE),
47  fDefaultClusterEnergy(-1)
48 {
49  // Standard constructor.
50 
51  fClassName = "AliVCluster";
52 
53  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
54  fUserDefEnergyCut[i] = 0.;
55  }
56 }
57 
58 //________________________________________________________________________
59 AliVCluster* AliClusterContainer::GetLeadingCluster(const char* opt)
60 {
61  // Get the leading cluster; use e if "e" is contained in opt (otherwise et)
62 
63  TString option(opt);
64  option.ToLower();
65 
66  Int_t tempID = fCurrentID;
67 
68  AliVCluster *clusterMax = GetNextAcceptCluster(0);
69  AliVCluster *cluster = 0;
70 
71  if (option.Contains("e")) {
72  while ((cluster = GetNextAcceptCluster())) {
73  if (cluster->E() > clusterMax->E()) clusterMax = cluster;
74  }
75  }
76  else {
77  Double_t et = 0;
78  Double_t etmax = 0;
79  while ((cluster = GetNextAcceptCluster())) {
80  TLorentzVector mom;
81  cluster->GetMomentum(mom,const_cast<Double_t*>(fVertex));
82  et = mom.Et();
83  if (et > etmax) {
84  clusterMax = cluster;
85  etmax = et;
86  }
87  }
88  }
89 
90  fCurrentID = tempID;
91 
92  return clusterMax;
93 }
94 
95 //________________________________________________________________________
96 AliVCluster* AliClusterContainer::GetCluster(Int_t i) const
97 {
98  //Get i^th cluster in array
99 
100  if(i<0 || i>fClArray->GetEntriesFast()) return 0;
101  AliVCluster *vp = static_cast<AliVCluster*>(fClArray->At(i));
102  return vp;
103 
104 }
105 
106 //________________________________________________________________________
108 {
109  //Return pointer to cluster if cluster is accepted
110 
111  AliVCluster *vc = GetCluster(i);
112  if (!vc) return 0;
113 
114  if (AcceptCluster(vc))
115  return vc;
116  else {
117  AliDebug(2,"Cluster not accepted.");
118  return 0;
119  }
120 }
121 
122 //________________________________________________________________________
123 AliVCluster* AliClusterContainer::GetClusterWithLabel(Int_t lab) const
124 {
125  //Get particle with label lab in array
126 
127  Int_t i = GetIndexFromLabel(lab);
128  return GetCluster(i);
129 }
130 
131 //________________________________________________________________________
133 {
134  //Get particle with label lab in array
135 
136  Int_t i = GetIndexFromLabel(lab);
137  return GetAcceptCluster(i);
138 }
139 
140 //________________________________________________________________________
142 {
143  //Get next accepted cluster; if i >= 0 (re)start counter from i; return 0 if no accepted cluster could be found
144 
145  if (i>=0) fCurrentID = i;
146 
147  const Int_t n = GetNEntries();
148  AliVCluster *c = 0;
149  do {
150  fCurrentID++;
151  if (fCurrentID >= n) break;
153  } while (!c);
154 
155  return c;
156 }
157 
158 //________________________________________________________________________
160 {
161  //Get next cluster; if i >= 0 (re)start counter from i; return 0 if no cluster could be found
162 
163  if (i>=0) fCurrentID = i;
164 
165  const Int_t n = GetNEntries();
166  AliVCluster *c = 0;
167  do {
168  fCurrentID++;
169  if (fCurrentID >= n) break;
170  c = GetCluster(fCurrentID);
171  } while (!c);
172 
173  return c;
174 }
175 
176 //________________________________________________________________________
177 Bool_t AliClusterContainer::GetMomentum(TLorentzVector &mom, Int_t i)
178 {
179  //Get momentum of the i^th particle in array
180 
181  AliVCluster *vc = GetCluster(i);
182  if (vc) {
183  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
184  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
185  }
186  else {
187  vc->GetMomentum(mom, fVertex);
188  }
189  return kTRUE;
190  }
191  else {
192  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
193  return kFALSE;
194  }
195 }
196 
197 //________________________________________________________________________
198 Bool_t AliClusterContainer::GetNextMomentum(TLorentzVector &mom, Int_t i)
199 {
200  //Get momentum of the i^th particle in array
201 
202  AliVCluster *vc = GetNextCluster(i);
203  if (vc) {
204  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
205  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
206  }
207  else {
208  vc->GetMomentum(mom, fVertex);
209  }
210  return kTRUE;
211  }
212  else {
213  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
214  return kFALSE;
215  }
216 }
217 
218 //________________________________________________________________________
219 Bool_t AliClusterContainer::GetAcceptMomentum(TLorentzVector &mom, Int_t i)
220 {
221  //Get momentum of the i^th particle in array
222 
223  AliVCluster *vc = GetAcceptCluster(i);
224  if (vc) {
225  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
226  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
227  }
228  else {
229  vc->GetMomentum(mom, fVertex);
230  }
231 
232  return kTRUE;
233  }
234  else {
235  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
236  return kFALSE;
237  }
238 }
239 
240 //________________________________________________________________________
241 Bool_t AliClusterContainer::GetNextAcceptMomentum(TLorentzVector &mom, Int_t i)
242 {
243  //Get momentum of the i^th particle in array
244 
245  AliVCluster *vc = GetNextAcceptCluster(i);
246  if (vc) {
247  if (fDefaultClusterEnergy >= 0 && fDefaultClusterEnergy <= AliVCluster::kLastUserDefEnergy) {
248  vc->GetMomentum(mom, fVertex, (AliVCluster::VCluUserDefEnergy_t)fDefaultClusterEnergy);
249  }
250  else {
251  vc->GetMomentum(mom, fVertex);
252  }
253 
254  return kTRUE;
255  }
256  else {
257  mom.SetPtEtaPhiM(0, 0, 0, 0.139);
258  return kFALSE;
259  }
260 }
261 
262 //________________________________________________________________________
263 Bool_t AliClusterContainer::AcceptCluster(AliVCluster *clus)
264 {
265  // Return true if cluster is accepted.
266 
267  fRejectionReason = 0;
268 
269  if (!clus) {
271  return kFALSE;
272  }
273 
274  if (!clus->IsEMCAL()) {
276  return kFALSE;
277  }
278 
279  if (clus->TestBits(fBitMap) != (Int_t)fBitMap) {
281  return kFALSE;
282  }
283 
284  if (fMinMCLabel >= 0 && TMath::Abs(clus->GetLabel()) > fMinMCLabel) {
286  return kFALSE;
287  }
288 
289  if (fMaxMCLabel >= 0 && TMath::Abs(clus->GetLabel()) < fMaxMCLabel) {
291  return kFALSE;
292  }
293 
294  if (clus->GetTOF() > fClusTimeCutUp || clus->GetTOF() < fClusTimeCutLow) {
296  return kFALSE;
297  }
298 
299  if (clus->E()<fClusECut) {
301  return kFALSE;
302  }
303 
304  TLorentzVector nPart;
305  clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
306 
307  if (nPart.Et() < fClusPtCut) {
309  return kFALSE;
310  }
311 
312  if (fExoticCut && clus->GetIsExotic()) {
314  return kFALSE;
315  }
316 
317  for (Int_t i = 0; i <= AliVCluster::kLastUserDefEnergy; i++) {
318  if (clus->GetUserDefEnergy((VCluUserDefEnergy_t)i) < fUserDefEnergyCut[i]) {
320  return kFALSE;
321  }
322  }
323 
324  return kTRUE;
325 }
326 
327 //________________________________________________________________________
329 {
330  // Get number of accepted particles
331 
332  Int_t nClus = 0;
333 
334  AliVCluster *clus = GetNextAcceptCluster(0);
335  if(clus) nClus = 1;
336  while (GetNextAcceptCluster())
337  nClus++;
338 
339  return nClus;
340 }
341 
342 //________________________________________________________________________
344 {
345  if (t >= 0 && t <= AliVCluster::kLastUserDefEnergy){
346  return fUserDefEnergyCut[t];
347  }
348  else {
349  return fClusECut;
350  }
351 }
352 
353 //________________________________________________________________________
355 {
356  if (t >= 0 && t <= AliVCluster::kLastUserDefEnergy){
357  fUserDefEnergyCut[t] = cut;
358  }
359  else {
360  fClusECut = cut;
361  }
362 }
363 
364 
365 //________________________________________________________________________
366 void AliClusterContainer::SetClassName(const char *clname)
367 {
368  // Set the class name
369 
370  TClass cls(clname);
371  if (cls.InheritsFrom("AliVCluster")) fClassName = clname;
372  else AliError(Form("Unable to set class name %s for a AliClusterContainer, it must inherits from AliVCluster!",clname));
373 }
374 
375 //________________________________________________________________________
376 const char* AliClusterContainer::GetTitle() const
377 {
378  static TString clusterString;
379 
381 
382  if (Ecut == 0) {
383  clusterString = TString::Format("%s_E0000", GetArrayName().Data());
384  }
385  else if (Ecut < 1.0) {
386  clusterString = TString::Format("%s_E0%3.0f", GetArrayName().Data(), Ecut*1000.0);
387  }
388  else {
389  clusterString = TString::Format("%s_E%4.0f", GetArrayName().Data(), Ecut*1000.0);
390  }
391 
392  return clusterString.Data();
393 }
const char * GetTitle() const
virtual Bool_t AcceptCluster(Int_t i)
Int_t GetIndexFromLabel(Int_t lab) const
AliVCluster * GetAcceptClusterWithLabel(Int_t lab)
Double_t fUserDefEnergyCut[AliVCluster::kLastUserDefEnergy+1]
AliVCluster * GetNextAcceptCluster(Int_t i=-1)
void SetClusUserDefEnergyCut(Int_t t, Double_t cut)
AliVCluster * GetLeadingCluster(const char *opt="")
Double_t GetClusUserDefEnergyCut(Int_t t) const
Int_t GetDefaultClusterEnergy() const
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
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void SetClassName(const char *clname)
const TString & GetArrayName() const
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)