]>
Commit | Line | Data |
---|---|---|
9239b066 | 1 | // $Id$ |
e58333e0 | 2 | // |
9239b066 | 3 | // Container with name, TClonesArray and cuts for particles |
e58333e0 | 4 | // |
5 | // Author: M. Verweij | |
6 | ||
e58333e0 | 7 | #include <TClonesArray.h> |
6421eeb0 | 8 | |
e58333e0 | 9 | #include "AliVEvent.h" |
10 | #include "AliLog.h" | |
11 | ||
12 | #include "AliClusterContainer.h" | |
13 | ||
14 | ClassImp(AliClusterContainer) | |
15 | ||
16 | //________________________________________________________________________ | |
17 | AliClusterContainer::AliClusterContainer(): | |
18 | AliEmcalContainer("AliClusterContainer"), | |
19 | fClusPtCut(0.15), | |
29462c2a | 20 | fClusECut(0.15), |
e58333e0 | 21 | fClusTimeCutLow(-10), |
22 | fClusTimeCutUp(10), | |
23 | fClusterBitMap(0), | |
24 | fMCClusterBitMap(0), | |
6421eeb0 | 25 | fMinMCLabel(0) |
e58333e0 | 26 | { |
27 | // Default constructor. | |
28 | ||
b6f970ad | 29 | fClassName = "AliVCluster"; |
e58333e0 | 30 | } |
31 | ||
32 | //________________________________________________________________________ | |
33 | AliClusterContainer::AliClusterContainer(const char *name): | |
34 | AliEmcalContainer(name), | |
35 | fClusPtCut(0.15), | |
29462c2a | 36 | fClusECut(0.15), |
e58333e0 | 37 | fClusTimeCutLow(-10), |
38 | fClusTimeCutUp(10), | |
39 | fClusterBitMap(0), | |
40 | fMCClusterBitMap(0), | |
6421eeb0 | 41 | fMinMCLabel(0) |
e58333e0 | 42 | { |
43 | // Standard constructor. | |
44 | ||
b6f970ad | 45 | fClassName = "AliVCluster"; |
e58333e0 | 46 | } |
47 | ||
48 | //________________________________________________________________________ | |
b6f970ad | 49 | AliVCluster* AliClusterContainer::GetLeadingCluster(const char* opt) |
e58333e0 | 50 | { |
6421eeb0 | 51 | // Get the leading cluster; use e if "e" is contained in opt (otherwise et) |
e58333e0 | 52 | |
6421eeb0 | 53 | TString option(opt); |
54 | option.ToLower(); | |
55 | ||
b6f970ad | 56 | Int_t tempID = fCurrentID; |
57 | ||
6421eeb0 | 58 | AliVCluster *clusterMax = GetNextAcceptCluster(0); |
59 | AliVCluster *cluster = 0; | |
e58333e0 | 60 | |
6421eeb0 | 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 | } | |
e58333e0 | 78 | } |
79 | ||
b6f970ad | 80 | fCurrentID = tempID; |
81 | ||
6421eeb0 | 82 | return clusterMax; |
e58333e0 | 83 | } |
84 | ||
85 | //________________________________________________________________________ | |
157b926a | 86 | AliVCluster* AliClusterContainer::GetCluster(Int_t i) const |
87 | { | |
6421eeb0 | 88 | //Get i^th cluster in array |
e58333e0 | 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 | //________________________________________________________________________ | |
157b926a | 97 | AliVCluster* AliClusterContainer::GetAcceptCluster(Int_t i) const |
98 | { | |
99 | //Return pointer to cluster if cluster is accepted | |
e58333e0 | 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 | ||
ef46ebe5 | 112 | //________________________________________________________________________ |
157b926a | 113 | AliVCluster* AliClusterContainer::GetClusterWithLabel(Int_t lab) const |
114 | { | |
ef46ebe5 | 115 | //Get particle with label lab in array |
116 | ||
117 | Int_t i = GetIndexFromLabel(lab); | |
118 | return GetCluster(i); | |
119 | } | |
120 | ||
121 | //________________________________________________________________________ | |
157b926a | 122 | AliVCluster* AliClusterContainer::GetAcceptClusterWithLabel(Int_t lab) const |
123 | { | |
ef46ebe5 | 124 | //Get particle with label lab in array |
125 | ||
126 | Int_t i = GetIndexFromLabel(lab); | |
127 | return GetAcceptCluster(i); | |
128 | } | |
129 | ||
6421eeb0 | 130 | //________________________________________________________________________ |
157b926a | 131 | AliVCluster* AliClusterContainer::GetNextAcceptCluster(Int_t i) |
132 | { | |
ef46ebe5 | 133 | //Get next accepted cluster; if i >= 0 (re)start counter from i; return 0 if no accepted cluster could be found |
6421eeb0 | 134 | |
b6f970ad | 135 | if (i>=0) fCurrentID = i; |
6421eeb0 | 136 | |
137 | const Int_t n = GetNEntries(); | |
138 | AliVCluster *c = 0; | |
b6f970ad | 139 | while (fCurrentID < n && !c) { |
140 | c = GetAcceptCluster(fCurrentID); | |
141 | fCurrentID++; | |
6421eeb0 | 142 | } |
143 | ||
144 | return c; | |
145 | } | |
146 | ||
ef46ebe5 | 147 | //________________________________________________________________________ |
157b926a | 148 | AliVCluster* AliClusterContainer::GetNextCluster(Int_t i) |
149 | { | |
ef46ebe5 | 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 | ||
6421eeb0 | 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 | ||
e58333e0 | 173 | //________________________________________________________________________ |
174 | Bool_t AliClusterContainer::AcceptCluster(AliVCluster *clus) const | |
175 | { | |
176 | // Return true if cluster is accepted. | |
177 | ||
178 | if (!clus) | |
179 | return kFALSE; | |
180 | ||
181 | if (!clus->IsEMCAL()) | |
182 | return kFALSE; | |
183 | ||
184 | if (clus->GetLabel() > fMinMCLabel) { | |
185 | if (clus->TestBits(fMCClusterBitMap) != (Int_t)fMCClusterBitMap) { | |
186 | AliDebug(2,"MC Cluster not accepted because of MC bit map."); | |
187 | return kFALSE; | |
188 | } | |
189 | } | |
190 | else { | |
191 | if (clus->TestBits(fClusterBitMap) != (Int_t)fClusterBitMap) { | |
192 | AliDebug(2,"Cluster not accepted because of bit map."); | |
193 | return kFALSE; | |
194 | } | |
195 | } | |
196 | ||
197 | if (clus->GetTOF() > fClusTimeCutUp || clus->GetTOF() < fClusTimeCutLow) | |
198 | return kFALSE; | |
199 | ||
29462c2a | 200 | if (clus->E()<fClusECut) |
201 | return kFALSE; | |
202 | ||
e58333e0 | 203 | TLorentzVector nPart; |
204 | clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex)); | |
205 | ||
206 | if (nPart.Et() < fClusPtCut) | |
207 | return kFALSE; | |
208 | ||
209 | return kTRUE; | |
e58333e0 | 210 | } |
b6f970ad | 211 | |
212 | //________________________________________________________________________ | |
213 | void AliClusterContainer::SetClassName(const char *clname) | |
214 | { | |
215 | // Set the class name | |
216 | ||
217 | TClass cls(clname); | |
218 | if (cls.InheritsFrom("AliVCluster")) fClassName = clname; | |
219 | else AliError(Form("Unable to set class name %s for a AliClusterContainer, it must inherits from AliVCluster!",clname)); | |
220 | } |