CMS 3D CMS Logo

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

void clearHits () override
 
void EndOfEvent (G4HCofThisEvent *) override
 
void fillHits (edm::PSimHitContainer &, const std::string &) override
 
const MuonSlaveSDGetSlaveMuon () const
 
 MuonSensitiveDetector (const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
uint32_t setDetUnitId (const G4Step *) override
 
std::string type ()
 
 ~MuonSensitiveDetector () override
 
- Public Member Functions inherited from SensitiveTkDetector
 SensitiveTkDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
 SensitiveDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
 ~SensitiveDetector () override
 
- 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

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 (const G4Step *)
 
Local3DPoint toOrcaRef (Local3DPoint in, G4Step *)
 
Local3DPoint toOrcaUnits (const Local3DPoint &)
 
Global3DPoint toOrcaUnits (const Global3DPoint &)
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *) override
 
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

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Member Functions inherited from SensitiveDetector
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 
- 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 45 of file MuonSensitiveDetector.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file MuonSensitiveDetector.cc.

References detector, g4numbering, edm::ParameterSet::getParameter(), MuonSubDetector::isEndcap(), MuonSubDetector::isGEM(), MuonSubDetector::isME0(), MuonSubDetector::isRPC(), LogDebug, myG4TrackToParticleID, numbering, printHits, slaveMuon, STallMuonsPersistent, STenergyPersistentCut, theG4ProcessTypeEnumerator, theManager, thePrinter, and theRotation.

37  : SensitiveTkDetector(name, cpv, clg, p),
38  thePV(nullptr), theHit(nullptr), theDetUnitId(0), theTrackID(0), theManager(manager)
39 {
40  edm::ParameterSet m_MuonSD = p.getParameter<edm::ParameterSet>("MuonSD");
41  STenergyPersistentCut = m_MuonSD.getParameter<double>("EnergyThresholdForPersistency");//Default 1. GeV
42  STallMuonsPersistent = m_MuonSD.getParameter<bool>("AllMuonsPersistent");
43  printHits = m_MuonSD.getParameter<bool>("PrintHits");
44 
45  //
46  // Here simply create 1 MuonSlaveSD for the moment
47  //
48 
49  LogDebug("MuonSimDebug") << "create MuonSubDetector "<<name<<std::endl;
50 
52 
53  LogDebug("MuonSimDebug") << "create MuonFrameRotation"<<std::endl;
54 
55  //The constants take time to calculate and are needed by many helpers
57  if (detector->isEndcap()) {
58  // cout << "MuonFrameRotation create MuonEndcapFrameRotation"<<endl;
60  } else if (detector->isRPC()) {
61  // cout << "MuonFrameRotation create MuonRPCFrameRotation"<<endl;
63  } else if (detector->isGEM()) {
64  // cout << "MuonFrameRotation create MuonGEMFrameRotation"<<endl;
66  } else if (detector->isME0()) {
67  // cout << "MuonFrameRotation create MuonME0FrameRotation"<<endl;
69  } else {
70  theRotation = nullptr;
71  }
72  LogDebug("MuonSimDebug") << "create MuonSlaveSD"<<std::endl;
74  LogDebug("MuonSimDebug") << "create MuonSimHitNumberingScheme"<<std::endl;
77 
78  if (printHits) {
79  thePrinter = new SimHitPrinter("HitPositionOSCAR.dat");
80  }
81 
82 
83  edm::LogInfo("MuonSimDebug") << " EnergyThresholdForPersistency "
84  << STenergyPersistentCut << " AllMuonsPersistent "
86 
89 }
#define LogDebug(id)
T getParameter(std::string const &) const
MuonSubDetector * detector
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
const SimTrackManager * theManager
MuonFrameRotation * theRotation
MuonSimHitNumberingScheme * numbering
G4TrackToParticleID * myG4TrackToParticleID
G4VPhysicalVolume * thePV
SensitiveTkDetector(const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
MuonG4Numbering * g4numbering
MuonSensitiveDetector::~MuonSensitiveDetector ( )
override

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 ( )
overridevirtual

Implements SensitiveDetector.

Definition at line 117 of file MuonSensitiveDetector.cc.

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

Referenced by update().

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

Definition at line 205 of file MuonSensitiveDetector.cc.

References funct::abs(), SensitiveDetector::ConvertToLocal3DPoint(), detector, SensitiveDetector::FinalStepPosition(), FinalStepPositionVsParent(), getOrCreateTrackInformation(), GeV, info(), SensitiveDetector::InitialStepPosition(), InitialStepPositionVsParent(), MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), SensitiveDetector::LocalCoordinates, LogDebug, mag(), myG4TrackToParticleID, AlCaHLTBitMon_ParallelJobs::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().

