CMS 3D CMS Logo

Phase1PixelMaps.h
Go to the documentation of this file.
1 #ifndef DQM_TRACKERREMAPPER_PHASE1PIXELMAPS_H
2 #define DQM_TRACKERREMAPPER_PHASE1PIXELMAPS_H
3 
4 #include "TH2Poly.h"
5 #include "TGraph.h"
6 #include "TH1.h"
7 #include "TH2.h"
8 #include "TStyle.h"
9 #include "TCanvas.h"
10 
11 #include <fmt/printf.h>
12 #include <fstream>
13 #include <boost/tokenizer.hpp>
14 #include <boost/range/adaptor/indexed.hpp>
15 
19 
20 #ifndef PHASE1PIXELMAP_STANDALONE
21 #define LOGDEBUG(x) LogDebug(x)
22 #else
23 #define LOGDEBUG(x) std::cout << x << ": "
24 #endif
25 
26 using indexedCorners = std::map<unsigned int, std::pair<std::vector<float>, std::vector<float>>>;
27 
28 /*--------------------------------------------------------------------
29 / Ancillary class to build pixel phase-1 tracker maps
30 /--------------------------------------------------------------------*/
32 public:
33  Phase1PixelMaps(const char* option)
34  : m_option{option},
35  m_isBooked{std::make_pair(false, false)},
36  m_knownNames{{}},
38  edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
39  // set the rescale to true by default
40  m_autorescale = true;
41 
42  // store the file in path for the corners (BPIX)
43  for (unsigned int i = 1; i <= 4; i++) {
44  m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i)));
45  }
46 
47  // store the file in path for the corners (BPIX)
48  for (int j : {-3, -2, -1, 1, 2, 3}) {
49  m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j)));
50  }
51  }
52 
53  ~Phase1PixelMaps() = default;
54 
55  // set of no rescale
56  inline void setNoRescale() { m_autorescale = false; }
57 
58  // set option, but only if not already set
59  void resetOption(const char* option);
60 
61  // book them all
62  void book(const std::string& currentHistoName, const char* what, const char* zaxis);
63 
64  // booking methods
65  void bookBarrelHistograms(const std::string& currentHistoName, const char* what, const char* zaxis);
66  void bookForwardHistograms(const std::string& currentHistoName, const char* what, const char* zaxis);
67 
68  // fill them all
69  void fill(const std::string& currentHistoName, unsigned int id, double value);
70 
71  // filling methods
72  void fillBarrelBin(const std::string& currentHistoName, unsigned int id, double value);
73  void fillForwardBin(const std::string& currentHistoName, unsigned int id, double value);
74 
75  // beautification methods
76  void beautifyAllHistograms();
77  void setBarrelScale(const std::string& currentHistoName, std::pair<float, float> extrema);
78  void setForwardScale(const std::string& currentHistoName, std::pair<float, float> extrema);
79 
80  // drawing methos
81  void drawBarrelMaps(const std::string& currentHistoName, TCanvas& canvas, const char* drawOption = nullptr);
82  void drawForwardMaps(const std::string& currentHistoName, TCanvas& canvas, const char* drawOption = nullptr);
83  void drawSummaryMaps(const std::string& currentHistoName, TCanvas& canvas, const char* drawOption = nullptr);
84 
85 private:
86  Option_t* m_option;
88  std::pair<bool, bool> m_isBooked;
89  std::vector<std::string> m_knownNames;
90 
92 
93  std::map<uint32_t, std::shared_ptr<TGraph>> bins, binsSummary;
94  std::map<std::string, std::vector<std::shared_ptr<TH2Poly>>> pxbTh2PolyBarrel;
95  std::map<std::string, std::shared_ptr<TH2Poly>> pxbTh2PolyBarrelSummary;
96  std::map<std::string, std::vector<std::shared_ptr<TH2Poly>>> pxfTh2PolyForward;
97  std::map<std::string, std::shared_ptr<TH2Poly>> pxfTh2PolyForwardSummary;
98 
99  std::vector<edm::FileInPath> m_cornersBPIX;
100  std::vector<edm::FileInPath> m_cornersFPIX;
101 
102  const indexedCorners retrieveCorners(const std::vector<edm::FileInPath>& cornerFiles, const unsigned int reads);
103 
104  // called by book histograms
105  void bookBarrelBins(const std::string& currentHistoName);
106  void bookForwardBins(const std::string& currentHistoName);
107 
108  // graphics
109  void makeNicePlotStyle(TH1* hist);
110  void adjustCanvasMargins(TVirtualPad* pad, float top, float bottom, float left, float right);
111  void rescaleAllBarrel(const std::string& currentHistoName);
112  void rescaleAllForward(const std::string& currentHistoName);
113 };
114 
115 #endif
void drawForwardMaps(const std::string &currentHistoName, TCanvas &canvas, const char *drawOption=nullptr)
std::vector< edm::FileInPath > m_cornersFPIX
void setBarrelScale(const std::string &currentHistoName, std::pair< float, float > extrema)
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
void makeNicePlotStyle(TH1 *hist)
Option_t * m_option
void rescaleAllForward(const std::string &currentHistoName)
void drawSummaryMaps(const std::string &currentHistoName, TCanvas &canvas, const char *drawOption=nullptr)
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
void fillForwardBin(const std::string &currentHistoName, unsigned int id, double value)
std::map< uint32_t, std::shared_ptr< TGraph > > binsSummary
std::vector< edm::FileInPath > m_cornersBPIX
void drawBarrelMaps(const std::string &currentHistoName, TCanvas &canvas, const char *drawOption=nullptr)
std::map< uint32_t, std::shared_ptr< TGraph > > bins
const indexedCorners retrieveCorners(const std::vector< edm::FileInPath > &cornerFiles, const unsigned int reads)
void resetOption(const char *option)
void bookBarrelBins(const std::string &currentHistoName)
TrackerTopology m_trackerTopo
void rescaleAllBarrel(const std::string &currentHistoName)
Phase1PixelMaps(const char *option)
std::map< unsigned int, std::pair< std::vector< float >, std::vector< float > >> indexedCorners
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
Definition: value.py:1
void bookForwardBins(const std::string &currentHistoName)
void beautifyAllHistograms()
std::pair< bool, bool > m_isBooked
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
std::vector< std::string > m_knownNames
void bookBarrelHistograms(const std::string &currentHistoName, const char *what, const char *zaxis)
void book(const std::string &currentHistoName, const char *what, const char *zaxis)
~Phase1PixelMaps()=default
void bookForwardHistograms(const std::string &currentHistoName, const char *what, const char *zaxis)
void fillBarrelBin(const std::string &currentHistoName, unsigned int id, double value)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
def canvas(sub, attr)
Definition: svgfig.py:482
void setForwardScale(const std::string &currentHistoName, std::pair< float, float > extrema)
void fill(const std::string &currentHistoName, unsigned int id, double value)