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 &)
 
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 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 &)
 
const HGCPassiveoperator= (const HGCPassive &)
 
void storeInfo (const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy)
 
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::string motherName_
 
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > 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 36 of file HGCPassive.h.

Member Typedef Documentation

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

Definition at line 60 of file HGCPassive.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file HGCPassive.cc.

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

22  : topPV_(0), topLV_(0),
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  std::cout << "Name of the mother volume " << motherName_ << std::endl;
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  std::cout << "Collection name[" << k << "] " << name << std::endl;
37  ++k;
38 #endif
39  }
40 }
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 ( )
virtual

Definition at line 42 of file HGCPassive.cc.

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

Member Function Documentation

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

Definition at line 150 of file HGCPassive.cc.

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

Referenced by produce().

150  {
151 #ifdef EDM_ML_DEBUG
152  unsigned int kount(0);
153 #endif
154  for (const auto& element : store_) {
155  G4LogicalVolume* lv = (element.first).first;
156  auto it = mapLV_.find(lv);
157  if (it != mapLV_.end()) {
158  if ((it->second).first == k) {
159  PassiveHit hit((it->second).second,(element.first).second,
160  (element.second).second,(element.second).first);
161  hgcPH.push_back(hit);
162 #ifdef EDM_ML_DEBUG
163  std::cout << "HGCPassive[" << k << "] Hit[" << kount << "] " << hit
164  << std::endl;
165  ++kount;
166 #endif
167  }
168  }
169  }
170 }
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
Definition: HGCPassive.h:77
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71
int k[5][pyjets_maxn]
HGCPassive::volumeIterator HGCPassive::findLV ( G4LogicalVolume *  plv)
private

Definition at line 176 of file HGCPassive.cc.

References gen::k, LVNames_, mapLV_, motherName_, dataset::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_ == 0) {
189  if (std::string(plv->GetName()) == motherName_) topLV_ = plv;
190  }
191  return itr;
192 }
G4LogicalVolume * topLV_
Definition: HGCPassive.h:70
std::vector< std::string > LVNames_
Definition: HGCPassive.h:68
std::string motherName_
Definition: HGCPassive.h:72
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71
int k[5][pyjets_maxn]
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 )
private
void HGCPassive::produce ( edm::Event e,
const edm::EventSetup  
)
virtual

Implements SimProducer.

Definition at line 45 of file HGCPassive.cc.

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

45  {
46 
47  for (unsigned int k=0; k<LVNames_.size(); ++k) {
48  std::unique_ptr<edm::PassiveHitContainer> hgcPH(new edm::PassiveHitContainer);
49  endOfEvent(*hgcPH, k);
50  e.put(std::move(hgcPH),Form("%sPassiveHits",LVNames_[k].c_str()));
51  }
52 }
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:150
std::vector< std::string > LVNames_
Definition: HGCPassive.h:68
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:57
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 
)
private

Definition at line 194 of file HGCPassive.cc.

References gather_cfg::cout, DEFINE_SIMWATCHER, plotBeamSpotDB::first, crabWrapper::key, edm::second(), store_, and ntuplemaker::time.

Referenced by update().

196  {
197 
198  std::pair<G4LogicalVolume*,unsigned int> key(plv,copy);
199  auto itr = store_.find(key);
200  if (itr == store_.end()) {
201  store_[key] = std::pair<double,double>(time,energy);
202  } else {
203  (itr->second).second += energy;
204  }
205 #ifdef EDM_ML_DEBUG
206  std::cout << "HGCPassive: Element " << (it->second).first << ":"
207  << (it->second).second << ":" << copy << " T "
208  << (itr->second).first << " E " << (itr->second).second
209  << std::endl;
210 #endif
211 }
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
Definition: HGCPassive.h:77
U second(std::pair< T, U > const &p)
void HGCPassive::update ( const BeginOfRun )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

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

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

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

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 90 of file HGCPassive.cc.

References popcon2dropbox::copy(), gather_cfg::cout, findLV(), GeV, init_, createfilelist::int, mapLV_, NULL, 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().

90  {
91 
92  if (aStep != NULL) {
93 
94  G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
95  if (curSD==NULL) {
96 
97  G4TouchableHistory* touchable = (G4TouchableHistory*)aStep->GetPreStepPoint()->GetTouchable();
98  G4LogicalVolume* plv = (G4LogicalVolume*)touchable->GetVolume()->GetLogicalVolume();
99  auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
100  if (((aStep->GetPostStepPoint() == 0) ||
101  (aStep->GetTrack()->GetNextVolume() == 0)) &&
102  (aStep->IsLastStepInVolume())) {
103 #ifdef EDM_ML_DEBUG
104  std::cout << plv->GetName() << " F|L Step "
105  << aStep->IsFirstStepInVolume() << ":"
106  << aStep->IsLastStepInVolume() << " Position"
107  << aStep->GetPreStepPoint()->GetPosition() << " Track "
108  << aStep->GetTrack()->GetDefinition()->GetParticleName()
109  << " at" << aStep->GetTrack()->GetPosition() << " Volume "
110  << aStep->GetTrack()->GetVolume() << ":"
111  << aStep->GetTrack()->GetNextVolume() << " Status "
112  << aStep->GetTrack()->GetTrackStatus() << " KE "
113  << aStep->GetTrack()->GetKineticEnergy() << " Deposit "
114  << aStep->GetTotalEnergyDeposit() << " Map "
115  << (it != mapLV_.end()) << std::endl;
116 #endif
117  double time = aStep->GetTrack()->GetGlobalTime();
118  double energy = (aStep->GetPreStepPoint()->GetKineticEnergy() +
119  aStep->GetTotalEnergyDeposit())/CLHEP::GeV;
120  if (it != mapLV_.end()) {
121  storeInfo(it, plv, 0, time, energy);
122  } else if (topLV_ != 0) {
123  auto itr = (init_) ? mapLV_.find(topLV_) : findLV(topLV_);
124  if (itr != mapLV_.end()) {
125  storeInfo(itr, topLV_, 0, time, energy);
126  }
127  }
128  } else if (it != mapLV_.end()) {
129  unsigned int copy = (unsigned int)(touchable->GetReplicaNumber(0) +
130  1000*touchable->GetReplicaNumber(1));
131  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
132  double edeposit = (aStep->GetTotalEnergyDeposit())/CLHEP::GeV;
133  storeInfo(it, plv, copy, time, edeposit);
134  } else if (topLV_ != 0) {
135  auto itr = findLV(topLV_);
136  if (itr != mapLV_.end()) {
137  double time = (aStep->GetPostStepPoint()->GetGlobalTime());
138  double edeposit = (aStep->GetTotalEnergyDeposit())/CLHEP::GeV;
139  storeInfo(itr, topLV_, 100, time, edeposit);
140  }
141  }
142  }//if (curSD==NULL)
143  }//if (aStep != NULL)
144 
145 
146 }//end update aStep
const double GeV
Definition: MathUtil.h:16
G4LogicalVolume * topLV_
Definition: HGCPassive.h:70
#define NULL
Definition: scimark2.h:8
volumeIterator findLV(G4LogicalVolume *plv)
Definition: HGCPassive.cc:176
void storeInfo(const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy)
Definition: HGCPassive.cc:194
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
Definition: HGCPassive.h:71
bool init_
Definition: HGCPassive.h:76

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::pair<double,double> > HGCPassive::store_
private

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