1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 /* History of cvs commits:
20 * Revision 1.9 2007/10/10 09:05:10 schutz
21 * Changing name QualAss to QA
23 * Revision 1.8 2007/08/28 12:55:08 policheh
24 * Loaders removed from the reconstruction code (C.Cheshkov)
26 * Revision 1.7 2007/08/07 14:12:03 kharlov
27 * Quality assurance added (Yves Schutz)
29 * Revision 1.6 2007/08/03 14:41:37 cvetan
30 * Missing header files
32 * Revision 1.5 2007/08/03 13:52:16 kharlov
33 * Working skeleton of matching the ESD tracks and ESD clusters (Iouri Belikov)
37 #include <TClonesArray.h>
41 #include "AliPHOSTracker.h"
42 #include "AliPHOSEmcRecPoint.h"
43 #include "AliESDEvent.h"
44 #include "AliESDtrack.h"
45 #include "AliPHOSTrackSegmentMakerv1.h"
46 #include "AliPHOSPIDv1.h"
48 //-------------------------------------------------------------------------
50 // Matches ESD tracks with the PHOS and makes the PID.
52 //-------------------------------------------------------------------------
54 ClassImp(AliPHOSTracker)
56 Bool_t AliPHOSTracker::fgDebug = kFALSE ;
59 // ***** Some geometrical constants (used in PropagateBack)
61 const Double_t kR=460.+ 9; // Radial coord. of the centre of EMC module (cm)
63 const Double_t kAlpha=20.*TMath::Pi()/180.; // Segmentation angle (rad)
64 const Double_t kYmax=kR*TMath::Tan(0.5*kAlpha); // Maximal possible y-coord.(cm)
65 const Double_t kZmax=65.; // Approximately: the maximal possible z-coord.(cm)
69 //____________________________________________________________________________
70 AliPHOSTracker::AliPHOSTracker():
73 //--------------------------------------------------------------------
74 // The default constructor
75 //--------------------------------------------------------------------
76 for (Int_t i=0; i<5; i++)
77 fModules[i]=new TClonesArray("AliPHOSEmcRecPoint",777);
80 //____________________________________________________________________________
81 AliPHOSTracker::~AliPHOSTracker()
83 //--------------------------------------------------------------------
85 //--------------------------------------------------------------------
86 for (Int_t i=0; i<5; i++) {
87 (fModules[i])->Delete();
92 //____________________________________________________________________________
93 Int_t AliPHOSTracker::LoadClusters(TTree *cTree) {
94 //--------------------------------------------------------------------
95 // This function loads the PHOS clusters
96 //--------------------------------------------------------------------
98 TBranch *branch=cTree->GetBranch("PHOSEmcRP");
100 AliError("No branch with the EMC clusters found !");
103 branch->SetAddress(&arr);
106 Int_t nentr=(Int_t)branch->GetEntries();
107 for (Int_t i=0; i<nentr; i++) {
108 if (!branch->GetEvent(i)) continue;
109 Int_t ncl=arr->GetEntriesFast();
111 AliPHOSEmcRecPoint *cl=(AliPHOSEmcRecPoint*)arr->UncheckedAt(ncl);
113 Int_t m=cl->GetPHOSMod();
115 AliError("Wrong module index !");
119 // Here is how the alignment is treated
120 if (!cl->Misalign()) AliWarning("Can't misalign this cluster !");
122 cl->SetBit(14,kFALSE); // The clusters are not yet attached to any track
124 TClonesArray &module=*fModules[m-1];
125 Int_t idx=module.GetEntriesFast();
126 new (module[idx]) AliPHOSEmcRecPoint(*cl);
133 Info("LoadClusters","Number of loaded clusters: %d",nclusters);
138 //____________________________________________________________________________
139 Int_t AliPHOSTracker::PropagateBack(AliESDEvent *esd) {
140 //--------------------------------------------------------------------
141 // Called by AliReconstruction
142 // Performs the track matching with the PHOS modules
144 //--------------------------------------------------------------------
146 Int_t nt=esd->GetNumberOfTracks();
148 // *** Select and sort the ESD track in accordance with their quality
149 Double_t *quality=new Double_t[nt];
150 Int_t *index=new Int_t[nt];
151 for (Int_t i=0; i<nt; i++) {
152 AliESDtrack *esdTrack=esd->GetTrack(i);
153 quality[i] = esdTrack->GetSigmaY2() + esdTrack->GetSigmaZ2();
155 TMath::Sort(nt,quality,index,kFALSE);
158 // *** Start the matching
161 for (Int_t i=0; i<nt; i++) {
162 AliESDtrack *esdTrack=esd->GetTrack(index[i]);
164 // Skip the tracks having "wrong" status (has to be checked/tuned)
165 ULong_t status = esdTrack->GetStatus();
166 if ((status & AliESDtrack::kTRDout) == 0) continue;
167 if ((status & AliESDtrack::kTRDrefit) == 1) continue;
169 AliExternalTrackParam t(*esdTrack);
171 Int_t isec=Int_t(t.GetAlpha()/kAlpha);
172 Int_t imod=-isec-2; // PHOS module
174 Double_t y; // Some tracks do not reach the PHOS
175 if (!t.GetYAt(kR,bz,y)) continue; // because of the bending
177 Double_t z; t.GetZAt(kR,bz,z);
178 if (TMath::Abs(z) > kZmax) continue; // Some tracks miss the PHOS in Z
181 while (TMath::Abs(y) > kYmax) { // Find the matching module
182 Double_t alp=t.GetAlpha();
184 if (!t.Rotate(alp+kAlpha)) {ok=kFALSE; break;}
186 } else if (y < -kYmax) {
187 if (!t.Rotate(alp-kAlpha)) {ok=kFALSE; break;}
190 if (!t.GetYAt(kR,bz,y)) {ok=kFALSE; break;}
192 if (!ok) continue; // Track rotation failed
195 if ((imod<0)||(imod>4)) continue; // Some tracks miss the PHOS in azimuth
197 //t.CorrectForMaterial(...); // Correct for the TOF material, if needed
198 t.PropagateTo(kR,bz); // Propagate to the matching module
201 // *** Search for the "best" cluster (can be improved)
202 TClonesArray &cArray=*fModules[imod];
203 Int_t ncl=cArray.GetEntriesFast();
204 AliPHOSEmcRecPoint *bestCluster=0; // The "best" cluster
205 Double_t maxd2=400; // (cm^2)
206 for (Int_t j=0; j<ncl; j++) {
207 AliPHOSEmcRecPoint *c=(AliPHOSEmcRecPoint *)cArray.UncheckedAt(j);
209 if (c->TestBit(14)) continue; // This clusters is "used"
211 Double_t dy = t.GetY() - c->GetY(), dz = t.GetZ() - c->GetZ();
212 Double_t d2 = dy*dy + dz*dz;
219 if (!bestCluster) continue; // No reasonable matching found
221 bestCluster->SetBit(14,kTRUE); // This clusters is now attached to a track
225 // *** Now, do the PID with the "bestCluster"
226 // and add the corresponding info to the ESD track pointed by "esdTrack"
229 printf("%e %e %e %e\n",t.GetSign(), t.GetX() - bestCluster->GetX(),
230 t.GetY() - bestCluster->GetY(),
231 t.GetZ() - bestCluster->GetZ());
235 Info("PropagateBack","Number of matched tracks: %d",matched);
243 //____________________________________________________________________________
244 AliCluster *AliPHOSTracker::GetCluster(Int_t index) const {
245 //--------------------------------------------------------------------
246 // Returns the pointer to a given cluster
247 //--------------------------------------------------------------------
248 Int_t m=(index & 0xf0000000) >> 28; // Module number
249 Int_t i=(index & 0x0fffffff) >> 00; // Index within the module
251 return (AliCluster*)(fModules[m])->UncheckedAt(i);
254 //____________________________________________________________________________
255 void AliPHOSTracker::UnloadClusters() {
256 //--------------------------------------------------------------------
257 // This function unloads the PHOS clusters
258 //--------------------------------------------------------------------
259 for (Int_t i=0; i<5; i++) (fModules[i])->Delete();