CMS 3D CMS Logo

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

#include <MuonSensitiveDetector.h>

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

Public Member Functions

void clearHits () override
 
void EndOfEvent (G4HCofThisEvent *) override
 
void fillHits (edm::PSimHitContainer &, const std::string &) override
 
const MuonSlaveSDGetSlaveMuon () const
 
 MuonSensitiveDetector (const std::string &, const MuonOffsetMap *, const MuonGeometryConstants &, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, const SimTrackManager *)
 
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
uint32_t setDetUnitId (const G4Step *) override
 
 ~MuonSensitiveDetector () 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

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

bool acceptHit (uint32_t id)
 
Local3DPoint cmsUnits (const Local3DPoint &v)
 
void createHit (const G4Step *)
 
Local3DPoint FinalStepPositionVsParent (const G4Step *currentStep, G4int levelsUp)
 
Local3DPoint InitialStepPositionVsParent (const G4Step *currentStep, G4int levelsUp)
 
bool newHit (const G4Step *)
 
void saveHit ()
 
void updateHit (const G4Step *)
 

Private Attributes

bool allMuonsPersistent_
 
bool demoGEM_
 
bool demoRPC_
 
MuonSubDetectordetector
 
float ePersistentCutGeV_
 
MuonG4Numberingg4numbering
 
bool haveDemo_
 
uint32_t newDetUnitId
 
MuonSimHitNumberingSchemenumbering
 
bool printHits_
 
MuonSlaveSDslaveMuon
 
uint32_t theDetUnitId
 
G4ProcessTypeEnumeratortheG4ProcessTypeEnumerator
 
UpdatablePSimHittheHit
 
const SimTrackManagertheManager
 
SimHitPrinterthePrinter
 
const G4VPhysicalVolume * thePV
 
const MuonFrameRotationtheRotation
 
int theTrackID
 

Additional Inherited Members

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

Detailed Description

implementation of SensitiveDetector for the muon detector; a MuonSlaveSD handles the interfacing to the database; numbering scheme are booked according to the detector name

Author
Arno Straessner, CERN arno..nosp@m.stra.nosp@m.essne.nosp@m.r@ce.nosp@m.rn.ch

Modification: 19/05/03. P.Arce Add SimTracks selection

Definition at line 39 of file MuonSensitiveDetector.h.

Constructor & Destructor Documentation

◆ MuonSensitiveDetector()

MuonSensitiveDetector::MuonSensitiveDetector ( const std::string &  name,
const MuonOffsetMap offmap,
const MuonGeometryConstants constants,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)
explicit

Definition at line 39 of file MuonSensitiveDetector.cc.

References allMuonsPersistent_, demoGEM_, demoRPC_, detector, ePersistentCutGeV_, g4numbering, haveDemo_, MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), MuonSubDetector::isGEM(), MuonSubDetector::isME0(), MuonSubDetector::isRPC(), mergeVDriftHistosByStation::name, numbering, AlCaHLTBitMon_ParallelJobs::p, printHits_, slaveMuon, theG4ProcessTypeEnumerator, theManager, thePrinter, and theRotation.

