CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
CaloTrkProcessing Class Reference

#include <CaloTrkProcessing.h>

Inheritance diagram for CaloTrkProcessing:
SensitiveCaloDetector Observer< const BeginOfEvent *> Observer< const G4Step *> SensitiveDetector

Classes

struct  Detector
 

Public Member Functions

 CaloTrkProcessing (const std::string &aSDname, const CaloSimulationParameters &csps, const SensitiveDetectorCatalog &clg, bool testBeam, double eMin, bool putHistory, bool doFineCalo, double eMinFine, int addlevel, const std::vector< std::string > &fineNames, const std::vector< int > &fineLevels, const std::vector< int > &useFines, const SimTrackManager *)
 
void clearHits () override
 
void EndOfEvent (G4HCofThisEvent *) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *) override
 
bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
uint32_t setDetUnitId (const G4Step *step) override
 
 ~CaloTrkProcessing () override
 
- Public Member Functions inherited from SensitiveCaloDetector
virtual void reset ()
 
 SensitiveCaloDetector (const std::string &iname, const SensitiveDetectorCatalog &clg)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
bool isCaloSD () const
 
 SensitiveDetector (const std::string &iname, const SensitiveDetectorCatalog &, bool calo)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfEvent *>
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step *>
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Member Functions

void detectorLevel (const G4VTouchable *, int &, int *, G4String *) const
 
int detLevels (const G4VTouchable *) const
 
G4LogicalVolume * detLV (const G4VTouchable *, int) const
 
int isItCalo (const G4VTouchable *, const std::vector< Detector > &)
 
int isItInside (const G4VTouchable *, int, int)
 
void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

const int addlevel_
 
std::vector< Detectordetectors_
 
bool doFineCalo_
 
const double eMin_
 
const double eMinFine_
 
std::vector< DetectorfineDetectors_
 
int lastTrackID_
 
const bool putHistory_
 
const bool testBeam_
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Member Functions inherited from SensitiveDetector
TrackInformationcmsTrackInformation (const G4Track *aTrack)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 

Detailed Description

Definition at line 27 of file CaloTrkProcessing.h.

Constructor & Destructor Documentation

◆ CaloTrkProcessing()

CaloTrkProcessing::CaloTrkProcessing ( const std::string &  aSDname,
const CaloSimulationParameters csps,
const SensitiveDetectorCatalog clg,
bool  testBeam,
double  eMin,
bool  putHistory,
bool  doFineCalo,
double  eMinFine,
int  addlevel,
const std::vector< std::string > &  fineNames,
const std::vector< int > &  fineLevels,
const std::vector< int > &  useFines,
const SimTrackManager  
)

Definition at line 21 of file CaloTrkProcessing.cc.

References addlevel_, CaloSimulationParameters::caloNames_, hgcalTestNeighbor_cfi::detector, detectors_, doFineCalo_, eMin_, Exception, fineDetectors_, mps_fire::i, CaloSimulationParameters::insideLevel_, CaloSimulationParameters::insideNames_, dqmdumpme::k, CaloSimulationParameters::levels_, Skims_PA_cff::name, CaloSimulationParameters::neighbours_, putHistory_, and testBeam_.

