CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
CaloSteppingAction Class Reference
Inheritance diagram for CaloSteppingAction:
SimProducer Observer< const BeginOfRun *> Observer< const BeginOfEvent *> Observer< const EndOfEvent *> Observer< const G4Step *> SimWatcher

Public Member Functions

void beginRun (edm::EventSetup const &) override
 
 CaloSteppingAction (const edm::ParameterSet &p)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void registerConsumes (edm::ConsumesCollector) override
 
 ~CaloSteppingAction () override
 
- Public Member Functions inherited from SimProducer
const SimProduceroperator= (const SimProducer &)=delete
 
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
 SimProducer (const SimProducer &)=delete
 
- Public Member Functions inherited from SimWatcher
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
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 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 Types

typedef std::tuple< const G4LogicalVolume *, uint32_t, int, int, double, double, double, double, double, double, double > PassiveData
 

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)
 
void fillPassiveHits (edm::PassiveHitContainer &cc)
 
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 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

const int allSteps_
 
const double birkC1EC_
 
const double birkC1HC_
 
const double birkC2HC_
 
const double birkC3HC_
 
const double birkCutEC_
 
const 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_]
 
const edm::ParameterSet iC_
 
std::map< const G4LogicalVolume *, std::string > mapLV_
 
const std::vector< std::string > nameEBSD_
 
const std::vector< std::string > nameEESD_
 
const std::vector< std::string > nameHCSD_
 
const std::vector< std::string > nameHitC_
 
std::unique_ptr< CaloSlaveSDslave_ [nSD_]
 
const double slopeLY_
 
std::vector< PassiveDatastore_
 
const double timeSliceUnit_
 
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)
 
- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 68 of file CaloSteppingAction.cc.

Member Typedef Documentation

◆ PassiveData

typedef std::tuple<const G4LogicalVolume*, uint32_t, int, int, double, double, double, double, double, double, double> CaloSteppingAction::PassiveData
private

Definition at line 123 of file CaloSteppingAction.cc.

Constructor & Destructor Documentation

◆ CaloSteppingAction()

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

Definition at line 127 of file CaloSteppingAction.cc.

References allSteps_, birkC1EC_, birkC1HC_, birkC2HC_, birkC3HC_, birkCutEC_, birkSlopeEC_, ebNumberingScheme_, eeNumberingScheme_, hcNumberingPS_, hcNumberingScheme_, isotrackApplyRegressor::k, nameEBSD_, nameEESD_, nameHCSD_, nameHitC_, nSD_, AlCaHLTBitMon_ParallelJobs::p, slave_, slopeLY_, and timeSliceUnit_.

