test
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 &, const 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, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (const std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (const 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, const 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 45 of file MuonSensitiveDetector.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file MuonSensitiveDetector.cc.

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

36  : SensitiveTkDetector(name, cpv, clg, p),
37  thePV(0), theHit(0), theDetUnitId(0), theTrackID(0), theManager(manager)
38 {
39  edm::ParameterSet m_MuonSD = p.getParameter<edm::ParameterSet>("MuonSD");
40  STenergyPersistentCut = m_MuonSD.getParameter<double>("EnergyThresholdForPersistency");//Default 1. GeV
41  STallMuonsPersistent = m_MuonSD.getParameter<bool>("AllMuonsPersistent");
42  printHits = m_MuonSD.getParameter<bool>("PrintHits");
43 
44  //
45  // Here simply create 1 MuonSlaveSD for the moment
46  //
47 
48  LogDebug("MuonSimDebug") << "create MuonSubDetector "<<name<<std::endl;
49 
51 
52  LogDebug("MuonSimDebug") << "create MuonFrameRotation"<<std::endl;
53 
54  if (detector->isEndcap()) {
55  // cout << "MuonFrameRotation create MuonEndcapFrameRotation"<<endl;
57  } else if (detector->isRPC()) {
58  // cout << "MuonFrameRotation create MuonRPCFrameRotation"<<endl;
60  } else if (detector->isGEM()) {
61  // cout << "MuonFrameRotation create MuonGEMFrameRotation"<<endl;
63  } else if (detector->isME0()) {
64  // cout << "MuonFrameRotation create MuonME0FrameRotation"<<endl;
66  } else {
67  theRotation = 0;
68  }
69  LogDebug("MuonSimDebug") << "create MuonSlaveSD"<<std::endl;
71  LogDebug("MuonSimDebug") << "create MuonSimHitNumberingScheme"<<std::endl;
73  g4numbering = new MuonG4Numbering(cpv);
74 
75 
76  //
77  // Now attach the right detectors (LogicalVolumes) to me
78  //
79  const std::vector<std::string>& lvNames = clg.logicalNames(name);
80  this->Register();
81  for (std::vector<std::string>::const_iterator it = lvNames.begin(); it != lvNames.end(); it++){
82  LogDebug("MuonSimDebug") << name << " MuonSensitiveDetector:: attaching SD to LV " << *it << std::endl;
83  this->AssignSD(*it);
84  }
85 
86  if (printHits) {
87  thePrinter = new SimHitPrinter("HitPositionOSCAR.dat");
88  }
89 
90 
91  LogDebug("MuonSimDebug") << " EnergyThresholdForPersistency " << STenergyPersistentCut << " AllMuonsPersistent " << STallMuonsPersistent << std::endl;
92 
95 
96 }
#define LogDebug(id)
T getParameter(std::string const &) const
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
virtual void AssignSD(const std::string &vname)
MuonSubDetector * detector
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
const SimTrackManager * theManager
MuonFrameRotation * theRotation
MuonSimHitNumberingScheme * numbering
SensitiveTkDetector(std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
G4TrackToParticleID * myG4TrackToParticleID
G4VPhysicalVolume * thePV
MuonG4Numbering * g4numbering
MuonSensitiveDetector::~MuonSensitiveDetector ( )
virtual

Definition at line 99 of file MuonSensitiveDetector.cc.

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

99  {
100  delete g4numbering;
101  delete numbering;
102  delete slaveMuon;
103  delete theRotation;
104  delete detector;
105 
107 
108  delete myG4TrackToParticleID;
109 }
MuonSubDetector * detector
G4ProcessTypeEnumerator * theG4ProcessTypeEnumerator
MuonFrameRotation * theRotation
MuonSimHitNumberingScheme * numbering
G4TrackToParticleID * myG4TrackToParticleID
MuonG4Numbering * g4numbering

Member Function Documentation

void MuonSensitiveDetector::clearHits ( )
privatevirtual

Implements SensitiveDetector.

Definition at line 127 of file MuonSensitiveDetector.cc.

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

Referenced by update().

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

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

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

Reimplemented from SensitiveDetector.

Definition at line 401 of file MuonSensitiveDetector.cc.

References saveHit().

402 {
403 // TimeMe t("MuonSensitiveDetector::EndOfEvent", false);
404  // LogDebug("MuonSimDebug") << "MuonSensitiveDetector::EndOfEvent saving last hit en event " << std::endl;
405  saveHit();
406 }
void MuonSensitiveDetector::fillHits ( edm::PSimHitContainer c,
std::string  use 
)
virtual

Implements SensitiveTkDetector.

Definition at line 409 of file MuonSensitiveDetector.cc.

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

409  {
410  //
411  // do it once for low, once for High
412  //
413 
414  if (slaveMuon->name() == n) c=slaveMuon->hits();
415 
416 }
std::string name() const
std::vector< PSimHit > & hits()
Local3DPoint MuonSensitiveDetector::FinalStepPositionVsParent ( G4Step *  currentStep,
G4int  levelsUp 
)
private

Definition at line 439 of file MuonSensitiveDetector.cc.

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

Referenced by createHit(), and updateHit().

439  {
440 
441  G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
442  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
443  G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
444 
445  const G4TouchableHistory * theTouchable = (const G4TouchableHistory *)
446  (preStepPoint->GetTouchable());
447 
448  G4int depth = theTouchable->GetHistory()->GetDepth();
449  G4ThreeVector localCoordinates = theTouchable->GetHistory()
450  ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
451 
452  return ConvertToLocal3DPoint(localCoordinates);
453 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
std::vector< std::string > MuonSensitiveDetector::getNames ( )
virtual

Reimplemented from SensitiveDetector.

Definition at line 418 of file MuonSensitiveDetector.cc.

References TrackingSlaveSD::name(), slaveMuon, and groupFilesInBlocks::temp.

418  {
419  std::vector<std::string> temp;
420  temp.push_back(slaveMuon->name());
421  return temp;
422 }
std::string name() const
TrackInformation * MuonSensitiveDetector::getOrCreateTrackInformation ( const G4Track *  theTrack)
private

Definition at line 385 of file MuonSensitiveDetector.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, info(), and groupFilesInBlocks::temp.

Referenced by createHit().

386 {
387  G4VUserTrackInformation* temp = gTrack->GetUserInformation();
388  if (temp == 0){
389  std::cerr <<" ERROR: no G4VUserTrackInformation available"<<std::endl;
390  abort();
391  }else{
392  TrackInformation* info = dynamic_cast<TrackInformation*>(temp);
393  if (info ==0){
394  std::cerr <<" ERROR: TkSimTrackSelection: the UserInformation does not appear to be a TrackInformation"<<std::endl;
395  abort();
396  }
397  return info;
398  }
399 }
static const TGPicture * info(bool iBackgroundIsBlack)
const MuonSlaveSD* MuonSensitiveDetector::GetSlaveMuon ( ) const
inline

Definition at line 64 of file MuonSensitiveDetector.h.

References slaveMuon.

64  {
65  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 424 of file MuonSensitiveDetector.cc.

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

Referenced by createHit().

424  {
425 
426  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
427  G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
428 
429  const G4TouchableHistory * theTouchable=(const G4TouchableHistory *)
430  (preStepPoint->GetTouchable());
431 
432  G4int depth = theTouchable->GetHistory()->GetDepth();
433  G4ThreeVector localCoordinates = theTouchable->GetHistory()
434  ->GetTransform(depth-levelsUp).TransformPoint(globalCoordinates);
435 
436  return ConvertToLocal3DPoint(localCoordinates);
437 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
bool MuonSensitiveDetector::newHit ( G4Step *  aStep)
private

Definition at line 201 of file MuonSensitiveDetector.cc.

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

Referenced by ProcessHits().

201  {
202 
203  G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
204  G4Track * t = aStep->GetTrack();
205  uint32_t currentUnitId=setDetUnitId(aStep);
206  LogDebug("MuonSimDebug") <<"MuonSensitiveDetector::newHit :: currentUnitId = "<<currentUnitId;
207  unsigned int currentTrackID=t->GetTrackID();
208  //unsigned int currentEventID=G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID();
209  bool changed=((pv!=thePV) ||
210  (currentUnitId!=theDetUnitId) ||
211  (currentTrackID!=theTrackID));
212  return changed;
213 }
#define LogDebug(id)
G4VPhysicalVolume * thePV
virtual uint32_t setDetUnitId(G4Step *)
bool MuonSensitiveDetector::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
virtual

Implements SensitiveDetector.

Definition at line 133 of file MuonSensitiveDetector.cc.

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

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

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

364  {
365 
366  if (theHit) {
367  if (printHits) {
370  // thePrinter->printTrack(theHit->trackId());
371  //thePrinter->printPabs(theHit->pabs());
372  //thePrinter->printEloss(theHit->energyLoss());
375  }
377  // seems the hit does not want to be deleted
378  // done by the hit collection?
379  delete theHit;
380  theHit = 0; //set it to 0, because you are checking that is 0
381  }
382 
383 }
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 ( G4Step *  aStep)
virtual

Implements SensitiveDetector.

Definition at line 158 of file MuonSensitiveDetector.cc.

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

Referenced by createHit(), and newHit().

159 {
160  // G4VPhysicalVolume * pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
162 
163  std::stringstream MuonBaseNumber;
164  // LogDebug :: Print MuonBaseNumber
165  MuonBaseNumber << "MuonNumbering :: number of levels = "<<num.getLevels()<<std::endl;
166  MuonBaseNumber << "Level \t SuperNo \t BaseNo"<<std::endl;
167  for (int level=1;level<=num.getLevels();level++) {
168  MuonBaseNumber << level << " \t " << num.getSuperNo(level)
169  << " \t " << num.getBaseNo(level) << std::endl;
170  }
171  std::string MuonBaseNumbr = MuonBaseNumber.str();
172 
173  LogDebug("MuonSimDebug") <<"MuonSensitiveDetector::setDetUnitId :: "<<MuonBaseNumbr;
174  LogDebug("MuonSimDebug") <<"MuonSensitiveDetector::setDetUnitId :: MuonDetUnitId = "<<(numbering->baseNumberToUnitNumber(num));
175  return numbering->baseNumberToUnitNumber(num);
176 }
#define LogDebug(id)
int getBaseNo(int level) const
virtual int baseNumberToUnitNumber(const MuonBaseNumber &)
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
MuonSimHitNumberingScheme * numbering
int getLevels() const
int getSuperNo(int level) const
tuple level
Definition: testEve_cfg.py:34
MuonG4Numbering * g4numbering
void MuonSensitiveDetector::storeVolumeAndTrack ( G4Step *  aStep)
private

Definition at line 194 of file MuonSensitiveDetector.cc.

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

Referenced by createHit(), and ProcessHits().

194  {
195  G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
196  G4Track * t = aStep->GetTrack();
197  thePV=pv;
198  theTrackID=t->GetTrackID();
199 }
G4VPhysicalVolume * thePV
Local3DPoint MuonSensitiveDetector::toOrcaRef ( Local3DPoint  in,
G4Step *  s 
)
private

Definition at line 179 of file MuonSensitiveDetector.cc.

References theRotation, and MuonFrameRotation::transformPoint().

Referenced by createHit(), and updateHit().

179  {
180  if (theRotation !=0 ) {
181  return theRotation->transformPoint(in,s);
182  }
183  return (in);
184 }
virtual Local3DPoint transformPoint(const Local3DPoint &, const G4Step *) const =0
MuonFrameRotation * theRotation
Local3DPoint MuonSensitiveDetector::toOrcaUnits ( Local3DPoint  in)
private

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

186  {
187  return Local3DPoint(in.x()/cm,in.y()/cm,in.z()/cm);
188 }
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 ( Global3DPoint  in)
private

Definition at line 190 of file MuonSensitiveDetector.cc.

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

190  {
191  return Global3DPoint(in.x()/cm,in.y()/cm,in.z()/cm);
192 }
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 )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

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

111  {
112  clearHits();
113 
114  //----- Initialize variables to check if two steps belong to same hit
115  thePV = 0;
116  theDetUnitId = 0;
117  theTrackID = 0;
118 
119 }
G4VPhysicalVolume * thePV
void MuonSensitiveDetector::update ( const ::EndOfEvent ev)
private

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

122 {
123  //slaveMuon->renumbering(theManager);
124 }
void MuonSensitiveDetector::updateHit ( G4Step *  aStep)
private

Definition at line 319 of file MuonSensitiveDetector.cc.

References UpdatablePSimHit::addEnergyLoss(), ecal_dqm_sourceclient-live_cfg::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().

319  {
320  // float thePabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
321  // Local3DPoint theEntryPoint= InitialStepPosition(aStep,LocalCoordinates);
322 
323 
324  Local3DPoint theExitPoint;
325 
326  if (detector->isBarrel()) {
327  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,1),aStep));
328  } else if (detector->isEndcap()) {
329  // save local z at current level
330  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
331  float zexit = theExitPoint.z();
332  Local3DPoint tempExitPoint= toOrcaUnits(toOrcaRef(FinalStepPositionVsParent(aStep,4),aStep));
333  theExitPoint = Local3DPoint( tempExitPoint.x(), tempExitPoint.y(), zexit );
334  } else {
335  theExitPoint= toOrcaUnits(toOrcaRef(FinalStepPosition(aStep,LocalCoordinates),aStep));
336  }
337 
338  float theEnergyLoss = aStep->GetTotalEnergyDeposit()/GeV;
339 
340  if( theHit == 0 ){
341  std::cerr << "!!ERRROR in MuonSensitiveDetector::updateHit. It is called when there is no hit " << std::endl;
342  }
343 
344  theHit->updateExitPoint(theExitPoint);
345  theHit->addEnergyLoss(theEnergyLoss);
346 
347  LogDebug("MuonSimDebug") <<"=== UPDATE ===============> ELOSS = "<<theEnergyLoss<<" "
348  <<thePV->GetLogicalVolume()->GetName()<<std::endl;
349  const G4VProcess* p = aStep->GetPostStepPoint()->GetProcessDefinedStep();
350  const G4VProcess* p2 = aStep->GetPreStepPoint()->GetProcessDefinedStep();
351  if (p)
352  LogDebug("MuonSimDebug") <<" POST PROCESS = "<<p->GetProcessName()<<std::endl;
353  if (p2)
354  LogDebug("MuonSimDebug") <<" PRE PROCESS = "<<p2->GetProcessName()<<std::endl;
355  LogDebug("MuonSimDebug") << "updhit exit " << theExitPoint<<std::endl;
356  LogDebug("MuonSimDebug") << "updhit eloss " << theHit->energyLoss() <<std::endl;
357  LogDebug("MuonSimDebug") << "updhit detid " << theDetUnitId<<std::endl;
358  LogDebug("MuonSimDebug") << "updhit delta " << (theExitPoint-theHit->entryPoint())<<std::endl;
359  LogDebug("MuonSimDebug") << "updhit deltu " << (theExitPoint-theHit->entryPoint()).unit();
360  LogDebug("MuonSimDebug") << " " << (theExitPoint-theHit->entryPoint()).mag()<<std::endl;
361 
362 }
#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
void updateExitPoint(const Local3DPoint &exit)
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:64
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:62
Local3DPoint entryPoint() const
Entry point in the local Det frame.
Definition: PSimHit.h:35

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 104 of file MuonSensitiveDetector.h.

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

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