]>
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" |
95bf21ad | 43 | #include "AliPHOSGeometry.h" |
af885e0f | 44 | #include "AliESDEvent.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 | ||
ddd1a39c | 59 | //____________________________________________________________________________ |
60 | AliPHOSTracker::AliPHOSTracker(): | |
9a2cdbdf | 61 | AliTracker() |
ddd1a39c | 62 | { |
04e92dc8 | 63 | //-------------------------------------------------------------------- |
64 | // The default constructor | |
65 | //-------------------------------------------------------------------- | |
66 | for (Int_t i=0; i<5; i++) | |
67 | fModules[i]=new TClonesArray("AliPHOSEmcRecPoint",777); | |
d7737747 | 68 | |
04e92dc8 | 69 | } |
70 | ||
ddd1a39c | 71 | //____________________________________________________________________________ |
72 | AliPHOSTracker::~AliPHOSTracker() | |
73 | { | |
04e92dc8 | 74 | //-------------------------------------------------------------------- |
75 | // The destructor | |
76 | //-------------------------------------------------------------------- | |
77 | for (Int_t i=0; i<5; i++) { | |
78 | (fModules[i])->Delete(); | |
79 | delete fModules[i]; | |
80 | } | |
81 | } | |
82 | ||
ddd1a39c | 83 | //____________________________________________________________________________ |
95bf21ad | 84 | Int_t AliPHOSTracker::LoadClusters(TTree *cTree) { |
04e92dc8 | 85 | //-------------------------------------------------------------------- |
86 | // This function loads the PHOS clusters | |
87 | //-------------------------------------------------------------------- | |
95bf21ad | 88 | |
89 | TObjArray *arr=NULL; | |
90 | TBranch *branch=cTree->GetBranch("PHOSEmcRP"); | |
91 | if (branch==0) { | |
92 | AliError("No branch with the EMC clusters found !"); | |
93 | return 1; | |
94 | } | |
95 | branch->SetAddress(&arr); | |
96 | ||
771123c7 | 97 | for(Int_t m=0;m<5; m++) fModules[m]->Clear("C") ; |
95bf21ad | 98 | |
99 | Int_t nclusters=0; | |
100 | Int_t nentr=(Int_t)branch->GetEntries(); | |
101 | for (Int_t i=0; i<nentr; i++) { | |
102 | if (!branch->GetEvent(i)) continue; | |
103 | Int_t ncl=arr->GetEntriesFast(); | |
104 | while (ncl--) { | |
105 | AliPHOSEmcRecPoint *cl=(AliPHOSEmcRecPoint*)arr->UncheckedAt(ncl); | |
106 | ||
107 | Int_t m=cl->GetPHOSMod(); | |
108 | if ((m<1)||(m>5)) { | |
109 | AliError(Form("Wrong module index: %d !",m)); | |
110 | continue ; | |
111 | } | |
112 | ||
113 | // Here is how the alignment is treated | |
114 | // Misalignment is already in cluster coordinates | |
115 | // if (!cl->Misalign()) AliWarning("Can't misalign this cluster !"); | |
116 | ||
117 | cl->SetBit(14,kFALSE); // The clusters are not yet attached to any track | |
118 | ||
119 | TClonesArray &module=*fModules[m-1]; | |
120 | Int_t idx=module.GetEntriesFast(); | |
121 | new (module[idx]) AliPHOSEmcRecPoint(*cl); | |
122 | ||
123 | nclusters++; | |
124 | ||
125 | } | |
126 | } | |
127 | arr->Delete(); | |
128 | Info("LoadClusters","Number of loaded clusters: %d",nclusters); | |
129 | ||
130 | return 0; | |
131 | ||
04e92dc8 | 132 | } |
133 | ||
ddd1a39c | 134 | //____________________________________________________________________________ |
95bf21ad | 135 | Int_t AliPHOSTracker::PropagateBack(AliESDEvent *esd) { |
04e92dc8 | 136 | //-------------------------------------------------------------------- |
23904d16 | 137 | // Called by AliReconstruction |
04e92dc8 | 138 | // Performs the track matching with the PHOS modules |
139 | // Makes the PID | |
140 | //-------------------------------------------------------------------- | |
141 | ||
95bf21ad | 142 | Int_t nt=esd->GetNumberOfTracks(); |
143 | ||
144 | // *** Select and sort the ESD track in accordance with their quality | |
145 | Double_t *quality=new Double_t[nt]; | |
146 | Int_t *index=new Int_t[nt]; | |
147 | for (Int_t i=0; i<nt; i++) { | |
148 | AliESDtrack *esdTrack=esd->GetTrack(i); | |
149 | quality[i] = esdTrack->GetSigmaY2() + esdTrack->GetSigmaZ2(); | |
150 | } | |
151 | TMath::Sort(nt,quality,index,kFALSE); | |
152 | ||
153 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; | |
154 | ||
155 | // *** Start the matching | |
156 | TVector3 vecEmc ; // Local position of EMC recpoint | |
157 | Double_t bz = GetBz() ; //For approximate matching | |
158 | Double_t b[3]; //For final matching | |
159 | Double_t gposTrack[3] ; | |
160 | Int_t matched=0; | |
161 | for (Int_t i=0; i<nt; i++) { | |
162 | AliESDtrack *esdTrack=esd->GetTrack(index[i]); | |
163 | ||
164 | // Skip the tracks having "wrong" status (has to be checked/tuned) | |
165 | ULong_t status = esdTrack->GetStatus(); | |
166 | if ((status & AliESDtrack::kTPCout) == 0) continue; | |
167 | // if ((status & AliESDtrack::kTRDout) == 0) continue; | |
168 | // if ((status & AliESDtrack::kTRDrefit) == 1) continue; | |
169 | ||
170 | //Continue extrapolation from TPC outer surface | |
171 | const AliExternalTrackParam *outerParam=esdTrack->GetOuterParam(); | |
172 | if (!outerParam) continue; | |
173 | AliExternalTrackParam t(*outerParam); | |
174 | ||
175 | t.GetBxByBz(b) ; | |
176 | ||
177 | //Loop over PHOS modules | |
178 | Double_t dx=0,dz=0; | |
179 | Double_t minDistance=999. ; | |
180 | Int_t emcIndex=0 ; | |
181 | for(Int_t mod=1; mod<=5; mod++){ | |
182 | if(fModules[mod-1]->GetEntriesFast()==0) //no PHOS clusters in this module or module does not exist | |
183 | continue ; | |
184 | ||
185 | //Approximate direction to the current PHOS module | |
186 | Double_t phiMod=(330.-20.*mod)/180.*TMath::Pi() ; | |
187 | if(!t.Rotate(phiMod)) | |
188 | continue ; | |
189 | TVector3 globaPos ; | |
190 | geom->Local2Global(mod, 0.,0., globaPos) ; | |
191 | const Double_t rPHOS = globaPos.Pt() ; //Distance to center of PHOS module | |
192 | const Double_t kYmax = 72.+10. ; //Size of the module (with some reserve) in phi direction | |
193 | const Double_t kZmax = 64.+20. ; //Size of the module (with some reserve) in z direction | |
194 | ||
195 | Double_t y; // Some tracks do not reach the PHOS | |
196 | if (!t.GetYAt(rPHOS,bz,y)) continue; // because of the bending | |
197 | ||
198 | Double_t z; | |
199 | if(!t.GetZAt(rPHOS,bz,z)) | |
200 | continue ; | |
201 | if (TMath::Abs(z) > kZmax) | |
202 | continue; // Some tracks miss the PHOS in Z | |
203 | if(TMath::Abs(y) < kYmax){ | |
204 | t.PropagateToBxByBz(rPHOS,b); // Propagate to the matching module | |
205 | //t.CorrectForMaterial(...); // Correct for the TOF material, if needed | |
206 | t.GetXYZ(gposTrack) ; | |
207 | TVector3 globalPositionTr(gposTrack) ; | |
208 | TVector3 localPositionTr ; | |
209 | geom->Global2Local(localPositionTr,globalPositionTr,mod) ; | |
210 | for(Int_t icl=0;icl<fModules[mod-1]->GetEntriesFast();icl++){ | |
211 | AliPHOSEmcRecPoint * clu =static_cast<AliPHOSEmcRecPoint*>(fModules[mod-1]->At(icl)) ; | |
212 | clu->GetLocalPosition(vecEmc) ; | |
213 | Double_t ddx = vecEmc.X()-localPositionTr.X(); | |
214 | Double_t ddz = vecEmc.Z()-localPositionTr.Z(); | |
215 | Double_t d2 = ddx*ddx + ddz*ddz; | |
216 | if(d2 < minDistance) { | |
217 | dx = ddx ; | |
218 | dz = ddz ; | |
219 | emcIndex=clu->GetIndexInList() ; | |
220 | minDistance=d2 ; | |
221 | } | |
222 | } | |
223 | break ; | |
224 | } | |
225 | } //Loop over modules | |
226 | ||
227 | if(minDistance<999.){ | |
228 | //found some match | |
229 | esdTrack->SetStatus(AliESDtrack::kPHOSmatch) ; | |
230 | esdTrack->SetPHOScluster(-emcIndex) ; //Should be ESDCaloCluster index which is not known yet. Will be transformed later in FillESD(). | |
231 | esdTrack->SetPHOSdxdz(dx,dz) ; | |
232 | matched++; | |
233 | } | |
234 | ||
235 | } | |
236 | ||
237 | Info("PropagateBack","Number of matched tracks: %d",matched); | |
238 | ||
239 | delete[] quality; | |
240 | delete[] index; | |
241 | ||
242 | return 0; | |
243 | ||
04e92dc8 | 244 | } |
245 | ||
ddd1a39c | 246 | //____________________________________________________________________________ |
04e92dc8 | 247 | AliCluster *AliPHOSTracker::GetCluster(Int_t index) const { |
248 | //-------------------------------------------------------------------- | |
249 | // Returns the pointer to a given cluster | |
250 | //-------------------------------------------------------------------- | |
251 | Int_t m=(index & 0xf0000000) >> 28; // Module number | |
252 | Int_t i=(index & 0x0fffffff) >> 00; // Index within the module | |
253 | ||
254 | return (AliCluster*)(fModules[m])->UncheckedAt(i); | |
255 | } | |
256 | ||
ddd1a39c | 257 | //____________________________________________________________________________ |
04e92dc8 | 258 | void AliPHOSTracker::UnloadClusters() { |
259 | //-------------------------------------------------------------------- | |
260 | // This function unloads the PHOS clusters | |
261 | //-------------------------------------------------------------------- | |
d7737747 | 262 | // for (Int_t i=0; i<5; i++) (fModules[i])->Delete(); |
04e92dc8 | 263 | } |