Skip to content

Commit

Permalink
Merge pull request #3777 from deguio/thread_unsafe
Browse files Browse the repository at this point in the history
DQMEDAnalyzers -- move modules to be thread_unsafe::DQMEDAnalyzers
  • Loading branch information
nclopezo committed May 9, 2014
2 parents 43847bc + 5fe6403 commit 250f017
Show file tree
Hide file tree
Showing 22 changed files with 1,324 additions and 1,359 deletions.
2 changes: 1 addition & 1 deletion DQM/PhysicsHWW/interface/HWWAnalyzer.h
Expand Up @@ -38,7 +38,7 @@
#include <DQMServices/Core/interface/DQMEDAnalyzer.h>


class HWWAnalyzer : public DQMEDAnalyzer {
class HWWAnalyzer : public thread_unsafe::DQMEDAnalyzer {

public:

Expand Down
Expand Up @@ -222,7 +222,7 @@ namespace HLTOfflineDQMTopSingleLepton {
/// define MonitorSingleLepton to be used
//using HLTOfflineDQMTopSingleLepton::MonitorSingleLepton;

class TopSingleLeptonHLTOfflineDQM : public DQMEDAnalyzer {
class TopSingleLeptonHLTOfflineDQM : public thread_unsafe::DQMEDAnalyzer {
public:
/// default constructor
TopSingleLeptonHLTOfflineDQM(const edm::ParameterSet& cfg);
Expand Down
19 changes: 11 additions & 8 deletions Validation/MuonIdentification/interface/MuonIdVal.h
Expand Up @@ -38,9 +38,6 @@
#include "DataFormats/MuonReco/interface/MuonCosmicCompatibility.h"
#include "DataFormats/MuonReco/interface/MuonShower.h"

#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"

#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
Expand All @@ -53,22 +50,27 @@
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"


class MuonIdVal : public edm::EDAnalyzer {
//class MuonIdVal : public edm::EDAnalyzer {
class MuonIdVal : public thread_unsafe::DQMEDAnalyzer {
public:
explicit MuonIdVal(const edm::ParameterSet&);
~MuonIdVal();

private:
virtual void beginJob();
virtual void beginRun(const edm::Run&, const edm::EventSetup& );
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob();
virtual void Fill(MonitorElement*, float);

DQMStore* dbe_;

edm::ParameterSet iConfig;
edm::ParameterSet parameters_;
std::string eventInfoFolder_;
std::string subsystemname_;

// ----------member data ---------------------------
edm::InputTag inputMuonCollection_;
edm::InputTag inputDTRecSegment4DCollection_;
Expand Down Expand Up @@ -96,6 +98,7 @@ class MuonIdVal : public edm::EDAnalyzer {
bool makeShowerInformationPlots_;
std::string baseFolder_;


edm::Handle<reco::MuonCollection> muonCollectionH_;
edm::Handle<DTRecSegment4DCollection> dtSegmentCollectionH_;
edm::Handle<CSCSegmentCollection> cscSegmentCollectionH_;
Expand Down
213 changes: 106 additions & 107 deletions Validation/MuonIdentification/src/MuonIdVal.cc

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions Validation/MuonIsolation/interface/MuIsoValidation.h
Expand Up @@ -31,7 +31,6 @@

//Member types
#include "FWCore/Utilities/interface/InputTag.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

Expand All @@ -41,6 +40,8 @@
#include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"

//----------------------------------------

//Forward declarations
Expand All @@ -53,7 +54,9 @@ class TProfile;
//------------------------------------------
// Class Declaration: MuIsoValidation
//--------------------------------------
class MuIsoValidation : public edm::EDAnalyzer {
//class MuIsoValidation : public edm::EDAnalyzer {

class MuIsoValidation : public thread_unsafe::DQMEDAnalyzer {
//---------namespace and typedefs--------------
typedef edm::View<reco::Muon>::const_iterator MuonIterator;
typedef edm::RefToBase<reco::Muon> MuonBaseRef;
Expand All @@ -68,12 +71,11 @@ class MuIsoValidation : public edm::EDAnalyzer {

private:
//---------methods----------------------------
virtual void beginJob() ;
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob() ;
void InitStatics();
void RecordData(MuonIterator muon);//Fills Histograms with info from single muon
void InitHistos();//adds title, bin information to member histograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;

void MakeLogBinsForProfile(Double_t* bin_edges, const double min, const double max);
void FillHistos();//Fills histograms with data
void NormalizeHistos(); //Normalize to number of muons
Expand All @@ -98,6 +100,8 @@ class MuIsoValidation : public edm::EDAnalyzer {
std::string dirName;
std::string subDirName;

std::string subsystemname_;

//Histogram parameters
static const int NUM_VARS = 21;
double L_BIN_WIDTH;//large bins
Expand All @@ -122,7 +126,8 @@ class MuIsoValidation : public edm::EDAnalyzer {

//MonitorElement
DQMStore* dbe;


edm::ParameterSet iConfig;
//The Data
int theMuonData;//[number of muons]
double theData[NUM_VARS];
Expand Down
4 changes: 2 additions & 2 deletions Validation/MuonIsolation/python/MuIsoVal_cff.py
Expand Up @@ -14,7 +14,7 @@
hcalIsoDeposit_Label = cms.untracked.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
tkIsoDeposit_Label = cms.untracked.InputTag("muIsoDepositTk"),
hoIsoDeposit_Label = cms.untracked.InputTag("muIsoDepositCalByAssociatorTowers","ho"),
directory = cms.string("Muons/MuonIsolationV_inc")
directory = cms.untracked.string("Muons/MuonIsolationV_inc")
)

MuIsoValidation_global = cms.EDAnalyzer("MuIsoValidation",
Expand All @@ -25,7 +25,7 @@
hcalIsoDeposit_Label = cms.untracked.InputTag("muIsoDepositCalByAssociatorTowers","hcal"),
tkIsoDeposit_Label = cms.untracked.InputTag("muIsoDepositTk"),
hoIsoDeposit_Label = cms.untracked.InputTag("muIsoDepositCalByAssociatorTowers","ho"),
directory = cms.string("Muons/MuonIsolationV_global")
directory = cms.untracked.string("Muons/MuonIsolationV_global")
)

muIsoVal_seq = cms.Sequence(MuIsoValidation_inc+MuIsoValidation_global)
80 changes: 13 additions & 67 deletions Validation/MuonIsolation/src/MuIsoValidation.cc
Expand Up @@ -60,15 +60,16 @@ using std::string;
//
//-----------------Constructors---------------------
//
MuIsoValidation::MuIsoValidation(const edm::ParameterSet& iConfig)
MuIsoValidation::MuIsoValidation(const edm::ParameterSet& ps)
{
iConfig=ps;

// rootfilename = iConfig.getUntrackedParameter<string>("rootfilename"); // comment out for inclusion
requireCombinedMuon = iConfig.getUntrackedParameter<bool>("requireCombinedMuon");
dirName = iConfig.getParameter<std::string>("directory");
// subDirName = iConfig.getParameter<std::string>("@module_label");
dirName = iConfig.getUntrackedParameter<std::string>("directory");
//subDirName = iConfig.getParameter<std::string>("@module_label");

// dirName += subDirName;
//dirName += subDirName;

//--------Initialize tags-------
Muon_Tag = iConfig.getUntrackedParameter<edm::InputTag>("Global_Muon_Label");
Expand All @@ -84,25 +85,13 @@ MuIsoValidation::MuIsoValidation(const edm::ParameterSet& iConfig)
//Set up DAQ
dbe = 0;
dbe = edm::Service<DQMStore>().operator->();
subsystemname_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder", "YourSubsystem") ;

//------"allocate" space for the data vectors-------

/*
h_1D is a 2D vector with indices [var][muon#]
cd_plots is a 2D vector with indices [var][muon#]
h_2D is a 3D vector with indices [var][var][muon#]
p_2D is a 3D vector with indices [var][var][muon#]
*/
//NOTE:the total number of muons and events is initially unknown,
// so that dimension is not initialized. Hence, theMuonData
// needs no resizing.

h_1D.resize (NUM_VARS);
cd_plots.resize(NUM_VARS);
// h_2D.resize(NUM_VARS, vector<MonitorElement*> (NUM_VARS));
p_2D.resize(NUM_VARS, vector<MonitorElement*>(NUM_VARS));

dbe->cd();
}

//
Expand Down Expand Up @@ -308,18 +297,14 @@ void MuIsoValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& i

//Fill historgams concerning muon isolation
uint iMuon=0;
dbe->setCurrentFolder(dirName.c_str());
for (MuonIterator muon = muonsHandle->begin(); muon != muonsHandle->end(); ++muon, ++iMuon ) {
++nIncMuons;
if (requireCombinedMuon) {
if (muon->combinedMuon().isNull()) continue;
}
// ++nCombinedMuons;
RecordData(muon);
FillHistos();
}
dbe->cd();

}

//---------------Record data for a signle muon's data---------------------
Expand Down Expand Up @@ -366,58 +351,19 @@ void MuIsoValidation::RecordData(MuonIterator muon){

}

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

edm::LogInfo("Tutorial") << "\n#########################################\n\n"
<< "Lets get started! "
<< "\n\n#########################################\n";
dbe->setCurrentFolder(dirName.c_str());
InitHistos();
dbe->cd();

}

// ------------ method called once each job just after ending the event loop ------------
void
MuIsoValidation::endJob() {

// check if ME still there (and not killed by MEtoEDM for memory saving)
if( dbe )
{
// check existence of first histo in the list
if (! dbe->get(dirName+"/nMuons")) return;
}
else
return;
void MuIsoValidation::bookHistograms(DQMStore::IBooker & ibooker,edm::Run const & iRun,edm::EventSetup const &){

edm::LogInfo("Tutorial") << "\n#########################################\n\n"
<< "Total Number of Events: " << nEvents
<< "\nTotal Number of Muons: " << nIncMuons
<< "\n\n#########################################\n"
<< "\nInitializing Histograms...\n";

edm::LogInfo("Tutorial") << "\nIntializing Finished. Filling...\n";
NormalizeHistos();
edm::LogInfo("Tutorial") << "\nFilled. Saving...\n";
// dbe->save(rootfilename); // comment out for incorporation
edm::LogInfo("Tutorial") << "\nSaved. Peace, homie, I'm out.\n";

}

void MuIsoValidation::InitHistos(){

ibooker.setCurrentFolder(dirName.c_str());
//---initialize number of muons histogram---
h_nMuons = dbe->book1D("nMuons", title_sam + "Number of Muons", 20, 0., 20.);
h_nMuons = ibooker.book1D("nMuons", title_sam + "Number of Muons", 20, 0., 20.);
h_nMuons->setAxisTitle("Number of Muons",XAXIS);
h_nMuons->setAxisTitle("Fraction of Events",YAXIS);


//---Initialize 1D Histograms---
for(int var = 0; var < NUM_VARS; var++){
h_1D[var] = dbe->book1D(
h_1D[var] = ibooker.book1D(
names[var],
title_sam + main_titles[var] + title_cone,
(int)param[var][0],
Expand All @@ -429,7 +375,7 @@ void MuIsoValidation::InitHistos(){
GetTH1FromMonitorElement(h_1D[var])->Sumw2();

if (cdCompNeeded[var]) {
cd_plots[var] = dbe->book1D(
cd_plots[var] = ibooker.book1D(
names[var] + "_cd",
title_sam + title_cd + main_titles[var] + title_cone,
(int)param[var][0],
Expand All @@ -447,7 +393,7 @@ void MuIsoValidation::InitHistos(){
for(int var2 = 0; var2 < NUM_VARS; var2++){
if(var1 == var2) continue;

/* h_2D[var1][var2] = dbe->book2D(
/* h_2D[var1][var2] = ibooker.book2D(
names[var1] + "_" + names[var2] + "_s",
//title is in "y-var vs. x-var" format
title_sam + main_titles[var2] + " <vs> " + main_titles[var1] + title_cone,
Expand All @@ -461,7 +407,7 @@ void MuIsoValidation::InitHistos(){
*/
//Monitor elements is weird and takes y axis parameters as well
//as x axis parameters for a 1D profile plot
p_2D[var1][var2] = dbe->bookProfile(
p_2D[var1][var2] = ibooker.bookProfile(
names[var1] + "_" + names[var2],
title_sam + main_titles[var2] + " <vs> " + main_titles[var1] + title_cone,
(int)param[var1][0],
Expand Down

0 comments on commit 250f017

Please sign in to comment.