Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:57:31

0001 /*
0002  * \file DQMHcalIsolatedBunchAlCaReco.cc
0003  *
0004  * \author Olga Kodolova
0005  *
0006  *
0007  *
0008  * Description: Monitoring of Phi Symmetry Calibration Stream
0009  */
0010 
0011 #include "FWCore/Common/interface/TriggerNames.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/EventSetup.h"
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/ServiceRegistry/interface/Service.h"
0019 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0020 
0021 // DQM include files
0022 
0023 #include "DQMServices/Core/interface/DQMStore.h"
0024 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0025 #include "DQMServices/Core/interface/DQMStore.h"
0026 
0027 // work on collections
0028 
0029 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0030 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0031 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
0032 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0033 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0034 #include "DataFormats/Common/interface/TriggerResults.h"
0035 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0036 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0037 
0038 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0039 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0040 
0041 #include "EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h"
0042 #include "EventFilter/HcalRawToDigi/interface/HcalHTRData.h"
0043 
0044 class DQMHcalIsolatedBunchAlCaReco : public DQMEDAnalyzer {
0045 public:
0046   DQMHcalIsolatedBunchAlCaReco(const edm::ParameterSet &);
0047   ~DQMHcalIsolatedBunchAlCaReco() override;
0048 
0049 protected:
0050   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0051   void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0052 
0053 private:
0054   //
0055   // Monitor elements
0056   //
0057   MonitorElement *h_Event_, *h_hbhehit_, *h_hfhit_, *h_hohit_;
0058 
0059   /// DQM folder name
0060   std::string folderName_, trigName_;
0061   bool plotAll_;
0062 
0063   /// object to monitor
0064   edm::EDGetTokenT<HBHERecHitCollection> hbhereco_;
0065   edm::EDGetTokenT<HORecHitCollection> horeco_;
0066   edm::EDGetTokenT<HFRecHitCollection> hfreco_;
0067   edm::EDGetTokenT<edm::TriggerResults> trigResult_;
0068 };
0069 
0070 // ******************************************
0071 // constructors
0072 // *****************************************
0073 
0074 DQMHcalIsolatedBunchAlCaReco::DQMHcalIsolatedBunchAlCaReco(const edm::ParameterSet &ps) {
0075   //
0076   // Input from configurator file
0077   //
0078   folderName_ = ps.getUntrackedParameter<std::string>("FolderName", "ALCAStreamHcalIsolatedBunch");
0079   trigName_ = ps.getParameter<std::string>("TriggerName");
0080   plotAll_ = ps.getUntrackedParameter<bool>("PlotAll", true);
0081 
0082   hbhereco_ = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInput"));
0083   horeco_ = consumes<HORecHitCollection>(ps.getParameter<edm::InputTag>("hoInput"));
0084   hfreco_ = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInput"));
0085   trigResult_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResult"));
0086 }
0087 
0088 DQMHcalIsolatedBunchAlCaReco::~DQMHcalIsolatedBunchAlCaReco() {}
0089 
0090 //--------------------------------------------------------
0091 void DQMHcalIsolatedBunchAlCaReco::bookHistograms(DQMStore::IBooker &ibooker,
0092                                                   edm::Run const &irun,
0093                                                   edm::EventSetup const &isetup) {
0094   // create and cd into new folder
0095   ibooker.setCurrentFolder(folderName_);
0096   h_Event_ = ibooker.book1D("hEvent", "Selection summary", 10, 0, 10);
0097   h_hbhehit_ = ibooker.book1D("hHBHEHit", "Size of HBHE Collection", 200, 0, 2000);
0098   h_hohit_ = ibooker.book1D("hHOHit", "Size of HO Collection", 200, 0, 2000);
0099   h_hfhit_ = ibooker.book1D("hHFHit", "Size of HF Collection", 200, 0, 2000);
0100 }
0101 
0102 //-------------------------------------------------------------
0103 
0104 void DQMHcalIsolatedBunchAlCaReco::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0105   bool accept(false);
0106   /////////////////////////////TriggerResults
0107   edm::Handle<edm::TriggerResults> triggerResults;
0108   iEvent.getByToken(trigResult_, triggerResults);
0109   if (triggerResults.isValid()) {
0110     const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerResults);
0111     const std::vector<std::string> &triggerNames_ = triggerNames.triggerNames();
0112     for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) {
0113       int hlt = triggerResults->accept(iHLT);
0114       if (hlt > 0) {
0115         if (triggerNames_[iHLT].find(trigName_) != std::string::npos) {
0116           accept = true;
0117           break;
0118         }
0119       }
0120     }
0121   }
0122   h_Event_->Fill(0.);
0123   if (accept)
0124     h_Event_->Fill(1.);
0125 
0126   if (accept || plotAll_) {
0127     edm::Handle<HBHERecHitCollection> hbhe;
0128     iEvent.getByToken(hbhereco_, hbhe);
0129     if (!hbhe.isValid()) {
0130       edm::LogInfo("HcalCalib") << "Cannot get hbhe product!" << std::endl;
0131     } else {
0132       h_hbhehit_->Fill(hbhe->size());
0133     }
0134 
0135     edm::Handle<HFRecHitCollection> hf;
0136     iEvent.getByToken(hfreco_, hf);
0137     if (!hf.isValid()) {
0138       edm::LogInfo("HcalCalib") << "Cannot get hf product!" << std::endl;
0139     } else {
0140       h_hfhit_->Fill(hf->size());
0141     }
0142 
0143     edm::Handle<HORecHitCollection> ho;
0144     iEvent.getByToken(horeco_, ho);
0145     if (!ho.isValid()) {
0146       edm::LogInfo("HcalCalib") << "Cannot get ho product!" << std::endl;
0147     } else {
0148       h_hohit_->Fill(ho->size());
0149     }
0150   }
0151 
0152 }  // analyze
0153 
0154 DEFINE_FWK_MODULE(DQMHcalIsolatedBunchAlCaReco);