Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-12-19 04:05:18

0001 #ifndef SimG4Core_SteppingAction_H
0002 #define SimG4Core_SteppingAction_H
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "SimG4Core/Notification/interface/SimActivityRegistry.h"
0006 #include "SimG4Core/Application/interface/SteppingTrackStatus.h"
0007 
0008 #include "G4LogicalVolume.hh"
0009 #include "G4Region.hh"
0010 #include "G4UserSteppingAction.hh"
0011 #include "G4VPhysicalVolume.hh"
0012 #include "G4VTouchable.hh"
0013 #include "G4Track.hh"
0014 
0015 #include <string>
0016 #include <vector>
0017 
0018 class CMSSteppingVerbose;
0019 
0020 class SteppingAction : public G4UserSteppingAction {
0021 public:
0022   explicit SteppingAction(const CMSSteppingVerbose*, const edm::ParameterSet&, bool, bool);
0023   ~SteppingAction() override = default;
0024 
0025   void UserSteppingAction(const G4Step* aStep) final;
0026 
0027   SimActivityRegistry::G4StepSignal m_g4StepSignal;
0028 
0029 private:
0030   bool initPointer();
0031 
0032   inline bool isInsideDeadRegion(const G4Region* reg) const;
0033   inline bool isOutOfTimeWindow(const G4Region* reg, const double& time) const;
0034   inline bool isForZDC(const G4LogicalVolume* lv, int pdg) const;
0035 
0036   bool isLowEnergy(const G4LogicalVolume*, const G4Track*) const;
0037   void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
0038 
0039   const G4VPhysicalVolume* tracker{nullptr};
0040   const G4VPhysicalVolume* calo{nullptr};
0041   const CMSSteppingVerbose* steppingVerbose{nullptr};
0042   const G4LogicalVolume* m_CMStoZDC{nullptr};
0043   const G4Region* m_ZDCRegion{nullptr};
0044   double theCriticalEnergyForVacuum;
0045   double theCriticalDensity;
0046   double maxTrackTime;
0047   double maxTrackTimeForward;
0048   double maxZCentralCMS;
0049 
0050   unsigned int numberTimes;
0051   unsigned int numberEkins;
0052   unsigned int numberPart;
0053   unsigned int ndeadRegions;
0054   unsigned int nWarnings{0};
0055   G4int maxNumberOfSteps;
0056 
0057   bool initialized{false};
0058   bool killBeamPipe{false};
0059   bool m_CMStoZDCtransport;
0060   bool hasWatcher;
0061   bool dd4hep_;
0062 
0063   std::vector<double> maxTrackTimes, ekinMins;
0064   std::vector<std::string> maxTimeNames, ekinNames, ekinParticles;
0065   std::vector<std::string> deadRegionNames;
0066   std::vector<const G4Region*> maxTimeRegions;
0067   std::vector<const G4Region*> deadRegions;
0068   std::vector<G4LogicalVolume*> ekinVolumes;
0069   std::vector<int> ekinPDG;
0070   std::string trackerName_, caloName_, cms2ZDCName_;
0071 };
0072 
0073 inline bool SteppingAction::isInsideDeadRegion(const G4Region* reg) const {
0074   bool res = false;
0075   for (auto const& region : deadRegions) {
0076     if (reg == region) {
0077       res = true;
0078       break;
0079     }
0080   }
0081   return res;
0082 }
0083 
0084 inline bool SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double& time) const {
0085   double tofM = maxTrackTime;
0086   for (unsigned int i = 0; i < numberTimes; ++i) {
0087     if (reg == maxTimeRegions[i]) {
0088       tofM = maxTrackTimes[i];
0089       break;
0090     }
0091   }
0092   return (time > tofM);
0093 }
0094 
0095 inline bool SteppingAction::isForZDC(const G4LogicalVolume* lv, int pdg) const {
0096   return (m_CMStoZDCtransport && lv == m_CMStoZDC && (pdg == 22 || pdg == 2112));
0097 }
0098 
0099 #endif