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