Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:24:22

0001 #ifndef SimG4CMS_DreamSD_h
0002 #define SimG4CMS_DreamSD_h
0003 
0004 #include "SimG4CMS/Calo/interface/CaloSD.h"
0005 #include "DetectorDescription/Core/interface/DDCompactView.h"
0006 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0007 
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0011 
0012 #include "G4PhysicsFreeVector.hh"
0013 
0014 #include <DD4hep/DD4hepUnits.h>
0015 
0016 #include <map>
0017 
0018 const int MAXPHOTONS = 500;  // Maximum number of photons we can store
0019 
0020 class G4LogicalVolume;
0021 
0022 class DreamSD : public CaloSD {
0023 public:
0024   DreamSD(const std::string &,
0025           const DDCompactView *,
0026           const cms::DDCompactView *,
0027           const SensitiveDetectorCatalog &,
0028           edm::ParameterSet const &,
0029           const SimTrackManager *);
0030   ~DreamSD() override {}
0031 
0032   uint32_t setDetUnitId(const G4Step *) override;
0033 
0034 protected:
0035   double getEnergyDeposit(const G4Step *) override;
0036   void initRun() override;
0037 
0038 private:
0039   typedef std::pair<double, double> Doubles;
0040   typedef std::map<G4LogicalVolume *, Doubles> DimensionMap;
0041 
0042   void initMap(const std::string &);
0043   void fillMap(const std::string &, double, double);
0044   double curve_LY(const G4Step *, int);
0045   double crystalLength(G4LogicalVolume *) const;
0046   double crystalWidth(G4LogicalVolume *) const;
0047 
0048   /// Returns the total energy due to Cherenkov radiation
0049   double cherenkovDeposit_(const G4Step *aStep);
0050   /// Returns average number of photons created by track
0051   double getAverageNumberOfPhotons_(const double charge,
0052                                     const double beta,
0053                                     const G4Material *aMaterial,
0054                                     const G4MaterialPropertyVector *rIndex);
0055   /// Returns energy deposit for a given photon
0056   double getPhotonEnergyDeposit_(const G4ParticleMomentum &p, const G4ThreeVector &x, const G4Step *aStep);
0057   /// Sets material properties at run-time...
0058   bool setPbWO2MaterialProperties_(G4Material *aMaterial);
0059 
0060   static constexpr double k_ScaleFromDDDToG4 = 1.0;
0061   static constexpr double k_ScaleFromDD4hepToG4 = 1.0 / dd4hep::mm;
0062 
0063   const DDCompactView *cpvDDD_;
0064   const cms::DDCompactView *cpvDD4hep_;
0065 
0066   bool useBirk_, doCherenkov_, readBothSide_, dd4hep_;
0067   double birk1_, birk2_, birk3_;
0068   double slopeLY_;
0069   DimensionMap xtalLMap_;  // Store length and width
0070 
0071   int side_;
0072 
0073   /// Table of Cherenkov angle integrals vs photon momentum
0074   std::unique_ptr<G4PhysicsFreeVector> chAngleIntegrals_;
0075   G4MaterialPropertiesTable *materialPropertiesTable_;
0076 
0077   int nphotons_;
0078 };
0079 
0080 #endif  // DreamSD_h