CMS 3D CMS Logo

List of all members | Public Member Functions | 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 &)
 
virtual ~HGCPassive ()
 
- 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 Member Functions

void endOfEvent (edm::PassiveHitContainer &hgcPH, unsigned int k)
 
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > >::iterator findLV (G4LogicalVolume *plv)
 
G4VPhysicalVolume * getTopPV ()
 
 HGCPassive (const HGCPassive &)
 
const HGCPassiveoperator= (const HGCPassive &)
 
void update (const BeginOfRun *run)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step)
 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::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
 
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 34 of file HGCPassive.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file HGCPassive.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), gen::k, LVNames_, and dataset::name.

24  : count_(0), init_(false) {
25 
26  edm::ParameterSet m_Passive = p.getParameter<edm::ParameterSet>("HGCPassive");
27  LVNames_ = m_Passive.getUntrackedParameter<std::vector<std::string> >("LVNames");
28 
29 #ifdef EDM_ML_DEBUG
30  unsigned int k(0);
31 #endif
32  for (const auto& name : LVNames_) {
33  produces<edm::PassiveHitContainer>(Form("%sPassiveHits",name.c_str()));
34 #ifdef EDM_ML_DEBUG
35  std::cout << "Collection name[" << k << "] " << name << std::endl;
36  ++k;
37 #endif
38  }
39 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > LVNames_
Definition: HGCPassive.h:62
int k[5][pyjets_maxn]
unsigned int count_
Definition: HGCPassive.h:67
bool init_
Definition: HGCPassive.h:68
HGCPassive::~HGCPassive ( )
virtual

Definition at line 41 of file HGCPassive.cc.

41  {
42 }
HGCPassive::HGCPassive ( const HGCPassive )
private

Member Function Documentation

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

Definition at line 127 of file HGCPassive.cc.

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

Referenced by produce().

127  {
128 #ifdef EDM_ML_DEBUG
129  unsigned int kount(0);
130 #endif
131  for (const auto& element : store_) {
132  G4LogicalVolume* lv = (element.first).first;
133  auto it = mapLV_.find(lv);
134  if (it != mapLV_.end()) {
135  if ((it->second).first == k) {
136  PassiveHit hit((it->second).second,(element.first).second,
137  (element.second).second,(element.second).first);
138  hgcPH.push_back(hit);
139 #ifdef EDM_ML_DEBUG
140  std::cout << "HGCPassive[" << k << "] Hit[" << kount << "] " << hit
141  << std::endl;
142  ++kount;
143 #endif
144  }
145  }
146  }
147 }
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
Definition: HGCPassive.h:69
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:64
int k[5][pyjets_maxn]
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > >::iterator HGCPassive::findLV ( G4LogicalVolume *  plv)
private

Definition at line 153 of file HGCPassive.cc.

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

Referenced by update().

153  {
154  auto itr = mapLV_.find(plv);
155  if (itr == mapLV_.end()) {
156  std::string name = plv->GetName();
157  for (unsigned int k=0; k<LVNames_.size(); ++k) {
158  if (name.find(LVNames_[k]) != std::string::npos) {
159  mapLV_[plv] = std::pair<unsigned int,std::string>(k,name);
160  itr = mapLV_.find(plv);
161  break;
162  }
163  }
164  }
165  return itr;
166 }
std::vector< std::string > LVNames_
Definition: HGCPassive.h:62
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:64
int k[5][pyjets_maxn]
G4VPhysicalVolume * HGCPassive::getTopPV ( )
private

Definition at line 149 of file HGCPassive.cc.

Referenced by update().

149  {
150  return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
151 }
const HGCPassive& HGCPassive::operator= ( const HGCPassive )
private
void HGCPassive::produce ( edm::Event e,
const edm::EventSetup  
)
virtual

Implements SimProducer.

Definition at line 44 of file HGCPassive.cc.

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

44  {
45 
46  for (unsigned int k=0; k<LVNames_.size(); ++k) {
47  std::unique_ptr<edm::PassiveHitContainer> hgcPH(new edm::PassiveHitContainer);
48  endOfEvent(*hgcPH, k);
49  e.put(std::move(hgcPH),Form("%sPassiveHits",LVNames_[k].c_str()));
50  }
51 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
Definition: HGCPassive.cc:127
std::vector< std::string > LVNames_
Definition: HGCPassive.h:62
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:57
int k[5][pyjets_maxn]
def move(src, dest)
Definition: eostools.py:510
void HGCPassive::update ( const BeginOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 53 of file HGCPassive.cc.

References gather_cfg::cout, 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().

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

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 
80  int iev = (*evt)()->GetEventID();
81  edm::LogInfo("ValidHGCal") << "HGCPassive: =====> Begin event = "
82  << iev << std::endl;
83 
84  ++count_;
85  store_.clear();
86 }
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
Definition: HGCPassive.h:69
unsigned int count_
Definition: HGCPassive.h:67
void HGCPassive::update ( const G4Step *  )
privatevirtual

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(), gather_cfg::cout, findLV(), plotBeamSpotDB::first, init_, createfilelist::int, crabWrapper::key, mapLV_, NULL, edm::second(), store_, and ntuplemaker::time.

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 
91  if (aStep != NULL) {
92 
93  G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
94  if (curSD==NULL) {
95 
96  G4TouchableHistory* touchable = (G4TouchableHistory*)aStep->GetPreStepPoint()->GetTouchable();
97  G4LogicalVolume* plv = (G4LogicalVolume*)touchable->GetVolume()->GetLogicalVolume();
98  auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
99  if (it != mapLV_.end()) {
100  unsigned int copy = (unsigned int)(touchable->GetReplicaNumber(0) +
101  1000*touchable->GetReplicaNumber(1));
102  std::pair<G4LogicalVolume*,unsigned int> key(plv,copy);
103  auto itr = store_.find(key);
104  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
105  if (itr == store_.end()) {
106  store_[key] = std::pair<double,double>(time,0.0);
107  itr = store_.find(key);
108  }
109  double edeposit = aStep->GetTotalEnergyDeposit();
110  (itr->second).second += edeposit;
111 #ifdef EDM_ML_DEBUG
112  std::cout << "HGCPassive: Element " << (it->second).first << ":"
113  << (it->second).second << ":" << copy << " T "
114  << (itr->second).first << " E " << (itr->second).second
115  << std::endl;
116 #endif
117  }//if( it != map.end() )
118  }//if (curSD==NULL)
119  }//if (aStep != NULL)
120 
121 
122 }//end update aStep
#define NULL
Definition: scimark2.h:8
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
Definition: HGCPassive.h:69
U second(std::pair< T, U > const &p)
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:64
bool init_
Definition: HGCPassive.h:68
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > >::iterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:153

Member Data Documentation

unsigned int HGCPassive::count_
private

Definition at line 67 of file HGCPassive.h.

Referenced by update().

bool HGCPassive::init_
private

Definition at line 68 of file HGCPassive.h.

Referenced by update().

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

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

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

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

Definition at line 69 of file HGCPassive.h.

Referenced by endOfEvent(), and update().

G4VPhysicalVolume* HGCPassive::topPV_
private

Definition at line 63 of file HGCPassive.h.

Referenced by update().