CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
CaloSteppingAction Class Reference

#include <CaloSteppingAction.h>

Inheritance diagram for CaloSteppingAction:
SimProducer Observer< const BeginOfJob * > Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const EndOfEvent * > Observer< const G4Step * > SimWatcher

Public Member Functions

 CaloSteppingAction (const edm::ParameterSet &p)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~CaloSteppingAction () 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 BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob * iT)
 
virtual ~Observer ()
 
- 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 EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Member Functions

double curve_LY (double crystalLength, double crystalDepth) const
 
void fillHit (uint32_t id, double dE, double time, int primID, uint16_t depth, double em, int flag)
 
void fillHits (edm::PCaloHitContainer &cc, int type)
 
double getBirkHC (double dE, double step, double chg, double dens) const
 
double getBirkL3 (double dE, double step, double chg, double dens) const
 
uint16_t getDepth (bool flag, double crystalDepth, double radl) const
 
uint32_t getDetIDHC (int det, int lay, int depth, const math::XYZVectorD &pos) const
 
void NaNTrap (const G4Step *) const
 
void saveHits (int flag)
 
void update (const BeginOfJob *job) override
 This routine will be called when the appropriate signal arrives. More...
 
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...
 
void update (const EndOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

double birkC1EC_
 
double birkC1HC_
 
double birkC2HC_
 
double birkC3HC_
 
double birkCutEC_
 
double birkSlopeEC_
 
int count_
 
std::unique_ptr< EcalBarrelNumberingSchemeebNumberingScheme_
 
std::unique_ptr< EcalEndcapNumberingSchemeeeNumberingScheme_
 
int eventID_
 
std::unique_ptr< HcalNumberingFromPShcNumberingPS_
 
std::unique_ptr< HcalNumberingSchemehcNumberingScheme_
 
std::map< std::pair< int, CaloHitID >, CaloGVHithitMap_ [nSD_]
 
std::vector< std::string > nameEBSD_
 
std::vector< std::string > nameEESD_
 
std::vector< std::string > nameHCSD_
 
std::vector< std::string > nameHitC_
 
std::unique_ptr< CaloSlaveSDslave_ [nSD_]
 
double slopeLY_
 
std::vector< const G4LogicalVolume * > volEBSD_
 
std::vector< const G4LogicalVolume * > volEESD_
 
std::vector< const G4LogicalVolume * > volHCSD_
 
std::map< const G4LogicalVolume *, double > xtalMap_
 

Static Private Attributes

static const int nSD_ = 3
 

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 50 of file CaloSteppingAction.h.

Constructor & Destructor Documentation

CaloSteppingAction::CaloSteppingAction ( const edm::ParameterSet p)

Definition at line 33 of file CaloSteppingAction.cc.

References birkC1EC_, birkC1HC_, birkC2HC_, birkC3HC_, birkCutEC_, birkSlopeEC_, ebNumberingScheme_, eeNumberingScheme_, g, edm::ParameterSet::getParameter(), hcNumberingPS_, hcNumberingScheme_, gen::k, MeV, nameEBSD_, nameEESD_, nameHCSD_, nameHitC_, nSD_, slave_, and slopeLY_.

33  : count_(0) {
34  edm::ParameterSet iC = p.getParameter<edm::ParameterSet>("CaloSteppingAction");
35  nameEBSD_ = iC.getParameter<std::vector<std::string> >("EBSDNames");
36  nameEESD_ = iC.getParameter<std::vector<std::string> >("EESDNames");
37  nameHCSD_ = iC.getParameter<std::vector<std::string> >("HCSDNames");
38  nameHitC_ = iC.getParameter<std::vector<std::string> >("HitCollNames");
39  slopeLY_ = iC.getParameter<double>("SlopeLightYield");
40  birkC1EC_ = iC.getParameter<double>("BirkC1EC") * (g / (MeV * cm2));
41  birkSlopeEC_ = iC.getParameter<double>("BirkSlopeEC");
42  birkCutEC_ = iC.getParameter<double>("BirkCutEC");
43  birkC1HC_ = iC.getParameter<double>("BirkC1HC") * (g / (MeV * cm2));
44  birkC2HC_ = iC.getParameter<double>("BirkC2HC");
45  birkC3HC_ = iC.getParameter<double>("BirkC3HC");
46 
47  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEBSD_.size() << " names for EB SD's";
48  for (unsigned int k = 0; k < nameEBSD_.size(); ++k)
49  edm::LogVerbatim("Step") << "[" << k << "] " << nameEBSD_[k];
50  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEESD_.size() << " names for EE SD's";
51  for (unsigned int k = 0; k < nameEESD_.size(); ++k)
52  edm::LogVerbatim("Step") << "[" << k << "] " << nameEESD_[k];
53  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameHCSD_.size() << " names for HC SD's";
54  for (unsigned int k = 0; k < nameHCSD_.size(); ++k)
55  edm::LogVerbatim("Step") << "[" << k << "] " << nameHCSD_[k];
56  edm::LogVerbatim("Step") << "CaloSteppingAction::Constants for ECAL: slope " << slopeLY_ << " Birk constants "
57  << birkC1EC_ << ":" << birkSlopeEC_ << ":" << birkCutEC_;
58  edm::LogVerbatim("Step") << "CaloSteppingAction::Constants for HCAL: Birk "
59  << "constants " << birkC1HC_ << ":" << birkC2HC_ << ":" << birkC3HC_;
60  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameHitC_.size() << " hit collections";
61  for (unsigned int k = 0; k < nameHitC_.size(); ++k)
62  edm::LogVerbatim("Step") << "[" << k << "] " << nameHitC_[k];
63 
64  ebNumberingScheme_ = std::make_unique<EcalBarrelNumberingScheme>();
65  eeNumberingScheme_ = std::make_unique<EcalEndcapNumberingScheme>();
66  hcNumberingPS_ = std::make_unique<HcalNumberingFromPS>(iC);
67  hcNumberingScheme_ = std::make_unique<HcalNumberingScheme>();
68 #ifdef HcalNumberingTest
69  hcNumbering_.reset(nullptr);
70 #endif
71  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
72  slave_[k] = std::make_unique<CaloSlaveSD>(nameHitC_[k]);
73  produces<edm::PCaloHitContainer>(nameHitC_[k]);
74  }
75 }
T getParameter(std::string const &) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
const double MeV
std::vector< std::string > nameHitC_
std::vector< std::string > nameHCSD_
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
int k[5][pyjets_maxn]
std::vector< std::string > nameEBSD_
std::unique_ptr< HcalNumberingFromPS > hcNumberingPS_
std::unique_ptr< HcalNumberingScheme > hcNumberingScheme_
std::unique_ptr< EcalBarrelNumberingScheme > ebNumberingScheme_
std::unique_ptr< EcalEndcapNumberingScheme > eeNumberingScheme_
std::vector< std::string > nameEESD_
static const int nSD_
CaloSteppingAction::~CaloSteppingAction ( )
override

