FairRoot/PandaRoot
gem_digi.C
Go to the documentation of this file.
1 // Macro created by Radoslaw Karabowicz
2 // This macro takes MC file and produces digis only
3 
4 Int_t gem_digi(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 0;
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 MCFile = baseName + ".root";
18  TString parFile = baseName + "_par.root";
19  TString outFile = baseName + "_digi.root";
20 
21  std::cout << "Output File: " << outFile.Data()<< std::endl;
22 
23  // ----- Timer --------------------------------------------------------
24  TStopwatch timer;
25  timer.Start();
26 
27 
28  // ----- Reconstruction run -------------------------------------------
29  FairRunAna *fRun= new FairRunAna();
30  fRun->SetInputFile(MCFile);
31  fRun->SetOutputFile(outFile);
32  fRun->SetUseFairLinks(kTRUE);
33 
34  // ----- Parameter database --------------------------------------------
35  //TString allDigiFile = sysFile+"/macro/params/gem_3Stations.digi.par";
36  TString allDigiFile = sysFile+"/macro/params/gem_3Stations_realistic_v1.digi.par";
37  if ( nStations == 4 ) allDigiFile = sysFile+"/macro/params/gem_4Stations.digi.par";
38 
39  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
40  FairParRootFileIo* parInput1 = new FairParRootFileIo();
41  parInput1->open(parFile.Data());
42 
43  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
44  parIo1->open(allDigiFile.Data(),"in");
45 
46  rtdb->setFirstInput(parInput1);
47  rtdb->setSecondInput(parIo1);
48  // ------------------------------------------------------------------------
49 
50  // ----- GEM Digitizer -----------------------------------------------
51  PndGemDigitize* gemDigitize = new PndGemDigitize("GEM Digitizer", verboseLevel);
52  fRun->AddTask(gemDigitize);
53 
54 
55  // ----- Intialise and run --------------------------------------------
56  fRun->Init();
57  fRun->Run(0,nEvents);
58 
59 
60  // ----- Finish -------------------------------------------------------
61  timer.Stop();
62  Double_t rtime = timer.RealTime();
63  Double_t ctime = timer.CpuTime();
64  cout << endl << endl;
65  cout << "Macro finished succesfully." << endl;
66  cout << "Output file is " << outFile << endl;
67  cout << "Parameter file is " << parFile << endl;
68  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
69  cout << endl;
70 
71  return 1;
72 }
73 
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString outFile
Definition: hit_dirc.C:17
TString allDigiFile
Definition: hit_muo.C:36
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
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Double_t ctime
Definition: hit_dirc.C:114
PndGemDigitize * gemDigitize
FairParAsciiFileIo * parIo1
Definition: bump_emc.C:53
TString MCFile
Int_t gem_digi(Int_t nStations, Double_t momentum=15., Int_t nEvents=1000, int verboseLevel=0)
Definition: gem_digi.C:4
Double_t rtime
Definition: hit_dirc.C:113