CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HGCPassive Class Reference

#include <HGCPassive.h>

Inheritance diagram for HGCPassive:
SimProducer Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const G4Step * > SimWatcher

Public Member Functions

 HGCPassive (const edm::ParameterSet &p)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HGCPassive () override
 
- Public Member Functions inherited from SimProducer
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Types

typedef std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > >::iterator volumeIterator
 

Private Member Functions

void endOfEvent (edm::PassiveHitContainer &hgcPH, unsigned int k)
 
volumeIterator findLV (G4LogicalVolume *plv)
 
G4VPhysicalVolume * getTopPV ()
 
 HGCPassive (const HGCPassive &)=delete
 
const HGCPassiveoperator= (const HGCPassive &)=delete
 
void storeInfo (const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy, bool flag)
 
void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

unsigned int count_
 
bool init_
 
std::vector< std::string > LVNames_
 
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
 
std::string motherName_
 
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
 
G4LogicalVolume * topLV_
 
G4VPhysicalVolume * topPV_
 

Additional Inherited Members

- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 

Detailed Description

Definition at line 37 of file HGCPassive.h.

Member Typedef Documentation

◆ volumeIterator

typedef std::map<G4LogicalVolume *, std::pair<unsigned int, std::string> >::iterator HGCPassive::volumeIterator
private

Definition at line 59 of file HGCPassive.h.

Constructor & Destructor Documentation

◆ HGCPassive() [1/2]

HGCPassive::HGCPassive ( const edm::ParameterSet p)

Definition at line 22 of file HGCPassive.cc.

22  : topPV_(nullptr), topLV_(nullptr), count_(0), init_(false) {
23  edm::ParameterSet m_Passive = p.getParameter<edm::ParameterSet>("HGCPassive");
24  LVNames_ = m_Passive.getParameter<std::vector<std::string> >("LVNames");
25  motherName_ = m_Passive.getParameter<std::string>("MotherName");
26 
27 #ifdef EDM_ML_DEBUG
28  edm::LogVerbatim("HGCSim") << "Name of the mother volume " << motherName_;
29  unsigned k(0);
30 #endif
31  for (auto name : LVNames_) {
32  produces<edm::PassiveHitContainer>(Form("%sPassiveHits", name.c_str()));
33 #ifdef EDM_ML_DEBUG
34  edm::LogVerbatim("HGCSim") << "Collection name[" << k << "] " << name;
35  ++k;
36 #endif
37  }
38 }

References edm::ParameterSet::getParameter(), dqmdumpme::k, LVNames_, motherName_, Skims_PA_cff::name, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~HGCPassive()

HGCPassive::~HGCPassive ( )
override

Definition at line 40 of file HGCPassive.cc.

40 {}

◆ HGCPassive() [2/2]

HGCPassive::HGCPassive ( const HGCPassive )
privatedelete

Member Function Documentation

◆ endOfEvent()

void HGCPassive::endOfEvent ( edm::PassiveHitContainer hgcPH,
unsigned int  k 
)
private

Definition at line 151 of file HGCPassive.cc.

151  {
152 #ifdef EDM_ML_DEBUG
153  unsigned int kount(0);
154 #endif
155  for (const auto& element : store_) {
156  G4LogicalVolume* lv = (element.first).first;
157  auto it = mapLV_.find(lv);
158  if (it != mapLV_.end()) {
159  if ((it->second).first == k) {
160  PassiveHit hit(
161  (it->second).second, (element.first).second, (element.second)[1], (element.second)[2], (element.second)[0]);
162  hgcPH.push_back(hit);
163 #ifdef EDM_ML_DEBUG
164  edm::LogVerbatim("HGCSim") << "HGCPassive[" << k << "] Hit[" << kount << "] " << hit;
165  ++kount;
166 #endif
167  }
168  }
169  }
170 }

References dqmdumpme::first, dqmdumpme::k, mapLV_, and store_.

Referenced by produce().

◆ findLV()

HGCPassive::volumeIterator HGCPassive::findLV ( G4LogicalVolume *  plv)
private

Definition at line 176 of file HGCPassive.cc.

176  {
177  auto itr = mapLV_.find(plv);
178  if (itr == mapLV_.end()) {
179  std::string name = plv->GetName();
180  for (unsigned int k = 0; k < LVNames_.size(); ++k) {
181  if (name.find(LVNames_[k]) != std::string::npos) {
182  mapLV_[plv] = std::pair<unsigned int, std::string>(k, name);
183  itr = mapLV_.find(plv);
184  break;
185  }
186  }
187  }
188  if (topLV_ == nullptr) {
189  if (std::string(plv->GetName()) == motherName_)
190  topLV_ = plv;
191  }
192  return itr;
193 }

References dqmdumpme::k, LVNames_, mapLV_, motherName_, Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and topLV_.

Referenced by update().

◆ getTopPV()

G4VPhysicalVolume * HGCPassive::getTopPV ( )
private

Definition at line 172 of file HGCPassive.cc.

