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 cerr << "Could not create transform settings, please check log for error messages!" << endl;
58 Int_t nEvents = runLoader->GetNumberOfEvents();
60 for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
61 runLoader->GetEvent(iEvent);
63 ReconstructWithConformalMapping(runLoader,iEvent);
64 ReconstructWithHoughTransform(runLoader,iEvent);
68 void AliHLTReconstructor::ReconstructWithConformalMapping(AliRunLoader* runLoader,Int_t iEvent) const
70 AliLevel3 *fHLT = new AliLevel3(runLoader);
71 fHLT->Init("./", AliLevel3::kRunLoader, 1);
73 Int_t phiSegments = 50;
74 Int_t etaSegments = 100;
75 Int_t trackletlength = 3;
76 Int_t tracklength = 10;
77 Int_t rowscopetracklet = 2;
78 Int_t rowscopetrack = 10;
79 Double_t minPtFit = 0;
80 Double_t maxangle = 0.1745;
81 Double_t goodDist = 5;
82 Double_t maxphi = 0.1;
83 Double_t maxeta = 0.1;
84 Double_t hitChi2Cut = 20;
85 Double_t goodHitChi2 = 5;
86 Double_t trackChi2Cut = 10;
87 Double_t xyerror = -1;
90 fHLT->SetClusterFinderParam(xyerror,zerror,kTRUE);
91 fHLT->SetTrackerParam(phiSegments, etaSegments,
92 trackletlength, tracklength,
93 rowscopetracklet, rowscopetrack,
94 minPtFit, maxangle, goodDist, hitChi2Cut,
95 goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE);
96 fHLT->SetMergerParameters(2,3,0.003,0.1,0.05);
98 fHLT->WriteFiles("./hlt/");
100 fHLT->ProcessEvent(0, 35, iEvent);
103 sprintf(filename, "confmap_%d",iEvent);
104 fHLT->DoBench(filename);
110 void AliHLTReconstructor::ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const
112 Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
116 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
117 zvertex = mcVertex[2];
119 cout<<" Hough Tranform will run with ptmin="<<ptmin<<" and zvertex="<<zvertex<<endl;
121 AliL3Hough *hough = new AliL3Hough();
123 hough->SetThreshold(4);
124 hough->SetTransformerParams(76,140,ptmin,-1);
125 hough->SetPeakThreshold(70,-1);
126 hough->SetRunLoader(runLoader);
127 hough->Init("./", kFALSE, 100, kFALSE,4,0,0,zvertex);
128 hough->SetAddHistograms();
130 for(int slice=0; slice<=35; slice++)
132 // cout<<"Processing slice "<<slice<<endl;
133 hough->ReadData(slice,iEvent);
135 hough->AddAllHistogramsRows();
136 hough->FindTrackCandidatesRow();
137 // hough->WriteTracks(slice,"./hough");
140 hough->WriteTracks("./hough");
143 sprintf(filename, "hough_%d",iEvent);
144 hough->DoBench(filename);
149 void AliHLTReconstructor::FillESD(AliRunLoader* runLoader,
152 Int_t iEvent = runLoader->GetEventNumber();
154 FillESDforConformalMapping(esd,iEvent);
155 FillESDforHoughTransform(esd,iEvent);
158 void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
160 //Assign MC labels for found tracks
161 int slicerange[2]={0,35};
162 int good = (int)(0.4*AliL3Transform::GetNRows());
163 int nclusters = (int)(0.4*AliL3Transform::GetNRows());
166 float maxfalseratio = 0.1;
168 AliL3Evaluate *fHLTEval = new AliL3Evaluate("./hlt",nclusters,good,ptmin,ptmax,slicerange);
169 fHLTEval->SetMaxFalseClusters(maxfalseratio);
171 fHLTEval->LoadData(iEvent,kTRUE);
172 fHLTEval->AssignPIDs();
173 fHLTEval->AssignIDs();
174 AliL3TrackArray *fTracks = fHLTEval->GetTracks();
175 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
177 AliL3Track *tpt = (AliL3Track *)fTracks->GetCheckedTrack(i);
180 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
182 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
183 esdtrack->SetNHits(tpt->GetNHits());
184 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
185 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
186 esdtrack->SetPt(tpt->GetPt());
187 esdtrack->SetPsi(tpt->GetPsi());
188 esdtrack->SetTgl(tpt->GetTgl());
189 esdtrack->SetCharge(tpt->GetCharge());
190 esdtrack->SetMCid(tpt->GetMCid());
191 esdtrack->SetSector(tpt->GetSector());
192 esdtrack->SetPID(tpt->GetPID());
193 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
195 esd->AddHLTConfMapTrack(esdtrack);
202 void AliHLTReconstructor::FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const
205 sprintf(filename,"./hough/tracks_%d.raw",iEvent);
207 AliL3FileHandler *tfile = new AliL3FileHandler();
208 if(!tfile->SetBinaryInput(filename)){
209 Error("FillESD","Inputfile ",filename," does not exist");
213 AliL3TrackArray *fTracks = new AliL3TrackArray("AliL3HoughTrack");
214 tfile->Binary2TrackArray(fTracks);
215 tfile->CloseBinaryInput();
218 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
220 AliL3HoughTrack *tpt = (AliL3HoughTrack *)fTracks->GetCheckedTrack(i);
223 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
225 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
226 esdtrack->SetNHits(tpt->GetNHits());
227 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
228 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
229 esdtrack->SetPt(tpt->GetPt());
230 esdtrack->SetPsi(tpt->GetPsi());
231 esdtrack->SetTgl(tpt->GetTgl());
232 esdtrack->SetCharge(tpt->GetCharge());
233 esdtrack->SetMCid(tpt->GetMCid());
234 esdtrack->SetWeight(tpt->GetWeight());
235 esdtrack->SetSector(tpt->GetSector());
236 esdtrack->SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
237 esdtrack->SetPID(tpt->GetPID());
238 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
240 esd->AddHLTHoughTrack(esdtrack);