Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 private:
0066   void getStepInfo(const G4Step*);
0067   bool hitExists(const G4Step*);
0068   void createNewHit(const G4Step*);
0069   void updateHit();
0070   void storeHit(BscG4Hit*);
0071 
0072   TrackingSlaveSD* slave;
0073   G4ProcessTypeEnumerator* theEnumerator;
0074 
0075   const SimTrackManager* theManager;
0076   BscG4HitCollection* theHC;
0077 
0078   BscG4Hit* currentHit;
0079   const G4Track* theTrack;
0080   const G4StepPoint* preStepPoint;
0081   const G4StepPoint* postStepPoint;
0082 
0083   uint32_t unitID, previousUnitID;
0084 
0085   int primID;
0086   int hcID;
0087   int tsID;
0088   int primaryID;
0089   int tSliceID;
0090 
0091   G4ThreeVector hitPoint;
0092   G4ThreeVector hitPointExit;
0093   G4ThreeVector hitPointLocal;
0094   G4ThreeVector hitPointLocalExit;
0095 
0096   double tSlice;
0097   double timeFactor;
0098 
0099   double energyCut;         // MeV
0100   double energyHistoryCut;  // MeV
0101 
0102   double incidentEnergy;  // MeV
0103   float tof;              // ns
0104   float edeposit;
0105   float edepositEM, edepositHAD;
0106 };
0107 
0108 #endif