Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SiStripMonitorDigi_SiStripMonitorDigi_h
0002 #define SiStripMonitorDigi_SiStripMonitorDigi_h
0003 // -*- C++ -*-
0004 // Package:     SiStripMonitorDigi
0005 // Class  :     SiStripMonitorDigi
0006 /**\class SiStripMonitorDigi SiStripMonitorDigi.h DQM/SiStripMonitorDigi/interface/SiStripMonitorDigi.h
0007    Data Quality Monitoring source of the Silicon Strip Tracker. Produces histograms related to digis.
0008 */
0009 // Original Author:  dkcira
0010 //         Created:  Sat Feb  4 20:49:51 CET 2006
0011 
0012 #include <memory>
0013 
0014 #include "CondFormats/RunInfo/interface/RunInfo.h"
0015 #include "DQM/SiStripCommon/interface/APVShot.h"
0016 #include "DQM/SiStripCommon/interface/APVShotFinder.h"
0017 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0018 #include "DQM/SiStripCommon/interface/TkHistoMap.h"
0019 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0020 #include "DQMServices/Core/interface/DQMStore.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 #include "FWCore/Framework/interface/LuminosityBlock.h"
0024 #include "FWCore/Framework/interface/MakerMacros.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "FWCore/Utilities/interface/EDGetToken.h"
0027 
0028 class SiStripDCSStatus;
0029 class SiStripDetCabling;
0030 
0031 class EventWithHistory;
0032 class L1GlobalTriggerEvmReadoutRecord;
0033 class APVCyclePhaseCollection;
0034 
0035 class SiStripMonitorDigi : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<bool>> {
0036 public:
0037   explicit SiStripMonitorDigi(const edm::ParameterSet&);
0038   ~SiStripMonitorDigi() override;
0039   void analyze(const edm::Event&, const edm::EventSetup&) override;
0040   std::shared_ptr<bool> globalBeginLuminosityBlock(const edm::LuminosityBlock& lumi,
0041                                                    const edm::EventSetup& iSetup) const override;
0042   void globalEndLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& iSetup) override;
0043   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0044   void dqmBeginRun(const edm::Run& r, const edm::EventSetup& c) override;
0045 
0046   std::string topFolderName_;
0047 
0048   struct ModMEs {
0049     MonitorElement* NumberOfDigis;
0050     MonitorElement* NumberOfDigisPerStrip;
0051     MonitorElement* ADCsHottestStrip;
0052     MonitorElement* ADCsCoolestStrip;
0053     MonitorElement* DigiADCs;
0054     MonitorElement* StripOccupancy;
0055   };
0056 
0057   struct LayerMEs {
0058     MonitorElement* LayerNumberOfDigis;
0059     MonitorElement* LayerNumberOfDigisTrend;
0060     MonitorElement* LayerADCsHottestStrip;
0061     MonitorElement* LayerADCsHottestStripTrend;
0062     MonitorElement* LayerADCsCoolestStrip;
0063     MonitorElement* LayerADCsCoolestStripTrend;
0064     MonitorElement* LayerDigiADCs;
0065     MonitorElement* LayerDigiADCsTrend;
0066     MonitorElement* LayerStripOccupancy;
0067     MonitorElement* LayerStripOccupancyTrend;
0068     MonitorElement* LayerNumberOfDigisProfile;
0069     MonitorElement* LayerDigiADCProfile;
0070   };
0071 
0072   struct SubDetMEs {
0073     int totNDigis = 0;
0074     MonitorElement* SubDetTotDigiProf = nullptr;
0075     MonitorElement* SubDetDigiApvProf = nullptr;
0076     MonitorElement* SubDetDigiApvTH2 = nullptr;
0077 
0078     //int totApvShots;
0079     std::vector<APVShot> SubDetApvShots;
0080     MonitorElement* SubDetNApvShotsTH1 = nullptr;
0081     MonitorElement* SubDetChargeMedianApvShotsTH1 = nullptr;
0082     MonitorElement* SubDetNStripsApvShotsTH1 = nullptr;
0083     MonitorElement* SubDetNApvShotsProf = nullptr;
0084     MonitorElement* SubDetNApvShotsNApvTH1 = nullptr;
0085   };
0086 
0087   struct DigiFailureMEs {
0088     MonitorElement* SubDetTotDigiProfLS;
0089     MonitorElement* SubDetDigiFailures2D;
0090   };
0091 
0092   MonitorElement* NumberOfFEDDigis = nullptr;
0093 
0094 private:
0095   void createMEs(DQMStore::IBooker& ibooker, const edm::EventSetup& es);
0096   void ResetModuleMEs(uint32_t idet);
0097   void bookLayer(DQMStore::IBooker& ibooker);
0098   MonitorElement* bookMETrend(DQMStore::IBooker& ibooker, const char* ParameterSetLabel, const char* HistoName);
0099   MonitorElement* bookME1D(DQMStore::IBooker& ibooker, const char* ParameterSetLabel, const char* HistoName);
0100   void bookTrendMEs(DQMStore::IBooker& ibooker, const TString& name, int32_t layer, uint32_t id, std::string flag);
0101   void fillDigiADCsMEs(int value, std::string name);
0102   void fillTrend(MonitorElement* me, float value, float timeinorbit);
0103   inline void fillME(MonitorElement* ME, float value1) {
0104     if (ME != nullptr)
0105       ME->Fill(value1);
0106   }
0107   inline void fillME(MonitorElement* ME, float value1, float value2) {
0108     if (ME != nullptr)
0109       ME->Fill(value1, value2);
0110   }
0111   inline void fillME(MonitorElement* ME, float value1, float value2, float value3) {
0112     if (ME != nullptr)
0113       ME->Fill(value1, value2, value3);
0114   }
0115   inline void fillME(MonitorElement* ME, float value1, float value2, float value3, float value4) {
0116     if (ME != nullptr)
0117       ME->Fill(value1, value2, value3, value4);
0118   }
0119   bool AllDigis(const edm::EventSetup& es);
0120 
0121   void createModuleMEs(DQMStore::IBooker& ibooker, ModMEs& mod_single, uint32_t detid);
0122   void createLayerMEs(DQMStore::IBooker& ibooker, std::string label, int ndet);
0123   void createSubDetMEs(DQMStore::IBooker& ibooker, std::string label);
0124   void createSubDetTH2(DQMStore::IBooker& ibooker, std::string label);
0125   int getDigiSourceIndex(uint32_t id);
0126   void AddApvShotsToSubDet(const std::vector<APVShot>&, std::vector<APVShot>&);
0127   void FillApvShotsMap(TkHistoMap*, const std::vector<APVShot>&, uint32_t id, int);
0128 
0129 private:
0130   edm::ParameterSet conf_;
0131   std::vector<edm::EDGetTokenT<edm::DetSetVector<SiStripDigi>>> digiProducerTokenList;
0132   std::vector<edm::InputTag> digiProducerList;
0133   std::map<uint32_t, ModMEs>
0134       DigiMEs;  // uint32_t me_type: 1=#digis/module; 2=adcs of hottest strip/module; 3= adcs of coolest strips/module.
0135   bool show_mechanical_structure_view, show_readout_view, show_control_view, select_all_detectors,
0136       calculate_strip_occupancy, reset_each_run;
0137 
0138   std::map<std::string, std::vector<uint32_t>> LayerDetMap;
0139   std::map<std::string, LayerMEs> LayerMEsMap;
0140   std::map<std::string, SubDetMEs> SubDetMEsMap;
0141   std::map<std::string, std::string> SubDetPhasePartMap;
0142   DigiFailureMEs digiFailureMEs;
0143 
0144   TString name;
0145   SiStripFolderOrganizer folder_organizer;
0146   std::map<std::pair<std::string, int32_t>, bool> DetectedLayers;
0147   std::vector<const edm::DetSetVector<SiStripDigi>*> digi_detset_handles;
0148 
0149   unsigned long long m_cacheID_;
0150   const SiStripDetCabling* SiStripDetCabling_;
0151   std::vector<uint32_t> ModulesToBeExcluded_;
0152 
0153   //Global MEs to monitor APV Shots properties
0154   MonitorElement *NApvShotsGlobal, *NApvShotsGlobalProf, *MedianChargeApvShotsGlobal, *NApvApvShotsGlobal,
0155       *StripMultiplicityApvShotsGlobal, *ShotsVsTimeApvShotsGlobal;
0156 
0157   std::unique_ptr<TkHistoMap> tkmapdigi, tkmapNApvshots, tkmapNstripApvshot, tkmapMedianChargeApvshots;
0158 
0159   int runNb, eventNb;
0160   int firstEvent;
0161   int TotalNShots;
0162 
0163   bool globalsummaryapvshotson;
0164 
0165   bool layerswitchnumdigison;
0166   bool layerswitchnumdigisapvon;
0167   bool layerswitchadchotteston;
0168   bool layerswitchadccooleston;
0169   bool layerswitchdigiadcson;
0170   bool layerswitchstripoccupancyon;
0171   bool layerswitchnumdigisprofon;
0172   bool layerswitchdigiadcprofon;
0173 
0174   bool moduleswitchnumdigison;
0175   bool moduleswitchnumdigispstripon;
0176   bool moduleswitchadchotteston;
0177   bool moduleswitchadccooleston;
0178   bool moduleswitchdigiadcson;
0179   bool moduleswitchstripoccupancyon;
0180 
0181   bool subdetswitchtotdigiprofon;
0182   bool subdetswitchapvcycleprofon;
0183   bool subdetswitchapvcycleth2on;
0184 
0185   bool subdetswitchtotdigifailureon;
0186 
0187   bool subdetswitchnapvshotson;
0188   bool subdetswitchnstripsapvshotson;
0189   bool subdetswitchapvshotsonprof;
0190   bool subdetswitchchargemedianapvshotson;
0191   bool subdetswitchapvshotsApvon;
0192 
0193   bool globalswitchnapvshotson;
0194   bool globalswitchnstripsapvshotson;
0195   bool globalswitchapvshotsonprof;
0196   bool globalswitchchargemedianapvshotson;
0197   bool globalswitchapvshotsApvon;
0198   bool globalswitchNDigisFEDID;
0199 
0200   //  int xLumiProf;
0201   int ignoreFirstNLumisections_;
0202   int integrateNLumisections_;
0203   int SBDeclaredAt;
0204   bool SBTransitionDone;
0205   int nFedTIB;
0206   int nFedTIDp;
0207   int nFedTIDm;
0208   int nFedTECp;
0209   int nFedTECm;
0210   int nFedTOB;
0211   //  int nFEDConnected;
0212 
0213   bool Mod_On_;
0214 
0215   bool digitkhistomapon;
0216   bool shotshistomapon;
0217   bool shotsstripshistomapon;
0218   bool shotschargehistomapon;
0219 
0220   bool createTrendMEs;
0221 
0222   bool m_trendVs10LS;
0223 
0224   std::vector<float> vecSubDetTotDigiProfLS;
0225   edm::InputTag historyProducer_;
0226   edm::InputTag apvPhaseProducer_;
0227 
0228   edm::EDGetTokenT<EventWithHistory> historyProducerToken_;
0229   edm::EDGetTokenT<APVCyclePhaseCollection> apvPhaseProducerToken_;
0230   edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> gtEvmToken_;
0231   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoTokenRun_;
0232   edm::ESGetToken<TkDetMap, TrackerTopologyRcd> tkDetMapTokenRun_;
0233   edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> SiStripDetCablingTokenRun_;
0234   edm::ESGetToken<RunInfo, RunInfoRcd> runInfoTokenRun_;
0235   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0236 
0237   SiStripDCSStatus* dcsStatus_;
0238 };
0239 #endif