SimG4CMS
Forward
src
TotemTestGem.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: Forward
4
// Class : TotemTestGem
5
//
6
// Implementation:
7
// <Notes on implementation>
8
//
9
// Original Author:
10
// Created: Tue May 16 10:14:34 CEST 2006
11
//
12
13
// system include files
14
#include <iostream>
15
#include <iomanip>
16
#include <cmath>
17
18
// user include files
19
#include "
SimG4Core/Notification/interface/BeginOfEvent.h
"
20
#include "
SimG4Core/Notification/interface/EndOfEvent.h
"
21
22
#include "
FWCore/Framework/interface/Event.h
"
23
#include "
FWCore/Framework/interface/EventSetup.h
"
24
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
25
26
#include "
SimG4CMS/Forward/interface/TotemTestGem.h
"
27
#include "
SimG4CMS/Forward/interface/TotemG4HitCollection.h
"
28
29
#include "G4SDManager.hh"
30
#include "G4HCofThisEvent.hh"
31
#include "CLHEP/Units/GlobalSystemOfUnits.h"
32
#include "CLHEP/Units/GlobalPhysicalConstants.h"
33
34
//
35
// constructors and destructor
36
//
37
38
TotemTestGem::TotemTestGem
(
const
edm::ParameterSet
&
p
) {
39
edm::ParameterSet
m_Anal =
p
.getParameter<
edm::ParameterSet
>(
"TotemTestGem"
);
40
names
= m_Anal.
getParameter
<std::vector<std::string> >(
"Names"
);
41
42
edm::LogInfo
(
"ForwardSim"
) <<
"TotemTestGem:: Initialised as observer of "
43
<<
"begin of job, begin/end events and of G4step"
;
44
}
45
46
TotemTestGem::~TotemTestGem
() {}
47
48
//
49
// member functions
50
//
51
52
void
TotemTestGem::produce
(
edm::Event
&
e
,
const
edm::EventSetup
&) {
53
std::unique_ptr<TotemTestHistoClass> product(
new
TotemTestHistoClass
);
54
fillEvent
(*product);
55
e
.put(
std::move
(product));
56
}
57
58
void
TotemTestGem::update
(
const
BeginOfEvent
* evt) {
59
int
iev = (*evt)()->GetEventID();
60
LogDebug
(
"ForwardSim"
) <<
"TotemTestGem: Begin of event = "
<< iev;
61
clear
();
62
}
63
64
void
TotemTestGem::update
(
const
EndOfEvent
* evt) {
65
evtnum
= (*evt)()->GetEventID();
66
LogDebug
(
"ForwardSim"
) <<
"TotemTestGem:: Fill event "
<<
evtnum
;
67
68
// access to the G4 hit collections
69
G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
70
71
int
nhit = 0;
72
for
(
unsigned
int
in
= 0;
in
<
names
.size();
in
++) {
73
int
HCid = G4SDManager::GetSDMpointer()->GetCollectionID(
names
[
in
]);
74
TotemG4HitCollection
* theHC = (
TotemG4HitCollection
*)allHC->GetHC(HCid);
75
LogDebug
(
"ForwardSim"
) <<
"TotemTestGem :: Hit Collection for "
<<
names
[
in
] <<
" of ID "
<< HCid
76
<<
" is obtained at "
<< theHC;
77
78
if
(HCid >= 0 && theHC !=
nullptr
) {
79
int
nentries = theHC->entries();
80
LogDebug
(
"ForwardSim"
) <<
"TotemTestGem :: "
<<
names
[
in
] <<
" with "
<< nentries <<
" entries"
;
81
for
(
int
ihit = 0; ihit < nentries; ihit++) {
82
TotemG4Hit
* aHit = (*theHC)[ihit];
83
hits
.push_back(aHit);
84
}
85
nhit += nentries;
86
}
87
}
88
89
// Writing the data to the Tree
90
LogDebug
(
"ForwardSim"
) <<
"TotemTestGem:: --- after fillTree with "
<< nhit <<
" Hits"
;
91
}
92
93
void
TotemTestGem::fillEvent
(
TotemTestHistoClass
& product) {
94
product.
setEVT
(
evtnum
);
95
96
for
(
unsigned
ihit = 0; ihit <
hits
.size(); ihit++) {
97
TotemG4Hit
* aHit =
hits
[ihit];
98
int
UID = aHit->
getUnitID
();
99
int
Ptype = aHit->
getParticleType
();
100
int
TID
= aHit->
getTrackID
();
101
int
PID
= aHit->
getParentId
();
102
float
ELoss = aHit->
getEnergyLoss
();
103
float
PABS = aHit->
getPabs
();
104
float
x
= aHit->
getEntry
().x();
105
float
y
= aHit->
getEntry
().y();
106
float
z
= aHit->
getEntry
().z();
107
float
vx = aHit->
getVx
();
108
float
vy = aHit->
getVy
();
109
float
vz = aHit->
getVz
();
110
product.
fillHit
(UID, Ptype,
TID
,
PID
, ELoss, PABS, vx, vy, vz,
x
,
y
,
z
);
111
}
112
}
113
114
void
TotemTestGem::clear
() {
115
evtnum
= 0;
116
hits
.clear();
117
}
TotemG4HitCollection
TotemTestGem::hits
std::vector< TotemG4Hit * > hits
Definition:
TotemTestGem.h:60
DDAxes::y
TotemTestGem::TotemTestGem
TotemTestGem(const edm::ParameterSet &p)
Definition:
TotemTestGem.cc:38
MessageLogger.h
TotemTestGem::clear
void clear()
Definition:
TotemTestGem.cc:114
TotemG4Hit::getTrackID
int getTrackID() const
Definition:
TotemG4Hit.cc:125
TotemG4Hit::getUnitID
uint32_t getUnitID() const
Definition:
TotemG4Hit.cc:128
TotemTestGem::~TotemTestGem
~TotemTestGem() override
Definition:
TotemTestGem.cc:46
TotemG4Hit::getEntry
math::XYZPoint getEntry() const
Definition:
TotemG4Hit.cc:114
AlCaHLTBitMon_ParallelJobs.p
p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
TotemTestHistoClass::setEVT
void setEVT(int v)
Definition:
TotemTestHistoClass.h:53
EndOfEvent.h
DDAxes::x
TotemTestHistoClass::fillHit
void fillHit(int uID, int pType, int tID, int pID, float eLoss, float pAbs, float vX, float vY, float vZ, float x, float y, float z)
Definition:
TotemTestHistoClass.cc:29
edm::LogInfo
Log< level::Info, false > LogInfo
Definition:
MessageLogger.h:125
TotemTestGem::fillEvent
void fillEvent(TotemTestHistoClass &)
Definition:
TotemTestGem.cc:93
PID
PID
Definition:
data.h:16
TotemG4Hit::getVz
float getVz() const
Definition:
TotemG4Hit.cc:176
TotemTestGem::update
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
Definition:
TotemTestGem.cc:58
DDAxes::z
TotemG4Hit::getPabs
float getPabs() const
Definition:
TotemG4Hit.cc:142
TotemG4Hit::getVy
float getVy() const
Definition:
TotemG4Hit.cc:173
EndOfEvent
Definition:
EndOfEvent.h:6
TotemG4Hit::getVx
float getVx() const
Definition:
TotemG4Hit.cc:170
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:223
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
BeginOfEvent.h
BeginOfEvent
Definition:
BeginOfEvent.h:6
edm::EventSetup
Definition:
EventSetup.h:57
TotemG4HitCollection.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
TotemG4Hit::getEnergyLoss
float getEnergyLoss() const
Definition:
TotemG4Hit.cc:144
TotemG4Hit::getParticleType
int getParticleType() const
Definition:
TotemG4Hit.cc:145
TotemTestGem::evtnum
int evtnum
Definition:
TotemTestGem.h:59
TotemTestGem.h
TotemG4Hit::getParentId
int getParentId() const
Definition:
TotemG4Hit.cc:167
SectorBuilder_Tid_cff.TID
TID
Definition:
SectorBuilder_Tid_cff.py:16
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
TotemG4Hit
Definition:
TotemG4Hit.h:39
TotemTestHistoClass
Definition:
TotemTestHistoClass.h:26
edm::Event
Definition:
Event.h:73
TotemTestGem::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
TotemTestGem.cc:52
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
TotemTestGem::names
std::vector< std::string > names
Definition:
TotemTestGem.h:58
Generated for CMSSW Reference Manual by
1.8.16