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