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 "AliHLTStandardIncludes.h"
24 #include "AliHLTLogging.h"
25 #include "AliLevel3.h"
26 #include "AliHLTEvaluate.h"
27 #include "AliHLTReconstructor.h"
28 #include "AliHLTTransform.h"
29 #include "AliHLTHough.h"
30 #include "AliHLTFileHandler.h"
31 #include "AliHLTTrack.h"
32 #include "AliHLTHoughTrack.h"
33 #include "AliHLTTrackArray.h"
37 #include "AliHLTITStracker.h"
38 #include "AliHLTTPCtracker.h"
39 #include "MUON/src/AliRoot/AliHLTMUONTracker.h"
40 #include "MUON/src/AliRoot/AliHLTMUONHitReconstructor.h"
41 #include "AliRawReader.h"
46 ClassImp(AliHLTReconstructor)
48 AliHLTReconstructor::AliHLTReconstructor(): AliReconstructor()
52 AliHLTLog::fgLevel=AliHLTLog::kWarning;
60 AliHLTReconstructor::AliHLTReconstructor(Bool_t doTracker, Bool_t doHough): AliReconstructor()
64 AliHLTLog::fgLevel=AliHLTLog::kWarning;
72 AliHLTReconstructor::~AliHLTReconstructor()
77 gSystem->Exec("rm -rf hlt");
78 sprintf(name, "rm -f confmap_*.root confmap_*.dat");
80 gSystem->Exec("rm -rf hough");
81 sprintf(name, "rm -f hough_*.root hough_*.dat");
86 void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader) const
88 // do the standard and hough reconstruction chain
90 LOG(AliHLTLog::kFatal,"AliHLTReconstructor::Reconstruct","RunLoader")
91 <<" Missing RunLoader! 0x0"<<ENDLOG;
94 gSystem->Exec("rm -rf hlt");
95 gSystem->MakeDirectory("hlt");
96 gSystem->Exec("rm -rf hough");
97 gSystem->MakeDirectory("hough");
99 Bool_t isinit=AliHLTTransform::Init(runLoader);
101 LOG(AliHLTLog::kError,"AliHLTReconstructor::Reconstruct","Transformer")
102 << "Could not create transform settings, please check log for error messages!" << ENDLOG;
106 Int_t nEvents = runLoader->GetNumberOfEvents();
108 for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
109 runLoader->GetEvent(iEvent);
111 if(fDoTracker) ReconstructWithConformalMapping(runLoader,iEvent);
112 if(fDoHough) ReconstructWithHoughTransform(runLoader,iEvent);
116 void AliHLTReconstructor::ReconstructWithConformalMapping(AliRunLoader* runLoader,Int_t iEvent) const
118 // reconstruct with conformal mapper
119 AliLevel3 *fHLT = new AliLevel3(runLoader);
120 fHLT->Init("./", AliLevel3::kRunLoader, 1);
122 Int_t phiSegments = 50;
123 Int_t etaSegments = 100;
124 Int_t trackletlength = 3;
125 Int_t tracklength = 10;
126 Int_t rowscopetracklet = 2;
127 Int_t rowscopetrack = 10;
128 Double_t minPtFit = 0;
129 Double_t maxangle = 0.1745;
130 Double_t goodDist = 5;
131 Double_t maxphi = 0.1;
132 Double_t maxeta = 0.1;
133 Double_t hitChi2Cut = 20;
134 Double_t goodHitChi2 = 5;
135 Double_t trackChi2Cut = 10;
136 Double_t xyerror = -1;
137 Double_t zerror = -1;
139 fHLT->SetClusterFinderParam(xyerror,zerror,kTRUE);
140 fHLT->SetTrackerParam(phiSegments, etaSegments,
141 trackletlength, tracklength,
142 rowscopetracklet, rowscopetrack,
143 minPtFit, maxangle, goodDist, hitChi2Cut,
144 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE);
145 fHLT->SetTrackerParam(phiSegments, etaSegments,
146 trackletlength, tracklength,
147 rowscopetracklet, rowscopetrack,
148 minPtFit, maxangle, goodDist, hitChi2Cut,
149 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kFALSE);
150 fHLT->SetMergerParameters(2,3,0.003,0.1,0.05);
152 fHLT->DoNonVertexTracking(); /*2 tracking passes, last without vertex contraint.*/
153 fHLT->WriteFiles("./hlt/");
154 fHLT->ProcessEvent(0, 35, iEvent);
157 sprintf(filename, "confmap_%d",iEvent);
158 fHLT->DoBench(filename);
164 void AliHLTReconstructor::ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const
166 //reconstruct with hough
167 //not used anymore, Hough tracking is moved out of the local
168 //reconstruction chain
169 Float_t ptmin = 0.1*AliHLTTransform::GetSolenoidField();
173 AliHeader * header = runLoader->GetHeader();
175 AliGenEventHeader * genHeader = header->GenEventHeader();
176 if (genHeader) genHeader->PrimaryVertex(mcVertex);
178 zvertex = mcVertex[2];
180 LOG(AliHLTLog::kInformational,"AliHLTReconstructor::Reconstruct","HoughTransform")
181 <<" Hough Transform will run with ptmin="<<ptmin<<" and zvertex="<<zvertex<<ENDLOG;
183 AliHLTHough *hough = new AliHLTHough();
185 hough->SetThreshold(4);
186 hough->CalcTransformerParams(ptmin);
187 hough->SetPeakThreshold(70,-1);
188 hough->SetRunLoader(runLoader);
189 hough->Init("./", kFALSE, 100, kFALSE,4,0,0,zvertex);
190 hough->SetAddHistograms();
192 for(Int_t slice=0; slice<=35; slice++)
194 //cout<<"Processing slice "<<slice<<endl;
195 hough->ReadData(slice,iEvent);
197 hough->AddAllHistogramsRows();
198 hough->FindTrackCandidatesRow();
199 //hough->WriteTracks(slice,"./hough");
202 hough->WriteTracks("./hough");
206 sprintf(filename, "hough_%d",iEvent);
207 hough->DoBench(filename);
212 void AliHLTReconstructor::FillESD(AliRunLoader* runLoader,
215 //fill the esd file with found tracks
216 Int_t iEvent = runLoader->GetEventNumber();
218 if(fDoTracker) FillESDforConformalMapping(esd,iEvent);
219 if(fDoHough) FillESDforHoughTransform(esd,iEvent);
222 void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
224 //fill esd with tracks from conformal mapping
225 Int_t slicerange[2]={0,35};
226 Int_t good = (int)(0.4*AliHLTTransform::GetNRows());
227 Int_t nclusters = (int)(0.4*AliHLTTransform::GetNRows());
228 Int_t nminpointsontracks = (int)(0.3*AliHLTTransform::GetNRows());
231 Float_t maxfalseratio = 0.1;
233 AliHLTEvaluate *fHLTEval = new AliHLTEvaluate("./hlt",nclusters,good,ptmin,ptmax,slicerange);
234 fHLTEval->SetMaxFalseClusters(maxfalseratio);
235 fHLTEval->LoadData(iEvent,kTRUE);
236 fHLTEval->AssignPIDs();
237 fHLTEval->AssignIDs();
238 AliHLTTrackArray *fTracks = fHLTEval->GetTracks();
243 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
245 AliHLTTrack *tpt = (AliHLTTrack *)fTracks->GetCheckedTrack(i);
247 if(tpt->GetNumberOfPoints() < nminpointsontracks) continue;
249 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
251 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
252 esdtrack->SetNHits(tpt->GetNHits());
253 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
254 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
255 esdtrack->SetPt(tpt->GetPt());
256 esdtrack->SetPsi(tpt->GetPsi());
257 esdtrack->SetTgl(tpt->GetTgl());
258 esdtrack->SetCharge(tpt->GetCharge());
259 esdtrack->SetMCid(tpt->GetMCid());
260 esdtrack->SetSector(tpt->GetSector());
261 esdtrack->SetPID(tpt->GetPID());
262 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
264 esd->AddHLTConfMapTrack(esdtrack);
270 void AliHLTReconstructor::FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const
272 //fill esd with tracks from hough
274 sprintf(filename,"./hough/tracks_%d.raw",iEvent);
276 AliHLTFileHandler *tfile = new AliHLTFileHandler();
277 if(!tfile->SetBinaryInput(filename)){
278 LOG(AliHLTLog::kError,"AliHLTReconstructor::FillESDforHoughTransform","Input file")
279 <<" Missing file "<<filename<<ENDLOG;
283 AliHLTTrackArray *fTracks = new AliHLTTrackArray("AliHLTHoughTrack");
284 tfile->Binary2TrackArray(fTracks);
285 tfile->CloseBinaryInput();
288 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
290 AliHLTHoughTrack *tpt = (AliHLTHoughTrack *)fTracks->GetCheckedTrack(i);
293 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
295 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
296 esdtrack->SetNHits(tpt->GetNHits());
297 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
298 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
299 esdtrack->SetPt(tpt->GetPt());
300 esdtrack->SetPsi(tpt->GetPsi());
301 esdtrack->SetTgl(tpt->GetTgl());
302 esdtrack->SetCharge(tpt->GetCharge());
303 esdtrack->SetMCid(tpt->GetMCid());
304 esdtrack->SetWeight(tpt->GetWeight());
305 esdtrack->SetSector(tpt->GetSector());
306 esdtrack->SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
307 esdtrack->SetPID(tpt->GetPID());
308 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
310 esd->AddHLTHoughTrack(esdtrack);
317 AliTracker* AliHLTReconstructor::CreateTracker(AliRunLoader* runLoader) const
319 //Create HLT trackers for TPC and ITS
321 TString opt = GetOption();
322 if(!opt.CompareTo("TPC")) {
323 // Create Hough tracker for TPC
324 return new AliHLTTPCtracker(runLoader);
326 if(!opt.CompareTo("ITS")) {
327 // Create ITS tracker
328 return new AliHLTITStracker(0);
330 if(!opt.CompareTo("MUON")) {
331 return new AliHLTMUONTracker(runLoader);
337 void AliHLTReconstructor::FillDHLTRecPoint(AliRawReader* rawReader, Int_t nofEvent, Int_t dcCut = 0) const
339 // Hit recontruction for dimuon-HLT
340 AliHLTMUONHitReconstructor kdHLTRec(rawReader);
343 kdHLTRec.SetDCCut(dcCut);
344 TString lookupTablePath = getenv("ALICE_ROOT");
345 lookupTablePath += "/HLT/MUON/src/AliRoot/Lut";
346 kdHLTRec.Init(lookupTablePath.Data(),lookupTablePath.Data());
348 while(rawReader->NextEvent() && iEvent < nofEvent){
349 AliInfo(Form("Event : %d",iEvent));
350 kdHLTRec.WriteDHLTRecHits(iEvent);