35  testBeam_(testBeam),
36  eMin_(eMin),
37  putHistory_(putHistory),
38  doFineCalo_(doFineCalo),
39  eMinFine_(eMinFine),
40  addlevel_(addlevel),
41  lastTrackID_(-1) {
42  //Initialise the parameter set
43 
44  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Initialised with TestBeam = " << testBeam_ << " Emin = " << eMin_
45  << " Flags " << putHistory_ << " (History), " << doFineCalo_ << " (Special Calorimeter)";
46  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Have a possibility of " << fineNames.size()
47  << " fine calorimeters of which " << useFines.size() << " are selected";
48  for (unsigned int k = 0; k < fineNames.size(); ++k)
49  edm::LogVerbatim("CaloSim") << "[" << k << "] " << fineNames[k] << " at " << fineLevels[k];
50  std::ostringstream st1;
51  for (unsigned int k = 0; k < useFines.size(); ++k)
52  st1 << " [" << k << "] " << useFines[k] << ":" << fineNames[useFines[k]];
53  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing used calorimeters" << st1.str();
54 
55  // Debug prints
56  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: " << csps.caloNames_.size() << " entries for caloNames:";
57  for (unsigned int i = 0; i < csps.caloNames_.size(); i++)
58  edm::LogVerbatim("CaloSim") << " (" << i << ") " << csps.caloNames_[i];
59  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: " << csps.levels_.size() << " entries for levels:";
60  for (unsigned int i = 0; i < csps.levels_.size(); i++)
61  edm::LogVerbatim("CaloSim") << " (" << i << ") " << (csps.levels_[i] + addlevel_);
62  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: " << csps.neighbours_.size() << " entries for neighbours:";
63  for (unsigned int i = 0; i < csps.neighbours_.size(); i++)
64  edm::LogVerbatim("CaloSim") << " (" << i << ") " << csps.neighbours_[i];
65  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: " << csps.insideNames_.size() << " entries for insideNames:";
66  for (unsigned int i = 0; i < csps.insideNames_.size(); i++)
67  edm::LogVerbatim("CaloSim") << " (" << i << ") " << csps.insideNames_[i];
68  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: " << csps.insideLevel_.size() << " entries for insideLevel:";
69  for (unsigned int i = 0; i < csps.insideLevel_.size(); i++)
70  edm::LogVerbatim("CaloSim") << " (" << i << ") " << (csps.insideLevel_[i] + addlevel_);
71 
72  if (csps.caloNames_.size() < csps.neighbours_.size()) {
73  edm::LogError("CaloSim") << "CaloTrkProcessing: # of Calorimeter bins " << csps.caloNames_.size()
74  << " does not match with " << csps.neighbours_.size() << " ==> illegal ";
75  throw cms::Exception("Unknown", "CaloTrkProcessing")
76  << "Calorimeter array size does not match with size of neighbours\n";
77  }
78 
79  const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
80  std::vector<G4LogicalVolume*>::const_iterator lvcite;
81  int istart = 0;
82  for (unsigned int i = 0; i < csps.caloNames_.size(); i++) {
83  G4LogicalVolume* lv = nullptr;
84  G4String name(csps.caloNames_[i]);
85  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
86  G4String namx(static_cast<std::string>(dd4hep::dd::noNamespace((*lvcite)->GetName())));
87  if (namx == name) {
88  lv = (*lvcite);
89  break;
90  }
91  }
92  if (lv != nullptr) {
94  detector.name = name;
95  detector.lv = lv;
96  detector.level = (csps.levels_[i] + addlevel_);
97  if (istart + csps.neighbours_[i] > static_cast<int>(csps.insideNames_.size())) {
98  edm::LogError("CaloSim") << "CaloTrkProcessing: # of InsideNames bins " << csps.insideNames_.size()
99  << " too few compaerd to " << istart + csps.neighbours_[i]
100  << " requested ==> illegal ";
101  throw cms::Exception("Unknown", "CaloTrkProcessing")
102  << "InsideNames array size does not match with list of neighbours\n";
103  }
104  std::vector<std::string> inside;
105  std::vector<G4LogicalVolume*> insideLV;
106  std::vector<int> insideLevels;
107  for (int k = 0; k < csps.neighbours_[i]; k++) {
108  lv = nullptr;
109  name = static_cast<G4String>(csps.insideNames_[istart + k]);
110  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
111  G4String namx(static_cast<std::string>(dd4hep::dd::noNamespace((*lvcite)->GetName())));
112  if (namx == name) {
113  lv = (*lvcite);
114  break;
115  }
116  }
117  inside.push_back(name);
118  insideLV.push_back(lv);
119  insideLevels.push_back(csps.insideLevel_[istart + k] + addlevel_);
120  }
121  detector.fromDets = inside;
122  detector.fromDetL = insideLV;
123  detector.fromLevels = insideLevels;
124  detectors_.emplace_back(detector);
125  }
126  istart += csps.neighbours_[i];
127  }
128 
129  for (unsigned int i = 0; i < useFines.size(); i++) {
130  G4LogicalVolume* lv = nullptr;
131  G4String name = static_cast<G4String>(fineNames[useFines[i]]);
132  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
133  G4String namx(static_cast<std::string>(dd4hep::dd::noNamespace((*lvcite)->GetName())));
134  if (namx == name) {
135  lv = (*lvcite);
136  break;
137  }
138  }
139  if (lv != nullptr) {
141  detector.name = name;
142  detector.lv = lv;
143  detector.level = fineLevels[useFines[i]];
144  detector.fromDets.clear();
145  detector.fromDetL.clear();
146  detector.fromLevels.clear();
147  fineDetectors_.emplace_back(detector);
148  }
149  }
150 
151  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: with " << detectors_.size() << " calorimetric volumes";
152  for (unsigned int i = 0; i < detectors_.size(); i++) {
153  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Calorimeter volume " << i << " " << detectors_[i].name << " LV "
154  << detectors_[i].lv << " at level " << detectors_[i].level << " with "
155  << detectors_[i].fromDets.size() << " neighbours";
156  for (unsigned int k = 0; k < detectors_[i].fromDets.size(); k++)
157  edm::LogVerbatim("CaloSim") << " Element " << k << " " << detectors_[i].fromDets[k] << " LV "
158  << detectors_[i].fromDetL[k] << " at level " << detectors_[i].fromLevels[k];
159  }
160 
161  doFineCalo_ = doFineCalo_ && !(fineDetectors_.empty());
162  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: with " << fineDetectors_.size() << " special calorimetric volumes";
163  for (unsigned int i = 0; i < detectors_.size(); i++)
164  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: Calorimeter volume " << i << " " << detectors_[i].name << " LV "
165  << detectors_[i].lv << " at level " << detectors_[i].level;
166 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > insideNames_
const double eMinFine_
Log< level::Error, false > LogError
SensitiveCaloDetector(const std::string &iname, const SensitiveDetectorCatalog &clg)
std::vector< Detector > fineDetectors_
std::vector< std::string > caloNames_
std::vector< Detector > detectors_

