Skip to content

Commit

Permalink
Migration to 'getByToken', part I.
Browse files Browse the repository at this point in the history
  • Loading branch information
Volker Adler committed Oct 17, 2013
1 parent db648f1 commit fa38838
Show file tree
Hide file tree
Showing 17 changed files with 1,044 additions and 1,040 deletions.
278 changes: 139 additions & 139 deletions DQM/SiStripMonitorCluster/src/SiStripMonitorCluster.cc

Large diffs are not rendered by default.

206 changes: 103 additions & 103 deletions DQM/SiStripMonitorTrack/src/SiStripMonitorTrack.cc

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions DQM/TrackerMonitorTrack/src/MonitorTrackResiduals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
#include "DQMServices/Core/interface/MonitorElement.h"
#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"

MonitorTrackResiduals::MonitorTrackResiduals(const edm::ParameterSet& iConfig)
MonitorTrackResiduals::MonitorTrackResiduals(const edm::ParameterSet& iConfig)
: dqmStore_( edm::Service<DQMStore>().operator->() )
, conf_(iConfig), m_cacheID_(0)
, genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig)) {
, conf_(iConfig), m_cacheID_(0)
, genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig, consumesCollector())) {
}

MonitorTrackResiduals::~MonitorTrackResiduals() {
if (genTriggerEventFlag_) delete genTriggerEventFlag_;
if (genTriggerEventFlag_) delete genTriggerEventFlag_;
}


Expand All @@ -38,26 +38,26 @@ void MonitorTrackResiduals::beginJob(void) {
}

