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::ProducerBase &iProd)
 
 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 61 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(), gen::k, LVNames_, motherName_, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

23  : topPV_(nullptr), topLV_(nullptr), count_(0), init_(false) {
24  edm::ParameterSet m_Passive = p.getParameter<edm::ParameterSet>("HGCPassive");
25  LVNames_ = m_Passive.getParameter<std::vector<std::string> >("LVNames");
26  motherName_ = m_Passive.getParameter<std::string>("MotherName");
27 
28 #ifdef EDM_ML_DEBUG
29  edm::LogVerbatim("ValidHGCal") << "Name of the mother volume " << motherName_;
30  unsigned k(0);
31 #endif
32  for (auto name : LVNames_) {
33  produces<edm::PassiveHitContainer>(Form("%sPassiveHits", name.c_str()));
34 #ifdef EDM_ML_DEBUG
35  edm::LogVerbatim("ValidHGCal") << "Collection name[" << k << "] " << name;
36  ++k;
37 #endif
38  }
39 }
T getParameter(std::string const &) const
G4LogicalVolume * topLV_
Definition: HGCPassive.h:70
G4VPhysicalVolume * topPV_
Definition: HGCPassive.h:69
std::vector< std::string > LVNames_
Definition: HGCPassive.h:68
std::string motherName_
Definition: HGCPassive.h:72
int k[5][pyjets_maxn]
unsigned int count_
Definition: HGCPassive.h:75
bool init_
Definition: HGCPassive.h:76
HGCPassive::~HGCPassive ( )
override

Definition at line 41 of file HGCPassive.cc.

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

Member Function Documentation

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

Definition at line 165 of file HGCPassive.cc.

References plotBeamSpotDB::first, gen::k, mapLV_, and store_.

Referenced by produce().

165  {
166 #ifdef EDM_ML_DEBUG
167  unsigned int kount(0);
168 #endif
169  for (const auto& element : store_) {
170  G4LogicalVolume* lv = (element.first).first;
171  auto it = mapLV_.find(lv);
172  if (it != mapLV_.end()) {
173  if ((it->second).first == k) {
174  PassiveHit hit((it->second).second, (element.first).second,
175  (element.second)[1], (element.second)[2],
176  (element.second)[0]);
177  hgcPH.push_back(hit);
178 #ifdef EDM_ML_DEBUG
179  edm::LogVerbatim("ValidHGCal")
180  << "HGCPassive[" << k << "] Hit[" << kount << "] " << hit;
181  ++kount;
182 #endif
183  }
184  }
185  }
186 }
int k[5][pyjets_maxn]
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:78
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71
HGCPassive::volumeIterator HGCPassive::findLV ( G4LogicalVolume *  plv)
private

Definition at line 194 of file HGCPassive.cc.

References gen::k, LVNames_, mapLV_, motherName_, dataset::name, AlCaHLTBitMon_QueryRunRegistry::string, and topLV_.

Referenced by update().

194  {
195  auto itr = mapLV_.find(plv);
196  if (itr == mapLV_.end()) {
197  std::string name = plv->GetName();
198  for (unsigned int k = 0; k < LVNames_.size(); ++k) {
199  if (name.find(LVNames_[k]) != std::string::npos) {
200  mapLV_[plv] = std::pair<unsigned int, std::string>(k, name);
201  itr = mapLV_.find(plv);
202  break;
203  }
204  }
205  }
206  if (topLV_ == nullptr) {
207  if (std::string(plv->GetName()) == motherName_) topLV_ = plv;
208  }
209  return itr;
210 }
G4LogicalVolume * topLV_
Definition: HGCPassive.h:70
std::vector< std::string > LVNames_
Definition: HGCPassive.h:68
std::string motherName_
Definition: HGCPassive.h:72
int k[5][pyjets_maxn]
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71
G4VPhysicalVolume * HGCPassive::getTopPV ( )
private

Definition at line 188 of file HGCPassive.cc.

