SimG4CMS
Calo
plugins
HGCalSensitiveDetectorBuilder.cc
Go to the documentation of this file.
1
2
// system include files
3
#include <string>
4
#include <vector>
5
6
// user include files
7
#include "
SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h
"
8
#include "
SimG4Core/Notification/interface/SimActivityRegistryEnroller.h
"
9
#include "
SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h
"
10
11
#include "
Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
"
12
#include "
Geometry/Records/interface/IdealGeometryRecord.h
"
13
#include "
SimG4CMS/Calo/interface/HGCalSD.h
"
14
15
#include "
FWCore/Framework/interface/ConsumesCollector.h
"
16
#include "
FWCore/Framework/interface/ESHandle.h
"
17
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
18
#include "
FWCore/Utilities/interface/ESGetToken.h
"
19
#include "
FWCore/PluginManager/interface/ModuleDef.h
"
20
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
21
22
class
HGCalSensitiveDetectorBuilder
:
public
SensitiveDetectorMakerBase
{
23
public
:
24
explicit
HGCalSensitiveDetectorBuilder
(
edm::ParameterSet
const
&
p
,
edm::ConsumesCollector
cc
)
25
:
hgcEEToken_
{
cc
.esConsumes<
edm::Transition::BeginRun
>(
edm::ESInputTag
{
""
,
"HGCalEESensitive"
})},
26
hgcHEToken_
{
cc
.esConsumes<
edm::Transition::BeginRun
>(
edm::ESInputTag
{
""
,
"HGCalHESiliconSensitive"
})} {
27
edm::ParameterSet
m_HGC =
p
.getParameter<
edm::ParameterSet
>(
"HGCSD"
);
28
int
num
= m_HGC.
getUntrackedParameter
<
int
>(
"UseDetector"
);
29
doEE_
= ((
num
% 2) == 1);
30
doHE_
= (((
num
/ 2) % 2) == 1);
31
}
32
33
void
beginRun
(
const
edm::EventSetup
& es)
final
{
34
if
(
doEE_
)
35
hgcalEE_
= es.getHandle(
hgcEEToken_
);
36
if
(
doHE_
)
37
hgcalHE_
= es.getHandle(
hgcHEToken_
);
38
}
39
40
std::unique_ptr<SensitiveDetector>
make
(
const
std::string
& iname,
41
const
SensitiveDetectorCatalog
& clg,
42
const
edm::ParameterSet
&
p
,
43
const
SimTrackManager
* man,
44
SimActivityRegistry
& reg)
const
final
{
45
auto
hgc
=
46
(((iname.find(
"HitsEE"
) != std::string::npos) &&
doEE_
&&
hgcalEE_
.
isValid
())
47
?
hgcalEE_
.
product
()
48
: (((iname.find(
"HitsHEfront"
) != std::string::npos) &&
doHE_
&&
hgcalHE_
.
isValid
()) ?
hgcalHE_
.
product
()
49
:
nullptr
));
50
auto
sd
= std::make_unique<HGCalSD>(iname,
hgc
, clg,
p
, man);
51
SimActivityRegistryEnroller::enroll
(reg,
sd
.get());
52
return
sd
;
53
}
54
55
private
:
56
const
edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord>
hgcEEToken_
;
57
const
edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord>
hgcHEToken_
;
58
bool
doEE_
,
doHE_
;
59
edm::ESHandle<HGCalDDDConstants>
hgcalEE_
,
hgcalHE_
;
60
};
61
62
typedef
HGCalSD
HGCalSensitiveDetector
;
63
DEFINE_SENSITIVEDETECTORBUILDER
(
HGCalSensitiveDetectorBuilder
,
HGCalSensitiveDetector
);
HGCalSensitiveDetectorBuilder::hgcHEToken_
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hgcHEToken_
Definition:
HGCalSensitiveDetectorBuilder.cc:57
edm::ESHandle::product
T const * product() const
Definition:
ESHandle.h:86
SimTrackManager
Definition:
SimTrackManager.h:35
HGCalSensitiveDetectorBuilder::hgcEEToken_
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hgcEEToken_
Definition:
HGCalSensitiveDetectorBuilder.cc:56
edm::ESInputTag
Definition:
ESInputTag.h:87
MessageLogger.h
HGCalSensitiveDetectorBuilder::beginRun
void beginRun(const edm::EventSetup &es) final
Definition:
HGCalSensitiveDetectorBuilder.cc:33
ESHandle.h
HGCalSensitiveDetectorBuilder::make
std::unique_ptr< SensitiveDetector > make(const std::string &iname, const SensitiveDetectorCatalog &clg, const edm::ParameterSet &p, const SimTrackManager *man, SimActivityRegistry ®) const final
Definition:
HGCalSensitiveDetectorBuilder.cc:40
HGCalSensitiveDetectorBuilder::doEE_
bool doEE_
Definition:
HGCalSensitiveDetectorBuilder.cc:58
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ESGetToken.h
HGCalSensitiveDetectorBuilder::HGCalSensitiveDetectorBuilder
HGCalSensitiveDetectorBuilder(edm::ParameterSet const &p, edm::ConsumesCollector cc)
Definition:
HGCalSensitiveDetectorBuilder.cc:24
HGCalSD.h
hgc_digi
Definition:
HGCDigitizerTypes.h:10
HGCalSD
Definition:
HGCalSD.h:20
HGCalSensitiveDetectorBuilder
Definition:
HGCalSensitiveDetectorBuilder.cc:22
edm::ESHandle< HGCalDDDConstants >
SensitiveDetectorCatalog
Definition:
SensitiveDetectorCatalog.h:10
edm::ParameterSet
Definition:
ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
HGCalSensitiveDetectorBuilder::hgcalEE_
edm::ESHandle< HGCalDDDConstants > hgcalEE_
Definition:
HGCalSensitiveDetectorBuilder.cc:59
SensitiveDetectorMakerBase
Definition:
SensitiveDetectorMakerBase.h:28
ModuleDef.h
SimActivityRegistryEnroller::enroll
static void enroll(SimActivityRegistry &iReg, T *iObj)
Definition:
SimActivityRegistryEnroller.h:50
IdealGeometryRecord.h
edm::EventSetup
Definition:
EventSetup.h:58
cc
edm::ESHandleBase::isValid
bool isValid() const
Definition:
ESHandle.h:44
edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
EgammaValidation_cff.num
num
Definition:
EgammaValidation_cff.py:33
SimActivityRegistryEnroller.h
SimActivityRegistry
Definition:
SimActivityRegistry.h:39
DEFINE_SENSITIVEDETECTORBUILDER
#define DEFINE_SENSITIVEDETECTORBUILDER(type, name)
Definition:
SensitiveDetectorPluginFactory.h:21
edm::Transition::BeginRun
HGCalSensitiveDetectorBuilder::doHE_
bool doHE_
Definition:
HGCalSensitiveDetectorBuilder.cc:58
HGCalSensitiveDetector
HGCalSD HGCalSensitiveDetector
Definition:
HGCalSensitiveDetectorBuilder.cc:62
HGCalSensitiveDetectorBuilder::hgcalHE_
edm::ESHandle< HGCalDDDConstants > hgcalHE_
Definition:
HGCalSensitiveDetectorBuilder.cc:59
sd
double sd
Definition:
CascadeWrapper.h:113
ConsumesCollector.h
SensitiveDetectorPluginFactory.h
HGCalDDDConstants.h
ParameterSet.h
SensitiveDetectorMakerBase.h
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
Generated for CMSSW Reference Manual by
1.8.16