205  {
206 
207  G4Track * theTrack = aStep->GetTrack();
208 
209  Local3DPoint theEntryPoint;
210  Local3DPoint theExitPoint;
211 
212  if (detector->isBarrel()) {
213  theEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPositionVsParent(aStep,1),aStep)); // 1 level up
214  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,1),aStep));
215  } else if (detector->isEndcap()) {
216  // save local z at current level
217  theEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPosition(aStep,LocalCoordinates),aStep));
218  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
219  float zentry = theEntryPoint.z();
220  float zexit = theExitPoint.z();
221  Local3DPoint tempEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPositionVsParent(aStep,4),aStep)); // 4 levels up
222  Local3DPoint tempExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,4),aStep));
223  // reset local z from z wrt deep-parent volume to z wrt low-level volume
224  theEntryPoint = Local3DPoint( tempEntryPoint.x(), tempEntryPoint.y(), zentry );
225  theExitPoint = Local3DPoint( tempExitPoint.x(), tempExitPoint.y(), zexit );
226  } else {
227  theEntryPoint= toOrcaUnits(toOrcaRef(InitialStepPosition(aStep,LocalCoordinates),aStep));
228  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
229  }
230 
231  float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
232  float theTof = aStep->GetPreStepPoint()->GetGlobalTime()/nanosecond;
233  float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
234  // int theParticleType = theTrack->GetDefinition()->GetPDGEncoding();
235  int theParticleType = myG4TrackToParticleID->particleID(theTrack);
236  G4ThreeVector gmd = aStep->GetPreStepPoint()->GetMomentumDirection();
237  G4ThreeVector lmd = ((const G4TouchableHistory *)(aStep->GetPreStepPoint()->GetTouchable()))->GetHistory()
238  ->GetTopTransform().TransformAxis(gmd);
239  Local3DPoint lnmd = toOrcaRef(ConvertToLocal3DPoint(lmd),aStep);
240  float theThetaAtEntry = lnmd.theta();
241  float thePhiAtEntry = lnmd.phi();
242 
243  storeVolumeAndTrack( aStep );
244  theDetUnitId = setDetUnitId(aStep);
245 
246  Global3DPoint theGlobalPos;
247  if (printHits) {
248  Local3DPoint theGlobalHelp = InitialStepPosition(aStep,WorldCoordinates);
249  theGlobalEntry = toOrcaUnits(Global3DPoint (theGlobalHelp.x(),theGlobalHelp.y(),theGlobalHelp.z()));
250 
251  G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
252  const G4TouchableHistory * theTouchable=(const G4TouchableHistory *)
253  (preStepPoint->GetTouchable());
254  theGlobalHelp=ConvertToLocal3DPoint(theTouchable->GetTranslation());
255  theGlobalPos = toOrcaUnits(Global3DPoint (theGlobalHelp.x(),theGlobalHelp.y(),theGlobalHelp.z()));
256  // const G4RotationMatrix * theGlobalRot = theTouchable->GetRotation();
257  }
258 
259  LogDebug("MuonSimDebug") << "MuonSensitiveDetector::createHit UpdatablePSimHit"<<std::endl;
260 
261  theHit = new UpdatablePSimHit(theEntryPoint,theExitPoint,thePabs,theTof,
262  theEnergyLoss,theParticleType,theDetUnitId,
263  theTrackID,theThetaAtEntry,thePhiAtEntry,
264  theG4ProcessTypeEnumerator->processId(theTrack->GetCreatorProcess()));
265 
266 
267  LogDebug("MuonSimDebug") <<"=== NEW ==================> ELOSS = "<<theEnergyLoss<<" "
268  <<thePV->GetLogicalVolume()->GetName()<<std::endl;
269  const G4VProcess* p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
270  const G4VProcess* p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
271  if (p)
272  LogDebug("MuonSimDebug") <<" POST PROCESS = "<<p->GetProcessName()<<std::endl;
273  if (p2)
274  LogDebug("MuonSimDebug") <<" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
275  LogDebug("MuonSimDebug") << "newhit theta " << theThetaAtEntry<<std::endl;
276  LogDebug("MuonSimDebug") << "newhit phi " << thePhiAtEntry<<std::endl;
277  LogDebug("MuonSimDebug") << "newhit pabs " << thePabs<<std::endl;
278  LogDebug("MuonSimDebug") << "newhit tof " << theTof<<std::endl;
279  LogDebug("MuonSimDebug") << "newhit track " << theTrackID<<std::endl;
280  LogDebug("MuonSimDebug") << "newhit entry " << theEntryPoint<<std::endl;
281  LogDebug("MuonSimDebug") << "newhit exit " << theExitPoint<<std::endl;
282  LogDebug("MuonSimDebug") << "newhit eloss " << theEnergyLoss << std::endl;
283  LogDebug("MuonSimDebug") << "newhit detid " << theDetUnitId<<std::endl;
284  LogDebug("MuonSimDebug") << "newhit delta " << (theExitPoint-theEntryPoint)<<std::endl;
285  LogDebug("MuonSimDebug") << "newhit deltu " << (theExitPoint-theEntryPoint).unit();
286  LogDebug("MuonSimDebug") << " " << (theExitPoint-theEntryPoint).mag()<<std::endl;
287  LogDebug("MuonSimDebug") << "newhit glob " << theGlobalEntry<<std::endl;
288  LogDebug("MuonSimDebug") << "newhit dpos " << theGlobalPos<<std::endl;
289  LogDebug("MuonSimDebug") << "newhit drot " << std::endl;
290  // theGlobalRot->print(LogDebug("MuonSimDebug"));
291 
292 
293  //
294  //----- SimTracks: Make it persistent?
295  //
296  int thePID = theTrack->GetDefinition()->GetPDGEncoding();
297  LogDebug("MuonSimDebug") << " checking simtrack " << thePID << " " << thePabs << " STenergyPersistentCut " << STenergyPersistentCut << std::endl;
298 
299  if( thePabs*GeV > STenergyPersistentCut
300  || ( abs(thePID) == 13 && STallMuonsPersistent ) ){
302  LogDebug("MuonSimDebug") <<" track leaving hit in muons made selected for persistency"<<std::endl;
303 
304  info->storeTrack(true);
305  }
306 
307 }
#define LogDebug(id)
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
static const TGPicture * info(bool iBackgroundIsBlack)
const double GeV
Definition: MathUtil.h:16
bool storeTrack() const
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
void storeVolumeAndTrack(const G4Step *)
MuonSubDetector * detector
Local3DPoint toOrcaUnits(const Local3DPoint &)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
unsigned int processId(const G4VProcess *p) const
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double p2[4]
Definition: TauolaWrapper.h:90
static int particleID(const G4Track *)
uint32_t setDetUnitId(const G4Step *) override
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
G4TrackToParticleID * myG4TrackToParticleID
G4VPhysicalVolume * thePV
Local3DPoint InitialStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
T x() const
Definition: PV3DBase.h:62
TrackInformation * getOrCreateTrackInformation(const G4Track *theTrack)
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *)
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const
void MuonSensitiveDetector::EndOfEvent ( G4HCofThisEvent *  )
override

