Skip to content

Commit

Permalink
modernize CalibTracker/SiStripDCS
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Sep 15, 2021
1 parent 0db308a commit 2b5170b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 81 deletions.
67 changes: 55 additions & 12 deletions CalibTracker/SiStripDCS/plugins/FilterTrackerOn.cc
Original file line number Diff line number Diff line change
@@ -1,31 +1,74 @@
#include "CalibTracker/SiStripDCS/plugins/FilterTrackerOn.h"
// -*- C++ -*-
//
// Package: CalibTracker/SiStripDCS/plugins
// Class: FilterTrackerOn
//
/**\class FilterTrackerOn FilterTrackerOn.cc
#include "FWCore/Framework/interface/EventSetup.h"
Description: EDFilter returning true when the number of modules with HV on in the Tracker is
above a given threshold.
*/
//
// Original Author: Marco DE MATTIA
// Created: 2010/03/10 10:51:00
//
//

// system include files
#include <memory>
#include <iostream>
#include <algorithm>

// user include files
#include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDFilter.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

class FilterTrackerOn : public edm::stream::EDFilter<> {
public:
explicit FilterTrackerOn(const edm::ParameterSet&);
static void fillDescriptions(edm::ConfigurationDescriptions&);
~FilterTrackerOn() override;

private:
bool filter(edm::Event&, const edm::EventSetup&) override;

int minModulesWithHVoff_;
edm::ESGetToken<SiStripDetVOff, SiStripDetVOffRcd> detVOffToken_;
};

FilterTrackerOn::FilterTrackerOn(const edm::ParameterSet& iConfig)
: minModulesWithHVoff_(iConfig.getParameter<int>("MinModulesWithHVoff")), detVOffToken_(esConsumes()) {}

FilterTrackerOn::~FilterTrackerOn() {}
FilterTrackerOn::~FilterTrackerOn() = default;

void FilterTrackerOn::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.setComment("Filters out events in which at least a fraction of Tracker is DCS ON");
desc.addUntracked<int>("MinModulesWithHVoff", 0);
descriptions.addWithDefaultLabel(desc);
}

bool FilterTrackerOn::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;

const auto& detVOff = iSetup.getData(detVOffToken_);

// std::cout << "detVOff.getHVoffCounts() = " << detVOff.getHVoffCounts() << " < " << minModulesWithHVoff_;
LogDebug("FilterTrackerOn") << "detVOff.getHVoffCounts() = " << detVOff.getHVoffCounts() << " < "
<< minModulesWithHVoff_;
if (detVOff.getHVoffCounts() > minModulesWithHVoff_) {
// std::cout << " skipping event" << std::endl;
LogDebug("FilterTrackerOn") << " skipping event";
return false;
}
// cout << " keeping event" << endl;
LogDebug("FilterTrackerOn") << " keeping event";
return true;
}

// ------------ method called once each job just before starting event loop ------------
void FilterTrackerOn::beginJob() {}

// ------------ method called once each job just after ending the event loop ------------
void FilterTrackerOn::endJob() {}
// EDFilter on the max number of modules with HV off
DEFINE_FWK_MODULE(FilterTrackerOn);
44 changes: 0 additions & 44 deletions CalibTracker/SiStripDCS/plugins/FilterTrackerOn.h
Original file line number Diff line number Diff line change
@@ -1,45 +1 @@
// -*- C++ -*-
//
// Package: CalibTracker/SiStripDCS/plugins
// Class: SyncDCSO2O
//
/**\class FilterTrackerOn FilterTrackerOn.cc

Description: EDFilter returning true when the number of modules with HV on in the Tracker is
above a given threshold.
*/
//
// Original Author: Marco DE MATTIA
// Created: 2010/03/10 10:51:00
//
//

// system include files
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDFilter.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
#include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"

class FilterTrackerOn : public edm::EDFilter {
public:
explicit FilterTrackerOn(const edm::ParameterSet&);
~FilterTrackerOn() override;

private:
void beginJob() override;
bool filter(edm::Event&, const edm::EventSetup&) override;
void endJob() override;

int minModulesWithHVoff_;
edm::ESGetToken<SiStripDetVOff, SiStripDetVOffRcd> detVOffToken_;
};
4 changes: 0 additions & 4 deletions CalibTracker/SiStripDCS/plugins/SealModules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@
#include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
#include "CalibTracker/SiStripDCS/interface/SiStripDetVOffBuilder.h"
DEFINE_FWK_SERVICE(SiStripDetVOffBuilder);

// EDFilter on the max number of modules with HV off
#include "CalibTracker/SiStripDCS/plugins/FilterTrackerOn.h"
DEFINE_FWK_MODULE(FilterTrackerOn);
6 changes: 3 additions & 3 deletions CalibTracker/SiStripDCS/plugins/SiStripDetVOffHandler.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -11,7 +11,7 @@

#include "CalibTracker/SiStripDCS/interface/SiStripDetVOffBuilder.h"

