File indexing completed on 2025-08-06 08:11:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #pragma once
0013
0014 using namespace std;
0015
0016
0017
0018
0019
0020 void SDeltaPtCutStudy::SetInputOutputFiles(const TString sInput, const TString sOutput) {
0021
0022 sInFile = sInput;
0023 sOutFile = sOutput;
0024 cout << " Set input/output files:\n"
0025 << " input = " << sInFile.Data() << "\n"
0026 << " output = " << sOutFile.Data()
0027 << endl;
0028 return;
0029
0030 }
0031
0032
0033
0034 void SDeltaPtCutStudy::SetInputTuples(const TString sTrack, const TString sTruth) {
0035
0036 sInTrack = sTrack;
0037 sInTruth = sTruth;
0038 cout << " Set track/truth tuples:\n"
0039 << " track tuple = " << sInTrack.Data() << "\n"
0040 << " truth tuple = " << sInTruth.Data()
0041 << endl;
0042 return;
0043
0044 }
0045
0046
0047
0048 void SDeltaPtCutStudy::SetGeneralTrackCuts(const uint32_t nInttCut, const uint32_t nMvtxCut, const uint32_t nTpcCut, const double qualCut, const double vzCut, const double ptCut) {
0049
0050 nInttTrkMin = nInttCut;
0051 nMVtxTrkMin = nMvtxCut;
0052 nTpcTrkMin = nTpcCut;
0053 qualTrkMax = qualCut;
0054 vzTrkMax = vzCut;
0055 ptTrkMin = ptCut;
0056 cout << " Set general track cuts:\n"
0057 << " nIntt > " << nInttTrkMin << "\n"
0058 << " nMvtx > " << nMVtxTrkMin << "\n"
0059 << " nTpc > " << nTpcTrkMin << "\n"
0060 << " quality < " << qualTrkMax << "\n"
0061 << " |vz| < " << vzTrkMax << "\n"
0062 << " pt > " << ptTrkMin
0063 << endl;
0064 return;
0065
0066 }
0067
0068
0069
0070 void SDeltaPtCutStudy::SetSigmaFitGuesses(const array<float, Const::NPar> hiGuess, const array<float, Const::NPar> loGuess) {
0071
0072 for (uint8_t iPar = 0; iPar < Const::NPar; iPar++) {
0073 sigHiGuess[iPar] = hiGuess[iPar];
0074 sigLoGuess[iPar] = loGuess[iPar];
0075 }
0076 cout << " Set sigma(delta-pt / pt) fit guesses:\n"
0077 << " high guess parameters = (" << sigHiGuess[0] << ", " << sigHiGuess[1] << ", " << sigHiGuess[2] << ")\n"
0078 << " low guess parameters = (" << sigLoGuess[0] << ", " << sigLoGuess[1] << ", " << sigLoGuess[2] << ")"
0079 << endl;
0080 return;
0081
0082 }
0083
0084
0085
0086 void SDeltaPtCutStudy::SetNormAndFitRanges(const pair<float, float> norm, const pair<float, float> ptFit, const pair<float, float> deltaFit) {
0087
0088 normRange[0] = norm.first;
0089 normRange[1] = norm.second;
0090 ptFitRange[0] = ptFit.first;
0091 ptFitRange[1] = ptFit.second;
0092 deltaFitRange[0] = deltaFit.first;
0093 deltaFitRange[1] = deltaFit.second;
0094 cout << " Set normalization and fit ranges:\n"
0095 << " normalization = (" << normRange[0] << ", " << normRange[1] << ")\n"
0096 << " pt fit = (" << ptFitRange[0] << ", " << ptFitRange[1] << ")\n"
0097 << " delta-pt fit = (" << deltaFitRange[0] << ", " << deltaFitRange[1] << ")"
0098 << endl;
0099 return;
0100
0101 }
0102
0103
0104
0105 void SDeltaPtCutStudy::SetPlotRanges(const pair<float, float> ptRange, const pair<float, float> fracRange, const pair<float, float> deltaRange) {
0106
0107 rPtRange[0] = ptRange.first;
0108 rPtRange[1] = ptRange.second;
0109 rFracRange[0] = fracRange.first;
0110 rFracRange[1] = fracRange.second;
0111 rDeltaRange[0] = deltaRange.first;
0112 rDeltaRange[1] = deltaRange.second;
0113 cout << " Set plot ranges:\n"
0114 << " pt = (" << rPtRange[0] << ", " << rPtRange[1] << ")\n"
0115 << " frac = (" << rFracRange[0] << ", " << rFracRange[1] << ")\n"
0116 << " delta = (" << rDeltaRange[0] << ", " << rDeltaRange[1] << ")"
0117 << endl;
0118 return;
0119
0120 }
0121
0122
0123
0124 void SDeltaPtCutStudy::SetGeneralStyleParameters(const array<uint32_t, Const::NTypes> arrCol, const array<uint32_t, Const::NTypes> arrMar) {
0125
0126 fColTrue = arrCol[0];
0127 fColPure = arrCol[1];
0128 fColTrk = arrCol[2];
0129 fMarTrue = arrMar[0];
0130 fMarPure = arrMar[1];
0131 fMarTrk = arrMar[2];
0132 cout << " Set general style parameters:\n"
0133 << " colors (true, pure, track) = (" << fColTrue << ", " << fColPure << ", " << fColTrk << ")\n"
0134 << " markers (true, pure, track) = (" << fMarTrue << ", " << fMarPure << ", " << fMarTrk << ")"
0135 << endl;
0136 return;
0137
0138 }
0139
0140
0141
0142 void SDeltaPtCutStudy::SetGeneralHistParameters(const uint32_t fill, const uint32_t line, const uint32_t width, const uint32_t font, const uint32_t align, const uint32_t center) {
0143
0144 fFil = fill;
0145 fLin = line;
0146 fWid = width;
0147 fTxt = font;
0148 fAln = align;
0149 fCnt = center;
0150 cout << " Set general histogram parameters:\n"
0151 << " fill = " << fFil << "\n"
0152 << " line = " << fLin << "\n"
0153 << " width = " << fWid << "\n"
0154 << " font = " << fTxt << "\n"
0155 << " align = " << fAln << "\n"
0156 << " center = " << fCnt
0157 << endl;
0158 return;
0159
0160 }
0161
0162
0163
0164 void SDeltaPtCutStudy::SetHistBaseNames(const TString sProj, const TString sDelta, const TString sTrue, const TString sReco, const TString sFrac, const TString sTrack) {
0165
0166 sPtProjBase = sProj;
0167 sPtDeltaBase = sDelta;
0168 sPtTrueBase = sTrue;
0169 sPtRecoBase = sReco;
0170 sPtFracBase = sFrac;
0171 sPtTrkTruBase = sTrack;
0172 cout << " Set histogram base names:\n"
0173 << " " << sPtProjBase << "\n"
0174 << " " << sPtDeltaBase << "\n"
0175 << " " << sPtTrueBase << "\n"
0176 << " " << sPtRecoBase << "\n"
0177 << " " << sPtFracBase << "\n"
0178 << " " << sPtTrkTruBase
0179 << endl;
0180 return;
0181
0182 }
0183
0184
0185
0186 void SDeltaPtCutStudy::SetPlotText(const vector<TString> plotText) {
0187
0188 nTxt = plotText.size();
0189 sInfo = plotText;
0190
0191 cout << " Set plot text:" << endl;
0192 for (size_t iTxt = 0; iTxt < nTxt; iTxt++) {
0193 cout << " " << sInfo[iTxt] << endl;
0194 }
0195 return;
0196
0197 }
0198
0199
0200
0201 void SDeltaPtCutStudy::SetEffRebinParameters(const bool doRebin, const size_t nRebin) {
0202
0203 doEffRebin = doRebin;
0204 nEffRebin = nRebin;
0205 cout << " Set efficiency rebinning parameters:\n"
0206 << " do rebin? = " << doEffRebin << "\n"
0207 << " nRebin = " << nEffRebin
0208 << endl;
0209 return;
0210
0211 }
0212
0213
0214
0215 void SDeltaPtCutStudy::SetProjectionParameters(const vector<tuple<double, TString, uint32_t, uint32_t, uint32_t>> projParams) {
0216
0217 nProj = projParams.size();
0218 for (auto param : projParams) {
0219 ptProj.push_back(get<0>(param));
0220 sProjSuffix.push_back(get<1>(param));
0221 fColProj.push_back(get<2>(param));
0222 fMarProj.push_back(get<3>(param));
0223 fColFit.push_back(get<4>(param));
0224 }
0225
0226 cout << " Set projection parameters." << endl;
0227 return;
0228
0229 }
0230
0231
0232
0233 void SDeltaPtCutStudy::SetFlatCutParameters(const vector<tuple<double, TString, uint32_t, uint32_t, bool>> flatParams) {
0234
0235 bool cutSelected = false;
0236 size_t iParam = 0;
0237 for (auto param : flatParams) {
0238
0239
0240 ptDeltaMax.push_back(get<0>(param));
0241 sDPtSuffix.push_back(get<1>(param));
0242 fColCut.push_back(get<2>(param));
0243 fMarCut.push_back(get<3>(param));
0244
0245
0246 if (!cutSelected && get<4>(param)) {
0247 iCutToDraw = iParam;
0248 cutSelected = true;
0249 }
0250 ++iParam;
0251 }
0252 nDPtCuts = flatParams.size();
0253
0254 cout << " Set flat delta-pt cut parameters." << endl;
0255 return;
0256
0257 }
0258
0259
0260
0261 void SDeltaPtCutStudy::SetPtDependCutParameters(const vector<tuple<double, TString, uint32_t, uint32_t, uint32_t, bool>> ptDependParams) {
0262
0263 bool cutSelected = false;
0264 size_t iParam = 0;
0265 for (auto param : ptDependParams) {
0266
0267
0268 ptDeltaSig.push_back(get<0>(param));
0269 sSigSuffix.push_back(get<1>(param));
0270 fColSig.push_back(get<2>(param));
0271 fMarSig.push_back(get<3>(param));
0272 fColSigFit.push_back(get<4>(param));
0273
0274
0275 if (!cutSelected && get<5>(param)) {
0276 iCutToDraw = iParam;
0277 cutSelected = true;
0278 }
0279 ++iParam;
0280 }
0281 nSigCuts = ptDependParams.size();
0282
0283 cout << " Set pt-dependent delta-pt cut parameters." << endl;
0284 return;
0285
0286 }
0287
0288
0289
0290
0291
0292 void SDeltaPtCutStudy::OpenFiles() {
0293
0294 fOutput = new TFile(sOutFile.Data(), "recreate");
0295 fInput = new TFile(sInFile.Data(), "read");
0296 if (!fInput || !fOutput) {
0297 cerr << "PANIC: couldn't open a file!\n"
0298 << " fInput = " << fInput << "\n"
0299 << " fOutput = " << fOutput << "\n"
0300 << endl;
0301 assert(fOutput && fInput);
0302 }
0303
0304 cout << " Opened files." << endl;
0305 return;
0306
0307 }
0308
0309
0310
0311 void SDeltaPtCutStudy::GetTuples() {
0312
0313 ntTrack = (TNtuple*) fInput -> Get(sInTrack.Data());
0314 ntTruth = (TNtuple*) fInput -> Get(sInTruth.Data());
0315 if (!ntTrack || !ntTruth) {
0316 cerr << "PANIC: couldn't grab aninput tuple!\n"
0317 << " ntTrack = " << ntTrack << "\n"
0318 << " ntTruth = " << ntTruth << "\n"
0319 << endl;
0320 assert(ntTrack && ntTruth);
0321 }
0322
0323 cout << " Grabbed input tuples." << endl;
0324 return;
0325
0326 }
0327
0328
0329
0330 void SDeltaPtCutStudy::SaveOutput() {
0331
0332
0333 TDirectory *dNoCut = (TDirectory*) fOutput -> mkdir("NoCuts");
0334 TDirectory *dFlatCut = (TDirectory*) fOutput -> mkdir("FlatCuts");
0335 TDirectory *dSigmaCut = (TDirectory*) fOutput -> mkdir("SigmaCuts");
0336 TDirectory *dProject = (TDirectory*) fOutput -> mkdir("Projections");
0337 cout << " Made output directories." << endl;
0338
0339
0340 fOutput -> cd();
0341 dNoCut -> cd();
0342 hEff -> Write();
0343 hPtTruth -> Write();
0344 hPtDelta -> Write();
0345 hPtTrack -> Write();
0346 hPtFrac -> Write();
0347 hPtTrkTru -> Write();
0348 hPtDeltaVsFrac -> Write();
0349 hPtDeltaVsTrue -> Write();
0350 hPtDeltaVsTrack -> Write();
0351 hPtTrueVsTrack -> Write();
0352
0353
0354 dFlatCut -> cd();
0355 grRejCut -> Write();
0356 for (size_t iCut = 0; iCut < nDPtCuts; iCut++) {
0357 hEffCut[iCut] -> Write();
0358 hPtDeltaCut[iCut] -> Write();
0359 hPtTrackCut[iCut] -> Write();
0360 hPtFracCut[iCut] -> Write();
0361 hPtTrkTruCut[iCut] -> Write();
0362 hPtDeltaVsFracCut[iCut] -> Write();
0363 hPtDeltaVsTrueCut[iCut] -> Write();
0364 hPtDeltaVsTrackCut[iCut] -> Write();
0365 hPtTrueVsTrackCut[iCut] -> Write();
0366 }
0367
0368
0369 dSigmaCut -> cd();
0370 grRejSig -> Write();
0371 for (size_t iSig = 0; iSig < nSigCuts; iSig++) {
0372 hEffSig[iSig] -> Write();
0373 hPtDeltaSig[iSig] -> Write();
0374 hPtTrackSig[iSig] -> Write();
0375 hPtFracSig[iSig] -> Write();
0376 hPtTrkTruSig[iSig] -> Write();
0377 hPtDeltaVsFracSig[iSig] -> Write();
0378 hPtDeltaVsTrueSig[iSig] -> Write();
0379 hPtDeltaVsTrackSig[iSig] -> Write();
0380 hPtTrueVsTrackSig[iSig] -> Write();
0381 }
0382
0383
0384 dProject -> cd();
0385 grMuProj -> Write();
0386 grSigProj -> Write();
0387 for (size_t iProj = 0; iProj < nProj; iProj++) {
0388 hPtDeltaProj[iProj] -> Write();
0389 fPtDeltaProj[iProj] -> Write();
0390 }
0391 for (size_t iSig = 0; iSig < nSigCuts; iSig++) {
0392 fMuHiProj[iSig] -> Write();
0393 fMuLoProj[iSig] -> Write();
0394 grMuHiProj[iSig] -> Write();
0395 grMuLoProj[iSig] -> Write();
0396 }
0397
0398 cout << " Saved output." << endl;
0399 return;
0400
0401 }
0402
0403
0404
0405 void SDeltaPtCutStudy::CloseFiles() {
0406
0407 fOutput -> cd();
0408 fOutput -> Close();
0409 fInput -> cd();
0410 fInput -> Close();
0411
0412 cout << " Closed files." << endl;
0413 return;
0414
0415 }
0416
0417