Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-20 03:14:13

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   // general method to determine classification of hit based on its properties
0069   virtual void setHitClassID(const G4Step*);
0070 
0071 private:
0072   void getStepInfo(const G4Step*);
0073   bool hitExists(const G4Step*);
0074   void createNewHit(const G4Step*);
0075   void updateHit();
0076   void storeHit(BscG4Hit*);
0077 
0078   TrackingSlaveSD* slave;
0079   G4ProcessTypeEnumerator* theEnumerator;
0080 
0081   const SimTrackManager* theManager;
0082   BscG4HitCollection* theHC;
0083 
0084   BscG4Hit* currentHit;
0085   const G4Track* theTrack;
0086   const G4StepPoint* preStepPoint;
0087   const G4StepPoint* postStepPoint;
0088 
0089   uint32_t unitID, previousUnitID;
0090 
0091   int primID;
0092   int hcID;
0093   int tsID;
0094   int primaryID;
0095   int tSliceID;
0096 
0097   G4ThreeVector hitPoint;
0098   G4ThreeVector hitPointExit;
0099   G4ThreeVector hitPointLocal;
0100   G4ThreeVector hitPointLocalExit;
0101 
0102   double tSlice;
0103   double timeFactor;
0104 
0105   double energyCut;         // MeV
0106   double energyHistoryCut;  // MeV
0107 
0108   double incidentEnergy;  // MeV
0109   float tof;              // ns
0110   float edeposit;
0111   float edepositEM, edepositHAD;
0112 
0113 protected:
0114   unsigned int hitClassID;
0115 };
0116 
0117 #endif