Definition at line 77 of file CaloSteppingAction.cc.

References count_.

77  {
78  edm::LogVerbatim("Step") << "CaloSteppingAction: --------> Total number of "
79  << "selected entries : " << count_;
80 }

Member Function Documentation

double CaloSteppingAction::curve_LY ( double  crystalLength,
double  crystalDepth 
) const
private

Definition at line 298 of file CaloSteppingAction.cc.

References slopeLY_, and mps_merge::weight.

Referenced by update().

298  {
299  double weight = 1.;
300  double dapd = crystalLength - crystalDepth;
301  if (dapd >= -0.1 || dapd <= crystalLength + 0.1) {
302  if (dapd <= 100.)
303  weight = 1.0 + slopeLY_ - dapd * 0.01 * slopeLY_;
304 #ifdef EDM_ML_DEBUG
305  edm::LogVerbatim("Step") << "CaloSteppingAction::curve_LY " << crystalDepth << ":" << crystalLength << ":" << dapd
306  << ":" << weight;
307 #endif
308  } else {
309  edm::LogWarning("Step") << "CaloSteppingAction: light coll curve : wrong "
310  << "distance to APD " << dapd << " crlength = " << crystalLength
311  << " crystal Depth = " << crystalDepth << " weight = " << weight;
312  }
313  return weight;
314 }
Definition: weight.py:1
void CaloSteppingAction::fillHit ( uint32_t  id,
double  dE,
double  time,
int  primID,
uint16_t  depth,
double  em,
int  flag 
)
private

Definition at line 271 of file CaloSteppingAction.cc.

References CaloGVHit::addEnergyDeposit(), end, eventID_, RemoveAddSevLevel::flag, hitMap_, CaloGVHit::setEventID(), and CaloGVHit::setID().

