FairRoot/PandaRoot
runLumiPixel2dDynamicCutFinder.C
Go to the documentation of this file.
1 /*
2  * Finds pixel hit pairs and stores them to pair File
3  *
4  * Author: Roman Klasen, roklasen@uni-mainz.de or klasen@kph.uni-mainz.de
5  *
6  */
7 
8 void runLumiPixel2dDynamicCutFinder(const int nEvents=0, const int startEvent=00000, TString storePath="test/fullrun-1.5/digi", const int verboseLevel=0)
9 {
10  // ----- Timer --------------------------------------------------------
11  TStopwatch timer;
12  timer.Start();
13 
14  //gSystem->Load("libLmd");
15  //gSystem->Load("libLmdPairFinder");
16  //gSystem->Load("libLmdSensorAligner");
17 
18  cout << "***********************\n";
19  cout << "Running PairFinderTask.\n";
20  cout << "***********************\n";
21 
22  // ----- Input File ----------------------------------------------------
23  TString inFile=storePath+"/Lumi_digi_";
24  inFile += startEvent;
25  inFile += ".root";
26  TString inFileReco=storePath+"/Lumi_reco_";
27  inFileReco += startEvent;
28  inFileReco += ".root";
29 
30 
31  /*
32  * This is very ugly. I don't need an output file here, but the FairRunAna segfaults when none is specified.
33  * So I create a temp file and delete it afterwards.
34  */
35  // // ----- Parameter Files ------------------------------------------------
36  TString parFile=storePath+"/Lumi_Params_";
37  parFile += startEvent;
38  parFile += ".root";
39  TString digiparFile = "lumi.digi.par";
40  TString cutParameterfile = storePath + TString("/cutParameters.json");
41 
42  cout << "===================\ncut parameter file: "<< cutParameterfile << "\n===================\n";
43 
44  // ----- Output File --------------------------------------------------
45  TString outFile = storePath+"/Lumi_TEMP_";
46  outFile += startEvent;
47  outFile += ".root";
48  //std::cout << "DigiFileName: " << outFile.Data() << std::endl;
49 
50 
51  // ----- Reconstruction run -------------------------------------------
52  FairRunAna *fRun = new FairRunAna();
53  FairFileSource input_source(inFile);
54  input_source.AddFriend(inFileReco);
55  fRun->SetSource(&input_source);
56  fRun->SetOutputFile(outFile);
57  // ------------------------------------------------------------------------
58 
59 
60  // // ----- Pair Finder / Cut Finder Runs -------------------------------------------
61  // FairRunAna *fRun= new FairRunAna();
62  // fRun->SetInputFile(inFile);
63  // fRun->SetOutputFile(outFile);
64  // fRun->SetEventMeanTime(50);// TODO: 50 ???
65 
66  // ----- Parameter database --------------------------------------------
67  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
68  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
69  parInput1->open(parFile.Data(),"UPDATE");
70  rtdb->setFirstInput(parInput1);
71  //FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
72  //parInput2->open(digiparFile.Data(),"in");
73  //rtdb->setSecondInput(parInput2);
74 
75 
76  // =========================================================================
77  // ===== Start of CutFinder =====
78  // ----- Actual Task ---------------------------------------------------
79 
80  //find dynamic cut parameters
81  LmdPairFinderTask* lmdPairFinder = new LmdPairFinderTask();
82  lmdPairFinder->findDynamicCutParameters(true, cutParameterfile.Data() );
83  fRun->AddTask(lmdPairFinder);
84 
85  // this line is important! is changes the param file for the next macro
86  rtdb->setOutput(parInput1);
87  //rtdb->print();
88  // ===== End of PairFinder =====
89  // =========================================================================
90 
91  // ----- No Idea what this does ----------------------------------------
92  //PndSdsGeoPar* geoPar = (PndSdsGeoPar*)(rtdb->getContainer("PndSdsGeoPar"));
93 
94  // ----- Initialize and run PairFinder ----------------------------------
95  fRun->Init();
96  fRun->Run(0,nEvents);
97  //rtdb->saveOutput();
98  //rtdb->print();
99  //remove(outFile);
100 
101  // temporary fix to avoid double frees at the destruction of te program for pandaroot/fairroot with root6
102  gGeoManager->GetListOfVolumes()->Delete();
103  gGeoManager->GetListOfShapes()->Delete();
104  delete gGeoManager;
105 
106 
107  return;
108 }
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 inFile
Definition: hit_dirc.C:8
TString parFile
Definition: hit_dirc.C:14
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
void runLumiPixel2dDynamicCutFinder(const int nEvents=0, const int startEvent=00000, TString storePath="test/fullrun-1.5/digi", const int verboseLevel=0)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
TString digiparFile