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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
//
// HcalNoiseRates.cc
//
//   description: Calculation for single particle response corrections
//
//   author: K. Hatakeyama, H. Liu, Baylor
//
//

#include "DQMOffline/Hcal/interface/HcalNoiseRates.h"
#include "FWCore/Utilities/interface/EDMException.h"

//
// constructors and destructor
//

HcalNoiseRates::HcalNoiseRates(const edm::ParameterSet &iConfig) {
  // DQM ROOT output
  outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root");

  // set parameters
  rbxCollName_ = iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName");
  tok_rbx_ = consumes<reco::HcalNoiseRBXCollection>(rbxCollName_);
  minRBXEnergy_ = iConfig.getUntrackedParameter<double>("minRBXEnergy");
  minHitEnergy_ = iConfig.getUntrackedParameter<double>("minHitEnergy");

  useAllHistos_ = iConfig.getUntrackedParameter<bool>("useAllHistos", false);

  // Hcal Noise Summary
  noisetoken_ = consumes<HcalNoiseSummary>(iConfig.getParameter<edm::InputTag>("noiselabel"));
}

void HcalNoiseRates::bookHistograms(DQMStore::IBooker &ibooker,
                                    edm::Run const & /* iRun*/,
                                    edm::EventSetup const & /* iSetup */)

{
  ibooker.setCurrentFolder("HcalNoiseRatesD/HcalNoiseRatesTask");

  Char_t histo[100];

  // book histograms

  // Lumi block is not drawn; the rest are
  if (useAllHistos_) {
    sprintf(histo, "hLumiBlockCount");
    hLumiBlockCount_ = ibooker.book1D(histo, histo, 1, -0.5, 0.5);
  }

  sprintf(histo, "hRBXEnergy");
  hRBXEnergy_ = ibooker.book1D(histo, histo, 300, 0, 3000);

  sprintf(histo, "hRBXEnergyType1");
  hRBXEnergyType1_ = ibooker.book1D(histo, histo, 300, 0, 3000);

  sprintf(histo, "hRBXEnergyType2");
  hRBXEnergyType2_ = ibooker.book1D(histo, histo, 300, 0, 3000);

  sprintf(histo, "hRBXEnergyType3");
  hRBXEnergyType3_ = ibooker.book1D(histo, histo, 300, 0, 3000);

  sprintf(histo, "hRBXNHits");
  hRBXNHits_ = ibooker.book1D(histo, histo, 73, -0.5, 72.5);

  // HcalNoiseSummary

  sprintf(histo, "nNNumChannels");
  nNNumChannels_ = ibooker.book1D(histo, histo, 100, 0, 100);
  sprintf(histo, "nNSumE");
  nNSumE_ = ibooker.book1D(histo, histo, 100, 0, 5000);
  sprintf(histo, "nNSumEt");
  nNSumEt_ = ibooker.book1D(histo, histo, 100, 0, 2000);

  sprintf(histo, "sNNumChannels");
  sNNumChannels_ = ibooker.book1D(histo, histo, 100, 0, 100);
  sprintf(histo, "sNSumE");
  sNSumE_ = ibooker.book1D(histo, histo, 100, 0, 5000);
  sprintf(histo, "sNSumEt");
  sNSumEt_ = ibooker.book1D(histo, histo, 100, 0, 2000);

  sprintf(histo, "iNNumChannels");
  iNNumChannels_ = ibooker.book1D(histo, histo, 100, 0, 100);
  sprintf(histo, "iNSumE");
  iNSumE_ = ibooker.book1D(histo, histo, 100, 0, 5000);
  sprintf(histo, "iNSumEt");
  iNSumEt_ = ibooker.book1D(histo, histo, 100, 0, 2000);

  sprintf(histo, "hNoise_maxZeros");
  hNoise_maxZeros_ = ibooker.book1D(histo, histo, 80, 0, 80);
  sprintf(histo, "hNoise_maxHPDHits");
  hNoise_maxHPDHits_ = ibooker.book1D(histo, histo, 20, 0, 20);
  sprintf(histo, "hNoise_maxHPDNoOtherHits");
  hNoise_maxHPDNoOtherHits_ = ibooker.book1D(histo, histo, 20, 0, 20);
}

HcalNoiseRates::~HcalNoiseRates() {}

//
// member functions
//

// ------------ method called to for each event  ------------
void HcalNoiseRates::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
  // get the lumi section
  int lumiSection = iEvent.luminosityBlock();
  lumiCountMap_[lumiSection]++;

  // get the RBX Noise collection
  edm::Handle<reco::HcalNoiseRBXCollection> handle;
  iEvent.getByToken(tok_rbx_, handle);
  if (!handle.isValid()) {
    throw edm::Exception(edm::errors::ProductNotFound)
        << " could not find HcalNoiseRBXCollection named " << rbxCollName_ << ".\n";
    return;
  }

  // get the Noise summary object
  edm::Handle<HcalNoiseSummary> summary_h;
  iEvent.getByToken(noisetoken_, summary_h);
  if (!summary_h.isValid()) {
    throw edm::Exception(edm::errors::ProductNotFound) << " could not find HcalNoiseSummary.\n";
    return;
  }
  const HcalNoiseSummary summary = *summary_h;

  // Fill the Noise Summary histograms
  nNNumChannels_->Fill(summary.numNegativeNoiseChannels());
  nNSumE_->Fill(summary.NegativeNoiseSumE());
  nNSumEt_->Fill(summary.NegativeNoiseSumEt());

  sNNumChannels_->Fill(summary.numSpikeNoiseChannels());
  sNSumE_->Fill(summary.spikeNoiseSumE());
  sNSumEt_->Fill(summary.spikeNoiseSumEt());

  iNNumChannels_->Fill(summary.numIsolatedNoiseChannels());
  iNSumE_->Fill(summary.isolatedNoiseSumE());
  iNSumEt_->Fill(summary.isolatedNoiseSumEt());

  hNoise_maxZeros_->Fill(summary.maxZeros());
  hNoise_maxHPDHits_->Fill(summary.maxHPDHits());
  hNoise_maxHPDNoOtherHits_->Fill(summary.maxHPDNoOtherHits());

  // loop over the RBXs and fill the histograms
  for (reco::HcalNoiseRBXCollection::const_iterator it = handle->begin(); it != handle->end(); ++it) {
    const reco::HcalNoiseRBX &rbx = (*it);

    double energy = rbx.recHitEnergy(minHitEnergy_);

    int nhits = rbx.numRecHits(minHitEnergy_);

    if (energy < minRBXEnergy_)
      continue;

    hRBXEnergy_->Fill(energy);

    if (nhits <= 9)
      hRBXEnergyType1_->Fill(energy);
    else if (nhits <= 18)
      hRBXEnergyType2_->Fill(energy);
    else
      hRBXEnergyType3_->Fill(energy);

    hRBXNHits_->Fill(nhits);

  }  // done looping over RBXs
}

// define this as a plug-in
DEFINE_FWK_MODULE(HcalNoiseRates);