From 2ad424c37580304d74dcb5ad9c17203e43f3c84d Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 8 Aug 2014 14:23:40 +0200 Subject: [PATCH] Debug HGCal geometry --- Geometry/CaloTopology/src/HGCalTopology.cc | 4 +- .../HGCalCommonData/src/HGCalDDDConstants.cc | 5 + .../HGCSimProducers/interface/HGCDigitizer.h | 4 + .../HGCSimProducers/src/HGCDigitizer.cc | 18 ++- .../HGCSimProducers/test/BuildFile.xml | 13 ++ .../HGCSimProducers/test/HGCalDigiTester.cc | 121 ++++++++++++++++++ .../HGCSimProducers/test/testHGCalDigi_cfg.py | 120 +++++++++++++++++ SimG4CMS/Calo/interface/HGCNumberingScheme.h | 4 +- SimG4CMS/Calo/interface/HGCSD.h | 2 +- SimG4CMS/Calo/src/HGCNumberingScheme.cc | 17 ++- SimG4CMS/Calo/src/HGCSD.cc | 7 +- .../MixingModule/python/hgcalDigitizer_cfi.py | 6 + 12 files changed, 303 insertions(+), 18 deletions(-) create mode 100644 SimCalorimetry/HGCSimProducers/test/BuildFile.xml create mode 100644 SimCalorimetry/HGCSimProducers/test/HGCalDigiTester.cc create mode 100644 SimCalorimetry/HGCSimProducers/test/testHGCalDigi_cfg.py diff --git a/Geometry/CaloTopology/src/HGCalTopology.cc b/Geometry/CaloTopology/src/HGCalTopology.cc index aaa48be2cb628..ba1ad69719ac2 100644 --- a/Geometry/CaloTopology/src/HGCalTopology.cc +++ b/Geometry/CaloTopology/src/HGCalTopology.cc @@ -39,7 +39,7 @@ DetId HGCalTopology::denseId2detId(uint32_t hi) const { id_.zside = ((int)(hi) HGCalDDDConstants::simToReco(int cell, int lay, for (int iky=0; iky(kx,depth); } diff --git a/SimCalorimetry/HGCSimProducers/interface/HGCDigitizer.h b/SimCalorimetry/HGCSimProducers/interface/HGCDigitizer.h index 23bc55555133e..392ecd01479e7 100644 --- a/SimCalorimetry/HGCSimProducers/interface/HGCDigitizer.h +++ b/SimCalorimetry/HGCSimProducers/interface/HGCDigitizer.h @@ -79,6 +79,10 @@ private : //subdetector id ForwardSubdetector mySubDet_; + + //misc switches + bool useAllChannels_; + int verbosity_; }; #endif diff --git a/SimCalorimetry/HGCSimProducers/src/HGCDigitizer.cc b/SimCalorimetry/HGCSimProducers/src/HGCDigitizer.cc index ca44ac7a683b9..7139d69ccd4a2 100644 --- a/SimCalorimetry/HGCSimProducers/src/HGCDigitizer.cc +++ b/SimCalorimetry/HGCSimProducers/src/HGCDigitizer.cc @@ -26,6 +26,8 @@ HGCDigitizer::HGCDigitizer(const edm::ParameterSet& ps) : maxSimHitsAccTime_ = ps.getParameter< uint32_t >("maxSimHitsAccTime"); bxTime_ = ps.getParameter< int32_t >("bxTime"); digitizationType_ = ps.getParameter< uint32_t >("digitizationType"); + useAllChannels_ = ps.getParameter< bool >("useAllChannels"); + verbosity_ = ps.getUntrackedParameter< int32_t >("verbosity",0); //get the random number generator edm::Service rng; @@ -153,6 +155,12 @@ void HGCDigitizer::accumulate(edm::Handle const &hits, i (uint32_t)HGCEEDetId(mySubDet_,simId.zside(),layer,simId.sector(),simId.subsector(),cell): (uint32_t)HGCHEDetId(mySubDet_,simId.zside(),layer,simId.sector(),simId.subsector(),cell) ); + if (verbosity_>0) { + if (producesEEDigis()) + std::cout << "HGCDigitizer: i/p " << simId << " o/p " << HGCEEDetId(id) << std::endl; + else + std::cout << "HGCDigitizer: i/p " << simId << " o/p " << HGCHEDetId(id) << std::endl; + } //hit time: [time()]=ns [zPos]=cm [CLHEP::c_light]=mm/ns //for now accumulate in buckets of bxTime_ int itime=floor( (hit_it->time()-zPos/(0.1*CLHEP::c_light))/bxTime_); @@ -185,14 +193,18 @@ void HGCDigitizer::accumulate(edm::Handle const &hits, i baseData.fill(0.); const std::vector &validIds=geom->getValidDetIds(); int nadded(0); - for(std::vector::const_iterator it=validIds.begin(); it!=validIds.end(); it++) - { + if (useAllChannels_) { + for(std::vector::const_iterator it=validIds.begin(); it!=validIds.end(); it++) { uint32_t id(it->rawId()); if(simHitAccumulator_->find(id)!=simHitAccumulator_->end()) continue; simHitAccumulator_->insert( std::make_pair(id,baseData) ); nadded++; } - std::cout << "Added " << nadded << " detIds without " << hitCollection_ << " in first event processed" << std::endl; + } + if (verbosity_ > 0) + std::cout << "HGCDigitizer:Added " << nadded << ":" << validIds.size() + << " detIds without " << hitCollection_ + << " in first event processed" << std::endl; checkValidDetIds_=false; } diff --git a/SimCalorimetry/HGCSimProducers/test/BuildFile.xml b/SimCalorimetry/HGCSimProducers/test/BuildFile.xml new file mode 100644 index 0000000000000..3d40d9de3b393 --- /dev/null +++ b/SimCalorimetry/HGCSimProducers/test/BuildFile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/SimCalorimetry/HGCSimProducers/test/HGCalDigiTester.cc b/SimCalorimetry/HGCSimProducers/test/HGCalDigiTester.cc new file mode 100644 index 0000000000000..6efb8616efeaf --- /dev/null +++ b/SimCalorimetry/HGCSimProducers/test/HGCalDigiTester.cc @@ -0,0 +1,121 @@ +#include +#include +#include + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "Geometry/FCalGeometry/interface/HGCalGeometry.h" +#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" +#include "DataFormats/ForwardDetId/interface/HGCEEDetId.h" +#include "DataFormats/ForwardDetId/interface/HGCHEDetId.h" +#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" + +class HGCalDigiTester : public edm::EDAnalyzer { +public: + explicit HGCalDigiTester(const edm::ParameterSet& ); + ~HGCalDigiTester(); + + + virtual void analyze(const edm::Event&, const edm::EventSetup& ); + +private: + // ----------member data --------------------------- +}; + +HGCalDigiTester::HGCalDigiTester(const edm::ParameterSet& ) {} + + +HGCalDigiTester::~HGCalDigiTester() {} + +void HGCalDigiTester::analyze(const edm::Event& iEvent, + const edm::EventSetup& iSetup ) { + + std::string name; + edm::ESHandle geom; + + name = "HGCalEESensitive"; + iSetup.get().get(name,geom); + if (geom.isValid()) { + edm::Handle digis; + iEvent.getByLabel(edm::InputTag("mix","HGCDigisEE"),digis); + if (digis.isValid()) { + std::cout << "HGCEE with " << (*digis).size() << " elements" + << std::endl; + for (unsigned int k=0; k < (*digis).size(); ++k) { + HGCEEDetId id = (*digis)[k].id(); + GlobalPoint global = (*geom).getPosition(id); + HGCEEDetId idc = (HGCEEDetId)((*geom).getClosestCell(global)); + std::cout << "HGCalDigiTester:ID " << id << " global (" << global.x() + << ", " << global.y() << ", " << global.z() << ") new ID " + << idc << std::endl; + } + } else { + std::cout << "No valid collection for HGCEE" << std::endl; + } + } else { + std::cout << "Cannot get valid HGCalGeometry Object for " << name + << std::endl; + } + + name = "HGCalHESiliconSensitive"; + iSetup.get().get(name,geom); + if (geom.isValid()) { + edm::Handle digis; + iEvent.getByLabel(edm::InputTag("mix","HGCDigisHEfront"),digis); + if (digis.isValid()) { + std::cout << "HGCHEfront with " << (*digis).size() << " elements" + << std::endl; + for (unsigned int k=0; k < (*digis).size(); ++k) { + HGCHEDetId id = (*digis)[k].id(); + GlobalPoint global = (*geom).getPosition(id); + HGCHEDetId idc = (HGCHEDetId)((*geom).getClosestCell(global)); + std::cout << "HGCalDigiTester:ID " << id << " global (" << global.x() + << ", " << global.y() << ", " << global.z() << ") new ID " + << idc << std::endl; + } + } else { + std::cout << "No valid collection for HGCHEfront" << std::endl; + } + } else { + std::cout << "Cannot get valid HGCalGeometry Object for " << name + << std::endl; + } + + name = "HGCalHEScintillatorSensitive"; + iSetup.get().get(name,geom); + if (geom.isValid()) { + edm::Handle digis; + iEvent.getByLabel(edm::InputTag("mix","HGCDigisHEback"),digis); + if (digis.isValid()) { + std::cout << "HGCHEback with " << (*digis).size() << " elements" + << std::endl; + for (unsigned int k=0; k < (*digis).size(); ++k) { + HGCHEDetId id = (*digis)[k].id(); + GlobalPoint global = (*geom).getPosition(id); + HGCHEDetId idc = (HGCHEDetId)((*geom).getClosestCell(global)); + std::cout << "HGCalDigiTester:ID " << id << " global (" << global.x() + << ", " << global.y() << ", " << global.z() << ") new ID " + << idc << std::endl; + } + } else { + std::cout << "No valid collection for HGCHEback" << std::endl; + } + } else { + std::cout << "Cannot get valid HGCalGeometry Object for " << name + << std::endl; + } + +} + + +//define this as a plug-in +DEFINE_FWK_MODULE(HGCalDigiTester); diff --git a/SimCalorimetry/HGCSimProducers/test/testHGCalDigi_cfg.py b/SimCalorimetry/HGCSimProducers/test/testHGCalDigi_cfg.py new file mode 100644 index 0000000000000..60af896fd7af5 --- /dev/null +++ b/SimCalorimetry/HGCSimProducers/test/testHGCalDigi_cfg.py @@ -0,0 +1,120 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('SIMDIGI') + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023HGCalMuonReco_cff') +process.load('Configuration.Geometry.GeometryExtended2023HGCalMuon_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedGauss_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string('$Revision: 1.20 $'), + annotation = cms.untracked.string('SingleElectronPt10_cfi nevts:10'), + name = cms.untracked.string('Applications') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + fileName = cms.untracked.string('file:junk.root'), + dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW') + ), + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + PGunParameters = cms.PSet( + MaxPt = cms.double(10.01), + MinPt = cms.double(9.99), + PartID = cms.vint32(13), + MaxEta = cms.double(2.5), + MaxPhi = cms.double(3.14159265359), + MinEta = cms.double(-2.5), + MinPhi = cms.double(-3.14159265359) + ), + Verbosity = cms.untracked.int32(0), + psethack = cms.string('single electron pt 10'), + AddAntiParticle = cms.bool(True), + firstRun = cms.untracked.uint32(1) +) + +process.mix.digitizers = cms.PSet(process.theDigitizersValid) + +process.DigiTester = cms.EDAnalyzer("HGCalDigiTester") + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.digitisation_step = cms.Path(process.pdigi_valid) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.digi2raw_step = cms.Path(process.DigiToRaw) +process.digitest_step = cms.Path(process.DigiTester) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1simulation_step,process.digi2raw_step,process.digitest_step) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path)._seq = process.generator * getattr(process,path)._seq + +# customisation of the process. + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.combinedCustoms +from SLHCUpgradeSimulations.Configuration.combinedCustoms import cust_2023HGCalMuon + +#call to customisation function cust_2023HGCalMuon imported from SLHCUpgradeSimulations.Configuration.combinedCustoms +process = cust_2023HGCalMuon(process) + +# End of customisation functions + +process.g4SimHits.HGCSD.Verbosity = 1 +process.mix.digitizers.hgceeDigitizer.useAllChannels = False +process.mix.digitizers.hgceeDigitizer.verbosity = 1 +process.mix.digitizers.hgchefrontDigitizer.useAllChannels = False +process.mix.digitizers.hgchefrontDigitizer.verbosity = 1 +process.mix.digitizers.hgchebackDigitizer.useAllChannels = False +process.mix.digitizers.hgchebackDigitizer.verbosity = 1 + + diff --git a/SimG4CMS/Calo/interface/HGCNumberingScheme.h b/SimG4CMS/Calo/interface/HGCNumberingScheme.h index 4481e1ac1ad08..bbdd07c2f31f6 100644 --- a/SimG4CMS/Calo/interface/HGCNumberingScheme.h +++ b/SimG4CMS/Calo/interface/HGCNumberingScheme.h @@ -21,7 +21,8 @@ class HGCNumberingScheme : public CaloNumberingScheme { enum HGCNumberingParameters { HGCCellSize }; - HGCNumberingScheme(const DDCompactView & cpv, std::string& name, bool check); + HGCNumberingScheme(const DDCompactView & cpv, std::string& name, bool check, + int verbose); virtual ~HGCNumberingScheme(); @@ -50,6 +51,7 @@ class HGCNumberingScheme : public CaloNumberingScheme { HGCNumberingScheme(); bool check_; + int verbosity; HGCalDDDConstants *hgcons; }; diff --git a/SimG4CMS/Calo/interface/HGCSD.h b/SimG4CMS/Calo/interface/HGCSD.h index 61397cfd6ac82..97e1b9f03f5ce 100644 --- a/SimG4CMS/Calo/interface/HGCSD.h +++ b/SimG4CMS/Calo/interface/HGCSD.h @@ -44,7 +44,7 @@ class HGCSD : public CaloSD { int setTrackID(G4Step * step); HGCNumberingScheme* numberingScheme; - G4int mumPDG, mupPDG; + G4int verbosity, mumPDG, mupPDG; double eminHit; ForwardSubdetector myFwdSubdet_; }; diff --git a/SimG4CMS/Calo/src/HGCNumberingScheme.cc b/SimG4CMS/Calo/src/HGCNumberingScheme.cc index 04ca7eff4be20..4130177a2cbe6 100644 --- a/SimG4CMS/Calo/src/HGCNumberingScheme.cc +++ b/SimG4CMS/Calo/src/HGCNumberingScheme.cc @@ -9,11 +9,10 @@ #include "CLHEP/Units/GlobalSystemOfUnits.h" #include -//#define DebugLog - HGCNumberingScheme::HGCNumberingScheme(const DDCompactView & cpv, - std::string & name, bool check) : - CaloNumberingScheme(0), check_(check), + std::string & name, bool check, + int verbose) : + CaloNumberingScheme(0), check_(check), verbosity(verbose), hgcons(new HGCalDDDConstants(cpv,name)) { edm::LogInfo("HGCSim") << "Creating HGCNumberingScheme for " << name; } @@ -45,11 +44,11 @@ uint32_t HGCNumberingScheme::getUnitID(ForwardSubdetector &subdet, int &layer, i << "," << pos.y() << "," << pos.z() << ")"; } } -#ifdef DebugLog - std::cout << "HGCNumberingScheme::i/p " << subdet << ":" << layer << ":" - << sector << ":" << iz << ":" << pos << " o/p " << phiSector << ":" - << icell << ":" << std::hex << index << std::dec << std::endl; -#endif + if (verbosity > 0) + std::cout << "HGCNumberingScheme::i/p " << subdet << ":" << layer << ":" + << sector << ":" << iz << ":" << pos << " o/p " << phiSector + << ":" << icell << ":" << std::hex << index << std::dec << " " + << HGCalDetId(index) << std::endl; return index; } diff --git a/SimG4CMS/Calo/src/HGCSD.cc b/SimG4CMS/Calo/src/HGCSD.cc index 3dd67147d02c6..f77dd1f17d9d6 100644 --- a/SimG4CMS/Calo/src/HGCSD.cc +++ b/SimG4CMS/Calo/src/HGCSD.cc @@ -39,6 +39,7 @@ HGCSD::HGCSD(G4String name, const DDCompactView & cpv, edm::ParameterSet m_HGC = p.getParameter("HGCSD"); eminHit = m_HGC.getParameter("EminHit")*MeV; bool checkID = m_HGC.getUntrackedParameter("CheckID", false); + verbosity = m_HGC.getUntrackedParameter("Verbosity",0); //this is defined in the hgcsens.xml G4String myName(this->nameOfSD()); @@ -67,7 +68,7 @@ HGCSD::HGCSD(G4String name, const DDCompactView & cpv, #endif edm::LogInfo("HGCSim") << "HGCSD:: Threshold for storing hits: " << eminHit; - numberingScheme = new HGCNumberingScheme(cpv,nameX,checkID); + numberingScheme = new HGCNumberingScheme(cpv,nameX,checkID,verbosity); } HGCSD::~HGCSD() { @@ -122,7 +123,9 @@ uint32_t HGCSD::setDetUnitId(G4Step * aStep) { int layer = touch->GetReplicaNumber(0); int module = touch->GetReplicaNumber(1); - + if (verbosity > 0) + std::cout << "HGCSD::Global " << hitPoint << " local " << localpos + << std::endl; return setDetUnitId (subdet, layer, module, iz, localpos); } diff --git a/SimGeneral/MixingModule/python/hgcalDigitizer_cfi.py b/SimGeneral/MixingModule/python/hgcalDigitizer_cfi.py index 9619a70279fb5..0f14120e228b8 100644 --- a/SimGeneral/MixingModule/python/hgcalDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/hgcalDigitizer_cfi.py @@ -10,6 +10,8 @@ bxTime = cms.int32(25), digitizationType = cms.uint32(0), makeDigiSimLinks = cms.bool(False), + useAllChannels = cms.bool(True), + verbosity = cms.untracked.int32(0), digiCfg = cms.PSet( mipInKeV = cms.double(55.1), lsbInMIP = cms.double(0.25), mip2noise = cms.double(7.0), @@ -26,6 +28,8 @@ bxTime = cms.int32(25), digitizationType = cms.uint32(0), makeDigiSimLinks = cms.bool(False), + useAllChannels = cms.bool(True), + verbosity = cms.untracked.int32(0), digiCfg = cms.PSet( mipInKeV = cms.double(85.0), lsbInMIP = cms.double(0.25), mip2noise = cms.double(7.0), @@ -42,6 +46,8 @@ bxTime = cms.int32(25), digitizationType = cms.uint32(1), makeDigiSimLinks = cms.bool(False), + useAllChannels = cms.bool(True), + verbosity = cms.untracked.int32(0), digiCfg = cms.PSet( mipInKeV = cms.double(1498.4), lsbInMIP = cms.double(0.25), mip2noise = cms.double(5.0),