Skip to content

Commit

Permalink
Fixed code style and format
Browse files Browse the repository at this point in the history
  • Loading branch information
casarsa committed Aug 28, 2019
1 parent 251e58f commit 2c9a297
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
33 changes: 14 additions & 19 deletions Validation/MtdValidation/plugins/BtlSimHitsHarvester.cc
Expand Up @@ -23,7 +23,6 @@

#include "DataFormats/ForwardDetId/interface/BTLDetId.h"


class BtlSimHitsHarvester : public DQMEDHarvester {
public:
explicit BtlSimHitsHarvester(const edm::ParameterSet& iConfig);
Expand All @@ -32,28 +31,26 @@ class BtlSimHitsHarvester : public DQMEDHarvester {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

protected:
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override;
void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override;

private:
const std::string folder_;

// --- Histograms
MonitorElement* meHitOccupancy_;

};

// ------------ constructor and destructor --------------
BtlSimHitsHarvester::BtlSimHitsHarvester(const edm::ParameterSet &iConfig)
: folder_(iConfig.getParameter<std::string>("folder")) {}
BtlSimHitsHarvester::BtlSimHitsHarvester(const edm::ParameterSet& iConfig)
: folder_(iConfig.getParameter<std::string>("folder")) {}

BtlSimHitsHarvester::~BtlSimHitsHarvester() {}

// ------------ endjob tasks ----------------------------
void BtlSimHitsHarvester::dqmEndJob(DQMStore::IBooker &ibook, DQMStore::IGetter &igetter) {

void BtlSimHitsHarvester::dqmEndJob(DQMStore::IBooker& ibook, DQMStore::IGetter& igetter) {
// --- Get the monitoring histograms
MonitorElement* meBtlHitLogEnergy = igetter.get(folder_+"BtlHitLogEnergy");
MonitorElement* meNevents = igetter.get(folder_+"BtlNevents");
MonitorElement* meBtlHitLogEnergy = igetter.get(folder_ + "BtlHitLogEnergy");
MonitorElement* meNevents = igetter.get(folder_ + "BtlNevents");

if (!meBtlHitLogEnergy || !meNevents) {
edm::LogError("BtlSimHitsHarvester") << "Monitoring histograms not found!" << std::endl;
Expand All @@ -63,23 +60,22 @@ void BtlSimHitsHarvester::dqmEndJob(DQMStore::IBooker &ibook, DQMStore::IGetter
// --- Get the number of BTL crystals and the number of processed events
const float NBtlCrystals = BTLDetId::kCrystalsPerRODBarPhiFlat * BTLDetId::MAX_ROD;
const float Nevents = meNevents->getEntries();
const float scale = (Nevents > 0 ? 1./(Nevents*NBtlCrystals) : 1.);
const float scale = (Nevents > 0 ? 1. / (Nevents * NBtlCrystals) : 1.);

// --- Book the cumulative histogram
ibook.cd(folder_);
meHitOccupancy_ = ibook.book1D(
"BtlHitOccupancy", "BTL cell occupancy vs hit energy;log_{10}(E_{SIM} [MeV]); Occupancy per event",
meBtlHitLogEnergy->getNbinsX(),
meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmin(),
meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmax());
meHitOccupancy_ = ibook.book1D("BtlHitOccupancy",
"BTL cell occupancy vs hit energy;log_{10}(E_{SIM} [MeV]); Occupancy per event",
meBtlHitLogEnergy->getNbinsX(),
meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmin(),
meBtlHitLogEnergy->getTH1()->GetXaxis()->GetXmax());

// --- Calculate the cumulative histogram
double bin_sum = meBtlHitLogEnergy->getBinContent(meBtlHitLogEnergy->getNbinsX()+1);
for (int ibin = meBtlHitLogEnergy->getNbinsX(); ibin>=1; --ibin) {
double bin_sum = meBtlHitLogEnergy->getBinContent(meBtlHitLogEnergy->getNbinsX() + 1);
for (int ibin = meBtlHitLogEnergy->getNbinsX(); ibin >= 1; --ibin) {
bin_sum += meBtlHitLogEnergy->getBinContent(ibin);
meHitOccupancy_->setBinContent(ibin, scale * bin_sum);
}

}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
Expand All @@ -89,7 +85,6 @@ void BtlSimHitsHarvester::fillDescriptions(edm::ConfigurationDescriptions& descr
desc.add<std::string>("folder", "MTD/BTL/SimHits/");

descriptions.add("btlSimHitsPostProcessor", desc);

}

DEFINE_FWK_MODULE(BtlSimHitsHarvester);
2 changes: 1 addition & 1 deletion Validation/MtdValidation/plugins/BtlSimHitsValidation.cc
Expand Up @@ -155,7 +155,7 @@ void BtlSimHitsValidation::analyze(const edm::Event& iEvent, const edm::EventSet
// Histogram filling
// ==============================================================================

if (m_btlHits.size() > 0)
if (!m_btlHits.empty())
meNhits_->Fill(log10(m_btlHits.size()));

for (auto const& hit : m_btlTrkPerCell)
Expand Down

0 comments on commit 2c9a297

Please sign in to comment.