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 **************************************************************************/
19 /// \file MUONRecoCheck.C
20 /// \brief Utility macro to check the muon reconstruction.
22 /// Reconstructed tracks are compared to reference tracks. The reference tracks
23 /// are built from AliTrackReference for the hit in chamber (0..9) and from
24 /// kinematics (TreeK) for the vertex parameters.
26 /// \author Jean-Pierre Cussonneau, Subatech
29 #include "TClonesArray.h"
32 #include <TGeoManager.h>
36 #include "AliHeader.h"
40 #include "AliTracker.h"
43 #include "AliMUONConstants.h"
44 #include "AliMUONTrack.h"
45 #include "AliMUONRecoCheck.h"
46 #include "AliMUONTrackParam.h"
47 #include "AliMUONTrackExtrap.h"
48 #include "AliMUONVTrackStore.h"
50 Int_t TrackCheck( Bool_t *compTrack);
52 void MUONRecoCheck (Int_t nEvent = -1, char* geoFilename = "geometry.root",
53 char * pathSim="./generated/", char * esdFileName="AliESDs.root")
57 Bool_t compTrackOK[10];
61 AliMUONTrack* trackOK(0x0);
63 Double_t sigmaCut = 4.; // 4 sigmas cut
64 Double_t maxChi2 = 999.;
65 AliMUONTrackParam *trackParam;
66 Double_t x1,y1,z1,pX1,pY1,pZ1,p1;
67 Double_t x2,y2,z2,pX2,pY2,pZ2,p2;
69 // File for histograms and histogram booking
70 TFile *histoFile = new TFile("MUONRecoCheck.root", "RECREATE");
72 TH1F *hReconstructible = new TH1F("hReconstructible"," Nb of reconstructible tracks ",15,-0.5,14.5);
73 TH1F *hReco = new TH1F("hReco"," Nb of reconstructed tracks / evt",15,-0.5,14.5);
74 TH1F *hNClusterComp = new TH1F("hNClusterComp"," Nb of compatible clusters / track ",15,-0.5,14.5);
75 TH1F *hTestTrack = new TH1F("hTestTrack"," Reconstruction requirement / track",15,-0.5,14.5);
76 TH1F *hTrackRefID = new TH1F("hTrackRefID"," track reference ID ",100,-0.5,99.5);
78 TH1F *hResMomVertex = new TH1F("hResMomVertex"," delta P vertex (GeV/c)",100,-10.,10);
79 TH1F *hResMomFirstCluster = new TH1F("hResMomFirstCluster"," delta P first cluster (GeV/c)",100,-10.,10);
81 // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
83 TGeoManager::Import(geoFilename);
85 Error("MUONmass_ESD", "getting geometry from file %s failed", geoFilename);
91 // waiting for mag field in CDB
92 if (!TGeoGlobalMagField::Instance()->GetField()) {
93 printf("Loading field map...\n");
94 AliMagF* field = new AliMagF("Maps","Maps",2,1.,1., 10.,AliMagF::k5kG);
95 TGeoGlobalMagField::Instance()->SetField(field);
97 // set the magnetic field for track extrapolations
98 AliMUONTrackExtrap::SetField();
100 AliMUONRecoCheck rc(esdFileName, pathSim);
102 Int_t nevents = rc.NumberOfEvents();
104 if (nevents < nEvent || nEvent < 0) nEvent = nevents;
107 Int_t nReconstructibleTracks = 0;
108 Int_t nReconstructedTracks = 0;
109 Int_t nReconstructibleTracksCheck = 0;
111 for (ievent=0; ievent<nEvent; ievent++)
113 if (!(ievent%10)) printf(" **** event # %d \n",ievent);
115 AliMUONVTrackStore* trackStore = rc.ReconstructedTracks(ievent);
116 AliMUONVTrackStore* trackRefStore = rc.ReconstructibleTracks(ievent);
118 hReconstructible->Fill(trackRefStore->GetSize());
119 hReco->Fill(trackStore->GetSize());
121 nReconstructibleTracks += trackRefStore->GetSize();
122 nReconstructedTracks += trackStore->GetSize();
124 TIter next(trackRefStore->CreateIterator());
125 AliMUONTrack* trackRef;
127 while ( ( trackRef = static_cast<AliMUONTrack*>(next()) ) )
132 for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++)
134 compTrackOK[ch] = kFALSE;
137 TIter next2(trackStore->CreateIterator());
138 AliMUONTrack* trackReco;
140 while ( ( trackReco = static_cast<AliMUONTrack*>(next2()) ) )
142 // check if trackRef is compatible with trackReco
143 if (trackReco->GetNClusters() > 1) {
145 // check cluster by cluster if trackReco contain info at each cluster
146 trackRef->CompatibleTrack(trackReco,sigmaCut,compTrack);
148 iTrack = TrackCheck(compTrack);
150 if (iTrack > testTrack)
153 for (Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++)
155 if (compTrack[ch]) nClusterOk++;
156 compTrackOK[ch] = compTrack[ch];
164 // check only parameters at the z position of the first trackRef
165 AliMUONTrackParam *refParam = (AliMUONTrackParam*) trackRef->GetTrackParamAtCluster()->First();
166 AliMUONTrackParam recoParam(*((AliMUONTrackParam*) trackReco->GetTrackParamAtCluster()->First()));
168 if (AliMUONTrackExtrap::ExtrapToZCov(&recoParam, refParam->GetZ()) &&
169 refParam->CompatibleTrackParam(recoParam, sigmaCut, chi2) && chi2 < maxChi2)
179 hTestTrack->Fill(testTrack);
180 trackID = trackRef->GetMCLabel();
181 hTrackRefID->Fill(trackID);
183 if (testTrack == 4 || maxChi2 < 5.*sigmaCut*sigmaCut) { // tracking requirements verified, track is found
184 nReconstructibleTracksCheck++;
185 hNClusterComp->Fill(nClusterOk);
186 trackParam = trackRef->GetTrackParamAtVertex();
187 x1 = trackParam->GetNonBendingCoor();
188 y1 = trackParam->GetBendingCoor();
189 z1 = trackParam->GetZ();
190 pX1 = trackParam->Px();
191 pY1 = trackParam->Py();
192 pZ1 = trackParam->Pz();
193 p1 = trackParam->P();
195 // printf(" Ref. track at vertex: x,y,z: %f %f %f px,py,pz,p: %f %f %f %f \n",x1,y1,z1,pX1,pY1,pZ1,p1);
197 trackParam = new AliMUONTrackParam(*((AliMUONTrackParam*)(trackReco->GetTrackParamAtVertex())));
198 x2 = trackParam->GetNonBendingCoor();
199 y2 = trackParam->GetBendingCoor();
200 z2 = trackParam->GetZ();
201 pX2 = trackParam->Px();
202 pY2 = trackParam->Py();
203 pZ2 = trackParam->Pz();
204 p2 = trackParam->P();
206 // printf(" Reconst. track at vertex: x,y,z: %f %f %f px,py,pz: %f %f %f %f \n",x2,y2,z2,pX2,pY2,pZ2,p2);
208 hResMomVertex->Fill(p2-p1);
210 trackParam = (AliMUONTrackParam*) trackRef->GetTrackParamAtCluster()->First();
211 x1 = trackParam->GetNonBendingCoor();
212 y1 = trackParam->GetBendingCoor();
213 z1 = trackParam->GetZ();
214 pX1 = trackParam->Px();
215 pY1 = trackParam->Py();
216 pZ1 = trackParam->Pz();
217 p1 = trackParam->P();
218 // printf(" Ref. track at 1st cluster: x,y,z: %f %f %f px,py,pz: %f %f %f \n",x1,y1,z1,pX1,pY1,pZ1);
219 trackParam = (AliMUONTrackParam*) trackOK->GetTrackParamAtCluster()->First();
220 x2 = trackParam->GetNonBendingCoor();
221 y2 = trackParam->GetBendingCoor();
222 z2 = trackParam->GetZ();
223 pX2 = trackParam->Px();
224 pY2 = trackParam->Py();
225 pZ2 = trackParam->Pz();
226 p2 = trackParam->P();
227 // printf(" Reconst. track at 1st cluster: x,y,z: %f %f %f px,py,pz: %f %f %f \n",x2,y2,z2,pX2,pY2,pZ2);
229 hResMomFirstCluster->Fill(p2-p1);
232 } // end loop track ref.
234 } // end loop on event
236 printf(" nb of reconstructible tracks: %d \n", nReconstructibleTracks);
237 printf(" nb of reconstructed tracks: %d \n", nReconstructedTracks);
238 printf(" nb of reconstructible tracks which are reconstructed: %d \n", nReconstructibleTracksCheck);
245 Int_t TrackCheck( Bool_t *compTrack)
247 // Apply reconstruction requirements
248 // Return number of validated conditions
249 // If all the tests are verified then TrackCheck = 4 (good track)
251 Int_t nCompClustersInLastStations = 0;
253 // apply reconstruction requirements
254 if (compTrack[0] || compTrack[1]) iTrack++; // at least one compatible cluster in st. 0
255 if (compTrack[2] || compTrack[3]) iTrack++; // at least one compatible cluster in st. 1
256 if (compTrack[4] || compTrack[5]) iTrack++; // at least one compatible cluster in st. 2
257 for (Int_t ch = 6; ch < AliMUONConstants::NTrackingCh(); ch++) {
258 if (compTrack[ch]) nCompClustersInLastStations++;
260 if (nCompClustersInLastStations > 2) iTrack++; // at least 3 compatible clusters in st. 3 & 4