Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:23:45

0001 #ifndef DQM_TRACKERREMAPPER_PHASE1PIXELMAPS_H
0002 #define DQM_TRACKERREMAPPER_PHASE1PIXELMAPS_H
0003 
0004 #include "TH2Poly.h"
0005 #include "TGraph.h"
0006 #include "TH1.h"
0007 #include "TH2.h"
0008 #include "TStyle.h"
0009 #include "TCanvas.h"
0010 
0011 #include <fmt/printf.h>
0012 #include <fstream>
0013 #include <boost/tokenizer.hpp>
0014 #include <boost/range/adaptor/indexed.hpp>
0015 
0016 #include "FWCore/ParameterSet/interface/FileInPath.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0019 
0020 #ifndef PHASE1PIXELMAP_STANDALONE
0021 #define LOGDEBUG(x) LogDebug(x)
0022 #else
0023 #define LOGDEBUG(x) std::cout << x << ": "
0024 #endif
0025 
0026 using indexedCorners = std::map<unsigned int, std::pair<std::vector<float>, std::vector<float>>>;
0027 
0028 /*--------------------------------------------------------------------
0029 / Ancillary class to build pixel phase-1 tracker maps
0030 /--------------------------------------------------------------------*/
0031 class Phase1PixelMaps {
0032 public:
0033   Phase1PixelMaps(const char* option)
0034       : m_option{option},
0035         m_isBooked{std::make_pair(false, false)},
0036         m_knownNames{{}},
0037         m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
0038             edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
0039     // set the rescale to true by default
0040     m_autorescale = true;
0041 
0042     // store the file in path for the corners (BPIX)
0043     for (unsigned int i = 1; i <= 4; i++) {
0044       m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i)));
0045     }
0046 
0047     // store the file in path for the corners (BPIX)
0048     for (int j : {-3, -2, -1, 1, 2, 3}) {
0049       m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j)));
0050     }
0051   }
0052 
0053   ~Phase1PixelMaps() = default;
0054 
0055   // set of no rescale
0056   inline void setNoRescale() { m_autorescale = false; }
0057 
0058   // set option, but only if not already set
0059   void resetOption(const char* option);
0060 
0061   // book them all
0062   void book(const std::string& currentHistoName, const char* what, const char* zaxis);
0063 
0064   // booking methods
0065   void bookBarrelHistograms(const std::string& currentHistoName, const char* what, const char* zaxis);
0066   void bookForwardHistograms(const std::string& currentHistoName, const char* what, const char* zaxis);
0067 
0068   // fill them all
0069   void fill(const std::string& currentHistoName, unsigned int id, double value);
0070 
0071   // filling methods
0072   void fillBarrelBin(const std::string& currentHistoName, unsigned int id, double value);
0073   void fillForwardBin(const std::string& currentHistoName, unsigned int id, double value);
0074 
0075   // beautification methods
0076   void beautifyAllHistograms();
0077   void setBarrelScale(const std::string& currentHistoName, std::pair<float, float> extrema);
0078   void setForwardScale(const std::string& currentHistoName, std::pair<float, float> extrema);
0079 
0080   // drawing methos
0081   void drawBarrelMaps(const std::string& currentHistoName, TCanvas& canvas, const char* drawOption = nullptr);
0082   void drawForwardMaps(const std::string& currentHistoName, TCanvas& canvas, const char* drawOption = nullptr);
0083   void drawSummaryMaps(const std::string& currentHistoName, TCanvas& canvas, const char* drawOption = nullptr);
0084 
0085 private:
0086   Option_t* m_option;
0087   bool m_autorescale;
0088   std::pair<bool, bool> m_isBooked;
0089   std::vector<std::string> m_knownNames;
0090 
0091   TrackerTopology m_trackerTopo;
0092 
0093   std::map<uint32_t, std::shared_ptr<TGraph>> bins, binsSummary;
0094   std::map<std::string, std::vector<std::shared_ptr<TH2Poly>>> pxbTh2PolyBarrel;
0095   std::map<std::string, std::shared_ptr<TH2Poly>> pxbTh2PolyBarrelSummary;
0096   std::map<std::string, std::vector<std::shared_ptr<TH2Poly>>> pxfTh2PolyForward;
0097   std::map<std::string, std::shared_ptr<TH2Poly>> pxfTh2PolyForwardSummary;
0098 
0099   std::vector<edm::FileInPath> m_cornersBPIX;
0100   std::vector<edm::FileInPath> m_cornersFPIX;
0101 
0102   const indexedCorners retrieveCorners(const std::vector<edm::FileInPath>& cornerFiles, const unsigned int reads);
0103 
0104   // called by book histograms
0105   void bookBarrelBins(const std::string& currentHistoName);
0106   void bookForwardBins(const std::string& currentHistoName);
0107 
0108   // graphics
0109   void makeNicePlotStyle(TH1* hist);
0110   void adjustCanvasMargins(TVirtualPad* pad, float top, float bottom, float left, float right);
0111   void rescaleAllBarrel(const std::string& currentHistoName);
0112   void rescaleAllForward(const std::string& currentHistoName);
0113 };
0114 
0115 #endif