Definition at line 391 of file MuonSensitiveDetector.cc.

References saveHit().

392 {
393 // TimeMe t("MuonSensitiveDetector::EndOfEvent", false);
394  // LogDebug("MuonSimDebug") << "MuonSensitiveDetector::EndOfEvent saving last hit en event " << std::endl;
395  saveHit();
396 }
void MuonSensitiveDetector::fillHits ( edm::PSimHitContainer cc,
const std::string &  hname 
)
overridevirtual

Implements SensitiveTkDetector.

Definition at line 399 of file MuonSensitiveDetector.cc.

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

399  {
400  if (slaveMuon->name() == hname) { cc=slaveMuon->hits(); }
401 }
std::string name() const
std::vector< PSimHit > & hits()
Local3DPoint MuonSensitiveDetector::FinalStepPositionVsParent ( G4Step *  currentStep,
G4int  levelsUp 
)
private

Definition at line 418 of file MuonSensitiveDetector.cc.

References SensitiveDetector::ConvertToLocal3DPoint(), and egammaForCoreTracking_cff::depth.

Referenced by createHit(), and updateHit().

418  {
419 
420  G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
421  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
422  const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
423 
424  const G4TouchableHistory * theTouchable = (const G4TouchableHistory *)
425  (preStepPoint->GetTouchable());
426 
427  G4int depth = theTouchable->GetHistory()->GetDepth();
428  G4ThreeVector localCoordinates = theTouchable->GetHistory()
429  ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
430 
431  return ConvertToLocal3DPoint(localCoordinates);
432 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
TrackInformation * MuonSensitiveDetector::getOrCreateTrackInformation ( const G4Track *  theTrack)
private

Definition at line 375 of file MuonSensitiveDetector.cc.

References MessageLogger_cfi::cerr, info(), and groupFilesInBlocks::temp.

Referenced by createHit(), and GetSlaveMuon().

376 {
377  G4VUserTrackInformation* temp = gTrack->GetUserInformation();
378  if (temp == nullptr){
379  std::cerr <<" ERROR: no G4VUserTrackInformation available"<<std::endl;
380  abort();
381  }else{
382  TrackInformation* info = dynamic_cast<TrackInformation*>(temp);
383  if (info ==nullptr){
384  std::cerr <<" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
385  abort();
386  }
387  return info;
388  }
389 }
static const TGPicture * info(bool iBackgroundIsBlack)
const MuonSlaveSD* MuonSensitiveDetector::GetSlaveMuon ( ) const
inline

Definition at line 65 of file MuonSensitiveDetector.h.

References getOrCreateTrackInformation(), recoMuon::in, slaveMuon, toOrcaRef(), toOrcaUnits(), and update().

65  {
66  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 403 of file MuonSensitiveDetector.cc.

References SensitiveDetector::ConvertToLocal3DPoint(), and egammaForCoreTracking_cff::depth.

Referenced by createHit().

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

Definition at line 191 of file MuonSensitiveDetector.cc.

References LogDebug, MetAnalyzer::pv(), setDetUnitId(), lumiQTWidget::t, theDetUnitId, thePV, and theTrackID.

Referenced by ProcessHits().

191  {
192 
193  G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
194  G4Track * t = aStep->GetTrack();
195  uint32_t currentUnitId=setDetUnitId(aStep);
196  LogDebug("MuonSimDebug") <<"MuonSensitiveDetector::newHit :: currentUnitId = "<<currentUnitId;
197  unsigned int currentTrackID=t->GetTrackID();
198  //unsigned int currentEventID=G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID();
199  bool changed=((pv!=thePV) ||
200  (currentUnitId!=theDetUnitId) ||
201  (currentTrackID!=theTrackID));
202  return changed;
203 }
#define LogDebug(id)
def pv(vc)
Definition: MetAnalyzer.py:6
uint32_t setDetUnitId(const G4Step *) override
G4VPhysicalVolume * thePV
bool MuonSensitiveDetector::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
overridevirtual

Implements SensitiveDetector.

Definition at line 123 of file MuonSensitiveDetector.cc.

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

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

Definition at line 354 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().

354  {
355 
356  if (theHit) {
357  if (printHits) {
360  // thePrinter->printTrack(theHit->trackId());
361  //thePrinter->printPabs(theHit->pabs());
362  //thePrinter->printEloss(theHit->energyLoss());
365  }
367  // seems the hit does not want to be deleted
368  // done by the hit collection?
369  delete theHit;
370  theHit = nullptr; //set it to 0, because you are checking that is 0
371  }
372 
373 }
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
uint32_t MuonSensitiveDetector::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements SensitiveDetector.

Definition at line 148 of file MuonSensitiveDetector.cc.

References MuonSimHitNumberingScheme::baseNumberToUnitNumber(), g4numbering, MuonBaseNumber::getBaseNo(), MuonBaseNumber::getLevels(), MuonBaseNumber::getSuperNo(), hcalDigis_cfi::level, LogDebug, pileupDistInMC::num, numbering, MuonG4Numbering::PhysicalVolumeToBaseNumber(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createHit(), and newHit().

149 {
150  // G4VPhysicalVolume * pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
152 
153  std::stringstream MuonBaseNumber;
154  // LogDebug :: Print MuonBaseNumber
155  MuonBaseNumber << "MuonNumbering :: number of levels = "<<num.getLevels()<<std::endl;
156  MuonBaseNumber << "Level \t SuperNo \t BaseNo"<<std::endl;
157  for (int level=1;level<=num.getLevels();level++) {
158  MuonBaseNumber << level << " \t " << num.getSuperNo(level)
159  << " \t " << num.getBaseNo(level) << std::endl;
160  }
161  std::string MuonBaseNumbr = MuonBaseNumber.str();
162 
163  LogDebug("MuonSimDebug") <<"MuonSensitiveDetector::setDetUnitId :: "<<MuonBaseNumbr;
164  LogDebug("MuonSimDebug") <<"MuonSensitiveDetector::setDetUnitId :: MuonDetUnitId = "<<(numbering->baseNumberToUnitNumber(num));
165  return numbering->baseNumberToUnitNumber(num);
166 }
#define LogDebug(id)
int getBaseNo(int level) const
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
MuonSimHitNumberingScheme * numbering
int getLevels() const
int getSuperNo(int level) const
int baseNumberToUnitNumber(const MuonBaseNumber &) override
MuonG4Numbering * g4numbering
void MuonSensitiveDetector::storeVolumeAndTrack ( const G4Step *  aStep)
private

Definition at line 184 of file MuonSensitiveDetector.cc.

References MetAnalyzer::pv(), lumiQTWidget::t, thePV, and theTrackID.

Referenced by createHit(), and ProcessHits().

184  {
185  G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
186  G4Track * t = aStep->GetTrack();
187  thePV=pv;
188  theTrackID=t->GetTrackID();
189 }
def pv(vc)
Definition: MetAnalyzer.py:6
G4VPhysicalVolume * thePV
Local3DPoint MuonSensitiveDetector::toOrcaRef ( Local3DPoint  in,
G4Step *  step 
)
private

Definition at line 169 of file MuonSensitiveDetector.cc.

References theRotation, and MuonFrameRotation::transformPoint().

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

169  {
170  if (theRotation !=nullptr ) {
171  return theRotation->transformPoint(in,step);
172  }
173  return (in);
174 }
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const =0
MuonFrameRotation * theRotation
step
Local3DPoint MuonSensitiveDetector::toOrcaUnits ( const Local3DPoint in)
private

Definition at line 176 of file MuonSensitiveDetector.cc.

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

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

176  {
177  return Local3DPoint(in.x()/cm,in.y()/cm,in.z()/cm);
178 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
T x() const
Definition: PV3DBase.h:62
Global3DPoint MuonSensitiveDetector::toOrcaUnits ( const Global3DPoint in)
private

Definition at line 180 of file MuonSensitiveDetector.cc.

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

180  {
181  return Global3DPoint(in.x()/cm,in.y()/cm,in.z()/cm);
182 }
T y() const
Definition: PV3DBase.h:63
Point3DBase< float, GlobalTag > Global3DPoint
Definition: GlobalPoint.h:7
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
std::string MuonSensitiveDetector::type ( )
void MuonSensitiveDetector::update ( const BeginOfEvent )
overrideprivatevirtual

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 progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), GetSlaveMuon(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

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

Definition at line 113 of file MuonSensitiveDetector.cc.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

114 {}
void MuonSensitiveDetector::updateHit ( G4Step *  aStep)
private

Definition at line 309 of file MuonSensitiveDetector.cc.

References UpdatablePSimHit::addEnergyLoss(), MessageLogger_cfi::cerr, detector, PSimHit::energyLoss(), PSimHit::entryPoint(), SensitiveDetector::FinalStepPosition(), FinalStepPositionVsParent(), GeV, MuonSubDetector::isBarrel(), MuonSubDetector::isEndcap(), SensitiveDetector::LocalCoordinates, LogDebug, mag(), AlCaHLTBitMon_ParallelJobs::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().

309  {
310  // float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
311  // Local3DPoint theEntryPoint= InitialStepPosition(aStep,LocalCoordinates);
312 
313 
314  Local3DPoint theExitPoint;
315 
316  if (detector->isBarrel()) {
317  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,1),aStep));
318  } else if (detector->isEndcap()) {
319  // save local z at current level
320  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
321  float zexit = theExitPoint.z();
322  Local3DPoint tempExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,4),aStep));
323  theExitPoint = Local3DPoint( tempExitPoint.x(), tempExitPoint.y(), zexit );
324  } else {
325  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
326  }
327 
328  float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
329 
330  if( theHit == nullptr ){
331  std::cerr << "!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
332  }
333 
334  theHit->updateExitPoint(theExitPoint);
335  theHit->addEnergyLoss(theEnergyLoss);
336 
337  LogDebug("MuonSimDebug") <<"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<" "
338  <<thePV->GetLogicalVolume()->GetName()<<std::endl;
339  const G4VProcess* p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
340  const G4VProcess* p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
341  if (p)
342  LogDebug("MuonSimDebug") <<" POST PROCESS = "<<p->GetProcessName()<<std::endl;
343  if (p2)
344  LogDebug("MuonSimDebug") <<" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
345  LogDebug("MuonSimDebug") << "updhit exit " << theExitPoint<<std::endl;
346  LogDebug("MuonSimDebug") << "updhit eloss " << theHit->energyLoss() <<std::endl;
347  LogDebug("MuonSimDebug") << "updhit detid " << theDetUnitId<<std::endl;
348  LogDebug("MuonSimDebug") << "updhit delta " << (theExitPoint-theHit->entryPoint())<<std::endl;
349  LogDebug("MuonSimDebug") << "updhit deltu " << (theExitPoint-theHit->entryPoint()).unit();
350  LogDebug("MuonSimDebug") << " " << (theExitPoint-theHit->entryPoint()).mag()<<std::endl;
351 
352 }
#define LogDebug(id)
Local3DPoint FinalStepPositionVsParent(G4Step *currentStep, G4int levelsUp)
const double GeV
Definition: MathUtil.h:16
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T y() const
Definition: PV3DBase.h:63
MuonSubDetector * detector
Local3DPoint toOrcaUnits(const Local3DPoint &)
void updateExitPoint(const Local3DPoint &exit)
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
void addEnergyLoss(float eloss)
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
G4VPhysicalVolume * thePV
T x() const
Definition: PV3DBase.h:62
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35
Local3DPoint toOrcaRef(Local3DPoint in, G4Step *)

Member Data Documentation

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

Definition at line 110 of file MuonSensitiveDetector.h.

Referenced by createHit(), and MuonSensitiveDetector().

double MuonSensitiveDetector::STenergyPersistentCut
private

Definition at line 109 of file MuonSensitiveDetector.h.

Referenced by createHit(), and MuonSensitiveDetector().

uint32_t MuonSensitiveDetector::theDetUnitId
private

Definition at line 101 of file MuonSensitiveDetector.h.

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

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

Definition at line 106 of file MuonSensitiveDetector.h.

Referenced by createHit(), and saveHit().

UpdatablePSimHit* MuonSensitiveDetector::theHit
private

Definition at line 100 of file MuonSensitiveDetector.h.

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

const SimTrackManager* MuonSensitiveDetector::theManager
private

Definition at line 115 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector().

SimHitPrinter* MuonSensitiveDetector::thePrinter
private

Definition at line 105 of file MuonSensitiveDetector.h.

Referenced by MuonSensitiveDetector(), and saveHit().

G4VPhysicalVolume* MuonSensitiveDetector::thePV
private

Definition at line 99 of file MuonSensitiveDetector.h.

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

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

Definition at line 102 of file MuonSensitiveDetector.h.

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