Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions SimG4CMS/HGCalTestBeam/CaloUtil.xml

This file was deleted.

39 changes: 39 additions & 0 deletions SimG4CMS/HGCalTestBeam/data/dd4hep/HGCalTB181Oct1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>

<DDDefinition>
<debug>
<!--
<debug_shapes/>
<debug_rotations/>
<debug_volumes/>
<debug_placements/>
<debug_algorithms/>
<debug_constants/>
<debug_includes/>
<debug_materials/>
<debug_namespaces/>
<debug_visattr/>
-->
</debug>

<open_geometry/>
<close_geometry/>

<IncludeSection>
<Include ref='Geometry/CMSCommonData/data/materials/2021/v2/materials.xml'/>
<Include ref='SimG4CMS/CherenkovAnalysis/data/singleDREAM.xml'/>
<Include ref='Geometry/CMSCommonData/data/materials.xml'/>
<Include ref='Geometry/CMSCommonData/data/rotations.xml'/>
<Include ref='Geometry/HGCalCommonData/data/hgcalMaterial/v1/hgcalMaterial.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/cms.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/ahcal.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/hgcalBeam.xml'/>
<Include ref='Geometry/HGCalCommonData/data/hgcalwafer/v7/hgcalwafer.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/hgcalsense.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/hgcProdCuts.xml'/>
<Include ref='Geometry/HGCalCommonData/data/TB181/Oct181/hgcalCons.xml'/>
</IncludeSection>
</DDDefinition>
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class HGCPassive : public SimProducer,
G4LogicalVolume *topLV_;
std::map<G4LogicalVolume *, std::pair<unsigned int, std::string>> mapLV_;
std::string motherName_;
int addlevel_;

// some private members for ananlysis
unsigned int count_;
Expand Down
1 change: 1 addition & 0 deletions SimG4CMS/HGCalTestBeam/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<use name="SimG4Core/Watcher"/>
<use name="geant4core"/>
<use name="clhep"/>
<use name="dd4hep"/>
<use name="rootphysics"/>
<use name="root"/>
<use name="hepmc"/>
Expand Down
26 changes: 16 additions & 10 deletions SimG4CMS/HGCalTestBeam/plugins/HGCPassive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
// Description: Main analysis class for HGCal Validation of G4 Hits
///////////////////////////////////////////////////////////////////////////////

#include "HGCPassive.h"
#include "SimG4CMS/HGCalTestBeam/interface/HGCPassive.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsunanda , I am sorry, but recent requirement from @smuzaffar was to have include files for plugin inside plugin directory. This include files should not be used by any other class except producer itself HGCPassive.cc, normally these two files should be merged together into HGCPassive.cc, two separate files only if the producer is too big.

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CLHEP/Units/GlobalPhysicalConstants.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "G4TransportationManager.hh"
#include "DD4hep/Filter.h"

