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.7 2007/08/07 14:12:03 kharlov
21 * Quality assurance added (Yves Schutz)
23 * Revision 1.6 2007/08/03 14:41:37 cvetan
24 * Missing header files
26 * Revision 1.5 2007/08/03 13:52:16 kharlov
27 * Working skeleton of matching the ESD tracks and ESD clusters (Iouri Belikov)
31 #include <TClonesArray.h>
35 #include "AliPHOSTracker.h"
36 #include "AliPHOSEmcRecPoint.h"
37 #include "AliESDEvent.h"
38 #include "AliPHOSQualAssDataMaker.h"
39 #include "AliPHOSGetter.h"
40 #include "AliESDtrack.h"
41 #include "AliPHOSTrackSegmentMakerv1.h"
42 #include "AliPHOSPIDv1.h"
44 //-------------------------------------------------------------------------
46 // Matches ESD tracks with the PHOS and makes the PID.
48 //-------------------------------------------------------------------------
50 ClassImp(AliPHOSTracker)
52 Bool_t AliPHOSTracker::fgDebug = kFALSE ;
55 // ***** Some geometrical constants (used in PropagateBack)
57 const Double_t kR=460.+ 9; // Radial coord. of the centre of EMC module (cm)
59 const Double_t kAlpha=20.*TMath::Pi()/180.; // Segmentation angle (rad)
60 const Double_t kYmax=kR*TMath::Tan(0.5*kAlpha); // Maximal possible y-coord.(cm)
61 const Double_t kZmax=65.; // Approximately: the maximal possible z-coord.(cm)
65 //____________________________________________________________________________
66 AliPHOSTracker::AliPHOSTracker():
69 //--------------------------------------------------------------------
70 // The default constructor
71 //--------------------------------------------------------------------
72 for (Int_t i=0; i<5; i++)
73 fModules[i]=new TClonesArray("AliPHOSEmcRecPoint",777);
76 //____________________________________________________________________________
77 AliPHOSTracker::~AliPHOSTracker()
79 //--------------------------------------------------------------------
81 //--------------------------------------------------------------------
82 for (Int_t i=0; i<5; i++) {
83 (fModules[i])->Delete();
88 //____________________________________________________________________________
89 Int_t AliPHOSTracker::LoadClusters(TTree *cTree) {
90 //--------------------------------------------------------------------
91 // This function loads the PHOS clusters
92 //--------------------------------------------------------------------
94 TBranch *branch=cTree->GetBranch("PHOSEmcRP");
96 AliError("No branch with the EMC clusters found !");
99 branch->SetAddress(&arr);
102 Int_t nentr=(Int_t)branch->GetEntries();
103 for (Int_t i=0; i<nentr; i++) {
104 if (!branch->GetEvent(i)) continue;
105 Int_t ncl=arr->GetEntriesFast();
107 AliPHOSEmcRecPoint *cl=(AliPHOSEmcRecPoint*)arr->UncheckedAt(ncl);
109 Int_t m=cl->GetPHOSMod();
111 AliError("Wrong module index !");
115 // Here is how the alignment is treated
116 if (!cl->Misalign()) AliWarning("Can't misalign this cluster !");
118 cl->SetBit(14,kFALSE); // The clusters are not yet attached to any track
120 TClonesArray &module=*fModules[m-1];
121 Int_t idx=module.GetEntriesFast();
122 new (module[idx]) AliPHOSEmcRecPoint(*cl);
129 Info("LoadClusters","Number of loaded clusters: %d",nclusters);
134 //____________________________________________________________________________
135 Int_t AliPHOSTracker::PropagateBack(AliESDEvent *esd) {
136 //--------------------------------------------------------------------
137 // Called by AliReconstruction
138 // Performs the track matching with the PHOS modules
140 //--------------------------------------------------------------------
142 Int_t nt=esd->GetNumberOfTracks();
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();
151 TMath::Sort(nt,quality,index,kFALSE);
154 // *** Start the matching
157 for (Int_t i=0; i<nt; i++) {
158 AliESDtrack *esdTrack=esd->GetTrack(index[i]);
160 // Skip the tracks having "wrong" status (has to be checked/tuned)
161 ULong_t status = esdTrack->GetStatus();
162 if ((status & AliESDtrack::kTRDout) == 0) continue;
163 if ((status & AliESDtrack::kTRDrefit) == 1) continue;
165 AliExternalTrackParam t(*esdTrack);
167 Int_t isec=Int_t(t.GetAlpha()/kAlpha);
168 Int_t imod=-isec-2; // PHOS module
170 Double_t y; // Some tracks do not reach the PHOS
171 if (!t.GetYAt(kR,bz,y)) continue; // because of the bending
173 Double_t z; t.GetZAt(kR,bz,z);
174 if (TMath::Abs(z) > kZmax) continue; // Some tracks miss the PHOS in Z
177 while (TMath::Abs(y) > kYmax) { // Find the matching module
178 Double_t alp=t.GetAlpha();
180 if (!t.Rotate(alp+kAlpha)) {ok=kFALSE; break;}
182 } else if (y < -kYmax) {
183 if (!t.Rotate(alp-kAlpha)) {ok=kFALSE; break;}
186 if (!t.GetYAt(kR,bz,y)) {ok=kFALSE; break;}
188 if (!ok) continue; // Track rotation failed
191 if ((imod<0)||(imod>4)) continue; // Some tracks miss the PHOS in azimuth
193 //t.CorrectForMaterial(...); // Correct for the TOF material, if needed
194 t.PropagateTo(kR,bz); // Propagate to the matching module
197 // *** Search for the "best" cluster (can be improved)
198 TClonesArray &cArray=*fModules[imod];
199 Int_t ncl=cArray.GetEntriesFast();
200 AliPHOSEmcRecPoint *bestCluster=0; // The "best" cluster
201 Double_t maxd2=400; // (cm^2)
202 for (Int_t i=0; i<ncl; i++) {
203 AliPHOSEmcRecPoint *c=(AliPHOSEmcRecPoint *)cArray.UncheckedAt(i);
205 if (c->TestBit(14)) continue; // This clusters is "used"
207 Double_t dy = t.GetY() - c->GetY(), dz = t.GetZ() - c->GetZ();
208 Double_t d2 = dy*dy + dz*dz;
215 if (!bestCluster) continue; // No reasonable matching found
217 bestCluster->SetBit(14,kTRUE); // This clusters is now attached to a track
221 // *** Now, do the PID with the "bestCluster"
222 // and add the corresponding info to the ESD track pointed by "esdTrack"
225 printf("%e %e %e %e\n",t.GetSign(), t.GetX() - bestCluster->GetX(),
226 t.GetY() - bestCluster->GetY(),
227 t.GetZ() - bestCluster->GetZ());
231 Info("PropagateBack","Number of matched tracks: %d",matched);
239 //____________________________________________________________________________
240 AliCluster *AliPHOSTracker::GetCluster(Int_t index) const {
241 //--------------------------------------------------------------------
242 // Returns the pointer to a given cluster
243 //--------------------------------------------------------------------
244 Int_t m=(index & 0xf0000000) >> 28; // Module number
245 Int_t i=(index & 0x0fffffff) >> 00; // Index within the module
247 return (AliCluster*)(fModules[m])->UncheckedAt(i);
250 //____________________________________________________________________________
251 void AliPHOSTracker::UnloadClusters() {
252 //--------------------------------------------------------------------
253 // This function unloads the PHOS clusters
254 //--------------------------------------------------------------------
255 for (Int_t i=0; i<5; i++) (fModules[i])->Delete();