CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonSensitiveDetector Class Reference

#include <MuonSensitiveDetector.h>

Inheritance diagram for MuonSensitiveDetector:
SensitiveTkDetector Observer< const BeginOfEvent * > Observer< const EndOfEvent * > SensitiveDetector

Public Member Functions

virtual void EndOfEvent (G4HCofThisEvent *)
 
void fillHits (edm::PSimHitContainer &, std::string use)
 
std::vector< std::string > getNames ()
 
const MuonSlaveSDGetSlaveMuon () const
 
 MuonSensitiveDetector (std::string, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
virtual G4bool ProcessHits (G4Step *, G4TouchableHistory *)
 
virtual uint32_t setDetUnitId (G4Step *)
 
std::string type ()
 
virtual ~MuonSensitiveDetector ()
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (G4ThreeVector point)
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual void Initialize (G4HCofThisEvent *eventHC)
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual ~SensitiveDetector ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent *iT)
 
virtual ~Observer ()
 

Private Member Functions

virtual void clearHits ()
 
void createHit (G4Step *)
 
Local3DPoint FinalStepPositionVsParent (G4Step *currentStep, G4int levelsUp)
 
TrackInformationgetOrCreateTrackInformation (const G4Track *theTrack)
 
Local3DPoint InitialStepPositionVsParent (G4Step *currentStep, G4int levelsUp)
 
bool newHit (G4Step *)
 
void saveHit ()
 
void storeVolumeAndTrack (G4Step *)
 
Local3DPoint toOrcaRef (Local3DPoint in, G4Step *s)
 
Local3DPoint toOrcaUnits (Local3DPoint)
 
Global3DPoint toOrcaUnits (Global3DPoint)
 
void update (const BeginOfEvent *)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *)
 
void updateHit (G4Step *)
 

Private Attributes

MuonSubDetectordetector
 
MuonG4Numberingg4numbering
 
G4TrackToParticleIDmyG4TrackToParticleID
 
MuonSimHitNumberingSchemenumbering
 
bool printHits
 
MuonSlaveSDslaveMuon
 
bool STallMuonsPersistent
 
double STenergyPersistentCut
 
uint32_t theDetUnitId
 
G4ProcessTypeEnumeratortheG4ProcessTypeEnumerator
 
Global3DPoint theGlobalEntry
 
UpdatablePSimHittheHit
 
const SimTrackManagertheManager
 
SimHitPrinterthePrinter
 
G4VPhysicalVolume * thePV
 
MuonFrameRotationtheRotation
 
unsigned int theTrackID
 

Additional Inherited Members

- Public Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Member Functions inherited from Observer< const EndOfEvent * >
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Detailed Description

implementation of SensitiveDetector for the muon detector; a MuonSlaveSD handles the interfacing to the database; numbering scheme are booked according to the detector name

Author
Arno Straessner, CERN arno..nosp@m.stra.nosp@m.essne.nosp@m.r@ce.nosp@m.rn.ch

Modification: 19/05/03. P.Arce Add SimTracks selection

Definition at line 44 of file MuonSensitiveDetector.h.

Constructor & Destructor Documentation

