Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-07 08:08:22

0001 // ----------------------------------------------------------------------------
0002 // 'STrackCutStudy.io.h'
0003 // Derek Anderson
0004 // 03.14.2022
0005 //
0006 // Reads in the 'ntp_track' Ntuple
0007 // generated by the SVtxEvaluator
0008 // class and studies the impact
0009 // of cutting on various quantities.
0010 // ----------------------------------------------------------------------------
0011 
0012 #pragma once
0013 
0014 using namespace std;
0015 
0016 
0017 
0018 // i/o methods ----------------------------------------------------------------
0019 
0020 void STrackCutStudy::SetBatchMode(const Bool_t doBatch) {
0021 
0022   inBatchMode = doBatch;
0023   if (inBatchMode) {
0024     cout << "    Will run in batch mode." << endl;
0025   } else {
0026     cout << "    Will not run in batch mode." << endl;
0027   }
0028   return;
0029 
0030 }  // end 'SetBatchMode(Bool_t)'
0031 
0032 
0033 
0034 void STrackCutStudy::SetInputOutputFiles(const TString sEmbedOnlyInput, const TString sPileupInput, const TString sOutput) {
0035 
0036   sInFileEO = sEmbedOnlyInput;
0037   sInFilePU = sPileupInput;
0038   sOutfile  = sOutput;
0039   cout << "    Set i/o files:\n"
0040        << "      Embed Only  = " << sInFileEO.Data() << "\n"
0041        << "      With Pileup = " << sInFilePU.Data() << "\n"
0042        << "      Output      = " << sOutput.Data()
0043        << endl;
0044   return;
0045 
0046 }  // end 'SetInputOutputFiles(TString, TString, TString)'
0047 
0048 
0049 
0050 void STrackCutStudy::SetInputTuples(const TString sEmbedOnlyTuple, const TString sPileupTuple, const TString sEmbedOnlyClusterTuple) {
0051 
0052   sInTupleEO = sEmbedOnlyTuple;
0053   sInTuplePU = sPileupTuple;
0054   sInClustEO = sEmbedOnlyClusterTuple;
0055   cout << "    Set input track tuples:\n"
0056        << "      Embed Only  = " << sInTupleEO.Data() << "\n"
0057        << "      With Pileup = " << sInTuplePU.Data()
0058        << endl;
0059 
0060   if (sEmbedOnlyClusterTuple != "") {
0061     cout << "    Set input cluster tuples:\n"
0062          << "      Embed-only cluster tuple = " << sInClustEO.Data()
0063          << endl;
0064   }
0065   return;
0066 
0067 }  // end 'SetInputTuples(TString, TString)'
0068 
0069 
0070 
0071 void STrackCutStudy::SetStudyParameters(const Bool_t plots, const Bool_t pileup, const Bool_t intNorm, const Bool_t beforeCuts, const Bool_t avgClustCalc, const Double_t normalFracMin, const Double_t normalFracMax) {
0072 
0073   makePlots       = plots;
0074   doPileup        = pileup;
0075   doIntNorm       = intNorm;
0076   doBeforeCuts    = beforeCuts;
0077   doAvgClustCalc  = avgClustCalc;
0078   normalPtFracMin = normalFracMin;
0079   normalPtFracMax = normalFracMax;
0080   cout << "    Set normal pT fraction:\n"
0081        << "      Normal Pt Fraction = (" << normalPtFracMin << ", " << normalPtFracMax << ")"
0082        << endl;
0083 
0084   if (makePlots) {
0085     cout << "    Making plots." << endl;
0086   } else {
0087     cout << "    Not making plots." << endl;
0088   }
0089 
0090   if (doPileup) {
0091     cout << "    Looking at pileup tuple." << endl;
0092   } else {
0093     cout << "    Not looking at pileup tuple." << endl;
0094   }
0095 
0096   if (doIntNorm) {
0097     cout << "    Normalizing by integral." << endl;
0098   } else {
0099     cout << "    No normalization." << endl;
0100   }
0101 
0102   if (doBeforeCuts) {
0103     cout << "    Including quantities before cuts." << endl;
0104   } else {
0105     cout << "    Not including quantities before cuts." << endl;
0106   }
0107 
0108   if (doAvgClustCalc) {
0109     cout << "    Will calculate average cluster size." << endl;
0110   } else {
0111     cout << "    Will not calculate average cluster size." << endl;
0112   }
0113   return;
0114 
0115 }  // end 'SetStudyParameters(bool, bool, bool, bool, bool, double, double)'
0116 
0117 
0118 
0119 void STrackCutStudy::SetCutFlags(const Bool_t doPrimary, const Bool_t doMVtx, const Bool_t doTpc, const Bool_t doVz, const Bool_t doDcaXY, const Bool_t doDcaZ, const Bool_t doQuality) {
0120 
0121   doPrimaryCut = doPrimary;
0122   doMVtxCut    = doMVtx;
0123   doTpcCut     = doTpc;
0124   doVzCut      = doVz;
0125   doDcaXyCut   = doDcaXY;
0126   doDcaZCut    = doDcaZ;
0127   doQualityCut = doQuality;
0128   cout << "    Set cut flags:\n"
0129        << "      doPrimaryCut = " << doPrimaryCut << "\n"
0130        << "      doMVtxCut    = " << doMVtxCut    << "\n"
0131        << "      doTpcCut     = " << doTpcCut     << "\n"
0132        << "      doVzCut      = " << doVzCut      << "\n"
0133        << "      doDcaXyCut   = " << doDcaXyCut   << "\n"
0134        << "      doDCaZCut    = " << doDcaZCut    << "\n"
0135        << "      doQualityCut = " << doQualityCut
0136        << endl;
0137   return;
0138 
0139 
0140 }  // end 'SetCutFlags(Bool_t, Bool_t, Bool_t, Bool_t, Bool_t, Bool_t, Bool_t)'
0141 
0142 
0143 
0144 void STrackCutStudy::SetTrackCuts(const pair<UInt_t, UInt_t> nMVtxRange, const pair<UInt_t, UInt_t> nTpcRange, const pair<Double_t, Double_t> vzRange, const pair<Double_t, Double_t> dcaXyRange, const pair <Double_t, Double_t> dcaZRange, const pair<Double_t, Double_t> qualityRange) {
0145 
0146   nMVtxCut   = nMVtxRange;
0147   nTpcCut    = nTpcRange;
0148   vzCut      = vzRange;
0149   dcaXyCut   = dcaXyRange;
0150   dcaZCut    = dcaZRange;
0151   qualityCut = qualityRange;
0152   cout << "    Set track cuts:\n"
0153        << "      mvtx hits = (" << nMVtxCut.first   << ", " << nMVtxCut.second   << ")\n"
0154        << "      tpc hits  = (" << nTpcCut.first    << ", " << nTpcCut.second    << ")\n"
0155        << "      z-vertex  = (" << vzCut.first      << ", " << vzCut.second      << ")\n"
0156        << "      dca (xy)  = (" << dcaXyCut.first   << ", " << dcaXyCut.second   << ")\n"
0157        << "      dca (z)   = (" << dcaZCut.first    << ", " << dcaZCut.second    << ")\n"
0158        << "      quality   = (" << qualityCut.first << ", " << qualityCut.second << ")"
0159        << endl;
0160   return;
0161 
0162 }  // end 'SetTrackCuts(pair<UInt_t, UInt_t>, pair<UInt_t, UInt_t>, pair<Double_t, Double_t>, pair<Double_t, Double_t>, pair<Double_t, Double_t>, pair<Double_t, Double_t>)'
0163 
0164 
0165 
0166 void STrackCutStudy::SetPlotText(const Ssiz_t nTxtE, const Ssiz_t nTxtP, const TString sTxtE[], const TString sTxtP[]) {
0167 
0168   nTxtEO = nTxtE;
0169   nTxtPU = nTxtP;
0170   for (Ssiz_t iTxtEO = 0; iTxtEO < nTxtEO; iTxtEO++) {
0171     sTxtEO.push_back(sTxtE[iTxtEO]);
0172   }
0173   for (Ssiz_t iTxtPU = 0; iTxtPU < nTxtPU; iTxtPU++) {
0174     sTxtPU.push_back(sTxtP[iTxtPU]);
0175   }
0176   cout << "    Set plot text." << endl;
0177   return;
0178 
0179 }  // end 'SetPlotText(Ssiz_t, Ssiz_t, TString[], TString[])'
0180 
0181 
0182 
0183 void STrackCutStudy::InitFiles() {
0184 
0185   // open files
0186   fOut  = new TFile(sOutfile.Data(),  "recreate");
0187   fInEO = new TFile(sInFileEO.Data(), "read");
0188   fInPU = new TFile(sInFilePU.Data(), "read");
0189   if (!fOut || !fInEO || !fInPU) {
0190     cerr << "PANIC: couldn't open a file!\n"
0191          << "       fOut = " << fOut << ", fInEO = " << fInEO << ", fInPU = " << fInPU << "\n"
0192          << endl;
0193     assert(fOut && fInEO && fInPU);
0194   }
0195   cout << "      Initialized files." << endl;
0196   return;
0197 
0198 }  // end 'InitFiles()'
0199 
0200 
0201 
0202 void STrackCutStudy::InitTuples() {
0203 
0204   // grab embed-only tuples
0205   ntTrkEO = (TNtuple*) fInEO -> Get(sInTupleEO.Data());
0206   if (!ntTrkEO) {
0207     cerr << "PANIC: couldn't grab an input Ntuple!\n"
0208          << "       ntTrkEO = " << ntTrkEO << "\n"
0209          << endl;
0210     assert(ntTrkEO);
0211   }
0212 
0213   if (doPileup) {
0214     ntTrkPU = (TNtuple*) fInPU -> Get(sInTuplePU.Data());
0215     if (!ntTrkPU) {
0216       cerr << "PANIC: couldn't grab an input Ntuple!\n"
0217            << "       ntTrkPU = " << ntTrkPU << "\n"
0218            << endl;
0219       assert(ntTrkPU);
0220     }
0221   }
0222 
0223   if (doAvgClustCalc) {
0224     ntClustEO = (TNtuple*) fInEO -> Get(sInClustEO.Data());
0225     if (!ntClustEO) {
0226       cerr << "PANIC: couldn't grab an input cluster NTuple!\n"
0227            << "       ntClustEO = " << ntClustEO << "\n"
0228            << endl;
0229       assert(ntClustEO);
0230     }
0231   }
0232   cout << "      Initialized input ntuples." << endl;
0233 
0234   // set embed-only branch addresses
0235   ntTrkEO -> SetBranchAddress("event",           &event);
0236   ntTrkEO -> SetBranchAddress("seed",            &seed);
0237   ntTrkEO -> SetBranchAddress("trackID",         &trackID);
0238   ntTrkEO -> SetBranchAddress("crossing",        &crossing);
0239   ntTrkEO -> SetBranchAddress("px",              &px);
0240   ntTrkEO -> SetBranchAddress("py",              &py);
0241   ntTrkEO -> SetBranchAddress("pz",              &pz);
0242   ntTrkEO -> SetBranchAddress("pt",              &pt);
0243   ntTrkEO -> SetBranchAddress("eta",             &eta);
0244   ntTrkEO -> SetBranchAddress("phi",             &phi);
0245   ntTrkEO -> SetBranchAddress("deltapt",         &deltapt);
0246   ntTrkEO -> SetBranchAddress("deltaeta",        &deltaeta);
0247   ntTrkEO -> SetBranchAddress("deltaphi",        &deltaphi);
0248   ntTrkEO -> SetBranchAddress("charge",          &charge);
0249   ntTrkEO -> SetBranchAddress("quality",         &quality);
0250   ntTrkEO -> SetBranchAddress("chisq",           &chisq);
0251   ntTrkEO -> SetBranchAddress("ndf",             &ndf);
0252   ntTrkEO -> SetBranchAddress("nhits",           &nhits);
0253   ntTrkEO -> SetBranchAddress("nmaps",           &nmaps);
0254   ntTrkEO -> SetBranchAddress("nintt",           &nintt);
0255   ntTrkEO -> SetBranchAddress("ntpc",            &ntpc);
0256   ntTrkEO -> SetBranchAddress("nmms",            &nmms);
0257   ntTrkEO -> SetBranchAddress("ntpc1",           &ntpc1);
0258   ntTrkEO -> SetBranchAddress("ntpc11",          &ntpc11);
0259   ntTrkEO -> SetBranchAddress("ntpc2",           &ntpc2);
0260   ntTrkEO -> SetBranchAddress("ntpc3",           &ntpc3);
0261   ntTrkEO -> SetBranchAddress("nlmaps",          &nlmaps);
0262   ntTrkEO -> SetBranchAddress("nlintt",          &nlintt);
0263   ntTrkEO -> SetBranchAddress("nltpc",           &nltpc);
0264   ntTrkEO -> SetBranchAddress("nlmms",           &nlmms);
0265   ntTrkEO -> SetBranchAddress("layers",          &layers);
0266   ntTrkEO -> SetBranchAddress("vertexID",        &vertexID);
0267   ntTrkEO -> SetBranchAddress("vx",              &vx);
0268   ntTrkEO -> SetBranchAddress("vy",              &vy);
0269   ntTrkEO -> SetBranchAddress("vz",              &vz);
0270   ntTrkEO -> SetBranchAddress("dca2d",           &dca2d);
0271   ntTrkEO -> SetBranchAddress("dca2dsigma",      &dca2dsigma);
0272   ntTrkEO -> SetBranchAddress("dca3dxy",         &dca3dxy);
0273   ntTrkEO -> SetBranchAddress("dca3dxysigma",    &dca3dxysigma);
0274   ntTrkEO -> SetBranchAddress("dca3dz",          &dca3dz);
0275   ntTrkEO -> SetBranchAddress("dca3dzsigma",     &dca3dzsigma);
0276   ntTrkEO -> SetBranchAddress("pcax",            &pcax);
0277   ntTrkEO -> SetBranchAddress("pcay",            &pcay);
0278   ntTrkEO -> SetBranchAddress("pcaz",            &pcaz);
0279   ntTrkEO -> SetBranchAddress("gtrackID",        &gtrackID);
0280   ntTrkEO -> SetBranchAddress("gflavor",         &gflavor);
0281   ntTrkEO -> SetBranchAddress("gnhits",          &gnhits);
0282   ntTrkEO -> SetBranchAddress("gnmaps",          &gnmaps);
0283   ntTrkEO -> SetBranchAddress("gnintt",          &gnintt);
0284   ntTrkEO -> SetBranchAddress("gntpc",           &gntpc);
0285   ntTrkEO -> SetBranchAddress("gnmms",           &gnmms);
0286   ntTrkEO -> SetBranchAddress("gnlmaps",         &gnlmaps);
0287   ntTrkEO -> SetBranchAddress("gnlintt",         &gnlintt);
0288   ntTrkEO -> SetBranchAddress("gnltpc",          &gnltpc);
0289   ntTrkEO -> SetBranchAddress("gnlmms",          &gnlmms);
0290   ntTrkEO -> SetBranchAddress("gpx",             &gpx);
0291   ntTrkEO -> SetBranchAddress("gpy",             &gpy);
0292   ntTrkEO -> SetBranchAddress("gpz",             &gpz);
0293   ntTrkEO -> SetBranchAddress("gpt",             &gpt);
0294   ntTrkEO -> SetBranchAddress("geta",            &geta);
0295   ntTrkEO -> SetBranchAddress("gphi",            &gphi);
0296   ntTrkEO -> SetBranchAddress("gvx",             &gvx);
0297   ntTrkEO -> SetBranchAddress("gvy",             &gvy);
0298   ntTrkEO -> SetBranchAddress("gvz",             &gvz);
0299   ntTrkEO -> SetBranchAddress("gvt",             &gvt);
0300   ntTrkEO -> SetBranchAddress("gfpx",            &gfpx);
0301   ntTrkEO -> SetBranchAddress("gfpy",            &gfpy);
0302   ntTrkEO -> SetBranchAddress("gfpz",            &gfpz);
0303   ntTrkEO -> SetBranchAddress("gfx",             &gfx);
0304   ntTrkEO -> SetBranchAddress("gfy",             &gfy);
0305   ntTrkEO -> SetBranchAddress("gfz",             &gfz);
0306   ntTrkEO -> SetBranchAddress("gembed",          &gembed);
0307   ntTrkEO -> SetBranchAddress("gprimary",        &gprimary);
0308   ntTrkEO -> SetBranchAddress("nfromtruth",      &nfromtruth);
0309   ntTrkEO -> SetBranchAddress("nwrong",          &nwrong);
0310   ntTrkEO -> SetBranchAddress("ntrumaps",        &ntrumaps);
0311   ntTrkEO -> SetBranchAddress("ntruintt",        &ntruintt);
0312   ntTrkEO -> SetBranchAddress("ntrutpc",         &ntrutpc);
0313   ntTrkEO -> SetBranchAddress("ntrumms",         &ntrumms);
0314   ntTrkEO -> SetBranchAddress("ntrutpc1",        &ntrutpc1);
0315   ntTrkEO -> SetBranchAddress("ntrutpc11",       &ntrutpc11);
0316   ntTrkEO -> SetBranchAddress("ntrutpc2",        &ntrutpc2);
0317   ntTrkEO -> SetBranchAddress("ntrutpc3",        &ntrutpc3);
0318   ntTrkEO -> SetBranchAddress("layersfromtruth", &layersfromtruth);
0319   ntTrkEO -> SetBranchAddress("nhittpcall",      &nhittpcall);
0320   ntTrkEO -> SetBranchAddress("nhittpcin",       &nhittpcin);
0321   ntTrkEO -> SetBranchAddress("nhittpcmid",      &nhittpcmid);
0322   ntTrkEO -> SetBranchAddress("nhittpcout",      &nhittpcout);
0323   ntTrkEO -> SetBranchAddress("nclusall",        &nclusall);
0324   ntTrkEO -> SetBranchAddress("nclustpc",        &nclustpc);
0325   ntTrkEO -> SetBranchAddress("nclusintt",       &nclusintt);
0326   ntTrkEO -> SetBranchAddress("nclusmaps",       &nclusmaps);
0327   ntTrkEO -> SetBranchAddress("nclusmms",        &nclusmms);
0328 
0329   // set with-pileup branch
0330   if (doPileup) {
0331     ntTrkPU -> SetBranchAddress("event",           &pu_event);
0332     ntTrkPU -> SetBranchAddress("seed",            &pu_seed);
0333     ntTrkPU -> SetBranchAddress("gntracks",        &pu_gntracks);
0334     ntTrkPU -> SetBranchAddress("gtrackID",        &pu_gtrackID);
0335     ntTrkPU -> SetBranchAddress("gflavor",         &pu_gflavor);
0336     ntTrkPU -> SetBranchAddress("gnhits",          &pu_gnhits);
0337     ntTrkPU -> SetBranchAddress("gnmaps",          &pu_gnmaps);
0338     ntTrkPU -> SetBranchAddress("gnintt",          &pu_gnintt);
0339     ntTrkPU -> SetBranchAddress("gnmms",           &pu_gnmms);
0340     ntTrkPU -> SetBranchAddress("gnintt1",         &pu_gnintt1);
0341     ntTrkPU -> SetBranchAddress("gnintt2",         &pu_gnintt2);
0342     ntTrkPU -> SetBranchAddress("gnintt3",         &pu_gnintt3);
0343     ntTrkPU -> SetBranchAddress("gnintt4",         &pu_gnintt4);
0344     ntTrkPU -> SetBranchAddress("gnintt5",         &pu_gnintt5);
0345     ntTrkPU -> SetBranchAddress("gnintt6",         &pu_gnintt6);
0346     ntTrkPU -> SetBranchAddress("gnintt7",         &pu_gnintt7);
0347     ntTrkPU -> SetBranchAddress("gnintt8",         &pu_gnintt8);
0348     ntTrkPU -> SetBranchAddress("gntpc",           &pu_gntpc);
0349     ntTrkPU -> SetBranchAddress("gnlmaps",         &pu_gnlmaps);
0350     ntTrkPU -> SetBranchAddress("gnlintt",         &pu_gnlintt);
0351     ntTrkPU -> SetBranchAddress("gnltpc",          &pu_gnltpc);
0352     ntTrkPU -> SetBranchAddress("gnlmms",          &pu_gnlmms);
0353     ntTrkPU -> SetBranchAddress("gpx",             &pu_gpx);
0354     ntTrkPU -> SetBranchAddress("gpy",             &pu_gpy);
0355     ntTrkPU -> SetBranchAddress("gpz",             &pu_gpz);
0356     ntTrkPU -> SetBranchAddress("gpt",             &pu_gpt);
0357     ntTrkPU -> SetBranchAddress("geta",            &pu_geta);
0358     ntTrkPU -> SetBranchAddress("gphi",            &pu_gphi);
0359     ntTrkPU -> SetBranchAddress("gvx",             &pu_gvx);
0360     ntTrkPU -> SetBranchAddress("gvy",             &pu_gvy);
0361     ntTrkPU -> SetBranchAddress("gvz",             &pu_gvz);
0362     ntTrkPU -> SetBranchAddress("gvt",             &pu_gvt);
0363     ntTrkPU -> SetBranchAddress("gfpx",            &pu_gfpx);
0364     ntTrkPU -> SetBranchAddress("gfpy",            &pu_gfpy);
0365     ntTrkPU -> SetBranchAddress("gfpz",            &pu_gfpz);
0366     ntTrkPU -> SetBranchAddress("gfx",             &pu_gfx);
0367     ntTrkPU -> SetBranchAddress("gfy",             &pu_gfy);
0368     ntTrkPU -> SetBranchAddress("gfz",             &pu_gfz);
0369     ntTrkPU -> SetBranchAddress("gembed",          &pu_gembed);
0370     ntTrkPU -> SetBranchAddress("gprimary",        &pu_gprimary);
0371     ntTrkPU -> SetBranchAddress("trackID",         &pu_trackID);
0372     ntTrkPU -> SetBranchAddress("px",              &pu_px);
0373     ntTrkPU -> SetBranchAddress("py",              &pu_py);
0374     ntTrkPU -> SetBranchAddress("pz",              &pu_pz);
0375     ntTrkPU -> SetBranchAddress("pt",              &pu_pt);
0376     ntTrkPU -> SetBranchAddress("eta",             &pu_eta);
0377     ntTrkPU -> SetBranchAddress("phi",             &pu_phi);
0378     ntTrkPU -> SetBranchAddress("deltapt",         &pu_deltapt);
0379     ntTrkPU -> SetBranchAddress("deltaeta",        &pu_deltaeta);
0380     ntTrkPU -> SetBranchAddress("deltaphi",        &pu_deltaphi);
0381     ntTrkPU -> SetBranchAddress("charge",          &pu_charge);
0382     ntTrkPU -> SetBranchAddress("quality",         &pu_quality);
0383     ntTrkPU -> SetBranchAddress("chisq",           &pu_chisq);
0384     ntTrkPU -> SetBranchAddress("ndf",             &pu_ndf);
0385     ntTrkPU -> SetBranchAddress("nhits",           &pu_nhits);
0386     ntTrkPU -> SetBranchAddress("layers",          &pu_layers);
0387     ntTrkPU -> SetBranchAddress("nmaps",           &pu_nmaps);
0388     ntTrkPU -> SetBranchAddress("nintt",           &pu_nintt);
0389     ntTrkPU -> SetBranchAddress("ntpc",            &pu_ntpc);
0390     ntTrkPU -> SetBranchAddress("nmms",            &pu_nmms);
0391     ntTrkPU -> SetBranchAddress("ntpc1",           &pu_ntpc1);
0392     ntTrkPU -> SetBranchAddress("ntpc11",          &pu_ntpc11);
0393     ntTrkPU -> SetBranchAddress("ntpc2",           &pu_ntpc2);
0394     ntTrkPU -> SetBranchAddress("ntpc3",           &pu_ntpc3);
0395     ntTrkPU -> SetBranchAddress("nlmaps",          &pu_nlmaps);
0396     ntTrkPU -> SetBranchAddress("nlintt",          &pu_nlintt);
0397     ntTrkPU -> SetBranchAddress("nltpc",           &pu_nltpc);
0398     ntTrkPU -> SetBranchAddress("nlmms",           &pu_nlmms);
0399     ntTrkPU -> SetBranchAddress("vertexID",        &pu_vertexID);
0400     ntTrkPU -> SetBranchAddress("vx",              &pu_vx);
0401     ntTrkPU -> SetBranchAddress("vy",              &pu_vy);
0402     ntTrkPU -> SetBranchAddress("vz",              &pu_vz);
0403     ntTrkPU -> SetBranchAddress("dca2d",           &pu_dca2d);
0404     ntTrkPU -> SetBranchAddress("dca2dsigma",      &pu_dca2dsigma);
0405     ntTrkPU -> SetBranchAddress("dca3dxy",         &pu_dca3dxy);
0406     ntTrkPU -> SetBranchAddress("dca3dxysigma",    &pu_dca3dxysigma);
0407     ntTrkPU -> SetBranchAddress("dca3dz",          &pu_dca3dz);
0408     ntTrkPU -> SetBranchAddress("dca3dzsigma",     &pu_dca3dzsigma);
0409     ntTrkPU -> SetBranchAddress("pcax",            &pu_pcax);
0410     ntTrkPU -> SetBranchAddress("pcay",            &pu_pcay);
0411     ntTrkPU -> SetBranchAddress("pcaz",            &pu_pcaz);
0412     ntTrkPU -> SetBranchAddress("nfromtruth",      &pu_nfromtruth);
0413     ntTrkPU -> SetBranchAddress("nwrong",          &pu_nwrong);
0414     ntTrkPU -> SetBranchAddress("ntrumaps",        &pu_ntrumaps);
0415     ntTrkPU -> SetBranchAddress("ntruintt",        &pu_ntruintt);
0416     ntTrkPU -> SetBranchAddress("ntrutpc",         &pu_ntrutpc);
0417     ntTrkPU -> SetBranchAddress("ntrumms",         &pu_ntrumms);
0418     ntTrkPU -> SetBranchAddress("ntrutpc1",        &pu_ntrutpc1);
0419     ntTrkPU -> SetBranchAddress("ntrutpc11",       &pu_ntrutpc11);
0420     ntTrkPU -> SetBranchAddress("ntrutpc2",        &pu_ntrutpc2);
0421     ntTrkPU -> SetBranchAddress("ntrutpc3",        &pu_ntrutpc3);
0422     ntTrkPU -> SetBranchAddress("layersfromtruth", &pu_layersfromtruth);
0423     ntTrkPU -> SetBranchAddress("nhittpcall",      &pu_nhittpcall);
0424     ntTrkPU -> SetBranchAddress("nhittpcin",       &pu_nhittpcin);
0425     ntTrkPU -> SetBranchAddress("nhittpcmid",      &pu_nhittpcmid);
0426     ntTrkPU -> SetBranchAddress("nhittpcout",      &pu_nhittpcout);
0427     ntTrkPU -> SetBranchAddress("nclusall",        &pu_nclusall);
0428     ntTrkPU -> SetBranchAddress("nclustpc",        &pu_nclustpc);
0429     ntTrkPU -> SetBranchAddress("nclusintt",       &pu_nclusintt);
0430     ntTrkPU -> SetBranchAddress("nclusmaps",       &pu_nclusmaps);
0431     ntTrkPU -> SetBranchAddress("nclusmms",        &pu_nclusmms);
0432   }
0433   cout << "      Set branch addresses." << endl;
0434   return;
0435 
0436 }  // end 'InitTuples()'
0437 
0438 
0439 
0440 void STrackCutStudy::SaveHists() {
0441 
0442   // create output directories
0443   TDirectory *dOut[NType];
0444   for (UInt_t iDir = 0; iDir < NType; iDir++) {
0445    
0446     // check if directory should be created
0447     if (isBeforeCuts[iDir] || isPileup[iDir]) {
0448       if (isBeforeCuts[iDir] && !doBeforeCuts) continue;
0449       if (isPileup[iDir]     && !doPileup)     continue;
0450     }
0451 
0452     // create directory 
0453     fOut       -> cd();
0454     dOut[iDir] = (TDirectory*) fOut -> mkdir(sTrkNames[iDir].Data());
0455   }
0456   cout << "      Made directories." << endl;
0457 
0458   // save histograms
0459   for (int iType = 0; iType < NType; iType++) {
0460 
0461     // check if histograms should be saved
0462     if (isBeforeCuts[iType] || isPileup[iType]) {
0463       if (isBeforeCuts[iType] && !doBeforeCuts) continue;
0464       if (isPileup[iType]     && !doPileup)     continue;
0465     }
0466 
0467     dOut[iType] -> cd(); 
0468     for (size_t iTrkVar = 0; iTrkVar < NTrkVar; iTrkVar++) {
0469       hTrkVar[iType][iTrkVar]         -> Write();
0470       hTrkVarDiff[iType][iTrkVar]     -> Write();
0471       hTrkVarFrac[iType][iTrkVar]     -> Write();
0472       hTrkVarVsNTpc[iType][iTrkVar]   -> Write();
0473       hTrkVarVsPtReco[iType][iTrkVar] -> Write();
0474       hTrkVarVsPtTrue[iType][iTrkVar] -> Write();
0475       hTrkVarVsPtFrac[iType][iTrkVar] -> Write();
0476     }
0477     for (size_t iPhysVar = 0; iPhysVar < NPhysVar; iPhysVar++) {
0478       hPhysVar[iType][iPhysVar]         -> Write();
0479       hPhysVarDiff[iType][iPhysVar]     -> Write();
0480       hPhysVarFrac[iType][iPhysVar]     -> Write();
0481       hPhysVarVsNTpc[iType][iPhysVar]   -> Write();
0482       hPhysVarVsPtReco[iType][iPhysVar] -> Write();
0483       hPhysVarVsPtTrue[iType][iPhysVar] -> Write();
0484       hPhysVarVsPtFrac[iType][iPhysVar] -> Write();
0485     }
0486   }  // end type loop
0487 
0488   cout << "      Saved histograms." << endl;
0489   return;
0490 
0491 }  // end 'SaveHists()'
0492 
0493 // end ------------------------------------------------------------------------