CMS 3D CMS Logo

BtlSimHitsHarvester.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Validation/MtdValidation
4 // Class: BtlSimHitsHarvester
5 //
14 #include <string>
15 
20 
23 
25 
27 public:
28  explicit BtlSimHitsHarvester(const edm::ParameterSet& iConfig);
29  ~BtlSimHitsHarvester() override;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 protected:
35 
36 private:
38 
39  // --- Histograms
41 };
42 
43 // ------------ constructor and destructor --------------
45  : folder_(iConfig.getParameter<std::string>("folder")) {}
46 
48 
49 // ------------ endjob tasks ----------------------------
51  // --- Get the monitoring histograms
52  MonitorElement* meBtlHitLogEnergy = igetter.get(folder_ + "BtlHitLogEnergy");
53  MonitorElement* meNevents = igetter.get(folder_ + "BtlNevents");
54 
55  if (!meBtlHitLogEnergy || !meNevents) {
56  edm::LogError("BtlSimHitsHarvester") << "Monitoring histograms not found!" << std::endl;
57  return;
58  }
59 
60  // --- Get the number of BTL crystals and the number of processed events
61  const float NBtlCrystals = BTLDetId::kCrystalsPerRODBarPhiFlat * BTLDetId::MAX_ROD;
62  const float Nevents = meNevents->getEntries();
63  const float scale = (Nevents > 0 ? 1. / (Nevents * NBtlCrystals) : 1.);
64 
65  // --- Book the cumulative histogram
66  ibook.cd(folder_);
67  meHitOccupancy_ = ibook.book1D("BtlHitOccupancy",
68  "BTL cell occupancy vs hit energy;log_{10}(E_{SIM} [MeV]); Occupancy per event",
69  meBtlHitLogEnergy->getNbinsX(),
70  meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmin(),
71  meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmax());
72 
73  // --- Calculate the cumulative histogram
74  double bin_sum = meBtlHitLogEnergy->getBinContent(meBtlHitLogEnergy->getNbinsX() + 1);
75  for (int ibin = meBtlHitLogEnergy->getNbinsX(); ibin >= 1; --ibin) {
76  bin_sum += meBtlHitLogEnergy->getBinContent(ibin);
77  meHitOccupancy_->setBinContent(ibin, scale * bin_sum);
78  }
79 }
80 
81 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
84 
85  desc.add<std::string>("folder", "MTD/BTL/SimHits/");
86 
87  descriptions.add("btlSimHitsPostProcessor", desc);
88 }
89 
DQMEDHarvester.h
BTLDetId.h
MessageLogger.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
BtlSimHitsHarvester::meHitOccupancy_
MonitorElement * meHitOccupancy_
Definition: BtlSimHitsHarvester.cc:40
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
BtlSimHitsHarvester::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: BtlSimHitsHarvester.cc:82
MakerMacros.h
BtlSimHitsHarvester::folder_
const std::string folder_
Definition: BtlSimHitsHarvester.cc:37
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Service.h
BTLDetId::MAX_ROD
static constexpr int MAX_ROD
Definition: BTLDetId.h:51
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:475
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqm::impl::MonitorElement::getEntries
virtual double getEntries() const
get # of entries
Definition: MonitorElement.cc:628
folder_
std::string folder_
Definition: DQMEDAnalyzer.cc:60
BtlSimHitsHarvester::~BtlSimHitsHarvester
~BtlSimHitsHarvester() override
Definition: BtlSimHitsHarvester.cc:47
edm::ParameterSet
Definition: ParameterSet.h:47
BtlSimHitsHarvester::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: BtlSimHitsHarvester.cc:50
BtlSimHitsHarvester::BtlSimHitsHarvester
BtlSimHitsHarvester(const edm::ParameterSet &iConfig)
Definition: BtlSimHitsHarvester.cc:44
BTLDetId::kCrystalsPerRODBarPhiFlat
static constexpr int kCrystalsPerRODBarPhiFlat
Definition: BTLDetId.h:48
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DQMEDHarvester
Definition: DQMEDHarvester.py:1
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
BtlSimHitsHarvester
Definition: BtlSimHitsHarvester.cc:26
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
dqm::implementation::IBooker
Definition: DQMStore.h:43
ParameterSet.h
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98