#include <cmath>
#include <iomanip>
Expand All @@ -23,9 +24,11 @@ HGCPassive::HGCPassive(const edm::ParameterSet& p) : topPV_(nullptr), topLV_(nul
edm::ParameterSet m_Passive = p.getParameter<edm::ParameterSet>("HGCPassive");
LVNames_ = m_Passive.getParameter<std::vector<std::string> >("LVNames");
motherName_ = m_Passive.getParameter<std::string>("MotherName");
bool dd4hep = m_Passive.getParameter<bool>("IfDD4Hep");
addlevel_ = dd4hep ? 1 : 0;

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << "Name of the mother volume " << motherName_;
edm::LogVerbatim("HGCSim") << "Name of the mother volume " << motherName_ << " AddLevel " << addlevel_;
unsigned k(0);
#endif
for (const auto& name : LVNames_) {
Expand Down Expand Up @@ -86,6 +89,7 @@ void HGCPassive::update(const G4Step* aStep) {
G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();

int level = (touchable->GetHistoryDepth());
if (curSD == nullptr) {
G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume();
auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
Expand All @@ -96,8 +100,8 @@ void HGCPassive::update(const G4Step* aStep) {
if (((aStep->GetPostStepPoint() == nullptr) || (aStep->GetTrack()->GetNextVolume() == nullptr)) &&
(aStep->IsLastStepInVolume())) {
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << plv->GetName() << " F|L Step " << aStep->IsFirstStepInVolume() << ":"
<< aStep->IsLastStepInVolume() << " Position"
edm::LogVerbatim("HGCSim") << static_cast<std::string>(dd4hep::dd::noNamespace(plv->GetName())) << " F|L Step "
<< aStep->IsFirstStepInVolume() << ":" << aStep->IsLastStepInVolume() << " Position"
<< aStep->GetPreStepPoint()->GetPosition() << " Track "
<< aStep->GetTrack()->GetDefinition()->GetParticleName() << " at"
<< aStep->GetTrack()->GetPosition() << " Volume " << aStep->GetTrack()->GetVolume()
Expand All @@ -109,7 +113,9 @@ void HGCPassive::update(const G4Step* aStep) {
energy += (aStep->GetPreStepPoint()->GetKineticEnergy() / CLHEP::GeV);
} else {
time = (aStep->GetPostStepPoint()->GetGlobalTime());
copy = (unsigned int)(touchable->GetReplicaNumber(0) + 1000 * touchable->GetReplicaNumber(1));
copy = (level < 2)
? 0
: static_cast<unsigned int>(touchable->GetReplicaNumber(0) + 1000 * touchable->GetReplicaNumber(1));
}
if (it != mapLV_.end()) {
storeInfo(it, plv, copy, time, energy, true);
Expand All @@ -122,7 +128,6 @@ void HGCPassive::update(const G4Step* aStep) {
} // if (curSD==NULL)

// Now for the mother volumes
int level = (touchable->GetHistoryDepth());
if (level > 0) {
double energy = (aStep->GetTotalEnergyDeposit()) / CLHEP::GeV;
double time = (aStep->GetTrack()->GetGlobalTime());
Expand All @@ -131,8 +136,9 @@ void HGCPassive::update(const G4Step* aStep) {
G4LogicalVolume* plv = touchable->GetVolume(i)->GetLogicalVolume();
auto it = (init_) ? mapLV_.find(plv) : findLV(plv);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCSim") << "Level: " << level << ":" << i << " " << plv->GetName() << " flag in the List "
<< (it != mapLV_.end());
edm::LogVerbatim("HGCSim") << "Level: " << level << ":" << i << " "
<< static_cast<std::string>(dd4hep::dd::noNamespace(plv->GetName()))
<< " flag in the List " << (it != mapLV_.end());
#endif
if (it != mapLV_.end()) {
unsigned int copy =
Expand Down Expand Up @@ -176,7 +182,7 @@ G4VPhysicalVolume* HGCPassive::getTopPV() {
HGCPassive::volumeIterator HGCPassive::findLV(G4LogicalVolume* plv) {
auto itr = mapLV_.find(plv);
if (itr == mapLV_.end()) {
std::string name = plv->GetName();
std::string name = static_cast<std::string>(dd4hep::dd::noNamespace(plv->GetName()));
for (unsigned int k = 0; k < LVNames_.size(); ++k) {
if (name.find(LVNames_[k]) != std::string::npos) {
mapLV_[plv] = std::pair<unsigned int, std::string>(k, name);
Expand All @@ -186,7 +192,7 @@ HGCPassive::volumeIterator HGCPassive::findLV(G4LogicalVolume* plv) {
}
}
if (topLV_ == nullptr) {
if (std::string(plv->GetName()) == motherName_)
if (static_cast<std::string>(dd4hep::dd::noNamespace(plv->GetName())) == motherName_)
topLV_ = plv;
}
return itr;
Expand Down
7 changes: 4 additions & 3 deletions SimG4CMS/HGCalTestBeam/test/HGCalTBCERN170_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@
'HcalTB06BeamDetector']
process.g4SimHits.Watchers = cms.VPSet(cms.PSet(
HGCPassive = cms.PSet(
LVNames = cms.vstring('HGCalEE','HGCalHE','HGCalAH', 'HGCalBeam', 'CMSE'),
MotherName = cms.string('OCMS'),
),
LVNames = cms.vstring('HGCalEE','HGCalHE','HGCalAH', 'HGCalBeam', 'CMSE'),
MotherName = cms.string('OCMS'),
IfDD4Hep = cms.bool(False),
),
type = cms.string('HGCPassive'),
)
)
Expand Down
151 changes: 151 additions & 0 deletions SimG4CMS/HGCalTestBeam/test/HGCalTBCERN181Oct1DD4Hep_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import FWCore.ParameterSet.Config as cms
from Configuration.ProcessModifiers.dd4hep_cff import dd4hep

process = cms.Process('SIM',dd4hep)

# import of standard configurations
process.load("FWCore.MessageService.MessageLogger_cfi")
process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('Configuration.EventContent.EventContent_cff')
process.load('SimGeneral.MixingModule.mixNoPU_cfi')
process.load("Configuration.Geometry.GeometryDD4hep_cff")
process.load('Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi')
process.load('Geometry.HGCalCommonData.hgcalParametersInitialization_cfi')
process.load('Geometry.HcalTestBeamData.hcalTB06Parameters_cff')
process.load('Configuration.StandardSequences.MagneticField_0T_cff')
process.load('Configuration.StandardSequences.Generator_cff')
process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi')
process.load('GeneratorInterface.Core.genFilterSummary_cff')
process.load('Configuration.StandardSequences.SimIdeal_cff')
process.load('Configuration.StandardSequences.EndOfProcess_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.load('SimG4CMS.HGCalTestBeam.HGCalTBAnalyzer_cfi')
process.load('SimG4CMS.HGCalTestBeam.HGCalTBCheckGunPosition_cfi')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(10)
)

if 'MessageLogger' in process.__dict__:
process.MessageLogger.HGCalGeom=dict()
process.MessageLogger.HGCSim=dict()
process.MessageLogger.HcalSim=dict()
process.MessageLogger.HcalTB06BeamSD=dict()
# process.MessageLogger.SimG4CoreGeometry=dict()

# Input source
process.source = cms.Source("EmptySource")

process.options = cms.untracked.PSet(
)

# Production Info
process.configurationMetadata = cms.untracked.PSet(
annotation = cms.untracked.string('SingleMuonE200_cfi nevts:10'),
name = cms.untracked.string('Applications'),
version = cms.untracked.string('$Revision: 1.19 $')
)

# Output definition

process.FEVTDEBUGoutput = cms.OutputModule("PoolOutputModule",
SelectEvents = cms.untracked.PSet(
SelectEvents = cms.vstring('generation_step')
),
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('GEN-SIM'),
filterName = cms.untracked.string('')
),
fileName = cms.untracked.string('file:TBGenSim181Oct1DD4Hep.root'),
outputCommands = process.FEVTDEBUGEventContent.outputCommands,
splitLevel = cms.untracked.int32(0)
)

# Additional output definition
process.TFileService = cms.Service("TFileService",
fileName = cms.string('TBGenSimDD4Hep.root')
)

# Other statements
process.genstepfilter.triggerConditions=cms.vstring("generation_step")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')

process.generator = cms.EDProducer("FlatRandomEThetaGunProducer",
AddAntiParticle = cms.bool(False),
PGunParameters = cms.PSet(
MinE = cms.double(99.99),
MaxE = cms.double(100.01),
MinTheta = cms.double(0.0),
MaxTheta = cms.double(0.0),
MinPhi = cms.double(-3.14159265359),
MaxPhi = cms.double(3.14159265359),
PartID = cms.vint32(11)
),
Verbosity = cms.untracked.int32(0),
firstRun = cms.untracked.uint32(1),
psethack = cms.string('single muon E 100')
)
process.VtxSmeared.MinZ = -800.0
process.VtxSmeared.MaxZ = -800.0
process.VtxSmeared.MinX = -7.5
process.VtxSmeared.MaxX = 7.5
process.VtxSmeared.MinY = -7.5
process.VtxSmeared.MaxY = 7.5
process.g4SimHits.HGCSD.RejectMouseBite = True
process.g4SimHits.HGCSD.RotatedWafer = True
process.g4SimHits.OnlySDs = ['AHcalSensitiveDetector',
'HGCSensitiveDetector',
'HGCalTB1601SensitiveDetector',
'HcalTB06BeamDetector']
process.DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("SimG4CMS/HGCalTestBeam/data/dd4hep/HGCalTB181Oct1.xml")

process.g4SimHits.Watchers = cms.VPSet(cms.PSet(
HGCPassive = cms.PSet(
LVNames = cms.vstring('HGCalEE','HGCalHE','HGCalAH', 'HGCalBeam', 'CMSE'),
MotherName = cms.string('OCMS'),
IfDD4Hep = cms.bool(True),
),
type = cms.string('HGCPassive'),
)
)
process.HGCalTBAnalyzer.doDigis = False
process.HGCalTBAnalyzer.doRecHits = False
process.HGCalTBAnalyzer.useFH = True
process.HGCalTBAnalyzer.useBH = True
process.HGCalTBAnalyzer.useBeam = True
process.HGCalTBAnalyzer.zFrontEE = 1110.0
process.HGCalTBAnalyzer.zFrontFH = 1176.5
process.HGCalTBAnalyzer.zFrontFH = 1307.5
process.HGCalTBAnalyzer.maxDepth = 39
process.HGCalTBAnalyzer.deltaZ = 26.2
process.HGCalTBAnalyzer.zFirst = 22.8
process.HGCalTBAnalyzer.doPassive = True
process.HGCalTBAnalyzer.doPassiveEE = True
process.HGCalTBAnalyzer.doPassiveHE = True
process.HGCalTBAnalyzer.doPassiveBH = True

# Path and EndPath definitions
process.generation_step = cms.Path(process.pgen)
process.gunfilter_step = cms.Path(process.HGCalTBCheckGunPostion)
process.simulation_step = cms.Path(process.psim)
process.genfiltersummary_step = cms.EndPath(process.genFilterSummary)
process.analysis_step = cms.Path(process.HGCalTBAnalyzer)
process.endjob_step = cms.EndPath(process.endOfProcess)
process.FEVTDEBUGoutput_step = cms.EndPath(process.FEVTDEBUGoutput)

# Schedule definition
process.schedule = cms.Schedule(process.generation_step,
process.genfiltersummary_step,
process.simulation_step,
process.gunfilter_step,
process.analysis_step,
process.endjob_step,
process.FEVTDEBUGoutput_step
)
# filter all path with the production filter sequence
for path in process.paths:
getattr(process,path)._seq = process.generator * getattr(process,path)._seq


Loading