Commit message
[u/mrichter/AliRoot.git] / STEER / AliESDMuonTest.C
CommitLineData
5ec1b3bc 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
16/* $Id$ */
17
18//
19// Macro for checking aliroot output and associated files contents
20// Gines Martinez, Subatech June 2003
21//
22
23// ROOT includes
24#include "TBranch.h"
25#include "TClonesArray.h"
26#include "TFile.h"
27#include "TH1.h"
28#include "TParticle.h"
29#include "TTree.h"
30
31// STEER includes
32#include "AliRun.h"
33#include "AliRunLoader.h"
34#include "AliHeader.h"
35#include "AliLoader.h"
36#include "AliStack.h"
86ad5fcb 37#include "AliESDEvent.h"
5ec1b3bc 38
39// MUON includes
40#include "AliMUON.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"
47
48
49void AliESDMuonTest(char * filename="galice.root", Int_t run=0){
50
8252d536 51 TClonesArray* recTracksArray;
52 TClonesArray* recTrigTracksArray;
53 TTree* treeE;
5ec1b3bc 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);
58 return;
59 }
60
61 // creating ESD file
62 TFile *ef=TFile::Open("AliESD.Muon.root","RECREATE");
63 if (!ef->IsOpen()) cerr<<"Can't open AliESD.root file!\n";
64
8252d536 65 treeE = new TTree("ESD", "ESD");
66
67 AliLoader* MUONLoader = RunLoader->GetLoader("MUONLoader");
5ec1b3bc 68 MUONLoader->LoadTracks("READ");
69
70 // Creating MUON data container
71 AliMUONData muondata(MUONLoader,"MUON","MUON");
72
73 // declaration
74 Int_t ievent, nevents;
75 Int_t ntrackhits;
76 Double_t fitfmin;
77 Int_t nrectracks;
78
79 Double_t bendingSlope, nonBendingSlope, fInverseBendingMomentum;
8252d536 80 Double_t fXRec, fYRec, fZRec, chi2MatchTrigger;
81 Bool_t matchTrigger;
5ec1b3bc 82
83 nevents = RunLoader->GetNumberOfEvents();
8252d536 84
5ec1b3bc 85 // setting pointer for tracks, triggertracks& trackparam at vertex
8252d536 86 AliMUONTrack* rectrack;
87 AliMUONTriggerTrack* rectriggertrack;
88 AliMUONTrackParam* trackParam;
5ec1b3bc 89
90 for (ievent = 0; ievent < nevents; ievent++) {
5ec1b3bc 91
8252d536 92 RunLoader->GetEvent(ievent);
5ec1b3bc 93
94 // setting ESD class pointer
86ad5fcb 95 AliESDEvent* event = new AliESDEvent();
96 event->CreateStdContent();
8252d536 97 char name[255];
86ad5fcb 98 event->WriteToTree(treeE);
8252d536 99
5ec1b3bc 100 event->SetRunNumber(run);
101 event->SetEventNumber(ievent);
102
5ec1b3bc 103 // setting ESD MUON class
104 AliESDMuonTrack* ESDTrack = new AliESDMuonTrack() ;
8252d536 105
106 // ---------------- tracks ----------------
5ec1b3bc 107 muondata.SetTreeAddress("RT");
108 muondata.GetRecTracks();
109 recTracksArray = muondata.RecTracks();
8252d536 110 nrectracks = (Int_t) recTracksArray->GetEntriesFast();
5ec1b3bc 111
8252d536 112// --------------- trigger tracks ----------
113 Long_t trigPat = 0;
5ec1b3bc 114
5ec1b3bc 115 muondata.SetTreeAddress("RL");
116 muondata.GetRecTriggerTracks();
8252d536 117 recTrigTracksArray = muondata.RecTriggerTracks();
118 rectriggertrack = (AliMUONTriggerTrack*) recTrigTracksArray->First();
119 trigPat = rectriggertrack->GetGTPattern();
120
5ec1b3bc 121 printf(">>> Event %d Number of Recconstructed tracks %d \n",ievent, nrectracks);
8252d536 122
5ec1b3bc 123 for (Int_t irectracks = 0; irectracks < nrectracks; irectracks++) {
124
8252d536 125 // ---------------- tracks ----------------
126 rectrack = (AliMUONTrack*) recTracksArray->At(irectracks);
127 trackParam = rectrack->GetTrackParamAtVertex();
128
129 bendingSlope = trackParam->GetBendingSlope();
130 nonBendingSlope = trackParam->GetNonBendingSlope();
131 // printf(" SlopeX %f SlopeY %f\n",bendingSlope ,nonBendingSlope);
132
133 fInverseBendingMomentum = trackParam->GetInverseBendingMomentum();
134 fXRec = trackParam->GetNonBendingCoor();
135 fYRec = trackParam->GetBendingCoor();
136 // printf(" X %f Y %f\n", fXRec, fYRec);
137
138 fZRec = trackParam->GetZ();
139 // printf(" Z %f\n", fZRec);
140
141 ntrackhits = rectrack->GetNTrackHits();
142 fitfmin = rectrack->GetFitFMin();
143 matchTrigger = rectrack->GetMatchTrigger();
144 chi2MatchTrigger = rectrack->GetChi2MatchTrigger();
145
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);
157
158 // storing ESD MUON Track into ESD Event & reset muondata
159 event->AddMuonTrack(ESDTrack);
160 }// track loop
161
162 event->SetTrigger(trigPat);
5ec1b3bc 163
8252d536 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;
168 }
8252d536 169 treeE->Fill();
86ad5fcb 170 event->Reset();
8252d536 171
5ec1b3bc 172 muondata.ResetRecTracks();
173 muondata.ResetRecTriggerTracks();
174
86ad5fcb 175 } // end loop on event
176 treeE->GetUserInfo()->Add(event);
8252d536 177 ef->Write();
5ec1b3bc 178 ef->Close();
179 MUONLoader->UnloadTracks();
86ad5fcb 180 delete event;
5ec1b3bc 181
182}
183
184
185
186
187
188
189
190
191
192