Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_MDC2reco.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_MDC2reco.C
1 #include "HFReco.C"
2 
4 
5 #include <G4_Global.C>
6 #include <G4_Magnet.C>
7 #include <G4_ActsGeom.C>
8 #include <G4_TrkrSimulation.C>
9 
10 #include <Trkr_Clustering.C>
11 #include <Trkr_Reco.C>
12 #include <Trkr_RecoInit.C>
13 
14 #include <FROG.h>
16 #include <hftrackefficiency/HFTrackEfficiency.h>
17 
19 
20 #include <g4eval/SvtxEvaluator.h>
22 
24 #include <phool/recoConsts.h>
26 
27 R__LOAD_LIBRARY(libfun4all.so)
28 R__LOAD_LIBRARY(libdecayfinder.so)
29 R__LOAD_LIBRARY(libhftrackefficiency.so)
30 R__LOAD_LIBRARY(libg4vertex.so)
31 R__LOAD_LIBRARY(libglobalvertex.so)
32 
33 using namespace std;
34 using namespace HeavyFlavorReco;
35 
36 /****************************/
37 /* MDC2 Reco for MDC2 */
38 /* Cameron Dean, LANL, 2021 */
39 /* cdean@bnl.gov */
40 /****************************/
41 
42 void Fun4All_MDC2reco(vector<string> myInputLists = {"condorJob/fileLists/productionFiles-CHARM-dst_tracks-00000.list"}, const int nEvents = 0)
43 {
44  bool runDemo = true; //Run the pure Bs2JpsiKs0 reco
45 
46  gSystem->Load("libg4dst.so");
47  gSystem->Load("libFROG.so");
48  FROG *fr = new FROG();
49 
50  string outDir = "./";
51  if (!runDemo)
52  {
53  //The next set of lines figures out folder revisions, file numbers etc
54  if (outDir.substr(outDir.size() - 1, 1) != "/") outDir += "/";
55  outDir += reconstructionName + "/";
56 
57  string fileNumber = myInputLists[0];
58  size_t findLastDash = fileNumber.find_last_of("-");
59  if (findLastDash != string::npos) fileNumber.erase(0, findLastDash + 1);
60  string remove_this = ".list";
61  size_t pos = fileNumber.find(remove_this);
62  if (pos != string::npos) fileNumber.erase(pos, remove_this.length());
63  string outputFileName = "outputFile_" + reconstructionName + "_" + fileNumber + ".root";
64  string outputHFEffFileName = "outputHFEff_" + reconstructionName + "_" + fileNumber + ".root";
65 
66  string outputRecoDir = outDir + "inReconstruction/";
67  string makeDirectory = "mkdir -p " + outputRecoDir;
68  system(makeDirectory.c_str());
69  outputRecoFile = outputRecoDir + outputFileName;
70  if (runTrackEff) outputHFEffFile = outputRecoDir + outputHFEffFileName;
71  }
72 
74  // global tag
75  rc->set_StringFlag("CDB_GLOBALTAG", "MDC2");
76  // 64 bit timestamp
77  rc->set_uint64Flag("TIMESTAMP", 6);
78 
79  //Create the server
81  se->Verbosity(1);
82  if (runDemo)
83  {
85  infile->AddListFile("demo.list");
86  se->registerInputManager(infile);
87 
88  myDemoReco();
89  }
90  else
91  {
92  //Add all required input files
93  for (unsigned int i = 0; i < myInputLists.size(); ++i)
94  {
95  Fun4AllInputManager *infile = new Fun4AllDstInputManager("DSTin_" + to_string(i));
96  infile->AddListFile(myInputLists[i]);
97  se->registerInputManager(infile);
98  }
99 
100  // Runs decay finder to trigger on your decay. Useful for signal cleaning
101  if (runTruthTrigger)
102  {
103  DecayFinder *myFinder = new DecayFinder("myFinder");
104  myFinder->Verbosity(INT_MAX);
106  myFinder->saveDST(1);
107  myFinder->allowPi0(0);
108  myFinder->allowPhotons(1);
109  myFinder->triggerOnDecay(1);
110  myFinder->setPTmin(0.2); //Note: sPHENIX min pT is 0.2 GeV for tracking
111  myFinder->setEtaRange(-1.1, 1.1); //Note: sPHENIX acceptance is |eta| <= 1.1
112  se->registerSubsystem(myFinder);
113  }
114 
115  //Run the tracking if not already done
116  if (runTracking)
117  {
118  Enable::MICROMEGAS=true;
119 
121  MagnetInit();
122  MagnetFieldInit();
123 
124  Mvtx_Cells();
125  Intt_Cells();
126  TPC_Cells();
128 
129  TrackingInit();
130 
131  Mvtx_Clustering();
132  Intt_Clustering();
133  TPC_Clustering();
135 
136  Tracking_Reco();
137 
138  Global_Reco();
139  }
140 
141  if (buildTruthTable)
142  {
144  tables->Verbosity(VERBOSITY);
145  se->registerSubsystem(tables);
146  }
147 
148  if (runTrackEff)
149  {
150  HFTrackEfficiency *myTrackEff = new HFTrackEfficiency("myTrackEff");
151  myTrackEff->Verbosity(1);
152  myTrackEff->setDFNodeName("myFinder");
153  myTrackEff->triggerOnDecay(1);
154  myTrackEff->writeSelectedTrackMap(true);
155  myTrackEff->writeOutputFile(true);
156  myTrackEff->setOutputFileName(outputHFEffFile);
157  se->registerSubsystem(myTrackEff);
158  }
159 
160  //Now run the actual reconstruction
162  }
163 
164  se->run(nEvents);
165  se->End();
166 
167  if (!runDemo)
168  {
169  ifstream file(outputRecoFile.c_str());
170  if (file.good())
171  {
172  string moveOutput = "mv " + outputRecoFile + " " + outDir;
173  system(moveOutput.c_str());
174  }
175 
176  if (runTrackEff)
177  {
178  ifstream evalfile(outputHFEffFile.c_str());
179  if (evalfile.good())
180  {
181  string moveOutput = "mv " + outputHFEffFile + " " + outDir;
182  system(moveOutput.c_str());
183  }
184  }
185  }
186 
187  std::cout << "All done" << std::endl;
188  delete se;
189  gSystem->Exit(0);
190 
191  return;
192 }