128  : iC_(p.getParameter<edm::ParameterSet>("CaloSteppingAction")),
129  nameEBSD_(iC_.getParameter<std::vector<std::string> >("EBSDNames")),
130  nameEESD_(iC_.getParameter<std::vector<std::string> >("EESDNames")),
131  nameHCSD_(iC_.getParameter<std::vector<std::string> >("HCSDNames")),
132  nameHitC_(iC_.getParameter<std::vector<std::string> >("HitCollNames")),
133  allSteps_(iC_.getParameter<int>("AllSteps")),
134  slopeLY_(iC_.getParameter<double>("SlopeLightYield")),
135  birkC1EC_(iC_.getParameter<double>("BirkC1EC")),
136  birkSlopeEC_(iC_.getParameter<double>("BirkSlopeEC")),
137  birkCutEC_(iC_.getParameter<double>("BirkCutEC")),
138  birkC1HC_(iC_.getParameter<double>("BirkC1HC")),
139  birkC2HC_(iC_.getParameter<double>("BirkC2HC")),
140  birkC3HC_(iC_.getParameter<double>("BirkC3HC")),
141  timeSliceUnit_(iC_.getUntrackedParameter<double>("TimeSliceUnit", 1.0)),
142  count_(0) {
143  edm::ParameterSet iC = p.getParameter<edm::ParameterSet>("CaloSteppingAction");
144 
145  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEBSD_.size() << " names for EB SD's";
146  for (unsigned int k = 0; k < nameEBSD_.size(); ++k)
147  edm::LogVerbatim("Step") << "[" << k << "] " << nameEBSD_[k];
148  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameEESD_.size() << " names for EE SD's";
149  for (unsigned int k = 0; k < nameEESD_.size(); ++k)
150  edm::LogVerbatim("Step") << "[" << k << "] " << nameEESD_[k];
151  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameHCSD_.size() << " names for HC SD's";
152  for (unsigned int k = 0; k < nameHCSD_.size(); ++k)
153  edm::LogVerbatim("Step") << "[" << k << "] " << nameHCSD_[k];
154  edm::LogVerbatim("Step") << "CaloSteppingAction::Constants for ECAL: slope " << slopeLY_ << " Birk constants "
155  << birkC1EC_ << ":" << birkSlopeEC_ << ":" << birkCutEC_;
156  edm::LogVerbatim("Step") << "CaloSteppingAction::Constants for HCAL: Birk "
157  << "constants " << birkC1HC_ << ":" << birkC2HC_ << ":" << birkC3HC_;
158  edm::LogVerbatim("Step") << "CaloSteppingAction::Constant for time slice " << timeSliceUnit_;
159  edm::LogVerbatim("Step") << "CaloSteppingAction:: " << nameHitC_.size() << " hit collections";
160  for (unsigned int k = 0; k < nameHitC_.size(); ++k)
161  edm::LogVerbatim("Step") << "[" << k << "] " << nameHitC_[k];
162 
163  ebNumberingScheme_ = std::make_unique<EcalBarrelNumberingScheme>();
164  eeNumberingScheme_ = std::make_unique<EcalEndcapNumberingScheme>();
165  hcNumberingPS_ = std::make_unique<HcalNumberingFromPS>(iC);
166  hcNumberingScheme_ = std::make_unique<HcalNumberingScheme>();
167 #ifdef HcalNumberingTest
168  hcNumbering_.reset(nullptr);
169 #endif
170  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
171  slave_[k] = std::make_unique<CaloSlaveSD>(nameHitC_[k]);
172  produces<edm::PCaloHitContainer>(nameHitC_[k]);
173  }
174  if (allSteps_ != 0)
175  produces<edm::PassiveHitContainer>("AllPassiveHits");
176  edm::LogVerbatim("Step") << "CaloSteppingAction:: All Steps Flag " << allSteps_ << " for passive hits";
177 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const std::vector< std::string > nameHitC_
const std::vector< std::string > nameEESD_
const std::vector< std::string > nameEBSD_
T getUntrackedParameter(std::string const &, T const &) const
const edm::ParameterSet iC_
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
std::unique_ptr< HcalNumberingFromPS > hcNumberingPS_
std::unique_ptr< HcalNumberingScheme > hcNumberingScheme_
std::unique_ptr< EcalBarrelNumberingScheme > ebNumberingScheme_
std::unique_ptr< EcalEndcapNumberingScheme > eeNumberingScheme_
const std::vector< std::string > nameHCSD_
static const int nSD_

◆ ~CaloSteppingAction()

CaloSteppingAction::~CaloSteppingAction ( )
override

Definition at line 179 of file CaloSteppingAction.cc.

References count_.

