CMS 3D CMS Logo

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

#include <MtdSD.h>

Inheritance diagram for MtdSD:
TimingSD SensitiveTkDetector Observer< const BeginOfEvent *> SensitiveDetector

Public Member Functions

 MtdSD (const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
uint32_t setDetUnitId (const G4Step *) override
 
 ~MtdSD () override
 
- Public Member Functions inherited from TimingSD
void clearHits () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PSimHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
 TimingSD (const std::string &, const SensitiveDetectorCatalog &, const SimTrackManager *)
 
 ~TimingSD () override
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (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, const std::string &newcollname="")
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfEvent *>
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

int getTrackID (const G4Track *) override
 
- Protected Member Functions inherited from TimingSD
virtual bool checkHit (const G4Step *, BscG4Hit *)
 
const G4ThreeVector & getGlobalEntryPoint () const
 
const G4ThreeVector & getLocalEntryPoint () const
 
void setCuts (double eCut, double historyCut)
 
void setTimeFactor (double)
 
void setToLocal (const G4StepPoint *stepPoint, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint)
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
- 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 > &)
 

Private Member Functions

void getBaseNumber (const G4Step *)
 
void setNumberingScheme (MTDNumberingScheme *)
 

Private Attributes

double energyCut
 
double energyHistoryCut
 
bool isBTL
 
bool isETL
 
MTDNumberingSchemenumberingScheme
 
MTDBaseNumber theBaseNumber
 

Static Private Attributes

static constexpr unsigned int k_idFromCaloOffset = 3
 
static constexpr unsigned int k_idloopOffset = 2
 
static constexpr unsigned int k_idsecOffset = 1
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Detailed Description

Definition at line 19 of file MtdSD.h.

Constructor & Destructor Documentation

◆ MtdSD()

MtdSD::MtdSD ( const std::string &  name,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 20 of file MtdSD.cc.

References energyCut, energyHistoryCut, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isBTL, isETL, mergeVDriftHistosByStation::name, AlCaHLTBitMon_ParallelJobs::p, generator_cfi::scheme, TimingSD::setCuts(), setNumberingScheme(), and TimingSD::setTimeFactor().

24  : TimingSD(name, clg, manager), numberingScheme(nullptr) {
25  //Parameters
26  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("MtdSD");
27  int verbn = m_p.getUntrackedParameter<int>("Verbosity");
28 
29  SetVerboseLevel(verbn);
30 
31  MTDNumberingScheme* scheme = nullptr;
32  if (name == "FastTimerHitsBarrel") {
33  scheme = dynamic_cast<MTDNumberingScheme*>(new BTLNumberingScheme());
34  isBTL = true;
35  } else if (name == "FastTimerHitsEndcap") {
36  scheme = dynamic_cast<MTDNumberingScheme*>(new ETLNumberingScheme());
37  isETL = true;
38  } else {
39  scheme = nullptr;
40  edm::LogWarning("MtdSim") << "MtdSD: ReadoutName not supported";
41  }
42  if (scheme)
44 
45  energyCut = m_p.getParameter<double>("EnergyThresholdForPersistencyInGeV") * CLHEP::GeV; //default must be 0.5
46  energyHistoryCut = m_p.getParameter<double>("EnergyThresholdForHistoryInGeV") * CLHEP::GeV; //default must be 0.05
47 
49 
50  double newTimeFactor = 1. / m_p.getParameter<double>("TimeSliceUnit");
51  edm::LogVerbatim("MtdSim") << "New time factor = " << newTimeFactor;
52  setTimeFactor(newTimeFactor);
53 
54  edm::LogVerbatim("MtdSim") << "MtdSD: Instantiation completed for " << name;
55 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void setTimeFactor(double)
Definition: TimingSD.cc:79
bool isBTL
Definition: MtdSD.h:43
bool isETL
Definition: MtdSD.h:44
void setCuts(double eCut, double historyCut)
Definition: TimingSD.cc:89
T getUntrackedParameter(std::string const &, T const &) const
TimingSD(const std::string &, const SensitiveDetectorCatalog &, const SimTrackManager *)
Definition: TimingSD.cc:37
double energyCut
Definition: MtdSD.h:35
double energyHistoryCut
Definition: MtdSD.h:36
void setNumberingScheme(MTDNumberingScheme *)
Definition: MtdSD.cc:71
MTDNumberingScheme * numberingScheme
Definition: MtdSD.h:41
Log< level::Warning, false > LogWarning

◆ ~MtdSD()

MtdSD::~MtdSD ( )
override

Definition at line 57 of file MtdSD.cc.

57 {}

Member Function Documentation

◆ getBaseNumber()

void MtdSD::getBaseNumber ( const G4Step *  aStep)
private

Definition at line 80 of file MtdSD.cc.

References MTDBaseNumber::addLevel(), MTDBaseNumber::getCapacity(), cuy::ii, MTDBaseNumber::reset(), MTDBaseNumber::setSize(), and theBaseNumber.

Referenced by setDetUnitId().

80  {
82  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
83  int theSize = touch->GetHistoryDepth() + 1;
84  if (theBaseNumber.getCapacity() < theSize)
85  theBaseNumber.setSize(theSize);
86  //Get name and copy numbers
87  if (theSize > 1) {
88 #ifdef EDM_ML_DEBUG
89  edm::LogVerbatim("MtdSim") << "Building MTD basenumber:";
90 #endif
91  for (int ii = 0; ii < theSize; ii++) {
92  theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), touch->GetReplicaNumber(ii));
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("MtdSim") << "MtdSD::getBaseNumber(): Adding level " << ii << ": "
95  << touch->GetVolume(ii)->GetName() << "[" << touch->GetReplicaNumber(ii) << "]";
96 #endif
97  }
98  }
99 }
Log< level::Info, true > LogVerbatim
void addLevel(const std::string_view name, const int copyNumber)
MTDBaseNumber theBaseNumber
Definition: MtdSD.h:42
ii
Definition: cuy.py:589
void setSize(const int size)

