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/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/Utilities/interface/InputTag.h
"
33
34
#include "
SimDataFormats/CaloHit/interface/PCaloHit.h
"
35
#include "
SimDataFormats/CaloHit/interface/PCaloHitContainer.h
"
36
37
#include "
CommonTools/UtilAlgos/interface/TFileService.h
"
38
#include "
FWCore/ServiceRegistry/interface/Service.h
"
39
#include <TH1F.h>
40
41
#define EDM_ML_DEBUG
42
43
class
CherenkovAnalysis
:
public
edm::EDAnalyzer
{
44
public
:
45
explicit
CherenkovAnalysis
(
const
edm::ParameterSet
&);
46
~CherenkovAnalysis
()
override
{}
47
48
private
:
49
edm::EDGetTokenT<edm::PCaloHitContainer>
tok_calo_
;
50
TH1F *
hEnergy_
;
51
double
maxEnergy_
;
52
int
nBinsEnergy_
;
53
54
TH1F *
hTimeStructure_
;
55
56
void
beginJob
()
override
{}
57
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
58
void
endJob
()
override
{}
59
};
60
61
//__________________________________________________________________________________________________
62
CherenkovAnalysis::CherenkovAnalysis
(
const
edm::ParameterSet
&iConfig)
63
: maxEnergy_(iConfig.getParameter<double>(
"maxEnergy"
)),
64
nBinsEnergy_(iConfig.getParameter<unsigned>(
"nBinsEnergy"
)) {
65
tok_calo_
= consumes<edm::PCaloHitContainer>(iConfig.
getParameter
<
edm::InputTag
>(
"caloHitSource"
));
66
67
// Book histograms
68
edm::Service<TFileService>
tfile
;
69
70
if
(!
tfile
.isAvailable())
71
throw
cms::Exception
(
"BadConfig"
) <<
"TFileService unavailable: "
72
<<
"please add it to config file"
;
73
74
hEnergy_
=
tfile
->make<TH1F>(
"hEnergy"
,
"Total energy deposit [GeV]"
,
nBinsEnergy_
, 0,
maxEnergy_
);
75
hTimeStructure_
=
tfile
->make<TH1F>(
"hTimeStructure"
,
"Time structure [ns]"
, 100, 0, 0.3);
76
}
77
78
//__________________________________________________________________________________________________
79
void
CherenkovAnalysis::analyze
(
const
edm::Event
&
iEvent
,
const
edm::EventSetup
&iSetup) {
80
edm::Handle<edm::PCaloHitContainer>
pCaloHits;
81
iEvent
.getByToken(
tok_calo_
, pCaloHits);
82
83
double
totalEnergy = 0;
84
85
// Loop on all hits and calculate total energy loss
86
edm::PCaloHitContainer::const_iterator it = pCaloHits.
product
()->begin();
87
edm::PCaloHitContainer::const_iterator itend = pCaloHits.
product
()->end();
88
for
(; it != itend; ++it) {
89
totalEnergy += (*it).energy();
90
hTimeStructure_
->Fill((*it).time(),
91
(*it).energy());
// Time weighted by energy...
92
// edm::LogInfo("CherenkovAnalysis") << "Time = " << (*it).time() <<
93
// std::endl;
94
}
95
#ifdef EDM_ML_DEBUG
96
edm::LogVerbatim
(
"CherenkovAnalysis"
) <<
"CherenkovAnalysis::Total energy = "
<< totalEnergy;
97
#endif
98
hEnergy_
->Fill(totalEnergy);
99
}
100
101
DEFINE_FWK_MODULE
(
CherenkovAnalysis
);
MessageLogger.h
CherenkovAnalysis::hTimeStructure_
TH1F * hTimeStructure_
Definition:
CherenkovAnalysis.cc:54
edm::Handle::product
T const * product() const
Definition:
Handle.h:70
CherenkovAnalysis
Definition:
CherenkovAnalysis.cc:43
edm::EDGetTokenT< edm::PCaloHitContainer >
CherenkovAnalysis::~CherenkovAnalysis
~CherenkovAnalysis() override
Definition:
CherenkovAnalysis.cc:46
CherenkovAnalysis::maxEnergy_
double maxEnergy_
Definition:
CherenkovAnalysis.cc:51
EDAnalyzer.h
edm::Handle
Definition:
AssociativeIterator.h:50
edm::EDAnalyzer
Definition:
EDAnalyzer.h:29
CherenkovAnalysis::hEnergy_
TH1F * hEnergy_
Definition:
CherenkovAnalysis.cc:50
MakerMacros.h
CherenkovAnalysis::beginJob
void beginJob() override
Definition:
CherenkovAnalysis.cc:56
CherenkovAnalysis::endJob
void endJob() override
Definition:
CherenkovAnalysis.cc:58
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
Service.h
tfile
Definition:
tfile.py:1
CherenkovAnalysis::CherenkovAnalysis
CherenkovAnalysis(const edm::ParameterSet &)
Definition:
CherenkovAnalysis.cc:62
TFileService.h
edm::ParameterSet
Definition:
ParameterSet.h:36
Event.h
PCaloHit.h
CherenkovAnalysis::nBinsEnergy_
int nBinsEnergy_
Definition:
CherenkovAnalysis.cc:52
edm::Service< TFileService >
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::LogVerbatim
Definition:
MessageLogger.h:297
edm::EventSetup
Definition:
EventSetup.h:57
CherenkovAnalysis::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
CherenkovAnalysis.cc:79
InputTag.h
compare.tfile
tfile
Definition:
compare.py:325
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Frameworkfwd.h
CherenkovAnalysis::tok_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
Definition:
CherenkovAnalysis.cc:49
PCaloHitContainer.h
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