DQMHcalIsolatedBunchAlCaReco

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
/*
 * \file DQMHcalIsolatedBunchAlCaReco.cc
 *
 * \author Olga Kodolova
 *
 *
 *
 * Description: Monitoring of Phi Symmetry Calibration Stream
 */

#include "FWCore/Common/interface/TriggerNames.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

// DQM include files

#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

// work on collections

#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/FEDRawData/interface/FEDHeader.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/FEDRawData/interface/FEDRawData.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"

#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"

#include "EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h"
#include "EventFilter/HcalRawToDigi/interface/HcalHTRData.h"

class DQMHcalIsolatedBunchAlCaReco : public DQMEDAnalyzer {
public:
  DQMHcalIsolatedBunchAlCaReco(const edm::ParameterSet &);
  ~DQMHcalIsolatedBunchAlCaReco() override;

protected:
  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
  void analyze(const edm::Event &e, const edm::EventSetup &c) override;

private:
  //
  // Monitor elements
  //
  MonitorElement *h_Event_, *h_hbhehit_, *h_hfhit_, *h_hohit_;

  /// DQM folder name
  std::string folderName_, trigName_;
  bool plotAll_;

  /// object to monitor
  edm::EDGetTokenT<HBHERecHitCollection> hbhereco_;
  edm::EDGetTokenT<HORecHitCollection> horeco_;
  edm::EDGetTokenT<HFRecHitCollection> hfreco_;
  edm::EDGetTokenT<edm::TriggerResults> trigResult_;
};

// ******************************************
// constructors
// *****************************************

DQMHcalIsolatedBunchAlCaReco::DQMHcalIsolatedBunchAlCaReco(const edm::ParameterSet &ps) {
  //
  // Input from configurator file
  //
  folderName_ = ps.getUntrackedParameter<std::string>("FolderName", "ALCAStreamHcalIsolatedBunch");
  trigName_ = ps.getParameter<std::string>("TriggerName");
  plotAll_ = ps.getUntrackedParameter<bool>("PlotAll", true);

  hbhereco_ = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInput"));
  horeco_ = consumes<HORecHitCollection>(ps.getParameter<edm::InputTag>("hoInput"));
  hfreco_ = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInput"));
  trigResult_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResult"));
}

DQMHcalIsolatedBunchAlCaReco::~DQMHcalIsolatedBunchAlCaReco() {}

//--------------------------------------------------------
void DQMHcalIsolatedBunchAlCaReco::bookHistograms(DQMStore::IBooker &ibooker,
                                                  edm::Run const &irun,
                                                  edm::EventSetup const &isetup) {
  // create and cd into new folder
  ibooker.setCurrentFolder(folderName_);
  h_Event_ = ibooker.book1D("hEvent", "Selection summary", 10, 0, 10);
  h_hbhehit_ = ibooker.book1D("hHBHEHit", "Size of HBHE Collection", 200, 0, 2000);
  h_hohit_ = ibooker.book1D("hHOHit", "Size of HO Collection", 200, 0, 2000);
  h_hfhit_ = ibooker.book1D("hHFHit", "Size of HF Collection", 200, 0, 2000);
}

//-------------------------------------------------------------

void DQMHcalIsolatedBunchAlCaReco::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
  bool accept(false);
  /////////////////////////////TriggerResults
  edm::Handle<edm::TriggerResults> triggerResults;
  iEvent.getByToken(trigResult_, triggerResults);
  if (triggerResults.isValid()) {
    const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerResults);
    const std::vector<std::string> &triggerNames_ = triggerNames.triggerNames();
    for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) {
      int hlt = triggerResults->accept(iHLT);
      if (hlt > 0) {
        if (triggerNames_[iHLT].find(trigName_) != std::string::npos) {
          accept = true;
          break;
        }
      }
    }
  }
  h_Event_->Fill(0.);
  if (accept)
    h_Event_->Fill(1.);

  if (accept || plotAll_) {
    edm::Handle<HBHERecHitCollection> hbhe;
    iEvent.getByToken(hbhereco_, hbhe);
    if (!hbhe.isValid()) {
      edm::LogInfo("HcalCalib") << "Cannot get hbhe product!" << std::endl;
    } else {
      h_hbhehit_->Fill(hbhe->size());
    }

    edm::Handle<HFRecHitCollection> hf;
    iEvent.getByToken(hfreco_, hf);
    if (!hf.isValid()) {
      edm::LogInfo("HcalCalib") << "Cannot get hf product!" << std::endl;
    } else {
      h_hfhit_->Fill(hf->size());
    }

    edm::Handle<HORecHitCollection> ho;
    iEvent.getByToken(horeco_, ho);
    if (!ho.isValid()) {
      edm::LogInfo("HcalCalib") << "Cannot get ho product!" << std::endl;
    } else {
      h_hohit_->Fill(ho->size());
    }
  }

}  // analyze

DEFINE_FWK_MODULE(DQMHcalIsolatedBunchAlCaReco);