Referenced by update().

271  {
272  CaloHitID currentID(id, time, primID, depth);
273  double edepEM = (em ? dE : 0);
274  double edepHAD = (em ? 0 : dE);
275  std::pair<int, CaloHitID> evID = std::make_pair(eventID_, currentID);
276  auto it = hitMap_[flag].find(evID);
277  if (it != hitMap_[flag].end()) {
278  (it->second).addEnergyDeposit(edepEM, edepHAD);
279  } else {
280  CaloGVHit aHit;
281  aHit.setEventID(eventID_);
282  aHit.setID(currentID);
283  aHit.addEnergyDeposit(edepEM, edepHAD);
284  hitMap_[flag][evID] = aHit;
285  }
286 }
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
void setID(uint32_t i, double d, int j, uint16_t k=0)
Definition: CaloGVHit.h:55
void setEventID(int id)
Definition: CaloGVHit.h:46
#define end
Definition: vmac.h:39
void addEnergyDeposit(double em, double hd)
Definition: CaloGVHit.cc:29
void CaloSteppingAction::fillHits ( edm::PCaloHitContainer cc,
int  type 
)
private

Definition at line 91 of file CaloSteppingAction.cc.

References slave_.

Referenced by produce().

91  {
92  edm::LogVerbatim("Step") << "CaloSteppingAction::fillHits for type " << type << " with "
93  << slave_[type].get()->hits().size() << " hits";
94  cc = slave_[type].get()->hits();
95  slave_[type].get()->Clean();
96 }
type
Definition: HCALResponse.h:21
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
double CaloSteppingAction::getBirkHC ( double  dE,
double  step,
double  chg,
double  dens 
) const
private

Definition at line 336 of file CaloSteppingAction.cc.

References funct::abs(), birkC1HC_, birkC2HC_, birkC3HC_, EnergyCorrector::c, and mps_merge::weight.

Referenced by update().

336  {
337  double weight = 1.;
338  if (charge != 0. && step > 0.) {
339  double dedx = dEStep / step;
340  double rkb = birkC1HC_ / density;
341  double c = birkC2HC_ * rkb * rkb;
342  if (std::abs(charge) >= 2.)
343  rkb /= birkC3HC_;
344  weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
345 #ifdef EDM_ML_DEBUG
346  edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkHC Charge " << charge << " dE/dx " << dedx << " Birk Const "
347  << rkb << ", " << c << " Weight = " << weight << " dE " << dEStep;
348 #endif
349  }
350  return weight;
351 }
Definition: weight.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
step
Definition: StallMonitor.cc:94
double CaloSteppingAction::getBirkL3 ( double  dE,
double  step,
double  chg,
double  dens 
) const
private

Definition at line 316 of file CaloSteppingAction.cc.

References birkC1EC_, birkCutEC_, birkSlopeEC_, cmsBatch::log, and mps_merge::weight.

Referenced by update().

316  {
317  double weight = 1.;
318  if (charge != 0. && step > 0.) {
319  double dedx = dEStep / step;
320  double rkb = birkC1EC_ / density;
321  if (dedx > 0) {
322  weight = 1. - birkSlopeEC_ * log(rkb * dedx);
323  if (weight < birkCutEC_)
324  weight = birkCutEC_;
325  else if (weight > 1.)
326  weight = 1.;
327  }
328 #ifdef EDM_ML_DEBUG
329  edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkL3 Charge " << charge << " dE/dx " << dedx << " Birk Const "
330  << rkb << " Weight = " << weight << " dE " << dEStep << " step " << step;
331 #endif
332  }
333  return weight;
334 }
Definition: weight.py:1
step
Definition: StallMonitor.cc:94
uint16_t CaloSteppingAction::getDepth ( bool  flag,
double  crystalDepth,
double  radl 
) const
private

Definition at line 288 of file CaloSteppingAction.cc.

References egammaForCoreTracking_cff::depth, PCaloHit::kEcalDepthMask, PCaloHit::kEcalDepthOffset, and PCaloHit::kEcalDepthRefz.

Referenced by update().

