17 #include "TDirectory.h"
26 gErrorIgnoreLevel = kError;
27 cout <<
"\n Beginning quick tuple plotting..." << endl;
30 const TString sOutput =
"truthPhiCheck.allVsWeirdVsNormal.pt2040n100weird2pim.d10m7y2023.root";
31 const TString sInput =
"input/embed_only/final_merge/sPhenixG4_forPtCheck_embedScanOn_embedOnly.pt2040n100pim.d8m5y2023.root";
32 const TString sInTuple =
"ntp_track";
35 const vector<TString> vecCutsToApply = {
36 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt<100)&&(quality<10)",
37 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt<100)&&(quality<10)&&((pt/gpt<0.2)||(pt/gpt>1.2))",
38 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt<100)&&(quality<10)&&((pt/gpt>=0.2)&&(pt/gpt<=1.2))",
39 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt<20)&&(quality<10)",
40 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt<20)&&(quality<10)&&((pt/gpt<0.2)||(pt/gpt>1.2))",
41 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt<20)&&(quality<10)&&((pt/gpt>=0.2)&&(pt/gpt<=1.2))",
42 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt>20)&&(pt<100)&&(quality<10)",
43 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt>20)&&(pt<100)&&(quality<10)&&((pt/gpt<0.2)||(pt/gpt>1.2))",
44 "(abs(vz)<10)&&(nintt>=1)&&(nmaps>2)&&(ntpc>35)&&(pt>20)&&(pt<100)&&(quality<10)&&((pt/gpt>=0.2)&&(pt/gpt<=1.2))"
46 const vector<TString> vecCutLabels = {
59 const vector<TString> vecToDraw1D = {
64 const vector<TString> vecHistNames1D = {
71 const vector<TString> vecToDraw2D = {
76 const vector<TString> vecHistNames2D = {
78 "hDeltaPtOverPtVsFracPt",
81 const vector<TString> vecHistOpts2D = {
88 const Ssiz_t nToDraw1D = vecToDraw1D.size();
89 const Ssiz_t nToDraw2D = vecToDraw2D.size();
90 const Ssiz_t nCutsToApply = vecCutsToApply.size();
92 TString sHistToDraw1D;
93 TString sHistToDraw2D;
94 vector<TString> vecHistToDraw1D;
95 vector<TString> vecHistToDraw2D;
96 for (Ssiz_t iCutToApply = 0; iCutToApply < nCutsToApply; iCutToApply++) {
97 for (Ssiz_t iToDraw1D = 0; iToDraw1D < nToDraw1D; iToDraw1D++) {
100 sHistToDraw1D = vecHistNames1D[iToDraw1D].Data();
101 sHistToDraw1D.Append(
"_");
102 sHistToDraw1D.Append(vecCutLabels[iCutToApply].
Data());
105 vecHistToDraw1D.push_back(sHistToDraw1D.Data());
107 for (Ssiz_t iToDraw2D = 0; iToDraw2D < nToDraw2D; iToDraw2D++) {
110 sHistToDraw2D = vecHistNames2D[iToDraw2D].Data();
111 sHistToDraw2D.Append(
"_");
112 sHistToDraw2D.Append(vecCutLabels[iCutToApply].
Data());
115 vecHistToDraw2D.push_back(sHistToDraw2D.Data());
118 cout <<
" Constructed histogram lists." << endl;
121 TFile *fOutput =
new TFile(sOutput.Data(),
"recreate");
122 TFile *fInput =
new TFile(sInput.Data(),
"read");
123 if (!fOutput || !fInput) {
124 cerr <<
"PANIC: couldn't open a file!\n"
125 <<
" fOutput = " << fOutput <<
", fInput = " << fInput <<
"\n"
129 cout <<
" Opened files." << endl;
132 TNtuple *ntToDrawFrom = (TNtuple*) fInput ->
Get(sInTuple.Data());
134 cerr <<
"PANIC: couldn't grab input tuple!\n" << endl;
137 cout <<
" Grabbed input tuple.\n"
138 <<
" Beginning draw loop..."
142 Ssiz_t iHistToDraw1D = 0;
143 Ssiz_t iHistToDraw2D = 0;
144 TString sDrawArg1D =
"";
145 TString sDrawArg2D =
"";
146 for (Ssiz_t iCutToApply = 0; iCutToApply < nCutsToApply; iCutToApply++) {
147 for (Ssiz_t iToDraw1D = 0; iToDraw1D < nToDraw1D; iToDraw1D++) {
150 sDrawArg1D = vecToDraw1D[iToDraw1D].Data();
151 sDrawArg1D.Append(
">>");
152 sDrawArg1D.Append(vecHistToDraw1D[iHistToDraw1D].
Data());
153 cout <<
" Drawing '" << sDrawArg1D.Data() <<
"'..." << endl;
156 ntToDrawFrom ->
Draw(sDrawArg1D.Data(), vecCutsToApply[iCutToApply].Data());
159 for (Ssiz_t iToDraw2D = 0; iToDraw2D < nToDraw2D; iToDraw2D++) {
162 sDrawArg2D = vecToDraw2D[iToDraw2D].Data();
163 sDrawArg2D.Append(
">>");
164 sDrawArg2D.Append(vecHistToDraw2D[iHistToDraw2D].
Data());
165 cout <<
" Drawing '" << sDrawArg2D.Data() <<
"'..." << endl;
168 ntToDrawFrom ->
Draw(sDrawArg2D.Data(), vecCutsToApply[iCutToApply].Data());
172 cout <<
" Drew histograms from tuple." << endl;
175 const Ssiz_t nHistToDraw1D = vecHistToDraw1D.size();
176 const Ssiz_t nHistToDraw2D = vecHistToDraw2D.size();
178 TH1D *hHistToDraw1D[nHistToDraw1D];
179 TH2D *hHistToDraw2D[nHistToDraw2D];
180 for (Ssiz_t iHist1D = 0; iHist1D < nHistToDraw1D; iHist1D++) {
184 hHistToDraw1D[iHist1D] = (TH1D*) gDirectory ->
Get(vecHistToDraw1D[iHist1D].
Data());
188 hHistToDraw1D[iHist1D] ->
Write();
190 for (Ssiz_t iHist2D = 0; iHist2D < nHistToDraw2D; iHist2D++) {
194 hHistToDraw2D[iHist2D] = (TH2D*) gDirectory ->
Get(vecHistToDraw2D[iHist2D].
Data());
198 hHistToDraw2D[iHist2D] ->
Write();
200 cout <<
" Saved histograms." << endl;
207 cout <<
" Closed files." << endl;
210 cout <<
" Finished quick tuple plotting!\n" << endl;