Referenced by update().

188  {
189  return G4TransportationManager::GetTransportationManager()
190  ->GetNavigatorForTracking()
191  ->GetWorldVolume();
192 }
const HGCPassive& HGCPassive::operator= ( const HGCPassive )
privatedelete
void HGCPassive::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 43 of file HGCPassive.cc.

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

43  {
44  for (unsigned int k = 0; k < LVNames_.size(); ++k) {
45  std::unique_ptr<edm::PassiveHitContainer> hgcPH(
47  endOfEvent(*hgcPH, k);
48  e.put(std::move(hgcPH), Form("%sPassiveHits", LVNames_[k].c_str()));
49  }
50 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
Definition: HGCPassive.cc:165
std::vector< std::string > LVNames_
Definition: HGCPassive.h:68
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:58
int k[5][pyjets_maxn]
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 212 of file HGCPassive.cc.

References DEFINE_SIMWATCHER, plotBeamSpotDB::first, RemoveAddSevLevel::flag, crabWrapper::key, store_, and ntuplemaker::time.

Referenced by update().

214  {
215  std::pair<G4LogicalVolume*, unsigned int> key(plv, copy);
216  auto itr = store_.find(key);
217  double ee = (flag) ? energy : 0;
218  if (itr == store_.end()) {
219  store_[key] = {{time, energy, energy}};
220  } else {
221  (itr->second)[1] += ee;
222  (itr->second)[2] += energy;
223  }
224 #ifdef EDM_ML_DEBUG
225  itr = store_.find(key);
226  edm::LogVerbatim("ValidHGCal")
227  << "HGCPassive: Element " << (it->second).first << ":"
228  << (it->second).second << ":" << copy << " T " << (itr->second)[0]
229  << " E " << (itr->second)[1] << ":" << (itr->second)[2];
230 #endif
231 }
def copy(args, dbName)
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:78
void HGCPassive::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 52 of file HGCPassive.cc.

References findLV(), plotBeamSpotDB::first, getTopPV(), init_, gen::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().

52  {
53  topPV_ = getTopPV();
54  if (topPV_ == nullptr) {
55  edm::LogWarning("HGCPassive") << "Cannot find top level volume\n";
56  } else {
57  init_ = true;
58  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
59  for (auto lvcite : *lvs) {
60  findLV(lvcite);
61  }
62 
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("ValidHGCal")
65  << "HGCPassive::Finds " << mapLV_.size() << " logical volumes";
66  unsigned int k(0);
67  for (const auto& lvs : mapLV_) {
68  edm::LogVerbatim("ValidHGCal")
69  << "Entry[" << k << "] " << lvs.first << ": (" << (lvs.second).first
70  << ", " << (lvs.second).second << ")";
71  ++k;
72  }
73 #endif
74  }
75 }
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:194
G4VPhysicalVolume * topPV_
Definition: HGCPassive.h:69
G4VPhysicalVolume * getTopPV()
Definition: HGCPassive.cc:188
int k[5][pyjets_maxn]
bool init_
Definition: HGCPassive.h:76
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71
void HGCPassive::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 78 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().

78  {
79  int iev = (*evt)()->GetEventID();
80  edm::LogVerbatim("ValidHGCal")
81  << "HGCPassive: =====> Begin event = " << iev << std::endl;
82 
83  ++count_;
84  store_.clear();
85 }
unsigned int count_
Definition: HGCPassive.h:75
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
Definition: HGCPassive.h:78
void HGCPassive::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 89 of file HGCPassive.cc.

References popcon2dropbox::copy(), findLV(), GeV, mps_fire::i, cuy::ii, init_, createfilelist::int, hcalDigis_cfi::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().

89  {
90  if (aStep != nullptr) {
91  G4VSensitiveDetector* curSD =
92  aStep->GetPreStepPoint()->GetSensitiveDetector();
93  const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();
94 
95  if (curSD == nullptr) {
96  G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume();
97  auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
98  double time = aStep->GetTrack()->GetGlobalTime();
99  double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV;
100 
101  unsigned int copy(0);
102  if (((aStep->GetPostStepPoint() == nullptr) ||
103  (aStep->GetTrack()->GetNextVolume() == nullptr)) &&
104  (aStep->IsLastStepInVolume())) {
105 #ifdef EDM_ML_DEBUG
106  edm::LogVerbatim("ValidHGCal")
107  << plv->GetName() << " F|L Step " << aStep->IsFirstStepInVolume()
108  << ":" << aStep->IsLastStepInVolume() << " Position"
109  << aStep->GetPreStepPoint()->GetPosition() << " Track "
110  << aStep->GetTrack()->GetDefinition()->GetParticleName() << " at"
111  << aStep->GetTrack()->GetPosition() << " Volume "
112  << aStep->GetTrack()->GetVolume() << ":"
113  << aStep->GetTrack()->GetNextVolume() << " Status "
114  << aStep->GetTrack()->GetTrackStatus() << " KE "
115  << aStep->GetTrack()->GetKineticEnergy() << " Deposit "
116  << aStep->GetTotalEnergyDeposit() << " Map "
117  << (it != mapLV_.end());
118 #endif
119  energy += (aStep->GetPreStepPoint()->GetKineticEnergy() / CLHEP::GeV);
120  } else {
121  time = (aStep->GetPostStepPoint()->GetGlobalTime());
122  copy = (unsigned int)(touchable->GetReplicaNumber(0) +
123  1000 * touchable->GetReplicaNumber(1));
124  }
125  if (it != mapLV_.end()) {
126  storeInfo(it, plv, copy, time, energy, true);
127  } else if (topLV_ != nullptr) {
128  auto itr = findLV(topLV_);
129  if (itr != mapLV_.end()) {
130  storeInfo(itr, topLV_, copy, time, energy, true);
131  }
132  }
133  } // if (curSD==NULL)
134 
135  // Now for the mother volumes
136  int level = (touchable->GetHistoryDepth());
137  if (level > 0) {
138  double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV;
139  double time = (aStep->GetTrack()->GetGlobalTime());
140 
141  for (int i = level; i > 0; --i) {
142  G4LogicalVolume* plv = touchable->GetVolume(i)->GetLogicalVolume();
143  auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
144 #ifdef EDM_ML_DEBUG
145  edm::LogVerbatim("ValidHGCal")
146  << "Level: " << ii << ":" << i << " " << plv->GetName()
147  << " flag in the List " << (it != mapLV_.end());
148 #endif
149  if (it != mapLV_.end()) {
150  unsigned int copy =
151  (i == level)
152  ? 0
153  : (unsigned int)(touchable->GetReplicaNumber(i) +
154  1000 * touchable->GetReplicaNumber(i + 1));
155  storeInfo(it, plv, copy, time, energy, false);
156  }
157  }
158  }
159  } // if (aStep != NULL)
160 
161 } // 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:212
def copy(args, dbName)
G4LogicalVolume * topLV_
Definition: HGCPassive.h:70
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:194
ii
Definition: cuy.py:590
bool init_
Definition: HGCPassive.h:76
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71

Member Data Documentation

unsigned int HGCPassive::count_
private

Definition at line 75 of file HGCPassive.h.

Referenced by update().

bool HGCPassive::init_
private

Definition at line 76 of file HGCPassive.h.

Referenced by update().

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

Definition at line 68 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 71 of file HGCPassive.h.

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

std::string HGCPassive::motherName_
private

Definition at line 72 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 78 of file HGCPassive.h.

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

G4LogicalVolume* HGCPassive::topLV_
private

Definition at line 70 of file HGCPassive.h.

Referenced by findLV(), and update().

G4VPhysicalVolume* HGCPassive::topPV_
private

Definition at line 69 of file HGCPassive.h.

Referenced by update().