288  {
289  uint16_t depth1 = (flag ? 0 : PCaloHit::kEcalDepthRefz);
290  uint16_t depth2 = (uint16_t)floor(crystalDepth / radl);
291  uint16_t depth = (((depth2 & PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1);
292 #ifdef EDM_ML_DEBUG
293  edm::LogVerbatim("Step") << "CaloSteppingAction::getDepth radl " << radl << ":" << crystalDepth << " depth " << depth;
294 #endif
295  return depth;
296 }
static const int kEcalDepthRefz
Definition: PCaloHit.h:63
static const int kEcalDepthMask
Definition: PCaloHit.h:61
static const int kEcalDepthOffset
Definition: PCaloHit.h:62
uint32_t CaloSteppingAction::getDetIDHC ( int  det,
int  lay,
int  depth,
const math::XYZVectorD pos 
) const
private

Definition at line 259 of file CaloSteppingAction.cc.

References relativeConstraints::error, hcNumberingPS_, hcNumberingScheme_, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by update().

259  {
260  HcalNumberingFromDDD::HcalID tmp = hcNumberingPS_.get()->unitID(det, lay, depth, pos);
261 #ifdef HcalNumberingTest
262  auto id0 = hcNumberingScheme_.get()->getUnitID(tmp);
263  HcalNumberingFromDDD::HcalID tmpO = hcNumbering_.get()->unitID(det, pos, depth, lay);
264  auto idO = hcNumberingScheme_.get()->getUnitID(tmpO);
265  std::string error = (id0 == idO) ? " ** OK **" : " ** ERROR **";
266  edm::LogVerbatim("Step") << "Det ID " << HcalDetId(id0) << " Original " << HcalDetId(idO) << error;
267 #endif
268  return (hcNumberingScheme_.get()->getUnitID(tmp));
269 }
std::unique_ptr< HcalNumberingFromPS > hcNumberingPS_
std::unique_ptr< HcalNumberingScheme > hcNumberingScheme_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void CaloSteppingAction::NaNTrap ( const G4Step *  aStep) const
private

Definition at line 245 of file CaloSteppingAction.cc.

References Exception, and edm::isNotFinite().

Referenced by update().

245  {
246  auto currentPos = aStep->GetTrack()->GetPosition();
247  double xyz = currentPos.x() + currentPos.y() + currentPos.z();
248  auto currentMom = aStep->GetTrack()->GetMomentum();
249  xyz += currentMom.x() + currentMom.y() + currentMom.z();
250 
251  if (edm::isNotFinite(xyz)) {
252  auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
253  auto& nameOfVol = pCurrentVol->GetName();
254  throw cms::Exception("Unknown", "CaloSteppingAction")
255  << " Corrupted Event - NaN detected in volume " << nameOfVol << "\n";
256  }
257 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void CaloSteppingAction::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 82 of file CaloSteppingAction.cc.

References fillHits(), gen::k, eostools::move(), nameHitC_, nSD_, edm::Event::put(), and saveHits().

82  {
83  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
84  saveHits(k);
85  auto product = std::make_unique<edm::PCaloHitContainer>();
86  fillHits(*product, k);
87  e.put(std::move(product), nameHitC_[k]);
88  }
89 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void fillHits(edm::PCaloHitContainer &cc, int type)
std::vector< std::string > nameHitC_
int k[5][pyjets_maxn]
static const int nSD_
def move(src, dest)
Definition: eostools.py:511
void CaloSteppingAction::saveHits ( int  flag)
private

Definition at line 353 of file CaloSteppingAction.cc.

References GeV, hitMap_, findQualityFiles::size, and slave_.

Referenced by produce().

353  {
354  edm::LogVerbatim("Step") << "CaloSteppingAction:: saveHits for type " << type << " with " << hitMap_[type].size()
355  << " hits";
356  slave_[type].get()->ReserveMemory(hitMap_[type].size());
357  for (auto const& hit : hitMap_[type]) {
358  slave_[type].get()->processHits(hit.second.getUnitID(),
359  hit.second.getEM() / GeV,
360  hit.second.getHadr() / GeV,
361  hit.second.getTimeSlice(),
362  hit.second.getTrackID(),
363  hit.second.getDepth());
364  }
365 }
size
Write out results.
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
type
Definition: HCALResponse.h:21
const double GeV
Definition: MathUtil.h:16
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
void CaloSteppingAction::update ( const BeginOfJob )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 98 of file CaloSteppingAction.cc.

References edm::ESHandle< T >::product().

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

98  {
99  edm::LogVerbatim("Step") << "CaloSteppingAction:: Enter BeginOfJob";
100 
101 #ifdef HcalNumberingTest
102  // Numbering From DDD
104  (*job)()->get<HcalSimNumberingRecord>().get(hdc);
105  const HcalDDDSimConstants* hcons_ = hdc.product();
106  edm::LogVerbatim("Step") << "CaloSteppingAction:: Initialise "
107  << "HcalNumberingFromDDD";
108  hcNumbering_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
109 #endif
110 }
T const * product() const
Definition: ESHandle.h:86
void CaloSteppingAction::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 113 of file CaloSteppingAction.cc.

References PVValHelper::dz, gen::k, dataset::name, nameEBSD_, nameEESD_, nameHCSD_, AlCaHLTBitMon_QueryRunRegistry::string, volEBSD_, volEESD_, volHCSD_, and xtalMap_.

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

113  {
114  int irun = (*run)()->GetRunID();
115  edm::LogVerbatim("Step") << "CaloSteppingAction:: Begin of Run = " << irun;
116 
117  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
118  if (lvs) {
119  std::map<const std::string, const G4LogicalVolume*> nameMap;
120  std::map<const std::string, const G4LogicalVolume*>::const_iterator itr;
121  for (auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi)
122  nameMap.emplace((*lvi)->GetName(), *lvi);
123  for (auto const& name : nameEBSD_) {
124  for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
125  const std::string& lvname = itr->first;
126  if (lvname.find(name) != std::string::npos) {
127  volEBSD_.emplace_back(itr->second);
128  int type = (lvname.find("refl") == std::string::npos) ? -1 : 1;
129  G4Trap* solid = static_cast<G4Trap*>(itr->second->GetSolid());
130  double dz = 2 * solid->GetZHalfLength();
131  xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
132  }
133  }
134  }
135  for (auto const& name : nameEESD_) {
136  for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
137  const std::string& lvname = itr->first;
138  if (lvname.find(name) != std::string::npos) {
139  volEESD_.emplace_back(itr->second);
140  int type = (lvname.find("refl") == std::string::npos) ? 1 : -1;
141  G4Trap* solid = static_cast<G4Trap*>(itr->second->GetSolid());
142  double dz = 2 * solid->GetZHalfLength();
143  xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
144  }
145  }
146  }
147  for (auto const& name : nameHCSD_) {
148  for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
149  const std::string& lvname = itr->first;
150  if (lvname.find(name) != std::string::npos)
151  volHCSD_.emplace_back(itr->second);
152  }
153  }
154  }
155 #ifdef EDM_ML_DEBUG
156  edm::LogVerbatim("Step") << volEBSD_.size() << " logical volumes for EB SD";
157  for (unsigned int k = 0; k < volEBSD_.size(); ++k)
158  edm::LogVerbatim("Step") << "[" << k << "] " << volEBSD_[k];
159  edm::LogVerbatim("Step") << volEESD_.size() << " logical volumes for EE SD";
160  for (unsigned int k = 0; k < volEESD_.size(); ++k)
161  edm::LogVerbatim("Step") << "[" << k << "] " << volEESD_[k];
162  edm::LogVerbatim("Step") << volHCSD_.size() << " logical volumes for HC SD";
163  for (unsigned int k = 0; k < volHCSD_.size(); ++k)
164  edm::LogVerbatim("Step") << "[" << k << "] " << volHCSD_[k];
165 #endif
166 }
std::vector< const G4LogicalVolume * > volEBSD_
type
Definition: HCALResponse.h:21
std::vector< const G4LogicalVolume * > volEESD_
std::vector< const G4LogicalVolume * > volHCSD_
std::vector< std::string > nameHCSD_
std::map< const G4LogicalVolume *, double > xtalMap_
int k[5][pyjets_maxn]
std::vector< std::string > nameEBSD_
std::vector< std::string > nameEESD_
void CaloSteppingAction::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 169 of file CaloSteppingAction.cc.

