Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-03 00:58:53

0001 #ifndef DQM_TRACKERREMAPPER_PHASE1PIXELSUMMARYMAP_H
0002 #define DQM_TRACKERREMAPPER_PHASE1PIXELSUMMARYMAP_H
0003 
0004 #include "TArrow.h"
0005 #include "TCanvas.h"
0006 #include "TGraph.h"
0007 #include "TH1.h"
0008 #include "TH2.h"
0009 #include "TH2Poly.h"
0010 #include "TLatex.h"
0011 #include "TStyle.h"
0012 
0013 #include <array>
0014 #include <fmt/printf.h>
0015 #include <fstream>
0016 #include <memory>
0017 #include <boost/tokenizer.hpp>
0018 #include <boost/range/adaptor/indexed.hpp>
0019 
0020 #include "FWCore/ParameterSet/interface/FileInPath.h"
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 #include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"
0023 
0024 #ifndef PH1PSUMMARYMAP_STANDALONE
0025 #define LOGDEBUG(x) LogDebug(x)
0026 #define LOGINFO(x) edm::LogInfo(x)
0027 #define LOGPRINT(x) edm::LogPrint(x)
0028 #else
0029 #define LOGDEBUG(x) std::cout << x << " Debug : "
0030 #define LOGINFO(x) std::cout << x << " Info : "
0031 #define LOGPRINT(x) std::cout << x << " : "
0032 #endif
0033 
0034 using indexedCorners = std::map<unsigned int, std::pair<std::vector<float>, std::vector<float>>>;
0035 
0036 namespace Ph1PMapSummaryHelper {
0037   //============================================================================
0038   // utility to tokenize std::string
0039   //============================================================================
0040   inline std::vector<std::string> tokenize(std::string line, char delimiter) {
0041     // Vector of string to save tokens
0042     std::vector<std::string> tokens;
0043     std::stringstream check1(line);
0044     std::string intermediate;
0045 
0046     // Tokenizing w.r.t. delimiter
0047     while (getline(check1, intermediate, delimiter)) {
0048       tokens.push_back(intermediate);
0049     }
0050     return tokens;
0051   }
0052 }  // namespace Ph1PMapSummaryHelper
0053 
0054 /*--------------------------------------------------------------------
0055 / Ancillary class to build pixel phase-1 tracker maps
0056 /--------------------------------------------------------------------*/
0057 class Phase1PixelSummaryMap {
0058 public:
0059   Phase1PixelSummaryMap(const char* option, std::string title, std::string zAxisTitle)
0060       : m_option{option},
0061         m_title{title},
0062         m_zAxisTitle{zAxisTitle},
0063         m_trackerTopo{StandaloneTrackerTopology::fromTrackerParametersXMLFile(
0064             edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
0065     // store the file in path for the corners (BPIX)
0066     for (unsigned int i = 1; i <= 4; i++) {
0067       m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i)));
0068     }
0069 
0070     // store the file in path for the corners (BPIX)
0071     for (int j : {-3, -2, -1, 1, 2, 3}) {
0072       m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j)));
0073     }
0074   }
0075 
0076   ~Phase1PixelSummaryMap() = default;
0077 
0078   void resetOption(const char* option);
0079   void createTrackerBaseMap();
0080   void printTrackerMap(TCanvas& canvas, const float topMargin = 0.02);
0081   bool fillTrackerMap(unsigned int id, double value);
0082 
0083 protected:
0084   void addNamedBins(edm::FileInPath geoFile, int tX, int tY, int sX, int sY, bool applyModuleRotation = false);
0085 
0086 private:
0087   Option_t* m_option;
0088   const std::string m_title;
0089   const std::string m_zAxisTitle;
0090 
0091   TrackerTopology m_trackerTopo;
0092   std::shared_ptr<TH2Poly> m_BaseTrackerMap;
0093   std::map<uint32_t, std::shared_ptr<TGraph>> bins;
0094 
0095   std::vector<edm::FileInPath> m_cornersBPIX;
0096   std::vector<edm::FileInPath> m_cornersFPIX;
0097 
0098   static const unsigned int maxPxBarrel = 4;
0099   static const unsigned int maxPxForward = 3;
0100   const std::array<int, maxPxBarrel> barrelLadderShift = {{0, 14, 44, 90}};
0101   const std::array<int, maxPxForward> forwardDiskXShift = {{25, 75, 125}};
0102 
0103   const int forwardDiskYShift = 45;  //# to make +DISK on top in the 'strip-like' layout
0104 
0105   const int plotWidth = 3000;
0106   const int plotHeight = 2000;
0107 
0108   TArrow arrow, phiArrow, xArrow, yArrow;
0109 };
0110 
0111 #endif