SimG4CMS
Muon
plugins
MuonSensitiveDetectorBuilder.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: SimG4CMS/Muon
4
// Class : MuonSensitiveDetectorBuilder
5
//
6
// Implementation:
7
// [Notes on implementation]
8
//
9
// Original Author: Christopher Jones
10
// Created: Fri, 04 Jun 2021 18:18:17 GMT
11
//
12
13
// system include files
14
15
// user include files
16
#include "
SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h
"
17
#include "
SimG4Core/Notification/interface/SimActivityRegistryEnroller.h
"
18
#include "
SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h
"
19
20
#include "
Geometry/MuonNumbering/interface/MuonGeometryConstants.h
"
21
#include "
Geometry/Records/interface/IdealGeometryRecord.h
"
22
23
#include "
SimG4CMS/Muon/interface/MuonSensitiveDetector.h
"
24
25
#include "
FWCore/Framework/interface/ESHandle.h
"
26
#include "
FWCore/Framework/interface/EventSetup.h
"
27
#include "
FWCore/Framework/interface/ConsumesCollector.h
"
28
#include "
FWCore/Utilities/interface/ESGetToken.h
"
29
#include "
FWCore/PluginManager/interface/ModuleDef.h
"
30
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
31
32
class
MuonSensitiveDetectorBuilder
:
public
SensitiveDetectorMakerBase
{
33
public
:
34
explicit
MuonSensitiveDetectorBuilder
(
edm::ParameterSet
const
&
p
,
edm::ConsumesCollector
cc
)
35
:
offmap_
{
nullptr
},
36
mdc_
{
nullptr
},
37
offsetToken_
{
cc
.esConsumes<
edm::Transition::BeginRun
>()},
38
geomConstantsToken_
{
cc
.esConsumes<
edm::Transition::BeginRun
>()} {
39
edm::ParameterSet
muonSD =
p
.getParameter<
edm::ParameterSet
>(
"MuonSD"
);
40
ePersistentCutGeV_
= muonSD.
getParameter
<
double
>(
"EnergyThresholdForPersistency"
) /
CLHEP::GeV
;
//Default 1. GeV
41
allMuonsPersistent_
= muonSD.
getParameter
<
bool
>(
"AllMuonsPersistent"
);
42
printHits_
= muonSD.
getParameter
<
bool
>(
"PrintHits"
);
43
dd4hep_
=
p
.getParameter<
bool
>(
"g4GeometryDD4hepSource"
);
44
}
45
46
void
beginRun
(
const
edm::EventSetup
& es)
final
{
47
edm::ESHandle<MuonOffsetMap>
mom = es.getHandle(
offsetToken_
);
48
offmap_
= (mom.
isValid
()) ? mom.
product
() :
nullptr
;
49
edm::LogVerbatim
(
"MuonSim"
) <<
"Finds the offset map at "
<<
offmap_
;
50
mdc_
= &es.getData(
geomConstantsToken_
);
51
}
52
53
std::unique_ptr<SensitiveDetector>
make
(
const
std::string
& iname,
54
const
SensitiveDetectorCatalog
& clg,
55
const
edm::ParameterSet
&
p
,
56
const
SimTrackManager
* man,
57
SimActivityRegistry
& reg)
const
final
{
58
auto
sd
= std::make_unique<MuonSensitiveDetector>(
59
iname,
offmap_
, *
mdc_
, clg,
ePersistentCutGeV_
,
allMuonsPersistent_
,
printHits_
,
dd4hep_
, man);
60
SimActivityRegistryEnroller::enroll
(reg,
sd
.get());
61
return
sd
;
62
}
63
64
private
:
65
const
MuonOffsetMap
*
offmap_
;
66
const
MuonGeometryConstants
*
mdc_
;
67
const
edm::ESGetToken<MuonOffsetMap, IdealGeometryRecord>
offsetToken_
;
68
const
edm::ESGetToken<MuonGeometryConstants, IdealGeometryRecord>
geomConstantsToken_
;
69
double
ePersistentCutGeV_
;
70
bool
allMuonsPersistent_
;
71
bool
printHits_
;
72
bool
dd4hep_
;
73
};
74
75
DEFINE_SENSITIVEDETECTORBUILDER
(
MuonSensitiveDetectorBuilder
,
MuonSensitiveDetector
);
edm::ESHandle::product
T const * product() const
Definition:
ESHandle.h:86
MuonGeometryConstants
Definition:
MuonGeometryConstants.h:20
SimTrackManager
Definition:
SimTrackManager.h:35
MuonSensitiveDetectorBuilder::beginRun
void beginRun(const edm::EventSetup &es) final
Definition:
MuonSensitiveDetectorBuilder.cc:46
MuonSensitiveDetectorBuilder::printHits_
bool printHits_
Definition:
MuonSensitiveDetectorBuilder.cc:71
ESHandle.h
MuonSensitiveDetectorBuilder::ePersistentCutGeV_
double ePersistentCutGeV_
Definition:
MuonSensitiveDetectorBuilder.cc:69
MuonGeometryConstants.h
MuonSensitiveDetectorBuilder::allMuonsPersistent_
bool allMuonsPersistent_
Definition:
MuonSensitiveDetectorBuilder.cc:70
ESGetToken.h
MuonOffsetMap
Definition:
MuonOffsetMap.h:9
MuonSensitiveDetector
Definition:
MuonSensitiveDetector.h:38
MuonSensitiveDetectorBuilder
Definition:
MuonSensitiveDetectorBuilder.cc:32
MuonSensitiveDetectorBuilder::offmap_
const MuonOffsetMap * offmap_
Definition:
MuonSensitiveDetectorBuilder.cc:65
edm::ESHandle
Definition:
DTSurvey.h:22
SensitiveDetectorCatalog
Definition:
SensitiveDetectorCatalog.h:10
edm::ParameterSet
Definition:
ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
GeV
const double GeV
Definition:
MathUtil.h:16
MuonSensitiveDetectorBuilder::offsetToken_
const edm::ESGetToken< MuonOffsetMap, IdealGeometryRecord > offsetToken_
Definition:
MuonSensitiveDetectorBuilder.cc:67
MuonSensitiveDetectorBuilder::mdc_
const MuonGeometryConstants * mdc_
Definition:
MuonSensitiveDetectorBuilder.cc:66
SensitiveDetectorMakerBase
Definition:
SensitiveDetectorMakerBase.h:28
ModuleDef.h
SimActivityRegistryEnroller::enroll
static void enroll(SimActivityRegistry &iReg, T *iObj)
Definition:
SimActivityRegistryEnroller.h:50
MuonSensitiveDetectorBuilder::MuonSensitiveDetectorBuilder
MuonSensitiveDetectorBuilder(edm::ParameterSet const &p, edm::ConsumesCollector cc)
Definition:
MuonSensitiveDetectorBuilder.cc:34
MuonSensitiveDetectorBuilder::dd4hep_
bool dd4hep_
Definition:
MuonSensitiveDetectorBuilder.cc:72
IdealGeometryRecord.h
edm::EventSetup
Definition:
EventSetup.h:58
MuonSensitiveDetector.h
cc
edm::ESHandleBase::isValid
bool isValid() const
Definition:
ESHandle.h:44
edm::ESGetToken< MuonOffsetMap, IdealGeometryRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
SimActivityRegistryEnroller.h
SimActivityRegistry
Definition:
SimActivityRegistry.h:39
DEFINE_SENSITIVEDETECTORBUILDER
#define DEFINE_SENSITIVEDETECTORBUILDER(type, name)
Definition:
SensitiveDetectorPluginFactory.h:21
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition:
MessageLogger.h:128
edm::Transition::BeginRun
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
sd
double sd
Definition:
CascadeWrapper.h:113
ConsumesCollector.h
SensitiveDetectorPluginFactory.h
ParameterSet.h
MuonSensitiveDetectorBuilder::make
std::unique_ptr< SensitiveDetector > make(const std::string &iname, const SensitiveDetectorCatalog &clg, const edm::ParameterSet &p, const SimTrackManager *man, SimActivityRegistry ®) const final
Definition:
MuonSensitiveDetectorBuilder.cc:53
MuonSensitiveDetectorBuilder::geomConstantsToken_
const edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > geomConstantsToken_
Definition:
MuonSensitiveDetectorBuilder.cc:68
SensitiveDetectorMakerBase.h
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
Generated for CMSSW Reference Manual by
1.8.16