References begin, end, eventID_, hitMap_, gen::k, nSD_, and slave_.

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

169  {
170  eventID_ = (*evt)()->GetEventID();
171  edm::LogVerbatim("Step") << "CaloSteppingAction: Begin of event = " << eventID_;
172  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
173  hitMap_[k].erase(hitMap_[k].begin(), hitMap_[k].end());
174  slave_[k].get()->Initialize();
175  }
176 }
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
#define end
Definition: vmac.h:39
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
int k[5][pyjets_maxn]
#define begin
Definition: vmac.h:32
static const int nSD_
void CaloSteppingAction::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 179 of file CaloSteppingAction.cc.

References funct::abs(), EcalBaseNumber::addLevel(), curve_LY(), egammaForCoreTracking_cff::depth, ebNumberingScheme_, eeNumberingScheme_, fillHit(), spr::find(), RemoveAddSevLevel::flag, getBirkHC(), getBirkL3(), EcalBaseNumber::getCapacity(), getDepth(), getDetIDHC(), AnalysisDataFormats_SUSYBSMObjects::hc, cuy::ii, G4TrackToParticleID::isGammaElectronPositron(), DTRecHitClients_cfi::local, NaNTrap(), EcalBaseNumber::setSize(), findQualityFiles::size, protons_cff::time, volEBSD_, volEESD_, volHCSD_, and xtalMap_.

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

