Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:24

0001 #ifndef _PlotValidation_
0002 #define _PlotValidation_
0003 
0004 #include "TFile.h"
0005 #include "TTree.h"
0006 #include "TBranch.h"
0007 #include "TDirectory.h"
0008 #include "TString.h"
0009 #include "TEfficiency.h"
0010 #include "TH1F.h"
0011 #include "TCanvas.h"
0012 #include "TROOT.h"
0013 #include "TSystem.h"
0014 #include "TStyle.h"
0015 
0016 #include <string>
0017 #include <vector>
0018 #include <map>
0019 #include <iomanip>
0020 #include <iostream>
0021 #include <fstream>
0022 #include <sstream>
0023 #include <cmath>
0024 
0025 typedef std::vector<Float_t> FltVec;
0026 typedef std::vector<FltVec> FltVecVec;
0027 typedef std::vector<Double_t> DblVec;
0028 typedef std::vector<DblVec> DblVecVec;
0029 typedef std::vector<Int_t> IntVec;
0030 typedef std::vector<TString> TStrVec;
0031 
0032 typedef std::vector<TBranch*> TBrRefVec;
0033 typedef std::vector<TBrRefVec> TBrRefVecVec;
0034 typedef std::vector<TDirectory*> TDirRefVec;
0035 
0036 typedef std::map<TString, TH1F*> TH1FRefMap;
0037 typedef std::map<TString, TEfficiency*> TEffRefMap;
0038 
0039 struct EffStruct {
0040   EffStruct() {}
0041   ~EffStruct() {}
0042 
0043   Float_t passed_;
0044   Float_t total_;
0045 
0046   Float_t eff_;
0047   Float_t elow_;
0048   Float_t eup_;
0049 };
0050 
0051 class PlotValidation {
0052 public:
0053   PlotValidation(const TString& inName,
0054                  const TString& outName,
0055                  const Bool_t cmsswComp,
0056                  const int algo,
0057                  const Bool_t mvInput,
0058                  const Bool_t rmSuffix,
0059                  const Bool_t saveAs,
0060                  const TString& outType);
0061   ~PlotValidation();
0062 
0063   // setup functions
0064   void SetupStyle();
0065   void SetupBins();
0066   void SetupVariableBins(const std::string& s_bins, DblVec& bins);
0067   void SetupFixedBins(const UInt_t nBins, const Double_t low, const Double_t high, DblVec& bins);
0068   void SetupCommonVars();
0069 
0070   // main call
0071   void Validation(int algo = 0);
0072   void PlotEffTree(int algo = 0);
0073   void PlotFRTree(int algo = 0);
0074   void PrintTotals(int algo = 0);
0075 
0076   // output functions
0077   template <typename T>
0078   void DrawWriteSavePlot(T*& plot, TDirectory*& subdir, const TString& subdirname, const TString& option);
0079 
0080   // helper functions
0081   void MakeOutDir(const TString& outdirname);
0082   void GetTotalEfficiency(const TEfficiency* eff, EffStruct& effs);
0083   TDirectory* MakeSubDirs(const TString& subdirname);
0084   void MoveInput();
0085 
0086 private:
0087   // input+output config
0088   const TString fInName;
0089   const Bool_t fCmsswComp;
0090   const Bool_t fMvInput;
0091   const Bool_t fRmSuffix;
0092   const Bool_t fSaveAs;
0093   const TString fOutType;
0094 
0095   const int fAlgo;
0096 
0097   // main input
0098   TFile* fInRoot;
0099   TTree* efftree;
0100   TTree* frtree;
0101 
0102   // binning for rate plots
0103   DblVec fPtBins;
0104   DblVec fEtaBins;
0105   DblVec fPhiBins;
0106   DblVec fNLayersBins;
0107 
0108   // binning for track quality hists
0109   DblVec fNHitsBins;
0110   DblVec fFracHitsBins;
0111   DblVec fScoreBins;
0112 
0113   // binning for diff hists
0114   DblVec fDNHitsBins;
0115   DblVec fDInvPtBins;
0116   DblVec fDPhiBins;
0117   DblVec fDEtaBins;
0118 
0119   // rate vars
0120   TStrVec fVars;
0121   TStrVec fSVars;
0122   TStrVec fSUnits;
0123   UInt_t fNVars;
0124 
0125   TString fSVarPt;
0126   TString fSUnitPt;
0127 
0128   // rate bins
0129   DblVecVec fVarBins;
0130 
0131   // track collections
0132   TStrVec fTrks;
0133   TStrVec fSTrks;
0134   UInt_t fNTrks;
0135 
0136   // pt cuts
0137   FltVec fPtCuts;
0138   TStrVec fSPtCuts;
0139   TStrVec fHPtCuts;
0140   UInt_t fNPtCuts;
0141 
0142   // track quality plots
0143   TStrVec fTrkQual;
0144   TStrVec fSTrkQual;
0145   UInt_t fNTrkQual;
0146 
0147   // reference related strings
0148   TString fSRefTitle;
0149   TString fSRefVar;
0150   TString fSRefMask;
0151   TString fSRefVarTrk;
0152   TString fSRefDir;
0153   TString fSRefOut;
0154 
0155   // output variables
0156   TString fOutName;
0157   TFile* fOutRoot;
0158 };
0159 
0160 #endif