Skip to content

Commit

Permalink
Update the analyzers and scripts for Cherenkov Analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Jul 13, 2021
1 parent fbaa8eb commit 38264be
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 33 deletions.
24 changes: 19 additions & 5 deletions SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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_;

Expand All @@ -59,7 +62,10 @@ class CherenkovAnalysis : public edm::EDAnalyzer {
//__________________________________________________________________________________________________
CherenkovAnalysis::CherenkovAnalysis(const edm::ParameterSet &iConfig)
: maxEnergy_(iConfig.getParameter<double>("maxEnergy")),
nBinsEnergy_(iConfig.getParameter<unsigned>("nBinsEnergy")) {
nBinsEnergy_(iConfig.getParameter<int>("nBinsEnergy")) {

usesResource(TFileService::kSharedResource);

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

// Book histograms
Expand All @@ -73,6 +79,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;
Expand Down
29 changes: 19 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"
Expand All @@ -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;
Expand All @@ -59,13 +62,11 @@ 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_));
Expand Down Expand Up @@ -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<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();
Expand Down
8 changes: 2 additions & 6 deletions SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDDD_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions SimG4CMS/CherenkovAnalysis/test/testMuon_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -86,4 +83,3 @@
UseBirkLaw = cms.bool(False),
BirkSlope = cms.double(0.253694)
)

0 comments on commit 38264be

Please sign in to comment.