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