MuonSensitiveDetector::MuonSensitiveDetector ( std::string  name,
const DDCompactView cpv,
SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 29 of file MuonSensitiveDetector.cc.

References SensitiveDetector::AssignSD(), detector, g4numbering, edm::ParameterSet::getParameter(), MuonSubDetector::isEndcap(), MuonSubDetector::isRpc(), LogDebug, SensitiveDetectorCatalog::logicalNames(), myG4TrackToParticleID, numbering, printHits, SensitiveDetector::Register(), slaveMuon, STallMuonsPersistent, STenergyPersistentCut, theG4ProcessTypeEnumerator, theManager, thePrinter, and theRotation.

34  : SensitiveTkDetector(name, cpv, clg, p),
35  thePV(0), theHit(0), theDetUnitId(0), theTrackID(0), theManager(manager)
36 {
37  edm::ParameterSet m_MuonSD = p.getParameter<edm::ParameterSet>("MuonSD");
38  STenergyPersistentCut = m_MuonSD.getParameter<double>("EnergyThresholdForPersistency");//Default 1. GeV
39  STallMuonsPersistent = m_MuonSD.getParameter<bool>("AllMuonsPersistent");
40  printHits = m_MuonSD.getParameter<bool>("PrintHits");
41 
42  //
43  // Here simply create 1 MuonSlaveSD for the moment
44  //
45 
46  LogDebug("MuonSimDebug") << "create MuonSubDetector "<<name<<std::endl;
47 
49 
50  LogDebug("MuonSimDebug") << "create MuonFrameRotation"<<std::endl;
51 
52  if (detector->isEndcap()) {
53  // cout << "MuonFrameRotation create MuonEndcapFrameRotation"<<endl;
55  } else if (detector->isRpc()) {
56  // cout << "MuonFrameRotation create MuonRpcFrameRotation"<<endl;
58  } else {
59  theRotation = 0;
60  }
61  LogDebug("MuonSimDebug") << "create MuonSlaveSD"<<std::endl;
63  LogDebug("MuonSimDebug") << "create MuonSimHitNumberingScheme"<<std::endl;
65  g4numbering = new MuonG4Numbering(cpv);
66 
67 
68  //
69  // Now attach the right detectors (LogicalVolumes) to me
70  //
71  std::vector<std::string> lvNames = clg.logicalNames(name);
72  this->Register();
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;
75  this->AssignSD(*it);
76  }
77 
78  if (printHits) {
79  thePrinter = new SimHitPrinter("HitPositionOSCAR.dat");
80  }
81 
82 
83  LogDebug("MuonSimDebug") << " EnergyThresholdForPersistency " << STenergyPersistentCut << " AllMuonsPersistent " << STallMuonsPersistent << std::endl;
84 
87 
88 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::vector< std::string > logicalNames(std::string &readoutName)
MuonSubDetector * detector
SensitiveTkDetector(std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
const SimTrackManager * theManager
MuonFrameRotation * theRotation
MuonSimHitNumberingScheme * numbering
G4TrackToParticleID * myG4TrackToParticleID
virtual void AssignSD(std::string &vname)
G4VPhysicalVolume * thePV
UpdatablePSimHit * theHit
MuonG4Numbering * g4numbering
MuonSensitiveDetector::~MuonSensitiveDetector ( )
virtual

Definition at line 91 of file MuonSensitiveDetector.cc.

References detector, g4numbering, myG4TrackToParticleID, numbering, slaveMuon, theG4ProcessTypeEnumerator, and theRotation.

91  {
92  delete g4numbering;
93  delete numbering;
94  delete slaveMuon;
95  delete theRotation;
96  delete detector;
97 
99 
100  delete myG4TrackToParticleID;
101 }
MuonSubDetector * detector
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
MuonFrameRotation * theRotation
MuonSimHitNumberingScheme * numbering
G4TrackToParticleID * myG4TrackToParticleID
MuonG4Numbering * g4numbering

Member Function Documentation

void MuonSensitiveDetector::clearHits ( )
privatevirtual

Implements SensitiveDetector.

Definition at line 119 of file MuonSensitiveDetector.cc.

References TrackingSlaveSD::Initialize(), LogDebug, and slaveMuon.

Referenced by update().

120 {
121  LogDebug("MuonSimDebug") << "MuonSensitiveDetector::clearHits"<<std::endl;
123 }
#define LogDebug(id)
virtual void Initialize()
void MuonSensitiveDetector::createHit ( G4Step *  aStep)
private

Definition at line 194 of file MuonSensitiveDetector.cc.

References abs, SensitiveDetector::ConvertToLocal3DPoint(), detector, SensitiveDetector::FinalStepPosition(), FinalStepPositionVsParent(), getOrCreateTrackInformation(), info, SensitiveDetector::InitialStepPosition(), InitialStepPositionVsParent(), MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), SensitiveDetector::LocalCoordinates, LogDebug, mag(), myG4TrackToParticleID, L1TEmulatorMonitor_cff::p, p2, G4TrackToParticleID::particleID(), PV3DBase< T, PVType, FrameType >::phi(), printHits, G4ProcessTypeEnumerator::processId(), setDetUnitId(), STallMuonsPersistent, STenergyPersistentCut, TrackInformation::storeTrack(), storeVolumeAndTrack(), theDetUnitId, theG4ProcessTypeEnumerator, theGlobalEntry, theHit, thePV, PV3DBase< T, PVType, FrameType >::theta(), theTrackID, toOrcaRef(), toOrcaUnits(), csvLumiCalc::unit, SensitiveDetector::WorldCoordinates, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ProcessHits().

194  {
195 
196  G4Track * theTrack = aStep->GetTrack();
197 
198  Local3DPoint theEntryPoint;
199  Local3DPoint theExitPoint;
200 
201  if (detector->isBarrel()) {
202  theEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPositionVsParent(aStep,1),aStep)); // 1 level up
203  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,1),aStep));
204  } else if (detector->isEndcap()) {
205  // save local z at current level
206  theEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPosition(aStep,LocalCoordinates),aStep));
207  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
208  float zentry = theEntryPoint.z();
209  float zexit = theExitPoint.z();
210  Local3DPoint tempEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPositionVsParent(aStep,4),aStep)); // 4 levels up
211  Local3DPoint tempExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,4),aStep));
212  // reset local z from z wrt deep-parent volume to z wrt low-level volume
213  theEntryPoint = Local3DPoint( tempEntryPoint.x(), tempEntryPoint.y(), zentry );
214  theExitPoint = Local3DPoint( tempExitPoint.x(), tempExitPoint.y(), zexit );
215  } else {
216  theEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPosition(aStep,LocalCoordinates),aStep));
217  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
218  }
219 
220  float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
221  float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
222  float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
223  // int theParticleType = theTrack->GetDefinition()->GetPDGEncoding();
224  int theParticleType = myG4TrackToParticleID->particleID(theTrack);
225  G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
226  G4ThreeVector lmd = ((G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
227  ->GetTopTransform().TransformAxis(gmd);
228  Local3DPoint lnmd = toOrcaRef(ConvertToLocal3DPoint(lmd),aStep);
229  float theThetaAtEntry = lnmd.theta();
230  float thePhiAtEntry = lnmd.phi();
231 
232  storeVolumeAndTrack( aStep );
233  theDetUnitId = setDetUnitId(aStep);
234 
235  Global3DPoint theGlobalPos;
236  if (printHits) {
237  const G4RotationMatrix * theGlobalRot;
238  Local3DPoint theGlobalHelp = InitialStepPosition(aStep,WorldCoordinates);
239  theGlobalEntry = toOrcaUnits(Global3DPoint (theGlobalHelp.x(),theGlobalHelp.y(),theGlobalHelp.z()));
240 
241  G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
242  G4TouchableHistory * theTouchable=(G4TouchableHistory *)
243  (preStepPoint->GetTouchable());
244  theGlobalHelp=ConvertToLocal3DPoint(theTouchable->GetTranslation());
245  theGlobalPos = toOrcaUnits(Global3DPoint (theGlobalHelp.x(),theGlobalHelp.y(),theGlobalHelp.z()));
246  theGlobalRot = theTouchable->GetRotation();
247  }
248 
249  LogDebug("MuonSimDebug") << "MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
250 
251  theHit = new UpdatablePSimHit(theEntryPoint,theExitPoint,thePabs,theTof,
252  theEnergyLoss,theParticleType,theDetUnitId,
253  theTrackID,theThetaAtEntry,thePhiAtEntry,
254  theG4ProcessTypeEnumerator->processId(theTrack->GetCreatorProcess()));
255 
256 
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();
261  if (p)
262  LogDebug("MuonSimDebug") <<" POST PROCESS = "<<p->GetProcessName()<<std::endl;
263  if (p2)
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;
269  LogDebug("MuonSimDebug") << "newhit track " << theTrackID<<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;
273  LogDebug("MuonSimDebug") << "newhit detid " << theDetUnitId<<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;
277  LogDebug("MuonSimDebug") << "newhit glob " << theGlobalEntry<<std::endl;
278  LogDebug("MuonSimDebug") << "newhit dpos " << theGlobalPos<<std::endl;
279  LogDebug("MuonSimDebug") << "newhit drot " << std::endl;
280  // theGlobalRot->print(LogDebug("MuonSimDebug"));
281 
282 
283  //
284  //----- SimTracks: Make it persistent?
285  //
286  int thePID = theTrack->GetDefinition()->GetPDGEncoding();
287  LogDebug("MuonSimDebug") << " checking simtrack " << thePID << " " << thePabs << " STenergyPersistentCut " << STenergyPersistentCut << std::endl;
288 
289  if( thePabs*GeV > STenergyPersistentCut
290  || ( abs(thePID) == 13 && STallMuonsPersistent ) ){
292  LogDebug("MuonSimDebug") <<" track leaving hit in muons made selected for persistency"<<std::endl;
293 
294  info->storeTrack(true);
295  }
296 
297 }
#define LogDebug(id)
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
bool storeTrack() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
T y() const
Definition: PV3DBase.h:57
#define abs(x)
Definition: mlp_lapack.h:159
MuonSubDetector * detector
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:58
Local3DPoint toOrcaUnits(Local3DPoint)
double p2[4]
Definition: TauolaWrapper.h:90
int particleID(const G4Track *)
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
unsigned int processId(const G4VProcess *)
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *s)
G4TrackToParticleID * myG4TrackToParticleID
G4VPhysicalVolume * thePV
Local3DPoint InitialStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
virtual uint32_t setDetUnitId(G4Step *)
T x() const
Definition: PV3DBase.h:56
TrackInformation * getOrCreateTrackInformation(const G4Track *theTrack)
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
UpdatablePSimHit * theHit
void MuonSensitiveDetector::EndOfEvent ( G4HCofThisEvent *  )
virtual

