17 #include <TDirectory.h>
18 #include <ROOT/RDataFrame.hxx>
19 #include <ROOT/RDF/HistoModels.hxx>
35 gErrorIgnoreLevel = kError;
36 cout <<
"\n Beginning weird track tuple plotting..." << endl;
41 const string sOutput =
"weirdTracksVsDr.pp200py8jet10run8.d27m10y2023.root";
42 const string sInput =
"output/condor/final_merge/correlatorJetTree.pp200py8jet10run8_roughCutsWithWeirdTrackTuple.d27m10y2023.root";
43 const string sInTuple =
"ntWeirdTracks";
46 const string sCut(
"");
47 const string sDeltaR(
"deltartrack");
50 const size_t nDrBins(75);
51 const vector<double> drBinEdges = {
131 enum Var {VNum, VEne, VEta, VPhi, VDca, VVtx, VQual, VDPt, VFrac};
137 vector<tuple<size_t, double, double>> vecBins = {
150 enum Hist {HPt, HPFrac, HEta, HPhi, HEne, HDcaXY, HDcaZ, HVtxX, HVtxY, HVtxZ, HQual, HDPt, HNLMvtx, HNLIntt, HNLTpc, HNCMvtx, HNCIntt, HNCTpc, HNKey, HNSame, HNFrac};
153 const vector<string> vecTitles = {
154 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};p_{T}^{trk} [GeV]",
155 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};p_{T,i}^{trk} / p_{T,j}^{trk}",
156 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};#eta^{trk}",
157 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};#varphi^{trk}",
158 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};E_{trk}",
159 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};DCA_{xy} [cm]",
160 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};DCZ_{z} [cm]",
161 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};v_{x} [cm]",
162 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};v_{y} [cm]",
163 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};v_{z} [cm]",
164 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};#chi^{2}/ndf",
165 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};#deltap_{T}^{trk}/p_{T}^{trk}",
166 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{layer}^{mvtx}",
167 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{layer}^{intt}",
168 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{layer}^{tpc}",
169 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{clust}^{mvtx}",
170 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{clust}^{intt}",
171 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{clust}^{tpc}",
172 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{clust}^{tot}",
173 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{clust}^{same}",
174 ";#DeltaR = #sqrt{(#Delta#varphi)^{2} + (#Delta#eta)^{2})};N_{clust}^{same} / N_{clust}^{tot}"
182 const vector<tuple<string, string, string, tuple<size_t, double, double>>> vecHistDef = {
183 make_tuple(
"pt_a",
"hPtVsDr", vecTitles[Hist::HPt], vecBins[Var::VEne]),
184 make_tuple(
"ptFrac",
"hPtFracVsDr", vecTitles[Hist::HPFrac], vecBins[Var::VFrac]),
185 make_tuple(
"eta_a",
"hEtaVsDr", vecTitles[Hist::HEta], vecBins[Var::VEta]),
186 make_tuple(
"phi_a",
"hPhiVsDr", vecTitles[Hist::HPhi], vecBins[Var::VPhi]),
187 make_tuple(
"ene_a",
"hEneVsDr", vecTitles[Hist::HEne], vecBins[Var::VEne]),
188 make_tuple(
"dcaxy_a",
"hDcaXYVsDr", vecTitles[Hist::HDcaXY], vecBins[Var::VDca]),
189 make_tuple(
"dcaz_a",
"hDcaZVsDr", vecTitles[Hist::HDcaZ], vecBins[Var::VDca]),
190 make_tuple(
"vtxx_a",
"hVtxXVsDr", vecTitles[Hist::HVtxX], vecBins[Var::VVtx]),
191 make_tuple(
"vtxy_a",
"hVtxYVsDr", vecTitles[Hist::HVtxY], vecBins[Var::VVtx]),
192 make_tuple(
"vtxz_a",
"hVtxZVsDr", vecTitles[Hist::HVtxZ], vecBins[Var::VVtx]),
193 make_tuple(
"quality_a",
"hQualityVsDr", vecTitles[Hist::HQual], vecBins[Var::VQual]),
194 make_tuple(
"deltapt_a",
"hDeltaPtVsDr", vecTitles[Hist::HDPt], vecBins[Var::VDPt]),
195 make_tuple(
"nmvtxlayers_a",
"hNMvtxLayerVsDr", vecTitles[Hist::HNLMvtx], vecBins[Var::VNum]),
196 make_tuple(
"ninttlayers_a",
"hNInttLayerVsDr", vecTitles[Hist::HNLIntt], vecBins[Var::VNum]),
197 make_tuple(
"ntpclayers_a",
"hNTpcLayerVsDr", vecTitles[Hist::HNLTpc], vecBins[Var::VNum]),
198 make_tuple(
"nmvtxclusts_a",
"hNMvtxClustVsDr", vecTitles[Hist::HNCMvtx], vecBins[Var::VNum]),
199 make_tuple(
"ninttclusts_a",
"hNInttClustVsDr", vecTitles[Hist::HNCIntt], vecBins[Var::VNum]),
200 make_tuple(
"ntpcclusts_a",
"hNTpcClustVsDr", vecTitles[Hist::HNCTpc], vecBins[Var::VNum]),
201 make_tuple(
"nclustkey_a",
"hNClustKeyVsDr", vecTitles[Hist::HNKey], vecBins[Var::VNum]),
202 make_tuple(
"nsameclustkey",
"hNSameKeyVsDr", vecTitles[Hist::HNSame], vecBins[Var::VNum]),
203 make_tuple(
"nSameFrac",
"hNSameFracVsDr", vecTitles[Hist::HNFrac], vecBins[Var::VFrac])
205 cout <<
" Defined output histograms." << endl;
212 vector<tuple<string, string, TH2Def>> vecArgAndHist;
213 for (
const auto histDef : vecHistDef) {
216 auto bins = get<3>(histDef);
220 vecArgAndHist.push_back(
make_tuple(get<0>(histDef), sDeltaR, hist));
222 cout <<
" Created output histograms and TNtuple arguments." << endl;
226 auto getFrac = [](
const float a,
const float b) {
233 TFile* fOutput =
new TFile(sOutput.data(),
"recreate");
235 cerr <<
"PANIC: couldn't open a file!\n"
236 <<
" fOutput = " << fOutput <<
"\n"
240 cout <<
" Opened output file." << endl;
243 RDataFrame frame(sInTuple.data(), sInput.data());
246 auto pairs = frame.Count();
248 cerr <<
"Error: No track pairs found!" << endl;
251 cout <<
" Set up data frame." << endl;
256 auto analysis = frame.Define(
"ptFrac", getFrac, {
"pt_a",
"pt_b"})
257 .Define(
"nSameFrac", getFrac, {
"nsameclustkey",
"nclustkey_a"});
258 cout <<
" Defined additional columns.\n"
259 <<
" Beginning draw loop..."
263 for (
auto argAndHist : vecArgAndHist) {
266 auto hist =
analysis.Histo2D(get<2>(argAndHist), get<1>(argAndHist), get<0>(argAndHist));
267 cout <<
" Drawing '" << get<0>(argAndHist) <<
"'..." << endl;
273 cout <<
" Finished drawing and saved all histograms." << endl;
280 cout <<
" Closed files." << endl;
283 cout <<
" Finished weird track tuple plotting!\n" << endl;