Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_RunCorrelatorQAModules.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_RunCorrelatorQAModules.C
1 // ----------------------------------------------------------------------------
2 // 'Fun4All_RunCorrelatorQAModules.C'
3 // Derek Anderson
4 // 12.27.2023
5 //
6 // A F4A macro to run correlator QA modules.
7 // ----------------------------------------------------------------------------
8 
9 #ifndef FUN4ALL_RUNCORRELATORQAMODULES_C
10 #define FUN4ALL_RUNCORRELATORQAMODULES_C
11 
12 // c++ utilities
13 #include <vector>
14 #include <string>
15 #include <cstdlib>
16 #include <utility>
17 // f4a/sphenix utilities
18 #include <FROG.h>
19 #include <G4_Magnet.C>
22 // tracking utilities
23 #include <Trkr_QA.C>
24 #include <Trkr_Reco.C>
25 #include <Trkr_Eval.C>
26 #include <Trkr_RecoInit.C>
27 #include <Trkr_Clustering.C>
28 #include <Trkr_Diagnostics.C>
29 #include <G4_TrkrSimulation.C>
30 #include <g4eval/SvtxEvaluator.h>
32 // calo/pf libraries
33 #include <caloreco/RawClusterBuilderTopo.h>
34 #include <particleflowreco/ParticleFlowReco.h>
35 // user includes
36 #include "/sphenix/user/danderson/eec/SCorrelatorQAMaker/src/SCorrelatorQAMaker.h"
37 #include "/sphenix/user/danderson/eec/SCorrelatorQAMaker/src/SCheckTrackPairs.h"
38 #include "/sphenix/user/danderson/eec/SCorrelatorQAMaker/src/SMakeTrkQATuples.h"
39 #include "/sphenix/user/danderson/eec/SCorrelatorUtilities/TrkTools.h"
40 
41 using namespace std;
42 using namespace SColdQcdCorrelatorAnalysis;
43 using namespace SColdQcdCorrelatorAnalysis::SCorrelatorUtilities;
44 
45 // load libraries
46 R__LOAD_LIBRARY(libg4eval.so)
47 R__LOAD_LIBRARY(libfun4all.so)
48 R__LOAD_LIBRARY(libcalo_reco.so)
49 R__LOAD_LIBRARY(libparticleflow.so)
50 R__LOAD_LIBRARY(/sphenix/user/danderson/install/lib/libcorrelatorqamaker.so)
51 
52 // default input/output
53 static const vector<string> VecInFilesDefault = {
54  "DST_GLOBAL_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
55  "DST_TRKR_G4HIT_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
56  "DST_TRACKSEEDS_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
57  "DST_TRKR_CLUSTER_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
58  "DST_TRACKS_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
59  "DST_CALO_G4HIT_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
60  "DST_CALO_CLUSTER_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
61  "DST_TRUTH_G4HIT_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
62  "DST_TRUTH_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root"
63 };
64 static const vector<string> VecOutFilesDefault = {
65  "test.root",
66  "test1.root"
67 };
68 static const vector<string> VecOutDirDefault = {
69  "CheckTrackPairs",
70  "TrackQATuples"
71 };
72 
73 // other default arguments
74 static const int NEvtDefault = 10;
75 static const int VerbDefault = 0;
76 static const bool DebugDefault = false;
77 
78 
79 
80 // macro body -----------------------------------------------------------------
81 
83  const vector<string>& vecOutFiles = VecOutFilesDefault,
84  const vector<string>& vecOutDir = VecOutDirDefault,
85  const vector<string>& vecInFiles = VecInFilesDefault,
86  const int nEvents = NEvtDefault,
87  const int verbosity = VerbDefault,
88  const bool debug = DebugDefault
89 ) {
90 
91  // options ------------------------------------------------------------------
92 
93  // track & particle flow parameters
94  const bool runTracking(false);
95  const bool doTruthTableReco(false);
96 
97  // track minima
98  TrkInfo cfg_trkMin;
99  cfg_trkMin.nMvtxLayer = 2.;
100  cfg_trkMin.nInttLayer = 1.;
101  cfg_trkMin.nTpcLayer = 24.;
102  cfg_trkMin.pt = 0.2;
103  cfg_trkMin.eta = -1.1;
104  cfg_trkMin.dcaXY = -5.;
105  cfg_trkMin.dcaZ = -5.;
106  cfg_trkMin.ptErr = 0.;
107  cfg_trkMin.quality = 0.;
108 
109  // track maxima
110  TrkInfo cfg_trkMax;
111  cfg_trkMax.nMvtxLayer = 100.;
112  cfg_trkMax.nInttLayer = 100.;
113  cfg_trkMax.nTpcLayer = 100.;
114  cfg_trkMax.pt = 100.;
115  cfg_trkMax.eta = 1.1;
116  cfg_trkMax.dcaXY = 5.;
117  cfg_trkMax.dcaZ = 5.;
118  cfg_trkMax.ptErr = 0.5;
119  cfg_trkMax.quality = 10.;
120 
121  // SCheckTrackPairs configuration
122  SCheckTrackPairsConfig cfg_checkTrackPairs = {
123  .doDcaSigCut = false,
124  .requireSiSeed = true,
125  .useOnlyPrimVtx = true,
126  .minAccept = cfg_trkMin,
127  .maxAccept = cfg_trkMax
128  };
129 
130  // SMakeTrkQATuples configuration
131  SMakeTrkQATuplesConfig cfg_makeTrackQATuples = {
132  .isEmbed = true,
133  .doDcaSigCut = false,
134  .requireSiSeed = true,
135  .useOnlyPrimVtx = true,
136  .minAccept = cfg_trkMin,
137  .maxAccept = cfg_trkMax
138  };
139 
140  // initialize f4a -----------------------------------------------------------
141 
142  // load libraries and create f4a server
143  gSystem -> Load("libg4dst.so");
144  gSystem -> Load("libFROG.so");
145 
146  FROG* frog = new FROG();
147  Fun4AllServer* ffaServer = Fun4AllServer::instance();
148  ffaServer -> Verbosity(verbosity);
149 
150  // add input files
151  for (size_t iInput = 0; iInput < vecInFiles.size(); iInput++) {
152  Fun4AllDstInputManager* inManager = new Fun4AllDstInputManager("InputDstManager" + to_string(iInput));
153  inManager -> AddFile(vecInFiles.at(iInput));
154  ffaServer -> registerInputManager(inManager);
155  }
156 
157  // set up tracking and truth tables -----------------------------------------
158 
159  // run the tracking if not already done
160  if (runTracking) {
161 
162  // enable mms
163  Enable::MICROMEGAS = true;
164 
165  // initialize magnetic field
167  MagnetInit();
168  MagnetFieldInit();
169 
170  // initialize tracker cells
171  Mvtx_Cells();
172  Intt_Cells();
173  TPC_Cells();
175 
176  // initialize tracking
177  TrackingInit();
178 
179  // do tracker clustering & reconstruction
180  Mvtx_Clustering();
181  Intt_Clustering();
182  TPC_Clustering();
184  Tracking_Reco();
185  }
186 
187  // construct track/truth table
188  if (doTruthTableReco) {
190  tables -> Verbosity(verbosity);
191  if (runTracking) {
192  ffaServer -> registerSubsystem(tables);
193  }
194  }
195 
196  // register qa makers -------------------------------------------------------
197 
198  // instantiate qa maker and plugins
199  SCorrelatorQAMaker* maker = new SCorrelatorQAMaker();
200  maker -> InitPlugin(cfg_checkTrackPairs, "CheckTrackPairs");
201  maker -> InitPlugin(cfg_makeTrackQATuples, "MakeTrackQATuples");
202  //maker -> SetGlobalOutFile(vecOutFiles.at(0));
203  maker -> CheckTrackPairs() -> SetOutFile(vecOutFiles.at(0));
204  maker -> MakeTrackQATuples() -> SetOutFile(vecOutFiles.at(1));
205  maker -> SetGlobalVerbosity(verbosity);
206  maker -> SetGlobalDebug(debug);
207  maker -> CheckTrackPairs() -> SetOutDir(vecOutDir.at(0));
208  maker -> MakeTrackQATuples() -> SetOutDir(vecOutDir.at(1));
209  ffaServer -> registerSubsystem(maker -> CheckTrackPairs());
210  ffaServer -> registerSubsystem(maker -> MakeTrackQATuples());
211 
212  // run and close f4a --------------------------------------------------------
213 
214  // run reconstruction & close f4a
215  ffaServer -> run(nEvents);
216  ffaServer -> End();
217  delete ffaServer;
218 
219  // announce end & exit
220  gSystem -> Exit(0);
221  return;
222 
223 }
224 
225 #endif
226 
227 // end ------------------------------------------------------------------------