Reimplemented from SensitiveDetector.

Definition at line 381 of file MuonSensitiveDetector.cc.

References saveHit().

382 {
383 // TimeMe t("MuonSensitiveDetector::EndOfEvent", false);
384  // LogDebug("MuonSimDebug") << "MuonSensitiveDetector::EndOfEvent saving last hit en event " << std::endl;
385  saveHit();
386 }
void MuonSensitiveDetector::fillHits ( edm::PSimHitContainer c,
std::string  use 
)
virtual

Implements SensitiveTkDetector.

Definition at line 389 of file MuonSensitiveDetector.cc.

References TrackingSlaveSD::hits(), n, TrackingSlaveSD::name(), and slaveMuon.

389  {
390  //
391  // do it once for low, once for High
392  //
393 
394  if (slaveMuon->name() == n) c=slaveMuon->hits();
395 
396 }
std::string name() const
std::vector< PSimHit > & hits()
Local3DPoint MuonSensitiveDetector::FinalStepPositionVsParent ( G4Step *  currentStep,
G4int  levelsUp 
)
private

Definition at line 419 of file MuonSensitiveDetector.cc.

References SensitiveDetector::ConvertToLocal3DPoint().

Referenced by createHit(), and updateHit().

419  {
420 
421  G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
422  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
423  G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
424 
425  G4TouchableHistory * theTouchable = (G4TouchableHistory *)
426  (preStepPoint->GetTouchable());
427 
428  G4int depth = theTouchable->GetHistory()->GetDepth();
429  G4ThreeVector localCoordinates = theTouchable->GetHistory()
430  ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
431 
432  return ConvertToLocal3DPoint(localCoordinates);
433 }
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
std::vector< std::string > MuonSensitiveDetector::getNames ( )
virtual