172  {
173  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
174 }

Referenced by update().

◆ operator=()

const HGCPassive& HGCPassive::operator= ( const HGCPassive )
privatedelete

◆ produce()

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

Implements SimProducer.

Definition at line 42 of file HGCPassive.cc.

42  {
43  for (unsigned int k = 0; k < LVNames_.size(); ++k) {
44  std::unique_ptr<edm::PassiveHitContainer> hgcPH(new edm::PassiveHitContainer);
45  endOfEvent(*hgcPH, k);
46  e.put(std::move(hgcPH), Form("%sPassiveHits", LVNames_[k].c_str()));
47  }
48 }

References MillePedeFileConverter_cfg::e, endOfEvent(), dqmdumpme::k, LVNames_, and eostools::move().

◆ storeInfo()

void HGCPassive::storeInfo ( const volumeIterator  itr,
G4LogicalVolume *  plv,
unsigned int  copy,
double  time,
double  energy,
bool  flag 
)
private

Definition at line 195 of file HGCPassive.cc.

200  {
201  std::pair<G4LogicalVolume*, unsigned int> key(plv, copy);
202  auto itr = store_.find(key);
203  double ee = (flag) ? energy : 0;
204  if (itr == store_.end()) {
205  store_[key] = {{time, energy, energy}};
206  } else {
207  (itr->second)[1] += ee;
208  (itr->second)[2] += energy;
209  }
210 #ifdef EDM_ML_DEBUG
211  itr = store_.find(key);
212  edm::LogVerbatim("HGCSim") << "HGCPassive: Element " << (it->second).first << ":" << (it->second).second << ":"
213  << copy << " T " << (itr->second)[0] << " E " << (itr->second)[1] << ":"
214  << (itr->second)[2];
215 #endif
216 }

References filterCSVwithJSON::copy, HCALHighEnergyHPDFilter_cfi::energy, dqmdumpme::first, RemoveAddSevLevel::flag, crabWrapper::key, store_, and ntuplemaker::time.

Referenced by update().

◆ update() [1/3]

void HGCPassive::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 74 of file HGCPassive.cc.

74  {
75  int iev = (*evt)()->GetEventID();
76  edm::LogVerbatim("HGCSim") << "HGCPassive: =====> Begin event = " << iev << std::endl;
77 
78  ++count_;
79  store_.clear();
80 }

References count_, and store_.

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

◆ update() [2/3]

void HGCPassive::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 50 of file HGCPassive.cc.

50  {
51  topPV_ = getTopPV();
52  if (topPV_ == nullptr) {
53  edm::LogWarning("HGCSim") << "Cannot find top level volume\n";
54  } else {
55  init_ = true;
56  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
57  for (auto lvcite : *lvs) {
58  findLV(lvcite);
59  }
60 
61 #ifdef EDM_ML_DEBUG
62  edm::LogVerbatim("HGCSim") << "HGCPassive::Finds " << mapLV_.size() << " logical volumes";
63  unsigned int k(0);
64  for (const auto& lvs : mapLV_) {
65  edm::LogVerbatim("HGCSim") << "Entry[" << k << "] " << lvs.first << ": (" << (lvs.second).first << ", "
66  << (lvs.second).second << ")";
67  ++k;
68  }
69 #endif
70  }
71 }

References findLV(), dqmdumpme::first, getTopPV(), init_, dqmdumpme::k, mapLV_, and topPV_.

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

◆ update() [3/3]

void HGCPassive::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 84 of file HGCPassive.cc.

