21 #include "G4SDManager.hh"
22 #include "G4VProcess.hh"
23 #include "G4EventManager.hh"
35 thePV(0), theHit(0), theDetUnitId(0), theTrackID(0), theManager(manager)
46 LogDebug(
"MuonSimDebug") <<
"create MuonSubDetector "<<name<<std::endl;
50 LogDebug(
"MuonSimDebug") <<
"create MuonFrameRotation"<<std::endl;
64 LogDebug(
"MuonSimDebug") <<
"create MuonSlaveSD"<<std::endl;
66 LogDebug(
"MuonSimDebug") <<
"create MuonSimHitNumberingScheme"<<std::endl;
74 std::vector<std::string> lvNames = clg.
logicalNames(name);
76 for (std::vector<std::string>::iterator it = lvNames.begin(); it != lvNames.end(); it++){
77 LogDebug(
"MuonSimDebug") << name <<
" MuonSensitiveDetector:: attaching SD to LV " << *it << std::endl;
86 LogDebug(
"MuonSimDebug") <<
" EnergyThresholdForPersistency " << STenergyPersistentCut <<
" AllMuonsPersistent " << STallMuonsPersistent << std::endl;
124 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::clearHits"<<std::endl;
134 if (aStep->GetTotalEnergyDeposit()>0.){
136 if( aStep->GetTrack()->GetDynamicParticle()->GetCharge() != 0 ){
177 G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
178 G4Track *
t = aStep->GetTrack();
185 G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
186 G4Track *
t = aStep->GetTrack();
188 unsigned int currentTrackID=t->GetTrackID();
190 bool changed=((pv!=
thePV) ||
198 G4Track * theTrack = aStep->GetTrack();
210 float zentry = theEntryPoint.
z();
211 float zexit = theExitPoint.
z();
215 theEntryPoint =
Local3DPoint( tempEntryPoint.
x(), tempEntryPoint.
y(), zentry );
216 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
222 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
223 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
224 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
227 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
228 G4ThreeVector lmd = ((
const G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
229 ->GetTopTransform().TransformAxis(gmd);
231 float theThetaAtEntry = lnmd.
theta();
232 float thePhiAtEntry = lnmd.
phi();
242 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
243 const G4TouchableHistory * theTouchable=(
const G4TouchableHistory *)
244 (preStepPoint->GetTouchable());
250 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
258 LogDebug(
"MuonSimDebug") <<
"=== NEW ==================> ELOSS = "<<theEnergyLoss<<
" "
259 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
260 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
261 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
263 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
265 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
266 LogDebug(
"MuonSimDebug") <<
"newhit theta " << theThetaAtEntry<<std::endl;
267 LogDebug(
"MuonSimDebug") <<
"newhit phi " << thePhiAtEntry<<std::endl;
268 LogDebug(
"MuonSimDebug") <<
"newhit pabs " << thePabs<<std::endl;
269 LogDebug(
"MuonSimDebug") <<
"newhit tof " << theTof<<std::endl;
271 LogDebug(
"MuonSimDebug") <<
"newhit entry " << theEntryPoint<<std::endl;
272 LogDebug(
"MuonSimDebug") <<
"newhit exit " << theExitPoint<<std::endl;
273 LogDebug(
"MuonSimDebug") <<
"newhit eloss " << theEnergyLoss << std::endl;
275 LogDebug(
"MuonSimDebug") <<
"newhit delta " << (theExitPoint-theEntryPoint)<<std::endl;
276 LogDebug(
"MuonSimDebug") <<
"newhit deltu " << (theExitPoint-theEntryPoint).
unit();
277 LogDebug(
"MuonSimDebug") <<
" " << (theExitPoint-theEntryPoint).
mag()<<std::endl;
279 LogDebug(
"MuonSimDebug") <<
"newhit dpos " << theGlobalPos<<std::endl;
280 LogDebug(
"MuonSimDebug") <<
"newhit drot " << std::endl;
287 int thePID = theTrack->GetDefinition()->GetPDGEncoding();
288 LogDebug(
"MuonSimDebug") <<
" checking simtrack " << thePID <<
" " << thePabs <<
" STenergyPersistentCut " <<
STenergyPersistentCut << std::endl;
293 LogDebug(
"MuonSimDebug") <<
" track leaving hit in muons made selected for persistency"<<std::endl;
312 float zexit = theExitPoint.
z();
314 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
319 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
322 std::cerr <<
"!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
328 LogDebug(
"MuonSimDebug") <<
"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<
" "
329 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
330 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
331 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
333 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
335 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
336 LogDebug(
"MuonSimDebug") <<
"updhit exit " << theExitPoint<<std::endl;
368 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
370 std::cerr <<
" ERROR: no G4VUserTrackInformation available"<<std::endl;
375 std::cerr <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
400 std::vector<std::string>
temp;
407 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
408 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
410 const G4TouchableHistory * theTouchable=(
const G4TouchableHistory *)
411 (preStepPoint->GetTouchable());
413 G4int depth = theTouchable->GetHistory()->GetDepth();
414 G4ThreeVector localCoordinates = theTouchable->GetHistory()
415 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
422 G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
423 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
424 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
426 const G4TouchableHistory * theTouchable = (
const G4TouchableHistory *)
427 (preStepPoint->GetTouchable());
429 G4int depth = theTouchable->GetHistory()->GetDepth();
430 G4ThreeVector localCoordinates = theTouchable->GetHistory()
431 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
T getParameter(std::string const &) const
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
std::vector< std::string > logicalNames(std::string &readoutName)
virtual int baseNumberToUnitNumber(const MuonBaseNumber)
void printLocal(LocalPoint, LocalPoint) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
Geom::Phi< T > phi() const
void fillHits(edm::PSimHitContainer &, std::string use)
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const =0
type of data representation of DDCompactView
MuonSubDetector * detector
virtual void EndOfEvent(G4HCofThisEvent *)
bool STallMuonsPersistent
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()
void updateExitPoint(const Local3DPoint &exit)
virtual void Initialize()
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Global3DPoint theGlobalEntry
Local3DPoint toOrcaUnits(Local3DPoint)
std::vector< std::string > getNames()
const SimTrackManager * theManager
void printGlobal(GlobalPoint) const
int particleID(const G4Track *)
MuonFrameRotation * theRotation
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
double STenergyPersistentCut
Point3DBase< float, LocalTag > Local3DPoint
void addEnergyLoss(float eloss)
unsigned int processId(const G4VProcess *)
void startNewSimHit(std::string)
MuonSimHitNumberingScheme * numbering
MuonSensitiveDetector(std::string, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *s)
G4TrackToParticleID * myG4TrackToParticleID
virtual void AssignSD(std::string &vname)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
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