Reimplemented from SensitiveDetector.

Definition at line 398 of file MuonSensitiveDetector.cc.

References TrackingSlaveSD::name(), slaveMuon, and cond::rpcobtemp::temp.

398  {
399  std::vector<std::string> temp;
400  temp.push_back(slaveMuon->name());
401  return temp;
402 }
std::string name() const
TrackInformation * MuonSensitiveDetector::getOrCreateTrackInformation ( const G4Track *  theTrack)
private

Definition at line 365 of file MuonSensitiveDetector.cc.

References benchmark_cfg::cerr, info, and cond::rpcobtemp::temp.

Referenced by createHit().

366 {
367  G4VUserTrackInformation* temp = gTrack->GetUserInformation();
368  if (temp == 0){
369  std::cerr <<" ERROR: no G4VUserTrackInformation available"<<std::endl;
370  abort();
371  }else{
372  TrackInformation* info = dynamic_cast<TrackInformation*>(temp);
373  if (info ==0){
374  std::cerr <<" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
375  abort();
376  }
377  return info;
378  }
379 }
const MuonSlaveSD* MuonSensitiveDetector::GetSlaveMuon ( ) const
inline

Definition at line 63 of file MuonSensitiveDetector.h.

References slaveMuon.

63  {
64  return slaveMuon; }
Local3DPoint MuonSensitiveDetector::InitialStepPositionVsParent ( G4Step *  currentStep,
G4int  levelsUp 
)
private

