CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

int allSteps_
 
double birkC1EC_
 
double birkC1HC_
 
double birkC2HC_
 
double birkC3HC_
 
double birkCutEC_
 
double birkSlopeEC_
 
int count_
 
std::unique_ptr
< EcalBarrelNumberingScheme
ebNumberingScheme_
 
std::unique_ptr
< EcalEndcapNumberingScheme
eeNumberingScheme_
 
int eventID_
 
std::unique_ptr
< HcalNumberingFromPS
hcNumberingPS_
 
std::unique_ptr
< HcalNumberingScheme
hcNumberingScheme_
 
std::map< std::pair< int,
CaloHitID >, CaloGVHit
hitMap_ [nSD_]
 
std::map< const
G4LogicalVolume *, std::string > 
mapLV_
 
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< PassiveDatastore_
 
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 67 of file CaloSteppingAction.cc.

Member Typedef Documentation

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

Definition at line 120 of file CaloSteppingAction.cc.

Constructor & Destructor Documentation

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

Definition at line 124 of file CaloSteppingAction.cc.

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

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

References count_.

174  {
175  edm::LogVerbatim("Step") << "CaloSteppingAction: --------> Total number of "
176  << "selected entries : " << count_;
177 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

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

Reimplemented from SimWatcher.

Definition at line 229 of file CaloSteppingAction.cc.

References edm::EventSetup::getData().

229  {
230  edm::LogVerbatim("Step") << "CaloSteppingAction:: Enter BeginOfRun";
231 
232 #ifdef HcalNumberingTest
233  // Numbering From DDD
234  const HcalDDDSimConstants* hcons_ = &es.getData(ddconsToken_);
235  edm::LogVerbatim("Step") << "CaloSteppingAction:: Initialise "
236  << "HcalNumberingFromDDD";
237  hcNumbering_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
238 #endif
239 }
Log< level::Info, true > LogVerbatim
double CaloSteppingAction::curve_LY ( double  crystalLength,
double  crystalDepth 
) const
private

Definition at line 483 of file CaloSteppingAction.cc.

References slopeLY_, and histoStyle::weight.

Referenced by update().

483  {
484  double weight = 1.;
485  double dapd = crystalLength - crystalDepth;
486  if (dapd >= -0.1 || dapd <= crystalLength + 0.1) {
487  if (dapd <= 100.)
488  weight = 1.0 + slopeLY_ - dapd * 0.01 * slopeLY_;
489 #ifdef EDM_ML_DEBUG
490  edm::LogVerbatim("Step") << "CaloSteppingAction::curve_LY " << crystalDepth << ":" << crystalLength << ":" << dapd
491  << ":" << weight;
492 #endif
493  } else {
494  edm::LogWarning("Step") << "CaloSteppingAction: light coll curve : wrong "
495  << "distance to APD " << dapd << " crlength = " << crystalLength
496  << " crystal Depth = " << crystalDepth << " weight = " << weight;
497  }
498  return weight;
499 }
Log< level::Info, true > LogVerbatim
Log< level::Warning, false > LogWarning
int weight
Definition: histoStyle.py:51
void CaloSteppingAction::fillHit ( uint32_t  id,
double  dE,
double  time,
int  primID,
uint16_t  depth,
double  em,
int  flag 
)
private

Definition at line 456 of file CaloSteppingAction.cc.

References CaloGVHit::addEnergyDeposit(), dataset::end, eventID_, hitMap_, CaloGVHit::setEventID(), CaloGVHit::setID(), and timeSliceUnit_.

Referenced by update().

456  {
457  CaloHitID currentID(id, time, primID, depth, timeSliceUnit_);
458  double edepEM = (em ? dE : 0);
459  double edepHAD = (em ? 0 : dE);
460  std::pair<int, CaloHitID> evID = std::make_pair(eventID_, currentID);
461  auto it = hitMap_[flag].find(evID);
462  if (it != hitMap_[flag].end()) {
463  (it->second).addEnergyDeposit(edepEM, edepHAD);
464  } else {
465  CaloGVHit aHit;
466  aHit.setEventID(eventID_);
467  aHit.setID(currentID);
468  aHit.addEnergyDeposit(edepEM, edepHAD);
469  hitMap_[flag][evID] = aHit;
470  }
471 }
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
string end
Definition: dataset.py:937
void CaloSteppingAction::fillHits ( edm::PCaloHitContainer cc,
int  type 
)
private

Definition at line 200 of file CaloSteppingAction.cc.

References slave_.

Referenced by produce().

200  {
201  edm::LogVerbatim("Step") << "CaloSteppingAction::fillHits for type " << type << " with "
202  << slave_[type].get()->hits().size() << " hits";
203  cc = slave_[type].get()->hits();
204  slave_[type].get()->Clean();
205 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
void CaloSteppingAction::fillPassiveHits ( edm::PassiveHitContainer cc)
private

Definition at line 207 of file CaloSteppingAction.cc.

References mapLV_, and store_.

Referenced by produce().

207  {
208  edm::LogVerbatim("Step") << "CaloSteppingAction::fillPassiveHits with " << store_.size() << " hits";
209  for (const auto& element : store_) {
210  auto lv = std::get<0>(element);
211  auto it = mapLV_.find(lv);
212  if (it != mapLV_.end()) {
213  PassiveHit hit(it->second,
214  std::get<1>(element),
215  std::get<5>(element),
216  std::get<6>(element),
217  std::get<4>(element),
218  std::get<2>(element),
219  std::get<3>(element),
220  std::get<7>(element),
221  std::get<8>(element),
222  std::get<9>(element),
223  std::get<10>(element));
224  cc.emplace_back(hit);
225  }
226  }
227 }
Log< level::Info, true > LogVerbatim
std::map< const G4LogicalVolume *, std::string > mapLV_
std::vector< PassiveData > store_
double CaloSteppingAction::getBirkHC ( double  dE,
double  step,
double  chg,
double  dens 
) const
private

Definition at line 521 of file CaloSteppingAction.cc.

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

Referenced by update().

521  {
522  double weight = 1.;
523  if (charge != 0. && step > 0.) {
524  double dedx = dEStep / step;
525  double rkb = birkC1HC_ / density;
526  double c = birkC2HC_ * rkb * rkb;
527  if (std::abs(charge) >= 2.)
528  rkb /= birkC3HC_;
529  weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
530 #ifdef EDM_ML_DEBUG
531  edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkHC Charge " << charge << " dE/dx " << dedx << " Birk Const "
532  << rkb << ", " << c << " Weight = " << weight << " dE " << dEStep;
533 #endif
534  }
535  return weight;
536 }
Log< level::Info, true > LogVerbatim
const edm::EventSetup & c
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
step
Definition: StallMonitor.cc:94
int weight
Definition: histoStyle.py:51
double CaloSteppingAction::getBirkL3 ( double  dE,
double  step,
double  chg,
double  dens 
) const
private

Definition at line 501 of file CaloSteppingAction.cc.

References birkC1EC_, birkCutEC_, birkSlopeEC_, log, and histoStyle::weight.

Referenced by update().

501  {
502  double weight = 1.;
503  if (charge != 0. && step > 0.) {
504  double dedx = dEStep / step;
505  double rkb = birkC1EC_ / density;
506  if (dedx > 0) {
507  weight = 1. - birkSlopeEC_ * log(rkb * dedx);
508  if (weight < birkCutEC_)
509  weight = birkCutEC_;
510  else if (weight > 1.)
511  weight = 1.;
512  }
513 #ifdef EDM_ML_DEBUG
514  edm::LogVerbatim("Step") << "CaloSteppingAction::getBirkL3 Charge " << charge << " dE/dx " << dedx << " Birk Const "
515  << rkb << " Weight = " << weight << " dE " << dEStep << " step " << step;
516 #endif
517  }
518  return weight;
519 }
Log< level::Info, true > LogVerbatim
static std::vector< std::string > checklist log
step
Definition: StallMonitor.cc:94
int weight
Definition: histoStyle.py:51
uint16_t CaloSteppingAction::getDepth ( bool  flag,
double  crystalDepth,
double  radl 
) const
private

Definition at line 473 of file CaloSteppingAction.cc.

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

Referenced by update().

473  {
474  uint16_t depth1 = (flag ? 0 : PCaloHit::kEcalDepthRefz);
475  uint16_t depth2 = (uint16_t)floor(crystalDepth / radl);
476  uint16_t depth = (((depth2 & PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1);
477 #ifdef EDM_ML_DEBUG
478  edm::LogVerbatim("Step") << "CaloSteppingAction::getDepth radl " << radl << ":" << crystalDepth << " depth " << depth;
479 #endif
480  return depth;
481 }
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
uint32_t CaloSteppingAction::getDetIDHC ( int  det,
int  lay,
int  depth,
const math::XYZVectorD pos 
) const
private

Definition at line 444 of file CaloSteppingAction.cc.

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

Referenced by update().

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

Definition at line 430 of file CaloSteppingAction.cc.

References Exception, and edm::isNotFinite().

Referenced by update().

430  {
431  auto currentPos = aStep->GetTrack()->GetPosition();
432  double xyz = currentPos.x() + currentPos.y() + currentPos.z();
433  auto currentMom = aStep->GetTrack()->GetMomentum();
434  xyz += currentMom.x() + currentMom.y() + currentMom.z();
435 
436  if (edm::isNotFinite(xyz)) {
437  auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
438  auto& nameOfVol = pCurrentVol->GetName();
439  throw cms::Exception("Unknown", "CaloSteppingAction")
440  << " Corrupted Event - NaN detected in volume " << nameOfVol << "\n";
441  }
442 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void CaloSteppingAction::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 186 of file CaloSteppingAction.cc.

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

186  {
187  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
188  saveHits(k);
189  auto product = std::make_unique<edm::PCaloHitContainer>();
190  fillHits(*product, k);
191  e.put(std::move(product), nameHitC_[k]);
192  }
193  if (allSteps_ != 0) {
194  std::unique_ptr<edm::PassiveHitContainer> hgcPH(new edm::PassiveHitContainer);
195  fillPassiveHits(*hgcPH);
196  e.put(std::move(hgcPH), "AllPassiveHits");
197  }
198 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void fillHits(edm::PCaloHitContainer &cc, int type)
std::vector< std::string > nameHitC_
def move
Definition: eostools.py:511
void fillPassiveHits(edm::PassiveHitContainer &cc)
std::vector< PassiveHit > PassiveHitContainer
Definition: PassiveHit.h:100
static const int nSD_
void CaloSteppingAction::registerConsumes ( edm::ConsumesCollector  cc)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 179 of file CaloSteppingAction.cc.

References edm::BeginRun, and edm::ConsumesCollector::esConsumes().

179  {
180 #ifdef HcalNumberingTest
182  edm::LogVerbatim("Step") << "CaloSteppingAction::Initialize ESGetToken for HcalDDDSimConstants";
183 #endif
184 }
Log< level::Info, true > LogVerbatim
void CaloSteppingAction::saveHits ( int  flag)
private

Definition at line 538 of file CaloSteppingAction.cc.

References hitMap_, findQualityFiles::size, and slave_.

Referenced by produce().

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

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

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

References allSteps_, SplitLinear::begin, dataset::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().

316  {
317  eventID_ = (*evt)()->GetEventID();
318  edm::LogVerbatim("Step") << "CaloSteppingAction: Begin of event = " << eventID_;
319  for (int k = 0; k < CaloSteppingAction::nSD_; ++k) {
320  hitMap_[k].erase(hitMap_[k].begin(), hitMap_[k].end());
321  slave_[k].get()->Initialize();
322  }
323  if (allSteps_ != 0)
324  store_.clear();
325 }
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
Log< level::Info, true > LogVerbatim
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
string end
Definition: dataset.py:937
std::vector< PassiveData > store_
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 328 of file CaloSteppingAction.cc.

References funct::abs(), EcalBaseNumber::addLevel(), allSteps_, filterCSVwithJSON::copy, curve_LY(), HLT_FULL_cff::depth, ebNumberingScheme_, eeNumberingScheme_, relval_parameters_module::energy, fillHit(), spr::find(), g, getBirkHC(), getBirkL3(), EcalBaseNumber::getCapacity(), getDepth(), getDetIDHC(), cuy::ii, G4TrackToParticleID::isGammaElectronPositron(), submitPVResolutionJobs::key, mapLV_, MeV, NaNTrap(), EcalBaseNumber::setSize(), findQualityFiles::size, store_, volEBSD_, volEESD_, volHCSD_, and xtalMap_.

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

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 424 of file CaloSteppingAction.cc.

References count_.

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

424  {
425  ++count_;
426  // Fill event input
427  edm::LogVerbatim("Step") << "CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID();
428 }
Log< level::Info, true > LogVerbatim

Member Data Documentation

int CaloSteppingAction::allSteps_
private

Definition at line 114 of file CaloSteppingAction.cc.

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

double CaloSteppingAction::birkC1EC_
private

Definition at line 115 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkL3().

double CaloSteppingAction::birkC1HC_
private

Definition at line 116 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkHC().

double CaloSteppingAction::birkC2HC_
private

Definition at line 116 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkHC().

double CaloSteppingAction::birkC3HC_
private

Definition at line 117 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkHC().

double CaloSteppingAction::birkCutEC_
private

Definition at line 116 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkL3().

double CaloSteppingAction::birkSlopeEC_
private

Definition at line 115 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getBirkL3().

int CaloSteppingAction::count_
private

Definition at line 114 of file CaloSteppingAction.cc.

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

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

Definition at line 99 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

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

Definition at line 100 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

int CaloSteppingAction::eventID_
private

Definition at line 114 of file CaloSteppingAction.cc.

Referenced by fillHit(), and update().

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

Definition at line 101 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getDetIDHC().

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

Definition at line 106 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and getDetIDHC().

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

Definition at line 118 of file CaloSteppingAction.cc.

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

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

Definition at line 113 of file CaloSteppingAction.cc.

Referenced by fillPassiveHits(), and update().

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

Definition at line 109 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

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

Definition at line 109 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

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

Definition at line 109 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and update().

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

Definition at line 110 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and produce().

const int CaloSteppingAction::nSD_ = 3
staticprivate

Definition at line 98 of file CaloSteppingAction.cc.

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

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

Definition at line 107 of file CaloSteppingAction.cc.

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

double CaloSteppingAction::slopeLY_
private

Definition at line 115 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and curve_LY().

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

Definition at line 121 of file CaloSteppingAction.cc.

Referenced by fillPassiveHits(), and update().

double CaloSteppingAction::timeSliceUnit_
private

Definition at line 117 of file CaloSteppingAction.cc.

Referenced by CaloSteppingAction(), and fillHit().

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

Definition at line 111 of file CaloSteppingAction.cc.

Referenced by update().

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

Definition at line 111 of file CaloSteppingAction.cc.

Referenced by update().

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

Definition at line 111 of file CaloSteppingAction.cc.

Referenced by update().

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

Definition at line 112 of file CaloSteppingAction.cc.

Referenced by update().