◆ getTrackID()

int MtdSD::getTrackID ( const G4Track *  aTrack)
overrideprotectedvirtual

Reimplemented from TimingSD.

Definition at line 101 of file MtdSD.cc.

References PSimHit::addTrackIdOffset(), SensitiveDetector::cmsTrackInformation(), Exception, TrackInformation::getIDonCaloSurface(), TrackInformation::isBTLlooper(), TrackInformation::isExtSecondary(), TrackInformation::isInTrkFromBackscattering(), k_idFromCaloOffset, k_idloopOffset, k_idsecOffset, TrackInformation::mcTruthID(), TrackInformation::Print(), and rname.

101  {
102  int theID = aTrack->GetTrackID();
103  TrackInformation* trkInfo = cmsTrackInformation(aTrack);
104  const G4String& rname = aTrack->GetVolume()->GetLogicalVolume()->GetRegion()->GetName();
105  if (trkInfo != nullptr) {
106 #ifdef EDM_ML_DEBUG
107  trkInfo->Print();
108 #endif
109  if (rname == "FastTimerRegionSensBTL") {
110  theID = trkInfo->mcTruthID();
111  if (trkInfo->isExtSecondary() && !trkInfo->isInTrkFromBackscattering()) {
113  } else if (trkInfo->isInTrkFromBackscattering()) {
115  } else if (trkInfo->isBTLlooper()) {
117  }
118 #ifdef EDM_ML_DEBUG
119  edm::LogVerbatim("MtdSim") << "MtdSD: Track ID: " << aTrack->GetTrackID()
120  << " BTL Track ID: " << trkInfo->mcTruthID() << ":" << theID;
121 #endif
122  } else if (rname == "FastTimerRegionSensETL") {
123  theID = trkInfo->getIDonCaloSurface();
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("MtdSim") << "MtdSD: Track ID: " << aTrack->GetTrackID()
126  << " ETL Track ID: " << trkInfo->mcTruthID() << ":" << theID;
127 #endif
128  } else {
129  throw cms::Exception("MtdSDError") << "MtdSD called in incorrect region " << rname;
130  }
131  } else {
132 #ifdef EDM_ML_DEBUG
133  edm::LogWarning("MtdSim") << "MtdSD: Problem with primaryID **** set by force to TkID **** " << theID;
134 #endif
135  }
136  return theID;
137 }
Log< level::Info, true > LogVerbatim
static unsigned int addTrackIdOffset(unsigned int tId, unsigned int offset)
Definition: PSimHit.h:117
static constexpr unsigned int k_idsecOffset
Definition: MtdSD.h:31
static constexpr unsigned int k_idloopOffset
Definition: MtdSD.h:32
bool isExtSecondary() const
bool isInTrkFromBackscattering() const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int getIDonCaloSurface() const
void Print() const override
int mcTruthID() const
bool isBTLlooper() const
const G4String rname[NREG]
static constexpr unsigned int k_idFromCaloOffset
Definition: MtdSD.h:33
Log< level::Warning, false > LogWarning