Transform from local coordinates of a volume to local coordinates of a parent volume one or more levels up the volume hierarchy: e.g. levelsUp = 1 for immediate parent.
This is done by moving from local_1 -> global -> local_2.

Definition at line 404 of file MuonSensitiveDetector.cc.

References SensitiveDetector::ConvertToLocal3DPoint().

Referenced by createHit().

404  {
405 
406  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
407  G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
408 
409  G4TouchableHistory * theTouchable=(G4TouchableHistory *)
410  (preStepPoint->GetTouchable());
411 
412  G4int depth = theTouchable->GetHistory()->GetDepth();
413  G4ThreeVector localCoordinates = theTouchable->GetHistory()
414  ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
415 
416  return ConvertToLocal3DPoint(localCoordinates);
417 }
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
bool MuonSensitiveDetector::newHit ( G4Step *  aStep)
private

Definition at line 181 of file MuonSensitiveDetector.cc.

References setDetUnitId(), matplotRender::t, theDetUnitId, thePV, and theTrackID.

Referenced by ProcessHits().

181  {
182 
183  G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
184  G4Track * t = aStep->GetTrack();
185  uint32_t currentUnitId=setDetUnitId(aStep);
186  unsigned int currentTrackID=t->GetTrackID();
187  //unsigned int currentEventID=G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID();
188  bool changed=((pv!=thePV) ||
189  (currentUnitId!=theDetUnitId) ||
190  (currentTrackID!=theTrackID));
191  return changed;
192 }
G4VPhysicalVolume * thePV
virtual uint32_t setDetUnitId(G4Step *)
bool MuonSensitiveDetector::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
virtual

Implements SensitiveDetector.

Definition at line 125 of file MuonSensitiveDetector.cc.

References createHit(), SensitiveDetector::InitialStepPosition(), LogDebug, newHit(), saveHit(), storeVolumeAndTrack(), updateHit(), and SensitiveDetector::WorldCoordinates.

126 {
127  LogDebug("MuonSimDebug") <<" MuonSensitiveDetector::ProcessHits "<<InitialStepPosition(aStep,WorldCoordinates)<<std::endl;
128 
129  // TimeMe t1( theHitTimer, false);
130 
131  if (aStep->GetTotalEnergyDeposit()>0.){
132  // do not count neutrals that are killed by User Limits MinEKine
133  if( aStep->GetTrack()->GetDynamicParticle()->GetCharge() != 0 ){
134 
135  if (newHit(aStep)) {
136  saveHit();
137  createHit(aStep);
138  } else {
139  updateHit(aStep);
140  }
141  return true;
142  } else {
143  storeVolumeAndTrack(aStep);
144  return false;
145  }
146  }
147  return false;
148 }
#define LogDebug(id)
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
void MuonSensitiveDetector::saveHit ( )
private

Definition at line 344 of file MuonSensitiveDetector.cc.

References detector, PSimHit::detUnitId(), PSimHit::entryPoint(), PSimHit::exitPoint(), MuonSubDetector::name(), SimHitPrinter::printGlobal(), printHits, SimHitPrinter::printId(), SimHitPrinter::printLocal(), TrackingSlaveSD::processHits(), slaveMuon, SimHitPrinter::startNewSimHit(), theGlobalEntry, theHit, and thePrinter.

Referenced by EndOfEvent(), and ProcessHits().

344  {
345 
346  if (theHit) {
347  if (printHits) {
350  // thePrinter->printTrack(theHit->trackId());
351  //thePrinter->printPabs(theHit->pabs());
352  //thePrinter->printEloss(theHit->energyLoss());
355  }
357  // seems the hit does not want to be deleted
358  // done by the hit collection?
359  delete theHit;
360  theHit = 0; //set it to 0, because you are checking that is 0
361  }
362 
363 }
void printLocal(LocalPoint, LocalPoint) const
std::string name()
MuonSubDetector * detector
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Definition: PSimHit.h:38
void printGlobal(GlobalPoint) const
void startNewSimHit(std::string)
void printId(int) const
virtual bool processHits(const PSimHit &)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
unsigned int detUnitId() const
Definition: PSimHit.h:93
UpdatablePSimHit * theHit
uint32_t MuonSensitiveDetector::setDetUnitId ( G4Step *  aStep)
virtual

