Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-12 03:09:52

0001 #ifndef SimG4Core_SensitiveDetector_H
0002 #define SimG4Core_SensitiveDetector_H
0003 
0004 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0005 #include "SimG4Core/Geometry/interface/SensitiveDetectorCatalog.h"
0006 #include "SimG4Core/Notification/interface/TrackInformation.h"
0007 
0008 #include "G4VSensitiveDetector.hh"
0009 
0010 #include <string>
0011 #include <cstdint>
0012 
0013 class G4Track;
0014 class G4Step;
0015 class G4HCofThisEvent;
0016 class G4TouchableHistory;
0017 class G4VPhysicalVolume;
0018 
0019 class SensitiveDetector : public G4VSensitiveDetector {
0020 public:
0021   explicit SensitiveDetector(const std::string& iname, const SensitiveDetectorCatalog&, bool calo);
0022 
0023   ~SensitiveDetector() override;
0024 
0025   void Initialize(G4HCofThisEvent* eventHC) override;
0026   G4bool ProcessHits(G4Step* step, G4TouchableHistory* tHistory) override = 0;
0027   void EndOfEvent(G4HCofThisEvent* eventHC) override;
0028 
0029   virtual uint32_t setDetUnitId(const G4Step* step) = 0;
0030   virtual void clearHits() = 0;
0031 
0032   inline const std::vector<std::string>& getNames() const { return m_namesOfSD; }
0033 
0034   inline bool isCaloSD() const { return m_isCalo; }
0035 
0036 protected:
0037   // generic geometry methods, all coordinates in mm
0038   enum coordinates { WorldCoordinates, LocalCoordinates };
0039   Local3DPoint InitialStepPosition(const G4Step* step, coordinates) const;
0040   Local3DPoint FinalStepPosition(const G4Step* step, coordinates) const;
0041 
0042   // local coordinates to the volume, in which the step is done
0043   Local3DPoint LocalPreStepPosition(const G4Step* step) const;
0044   Local3DPoint LocalPostStepPosition(const G4Step* step) const;
0045 
0046   inline Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector& point) const {
0047     return Local3DPoint(point.x(), point.y(), point.z());
0048   }
0049 
0050   void setNames(const std::vector<std::string>&);
0051   void NaNTrap(const G4Step* step) const;
0052 
0053   TrackInformation* cmsTrackInformation(const G4Track* aTrack);
0054 
0055 private:
0056   void AssignSD(const std::string& vname);
0057 
0058   std::vector<std::string> m_namesOfSD;
0059   bool m_isCalo;
0060 };
0061 
0062 #endif