179  {
180  // edm::LogVerbatim("Step") <<"CaloSteppingAction: At each Step";
181  NaNTrap(aStep);
182  auto lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
183  bool hc = (std::find(volHCSD_.begin(), volHCSD_.end(), lv) != volHCSD_.end());
184  bool eb = (std::find(volEBSD_.begin(), volEBSD_.end(), lv) != volEBSD_.end());
185  bool ee = (std::find(volEESD_.begin(), volEESD_.end(), lv) != volEESD_.end());
186  if (hc || eb || ee) {
187  double dEStep = aStep->GetTotalEnergyDeposit();
188  auto const theTrack = aStep->GetTrack();
189  double time = theTrack->GetGlobalTime() / nanosecond;
190  int primID = theTrack->GetTrackID();
192  auto const touch = aStep->GetPreStepPoint()->GetTouchable();
193  auto const& hitPoint = aStep->GetPreStepPoint()->GetPosition();
194  if (hc) {
195  int depth = (touch->GetReplicaNumber(0)) % 10 + 1;
196  int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
197  int det = (touch->GetReplicaNumber(1)) / 1000;
198  auto unitID = getDetIDHC(det, lay, depth, math::XYZVectorD(hitPoint.x(), hitPoint.y(), hitPoint.z()));
199  if (unitID > 0 && dEStep > 0.0) {
200  dEStep *= getBirkHC(dEStep,
201  aStep->GetStepLength(),
202  aStep->GetPreStepPoint()->GetCharge(),
203  aStep->GetPreStepPoint()->GetMaterial()->GetDensity());
204  fillHit(unitID, dEStep, time, primID, 0, em, 2);
205  }
206  } else {
207  EcalBaseNumber theBaseNumber;
208  int size = touch->GetHistoryDepth() + 1;
209  if (theBaseNumber.getCapacity() < size)
210  theBaseNumber.setSize(size);
211  //Get name and copy numbers
212  if (size > 1) {
213  for (int ii = 0; ii < size; ii++) {
214  theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), touch->GetReplicaNumber(ii));
215  }
216  }
217  auto unitID =
218  (eb ? (ebNumberingScheme_->getUnitID(theBaseNumber)) : (eeNumberingScheme_->getUnitID(theBaseNumber)));
219  if (unitID > 0 && dEStep > 0.0) {
220  auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
221  auto ite = xtalMap_.find(lv);
222  double crystalLength = ((ite == xtalMap_.end()) ? 230.0 : std::abs(ite->second));
223  double crystalDepth = ((ite == xtalMap_.end()) ? 0.0 : (std::abs(0.5 * (ite->second) + local.z())));
224  double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen();
225  bool flag = ((ite == xtalMap_.end()) ? true : (((ite->second) >= 0) ? true : false));
226  auto depth = getDepth(flag, crystalDepth, radl);
227  dEStep *= (getBirkL3(dEStep,
228  aStep->GetStepLength(),
229  aStep->GetPreStepPoint()->GetCharge(),
230  aStep->GetPreStepPoint()->GetMaterial()->GetDensity()) *
231  curve_LY(crystalLength, crystalDepth));
232  fillHit(unitID, dEStep, time, primID, depth, em, (eb ? 0 : 1));
233  }
234  }
235  }
236 }
size
Write out results.
std::vector< const G4LogicalVolume * > volEBSD_
double getBirkL3(double dE, double step, double chg, double dens) const
uint32_t getDetIDHC(int det, int lay, int depth, const math::XYZVectorD &pos) const
double getBirkHC(double dE, double step, double chg, double dens) const
double curve_LY(double crystalLength, double crystalDepth) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void addLevel(const std::string &name, const int &copyNumber)
std::vector< const G4LogicalVolume * > volEESD_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
std::vector< const G4LogicalVolume * > volHCSD_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< const G4LogicalVolume *, double > xtalMap_
ii
Definition: cuy.py:590
void fillHit(uint32_t id, double dE, double time, int primID, uint16_t depth, double em, int flag)
void NaNTrap(const G4Step *) const
std::unique_ptr< EcalBarrelNumberingScheme > ebNumberingScheme_
static bool isGammaElectronPositron(int pdgCode)
susybsm::HSCParticleCollection hc
Definition: classes.h:25
std::unique_ptr< EcalEndcapNumberingScheme > eeNumberingScheme_
void setSize(const int &size)
uint16_t getDepth(bool flag, double crystalDepth, double radl) const
void CaloSteppingAction::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 239 of file CaloSteppingAction.cc.

