Skip to content

Commit 931cbaa

Browse files
authored
Merge pull request #47589 from bsunanda/Run3-gex187P
Run3-gex187P Provide a way to avoid saving hits for a list of GEM chambers (eg missing GE11 chambers)
2 parents f3c852e + dfbe638 commit 931cbaa

File tree

4 files changed

+101
-3
lines changed

4 files changed

+101
-3
lines changed

SimG4CMS/Muon/interface/MuonSensitiveDetector.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ class MuonSensitiveDetector : public SensitiveTkDetector, public Observer<const
9898
bool demoGEM_;
9999
bool demoRPC_;
100100

101+
// For list of GEM DetId to be removed
102+
// DetId = (region * 10000 + ring * 1000 + stattion * 100 +chamber)
103+
// region = 0 for -1; 2 for +1
104+
std::vector<int32_t> removeGEMHits_;
105+
101106
G4ProcessTypeEnumerator* theG4ProcessTypeEnumerator;
102107

103108
const SimTrackManager* theManager;

SimG4CMS/Muon/src/MuonSensitiveDetector.cc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "FWCore/MessageLogger/interface/MessageLogger.h"
3434

3535
#include <iostream>
36+
#include <sstream>
3637

3738
//#define EDM_ML_DEBUG
3839

@@ -60,11 +61,18 @@ MuonSensitiveDetector::MuonSensitiveDetector(const std::string& name,
6061
haveDemo_ = muonSD.getParameter<bool>("HaveDemoChambers");
6162
demoGEM_ = muonSD.getParameter<bool>("UseDemoHitGEM");
6263
demoRPC_ = muonSD.getParameter<bool>("UseDemoHitRPC");
64+
removeGEMHits_ = muonSD.getParameter<std::vector<int32_t>>("RemoveGEMHits");
6365

6466
#ifdef EDM_ML_DEBUG
6567
edm::LogVerbatim("MuonSim") << "create MuonSubDetector " << name << " with dd4hep flag " << dd4hep
6668
<< " Flags for Demonstration chambers " << haveDemo_ << " for GEM " << demoGEM_
67-
<< " for RPC " << demoRPC_;
69+
<< " for RPC " << demoRPC_ << " " << removeGEMHits_.size() << " GEM Hits to be removed";
70+
if (!removeGEMHits_.empty()) {
71+
std::ostringstream st1;
72+
for (const auto& id : removeGEMHits_)
73+
st1 << " " << id;
74+
edm::LogVerbatim("MuonSim") << "IDs to be removed " << st1.str();
75+
}
6876
#endif
6977
detector = new MuonSubDetector(name);
7078

@@ -358,10 +366,22 @@ Local3DPoint MuonSensitiveDetector::FinalStepPositionVsParent(const G4Step* curr
358366
bool MuonSensitiveDetector::acceptHit(uint32_t id) {
359367
if (id == 0) {
360368
#ifdef EDM_ML_DEBUG
361-
edm::LogVerbatim("MuonSim") << "DetId " << id << " Flag " << false;
369+
edm::LogVerbatim("MuonSim") << "DetId " << std::hex << id << std::dec << " Flag " << false;
362370
#endif
363371
return false;
364372
}
373+
if (!removeGEMHits_.empty()) {
374+
if (DetId(id).subdetId() == MuonSubdetId::GEM) {
375+
int id0 = ((GEMDetId(id).region() - GEMDetId::minRegionId)) * 10000 + GEMDetId(id).ring() * 1000 +
376+
GEMDetId(id).station() * 100 + GEMDetId(id).chamber();
377+
if (std::find(removeGEMHits_.begin(), removeGEMHits_.end(), id0) != removeGEMHits_.end()) {
378+
#ifdef EDM_ML_DEBUG
379+
edm::LogVerbatim("MuonSim") << "Remove Hits for DetId " << GEMDetId(id);
380+
#endif
381+
return false;
382+
}
383+
}
384+
}
365385
bool flag(true);
366386
if (haveDemo_) {
367387
int subdet = DetId(id).subdetId();

SimG4CMS/Muon/test/runGEM_cfg.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import FWCore.ParameterSet.Config as cms
2+
from Configuration.Eras.Era_Run3_DDD_cff import Run3_DDD
3+
4+
process = cms.Process("PROD",Run3_DDD)
5+
process.load("SimG4CMS.Calo.pythiapdt_cfi")
6+
process.load('FWCore.MessageService.MessageLogger_cfi')
7+
process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi")
8+
process.load("Configuration.Geometry.GeometryExtended2025Reco_cff")
9+
process.load("Configuration.StandardSequences.MagneticField_cff")
10+
process.load("Configuration.EventContent.EventContent_cff")
11+
process.load('Configuration.StandardSequences.Generator_cff')
12+
process.load('Configuration.StandardSequences.SimIdeal_cff')
13+
14+
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
15+
from Configuration.AlCa.autoCond import autoCond
16+
process.GlobalTag.globaltag = autoCond['phase1_2025_realistic']
17+
18+
if 'MessageLogger' in process.__dict__:
19+
process.MessageLogger.G4cerr=dict()
20+
process.MessageLogger.MuonSim=dict()
21+
22+
process.load("IOMC.RandomEngine.IOMC_cff")
23+
process.RandomNumberGeneratorService.generator.initialSeed = 456789
24+
process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876
25+
process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789
26+
27+
process.maxEvents = cms.untracked.PSet(
28+
input = cms.untracked.int32(200)
29+
)
30+
31+
process.source = cms.Source("EmptySource")
32+
33+
process.generator = cms.EDProducer("FlatRandomEGunProducer",
34+
PGunParameters = cms.PSet(
35+
PartID = cms.vint32(13),
36+
MinEta = cms.double(1.5),
37+
MaxEta = cms.double(2.5),
38+
MinPhi = cms.double(-3.1415926),
39+
MaxPhi = cms.double(3.1415926),
40+
MinE = cms.double(50.),
41+
MaxE = cms.double(50.)
42+
),
43+
Verbosity = cms.untracked.int32(0),
44+
AddAntiParticle = cms.bool(True),
45+
firstRun = cms.untracked.uint32(1)
46+
)
47+
48+
process.output = cms.OutputModule("PoolOutputModule",
49+
process.FEVTSIMEventContent,
50+
fileName = cms.untracked.string('simeventMuon.root')
51+
)
52+
53+
process.Timing = cms.Service("Timing")
54+
55+
process.generation_step = cms.Path(process.pgen)
56+
process.simulation_step = cms.Path(process.psim)
57+
process.out_step = cms.EndPath(process.output)
58+
59+
process.g4SimHits.Physics.type = 'SimG4Core/Physics/FTFP_BERT_EMM'
60+
process.g4SimHits.Physics.Verbosity = 0
61+
process.g4SimHits.G4Commands = ['/tracking/verbose 1']
62+
process.g4SimHits.MuonSD.RemoveGEMHits = [1101, 1102, 1103, 1104, 1106, 1108]
63+
64+
# Schedule definition
65+
process.schedule = cms.Schedule(process.generation_step,
66+
process.simulation_step,
67+
process.out_step
68+
)
69+
70+
# filter all path with the production filter sequence
71+
for path in process.paths:
72+
getattr(process,path)._seq = process.generator * getattr(process,path)._seq

SimG4Core/Application/python/g4SimHits_cfi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@
373373
AllMuonsPersistent = cms.bool(True),
374374
UseDemoHitRPC = cms.bool(True),
375375
UseDemoHitGEM = cms.bool(True),
376-
HaveDemoChambers = cms.bool(True)
376+
HaveDemoChambers = cms.bool(True),
377+
RemoveGEMHits = cms.vint32()
377378
),
378379
CaloSD = cms.PSet(
379380
common_heavy_suppression,

0 commit comments

Comments
 (0)