Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DoDeltaPtCutStudy.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DoDeltaPtCutStudy.C
1 // ----------------------------------------------------------------------------
2 // 'DoTrackCutStudy.C'
3 // Derek Anderson
4 // 06.29.2023
5 //
6 // Runs the 'SDeltaPtCutStudy' class.
7 // ----------------------------------------------------------------------------
8 
9 #ifndef DODELTAPTCUTSTUDY_C
10 #define DODELTAPTCUTSTUDY_C
11 
12 // standard c includes
13 #include <array>
14 #include <cstdlib>
15 #include <utility>
16 // root includes
17 #include <TROOT.h>
18 #include <TString.h>
19 // user includes
20 #include "/sphenix/user/danderson/install/include/sdeltaptcutstudy/SDeltaPtCutStudy.h"
21 
22 using namespace std;
23 
24 // load libraries
25 R__LOAD_LIBRARY(/sphenix/user/danderson/install/lib/libsdeltaptcutstudy.so)
26 
27 // global constants
28 static const bool DefBatch = false;
29 static const size_t NPar = 3;
30 static const size_t NTypes = 3;
31 
32 
33 
34 void DoDeltaPtCutStudy(const bool inBatchMode = DefBatch) {
35 
36  // lower verbosity
37  gErrorIgnoreLevel = kWarning;
38 
39  // io parameters
40  const TString sInFile("../TruthMatching/input/merged/sPhenixG4_testingNewMatcher_oldEvaluator.pt020num10evt500pipm.d15m9y2023.root");
41  const TString sOutFile("deltaPtStudy.testingSignChange_piboth.pt020num5evt500pipm.d3m10y2023.root");
42  const TString sInTrack("ntp_track");
43  const TString sInTruth("ntp_gtrack");
44 
45  // projection parameters
46  // <0> = bin center of projection
47  // <1> = histogram suffix
48  // <2> = histogram color
49  // <3> = histogram marker
50  // <4> = fit color
51  const vector<tuple<double, TString, uint32_t, uint32_t, uint32_t>> projParams = {
52  make_tuple(0.5, "_pt05", 799, 20, 803),
53  make_tuple(1.0, "_pt1", 633, 22, 636),
54  make_tuple(2.0, "_pt2", 899, 23, 893),
55  make_tuple(5.0, "_pt5", 617, 21, 620),
56  make_tuple(10., "_pt10", 879, 33, 883),
57  make_tuple(20., "_pt20", 859, 34, 863),
58  make_tuple(30., "_pt30", 839, 47, 843),
59  make_tuple(40., "_pt40", 819, 20, 813)
60  };
61 
62  // flat delta-pt cut parameters
63  // <0> = max delta-pt
64  // <1> = histogram suffix
65  // <2> = histogram color
66  // <3> = histogram marker
67  // <4> = draw this one?
68  // (only 1st cut set to true will be drawn)
69  const vector<tuple<double, TString, uint32_t, uint32_t, bool>> flatParams = {
70  make_tuple(0.50, "_dPt50", 899, 24, false),
71  make_tuple(0.25, "_dPt25", 909, 26, false),
72  make_tuple(0.10, "_dPt10", 879, 32, false),
73  make_tuple(0.05, "_dPt05", 889, 25, false),
74  make_tuple(0.03, "_dPt03", 859, 27, true),
75  make_tuple(0.02, "_dPt02", 869, 28, false),
76  make_tuple(0.01, "_dPt01", 839, 30, false)
77  };
78 
79  // pt-dependent delta-pt cut parameters
80  // <0> = max n-sigma away from mean
81  // <1> = histogram suffix
82  // <2> = histogram color
83  // <3> = histogram marker
84  // <4> = fit color
85  // <5> = draw this one?
86  // (only 1st cut set to true will be drawn)
87  const vector<tuple<double, TString, uint32_t, uint32_t, uint32_t, bool>> ptDependParams = {
88  make_tuple(1.0, "_sigDPt10", 899, 24, 893, false),
89  make_tuple(1.5, "_sigDPt15", 909, 26, 903, false),
90  make_tuple(2.0, "_sigDPt20", 879, 32, 873, true),
91  make_tuple(2.5, "_sigDPt25", 889, 25, 883, false),
92  make_tuple(3.0, "_sigDPt30", 859, 27, 863, false)
93  };
94 
95  // fit guesses, and norm and fit ranges
96  array<float, NPar> sigHiGuess = {1., -1., 1.};
97  array<float, NPar> sigLoGuess = {1., -1., 1.};
98  pair<float, float> normRange = {0.2, 1.2};
99  pair<float, float> ptFitRange = {0.5, 40.};
100  pair<float, float> deltaFitRange = {0., 0.1};
101 
102  // general track cuts
103  const uint32_t nInttTrkMin = 1;
104  const uint32_t nMVtxTrkMin = 2;
105  const uint32_t nTpcTrkMin = 35;
106  const double qualTrkMax = 10.;
107  const double vzTrkMax = 10.;
108  const double ptTrkMin = 0.1;
109 
110  // general style parameters
111  const pair<float, float> rPtRange = {0., 60.};
112  const pair<float, float> rFracRange = {0., 4.};
113  const pair<float, float> rDeltaRange = {0., 0.1};
114  const array<uint32_t, NTypes> arrColGraph = {923, 923, 809};
115  const array<uint32_t, NTypes> arrMarGraph = {20, 20, 46};
116 
117  // general histogram parameters
118  const uint32_t fFil = 0;
119  const uint32_t fLin = 1;
120  const uint32_t fWid = 1;
121  const uint32_t fTxt = 42;
122  const uint32_t fAln = 12;
123  const uint32_t fCnt = 1;
124 
125  // bases of histogram names
126  const TString sPtProjBase("DeltaPtProj");
127  const TString sPtDeltaBase("DeltaPt");
128  const TString sPtTrueBase("PtTrue");
129  const TString sPtRecoBase("PtReco");
130  const TString sPtFracBase("PtFrac");
131  const TString sPtTrkTruBase("PtTrkTruth");
132 
133  // plot text
134  const vector<TString> sPlotTxt = {
135  "#bf{#it{sPHENIX}} Simulation",
136  "5 #pi^{-} + 5 #pi^{+}/event, p_{T} #in (0, 20) GeV/c",
137  "#bf{Only #pi^{#pm}}"
138  };
139 
140  // misc plot parameters
141  bool doEffRebin = true;
142  size_t nEffRebin = 5;
143 
144  // run track cut study
145  SDeltaPtCutStudy *study = new SDeltaPtCutStudy();
146  study -> SetInputOutputFiles(sInFile, sOutFile);
147  study -> SetInputTuples(sInTrack, sInTruth);
148  study -> SetGeneralTrackCuts(nInttTrkMin, nMVtxTrkMin, nTpcTrkMin, qualTrkMax, vzTrkMax, ptTrkMin);
149  study -> SetSigmaFitGuesses(sigHiGuess, sigLoGuess);
150  study -> SetNormAndFitRanges(normRange, ptFitRange, deltaFitRange);
151  study -> SetPlotRanges(rPtRange, rFracRange, rDeltaRange);
152  study -> SetGeneralStyleParameters(arrColGraph, arrMarGraph);
153  study -> SetGeneralHistParameters(fFil, fLin, fWid, fTxt, fAln, fCnt);
154  study -> SetHistBaseNames(sPtProjBase, sPtDeltaBase, sPtTrueBase, sPtRecoBase, sPtFracBase, sPtTrkTruBase);
155  study -> SetPlotText(sPlotTxt);
156  study -> SetEffRebinParameters(doEffRebin, nEffRebin);
157  study -> SetProjectionParameters(projParams);
158  study -> SetFlatCutParameters(flatParams);
159  study -> SetPtDependCutParameters(ptDependParams);
160  study -> Init();
161  study -> Analyze();
162  study -> End();
163 
164 } // end 'DoDeltaPtCutStudy()'
165 
166 #endif
167 
168 // end ------------------------------------------------------------------------