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 BeginOfRun *run) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt) 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

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::HGCPassive ( const edm::ParameterSet p)

Definition at line 22 of file HGCPassive.cc.

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

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("ValidHGCal") << "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("ValidHGCal") << "Collection name[" << k << "] " << name;
35  ++k;
36 #endif
37  }
38 }
T getParameter(std::string const &) const
G4LogicalVolume * topLV_
Definition: HGCPassive.h:68
G4VPhysicalVolume * topPV_
Definition: HGCPassive.h:67
std::vector< std::string > LVNames_
Definition: HGCPassive.h:66
std::string motherName_
Definition: HGCPassive.h:70
unsigned int count_
Definition: HGCPassive.h:73
bool init_
Definition: HGCPassive.h:74
HGCPassive::~HGCPassive ( )
override

Definition at line 40 of file HGCPassive.cc.

40 {}
HGCPassive::HGCPassive ( const HGCPassive )
privatedelete

Member Function Documentation

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

Definition at line 151 of file HGCPassive.cc.

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

Referenced by produce().

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("ValidHGCal") << "HGCPassive[" << k << "] Hit[" << kount << "] " << hit;
165  ++kount;
166 #endif
167  }
168  }
169  }
170 }
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:75
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:69
HGCPassive::volumeIterator HGCPassive::findLV ( G4LogicalVolume *  plv)
private

Definition at line 176 of file HGCPassive.cc.

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

Referenced by update().

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 }
G4LogicalVolume * topLV_
Definition: HGCPassive.h:68
std::vector< std::string > LVNames_
Definition: HGCPassive.h:66
std::string motherName_
Definition: HGCPassive.h:70
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:69
G4VPhysicalVolume * HGCPassive::getTopPV ( )
private

Definition at line 172 of file HGCPassive.cc.

Referenced by update().

172  {
173  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
174 }
const HGCPassive& HGCPassive::operator= ( const HGCPassive )
privatedelete
void HGCPassive::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 42 of file HGCPassive.cc.

References endOfEvent(), dqmdumpme::k, LVNames_, eostools::move(), and edm::Event::put().

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
Definition: HGCPassive.cc:151
std::vector< std::string > LVNames_
Definition: HGCPassive.h:66
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:75
def move(src, dest)
Definition: eostools.py:511
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.

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

Referenced by update().

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("ValidHGCal") << "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 }
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:75
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.

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

50  {
51  topPV_ = getTopPV();
52  if (topPV_ == nullptr) {
53  edm::LogWarning("HGCPassive") << "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("ValidHGCal") << "HGCPassive::Finds " << mapLV_.size() << " logical volumes";
63  unsigned int k(0);
64  for (const auto& lvs : mapLV_) {
65  edm::LogVerbatim("ValidHGCal") << "Entry[" << k << "] " << lvs.first << ": (" << (lvs.second).first << ", "
66  << (lvs.second).second << ")";
67  ++k;
68  }
69 #endif
70  }
71 }
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:176
G4VPhysicalVolume * topPV_
Definition: HGCPassive.h:67
G4VPhysicalVolume * getTopPV()
Definition: HGCPassive.cc:172
bool init_
Definition: HGCPassive.h:74
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:69
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.

References count_, and store_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

74  {
75  int iev = (*evt)()->GetEventID();
76  edm::LogVerbatim("ValidHGCal") << "HGCPassive: =====> Begin event = " << iev << std::endl;
77 
78  ++count_;
79  store_.clear();
80 }
unsigned int count_
Definition: HGCPassive.h:73
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:75
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.

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

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("ValidHGCal") << 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 "
104  << aStep->GetTrack()->GetVolume() << ":" << aStep->GetTrack()->GetNextVolume()
105  << " Status " << 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("ValidHGCal") << "Level: " << ii << ":" << 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
const double GeV
Definition: MathUtil.h:16
void storeInfo(const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy, bool flag)
Definition: HGCPassive.cc:195
G4LogicalVolume * topLV_
Definition: HGCPassive.h:68
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:176
ii
Definition: cuy.py:590
bool init_
Definition: HGCPassive.h:74
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:69

Member Data Documentation

unsigned int HGCPassive::count_
private

Definition at line 73 of file HGCPassive.h.

Referenced by update().

bool HGCPassive::init_
private

Definition at line 74 of file HGCPassive.h.

Referenced by update().

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

Definition at line 66 of file HGCPassive.h.

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

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().

std::string HGCPassive::motherName_
private

Definition at line 70 of file HGCPassive.h.

Referenced by findLV(), and HGCPassive().

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().

G4LogicalVolume* HGCPassive::topLV_
private

Definition at line 68 of file HGCPassive.h.

Referenced by findLV(), and update().

G4VPhysicalVolume* HGCPassive::topPV_
private

Definition at line 67 of file HGCPassive.h.

Referenced by update().