45  : SensitiveTkDetector(name, clg),
46  thePV(nullptr),
47  theHit(nullptr),
48  theDetUnitId(0),
49  newDetUnitId(0),
50  theTrackID(0),
51  thePrinter(nullptr),
52  theManager(manager) {
53  // Here simply create 1 MuonSlaveSD for the moment
54  //
55  bool dd4hep = p.getParameter<bool>("g4GeometryDD4hepSource");
56  edm::ParameterSet muonSD = p.getParameter<edm::ParameterSet>("MuonSD");
57  printHits_ = muonSD.getParameter<bool>("PrintHits");
58  ePersistentCutGeV_ = muonSD.getParameter<double>("EnergyThresholdForPersistency") / CLHEP::GeV; //Default 1. GeV
59  allMuonsPersistent_ = muonSD.getParameter<bool>("AllMuonsPersistent");
60  haveDemo_ = muonSD.getParameter<bool>("HaveDemoChambers");
61  demoGEM_ = muonSD.getParameter<bool>("UseDemoHitGEM");
62  demoRPC_ = muonSD.getParameter<bool>("UseDemoHitRPC");
63 
64 #ifdef EDM_ML_DEBUG
65  edm::LogVerbatim("MuonSim") << "create MuonSubDetector " << name << " with dd4hep flag " << dd4hep
66  << " Flags for Demonstration chambers " << haveDemo_ << " for GEM " << demoGEM_
67  << " for RPC " << demoRPC_;
68 #endif
70 
71  G4String sdet = "unknown";
72  if (detector->isEndcap()) {
74  sdet = "Endcap";
75  } else if (detector->isRPC()) {
77  sdet = "RPC";
78  } else if (detector->isGEM()) {
80  sdet = "GEM";
81  } else if (detector->isME0()) {
83  sdet = "ME0";
84  } else {
86  if (detector->isBarrel())
87  sdet = "Barrel";
88  }
92 
93  if (printHits_) {
94  thePrinter = new SimHitPrinter("HitPositionOSCAR.dat");
95  }
96 
97  edm::LogVerbatim("MuonSim") << " of type " << sdet << " <" << GetName() << "> EnergyThresholdForPersistency(GeV) "
98  << ePersistentCutGeV_ / CLHEP::GeV << " allMuonsPersistent: " << allMuonsPersistent_;
99 
101 }
Log< level::Info, true > LogVerbatim
const G4VPhysicalVolume * thePV
MuonSubDetector * detector
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
const MuonFrameRotation * theRotation
const SimTrackManager * theManager
MuonSimHitNumberingScheme * numbering
SensitiveTkDetector(const std::string &iname, const SensitiveDetectorCatalog &clg)
UpdatablePSimHit * theHit
MuonG4Numbering * g4numbering

◆ ~MuonSensitiveDetector()

MuonSensitiveDetector::~MuonSensitiveDetector ( )
override

Definition at line 103 of file MuonSensitiveDetector.cc.

References detector, g4numbering, numbering, slaveMuon, theG4ProcessTypeEnumerator, and theRotation.

103  {
104  delete g4numbering;
105  delete numbering;
106  delete slaveMuon;
107  delete theRotation;
108  delete detector;
110 }
MuonSubDetector * detector
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
const MuonFrameRotation * theRotation
MuonSimHitNumberingScheme * numbering
MuonG4Numbering * g4numbering

Member Function Documentation

◆ acceptHit()

bool MuonSensitiveDetector::acceptHit ( uint32_t  id)
private

Definition at line 357 of file MuonSensitiveDetector.cc.

References MuonSubdetId::CSC, TauDecayModes::dec, demoGEM_, demoRPC_, MuonSubdetId::DT, RemoveAddSevLevel::flag, MuonSubdetId::GEM, haveDemo_, MuonSubdetId::ME0, nano_mu_digi_cff::region, relativeConstraints::ring, MuonSubdetId::RPC, relativeConstraints::station, and DetId::subdetId().

Referenced by saveHit().

