Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-13 01:44:06

0001 #ifndef SimG4CMS_Muon_MuonSensitiveDetector_h
0002 #define SimG4CMS_Muon_MuonSensitiveDetector_h
0003 
0004 /** \class MuonSensitiveDetector
0005  *
0006  * implementation of SensitiveDetector for the muon detector;
0007  * a MuonSlaveSD handles the interfacing to the database;
0008  * numbering scheme are booked according
0009  * to the detector name
0010  * 
0011  * \author Arno Straessner, CERN <arno.straessner@cern.ch>
0012  *
0013  * Modification:
0014  * 19/05/03. P.Arce
0015  * Add SimTracks selection
0016  */
0017 
0018 #include "SimG4Core/Notification/interface/Observer.h"
0019 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
0020 #include "SimG4Core/SensitiveDetector/interface/SensitiveTkDetector.h"
0021 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0022 #include "CondFormats/GeometryObjects/interface/MuonOffsetMap.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0025 
0026 #include <string>
0027 
0028 class MuonSlaveSD;
0029 class MuonSimHitNumberingScheme;
0030 class MuonFrameRotation;
0031 class UpdatablePSimHit;
0032 class MuonSubDetector;
0033 class MuonG4Numbering;
0034 class SimHitPrinter;
0035 class G4Step;
0036 class G4ProcessTypeEnumerator;
0037 class SimTrackManager;
0038 
0039 class MuonSensitiveDetector : public SensitiveTkDetector, public Observer<const BeginOfEvent*> {
0040 public:
0041   explicit MuonSensitiveDetector(const std::string&,
0042                                  const MuonOffsetMap*,
0043                                  const MuonGeometryConstants&,
0044                                  const SensitiveDetectorCatalog&,
0045                                  edm::ParameterSet const& p,
0046                                  const SimTrackManager*);
0047   ~MuonSensitiveDetector() override;
0048   G4bool ProcessHits(G4Step*, G4TouchableHistory*) override;
0049   uint32_t setDetUnitId(const G4Step*) override;
0050   void EndOfEvent(G4HCofThisEvent*) override;
0051 
0052   void fillHits(edm::PSimHitContainer&, const std::string&) override;
0053   void clearHits() override;
0054 
0055   const MuonSlaveSD* GetSlaveMuon() const { return slaveMuon; }
0056 
0057 protected:
0058   void update(const BeginOfEvent*) override;
0059 
0060 private:
0061   inline Local3DPoint cmsUnits(const Local3DPoint& v) { return Local3DPoint(v.x() * 0.1, v.y() * 0.1, v.z() * 0.1); }
0062   bool acceptHit(uint32_t id);
0063 
0064   MuonSlaveSD* slaveMuon;
0065   MuonSimHitNumberingScheme* numbering;
0066   MuonSubDetector* detector;
0067   const MuonFrameRotation* theRotation;
0068   MuonG4Numbering* g4numbering;
0069 
0070   bool newHit(const G4Step*);
0071   void createHit(const G4Step*);
0072   void updateHit(const G4Step*);
0073   void saveHit();
0074 
0075   /**
0076    * Transform from local coordinates of a volume to local coordinates of a parent volume
0077    * one or more levels up the volume hierarchy: e.g. levelsUp = 1 for immediate parent.
0078    * This is done by moving from local_1 -> global -> local_2.
0079    */
0080   Local3DPoint InitialStepPositionVsParent(const G4Step* currentStep, G4int levelsUp);
0081   Local3DPoint FinalStepPositionVsParent(const G4Step* currentStep, G4int levelsUp);
0082 
0083   const G4VPhysicalVolume* thePV;
0084   UpdatablePSimHit* theHit;
0085   uint32_t theDetUnitId;
0086   uint32_t newDetUnitId;
0087   int theTrackID;
0088 
0089   bool printHits_;
0090   SimHitPrinter* thePrinter;
0091 
0092   //--- SimTracks cuts
0093   float ePersistentCutGeV_;
0094   bool allMuonsPersistent_;
0095 
0096   // For choice of demo chambers
0097   bool haveDemo_;
0098   bool demoGEM_;
0099   bool demoRPC_;
0100 
0101   G4ProcessTypeEnumerator* theG4ProcessTypeEnumerator;
0102 
0103   const SimTrackManager* theManager;
0104 };
0105 
0106 #endif  // MuonSensitiveDetector_h