New macros to reconstruct tracks in ITS and TRD (T.Kuhr)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Mar 2003 17:19:23 +0000 (17:19 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Mar 2003 17:19:23 +0000 (17:19 +0000)
ITS/AliITSTrackingV2.C [new file with mode: 0644]
TRD/AliTRDTracking.C [new file with mode: 0644]

diff --git a/ITS/AliITSTrackingV2.C b/ITS/AliITSTrackingV2.C
new file mode 100644 (file)
index 0000000..aed8dfe
--- /dev/null
@@ -0,0 +1,171 @@
+////////////////////////////////////////////////////////////////////////
+//
+// AliITSTrackingV2.C 
+//
+// date: 18.03.2003
+// author: Thomas Kuhr based on AliTPCTracking.C, AliITSFindClustersV2.C
+//         and AliITSFindTracksV2.C
+// version: 1.0
+// description: 
+//      reconstructs of tracks in ITS in the following steps:
+//         ITS cluster finding
+//         ITS track finding
+// input parameters: 
+//        Int_t nEvents      ... nr of events to process
+//        Int_t firstEventNr ... first event number (starts from 0)
+//        char* fileNameHits ... name of file with hits
+//        char* fileNameITSDigits .. name of file with ITS digits
+//        char* fileNameITSTracks .. name of file with TPC tracks
+//        char* fileNameITSClusters .. name of file with ITS clusters (output)
+//        char* fileNameITSTracks .. name of file with ITS tracks (output)
+//
+////////////////////////////////////////////////////////////////////////
+
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "Riostream.h"
+#include "TFile.h"
+#include "TBenchmark.h"
+#include "AliITS.h"
+#include "AliITSgeom.h"
+#include "AliITSclustererV2.h"
+#include "AliITStrackerV2.h"
+#include "AliRun.h"
+#endif
+
+Int_t gDEBUG = 2;
+
+Int_t AliITSTrackingV2(Int_t nEvents=1, Int_t firstEvent=0,
+                      const char* fileNameHits="galice.root",
+                      const char* fileNameITSDigits="its.digits.root",
+                      const char* fileNameTPCTracks="tpc.tracks.root",
+                      const char* fileNameITSClusters="its.clusters.root",
+                      const char* fileNameITSTracks="its.tracks.root");
+            
+Int_t ITSFindClustersV2(const char* fileNameITSDigits, 
+                       const char* fileNameITSClusters, 
+                       Int_t n, Int_t first);
+Int_t ITSFindTracksV2(const char* fileNameTPCTracks, 
+                     const char* fileNameITSClusters, 
+                     const char* fileNameITSTracks, 
+                     Int_t n, Int_t first);
+
+////////////////////////////////////////////////////////////////////////
+Int_t AliITSTrackingV2(Int_t nEvents, Int_t firstEvent,
+                      const char* fileNameHits,
+                      const char* fileNameITSDigits,
+                      const char* fileNameTPCTracks,
+                      const char* fileNameITSClusters,
+                      const char* fileNameITSTracks) {
+
+  AliTracker::SetFieldFactor(fileNameHits,kFALSE);
+
+// find clusters
+
+  if (fileNameITSDigits && fileNameITSClusters) {
+    if(ITSFindClustersV2(fileNameITSDigits,fileNameITSClusters,nEvents,firstEvent)) {
+      cerr << "ITS clustering failed \n";
+      return 1;
+    }
+  }
+
+// find tracks
+
+  if (fileNameTPCTracks && fileNameITSClusters && fileNameITSTracks) {
+    if(ITSFindTracksV2(fileNameTPCTracks,fileNameITSClusters,fileNameITSTracks,nEvents,firstEvent)) {
+      cerr << "ITS tracking failed \n";
+      return 2;
+    }
+  }
+
+  return 0;
+}
+////////////////////////////////////////////////////////////////////////
+Int_t ITSFindClustersV2(const char* fileNameITSDigits, const char* fileNameITSClusters, Int_t nEvents, Int_t firstEvent) {
+//
+// create ITS clusters, store them in the file fileNameITSClusters
+// gAlice object must be in memory
+
+  const char *name="ITSFindClustersV2";
+  if (gDEBUG>1) cout<<name<<" starts...\n";
+  if (gDEBUG>1) gBenchmark->Start(name);
+
+  TFile *in =TFile::Open(fileNameITSDigits);
+  if (!in->IsOpen()) {
+    cerr<<"Can't open file "<<fileNameITSDigits<<endl; 
+    return 1;
+  }
+  gAlice->SetTreeDFileName(fileNameITSDigits);
+  TFile *out=TFile::Open(fileNameITSClusters,"recreate");
+  if (!out->IsOpen()) {
+    cerr<<"Can't open file "<<fileNameITSClusters<<endl; 
+    return 1;
+  }
+
+  AliITS *ITS  = (AliITS*)gAlice->GetModule("ITS");
+  if (!ITS) { cerr<<"Can't find the ITS !\n"; return 3; }
+
+  AliITSgeom *geom=ITS->GetITSgeom();
+  out->cd();
+  geom->Write();
+  gROOT->cd();
+
+  AliITSclustererV2 clusterer(geom);
+  for (Int_t iEvent = firstEvent; iEvent<firstEvent+nEvents; iEvent++){
+    cout<<"ITSFindClusters: processing event "<<iEvent<<endl;
+    gAlice->GetEvent(iEvent);
+    in->cd();
+    clusterer.SetEvent(iEvent);
+    clusterer.Digits2Clusters(in,out); 
+  }
+
+  out->Close();
+  in->Close();
+
+  if (gDEBUG>1) gBenchmark->Show(name);
+  return 0;
+}
+////////////////////////////////////////////////////////////////////////
+Int_t ITSFindTracksV2(const char* fileNameTPCTracks, 
+                     const char* fileNameITSClusters, 
+                     const char* fileNameITSTracks, 
+                     Int_t nEvents, Int_t first) {
+  Int_t rc=0;
+  const char *name="ITSFindTracksV2";
+  if (gDEBUG>1) cout<<name<<" starts...\n";
+  if (gDEBUG>1) gBenchmark->Start(name);
+
+  TFile *out=TFile::Open(fileNameITSTracks,"recreate");
+  if (!out->IsOpen()) {
+    cerr<<"Can't open file "<<fileNameITSTracks<<endl; 
+    return 1;
+  }
+  TFile *in =TFile::Open(fileNameTPCTracks);
+  if (!in->IsOpen()) {
+    cerr<<"Can't open file "<<fileNameTPCTracks<<endl; 
+    return 1;
+  }
+  TFile *in2 =TFile::Open(fileNameITSClusters);
+  if (!in2->IsOpen()) {
+    cerr<<"Can't open file "<<fileNameITSClusters<<endl; 
+    return 1;
+  }
+
+  AliITSgeom *geom=(AliITSgeom*)in2->Get("AliITSgeom");
+  if (!geom) { cerr<<"can't get ITS geometry !\n"; return 1;}
+
+  AliITStrackerV2 tracker(geom);
+  for (Int_t iEvent=first;iEvent<first+nEvents;iEvent++){
+    cout<<"ITSFindTracks -- event "<<iEvent<<endl;
+    tracker.SetEventNumber(iEvent);
+    rc=tracker.Clusters2Tracks(in,out);
+  }
+
+  in->Close();
+  in2->Close();
+  out->Close();
+
+  if (gDEBUG>1) gBenchmark->Show(name);
+  return rc;
+}
+
diff --git a/TRD/AliTRDTracking.C b/TRD/AliTRDTracking.C
new file mode 100644 (file)
index 0000000..6b45196
--- /dev/null
@@ -0,0 +1,296 @@
+////////////////////////////////////////////////////////////////////////
+//
+// AliTRDTracking.C 
+//
+// date: 06.02.2003
+// author: Thomas Kuhr based on AliTPCTracking.C
+// version: 1.0
+// description: 
+//      reconstructs of tracks in TRD in the following steps:
+//         TRD cluster finding
+//         TRD track finding
+// input parameters: 
+//        Int_t nEvents      ... nr of events to process
+//        Int_t firstEventNr ... first event number (starts from 0)
+//        const char* fileNameParam ... name of file with TPC parameters
+//        const char* fileNameHits ... name of file with hits
+//        const char* fileNameDigits .. name of file with TRD digits
+//        const char* fileNameSeeds .. name of file with TPC track seeds
+//        const char* fileNameClusters .. name of file with TRD clusters (output)
+//        const char* fileNameTracks .. name of file with TRD tracks (output)
+//
+//        default file names correspond to pp production (2002-04)
+//
+////////////////////////////////////////////////////////////////////////
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "Riostream.h"
+#include "TFile.h"
+#include "TBenchmark.h"
+#include "AliTRD.h"
+#include "AliTRDparameter.h"
+#include "AliTRDtracker.h"
+#include "AliTRDclusterizerV1.h"
+#include "AliTPC.h"
+#include "AliTPCParamSR.h"
+#include "AliTPCtracker.h"
+#include "AliITS.h"
+#include "AliITSgeom.h"
+#include "AliITStrackerV2.h"
+#include "AliRun.h"
+#endif
+
+Int_t gDEBUG = 2;
+
+Int_t AliTRDTracking(Int_t nEvents=1, Int_t firstEvent=0,
+                    const char* fileNameParam="trd.sdigits.root",
+                    const char* fileNameDigits="trd.digits.root",
+                    const char* fileNameSeed="tpc.tracks.root",
+                    const char* fileNameClusters="trd.clusters.root",
+                    const char* fileNameTracks="trd.tracks.root");
+
+Bool_t ITSPropagateBack(Int_t nEvents=1, Int_t firstEvent=0,
+                       const char* fileNameClusters="its.clusters.root",
+                       const char* fileNameTracks="its.tracks.root",
+                       const char* fileNameBackTracks="its.back.tracks.root");
+Bool_t TPCPropagateBack(Int_t nEvents=1, Int_t firstEvent=0,
+                       const char* fileNameClusters="tpc.clusters.root",
+                       const char* fileNameTracks="tpc.tracks.root",
+                       const char* fileNameITSBackTracks="its.back.tracks.root",
+                       const char* fileNameBackTracks="tpc.back.tracks.root");
+Bool_t TRDFindClusters(Int_t nEvents=1, Int_t firstEvent=0,
+                     const char* fileNameParam="trd.sdigits.root", 
+                     const char* fileNameDigits="trd.digits.root", 
+                     const char* fileNameClusters="trd.clusters.root");
+Bool_t TRDFindTracks(Int_t nEvents=1, Int_t firstEvent=0,
+                   const char* fileNameSeeds="tpc.tracks.root",
+                   const char* fileNameClusters="trd.clusters.root",
+                   const char* fileNameTracks="trd.tracks.root",
+                    Bool_t inwards = kTRUE, Bool_t addSeeds = kTRUE);
+
+
+////////////////////////////////////////////////////////////////////////
+Int_t AliTRDTracking( Int_t nEvents, Int_t firstEvent,
+                     const char* fileNameParam,
+                     const char* fileNameDigits,
+                     const char* fileNameSeeds,
+                     const char* fileNameClusters,
+                     const char* fileNameTracks) {
+
+  AliTracker::SetFieldFactor(fileNameParam,kFALSE);
+
+// ********** Find TRD clusters *********** //
+  if (fileNameParam && fileNameDigits && fileNameClusters){
+    if (!TRDFindClusters(nEvents,firstEvent,fileNameParam,fileNameDigits,fileNameClusters)) {
+      cerr<<"Failed to get TRD clusters: !\n";
+      return 1;
+    }
+  }      
+
+// ********** Find TRD tracks *********** //
+  if (fileNameSeeds && fileNameClusters && fileNameTracks) {
+    if (!TRDFindTracks(nEvents,firstEvent,fileNameSeeds,fileNameClusters,fileNameTracks)) {
+      cerr<<"Failed to get TRD tracks !\n";
+      return 2;
+    }
+  }
+
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+Bool_t ITSPropagateBack(Int_t nEvents, Int_t firstEvent,
+                       const char* fileNameClusters,
+                       const char* fileNameTracks,
+                       const char* fileNameBackTracks)
+{
+  const char *name="ITSPropagateBack";
+  if (gDEBUG>1) cout<<name<<" starts...\n";
+  if (gDEBUG>1) gBenchmark->Start(name);
+
+  TFile* clustersFile = TFile::Open(fileNameClusters);
+  if (!clustersFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameClusters<<" !\n"; 
+    return kFALSE;
+  }
+  TFile* tracksFile = NULL;
+  TFile* backTracksFile = NULL;
+  if (strcmp(fileNameTracks, fileNameBackTracks) == 0) {
+    tracksFile = backTracksFile = TFile::Open(fileNameTracks, "UPDATE");
+  } else {
+    backTracksFile = TFile::Open(fileNameBackTracks, "RECREATE");
+    tracksFile = TFile::Open(fileNameTracks);
+  }
+  if (!tracksFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameTracks<<" !\n"; 
+    return kFALSE;
+  }
+
+  gROOT->cd();
+  AliITSgeom* geom = (AliITSgeom*) clustersFile->Get("AliITSgeom");
+  AliITStrackerV2 tracker(geom);
+  clustersFile->cd();
+
+  for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
+    tracker.SetEventNumber(iEvent);
+    tracker.PropagateBack(tracksFile, backTracksFile);
+  }
+
+  if (tracksFile != backTracksFile) {
+    backTracksFile->Close();
+    delete backTracksFile;
+  }
+  tracksFile->Close();
+  delete tracksFile;
+  clustersFile->Close();
+  delete clustersFile;
+
+  if (gDEBUG>1) gBenchmark->Show(name);
+  return kTRUE;
+}
+////////////////////////////////////////////////////////////////////////
+Bool_t TPCPropagateBack(Int_t nEvents, Int_t firstEvent,
+                       const char* fileNameClusters,
+                       const char* fileNameTracks,
+                       const char* fileNameITSBackTracks,
+                       const char* fileNameBackTracks)
+{
+  const char *name="TPCPropagateBack";
+  if (gDEBUG>1) cout<<name<<" starts...\n";
+  if (gDEBUG>1) gBenchmark->Start(name);
+
+  TFile* clustersFile = TFile::Open(fileNameClusters);
+  if (!clustersFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameClusters<<" !\n"; 
+    return kFALSE;
+  }
+  TFile* itsBackFile = NULL;
+  if (fileNameITSBackTracks) {
+    itsBackFile = TFile::Open(fileNameITSBackTracks);
+    if (!itsBackFile->IsOpen()) {
+      cerr<<"Cannot open "<<fileNameITSBackTracks<<" !\n"; 
+      return kFALSE;
+    }
+  }
+  TFile* tracksFile = NULL;
+  TFile* backTracksFile = NULL;
+  if (strcmp(fileNameTracks, fileNameBackTracks) == 0) {
+    tracksFile = backTracksFile = TFile::Open(fileNameTracks, "UPDATE");
+  } else {
+    backTracksFile = TFile::Open(fileNameBackTracks, "RECREATE");
+    tracksFile = TFile::Open(fileNameTracks);
+  }
+  if (!tracksFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameTracks<<" !\n"; 
+    return kFALSE;
+  }
+
+  gROOT->cd();
+  AliTPCParam* tpcParam = (AliTPCParam*) 
+    clustersFile->Get("75x40_100x60_150x60");
+  if (!tpcParam) tpcParam = new AliTPCParamSR;
+  AliTPCtracker tracker(tpcParam);
+  clustersFile->cd();
+
+  for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
+    tracker.SetEventNumber(iEvent);
+    tracker.PropagateBack(tracksFile, itsBackFile, backTracksFile);
+  }
+
+  if (tracksFile != backTracksFile) {
+    backTracksFile->Close();
+    delete backTracksFile;
+  }
+  tracksFile->Close();
+  delete tracksFile;
+  clustersFile->Close();
+  delete clustersFile;
+
+  if (gDEBUG>1) gBenchmark->Show(name);
+  return kTRUE;
+}
+////////////////////////////////////////////////////////////////////////
+Bool_t TRDFindClusters(Int_t nEvents, Int_t firstEvent,
+                     const char* fileNameParam, 
+                     const char* fileNameDigits, const char* fileNameClusters) {
+  
+  const char *name="TRDFindClusters";
+  if (gDEBUG>1) cout<<name<<" starts...\n";
+  if (gDEBUG>1) gBenchmark->Start(name);
+
+  TFile* paramFile = TFile::Open(fileNameParam);
+  if (!paramFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameParam<<" !\n"; 
+    return kFALSE;
+  }
+  AliTRDparameter* trdParam = 
+    (AliTRDparameter*) paramFile->Get("TRDparameter"); 
+  if (!trdParam) {
+    cerr << "TRD parameters have not been found !\n"; 
+    return kFALSE;
+  }
+  trdParam->ReInit();
+  AliTRDclusterizerV1 clusterizer("clusterizer", "Clusterizer class"); 
+  clusterizer.SetParameter(trdParam);
+
+  for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
+    clusterizer.Open(fileNameDigits, fileNameClusters, iEvent);
+    clusterizer.ReadDigits();
+    clusterizer.MakeClusters();
+    clusterizer.WriteClusters(-1);
+  }
+
+  paramFile->Close();
+  delete paramFile;
+
+  if (gDEBUG>1) gBenchmark->Show(name);
+  return kTRUE;
+}
+////////////////////////////////////////////////////////////////////////
+Bool_t TRDFindTracks(Int_t nEvents, Int_t firstEvent,
+                   const char* fileNameSeeds,
+                    const char* fileNameClusters, const char* fileNameTracks,
+                    Bool_t inwards, Bool_t addSeeds) {
+
+  const char *name="TRDFindTracks";
+  if (gDEBUG>1) cout<<name<<" starts...\n";
+  if (gDEBUG>1) gBenchmark->Start(name);
+
+  TFile* seedsFile = TFile::Open(fileNameSeeds);
+  if (!seedsFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameSeeds<<" !\n"; 
+    return kFALSE;
+  }
+  TFile* clustersFile = TFile::Open(fileNameClusters);
+  if (!clustersFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameClusters<<" !\n"; 
+    return kFALSE;
+  }
+  TFile* tracksFile = TFile::Open(fileNameTracks, "recreate");
+  if (!tracksFile->IsOpen()) {
+    cerr<<"Cannot open "<<fileNameTracks<<" !\n"; 
+    return kFALSE;
+  }
+
+  AliTRDtracker tracker(clustersFile);
+  if (addSeeds) tracker.SetAddTRDseeds();
+  clustersFile->cd();  
+  for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++) {
+    printf("Processing event %d\n", iEvent);
+    tracker.SetEventNumber(iEvent);
+    tracker.PropagateBack(seedsFile, tracksFile);
+    if (inwards) tracker.Clusters2Tracks(tracksFile, tracksFile);
+  }
+
+  seedsFile->Close();
+  delete seedsFile;
+  clustersFile->Close();
+  delete clustersFile;
+  tracksFile->Close();
+  delete tracksFile;
+
+  if (gDEBUG>1) gBenchmark->Show(name);
+  return kTRUE;
+}
+