357  {
358  if (id == 0) {
359 #ifdef EDM_ML_DEBUG
360  edm::LogVerbatim("MuonSim") << "DetId " << id << " Flag " << false;
361 #endif
362  return false;
363  }
364  bool flag(true);
365  if (haveDemo_) {
366  int subdet = DetId(id).subdetId();
367  if (subdet == MuonSubdetId::GEM) {
368  if (GEMDetId(id).station() == 2)
369  flag = demoGEM_;
370  } else if (subdet == MuonSubdetId::RPC) {
371  if ((RPCDetId(id).region() != 0) && (RPCDetId(id).ring() == 1) && (RPCDetId(id).station() > 2))
372  flag = demoRPC_;
373  }
374  }
375 #ifdef EDM_ML_DEBUG
376  int subdet = DetId(id).subdetId();
377  if (subdet == MuonSubdetId::RPC)
378  edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " RPC " << RPCDetId(id) << " Flag "
379  << flag;
380  else if (subdet == MuonSubdetId::GEM)
381  edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " GEM " << GEMDetId(id) << " Flag "
382  << flag;
383  else if (subdet == MuonSubdetId::ME0)
384  edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " " << ME0DetId(id) << " Flag " << flag;
385  else if (subdet == MuonSubdetId::CSC)
386  edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " CSC Flag " << flag;
387  else if (subdet == MuonSubdetId::DT)
388  edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " DT Flag " << flag;
389  else
390  edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " Unknown Flag " << flag;
391 #endif
392  return flag;
393 }
Log< level::Info, true > LogVerbatim
static constexpr int GEM
Definition: MuonSubdetId.h:14
static constexpr int ME0
Definition: MuonSubdetId.h:15
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
static constexpr int RPC
Definition: MuonSubdetId.h:13
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12

◆ clearHits()

void MuonSensitiveDetector::clearHits ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 120 of file MuonSensitiveDetector.cc.

References TrackingSlaveSD::Initialize(), and slaveMuon.

Referenced by update().

120  {
121 #ifdef EDM_ML_DEBUG
122  edm::LogVerbatim("MuonSim") << "MuonSensitiveDetector::clearHits";
123 #endif
125 }
Log< level::Info, true > LogVerbatim
virtual void Initialize()

◆ cmsUnits()

Local3DPoint MuonSensitiveDetector::cmsUnits ( const Local3DPoint v)
inlineprivate

Definition at line 61 of file MuonSensitiveDetector.h.

References findQualityFiles::v.

Referenced by createHit(), and updateHit().

61 { return Local3DPoint(v.x() * 0.1, v.y() * 0.1, v.z() * 0.1); }
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9

◆ createHit()

void MuonSensitiveDetector::createHit ( const G4Step *  aStep)
private

Definition at line 178 of file MuonSensitiveDetector.cc.

