//////////////////////////////////////////////////////////////////////// // // AliTPCTracking.C // // date: 22.08.2002 // author: Jiri Chudoba based on code of Jourij Belikov // version: 1.0 // description: // reconstructs of tracks in TPC inthe following steps: // TPC cluster finding // TPC track finding // input parameters: // Int_t nEvents ... nr of events to process // Int_t firstEventNr ... first event number (starts from 0) // TString fileNameHits ... name of file with hits // TString fileNameDigits .. name of file with TPC digits // TString fileNameClusters .. name of file with TPC clusters (output) // TString fileNameTracks .. name of file with TPC tracks (output) // // default file names correspond to pp production (2002-04) // // History: // // 22.08.2002 ... first version // //////////////////////////////////////////////////////////////////////// #if !defined(__CINT__) || defined(__MAKECINT__) #include "iostream.h" #include "TTree.h" #include "TSystem.h" #include "TArrayF.h" #include "TPC/alles.h" #include "TPC/AliTPCtracker.h" #include "TPC/AliTPCclusterer.h" #include "STEER/AliRun.h" #include "STEER/AliHeader.h" #include "STEER/AliGenEventHeader.h" #include "STEER/AliMagF.h" #endif Int_t gDEBUG = 2; Int_t TPCFindClusters(Int_t nEvents=1, Int_t firstEvent=0, TString fileNameDigits="rfio:galiceSDR.root", TString fileNameClusters="tpc.clusters.root"); Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent, TFile* fileDigits, TFile* fileClusters, AliTPCParam* paramTPC=0); Int_t TPCFindTracks(Int_t nEvents=1, Int_t firstEvent=0, TString fileNameClusters="tpc.clusters.root", TString fileNameTracks="tpc.tracks.root"); Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent, TFile* fileClusters, TFile* fileTracks, AliTPCParam* paramTPC=0); AliTPCParam* LoadTPCParam(TFile *file); void FindVertex(Int_t iEvent, Double_t *vertex); void PrintVertex(TArrayF &primaryVertex); Int_t SetFieldFactor(TString fileName, Bool_t closeFile = kTRUE); Int_t SetFieldFactor(TFile* file, Bool_t deletegAlice = kTRUE); Int_t SetFieldFactor(); Int_t AliTPCTracking(Int_t nEvents=1, Int_t firstEvent=0, TString fileNameHits="rfio:galice.root", TString fileNameDigits="rfio:galiceSDR.root", TString fileNameClusters="tpc.clusters.root", TString fileNameTracks="tpc.tracks.root"); //////////////////////////////////////////////////////////////////////// Int_t AliTPCTracking( Int_t nEvents, Int_t firstEvent, TString fileNameHits, TString fileNameDigits, TString fileNameClusters, TString fileNameTracks) { SetFieldFactor(fileNameHits,kFALSE); // ********** Find TPC clusters *********** // if (TPCFindClusters(nEvents,firstEvent,fileNameDigits,fileNameClusters)) { cerr<<"Failed to get TPC clusters: !\n"; return 1; } // ********** Find TPC tracks *********** // if (TPCFindTracks(nEvents,firstEvent,fileNameClusters,fileNameTracks)) { cerr<<"Failed to get TPC tracks !\n"; return 2; } return 0; } //////////////////////////////////////////////////////////////////////// Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent, TString fileNameDigits, TString fileNameClusters) { Int_t rc; const Char_t *name="TPCFindClusters"; if (gDEBUG>1) cout<1) gBenchmark->Start(name); TFile *fileClusters = TFile::Open(fileNameClusters,"recreate"); TFile *fileDigits = TFile::Open(fileNameDigits); if (!fileDigits->IsOpen()) { cerr<<"Cannnot open "<IsOpen()) { cerr<<"Cannnot open "<Close(); fileClusters->Close(); delete fileDigits; delete fileClusters; if (gDEBUG>1) gBenchmark->Stop(name); if (gDEBUG>1) gBenchmark->Show(name); return rc; } //////////////////////////////////////////////////////////////////////// Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent, TFile* fileDigits, TFile* fileClusters, AliTPCParam* paramTPC) { fileDigits->cd(); if (!paramTPC) paramTPC = LoadTPCParam(fileDigits); if (!paramTPC) return 1; for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){ if (gDEBUG > 2) cout<<"TPCFindClusters: event "<1) cout<1) gBenchmark->Start(name); TFile *fileTracks = TFile::Open(fileNameTracks,"recreate"); TFile *fileClusters =TFile::Open(fileNameClusters); rc = TPCFindTracks(nEvents, firstEvent, fileClusters, fileTracks); fileClusters->Close(); fileTracks->Close(); delete fileClusters; delete fileTracks; if (gDEBUG>1) gBenchmark->Stop(name); if (gDEBUG>1) gBenchmark->Show(name); return rc; } //////////////////////////////////////////////////////////////////////// Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent, TFile *fileClusters, TFile * fileTracks, AliTPCParam* paramTPC) { Int_t rc = 0; if (!paramTPC) paramTPC = LoadTPCParam(fileClusters); if (!paramTPC) return 1; for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){ if (gDEBUG > 2) cout<<"TPCFindTracks: event "<SetVertex(vertex); fileClusters->cd(); rc = tracker->Clusters2Tracks(0,fileTracks); delete tracker; } return rc; } //////////////////////////////////////////////////////////////////////// Int_t SetFieldFactor() { AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField()); if (gDEBUG > 2) cout<<"Magnetic field in kGauss: "<Field()->SolenoidField()<Get("gAlice"))) { cerr<<"gAlice has not been found in file "<GetName(); return 1; } Int_t rc = SetFieldFactor(); if (deletegAlice) { delete gAlice; gAlice = 0; } return rc; } //////////////////////////////////////////////////////////////////////// Int_t SetFieldFactor(TString fileName, Bool_t closeFile) { TFile *file=TFile::Open(fileName); if (!file->IsOpen()) {cerr<<"Cannnot open "<Close(); return rc; } //////////////////////////////////////////////////////////////////////// AliTPCParam* LoadTPCParam(TFile *file) { char paramName[50]; sprintf(paramName,"75x40_100x60_150x60"); AliTPCParam *paramTPC=(AliTPCParam*)file->Get(paramName); if (paramTPC) { if (gDEBUG > 1) cout<<"TPC parameters "<Get(paramName); // if (paramTPC) { // cout<<"TPC parameters "<Get(paramName); // if (paramTPC) { // cout<<"TPC parameters "<GetEvent(eventNr); AliHeader *header = gAlice->GetHeader(); if (!header) { cerr<<"header was not found!\n"; return; } AliGenEventHeader* genEventHeader = header->GenEventHeader(); if (!genEventHeader) { cerr<<"AliGenEventHeader was not found!\n"; return; } TArrayF primaryVertex(3); genEventHeader->PrimaryVertex(primaryVertex); PrintVertex(primaryVertex); vertex[0] = static_cast(primaryVertex[0]); vertex[1] = static_cast(primaryVertex[1]); vertex[2] = static_cast(primaryVertex[2]); // delete header; delete genEventHeader; return; } //////////////////////////////////////////////////////////////////////// void PrintVertex(TArrayF &primaryVertex) { cout <<"Vertex: " <