From 38264be440c32af1bf995c01b48d19c8915272a7 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 13 Jul 2021 15:51:12 +0200 Subject: [PATCH] Update the analyzers and scripts for Cherenkov Analysis --- .../plugins/CherenkovAnalysis.cc | 24 +++++++++++---- .../plugins/XtalDedxAnalysis.cc | 29 ++++++++++++------- .../test/runSingleDREAMDD4Hep_cfg.py | 8 ++--- .../test/runSingleDREAMDDD_cfg.py | 8 ++--- .../CherenkovAnalysis/test/testMuon_cfg.py | 8 ++--- 5 files changed, 44 insertions(+), 33 deletions(-) diff --git a/SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc b/SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc index dae028877c83a..4bb1fbd355e03 100644 --- a/SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc +++ b/SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc @@ -21,7 +21,7 @@ Description: #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -29,6 +29,7 @@ Description: #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/Utilities/interface/InputTag.h" #include "SimDataFormats/CaloHit/interface/PCaloHit.h" @@ -38,16 +39,18 @@ Description: #include "FWCore/ServiceRegistry/interface/Service.h" #include -class CherenkovAnalysis : public edm::EDAnalyzer { +class CherenkovAnalysis : public edm::one::EDAnalyzer { public: explicit CherenkovAnalysis(const edm::ParameterSet &); ~CherenkovAnalysis() override {} + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + private: + const double maxEnergy_; + const int nBinsEnergy_; edm::EDGetTokenT tok_calo_; TH1F *hEnergy_; - double maxEnergy_; - int nBinsEnergy_; TH1F *hTimeStructure_; @@ -59,7 +62,10 @@ class CherenkovAnalysis : public edm::EDAnalyzer { //__________________________________________________________________________________________________ CherenkovAnalysis::CherenkovAnalysis(const edm::ParameterSet &iConfig) : maxEnergy_(iConfig.getParameter("maxEnergy")), - nBinsEnergy_(iConfig.getParameter("nBinsEnergy")) { + nBinsEnergy_(iConfig.getParameter("nBinsEnergy")) { + + usesResource(TFileService::kSharedResource); + tok_calo_ = consumes(iConfig.getParameter("caloHitSource")); // Book histograms @@ -73,6 +79,14 @@ CherenkovAnalysis::CherenkovAnalysis(const edm::ParameterSet &iConfig) hTimeStructure_ = tfile->make("hTimeStructure", "Time structure [ns]", 100, 0, 0.3); } +void CherenkovAnalysis::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("caloHitSource", edm::InputTag("g4SimHits","EcalHitsEB")); + desc.add("maxEnergy", 2.0); + desc.add("nBinsEnergy", 50); + descriptions.add("cherenkovAnalysis", desc); +} + //__________________________________________________________________________________________________ void CherenkovAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { edm::Handle pCaloHits; diff --git a/SimG4CMS/CherenkovAnalysis/plugins/XtalDedxAnalysis.cc b/SimG4CMS/CherenkovAnalysis/plugins/XtalDedxAnalysis.cc index b0eda2565d12d..638d557fb23df 100644 --- a/SimG4CMS/CherenkovAnalysis/plugins/XtalDedxAnalysis.cc +++ b/SimG4CMS/CherenkovAnalysis/plugins/XtalDedxAnalysis.cc @@ -1,20 +1,19 @@ - // system include files #include #include #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Utilities/interface/Exception.h" @@ -32,11 +31,15 @@ #include #include -class XtalDedxAnalysis : public edm::EDAnalyzer { +#define EDM_ML_DEBUG + +class XtalDedxAnalysis : public edm::one::EDAnalyzer { public: explicit XtalDedxAnalysis(const edm::ParameterSet &); ~XtalDedxAnalysis() override {} + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + protected: void beginJob() override {} void analyze(const edm::Event &, const edm::EventSetup &) override; @@ -59,13 +62,11 @@ class XtalDedxAnalysis : public edm::EDAnalyzer { }; XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps) { + usesResource(TFileService::kSharedResource); caloHitSource_ = ps.getParameter("caloHitSource"); - simTkLabel_ = ps.getUntrackedParameter("moduleLabelTk", "g4SimHits"); - double energyMax = ps.getParameter("EnergyMax"); -#ifdef EDM_ML_DEBUG - edm::LogInfo("CherenkovAnalysis") << "XtalDedxAnalysis::Source " << caloHitSource_ << " Track Label " << simTkLabel_ - << " Energy Max " << energyMax; -#endif + simTkLabel_ = ps.getParameter("moduleLabelTk"); + double energyMax = ps.getParameter("energyMax"); + edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Source " << caloHitSource_ << " Track Label " << simTkLabel_ << " Energy Max " << energyMax; // register for data access tok_calo_ = consumes(caloHitSource_); tok_tk_ = consumes(edm::InputTag(simTkLabel_)); @@ -114,6 +115,14 @@ XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps) { mType_->GetYaxis()->SetTitle("Tracks"); } +void XtalDedxAnalysis::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("caloHitSource", edm::InputTag("g4SimHits","EcalHitsEB")); + desc.add("moduleLabelTk", "g4SimHits"); + desc.add("energyMax", 2.0); + descriptions.add("xtalDedxAnalysis", desc); +} + void XtalDedxAnalysis::analyze(const edm::Event &e, const edm::EventSetup &) { #ifdef EDM_ML_DEBUG edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Run = " << e.id().run() << " Event = " << e.id().event(); diff --git a/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py b/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py index 2f2114d465eae..0984d6118dfd5 100644 --- a/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py +++ b/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py @@ -31,13 +31,9 @@ process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 -process.analyzer = cms.EDAnalyzer("CherenkovAnalysis", - maxEnergy = cms.double(2.0), - caloHitSource = cms.InputTag("g4SimHits","EcalHitsEB"), - nBinsEnergy = cms.uint32(50) -) +process.load("SimG4CMS.CherenkovAnalysis.cherenkovAnalysis_cfi") -process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.analyzer) +process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.cherenkovAnalysis) process.DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("SimG4CMS/CherenkovAnalysis/data/SingleDREAMDD4Hep.xml") process.generator.PGunParameters.MinE = 10.0 diff --git a/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDDD_cfg.py b/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDDD_cfg.py index ebd7dd8810e4c..f00be6da65cf4 100644 --- a/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDDD_cfg.py +++ b/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDDD_cfg.py @@ -31,13 +31,9 @@ process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 -process.analyzer = cms.EDAnalyzer("CherenkovAnalysis", - maxEnergy = cms.double(2.0), - caloHitSource = cms.InputTag("g4SimHits","EcalHitsEB"), - nBinsEnergy = cms.uint32(50) -) +process.load("SimG4CMS.CherenkovAnalysis.cherenkovAnalysis_cfi") -process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.analyzer) +process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.cherenkovAnalysis) process.generator.PGunParameters.MinE = 10.0 process.generator.PGunParameters.MaxE = 10.0 diff --git a/SimG4CMS/CherenkovAnalysis/test/testMuon_cfg.py b/SimG4CMS/CherenkovAnalysis/test/testMuon_cfg.py index 5f1341fb02836..3f77a26b73315 100644 --- a/SimG4CMS/CherenkovAnalysis/test/testMuon_cfg.py +++ b/SimG4CMS/CherenkovAnalysis/test/testMuon_cfg.py @@ -60,12 +60,9 @@ process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 -process.analyzer = cms.EDAnalyzer("XtalDedxAnalysis", - caloHitSource = cms.InputTag("g4SimHits","HcalHits"), - EnergyMax = cms.double(200.0) -) +process.load("SimG4CMS.CherenkovAnalysis.xtalDedxAnalysis_cfi") -process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.analyzer) +process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.xtalDedxAnalysis) process.outpath = cms.EndPath(process.o1) process.g4SimHits.UseMagneticField = False process.g4SimHits.Physics.type = 'SimG4Core/Physics/QGSP_FTFP_BERT_EML' @@ -86,4 +83,3 @@ UseBirkLaw = cms.bool(False), BirkSlope = cms.double(0.253694) ) -