Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:59

0001 #ifndef Forward_TimingSD_h
0002 #define Forward_TimingSD_h
0003 //
0004 // Base sensitive class for timing detectors and sensors
0005 //
0006 // Created 17 June 2018 V.Ivantchenko
0007 //
0008 
0009 #include "SimG4Core/Notification/interface/Observer.h"
0010 #include "SimG4Core/SensitiveDetector/interface/SensitiveTkDetector.h"
0011 
0012 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
0013 
0014 #include "SimG4CMS/Forward/interface/BscG4Hit.h"
0015 #include "SimG4CMS/Forward/interface/BscG4HitCollection.h"
0016 
0017 #include <string>
0018 
0019 class G4Step;
0020 class G4StepPoint;
0021 class G4Track;
0022 class G4VPhysicalVolume;
0023 class TrackingSlaveSD;
0024 class SimTrackManager;
0025 class G4ProcessTypeEnumerator;
0026 
0027 //-------------------------------------------------------------------
0028 
0029 class TimingSD : public SensitiveTkDetector, public Observer<const BeginOfEvent*> {
0030 public:
0031   TimingSD(const std::string&, const SensitiveDetectorCatalog&, const SimTrackManager*);
0032 
0033   ~TimingSD() override;
0034 
0035   bool ProcessHits(G4Step*, G4TouchableHistory*) override;
0036 
0037   void Initialize(G4HCofThisEvent* HCE) override;
0038   void EndOfEvent(G4HCofThisEvent* eventHC) override;
0039   void PrintAll() override;
0040 
0041   void fillHits(edm::PSimHitContainer&, const std::string&) override;
0042   void clearHits() override;
0043 
0044 protected:
0045   void update(const BeginOfEvent*) override;
0046 
0047   // define time slices
0048   void setTimeFactor(double);
0049 
0050   // define MC truth thresholds
0051   void setCuts(double eCut, double historyCut);
0052 
0053   // by default accumulate hit for the same detector
0054   // and time slice, use primary information for fastest
0055   // Geant4 particle, check if for this detector new
0056   // hit can be merged with the existing one
0057   virtual bool checkHit(const G4Step*, BscG4Hit*);
0058 
0059   void setToLocal(const G4StepPoint* stepPoint, const G4ThreeVector& globalPoint, G4ThreeVector& localPoint);
0060 
0061   // accessors
0062   const G4ThreeVector& getLocalEntryPoint() const { return hitPointLocal; };
0063   const G4ThreeVector& getGlobalEntryPoint() const { return hitPoint; };
0064 
0065   // general method to assign track ID to be stored in hits
0066   virtual int getTrackID(const G4Track*);
0067 
0068 private:
0069   void getStepInfo(const G4Step*);
0070   bool hitExists(const G4Step*);
0071   void createNewHit(const G4Step*);
0072   void updateHit();
0073   void storeHit(BscG4Hit*);
0074 
0075   TrackingSlaveSD* slave;
0076   G4ProcessTypeEnumerator* theEnumerator;
0077 
0078   const SimTrackManager* theManager;
0079   BscG4HitCollection* theHC;
0080 
0081   BscG4Hit* currentHit;
0082   const G4Track* theTrack;
0083   const G4StepPoint* preStepPoint;
0084   const G4StepPoint* postStepPoint;
0085 
0086   uint32_t unitID, previousUnitID;
0087 
0088   int primID;
0089   int hcID;
0090   int tsID;
0091   int primaryID;
0092   int tSliceID;
0093 
0094   G4ThreeVector hitPoint;
0095   G4ThreeVector hitPointExit;
0096   G4ThreeVector hitPointLocal;
0097   G4ThreeVector hitPointLocalExit;
0098 
0099   double tSlice;
0100   double timeFactor;
0101 
0102   double energyCut;         // MeV
0103   double energyHistoryCut;  // MeV
0104 
0105   double incidentEnergy;  // MeV
0106   float tof;              // ns
0107   float edeposit;
0108   float edepositEM, edepositHAD;
0109 };
0110 
0111 #endif