Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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