Skip to content

Commit

Permalink
Merge pull request #36680 from bsunanda/Run3-gex112
Browse files Browse the repository at this point in the history
Run3-gex112 Correction to some of the Forward detector SD's for the dd4hep scenarios
  • Loading branch information
cmsbuild committed Jan 12, 2022
2 parents 3fa904d + 5264a14 commit 4a9cd35
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 41 deletions.
12 changes: 12 additions & 0 deletions SimG4CMS/Forward/interface/ForwardName.h
@@ -0,0 +1,12 @@
#ifndef SimG4CMSForward_ForwardName_h
#define SimG4CMSForward_ForwardName_h

#include <G4String.hh>
#include <cstdint>
#include <string>

namespace ForwardName {
std::string getName(const G4String &);
}; // namespace ForwardName

#endif
3 changes: 2 additions & 1 deletion 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"
Expand All @@ -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);
}
}
Expand Down
13 changes: 7 additions & 6 deletions SimG4CMS/Forward/src/Bcm1fSD.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions SimG4CMS/Forward/src/BscNumberingScheme.cc
Expand Up @@ -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"; }

Expand All @@ -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);
}
}
Expand Down
13 changes: 13 additions & 0 deletions 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<std::string>(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);
}
}
7 changes: 4 additions & 3 deletions 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"
Expand Down Expand Up @@ -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")
Expand Down
12 changes: 8 additions & 4 deletions SimG4CMS/Forward/src/TotemT1Organization.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
46 changes: 24 additions & 22 deletions SimG4CMS/Forward/src/TotemT2OrganizationGem.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion SimG4CMS/Forward/src/ZdcNumberingScheme.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
}
Expand Down
5 changes: 3 additions & 2 deletions SimG4CMS/Forward/src/ZdcSD.cc
Expand Up @@ -7,6 +7,7 @@
#include <memory>

#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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4a9cd35

Please sign in to comment.