26 #include "G4VProcess.hh"
27 #include "G4EventManager.hh"
28 #include "G4SystemOfUnits.hh"
30 #include "G4StepPoint.hh"
57 printHits_ = muonSD.getParameter<
bool>(
"PrintHits");
58 ePersistentCutGeV_ = muonSD.getParameter<
double>(
"EnergyThresholdForPersistency") / CLHEP::GeV;
60 haveDemo_ = muonSD.getParameter<
bool>(
"HaveDemoChambers");
61 demoGEM_ = muonSD.getParameter<
bool>(
"UseDemoHitGEM");
62 demoRPC_ = muonSD.getParameter<
bool>(
"UseDemoHitRPC");
65 edm::LogVerbatim(
"MuonSim") <<
"create MuonSubDetector " << name <<
" with dd4hep flag " << dd4hep
66 <<
" Flags for Demonstration chambers " << haveDemo_ <<
" for GEM " << demoGEM_
71 G4String sdet =
"unknown";
97 edm::LogVerbatim(
"MuonSim") <<
" of type " << sdet <<
" <" << GetName() <<
"> EnergyThresholdForPersistency(GeV) "
132 if (aStep->GetTotalEnergyDeposit() > 0.) {
135 G4VPhysicalVolume* vol = aStep->GetPreStepPoint()->GetTouchable()->GetVolume(0);
147 thePV = aStep->GetPreStepPoint()->GetPhysicalVolume();
159 MuonBaseNumber <<
"MuonNumbering :: number of levels = " << num.
getLevels() << std::endl;
160 MuonBaseNumber <<
"Level \t SuperNo \t BaseNo" << std::endl;
166 edm::LogVerbatim(
"MuonSim") <<
"MuonSensitiveDetector::setDetUnitId :: " << MuonBaseNumbr;
167 edm::LogVerbatim(
"MuonSim") <<
"MuonSensitiveDetector::setDetUnitId :: MuonDetUnitId = "
190 float zentry = theEntryPoint.
z();
191 float zexit = theExitPoint.
z();
203 const G4Track* theTrack = aStep->GetTrack();
204 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
206 float thePabs = preStepPoint->GetMomentum().
mag() / CLHEP::GeV;
207 float theTof = preStepPoint->GetGlobalTime() / CLHEP::nanosecond;
208 float theEnergyLoss = aStep->GetTotalEnergyDeposit() / CLHEP::GeV;
212 thePV = preStepPoint->GetPhysicalVolume();
216 const G4ThreeVector& gmd = preStepPoint->GetMomentumDirection();
217 G4ThreeVector lmd =
static_cast<const G4TouchableHistory*
>(preStepPoint->GetTouchable())
223 float theThetaAtEntry = lnmd.
theta();
224 float thePhiAtEntry = lnmd.
phi();
239 int thePID =
std::abs(theTrack->GetDefinition()->GetPDGEncoding());
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();
253 sss +=
" POST PROCESS: " + p->GetProcessName();
255 sss +=
"; PRE PROCESS: " + p2->GetProcessName();
258 edm::LogVerbatim(
"MuonSim") <<
" theta= " << theThetaAtEntry <<
" phi= " << thePhiAtEntry <<
" Pabs(GeV/c) "
259 << thePabs <<
" Eloss(GeV)= " << theEnergyLoss <<
" Tof(ns)= " << theTof
261 << theEntryPoint <<
" exit " << theExitPoint <<
" delta "
262 << (theExitPoint - theEntryPoint) <<
"\n Global: entry "
263 << aStep->GetPreStepPoint()->GetPosition() <<
" exit "
264 << aStep->GetPostStepPoint()->GetPosition();
276 float zexit = theExitPoint.
z();
283 float theEnergyLoss = aStep->GetTotalEnergyDeposit() / CLHEP::GeV;
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();
295 sss +=
" POST PROCESS: " + p->GetProcessName();
297 sss +=
"; PRE PROCESS: " + p2->GetProcessName();
301 <<
" Tof(ns)= " << aStep->GetPreStepPoint()->GetGlobalTime() / CLHEP::nanosecond
331 const G4StepPoint* preStepPoint = currentStep->GetPreStepPoint();
332 const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
334 const G4TouchableHistory* theTouchable = (
const G4TouchableHistory*)(preStepPoint->GetTouchable());
336 G4int
depth = theTouchable->GetHistory()->GetDepth();
337 G4ThreeVector localCoordinates =
338 theTouchable->GetHistory()->GetTransform(depth - levelsUp).TransformPoint(globalCoordinates);
344 const G4StepPoint* postStepPoint = currentStep->GetPostStepPoint();
345 const G4StepPoint* preStepPoint = currentStep->GetPreStepPoint();
346 const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
348 const G4TouchableHistory* theTouchable = (
const G4TouchableHistory*)(preStepPoint->GetTouchable());
350 G4int
depth = theTouchable->GetHistory()->GetDepth();
351 G4ThreeVector localCoordinates =
352 theTouchable->GetHistory()->GetTransform(depth - levelsUp).TransformPoint(globalCoordinates);
Log< level::Info, true > LogVerbatim
const G4VPhysicalVolume * thePV
Local3DPoint FinalStepPositionVsParent(const G4Step *currentStep, G4int levelsUp)
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
G4bool ProcessHits(G4Step *, G4TouchableHistory *) override
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
void updateHit(const G4Step *)
void printLocal(LocalPoint, LocalPoint) const
int getBaseNo(int level) const
Geom::Phi< T > phi() const
MuonSubDetector * detector
void fillHits(edm::PSimHitContainer &, const std::string &) override
Geom::Theta< T > theta() const
Local3DPoint cmsUnits(const Local3DPoint &v)
std::vector< PSimHit > & hits()
unsigned int processId(const G4VProcess *p) const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
void createHit(const G4Step *)
void clearHits() override
void updateExitPoint(const Local3DPoint &exit)
virtual void Initialize()
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool newHit(const G4Step *)
Abs< T >::type abs(const T &t)
const MuonFrameRotation * theRotation
MuonSensitiveDetector(const std::string &, const MuonOffsetMap *, const MuonGeometryConstants &, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, const SimTrackManager *)
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const
~MuonSensitiveDetector() override
const SimTrackManager * theManager
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
static int particleID(const G4Track *)
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
uint32_t setDetUnitId(const G4Step *) override
void addEnergyLoss(float eloss)
void startNewSimHit(std::string)
void EndOfEvent(G4HCofThisEvent *) override
bool acceptHit(uint32_t id)
MuonSimHitNumberingScheme * numbering
T getParameter(std::string const &) const
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
int getSuperNo(int level) const
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int detUnitId() const
Local3DPoint InitialStepPositionVsParent(const G4Step *currentStep, G4int levelsUp)
UpdatablePSimHit * theHit
MuonG4Numbering * g4numbering
SimHitPrinter * thePrinter
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const
Point3DBase< float, LocalTag > Local3DPoint