Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:24

0001 #ifndef _DQMOFFLINE_HCAL_HCALRECHITSANALYZER_H_
0002 #define _DQMOFFLINE_HCAL_HCALRECHITSANALYZER_H_
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/Frameworkfwd.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Utilities/interface/ESGetToken.h"
0011 
0012 #include "DQMServices/Core/interface/DQMStore.h"
0013 
0014 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0015 #include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
0016 
0017 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0018 #include <DataFormats/EcalDetId/interface/EBDetId.h>
0019 #include <DataFormats/EcalDetId/interface/EEDetId.h>
0020 
0021 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0022 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
0023 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
0024 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0025 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0026 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0027 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0028 #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
0029 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
0030 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0031 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0032 
0033 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0034 #include <algorithm>
0035 #include <cmath>
0036 #include <ostream>
0037 #include <string>
0038 #include <utility>
0039 #include <vector>
0040 
0041 #include "DataFormats/DetId/interface/DetId.h"
0042 // channel status
0043 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
0044 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0045 
0046 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
0047 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
0048 
0049 // severity level assignment for HCAL
0050 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
0051 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
0052 
0053 // severity level assignment for ECAL
0054 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
0055 
0056 class HcalRecHitsAnalyzer : public DQMEDAnalyzer {
0057 public:
0058   HcalRecHitsAnalyzer(edm::ParameterSet const &conf);
0059 
0060   void analyze(edm::Event const &ev, edm::EventSetup const &) override;
0061   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0062   // virtual void beginRun(edm::Run const& run, edm::EventSetup const&)
0063   // override;
0064   void dqmBeginRun(const edm::Run &run, const edm::EventSetup &) override;
0065 
0066 private:
0067   virtual void fillRecHitsTmp(int subdet_, edm::Event const &ev);
0068   double dR(double eta1, double phi1, double eta2, double phi2);
0069   double phi12(double phi1, double en1, double phi2, double en2);
0070   double dPhiWsign(double phi1, double phi2);
0071 
0072   std::string topFolderName_;
0073 
0074   std::string outputFile_;
0075   std::string hcalselector_;
0076   std::string ecalselector_;
0077   std::string eventype_;
0078   std::string sign_;
0079   bool hep17_;
0080   std::string mc_;
0081   bool famos_;
0082 
0083   int maxDepthHB_, maxDepthHE_, maxDepthHO_, maxDepthHF_, maxDepthAll_;
0084 
0085   int nChannels_[5];  // 0:any, 1:HB, 2:HE
0086 
0087   int iphi_bins_;
0088   float iphi_min_, iphi_max_;
0089 
0090   int ieta_bins_;
0091   float ieta_min_, ieta_max_;
0092 
0093   // RecHit Collection input tags
0094   edm::EDGetTokenT<HBHERecHitCollection> tok_hbhe_;
0095   edm::EDGetTokenT<HORecHitCollection> tok_ho_;
0096   edm::EDGetTokenT<HFRecHitCollection> tok_hf_;
0097   edm::EDGetTokenT<EBRecHitCollection> tok_EB_;
0098   edm::EDGetTokenT<EERecHitCollection> tok_EE_;
0099 
0100   edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> hcalDDDRecConstantsToken_;
0101   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryRunToken_;
0102   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryEventToken_;
0103   edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> hcalTopologyToken_;
0104   edm::ESGetToken<HcalChannelQuality, HcalChannelQualityRcd> hcalChannelQualityToken_;
0105   edm::ESGetToken<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd> hcalSeverityLevelComputerToken_;
0106 
0107   // choice of subdetector in config : noise/HB/HE/HO/HF/ALL (0/1/2/3/4/5)
0108   int subdet_;
0109 
0110   // single/multi-particle sample (1/2)
0111   int etype_;
0112   int iz;
0113   int imc;
0114 
0115   // Hcal topology
0116   const HcalTopology *theHcalTopology = nullptr;
0117   // for checking the status of ECAL and HCAL channels stored in the DB
0118   const HcalChannelQuality *theHcalChStatus = nullptr;
0119   // calculator of severety level for HCAL
0120   const HcalSeverityLevelComputer *theHcalSevLvlComputer = nullptr;
0121   int hcalSevLvl(const CaloRecHit *hit);
0122 
0123   std::vector<int> hcalHBSevLvlVec, hcalHESevLvlVec, hcalHFSevLvlVec, hcalHOSevLvlVec;
0124 
0125   MonitorElement *sevLvl_HB;
0126   MonitorElement *sevLvl_HE;
0127   MonitorElement *sevLvl_HF;
0128   MonitorElement *sevLvl_HO;
0129 
0130   // RecHits counters
0131   std::vector<MonitorElement *> Nhb;
0132   std::vector<MonitorElement *> Nhe;
0133   std::vector<MonitorElement *> Nho;
0134   std::vector<MonitorElement *> Nhf;
0135 
0136   // In ALL other cases : 2D ieta-iphi maps
0137   // without and with cuts (a la "Scheme B") on energy
0138   // - only in the cone around particle for single-part samples (mc = "yes")
0139   // - for all calls in milti-particle samples (mc = "no")
0140 
0141   MonitorElement *map_ecal;
0142 
0143   std::vector<MonitorElement *> emap;
0144   MonitorElement *emap_HO;
0145 
0146   std::vector<MonitorElement *> emean_vs_ieta_HB;
0147   std::vector<MonitorElement *> emean_vs_ieta_HBM0;
0148   std::vector<MonitorElement *> emean_vs_ieta_HBM3;
0149   std::vector<MonitorElement *> emean_vs_ieta_HE;
0150   std::vector<MonitorElement *> emean_vs_ieta_HEM0;
0151   std::vector<MonitorElement *> emean_vs_ieta_HEM3;
0152   std::vector<MonitorElement *> emean_vs_ieta_HEP17;
0153   std::vector<MonitorElement *> emean_vs_ieta_HEP17M0;
0154   std::vector<MonitorElement *> emean_vs_ieta_HEP17M3;
0155   std::vector<MonitorElement *> emean_vs_ieta_HF;
0156   MonitorElement *emean_vs_ieta_HO;
0157 
0158   std::vector<MonitorElement *> occupancy_map_HB;
0159   std::vector<MonitorElement *> occupancy_map_HE;
0160   std::vector<MonitorElement *> occupancy_map_HF;
0161   MonitorElement *occupancy_map_HO;
0162 
0163   std::vector<MonitorElement *> occupancy_vs_ieta_HB;
0164   std::vector<MonitorElement *> occupancy_vs_ieta_HE;
0165   std::vector<MonitorElement *> occupancy_vs_ieta_HF;
0166   MonitorElement *occupancy_vs_ieta_HO;
0167 
0168   std::vector<MonitorElement *> nrechits_vs_iphi_HBP, nrechits_vs_iphi_HBM;
0169   std::vector<MonitorElement *> nrechits_vs_iphi_HEP, nrechits_vs_iphi_HEM;
0170   std::vector<MonitorElement *> nrechits_vs_iphi_HFP, nrechits_vs_iphi_HFM;
0171   MonitorElement *nrechits_vs_iphi_HOP, *nrechits_vs_iphi_HOM;
0172 
0173   // for single monoenergetic particles - cone collection profile vs ieta.
0174   MonitorElement *meEnConeEtaProfile;
0175   MonitorElement *meEnConeEtaProfile_E;
0176   MonitorElement *meEnConeEtaProfile_EH;
0177   // Single particles - deviation of cluster from MC truth
0178   MonitorElement *meDeltaPhi;
0179   MonitorElement *meDeltaEta;
0180 
0181   // time?
0182   MonitorElement *meTimeHB;
0183   MonitorElement *meTimeHE;
0184   MonitorElement *meTimeHO;
0185   MonitorElement *meTimeHF;
0186 
0187   // energy of rechits
0188   MonitorElement *meRecHitsEnergyHB;
0189   MonitorElement *meRecHitsCleanedEnergyHB;
0190   MonitorElement *meRecHitsEnergyHBM0;
0191   MonitorElement *meRecHitsEnergyHBM3;
0192   MonitorElement *meRecHitsEnergyM2vM0HB;
0193   MonitorElement *meRecHitsEnergyM3vM0HB;
0194   MonitorElement *meRecHitsEnergyM3vM2HB;
0195   MonitorElement *meRecHitsM2Chi2HB;
0196 
0197   MonitorElement *meRecHitsEnergyHE;
0198   MonitorElement *meRecHitsCleanedEnergyHE;
0199   MonitorElement *meRecHitsEnergyHEM0;
0200   MonitorElement *meRecHitsEnergyHEM3;
0201   std::vector<MonitorElement *> meRecHitsEnergyHEP17;
0202   std::vector<MonitorElement *> meRecHitsEnergyHEP17M0;
0203   std::vector<MonitorElement *> meRecHitsEnergyHEP17M3;
0204   MonitorElement *meRecHitsEnergyM2vM0HE;
0205   MonitorElement *meRecHitsEnergyM3vM0HE;
0206   MonitorElement *meRecHitsEnergyM3vM2HE;
0207   MonitorElement *meRecHitsM2Chi2HE;
0208 
0209   MonitorElement *meRecHitsEnergyHO;
0210   MonitorElement *meRecHitsCleanedEnergyHO;
0211 
0212   MonitorElement *meRecHitsEnergyHF;
0213   MonitorElement *meRecHitsCleanedEnergyHF;
0214 
0215   MonitorElement *meTE_Low_HB;
0216   MonitorElement *meTE_HB;
0217   MonitorElement *meTE_High_HB;
0218   MonitorElement *meTEprofileHB_Low;
0219   MonitorElement *meTEprofileHB;
0220   MonitorElement *meLog10Chi2profileHB;
0221   MonitorElement *meTEprofileHB_High;
0222 
0223   MonitorElement *meTE_Low_HE;
0224   MonitorElement *meTE_HE;
0225   MonitorElement *meTEprofileHE_Low;
0226   MonitorElement *meTEprofileHE;
0227   MonitorElement *meLog10Chi2profileHE;
0228 
0229   MonitorElement *meTE_HO;
0230   MonitorElement *meTE_High_HO;
0231   MonitorElement *meTEprofileHO;
0232   MonitorElement *meTEprofileHO_High;
0233 
0234   MonitorElement *meTE_Low_HF;
0235   MonitorElement *meTE_HF;
0236   MonitorElement *meTEprofileHF_Low;
0237   MonitorElement *meTEprofileHF;
0238 
0239   MonitorElement *meSumRecHitsEnergyHB;
0240   MonitorElement *meSumRecHitsEnergyHE;
0241   MonitorElement *meSumRecHitsEnergyHO;
0242   MonitorElement *meSumRecHitsEnergyHF;
0243 
0244   MonitorElement *meSumRecHitsEnergyConeHB;
0245   MonitorElement *meSumRecHitsEnergyConeHE;
0246   MonitorElement *meSumRecHitsEnergyConeHO;
0247   MonitorElement *meSumRecHitsEnergyConeHF;
0248   MonitorElement *meSumRecHitsEnergyConeHFL;
0249   MonitorElement *meSumRecHitsEnergyConeHFS;
0250 
0251   MonitorElement *meEcalHcalEnergyHB;
0252   MonitorElement *meEcalHcalEnergyHE;
0253 
0254   MonitorElement *meEcalHcalEnergyConeHB;
0255   MonitorElement *meEcalHcalEnergyConeHE;
0256   MonitorElement *meEcalHcalEnergyConeHO;
0257   MonitorElement *meEcalHcalEnergyConeHF;
0258 
0259   // 2D plot of sum of RecHits in HCAL as function of ECAL's one
0260   MonitorElement *meEnergyHcalVsEcalHB;
0261   MonitorElement *meEnergyHcalVsEcalHE;
0262 
0263   // number of ECAL's rechits in cone 0.3
0264   MonitorElement *meNumEcalRecHitsConeHB;
0265   MonitorElement *meNumEcalRecHitsConeHE;
0266 
0267   CaloGeometry const *geometry = nullptr;
0268 
0269   // Status word histos
0270   MonitorElement *RecHit_StatusWord_HB;
0271   MonitorElement *RecHit_StatusWord_HE;
0272   MonitorElement *RecHit_StatusWord_HF;
0273   MonitorElement *RecHit_StatusWord_HF67;
0274   MonitorElement *RecHit_StatusWord_HO;
0275 
0276   // Status word correlation
0277   MonitorElement *RecHit_StatusWordCorr_HB;
0278   MonitorElement *RecHit_StatusWordCorr_HE;
0279 
0280   // Aux Status word histos
0281   MonitorElement *RecHit_Aux_StatusWord_HB;
0282   MonitorElement *RecHit_Aux_StatusWord_HE;
0283   MonitorElement *RecHit_Aux_StatusWord_HF;
0284   MonitorElement *RecHit_Aux_StatusWord_HO;
0285 
0286   // Filling vectors with essential RecHits data
0287   std::vector<int> csub;
0288   std::vector<int> cieta;
0289   std::vector<int> ciphi;
0290   std::vector<int> cdepth;
0291   std::vector<double> cen;
0292   std::vector<double> cenM0;
0293   std::vector<double> cenM3;
0294   std::vector<double> cchi2;
0295   std::vector<double> ceta;
0296   std::vector<double> cphi;
0297   std::vector<double> ctime;
0298   std::vector<double> cz;
0299   std::vector<uint32_t> cstwd;
0300   std::vector<uint32_t> cauxstwd;
0301   std::vector<int> csevlev;
0302 
0303   // counter
0304   int nevtot;
0305 };
0306 
0307 #endif