diff --git a/SimG4CMS/Calo/plugins/HGCalHitPartial.cc b/SimG4CMS/Calo/plugins/HGCalHitPartial.cc new file mode 100644 index 0000000000000..cffd562acf7e0 --- /dev/null +++ b/SimG4CMS/Calo/plugins/HGCalHitPartial.cc @@ -0,0 +1,103 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" + +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" +#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h" + +#include "Geometry/CaloTopology/interface/HGCalTopology.h" +#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" +#include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" +#include "Geometry/HGCalCommonData/interface/HGCalParameters.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" + +#include +#include + +class HGcalHitPartial : public edm::one::EDAnalyzer<> { +public: + HGcalHitPartial(const edm::ParameterSet& ps); + ~HGcalHitPartial() override = default; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +protected: + void analyze(edm::Event const&, edm::EventSetup const&) override; + void beginJob() override {} + void endJob() override {} + +private: + const std::string g4Label_, caloHitSource_, nameSense_; + const edm::EDGetTokenT tok_calo_; + const edm::ESGetToken geomToken_; +}; + +HGcalHitPartial::HGcalHitPartial(const edm::ParameterSet& ps) + : g4Label_(ps.getParameter("moduleLabel")), + caloHitSource_(ps.getParameter("caloHitSource")), + nameSense_(ps.getParameter("nameSense")), + tok_calo_(consumes(edm::InputTag(g4Label_, caloHitSource_))), + geomToken_(esConsumes(edm::ESInputTag{"", nameSense_})) { + edm::LogVerbatim("HGCalSim") << "Test Hit ID using SimHits for " << nameSense_ << " with module Label: " << g4Label_ + << " Hits: " << caloHitSource_; +} + +void HGcalHitPartial::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("moduleLabel", "g4SimHits"); + desc.add("caloHitSource", "HGCHitsEE"); + desc.add("nameSense", "HGCalEESensitive"); + descriptions.add("hgcalHitPartialEE", desc); +} + +void HGcalHitPartial::analyze(const edm::Event& e, const edm::EventSetup& iS) { + // get hcalGeometry + const HGCalGeometry* geom = &iS.getData(geomToken_); + const HGCalDDDConstants& hgc = geom->topology().dddConstants(); + // get the hit collection + const edm::Handle& hitsCalo = e.getHandle(tok_calo_); + bool getHits = (hitsCalo.isValid()); + uint32_t nhits = (getHits) ? hitsCalo->size() : 0; + uint32_t good(0), allSi(0), all(0); + edm::LogVerbatim("HGCalSim") << "HGcalHitPartial: Input flags Hits " << getHits << " with " << nhits << " hits"; + + if (getHits) { + std::vector hits; + hits.insert(hits.end(), hitsCalo->begin(), hitsCalo->end()); + if (!hits.empty()) { + // Loop over all hits + for (auto hit : hits) { + ++all; + DetId id(hit.id()); + if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) { + ++allSi; + HGCSiliconDetId hid(id); + const auto& info = hgc.waferInfo(hid.layer(), hid.waferU(), hid.waferV()); + // Only partial wafers + if (info.part != HGCalTypes::WaferFull) { + ++good; + GlobalPoint pos = geom->getPosition(id); + edm::LogVerbatim("HGCalSim") << "Hit[" << all << ":" << allSi << ":" << good << "]" << HGCSiliconDetId(id) + << " Wafer Type:Part:Orient:Cassette " << info.type << ":" << info.part << ":" + << info.orient << ":" << info.cassette << " at (" << pos.x() << ", " << pos.y() + << ", " << pos.z() << ")"; + } + } + } + } + } + edm::LogVerbatim("HGCalSim") << "Total hits = " << all << ":" << nhits << " Good DetIds = " << allSi << ":" << good; +} + +//define this as a plug-in +DEFINE_FWK_MODULE(HGcalHitPartial); diff --git a/SimG4CMS/Calo/python/hgcalHitPartial_cff.py b/SimG4CMS/Calo/python/hgcalHitPartial_cff.py new file mode 100644 index 0000000000000..44e155439ad26 --- /dev/null +++ b/SimG4CMS/Calo/python/hgcalHitPartial_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +from SimG4CMS.Calo.hgcalHitPartialEE_cfi import * + +hgcalHitPartialHE = hgcalHitPartialEE.clone( + nameSense = "HGCalHESiliconSensitive", + caloHitSource = "HGCHitsHEfront" +) diff --git a/SimG4CMS/Calo/test/python/runHGC7_cfg.py b/SimG4CMS/Calo/test/python/runHGC7_cfg.py new file mode 100644 index 0000000000000..305f15f7e5550 --- /dev/null +++ b/SimG4CMS/Calo/test/python/runHGC7_cfg.py @@ -0,0 +1,74 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Era_Phase2C11_cff import Phase2C11 + +process = cms.Process("PROD",Phase2C11) +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") +process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") +process.load("Configuration.Geometry.GeometryExtended2026D92Reco_cff") +process.load("Configuration.StandardSequences.MagneticField_cff") +process.load("Configuration.EventContent.EventContent_cff") +process.load('Configuration.StandardSequences.Generator_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('SimG4CMS.Calo.hgcalHitPartial_cff') +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T21', '') + +if hasattr(process,'MessageLogger'): + process.MessageLogger.HGCalGeom=dict() + process.MessageLogger.HGCalSim=dict() + process.MessageLogger.CaloSim=dict() + +process.load("IOMC.RandomEngine.IOMC_cff") +process.RandomNumberGeneratorService.generator.initialSeed = 456789 +process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 +process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 + +process.Timing = cms.Service("Timing") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(25) +) + +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(1), + firstEvent = cms.untracked.uint32(1) +) + +process.generator = cms.EDProducer("FlatRandomEGunProducer", + PGunParameters = cms.PSet( + PartID = cms.vint32(211), + MinEta = cms.double(1.50), + MaxEta = cms.double(3.00), + MinPhi = cms.double(-3.1415926), + MaxPhi = cms.double(-1.5707963), + MinE = cms.double(100.00), + MaxE = cms.double(100.00) + ), + Verbosity = cms.untracked.int32(0), + AddAntiParticle = cms.bool(True) +) + +process.output = cms.OutputModule("PoolOutputModule", + process.FEVTSIMEventContent, + fileName = cms.untracked.string('hgcV17.root') +) + +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.analysis_step = cms.Path(process.hgcalHitPartialEE+process.hgcalHitPartialHE) +process.out_step = cms.EndPath(process.output) + +process.g4SimHits.Physics.type = 'SimG4Core/Physics/FTFP_BERT_EMM' + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step, + process.simulation_step, + process.analysis_step, + process.out_step + ) + +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path)._seq = process.generator * getattr(process,path)._seq