Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:03

0001 // ----------------------------------------------------------------------------
0002 // 'STrackMatcherComparator.h'
0003 // Derek Anderson
0004 // 01.30.2024
0005 //
0006 // Small module to produce plots from the output of the
0007 // SvtxEvaluator and FillMatchedClusTree modules.
0008 // ----------------------------------------------------------------------------
0009 
0010 #ifndef STRACKMATCHERCOMPARATOR_H
0011 #define STRACKMATCHERCOMPARATOR_H
0012 
0013 // c++ utilities
0014 #include <string>
0015 #include <optional>
0016 // root libraries
0017 #include <TFile.h>
0018 #include <TTree.h>
0019 #include <TNtuple.h>
0020 #include <TDirectory.h>
0021 // analysis utilities
0022 #include "STrackMatcherComparatorConfig.h"
0023 #include "STrackMatcherComparatorHistDef.h"
0024 #include "STrackMatcherComparatorHistContent.h"
0025 
0026 // make common namespaces implicit
0027 using namespace std;
0028 
0029 // forward declarations
0030 class PHCompositeNode;
0031 
0032 
0033 
0034 // STrackMatcherComparator definition -----------------------------------------
0035 
0036 class STrackMatcherComparator {
0037 
0038   // accessors
0039   enum Src {
0040     NewTree,
0041     NewTuple,
0042     OldTuple
0043   };
0044   enum Var {
0045     NTot,
0046     NIntt,
0047     NMvtx,
0048     NTpc,
0049     RTot,
0050     RIntt,
0051     RMvtx,
0052     RTpc,
0053     Phi,
0054     Eta,
0055     Pt,
0056     Frac,
0057     Qual,
0058     PtErr,
0059     EtaErr,
0060     PhiErr,
0061     PtRes,
0062     EtaRes,
0063     PhiRes
0064   };
0065   enum Type {
0066     Truth,
0067     Track,
0068     Weird,
0069     Normal
0070   };
0071   enum Comp {
0072     VsTruthPt,
0073     VsNumTpc
0074   };
0075 
0076   public:
0077 
0078     // ctor/dtor
0079     STrackMatcherComparator(optional<STrackMatcherComparatorConfig> config = nullopt);
0080     ~STrackMatcherComparator();
0081 
0082     // public methods
0083     void Init();
0084     void Analyze();
0085     void End();
0086 
0087      // setters
0088      void SetConfig(STrackMatcherComparatorConfig& config)  {m_config = config;}
0089      void SetHistDef(STrackMatcherComparatorHistDef& histo) {m_hist = histo;}
0090 
0091      // getters
0092      STrackMatcherComparatorConfig  GetConfig()  {return m_config;}
0093      STrackMatcherComparatorHistDef GetHistDef() {return m_hist;}
0094 
0095    private:
0096 
0097     // internal methods
0098     void OpenOutput();
0099     void OpenInput();
0100     void InitHists();
0101     void GetNewTreeHists();
0102     void GetNewTupleHists();
0103     void GetOldTupleHists();
0104     void MakeRatiosAndPlots(const vector<vector<TH1D*>> vecNewHists1D, const vector<vector<vector<TH2D*>>> vecNewHists2D, const int iDir, const string sLabel);
0105     void SaveHistograms();
0106     void CloseInput();
0107     void CloseOutput();
0108 
0109     // helper functions
0110     void FillHistogram1D(const STrackMatcherComparatorHistContent& content, const Type type, const vector<vector<TH1D*>> vecHist1D);
0111     void FillHistogram2D(const STrackMatcherComparatorHistContent& content, const Type type, const Comp comparison, const double value, const vector<vector<vector<TH2D*>>> vecHist2D);
0112     bool IsNearSector(const float phi);
0113 
0114     // configuration & histogram info
0115     STrackMatcherComparatorConfig  m_config;
0116     STrackMatcherComparatorHistDef m_hist;
0117 
0118     // i/o files
0119     TFile* m_outFile         = NULL;
0120     TFile* m_treeInFileTrue  = NULL;
0121     TFile* m_treeInFileReco  = NULL;
0122     TFile* m_tupleInFileTrue = NULL;
0123     TFile* m_tupleInFileReco = NULL;
0124     TFile* m_oldInFileTrue   = NULL;
0125     TFile* m_oldInFileReco   = NULL;
0126 
0127     // input trees/tuples
0128     TTree*   m_tTreeTrue   = NULL;
0129     TTree*   m_tTreeReco   = NULL;
0130     TNtuple* m_ntTupleTrue = NULL;
0131     TNtuple* m_ntTupleReco = NULL;
0132     TNtuple* m_ntOldTrue   = NULL;
0133     TNtuple* m_ntOldReco   = NULL;
0134 
0135     // output directories
0136     vector<TDirectory*> m_vecHistDirs;
0137     vector<TDirectory*> m_vecRatioDirs;
0138     vector<TDirectory*> m_vecPlotDirs;
0139 
0140     // 1d histogram vectors
0141     vector<vector<TH1D*>> m_vecTreeHists1D;
0142     vector<vector<TH1D*>> m_vecTupleHists1D;
0143     vector<vector<TH1D*>> m_vecOldHists1D;
0144 
0145     // 2d histogram vectors
0146     vector<vector<vector<TH2D*>>> m_vecTreeHists2D;
0147     vector<vector<vector<TH2D*>>> m_vecTupleHists2D;
0148     vector<vector<vector<TH2D*>>> m_vecOldHists2D;
0149 
0150     // class-wide constants
0151     struct Consts {
0152       size_t nDirHist;
0153       size_t nDirRatio;
0154       size_t nDirPlot;
0155       size_t nVtx;
0156       size_t nSide;
0157       size_t nAxes;
0158       size_t nSectors;
0159     } m_const = {3, 2, 2, 4, 4, 3, 12};
0160 
0161 };
0162 
0163 #endif
0164 
0165 // end ------------------------------------------------------------------------