Skip to content

Commit

Permalink
Merge pull request #34462 from bsunanda/Run3-sim90
Browse files Browse the repository at this point in the history
Run3-sim90 Update the analyzers and scripts for Cherenkov Analysis
cmsbuild authored Jul 13, 2021

Verified

This commit was signed with the committer’s verified signature.
Exirel Florian Strzelecki
2 parents d3d8f9c + e4a97f8 commit 6974365
Showing 5 changed files with 44 additions and 34 deletions.
24 changes: 18 additions & 6 deletions SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc
Original file line number Diff line number Diff line change
@@ -21,14 +21,15 @@ Description: <one line class summary>
#include <memory>

// 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"

#include "FWCore/Framework/interface/Event.h"
#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: <one line class summary>
#include "FWCore/ServiceRegistry/interface/Service.h"
#include <TH1F.h>

class CherenkovAnalysis : public edm::EDAnalyzer {
class CherenkovAnalysis : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit CherenkovAnalysis(const edm::ParameterSet &);
~CherenkovAnalysis() override {}

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
const double maxEnergy_;
const int nBinsEnergy_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_calo_;
TH1F *hEnergy_;
double maxEnergy_;
int nBinsEnergy_;

TH1F *hTimeStructure_;

@@ -58,8 +61,9 @@ class CherenkovAnalysis : public edm::EDAnalyzer {

//__________________________________________________________________________________________________
CherenkovAnalysis::CherenkovAnalysis(const edm::ParameterSet &iConfig)
: maxEnergy_(iConfig.getParameter<double>("maxEnergy")),
nBinsEnergy_(iConfig.getParameter<unsigned>("nBinsEnergy")) {
: maxEnergy_(iConfig.getParameter<double>("maxEnergy")), nBinsEnergy_(iConfig.getParameter<int>("nBinsEnergy")) {
usesResource(TFileService::kSharedResource);

tok_calo_ = consumes<edm::PCaloHitContainer>(iConfig.getParameter<edm::InputTag>("caloHitSource"));

// Book histograms
@@ -73,6 +77,14 @@ CherenkovAnalysis::CherenkovAnalysis(const edm::ParameterSet &iConfig)
hTimeStructure_ = tfile->make<TH1F>("hTimeStructure", "Time structure [ns]", 100, 0, 0.3);
}

void CherenkovAnalysis::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("caloHitSource", edm::InputTag("g4SimHits", "EcalHitsEB"));
desc.add<double>("maxEnergy", 2.0);
desc.add<int>("nBinsEnergy", 50);
descriptions.add("cherenkovAnalysis", desc);
}

//__________________________________________________________________________________________________
void CherenkovAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
edm::Handle<edm::PCaloHitContainer> pCaloHits;
30 changes: 20 additions & 10 deletions SimG4CMS/CherenkovAnalysis/plugins/XtalDedxAnalysis.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@

// system include files
#include <memory>
#include <string>
#include <vector>

// 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 <TH1F.h>
#include <TH1I.h>

class XtalDedxAnalysis : public edm::EDAnalyzer {
#define EDM_ML_DEBUG

class XtalDedxAnalysis : public edm::one::EDAnalyzer<edm::one::SharedResources> {
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,12 @@ class XtalDedxAnalysis : public edm::EDAnalyzer {
};

XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps) {
usesResource(TFileService::kSharedResource);
caloHitSource_ = ps.getParameter<edm::InputTag>("caloHitSource");
simTkLabel_ = ps.getUntrackedParameter<std::string>("moduleLabelTk", "g4SimHits");
double energyMax = ps.getParameter<double>("EnergyMax");
#ifdef EDM_ML_DEBUG
edm::LogInfo("CherenkovAnalysis") << "XtalDedxAnalysis::Source " << caloHitSource_ << " Track Label " << simTkLabel_
<< " Energy Max " << energyMax;
#endif
simTkLabel_ = ps.getParameter<std::string>("moduleLabelTk");
double energyMax = ps.getParameter<double>("energyMax");
edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Source " << caloHitSource_ << " Track Label "
<< simTkLabel_ << " Energy Max " << energyMax;
// register for data access
tok_calo_ = consumes<edm::PCaloHitContainer>(caloHitSource_);
tok_tk_ = consumes<edm::SimTrackContainer>(edm::InputTag(simTkLabel_));
@@ -114,6 +116,14 @@ XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps) {
mType_->GetYaxis()->SetTitle("Tracks");
}

void XtalDedxAnalysis::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("caloHitSource", edm::InputTag("g4SimHits", "EcalHitsEB"));
desc.add<std::string>("moduleLabelTk", "g4SimHits");
desc.add<double>("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();
8 changes: 2 additions & 6 deletions SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDDD_cfg.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions SimG4CMS/CherenkovAnalysis/test/testMuon_cfg.py
Original file line number Diff line number Diff line change
@@ -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)
)

0 comments on commit 6974365

Please sign in to comment.