23 #include "G4SDManager.hh" 24 #include "G4VProcess.hh" 25 #include "G4EventManager.hh" 26 #include "G4SystemOfUnits.hh" 38 thePV(0), theHit(0), 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;
82 const std::vector<std::string>& lvNames = clg.
logicalNames(name);
84 for (std::vector<std::string>::const_iterator it = lvNames.begin(); it != lvNames.end(); it++){
85 LogDebug(
"MuonSimDebug") << name <<
" MuonSensitiveDetector:: attaching SD to LV " << *it << std::endl;
94 LogDebug(
"MuonSimDebug") <<
" EnergyThresholdForPersistency " << STenergyPersistentCut <<
" AllMuonsPersistent " << STallMuonsPersistent << std::endl;
132 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::clearHits"<<std::endl;
142 if (aStep->GetTotalEnergyDeposit()>0.){
144 if( aStep->GetTrack()->GetDynamicParticle()->GetCharge() != 0 ){
168 MuonBaseNumber <<
"MuonNumbering :: number of levels = "<<num.
getLevels()<<std::endl;
169 MuonBaseNumber <<
"Level \t SuperNo \t BaseNo"<<std::endl;
176 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::setDetUnitId :: "<<MuonBaseNumbr;
198 G4VPhysicalVolume*
pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
199 G4Track *
t = aStep->GetTrack();
206 G4VPhysicalVolume*
pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
207 G4Track *
t = aStep->GetTrack();
209 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::newHit :: currentUnitId = "<<currentUnitId;
210 unsigned int currentTrackID=t->GetTrackID();
212 bool changed=((pv!=
thePV) ||
220 G4Track * theTrack = aStep->GetTrack();
232 float zentry = theEntryPoint.
z();
233 float zexit = theExitPoint.
z();
237 theEntryPoint =
Local3DPoint( tempEntryPoint.
x(), tempEntryPoint.
y(), zentry );
238 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
244 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
245 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
246 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
249 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
250 G4ThreeVector lmd = ((
const G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
251 ->GetTopTransform().TransformAxis(gmd);
253 float theThetaAtEntry = lnmd.
theta();
254 float thePhiAtEntry = lnmd.
phi();
264 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
265 const G4TouchableHistory * theTouchable=(
const G4TouchableHistory *)
266 (preStepPoint->GetTouchable());
272 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
280 LogDebug(
"MuonSimDebug") <<
"=== NEW ==================> ELOSS = "<<theEnergyLoss<<
" " 281 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
282 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
283 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
285 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
287 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
288 LogDebug(
"MuonSimDebug") <<
"newhit theta " << theThetaAtEntry<<std::endl;
289 LogDebug(
"MuonSimDebug") <<
"newhit phi " << thePhiAtEntry<<std::endl;
290 LogDebug(
"MuonSimDebug") <<
"newhit pabs " << thePabs<<std::endl;
291 LogDebug(
"MuonSimDebug") <<
"newhit tof " << theTof<<std::endl;
293 LogDebug(
"MuonSimDebug") <<
"newhit entry " << theEntryPoint<<std::endl;
294 LogDebug(
"MuonSimDebug") <<
"newhit exit " << theExitPoint<<std::endl;
295 LogDebug(
"MuonSimDebug") <<
"newhit eloss " << theEnergyLoss << std::endl;
297 LogDebug(
"MuonSimDebug") <<
"newhit delta " << (theExitPoint-theEntryPoint)<<std::endl;
298 LogDebug(
"MuonSimDebug") <<
"newhit deltu " << (theExitPoint-theEntryPoint).
unit();
299 LogDebug(
"MuonSimDebug") <<
" " << (theExitPoint-theEntryPoint).
mag()<<std::endl;
301 LogDebug(
"MuonSimDebug") <<
"newhit dpos " << theGlobalPos<<std::endl;
302 LogDebug(
"MuonSimDebug") <<
"newhit drot " << std::endl;
309 int thePID = theTrack->GetDefinition()->GetPDGEncoding();
310 LogDebug(
"MuonSimDebug") <<
" checking simtrack " << thePID <<
" " << thePabs <<
" STenergyPersistentCut " <<
STenergyPersistentCut << std::endl;
315 LogDebug(
"MuonSimDebug") <<
" track leaving hit in muons made selected for persistency"<<std::endl;
334 float zexit = theExitPoint.
z();
336 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
341 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/
GeV;
344 std::cerr <<
"!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
350 LogDebug(
"MuonSimDebug") <<
"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<
" " 351 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
352 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
353 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
355 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
357 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
358 LogDebug(
"MuonSimDebug") <<
"updhit exit " << theExitPoint<<std::endl;
390 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
392 std::cerr <<
" ERROR: no G4VUserTrackInformation available"<<std::endl;
397 std::cerr <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
422 std::vector<std::string>
temp;
429 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
430 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
432 const G4TouchableHistory * theTouchable=(
const G4TouchableHistory *)
433 (preStepPoint->GetTouchable());
435 G4int
depth = theTouchable->GetHistory()->GetDepth();
436 G4ThreeVector localCoordinates = theTouchable->GetHistory()
437 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
444 G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
445 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
446 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
448 const G4TouchableHistory * theTouchable = (
const G4TouchableHistory *)
449 (preStepPoint->GetTouchable());
451 G4int
depth = theTouchable->GetHistory()->GetDepth();
452 G4ThreeVector localCoordinates = theTouchable->GetHistory()
453 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
T getParameter(std::string const &) const
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
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 fillHits(edm::PSimHitContainer &, std::string use)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
type of data representation of DDCompactView
virtual void AssignSD(const std::string &vname)
MuonSubDetector * detector
virtual void EndOfEvent(G4HCofThisEvent *)
bool STallMuonsPersistent
unsigned int processId(const G4VProcess *p)
Geom::Theta< T > theta() const
std::vector< PSimHit > & hits()
Point3DBase< float, GlobalTag > Global3DPoint
Local3DPoint exitPoint() const
Exit point in the local Det frame.
virtual ~MuonSensitiveDetector()
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
void updateExitPoint(const Local3DPoint &exit)
virtual void Initialize()
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Global3DPoint theGlobalEntry
Local3DPoint toOrcaUnits(Local3DPoint)
Abs< T >::type abs(const T &t)
std::vector< std::string > getNames()
const SimTrackManager * theManager
void printGlobal(GlobalPoint) const
static int particleID(const G4Track *)
MuonFrameRotation * theRotation
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
double STenergyPersistentCut
Point3DBase< float, LocalTag > Local3DPoint
void addEnergyLoss(float eloss)
void startNewSimHit(std::string)
MuonSimHitNumberingScheme * numbering
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *s)
G4TrackToParticleID * myG4TrackToParticleID
float energyLoss() const
The energy deposit in the PSimHit, in ???.
MuonSensitiveDetector(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
int getSuperNo(int level) const
G4VPhysicalVolume * thePV
virtual bool processHits(const PSimHit &)
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
std::vector< PSimHit > PSimHitContainer
Local3DPoint InitialStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
virtual uint32_t setDetUnitId(G4Step *)
void storeVolumeAndTrack(G4Step *)
TrackInformation * getOrCreateTrackInformation(const G4Track *theTrack)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
unsigned int detUnitId() const
UpdatablePSimHit * theHit
MuonG4Numbering * g4numbering
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
SimHitPrinter * thePrinter