Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:10:56

0001 // ----------------------------------------------------------------------------
0002 // 'DoTrackCutStudy.C'
0003 // Derek Anderson
0004 // 06.29.2023
0005 //
0006 // Runs the 'SDeltaPtCutStudy' class.
0007 // ----------------------------------------------------------------------------
0008 
0009 #ifndef DODELTAPTCUTSTUDY_C
0010 #define DODELTAPTCUTSTUDY_C
0011 
0012 // standard c includes
0013 #include <array>
0014 #include <cstdlib>
0015 #include <utility>
0016 // root includes
0017 #include <TROOT.h>
0018 #include <TString.h>
0019 // user includes
0020 #include "/sphenix/user/danderson/install/include/sdeltaptcutstudy/SDeltaPtCutStudy.h"
0021 
0022 using namespace std;
0023 
0024 // load libraries
0025 R__LOAD_LIBRARY(/sphenix/user/danderson/install/lib/libsdeltaptcutstudy.so)
0026 
0027 // global constants
0028 static const bool   DefBatch = false;
0029 static const size_t NPar     = 3;
0030 static const size_t NTypes   = 3;
0031 
0032 
0033 
0034 void DoDeltaPtCutStudy(const bool inBatchMode = DefBatch) {
0035 
0036   // lower verbosity
0037   gErrorIgnoreLevel = kWarning;
0038 
0039   // io parameters
0040   const TString sInFile("../TruthMatching/input/merged/sPhenixG4_testingNewMatcher_oldEvaluator.pt020num10evt500pipm.d15m9y2023.root");
0041   const TString sOutFile("deltaPtStudy.testingSignChange_piboth.pt020num5evt500pipm.d3m10y2023.root");
0042   const TString sInTrack("ntp_track");
0043   const TString sInTruth("ntp_gtrack");
0044 
0045   // projection parameters
0046   //   <0> = bin center of projection
0047   //   <1> = histogram suffix
0048   //   <2> = histogram color
0049   //   <3> = histogram marker
0050   //   <4> = fit color
0051   const vector<tuple<double, TString, uint32_t, uint32_t, uint32_t>> projParams = {
0052     make_tuple(0.5, "_pt05", 799, 20, 803),
0053     make_tuple(1.0, "_pt1",  633, 22, 636),
0054     make_tuple(2.0, "_pt2",  899, 23, 893),
0055     make_tuple(5.0, "_pt5",  617, 21, 620),
0056     make_tuple(10., "_pt10", 879, 33, 883),
0057     make_tuple(20., "_pt20", 859, 34, 863),
0058     make_tuple(30., "_pt30", 839, 47, 843),
0059     make_tuple(40., "_pt40", 819, 20, 813)
0060   };
0061 
0062   // flat delta-pt cut parameters
0063   //   <0> = max delta-pt
0064   //   <1> = histogram suffix
0065   //   <2> = histogram color
0066   //   <3> = histogram marker
0067   //   <4> = draw this one?
0068   //         (only 1st cut set to true will be drawn)
0069   const vector<tuple<double, TString, uint32_t, uint32_t, bool>> flatParams = {
0070     make_tuple(0.50, "_dPt50", 899, 24, false),
0071     make_tuple(0.25, "_dPt25", 909, 26, false),
0072     make_tuple(0.10, "_dPt10", 879, 32, false),
0073     make_tuple(0.05, "_dPt05", 889, 25, false),
0074     make_tuple(0.03, "_dPt03", 859, 27, true),
0075     make_tuple(0.02, "_dPt02", 869, 28, false),
0076     make_tuple(0.01, "_dPt01", 839, 30, false)
0077   };
0078 
0079   // pt-dependent delta-pt cut parameters
0080   //   <0> = max n-sigma away from mean
0081   //   <1> = histogram suffix
0082   //   <2> = histogram color
0083   //   <3> = histogram marker
0084   //   <4> = fit color
0085   //   <5> = draw this one?
0086   //         (only 1st cut set to true will be drawn)
0087   const vector<tuple<double, TString, uint32_t, uint32_t, uint32_t, bool>> ptDependParams = {
0088     make_tuple(1.0, "_sigDPt10", 899, 24, 893, false),
0089     make_tuple(1.5, "_sigDPt15", 909, 26, 903, false),
0090     make_tuple(2.0, "_sigDPt20", 879, 32, 873, true),
0091     make_tuple(2.5, "_sigDPt25", 889, 25, 883, false),
0092     make_tuple(3.0, "_sigDPt30", 859, 27, 863, false) 
0093   };
0094 
0095   // fit guesses, and norm and fit ranges
0096   array<float, NPar> sigHiGuess    = {1., -1., 1.};
0097   array<float, NPar> sigLoGuess    = {1., -1., 1.};
0098   pair<float, float> normRange     = {0.2, 1.2};
0099   pair<float, float> ptFitRange    = {0.5, 40.};
0100   pair<float, float> deltaFitRange = {0.,  0.1};
0101 
0102   // general track cuts
0103   const uint32_t nInttTrkMin = 1;
0104   const uint32_t nMVtxTrkMin = 2;
0105   const uint32_t nTpcTrkMin  = 35;
0106   const double   qualTrkMax  = 10.;
0107   const double   vzTrkMax    = 10.;
0108   const double   ptTrkMin    = 0.1;
0109 
0110   // general style parameters
0111   const pair<float, float>      rPtRange    = {0., 60.};
0112   const pair<float, float>      rFracRange  = {0., 4.};
0113   const pair<float, float>      rDeltaRange = {0., 0.1};
0114   const array<uint32_t, NTypes> arrColGraph = {923, 923, 809};
0115   const array<uint32_t, NTypes> arrMarGraph = {20,  20,  46};
0116 
0117   // general histogram parameters
0118   const uint32_t fFil = 0;
0119   const uint32_t fLin = 1;
0120   const uint32_t fWid = 1;
0121   const uint32_t fTxt = 42;
0122   const uint32_t fAln = 12;
0123   const uint32_t fCnt = 1;
0124 
0125   // bases of histogram names
0126   const TString sPtProjBase("DeltaPtProj");
0127   const TString sPtDeltaBase("DeltaPt");
0128   const TString sPtTrueBase("PtTrue");
0129   const TString sPtRecoBase("PtReco");
0130   const TString sPtFracBase("PtFrac");
0131   const TString sPtTrkTruBase("PtTrkTruth");
0132 
0133   // plot text
0134   const vector<TString> sPlotTxt = {
0135     "#bf{#it{sPHENIX}} Simulation",
0136     "5 #pi^{-} + 5 #pi^{+}/event, p_{T} #in (0, 20) GeV/c",
0137     "#bf{Only #pi^{#pm}}"
0138   };
0139 
0140   // misc plot parameters
0141   bool   doEffRebin = true;
0142   size_t nEffRebin  = 5;
0143 
0144   // run track cut study
0145   SDeltaPtCutStudy *study = new SDeltaPtCutStudy();
0146   study -> SetInputOutputFiles(sInFile, sOutFile);
0147   study -> SetInputTuples(sInTrack, sInTruth);
0148   study -> SetGeneralTrackCuts(nInttTrkMin, nMVtxTrkMin, nTpcTrkMin, qualTrkMax, vzTrkMax, ptTrkMin);
0149   study -> SetSigmaFitGuesses(sigHiGuess, sigLoGuess);
0150   study -> SetNormAndFitRanges(normRange, ptFitRange, deltaFitRange);
0151   study -> SetPlotRanges(rPtRange, rFracRange, rDeltaRange);
0152   study -> SetGeneralStyleParameters(arrColGraph, arrMarGraph);
0153   study -> SetGeneralHistParameters(fFil, fLin, fWid, fTxt, fAln, fCnt);
0154   study -> SetHistBaseNames(sPtProjBase, sPtDeltaBase, sPtTrueBase, sPtRecoBase, sPtFracBase, sPtTrkTruBase);
0155   study -> SetPlotText(sPlotTxt);
0156   study -> SetEffRebinParameters(doEffRebin, nEffRebin);
0157   study -> SetProjectionParameters(projParams);
0158   study -> SetFlatCutParameters(flatParams);
0159   study -> SetPtDependCutParameters(ptDependParams);
0160   study -> Init();
0161   study -> Analyze();
0162   study -> End();
0163 
0164 }  // end 'DoDeltaPtCutStudy()'
0165 
0166 #endif
0167 
0168 // end ------------------------------------------------------------------------