Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:38

0001 #ifndef DQM_SiStripCommon_TKHistoMap_h
0002 #define DQM_SiStripCommon_TKHistoMap_h
0003 
0004 #include "DQMServices/Core/interface/DQMStore.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ServiceRegistry/interface/Service.h"
0007 
0008 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
0009 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0010 #include <string>
0011 
0012 class TkHistoMap {
0013 protected:
0014   typedef dqm::legacy::DQMStore DQMStore;
0015   typedef dqm::legacy::MonitorElement MonitorElement;
0016   typedef std::vector<MonitorElement*> tkHistoMapVect;
0017 
0018 public:
0019   TkHistoMap(const TkDetMap* tkDetMap,
0020              DQMStore::IBooker& ibooker,
0021              const std::string& path,
0022              const std::string& MapName,
0023              float baseline = 0,
0024              bool mechanicalView = false,
0025              bool isTH2F = false);
0026   TkHistoMap(const TkDetMap* tkDetMap,
0027              const std::string& path,
0028              const std::string& MapName,
0029              float baseline = 0,
0030              bool mechanicalView = false);
0031   TkHistoMap(const TkDetMap* tkDetMap,
0032              const std::string& path,
0033              const std::string& MapName,
0034              float baseline,
0035              bool mechanicalView,
0036              bool isTH2F);
0037   TkHistoMap(const TkDetMap* tkDetMap);
0038   ~TkHistoMap() = default;
0039 
0040   void loadServices();
0041 
0042   void loadTkHistoMap(const std::string& path, const std::string& MapName, bool mechanicalView = false);
0043 
0044   MonitorElement* getMap(short layerNumber) { return tkHistoMap_[layerNumber]; };
0045   const std::vector<MonitorElement*>& getAllMaps() const { return tkHistoMap_; };
0046   std::vector<MonitorElement*>& getAllMaps() { return tkHistoMap_; };
0047 
0048   float getValue(DetId detid);
0049   float getEntries(DetId detid);
0050   DetId getDetId(const std::string& title, int ix, int iy) {
0051     return getDetId(getLayerNum(getLayerName(title)), ix, iy);
0052   }
0053   DetId getDetId(int layer, int ix, int iy) { return tkdetmap_->getDetFromBin(layer, ix, iy); }
0054   DetId getDetId(const MonitorElement* ME, int ix, int iy) { return getDetId(ME->getTitle(), ix, iy); }
0055   std::string getLayerName(std::string title) { return title.erase(0, MapName_.size() + 1); }
0056   uint16_t getLayerNum(const std::string& layerName) { return tkdetmap_->getLayerNum(layerName); }
0057 
0058   void fillFromAscii(const std::string& filename);
0059   void fill(DetId detid, float value);
0060   void setBinContent(DetId detid, float value);
0061   void add(DetId detid, float value);
0062 
0063   void dumpInTkMap(TrackerMap* tkmap,
0064                    bool dumpEntries = false);  //dumpEntries==true? (dump entries) : (dump mean values)
0065   void save(const std::string& filename);
0066   void saveAsCanvas(const std::string& filename, const std::string& options = "", const std::string& mode = "RECREATE");
0067 
0068 private:
0069   void load(const TkDetMap* tkDetMap,
0070             const std::string& path,
0071             float baseline,
0072             bool mechanicalView,
0073             bool isTH2F,
0074             bool createTkMap = true);
0075 
0076   void createTkHistoMap(DQMStore::IBooker& ibooker,
0077                         const std::string& path,
0078                         const std::string& MapName,
0079                         float baseline,
0080                         bool mechanicalView);
0081 
0082   std::string folderDefinition(DQMStore::IBooker& ibooker,
0083                                std::string folder,
0084                                const std::string& MapName,
0085                                int layer,
0086                                bool mechanicalView,
0087                                std::string& fullName);
0088 
0089   DQMStore* dqmStore_{nullptr};
0090 
0091   const TkDetMap* tkdetmap_;
0092   DetId cached_detid;
0093   int16_t cached_layer;
0094   TkLayerMap::XYbin cached_XYbin;
0095   std::vector<MonitorElement*> tkHistoMap_;
0096   int HistoNumber;
0097   std::string MapName_;
0098   bool isTH2F_;
0099 };
0100 
0101 #endif