Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-11 02:41:14

0001 //
0002 // NoiseRates.cc
0003 //
0004 //   description: Calculation for single particle response corrections
0005 //
0006 //   author: J.P. Chou, Brown
0007 //
0008 //
0009 
0010 #include "FWCore/Utilities/interface/EDMException.h"
0011 #include "Validation/HcalRecHits/interface/NoiseRates.h"
0012 
0013 //
0014 // constructors and destructor
0015 //
0016 
0017 NoiseRates::NoiseRates(const edm::ParameterSet &iConfig)
0018     : outputFile_(iConfig.getUntrackedParameter<std::string>("outputFile", "myfile.root")),
0019       rbxCollName_(iConfig.getUntrackedParameter<edm::InputTag>("rbxCollName")),
0020       minRBXEnergy_(iConfig.getUntrackedParameter<double>("minRBXEnergy")),
0021       minHitEnergy_(iConfig.getUntrackedParameter<double>("minHitEnergy")),
0022       useAllHistos_(iConfig.getUntrackedParameter<bool>("useAllHistos", false)),
0023       tok_rbx_(consumes<reco::HcalNoiseRBXCollection>(rbxCollName_)),
0024       noisetoken_(consumes<HcalNoiseSummary>(iConfig.getParameter<edm::InputTag>("noiselabel"))) {
0025   // DQM ROOT output
0026   // set parameters
0027   // Hcal Noise Summary
0028 }
0029 
0030 //
0031 // member functions
0032 //
0033 
0034 void NoiseRates::bookHistograms(DQMStore::IBooker &ib, edm::Run const &run, edm::EventSetup const &es) {
0035   ib.setCurrentFolder("NoiseRatesV/NoiseRatesTask");
0036 
0037   // book histograms
0038   Char_t histo[100];
0039 
0040   // Lumi block is not drawn; the rest are
0041   if (useAllHistos_) {
0042     sprintf(histo, "hLumiBlockCount");
0043     hLumiBlockCount_ = ib.book1D(histo, histo, 1, -0.5, 0.5);
0044   }
0045 
0046   sprintf(histo, "hRBXEnergy");
0047   hRBXEnergy_ = ib.book1D(histo, histo, 300, 0, 3000);
0048 
0049   sprintf(histo, "hRBXEnergyType1");
0050   hRBXEnergyType1_ = ib.book1D(histo, histo, 300, 0, 3000);
0051 
0052   sprintf(histo, "hRBXEnergyType2");
0053   hRBXEnergyType2_ = ib.book1D(histo, histo, 300, 0, 3000);
0054 
0055   sprintf(histo, "hRBXEnergyType3");
0056   hRBXEnergyType3_ = ib.book1D(histo, histo, 300, 0, 3000);
0057 
0058   sprintf(histo, "hRBXNHits");
0059   hRBXNHits_ = ib.book1D(histo, histo, 73, -0.5, 72.5);
0060 
0061   // HcalNoiseSummary
0062 
0063   sprintf(histo, "nNNumChannels");
0064   nNNumChannels_ = ib.book1D(histo, histo, 100, 0, 100);
0065   sprintf(histo, "nNSumE");
0066   nNSumE_ = ib.book1D(histo, histo, 100, 0, 5000);
0067   sprintf(histo, "nNSumEt");
0068   nNSumEt_ = ib.book1D(histo, histo, 100, 0, 2000);
0069 
0070   sprintf(histo, "sNNumChannels");
0071   sNNumChannels_ = ib.book1D(histo, histo, 100, 0, 100);
0072   sprintf(histo, "sNSumE");
0073   sNSumE_ = ib.book1D(histo, histo, 100, 0, 5000);
0074   sprintf(histo, "sNSumEt");
0075   sNSumEt_ = ib.book1D(histo, histo, 100, 0, 2000);
0076 
0077   sprintf(histo, "iNNumChannels");
0078   iNNumChannels_ = ib.book1D(histo, histo, 100, 0, 100);
0079   sprintf(histo, "iNSumE");
0080   iNSumE_ = ib.book1D(histo, histo, 100, 0, 5000);
0081   sprintf(histo, "iNSumEt");
0082   iNSumEt_ = ib.book1D(histo, histo, 100, 0, 2000);
0083 
0084   sprintf(histo, "hNoise_maxZeros");
0085   hNoise_maxZeros_ = ib.book1D(histo, histo, 80, 0, 80);
0086   sprintf(histo, "hNoise_maxHPDHits");
0087   hNoise_maxHPDHits_ = ib.book1D(histo, histo, 20, 0, 20);
0088   sprintf(histo, "hNoise_maxHPDNoOtherHits");
0089   hNoise_maxHPDNoOtherHits_ = ib.book1D(histo, histo, 20, 0, 20);
0090 }
0091 
0092 // ------------ method called to for each event  ------------
0093 void NoiseRates::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
0094   // get the lumi section
0095   int lumiSection = iEvent.luminosityBlock();
0096   lumiCountMap_[lumiSection]++;
0097 
0098   // get the RBX Noise collection
0099   const edm::Handle<reco::HcalNoiseRBXCollection> &handle = iEvent.getHandle(tok_rbx_);
0100   if (!handle.isValid()) {
0101     throw edm::Exception(edm::errors::ProductNotFound)
0102         << " could not find HcalNoiseRBXCollection named " << rbxCollName_ << ".\n";
0103     return;
0104   }
0105 
0106   // get the Noise summary object
0107   const edm::Handle<HcalNoiseSummary> &summary_h = iEvent.getHandle(noisetoken_);
0108   if (!summary_h.isValid()) {
0109     throw edm::Exception(edm::errors::ProductNotFound) << " could not find HcalNoiseSummary.\n";
0110     return;
0111   }
0112   const HcalNoiseSummary summary = *summary_h;
0113 
0114   // Fill the Noise Summary histograms
0115   nNNumChannels_->Fill(summary.numNegativeNoiseChannels());
0116   nNSumE_->Fill(summary.NegativeNoiseSumE());
0117   nNSumEt_->Fill(summary.NegativeNoiseSumEt());
0118 
0119   sNNumChannels_->Fill(summary.numSpikeNoiseChannels());
0120   sNSumE_->Fill(summary.spikeNoiseSumE());
0121   sNSumEt_->Fill(summary.spikeNoiseSumEt());
0122 
0123   iNNumChannels_->Fill(summary.numIsolatedNoiseChannels());
0124   iNSumE_->Fill(summary.isolatedNoiseSumE());
0125   iNSumEt_->Fill(summary.isolatedNoiseSumEt());
0126 
0127   hNoise_maxZeros_->Fill(summary.maxZeros());
0128   hNoise_maxHPDHits_->Fill(summary.maxHPDHits());
0129   hNoise_maxHPDNoOtherHits_->Fill(summary.maxHPDNoOtherHits());
0130 
0131   // loop over the RBXs and fill the histograms
0132   for (reco::HcalNoiseRBXCollection::const_iterator it = handle->begin(); it != handle->end(); ++it) {
0133     const reco::HcalNoiseRBX &rbx = (*it);
0134 
0135     double energy = rbx.recHitEnergy(minHitEnergy_);
0136 
0137     int nhits = rbx.numRecHits(minHitEnergy_);
0138 
0139     if (energy < minRBXEnergy_)
0140       continue;
0141 
0142     hRBXEnergy_->Fill(energy);
0143 
0144     if (nhits <= 9)
0145       hRBXEnergyType1_->Fill(energy);
0146     else if (nhits <= 18)
0147       hRBXEnergyType2_->Fill(energy);
0148     else
0149       hRBXEnergyType3_->Fill(energy);
0150 
0151     hRBXNHits_->Fill(nhits);
0152 
0153   }  // done looping over RBXs
0154 }
0155 
0156 // define this as a plug-in
0157 DEFINE_FWK_MODULE(NoiseRates);