◆ setDetUnitId()

uint32_t MtdSD::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements SensitiveDetector.

Definition at line 59 of file MtdSD.cc.

References getBaseNumber(), MTDNumberingScheme::getUnitID(), numberingScheme, and theBaseNumber.

59  {
60  if (numberingScheme == nullptr) {
61  return MTDDetId();
62  } else {
63  getBaseNumber(aStep);
64 #ifdef EDM_ML_DEBUG
65  edm::LogVerbatim("MtdSim") << "DetId = " << numberingScheme->getUnitID(theBaseNumber);
66 #endif
68  }
69 }
Log< level::Info, true > LogVerbatim
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
MTDBaseNumber theBaseNumber
Definition: MtdSD.h:42
void getBaseNumber(const G4Step *)
Definition: MtdSD.cc:80
MTDNumberingScheme * numberingScheme
Definition: MtdSD.h:41
virtual uint32_t getUnitID(const MTDBaseNumber &baseNumber) const =0

◆ setNumberingScheme()

void MtdSD::setNumberingScheme ( MTDNumberingScheme scheme)
private

Definition at line 71 of file MtdSD.cc.

References numberingScheme, and generator_cfi::scheme.

Referenced by MtdSD().

71  {
72  if (scheme != nullptr) {
73  edm::LogVerbatim("MtdSim") << "MtdSD: updates numbering scheme for " << GetName();
74  if (numberingScheme)
75  delete numberingScheme;
77  }
78 }
Log< level::Info, true > LogVerbatim
MTDNumberingScheme * numberingScheme
Definition: MtdSD.h:41

Member Data Documentation

◆ energyCut

double MtdSD::energyCut
private

Definition at line 35 of file MtdSD.h.

Referenced by MtdSD().

◆ energyHistoryCut

double MtdSD::energyHistoryCut
private

Definition at line 36 of file MtdSD.h.

Referenced by MtdSD().

◆ isBTL

bool MtdSD::isBTL
private

Definition at line 43 of file MtdSD.h.

Referenced by MtdSD().

◆ isETL

bool MtdSD::isETL
private

Definition at line 44 of file MtdSD.h.

Referenced by MtdSD().

◆ k_idFromCaloOffset

constexpr unsigned int MtdSD::k_idFromCaloOffset = 3
staticprivate

Definition at line 33 of file MtdSD.h.

Referenced by getTrackID().

◆ k_idloopOffset

constexpr unsigned int MtdSD::k_idloopOffset = 2
staticprivate

Definition at line 32 of file MtdSD.h.

Referenced by getTrackID().

◆ k_idsecOffset

constexpr unsigned int MtdSD::k_idsecOffset = 1
staticprivate

Definition at line 31 of file MtdSD.h.

Referenced by getTrackID().

◆ numberingScheme

MTDNumberingScheme* MtdSD::numberingScheme
private

Definition at line 41 of file MtdSD.h.

Referenced by setDetUnitId(), and setNumberingScheme().

◆ theBaseNumber

MTDBaseNumber MtdSD::theBaseNumber
private

Definition at line 42 of file MtdSD.h.

Referenced by getBaseNumber(), and setDetUnitId().