◆ ~CaloTrkProcessing()

CaloTrkProcessing::~CaloTrkProcessing ( )
override

Definition at line 168 of file CaloTrkProcessing.cc.

168 {}

Member Function Documentation

◆ clearHits()

void CaloTrkProcessing::clearHits ( )
inlineoverridevirtual

Implements SensitiveDetector.

Definition at line 46 of file CaloTrkProcessing.h.

46 {}

◆ detectorLevel()

void CaloTrkProcessing::detectorLevel ( const G4VTouchable *  touch,
int &  level,
int *  copyno,
G4String *  name 
) const
private

Definition at line 423 of file CaloTrkProcessing.cc.

References detLevels(), mps_fire::i, cuy::ii, personalPlayback::level, Skims_PA_cff::name, MetAnalyzer::pv(), AlCaHLTBitMon_QueryRunRegistry::string, and susybsm::HSCParticleType::unknown.

Referenced by isItCalo(), and isItInside().

423  {
424  static const std::string unknown("Unknown");
425  //Get name and copy numbers
426  if (level > 0) {
427  for (int ii = 0; ii < level; ii++) {
428  int i = level - ii - 1;
429  G4VPhysicalVolume* pv = touch->GetVolume(i);
430  if (pv != nullptr)
431  name[ii] = pv->GetName();
432  else
433  name[ii] = unknown;
434  copyno[ii] = touch->GetReplicaNumber(i);
435  }
436  }
437 #ifdef EDM_ML_DEBUG
438  edm::LogVerbatim("CaloSimX") << "CaloTrkProcessing::detectorLevel "
439  << " with " << level << ":" << detLevels(touch) << " levels";
440  for (int ii = 0; ii < level; ii++)
441  edm::LogVerbatim("CaloSimX") << "[" << ii << "] " << name[ii] << ":" << copyno[ii];
442 #endif
443 }
Log< level::Info, true > LogVerbatim
def pv(vc)
Definition: MetAnalyzer.py:7
int detLevels(const G4VTouchable *) const
ii
Definition: cuy.py:589

◆ detLevels()

int CaloTrkProcessing::detLevels ( const G4VTouchable *  touch) const
private

Definition at line 402 of file CaloTrkProcessing.cc.

Referenced by detectorLevel(), isItCalo(), and isItInside().

402  {
403  //Return number of levels
404  if (touch)
405  return ((touch->GetHistoryDepth()) + 1);
406  else
407  return 0;
408 }

◆ detLV()

G4LogicalVolume * CaloTrkProcessing::detLV ( const G4VTouchable *  touch,
int  currentlevel 
) const
private

Definition at line 410 of file CaloTrkProcessing.cc.

References cuy::ii, and personalPlayback::level.

Referenced by isItCalo(), and isItInside().

