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 // Macro for checking aliroot output and associated files contents
20 // Gines Martinez, Subatech June 2003
25 #include "TClonesArray.h"
28 #include "TParticle.h"
33 #include "AliRunLoader.h"
34 #include "AliHeader.h"
35 #include "AliLoader.h"
37 #include "AliESDEvent.h"
41 #include "AliMUONData.h"
42 #include "AliMUONConstants.h"
43 #include "AliMUONRawCluster.h"
44 #include "AliMUONTrack.h"
45 #include "AliMUONTriggerTrack.h"
46 #include "AliESDMuonTrack.h"
49 void AliESDMuonTest(char * filename="galice.root", Int_t run=0){
51 TClonesArray* recTracksArray;
52 TClonesArray* recTrigTracksArray;
54 // Creating Run Loader and openning file containing Hits
55 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
56 if (RunLoader ==0x0) {
57 printf(">>> Error : Error Opening %s file \n",filename);
62 TFile *ef=TFile::Open("AliESD.Muon.root","RECREATE");
63 if (!ef->IsOpen()) cerr<<"Can't open AliESD.root file!\n";
65 treeE = new TTree("ESD", "ESD");
67 AliLoader* MUONLoader = RunLoader->GetLoader("MUONLoader");
68 MUONLoader->LoadTracks("READ");
70 // Creating MUON data container
71 AliMUONData muondata(MUONLoader,"MUON","MUON");
74 Int_t ievent, nevents;
79 Double_t bendingSlope, nonBendingSlope, fInverseBendingMomentum;
80 Double_t fXRec, fYRec, fZRec, chi2MatchTrigger;
83 nevents = RunLoader->GetNumberOfEvents();
85 // setting pointer for tracks, triggertracks& trackparam at vertex
86 AliMUONTrack* rectrack;
87 AliMUONTriggerTrack* rectriggertrack;
88 AliMUONTrackParam* trackParam;
90 for (ievent = 0; ievent < nevents; ievent++) {
92 RunLoader->GetEvent(ievent);
94 // setting ESD class pointer
95 AliESDEvent* event = new AliESDEvent();
96 event->CreateStdContent();
98 event->WriteToTree(treeE);
100 event->SetRunNumber(run);
101 event->SetEventNumber(ievent);
103 // setting ESD MUON class
104 AliESDMuonTrack* ESDTrack = new AliESDMuonTrack() ;
106 // ---------------- tracks ----------------
107 muondata.SetTreeAddress("RT");
108 muondata.GetRecTracks();
109 recTracksArray = muondata.RecTracks();
110 nrectracks = (Int_t) recTracksArray->GetEntriesFast();
112 // --------------- trigger tracks ----------
115 muondata.SetTreeAddress("RL");
116 muondata.GetRecTriggerTracks();
117 recTrigTracksArray = muondata.RecTriggerTracks();
118 rectriggertrack = (AliMUONTriggerTrack*) recTrigTracksArray->First();
119 trigPat = rectriggertrack->GetGTPattern();
121 printf(">>> Event %d Number of Recconstructed tracks %d \n",ievent, nrectracks);
123 for (Int_t irectracks = 0; irectracks < nrectracks; irectracks++) {
125 // ---------------- tracks ----------------
126 rectrack = (AliMUONTrack*) recTracksArray->At(irectracks);
127 trackParam = rectrack->GetTrackParamAtVertex();
129 bendingSlope = trackParam->GetBendingSlope();
130 nonBendingSlope = trackParam->GetNonBendingSlope();
131 // printf(" SlopeX %f SlopeY %f\n",bendingSlope ,nonBendingSlope);
133 fInverseBendingMomentum = trackParam->GetInverseBendingMomentum();
134 fXRec = trackParam->GetNonBendingCoor();
135 fYRec = trackParam->GetBendingCoor();
136 // printf(" X %f Y %f\n", fXRec, fYRec);
138 fZRec = trackParam->GetZ();
139 // printf(" Z %f\n", fZRec);
141 ntrackhits = rectrack->GetNTrackHits();
142 fitfmin = rectrack->GetFitFMin();
143 matchTrigger = rectrack->GetMatchTrigger();
144 chi2MatchTrigger = rectrack->GetChi2MatchTrigger();
146 // setting data member of ESD MUON
147 ESDTrack->SetInverseBendingMomentum(fInverseBendingMomentum);
148 ESDTrack->SetThetaX(TMath::ATan(nonBendingSlope));
149 ESDTrack->SetThetaY(TMath::ATan(bendingSlope));
150 ESDTrack->SetZ(fZRec);
151 ESDTrack->SetBendingCoor(fYRec);
152 ESDTrack->SetNonBendingCoor(fXRec);
153 ESDTrack->SetChi2(fitfmin);
154 ESDTrack->SetNHit(ntrackhits);
155 ESDTrack->SetMatchTrigger(matchTrigger);
156 ESDTrack->SetChi2MatchTrigger(chi2MatchTrigger);
158 // storing ESD MUON Track into ESD Event & reset muondata
159 event->AddMuonTrack(ESDTrack);
162 event->SetTrigger(trigPat);
164 for (Int_t iTrack = 0; iTrack < event->GetNumberOfMuonTracks(); iTrack++) {
165 AliESDMuonTrack* muonTrack = event->GetMuonTrack(iTrack);
166 Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum());
167 cout << " ptInv: "<<ptInv <<" nb track: "<< event->GetNumberOfMuonTracks() << endl;
172 muondata.ResetRecTracks();
173 muondata.ResetRecTriggerTracks();
175 } // end loop on event
176 treeE->GetUserInfo()->Add(event);
179 MUONLoader->UnloadTracks();