diff --git a/SimG4CMS/Forward/interface/ForwardName.h b/SimG4CMS/Forward/interface/ForwardName.h new file mode 100644 index 0000000000000..691c81fe9c657 --- /dev/null +++ b/SimG4CMS/Forward/interface/ForwardName.h @@ -0,0 +1,12 @@ +#ifndef SimG4CMSForward_ForwardName_h +#define SimG4CMSForward_ForwardName_h + +#include +#include +#include + +namespace ForwardName { + std::string getName(const G4String &); +}; // namespace ForwardName + +#endif diff --git a/SimG4CMS/Forward/src/BHMNumberingScheme.cc b/SimG4CMS/Forward/src/BHMNumberingScheme.cc index e2624348e8991..b3e842a43dad5 100644 --- a/SimG4CMS/Forward/src/BHMNumberingScheme.cc +++ b/SimG4CMS/Forward/src/BHMNumberingScheme.cc @@ -1,4 +1,5 @@ #include "SimG4CMS/Forward/interface/BHMNumberingScheme.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" #include "globals.hh" @@ -17,7 +18,7 @@ void BHMNumberingScheme::detectorLevel(const G4Step* aStep, int& level, int* cop const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); for (int ii = 0; ii < level; ++ii) { int i = level - ii - 1; - name[ii] = touch->GetVolume(i)->GetName(); + name[ii] = ForwardName::getName(touch->GetVolume(i)->GetName()); copyno[ii] = touch->GetReplicaNumber(i); } } diff --git a/SimG4CMS/Forward/src/Bcm1fSD.cc b/SimG4CMS/Forward/src/Bcm1fSD.cc index dec4c0fab0048..a32f724ada357 100644 --- a/SimG4CMS/Forward/src/Bcm1fSD.cc +++ b/SimG4CMS/Forward/src/Bcm1fSD.cc @@ -11,6 +11,7 @@ #include "SimDataFormats/SimHitMaker/interface/TrackingSlaveSD.h" #include "SimG4Core/Notification/interface/TrackInformation.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -52,16 +53,16 @@ uint32_t Bcm1fSD::setDetUnitId(const G4Step* aStep) { //Get name and copy numbers if (level > 1) { - G4String sensorName = touch->GetVolume(0)->GetName(); - G4String diamondName = touch->GetVolume(1)->GetName(); - G4String detectorName = touch->GetVolume(2)->GetName(); - G4String volumeName = touch->GetVolume(3)->GetName(); + std::string sensorName = ForwardName::getName(touch->GetVolume(0)->GetName()); + std::string diamondName = ForwardName::getName(touch->GetVolume(1)->GetName()); + std::string detectorName = ForwardName::getName(touch->GetVolume(2)->GetName()); + std::string volumeName = ForwardName::getName(touch->GetVolume(3)->GetName()); if (sensorName != "BCM1FSensor") { - edm::LogWarning("ForwardSim") << "Bcm1fSD::setDetUnitId -w- Sensor name not BCM1FSensor "; + edm::LogWarning("ForwardSim") << "Bcm1fSD::setDetUnitId -w- Sensor name " << sensorName << " not BCM1FSensor "; } if (detectorName != "BCM1F") { - edm::LogWarning("ForwardSim") << " Bcm1fSD::setDetUnitId -w- Detector name not BCM1F "; + edm::LogWarning("ForwardSim") << " Bcm1fSD::setDetUnitId -w- Detector name " << detectorName << " not BCM1F "; } int sensorNo = touch->GetReplicaNumber(0); int diamondNo = touch->GetReplicaNumber(1); diff --git a/SimG4CMS/Forward/src/BscNumberingScheme.cc b/SimG4CMS/Forward/src/BscNumberingScheme.cc index 4b377956bb04e..837638ca2b522 100644 --- a/SimG4CMS/Forward/src/BscNumberingScheme.cc +++ b/SimG4CMS/Forward/src/BscNumberingScheme.cc @@ -5,10 +5,11 @@ // Modifications: /////////////////////////////////////////////////////////////////////////////// #include "SimG4CMS/Forward/interface/BscNumberingScheme.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" // #include "CLHEP/Units/GlobalSystemOfUnits.h" #include "globals.hh" -#include "FWCore/MessageLogger/interface/MessageLogger.h" BscNumberingScheme::BscNumberingScheme() { LogDebug("BscSim") << " Creating BscNumberingScheme"; } @@ -24,7 +25,7 @@ void BscNumberingScheme::detectorLevel(const G4Step* aStep, int& level, int* cop const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); for (int ii = 0; ii < level; ++ii) { int i = level - ii - 1; - name[ii] = touch->GetVolume(i)->GetName(); + name[ii] = ForwardName::getName(touch->GetVolume(i)->GetName()); copyno[ii] = touch->GetReplicaNumber(i); } } diff --git a/SimG4CMS/Forward/src/ForwardName.cc b/SimG4CMS/Forward/src/ForwardName.cc new file mode 100644 index 0000000000000..d99b935f2d9dd --- /dev/null +++ b/SimG4CMS/Forward/src/ForwardName.cc @@ -0,0 +1,13 @@ +#include "SimG4CMS/Forward/interface/ForwardName.h" + +std::string ForwardName::getName(const G4String& namx) { + std::string name = static_cast(namx); + if (name.find(':') == std::string::npos) { + return name; + } else { + std::size_t first = name.find(':') + 1; + std::size_t last = name.rfind('_'); + std::size_t length = (last != std::string::npos) ? (last - first) : (name.size() - first); + return name.substr(first, length); + } +} diff --git a/SimG4CMS/Forward/src/PltSD.cc b/SimG4CMS/Forward/src/PltSD.cc index 30a54bb9267a3..d5d9baed44b21 100644 --- a/SimG4CMS/Forward/src/PltSD.cc +++ b/SimG4CMS/Forward/src/PltSD.cc @@ -1,4 +1,5 @@ #include "SimG4CMS/Forward/interface/PltSD.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -46,9 +47,9 @@ uint32_t PltSD::setDetUnitId(const G4Step* aStep) { //Get name and copy numbers if (level > 1) { //some debugging with the names - G4String sensorName = touch->GetVolume(2)->GetName(); - G4String telName = touch->GetVolume(3)->GetName(); - G4String volumeName = touch->GetVolume(4)->GetName(); + std::string sensorName = ForwardName::getName(touch->GetVolume(2)->GetName()); + std::string telName = ForwardName::getName(touch->GetVolume(3)->GetName()); + std::string volumeName = ForwardName::getName(touch->GetVolume(4)->GetName()); if (sensorName != "PLTSensorPlane") edm::LogVerbatim("PltSD") << " PltSD::setDetUnitId -w- Sensor name not PLTSensorPlane "; if (telName != "Telescope") diff --git a/SimG4CMS/Forward/src/TotemT1Organization.cc b/SimG4CMS/Forward/src/TotemT1Organization.cc index 87f44fbbbce95..0d1b711ea5407 100644 --- a/SimG4CMS/Forward/src/TotemT1Organization.cc +++ b/SimG4CMS/Forward/src/TotemT1Organization.cc @@ -15,6 +15,7 @@ // user include files #include "SimG4CMS/Forward/interface/TotemT1Organization.h" #include "SimG4CMS/Forward/interface/TotemNumberMerger.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "G4VPhysicalVolume.hh" @@ -58,10 +59,13 @@ uint32_t TotemT1Organization ::getUnitID(const G4Step* aStep) { << ", physVol->GetCopyNo()=" << physVol->GetCopyNo(); #endif - if (physVol->GetName() == "TotemT1" && physVol->GetCopyNo() == 1) - _currentDetectorPosition = 1; - if (physVol->GetName() == "TotemT1" && physVol->GetCopyNo() == 2) - _currentDetectorPosition = 2; + std::string dName = ForwardName::getName(physVol->GetName()); + if (dName == "TotemT1") { + if (physVol->GetCopyNo() == 1) + _currentDetectorPosition = 1; + else if (physVol->GetCopyNo() == 2) + _currentDetectorPosition = 2; + } } touch = aStep->GetPreStepPoint()->GetTouchable(); diff --git a/SimG4CMS/Forward/src/TotemT2OrganizationGem.cc b/SimG4CMS/Forward/src/TotemT2OrganizationGem.cc index dd4ea090cf6e0..a4c3461553542 100644 --- a/SimG4CMS/Forward/src/TotemT2OrganizationGem.cc +++ b/SimG4CMS/Forward/src/TotemT2OrganizationGem.cc @@ -15,6 +15,7 @@ // user include files #include "SimG4CMS/Forward/interface/TotemT2OrganizationGem.h" #include "SimG4CMS/Forward/interface/TotemNumberMerger.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "G4VPhysicalVolume.hh" @@ -46,49 +47,50 @@ uint32_t TotemT2OrganizationGem ::getUnitID(const G4Step* aStep) const { physVol = touch->GetVolume(0); - if (physVol->GetName() == "TotemT2gem") + std::string dName = ForwardName::getName(physVol->GetName()); + if (dName == "TotemT2gem") UNITA = 10 + physVol->GetCopyNo(); - if (physVol->GetName() == "TotemT2gem_supporto") + else if (dName == "TotemT2gem_supporto") UNITA = 20 + physVol->GetCopyNo(); - if (physVol->GetName() == "TotemT2gem_detector7r") + else if (dName == "TotemT2gem_detector7r") UNITA = 100 + physVol->GetCopyNo() + (touch->GetVolume(2)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_HC7r") + else if (dName == "TotemT2gem_HC7r") UNITA = 200 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_drift7r") + else if (dName == "TotemT2gem_drift7r") UNITA = 300 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_driftspace7r") + else if (dName == "TotemT2gem_driftspace7r") UNITA = 400 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMa7r") + else if (dName == "TotemT2gem_GEMa7r") UNITA = 500 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMb7r") + else if (dName == "TotemT2gem_GEMb7r") UNITA = 600 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMc7r") + else if (dName == "TotemT2gem_GEMc7r") UNITA = 700 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GAS7r") + else if (dName == "TotemT2gem_GAS7r") UNITA = 800 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMa17r") + else if (dName == "TotemT2gem_GEMa17r") UNITA = 900 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMb17r") + else if (dName == "TotemT2gem_GEMb17r") UNITA = 1000 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMc17r") + else if (dName == "TotemT2gem_GEMc17r") UNITA = 1100 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GAS17r") + else if (dName == "TotemT2gem_GAS17r") UNITA = 1200 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMa27r") + else if (dName == "TotemT2gem_GEMa27r") UNITA = 1300 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMb27r") + else if (dName == "TotemT2gem_GEMb27r") UNITA = 1400 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GEMc27r") + else if (dName == "TotemT2gem_GEMc27r") UNITA = 1500 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_GAS27r") + else if (dName == "TotemT2gem_GAS27r") UNITA = 1600 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_strips7r") + else if (dName == "TotemT2gem_strips7r") UNITA = 1700 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_isol7r") + else if (dName == "TotemT2gem_isol7r") UNITA = 1800 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_pads7r") + else if (dName == "TotemT2gem_pads7r") UNITA = 1900 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; - if (physVol->GetName() == "TotemT2gem_HC17r") + else if (dName == "TotemT2gem_HC17r") UNITA = 2000 + touch->GetVolume(1)->GetCopyNo() + (touch->GetVolume(3)->GetCopyNo()) * 1000; return UNITA; diff --git a/SimG4CMS/Forward/src/ZdcNumberingScheme.cc b/SimG4CMS/Forward/src/ZdcNumberingScheme.cc index fb3d8be72f04f..66107ce7ae320 100644 --- a/SimG4CMS/Forward/src/ZdcNumberingScheme.cc +++ b/SimG4CMS/Forward/src/ZdcNumberingScheme.cc @@ -5,6 +5,7 @@ // Modifications: /////////////////////////////////////////////////////////////////////////////// #include "SimG4CMS/Forward/interface/ZdcNumberingScheme.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" @@ -167,7 +168,7 @@ void ZdcNumberingScheme::detectorLevel(const G4Step* aStep, int& level, int* cop const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); for (int ii = 0; ii < level; ii++) { int i = level - ii - 1; - name[ii] = touch->GetVolume(i)->GetName(); + name[ii] = ForwardName::getName(touch->GetVolume(i)->GetName()); copyno[ii] = touch->GetReplicaNumber(i); } } diff --git a/SimG4CMS/Forward/src/ZdcSD.cc b/SimG4CMS/Forward/src/ZdcSD.cc index 314a00257762c..24ab9d2e72fcc 100644 --- a/SimG4CMS/Forward/src/ZdcSD.cc +++ b/SimG4CMS/Forward/src/ZdcSD.cc @@ -7,6 +7,7 @@ #include #include "SimG4CMS/Forward/interface/ZdcSD.h" +#include "SimG4CMS/Forward/interface/ForwardName.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" @@ -122,7 +123,7 @@ double ZdcSD::getEnergyDeposit(const G4Step* aStep) { // preStepPoint information G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume(); - const G4String& nameVolume = currentPV->GetName(); + std::string nameVolume = ForwardName::getName(currentPV->GetName()); const G4ThreeVector& hitPoint = preStepPoint->GetPosition(); const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection(); @@ -155,7 +156,7 @@ double ZdcSD::getEnergyDeposit(const G4Step* aStep) { // postStepPoint information G4StepPoint* postStepPoint = aStep->GetPostStepPoint(); G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume(); - const G4String& postnameVolume = postPV->GetName(); + std::string postnameVolume = ForwardName::getName(postPV->GetName()); edm::LogVerbatim("ForwardSim") << "ZdcSD:: getEnergyDeposit: \n" << " preStepPoint: " << nameVolume << "," << stepL << "," << stepE << "," << beta << "," << charge << "\n" diff --git a/SimG4CMS/Muon/interface/MuonSensitiveDetector.h b/SimG4CMS/Muon/interface/MuonSensitiveDetector.h index 48e721ba32923..746f2fdd65f08 100644 --- a/SimG4CMS/Muon/interface/MuonSensitiveDetector.h +++ b/SimG4CMS/Muon/interface/MuonSensitiveDetector.h @@ -20,6 +20,7 @@ #include "SimG4Core/SensitiveDetector/interface/SensitiveTkDetector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "CondFormats/GeometryObjects/interface/MuonOffsetMap.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h" #include @@ -41,10 +42,7 @@ class MuonSensitiveDetector : public SensitiveTkDetector, public Observer()}, - geomConstantsToken_{cc.esConsumes()} { - edm::ParameterSet muonSD = p.getParameter("MuonSD"); - ePersistentCutGeV_ = muonSD.getParameter("EnergyThresholdForPersistency") / CLHEP::GeV; //Default 1. GeV - allMuonsPersistent_ = muonSD.getParameter("AllMuonsPersistent"); - printHits_ = muonSD.getParameter("PrintHits"); - dd4hep_ = p.getParameter("g4GeometryDD4hepSource"); - } + geomConstantsToken_{cc.esConsumes()} {} void beginRun(const edm::EventSetup& es) final { edm::ESHandle mom = es.getHandle(offsetToken_); @@ -55,8 +49,7 @@ class MuonSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { const edm::ParameterSet& p, const SimTrackManager* man, SimActivityRegistry& reg) const final { - auto sd = std::make_unique( - iname, offmap_, *mdc_, clg, ePersistentCutGeV_, allMuonsPersistent_, printHits_, dd4hep_, man); + auto sd = std::make_unique(iname, offmap_, *mdc_, clg, p, man); SimActivityRegistryEnroller::enroll(reg, sd.get()); return sd; } diff --git a/SimG4CMS/Muon/src/MuonSensitiveDetector.cc b/SimG4CMS/Muon/src/MuonSensitiveDetector.cc index cf22fe9e8436e..b00b0aca9e327 100644 --- a/SimG4CMS/Muon/src/MuonSensitiveDetector.cc +++ b/SimG4CMS/Muon/src/MuonSensitiveDetector.cc @@ -9,6 +9,10 @@ #include "SimG4CMS/Muon/interface/SimHitPrinter.h" #include "SimDataFormats/TrackingHit/interface/UpdatablePSimHit.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DataFormats/MuonDetId/interface/MuonSubdetId.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "SimG4CMS/Muon/interface/MuonG4Numbering.h" #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h" @@ -36,10 +40,7 @@ MuonSensitiveDetector::MuonSensitiveDetector(const std::string& name, const MuonOffsetMap* offmap, const MuonGeometryConstants& constants, const SensitiveDetectorCatalog& clg, - double aEPersistentCutGeV, - bool aAllMuonsPersistent, - bool aPrintHits, - bool dd4hep, + edm::ParameterSet const& p, const SimTrackManager* manager) : SensitiveTkDetector(name, clg), thePV(nullptr), @@ -47,15 +48,23 @@ MuonSensitiveDetector::MuonSensitiveDetector(const std::string& name, theDetUnitId(0), newDetUnitId(0), theTrackID(0), - printHits(aPrintHits), thePrinter(nullptr), - ePersistentCutGeV(aEPersistentCutGeV), - allMuonsPersistent(aAllMuonsPersistent), theManager(manager) { // Here simply create 1 MuonSlaveSD for the moment // + bool dd4hep = p.getParameter("g4GeometryDD4hepSource"); + edm::ParameterSet muonSD = p.getParameter("MuonSD"); + printHits_ = muonSD.getParameter("PrintHits"); + ePersistentCutGeV_ = muonSD.getParameter("EnergyThresholdForPersistency") / CLHEP::GeV; //Default 1. GeV + allMuonsPersistent_ = muonSD.getParameter("AllMuonsPersistent"); + haveDemo_ = muonSD.getParameter("HaveDemoChambers"); + demoGEM_ = muonSD.getParameter("UseDemoHitGEM"); + demoRPC_ = muonSD.getParameter("UseDemoHitRPC"); + #ifdef EDM_ML_DEBUG - edm::LogVerbatim("MuonSim") << "create MuonSubDetector " << name << " with dd4hep flag " << dd4hep; + edm::LogVerbatim("MuonSim") << "create MuonSubDetector " << name << " with dd4hep flag " << dd4hep + << " Flags for Demonstration chambers " << haveDemo_ << " for GEM " << demoGEM_ + << " for RPC " << demoRPC_; #endif detector = new MuonSubDetector(name); @@ -81,12 +90,12 @@ MuonSensitiveDetector::MuonSensitiveDetector(const std::string& name, numbering = new MuonSimHitNumberingScheme(detector, constants); g4numbering = new MuonG4Numbering(constants, offmap, dd4hep); - if (printHits) { + if (printHits_) { thePrinter = new SimHitPrinter("HitPositionOSCAR.dat"); } edm::LogVerbatim("MuonSim") << " of type " << sdet << " <" << GetName() << "> EnergyThresholdForPersistency(GeV) " - << ePersistentCutGeV / CLHEP::GeV << " allMuonsPersistent: " << allMuonsPersistent; + << ePersistentCutGeV_ / CLHEP::GeV << " allMuonsPersistent: " << allMuonsPersistent_; theG4ProcessTypeEnumerator = new G4ProcessTypeEnumerator; } @@ -122,7 +131,13 @@ bool MuonSensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhis if (aStep->GetTotalEnergyDeposit() > 0.) { newDetUnitId = setDetUnitId(aStep); - +#ifdef EDM_ML_DEBUG + G4VPhysicalVolume* vol = aStep->GetPreStepPoint()->GetTouchable()->GetVolume(0); + std::string namx = static_cast(vol->GetName()); + std::string name = namx.substr(0, 2); + if (name == "RE") + edm::LogVerbatim("MuonSim") << "DETID " << namx << " " << RPCDetId(newDetUnitId); +#endif if (newHit(aStep)) { saveHit(); createHit(aStep); @@ -223,7 +238,7 @@ void MuonSensitiveDetector::createHit(const G4Step* aStep) { // Make track persistent int thePID = std::abs(theTrack->GetDefinition()->GetPDGEncoding()); //---VI - in parameters cut in energy is declared but applied to momentum - if (thePabs > ePersistentCutGeV || (thePID == 13 && allMuonsPersistent)) { + if (thePabs > ePersistentCutGeV_ || (thePID == 13 && allMuonsPersistent_)) { TrackInformation* info = cmsTrackInformation(theTrack); info->storeTrack(true); } @@ -290,13 +305,15 @@ void MuonSensitiveDetector::updateHit(const G4Step* aStep) { void MuonSensitiveDetector::saveHit() { if (theHit) { - if (printHits) { - thePrinter->startNewSimHit(detector->name()); - thePrinter->printId(theHit->detUnitId()); - thePrinter->printLocal(theHit->entryPoint(), theHit->exitPoint()); + if (acceptHit(theHit->detUnitId())) { + if (printHits_) { + thePrinter->startNewSimHit(detector->name()); + thePrinter->printId(theHit->detUnitId()); + thePrinter->printLocal(theHit->entryPoint(), theHit->exitPoint()); + } + // hit is included into hit collection + slaveMuon->processHits(*theHit); } - // hit is included into hit collection - slaveMuon->processHits(*theHit); delete theHit; theHit = nullptr; } @@ -336,3 +353,41 @@ Local3DPoint MuonSensitiveDetector::FinalStepPositionVsParent(const G4Step* curr return ConvertToLocal3DPoint(localCoordinates); } + +bool MuonSensitiveDetector::acceptHit(uint32_t id) { + if (id == 0) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("MuonSim") << "DetId " << id << " Flag " << false; +#endif + return false; + } + bool flag(true); + if (haveDemo_) { + int subdet = DetId(id).subdetId(); + if (subdet == MuonSubdetId::GEM) { + if (GEMDetId(id).station() == 2) + flag = demoGEM_; + } else if (subdet == MuonSubdetId::RPC) { + if ((RPCDetId(id).region() != 0) && (RPCDetId(id).ring() == 1) && (RPCDetId(id).station() > 2)) + flag = demoRPC_; + } + } +#ifdef EDM_ML_DEBUG + int subdet = DetId(id).subdetId(); + if (subdet == MuonSubdetId::RPC) + edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " RPC " << RPCDetId(id) << " Flag " + << flag; + else if (subdet == MuonSubdetId::GEM) + edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " GEM " << GEMDetId(id) << " Flag " + << flag; + else if (subdet == MuonSubdetId::ME0) + edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " " << ME0DetId(id) << " Flag " << flag; + else if (subdet == MuonSubdetId::CSC) + edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " CSC Flag " << flag; + else if (subdet == MuonSubdetId::DT) + edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " DT Flag " << flag; + else + edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " Unknown Flag " << flag; +#endif + return flag; +} diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index 7e234e027fdd6..bd89add8c6322 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -71,7 +71,7 @@ ## enable CaloBoundary information for all Phase2 workflows from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal phase2_hgcal.toModify(common_MCtruth, - SaveCaloBoundaryInformation =True + SaveCaloBoundaryInformation = True ) g4SimHits = cms.EDProducer("OscarMTProducer", @@ -327,7 +327,10 @@ MuonSD = cms.PSet( EnergyThresholdForPersistency = cms.double(1.0), PrintHits = cms.bool(False), - AllMuonsPersistent = cms.bool(True) + AllMuonsPersistent = cms.bool(True), + UseDemoHitRPC = cms.bool(True), + UseDemoHitGEM = cms.bool(True), + HaveDemoChambers = cms.bool(True) ), CaloSD = cms.PSet( common_heavy_suppression, @@ -625,25 +628,35 @@ run2_HCAL_2017.toModify( g4SimHits, HCalSD = dict( TestNumberingScheme = True ) ) ## -## Disable Castor from Run 3 +## Disable Castor from Run 3, enable PPS (***temporarily disable PPS***) ## from Configuration.Eras.Modifier_run3_common_cff import run3_common run3_common.toModify( g4SimHits, CastorSD = dict( useShowerLibrary = False ) ) +run3_common.toModify( g4SimHits, LHCTransport = False ) + +## +## Disable PPS from Run 3 PbPb runs +## +from Configuration.Eras.Modifier_pp_on_PbPb_run3_cff import pp_on_PbPb_run3 +pp_on_PbPb_run3.toModify( g4SimHits, LHCTransport = False ) ## ## Change ECAL time slices ## from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing -phase2_timing.toModify( g4SimHits.ECalSD, - StoreLayerTimeSim = cms.untracked.bool(True), - TimeSliceUnit = cms.double(0.001) ) +phase2_timing.toModify( g4SimHits, ECalSD = dict( + StoreLayerTimeSim = True, + TimeSliceUnit = 0.001 ) +) + ## ## Change CALO Thresholds ## from Configuration.Eras.Modifier_h2tb_cff import h2tb -h2tb.toModify(g4SimHits.CaloSD, - EminHits = cms.vdouble(0.0,0.0,0.0,0.0,0.0), - TmaxHits = cms.vdouble(1000.0,1000.0,1000.0,1000.0,2000.0) ) +h2tb.toModify(g4SimHits, CaloSD = dict( + EminHits = [0.0, 0.0, 0.0, 0.0, 0.0], + TmaxHits = [1000.0, 1000.0, 1000.0, 1000.0, 2000.0] ) +) ## ## DD4hep migration @@ -652,9 +665,13 @@ dd4hep.toModify( g4SimHits, g4GeometryDD4hepSource = True ) ## -## Selection of SD's for Phase2 +## Selection of SD's for Phase2, exclude PPS ## from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toModify(g4SimHits, - OnlySDs = cms.vstring('ZdcSensitiveDetector', 'TotemT2ScintSensitiveDetector', 'TotemSensitiveDetector', 'RomanPotSensitiveDetector', 'PLTSensitiveDetector', 'MuonSensitiveDetector', 'MtdSensitiveDetector', 'BCM1FSensitiveDetector', 'EcalSensitiveDetector', 'CTPPSSensitiveDetector', 'HGCalSensitiveDetector', 'BSCSensitiveDetector', 'CTPPSDiamondSensitiveDetector', 'FP420SensitiveDetector', 'BHMSensitiveDetector', 'HFNoseSensitiveDetector', 'HGCScintillatorSensitiveDetector', 'CastorSensitiveDetector', 'CaloTrkProcessing', 'HcalSensitiveDetector', 'TkAccumulatingSensitiveDetector') ) + OnlySDs = ['ZdcSensitiveDetector', 'TotemT2ScintSensitiveDetector', 'TotemSensitiveDetector', 'RomanPotSensitiveDetector', 'PLTSensitiveDetector', 'MuonSensitiveDetector', 'MtdSensitiveDetector', 'BCM1FSensitiveDetector', 'EcalSensitiveDetector', 'CTPPSSensitiveDetector', 'HGCalSensitiveDetector', 'BSCSensitiveDetector', 'CTPPSDiamondSensitiveDetector', 'FP420SensitiveDetector', 'BHMSensitiveDetector', 'HFNoseSensitiveDetector', 'HGCScintillatorSensitiveDetector', 'CastorSensitiveDetector', 'CaloTrkProcessing', 'HcalSensitiveDetector', 'TkAccumulatingSensitiveDetector'], + LHCTransport = False, + MuonSD = dict( + HaveDemoChambers = False ) +)