References count_.

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

239  {
240  ++count_;
241  // Fill event input
242  edm::LogVerbatim("Step") << "CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID();
243 }

Member Data Documentation

double CaloSteppingAction::birkC1EC_
private

Definition at line 95 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getBirkL3().

double CaloSteppingAction::birkC1HC_
private

Definition at line 96 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getBirkHC().

double CaloSteppingAction::birkC2HC_
private

Definition at line 96 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getBirkHC().

double CaloSteppingAction::birkC3HC_
private

Definition at line 97 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getBirkHC().

double CaloSteppingAction::birkCutEC_
private

Definition at line 96 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getBirkL3().

double CaloSteppingAction::birkSlopeEC_
private

Definition at line 95 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getBirkL3().

int CaloSteppingAction::count_
private

Definition at line 94 of file CaloSteppingAction.h.

Referenced by update(), and ~CaloSteppingAction().

std::unique_ptr<EcalBarrelNumberingScheme> CaloSteppingAction::ebNumberingScheme_
private

Definition at line 81 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and update().

std::unique_ptr<EcalEndcapNumberingScheme> CaloSteppingAction::eeNumberingScheme_
private

Definition at line 82 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and update().

int CaloSteppingAction::eventID_
private

Definition at line 94 of file CaloSteppingAction.h.

Referenced by fillHit(), and update().

std::unique_ptr<HcalNumberingFromPS> CaloSteppingAction::hcNumberingPS_
private

Definition at line 83 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getDetIDHC().

std::unique_ptr<HcalNumberingScheme> CaloSteppingAction::hcNumberingScheme_
private

Definition at line 87 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and getDetIDHC().

std::map<std::pair<int, CaloHitID>, CaloGVHit> CaloSteppingAction::hitMap_[nSD_]
private

Definition at line 98 of file CaloSteppingAction.h.

Referenced by fillHit(), saveHits(), and update().

std::vector<std::string> CaloSteppingAction::nameEBSD_
private

Definition at line 90 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and update().

std::vector<std::string> CaloSteppingAction::nameEESD_
private

Definition at line 90 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and update().

std::vector<std::string> CaloSteppingAction::nameHCSD_
private

Definition at line 90 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and update().

std::vector<std::string> CaloSteppingAction::nameHitC_
private

Definition at line 91 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and produce().

const int CaloSteppingAction::nSD_ = 3
staticprivate

Definition at line 80 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), produce(), and update().

std::unique_ptr<CaloSlaveSD> CaloSteppingAction::slave_[nSD_]
private

Definition at line 88 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), fillHits(), saveHits(), and update().

double CaloSteppingAction::slopeLY_
private

Definition at line 95 of file CaloSteppingAction.h.

Referenced by CaloSteppingAction(), and curve_LY().

std::vector<const G4LogicalVolume *> CaloSteppingAction::volEBSD_
private

Definition at line 92 of file CaloSteppingAction.h.

Referenced by update().

std::vector<const G4LogicalVolume *> CaloSteppingAction::volEESD_
private

Definition at line 92 of file CaloSteppingAction.h.

Referenced by update().

std::vector<const G4LogicalVolume *> CaloSteppingAction::volHCSD_
private

Definition at line 92 of file CaloSteppingAction.h.

Referenced by update().

std::map<const G4LogicalVolume *, double> CaloSteppingAction::xtalMap_
private

Definition at line 93 of file CaloSteppingAction.h.

Referenced by update().