]>
Commit | Line | Data |
---|---|---|
04e92dc8 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | /* $Id$ */ | |
16 | ||
17 | /* History of cvs commits: | |
18 | * | |
19 | * $Log$ | |
04236e67 | 20 | * Revision 1.9 2007/10/10 09:05:10 schutz |
21 | * Changing name QualAss to QA | |
22 | * | |
b8274834 | 23 | * Revision 1.8 2007/08/28 12:55:08 policheh |
24 | * Loaders removed from the reconstruction code (C.Cheshkov) | |
25 | * | |
9a2cdbdf | 26 | * Revision 1.7 2007/08/07 14:12:03 kharlov |
27 | * Quality assurance added (Yves Schutz) | |
28 | * | |
ddd1a39c | 29 | * Revision 1.6 2007/08/03 14:41:37 cvetan |
30 | * Missing header files | |
31 | * | |
1d0c181d | 32 | * Revision 1.5 2007/08/03 13:52:16 kharlov |
33 | * Working skeleton of matching the ESD tracks and ESD clusters (Iouri Belikov) | |
34 | * | |
04e92dc8 | 35 | */ |
36 | ||
37 | #include <TClonesArray.h> | |
1d0c181d | 38 | #include <TMath.h> |
04e92dc8 | 39 | |
40 | #include <AliLog.h> | |
23904d16 | 41 | #include "AliPHOSTracker.h" |
04e92dc8 | 42 | #include "AliPHOSEmcRecPoint.h" |
af885e0f | 43 | #include "AliESDEvent.h" |
ddd1a39c | 44 | #include "AliPHOSGetter.h" |
1d0c181d | 45 | #include "AliESDtrack.h" |
ddd1a39c | 46 | #include "AliPHOSTrackSegmentMakerv1.h" |
47 | #include "AliPHOSPIDv1.h" | |
23904d16 | 48 | |
49 | //------------------------------------------------------------------------- | |
50 | // PHOS tracker. | |
51 | // Matches ESD tracks with the PHOS and makes the PID. | |
04e92dc8 | 52 | // |
23904d16 | 53 | //------------------------------------------------------------------------- |
54 | ||
55 | ClassImp(AliPHOSTracker) | |
56 | ||
04e92dc8 | 57 | Bool_t AliPHOSTracker::fgDebug = kFALSE ; |
58 | ||
59 | ||
60 | // ***** Some geometrical constants (used in PropagateBack) | |
61 | ||
62 | const Double_t kR=460.+ 9; // Radial coord. of the centre of EMC module (cm) | |
63 | ||
64 | const Double_t kAlpha=20.*TMath::Pi()/180.; // Segmentation angle (rad) | |
65 | const Double_t kYmax=kR*TMath::Tan(0.5*kAlpha); // Maximal possible y-coord.(cm) | |
66 | const Double_t kZmax=65.; // Approximately: the maximal possible z-coord.(cm) | |
67 | ||
68 | ||
69 | ||
ddd1a39c | 70 | //____________________________________________________________________________ |
71 | AliPHOSTracker::AliPHOSTracker(): | |
9a2cdbdf | 72 | AliTracker() |
ddd1a39c | 73 | { |
04e92dc8 | 74 | //-------------------------------------------------------------------- |
75 | // The default constructor | |
76 | //-------------------------------------------------------------------- | |
77 | for (Int_t i=0; i<5; i++) | |
78 | fModules[i]=new TClonesArray("AliPHOSEmcRecPoint",777); | |
79 | } | |
80 | ||
ddd1a39c | 81 | //____________________________________________________________________________ |
82 | AliPHOSTracker::~AliPHOSTracker() | |
83 | { | |
04e92dc8 | 84 | //-------------------------------------------------------------------- |
85 | // The destructor | |
86 | //-------------------------------------------------------------------- | |
87 | for (Int_t i=0; i<5; i++) { | |
88 | (fModules[i])->Delete(); | |
89 | delete fModules[i]; | |
90 | } | |
91 | } | |
92 | ||
ddd1a39c | 93 | //____________________________________________________________________________ |
04e92dc8 | 94 | Int_t AliPHOSTracker::LoadClusters(TTree *cTree) { |
95 | //-------------------------------------------------------------------- | |
96 | // This function loads the PHOS clusters | |
97 | //-------------------------------------------------------------------- | |
98 | TObjArray *arr=NULL; | |
99 | TBranch *branch=cTree->GetBranch("PHOSEmcRP"); | |
100 | if (branch==0) { | |
101 | AliError("No branch with the EMC clusters found !"); | |
102 | return 1; | |
103 | } | |
104 | branch->SetAddress(&arr); | |
105 | ||
106 | Int_t nclusters=0; | |
107 | Int_t nentr=(Int_t)branch->GetEntries(); | |
108 | for (Int_t i=0; i<nentr; i++) { | |
109 | if (!branch->GetEvent(i)) continue; | |
110 | Int_t ncl=arr->GetEntriesFast(); | |
111 | while (ncl--) { | |
112 | AliPHOSEmcRecPoint *cl=(AliPHOSEmcRecPoint*)arr->UncheckedAt(ncl); | |
113 | ||
114 | Int_t m=cl->GetPHOSMod(); | |
115 | if ((m<1)||(m>5)) { | |
116 | AliError("Wrong module index !"); | |
117 | return 1; | |
118 | } | |
119 | ||
120 | // Here is how the alignment is treated | |
121 | if (!cl->Misalign()) AliWarning("Can't misalign this cluster !"); | |
122 | ||
123 | cl->SetBit(14,kFALSE); // The clusters are not yet attached to any track | |
124 | ||
125 | TClonesArray &module=*fModules[m-1]; | |
126 | Int_t idx=module.GetEntriesFast(); | |
127 | new (module[idx]) AliPHOSEmcRecPoint(*cl); | |
128 | ||
129 | nclusters++; | |
130 | ||
131 | } | |
132 | } | |
133 | ||
134 | Info("LoadClusters","Number of loaded clusters: %d",nclusters); | |
135 | ||
136 | return 0; | |
137 | } | |
138 | ||
ddd1a39c | 139 | //____________________________________________________________________________ |
af885e0f | 140 | Int_t AliPHOSTracker::PropagateBack(AliESDEvent *esd) { |
04e92dc8 | 141 | //-------------------------------------------------------------------- |
23904d16 | 142 | // Called by AliReconstruction |
04e92dc8 | 143 | // Performs the track matching with the PHOS modules |
144 | // Makes the PID | |
145 | //-------------------------------------------------------------------- | |
146 | ||
04e92dc8 | 147 | Int_t nt=esd->GetNumberOfTracks(); |
148 | ||
149 | // *** Select and sort the ESD track in accordance with their quality | |
150 | Double_t *quality=new Double_t[nt]; | |
151 | Int_t *index=new Int_t[nt]; | |
152 | for (Int_t i=0; i<nt; i++) { | |
153 | AliESDtrack *esdTrack=esd->GetTrack(i); | |
154 | quality[i] = esdTrack->GetSigmaY2() + esdTrack->GetSigmaZ2(); | |
155 | } | |
156 | TMath::Sort(nt,quality,index,kFALSE); | |
157 | ||
158 | ||
159 | // *** Start the matching | |
160 | Double_t bz=GetBz(); | |
161 | Int_t matched=0; | |
162 | for (Int_t i=0; i<nt; i++) { | |
163 | AliESDtrack *esdTrack=esd->GetTrack(index[i]); | |
164 | ||
165 | // Skip the tracks having "wrong" status (has to be checked/tuned) | |
166 | ULong_t status = esdTrack->GetStatus(); | |
167 | if ((status & AliESDtrack::kTRDout) == 0) continue; | |
168 | if ((status & AliESDtrack::kTRDrefit) == 1) continue; | |
169 | ||
170 | AliExternalTrackParam t(*esdTrack); | |
171 | ||
172 | Int_t isec=Int_t(t.GetAlpha()/kAlpha); | |
173 | Int_t imod=-isec-2; // PHOS module | |
174 | ||
175 | Double_t y; // Some tracks do not reach the PHOS | |
176 | if (!t.GetYAt(kR,bz,y)) continue; // because of the bending | |
177 | ||
178 | Double_t z; t.GetZAt(kR,bz,z); | |
179 | if (TMath::Abs(z) > kZmax) continue; // Some tracks miss the PHOS in Z | |
180 | ||
181 | Bool_t ok=kTRUE; | |
182 | while (TMath::Abs(y) > kYmax) { // Find the matching module | |
183 | Double_t alp=t.GetAlpha(); | |
184 | if (y > kYmax) { | |
185 | if (!t.Rotate(alp+kAlpha)) {ok=kFALSE; break;} | |
186 | imod--; | |
187 | } else if (y < -kYmax) { | |
188 | if (!t.Rotate(alp-kAlpha)) {ok=kFALSE; break;} | |
189 | imod++; | |
190 | } | |
191 | if (!t.GetYAt(kR,bz,y)) {ok=kFALSE; break;} | |
192 | } | |
193 | if (!ok) continue; // Track rotation failed | |
194 | ||
195 | ||
196 | if ((imod<0)||(imod>4)) continue; // Some tracks miss the PHOS in azimuth | |
197 | ||
198 | //t.CorrectForMaterial(...); // Correct for the TOF material, if needed | |
199 | t.PropagateTo(kR,bz); // Propagate to the matching module | |
200 | ||
201 | ||
202 | // *** Search for the "best" cluster (can be improved) | |
203 | TClonesArray &cArray=*fModules[imod]; | |
204 | Int_t ncl=cArray.GetEntriesFast(); | |
205 | AliPHOSEmcRecPoint *bestCluster=0; // The "best" cluster | |
206 | Double_t maxd2=400; // (cm^2) | |
207 | for (Int_t i=0; i<ncl; i++) { | |
208 | AliPHOSEmcRecPoint *c=(AliPHOSEmcRecPoint *)cArray.UncheckedAt(i); | |
209 | ||
210 | if (c->TestBit(14)) continue; // This clusters is "used" | |
211 | ||
212 | Double_t dy = t.GetY() - c->GetY(), dz = t.GetZ() - c->GetZ(); | |
213 | Double_t d2 = dy*dy + dz*dz; | |
214 | if (d2 < maxd2) { | |
215 | maxd2=d2; | |
216 | bestCluster=c; | |
217 | } | |
218 | } | |
219 | ||
220 | if (!bestCluster) continue; // No reasonable matching found | |
221 | ||
222 | bestCluster->SetBit(14,kTRUE); // This clusters is now attached to a track | |
223 | ||
224 | matched++; | |
225 | ||
226 | // *** Now, do the PID with the "bestCluster" | |
227 | // and add the corresponding info to the ESD track pointed by "esdTrack" | |
228 | ||
229 | /* | |
230 | printf("%e %e %e %e\n",t.GetSign(), t.GetX() - bestCluster->GetX(), | |
231 | t.GetY() - bestCluster->GetY(), | |
232 | t.GetZ() - bestCluster->GetZ()); | |
233 | */ | |
234 | } | |
235 | ||
236 | Info("PropagateBack","Number of matched tracks: %d",matched); | |
237 | ||
238 | delete[] quality; | |
239 | delete[] index; | |
240 | ||
241 | return 0; | |
242 | } | |
243 | ||
ddd1a39c | 244 | //____________________________________________________________________________ |
04e92dc8 | 245 | AliCluster *AliPHOSTracker::GetCluster(Int_t index) const { |
246 | //-------------------------------------------------------------------- | |
247 | // Returns the pointer to a given cluster | |
248 | //-------------------------------------------------------------------- | |
249 | Int_t m=(index & 0xf0000000) >> 28; // Module number | |
250 | Int_t i=(index & 0x0fffffff) >> 00; // Index within the module | |
251 | ||
252 | return (AliCluster*)(fModules[m])->UncheckedAt(i); | |
253 | } | |
254 | ||
ddd1a39c | 255 | //____________________________________________________________________________ |
04e92dc8 | 256 | void AliPHOSTracker::UnloadClusters() { |
257 | //-------------------------------------------------------------------- | |
258 | // This function unloads the PHOS clusters | |
259 | //-------------------------------------------------------------------- | |
260 | for (Int_t i=0; i<5; i++) (fModules[i])->Delete(); | |
261 | } |