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();
240 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
241 G4TouchableHistory * theTouchable=(G4TouchableHistory *)
242 (preStepPoint->GetTouchable());
248 LogDebug(
"MuonSimDebug") <<
"MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
256 LogDebug(
"MuonSimDebug") <<
"=== NEW ==================> ELOSS = "<<theEnergyLoss<<
" "
257 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
258 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
259 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
261 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
263 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
264 LogDebug(
"MuonSimDebug") <<
"newhit theta " << theThetaAtEntry<<std::endl;
265 LogDebug(
"MuonSimDebug") <<
"newhit phi " << thePhiAtEntry<<std::endl;
266 LogDebug(
"MuonSimDebug") <<
"newhit pabs " << thePabs<<std::endl;
267 LogDebug(
"MuonSimDebug") <<
"newhit tof " << theTof<<std::endl;
269 LogDebug(
"MuonSimDebug") <<
"newhit entry " << theEntryPoint<<std::endl;
270 LogDebug(
"MuonSimDebug") <<
"newhit exit " << theExitPoint<<std::endl;
271 LogDebug(
"MuonSimDebug") <<
"newhit eloss " << theEnergyLoss << std::endl;
273 LogDebug(
"MuonSimDebug") <<
"newhit delta " << (theExitPoint-theEntryPoint)<<std::endl;
274 LogDebug(
"MuonSimDebug") <<
"newhit deltu " << (theExitPoint-theEntryPoint).
unit();
275 LogDebug(
"MuonSimDebug") <<
" " << (theExitPoint-theEntryPoint).
mag()<<std::endl;
277 LogDebug(
"MuonSimDebug") <<
"newhit dpos " << theGlobalPos<<std::endl;
278 LogDebug(
"MuonSimDebug") <<
"newhit drot " << std::endl;
285 int thePID = theTrack->GetDefinition()->GetPDGEncoding();
286 LogDebug(
"MuonSimDebug") <<
" checking simtrack " << thePID <<
" " << thePabs <<
" STenergyPersistentCut " <<
STenergyPersistentCut << std::endl;
291 LogDebug(
"MuonSimDebug") <<
" track leaving hit in muons made selected for persistency"<<std::endl;
310 float zexit = theExitPoint.
z();
312 theExitPoint =
Local3DPoint( tempExitPoint.
x(), tempExitPoint.
y(), zexit );
317 float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
320 std::cerr <<
"!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
326 LogDebug(
"MuonSimDebug") <<
"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<
" "
327 <<
thePV->GetLogicalVolume()->GetName()<<std::endl;
328 const G4VProcess*
p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
329 const G4VProcess*
p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
331 LogDebug(
"MuonSimDebug") <<
" POST PROCESS = "<<p->GetProcessName()<<std::endl;
333 LogDebug(
"MuonSimDebug") <<
" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
334 LogDebug(
"MuonSimDebug") <<
"updhit exit " << theExitPoint<<std::endl;
366 G4VUserTrackInformation*
temp = gTrack->GetUserInformation();
368 std::cerr <<
" ERROR: no G4VUserTrackInformation available"<<std::endl;
373 std::cerr <<
" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
398 std::vector<std::string>
temp;
405 G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
406 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
408 G4TouchableHistory * theTouchable=(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 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
424 G4TouchableHistory * theTouchable = (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)
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
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)
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