SimG4CMS
Calo
plugins
HcalSimHitDump.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
2
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
3
4
#include "
FWCore/Framework/interface/Event.h
"
5
#include "
FWCore/Framework/interface/EventSetup.h
"
6
#include "
FWCore/Framework/interface/ESHandle.h
"
7
#include "
FWCore/Framework/interface/MakerMacros.h
"
8
9
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
10
#include "
FWCore/Utilities/interface/InputTag.h
"
11
#include "
FWCore/Utilities/interface/Exception.h
"
12
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
13
14
#include "
DataFormats/HcalDetId/interface/HcalDetId.h
"
15
#include "
DataFormats/HcalDetId/interface/HcalTestNumbering.h
"
16
#include "
SimDataFormats/CaloHit/interface/PCaloHit.h
"
17
#include "
SimDataFormats/CaloHit/interface/PCaloHitContainer.h
"
18
#include "
SimG4CMS/Calo/interface/CaloHitID.h
"
19
#include "
SimDataFormats/TrackingHit/interface/PSimHit.h
"
20
#include "
SimDataFormats/TrackingHit/interface/PSimHitContainer.h
"
21
22
#include "
SimDataFormats/GeneratorProducts/interface/HepMCProduct.h
"
23
24
#include <memory>
25
#include <iostream>
26
#include <fstream>
27
#include <vector>
28
#include <map>
29
#include <string>
30
31
class
HcalSimHitDump
:
public
edm::EDAnalyzer
{
32
public
:
33
HcalSimHitDump
(
const
edm::ParameterSet
& ps);
34
~HcalSimHitDump
()
override
{}
35
36
protected
:
37
void
beginJob
()
override
{}
38
void
endJob
()
override
{}
39
void
analyze
(
const
edm::Event
&
e
,
const
edm::EventSetup
&
c
)
override
;
40
41
void
analyzeHits
(std::vector<PCaloHit>&);
42
43
private
:
44
std::string
g4Label_
,
hitLab_
;
45
edm::EDGetTokenT<edm::PCaloHitContainer>
toks_calo_
;
46
int
nevt_
,
maxEvent_
;
47
};
48
49
HcalSimHitDump::HcalSimHitDump
(
const
edm::ParameterSet
& ps) : nevt_(0) {
50
g4Label_
= ps.
getUntrackedParameter
<
std::string
>(
"ModuleLabel"
,
"g4SimHits"
);
51
hitLab_
= ps.
getUntrackedParameter
<
std::string
>(
"HCCollection"
,
"HcalHits"
);
52
maxEvent_
= ps.
getUntrackedParameter
<
int
>(
"MaxEvent"
, 10);
53
54
// register for data access
55
toks_calo_
= consumes<edm::PCaloHitContainer>(
edm::InputTag
(
g4Label_
,
hitLab_
));
56
57
edm::LogVerbatim
(
"HitStudy"
) <<
"HcalSimHitDump::Module Label: "
<<
g4Label_
<<
" Hits: "
<<
hitLab_
<<
" MaxEvent "
58
<<
maxEvent_
;
59
}
60
61
void
HcalSimHitDump::analyze
(
const
edm::Event
&
e
,
const
edm::EventSetup
&) {
62
++
nevt_
;
63
edm::LogVerbatim
(
"HitStudy"
) <<
"HcalSimHitDump::Serial # "
<<
nevt_
<<
" Run # "
<<
e
.id().run() <<
" Event # "
64
<<
e
.id().event();
65
66
if
(
nevt_
<=
maxEvent_
) {
67
std::vector<PCaloHit> hcHits;
68
edm::Handle<edm::PCaloHitContainer>
hitsCalo;
69
e
.getByToken(
toks_calo_
, hitsCalo);
70
if
(hitsCalo.
isValid
()) {
71
edm::LogVerbatim
(
"HitStudy"
) <<
"HcalValidation: get valid hist for Hcal"
;
72
std::vector<PCaloHit> caloHits;
73
caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
74
edm::LogVerbatim
(
"HitStudy"
) <<
"HcalValidation: Hit buffer "
<< caloHits.size();
75
analyzeHits
(caloHits);
76
}
77
}
78
}
79
80
void
HcalSimHitDump::analyzeHits
(std::vector<PCaloHit>&
hits
) {
81
bool
testN(
false
);
82
for
(
unsigned
int
k
= 1;
k
<
hits
.size(); ++
k
) {
83
int
det = (((
hits
[
k
].id()) >> 28) & 0xF);
84
if
(det != 4) {
85
testN =
true
;
86
break
;
87
}
88
}
89
edm::LogVerbatim
(
"HitStudy"
) <<
"Hit ID uses numbering scheme "
<< testN <<
" (0 normal; 1 test)"
;
90
91
//Now the dump
92
for
(
unsigned
int
i
= 0;
i
<
hits
.size();
i
++) {
93
double
edep =
hits
[
i
].energy();
94
double
time
=
hits
[
i
].time();
95
unsigned
int
id_ =
hits
[
i
].id();
96
if
(testN) {
97
int
det,
z
,
depth
,
eta
,
phi
, lay;
98
HcalTestNumbering::unpackHcalIndex
(id_, det,
z
,
depth
,
eta
,
phi
, lay);
99
std::string
sub(
"HX"
);
100
if
(det == 1)
101
sub =
"HB"
;
102
else
if
(det == 2)
103
sub =
"HE"
;
104
else
if
(det == 3)
105
sub =
"HO"
;
106
else
if
(det == 4)
107
sub =
"HF"
;
108
else
if
(det == 5)
109
sub =
"HT"
;
110
int
side = (
z
== 0) ? (-1) : (1);
111
edm::LogVerbatim
(
"HitStudy"
) <<
"["
<<
i
<<
"] ("
<< sub <<
" "
<< side *
eta
<<
","
<<
phi
<<
","
<<
depth
<<
","
112
<< lay <<
") E "
<< edep <<
" T "
<<
time
;
113
}
else
{
114
edm::LogVerbatim
(
"HitStudy"
) <<
"["
<<
i
<<
"] "
<<
HcalDetId
(id_) <<
" E "
<< edep <<
" T "
<<
time
;
115
}
116
}
117
}
118
119
//define this as a plug-in
120
DEFINE_FWK_MODULE
(
HcalSimHitDump
);
mps_fire.i
i
Definition:
mps_fire.py:428
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition:
hfClusterShapes_cfi.py:5
ESHandle.h
edm::EDGetTokenT< edm::PCaloHitContainer >
PSimHitContainer.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
CaloHitID.h
HcalTestNumbering.h
edm::Handle
Definition:
AssociativeIterator.h:50
HcalSimHitDump::endJob
void endJob() override
Definition:
HcalSimHitDump.cc:38
HcalSimHitDump::toks_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > toks_calo_
Definition:
HcalSimHitDump.cc:45
edm::EDAnalyzer
Definition:
EDAnalyzer.h:28
MakerMacros.h
PSimHit.h
HcalTestNumbering::unpackHcalIndex
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
Definition:
HcalTestNumbering.cc:18
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
HcalSimHitDump::beginJob
void beginJob() override
Definition:
HcalSimHitDump.cc:37
PVValHelper::eta
Definition:
PVValidationHelpers.h:69
DDAxes::z
HcalSimHitDump
Definition:
HcalSimHitDump.cc:31
dqmdumpme.k
k
Definition:
dqmdumpme.py:60
HcalSimHitDump::g4Label_
std::string g4Label_
Definition:
HcalSimHitDump.cc:44
LEDCalibrationChannels.depth
depth
Definition:
LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
HcalDetId.h
PCaloHit.h
HcalSimHitDump::~HcalSimHitDump
~HcalSimHitDump() override
Definition:
HcalSimHitDump.cc:34
HcalDetId
Definition:
HcalDetId.h:12
HcalSimHitDump::HcalSimHitDump
HcalSimHitDump(const edm::ParameterSet &ps)
Definition:
HcalSimHitDump.cc:49
edm::EventSetup
Definition:
EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
InputTag.h
HcalSimHitDump::hitLab_
std::string hitLab_
Definition:
HcalSimHitDump.cc:44
DDAxes::phi
HcalSimHitDump::maxEvent_
int maxEvent_
Definition:
HcalSimHitDump.cc:46
HcalSimHitDump::analyzeHits
void analyzeHits(std::vector< PCaloHit > &)
Definition:
HcalSimHitDump.cc:80
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition:
MessageLogger.h:128
EventSetup.h
Exception.h
PCaloHitContainer.h
ParameterSet.h
HepMCProduct.h
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:70
ntuplemaker.time
time
Definition:
ntuplemaker.py:310
edm::Event
Definition:
Event.h:73
HcalSimHitDump::nevt_
int nevt_
Definition:
HcalSimHitDump.cc:46
edm::InputTag
Definition:
InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
HcalSimHitDump::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition:
HcalSimHitDump.cc:61
Generated for CMSSW Reference Manual by
1.8.16