179  {
180  edm::LogVerbatim("Step") << "CaloSteppingAction: --------> Total number of "
181  << "selected entries : " << count_;
182 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

◆ beginRun()

void CaloSteppingAction::beginRun ( edm::EventSetup const &  es)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 234 of file CaloSteppingAction.cc.

References edm::EventSetup::getData().

234  {
235  edm::LogVerbatim("Step") << "CaloSteppingAction:: Enter BeginOfRun";
236 
237 #ifdef HcalNumberingTest
238  // Numbering From DDD
239  const HcalDDDSimConstants* hcons_ = &es.getData(ddconsToken_);
240  edm::LogVerbatim("Step") << "CaloSteppingAction:: Initialise "
241  << "HcalNumberingFromDDD";
242  hcNumbering_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
243 #endif
244 }
Log< level::Info, true > LogVerbatim

◆ curve_LY()

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

Definition at line 488 of file CaloSteppingAction.cc.

References slopeLY_, and mps_merge::weight.

Referenced by update().

488  {
489  double weight = 1.;
490  double dapd = crystalLength - crystalDepth;
491  if (dapd >= -0.1 || dapd <= crystalLength + 0.1) {
492  if (dapd <= 100.)
493  weight = 1.0 + slopeLY_ - dapd * 0.01 * slopeLY_;
494 #ifdef EDM_ML_DEBUG
495  edm::LogVerbatim("Step") << "CaloSteppingAction::curve_LY " << crystalDepth << ":" << crystalLength << ":" << dapd
496  << ":" << weight;
497 #endif
498  } else {
499  edm::LogWarning("Step") << "CaloSteppingAction: light coll curve : wrong "
500  << "distance to APD " << dapd << " crlength = " << crystalLength
501  << " crystal Depth = " << crystalDepth << " weight = " << weight;
502  }
503  return weight;
504 }
Log< level::Info, true > LogVerbatim
Definition: weight.py:1
Log< level::Warning, false > LogWarning

◆ fillHit()

void CaloSteppingAction::fillHit ( uint32_t  id,
double  dE,
double  time,
int  primID,
uint16_t  depth,
double  em,
int  flag 
)
private

Definition at line 461 of file CaloSteppingAction.cc.

References CaloGVHit::addEnergyDeposit(), hcalRecHitTable_cff::depth, mps_fire::end, eventID_, RemoveAddSevLevel::flag, hitMap_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, CaloGVHit::setEventID(), CaloGVHit::setID(), hcalRecHitTable_cff::time, and timeSliceUnit_.

Referenced by update().

461  {
462  CaloHitID currentID(id, time, primID, depth, timeSliceUnit_);
463  double edepEM = (em ? dE : 0);
464  double edepHAD = (em ? 0 : dE);
465  std::pair<int, CaloHitID> evID = std::make_pair(eventID_, currentID);
466  auto it = hitMap_[flag].find(evID);
467  if (it != hitMap_[flag].end()) {
468  (it->second).addEnergyDeposit(edepEM, edepHAD);
469  } else {
470  CaloGVHit aHit;
471  aHit.setEventID(eventID_);
472  aHit.setID(currentID);
473  aHit.addEnergyDeposit(edepEM, edepHAD);
474  hitMap_[flag][evID] = aHit;
475  }
476 }
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
void addEnergyDeposit(double em, double hd)
Definition: CaloGVHit.cc:29

◆ fillHits()

void CaloSteppingAction::fillHits ( edm::PCaloHitContainer cc,
int  type 
)
private

Definition at line 205 of file CaloSteppingAction.cc.

References gpuPixelDoublets::cc, and slave_.

Referenced by produce().

205  {
206  edm::LogVerbatim("Step") << "CaloSteppingAction::fillHits for type " << type << " with "
207  << slave_[type].get()->hits().size() << " hits";
208  cc = slave_[type].get()->hits();
209  slave_[type].get()->Clean();
210 }
Log< level::Info, true > LogVerbatim
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::unique_ptr< CaloSlaveSD > slave_[nSD_]

◆ fillPassiveHits()

void CaloSteppingAction::fillPassiveHits ( edm::PassiveHitContainer cc)
private

Definition at line 212 of file CaloSteppingAction.cc.

References gpuPixelDoublets::cc, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, mapLV_, and store_.

Referenced by produce().

212  {
213  edm::LogVerbatim("Step") << "CaloSteppingAction::fillPassiveHits with " << store_.size() << " hits";
214  for (const auto& element : store_) {
215  auto lv = std::get<0>(element);
216  auto it = mapLV_.find(lv);
217  if (it != mapLV_.end()) {
218  PassiveHit hit(it->second,
219  std::get<1>(element),
220  std::get<5>(element),
221  std::get<6>(element),
222  std::get<4>(element),
223  std::get<2>(element),
224  std::get<3>(element),
225  std::get<7>(element),
226  std::get<8>(element),
227  std::get<9>(element),
228  std::get<10>(element));
229  cc.emplace_back(hit);
230  }
231  }
232 }
Log< level::Info, true > LogVerbatim
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::map< const G4LogicalVolume *, std::string > mapLV_
std::vector< PassiveData > store_

◆ getBirkHC()

double CaloSteppingAction::getBirkHC ( double  dE,
double  step,
double  chg,
double  dens 
) const
private

Definition at line 526 of file CaloSteppingAction.cc.

References funct::abs(), birkC1HC_, birkC2HC_, birkC3HC_, DummyCfis::c, ALCARECOTkAlJpsiMuMu_cff::charge, fastSimProducer_cff::density, and mps_merge::weight.

Referenced by update().

526  {
527  double weight = 1.;
528  if (charge != 0. && step > 0.) {
529  double dedx = dEStep / step;
530  double rkb = birkC1HC_ / density;
531  double c = birkC2HC_ * rkb * rkb;
532  if (std::abs(charge) >= 2.)
533  rkb /= birkC3HC_;
534  weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
535 #ifdef EDM_ML_DEBUG
536  edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkHC Charge " << charge << " dE/dx " << dedx << " Birk Const "
537  << rkb << ", " << c << " Weight = " << weight << " dE " << dEStep;
538 #endif
539  }
540  return weight;
541 }
Log< level::Info, true > LogVerbatim
Definition: weight.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
step
Definition: StallMonitor.cc:83

◆ getBirkL3()

double CaloSteppingAction::getBirkL3 ( double  dE,
double  step,
double  chg,
double  dens 
) const
private

Definition at line 506 of file CaloSteppingAction.cc.

References birkC1EC_, birkCutEC_, birkSlopeEC_, ALCARECOTkAlJpsiMuMu_cff::charge, fastSimProducer_cff::density, CrabHelper::log, and mps_merge::weight.

Referenced by update().

506  {
507  double weight = 1.;
508  if (charge != 0. && step > 0.) {
509  double dedx = dEStep / step;
510  double rkb = birkC1EC_ / density;
511  if (dedx > 0) {
512  weight = 1. - birkSlopeEC_ * log(rkb * dedx);
513  if (weight < birkCutEC_)
514  weight = birkCutEC_;
515  else if (weight > 1.)
516  weight = 1.;
517  }
518 #ifdef EDM_ML_DEBUG
519  edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkL3 Charge " << charge << " dE/dx " << dedx << " Birk Const "
520  << rkb << " Weight = " << weight << " dE " << dEStep << " step " << step;
521 #endif
522  }
523  return weight;
524 }
Log< level::Info, true > LogVerbatim
Definition: weight.py:1
step
Definition: StallMonitor.cc:83

◆ getDepth()

uint16_t CaloSteppingAction::getDepth ( bool  flag,
double  crystalDepth,
double  radl 
) const
private

Definition at line 478 of file CaloSteppingAction.cc.

References hcalRecHitTable_cff::depth, RemoveAddSevLevel::flag, PCaloHit::kEcalDepthMask, PCaloHit::kEcalDepthOffset, and PCaloHit::kEcalDepthRefz.

Referenced by update().

478  {
479  uint16_t depth1 = (flag ? 0 : PCaloHit::kEcalDepthRefz);
480  uint16_t depth2 = (uint16_t)floor(crystalDepth / radl);
481  uint16_t depth = (((depth2 & PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1);
482 #ifdef EDM_ML_DEBUG
483  edm::LogVerbatim("Step") << "CaloSteppingAction::getDepth radl " << radl << ":" << crystalDepth << " depth " << depth;
484 #endif
485  return depth;
486 }
Log< level::Info, true > LogVerbatim
static const int kEcalDepthRefz
Definition: PCaloHit.h:63
static const int kEcalDepthMask
Definition: PCaloHit.h:61
static const int kEcalDepthOffset
Definition: PCaloHit.h:62

◆ getDetIDHC()

uint32_t CaloSteppingAction::getDetIDHC ( int  det,
int  lay,
int  depth,
const math::XYZVectorD pos 
) const
private

Definition at line 449 of file CaloSteppingAction.cc.

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

Referenced by update().

449  {
450  HcalNumberingFromDDD::HcalID tmp = hcNumberingPS_.get()->unitID(det, lay, depth, pos);
451 #ifdef HcalNumberingTest
452  auto id0 = hcNumberingScheme_.get()->getUnitID(tmp);
453  HcalNumberingFromDDD::HcalID tmpO = hcNumbering_.get()->unitID(det, pos, depth, lay);
454  auto idO = hcNumberingScheme_.get()->getUnitID(tmpO);
455  std::string error = (id0 == idO) ? " ** OK **" : " ** ERROR **";
456  edm::LogVerbatim("Step") << "Det ID " << HcalDetId(id0) << " Original " << HcalDetId(idO) << error;
457 #endif
458  return (hcNumberingScheme_.get()->getUnitID(tmp));
459 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HcalNumberingFromPS > hcNumberingPS_
std::unique_ptr< HcalNumberingScheme > hcNumberingScheme_
tmp
align.sh
Definition: createJobs.py:716

◆ NaNTrap()

void CaloSteppingAction::NaNTrap ( const G4Step *  aStep) const
private

Definition at line 435 of file CaloSteppingAction.cc.

References Exception, and edm::isNotFinite().

Referenced by update().

435  {
436  auto currentPos = aStep->GetTrack()->GetPosition();
437  double xyz = currentPos.x() + currentPos.y() + currentPos.z();
438  auto currentMom = aStep->GetTrack()->GetMomentum();
439  xyz += currentMom.x() + currentMom.y() + currentMom.z();
440 
441  if (edm::isNotFinite(xyz)) {
442  auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
443  auto& nameOfVol = pCurrentVol->GetName();
444  throw cms::Exception("Unknown", "CaloSteppingAction")
445  << " Corrupted Event - NaN detected in volume " << nameOfVol << "\n";
446  }
447 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9

◆ produce()

void CaloSteppingAction::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 191 of file CaloSteppingAction.cc.

References allSteps_, MillePedeFileConverter_cfg::e, fillHits(), fillPassiveHits(), isotrackApplyRegressor::k, eostools::move(), nameHitC_, nSD_, and saveHits().

191  {
192  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
193  saveHits(k);
194  auto product = std::make_unique<edm::PCaloHitContainer>();
195  fillHits(*product, k);
196  e.put(std::move(product), nameHitC_[k]);
197  }
198  if (allSteps_ != 0) {
199  std::unique_ptr<edm::PassiveHitContainer> hgcPH(new edm::PassiveHitContainer);
200  fillPassiveHits(*hgcPH);
201  e.put(std::move(hgcPH), "AllPassiveHits");
202  }
203 }
const std::vector< std::string > nameHitC_
void fillHits(edm::PCaloHitContainer &cc, int type)
void fillPassiveHits(edm::PassiveHitContainer &cc)
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:100
static const int nSD_
def move(src, dest)
Definition: eostools.py:511

◆ registerConsumes()

void CaloSteppingAction::registerConsumes ( edm::ConsumesCollector  cc)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 184 of file CaloSteppingAction.cc.

References edm::BeginRun, and gpuPixelDoublets::cc.

184  {
185 #ifdef HcalNumberingTest
187  edm::LogVerbatim("Step") << "CaloSteppingAction::Initialize ESGetToken for HcalDDDSimConstants";
188 #endif
189 }
Log< level::Info, true > LogVerbatim
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49

◆ saveHits()

void CaloSteppingAction::saveHits ( int  flag)
private

Definition at line 543 of file CaloSteppingAction.cc.

References hitMap_, findQualityFiles::size, and slave_.

Referenced by produce().

543  {
544  edm::LogVerbatim("Step") << "CaloSteppingAction:: saveHits for type " << type << " with " << hitMap_[type].size()
545  << " hits";
546  slave_[type].get()->ReserveMemory(hitMap_[type].size());
547  for (auto const& hit : hitMap_[type]) {
548  slave_[type].get()->processHits(hit.second.getUnitID(),
549  0.001 * hit.second.getEM(),
550  0.001 * hit.second.getHadr(),
551  hit.second.getTimeSlice(),
552  hit.second.getTrackID(),
553  hit.second.getDepth());
554  }
555 }
size
Write out results.
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
Log< level::Info, true > LogVerbatim
std::unique_ptr< CaloSlaveSD > slave_[nSD_]

◆ update() [1/4]

void CaloSteppingAction::update ( const BeginOfRun )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 247 of file CaloSteppingAction.cc.

References allSteps_, PVValHelper::dz, isotrackApplyRegressor::k, mapLV_, mergeVDriftHistosByStation::name, nameEBSD_, nameEESD_, nameHCSD_, AlCaHLTBitMon_QueryRunRegistry::string, volEBSD_, volEESD_, volHCSD_, and xtalMap_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

247  {
248  int irun = (*run)()->GetRunID();
249  edm::LogVerbatim("Step") << "CaloSteppingAction:: Begin of Run = " << irun;
250 
251  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
252  if (lvs) {
253  std::map<const std::string, const G4LogicalVolume*> nameMap;
254  std::map<const std::string, const G4LogicalVolume*>::const_iterator itr;
255  for (auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi) {
256  nameMap.emplace((*lvi)->GetName(), *lvi);
257  if (allSteps_ < 0)
258  mapLV_[*lvi] = (*lvi)->GetName();
259  }
260 
261  for (auto const& name : nameEBSD_) {
262  for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
263  const std::string& lvname = itr->first;
264  if (lvname.find(name) != std::string::npos) {
265  volEBSD_.emplace_back(itr->second);
266  int type = (lvname.find("refl") == std::string::npos) ? -1 : 1;
267  G4Trap* solid = static_cast<G4Trap*>(itr->second->GetSolid());
268  double dz = 2 * solid->GetZHalfLength() / CLHEP::mm;
269  xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
270  if ((allSteps_ > 0) && ((allSteps_ % 10) > 0))
271  mapLV_[itr->second] = itr->first;
272  }
273  }
274  }
275  for (auto const& name : nameEESD_) {
276  for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
277  const std::string& lvname = itr->first;
278  if (lvname.find(name) != std::string::npos) {
279  volEESD_.emplace_back(itr->second);
280  int type = (lvname.find("refl") == std::string::npos) ? 1 : -1;
281  G4Trap* solid = static_cast<G4Trap*>(itr->second->GetSolid());
282  double dz = 2 * solid->GetZHalfLength() / CLHEP::mm;
283  xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
284  if ((allSteps_ > 0) && (((allSteps_ / 10) % 10) > 0))
285  mapLV_[itr->second] = itr->first;
286  }
287  }
288  }
289 
290  for (auto const& name : nameHCSD_) {
291  for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
292  const std::string& lvname = itr->first;
293  if (lvname.find(name) != std::string::npos) {
294  volHCSD_.emplace_back(itr->second);
295  if ((allSteps_ > 0) && (((allSteps_ / 100) % 10) > 0))
296  mapLV_[itr->second] = itr->first;
297  }
298  }
299  }
300  }
301 #ifdef EDM_ML_DEBUG
302  edm::LogVerbatim("Step") << volEBSD_.size() << " logical volumes for EB SD";
303  for (unsigned int k = 0; k < volEBSD_.size(); ++k)
304  edm::LogVerbatim("Step") << "[" << k << "] " << volEBSD_[k];
305  edm::LogVerbatim("Step") << volEESD_.size() << " logical volumes for EE SD";
306  for (unsigned int k = 0; k < volEESD_.size(); ++k)
307  edm::LogVerbatim("Step") << "[" << k << "] " << volEESD_[k];
308  edm::LogVerbatim("Step") << volHCSD_.size() << " logical volumes for HC SD";
309  for (unsigned int k = 0; k < volHCSD_.size(); ++k)
310  edm::LogVerbatim("Step") << "[" << k << "] " << volHCSD_[k];
311  edm::LogVerbatim("Step") << mapLV_.size() << " logical volumes for Passive hits";
312  unsigned int k(0);
313  for (auto itr = mapLV_.begin(); itr != mapLV_.end(); ++itr) {
314  edm::LogVerbatim("Step") << "[" << k << "] " << itr->second << ":" << itr->first;
315  ++k;
316  }
317 #endif
318 }
Log< level::Info, true > LogVerbatim
std::vector< const G4LogicalVolume * > volEBSD_
const std::vector< std::string > nameEESD_
std::map< const G4LogicalVolume *, double > xtalMap_
std::vector< const G4LogicalVolume * > volHCSD_
const std::vector< std::string > nameEBSD_
std::map< const G4LogicalVolume *, std::string > mapLV_
std::vector< const G4LogicalVolume * > volEESD_
const std::vector< std::string > nameHCSD_

◆ update() [2/4]

void CaloSteppingAction::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 321 of file CaloSteppingAction.cc.

References allSteps_, SplitLinear::begin, mps_fire::end, eventID_, hitMap_, isotrackApplyRegressor::k, nSD_, slave_, and store_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

321  {
322  eventID_ = (*evt)()->GetEventID();
323  edm::LogVerbatim("Step") << "CaloSteppingAction: Begin of event = " << eventID_;
324  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
325  hitMap_[k].erase(hitMap_[k].begin(), hitMap_[k].end());
326  slave_[k].get()->Initialize();
327  }
328  if (allSteps_ != 0)
329  store_.clear();
330 }
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
Log< level::Info, true > LogVerbatim
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
std::vector< PassiveData > store_
static const int nSD_

