Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-12 02:58:42

0001 // -*- C++ -*-
0002 //
0003 // Package:    Validation/MtdValidation
0004 // Class:      BtlSimHitsHarvester
0005 //
0006 /**\class BtlSimHitsHarvester BtlSimHitsHarvester.cc Validation/MtdValidation/plugins/BtlSimHitsHarvester.cc
0007 
0008  Description: BTL SIM hits validation harvester
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 
0014 #include <string>
0015 
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/ServiceRegistry/interface/Service.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 
0021 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0022 #include "DQMServices/Core/interface/DQMStore.h"
0023 
0024 #include "DataFormats/ForwardDetId/interface/BTLDetId.h"
0025 
0026 class BtlSimHitsHarvester : public DQMEDHarvester {
0027 public:
0028   explicit BtlSimHitsHarvester(const edm::ParameterSet& iConfig);
0029   ~BtlSimHitsHarvester() override;
0030 
0031   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0032 
0033 protected:
0034   void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override;
0035 
0036 private:
0037   const std::string folder_;
0038 
0039   // --- Histograms
0040   MonitorElement* meHitOccupancy_;
0041 };
0042 
0043 // ------------ constructor and destructor --------------
0044 BtlSimHitsHarvester::BtlSimHitsHarvester(const edm::ParameterSet& iConfig)
0045     : folder_(iConfig.getParameter<std::string>("folder")) {}
0046 
0047 BtlSimHitsHarvester::~BtlSimHitsHarvester() {}
0048 
0049 // ------------ endjob tasks ----------------------------
0050 void BtlSimHitsHarvester::dqmEndJob(DQMStore::IBooker& ibook, DQMStore::IGetter& igetter) {
0051   // --- Get the monitoring histograms
0052   MonitorElement* meBtlHitLogEnergy = igetter.get(folder_ + "BtlHitLogEnergy");
0053   MonitorElement* meNevents = igetter.get(folder_ + "BtlNevents");
0054 
0055   if (!meBtlHitLogEnergy || !meNevents) {
0056     edm::LogError("BtlSimHitsHarvester") << "Monitoring histograms not found!" << std::endl;
0057     return;
0058   }
0059 
0060   // --- Get the number of BTL crystals and the number of processed events
0061   const float NBtlCrystals = BTLDetId::kCrystalsBTL;
0062   const float Nevents = meNevents->getEntries();
0063   const float scale = (Nevents > 0 ? 1. / (Nevents * NBtlCrystals) : 1.);
0064 
0065   // --- Book the cumulative histogram
0066   ibook.cd(folder_);
0067   meHitOccupancy_ = ibook.book1D("BtlHitOccupancy",
0068                                  "BTL cell occupancy vs hit energy;log_{10}(E_{SIM} [MeV]); Occupancy per event",
0069                                  meBtlHitLogEnergy->getNbinsX(),
0070                                  meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmin(),
0071                                  meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmax());
0072 
0073   // --- Calculate the cumulative histogram
0074   double bin_sum = meBtlHitLogEnergy->getBinContent(meBtlHitLogEnergy->getNbinsX() + 1);
0075   for (int ibin = meBtlHitLogEnergy->getNbinsX(); ibin >= 1; --ibin) {
0076     bin_sum += meBtlHitLogEnergy->getBinContent(ibin);
0077     meHitOccupancy_->setBinContent(ibin, scale * bin_sum);
0078   }
0079 }
0080 
0081 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0082 void BtlSimHitsHarvester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0083   edm::ParameterSetDescription desc;
0084 
0085   desc.add<std::string>("folder", "MTD/BTL/SimHits/");
0086 
0087   descriptions.add("btlSimHitsPostProcessor", desc);
0088 }
0089 
0090 DEFINE_FWK_MODULE(BtlSimHitsHarvester);