Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "SimG4CMS/Forward/interface/TotemT2ScintSD.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "SimG4Core/Notification/interface/TrackInformation.h"
0005 
0006 #include "G4SDManager.hh"
0007 #include "G4Step.hh"
0008 #include "G4Track.hh"
0009 #include "G4VProcess.hh"
0010 #include "G4ios.hh"
0011 #include "G4Cerenkov.hh"
0012 #include "G4ParticleTable.hh"
0013 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0014 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0015 #include "Randomize.hh"
0016 #include "G4Poisson.hh"
0017 
0018 //#define EDM_ML_DEBUG
0019 
0020 TotemT2ScintSD::TotemT2ScintSD(const std::string& name,
0021                                const SensitiveDetectorCatalog& clg,
0022                                edm::ParameterSet const& p,
0023                                const SimTrackManager* manager)
0024     : CaloSD(name,
0025              clg,
0026              p,
0027              manager,
0028              (float)(p.getParameter<edm::ParameterSet>("TotemT2ScintSD").getParameter<double>("TimeSliceUnit")),
0029              p.getParameter<edm::ParameterSet>("TotemT2ScintSD").getParameter<bool>("IgnoreTrackID")) {
0030   edm::ParameterSet m_T2SD = p.getParameter<edm::ParameterSet>("TotemT2ScintSD");
0031   useBirk_ = m_T2SD.getParameter<bool>("UseBirkLaw");
0032   birk1_ = m_T2SD.getParameter<double>("BirkC1") * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
0033   birk2_ = m_T2SD.getParameter<double>("BirkC2");
0034   birk3_ = m_T2SD.getParameter<double>("BirkC3");
0035   setNumberingScheme(new TotemT2ScintNumberingScheme());
0036 
0037   edm::LogVerbatim("ForwardSim") << "***************************************************\n"
0038                                  << "*                                                 *\n"
0039                                  << "* Constructing a TotemT2ScintSD with name " << name << " *\n"
0040                                  << "*                                                 *\n"
0041                                  << "***************************************************";
0042 
0043   edm::LogVerbatim("ForwardSim") << "\nUse of Birks law is set to      " << useBirk_
0044                                  << "  with three constants kB = " << birk1_ << ", C1 = " << birk2_
0045                                  << ", C2 = " << birk3_;
0046 }
0047 
0048 uint32_t TotemT2ScintSD::setDetUnitId(const G4Step* aStep) {
0049   auto const prePoint = aStep->GetPreStepPoint();
0050   auto const touch = prePoint->GetTouchable();
0051 
0052   int iphi = (touch->GetReplicaNumber(0)) % 10;
0053   int lay = (touch->GetReplicaNumber(0) / 10) % 10 + 1;
0054   int zside = (((touch->GetReplicaNumber(1)) == 1) ? 1 : -1);
0055 
0056   return setDetUnitId(zside, lay, iphi);
0057 }
0058 
0059 void TotemT2ScintSD::setNumberingScheme(TotemT2ScintNumberingScheme* scheme) {
0060   if (scheme != nullptr) {
0061     edm::LogVerbatim("ForwardSim") << "TotemT2ScintSD: updates numbering scheme for " << GetName();
0062     numberingScheme.reset(scheme);
0063   }
0064 }
0065 
0066 double TotemT2ScintSD::getEnergyDeposit(const G4Step* aStep) {
0067   double destep = aStep->GetTotalEnergyDeposit();
0068   double weight = ((useBirk_) ? getAttenuation(aStep, birk1_, birk2_, birk3_) : 1.0);
0069   double edep = weight * destep;
0070 #ifdef EDM_ML_DEBUG
0071   edm::LogVerbatim("ForwardSim") << "TotemT2ScintSD: edep= " << destep << ":" << weight << ":" << edep;
0072 #endif
0073   return edep;
0074 }
0075 
0076 uint32_t TotemT2ScintSD::setDetUnitId(const int& zside, const int& lay, const int& iphi) {
0077   uint32_t id = ((numberingScheme.get()) ? numberingScheme->packID(zside, lay, iphi) : 0);
0078 #ifdef EDM_ML_DEBUG
0079   edm::LogVerbatim("ForwardSim") << "TotemT2ScintSD: zside " << zside << " layer " << lay << " phi " << iphi << " ID "
0080                                  << std::hex << id << std::dec;
0081 #endif
0082   return id;
0083 }