◆ update() [3/4]

void CaloSteppingAction::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 333 of file CaloSteppingAction.cc.

References funct::abs(), EcalBaseNumber::addLevel(), allSteps_, filterCSVwithJSON::copy, curve_LY(), hcalRecHitTable_cff::depth, ebNumberingScheme_, eeNumberingScheme_, HBHEDarkening_cff::energy, fillHit(), spr::find(), RemoveAddSevLevel::flag, g, getBirkHC(), getBirkL3(), EcalBaseNumber::getCapacity(), getDepth(), getDetIDHC(), cuy::ii, G4TrackToParticleID::isGammaElectronPositron(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, submitPVResolutionJobs::key, DTRecHitClients_cfi::local, mapLV_, NaNTrap(), EcalBaseNumber::setSize(), findQualityFiles::size, store_, hcalRecHitTable_cff::time, funct::true, volEBSD_, volEESD_, volHCSD_, and xtalMap_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

333  {
334  // edm::LogVerbatim("Step") <<"CaloSteppingAction: At each Step";
335  NaNTrap(aStep);
336  auto lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
337  bool hc = (std::find(volHCSD_.begin(), volHCSD_.end(), lv) != volHCSD_.end());
338  bool eb = (std::find(volEBSD_.begin(), volEBSD_.end(), lv) != volEBSD_.end());
339  bool ee = (std::find(volEESD_.begin(), volEESD_.end(), lv) != volEESD_.end());
340  uint32_t unitID(0);
341  if (hc || eb || ee) {
342  double dEStep = aStep->GetTotalEnergyDeposit() / CLHEP::MeV;
343  auto const theTrack = aStep->GetTrack();
344  double time = theTrack->GetGlobalTime() / CLHEP::nanosecond;
345  int primID = theTrack->GetTrackID();
347  auto const touch = aStep->GetPreStepPoint()->GetTouchable();
348  auto const& hitPoint = aStep->GetPreStepPoint()->GetPosition();
349  if (hc) {
350  int depth = (touch->GetReplicaNumber(0)) % 10 + 1;
351  int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
352  int det = (touch->GetReplicaNumber(1)) / 1000;
353  unitID = getDetIDHC(det, lay, depth, math::XYZVectorD(hitPoint.x(), hitPoint.y(), hitPoint.z()));
354  if (unitID > 0 && dEStep > 0.0) {
355  dEStep *= getBirkHC(dEStep,
356  (aStep->GetStepLength() / CLHEP::cm),
357  aStep->GetPreStepPoint()->GetCharge(),
358  (aStep->GetPreStepPoint()->GetMaterial()->GetDensity() / (CLHEP::g / CLHEP::cm3)));
359  fillHit(unitID, dEStep, time, primID, 0, em, 2);
360  }
361  } else {
362  EcalBaseNumber theBaseNumber;
363  int size = touch->GetHistoryDepth() + 1;
364  if (theBaseNumber.getCapacity() < size)
365  theBaseNumber.setSize(size);
366  //Get name and copy numbers
367  if (size > 1) {
368  for (int ii = 0; ii < size; ii++) {
369  theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), touch->GetReplicaNumber(ii));
370  }
371  }
372  unitID = (eb ? (ebNumberingScheme_->getUnitID(theBaseNumber)) : (eeNumberingScheme_->getUnitID(theBaseNumber)));
373  if (unitID > 0 && dEStep > 0.0) {
374  auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
375  auto ite = xtalMap_.find(lv);
376  double crystalLength = ((ite == xtalMap_.end()) ? 230.0 : std::abs(ite->second));
377  double crystalDepth =
378  ((ite == xtalMap_.end()) ? 0.0 : (std::abs(0.5 * (ite->second) + (local.z() / CLHEP::mm))));
379  double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() / CLHEP::mm;
380  bool flag = ((ite == xtalMap_.end()) ? true : (((ite->second) >= 0) ? true : false));
381  auto depth = getDepth(flag, crystalDepth, radl);
382  dEStep *= (getBirkL3(dEStep,
383  (aStep->GetStepLength() / CLHEP::cm),
384  aStep->GetPreStepPoint()->GetCharge(),
385  (aStep->GetPreStepPoint()->GetMaterial()->GetDensity() / (CLHEP::g / CLHEP::cm3))) *
386  curve_LY(crystalLength, crystalDepth));
387  fillHit(unitID, dEStep, time, primID, depth, em, (eb ? 0 : 1));
388  }
389  }
390  }
391 
392  if (allSteps_ != 0) {
393  auto it = mapLV_.find(lv);
394  if (it != mapLV_.end()) {
395  double energy = aStep->GetTotalEnergyDeposit() / CLHEP::MeV;
396  auto const touch = aStep->GetPreStepPoint()->GetTouchable();
397  double time = aStep->GetTrack()->GetGlobalTime() / CLHEP::nanosecond;
398  int trackId = aStep->GetTrack()->GetTrackID();
399  int pdg = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
400  double stepl = (aStep->GetStepLength() / CLHEP::cm);
401  double xp = aStep->GetPreStepPoint()->GetPosition().x() / CLHEP::cm;
402  double yp = aStep->GetPreStepPoint()->GetPosition().y() / CLHEP::cm;
403  double zp = aStep->GetPreStepPoint()->GetPosition().z() / CLHEP::cm;
404 #ifdef EDM_ML_DEBUG
405  edm::LogVerbatim("Step") << "CaloSteppingAction: Volume " << lv->GetName() << " History "
406  << touch->GetHistoryDepth() << " Pointers " << aStep->GetPostStepPoint() << ":"
407  << aStep->GetTrack()->GetNextVolume() << ":" << aStep->IsLastStepInVolume() << " E "
408  << energy << " T " << time << " PDG " << pdg << " step " << stepl << " Position (" << xp
409  << ", " << yp << ", " << zp << ")";
410 #endif
411  uint32_t copy = (allSteps_ < 0) ? 0 : unitID;
412  if (((aStep->GetPostStepPoint() == nullptr) || (aStep->GetTrack()->GetNextVolume() == nullptr)) &&
413  (aStep->IsLastStepInVolume())) {
414  energy += (aStep->GetPreStepPoint()->GetKineticEnergy() / CLHEP::MeV);
415  } else {
416  time = aStep->GetPostStepPoint()->GetGlobalTime() / CLHEP::nanosecond;
417  if (copy == 0)
418  copy = (touch->GetHistoryDepth() < 1)
419  ? static_cast<uint32_t>(touch->GetReplicaNumber(0))
420  : static_cast<uint32_t>(touch->GetReplicaNumber(0) + 1000 * touch->GetReplicaNumber(1));
421  }
422  PassiveData key(std::make_tuple(lv, copy, trackId, pdg, time, energy, energy, stepl, xp, yp, zp));
423  store_.push_back(key);
424  }
425  }
426 }
size
Write out results.
Log< level::Info, true > LogVerbatim
std::vector< const G4LogicalVolume * > volEBSD_
std::map< const G4LogicalVolume *, double > xtalMap_
std::vector< const G4LogicalVolume * > volHCSD_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
uint16_t getDepth(bool flag, double crystalDepth, double radl) 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
void NaNTrap(const G4Step *) const
void addLevel(const std::string &name, const int &copyNumber)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
key
prepare the HTCondor submission files and eventually submit them
std::map< const G4LogicalVolume *, std::string > mapLV_
uint32_t getDetIDHC(int det, int lay, int depth, const math::XYZVectorD &pos) const
ii
Definition: cuy.py:589
void fillHit(uint32_t id, double dE, double time, int primID, uint16_t depth, double em, int flag)
double getBirkHC(double dE, double step, double chg, double dens) const
std::vector< const G4LogicalVolume * > volEESD_
std::unique_ptr< EcalBarrelNumberingScheme > ebNumberingScheme_
std::tuple< const G4LogicalVolume *, uint32_t, int, int, double, double, double, double, double, double, double > PassiveData
static bool isGammaElectronPositron(int pdgCode)
std::unique_ptr< EcalEndcapNumberingScheme > eeNumberingScheme_
double getBirkL3(double dE, double step, double chg, double dens) const
std::vector< PassiveData > store_
void setSize(const int &size)
double curve_LY(double crystalLength, double crystalDepth) const