410  {
411  G4LogicalVolume* lv = nullptr;
412  if (touch) {
413  int level = ((touch->GetHistoryDepth()) + 1);
414  if (level > 0 && level >= currentlevel) {
415  int ii = level - currentlevel;
416  lv = touch->GetVolume(ii)->GetLogicalVolume();
417  return lv;
418  }
419  }
420  return lv;
421 }
ii
Definition: cuy.py:589

◆ EndOfEvent()

void CaloTrkProcessing::EndOfEvent ( G4HCofThisEvent *  )
inlineoverride

Definition at line 49 of file CaloTrkProcessing.h.

49 {}

◆ fillHits()

void CaloTrkProcessing::fillHits ( edm::PCaloHitContainer ,
const std::string &   
)
inlineoverridevirtual

Implements SensitiveCaloDetector.

Definition at line 50 of file CaloTrkProcessing.h.

50 {}

◆ Initialize()

void CaloTrkProcessing::Initialize ( G4HCofThisEvent *  )
inlineoverride

Definition at line 45 of file CaloTrkProcessing.h.

45 {}

◆ isItCalo()

int CaloTrkProcessing::isItCalo ( const G4VTouchable *  touch,
const std::vector< Detector > &  detectors 
)
private

Definition at line 312 of file CaloTrkProcessing.cc.

References detectorLevel(), MuonGeometrySanityCheck_cfi::detectors(), detLevels(), detLV(), testProducerWithPsetDescEmpty_cfi::i2, personalPlayback::level, jetsAK4_CHS_cff::levels, hfnoseParametersInitialization_cfi::name2, convertSQLiteXML::ok, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by update().

312  {
313  int lastLevel = -1;
314  G4LogicalVolume* lv = nullptr;
315  for (unsigned int it = 0; it < detectors.size(); it++) {
316  if (lastLevel != detectors[it].level) {
317  lastLevel = detectors[it].level;
318  lv = detLV(touch, lastLevel);
319 #ifdef EDM_ML_DEBUG
320  std::string name1 = "Unknown";
321  if (lv != 0)
322  name1 = lv->GetName();
323  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: volume " << name1 << " at Level " << lastLevel;
324  int levels = detLevels(touch);
325  if (levels > 0) {
326  G4String name2[20];
327  int copyno2[20];
328  detectorLevel(touch, levels, copyno2, name2);
329  for (int i2 = 0; i2 < levels; i2++)
330  edm::LogVerbatim("CaloSim") << " " << i2 << " " << name2[i2] << " " << copyno2[i2];
331  }
332 #endif
333  }
334  bool ok = (lv == detectors[it].lv);
335  if (ok)
336  return it;
337  }
338  return -1;
339 }
Log< level::Info, true > LogVerbatim
G4LogicalVolume * detLV(const G4VTouchable *, int) const
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, layers=False)
int detLevels(const G4VTouchable *) const

◆ isItInside()

int CaloTrkProcessing::isItInside ( const G4VTouchable *  touch,
int  idcal,
int  idin 
)
private

Definition at line 341 of file CaloTrkProcessing.cc.

References detectorLevel(), detectors_, detLevels(), detLV(), testProducerWithPsetDescEmpty_cfi::i2, globals_cff::id1, globals_cff::id2, jetsAK4_CHS_cff::levels, hfnoseParametersInitialization_cfi::name2, convertSQLiteXML::ok, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by update().

