FairRoot/PandaRoot
Functions
runLumiPixel2Reco.C File Reference

Go to the source code of this file.

Functions

int runLumiPixel2Reco (const int nEvents=10, const int startEvent=0, TString storePath="tmpOutput", std::string alignment_matrices_path="", std::string misalignment_matrices_path="", bool use_point_transform_misalignment=false, const int verboseLevel=0)
 

Function Documentation

int runLumiPixel2Reco ( const int  nEvents = 10,
const int  startEvent = 0,
TString  storePath = "tmpOutput",
std::string  alignment_matrices_path = "",
std::string  misalignment_matrices_path = "",
bool  use_point_transform_misalignment = false,
const int  verboseLevel = 0 
)

Definition at line 1 of file runLumiPixel2Reco.C.

References ctime, DigiFile, Double_t, fRun, gGeoManager, PndLmdPixelClusterTask::Init(), nEvents, outFile, parFile, parInput1, rtdb, rtime, startEvent, storePath, timer, TString, and verboseLevel.

4  {
5  // ========================================================================
6  TString DigiFile = storePath + "/Lumi_digi_"; //"/Lumi_digi_noise_";//"/Lumi_digi_";
7  DigiFile += startEvent;
8  DigiFile += ".root";
9  // Parameter file
10  TString parFile = storePath + "/Lumi_Params_";
11  parFile += startEvent;
12  parFile += ".root";
13 
14  // Output file
15  TString outFile = storePath + "/Lumi_reco_";
16  outFile += startEvent;
17  outFile += ".root";
18 
19  //std::cout << "MCFile : " << MCFile.Data()<< std::endl;
20  //std::cout << "DigiFile: " << DigiFile.Data() << std::endl;
21  //std::cout << "RecoFile: " << outFile.Data() << std::endl;
22 
23  // ----- Timer --------------------------------------------------------
24  TStopwatch timer;
25  timer.Start();
26  // ------------------------------------------------------------------------
27 
28  // ----- Reconstruction run -------------------------------------------
29  FairRunAna *fRun = new FairRunAna();
30  FairFileSource input_source(DigiFile);
31  fRun->SetSource(&input_source);
32  fRun->SetOutputFile(outFile);
33  // ------------------------------------------------------------------------
34 
35  // ----- Parameter database --------------------------------------------
36  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
37  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
38  parInput1->open(parFile.Data(), "UPDATE");
39 // FairParAsciiFileIo* parInput1 = new FairParAsciiFileIo();
40 // parInput1->open(parFile.Data(),"in");
41  rtdb->setFirstInput(parInput1);
42 
43  // alignment parameter file
44  // TString alignparFile = "lumi.align.par";//perfect! OLD
45  // TString alignparFile = "lumi.misalign.par";//misalignment! OLD
46  // TString alignparFile = "lumi.align_pixel_ideal.par";//perfect
47  /* TString alignparFile;
48  if(misalign){
49  alignparFile = storePath+"/lumi.misalign_pixel.par";//misalign
50  }
51  else{
52  alignparFile = "LMD_alignment/lumi.align_pixel_ideal.par";//perfect
53  }
54 
55  FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
56  parInput2->open(alignparFile.Data(),"in");
57  rtdb->setSecondInput(parInput2);*/
58 
59  /*Bool_t kParameterMerged=kTRUE;
60  FairParRootFileIo* output=new FairParRootFileIo(kParameterMerged);
61  output->open(parOutFile);
62  rtdb->setOutput(output);
63  */
64 // fRun->LoadGeometry();
65  // ------------------------------------------------------------------------
66  // =========================================================================
67  // ====== Hit Producers ======
68  // =========================================================================
69  // ----- LMD hit producer --------------------------------------------
71  lmdmccls->SetVerbose(verboseLevel);
72 
73  fRun->AddTask(lmdmccls);
74  rtdb->setOutput(parInput1);
75  rtdb->print();
76  // ===== End of HitProducers =====
77  // =========================================================================
78 
79  // set misalignement matrices to perform point transformations
80  if (misalignment_matrices_path != "" && use_point_transform_misalignment) {
81  // check if file exists, if true, try to read it
82  TFile *misalignmentMatrixRootfile = new TFile(misalignment_matrices_path.c_str(), "READ");
83  if (misalignmentMatrixRootfile->IsOpen()) {
84  std::map < std::string, TGeoHMatrix > *matrices;
85 
86  gDirectory->GetObject("PndLmdMisalignMatrices", matrices);
87  misalignmentMatrixRootfile->Close();
88 
89  cout << matrices->size() << " matrices successfully read from file.";
90 
91  //this call has to be made before fRun->Init();
92  fRun->AddAlignmentMatrices(*matrices, use_point_transform_misalignment);
93  cout << "matrices set!\n";
94  }
95  }
96 
97  if (alignment_matrices_path != "") {
98  //load matrices
99  TFile *alignmentMatrixRootfile = new TFile(alignment_matrices_path.c_str(), "READ");
100 
101  if (alignmentMatrixRootfile->IsOpen()) {
102  std::map < std::string, TGeoHMatrix > *matrices;
103 
104  gDirectory->GetObject("PndLmdMisalignMatrices", matrices);
105  alignmentMatrixRootfile->Close();
106 
107  cout << matrices->size() << " matrices successfully read from file.\n";
108 
109  //this call has to be made before fRun->Init();
110  fRun->AddAlignmentMatrices(*matrices);
111  }
112  else {
113  cout << "file could not be read\n";
114  return 1;
115  }
116  }
117 
118  // ----- Intialise and run --------------------------------------------
119  fRun->Init();
120 
121  fRun->Run(0, nEvents);
122  // ------------------------------------------------------------------------
123 
124  rtdb->saveOutput();
125  rtdb->print();
126  // ----- Finish -------------------------------------------------------
127  timer.Stop();
128  Double_t rtime = timer.RealTime();
129  Double_t ctime = timer.CpuTime();
130  cout << endl << endl;
131  cout << "Macro finished succesfully." << endl;
132  cout << "Output file is " << outFile << endl;
133  cout << "Parameter file is " << parFile << endl;
134  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
135  cout << endl;
136  // ------------------------------------------------------------------------
137 
138  // temporary fix to avoid double frees at the destruction of te program for pandaroot/fairroot with root6
139  gGeoManager->GetListOfVolumes()->Delete();
140  gGeoManager->GetListOfShapes()->Delete();
141  delete gGeoManager;
142 
143  return 0;
144 }
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString outFile
Definition: hit_dirc.C:17
Int_t startEvent
TString storePath
TGeoManager * gGeoManager
FairRunAna * fRun
Definition: hit_dirc.C:58
TString DigiFile
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
Double_t rtime
Definition: hit_dirc.C:113