3 ///////////////////////////////////////////////////////////////////////////////
5 // class for HLT reconstruction //
6 // <Cvetan.Cheshkov@cern.ch> //
7 // <loizides@ikf.uni-frankfurt.de> //
8 ///////////////////////////////////////////////////////////////////////////////
10 // very ugly but it has to work fast
11 #ifdef use_reconstruction
13 #include <Riostream.h>
17 #include <AliRunLoader.h>
18 #include <AliHeader.h>
19 #include <AliGenEventHeader.h>
21 #include <AliESDHLTtrack.h>
23 #include "AliL3StandardIncludes.h"
24 #include "AliL3Logging.h"
25 #include "AliLevel3.h"
26 #include "AliL3Evaluate.h"
27 #include "AliHLTReconstructor.h"
28 #include "AliL3Transform.h"
29 #include "AliL3Hough.h"
30 #include "AliL3FileHandler.h"
31 #include "AliL3Track.h"
32 #include "AliL3HoughTrack.h"
33 #include "AliL3TrackArray.h"
40 ClassImp(AliHLTReconstructor)
42 AliHLTReconstructor::AliHLTReconstructor(): AliReconstructor()
45 AliL3Log::fgLevel=AliL3Log::kWarning;
52 AliHLTReconstructor::AliHLTReconstructor(Bool_t doTracker, Bool_t doHough): AliReconstructor()
55 AliL3Log::fgLevel=AliL3Log::kWarning;
62 AliHLTReconstructor::~AliHLTReconstructor()
67 gSystem->Exec("rm -rf hlt");
68 sprintf(name, "rm -f confmap_*.root confmap_*.dat");
70 gSystem->Exec("rm -rf hough");
71 sprintf(name, "rm -f hough_*.root hough_*.dat");
76 void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader) const
78 // do the standard and hough reconstruction chain
80 LOG(AliL3Log::kFatal,"AliHLTReconstructor::Reconstruct","RunLoader")
81 <<" Missing RunLoader! 0x0"<<ENDLOG;
84 gSystem->Exec("rm -rf hlt");
85 gSystem->MakeDirectory("hlt");
86 gSystem->Exec("rm -rf hough");
87 gSystem->MakeDirectory("hough");
89 Bool_t isinit=AliL3Transform::Init(runLoader);
91 LOG(AliL3Log::kError,"AliHLTReconstructor::Reconstruct","Transformer")
92 << "Could not create transform settings, please check log for error messages!" << ENDLOG;
96 Int_t nEvents = runLoader->GetNumberOfEvents();
98 for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
99 runLoader->GetEvent(iEvent);
101 if(fDoTracker) ReconstructWithConformalMapping(runLoader,iEvent);
102 if(fDoHough) ReconstructWithHoughTransform(runLoader,iEvent);
106 void AliHLTReconstructor::ReconstructWithConformalMapping(AliRunLoader* runLoader,Int_t iEvent) const
108 // reconstruct with conformal mapper
109 AliLevel3 *fHLT = new AliLevel3(runLoader);
110 fHLT->Init("./", AliLevel3::kRunLoader, 1);
112 Int_t phiSegments = 50;
113 Int_t etaSegments = 100;
114 Int_t trackletlength = 3;
115 Int_t tracklength = 10;
116 Int_t rowscopetracklet = 2;
117 Int_t rowscopetrack = 10;
118 Double_t minPtFit = 0;
119 Double_t maxangle = 0.1745;
120 Double_t goodDist = 5;
121 Double_t maxphi = 0.1;
122 Double_t maxeta = 0.1;
123 Double_t hitChi2Cut = 20;
124 Double_t goodHitChi2 = 5;
125 Double_t trackChi2Cut = 10;
126 Double_t xyerror = -1;
127 Double_t zerror = -1;
129 fHLT->SetClusterFinderParam(xyerror,zerror,kTRUE);
130 fHLT->SetTrackerParam(phiSegments, etaSegments,
131 trackletlength, tracklength,
132 rowscopetracklet, rowscopetrack,
133 minPtFit, maxangle, goodDist, hitChi2Cut,
134 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE);
135 fHLT->SetTrackerParam(phiSegments, etaSegments,
136 trackletlength, tracklength,
137 rowscopetracklet, rowscopetrack,
138 minPtFit, maxangle, goodDist, hitChi2Cut,
139 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kFALSE);
140 fHLT->SetMergerParameters(2,3,0.003,0.1,0.05);
142 fHLT->DoNonVertexTracking(); /*2 tracking passes, last without vertex contraint.*/
143 fHLT->WriteFiles("./hlt/");
144 fHLT->ProcessEvent(0, 35, iEvent);
147 sprintf(filename, "confmap_%d",iEvent);
148 fHLT->DoBench(filename);
154 void AliHLTReconstructor::ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const
156 //reconstruct with hough
157 Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
161 AliHeader * header = runLoader->GetHeader();
163 AliGenEventHeader * genHeader = header->GenEventHeader();
164 if (genHeader) genHeader->PrimaryVertex(mcVertex);
166 zvertex = mcVertex[2];
168 LOG(AliL3Log::kInformational,"AliHLTReconstructor::Reconstruct","HoughTransform")
169 <<" Hough Transform will run with ptmin="<<ptmin<<" and zvertex="<<zvertex<<ENDLOG;
171 AliL3Hough *hough = new AliL3Hough();
173 hough->SetThreshold(4);
174 hough->SetTransformerParams(76,140,ptmin,-1);
175 hough->SetPeakThreshold(70,-1);
176 hough->SetRunLoader(runLoader);
177 hough->Init("./", kFALSE, 100, kFALSE,4,0,0,zvertex);
178 hough->SetAddHistograms();
180 for(Int_t slice=0; slice<=35; slice++)
182 //cout<<"Processing slice "<<slice<<endl;
183 hough->ReadData(slice,iEvent);
185 hough->AddAllHistogramsRows();
186 hough->FindTrackCandidatesRow();
187 //hough->WriteTracks(slice,"./hough");
190 hough->WriteTracks("./hough");
194 sprintf(filename, "hough_%d",iEvent);
195 hough->DoBench(filename);
200 void AliHLTReconstructor::FillESD(AliRunLoader* runLoader,
203 //fill the esd file with found tracks
204 Int_t iEvent = runLoader->GetEventNumber();
206 if(fDoTracker) FillESDforConformalMapping(esd,iEvent);
207 if(fDoHough) FillESDforHoughTransform(esd,iEvent);
210 void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
212 //fill esd with tracks from conformal mapping
213 Int_t slicerange[2]={0,35};
214 Int_t good = (int)(0.4*AliL3Transform::GetNRows());
215 Int_t nclusters = (int)(0.4*AliL3Transform::GetNRows());
216 Int_t nminpointsontracks = (int)(0.3*AliL3Transform::GetNRows());
219 Float_t maxfalseratio = 0.1;
221 AliL3Evaluate *fHLTEval = new AliL3Evaluate("./hlt",nclusters,good,ptmin,ptmax,slicerange);
222 fHLTEval->SetMaxFalseClusters(maxfalseratio);
223 fHLTEval->LoadData(iEvent,kTRUE);
224 fHLTEval->AssignPIDs();
225 fHLTEval->AssignIDs();
226 AliL3TrackArray *fTracks = fHLTEval->GetTracks();
231 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
233 AliL3Track *tpt = (AliL3Track *)fTracks->GetCheckedTrack(i);
235 if(tpt->GetNumberOfPoints() < nminpointsontracks) continue;
237 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
239 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
240 esdtrack->SetNHits(tpt->GetNHits());
241 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
242 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
243 esdtrack->SetPt(tpt->GetPt());
244 esdtrack->SetPsi(tpt->GetPsi());
245 esdtrack->SetTgl(tpt->GetTgl());
246 esdtrack->SetCharge(tpt->GetCharge());
247 esdtrack->SetMCid(tpt->GetMCid());
248 esdtrack->SetSector(tpt->GetSector());
249 esdtrack->SetPID(tpt->GetPID());
250 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
252 esd->AddHLTConfMapTrack(esdtrack);
258 void AliHLTReconstructor::FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const
260 //fill esd with tracks from hough
262 sprintf(filename,"./hough/tracks_%d.raw",iEvent);
264 AliL3FileHandler *tfile = new AliL3FileHandler();
265 if(!tfile->SetBinaryInput(filename)){
266 LOG(AliL3Log::kError,"AliHLTReconstructor::FillESDforHoughTransform","Input file")
267 <<" Missing file "<<filename<<ENDLOG;
271 AliL3TrackArray *fTracks = new AliL3TrackArray("AliL3HoughTrack");
272 tfile->Binary2TrackArray(fTracks);
273 tfile->CloseBinaryInput();
276 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
278 AliL3HoughTrack *tpt = (AliL3HoughTrack *)fTracks->GetCheckedTrack(i);
281 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
283 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
284 esdtrack->SetNHits(tpt->GetNHits());
285 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
286 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
287 esdtrack->SetPt(tpt->GetPt());
288 esdtrack->SetPsi(tpt->GetPsi());
289 esdtrack->SetTgl(tpt->GetTgl());
290 esdtrack->SetCharge(tpt->GetCharge());
291 esdtrack->SetMCid(tpt->GetMCid());
292 esdtrack->SetWeight(tpt->GetWeight());
293 esdtrack->SetSector(tpt->GetSector());
294 esdtrack->SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
295 esdtrack->SetPID(tpt->GetPID());
296 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
298 esd->AddHLTHoughTrack(esdtrack);