Skip to content

Commit

Permalink
Merge pull request #37003 from bsunanda/Run3-sim109C
Browse files Browse the repository at this point in the history
Run3-sim109C Clean the analyzers in SimG4CMS/CherenkovAnalysis/plugins
  • Loading branch information
cmsbuild committed Feb 22, 2022
2 parents e223798 + 3285560 commit 85971d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
11 changes: 5 additions & 6 deletions SimG4CMS/CherenkovAnalysis/plugins/CherenkovAnalysis.cc
Expand Up @@ -51,7 +51,7 @@ class CherenkovAnalysis : public edm::one::EDAnalyzer<edm::one::SharedResources>
private:
const double maxEnergy_;
const int nBinsEnergy_;
edm::EDGetTokenT<edm::PCaloHitContainer> tok_calo_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_calo_;
TH1F *hEnergy_;

TH1F *hTimeStructure_;
Expand All @@ -63,11 +63,11 @@ class CherenkovAnalysis : public edm::one::EDAnalyzer<edm::one::SharedResources>

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

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

// Book histograms
edm::Service<TFileService> tfile;

Expand All @@ -89,8 +89,7 @@ void CherenkovAnalysis::fillDescriptions(edm::ConfigurationDescriptions &descrip

//__________________________________________________________________________________________________
void CherenkovAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
edm::Handle<edm::PCaloHitContainer> pCaloHits;
iEvent.getByToken(tok_calo_, pCaloHits);
const edm::Handle<edm::PCaloHitContainer> &pCaloHits = iEvent.getHandle(tok_calo_);

double totalEnergy = 0;

Expand Down
57 changes: 25 additions & 32 deletions SimG4CMS/CherenkovAnalysis/plugins/XtalDedxAnalysis.cc
Expand Up @@ -46,32 +46,31 @@ class XtalDedxAnalysis : public edm::one::EDAnalyzer<edm::one::SharedResources>
void endJob() override {}

void analyzeHits(std::vector<PCaloHit> &,
edm::Handle<edm::SimTrackContainer> &,
edm::Handle<edm::SimVertexContainer> &);
const edm::Handle<edm::SimTrackContainer> &,
const edm::Handle<edm::SimVertexContainer> &);

private:
edm::InputTag caloHitSource_;
std::string simTkLabel_;

edm::EDGetTokenT<edm::PCaloHitContainer> tok_calo_;
edm::EDGetTokenT<edm::SimTrackContainer> tok_tk_;
edm::EDGetTokenT<edm::SimVertexContainer> tok_vtx_;
const edm::InputTag caloHitSource_;
const std::string simTkLabel_;
const double energyMax_;
const edm::EDGetTokenT<edm::PCaloHitContainer> tok_calo_;
const edm::EDGetTokenT<edm::SimTrackContainer> tok_tk_;
const edm::EDGetTokenT<edm::SimVertexContainer> tok_vtx_;

TH1F *meNHit_[4], *meE1T0_[4], *meE9T0_[4], *meE1T1_[4], *meE9T1_[4];
TH1I *mType_;
};

XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps) {
XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps)
: caloHitSource_(ps.getParameter<edm::InputTag>("caloHitSource")),
simTkLabel_(ps.getParameter<std::string>("moduleLabelTk")),
energyMax_(ps.getParameter<double>("energyMax")),
tok_calo_(consumes<edm::PCaloHitContainer>(caloHitSource_)),
tok_tk_(consumes<edm::SimTrackContainer>(edm::InputTag(simTkLabel_))),
tok_vtx_(consumes<edm::SimVertexContainer>(edm::InputTag(simTkLabel_))) {
usesResource(TFileService::kSharedResource);
caloHitSource_ = ps.getParameter<edm::InputTag>("caloHitSource");
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_));
tok_vtx_ = consumes<edm::SimVertexContainer>(edm::InputTag(simTkLabel_));
<< simTkLabel_ << " Energy Max " << energyMax_;

// Book histograms
edm::Service<TFileService> tfile;
Expand All @@ -90,22 +89,22 @@ XtalDedxAnalysis::XtalDedxAnalysis(const edm::ParameterSet &ps) {
meNHit_[i]->GetYaxis()->SetTitle("Events");
sprintf(name, "E1T0%d", i);
sprintf(title, "E1 (Loss %s) in GeV", types[i].c_str());
meE1T0_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax);
meE1T0_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
meE1T0_[i]->GetXaxis()->SetTitle(title);
meE1T0_[i]->GetYaxis()->SetTitle("Events");
sprintf(name, "E9T0%d", i);
sprintf(title, "E9 (Loss %s) in GeV", types[i].c_str());
meE9T0_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax);
meE9T0_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
meE9T0_[i]->GetXaxis()->SetTitle(title);
meE9T0_[i]->GetYaxis()->SetTitle("Events");
sprintf(name, "E1T1%d", i);
sprintf(title, "E1 (Loss %s with t < 400 ns) in GeV", types[i].c_str());
meE1T1_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax);
meE1T1_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
meE1T1_[i]->GetXaxis()->SetTitle(title);
meE1T1_[i]->GetYaxis()->SetTitle("Events");
sprintf(name, "E9T1%d", i);
sprintf(title, "E9 (Loss %s with t < 400 ns) in GeV", types[i].c_str());
meE9T1_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax);
meE9T1_[i] = tfile->make<TH1F>(name, title, 5000, 0, energyMax_);
meE9T1_[i]->GetXaxis()->SetTitle(title);
meE9T1_[i]->GetYaxis()->SetTitle("Events");
}
Expand All @@ -129,16 +128,10 @@ void XtalDedxAnalysis::analyze(const edm::Event &e, const edm::EventSetup &) {
edm::LogVerbatim("CherenkovAnalysis") << "XtalDedxAnalysis::Run = " << e.id().run() << " Event = " << e.id().event();
#endif
std::vector<PCaloHit> caloHits;
edm::Handle<edm::PCaloHitContainer> pCaloHits;
e.getByToken(tok_calo_, pCaloHits);

std::vector<SimTrack> theSimTracks;
edm::Handle<edm::SimTrackContainer> simTk;
e.getByToken(tok_tk_, simTk);
const edm::Handle<edm::PCaloHitContainer> &pCaloHits = e.getHandle(tok_calo_);

std::vector<SimVertex> theSimVertex;
edm::Handle<edm::SimVertexContainer> simVtx;
e.getByToken(tok_vtx_, simVtx);
const edm::Handle<edm::SimTrackContainer> &simTk = e.getHandle(tok_tk_);
const edm::Handle<edm::SimVertexContainer> &simVtx = e.getHandle(tok_vtx_);

if (pCaloHits.isValid()) {
caloHits.insert(caloHits.end(), pCaloHits->begin(), pCaloHits->end());
Expand All @@ -150,8 +143,8 @@ void XtalDedxAnalysis::analyze(const edm::Event &e, const edm::EventSetup &) {
}

void XtalDedxAnalysis::analyzeHits(std::vector<PCaloHit> &hits,
edm::Handle<edm::SimTrackContainer> &SimTk,
edm::Handle<edm::SimVertexContainer> &SimVtx) {
const edm::Handle<edm::SimTrackContainer> &SimTk,
const edm::Handle<edm::SimVertexContainer> &SimVtx) {
edm::SimTrackContainer::const_iterator simTrkItr;
int nHit = hits.size();
double e10[4], e90[4], e11[4], e91[4], hit[4];
Expand Down

0 comments on commit 85971d6

Please sign in to comment.