Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fun4All_RunCorrelatorJetTree.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Fun4All_RunCorrelatorJetTree.C
1 // ----------------------------------------------------------------------------
2 // 'Fun4All_RunCorrelatorJetTree.C'
3 // Derek Anderson
4 // 12.11.2022
5 //
6 // Use this to run the SCorrelatorJetTree
7 // class.
8 //
9 // Derived from code by Cameron Dean and
10 // Antonio Silva (thanks!!)
11 //
12 // NOTE: jetType sets whether or not jets
13 // are full (charge + neutral) or charged
14 // jetType = 0: charged jets
15 // jetType = 1: full jets
16 // ----------------------------------------------------------------------------
17 
18 /****************************/
19 /* MDC2 Reco for MDC2 */
20 /* Cameron Dean, LANL, 2021 */
21 /* cdean@bnl.gov */
22 /****************************/
23 
24 // standard c includes
25 #include <vector>
26 #include <string>
27 #include <cstdlib>
28 #include <utility>
29 // f4a/sphenix includes
30 #include <FROG.h>
31 #include <G4_Magnet.C>
34 // tracking includes
35 #include <Trkr_QA.C>
36 #include <Trkr_Reco.C>
37 #include <Trkr_Eval.C>
38 #include <Trkr_RecoInit.C>
39 #include <Trkr_Clustering.C>
40 #include <Trkr_Diagnostics.C>
41 #include <G4_TrkrSimulation.C>
42 #include <g4eval/SvtxEvaluator.h>
44 // calo/pf includes
45 #include <caloreco/RawClusterBuilderTopo.h>
46 #include <particleflowreco/ParticleFlowReco.h>
47 // user includes
48 #include "/sphenix/user/danderson/install/include/scorrelatorjettree/SCorrelatorJetTree.h"
49 
50 // load libraries
51 R__LOAD_LIBRARY(libg4eval.so)
52 R__LOAD_LIBRARY(libfun4all.so)
53 R__LOAD_LIBRARY(libcalo_reco.so)
54 R__LOAD_LIBRARY(libparticleflow.so)
55 R__LOAD_LIBRARY(/sphenix/user/danderson/install/lib/libscorrelatorjettree.so)
56 
57 using namespace std;
58 using namespace SColdQcdCorrelatorAnalysis;
59 
60 // global constants
61 static const int NEvtDefault = 10;
62 static const int VerbDefault = 0;
63 static const size_t NTopoClusts = 2;
64 static const size_t NTopoPar = 3;
65 static const string SOutDefault = "testingPAuInput.root";
66 static const vector<string> SInDefault = {
67  "DST_GLOBAL_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
68  "DST_TRKR_G4HIT_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
69  "DST_TRACKSEEDS_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
70  "DST_TRKR_CLUSTER_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
71  "DST_TRACKS_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
72  "DST_CALO_G4HIT_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
73  "DST_CALO_CLUSTER_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
74  "DST_TRUTH_G4HIT_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root",
75  "DST_TRUTH_pythia8_Jet10_sHijing_pAu_0_10fm_500kHz_bkg_0_10fm-0000000009-00009.root"
76 };
77 
78 
79 
80 void Fun4All_RunCorrelatorJetTree(const vector<string>& sInput = SInDefault, const string sOutput = SOutDefault, const int nEvents = NEvtDefault, const int verbosity = VerbDefault) {
81 
82  // track & particle flow parameters
83  const bool runTracking(false);
84  const bool doTruthTableReco(false);
85  const double nSigma(1.5);
86 
87  // topo cluster parameters
88  const double showerR(0.025);
89  const double noiseLevels[NTopoPar] = {0.0025, 0.006, 0.03};
90  const double significance[NTopoPar] = {4.0, 2.0, 0.0};
91  const double localMinE[NTopoPar] = {1.0, 2.0, 0.5};
92  const bool enableHCal[NTopoClusts] = {false, true};
93  const bool enableECal[NTopoClusts] = {true, false};
94  const bool doSplit(true);
95  const bool allowCorners(true);
96 
97  // jet tree general parameters
98  const bool isMC(true);
99  const bool isEmbed(true);
100  const bool doDebug(false);
101  const bool saveDst(true);
102  const bool doVtxCut(false);
103  const bool doQuality(true);
104  const bool requireSiSeeds(true);
105  const bool useOnlyPrimVtx(true);
106  const bool doDcaSigmaCut(false);
107  const bool maskTpcSectors(false);
108  const bool checkWeirdTrks(false);
109  const bool addTracks(true);
110  const bool addECal(false);
111  const bool addHCal(false);
112  const bool addParticleFlow(false);
113 
114  // jet tree jet parameters
115  const double jetRes = 0.4;
116  const unsigned int jetType = 0;
117  const auto jetAlgo = SCorrelatorJetTree::ALGO::ANTIKT;
118  const auto jetReco = SCorrelatorJetTree::RECOMB::PT_SCHEME;
119 
120  // event acceptance
121  const pair<double, double> vzEvtRange = {-10., 10.};
122  const pair<double, double> vrEvtRange = {0.0, 0.418};
123 
124  // particle acceptance
125  const pair<double, double> ptParRange = {0., 9999.};
126  const pair<double, double> etaParRange = {-1.1, 1.1};
127 
128  // track acceptance
129  const pair<double, double> ptTrackRange = {0.2, 100.};
130  const pair<double, double> etaTrackRange = {-1.1, 1.1};
131  const pair<double, double> qualTrackRange = {0., 10.};
132  const pair<double, double> nMvtxTrackRange = {2., 100.};
133  const pair<double, double> nInttTrackRange = {1., 100.};
134  const pair<double, double> nTpcTrackRange = {24., 100.};
135  const pair<double, double> dcaTrackRangeXY = {-5., 5.};
136  const pair<double, double> dcaTrackRangeZ = {-5., 5.};
137  const pair<double, double> deltaPtTrackRange = {0., 0.5};
138 
139  // for pt dependent dca cuts
140  const pair<double, double> dcaPtFitMax = {15., 15.};
141  const pair<double, double> nDcaSigmaTrack = {3., 3.};
142  const vector<double> dcaSigmaParamsXY = {-0.0095, 0.091, -0.029};
143  const vector<double> dcaSigmaParamsZ = {1.73, 26.1, -9.45};
144 
145  // particle flow acceptance
146  const pair<double, double> ptFlowRange = {0.2, 9999.};
147  const pair<double, double> etaFlowRange = {-1.1, 1.1};
148 
149  // calo acceptance
150  const pair<double, double> ptECalRange = {0.3, 9999.};
151  const pair<double, double> etaECalRange = {-1.1, 1.1};
152  const pair<double, double> ptHCalRange = {0.3, 9999.};
153  const pair<double, double> etaHCalRange = {-1.1, 1.1};
154 
155  // load libraries and create f4a server
156  gSystem -> Load("libg4dst.so");
157  gSystem -> Load("libFROG.so");
158 
159  FROG* frog = new FROG();
160  Fun4AllServer* ffaServer = Fun4AllServer::instance();
161  ffaServer -> Verbosity(verbosity);
162 
163  // add input files
164  for (size_t iInput = 0; iInput < sInput.size(); iInput++) {
165  Fun4AllDstInputManager* inManager = new Fun4AllDstInputManager("InputDstManager" + to_string(iInput));
166  inManager -> AddFile(sInput.at(iInput));
167  ffaServer -> registerInputManager(inManager);
168  }
169 
170  // run the tracking if not already done
171  if (runTracking) {
172 
173  // enable mms
174  Enable::MICROMEGAS = true;
175 
176  // initialize magnetic field
178  MagnetInit();
179  MagnetFieldInit();
180 
181  // initialize tracker cells
182  Mvtx_Cells();
183  Intt_Cells();
184  TPC_Cells();
186 
187  // initialize tracking
188  TrackingInit();
189 
190  // do tracker clustering & reconstruction
191  Mvtx_Clustering();
192  Intt_Clustering();
193  TPC_Clustering();
195  Tracking_Reco();
196  }
197 
198  // construct track/truth table
199  if (doTruthTableReco) {
201  tables -> Verbosity(verbosity);
202  if (runTracking) {
203  ffaServer -> registerSubsystem(tables);
204  }
205  }
206 
207  // if using particle flow, run pf reconstruction
208  if (addParticleFlow) {
209 
210  // build topo clusters
211  RawClusterBuilderTopo* ecalClusterBuilder = new RawClusterBuilderTopo("EcalRawClusterBuilderTopo");
212  ecalClusterBuilder -> Verbosity(verbosity);
213  ecalClusterBuilder -> set_nodename("TOPOCLUSTER_EMCAL");
214  ecalClusterBuilder -> set_enable_HCal(enableHCal[0]);
215  ecalClusterBuilder -> set_enable_EMCal(enableECal[0]);
216  ecalClusterBuilder -> set_noise(noiseLevels[0], noiseLevels[1], noiseLevels[2]);
217  ecalClusterBuilder -> set_significance(significance[0], significance[1], significance[2]);
218  ecalClusterBuilder -> allow_corner_neighbor(allowCorners);
219  ecalClusterBuilder -> set_do_split(doSplit);
220  ecalClusterBuilder -> set_minE_local_max(localMinE[0], localMinE[1], localMinE[2]);
221  ecalClusterBuilder -> set_R_shower(showerR);
222  ffaServer -> registerSubsystem(ecalClusterBuilder);
223 
224  RawClusterBuilderTopo* hcalClusterBuilder = new RawClusterBuilderTopo("HcalRawClusterBuilderTopo");
225  hcalClusterBuilder -> Verbosity(verbosity);
226  hcalClusterBuilder -> set_nodename("TOPOCLUSTER_HCAL");
227  hcalClusterBuilder -> set_enable_HCal(enableHCal[1]);
228  hcalClusterBuilder -> set_enable_EMCal(enableECal[1]);
229  hcalClusterBuilder -> set_noise(noiseLevels[0], noiseLevels[1], noiseLevels[2]);
230  hcalClusterBuilder -> set_significance(significance[0], significance[1], significance[1]);
231  hcalClusterBuilder -> allow_corner_neighbor(allowCorners);
232  hcalClusterBuilder -> set_do_split(doSplit);
233  hcalClusterBuilder -> set_minE_local_max(localMinE[0], localMinE[1], localMinE[2]);
234  hcalClusterBuilder -> set_R_shower(showerR);
235  ffaServer -> registerSubsystem(hcalClusterBuilder);
236 
237  // do particle flow
238  ParticleFlowReco *parFlowReco = new ParticleFlowReco();
239  parFlowReco -> set_energy_match_Nsigma(nSigma);
240  parFlowReco -> Verbosity(verbosity);
241  ffaServer -> registerSubsystem(parFlowReco);
242  }
243 
244  // create correlator jet tree
245  SCorrelatorJetTree *correlatorJetTree = new SCorrelatorJetTree("SCorrelatorJetTree", sOutput, isMC, isEmbed, doDebug);
246  correlatorJetTree -> Verbosity(verbosity);
247  correlatorJetTree -> SetDoVertexCut(doVtxCut);
248  correlatorJetTree -> SetDoQualityPlots(doQuality);
249  correlatorJetTree -> SetAddTracks(addTracks);
250  correlatorJetTree -> SetAddFlow(addParticleFlow);
251  correlatorJetTree -> SetAddECal(addECal);
252  correlatorJetTree -> SetAddHCal(addHCal);
253  correlatorJetTree -> SetEvtVzRange(vzEvtRange);
254  correlatorJetTree -> SetEvtVrRange(vrEvtRange);
255  if (isMC) {
256  correlatorJetTree -> SetParPtRange(ptParRange);
257  correlatorJetTree -> SetParEtaRange(etaParRange);
258  }
259  if (addTracks) {
260  correlatorJetTree -> SetRequireSiSeeds(requireSiSeeds);
261  correlatorJetTree -> SetUseOnlyPrimVtx(useOnlyPrimVtx);
262  correlatorJetTree -> SetMaskTpcSectors(maskTpcSectors);
263  correlatorJetTree -> SetCheckWeirdTrks(checkWeirdTrks);
264  correlatorJetTree -> SetTrackPtRange(ptTrackRange);
265  correlatorJetTree -> SetTrackEtaRange(etaTrackRange);
266  correlatorJetTree -> SetTrackQualityRange(qualTrackRange);
267  correlatorJetTree -> SetTrackNMvtxRange(nMvtxTrackRange);
268  correlatorJetTree -> SetTrackNInttRange(nInttTrackRange);
269  correlatorJetTree -> SetTrackNTpcRange(nTpcTrackRange);
270  correlatorJetTree -> SetTrackDcaRangeXY(dcaTrackRangeXY);
271  correlatorJetTree -> SetTrackDcaRangeZ(dcaTrackRangeZ);
272  correlatorJetTree -> SetTrackDeltaPtRange(deltaPtTrackRange);
273  if (doDcaSigmaCut) {
274  correlatorJetTree -> SetTrackDcaSigmaParameters(doDcaSigmaCut, dcaPtFitMax, nDcaSigmaTrack, dcaSigmaParamsXY, dcaSigmaParamsZ);
275  }
276  }
277  if (addParticleFlow) {
278  correlatorJetTree -> SetFlowPtRange(ptFlowRange);
279  correlatorJetTree -> SetFlowEtaRange(etaFlowRange);
280  }
281  if (addECal) {
282  correlatorJetTree -> SetECalPtRange(ptECalRange);
283  correlatorJetTree -> SetECalEtaRange(etaECalRange);
284  }
285  if (addHCal) {
286  correlatorJetTree -> SetHCalPtRange(ptHCalRange);
287  correlatorJetTree -> SetHCalEtaRange(etaHCalRange);
288  }
289  correlatorJetTree -> SetJetParameters(jetRes, jetType, jetAlgo, jetReco);
290  correlatorJetTree -> SetSaveDST(saveDst);
291  ffaServer -> registerSubsystem(correlatorJetTree);
292 
293  // run reconstruction & close f4a
294  ffaServer -> run(nEvents);
295  ffaServer -> End();
296  delete ffaServer;
297 
298  // announce end & exit
299  gSystem -> Exit(0);
300  return;
301 
302 }
303 
304 // end ------------------------------------------------------------------------