CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
TotemTestGem Class Reference

#include <SimG4CMS/Forward/interface/TotemTestGem.h>

Inheritance diagram for TotemTestGem:
SimProducer Observer< const BeginOfEvent * > Observer< const EndOfEvent * > SimWatcher

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 TotemTestGem (const edm::ParameterSet &p)
 
 ~TotemTestGem () override
 
- Public Member Functions inherited from SimProducer
const SimProduceroperator= (const SimProducer &)=delete
 
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
 SimProducer (const SimProducer &)=delete
 
- Public Member Functions inherited from SimWatcher
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 

Private Member Functions

void clear ()
 
void fillEvent (TotemTestHistoClass &)
 

Private Attributes

int evtnum
 
std::vector< TotemG4Hit * > hits
 
std::vector< std::string > names
 

Detailed Description

Description: Manages Root file creation for Totem Tests

Usage: Used in testing Totem simulation

Definition at line 40 of file TotemTestGem.h.

Constructor & Destructor Documentation

◆ TotemTestGem()

TotemTestGem::TotemTestGem ( const edm::ParameterSet p)

Definition at line 38 of file TotemTestGem.cc.

38  {
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 }

References edm::ParameterSet::getParameter(), names, and AlCaHLTBitMon_ParallelJobs::p.

◆ ~TotemTestGem()

TotemTestGem::~TotemTestGem ( )
override

Definition at line 46 of file TotemTestGem.cc.

46 {}

Member Function Documentation

◆ clear()

void TotemTestGem::clear ( void  )
private

Definition at line 114 of file TotemTestGem.cc.

114  {
115  evtnum = 0;
116  hits.clear();
117 }

References evtnum, and hits.

Referenced by update().

◆ fillEvent()

void TotemTestGem::fillEvent ( TotemTestHistoClass product)
private

Definition at line 93 of file TotemTestGem.cc.

93  {
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 }

References evtnum, TotemTestHistoClass::fillHit(), TotemG4Hit::getEnergyLoss(), TotemG4Hit::getEntry(), TotemG4Hit::getPabs(), TotemG4Hit::getParentId(), TotemG4Hit::getParticleType(), TotemG4Hit::getTrackID(), TotemG4Hit::getUnitID(), TotemG4Hit::getVx(), TotemG4Hit::getVy(), TotemG4Hit::getVz(), hits, TotemTestHistoClass::setEVT(), SectorBuilder_Tid_cff::TID, x, y, and z.

Referenced by produce().

◆ produce()

void TotemTestGem::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 52 of file TotemTestGem.cc.

52  {
53  std::unique_ptr<TotemTestHistoClass> product(new TotemTestHistoClass);
54  fillEvent(*product);
55  e.put(std::move(product));
56 }

References MillePedeFileConverter_cfg::e, fillEvent(), and eostools::move().

◆ update() [1/2]

void TotemTestGem::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 58 of file TotemTestGem.cc.

58  {
59  int iev = (*evt)()->GetEventID();
60  LogDebug("ForwardSim") << "TotemTestGem: Begin of event = " << iev;
61  clear();
62 }

References clear(), iev, and LogDebug.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [2/2]

void TotemTestGem::update ( const EndOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 64 of file TotemTestGem.cc.

64  {
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 }

References evtnum, hits, recoMuon::in, LogDebug, and names.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

Member Data Documentation

◆ evtnum

int TotemTestGem::evtnum
private

Definition at line 59 of file TotemTestGem.h.

Referenced by clear(), fillEvent(), and update().

◆ hits

std::vector<TotemG4Hit *> TotemTestGem::hits
private

Definition at line 60 of file TotemTestGem.h.

Referenced by clear(), fillEvent(), and update().

◆ names

std::vector<std::string> TotemTestGem::names
private

Definition at line 58 of file TotemTestGem.h.

Referenced by TotemTestGem(), and update().

TotemG4HitCollection
TotemTestGem::hits
std::vector< TotemG4Hit * > hits
Definition: TotemTestGem.h:60
DDAxes::y
iev
const HitContainer *__restrict__ const TkSoA *__restrict__ const Quality *__restrict__ const CAHitNtupletGeneratorKernelsGPU::HitToTuple *__restrict__ int32_t int iev
Definition: CAHitNtupletGeneratorKernelsImpl.h:862
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
TotemG4Hit::getEntry
math::XYZPoint getEntry() const
Definition: TotemG4Hit.cc:114
TotemTestHistoClass::setEVT
void setEVT(int v)
Definition: TotemTestHistoClass.h:53
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
DDAxes::z
TotemG4Hit::getPabs
float getPabs() const
Definition: TotemG4Hit.cc:142
TotemG4Hit::getVy
float getVy() const
Definition: TotemG4Hit.cc:173
TotemG4Hit::getVx
float getVx() const
Definition: TotemG4Hit.cc:170
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
recoMuon::in
Definition: RecoMuonEnumerators.h:6
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
TotemG4Hit::getParentId
int getParentId() const
Definition: TotemG4Hit.cc:167
SectorBuilder_Tid_cff.TID
TID
Definition: SectorBuilder_Tid_cff.py:16
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TotemG4Hit
Definition: TotemG4Hit.h:39
TotemTestHistoClass
Definition: TotemTestHistoClass.h:26
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TotemTestGem::names
std::vector< std::string > names
Definition: TotemTestGem.h:58