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;
46 gSystem->Exec("rm -rf hlt");
47 gSystem->MakeDirectory("hlt");
48 gSystem->Exec("rm -rf hough");
49 gSystem->MakeDirectory("hough");
50 gSystem->Exec("rm -f alirunfile.root");
51 gSystem->Exec("ln -s galice.root alirunfile.root");
53 Bool_t isinit=AliL3Transform::Init("./",kTRUE);
55 cerr << "Could not create transform settings, please check log for error messages!" << endl;
59 Int_t nEvents = runLoader->GetNumberOfEvents();
61 for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
62 runLoader->GetEvent(iEvent);
64 ReconstructWithConformalMapping(runLoader,iEvent);
65 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->SetMergerParameters(2,3,0.003,0.1,0.05);
99 fHLT->WriteFiles("./hlt/");
101 fHLT->ProcessEvent(0, 35, iEvent);
104 sprintf(filename, "confmap_%d",iEvent);
105 fHLT->DoBench(filename);
111 void AliHLTReconstructor::ReconstructWithHoughTransform(AliRunLoader* runLoader,Int_t iEvent) const
113 Float_t ptmin = 0.1*AliL3Transform::GetSolenoidField();
117 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
118 zvertex = mcVertex[2];
120 cout<<" Hough Tranform will run with ptmin="<<ptmin<<" and zvertex="<<zvertex<<endl;
122 AliL3Hough *hough = new AliL3Hough();
124 hough->SetThreshold(4);
125 hough->SetTransformerParams(76,140,ptmin,-1);
126 hough->SetPeakThreshold(70,-1);
127 hough->SetRunLoader(runLoader);
128 hough->Init("./", kFALSE, 100, kFALSE,4,0,0,zvertex);
129 hough->SetAddHistograms();
131 for(int slice=0; slice<=35; slice++)
133 // cout<<"Processing slice "<<slice<<endl;
134 hough->ReadData(slice,iEvent);
136 hough->AddAllHistogramsRows();
137 hough->FindTrackCandidatesRow();
138 // hough->WriteTracks(slice,"./hough");
141 hough->WriteTracks("./hough");
144 sprintf(filename, "hough_%d",iEvent);
145 hough->DoBench(filename);
150 void AliHLTReconstructor::FillESD(AliRunLoader* runLoader,
153 Int_t iEvent = runLoader->GetEventNumber();
155 FillESDforConformalMapping(esd,iEvent);
156 FillESDforHoughTransform(esd,iEvent);
159 void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
161 //Assign MC labels for found tracks
162 int slicerange[2]={0,35};
163 int good = (int)(0.4*AliL3Transform::GetNRows());
164 int nclusters = (int)(0.4*AliL3Transform::GetNRows());
167 float maxfalseratio = 0.1;
169 AliL3Evaluate *fHLTEval = new AliL3Evaluate("./hlt",nclusters,good,ptmin,ptmax,slicerange);
170 fHLTEval->SetMaxFalseClusters(maxfalseratio);
172 fHLTEval->LoadData(iEvent,kTRUE);
173 fHLTEval->AssignPIDs();
174 fHLTEval->AssignIDs();
175 AliL3TrackArray *fTracks = fHLTEval->GetTracks();
176 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
178 AliL3Track *tpt = (AliL3Track *)fTracks->GetCheckedTrack(i);
181 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
183 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
184 esdtrack->SetNHits(tpt->GetNHits());
185 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
186 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
187 esdtrack->SetPt(tpt->GetPt());
188 esdtrack->SetPsi(tpt->GetPsi());
189 esdtrack->SetTgl(tpt->GetTgl());
190 esdtrack->SetCharge(tpt->GetCharge());
191 esdtrack->SetMCid(tpt->GetMCid());
192 esdtrack->SetSector(tpt->GetSector());
193 esdtrack->SetPID(tpt->GetPID());
194 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
196 esd->AddHLTConfMapTrack(esdtrack);
203 void AliHLTReconstructor::FillESDforHoughTransform(AliESD* esd,Int_t iEvent) const
206 sprintf(filename,"./hough/tracks_%d.raw",iEvent);
208 AliL3FileHandler *tfile = new AliL3FileHandler();
209 if(!tfile->SetBinaryInput(filename)){
210 Error("FillESD","Inputfile ",filename," does not exist");
214 AliL3TrackArray *fTracks = new AliL3TrackArray("AliL3HoughTrack");
215 tfile->Binary2TrackArray(fTracks);
216 tfile->CloseBinaryInput();
219 for(Int_t i=0; i<fTracks->GetNTracks(); i++)
221 AliL3HoughTrack *tpt = (AliL3HoughTrack *)fTracks->GetCheckedTrack(i);
224 AliESDHLTtrack *esdtrack = new AliESDHLTtrack() ;
226 esdtrack->SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
227 esdtrack->SetNHits(tpt->GetNHits());
228 esdtrack->SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
229 esdtrack->SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
230 esdtrack->SetPt(tpt->GetPt());
231 esdtrack->SetPsi(tpt->GetPsi());
232 esdtrack->SetTgl(tpt->GetTgl());
233 esdtrack->SetCharge(tpt->GetCharge());
234 esdtrack->SetMCid(tpt->GetMCid());
235 esdtrack->SetWeight(tpt->GetWeight());
236 esdtrack->SetSector(tpt->GetSector());
237 esdtrack->SetBinXY(tpt->GetBinX(),tpt->GetBinY(),tpt->GetSizeX(),tpt->GetSizeY());
238 esdtrack->SetPID(tpt->GetPID());
239 esdtrack->ComesFromMainVertex(tpt->ComesFromMainVertex());
241 esd->AddHLTHoughTrack(esdtrack);