◆ update() [4/4]

void CaloSteppingAction::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent *>.

Definition at line 429 of file CaloSteppingAction.cc.

References count_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

429  {
430  ++count_;
431  // Fill event input
432  edm::LogVerbatim("Step") << "CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID();
433 }
Log< level::Info, true > LogVerbatim

Member Data Documentation

◆ allSteps_

const int CaloSteppingAction::allSteps_
private

Definition at line 116 of file CaloSteppingAction.cc.

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

◆ birkC1EC_

const double CaloSteppingAction::birkC1EC_
private

Definition at line 117 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkL3().

◆ birkC1HC_

const double CaloSteppingAction::birkC1HC_
private

Definition at line 118 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkHC().

◆ birkC2HC_

const double CaloSteppingAction::birkC2HC_
private

Definition at line 118 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkHC().

◆ birkC3HC_

const double CaloSteppingAction::birkC3HC_
private

Definition at line 119 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkHC().

◆ birkCutEC_

const double CaloSteppingAction::birkCutEC_
private

Definition at line 118 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkL3().

◆ birkSlopeEC_

const double CaloSteppingAction::birkSlopeEC_
private

Definition at line 117 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkL3().

◆ count_

int CaloSteppingAction::count_
private

Definition at line 120 of file CaloSteppingAction.cc.

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