void MonitorTrackResiduals::beginRun(edm::Run const& run, edm::EventSetup const& iSetup) {

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHandle;
iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
const TrackerTopology* const tTopo = tTopoHandle.product();

unsigned long long cacheID = iSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
if (m_cacheID_ != cacheID) {
m_cacheID_ = cacheID;
m_cacheID_ = cacheID;
this->createMEs(iSetup);
}
if(reset_me_after_each_run) {
if(ModOn) {
for(std::map<int32_t, MonitorElement*>::const_iterator it = HitResidual.begin(),
for(std::map<int32_t, MonitorElement*>::const_iterator it = HitResidual.begin(),
itEnd = HitResidual.end(); it!= itEnd;++it) {
this->resetModuleMEs(it->first);
this->resetLayerMEs(folder_organizer.GetSubDetAndLayer(it->first, tTopo));
}
} else {
for(std::map< std::pair<std::string,int32_t>, MonitorElement*>::const_iterator it = m_SubdetLayerResiduals.begin(),
for(std::map< std::pair<std::string,int32_t>, MonitorElement*>::const_iterator it = m_SubdetLayerResiduals.begin(),
itEnd = m_SubdetLayerResiduals.end(); it!= itEnd;++it) {
this->resetLayerMEs(it->first);
}
Expand All @@ -84,42 +84,42 @@ void MonitorTrackResiduals::createMEs(const edm::EventSetup& iSetup){
double d_normres_xmin = Parameters.getParameter<double>("xmin");
double d_normres_xmax = Parameters.getParameter<double>("xmax");


// use SistripHistoId for producing histogram id (and title)
SiStripHistoId hidmanager;
folder_organizer.setSiStripFolder(); // top SiStrip folder

// take from eventSetup the SiStripDetCabling object
edm::ESHandle<SiStripDetCabling> tkmechstruct;
iSetup.get<SiStripDetCablingRcd>().get(tkmechstruct);

// get list of active detectors from SiStripDetCabling
std::vector<uint32_t> activeDets;
activeDets.clear(); // just in case
tkmechstruct->addActiveDetectorsRawIds(activeDets);

// use SiStripSubStructure for selecting certain regions
SiStripSubStructure substructure;
std::vector<uint32_t> DetIds = activeDets;

// book histo per each detector module
for (std::vector<uint32_t>::const_iterator DetItr=activeDets.begin(),
for (std::vector<uint32_t>::const_iterator DetItr=activeDets.begin(),
DetItrEnd = activeDets.end(); DetItr!=DetItrEnd; ++DetItr)
{
uint ModuleID = (*DetItr);

// is this a StripModule?
if( SiStripDetId(ModuleID).subDetector() != 0 ) {
folder_organizer.setDetectorFolder(ModuleID, tTopo); // detid sets appropriate detector folder
// Book module histogramms?
if (ModOn) {

folder_organizer.setDetectorFolder(ModuleID, tTopo); // detid sets appropriate detector folder
// Book module histogramms?
if (ModOn) {
std::string hid = hidmanager.createHistoId("HitResiduals","det",ModuleID);
std::string normhid = hidmanager.createHistoId("NormalizedHitResiduals","det",ModuleID);
HitResidual[ModuleID] = dqmStore_->book1D(hid, hid,
std::string normhid = hidmanager.createHistoId("NormalizedHitResiduals","det",ModuleID);
HitResidual[ModuleID] = dqmStore_->book1D(hid, hid,
i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
HitResidual[ModuleID]->setAxisTitle("(x_{pred} - x_{rec})' [cm]");
NormedHitResiduals[ModuleID] = dqmStore_->book1D(normhid, normhid,
NormedHitResiduals[ModuleID] = dqmStore_->book1D(normhid, normhid,
i_normres_Nbins,d_normres_xmin,d_normres_xmax);
NormedHitResiduals[ModuleID]->setAxisTitle("(x_{pred} - x_{rec})'/#sigma");
}
Expand All @@ -128,22 +128,22 @@ void MonitorTrackResiduals::createMEs(const edm::EventSetup& iSetup){
folder_organizer.setLayerFolder(ModuleID,tTopo,subdetandlayer.second);
if(! m_SubdetLayerResiduals[subdetandlayer ] ) {
// book histogramms on layer level, check for barrel for correct labeling
std::string histoname = Form(subdetandlayer.first.find("B") != std::string::npos ?
std::string histoname = Form(subdetandlayer.first.find("B") != std::string::npos ?
"HitResiduals_%s__Layer__%d" : "HitResiduals_%s__wheel__%d" ,
subdetandlayer.first.c_str(),std::abs(subdetandlayer.second));
std::string normhistoname =
Form(subdetandlayer.first.find("B") != std::string::npos ?
std::string normhistoname =
Form(subdetandlayer.first.find("B") != std::string::npos ?
"NormalizedHitResidual_%s__Layer__%d" : "NormalizedHitResidual_%s__wheel__%d" ,
subdetandlayer.first.c_str(),std::abs(subdetandlayer.second));
m_SubdetLayerResiduals[subdetandlayer] =
m_SubdetLayerResiduals[subdetandlayer] =
dqmStore_->book1D(histoname.c_str(),histoname.c_str(),
i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
m_SubdetLayerResiduals[subdetandlayer]->setAxisTitle("(x_{pred} - x_{rec})' [cm]");
m_SubdetLayerNormedResiduals[subdetandlayer] =
m_SubdetLayerNormedResiduals[subdetandlayer] =
dqmStore_->book1D(normhistoname.c_str(),normhistoname.c_str(),
i_normres_Nbins,d_normres_xmin,d_normres_xmax);
m_SubdetLayerNormedResiduals[subdetandlayer]->setAxisTitle("(x_{pred} - x_{rec})'/#sigma");
}
}
} // end 'is strip module'
} // end loop over activeDets
}
Expand Down Expand Up @@ -178,7 +178,7 @@ void MonitorTrackResiduals::endJob(void){

void MonitorTrackResiduals::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {

// Filter out events if Trigger Filtering is requested
// Filter out events if Trigger Filtering is requested
if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;

//Retrieve tracker topology from geometry
Expand All @@ -192,10 +192,10 @@ void MonitorTrackResiduals::analyze(const edm::Event& iEvent, const edm::EventSe
for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator it = v_hitstruct.begin(),
itEnd = v_hitstruct.end(); it != itEnd; ++it) {
uint RawId = it->rawDetId;

// fill if hit belongs to StripDetector and its error is not zero
if( it->resXprimeErr != 0 && SiStripDetId(RawId).subDetector() != 0 ) {
if (ModOn && HitResidual[RawId]) {
if (ModOn && HitResidual[RawId]) {
HitResidual[RawId]->Fill(it->resXprime);
NormedHitResiduals[RawId]->Fill(it->resXprime/it->resXprimeErr);
}
Expand Down
68 changes: 34 additions & 34 deletions DQM/TrackingMonitor/src/LogMessageMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//
// Package: LogMessageMonitor
// Class: LogMessageMonitor
//
//
/**\class LogMessageMonitor LogMessageMonitor.cc DQM/LogMonitor/src/LogMessageMonitor.cc
Description: [one line class summary]
from https://twiki.cern.ch/twiki/bin/view/CMS/TrackingPOGFilters#Filters
Events with (partly) aborted track reconstruction
Events with (partly) aborted track reconstruction
The track reconstruction code is protected against events with too large occupancy which can cause an excessive use of CPU time and memory.
Each iteration of the track reconstruction can be aborted if:
- too many strip and/or pixel clusters are present as input to the seeding step (*TooManyClusters* error).
Expand All @@ -16,9 +16,9 @@
=> All the pairs/triplets found are discarded and the iteration continue (to be checked!)
NB: Despite the thrshold is the same,
similar iterations may have a different rate of errors depending on the CMSSW release,
because the requirement to accept a triplet/pair has been modified (cluster shape filters,...)
because the requirement to accept a triplet/pair has been modified (cluster shape filters,...)
- too many seeds are produced as input to the track building step (*TooManySeeds*).
=> No track is reconstructed from that iteration.
=> No track is reconstructed from that iteration.
# ELSeverityLevel
http://cmssdt.cern.ch/SDT/lxr/source/FWCore/MessageLogger/interface/ELseverityLevel.h?v=CMSSW_5_3_4
Expand Down Expand Up @@ -83,21 +83,21 @@ LogMessageMonitor::LogMessageMonitor(const edm::ParameterSet& iConfig)
, modules_vector_ ( iConfig.getParameter<std::vector<std::string> >("modules") )
, categories_vector_ ( iConfig.getParameter<std::vector<std::string> >("categories") )
, doWarningsPlots_ ( iConfig.getParameter<bool> ("doWarningsPlots") )
, doPUmonitoring_ ( iConfig.getParameter<bool> ("doPUmonitoring") )
, doPUmonitoring_ ( iConfig.getParameter<bool> ("doPUmonitoring") )
{

errorToken_ = consumes<std::vector<edm::ErrorSummaryEntry> >(edm::InputTag("logErrorHarvester") );

edm::ConsumesCollector c{ consumesCollector() };
//now do what ever initialization is needed
lumiDetails_ = new GetLumi( iConfig.getParameter<edm::ParameterSet>("BXlumiSetup"), c );
genTriggerEventFlag_ = new GenericTriggerEventFlag(iConfig);
genTriggerEventFlag_ = new GenericTriggerEventFlag(iConfig, consumesCollector());
}


LogMessageMonitor::~LogMessageMonitor()
{

// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
// if ( lumiDetails_ ) delete lumiDetails_;
Expand All @@ -121,16 +121,16 @@ LogMessageMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
double BXlumi = -1.;
if ( doPUmonitoring_ )
lumiDetails_->getValue(iEvent);

// Take the ErrorSummaryEntry container
edm::Handle<std::vector<edm::ErrorSummaryEntry> > errors;
// iEvent.getByLabel("logErrorHarvester",errors);
iEvent.getByToken(errorToken_,errors);
// Check that errors is valid
if(!errors.isValid()) return;
if(!errors.isValid()) return;
// Compare severity level of error with ELseveritylevel instance el : "-e" should be the lowest error
edm::ELseverityLevel el("-e");

// Find the total number of errors in iEvent
if(errors->size()==0){
if ( doPUmonitoring_ ) {
Expand All @@ -144,8 +144,8 @@ LogMessageMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet

size_t nCategories = categories_vector_.size();

for( size_t i = 0, n = errors->size(); i < n ; i++){
for( size_t i = 0, n = errors->size(); i < n ; i++){

// std::cout << "LogMessageMonitor::analyze] Severity for error/warning: " << (*errors)[i].severity << " " <<(*errors)[i].module << std::endl;
// remove the first part of the module string, what is before ":"
std::string s = (*errors)[i].module;
Expand Down Expand Up @@ -185,11 +185,11 @@ LogMessageMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
CategoriesVsModules->getTH1()->SetBinContent(ibinX,ibinY,ncount);
} else {
int ncount = CategoriesVsModules->getTH1()->GetBinContent(ibinX,nCategories)+1;
CategoriesVsModules->getTH1()->SetBinContent(ibinX,nCategories,ncount);
CategoriesVsModules->getTH1()->SetBinContent(ibinX,nCategories,ncount);
}
} else {
// IF ONLY WARNING, FILL WARNING HISTS
if ( doWarningsPlots_ )
if ( doWarningsPlots_ )
if ( doPUmonitoring_ )
ModulesWarningsVsBXlumi[it->second]->Fill(BXlumi, (*errors)[i].count);
}
Expand All @@ -200,10 +200,10 @@ LogMessageMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet


// ------------ method called once each job just before starting event loop ------------
void
void
LogMessageMonitor::beginJob()
{
std::string MEFolderName = conf_.getParameter<std::string>("LogFolderName");
std::string MEFolderName = conf_.getParameter<std::string>("LogFolderName");

dqmStore_->setCurrentFolder(MEFolderName);

Expand All @@ -220,7 +220,7 @@ LogMessageMonitor::beginJob()
// CategoriesVsModules->getTH1()->GetXaxis()->LabelsOption("v");
for (size_t icategories = 0; icategories < nCategories; icategories++)
CategoriesVsModules->setBinLabel(icategories+1,categories_vector_[icategories],2);

// MAKE MODULEMAP USING INPUT FROM CFG FILE
for (size_t i = 0; i < modules_vector_.size(); i++){
modulesMap.insert( std::pair<std::string,int>(modules_vector_[i],i) );
Expand All @@ -233,34 +233,34 @@ LogMessageMonitor::beginJob()
int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");

size_t i = 0;
for(std::map<std::string,int>::const_iterator it = modulesMap.begin();
it != modulesMap.end(); ++it, i++){
dqmStore_->setCurrentFolder(MEFolderName + "/PUmonitoring/Errors");
it != modulesMap.end(); ++it, i++){

dqmStore_->setCurrentFolder(MEFolderName + "/PUmonitoring/Errors");

histname = "errorsVsBXlumi_" + it->first;
ModulesErrorsVsBXlumi.push_back( dynamic_cast<MonitorElement*>(dqmStore_->bookProfile( histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, 0.,100, "")) );
ModulesErrorsVsBXlumi[i] -> setAxisTitle("BXlumi [10^{30} Hz cm^{-2}]", 1);
ModulesErrorsVsBXlumi[i] -> setAxisTitle("Mean number of errors", 2);

if ( doWarningsPlots_ ) {
dqmStore_->setCurrentFolder(MEFolderName + "/PUmonitoring/Warnings");
dqmStore_->setCurrentFolder(MEFolderName + "/PUmonitoring/Warnings");

histname = "warningVsBXlumi_" + it->first;
ModulesWarningsVsBXlumi.push_back( dynamic_cast<MonitorElement*>(dqmStore_->bookProfile( histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, 0.,100, "")) );
ModulesWarningsVsBXlumi[i] -> setAxisTitle("BXlumi [10^{30} Hz cm^{-2}]", 1);
ModulesWarningsVsBXlumi[i] -> setAxisTitle("Mean number of warnings", 2);
}
}
}
}

}

// ------------ method called once each job just after ending the event loop ------------
void
LogMessageMonitor::endJob()
void
LogMessageMonitor::endJob()
{
bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
Expand All @@ -272,26 +272,26 @@ LogMessageMonitor::endJob()
}

// ------------ method called when starting to processes a run ------------
void
void
LogMessageMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
{
if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
}

// ------------ method called when ending the processing of a run ------------
void
void
LogMessageMonitor::endRun(edm::Run const&, edm::EventSetup const&)
{
}

// ------------ method called when starting to processes a luminosity block ------------
void
void
LogMessageMonitor::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}

// ------------ method called when ending the processing of a luminosity block ------------
void
void
LogMessageMonitor::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
Expand Down
Loading

0 comments on commit fa38838

Please sign in to comment.