84  {
85  if (aStep != nullptr) {
86  G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
87  const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();
88 
89  if (curSD == nullptr) {
90  G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume();
91  auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
92  double time = aStep->GetTrack()->GetGlobalTime();
93  double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV;
94 
95  unsigned int copy(0);
96  if (((aStep->GetPostStepPoint() == nullptr) || (aStep->GetTrack()->GetNextVolume() == nullptr)) &&
97  (aStep->IsLastStepInVolume())) {
98 #ifdef EDM_ML_DEBUG
99  edm::LogVerbatim("HGCSim") << plv->GetName() << " F|L Step " << aStep->IsFirstStepInVolume() << ":"
100  << aStep->IsLastStepInVolume() << " Position"
101  << aStep->GetPreStepPoint()->GetPosition() << " Track "
102  << aStep->GetTrack()->GetDefinition()->GetParticleName() << " at"
103  << aStep->GetTrack()->GetPosition() << " Volume " << aStep->GetTrack()->GetVolume()
104  << ":" << aStep->GetTrack()->GetNextVolume() << " Status "
105  << aStep->GetTrack()->GetTrackStatus() << " KE "
106  << aStep->GetTrack()->GetKineticEnergy() << " Deposit "
107  << aStep->GetTotalEnergyDeposit() << " Map " << (it != mapLV_.end());
108 #endif
109  energy += (aStep->GetPreStepPoint()->GetKineticEnergy() / CLHEP::GeV);
110  } else {
111  time = (aStep->GetPostStepPoint()->GetGlobalTime());
112  copy = (unsigned int)(touchable->GetReplicaNumber(0) + 1000 * touchable->GetReplicaNumber(1));
113  }
114  if (it != mapLV_.end()) {
115  storeInfo(it, plv, copy, time, energy, true);
116  } else if (topLV_ != nullptr) {
117  auto itr = findLV(topLV_);
118  if (itr != mapLV_.end()) {
119  storeInfo(itr, topLV_, copy, time, energy, true);
120  }
121  }
122  } // if (curSD==NULL)
123 
124  // Now for the mother volumes
125  int level = (touchable->GetHistoryDepth());
126  if (level > 0) {
127  double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV;
128  double time = (aStep->GetTrack()->GetGlobalTime());
129 
130  for (int i = level; i > 0; --i) {
131  G4LogicalVolume* plv = touchable->GetVolume(i)->GetLogicalVolume();
132  auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("HGCSim") << "Level: " << level << ":" << i << " " << plv->GetName() << " flag in the List "
135  << (it != mapLV_.end());
136 #endif
137  if (it != mapLV_.end()) {
138  unsigned int copy =
139  (i == level) ? 0
140  : (unsigned int)(touchable->GetReplicaNumber(i) + 1000 * touchable->GetReplicaNumber(i + 1));
141  storeInfo(it, plv, copy, time, energy, false);
142  }
143  }
144  }
145  } // if (aStep != NULL)
146 
147 } // end update aStep

References filterCSVwithJSON::copy, HCALHighEnergyHPDFilter_cfi::energy, findLV(), GeV, mps_fire::i, init_, createfilelist::int, personalPlayback::level, mapLV_, storeInfo(), ntuplemaker::time, and topLV_.

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

Member Data Documentation

◆ count_

unsigned int HGCPassive::count_
private

Definition at line 73 of file HGCPassive.h.

Referenced by update().

◆ init_

bool HGCPassive::init_
private

Definition at line 74 of file HGCPassive.h.

Referenced by update().

◆ LVNames_

std::vector<std::string> HGCPassive::LVNames_
private

Definition at line 66 of file HGCPassive.h.

Referenced by findLV(), HGCPassive(), and produce().

◆ mapLV_

std::map<G4LogicalVolume *, std::pair<unsigned int, std::string> > HGCPassive::mapLV_
private

Definition at line 69 of file HGCPassive.h.

Referenced by endOfEvent(), findLV(), and update().

◆ motherName_

std::string HGCPassive::motherName_
private

Definition at line 70 of file HGCPassive.h.

Referenced by findLV(), and HGCPassive().

◆ store_

std::map<std::pair<G4LogicalVolume *, unsigned int>, std::array<double, 3> > HGCPassive::store_
private

Definition at line 75 of file HGCPassive.h.

Referenced by endOfEvent(), storeInfo(), and update().

◆ topLV_

G4LogicalVolume* HGCPassive::topLV_
private

Definition at line 68 of file HGCPassive.h.

Referenced by findLV(), and update().

◆ topPV_

G4VPhysicalVolume* HGCPassive::topPV_
private

Definition at line 67 of file HGCPassive.h.

Referenced by update().

personalPlayback.level
level
Definition: personalPlayback.py:22
mps_fire.i
i
Definition: mps_fire.py:355
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
HGCPassive::topPV_
G4VPhysicalVolume * topPV_
Definition: HGCPassive.h:67
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
dqmdumpme.first
first
Definition: dqmdumpme.py:55
HGCPassive::motherName_
std::string motherName_
Definition: HGCPassive.h:70
HGCPassive::mapLV_
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:69
PassiveHit
Definition: PassiveHit.h:9
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
GeV
const double GeV
Definition: MathUtil.h:16
HGCPassive::init_
bool init_
Definition: HGCPassive.h:74
createfilelist.int
int
Definition: createfilelist.py:10
edm::PassiveHitContainer
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:100
edm::LogVerbatim
Definition: MessageLogger.h:297
HGCPassive::endOfEvent
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
Definition: HGCPassive.cc:151
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
HGCPassive::LVNames_
std::vector< std::string > LVNames_
Definition: HGCPassive.h:66
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
HGCPassive::getTopPV
G4VPhysicalVolume * getTopPV()
Definition: HGCPassive.cc:172
HGCPassive::storeInfo
void storeInfo(const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy, bool flag)
Definition: HGCPassive.cc:195
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HGCPassive::topLV_
G4LogicalVolume * topLV_
Definition: HGCPassive.h:68
ntuplemaker.time
time
Definition: ntuplemaker.py:310
crabWrapper.key
key
Definition: crabWrapper.py:19
HGCPassive::store_
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:75
hit
Definition: SiStripHitEffFromCalibTree.cc:88
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
HGCPassive::findLV
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:176
HGCPassive::count_
unsigned int count_
Definition: HGCPassive.h:73
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37