FairRoot/PandaRoot
gem_fitTracks.C
Go to the documentation of this file.
1 // Macro created by Radoslaw Karabowicz
2 // This macro takes the digis and find hits
3 
4 Int_t gem_fitTracks(Int_t nStations, Double_t momentum = 15., Int_t nEvents = 1000, int verboseLevel = 0)
5 {
6  if ( nStations != 3 && nStations != 4 ) {
7  cout << "WRONG number of stations, only 3 or 4 allowed." << endl;
8  return;
9  }
10 
11  TString sysFile = gSystem->Getenv("VMCWORKDIR");
12 
13  // Input file (MC events)
14  TString baseName;
15  baseName.Form("Gem_%dStations_%gGeV_n%d",nStations,momentum,nEvents);
16 
17  TString parFile = baseName + "_par.root";
18  TString MCFile = baseName + ".root";
19  TString digFile = baseName + "_digi.root";
20  TString hitFile = baseName + "_hits.root";
21  TString trkFile = baseName + "_tracks.root";
22  // ------------------------------------------------------------------------
23  TString outFile = baseName + "_fitTracks.root";
24  std::cout << "Output File: " << outFile.Data()<< std::endl;
25 
26  // ----- Timer --------------------------------------------------------
27  TStopwatch timer;
28  timer.Start();
29 
30 
31  // ----- Reconstruction run -------------------------------------------
32  FairRunAna *fRun= new FairRunAna();
33  fRun->SetInputFile(trkFile);
34  fRun->AddFriend(MCFile);
35  fRun->AddFriend(digFile);
36  fRun->AddFriend(hitFile);
37  fRun->SetOutputFile(outFile);
38  fRun->SetUseFairLinks(kTRUE);
39 
40  // ----- Parameter database --------------------------------------------
41  //TString allDigiFile = sysFile+"/macro/params/gem_3Stations.digi.par";
42  TString allDigiFile = sysFile+"/macro/params/gem_3Stations_realistic_v1.digi.par";
43  if ( nStations == 4 ) allDigiFile = sysFile+"/macro/params/gem_4Stations.digi.par";
44 
45  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
46  FairParRootFileIo* parInput1 = new FairParRootFileIo();
47  parInput1->open(parFile.Data());
48 
49  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
50  parIo1->open(allDigiFile.Data(),"in");
51 
52  rtdb->setFirstInput(parInput1);
53  rtdb->setSecondInput(parIo1);
54  // ------------------------------------------------------------------------
55 
56  // ----- Prepare GEANE --------------------------------------------
57  // this will load Geant3 and execute setup macros to initialize geometry:
58  FairGeane *Geane = new FairGeane();
59  fRun->AddTask(Geane);
60  //--------------------------------------------------
61 
62  // ----- Run Kalman fitter --------------------------------------------
64  recoKalman->SetTrackInBranchName("GEMTrack");
65  recoKalman->SetTrackOutBranchName("GEMFitTrack");
66  //recoKalman->SetNumIterations(3);
67  fRun->AddTask(recoKalman);
68  // -------------------------------------------------
69 
70 
71  // ----- Intialise and run --------------------------------------------
72  fRun->Init();
73  fRun->Run(0,nEvents);
74 
75 
76  // ----- Finish -------------------------------------------------------
77  timer.Stop();
78  Double_t rtime = timer.RealTime();
79  Double_t ctime = timer.CpuTime();
80  cout << endl << endl;
81  cout << "Macro finished succesfully." << endl;
82  cout << "Output file is " << outFile << endl;
83  cout << "Parameter file is " << parFile << endl;
84  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
85  cout << endl;
86 
87 }
88 
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString outFile
Definition: hit_dirc.C:17
TString allDigiFile
Definition: hit_muo.C:36
void SetTrackOutBranchName(const TString &name)
FairGeane * Geane
FairRunAna * fRun
Definition: hit_dirc.C:58
TString sysFile
Double_t
TString parFile
Definition: hit_dirc.C:14
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
TString hitFile
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Double_t ctime
Definition: hit_dirc.C:114
FairParAsciiFileIo * parIo1
Definition: bump_emc.C:53
void SetTrackInBranchName(const TString &name)
TString MCFile
PndRecoKalmanTask * recoKalman
Double_t rtime
Definition: hit_dirc.C:113
Int_t gem_fitTracks(Int_t nStations, Double_t momentum=15., Int_t nEvents=1000, int verboseLevel=0)
Definition: gem_fitTracks.C:4