Implements SensitiveDetector.

Definition at line 150 of file MuonSensitiveDetector.cc.

References MuonSimHitNumberingScheme::baseNumberToUnitNumber(), g4numbering, numbering, and MuonG4Numbering::PhysicalVolumeToBaseNumber().

Referenced by createHit(), and newHit().

151 {
152  // G4VPhysicalVolume * pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
154  return numbering->baseNumberToUnitNumber(num);
155 }
virtual int baseNumberToUnitNumber(const MuonBaseNumber)
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
MuonSimHitNumberingScheme * numbering
long long int num
Definition: procUtils.cc:71
MuonG4Numbering * g4numbering
void MuonSensitiveDetector::storeVolumeAndTrack ( G4Step *  aStep)
private

Definition at line 173 of file MuonSensitiveDetector.cc.

References matplotRender::t, thePV, and theTrackID.

Referenced by createHit(), and ProcessHits().

174 {
175  G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
176  G4Track * t = aStep->GetTrack();
177  thePV=pv;
178  theTrackID=t->GetTrackID();
179 }
G4VPhysicalVolume * thePV
Local3DPoint MuonSensitiveDetector::toOrcaRef ( Local3DPoint  in,
G4Step *  s 
)
private

Definition at line 158 of file MuonSensitiveDetector.cc.

References theRotation, and MuonFrameRotation::transformPoint().

Referenced by createHit(), and updateHit().

158  {
159  if (theRotation !=0 ) {
160  return theRotation->transformPoint(in,s);
161  }
162  return (in);
163 }
virtual Local3DPoint transformPoint(Local3DPoint &, G4Step *) const =0
MuonFrameRotation * theRotation
string s
Definition: asciidump.py:422
Local3DPoint MuonSensitiveDetector::toOrcaUnits ( Local3DPoint  in)
private

Definition at line 165 of file MuonSensitiveDetector.cc.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by createHit(), and updateHit().

165  {
166  return Local3DPoint(in.x()/cm,in.y()/cm,in.z()/cm);
167 }
T y() const
Definition: PV3DBase.h:57
T z() const
Definition: PV3DBase.h:58
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
T x() const
Definition: PV3DBase.h:56
Global3DPoint MuonSensitiveDetector::toOrcaUnits ( Global3DPoint  in)
private

Definition at line 169 of file MuonSensitiveDetector.cc.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

169  {
170  return Global3DPoint(in.x()/cm,in.y()/cm,in.z()/cm);
171 }
T y() const
Definition: PV3DBase.h:57
Point3DBase< float, GlobalTag > Global3DPoint
Definition: GlobalPoint.h:7
T z() const
Definition: PV3DBase.h:58
T x() const
Definition: PV3DBase.h:56
std::string MuonSensitiveDetector::type ( )
void MuonSensitiveDetector::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 103 of file MuonSensitiveDetector.cc.

References clearHits(), theDetUnitId, thePV, and theTrackID.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

103  {
104  clearHits();
105 
106  //----- Initialize variables to check if two steps belong to same hit
107  thePV = 0;
108  theDetUnitId = 0;
109  theTrackID = 0;
110 
111 }
G4VPhysicalVolume * thePV
void MuonSensitiveDetector::update ( const ::EndOfEvent ev)
private

Definition at line 113 of file MuonSensitiveDetector.cc.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

114 {
115  //slaveMuon->renumbering(theManager);
116 }
void MuonSensitiveDetector::updateHit ( G4Step *  aStep)
private

Definition at line 299 of file MuonSensitiveDetector.cc.

