SimG4CMS
CherenkovAnalysis
plugins
CherenkovAnalysis.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: CherenkovAnalysis
4
// Class: CherenkovAnalysis
5
//
14
//
15
// Original Author: Frederic Ronga
16
// Created: Wed Mar 12 17:39:55 CET 2008
17
//
18
//
19
20
// system include files
21
#include <memory>
22
23
// user include files
24
#include "
FWCore/Framework/interface/one/EDAnalyzer.h
"
25
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
26
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
27
28
#include "
FWCore/Framework/interface/Event.h
"
29
#include "
FWCore/Framework/interface/MakerMacros.h
"
30
31
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
32
#include "
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
"
33
#include "
FWCore/Utilities/interface/InputTag.h
"
34
35
#include "
SimDataFormats/CaloHit/interface/PCaloHit.h
"
36
#include "
SimDataFormats/CaloHit/interface/PCaloHitContainer.h
"
37
38
#include "
CommonTools/UtilAlgos/interface/TFileService.h
"
39
#include "
FWCore/ServiceRegistry/interface/Service.h
"
40
#include <TH1F.h>
41
42
//#define EDM_ML_DEBUG
43
44
class
CherenkovAnalysis
:
public
edm::one::EDAnalyzer
<edm::one::SharedResources> {
45
public
:
46
explicit
CherenkovAnalysis
(
const
edm::ParameterSet
&);
47
~CherenkovAnalysis
()
override
{}
48
49
static
void
fillDescriptions
(
edm::ConfigurationDescriptions
&descriptions);
50
51
private
:
52
const
double
maxEnergy_
;
53
const
int
nBinsEnergy_
;
54
edm::EDGetTokenT<edm::PCaloHitContainer>
tok_calo_
;
55
TH1F *
hEnergy_
;
56
57
TH1F *
hTimeStructure_
;
58
59
void
beginJob
()
override
{}
60
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
61
void
endJob
()
override
{}
62
};
63
64
//__________________________________________________________________________________________________
65
CherenkovAnalysis::CherenkovAnalysis
(
const
edm::ParameterSet
&iConfig)
66
: maxEnergy_(iConfig.getParameter<double>(
"maxEnergy"
)), nBinsEnergy_(iConfig.getParameter<
int
>(
"nBinsEnergy"
)) {
67
usesResource(
TFileService::kSharedResource
);
68
69
tok_calo_
= consumes<edm::PCaloHitContainer>(iConfig.
getParameter
<
edm::InputTag
>(
"caloHitSource"
));
70
71
// Book histograms
72
edm::Service<TFileService>
tfile
;
73
74
if
(!
tfile
.isAvailable())
75
throw
cms::Exception
(
"BadConfig"
) <<
"TFileService unavailable: "
76
<<
"please add it to config file"
;
77
78
hEnergy_
=
tfile
->make<TH1F>(
"hEnergy"
,
"Total energy deposit [GeV]"
,
nBinsEnergy_
, 0,
maxEnergy_
);
79
hTimeStructure_
=
tfile
->make<TH1F>(
"hTimeStructure"
,
"Time structure [ns]"
, 100, 0, 0.3);
80
}
81
82
void
CherenkovAnalysis::fillDescriptions
(
edm::ConfigurationDescriptions
&descriptions) {
83
edm::ParameterSetDescription
desc
;
84
desc
.add<
edm::InputTag
>(
"caloHitSource"
,
edm::InputTag
(
"g4SimHits"
,
"EcalHitsEB"
));
85
desc
.add<
double
>(
"maxEnergy"
, 2.0);
86
desc
.add<
int
>(
"nBinsEnergy"
, 50);
87
descriptions.
add
(
"cherenkovAnalysis"
,
desc
);
88
}
89
90
//__________________________________________________________________________________________________
91
void
CherenkovAnalysis::analyze
(
const
edm::Event
&
iEvent
,
const
edm::EventSetup
&iSetup) {
92
edm::Handle<edm::PCaloHitContainer>
pCaloHits;
93
iEvent
.getByToken(
tok_calo_
, pCaloHits);
94
95
double
totalEnergy = 0;
96
97
// Loop on all hits and calculate total energy loss
98
edm::PCaloHitContainer::const_iterator it = pCaloHits.
product
()->begin();
99
edm::PCaloHitContainer::const_iterator itend = pCaloHits.
product
()->end();
100
for
(; it != itend; ++it) {
101
totalEnergy += (*it).energy();
102
hTimeStructure_
->Fill((*it).time(),
103
(*it).energy());
// Time weighted by energy...
104
// edm::LogInfo("CherenkovAnalysis") << "Time = " << (*it).time() <<
105
// std::endl;
106
}
107
#ifdef EDM_ML_DEBUG
108
edm::LogVerbatim
(
"CherenkovAnalysis"
) <<
"CherenkovAnalysis::Total energy = "
<< totalEnergy;
109
#endif
110
hEnergy_
->Fill(totalEnergy);
111
}
112
113
DEFINE_FWK_MODULE
(
CherenkovAnalysis
);
ConfigurationDescriptions.h
EDAnalyzer.h
MessageLogger.h
CherenkovAnalysis::hTimeStructure_
TH1F * hTimeStructure_
Definition:
CherenkovAnalysis.cc:57
edm::Handle::product
T const * product() const
Definition:
Handle.h:70
CherenkovAnalysis
Definition:
CherenkovAnalysis.cc:44
edm::EDGetTokenT< edm::PCaloHitContainer >
CherenkovAnalysis::~CherenkovAnalysis
~CherenkovAnalysis() override
Definition:
CherenkovAnalysis.cc:47
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
edm::one::EDAnalyzer
Definition:
EDAnalyzer.h:30
edm::Handle
Definition:
AssociativeIterator.h:50
CherenkovAnalysis::hEnergy_
TH1F * hEnergy_
Definition:
CherenkovAnalysis.cc:55
MakerMacros.h
CherenkovAnalysis::beginJob
void beginJob() override
Definition:
CherenkovAnalysis.cc:59
CherenkovAnalysis::endJob
void endJob() override
Definition:
CherenkovAnalysis.cc:61
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:57
Service.h
tfile
Definition:
tfile.py:1
CherenkovAnalysis::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition:
CherenkovAnalysis.cc:82
CherenkovAnalysis::CherenkovAnalysis
CherenkovAnalysis(const edm::ParameterSet &)
Definition:
CherenkovAnalysis.cc:65
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
TFileService.h
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
PCaloHit.h
edm::Service< TFileService >
createfilelist.int
int
Definition:
createfilelist.py:10
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:58
CherenkovAnalysis::maxEnergy_
const double maxEnergy_
Definition:
CherenkovAnalysis.cc:52
CherenkovAnalysis::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
CherenkovAnalysis.cc:91
InputTag.h
compare.tfile
tfile
Definition:
compare.py:324
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition:
MessageLogger.h:128
CherenkovAnalysis::tok_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
Definition:
CherenkovAnalysis.cc:54
TFileService::kSharedResource
static const std::string kSharedResource
Definition:
TFileService.h:76
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
PCaloHitContainer.h
CherenkovAnalysis::nBinsEnergy_
const int nBinsEnergy_
Definition:
CherenkovAnalysis.cc:53
cms::Exception
Definition:
Exception.h:70
ParameterSet.h
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
Generated for CMSSW Reference Manual by
1.8.16