3 ///////////////////////////////////////////////////////////////////////////////
5 // class for HLT reconstruction //
6 // <Cvetan.Cheshkov@cern.ch> //
7 ///////////////////////////////////////////////////////////////////////////////
9 // very ugly but it has to work fast
10 #ifdef use_reconstruction
12 #include <Riostream.h>
16 #include "AliL3StandardIncludes.h"
17 #include "AliL3Logging.h"
18 #include "AliLevel3.h"
19 #include "AliL3Evaluate.h"
20 #include "AliHLTReconstructor.h"
21 #include "AliL3Transform.h"
22 #include "AliL3Hough.h"
23 #include "AliL3FileHandler.h"
24 #include "AliL3Track.h"
25 #include "AliL3HoughTrack.h"
26 #include "AliL3TrackArray.h"
27 #include "AliRunLoader.h"
28 #include "AliHeader.h"
29 #include "AliGenEventHeader.h"
31 #include "AliESDHLTtrack.h"
38 ClassImp(AliHLTReconstructor)
40 void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader) const
43 LOG(AliL3Log::kFatal,"AliHLTReconstructor::Reconstruct","RunLoader")
44 <<" Missing RunLoader! 0x0"<<ENDLOG;
47 gSystem->Exec("rm -rf hlt");
48 gSystem->MakeDirectory("hlt");
49 gSystem->Exec("rm -rf hough");
50 gSystem->MakeDirectory("hough");
52 Bool_t isinit=AliL3Transform::Init(runLoader);
54 LOG(AliL3Log::kError,"AliHLTReconstructor::Reconstruct","Transformer")
55 << "Could not create transform settings, please check log for error messages!" << ENDLOG;
59 Int_t nEvents = runLoader->GetNumberOfEvents();
61 for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
62 runLoader->GetEvent(iEvent);
64 if(fDoTracker) ReconstructWithConformalMapping(runLoader,iEvent);
65 if(fDoHough) ReconstructWithHoughTransform(runLoader,iEvent);
69 void AliHLTReconstructor::ReconstructWithConformalMapping(AliRunLoader* runLoader,Int_t iEvent) const
71 AliLevel3 *fHLT = new AliLevel3(runLoader);
72 fHLT->Init("./", AliLevel3::kRunLoader, 1);
74 Int_t phiSegments = 50;
75 Int_t etaSegments = 100;
76 Int_t trackletlength = 3;
77 Int_t tracklength = 10;
78 Int_t rowscopetracklet = 2;
79 Int_t rowscopetrack = 10;
80 Double_t minPtFit = 0;
81 Double_t maxangle = 0.1745;
82 Double_t goodDist = 5;
83 Double_t maxphi = 0.1;
84 Double_t maxeta = 0.1;
85 Double_t hitChi2Cut = 20;
86 Double_t goodHitChi2 = 5;
87 Double_t trackChi2Cut = 10;
88 Double_t xyerror = -1;
91 fHLT->SetClusterFinderParam(xyerror,zerror,kTRUE);
92 fHLT->SetTrackerParam(phiSegments, etaSegments,
93 trackletlength, tracklength,
94 rowscopetracklet, rowscopetrack,
95 minPtFit, maxangle, goodDist, hitChi2Cut,
96 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE);
97 fHLT->SetTrackerParam(phiSegments, etaSegments,
98 trackletlength, tracklength,
99 rowscopetracklet, rowscopetrack,
100 minPtFit, maxangle, goodDist, hitChi2Cut,
101 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kFALSE);
102 fHLT->SetMergerParameters(2,3,0.003,0.1,0.05);
104 fHLT->DoNonVertexTracking(); /*2 tracking passes, last without vertex contraint.*/
105 fHLT->WriteFiles("./hlt/");
106 fHLT->ProcessEvent(0, 35, iEvent);
109 sprintf(filename, "confmap_%d",iEvent);
110 fHLT->DoBench(filename);
115 void AliHLTReconstructor::ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const
117 Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
121 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
122 zvertex = mcVertex[2];
124 LOG(AliL3Log::kInformational,"AliHLTReconstructor::Reconstruct","HoughTransform")
125 <<" Hough Transform will run with ptmin="<<ptmin<<" and zvertex="<<zvertex<<ENDLOG;
127 AliL3Hough *hough = new AliL3Hough();
129 hough->SetThreshold(4);
130 hough->SetTransformerParams(76,140,ptmin,-1);
131 hough->SetPeakThreshold(70,-1);
132 hough->SetRunLoader(runLoader);
133 hough->Init("./", kFALSE, 100, kFALSE,4,0,0,zvertex);
134 hough->SetAddHistograms();
136 for(Int_t slice=0; slice<=35; slice++)
138 //cout<<"Processing slice "<<slice<<endl;
139 hough->ReadData(slice,iEvent);
141 hough->AddAllHistogramsRows();
142 hough->FindTrackCandidatesRow();
143 //hough->WriteTracks(slice,"./hough");
146 hough->WriteTracks("./hough");
149 sprintf(filename, "hough_%d",iEvent);
150 hough->DoBench(filename);
155 void AliHLTReconstructor::FillESD(AliRunLoader* runLoader,
158 Int_t iEvent = runLoader->GetEventNumber();
160 if(fDoTracker) FillESDforConformalMapping(esd,iEvent);
161 if(fDoHough) FillESDforHoughTransform(esd,iEvent);
165 gSystem->Exec("rm -rf hlt");
166 sprintf(name, "rm -f confmap_%d.root confmap_%d.dat",iEvent,iEvent);
168 gSystem->Exec("rm -rf hough");
169 sprintf(name, "rm -f hough_%d.root hough_%d.dat",iEvent,iEvent);
174 void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
176 //Assign MC labels for found tracks
177 Int_t slicerange[2]={0,35};
178 Int_t good = (int)(0.4*AliL3Transform::GetNRows());
179 Int_t nclusters = (int)(0.4*AliL3Transform::GetNRows());
182 Float_t maxfalseratio = 0.1;
184 AliL3Evaluate *fHLTEval = new AliL3Evaluate("./hlt",nclusters,good,ptmin,ptmax,slicerange);
185 fHLTEval->SetMaxFalseClusters(maxfalseratio);
187 fHLTEval->LoadData(iEvent,kTRUE);
188 fHLTEval->AssignPIDs();
189 fHLTEval->AssignIDs();
190 AliL3TrackArray *fTracks = fHLTEval->GetTracks();
191 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
193 AliL3Track *tpt = (AliL3Track *)fTracks->GetCheckedTrack(i);
196 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
198 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
199 esdtrack->SetNHits(tpt->GetNHits());
200 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
201 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
202 esdtrack->SetPt(tpt->GetPt());
203 esdtrack->SetPsi(tpt->GetPsi());
204 esdtrack->SetTgl(tpt->GetTgl());
205 esdtrack->SetCharge(tpt->GetCharge());
206 esdtrack->SetMCid(tpt->GetMCid());
207 esdtrack->SetSector(tpt->GetSector());
208 esdtrack->SetPID(tpt->GetPID());
209 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
211 esd->AddHLTConfMapTrack(esdtrack);
217 void AliHLTReconstructor::FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const
220 sprintf(filename,"./hough/tracks_%d.raw",iEvent);
222 AliL3FileHandler *tfile = new AliL3FileHandler();
223 if(!tfile->SetBinaryInput(filename)){
224 Error("FillESD","Inputfile ",filename," does not exist");
228 AliL3TrackArray *fTracks = new AliL3TrackArray("AliL3HoughTrack");
229 tfile->Binary2TrackArray(fTracks);
230 tfile->CloseBinaryInput();
233 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
235 AliL3HoughTrack *tpt = (AliL3HoughTrack *)fTracks->GetCheckedTrack(i);
238 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
240 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
241 esdtrack->SetNHits(tpt->GetNHits());
242 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
243 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
244 esdtrack->SetPt(tpt->GetPt());
245 esdtrack->SetPsi(tpt->GetPsi());
246 esdtrack->SetTgl(tpt->GetTgl());
247 esdtrack->SetCharge(tpt->GetCharge());
248 esdtrack->SetMCid(tpt->GetMCid());
249 esdtrack->SetWeight(tpt->GetWeight());
250 esdtrack->SetSector(tpt->GetSector());
251 esdtrack->SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
252 esdtrack->SetPID(tpt->GetPID());
253 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
255 esd->AddHLTHoughTrack(esdtrack);