References UpdatablePSimHit::addEnergyLoss(), benchmark_cfg::cerr, detector, PSimHit::energyLoss(), PSimHit::entryPoint(), SensitiveDetector::FinalStepPosition(), FinalStepPositionVsParent(), MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), SensitiveDetector::LocalCoordinates, LogDebug, mag(), L1TEmulatorMonitor_cff::p, p2, theDetUnitId, theHit, thePV, toOrcaRef(), toOrcaUnits(), csvLumiCalc::unit, UpdatablePSimHit::updateExitPoint(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ProcessHits().

299  {
300  // float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
301  // Local3DPoint theEntryPoint= InitialStepPosition(aStep,LocalCoordinates);
302 
303 
304  Local3DPoint theExitPoint;
305 
306  if (detector->isBarrel()) {
307  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,1),aStep));
308  } else if (detector->isEndcap()) {
309  // save local z at current level
310  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
311  float zexit = theExitPoint.z();
312  Local3DPoint tempExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,4),aStep));
313  theExitPoint = Local3DPoint( tempExitPoint.x(), tempExitPoint.y(), zexit );
314  } else {
315  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
316  }
317 
318  float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
319 
320  if( theHit == 0 ){
321  std::cerr << "!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
322  }
323 
324  theHit->updateExitPoint(theExitPoint);
325  theHit->addEnergyLoss(theEnergyLoss);
326 
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();
331  if (p)
332  LogDebug("MuonSimDebug") <<" POST PROCESS = "<<p->GetProcessName()<<std::endl;
333  if (p2)
334  LogDebug("MuonSimDebug") <<" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
335  LogDebug("MuonSimDebug") << "updhit exit " << theExitPoint<<std::endl;
336  LogDebug("MuonSimDebug") << "updhit eloss " << theHit->energyLoss() <<std::endl;
337  LogDebug("MuonSimDebug") << "updhit detid " << theDetUnitId<<std::endl;
338  LogDebug("MuonSimDebug") << "updhit delta " << (theExitPoint-theHit->entryPoint())<<std::endl;
339  LogDebug("MuonSimDebug") << "updhit deltu " << (theExitPoint-theHit->entryPoint()).unit();
340  LogDebug("MuonSimDebug") << " " << (theExitPoint-theHit->entryPoint()).mag()<<std::endl;
341 
342 }
#define LogDebug(id)
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T y() const
Definition: PV3DBase.h:57
MuonSubDetector * detector
void updateExitPoint(const Local3DPoint &exit)
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:58
Local3DPoint toOrcaUnits(Local3DPoint)
double p2[4]
Definition: TauolaWrapper.h:90
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
void addEnergyLoss(float eloss)
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *s)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
G4VPhysicalVolume * thePV
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
T x() const
Definition: PV3DBase.h:56
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
UpdatablePSimHit * theHit

Member Data Documentation

MuonSubDetector* MuonSensitiveDetector::detector
private
MuonG4Numbering* MuonSensitiveDetector::g4numbering
private
G4TrackToParticleID* MuonSensitiveDetector::myG4TrackToParticleID
private
MuonSimHitNumberingScheme* MuonSensitiveDetector::numbering
private
bool MuonSensitiveDetector::printHits
private

Definition at line 103 of file MuonSensitiveDetector.h.

Referenced by createHit(), MuonSensitiveDetector(), and saveHit().

MuonSlaveSD* MuonSensitiveDetector::slaveMuon
private
bool MuonSensitiveDetector::STallMuonsPersistent
private

Definition at line 109 of file MuonSensitiveDetector.h.

Referenced by createHit(), and MuonSensitiveDetector().

double MuonSensitiveDetector::STenergyPersistentCut
private

Definition at line 108 of file MuonSensitiveDetector.h.

Referenced by createHit(), and MuonSensitiveDetector().

uint32_t MuonSensitiveDetector::theDetUnitId
private

Definition at line 100 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), update(), and updateHit().

G4ProcessTypeEnumerator* MuonSensitiveDetector::theG4ProcessTypeEnumerator
private
Global3DPoint MuonSensitiveDetector::theGlobalEntry
private

Definition at line 105 of file MuonSensitiveDetector.h.

Referenced by createHit(), and saveHit().

UpdatablePSimHit* MuonSensitiveDetector::theHit
private

Definition at line 99 of file MuonSensitiveDetector.h.

Referenced by createHit(), saveHit(), and updateHit().

const SimTrackManager* MuonSensitiveDetector::theManager
private

Definition at line 114 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector().

SimHitPrinter* MuonSensitiveDetector::thePrinter
private

Definition at line 104 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector(), and saveHit().

G4VPhysicalVolume* MuonSensitiveDetector::thePV
private

Definition at line 98 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), storeVolumeAndTrack(), update(), and updateHit().

MuonFrameRotation* MuonSensitiveDetector::theRotation
private
unsigned int MuonSensitiveDetector::theTrackID
private

Definition at line 101 of file MuonSensitiveDetector.h.

Referenced by createHit(), newHit(), storeVolumeAndTrack(), and update().