23 #include "G4SDManager.hh" 24 #include "G4VProcess.hh" 25 #include "G4EventManager.hh" 26 #include "G4SystemOfUnits.hh" 38 thePV(
nullptr), theHit(
nullptr), theDetUnitId(0), theTrackID(0), theManager(manager)
49 LogDebug(
"MuonSimDebug") <<
"create MuonSubDetector "<<name<<std::endl;
53 LogDebug(
"MuonSimDebug") <<
"create MuonFrameRotation"<<std::endl;
72 LogDebug(
"MuonSimDebug") <<
"create MuonSlaveSD"<<std::endl;
74 LogDebug(
"MuonSimDebug") <<
"create MuonSimHitNumberingScheme"<<std::endl;
83 edm::LogInfo(
"MuonSimDebug") <<
" EnergyThresholdForPersistency " 84 << STenergyPersistentCut <<
" AllMuonsPersistent " 119 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::clearHits"<<std::endl;
129 if (aStep->GetTotalEnergyDeposit()>0.){
131 if( aStep->GetTrack()->GetDynamicParticle()->GetCharge() != 0 ){
155 MuonBaseNumber <<
"MuonNumbering :: number of levels = "<<num.
getLevels()<<std::endl;
156 MuonBaseNumber <<
"Level \t SuperNo \t BaseNo"<<std::endl;
163 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::setDetUnitId :: "<<MuonBaseNumbr;
185 G4VPhysicalVolume*
pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
186 G4Track *
t = aStep->GetTrack();
193 G4VPhysicalVolume*
pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
194 G4Track *
t = aStep->GetTrack();
196 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::newHit :: currentUnitId = "<<currentUnitId;
197 unsigned int currentTrackID=t->GetTrackID();
199 bool changed=((pv!=
thePV) ||
207 G4Track * theTrack = aStep->GetTrack();
219 float zentry = theEntryPoint.
z();
220 float zexit = theExitPoint.
z();
224 theEntryPoint =
Local3DPoint( tempEntryPoint.
x(), tempEntryPoint.
y(), zentry );
225 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
231 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
232 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
233 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
236 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
237 G4ThreeVector lmd = ((
const G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
238 ->GetTopTransform().TransformAxis(gmd);
240 float theThetaAtEntry = lnmd.
theta();
241 float thePhiAtEntry = lnmd.
phi();
251 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
252 const G4TouchableHistory * theTouchable=(
const G4TouchableHistory *)
253 (preStepPoint->GetTouchable());
259 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
267 LogDebug(
"MuonSimDebug") <<
"=== NEW ==================> ELOSS = "<<theEnergyLoss<<
" " 268 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
269 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
270 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
272 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
274 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
275 LogDebug(
"MuonSimDebug") <<
"newhit theta " << theThetaAtEntry<<std::endl;
276 LogDebug(
"MuonSimDebug") <<
"newhit phi " << thePhiAtEntry<<std::endl;
277 LogDebug(
"MuonSimDebug") <<
"newhit pabs " << thePabs<<std::endl;
278 LogDebug(
"MuonSimDebug") <<
"newhit tof " << theTof<<std::endl;
280 LogDebug(
"MuonSimDebug") <<
"newhit entry " << theEntryPoint<<std::endl;
281 LogDebug(
"MuonSimDebug") <<
"newhit exit " << theExitPoint<<std::endl;
282 LogDebug(
"MuonSimDebug") <<
"newhit eloss " << theEnergyLoss << std::endl;
284 LogDebug(
"MuonSimDebug") <<
"newhit delta " << (theExitPoint-theEntryPoint)<<std::endl;
285 LogDebug(
"MuonSimDebug") <<
"newhit deltu " << (theExitPoint-theEntryPoint).
unit();
286 LogDebug(
"MuonSimDebug") <<
" " << (theExitPoint-theEntryPoint).
mag()<<std::endl;
288 LogDebug(
"MuonSimDebug") <<
"newhit dpos " << theGlobalPos<<std::endl;
289 LogDebug(
"MuonSimDebug") <<
"newhit drot " << std::endl;
296 int thePID = theTrack->GetDefinition()->GetPDGEncoding();
297 LogDebug(
"MuonSimDebug") <<
" checking simtrack " << thePID <<
" " << thePabs <<
" STenergyPersistentCut " <<
STenergyPersistentCut << std::endl;
302 LogDebug(
"MuonSimDebug") <<
" track leaving hit in muons made selected for persistency"<<std::endl;
321 float zexit = theExitPoint.
z();
323 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
328 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
331 std::cerr <<
"!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
337 LogDebug(
"MuonSimDebug") <<
"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<
" " 338 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
339 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
340 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
342 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
344 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
345 LogDebug(
"MuonSimDebug") <<
"updhit exit " << theExitPoint<<std::endl;
377 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
378 if (temp ==
nullptr){
379 std::cerr <<
" ERROR: no G4VUserTrackInformation available"<<std::endl;
384 std::cerr <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
405 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
406 const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
408 const G4TouchableHistory * theTouchable=(
const G4TouchableHistory *)
409 (preStepPoint->GetTouchable());
411 G4int
depth = theTouchable->GetHistory()->GetDepth();
412 G4ThreeVector localCoordinates = theTouchable->GetHistory()
413 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
420 G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
421 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
422 const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
424 const G4TouchableHistory * theTouchable = (
const G4TouchableHistory *)
425 (preStepPoint->GetTouchable());
427 G4int
depth = theTouchable->GetHistory()->GetDepth();
428 G4ThreeVector localCoordinates = theTouchable->GetHistory()
429 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
T getParameter(std::string const &) const
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
G4bool ProcessHits(G4Step *, G4TouchableHistory *) override
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
void printLocal(LocalPoint, LocalPoint) const
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const =0
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int getBaseNo(int level) const
Geom::Phi< T > phi() const
void storeVolumeAndTrack(const G4Step *)
type of data representation of DDCompactView
MuonSubDetector * detector
void fillHits(edm::PSimHitContainer &, const std::string &) override
bool STallMuonsPersistent
Local3DPoint toOrcaUnits(const Local3DPoint &)
Geom::Theta< T > theta() const
std::vector< PSimHit > & hits()
Point3DBase< float, GlobalTag > Global3DPoint
unsigned int processId(const G4VProcess *p) const
Local3DPoint exitPoint() const
Exit point in the local Det frame.
void clearHits() override
void updateExitPoint(const Local3DPoint &exit)
virtual void Initialize()
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
Global3DPoint theGlobalEntry
Abs< T >::type abs(const T &t)
~MuonSensitiveDetector() override
const SimTrackManager * theManager
void printGlobal(GlobalPoint) const
static int particleID(const G4Track *)
MuonFrameRotation * theRotation
MuonSensitiveDetector(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
double STenergyPersistentCut
uint32_t setDetUnitId(const G4Step *) override
Point3DBase< float, LocalTag > Local3DPoint
void addEnergyLoss(float eloss)
void startNewSimHit(std::string)
void EndOfEvent(G4HCofThisEvent *) override
MuonSimHitNumberingScheme * numbering
G4TrackToParticleID * myG4TrackToParticleID
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
float energyLoss() const
The energy deposit in the PSimHit, in ???.
int getSuperNo(int level) const
G4VPhysicalVolume * thePV
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
Local3DPoint InitialStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
int baseNumberToUnitNumber(const MuonBaseNumber &) override
TrackInformation * getOrCreateTrackInformation(const G4Track *theTrack)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *)
unsigned int detUnitId() const
UpdatablePSimHit * theHit
MuonG4Numbering * g4numbering
SimHitPrinter * thePrinter
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const