◆ ebNumberingScheme_

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

Definition at line 100 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

◆ eeNumberingScheme_

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

Definition at line 101 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

◆ eventID_

int CaloSteppingAction::eventID_
private

Definition at line 120 of file CaloSteppingAction.cc.

Referenced by fillHit(), and update().

◆ hcNumberingPS_

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

Definition at line 102 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getDetIDHC().

◆ hcNumberingScheme_

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

Definition at line 107 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getDetIDHC().

◆ hitMap_

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

Definition at line 121 of file CaloSteppingAction.cc.

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

◆ iC_

const edm::ParameterSet CaloSteppingAction::iC_
private

Definition at line 110 of file CaloSteppingAction.cc.

◆ mapLV_

std::map<const G4LogicalVolume*, std::string> CaloSteppingAction::mapLV_
private

Definition at line 115 of file CaloSteppingAction.cc.

Referenced by fillPassiveHits(), and update().

◆ nameEBSD_

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

Definition at line 111 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

◆ nameEESD_

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

Definition at line 111 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

◆ nameHCSD_

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

Definition at line 111 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

◆ nameHitC_

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

Definition at line 112 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and produce().

◆ nSD_

const int CaloSteppingAction::nSD_ = 3
staticprivate

Definition at line 99 of file CaloSteppingAction.cc.

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

◆ slave_

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

Definition at line 108 of file CaloSteppingAction.cc.

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

◆ slopeLY_

const double CaloSteppingAction::slopeLY_
private

Definition at line 117 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and curve_LY().

◆ store_

std::vector<PassiveData> CaloSteppingAction::store_
private

Definition at line 124 of file CaloSteppingAction.cc.

Referenced by fillPassiveHits(), and update().

◆ timeSliceUnit_

const double CaloSteppingAction::timeSliceUnit_
private

Definition at line 119 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and fillHit().

◆ volEBSD_

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

Definition at line 113 of file CaloSteppingAction.cc.

Referenced by update().

◆ volEESD_

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

Definition at line 113 of file CaloSteppingAction.cc.

Referenced by update().

◆ volHCSD_

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

Definition at line 113 of file CaloSteppingAction.cc.

Referenced by update().

◆ xtalMap_

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

Definition at line 114 of file CaloSteppingAction.cc.

Referenced by update().