20 #include "G4SDManager.hh"
21 #include "G4VProcess.hh"
22 #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;
61 LogDebug(
"MuonSimDebug") <<
"create MuonSlaveSD"<<std::endl;
63 LogDebug(
"MuonSimDebug") <<
"create MuonSimHitNumberingScheme"<<std::endl;
71 std::vector<std::string> lvNames = clg.
logicalNames(name);
73 for (std::vector<std::string>::iterator it = lvNames.begin(); it != lvNames.end(); it++){
74 LogDebug(
"MuonSimDebug") << name <<
" MuonSensitiveDetector:: attaching SD to LV " << *it << std::endl;
83 LogDebug(
"MuonSimDebug") <<
" EnergyThresholdForPersistency " << STenergyPersistentCut <<
" AllMuonsPersistent " << STallMuonsPersistent << std::endl;
121 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::clearHits"<<std::endl;
131 if (aStep->GetTotalEnergyDeposit()>0.){
133 if( aStep->GetTrack()->GetDynamicParticle()->GetCharge() != 0 ){
175 G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
176 G4Track *
t = aStep->GetTrack();
183 G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
184 G4Track *
t = aStep->GetTrack();
186 unsigned int currentTrackID=t->GetTrackID();
188 bool changed=((pv!=
thePV) ||
196 G4Track * theTrack = aStep->GetTrack();
208 float zentry = theEntryPoint.
z();
209 float zexit = theExitPoint.
z();
213 theEntryPoint =
Local3DPoint( tempEntryPoint.
x(), tempEntryPoint.
y(), zentry );
214 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
220 float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
221 float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
222 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
225 G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
226 G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
227 ->GetTopTransform().TransformAxis(gmd);
229 float theThetaAtEntry = lnmd.
theta();
230 float thePhiAtEntry = lnmd.
phi();
237 const G4RotationMatrix * theGlobalRot;
241 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
242 G4TouchableHistory * theTouchable=(G4TouchableHistory *)
243 (preStepPoint->GetTouchable());
246 theGlobalRot = theTouchable->GetRotation();
249 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
257 LogDebug(
"MuonSimDebug") <<
"=== NEW ==================> ELOSS = "<<theEnergyLoss<<
" "
258 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
259 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
260 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
262 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
264 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
265 LogDebug(
"MuonSimDebug") <<
"newhit theta " << theThetaAtEntry<<std::endl;
266 LogDebug(
"MuonSimDebug") <<
"newhit phi " << thePhiAtEntry<<std::endl;
267 LogDebug(
"MuonSimDebug") <<
"newhit pabs " << thePabs<<std::endl;
268 LogDebug(
"MuonSimDebug") <<
"newhit tof " << theTof<<std::endl;
270 LogDebug(
"MuonSimDebug") <<
"newhit entry " << theEntryPoint<<std::endl;
271 LogDebug(
"MuonSimDebug") <<
"newhit exit " << theExitPoint<<std::endl;
272 LogDebug(
"MuonSimDebug") <<
"newhit eloss " << theEnergyLoss << std::endl;
274 LogDebug(
"MuonSimDebug") <<
"newhit delta " << (theExitPoint-theEntryPoint)<<std::endl;
275 LogDebug(
"MuonSimDebug") <<
"newhit deltu " << (theExitPoint-theEntryPoint).
unit();
276 LogDebug(
"MuonSimDebug") <<
" " << (theExitPoint-theEntryPoint).
mag()<<std::endl;
278 LogDebug(
"MuonSimDebug") <<
"newhit dpos " << theGlobalPos<<std::endl;
279 LogDebug(
"MuonSimDebug") <<
"newhit drot " << std::endl;
286 int thePID = theTrack->GetDefinition()->GetPDGEncoding();
287 LogDebug(
"MuonSimDebug") <<
" checking simtrack " << thePID <<
" " << thePabs <<
" STenergyPersistentCut " <<
STenergyPersistentCut << std::endl;
292 LogDebug(
"MuonSimDebug") <<
" track leaving hit in muons made selected for persistency"<<std::endl;
311 float zexit = theExitPoint.
z();
313 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
318 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
321 std::cerr <<
"!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
327 LogDebug(
"MuonSimDebug") <<
"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<
" "
328 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
329 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
330 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
332 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
334 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
335 LogDebug(
"MuonSimDebug") <<
"updhit exit " << theExitPoint<<std::endl;
367 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
369 std::cerr <<
" ERROR: no G4VUserTrackInformation available"<<std::endl;
374 std::cerr <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
399 std::vector<std::string>
temp;
406 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
407 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
409 G4TouchableHistory * theTouchable=(G4TouchableHistory *)
410 (preStepPoint->GetTouchable());
412 G4int depth = theTouchable->GetHistory()->GetDepth();
413 G4ThreeVector localCoordinates = theTouchable->GetHistory()
414 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
421 G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
422 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
423 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
425 G4TouchableHistory * theTouchable = (G4TouchableHistory *)
426 (preStepPoint->GetTouchable());
428 G4int depth = theTouchable->GetHistory()->GetDepth();
429 G4ThreeVector localCoordinates = theTouchable->GetHistory()
430 ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
T getParameter(std::string const &) const
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
virtual Local3DPoint transformPoint(Local3DPoint &, G4Step *) const =0
std::vector< std::string > logicalNames(std::string &readoutName)
virtual int baseNumberToUnitNumber(const MuonBaseNumber)
void printLocal(LocalPoint, LocalPoint) const
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
Geom::Phi< T > phi() const
void fillHits(edm::PSimHitContainer &, std::string use)
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()
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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