class SiStripDetVOffHandler : public edm::EDAnalyzer {
class SiStripDetVOffHandler : public edm::one::EDAnalyzer<> {
public:
explicit SiStripDetVOffHandler(const edm::ParameterSet& iConfig);
~SiStripDetVOffHandler() override;
Expand Down Expand Up @@ -43,7 +43,7 @@ SiStripDetVOffHandler::SiStripDetVOffHandler(const edm::ParameterSet& iConfig)
m_condDb = m_localCondDbFile;
}

SiStripDetVOffHandler::~SiStripDetVOffHandler() {}
SiStripDetVOffHandler::~SiStripDetVOffHandler() = default;

void SiStripDetVOffHandler::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
// get last payload from condDb
Expand Down
2 changes: 1 addition & 1 deletion CalibTracker/SiStripDCS/plugins/SiStripDetVOffPrinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ SiStripDetVOffPrinter::SiStripDetVOffPrinter(const edm::ParameterSet& iConfig)
m_connectionPool.configure();
}

SiStripDetVOffPrinter::~SiStripDetVOffPrinter() {}
SiStripDetVOffPrinter::~SiStripDetVOffPrinter() = default;

void SiStripDetVOffPrinter::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
// use start and end time from config file
Expand Down
9 changes: 3 additions & 6 deletions CalibTracker/SiStripDCS/plugins/SiStripDetVOffTkMapPlotter.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -19,12 +19,11 @@
#include "DQM/SiStripCommon/interface/TkHistoMap.h"
#include "CommonTools/TrackerMap/interface/TrackerMap.h"

class SiStripDetVOffTkMapPlotter : public edm::EDAnalyzer {
class SiStripDetVOffTkMapPlotter : public edm::one::EDAnalyzer<> {
public:
explicit SiStripDetVOffTkMapPlotter(const edm::ParameterSet& iConfig);
~SiStripDetVOffTkMapPlotter() override;
void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) override;
void endJob() override;

private:
std::string formatIOV(cond::Time_t iov, std::string format = "%Y-%m-%d__%H_%M_%S");
Expand Down Expand Up @@ -60,7 +59,7 @@ SiStripDetVOffTkMapPlotter::SiStripDetVOffTkMapPlotter(const edm::ParameterSet&
m_connectionPool.configure();
}

SiStripDetVOffTkMapPlotter::~SiStripDetVOffTkMapPlotter() {}
SiStripDetVOffTkMapPlotter::~SiStripDetVOffTkMapPlotter() = default;

void SiStripDetVOffTkMapPlotter::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
cond::Time_t theIov = 0;
Expand Down Expand Up @@ -121,8 +120,6 @@ void SiStripDetVOffTkMapPlotter::analyze(const edm::Event& evt, const edm::Event
}
}

void SiStripDetVOffTkMapPlotter::endJob() {}

std::string SiStripDetVOffTkMapPlotter::formatIOV(cond::Time_t iov, std::string format) {
auto facet = new boost::posix_time::time_facet(format.c_str());
std::ostringstream stream;
Expand Down
7 changes: 2 additions & 5 deletions CalibTracker/SiStripDCS/plugins/SiStripDetVOffTrendPlotter.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -26,14 +26,13 @@
#include <TGraph.h>
#include <TH1.h>

class SiStripDetVOffTrendPlotter : public edm::EDAnalyzer {
class SiStripDetVOffTrendPlotter : public edm::one::EDAnalyzer<> {
public:
const std::vector<Color_t> PLOT_COLORS{kRed, kBlue, kBlack, kOrange, kMagenta};

explicit SiStripDetVOffTrendPlotter(const edm::ParameterSet &iConfig);
~SiStripDetVOffTrendPlotter() override;
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override;
void endJob() override;

private:
std::string formatIOV(cond::Time_t iov, std::string format = "%Y-%m-%d__%H_%M_%S");
Expand Down Expand Up @@ -212,8 +211,6 @@ void SiStripDetVOffTrendPlotter::analyze(const edm::Event &evt, const edm::Event
}
}

void SiStripDetVOffTrendPlotter::endJob() {}

std::string SiStripDetVOffTrendPlotter::formatIOV(cond::Time_t iov, std::string format) {
auto facet = new boost::posix_time::time_facet(format.c_str());
std::ostringstream stream;
Expand Down
9 changes: 3 additions & 6 deletions CalibTracker/SiStripDCS/plugins/TkVoltageMapCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -29,7 +29,7 @@
// class decleration
//

class TkVoltageMapCreator : public edm::EDAnalyzer {
class TkVoltageMapCreator : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
explicit TkVoltageMapCreator(const edm::ParameterSet&);
~TkVoltageMapCreator() override;
Expand Down Expand Up @@ -73,10 +73,7 @@ TkVoltageMapCreator::TkVoltageMapCreator(const edm::ParameterSet& iConfig)
//now do what ever initialization is needed
}

TkVoltageMapCreator::~TkVoltageMapCreator() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
TkVoltageMapCreator::~TkVoltageMapCreator() = default;

//
// member functions
Expand Down

0 comments on commit 2b5170b

Please sign in to comment.