Reducing the memory size needed for raw data reconstruction
[u/mrichter/AliRoot.git] / TRD / AliTRDReconstructor.cxx
CommitLineData
121a60bd 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 TRD reconstruction //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
e3b2b5e5 24#include <TFile.h>
121a60bd 25
26#include "AliTRDReconstructor.h"
27#include "AliRunLoader.h"
121a60bd 28#include "AliTRDclusterizerV1.h"
29#include "AliTRDtracker.h"
b0f03c34 30#include "AliTRDpidESD.h"
6965c99b 31#include "AliRawReader.h"
928e9fae 32#include "AliLog.h"
0ee00e25 33#include "AliTRDtrigger.h"
34#include "AliTRDtrigParam.h"
e3b2b5e5 35#include "AliTRDgtuTrack.h"
0ee00e25 36#include "AliRun.h"
37#include "AliESDTrdTrack.h"
38#include "AliESD.h"
121a60bd 39
40ClassImp(AliTRDReconstructor)
41
0397ce53 42Bool_t AliTRDReconstructor::fgkSeedingOn = kFALSE;
d337ef8d 43Int_t AliTRDReconstructor::fgStreamLevel = 0; // stream (debug) level
0397ce53 44
121a60bd 45//_____________________________________________________________________________
46void AliTRDReconstructor::Reconstruct(AliRunLoader* runLoader) const
47{
48// reconstruct clusters
49
2b217b01 50 AliLoader *loader=runLoader->GetLoader("TRDLoader");
51 loader->LoadRecPoints("recreate");
52
121a60bd 53 runLoader->CdGAFile();
121a60bd 54 Int_t nEvents = runLoader->GetNumberOfEvents();
55
56 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
4ab68796 57 AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer");
121a60bd 58 clusterer.Open(runLoader->GetFileName(), iEvent);
59 clusterer.ReadDigits();
60 clusterer.MakeClusters();
61 clusterer.WriteClusters(-1);
62 }
1a39153b 63
64 loader->UnloadRecPoints();
0ee00e25 65
66 // Trigger (tracklets, LTU)
67
b44e4c72 68 loader->LoadTracks("RECREATE");
69
e3b2b5e5 70 Info("Reconstruct","Trigger tracklets will be produced");
71
0ee00e25 72 AliTRDtrigger trdTrigger("Trigger","Trigger class");
73
74 AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters");
75
76 if (runLoader->GetAliRun() == 0x0) runLoader->LoadgAlice();
77 gAlice = runLoader->GetAliRun();
78 Double_t x[3] = { 0.0, 0.0, 0.0 };
79 Double_t b[3];
80 gAlice->Field(x,b); // b[] is in kilo Gauss
81 Float_t field = b[2] * 0.1; // Tesla
82 Info("Reconstruct","Trigger set for magnetic field = %f Tesla \n",field);
83
84 trigp->SetField(field);
85 trigp->Init();
86 trdTrigger.SetParameter(trigp);
87
88 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
89 trdTrigger.Open(runLoader->GetFileName(), iEvent);
90 trdTrigger.ReadDigits();
91 trdTrigger.MakeTracklets();
92 trdTrigger.WriteTracklets(-1);
93 }
94
95 loader->UnloadTracks();
96
121a60bd 97}
98
99//_____________________________________________________________________________
928e9fae 100void AliTRDReconstructor::Reconstruct(AliRunLoader* runLoader,
101 AliRawReader* rawReader) const
102{
103// reconstruct clusters
104
105 AliInfo("Reconstruct TRD clusters from RAW data");
106
107 AliLoader *loader=runLoader->GetLoader("TRDLoader");
108 loader->LoadRecPoints("recreate");
109
928e9fae 110 runLoader->CdGAFile();
928e9fae 111 Int_t nEvents = runLoader->GetNumberOfEvents();
112
113 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
114 if (!rawReader->NextEvent()) break;
4ab68796 115 AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer");
928e9fae 116 clusterer.Open(runLoader->GetFileName(), iEvent);
117 clusterer.ReadDigits(rawReader);
118 clusterer.MakeClusters();
119 clusterer.WriteClusters(-1);
120 }
121
122 loader->UnloadRecPoints();
0ee00e25 123
124 // Trigger (tracklets, LTU)
125
e3b2b5e5 126 loader->LoadTracks();
127 if (loader->TreeT()) {
128 Info("Reconstruct","Tracklets already exist");
129 return;
130 }
131 Info("Reconstruct","Trigger tracklets will be produced");
132
0ee00e25 133 AliTRDtrigger trdTrigger("Trigger","Trigger class");
134
135 AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters");
136
137 if (runLoader->GetAliRun() == 0x0) runLoader->LoadgAlice();
138 gAlice = runLoader->GetAliRun();
139 Double_t x[3] = { 0.0, 0.0, 0.0 };
140 Double_t b[3];
141 gAlice->Field(x,b); // b[] is in kilo Gauss
142 Float_t field = b[2] * 0.1; // Tesla
143 Info("Reconstruct","Trigger set for magnetic field = %f Tesla \n",field);
144
145 trigp->SetField(field);
146 trigp->Init();
147 trdTrigger.SetParameter(trigp);
148
d202144c 149 rawReader->RewindEvents();
150
0ee00e25 151 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
d202144c 152 if (!rawReader->NextEvent()) break;
0ee00e25 153 trdTrigger.Open(runLoader->GetFileName(), iEvent);
154 trdTrigger.ReadDigits(rawReader);
155 trdTrigger.MakeTracklets();
156 trdTrigger.WriteTracklets(-1);
157 }
158
159 loader->UnloadTracks();
160
928e9fae 161}
162
163//_____________________________________________________________________________
121a60bd 164AliTracker* AliTRDReconstructor::CreateTracker(AliRunLoader* runLoader) const
165{
166// create a TRD tracker
167
168 runLoader->CdGAFile();
169 return new AliTRDtracker(gFile);
170}
171
172//_____________________________________________________________________________
0ee00e25 173void AliTRDReconstructor::FillESD(AliRunLoader* runLoader,
b0f03c34 174 AliESD* esd) const
121a60bd 175{
b0f03c34 176// make PID
177
178 Double_t parTRD[] = {
eab5961e 179 280., // Min. Ionizing Particle signal. Check it !!!
b0f03c34 180 0.23, // relative resolution Check it !!!
181 10. // PID range (in sigmas)
182 };
183 AliTRDpidESD trdPID(parTRD);
184 trdPID.MakePID(esd);
0ee00e25 185
186 // Trigger (tracks, GTU)
187
188 AliTRDtrigger trdTrigger("Trigger","Trigger class");
189
190 AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam","TRD Trigger parameters");
191
192 if (runLoader->GetAliRun() == 0x0) runLoader->LoadgAlice();
193 gAlice = runLoader->GetAliRun();
194 Double_t x[3] = { 0.0, 0.0, 0.0 };
195 Double_t b[3];
196 gAlice->Field(x,b); // b[] is in kilo Gauss
197 Float_t field = b[2] * 0.1; // Tesla
198 Info("FillESD","Trigger set for magnetic field = %f Tesla \n",field);
199
200 trigp->SetField(field);
201 trigp->Init();
202
203 trdTrigger.SetParameter(trigp);
204 trdTrigger.SetRunLoader(runLoader);
205 trdTrigger.Init();
206
207 Int_t iEvent = runLoader->GetEventNumber();
208 runLoader->GetEvent(iEvent);
209 trdTrigger.ReadTracklets(runLoader);
210
211 AliESDTrdTrack *TrdTrack = new AliESDTrdTrack();
212 AliTRDgtuTrack *GtuTrack;
213
214 Int_t nTracks = trdTrigger.GetNumberOfTracks();
215 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
216
217 GtuTrack = trdTrigger.GetTrack(iTrack);
218
219 TrdTrack->SetYproj(GtuTrack->GetYproj());
220 TrdTrack->SetZproj(GtuTrack->GetZproj());
221 TrdTrack->SetSlope(GtuTrack->GetSlope());
222 TrdTrack->SetDetector(GtuTrack->GetDetector());
223 TrdTrack->SetTracklets(GtuTrack->GetTracklets());
224 TrdTrack->SetPlanes(GtuTrack->GetPlanes());
225 TrdTrack->SetClusters(GtuTrack->GetClusters());
226 TrdTrack->SetPt(GtuTrack->GetPt());
227 TrdTrack->SetPhi(GtuTrack->GetPhi());
228 TrdTrack->SetEta(GtuTrack->GetEta());
229 TrdTrack->SetLabel(GtuTrack->GetLabel());
230 TrdTrack->SetPID(GtuTrack->GetPID());
4c8471bd 231 TrdTrack->SetIsElectron(GtuTrack->IsElectron());
0ee00e25 232
233 esd->AddTrdTrack(TrdTrack);
234
235 }
236
121a60bd 237}
238
239
121a60bd 240