Obsolete TRD trigger code. It will be moved to the TRD simulation
[u/mrichter/AliRoot.git] / TRD / AliTRDReconstructor.cxx
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
24 #include <TFile.h>
25
26 #include "AliRunLoader.h"
27 #include "AliRawReader.h"
28 #include "AliLog.h"
29 #include "AliESDTrdTrack.h"
30 #include "AliESD.h"
31
32 #include "AliTRDReconstructor.h"
33 #include "AliTRDclusterizerV1.h"
34 #include "AliTRDtracker.h"
35 #include "AliTRDpidESD.h"
36 #include "AliTRDtrigger.h"
37 #include "AliTRDtrigParam.h"
38 #include "AliTRDgtuTrack.h"
39
40 ClassImp(AliTRDReconstructor)
41
42 Bool_t AliTRDReconstructor::fgkSeedingOn  = kFALSE;
43 Int_t  AliTRDReconstructor::fgStreamLevel = 0;      // Stream (debug) level
44
45 //_____________________________________________________________________________
46 void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader) const
47 {
48   //
49   // Reconstruct clusters
50   //
51
52   AliLoader *loader = runLoader->GetLoader("TRDLoader");
53   loader->LoadRecPoints("recreate");
54
55   runLoader->CdGAFile();
56   Int_t nEvents = runLoader->GetNumberOfEvents();
57
58   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
59     AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer");
60     clusterer.Open(runLoader->GetFileName(),iEvent);
61     clusterer.ReadDigits();
62     clusterer.MakeClusters();
63     clusterer.WriteClusters(-1);
64   }
65
66   loader->UnloadRecPoints();
67
68   //
69   // Trigger (tracklets, LTU)
70   //
71   loader->LoadTracks("RECREATE");
72   AliInfo("Trigger tracklets will be produced");
73
74   AliTRDtrigger trdTrigger("Trigger","Trigger class"); 
75
76   AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam"
77                                               ,"TRD Trigger parameters");
78
79   Float_t field = AliTracker::GetBz() * 0.1; // Tesla
80   AliInfo(Form("Trigger set for magnetic field = %f Tesla \n",field));
81   trigp->SetField(field);
82   trigp->Init();
83   trdTrigger.SetParameter(trigp);
84
85   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
86     trdTrigger.Open(runLoader->GetFileName(),iEvent);
87     trdTrigger.ReadDigits();
88     trdTrigger.MakeTracklets();
89     trdTrigger.WriteTracklets(-1);
90   }
91
92   loader->UnloadTracks();
93
94 }
95
96 //_____________________________________________________________________________
97 void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader
98                                     , AliRawReader *rawReader) const
99 {
100   //
101   // Reconstruct clusters
102   //
103
104   AliInfo("Reconstruct TRD clusters from RAW data");
105
106   AliLoader *loader = runLoader->GetLoader("TRDLoader");
107   loader->LoadRecPoints("recreate");
108
109   runLoader->CdGAFile();
110   Int_t nEvents = runLoader->GetNumberOfEvents();
111
112   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
113     if (!rawReader->NextEvent()) break;
114     AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer");
115     clusterer.Open(runLoader->GetFileName(),iEvent);
116     clusterer.ReadDigits(rawReader);
117     clusterer.MakeClusters();
118     clusterer.WriteClusters(-1);
119   }
120
121   loader->UnloadRecPoints();
122
123   //
124   // Trigger (tracklets, LTU)
125   //
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();
155
156 }
157
158 //_____________________________________________________________________________
159 AliTracker *AliTRDReconstructor::CreateTracker(AliRunLoader *runLoader) const
160 {
161   //
162   // Create a TRD tracker
163   //
164
165   runLoader->CdGAFile();
166
167   return new AliTRDtracker(gFile);
168
169 }
170
171 //_____________________________________________________________________________
172 void AliTRDReconstructor::FillESD(AliRunLoader *runLoader
173                                 , AliESD *esd) const
174 {
175   //
176   // Make PID
177   //
178
179   AliTRDpidESD trdPID;
180   trdPID.MakePID(esd);
181
182   //
183   // Trigger (tracks, GTU)
184   //
185   AliTRDtrigger trdTrigger("Trigger","Trigger class"); 
186
187   AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam"
188                                               ,"TRD Trigger parameters");
189
190   Float_t field = AliTracker::GetBz() * 0.1; // Tesla
191   AliInfo(Form("Trigger set for magnetic field = %f Tesla \n",field));
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());
223     TrdTrack->SetIsElectron(GtuTrack->IsElectron());
224
225     esd->AddTrdTrack(TrdTrack);
226
227   }
228
229 }