341  {
342  int lastLevel = -1;
343  G4LogicalVolume* lv = nullptr;
344  int id1, id2;
345  if (idcal < 0) {
346  id1 = 0;
347  id2 = static_cast<int>(detectors_.size());
348  } else {
349  id1 = idcal;
350  id2 = id1 + 1;
351  }
352  for (int it1 = id1; it1 < id2; it1++) {
353  if (idin < 0) {
354  for (unsigned int it2 = 0; it2 < detectors_[it1].fromDets.size(); it2++) {
355  if (lastLevel != detectors_[it1].fromLevels[it2]) {
356  lastLevel = detectors_[it1].fromLevels[it2];
357  lv = detLV(touch, lastLevel);
358 #ifdef EDM_ML_DEBUG
359  std::string name1 = "Unknown";
360  if (lv != 0)
361  name1 = lv->GetName();
362  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: volume " << name1 << " at Level " << lastLevel;
363  int levels = detLevels(touch);
364  if (levels > 0) {
365  G4String name2[20];
366  int copyno2[20];
367  detectorLevel(touch, levels, copyno2, name2);
368  for (int i2 = 0; i2 < levels; i2++)
369  edm::LogVerbatim("CaloSim") << " " << i2 << " " << name2[i2] << " " << copyno2[i2];
370  }
371 #endif
372  }
373  bool ok = (lv == detectors_[it1].fromDetL[it2]);
374  if (ok)
375  return it2;
376  }
377  } else {
378  lastLevel = detectors_[it1].fromLevels[idin];
379  lv = detLV(touch, lastLevel);
380 #ifdef EDM_ML_DEBUG
381  std::string name1 = "Unknown";
382  if (lv != 0)
383  name1 = lv->GetName();
384  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: volume " << name1 << " at Level " << lastLevel;
385  int levels = detLevels(touch);
386  if (levels > 0) {
387  G4String name2[20];
388  int copyno2[20];
389  detectorLevel(touch, levels, copyno2, name2);
390  for (int i2 = 0; i2 < levels; i2++)
391  edm::LogVerbatim("CaloSim") << " " << i2 << " " << name2[i2] << " " << copyno2[i2];
392  }
393 #endif
394  bool ok = (lv == detectors_[it1].fromDetL[idin]);
395  if (ok)
396  return idin;
397  }
398  }
399  return -1;
400 }
Log< level::Info, true > LogVerbatim
G4LogicalVolume * detLV(const G4VTouchable *, int) const
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
int detLevels(const G4VTouchable *) const
std::vector< Detector > detectors_

◆ ProcessHits()

bool CaloTrkProcessing::ProcessHits ( G4Step *  ,
G4TouchableHistory *   
)
inlineoverridevirtual

Implements SensitiveDetector.

Definition at line 47 of file CaloTrkProcessing.h.

47 { return true; }

◆ setDetUnitId()

uint32_t CaloTrkProcessing::setDetUnitId ( const G4Step *  step)
inlineoverridevirtual

Implements SensitiveDetector.

Definition at line 48 of file CaloTrkProcessing.h.

48 { return 0; }

◆ update() [1/2]

void CaloTrkProcessing::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 170 of file CaloTrkProcessing.cc.

References lastTrackID_.

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

170 { lastTrackID_ = -1; }

◆ update() [2/2]

void CaloTrkProcessing::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 172 of file CaloTrkProcessing.cc.

References TrackInformation::caloIDChecked(), TrackInformation::crossedBoundary(), detectors_, doFineCalo_, eMin_, Exception, fineDetectors_, TrackInformation::getIDCaloVolume(), TrackInformation::getIDLastVolume(), TrackInformation::getIDonCaloSurface(), l1ctLayer2EG_cff::id, isItCalo(), isItInside(), lastTrackID_, putHistory_, TrackInformation::putInHistory(), TrackInformation::setCaloIDChecked(), TrackInformation::setCrossedBoundary(), TrackInformation::setIDonCaloSurface(), TrackInformation::setStartedInFineVolume(), TrackInformation::startedInFineVolume(), TrackInformation::startedInFineVolumeIsSet(), and testBeam_.

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

