FastSimulation
ShowerDevelopment
src
FastHFShowerLibrary.cc
Go to the documentation of this file.
1
// File: FastHFShowerLibrary.cc
3
// Description: Shower library for Very forward hadron calorimeter
5
6
#include "
FastSimulation/ShowerDevelopment/interface/FastHFShowerLibrary.h
"
7
#include "
FastSimulation/Event/interface/FSimEvent.h
"
8
#include "
FastSimulation/Event/interface/FSimTrack.h
"
9
#include "
FastSimulation/Utilities/interface/RandomEngineAndDistribution.h
"
10
#include "
SimG4CMS/Calo/interface/HFFibreFiducial.h
"
11
#include "
FWCore/Framework/interface/ESTransientHandle.h
"
12
#include "
FWCore/Framework/interface/ESHandle.h
"
13
#include "
Geometry/Records/interface/IdealGeometryRecord.h
"
14
#include "
Geometry/Records/interface/HcalParametersRcd.h
"
15
#include "
Geometry/Records/interface/HcalSimNumberingRecord.h
"
16
#include "
Geometry/HcalCommonData/interface/HcalDDDSimConstants.h
"
17
#include "
Geometry/HcalCommonData/interface/HcalDDDSimulationConstants.h
"
18
#include "
FWCore/Utilities/interface/Exception.h
"
19
#include "
DataFormats/HcalDetId/interface/HcalDetId.h
"
20
#include "
DataFormats/HcalDetId/interface/HcalSubdetector.h
"
21
22
#include "Randomize.hh"
23
#include "CLHEP/Units/GlobalSystemOfUnits.h"
24
#include "CLHEP/Units/GlobalPhysicalConstants.h"
25
26
// Geant4 headers
27
#include "G4ParticleDefinition.hh"
28
#include "G4DynamicParticle.hh"
29
#include "G4DecayPhysics.hh"
30
#include "G4ParticleTable.hh"
31
#include "G4ParticleTypes.hh"
32
33
// STL headers
34
#include <vector>
35
#include <iostream>
36
#include <mutex>
37
38
//#define DebugLog
39
40
static
std::once_flag
initializeOnce
;
41
42
FastHFShowerLibrary::FastHFShowerLibrary
(
edm::ParameterSet
const
&
p
) : fast(
p
) {
43
edm::ParameterSet
m_HS =
p
.getParameter<
edm::ParameterSet
>(
"HFShowerLibrary"
);
44
applyFidCut
= m_HS.
getParameter
<
bool
>(
"ApplyFiducialCut"
);
45
}
46
47
void
const
FastHFShowerLibrary::initHFShowerLibrary
(
const
edm::EventSetup
& iSetup) {
48
edm::LogInfo
(
"FastCalorimetry"
) <<
"initHFShowerLibrary::initialization"
;
49
50
edm::ESHandle<HcalDDDSimConstants>
hdc;
51
iSetup.
get
<
HcalSimNumberingRecord
>().
get
(hdc);
52
hcalConstants
= hdc.
product
();
53
54
edm::ESHandle<HcalDDDSimulationConstants>
hdsc;
55
iSetup.
get
<
HcalSimNumberingRecord
>().
get
(hdsc);
56
const
HcalDDDSimulationConstants
* hsps = hdsc.
product
();
57
58
std::string
name
=
"HcalHits"
;
59
numberingFromDDD
.reset(
new
HcalNumberingFromDDD
(
hcalConstants
));
60
hfshower
.reset(
new
HFShowerLibrary
(
name
,
hcalConstants
, hsps->
hcalsimpar
(),
fast
));
61
62
//only one thread can be allowed to setup the G4 physics table.
63
std::call_once(
initializeOnce
, []() {
64
// Geant4 particles
65
G4DecayPhysics
decays
;
66
decays
.ConstructParticle();
67
G4ParticleTable* partTable = G4ParticleTable::GetParticleTable();
68
partTable->SetReadiness();
69
});
70
//G4ParticleTable* partTable = G4ParticleTable::GetParticleTable();
71
//hfshower->initRun(partTable, hcalConstants); // init particle code
72
}
73
74
void
FastHFShowerLibrary::SetRandom
(
const
RandomEngineAndDistribution
* rnd) {
75
// define Geant4 engine per thread
76
G4Random::setTheEngine(&(rnd->
theEngine
()));
77
LogDebug
(
"FastHFShowerLibrary::recoHFShowerLibrary"
)
78
<<
"Begin of event "
<< G4UniformRand() <<
" "
<< rnd->
theEngine
().name() <<
" "
<< rnd->
theEngine
();
79
}
80
81
void
FastHFShowerLibrary::recoHFShowerLibrary
(
const
FSimTrack
& myTrack) {
82
#ifdef DebugLog
83
edm::LogInfo
(
"FastCalorimetry"
) <<
"FastHFShowerLibrary: recoHFShowerLibrary "
;
84
#endif
85
86
if
(!myTrack.
onVFcal
()) {
87
#ifdef DebugLog
88
edm::LogInfo
(
"FastCalorimetry"
) <<
"FastHFShowerLibrary: we should not be here "
;
89
#endif
90
}
91
92
hitMap
.clear();
93
double
eGen = 1000. * myTrack.
vfcalEntrance
().
e
();
// energy in [MeV]
94
double
delZv = (myTrack.
vfcalEntrance
().
vertex
().Z() > 0.0) ? 50.0 : -50.0;
95
G4ThreeVector
vertex
(10. * myTrack.
vfcalEntrance
().
vertex
().X(),
96
10. * myTrack.
vfcalEntrance
().
vertex
().Y(),
97
10. * myTrack.
vfcalEntrance
().
vertex
().Z() + delZv);
// in [mm]
98
99
G4ThreeVector direction(
100
myTrack.
vfcalEntrance
().
Vect
().X(), myTrack.
vfcalEntrance
().
Vect
().Y(), myTrack.
vfcalEntrance
().
Vect
().Z());
101
102
bool
ok
;
103
double
weight
= 1.0;
// rad. damage
104
int
parCode = myTrack.
type
();
105
double
tSlice = 0.1 *
vertex
.mag() / 29.98;
106
107
std::vector<HFShowerLibrary::Hit>
hits
=
108
hfshower
->fillHits(
vertex
, direction, parCode, eGen,
ok
,
weight
, tSlice,
false
);
109
110
for
(
unsigned
int
i
= 0;
i
<
hits
.size(); ++
i
) {
111
G4ThreeVector
pos
=
hits
[
i
].position;
112
int
depth
=
hits
[
i
].depth;
113
double
time
=
hits
[
i
].time;
114
if
(!
applyFidCut
|| (
HFFibreFiducial::PMTNumber
(
pos
) > 0)) {
115
// if (!applyFidCut || (applyFidCut && HFFibreFiducial::PMTNumber(pos)>0)) {
116
int
det = 5;
117
int
lay = 1;
118
uint32_t
id
= 0;
119
HcalNumberingFromDDD::HcalID
tmp
=
120
numberingFromDDD
->unitID(det,
math::XYZVectorD
(
pos
.x(),
pos
.y(),
pos
.z()),
depth
, lay);
121
modifyDepth
(
tmp
);
122
id
=
numberingScheme
.
getUnitID
(
tmp
);
123
124
CaloHitID
current_id(
id
,
time
, myTrack.
id
());
125
std::map<CaloHitID, float>::iterator cellitr;
126
cellitr =
hitMap
.find(current_id);
127
if
(cellitr ==
hitMap
.end()) {
128
hitMap
.insert(std::pair<CaloHitID, float>(current_id, 1.0));
129
}
else
{
130
cellitr->second += 1.0;
131
}
132
}
// end of isItinFidVolume check
133
}
// end loop over hits
134
}
135
136
void
FastHFShowerLibrary::modifyDepth
(
HcalNumberingFromDDD::HcalID
&
id
) {
137
if
(
id
.subdet ==
HcalForward
) {
138
int
ieta
= (
id
.zside == 0) ? -
id
.etaR :
id
.etaR;
139
if
(
hcalConstants
->
maxHFDepth
(
ieta
,
id
.phis) > 2) {
140
if
(
id
.
depth
<= 2) {
141
if
(G4UniformRand() > 0.5)
142
id
.depth += 2;
143
}
144
}
145
}
146
}
FastHFShowerLibrary::hcalConstants
const HcalDDDSimConstants * hcalConstants
Definition:
FastHFShowerLibrary.h:56
edm::ESHandle::product
T const * product() const
Definition:
ESHandle.h:86
FastHFShowerLibrary.h
HcalDDDSimulationConstants::hcalsimpar
const HcalSimulationParameters * hcalsimpar() const
Definition:
HcalDDDSimulationConstants.h:20
FastHFShowerLibrary::fast
const edm::ParameterSet fast
Definition:
FastHFShowerLibrary.h:53
HcalNumberingScheme::getUnitID
virtual uint32_t getUnitID(const HcalNumberingFromDDD::HcalID &id)
Definition:
HcalNumberingScheme.cc:19
bJpsiMuMuTrigSettings_cff.decays
decays
Definition:
bJpsiMuMuTrigSettings_cff.py:15
mps_fire.i
i
Definition:
mps_fire.py:355
ESTransientHandle.h
HcalNumberingFromDDD::HcalID
Definition:
HcalNumberingFromDDD.h:21
hfClusterShapes_cfi.hits
hits
Definition:
hfClusterShapes_cfi.py:5
ESHandle.h
HcalSimNumberingRecord.h
RawParticle::vertex
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition:
RawParticle.h:320
FastHFShowerLibrary::recoHFShowerLibrary
void recoHFShowerLibrary(const FSimTrack &myTrack)
Definition:
FastHFShowerLibrary.cc:81
HFFibreFiducial.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
HcalNumberingFromDDD
Definition:
HcalNumberingFromDDD.h:16
pos
Definition:
PixelAliasList.h:18
edm::LogInfo
Definition:
MessageLogger.h:254
FSimTrack.h
HcalDDDSimulationConstants.h
FastHFShowerLibrary::numberingScheme
HcalNumberingScheme numberingScheme
Definition:
FastHFShowerLibrary.h:57
createJobs.tmp
tmp
align.sh
Definition:
createJobs.py:716
convertSQLiteXML.ok
bool ok
Definition:
convertSQLiteXML.py:98
RandomEngineAndDistribution.h
HFFibreFiducial::PMTNumber
int PMTNumber(const G4ThreeVector &pe_effect)
Definition:
HFFibreFiducial.cc:9
FastHFShowerLibrary::name
std::string name
Definition:
FastHFShowerLibrary.h:62
FSimEvent.h
FastHFShowerLibrary::FastHFShowerLibrary
FastHFShowerLibrary(edm::ParameterSet const &p)
Definition:
FastHFShowerLibrary.cc:42
HcalParametersRcd.h
edm::EventSetup::get
T get() const
Definition:
EventSetup.h:73
FSimTrack::vfcalEntrance
const RawParticle & vfcalEntrance() const
The particle at VFCAL entrance.
Definition:
FSimTrack.h:149
edm::ESHandle
Definition:
DTSurvey.h:22
FSimTrack::onVFcal
int onVFcal() const
Definition:
FSimTrack.h:121
HcalDDDSimConstants::maxHFDepth
int maxHFDepth(const int &ieta, const int &iphi) const
Definition:
HcalDDDSimConstants.cc:655
LEDCalibrationChannels.depth
depth
Definition:
LEDCalibrationChannels.py:65
RawParticle::Vect
XYZVector Vect() const
the momentum threevector
Definition:
RawParticle.h:323
FastHFShowerLibrary::hitMap
std::map< CaloHitID, float > hitMap
Definition:
FastHFShowerLibrary.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
math::XYZVectorD
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition:
Vector3D.h:8
FSimTrack::id
int id() const
the index in FBaseSimEvent and other vectors
Definition:
FSimTrack.h:96
LEDCalibrationChannels.ieta
ieta
Definition:
LEDCalibrationChannels.py:63
bphysicsOniaDQM_cfi.vertex
vertex
Definition:
bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:670
edm::ParameterSet
Definition:
ParameterSet.h:36
HcalDetId.h
Calorimetry_cff.HFShowerLibrary
HFShowerLibrary
Definition:
Calorimetry_cff.py:269
IdealGeometryRecord.h
CoreSimTrack::type
int type() const
particle type (HEP PDT convension)
Definition:
CoreSimTrack.h:22
edm::EventSetup
Definition:
EventSetup.h:57
HcalSubdetector.h
get
#define get
RandomEngineAndDistribution::theEngine
CLHEP::HepRandomEngine & theEngine() const
Definition:
RandomEngineAndDistribution.h:25
HcalDDDSimulationConstants
Definition:
HcalDDDSimulationConstants.h:15
HcalForward
Definition:
HcalAssistant.h:36
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
FastHFShowerLibrary::modifyDepth
void modifyDepth(HcalNumberingFromDDD::HcalID &id)
Definition:
FastHFShowerLibrary.cc:136
RawParticle::e
double e() const
energy of the momentum
Definition:
RawParticle.h:305
initializeOnce
static std::once_flag initializeOnce
Definition:
FastHFShowerLibrary.cc:40
CaloHitID
Definition:
CaloHitID.h:11
Exception.h
FastHFShowerLibrary::numberingFromDDD
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD
Definition:
FastHFShowerLibrary.h:55
FastHFShowerLibrary::hfshower
std::unique_ptr< HFShowerLibrary > hfshower
Definition:
FastHFShowerLibrary.h:54
FSimTrack
Definition:
FSimTrack.h:30
FastHFShowerLibrary::SetRandom
void SetRandom(const RandomEngineAndDistribution *)
Definition:
FastHFShowerLibrary.cc:74
ntuplemaker.time
time
Definition:
ntuplemaker.py:310
HcalSimNumberingRecord
Definition:
HcalSimNumberingRecord.h:25
FastHFShowerLibrary::applyFidCut
bool applyFidCut
Definition:
FastHFShowerLibrary.h:61
weight
Definition:
weight.py:1
FastHFShowerLibrary::initHFShowerLibrary
const void initHFShowerLibrary(const edm::EventSetup &)
Definition:
FastHFShowerLibrary.cc:47
HcalDDDSimConstants.h
RandomEngineAndDistribution
Definition:
RandomEngineAndDistribution.h:18
Generated for CMSSW Reference Manual by
1.8.16