FairRoot/PandaRoot
runLumiPixel2fMatrixFinder.C
Go to the documentation of this file.
1 /*
2  * @author: Roman Klasen, roklasen@uni-mainz.de or klasen@kph.uni-mainz.de
3  */
4 
5 // initialize a minimal, boiler plate FairRunAna so the gGeoManager loads the geometry
7 
8  //FIXME: don't hard code starting event!
9  TString inFile = storePath + "/Lumi_MC_1000000.root";
10  TString parFile = storePath + "/Lumi_Params_1000000.root";
11  TString outFile = storePath + "/Lumi_digi_0-dummy.root";
12  FairRunAna *fRun = new FairRunAna();
13  FairFileSource *input_source = new FairFileSource(inFile);
14  fRun->SetSource(input_source);
15  fRun->SetOutputFile(outFile);
16  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
17  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
18  parInput1->open(parFile.Data(), "in");
19  rtdb->setFirstInput(parInput1);
20  FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
21  rtdb->setSecondInput(parInput2);
22  fRun->Init();
23 }
24 
25 void cleanup(){
26  // ----- Finish -------------------------------------------------------
27  // temporary fix to avoid double frees at the destruction of te program for pandaroot/fairroot with root6
28  gGeoManager->GetListOfVolumes()->Delete();
29  gGeoManager->GetListOfShapes()->Delete();
30  delete gGeoManager;
31 
32 }
33 
34 int runLumiPixel2fMatrixFinder(TString pairFilePath = "tmpOutput", TString binaryPairFilePath = "",
35  TString LMDmatrixDir = "", bool incentimeters = true, const int verboseLevel = 2) {
36  // ----- Timer --------------------------------------------------------
37 
38  //load neccessary libraries
39  //gSystem->Load("libLmd");
40  //gSystem->Load("libLmdSensorAligner");
41 
42  //FIXME: don't hard code starting event!
43  cout << "populating gGeoManager with geometry data...\n";
44 
45  initMiniAna(pairFilePath);
46 
47  // don't forget trailing slashes!!
48  if (LMDmatrixDir == "") {
49  LMDmatrixDir = pairFilePath + "/LMDmatrices/";
50  }
51  if (binaryPairFilePath == "") {
52  binaryPairFilePath = pairFilePath + "/binaryPairs/";
53  }
54 
55  int readNoOfFiles = 0; //how many files should be processed? 0 for all
56 
57  PndLmdAlignManager manager;
58 
59  manager.setInCentimeters(incentimeters);
60  manager.setBinaryPairFileDirectory(binaryPairFilePath.Data());
61  manager.setMaxPairs(7e5);
62  manager.verboseLevel(verboseLevel);
63  manager.setMaxThreads(16);
64 
65  cout << "pairFilePath: " << pairFilePath << "\n";
66  cout << "binaryPairFilePath: " << binaryPairFilePath << "\n";
67  cout << "LMDmatrixDir: " << LMDmatrixDir << "\n";
68 
69  // ---------------------- check for binary files and sort/write, if necessary
70  cout << "looking for binary pair files...\n";
71  bool binaryPairsPresent = manager.checkForBinaryFiles();
72  if (!binaryPairsPresent) {
73  cout << "None found, reading pair root files...\n";
74 
75  manager.addFilesFromDirectory(pairFilePath.Data(), readNoOfFiles);
76  manager.setMatrixOutDir(LMDmatrixDir.Data());
77  manager.readFilesAndAlign();
78  }
79  else {
80  cout << "binary pair files found.\n";
81  //check for LMD Matrix Files
82  bool LMDMatrixFilesPresent = manager.checkForLmdMatrixFiles();
83  if (!LMDMatrixFilesPresent) {
84  cout << "reading binary pair files.\n";
85  manager.setMatrixOutDir(LMDmatrixDir.Data());
87  }
88  }
89 
90  //manager.computeCombinedMatrices();
91  // ---------------------- compute absolute correction matrices from overlap matrices and store to PndLmdDim format, compare to pndLmdDim
92  //TODO: well, this ^
93  // steps:
94  /*
95  * gather all modules
96  * gather all overlapping areas for each module
97  * compute all combined matrices for each module (this can be done multi-threadedly)
98  * store them in a good way (how?)
99  *
100  */
101 
102 
103  //cleanup();
104  return 0;
105 }
106 
void setMatrixOutDir(std::string directory)
void cleanup()
void setInCentimeters(bool inCentimeters)
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString outFile
Definition: hit_dirc.C:17
TString storePath
TString inFile
Definition: hit_dirc.C:8
TGeoManager * gGeoManager
FairRunAna * fRun
Definition: hit_dirc.C:58
TString parFile
Definition: hit_dirc.C:14
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParAsciiFileIo * parInput2
Definition: conMvdDigi.C:26
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
void setMaxThreads(int NmaxThreads=0)
void verboseLevel(int verbose)
void initMiniAna(TString storePath)
void setBinaryPairFileDirectory(const std::string &directory)
int runLumiPixel2fMatrixFinder(TString pairFilePath="tmpOutput", TString binaryPairFilePath="", TString LMDmatrixDir="", bool incentimeters=true, const int verboseLevel=2)
int addFilesFromDirectory(std::string directory, int maxFiles=0)
void setMaxPairs(int maxPairs)