172  {
173  // define if you are at the surface of CALO
174 
175  G4Track* theTrack = aStep->GetTrack();
176  int id = theTrack->GetTrackID();
177 
178  TrackInformation* trkInfo = dynamic_cast<TrackInformation*>(theTrack->GetUserInformation());
179 
180  if (trkInfo == nullptr) {
181  edm::LogError("CaloSim") << "CaloTrkProcessing: No trk info !!!! abort ";
182  throw cms::Exception("Unknown", "CaloTrkProcessing") << "cannot get trkInfo for Track " << id << "\n";
183  }
184 
185  if (doFineCalo_) {
186  int prestepLV = isItCalo(aStep->GetPreStepPoint()->GetTouchable(), fineDetectors_);
187  int poststepLV = isItCalo(aStep->GetPostStepPoint()->GetTouchable(), fineDetectors_);
188 
189  // Once per track, determine whether track started in fine volume
190  if (!trkInfo->startedInFineVolumeIsSet())
191  trkInfo->setStartedInFineVolume(prestepLV >= 0);
192 
193  // Boundary-crossing logic
194  if (prestepLV < 0 && poststepLV >= 0) {
195 #ifdef EDM_ML_DEBUG
196  edm::LogVerbatim("DoFineCalo") << "Track " << id << " entered a fine volume:"
197  << " pdgid=" << theTrack->GetDefinition()->GetPDGEncoding()
198  << " theTrack->GetCurrentStepNumber()=" << theTrack->GetCurrentStepNumber()
199  << " prestepLV=" << prestepLV << " poststepLV=" << poststepLV
200  << " GetKineticEnergy[GeV]=" << theTrack->GetKineticEnergy() / CLHEP::GeV
201  << " prestepPosition[cm]=("
202  << theTrack->GetStep()->GetPreStepPoint()->GetPosition().x() / CLHEP::cm << ","
203  << theTrack->GetStep()->GetPreStepPoint()->GetPosition().y() / CLHEP::cm << ","
204  << theTrack->GetStep()->GetPreStepPoint()->GetPosition().z() / CLHEP::cm << ")"
205  << " poststepPosition[cm]=("
206  << theTrack->GetStep()->GetPostStepPoint()->GetPosition().x() / CLHEP::cm << ","
207  << theTrack->GetStep()->GetPostStepPoint()->GetPosition().y() / CLHEP::cm << ","
208  << theTrack->GetStep()->GetPostStepPoint()->GetPosition().z() / CLHEP::cm << ")"
209  << " position[cm]=(" << theTrack->GetPosition().x() / CLHEP::cm << ","
210  << theTrack->GetPosition().y() / CLHEP::cm << ","
211  << theTrack->GetPosition().z() / CLHEP::cm << ")"
212  << " vertex_position[cm]=(" << theTrack->GetVertexPosition().x() / CLHEP::cm << ","
213  << theTrack->GetVertexPosition().y() / CLHEP::cm << ","
214  << theTrack->GetVertexPosition().z() / CLHEP::cm << ")"
215  << " GetVertexKineticEnergy[GeV]="
216  << theTrack->GetVertexKineticEnergy() / CLHEP::GeV;
217 #endif
218  if (!trkInfo->startedInFineVolume() && !trkInfo->crossedBoundary()) {
219  trkInfo->setCrossedBoundary(theTrack);
220 #ifdef EDM_ML_DEBUG
221  edm::LogVerbatim("DoFineCalo") << "Track " << id << " marked as boundary-crossing; sanity check:"
222  << " theTrack->GetTrackID()=" << theTrack->GetTrackID()
223  << " trkInfo->crossedBoundary()=" << trkInfo->crossedBoundary();
224 #endif
225  }
226 #ifdef EDM_ML_DEBUG
227  else {
228  edm::LogVerbatim("DoFineCalo") << "Track " << id << " REENTERED a fine volume;"
229  << " not counting this boundary crossing!";
230  }
231 #endif
232 
233  }
234 #ifdef EDM_ML_DEBUG
235  else if (prestepLV >= 0 && poststepLV < 0) {
236  edm::LogVerbatim("DoFineCalo") << "Track " << id << " exited a fine volume:"
237  << " theTrack->GetCurrentStepNumber()=" << theTrack->GetCurrentStepNumber()
238  << " prestepLV=" << prestepLV << " poststepLV=" << poststepLV
239  << " GetKineticEnergy[GeV]=" << theTrack->GetKineticEnergy() / CLHEP::GeV
240  << " prestepPosition[cm]=("
241  << theTrack->GetStep()->GetPreStepPoint()->GetPosition().x() / CLHEP::cm << ","
242  << theTrack->GetStep()->GetPreStepPoint()->GetPosition().y() / CLHEP::cm << ","
243  << theTrack->GetStep()->GetPreStepPoint()->GetPosition().z() / CLHEP::cm << ")"
244  << " poststepPosition[cm]=("
245  << theTrack->GetStep()->GetPostStepPoint()->GetPosition().x() / CLHEP::cm << ","
246  << theTrack->GetStep()->GetPostStepPoint()->GetPosition().y() / CLHEP::cm << ","
247  << theTrack->GetStep()->GetPostStepPoint()->GetPosition().z() / CLHEP::cm << ")";
248  }
249 #endif
250  }
251 
252  if (testBeam_) {
253  if (trkInfo->getIDonCaloSurface() == 0) {
254 #ifdef EDM_ML_DEBUG
255  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing set IDonCaloSurface to " << id << " at step Number "
256  << theTrack->GetCurrentStepNumber();
257 #endif
258  trkInfo->setIDonCaloSurface(id, 0, 0, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
259  lastTrackID_ = id;
260  if (theTrack->GetKineticEnergy() / CLHEP::MeV > eMin_)
261  trkInfo->putInHistory();
262  }
263  } else {
264  if (putHistory_) {
265  trkInfo->putInHistory();
266  // trkInfo->setAncestor();
267  }
268 #ifdef EDM_ML_DEBUG
269  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing Entered for " << id << " at stepNumber "
270  << theTrack->GetCurrentStepNumber() << " IDonCaloSur.. "
271  << trkInfo->getIDonCaloSurface() << " CaloCheck " << trkInfo->caloIDChecked();
272 #endif
273  if (trkInfo->getIDonCaloSurface() != 0) {
274  if (trkInfo->caloIDChecked() == false) {
275  G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
276  const G4VTouchable* post_touch = postStepPoint->GetTouchable();
277 
278  if (isItInside(post_touch, trkInfo->getIDCaloVolume(), trkInfo->getIDLastVolume()) > 0) {
279  trkInfo->setIDonCaloSurface(0, -1, -1, 0, 0);
280  } else {
281  trkInfo->setCaloIDChecked(true);
282  }
283  }
284  } else {
285  G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
286  const G4VTouchable* post_touch = postStepPoint->GetTouchable();
287  int ical = isItCalo(post_touch, detectors_);
288  if (ical >= 0) {
289  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
290  const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
291  int inside = isItInside(pre_touch, ical, -1);
292  if (inside >= 0 || (theTrack->GetCurrentStepNumber() == 1)) {
293  trkInfo->setIDonCaloSurface(
294  id, ical, inside, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
295  trkInfo->setCaloIDChecked(true);
296  if (!doFineCalo_)
297  trkInfo->setCrossedBoundary(theTrack);
298  lastTrackID_ = id;
299  if (theTrack->GetKineticEnergy() / CLHEP::MeV > eMin_)
300  trkInfo->putInHistory();
301 #ifdef EDM_ML_DEBUG
302  edm::LogVerbatim("CaloSim") << "CaloTrkProcessing: set ID on Calo " << ical << " surface (Inside " << inside
303  << ") to " << id << " of a Track with Kinetic Energy "
304  << theTrack->GetKineticEnergy() / CLHEP::MeV << " MeV";
305 #endif
306  }
307  }
308  }
309  }
310 }
Log< level::Info, true > LogVerbatim
int getIDCaloVolume() const
bool crossedBoundary() const
Log< level::Error, false > LogError
void setStartedInFineVolume(bool flag=true)
bool caloIDChecked() const
int isItInside(const G4VTouchable *, int, int)
std::vector< Detector > fineDetectors_
int getIDonCaloSurface() const
int getIDLastVolume() const
int isItCalo(const G4VTouchable *, const std::vector< Detector > &)
bool startedInFineVolumeIsSet()
bool startedInFineVolume() const
void setCaloIDChecked(bool f)
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
void setCrossedBoundary(const G4Track *track)
std::vector< Detector > detectors_

Member Data Documentation

◆ addlevel_

const int CaloTrkProcessing::addlevel_
private

Definition at line 78 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing().

◆ detectors_

std::vector<Detector> CaloTrkProcessing::detectors_
private

Definition at line 80 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing(), isItInside(), and update().

◆ doFineCalo_

bool CaloTrkProcessing::doFineCalo_
private

Definition at line 76 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing(), and update().

◆ eMin_

const double CaloTrkProcessing::eMin_
private

Definition at line 74 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing(), and update().

◆ eMinFine_

const double CaloTrkProcessing::eMinFine_
private

Definition at line 77 of file CaloTrkProcessing.h.

◆ fineDetectors_

std::vector<Detector> CaloTrkProcessing::fineDetectors_
private

Definition at line 80 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing(), and update().

◆ lastTrackID_

int CaloTrkProcessing::lastTrackID_
private

Definition at line 79 of file CaloTrkProcessing.h.

Referenced by update().

◆ putHistory_

const bool CaloTrkProcessing::putHistory_
private

Definition at line 75 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing(), and update().

◆ testBeam_

const bool CaloTrkProcessing::testBeam_
private

Definition at line 73 of file CaloTrkProcessing.h.

Referenced by CaloTrkProcessing(), and update().