References funct::abs(), allMuonsPersistent_, SensitiveDetector::cmsTrackInformation(), cmsUnits(), SensitiveDetector::ConvertToLocal3DPoint(), detector, ePersistentCutGeV_, SensitiveDetector::FinalStepPosition(), FinalStepPositionVsParent(), info(), SensitiveDetector::InitialStepPosition(), InitialStepPositionVsParent(), MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), SensitiveDetector::LocalCoordinates, PV3DBase< T, PVType, FrameType >::mag(), newDetUnitId, AlCaHLTBitMon_ParallelJobs::p, SiStripOfflineCRack_cfg::p2, G4TrackToParticleID::particleID(), PV3DBase< T, PVType, FrameType >::phi(), G4ProcessTypeEnumerator::processId(), theDetUnitId, theG4ProcessTypeEnumerator, theHit, thePV, theRotation, PV3DBase< T, PVType, FrameType >::theta(), theTrackID, MuonFrameRotation::transformPoint(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ProcessHits().

178  {
179  Local3DPoint theEntryPoint;
180  Local3DPoint theExitPoint;
181 
182  if (detector->isBarrel()) {
183  // 1 levels up
184  theEntryPoint = cmsUnits(theRotation->transformPoint(InitialStepPositionVsParent(aStep, 1), aStep));
185  theExitPoint = cmsUnits(theRotation->transformPoint(FinalStepPositionVsParent(aStep, 1), aStep));
186  } else if (detector->isEndcap()) {
187  // save local z at current level
188  theEntryPoint = theRotation->transformPoint(InitialStepPosition(aStep, LocalCoordinates), aStep);
189  theExitPoint = theRotation->transformPoint(FinalStepPosition(aStep, LocalCoordinates), aStep);
190  float zentry = theEntryPoint.z();
191  float zexit = theExitPoint.z();
192  // 4 levels up
195  // reset local z from z wrt deep-parent volume to z wrt low-level volume
196  theEntryPoint = cmsUnits(Local3DPoint(tempEntry.x(), tempEntry.y(), zentry));
197  theExitPoint = cmsUnits(Local3DPoint(tempExit.x(), tempExit.y(), zexit));
198  } else {
199  theEntryPoint = cmsUnits(theRotation->transformPoint(InitialStepPosition(aStep, LocalCoordinates), aStep));
200  theExitPoint = cmsUnits(theRotation->transformPoint(FinalStepPosition(aStep, LocalCoordinates), aStep));
201  }
202 
203  const G4Track* theTrack = aStep->GetTrack();
204  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
205 
206  float thePabs = preStepPoint->GetMomentum().mag() / CLHEP::GeV;
207  float theTof = preStepPoint->GetGlobalTime() / CLHEP::nanosecond;
208  float theEnergyLoss = aStep->GetTotalEnergyDeposit() / CLHEP::GeV;
209  int theParticleType = G4TrackToParticleID::particleID(theTrack);
210 
212  thePV = preStepPoint->GetPhysicalVolume();
213  theTrackID = theTrack->GetTrackID();
214 
215  // convert momentum direction it to local frame
216  const G4ThreeVector& gmd = preStepPoint->GetMomentumDirection();
217  G4ThreeVector lmd = static_cast<const G4TouchableHistory*>(preStepPoint->GetTouchable())
218  ->GetHistory()
219  ->GetTopTransform()
220  .TransformAxis(gmd);
222  lnmd = theRotation->transformPoint(lnmd, aStep);
223  float theThetaAtEntry = lnmd.theta();
224  float thePhiAtEntry = lnmd.phi();
225 
226  theHit = new UpdatablePSimHit(theEntryPoint,
227  theExitPoint,
228  thePabs,
229  theTof,
230  theEnergyLoss,
231  theParticleType,
232  theDetUnitId,
233  theTrackID,
234  theThetaAtEntry,
235  thePhiAtEntry,
236  theG4ProcessTypeEnumerator->processId(theTrack->GetCreatorProcess()));
237 
238  // Make track persistent
239  int thePID = std::abs(theTrack->GetDefinition()->GetPDGEncoding());
240  //---VI - in parameters cut in energy is declared but applied to momentum
241  if (thePabs > ePersistentCutGeV_ || (thePID == 13 && allMuonsPersistent_)) {
243  info->setStoreTrack();
244  }
245 
246 #ifdef EDM_ML_DEBUG
247  edm::LogVerbatim("MuonSim") << "=== NEW Muon hit for " << GetName() << " Edep(GeV)= " << theEnergyLoss << " "
248  << thePV->GetLogicalVolume()->GetName();
249  const G4VProcess* p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
250  const G4VProcess* p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
251  G4String sss = "";
252  if (p)
253  sss += " POST PROCESS: " + p->GetProcessName();
254  if (p2)
255  sss += "; PRE PROCESS: " + p2->GetProcessName();
256  if (!sss.empty())
257  edm::LogVerbatim("MuonSim") << sss;
258  edm::LogVerbatim("MuonSim") << " theta= " << theThetaAtEntry << " phi= " << thePhiAtEntry << " Pabs(GeV/c) "
259  << thePabs << " Eloss(GeV)= " << theEnergyLoss << " Tof(ns)= " << theTof
260  << " trackID= " << theTrackID << " detID= " << theDetUnitId << "\n Local: entry "
261  << theEntryPoint << " exit " << theExitPoint << " delta "
262  << (theExitPoint - theEntryPoint) << "\n Global: entry "
263  << aStep->GetPreStepPoint()->GetPosition() << " exit "
264  << aStep->GetPostStepPoint()->GetPosition();
265 #endif
266 }
Log< level::Info, true > LogVerbatim
const G4VPhysicalVolume * thePV
static const TGPicture * info(bool iBackgroundIsBlack)
Local3DPoint FinalStepPositionVsParent(const G4Step *currentStep, G4int levelsUp)
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const
MuonSubDetector * detector
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
Local3DPoint cmsUnits(const Local3DPoint &v)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
T mag() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const MuonFrameRotation * theRotation
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
static int particleID(const G4Track *)
unsigned int processId(const G4VProcess *p) const
Local3DPoint InitialStepPositionVsParent(const G4Step *currentStep, G4int levelsUp)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
UpdatablePSimHit * theHit
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9

◆ EndOfEvent()

void MuonSensitiveDetector::EndOfEvent ( G4HCofThisEvent *  )
override

Definition at line 322 of file MuonSensitiveDetector.cc.

References saveHit().

◆ fillHits()

void MuonSensitiveDetector::fillHits ( edm::PSimHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveTkDetector.

Definition at line 324 of file MuonSensitiveDetector.cc.

References gpuPixelDoublets::cc, TrackingSlaveSD::hits(), TrackingSlaveSD::name(), and slaveMuon.

324  {
325  if (slaveMuon->name() == hname) {
326  cc = slaveMuon->hits();
327  }
328 }
std::string name() const
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::vector< PSimHit > & hits()

◆ FinalStepPositionVsParent()

Local3DPoint MuonSensitiveDetector::FinalStepPositionVsParent ( const G4Step *  currentStep,
G4int  levelsUp 
)
private

Definition at line 343 of file MuonSensitiveDetector.cc.

References SensitiveDetector::ConvertToLocal3DPoint(), and hcalRecHitTable_cff::depth.

Referenced by createHit(), and updateHit().

343  {
344  const G4StepPoint* postStepPoint = currentStep->GetPostStepPoint();
345  const G4StepPoint* preStepPoint = currentStep->GetPreStepPoint();
346  const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
347 
348  const G4TouchableHistory* theTouchable = (const G4TouchableHistory*)(preStepPoint->GetTouchable());
349 
350  G4int depth = theTouchable->GetHistory()->GetDepth();
351  G4ThreeVector localCoordinates =
352  theTouchable->GetHistory()->GetTransform(depth - levelsUp).TransformPoint(globalCoordinates);
353 
354  return ConvertToLocal3DPoint(localCoordinates);
355 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const

◆ GetSlaveMuon()

const MuonSlaveSD* MuonSensitiveDetector::GetSlaveMuon ( ) const
inline

Definition at line 55 of file MuonSensitiveDetector.h.

References slaveMuon.

55 { return slaveMuon; }

◆ InitialStepPositionVsParent()

Local3DPoint MuonSensitiveDetector::InitialStepPositionVsParent ( const G4Step *  currentStep,
G4int  levelsUp 
)
private

Transform from local coordinates of a volume to local coordinates of a parent volume one or more levels up the volume hierarchy: e.g. levelsUp = 1 for immediate parent. This is done by moving from local_1 -> global -> local_2.

Definition at line 330 of file MuonSensitiveDetector.cc.

References SensitiveDetector::ConvertToLocal3DPoint(), and hcalRecHitTable_cff::depth.

Referenced by createHit().

330  {
331  const G4StepPoint* preStepPoint = currentStep->GetPreStepPoint();
332  const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
333 
334  const G4TouchableHistory* theTouchable = (const G4TouchableHistory*)(preStepPoint->GetTouchable());
335 
336  G4int depth = theTouchable->GetHistory()->GetDepth();
337  G4ThreeVector localCoordinates =
338  theTouchable->GetHistory()->GetTransform(depth - levelsUp).TransformPoint(globalCoordinates);
339 
340  return ConvertToLocal3DPoint(localCoordinates);
341 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const

◆ newHit()

bool MuonSensitiveDetector::newHit ( const G4Step *  aStep)
private

Definition at line 173 of file MuonSensitiveDetector.cc.

References newDetUnitId, theDetUnitId, theHit, thePV, and theTrackID.

Referenced by ProcessHits().

173  {
174  return (!theHit || (aStep->GetTrack()->GetTrackID() != theTrackID) ||
175  (aStep->GetPreStepPoint()->GetPhysicalVolume() != thePV) || newDetUnitId != theDetUnitId);
176 }
const G4VPhysicalVolume * thePV
UpdatablePSimHit * theHit

◆ ProcessHits()

bool MuonSensitiveDetector::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
overridevirtual

Implements SensitiveDetector.

Definition at line 127 of file MuonSensitiveDetector.cc.

References createHit(), SensitiveDetector::InitialStepPosition(), mergeVDriftHistosByStation::name, newDetUnitId, newHit(), saveHit(), setDetUnitId(), AlCaHLTBitMon_QueryRunRegistry::string, theDetUnitId, thePV, theTrackID, updateHit(), and SensitiveDetector::WorldCoordinates.

127  {
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("MuonSim") << " MuonSensitiveDetector::ProcessHits " << InitialStepPosition(aStep, WorldCoordinates);
130 #endif
131 
132  if (aStep->GetTotalEnergyDeposit() > 0.) {
133  newDetUnitId = setDetUnitId(aStep);
134 #ifdef EDM_ML_DEBUG
135  G4VPhysicalVolume* vol = aStep->GetPreStepPoint()->GetTouchable()->GetVolume(0);
136  std::string namx = static_cast<std::string>(vol->GetName());
137  std::string name = namx.substr(0, 2);
138  if (name == "RE")
139  edm::LogVerbatim("MuonSim") << "DETID " << namx << " " << RPCDetId(newDetUnitId);
140 #endif
141  if (newHit(aStep)) {
142  saveHit();
143  createHit(aStep);
144  } else {
145  updateHit(aStep);
146  }
147  thePV = aStep->GetPreStepPoint()->GetPhysicalVolume();
148  theTrackID = aStep->GetTrack()->GetTrackID();
150  }
151  return true;
152 }
Log< level::Info, true > LogVerbatim
const G4VPhysicalVolume * thePV
void updateHit(const G4Step *)
void createHit(const G4Step *)
bool newHit(const G4Step *)
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const
uint32_t setDetUnitId(const G4Step *) override

◆ saveHit()

void MuonSensitiveDetector::saveHit ( )
private

Definition at line 306 of file MuonSensitiveDetector.cc.

References acceptHit(), detector, PSimHit::detUnitId(), PSimHit::entryPoint(), PSimHit::exitPoint(), MuonSubDetector::name(), printHits_, SimHitPrinter::printId(), SimHitPrinter::printLocal(), TrackingSlaveSD::processHits(), slaveMuon, SimHitPrinter::startNewSimHit(), theHit, and thePrinter.

Referenced by EndOfEvent(), and ProcessHits().

306  {
307  if (theHit) {
308  if (acceptHit(theHit->detUnitId())) {
309  if (printHits_) {
313  }
314  // hit is included into hit collection
316  }
317  delete theHit;
318  theHit = nullptr;
319  }
320 }
unsigned int detUnitId() const
Definition: PSimHit.h:99
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:48
std::string name()
MuonSubDetector * detector
void printLocal(LocalPoint, LocalPoint) const
void printId(int) const
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:45
void startNewSimHit(std::string)
virtual bool processHits(const PSimHit &)
UpdatablePSimHit * theHit

◆ setDetUnitId()

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

Implements SensitiveDetector.

Definition at line 154 of file MuonSensitiveDetector.cc.

References MuonSimHitNumberingScheme::baseNumberToUnitNumber(), g4numbering, gammaJetAnalysis_CHSJECs_cff::level, EgammaValidation_cff::num, numbering, MuonG4Numbering::PhysicalVolumeToBaseNumber(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ProcessHits().

154  {
156 
157 #ifdef EDM_ML_DEBUG
158  std::stringstream MuonBaseNumber;
159  MuonBaseNumber << "MuonNumbering :: number of levels = " << num.getLevels() << std::endl;
160  MuonBaseNumber << "Level \t SuperNo \t BaseNo" << std::endl;
161  for (int level = 1; level <= num.getLevels(); level++) {
162  MuonBaseNumber << level << " \t " << num.getSuperNo(level) << " \t " << num.getBaseNo(level) << std::endl;
163  }
164  std::string MuonBaseNumbr = MuonBaseNumber.str();
165 
166  edm::LogVerbatim("MuonSim") << "MuonSensitiveDetector::setDetUnitId :: " << MuonBaseNumbr;
167  edm::LogVerbatim("MuonSim") << "MuonSensitiveDetector::setDetUnitId :: MuonDetUnitId = "
169 #endif
171 }
Log< level::Info, true > LogVerbatim
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
MuonSimHitNumberingScheme * numbering
MuonG4Numbering * g4numbering

◆ update()

void MuonSensitiveDetector::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 112 of file MuonSensitiveDetector.cc.

References clearHits(), theDetUnitId, thePV, and theTrackID.

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

112  {
113  clearHits();
114  //----- Initialize variables to check if two steps belong to same hit
115  thePV = nullptr;
116  theDetUnitId = 0;
117  theTrackID = 0;
118 }
const G4VPhysicalVolume * thePV

◆ updateHit()

void MuonSensitiveDetector::updateHit ( const G4Step *  aStep)
private

Definition at line 268 of file MuonSensitiveDetector.cc.

References UpdatablePSimHit::addEnergyLoss(), cmsUnits(), detector, SensitiveDetector::FinalStepPosition(), FinalStepPositionVsParent(), MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), SensitiveDetector::LocalCoordinates, AlCaHLTBitMon_ParallelJobs::p, SiStripOfflineCRack_cfg::p2, theDetUnitId, theHit, thePV, theRotation, theTrackID, MuonFrameRotation::transformPoint(), UpdatablePSimHit::updateExitPoint(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ProcessHits().

268  {
269  Local3DPoint theExitPoint;
270 
271  if (detector->isBarrel()) {
272  theExitPoint = cmsUnits(theRotation->transformPoint(FinalStepPositionVsParent(aStep, 1), aStep));
273  } else if (detector->isEndcap()) {
274  // save local z at current level
275  theExitPoint = theRotation->transformPoint(FinalStepPosition(aStep, LocalCoordinates), aStep);
276  float zexit = theExitPoint.z();
277  Local3DPoint tempExitPoint = theRotation->transformPoint(FinalStepPositionVsParent(aStep, 4), aStep);
278  theExitPoint = cmsUnits(Local3DPoint(tempExitPoint.x(), tempExitPoint.y(), zexit));
279  } else {
280  theExitPoint = cmsUnits(theRotation->transformPoint(FinalStepPosition(aStep, LocalCoordinates), aStep));
281  }
282 
283  float theEnergyLoss = aStep->GetTotalEnergyDeposit() / CLHEP::GeV;
284 
285  theHit->updateExitPoint(theExitPoint);
286  theHit->addEnergyLoss(theEnergyLoss);
287 
288 #ifdef EDM_ML_DEBUG
289  edm::LogVerbatim("MuonSim") << "=== NEW Update muon hit for " << GetName() << " Edep(GeV)= " << theEnergyLoss << " "
290  << thePV->GetLogicalVolume()->GetName();
291  const G4VProcess* p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
292  const G4VProcess* p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
293  G4String sss = "";
294  if (p)
295  sss += " POST PROCESS: " + p->GetProcessName();
296  if (p2)
297  sss += "; PRE PROCESS: " + p2->GetProcessName();
298  if (!sss.empty())
299  edm::LogVerbatim("MuonSim") << sss;
300  edm::LogVerbatim("MuonSim") << " delEloss(GeV)= " << theEnergyLoss
301  << " Tof(ns)= " << aStep->GetPreStepPoint()->GetGlobalTime() / CLHEP::nanosecond
302  << " trackID= " << theTrackID << " detID= " << theDetUnitId << " exit " << theExitPoint;
303 #endif
304 }
Log< level::Info, true > LogVerbatim
const G4VPhysicalVolume * thePV
Local3DPoint FinalStepPositionVsParent(const G4Step *currentStep, G4int levelsUp)
T z() const
Definition: PV3DBase.h:61
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const
MuonSubDetector * detector
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
Local3DPoint cmsUnits(const Local3DPoint &v)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
void updateExitPoint(const Local3DPoint &exit)
const MuonFrameRotation * theRotation
void addEnergyLoss(float eloss)
UpdatablePSimHit * theHit
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9

Member Data Documentation

◆ allMuonsPersistent_

bool MuonSensitiveDetector::allMuonsPersistent_
private

Definition at line 94 of file MuonSensitiveDetector.h.

Referenced by createHit(), and MuonSensitiveDetector().

◆ demoGEM_

bool MuonSensitiveDetector::demoGEM_
private

Definition at line 98 of file MuonSensitiveDetector.h.

Referenced by acceptHit(), and MuonSensitiveDetector().

◆ demoRPC_

bool MuonSensitiveDetector::demoRPC_
private

Definition at line 99 of file MuonSensitiveDetector.h.

Referenced by acceptHit(), and MuonSensitiveDetector().

◆ detector

MuonSubDetector* MuonSensitiveDetector::detector
private

◆ ePersistentCutGeV_

float MuonSensitiveDetector::ePersistentCutGeV_
private

Definition at line 93 of file MuonSensitiveDetector.h.

Referenced by createHit(), and MuonSensitiveDetector().

◆ g4numbering

MuonG4Numbering* MuonSensitiveDetector::g4numbering
private

◆ haveDemo_

bool MuonSensitiveDetector::haveDemo_
private

Definition at line 97 of file MuonSensitiveDetector.h.

Referenced by acceptHit(), and MuonSensitiveDetector().

◆ newDetUnitId

uint32_t MuonSensitiveDetector::newDetUnitId
private

Definition at line 86 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), and ProcessHits().

◆ numbering

MuonSimHitNumberingScheme* MuonSensitiveDetector::numbering
private

◆ printHits_

bool MuonSensitiveDetector::printHits_
private

Definition at line 89 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector(), and saveHit().

◆ slaveMuon

MuonSlaveSD* MuonSensitiveDetector::slaveMuon
private

◆ theDetUnitId

uint32_t MuonSensitiveDetector::theDetUnitId
private

Definition at line 85 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), ProcessHits(), update(), and updateHit().

◆ theG4ProcessTypeEnumerator

G4ProcessTypeEnumerator* MuonSensitiveDetector::theG4ProcessTypeEnumerator
private

◆ theHit

UpdatablePSimHit* MuonSensitiveDetector::theHit
private

Definition at line 84 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), saveHit(), and updateHit().

◆ theManager

const SimTrackManager* MuonSensitiveDetector::theManager
private

Definition at line 103 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector().

◆ thePrinter

SimHitPrinter* MuonSensitiveDetector::thePrinter
private

Definition at line 90 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector(), and saveHit().

◆ thePV

const G4VPhysicalVolume* MuonSensitiveDetector::thePV
private

Definition at line 83 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), ProcessHits(), update(), and updateHit().

◆ theRotation

const MuonFrameRotation* MuonSensitiveDetector::theRotation
private

◆ theTrackID

int MuonSensitiveDetector::theTrackID
private

Definition at line 87 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), ProcessHits(), update(), and updateHit().