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.

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

Definition at line 42 of file HGCPassive.cc.

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

Member Function Documentation

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

Definition at line 167 of file HGCPassive.cc.

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

Referenced by produce().

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

Definition at line 190 of file HGCPassive.cc.

Referenced by update().

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

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:136
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
Definition: HGCPassive.cc:167
std::vector< std::string > LVNames_
Definition: HGCPassive.h:69
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:60
int k[5][pyjets_maxn]
def move(src, dest)
Definition: eostools.py:510
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 
216  std::pair<G4LogicalVolume*,unsigned int> key(plv,copy);
217  auto itr = store_.find(key);
218  double ee = (flag) ? energy : 0;
219  if (itr == store_.end()) {
220  store_[key] = { {time, energy, energy} };
221  } else {
222  (itr->second)[1] += ee;
223  (itr->second)[2] += energy;
224  }
225 #ifdef EDM_ML_DEBUG
226  itr = store_.find(key);
227  edm::LogVerbatim("ValidHGCal") << "HGCPassive: Element "
228  << (it->second).first << ":"
229  << (it->second).second << ":" << copy << " T "
230  << (itr->second)[0] << " E "
231  << (itr->second)[1] << ":"
232  << (itr->second)[2];
233 #endif
234 }
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 53 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().

53  {
54 
55  topPV_ = getTopPV();
56  if (topPV_ == nullptr) {
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  edm::LogVerbatim("ValidHGCal") << "HGCPassive::Finds " << mapLV_.size()
67  << " logical volumes";
68  unsigned int k(0);
69  for (const auto& lvs : mapLV_) {
70  edm::LogVerbatim("ValidHGCal") << "Entry[" << k << "] " << lvs.first
71  << ": (" << (lvs.second).first << ", "
72  << (lvs.second).second << ")";
73  ++k;
74  }
75 #endif
76  }
77 }
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:194
G4VPhysicalVolume * topPV_
Definition: HGCPassive.h:70
G4VPhysicalVolume * getTopPV()
Definition: HGCPassive.cc:190
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:72
int k[5][pyjets_maxn]
bool init_
Definition: HGCPassive.h:77
void HGCPassive::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

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

80  {
81 
82  int iev = (*evt)()->GetEventID();
83  edm::LogVerbatim("ValidHGCal") << "HGCPassive: =====> Begin event = "
84  << iev << std::endl;
85 
86  ++count_;
87  store_.clear();
88 }
unsigned int count_
Definition: HGCPassive.h:76
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 91 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().

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

Member Data Documentation

unsigned int HGCPassive::count_
private

Definition at line 76 of file HGCPassive.h.

Referenced by update().

bool HGCPassive::init_
private

Definition at line 77 of file HGCPassive.h.

Referenced by update().

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

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

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

std::string HGCPassive::motherName_
private

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

Referenced by findLV(), and update().

G4VPhysicalVolume* HGCPassive::topPV_
private

Definition at line 70 of file HGCPassive.h.

Referenced by update().