MUON reconstruction with pluggins and cleaning-up AliMUON (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
CommitLineData
cac2eb58 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// //
20// class for MUON reconstruction //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24#include "AliRunLoader.h"
25#include "AliRun.h"
26#include "AliESD.h"
27#include "AliMUONData.h"
28#include "AliMUONEventReconstructor.h"
29#include "AliMUONClusterReconstructor.h"
30#include "AliMUONTriggerDecision.h"
31#include "AliMUONClusterFinderVS.h"
32#include "AliMUONTrack.h"
33#include "AliMUONTrackParam.h"
34#include "AliMUONTriggerTrack.h"
35#include "AliESDMuonTrack.h"
36#include "AliMUONReconstructor.h"
37
38ClassImp(AliMUONReconstructor)
39//_____________________________________________________________________________
40AliMUONReconstructor::AliMUONReconstructor()
41{
42}
43//_____________________________________________________________________________
44void AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader) const
45{
46// AliLoader
47 AliLoader* loader = runLoader->GetLoader("MUONLoader");
48 Int_t nEvents = runLoader->GetNumberOfEvents();
49
50// used local container for each method
51// passing fLoader as argument, could be avoided ???
52 AliMUONEventReconstructor* recoEvent = new AliMUONEventReconstructor(loader);
53 AliMUONData* dataEvent = recoEvent->GetMUONData();
54
55 AliMUONClusterReconstructor* recoCluster = new AliMUONClusterReconstructor(loader);
56 AliMUONData* dataCluster = recoCluster->GetMUONData();
57
58 AliMUONTriggerDecision* trigDec = new AliMUONTriggerDecision(loader);
59 AliMUONData* dataTrig = trigDec->GetMUONData();
60
61
62 for (Int_t i = 0; i < 10; i++) {
63 AliMUONClusterFinderVS *RecModel = new AliMUONClusterFinderVS();
64 RecModel->SetGhostChi2Cut(10);
65 recoCluster->SetReconstructionModel(i,RecModel);
66 }
67
68 loader->LoadDigits("READ");
69 loader->LoadRecPoints("RECREATE");
70 loader->LoadTracks("RECREATE");
71
72 // Loop over events
73 for(Int_t ievent = 0; ievent < nEvents; ievent++) {
74 printf("Event %d\n",ievent);
75 runLoader->GetEvent(ievent);
76
77 //----------------------- digit2cluster & Digits2Trigger -------------------
78 if (!loader->TreeR()) loader->MakeRecPointsContainer();
79
80 // tracking branch
81 dataCluster->MakeBranch("RC");
82 dataCluster->SetTreeAddress("D,RC");
83 recoCluster->Digits2Clusters();
84 dataCluster->Fill("RC");
85
86 // trigger branch
87 dataTrig->MakeBranch("GLT");
88 dataTrig->SetTreeAddress("D,GLT");
89 trigDec->Digits2Trigger();
90 dataTrig->Fill("GLT");
91
92 loader->WriteRecPoints("OVERWRITE");
93
94 //---------------------------- Track & TriggerTrack ---------------------
95 if (!loader->TreeT()) loader->MakeTracksContainer();
96
97 // trigger branch
98 dataEvent->MakeBranch("RL"); //trigger track
99 dataEvent->SetTreeAddress("RL");
100 recoEvent->EventReconstructTrigger();
101 dataEvent->Fill("RL");
102
103 // tracking branch
104 dataEvent->MakeBranch("RT"); //track
105 dataEvent->SetTreeAddress("RT");
106 recoEvent->EventReconstruct();
107 dataEvent->Fill("RT");
108
109 loader->WriteTracks("OVERWRITE");
110
111 //--------------------------- Resetting branches -----------------------
112 dataCluster->ResetDigits();
113 dataCluster->ResetRawClusters();
114
115 dataTrig->ResetDigits();
116 dataTrig->ResetTrigger();
117
118 dataEvent->ResetRawClusters();
119 dataEvent->ResetTrigger();
120 dataEvent->ResetRecTracks();
121 dataEvent->ResetRecTriggerTracks();
122
123 }
124 loader->UnloadDigits();
125 loader->UnloadRecPoints();
126 loader->UnloadTracks();
127
128 delete recoCluster;
129 delete recoEvent;
130 delete trigDec;
131}
132//_____________________________________________________________________________
133void AliMUONReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
134{
135 TClonesArray* recTracksArray = 0;
136 TClonesArray* recTrigTracksArray = 0;
137
138 AliLoader* loader = runLoader->GetLoader("MUONLoader");
139 loader->LoadTracks("READ");
140
141 AliMUONData* muonData = new AliMUONData(loader,"MUON","MUON");
142
143 // declaration
144 Int_t iEvent;
145 Int_t nTrackHits;
146 Double_t fitFmin;
147
148
149 Double_t bendingSlope, nonBendingSlope, inverseBendingMomentum;
150 Double_t xRec, yRec, zRec, chi2MatchTrigger;
151 Bool_t matchTrigger;
152
153 // setting pointer for tracks, triggertracks& trackparam at vertex
154 AliMUONTrack* recTrack = 0;
155 AliMUONTrackParam* trackParam = 0;
156 AliMUONTriggerTrack* recTriggerTrack = 0;
157
158 iEvent = runLoader->GetEventNumber();
159 runLoader->GetEvent(iEvent);
160
161 // setting ESD MUON class
162 AliESDMuonTrack* ESDTrack = new AliESDMuonTrack() ;
163
164 //-------------------- trigger tracks-------------
165 Long_t trigPat = 0;
166 muonData->SetTreeAddress("RL");
167 muonData->GetRecTriggerTracks();
168 recTrigTracksArray = muonData->RecTriggerTracks();
169
170 // ready global trigger pattern from first track
171 if (recTrigTracksArray)
172 recTriggerTrack = (AliMUONTriggerTrack*) recTrigTracksArray->First();
173 if (recTriggerTrack) trigPat = recTriggerTrack->GetGTPattern();
174
175 //printf(">>> Event %d Number of Recconstructed tracks %d \n",iEvent, nrectracks);
176
177 // -------------------- tracks-------------
178 muonData->SetTreeAddress("RT");
179 muonData->GetRecTracks();
180 recTracksArray = muonData->RecTracks();
181
182 Int_t nRecTracks = 0;
183 if (recTracksArray)
184 nRecTracks = (Int_t) recTracksArray->GetEntriesFast(); //
185
186 // loop over tracks
187 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
188
189 // reading info from tracks
190 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
191
192 trackParam = recTrack->GetTrackParamAtVertex();
193
194 bendingSlope = trackParam->GetBendingSlope();
195 nonBendingSlope = trackParam->GetNonBendingSlope();
196 inverseBendingMomentum = trackParam->GetInverseBendingMomentum();
197 xRec = trackParam->GetNonBendingCoor();
198 yRec = trackParam->GetBendingCoor();
199 zRec = trackParam->GetZ();
200
201 nTrackHits = recTrack->GetNTrackHits();
202 fitFmin = recTrack->GetFitFMin();
203 matchTrigger = recTrack->GetMatchTrigger();
204 chi2MatchTrigger = recTrack->GetChi2MatchTrigger();
205
206 // setting data member of ESD MUON
207 ESDTrack->SetInverseBendingMomentum(inverseBendingMomentum);
208 ESDTrack->SetThetaX(TMath::ATan(nonBendingSlope));
209 ESDTrack->SetThetaY(TMath::ATan(bendingSlope));
210 ESDTrack->SetZ(zRec);
211 ESDTrack->SetBendingCoor(yRec);
212 ESDTrack->SetNonBendingCoor(xRec);
213 ESDTrack->SetChi2(fitFmin);
214 ESDTrack->SetNHit(nTrackHits);
215 ESDTrack->SetMatchTrigger(matchTrigger);
216 ESDTrack->SetChi2MatchTrigger(chi2MatchTrigger);
217
218 // storing ESD MUON Track into ESD Event
219 if (nRecTracks != 0)
220 esd->AddMuonTrack(ESDTrack);
221 } // end loop tracks
222
223 // add global trigger pattern
224 if (nRecTracks != 0)
225 esd->SetTrigger(trigPat);
226
227 // reset muondata
228 muonData->ResetRecTracks();
229 muonData->ResetRecTriggerTracks();
230
231 //} // end loop on event
232 loader->UnloadTracks();
233 delete ESDTrack;
234 delete muonData;
235}