From cacab0a17f5e5831430a1cfe3202c668bfe0d41d Mon Sep 17 00:00:00 2001 From: Eric Cano Date: Tue, 27 Feb 2024 13:26:24 +0100 Subject: [PATCH 001/301] Removes duplicate/unneeded entries in serialization XML of test objects. --- DataFormats/PortableTestObjects/src/classes_def.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/DataFormats/PortableTestObjects/src/classes_def.xml b/DataFormats/PortableTestObjects/src/classes_def.xml index f2bcf4311fcdf..fbcd940f37203 100644 --- a/DataFormats/PortableTestObjects/src/classes_def.xml +++ b/DataFormats/PortableTestObjects/src/classes_def.xml @@ -1,6 +1,5 @@ - @@ -8,17 +7,10 @@ - - - - - - - From 4f779dee52482f416856a50e0454ccc2e668911a Mon Sep 17 00:00:00 2001 From: Eric Cano Date: Tue, 12 Mar 2024 11:08:26 +0100 Subject: [PATCH 002/301] Removes redundant class declration for dictionary generation. --- DataFormats/PortableTestObjects/src/classes_def.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/DataFormats/PortableTestObjects/src/classes_def.xml b/DataFormats/PortableTestObjects/src/classes_def.xml index fbcd940f37203..87fbdfc447f80 100644 --- a/DataFormats/PortableTestObjects/src/classes_def.xml +++ b/DataFormats/PortableTestObjects/src/classes_def.xml @@ -1,5 +1,4 @@ - From d6fdbefe90f63e2eff2f757c98ec04aa714723f9 Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 29 Nov 2023 10:52:19 +0100 Subject: [PATCH 003/301] enable CaloParticles in the barrel for Phase2 --- .../python/caloTruthProducer_cfi.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py index 0696591ad7b32..5cc586f2b3759 100644 --- a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py +++ b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py @@ -18,12 +18,6 @@ cms.InputTag('g4SimHits','HGCHitsHEfront'), cms.InputTag('g4SimHits','HGCHitsHEback') ), -# hcal = cms.VInputTag(cms.InputTag('g4SimHits','HcalHits')), -# ecal = cms.VInputTag( -# cms.InputTag('g4SimHits','EcalHitsEE'), -# cms.InputTag('g4SimHits','EcalHitsEB'), -# cms.InputTag('g4SimHits','EcalHitsES') -# ) ), simTrackCollection = cms.InputTag('g4SimHits'), simVertexCollection = cms.InputTag('g4SimHits'), @@ -59,3 +53,20 @@ from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(caloParticles, cms.PSet()) # don't allow this to run in fastsim +from Configuration.Eras.Modifier_phase2_common_cff import phase2_common +phase2_common.toModify( + caloParticles, + simHitCollections = cms.PSet( + hgc = cms.VInputTag( + cms.InputTag('g4SimHits', 'HGCHitsEE'), + cms.InputTag('g4SimHits', 'HGCHitsHEfront'), + cms.InputTag('g4SimHits', 'HGCHitsHEback'), + ), + hcal = cms.VInputTag(cms.InputTag('g4SimHits', 'HcalHits')), + ecal = cms.VInputTag( + cms.InputTag('g4SimHits', 'EcalHitsEB') + ) + ) +) + + From 7cadbac08ba0eed385e3c204c63c979631fd48f5 Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 29 Nov 2023 10:53:55 +0100 Subject: [PATCH 004/301] switch to ticl namespace --- .../TICL/plugins/SimTrackstersProducer.cc | 4 +- RecoHGCal/TICL/plugins/TICLDumper.cc | 60 ++++++++--------- .../LCToCPAssociatorByEnergyScoreImpl.cc | 31 ++++----- .../LCToCPAssociatorByEnergyScoreImpl.h | 20 +++--- .../LCToCPAssociatorByEnergyScoreProducer.cc | 4 +- .../plugins/LCToCPAssociatorEDProducer.cc | 18 +++--- .../LCToSCAssociatorByEnergyScoreImpl.cc | 26 ++++---- .../LCToSCAssociatorByEnergyScoreImpl.h | 16 ++--- .../LCToSCAssociatorByEnergyScoreProducer.cc | 4 +- .../plugins/LCToSCAssociatorEDProducer.cc | 19 +++--- .../LCToSimTSAssociatorByEnergyScoreImpl.cc | 16 ++--- .../LCToSimTSAssociatorByEnergyScoreImpl.h | 14 ++-- ...CToSimTSAssociatorByEnergyScoreProducer.cc | 4 +- .../plugins/LCToSimTSAssociatorEDProducer.cc | 34 +++++----- .../TSToSCAssociatorByEnergyScoreImpl.cc | 26 ++++---- .../TSToSCAssociatorByEnergyScoreImpl.h | 26 ++++---- .../TSToSCAssociatorByEnergyScoreProducer.cc | 4 +- .../plugins/TSToSCAssociatorEDProducer.cc | 18 +++--- .../TSToSimTSAssociatorByEnergyScoreImpl.cc | 20 +++--- .../TSToSimTSAssociatorByEnergyScoreImpl.h | 18 +++--- ...SToSimTSAssociatorByEnergyScoreProducer.cc | 4 +- .../plugins/TSToSimTSAssociatorEDProducer.cc | 18 +++--- ...ToSimTSHitLCAssociatorByEnergyScoreImpl.cc | 14 ++-- ...SToSimTSHitLCAssociatorByEnergyScoreImpl.h | 20 +++--- ...mTSHitLCAssociatorByEnergyScoreProducer.cc | 4 +- .../TSToSimTSHitLCAssociatorEDProducer.cc | 20 +++--- .../LayerClusterToCaloParticleAssociator.h | 14 ++-- ...rClusterToCaloParticleAssociatorBaseImpl.h | 12 ++-- .../LayerClusterToSimClusterAssociator.h | 14 ++-- ...yerClusterToSimClusterAssociatorBaseImpl.h | 8 +-- .../LayerClusterToSimTracksterAssociator.h | 18 +++--- ...rClusterToSimTracksterAssociatorBaseImpl.h | 16 ++--- .../TracksterToSimClusterAssociator.h | 18 +++--- .../TracksterToSimClusterAssociatorBaseImpl.h | 18 +++--- .../TracksterToSimTracksterAssociator.h | 20 +++--- ...racksterToSimTracksterAssociatorBaseImpl.h | 8 +-- .../TracksterToSimTracksterHitLCAssociator.h | 38 ++++++----- ...terToSimTracksterHitLCAssociatorBaseImpl.h | 18 +++--- .../LayerClusterToCaloParticleAssociator.cc | 4 +- ...ClusterToCaloParticleAssociatorBaseImpl.cc | 12 ++-- .../src/LayerClusterToSimClusterAssociator.cc | 4 +- ...erClusterToSimClusterAssociatorBaseImpl.cc | 12 ++-- .../LayerClusterToSimTracksterAssociator.cc | 4 +- ...ClusterToSimTracksterAssociatorBaseImpl.cc | 20 +++--- .../src/TracksterToSimClusterAssociator.cc | 4 +- ...TracksterToSimClusterAssociatorBaseImpl.cc | 12 ++-- .../src/TracksterToSimTracksterAssociator.cc | 4 +- ...acksterToSimTracksterAssociatorBaseImpl.cc | 12 ++-- .../TracksterToSimTracksterHitLCAssociator.cc | 4 +- ...erToSimTracksterHitLCAssociatorBaseImpl.cc | 16 ++--- .../Associations/src/classes_def.xml | 64 +++++++++---------- .../interface/HGCalValidator.h | 8 +-- .../interface/HGVHistoProducerAlgo.h | 16 ++--- .../HGCalValidation/plugins/HGCalValidator.cc | 16 ++--- .../src/HGVHistoProducerAlgo.cc | 16 ++--- 55 files changed, 441 insertions(+), 451 deletions(-) diff --git a/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc b/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc index c062f36a48fa8..4304bf8300152 100644 --- a/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc +++ b/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc @@ -85,8 +85,8 @@ class SimTrackstersProducer : public edm::stream::EDProducer<> { const edm::EDGetTokenT> simclusters_token_; const edm::EDGetTokenT> caloparticles_token_; - const edm::EDGetTokenT associatorMapSimClusterToReco_token_; - const edm::EDGetTokenT associatorMapCaloParticleToReco_token_; + const edm::EDGetTokenT associatorMapSimClusterToReco_token_; + const edm::EDGetTokenT associatorMapCaloParticleToReco_token_; const edm::ESGetToken geom_token_; hgcal::RecHitTools rhtools_; const float fractionCut_; diff --git a/RecoHGCal/TICL/plugins/TICLDumper.cc b/RecoHGCal/TICL/plugins/TICLDumper.cc index dc0c5741d42fb..2159bd2fc09db 100644 --- a/RecoHGCal/TICL/plugins/TICLDumper.cc +++ b/RecoHGCal/TICL/plugins/TICLDumper.cc @@ -103,16 +103,16 @@ class TICLDumper : public edm::one::EDAnalyzer> simTracksters_CP_token_; const edm::EDGetTokenT> simTracksters_PU_token_; const edm::EDGetTokenT> simTICLCandidate_token_; - const edm::EDGetTokenT tsRecoToSimSC_token_; - const edm::EDGetTokenT tsSimToRecoSC_token_; - const edm::EDGetTokenT tsRecoToSimCP_token_; - const edm::EDGetTokenT tsSimToRecoCP_token_; - const edm::EDGetTokenT MergeRecoToSimSC_token_; - const edm::EDGetTokenT MergeSimToRecoSC_token_; - const edm::EDGetTokenT MergeRecoToSimCP_token_; - const edm::EDGetTokenT MergeSimToRecoCP_token_; - const edm::EDGetTokenT MergeRecoToSimPU_token_; - const edm::EDGetTokenT MergeSimToRecoPU_token_; + const edm::EDGetTokenT tsRecoToSimSC_token_; + const edm::EDGetTokenT tsSimToRecoSC_token_; + const edm::EDGetTokenT tsRecoToSimCP_token_; + const edm::EDGetTokenT tsSimToRecoCP_token_; + const edm::EDGetTokenT MergeRecoToSimSC_token_; + const edm::EDGetTokenT MergeSimToRecoSC_token_; + const edm::EDGetTokenT MergeRecoToSimCP_token_; + const edm::EDGetTokenT MergeSimToRecoCP_token_; + const edm::EDGetTokenT MergeRecoToSimPU_token_; + const edm::EDGetTokenT MergeSimToRecoPU_token_; const edm::EDGetTokenT> simclusters_token_; const edm::EDGetTokenT> caloparticles_token_; @@ -739,24 +739,24 @@ TICLDumper::TICLDumper(const edm::ParameterSet& ps) simTICLCandidate_token_( consumes>(ps.getParameter("simTICLCandidates"))), tsRecoToSimSC_token_( - consumes(ps.getParameter("recoToSimAssociatorSC"))), + consumes(ps.getParameter("recoToSimAssociatorSC"))), tsSimToRecoSC_token_( - consumes(ps.getParameter("simToRecoAssociatorSC"))), + consumes(ps.getParameter("simToRecoAssociatorSC"))), tsRecoToSimCP_token_( - consumes(ps.getParameter("recoToSimAssociatorCP"))), + consumes(ps.getParameter("recoToSimAssociatorCP"))), tsSimToRecoCP_token_( - consumes(ps.getParameter("simToRecoAssociatorCP"))), - MergeRecoToSimSC_token_(consumes( + consumes(ps.getParameter("simToRecoAssociatorCP"))), + MergeRecoToSimSC_token_(consumes( ps.getParameter("MergerecoToSimAssociatorSC"))), - MergeSimToRecoSC_token_(consumes( + MergeSimToRecoSC_token_(consumes( ps.getParameter("MergesimToRecoAssociatorSC"))), - MergeRecoToSimCP_token_(consumes( + MergeRecoToSimCP_token_(consumes( ps.getParameter("MergerecoToSimAssociatorCP"))), - MergeSimToRecoCP_token_(consumes( + MergeSimToRecoCP_token_(consumes( ps.getParameter("MergesimToRecoAssociatorCP"))), - MergeRecoToSimPU_token_(consumes( + MergeRecoToSimPU_token_(consumes( ps.getParameter("MergerecoToSimAssociatorPU"))), - MergeSimToRecoPU_token_(consumes( + MergeSimToRecoPU_token_(consumes( ps.getParameter("MergesimToRecoAssociatorPU"))), simclusters_token_(consumes(ps.getParameter("simclusters"))), caloparticles_token_(consumes(ps.getParameter("caloparticles"))), @@ -1198,51 +1198,51 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) const auto& simTICLCandidates = *simTICLCandidates_h; // trackster reco to sim SC - edm::Handle tsRecoToSimSC_h; + edm::Handle tsRecoToSimSC_h; event.getByToken(tsRecoToSimSC_token_, tsRecoToSimSC_h); auto const& tsRecoSimSCMap = *tsRecoToSimSC_h; // sim simTrackster SC to reco trackster - edm::Handle tsSimToRecoSC_h; + edm::Handle tsSimToRecoSC_h; event.getByToken(tsSimToRecoSC_token_, tsSimToRecoSC_h); auto const& tsSimToRecoSCMap = *tsSimToRecoSC_h; // trackster reco to sim CP - edm::Handle tsRecoToSimCP_h; + edm::Handle tsRecoToSimCP_h; event.getByToken(tsRecoToSimCP_token_, tsRecoToSimCP_h); auto const& tsRecoSimCPMap = *tsRecoToSimCP_h; // sim simTrackster CP to reco trackster - edm::Handle tsSimToRecoCP_h; + edm::Handle tsSimToRecoCP_h; event.getByToken(tsSimToRecoCP_token_, tsSimToRecoCP_h); auto const& tsSimToRecoCPMap = *tsSimToRecoCP_h; - edm::Handle mergetsRecoToSimSC_h; + edm::Handle mergetsRecoToSimSC_h; event.getByToken(MergeRecoToSimSC_token_, mergetsRecoToSimSC_h); auto const& MergetsRecoSimSCMap = *mergetsRecoToSimSC_h; // sim simTrackster SC to reco trackster - edm::Handle mergetsSimToRecoSC_h; + edm::Handle mergetsSimToRecoSC_h; event.getByToken(MergeSimToRecoSC_token_, mergetsSimToRecoSC_h); auto const& MergetsSimToRecoSCMap = *mergetsSimToRecoSC_h; // trackster reco to sim CP - edm::Handle mergetsRecoToSimCP_h; + edm::Handle mergetsRecoToSimCP_h; event.getByToken(MergeRecoToSimCP_token_, mergetsRecoToSimCP_h); auto const& MergetsRecoSimCPMap = *mergetsRecoToSimCP_h; // sim simTrackster CP to reco trackster - edm::Handle mergetsSimToRecoCP_h; + edm::Handle mergetsSimToRecoCP_h; event.getByToken(MergeSimToRecoCP_token_, mergetsSimToRecoCP_h); auto const& MergetsSimToRecoCPMap = *mergetsSimToRecoCP_h; // trackster reco to sim PU - edm::Handle mergetsRecoToSimPU_h; + edm::Handle mergetsRecoToSimPU_h; event.getByToken(MergeRecoToSimPU_token_, mergetsRecoToSimPU_h); auto const& MergetsRecoSimPUMap = *mergetsRecoToSimPU_h; // sim simTrackster PU to reco trackster - edm::Handle mergetsSimToRecoPU_h; + edm::Handle mergetsSimToRecoPU_h; event.getByToken(MergeSimToRecoPU_token_, mergetsSimToRecoPU_h); auto const& MergetsSimToRecoPUMap = *mergetsSimToRecoPU_h; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index b482023a63b36..a7fdebbcf5790 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -18,7 +18,7 @@ LCToCPAssociatorByEnergyScoreImpl::LCToCPAssociatorByEnergyScoreImpl( layers_ = recHitTools_->lastLayerBH(); } -hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( +ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& cCCH, const edm::Handle& cPCH) const { // Get collections const auto& clusters = *cCCH.product(); @@ -34,7 +34,7 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( // among other the information to compute the CaloParticle-To-LayerCluster score. It is one of the two objects that // build the output of the makeConnections function. // cPOnLayer[cpId][layerId] - hgcal::caloParticleToLayerCluster cPOnLayer; + ticl::caloParticleToLayerCluster cPOnLayer; cPOnLayer.resize(nCaloParticles); for (unsigned int i = 0; i < nCaloParticles; ++i) { cPOnLayer[i].resize(layers_ * 2); @@ -51,7 +51,7 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( // contributed to that hit by storing the CaloParticle id and the fraction of the hit. Observe here // that all the different contributions of the same CaloParticle to a single hit (coming from their // internal SimClusters) are merged into a single entry with the fractions properly summed. - std::unordered_map> detIdToCaloParticleId_Map; + std::unordered_map> detIdToCaloParticleId_Map; for (const auto& cpId : cPIndices) { const SimClusterRefVector& simClusterRefVector = caloParticles[cpId].simClusters(); for (const auto& it_sc : simClusterRefVector) { @@ -65,12 +65,12 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (itcheck != hitMap_->end()) { auto hit_find_it = detIdToCaloParticleId_Map.find(hitid); if (hit_find_it == detIdToCaloParticleId_Map.end()) { - detIdToCaloParticleId_Map[hitid] = std::vector(); + detIdToCaloParticleId_Map[hitid] = std::vector(); detIdToCaloParticleId_Map[hitid].emplace_back(cpId, it_haf.second); } else { auto findHitIt = std::find(detIdToCaloParticleId_Map[hitid].begin(), detIdToCaloParticleId_Map[hitid].end(), - hgcal::detIdInfoInCluster{cpId, it_haf.second}); + ticl::detIdInfoInCluster{cpId, it_haf.second}); if (findHitIt != detIdToCaloParticleId_Map[hitid].end()) { findHitIt->fraction += it_haf.second; } else { @@ -137,12 +137,12 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( #endif // Fill detIdToLayerClusterId_Map and cpsInLayerCluster; update cPOnLayer - std::unordered_map> detIdToLayerClusterId_Map; + std::unordered_map> detIdToLayerClusterId_Map; // this contains the ids of the caloparticles contributing with at least one // hit to the layer cluster and the reconstruction error. To be returned // since this contains the information to compute the // LayerCluster-To-CaloParticle score. - hgcal::layerClusterToCaloParticle cpsInLayerCluster; + ticl::layerClusterToCaloParticle cpsInLayerCluster; cpsInLayerCluster.resize(nLayerClusters); for (unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) { @@ -155,10 +155,9 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( for (unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) { const auto rh_detid = hits_and_fractions[hitId].first; const auto rhFraction = hits_and_fractions[hitId].second; - auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid); if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) { - detIdToLayerClusterId_Map[rh_detid] = std::vector(); + detIdToLayerClusterId_Map[rh_detid] = std::vector(); } detIdToLayerClusterId_Map[rh_detid].emplace_back(lcId, rhFraction); @@ -358,7 +357,6 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( for (unsigned int i = 0; i < numberOfHitsInLC; ++i) { DetId rh_detid = hits_and_fractions[i].first; float rhFraction = hits_and_fractions[i].second; - bool hitWithNoCP = (detIdToCaloParticleId_Map.find(rh_detid) == detIdToCaloParticleId_Map.end()); auto itcheck = hitMap_->find(rh_detid); @@ -370,7 +368,7 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (!hitWithNoCP) { auto findHitIt = std::find(detIdToCaloParticleId_Map[rh_detid].begin(), detIdToCaloParticleId_Map[rh_detid].end(), - hgcal::detIdInfoInCluster{cpPair.first, 0.f}); + ticl::detIdInfoInCluster{cpPair.first, 0.f}); if (findHitIt != detIdToCaloParticleId_Map[rh_detid].end()) cpFraction = findHitIt->fraction; } @@ -425,7 +423,6 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( for (unsigned int i = 0; i < CPNumberOfHits; ++i) { auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[i].first; auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[i].second; - bool hitWithNoLC = false; if (cpFraction == 0.f) continue; //hopefully this should never happen @@ -442,7 +439,7 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (!hitWithNoLC) { auto findHitIt = std::find(detIdToLayerClusterId_Map[cp_hitDetId].begin(), detIdToLayerClusterId_Map[cp_hitDetId].end(), - hgcal::detIdInfoInCluster{layerClusterId, 0.f}); + ticl::detIdInfoInCluster{layerClusterId, 0.f}); if (findHitIt != detIdToLayerClusterId_Map[cp_hitDetId].end()) lcFraction = findHitIt->fraction; } @@ -476,9 +473,9 @@ hgcal::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( return {cpsInLayerCluster, cPOnLayer}; } -hgcal::RecoToSimCollection LCToCPAssociatorByEnergyScoreImpl::associateRecoToSim( +ticl::RecoToSimCollection LCToCPAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& cCCH, const edm::Handle& cPCH) const { - hgcal::RecoToSimCollection returnValue(productGetter_); + ticl::RecoToSimCollection returnValue(productGetter_); const auto& links = makeConnections(cCCH, cPCH); const auto& cpsInLayerCluster = std::get<0>(links); @@ -496,9 +493,9 @@ hgcal::RecoToSimCollection LCToCPAssociatorByEnergyScoreImpl::associateRecoToSim return returnValue; } -hgcal::SimToRecoCollection LCToCPAssociatorByEnergyScoreImpl::associateSimToReco( +ticl::SimToRecoCollection LCToCPAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& cCCH, const edm::Handle& cPCH) const { - hgcal::SimToRecoCollection returnValue(productGetter_); + ticl::SimToRecoCollection returnValue(productGetter_); const auto& links = makeConnections(cCCH, cPCH); const auto& cPOnLayer = std::get<1>(links); for (size_t cpId = 0; cpId < cPOnLayer.size(); ++cpId) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h index 2eed7b3f058e4..a88fc23df05d9 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h @@ -14,7 +14,7 @@ namespace edm { class EDProductGetter; } -namespace hgcal { +namespace ticl { // This structure is used both for LayerClusters and CaloParticles storing their id and the fraction of a hit // that belongs to the LayerCluster or CaloParticle. The meaning of the operator is extremely important since // this struct will be used inside maps and other containers and when searching for one particular occurence @@ -55,25 +55,25 @@ namespace hgcal { typedef std::vector>> layerClusterToCaloParticle; // This is used to save the caloParticleOnLayer structure for all CaloParticles in each layer. // It is not exactly what is returned outside, but out of its entries, the output object is build. - typedef std::vector> caloParticleToLayerCluster; + typedef std::vector> caloParticleToLayerCluster; //This is the output of the makeConnections function that contain all the work with CP2LC and LC2CP //association. It will be read by the relevant associateSimToReco and associateRecoToSim functions to //provide the final product. typedef std::tuple association; -} // namespace hgcal +} // namespace ticl -class LCToCPAssociatorByEnergyScoreImpl : public hgcal::LayerClusterToCaloParticleAssociatorBaseImpl { +class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticleAssociatorBaseImpl { public: explicit LCToCPAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, const std::unordered_map *); - hgcal::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, - const edm::Handle &cPCH) const override; + ticl::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, + const edm::Handle &cPCH) const override; - hgcal::SimToRecoCollection associateSimToReco(const edm::Handle &cCH, - const edm::Handle &cPCH) const override; + ticl::SimToRecoCollection associateSimToReco(const edm::Handle &cCH, + const edm::Handle &cPCH) const override; private: const bool hardScatterOnly_; @@ -81,6 +81,6 @@ class LCToCPAssociatorByEnergyScoreImpl : public hgcal::LayerClusterToCaloPartic const std::unordered_map *hitMap_; unsigned layers_; edm::EDProductGetter const *productGetter_; - hgcal::association makeConnections(const edm::Handle &cCH, - const edm::Handle &cPCH) const; + ticl::association makeConnections(const edm::Handle &cCH, + const edm::Handle &cPCH) const; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index 9187c7eac3202..1a3fcedc156c5 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -36,7 +36,7 @@ LCToCPAssociatorByEnergyScoreProducer::LCToCPAssociatorByEnergyScoreProducer(con rhtools_.reset(new hgcal::RecHitTools()); // Register the product - produces(); + produces(); } LCToCPAssociatorByEnergyScoreProducer::~LCToCPAssociatorByEnergyScoreProducer() {} @@ -51,7 +51,7 @@ void LCToCPAssociatorByEnergyScoreProducer::produce(edm::StreamID, auto impl = std::make_unique(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); - auto toPut = std::make_unique(std::move(impl)); + auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc index 41d1af3018340..e68cf40315c16 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc @@ -40,17 +40,17 @@ class LCToCPAssociatorEDProducer : public edm::global::EDProducer<> { edm::EDGetTokenT CPCollectionToken_; edm::EDGetTokenT LCCollectionToken_; - edm::EDGetTokenT associatorToken_; + edm::EDGetTokenT associatorToken_; }; LCToCPAssociatorEDProducer::LCToCPAssociatorEDProducer(const edm::ParameterSet &pset) { - produces(); - produces(); + produces(); + produces(); CPCollectionToken_ = consumes(pset.getParameter("label_cp")); LCCollectionToken_ = consumes(pset.getParameter("label_lc")); associatorToken_ = - consumes(pset.getParameter("associator")); + consumes(pset.getParameter("associator")); } LCToCPAssociatorEDProducer::~LCToCPAssociatorEDProducer() {} @@ -63,7 +63,7 @@ LCToCPAssociatorEDProducer::~LCToCPAssociatorEDProducer() {} void LCToCPAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; - edm::Handle theAssociator; + edm::Handle theAssociator; iEvent.getByToken(associatorToken_, theAssociator); Handle CPCollection; @@ -74,13 +74,13 @@ void LCToCPAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, cons // associate LC and CP LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n"; - hgcal::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(LCCollection, CPCollection); + ticl::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(LCCollection, CPCollection); LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n"; - hgcal::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(LCCollection, CPCollection); + ticl::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(LCCollection, CPCollection); - auto rts = std::make_unique(recSimColl); - auto str = std::make_unique(simRecColl); + auto rts = std::make_unique(recSimColl); + auto str = std::make_unique(simRecColl); iEvent.put(std::move(rts)); iEvent.put(std::move(str)); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index 361b25a5d4d46..01e2b290d321f 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -12,7 +12,7 @@ LCToSCAssociatorByEnergyScoreImpl::LCToSCAssociatorByEnergyScoreImpl( layers_ = recHitTools_->lastLayerBH(); } -hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( +ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& cCCH, const edm::Handle& sCCH) const { // Get collections const auto& clusters = *cCCH.product(); @@ -39,7 +39,7 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // among other the information to compute the SimCluster-To-LayerCluster score. It is one of the two objects that // build the output of the makeConnections function. // lcsInSimCluster[scId][layerId] - hgcal::simClusterToLayerCluster lcsInSimCluster; + ticl::simClusterToLayerCluster lcsInSimCluster; lcsInSimCluster.resize(nSimClusters); for (unsigned int i = 0; i < nSimClusters; ++i) { lcsInSimCluster[i].resize(layers_ * 2); @@ -55,7 +55,7 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // contributed to that hit by storing the SimCluster id and the fraction of the hit. Observe here // that in contrast to the CaloParticle case there is no merging and summing of the fractions, which // in the CaloParticle's case was necessary due to the multiple SimClusters of a single CaloParticle. - std::unordered_map> detIdToSimClusterId_Map; + std::unordered_map> detIdToSimClusterId_Map; for (const auto& scId : sCIndices) { const auto& hits_and_fractions = simClusters[scId].hits_and_fractions(); for (const auto& it_haf : hits_and_fractions) { @@ -67,7 +67,7 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (itcheck != hitMap_->end()) { auto hit_find_it = detIdToSimClusterId_Map.find(hitid); if (hit_find_it == detIdToSimClusterId_Map.end()) { - detIdToSimClusterId_Map[hitid] = std::vector(); + detIdToSimClusterId_Map[hitid] = std::vector(); } detIdToSimClusterId_Map[hitid].emplace_back(scId, it_haf.second); @@ -125,12 +125,12 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // Fill detIdToLayerClusterId_Map and scsInLayerCluster; update lcsInSimCluster // The detIdToLayerClusterId_Map is used to connect a hit Detid (key) with all the LayerClusters that // contributed to that hit by storing the LayerCluster id and the fraction of the corresponding hit. - std::unordered_map> detIdToLayerClusterId_Map; + std::unordered_map> detIdToLayerClusterId_Map; // scsInLayerCluster together with lcsInSimCluster are the two objects that are used to build the // output of the makeConnections function. scsInLayerCluster connects a LayerCluster with // all the SimClusters that share at least one cell with the LayerCluster and for each pair (LC,SC) // it stores the score. - hgcal::layerClusterToSimCluster scsInLayerCluster; //[lcId][scId]->(score) + ticl::layerClusterToSimCluster scsInLayerCluster; //[lcId][scId]->(score) scsInLayerCluster.resize(nLayerClusters); for (unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) { @@ -146,7 +146,7 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid); if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) { - detIdToLayerClusterId_Map[rh_detid] = std::vector(); + detIdToLayerClusterId_Map[rh_detid] = std::vector(); } detIdToLayerClusterId_Map[rh_detid].emplace_back(lcId, rhFraction); @@ -377,7 +377,7 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (hitWithSC) { auto findHitIt = std::find(detIdToSimClusterId_Map[rh_detid].begin(), detIdToSimClusterId_Map[rh_detid].end(), - hgcal::detIdInfoInCluster{scPair.first, 0.f}); + ticl::detIdInfoInCluster{scPair.first, 0.f}); if (findHitIt != detIdToSimClusterId_Map[rh_detid].end()) scFraction = findHitIt->fraction; } @@ -461,7 +461,7 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (hitWithLC) { auto findHitIt = std::find(detIdToLayerClusterId_Map[sc_hitDetId].begin(), detIdToLayerClusterId_Map[sc_hitDetId].end(), - hgcal::detIdInfoInCluster{layerClusterId, 0.f}); + ticl::detIdInfoInCluster{layerClusterId, 0.f}); if (findHitIt != detIdToLayerClusterId_Map[sc_hitDetId].end()) lcFraction = findHitIt->fraction; } @@ -496,9 +496,9 @@ hgcal::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( return {scsInLayerCluster, lcsInSimCluster}; } -hgcal::RecoToSimCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateRecoToSim( +ticl::RecoToSimCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& cCCH, const edm::Handle& sCCH) const { - hgcal::RecoToSimCollectionWithSimClusters returnValue(productGetter_); + ticl::RecoToSimCollectionWithSimClusters returnValue(productGetter_); const auto& links = makeConnections(cCCH, sCCH); const auto& scsInLayerCluster = std::get<0>(links); @@ -516,9 +516,9 @@ hgcal::RecoToSimCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::ass return returnValue; } -hgcal::SimToRecoCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateSimToReco( +ticl::SimToRecoCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& cCCH, const edm::Handle& sCCH) const { - hgcal::SimToRecoCollectionWithSimClusters returnValue(productGetter_); + ticl::SimToRecoCollectionWithSimClusters returnValue(productGetter_); const auto& links = makeConnections(cCCH, sCCH); const auto& lcsInSimCluster = std::get<1>(links); for (size_t scId = 0; scId < lcsInSimCluster.size(); ++scId) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h index c7b0b370b6507..b0a5182e239fe 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h @@ -14,7 +14,7 @@ namespace edm { class EDProductGetter; } -namespace hgcal { +namespace ticl { // This structure is used both for LayerClusters and SimClusters storing their id and the fraction of a hit // that belongs to the LayerCluster or SimCluster. The meaning of the operator is extremely important since // this struct will be used inside maps and other containers and when searching for one particular occurence @@ -52,25 +52,25 @@ namespace hgcal { typedef std::vector>> layerClusterToSimCluster; // This is used to save the simClusterOnLayer structure for all simClusters in each layer. // It is not exactly what is returned outside, but out of its entries, the output object is build. - typedef std::vector> simClusterToLayerCluster; + typedef std::vector> simClusterToLayerCluster; //This is the output of the makeConnections function that contain all the work with SC2LC and LC2SC //association. It will be read by the relevant associateSimToReco and associateRecoToSim functions to //provide the final product. typedef std::tuple association; -} // namespace hgcal +} // namespace ticl -class LCToSCAssociatorByEnergyScoreImpl : public hgcal::LayerClusterToSimClusterAssociatorBaseImpl { +class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterAssociatorBaseImpl { public: explicit LCToSCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, const std::unordered_map *); - hgcal::RecoToSimCollectionWithSimClusters associateRecoToSim( + ticl::RecoToSimCollectionWithSimClusters associateRecoToSim( const edm::Handle &cCH, const edm::Handle &sCCH) const override; - hgcal::SimToRecoCollectionWithSimClusters associateSimToReco( + ticl::SimToRecoCollectionWithSimClusters associateSimToReco( const edm::Handle &cCH, const edm::Handle &sCCH) const override; @@ -80,6 +80,6 @@ class LCToSCAssociatorByEnergyScoreImpl : public hgcal::LayerClusterToSimCluster const std::unordered_map *hitMap_; unsigned layers_; edm::EDProductGetter const *productGetter_; - hgcal::association makeConnections(const edm::Handle &cCH, - const edm::Handle &sCCH) const; + ticl::association makeConnections(const edm::Handle &cCH, + const edm::Handle &sCCH) const; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 1f13fcfe529db..9ada5ed00adea 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -36,7 +36,7 @@ LCToSCAssociatorByEnergyScoreProducer::LCToSCAssociatorByEnergyScoreProducer(con rhtools_.reset(new hgcal::RecHitTools()); // Register the product - produces(); + produces(); } LCToSCAssociatorByEnergyScoreProducer::~LCToSCAssociatorByEnergyScoreProducer() {} @@ -51,7 +51,7 @@ void LCToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, auto impl = std::make_unique(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); - auto toPut = std::make_unique(std::move(impl)); + auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index 6edda534b56ef..718348d34ed7c 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -39,17 +39,16 @@ class LCToSCAssociatorEDProducer : public edm::global::EDProducer<> { edm::EDGetTokenT SCCollectionToken_; edm::EDGetTokenT LCCollectionToken_; - edm::EDGetTokenT associatorToken_; + edm::EDGetTokenT associatorToken_; }; LCToSCAssociatorEDProducer::LCToSCAssociatorEDProducer(const edm::ParameterSet &pset) { - produces(); - produces(); + produces(); + produces(); SCCollectionToken_ = consumes(pset.getParameter("label_scl")); LCCollectionToken_ = consumes(pset.getParameter("label_lcl")); - associatorToken_ = - consumes(pset.getParameter("associator")); + associatorToken_ = consumes(pset.getParameter("associator")); } LCToSCAssociatorEDProducer::~LCToSCAssociatorEDProducer() {} @@ -62,7 +61,7 @@ LCToSCAssociatorEDProducer::~LCToSCAssociatorEDProducer() {} void LCToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; - edm::Handle theAssociator; + edm::Handle theAssociator; iEvent.getByToken(associatorToken_, theAssociator); Handle SCCollection; @@ -73,13 +72,13 @@ void LCToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, cons // associate LC and SC LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n"; - hgcal::RecoToSimCollectionWithSimClusters recSimColl = theAssociator->associateRecoToSim(LCCollection, SCCollection); + ticl::RecoToSimCollectionWithSimClusters recSimColl = theAssociator->associateRecoToSim(LCCollection, SCCollection); LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n"; - hgcal::SimToRecoCollectionWithSimClusters simRecColl = theAssociator->associateSimToReco(LCCollection, SCCollection); + ticl::SimToRecoCollectionWithSimClusters simRecColl = theAssociator->associateSimToReco(LCCollection, SCCollection); - auto rts = std::make_unique(recSimColl); - auto str = std::make_unique(simRecColl); + auto rts = std::make_unique(recSimColl); + auto str = std::make_unique(simRecColl); iEvent.put(std::move(rts)); iEvent.put(std::move(str)); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.cc index b94a29355c854..efdde13665e58 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.cc @@ -10,14 +10,14 @@ LCToSimTSAssociatorByEnergyScoreImpl::LCToSimTSAssociatorByEnergyScoreImpl(edm::EDProductGetter const& productGetter) : productGetter_(&productGetter) {} -hgcal::RecoToSimTracksterCollection LCToSimTSAssociatorByEnergyScoreImpl::associateRecoToSim( +ticl::RecoToSimTracksterCollection LCToSimTSAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& cCCH, const edm::Handle& sTCH, const edm::Handle& cPCH, - const hgcal::RecoToSimCollection& lCToCPs, + const ticl::RecoToSimCollection& lCToCPs, const edm::Handle& sCCH, - const hgcal::RecoToSimCollectionWithSimClusters& lCToSCs) const { - hgcal::RecoToSimTracksterCollection returnValue(productGetter_); + const ticl::RecoToSimCollectionWithSimClusters& lCToSCs) const { + ticl::RecoToSimTracksterCollection returnValue(productGetter_); const auto simTracksters = *sTCH.product(); @@ -89,14 +89,14 @@ hgcal::RecoToSimTracksterCollection LCToSimTSAssociatorByEnergyScoreImpl::associ return returnValue; } -hgcal::SimTracksterToRecoCollection LCToSimTSAssociatorByEnergyScoreImpl::associateSimToReco( +ticl::SimTracksterToRecoCollection LCToSimTSAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& cCCH, const edm::Handle& sTCH, const edm::Handle& cPCH, - const hgcal::SimToRecoCollection& cPToLCs, + const ticl::SimToRecoCollection& cPToLCs, const edm::Handle& sCCH, - const hgcal::SimToRecoCollectionWithSimClusters& sCToLCs) const { - hgcal::SimTracksterToRecoCollection returnValue(productGetter_); + const ticl::SimToRecoCollectionWithSimClusters& sCToLCs) const { + ticl::SimTracksterToRecoCollection returnValue(productGetter_); const auto simTracksters = *sTCH.product(); for (size_t tsId = 0; tsId < simTracksters.size(); ++tsId) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.h index 19dcb864ed05c..0d4530b11f018 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreImpl.h @@ -19,25 +19,25 @@ namespace edm { class EDProductGetter; } -class LCToSimTSAssociatorByEnergyScoreImpl : public hgcal::LayerClusterToSimTracksterAssociatorBaseImpl { +class LCToSimTSAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimTracksterAssociatorBaseImpl { public: explicit LCToSimTSAssociatorByEnergyScoreImpl(edm::EDProductGetter const &); - hgcal::RecoToSimTracksterCollection associateRecoToSim( + ticl::RecoToSimTracksterCollection associateRecoToSim( const edm::Handle &cCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::RecoToSimCollection &lCToCPs, + const ticl::RecoToSimCollection &lCToCPs, const edm::Handle &sCCH, - const hgcal::RecoToSimCollectionWithSimClusters &lCToSCs) const override; + const ticl::RecoToSimCollectionWithSimClusters &lCToSCs) const override; - hgcal::SimTracksterToRecoCollection associateSimToReco( + ticl::SimTracksterToRecoCollection associateSimToReco( const edm::Handle &cCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::SimToRecoCollection &cPToLCs, + const ticl::SimToRecoCollection &cPToLCs, const edm::Handle &sCCH, - const hgcal::SimToRecoCollectionWithSimClusters &sCToLCs) const override; + const ticl::SimToRecoCollectionWithSimClusters &sCToLCs) const override; private: edm::EDProductGetter const *productGetter_; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreProducer.cc index 4e73c7ca5ff33..5c93dd7cf2bf2 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorByEnergyScoreProducer.cc @@ -32,7 +32,7 @@ LCToSimTSAssociatorByEnergyScoreProducer::LCToSimTSAssociatorByEnergyScoreProduc rhtools_.reset(new hgcal::RecHitTools()); // Register the product - produces(); + produces(); } LCToSimTSAssociatorByEnergyScoreProducer::~LCToSimTSAssociatorByEnergyScoreProducer() {} @@ -44,7 +44,7 @@ void LCToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID, rhtools_->setGeometry(*geom); auto impl = std::make_unique(iEvent.productGetter()); - auto toPut = std::make_unique(std::move(impl)); + auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorEDProducer.cc index 46220917fb9d6..456e3c5892ac2 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSimTSAssociatorEDProducer.cc @@ -40,34 +40,34 @@ class LCToSimTSAssociatorEDProducer : public edm::global::EDProducer<> { edm::EDGetTokenT LCCollectionToken_; edm::EDGetTokenT SimTSCollectionToken_; - edm::EDGetTokenT associatorToken_; + edm::EDGetTokenT associatorToken_; edm::EDGetTokenT CPCollectionToken_; edm::InputTag associatorCP_; - edm::EDGetTokenT associationMapLCToCPToken_; - edm::EDGetTokenT associationMapCPToLCToken_; + edm::EDGetTokenT associationMapLCToCPToken_; + edm::EDGetTokenT associationMapCPToLCToken_; edm::EDGetTokenT SCCollectionToken_; edm::InputTag associatorSC_; - edm::EDGetTokenT associationMapLCToSCToken_; - edm::EDGetTokenT associationMapSCToLCToken_; + edm::EDGetTokenT associationMapLCToSCToken_; + edm::EDGetTokenT associationMapSCToLCToken_; }; LCToSimTSAssociatorEDProducer::LCToSimTSAssociatorEDProducer(const edm::ParameterSet &pset) : LCCollectionToken_(consumes(pset.getParameter("label_lc"))), SimTSCollectionToken_(consumes(pset.getParameter("label_simTst"))), associatorToken_( - consumes(pset.getParameter("associator"))), + consumes(pset.getParameter("associator"))), CPCollectionToken_(consumes(pset.getParameter("label_cp"))), associatorCP_(pset.getParameter("associator_cp")), - associationMapLCToCPToken_(consumes(associatorCP_)), - associationMapCPToLCToken_(consumes(associatorCP_)), + associationMapLCToCPToken_(consumes(associatorCP_)), + associationMapCPToLCToken_(consumes(associatorCP_)), SCCollectionToken_(consumes(pset.getParameter("label_scl"))), associatorSC_(pset.getParameter("associator_sc")), - associationMapLCToSCToken_(consumes(associatorSC_)), - associationMapSCToLCToken_(consumes(associatorSC_)) { - produces(); - produces(); + associationMapLCToSCToken_(consumes(associatorSC_)), + associationMapSCToLCToken_(consumes(associatorSC_)) { + produces(); + produces(); } LCToSimTSAssociatorEDProducer::~LCToSimTSAssociatorEDProducer() {} @@ -80,7 +80,7 @@ LCToSimTSAssociatorEDProducer::~LCToSimTSAssociatorEDProducer() {} void LCToSimTSAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; - edm::Handle theAssociator; + edm::Handle theAssociator; iEvent.getByToken(associatorToken_, theAssociator); Handle LCCollection; @@ -101,15 +101,15 @@ void LCToSimTSAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, c // associate LC and SimTS LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n"; - hgcal::RecoToSimTracksterCollection recSimColl = theAssociator->associateRecoToSim( + ticl::RecoToSimTracksterCollection recSimColl = theAssociator->associateRecoToSim( LCCollection, SimTSCollection, CPCollection, LCToCPsColl, SCCollection, LCToSCsColl); LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n"; - hgcal::SimTracksterToRecoCollection simRecColl = theAssociator->associateSimToReco( + ticl::SimTracksterToRecoCollection simRecColl = theAssociator->associateSimToReco( LCCollection, SimTSCollection, CPCollection, CPToLCsColl, SCCollection, SCToLCsColl); - auto rts = std::make_unique(recSimColl); - auto str = std::make_unique(simRecColl); + auto rts = std::make_unique(recSimColl); + auto str = std::make_unique(simRecColl); iEvent.put(std::move(rts)); iEvent.put(std::move(str)); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc index f93a9f3c1a99d..395e6bcb0851f 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc @@ -12,7 +12,7 @@ TSToSCAssociatorByEnergyScoreImpl::TSToSCAssociatorByEnergyScoreImpl( layers_ = recHitTools_->lastLayerBH(); } -hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( +ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sCCH) const { @@ -41,7 +41,7 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( // Initialize tssInSimCluster. To be returned outside, since it contains the // information to compute the SimCluster-To-Trackster score. // tssInSimCluster[scId]: - hgcal::simClusterToTrackster tssInSimCluster; + ticl::simClusterToTrackster tssInSimCluster; tssInSimCluster.resize(nSimClusters); for (unsigned int i = 0; i < nSimClusters; ++i) { tssInSimCluster[i].simClusterId = i; @@ -50,7 +50,7 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( } // Fill detIdToSimClusterId_Map and update tssInSimCluster - std::unordered_map> detIdToSimClusterId_Map; + std::unordered_map> detIdToSimClusterId_Map; for (const auto& scId : sCIndices) { const auto& hits_and_fractions = simClusters[scId].hits_and_fractions(); for (const auto& it_haf : hits_and_fractions) { @@ -59,7 +59,7 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (itcheck != hitMap_->end()) { const auto hit_find_it = detIdToSimClusterId_Map.find(hitid); if (hit_find_it == detIdToSimClusterId_Map.end()) { - detIdToSimClusterId_Map[hitid] = std::vector(); + detIdToSimClusterId_Map[hitid] = std::vector(); } detIdToSimClusterId_Map[hitid].emplace_back(scId, it_haf.second); @@ -107,11 +107,11 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( #endif // Fill detIdToLayerClusterId_Map and scsInTrackster; update tssInSimCluster - std::unordered_map> detIdToLayerClusterId_Map; + std::unordered_map> detIdToLayerClusterId_Map; // this contains the ids of the simclusters contributing with at least one // hit to the Trackster. To be returned since this contains the information // to compute the Trackster-To-SimCluster score. - hgcal::tracksterToSimCluster scsInTrackster; //[tsId][scId]->(energy,score) + ticl::tracksterToSimCluster scsInTrackster; //[tsId][scId]->(energy,score) scsInTrackster.resize(nTracksters); for (unsigned int tsId = 0; tsId < nTracksters; ++tsId) { @@ -128,7 +128,7 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( const auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid); if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) { - detIdToLayerClusterId_Map[rh_detid] = std::vector(); + detIdToLayerClusterId_Map[rh_detid] = std::vector(); } detIdToLayerClusterId_Map[rh_detid].emplace_back(lcId, rhFraction); @@ -359,7 +359,7 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (hitWithSC) { const auto findHitIt = std::find(detIdToSimClusterId_Map[rh_detid].begin(), detIdToSimClusterId_Map[rh_detid].end(), - hgcal::detIdInfoInCluster{scPair.first, 0.f}); + ticl::detIdInfoInCluster{scPair.first, 0.f}); if (findHitIt != detIdToSimClusterId_Map[rh_detid].end()) scFraction = findHitIt->fraction; } @@ -447,7 +447,7 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (hitWithLC) { const auto findHitIt = std::find(detIdToLayerClusterId_Map[sc_hitDetId].begin(), detIdToLayerClusterId_Map[sc_hitDetId].end(), - hgcal::detIdInfoInCluster{lcId, 0.f}); + ticl::detIdInfoInCluster{lcId, 0.f}); if (findHitIt != detIdToLayerClusterId_Map[sc_hitDetId].end()) tsFraction = findHitIt->fraction * lcFractionInTs; } @@ -480,11 +480,11 @@ hgcal::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( return {scsInTrackster, tssInSimCluster}; } -hgcal::RecoToSimCollectionTracksters TSToSCAssociatorByEnergyScoreImpl::associateRecoToSim( +ticl::RecoToSimCollectionTracksters TSToSCAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sCCH) const { - hgcal::RecoToSimCollectionTracksters returnValue(productGetter_); + ticl::RecoToSimCollectionTracksters returnValue(productGetter_); const auto& links = makeConnections(tCH, lCCH, sCCH); const auto& scsInTrackster = std::get<0>(links); @@ -502,11 +502,11 @@ hgcal::RecoToSimCollectionTracksters TSToSCAssociatorByEnergyScoreImpl::associat return returnValue; } -hgcal::SimToRecoCollectionTracksters TSToSCAssociatorByEnergyScoreImpl::associateSimToReco( +ticl::SimToRecoCollectionTracksters TSToSCAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sCCH) const { - hgcal::SimToRecoCollectionTracksters returnValue(productGetter_); + ticl::SimToRecoCollectionTracksters returnValue(productGetter_); const auto& links = makeConnections(tCH, lCCH, sCCH); const auto& tssInSimCluster = std::get<1>(links); for (size_t scId = 0; scId < tssInSimCluster.size(); ++scId) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h index 4c6552ac90bdd..470a68496fb96 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h @@ -14,7 +14,7 @@ namespace edm { class EDProductGetter; } -namespace hgcal { +namespace ticl { struct detIdInfoInCluster { bool operator==(const detIdInfoInCluster &o) const { return clusterId == o.clusterId; }; long unsigned int clusterId; @@ -33,24 +33,24 @@ namespace hgcal { }; typedef std::vector>> tracksterToSimCluster; - typedef std::vector simClusterToTrackster; + typedef std::vector simClusterToTrackster; typedef std::tuple association; -} // namespace hgcal +} // namespace ticl -class TSToSCAssociatorByEnergyScoreImpl : public hgcal::TracksterToSimClusterAssociatorBaseImpl { +class TSToSCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimClusterAssociatorBaseImpl { public: explicit TSToSCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, const std::unordered_map *); - hgcal::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const override; + ticl::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const override; - hgcal::SimToRecoCollectionTracksters associateSimToReco(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const override; + ticl::SimToRecoCollectionTracksters associateSimToReco(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const override; private: const bool hardScatterOnly_; @@ -58,7 +58,7 @@ class TSToSCAssociatorByEnergyScoreImpl : public hgcal::TracksterToSimClusterAss const std::unordered_map *hitMap_; unsigned layers_; edm::EDProductGetter const *productGetter_; - hgcal::association makeConnections(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const; + ticl::association makeConnections(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc index 332bf2882aa2c..e97af3baa97ef 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc @@ -36,7 +36,7 @@ TSToSCAssociatorByEnergyScoreProducer::TSToSCAssociatorByEnergyScoreProducer(con rhtools_.reset(new hgcal::RecHitTools()); // Register the product - produces(); + produces(); } TSToSCAssociatorByEnergyScoreProducer::~TSToSCAssociatorByEnergyScoreProducer() {} @@ -51,7 +51,7 @@ void TSToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, auto impl = std::make_unique(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); - auto toPut = std::make_unique(std::move(impl)); + auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorEDProducer.cc index a3405a8796279..ebc002be96ae1 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorEDProducer.cc @@ -40,17 +40,17 @@ class TSToSCAssociatorEDProducer : public edm::global::EDProducer<> { edm::EDGetTokenT SCCollectionToken_; edm::EDGetTokenT TSCollectionToken_; edm::EDGetTokenT LCCollectionToken_; - edm::EDGetTokenT associatorToken_; + edm::EDGetTokenT associatorToken_; }; TSToSCAssociatorEDProducer::TSToSCAssociatorEDProducer(const edm::ParameterSet &pset) { - produces(); - produces(); + produces(); + produces(); SCCollectionToken_ = consumes(pset.getParameter("label_scl")); TSCollectionToken_ = consumes(pset.getParameter("label_tst")); LCCollectionToken_ = consumes(pset.getParameter("label_lcl")); - associatorToken_ = consumes(pset.getParameter("associator")); + associatorToken_ = consumes(pset.getParameter("associator")); } TSToSCAssociatorEDProducer::~TSToSCAssociatorEDProducer() {} @@ -63,7 +63,7 @@ TSToSCAssociatorEDProducer::~TSToSCAssociatorEDProducer() {} void TSToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; - edm::Handle theAssociator; + edm::Handle theAssociator; iEvent.getByToken(associatorToken_, theAssociator); Handle SCCollection; @@ -77,15 +77,15 @@ void TSToSCAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, cons // associate TS and SC LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n"; - hgcal::RecoToSimCollectionTracksters recSimColl = + ticl::RecoToSimCollectionTracksters recSimColl = theAssociator->associateRecoToSim(TSCollection, LCCollection, SCCollection); LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n"; - hgcal::SimToRecoCollectionTracksters simRecColl = + ticl::SimToRecoCollectionTracksters simRecColl = theAssociator->associateSimToReco(TSCollection, LCCollection, SCCollection); - auto rts = std::make_unique(recSimColl); - auto str = std::make_unique(simRecColl); + auto rts = std::make_unique(recSimColl); + auto str = std::make_unique(simRecColl); iEvent.put(std::move(rts)); iEvent.put(std::move(str)); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc index d5307c9f94cab..d7e57d37af419 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc @@ -11,7 +11,7 @@ TSToSimTSAssociatorByEnergyScoreImpl::TSToSimTSAssociatorByEnergyScoreImpl( layers_ = recHitTools_->lastLayerBH(); } -hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( +ticl::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sTCH) const { @@ -38,7 +38,7 @@ hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( // among other the information to compute the SimTrackster-To-Trackster score. It is one of the two objects that // build the output of the makeConnections function. // tssInSimTrackster[stId] - hgcal::simTracksterToTrackster tssInSimTrackster; + ticl::simTracksterToTrackster tssInSimTrackster; tssInSimTrackster.resize(nSimTracksters); for (unsigned int i = 0; i < nSimTracksters; ++i) { tssInSimTrackster[i].simTracksterId = i; @@ -50,7 +50,7 @@ hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( // The lcToSimTracksterId_Map is used to connect a LayerCluster, via its id (key), with all the SimTracksters that // contributed to that LayerCluster by storing the SimTrackster id and the fraction of the LayerCluster's energy // in which the SimTrackster contributed. - std::unordered_map> lcToSimTracksterId_Map; + std::unordered_map> lcToSimTracksterId_Map; for (const auto& stId : sTIndices) { const auto& lcs = simTracksters[stId].vertices(); int lcInSimTst = 0; @@ -59,7 +59,7 @@ hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( const auto lc_find_it = lcToSimTracksterId_Map.find(lcId); if (lc_find_it == lcToSimTracksterId_Map.end()) { - lcToSimTracksterId_Map[lcId] = std::vector(); + lcToSimTracksterId_Map[lcId] = std::vector(); } lcToSimTracksterId_Map[lcId].emplace_back(stId, fraction); @@ -108,7 +108,7 @@ hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( // this contains the ids of the simTracksters contributing with at least one // hit to the Trackster. To be returned since this contains the information // to compute the Trackster-To-SimTrackster score. - hgcal::tracksterToSimTrackster stsInTrackster; // tsId->(stId,score) + ticl::tracksterToSimTrackster stsInTrackster; // tsId->(stId,score) stsInTrackster.resize(nTracksters); for (unsigned int tsId = 0; tsId < nTracksters; ++tsId) { @@ -328,7 +328,7 @@ hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( if (lcWithST) { const auto findLCIt = std::find(lcToSimTracksterId_Map[lcId].begin(), lcToSimTracksterId_Map[lcId].end(), - hgcal::lcInfoInTrackster{stPair.first, 0.f}); + ticl::lcInfoInTrackster{stPair.first, 0.f}); if (findLCIt != lcToSimTracksterId_Map[lcId].end()) { stFraction = findLCIt->fraction; } @@ -434,11 +434,11 @@ hgcal::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( return {stsInTrackster, tssInSimTrackster}; } -hgcal::RecoToSimCollectionSimTracksters TSToSimTSAssociatorByEnergyScoreImpl::associateRecoToSim( +ticl::RecoToSimCollectionSimTracksters TSToSimTSAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sTCH) const { - hgcal::RecoToSimCollectionSimTracksters returnValue(productGetter_); + ticl::RecoToSimCollectionSimTracksters returnValue(productGetter_); const auto& links = makeConnections(tCH, lCCH, sTCH); const auto& stsInTrackster = std::get<0>(links); @@ -457,11 +457,11 @@ hgcal::RecoToSimCollectionSimTracksters TSToSimTSAssociatorByEnergyScoreImpl::as return returnValue; } -hgcal::SimToRecoCollectionSimTracksters TSToSimTSAssociatorByEnergyScoreImpl::associateSimToReco( +ticl::SimToRecoCollectionSimTracksters TSToSimTSAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sTCH) const { - hgcal::SimToRecoCollectionSimTracksters returnValue(productGetter_); + ticl::SimToRecoCollectionSimTracksters returnValue(productGetter_); const auto& links = makeConnections(tCH, lCCH, sTCH); const auto& tssInSimTrackster = std::get<1>(links); for (size_t stId = 0; stId < tssInSimTrackster.size(); ++stId) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h index 067a5c544c16b..31d87944dd5c8 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h @@ -14,7 +14,7 @@ namespace edm { class EDProductGetter; } -namespace hgcal { +namespace ticl { // This structure is used for SimTracksters storing its id and the energy fraction of // a LayerCluster that is related to that SimTrackster. Be careful not to be confused by the fact that // similar structs are used in other HGCAL associators where the fraction is a hit's fraction. @@ -59,23 +59,23 @@ namespace hgcal { typedef std::vector>>> tracksterToSimTrackster; // This is used to save the simTracksterOnLayer structure for all simTracksters. // It is not exactly what is returned outside, but out of its entries, the output object is build. - typedef std::vector simTracksterToTrackster; + typedef std::vector simTracksterToTrackster; typedef std::tuple association; -} // namespace hgcal +} // namespace ticl -class TSToSimTSAssociatorByEnergyScoreImpl : public hgcal::TracksterToSimTracksterAssociatorBaseImpl { +class TSToSimTSAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTracksterAssociatorBaseImpl { public: explicit TSToSimTSAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, const std::unordered_map *); - hgcal::RecoToSimCollectionSimTracksters associateRecoToSim( + ticl::RecoToSimCollectionSimTracksters associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sTCH) const override; - hgcal::SimToRecoCollectionSimTracksters associateSimToReco( + ticl::SimToRecoCollectionSimTracksters associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sTCH) const override; @@ -86,7 +86,7 @@ class TSToSimTSAssociatorByEnergyScoreImpl : public hgcal::TracksterToSimTrackst const std::unordered_map *hitMap_; unsigned layers_; edm::EDProductGetter const *productGetter_; - hgcal::association makeConnections(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sTCH) const; + ticl::association makeConnections(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sTCH) const; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc index 732f0de1bed34..4e45ea6cab404 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc @@ -36,7 +36,7 @@ TSToSimTSAssociatorByEnergyScoreProducer::TSToSimTSAssociatorByEnergyScoreProduc rhtools_.reset(new hgcal::RecHitTools()); // Register the product - produces(); + produces(); } TSToSimTSAssociatorByEnergyScoreProducer::~TSToSimTSAssociatorByEnergyScoreProducer() {} @@ -51,7 +51,7 @@ void TSToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID, auto impl = std::make_unique( iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); - auto toPut = std::make_unique(std::move(impl)); + auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorEDProducer.cc index 53a9ed1e5998f..6fa4eed0e964b 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorEDProducer.cc @@ -40,17 +40,17 @@ class TSToSimTSAssociatorEDProducer : public edm::global::EDProducer<> { edm::EDGetTokenT TSCollectionToken_; edm::EDGetTokenT SimTSCollectionToken_; edm::EDGetTokenT LCCollectionToken_; - edm::EDGetTokenT associatorToken_; + edm::EDGetTokenT associatorToken_; }; TSToSimTSAssociatorEDProducer::TSToSimTSAssociatorEDProducer(const edm::ParameterSet &pset) { - produces("simToReco"); - produces("recoToSim"); + produces("simToReco"); + produces("recoToSim"); TSCollectionToken_ = consumes(pset.getParameter("label_tst")); SimTSCollectionToken_ = consumes(pset.getParameter("label_simTst")); LCCollectionToken_ = consumes(pset.getParameter("label_lcl")); - associatorToken_ = consumes(pset.getParameter("associator")); + associatorToken_ = consumes(pset.getParameter("associator")); } TSToSimTSAssociatorEDProducer::~TSToSimTSAssociatorEDProducer() {} @@ -63,7 +63,7 @@ TSToSimTSAssociatorEDProducer::~TSToSimTSAssociatorEDProducer() {} void TSToSimTSAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const { using namespace edm; - edm::Handle theAssociator; + edm::Handle theAssociator; iEvent.getByToken(associatorToken_, theAssociator); Handle TSCollection; @@ -77,15 +77,15 @@ void TSToSimTSAssociatorEDProducer::produce(edm::StreamID, edm::Event &iEvent, c // associate TS and SimTS LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n"; - hgcal::RecoToSimCollectionSimTracksters recSimColl = + ticl::RecoToSimCollectionSimTracksters recSimColl = theAssociator->associateRecoToSim(TSCollection, LCCollection, SimTSCollection); LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n"; - hgcal::SimToRecoCollectionSimTracksters simRecColl = + ticl::SimToRecoCollectionSimTracksters simRecColl = theAssociator->associateSimToReco(TSCollection, LCCollection, SimTSCollection); - auto rts = std::make_unique(recSimColl); - auto str = std::make_unique(simRecColl); + auto rts = std::make_unique(recSimColl); + auto str = std::make_unique(simRecColl); iEvent.put(std::move(rts), "recoToSim"); iEvent.put(std::move(str), "simToReco"); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc index 0b68d6772b667..ad01e43799c11 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc @@ -13,7 +13,7 @@ TSToSimTSHitLCAssociatorByEnergyScoreImpl::TSToSimTSHitLCAssociatorByEnergyScore layers_ = recHitTools_->lastLayerBH(); } -hgcal::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( +ticl::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sCCH, @@ -34,8 +34,8 @@ hgcal::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( std::unordered_map>> detIdCaloParticleId_Map; std::unordered_map>> detIdToRecoTSId_Map; - hgcal::sharedEnergyAndScore_t recoToSim_sharedEnergyAndScore; - hgcal::sharedEnergyAndScore_t simToReco_sharedEnergyAndScore; + ticl::sharedEnergyAndScore_t recoToSim_sharedEnergyAndScore; + ticl::sharedEnergyAndScore_t simToReco_sharedEnergyAndScore; recoToSim_sharedEnergyAndScore.resize(nTracksters); simToReco_sharedEnergyAndScore.resize(nSimTracksters); @@ -206,13 +206,13 @@ hgcal::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( return {recoToSim_sharedEnergyAndScore, simToReco_sharedEnergyAndScore}; } -hgcal::RecoToSimCollectionSimTracksters TSToSimTSHitLCAssociatorByEnergyScoreImpl::associateRecoToSim( +ticl::RecoToSimCollectionSimTracksters TSToSimTSHitLCAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sCCH, const edm::Handle& cPCH, const edm::Handle& sTCH) const { - hgcal::RecoToSimCollectionSimTracksters returnValue(productGetter_); + ticl::RecoToSimCollectionSimTracksters returnValue(productGetter_); const auto& links = makeConnections(tCH, lCCH, sCCH, cPCH, sTCH); const auto& recoToSim_sharedEnergyAndScore = std::get<0>(links); for (std::size_t tsId = 0; tsId < recoToSim_sharedEnergyAndScore.size(); ++tsId) { @@ -234,13 +234,13 @@ hgcal::RecoToSimCollectionSimTracksters TSToSimTSHitLCAssociatorByEnergyScoreImp return returnValue; } -hgcal::SimToRecoCollectionSimTracksters TSToSimTSHitLCAssociatorByEnergyScoreImpl::associateSimToReco( +ticl::SimToRecoCollectionSimTracksters TSToSimTSHitLCAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& tCH, const edm::Handle& lCCH, const edm::Handle& sCCH, const edm::Handle& cPCH, const edm::Handle& sTCH) const { - hgcal::SimToRecoCollectionSimTracksters returnValue(productGetter_); + ticl::SimToRecoCollectionSimTracksters returnValue(productGetter_); const auto& links = makeConnections(tCH, lCCH, sCCH, cPCH, sTCH); const auto& simToReco_sharedEnergyAndScore = std::get<1>(links); for (std::size_t simTsId = 0; simTsId < simToReco_sharedEnergyAndScore.size(); ++simTsId) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h index ff6d95d7f2b8d..1cefea40c7b65 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h @@ -14,7 +14,7 @@ namespace edm { class EDProductGetter; } -namespace hgcal { +namespace ticl { struct detIdInfoInCluster { bool operator==(const detIdInfoInCluster &o) const { return clusterId == o.clusterId; }; @@ -40,29 +40,29 @@ namespace hgcal { // the SimTracksters (via their ids (stIds)) that share at least one LayerCluster. In that pair // it stores the score (tsId->(stId,score)). Keep in mind that the association is not unique, since there could be // several instances of the same SimTrackster from several related SimClusters that each contributed to the same Trackster. -} // namespace hgcal +} // namespace ticl -class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public hgcal::TracksterToSimTracksterHitLCAssociatorBaseImpl { +class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTracksterHitLCAssociatorBaseImpl { public: explicit TSToSimTSHitLCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, const std::unordered_map *); - hgcal::association_t makeConnections(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH, - const edm::Handle &cPCH, - const edm::Handle &sTCH) const; + ticl::association_t makeConnections(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH, + const edm::Handle &cPCH, + const edm::Handle &sTCH) const; - hgcal::RecoToSimCollectionSimTracksters associateRecoToSim( + ticl::RecoToSimCollectionSimTracksters associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, const edm::Handle &cPCH, const edm::Handle &sTCH) const override; - hgcal::SimToRecoCollectionSimTracksters associateSimToReco( + ticl::SimToRecoCollectionSimTracksters associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc index 5c2f66d9c1d0e..28d105ede79d3 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc @@ -36,7 +36,7 @@ TSToSimTSHitLCAssociatorByEnergyScoreProducer::TSToSimTSHitLCAssociatorByEnergyS rhtools_.reset(new hgcal::RecHitTools()); // Register the product - produces(); + produces(); } TSToSimTSHitLCAssociatorByEnergyScoreProducer::~TSToSimTSHitLCAssociatorByEnergyScoreProducer() {} @@ -51,7 +51,7 @@ void TSToSimTSHitLCAssociatorByEnergyScoreProducer::produce(edm::StreamID, auto impl = std::make_unique( iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); - auto toPut = std::make_unique(std::move(impl)); + auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorEDProducer.cc index e66c29a89a91b..fb04e6ba80a97 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorEDProducer.cc @@ -41,13 +41,13 @@ class TSToSimTSHitLCAssociatorEDProducer : public edm::global::EDProducer<> { edm::EDGetTokenT SCCollectionToken_; edm::EDGetTokenT CPCollectionToken_; edm::EDGetTokenT>> simTrackstersMap_; - hgcal::validationType valType_; - edm::EDGetTokenT associatorToken_; + ticl::validationType valType_; + edm::EDGetTokenT associatorToken_; }; TSToSimTSHitLCAssociatorEDProducer::TSToSimTSHitLCAssociatorEDProducer(const edm::ParameterSet &pset) { - produces("simToReco"); - produces("recoToSim"); + produces("simToReco"); + produces("recoToSim"); TSCollectionToken_ = consumes(pset.getParameter("label_tst")); SimTSCollectionToken_ = consumes(pset.getParameter("label_simTst")); @@ -55,7 +55,7 @@ TSToSimTSHitLCAssociatorEDProducer::TSToSimTSHitLCAssociatorEDProducer(const edm SCCollectionToken_ = consumes(pset.getParameter("label_scl")); CPCollectionToken_ = consumes(pset.getParameter("label_cp")); associatorToken_ = - consumes(pset.getParameter("associator")); + consumes(pset.getParameter("associator")); } TSToSimTSHitLCAssociatorEDProducer::~TSToSimTSHitLCAssociatorEDProducer() {} @@ -65,7 +65,7 @@ void TSToSimTSHitLCAssociatorEDProducer::produce(edm::StreamID, const edm::EventSetup &iSetup) const { using namespace edm; - edm::Handle theAssociator; + edm::Handle theAssociator; iEvent.getByToken(associatorToken_, theAssociator); Handle TSCollection; @@ -86,15 +86,15 @@ void TSToSimTSHitLCAssociatorEDProducer::produce(edm::StreamID, // associate TS and SimTS LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n"; - hgcal::RecoToSimCollectionSimTracksters recSimColl = + ticl::RecoToSimCollectionSimTracksters recSimColl = theAssociator->associateRecoToSim(TSCollection, LCCollection, SCCollection, CPCollection, SimTSCollection); LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n"; - hgcal::SimToRecoCollectionSimTracksters simRecColl = + ticl::SimToRecoCollectionSimTracksters simRecColl = theAssociator->associateSimToReco(TSCollection, LCCollection, SCCollection, CPCollection, SimTSCollection); - auto rts = std::make_unique(recSimColl); - auto str = std::make_unique(simRecColl); + auto rts = std::make_unique(recSimColl); + auto str = std::make_unique(simRecColl); iEvent.put(std::move(rts), "recoToSim"); iEvent.put(std::move(str), "simToReco"); diff --git a/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h b/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h index c6f5d2668a830..d5c079a298fd8 100644 --- a/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h +++ b/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h @@ -11,11 +11,11 @@ // forward declarations -namespace hgcal { +namespace ticl { class LayerClusterToCaloParticleAssociator { public: - LayerClusterToCaloParticleAssociator(std::unique_ptr); + LayerClusterToCaloParticleAssociator(std::unique_ptr); LayerClusterToCaloParticleAssociator() = default; LayerClusterToCaloParticleAssociator(LayerClusterToCaloParticleAssociator &&) = default; LayerClusterToCaloParticleAssociator &operator=(LayerClusterToCaloParticleAssociator &&) = default; @@ -27,14 +27,14 @@ namespace hgcal { // ---------- const member functions --------------------- /// Associate a LayerCluster to CaloParticles - hgcal::RecoToSimCollection associateRecoToSim(const edm::Handle &cCCH, - const edm::Handle &cPCH) const { + ticl::RecoToSimCollection associateRecoToSim(const edm::Handle &cCCH, + const edm::Handle &cPCH) const { return m_impl->associateRecoToSim(cCCH, cPCH); }; /// Associate a CaloParticle to LayerClusters - hgcal::SimToRecoCollection associateSimToReco(const edm::Handle &cCCH, - const edm::Handle &cPCH) const { + ticl::SimToRecoCollection associateSimToReco(const edm::Handle &cCCH, + const edm::Handle &cPCH) const { return m_impl->associateSimToReco(cCCH, cPCH); } @@ -42,6 +42,6 @@ namespace hgcal { // ---------- member data -------------------------------- std::unique_ptr m_impl; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociatorBaseImpl.h b/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociatorBaseImpl.h index 8ff66876ba3e8..c61f36f362575 100644 --- a/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociatorBaseImpl.h +++ b/SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociatorBaseImpl.h @@ -16,7 +16,7 @@ #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h" -namespace hgcal { +namespace ticl { typedef edm::AssociationMap< edm::OneToManyWithQualityGeneric>> @@ -33,13 +33,13 @@ namespace hgcal { virtual ~LayerClusterToCaloParticleAssociatorBaseImpl(); /// Associate a LayerCluster to CaloParticles - virtual hgcal::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, - const edm::Handle &cPCH) const; + virtual ticl::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, + const edm::Handle &cPCH) const; /// Associate a CaloParticle to LayerClusters - virtual hgcal::SimToRecoCollection associateSimToReco(const edm::Handle &cCH, - const edm::Handle &cPCH) const; + virtual ticl::SimToRecoCollection associateSimToReco(const edm::Handle &cCH, + const edm::Handle &cPCH) const; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h b/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h index 094db05e3ba5d..6953c0fb3975c 100644 --- a/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h +++ b/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h @@ -11,11 +11,11 @@ // forward declarations -namespace hgcal { +namespace ticl { class LayerClusterToSimClusterAssociator { public: - LayerClusterToSimClusterAssociator(std::unique_ptr); + LayerClusterToSimClusterAssociator(std::unique_ptr); LayerClusterToSimClusterAssociator() = default; LayerClusterToSimClusterAssociator(LayerClusterToSimClusterAssociator &&) = default; LayerClusterToSimClusterAssociator &operator=(LayerClusterToSimClusterAssociator &&) = default; @@ -26,14 +26,14 @@ namespace hgcal { delete; // stop default // ---------- const member functions --------------------- /// Associate a LayerCluster to SimClusters - hgcal::RecoToSimCollectionWithSimClusters associateRecoToSim(const edm::Handle &cCCH, - const edm::Handle &sCCH) const { + ticl::RecoToSimCollectionWithSimClusters associateRecoToSim(const edm::Handle &cCCH, + const edm::Handle &sCCH) const { return m_impl->associateRecoToSim(cCCH, sCCH); }; /// Associate a SimCluster to LayerClusters - hgcal::SimToRecoCollectionWithSimClusters associateSimToReco(const edm::Handle &cCCH, - const edm::Handle &sCCH) const { + ticl::SimToRecoCollectionWithSimClusters associateSimToReco(const edm::Handle &cCCH, + const edm::Handle &sCCH) const { return m_impl->associateSimToReco(cCCH, sCCH); } @@ -41,6 +41,6 @@ namespace hgcal { // ---------- member data -------------------------------- std::unique_ptr m_impl; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociatorBaseImpl.h b/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociatorBaseImpl.h index 6045bc6cdf0c7..3c1fe3a9973fa 100644 --- a/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociatorBaseImpl.h +++ b/SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociatorBaseImpl.h @@ -16,7 +16,7 @@ #include "SimDataFormats/CaloAnalysis/interface/SimClusterFwd.h" -namespace hgcal { +namespace ticl { typedef edm::AssociationMap< edm::OneToManyWithQualityGeneric>> @@ -32,13 +32,13 @@ namespace hgcal { virtual ~LayerClusterToSimClusterAssociatorBaseImpl(); /// Associate a LayerCluster to SimClusters - virtual hgcal::RecoToSimCollectionWithSimClusters associateRecoToSim( + virtual ticl::RecoToSimCollectionWithSimClusters associateRecoToSim( const edm::Handle &cCH, const edm::Handle &sCCH) const; /// Associate a SimCluster to LayerClusters - virtual hgcal::SimToRecoCollectionWithSimClusters associateSimToReco( + virtual ticl::SimToRecoCollectionWithSimClusters associateSimToReco( const edm::Handle &cCH, const edm::Handle &sCCH) const; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociator.h b/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociator.h index 6f2533f24285e..77db7c9afce23 100644 --- a/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociator.h +++ b/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociator.h @@ -11,11 +11,11 @@ // forward declarations -namespace hgcal { +namespace ticl { class LayerClusterToSimTracksterAssociator { public: - LayerClusterToSimTracksterAssociator(std::unique_ptr); + LayerClusterToSimTracksterAssociator(std::unique_ptr); LayerClusterToSimTracksterAssociator() = default; LayerClusterToSimTracksterAssociator(LayerClusterToSimTracksterAssociator &&) = default; LayerClusterToSimTracksterAssociator &operator=(LayerClusterToSimTracksterAssociator &&) = default; @@ -27,24 +27,24 @@ namespace hgcal { // ---------- const member functions --------------------- /// Associate a LayerCluster to SimTracksters - hgcal::RecoToSimTracksterCollection associateRecoToSim( + ticl::RecoToSimTracksterCollection associateRecoToSim( const edm::Handle &cCCH, const edm::Handle &stCH, const edm::Handle &cPCH, - const hgcal::RecoToSimCollection &lCToCPs, + const ticl::RecoToSimCollection &lCToCPs, const edm::Handle &sCCH, - const hgcal::RecoToSimCollectionWithSimClusters &lCToSCs) const { + const ticl::RecoToSimCollectionWithSimClusters &lCToSCs) const { return m_impl->associateRecoToSim(cCCH, stCH, cPCH, lCToCPs, sCCH, lCToSCs); }; /// Associate a SimTrackster to LayerClusters - hgcal::SimTracksterToRecoCollection associateSimToReco( + ticl::SimTracksterToRecoCollection associateSimToReco( const edm::Handle &cCCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::SimToRecoCollection &cpToLCs, + const ticl::SimToRecoCollection &cpToLCs, const edm::Handle &sCCH, - const hgcal::SimToRecoCollectionWithSimClusters &sCToLCs) const { + const ticl::SimToRecoCollectionWithSimClusters &sCToLCs) const { return m_impl->associateSimToReco(cCCH, sTCH, cPCH, cpToLCs, sCCH, sCToLCs); } @@ -52,6 +52,6 @@ namespace hgcal { // ---------- member data -------------------------------- std::unique_ptr m_impl; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociatorBaseImpl.h b/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociatorBaseImpl.h index 771b7c2395aa3..9882ce85b5280 100644 --- a/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociatorBaseImpl.h +++ b/SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociatorBaseImpl.h @@ -20,7 +20,7 @@ #include "SimDataFormats/CaloAnalysis/interface/SimClusterFwd.h" #include "LayerClusterToSimClusterAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { typedef edm::AssociationMap< edm::OneToManyWithQualityGeneric>> @@ -37,23 +37,23 @@ namespace hgcal { virtual ~LayerClusterToSimTracksterAssociatorBaseImpl(); /// Associate a LayerCluster to SimTracksters - virtual hgcal::RecoToSimTracksterCollection associateRecoToSim( + virtual ticl::RecoToSimTracksterCollection associateRecoToSim( const edm::Handle &cCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::RecoToSimCollection &lCToCPs, + const ticl::RecoToSimCollection &lCToCPs, const edm::Handle &sCCH, - const hgcal::RecoToSimCollectionWithSimClusters &lCToSCs) const; + const ticl::RecoToSimCollectionWithSimClusters &lCToSCs) const; /// Associate a SimTrackster to LayerClusters - virtual hgcal::SimTracksterToRecoCollection associateSimToReco( + virtual ticl::SimTracksterToRecoCollection associateSimToReco( const edm::Handle &cCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::SimToRecoCollection &cPToLCs, + const ticl::SimToRecoCollection &cPToLCs, const edm::Handle &sCCH, - const hgcal::SimToRecoCollectionWithSimClusters &sCToLCs) const; + const ticl::SimToRecoCollectionWithSimClusters &sCToLCs) const; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/TracksterToSimClusterAssociator.h b/SimDataFormats/Associations/interface/TracksterToSimClusterAssociator.h index a3ef0455a4ebc..3bcfa788b9c95 100644 --- a/SimDataFormats/Associations/interface/TracksterToSimClusterAssociator.h +++ b/SimDataFormats/Associations/interface/TracksterToSimClusterAssociator.h @@ -11,11 +11,11 @@ // forward declarations -namespace hgcal { +namespace ticl { class TracksterToSimClusterAssociator { public: - TracksterToSimClusterAssociator(std::unique_ptr); + TracksterToSimClusterAssociator(std::unique_ptr); TracksterToSimClusterAssociator() = default; TracksterToSimClusterAssociator(TracksterToSimClusterAssociator &&) = default; TracksterToSimClusterAssociator &operator=(TracksterToSimClusterAssociator &&) = default; @@ -26,16 +26,16 @@ namespace hgcal { // ---------- const member functions --------------------- /// Associate a Trackster to SimClusters - hgcal::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const { + ticl::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const { return m_impl->associateRecoToSim(tCH, lCCH, sCCH); }; /// Associate a SimCluster to Tracksters - hgcal::SimToRecoCollectionTracksters associateSimToReco(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const { + ticl::SimToRecoCollectionTracksters associateSimToReco(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const { return m_impl->associateSimToReco(tCH, lCCH, sCCH); } @@ -43,6 +43,6 @@ namespace hgcal { // ---------- member data -------------------------------- std::unique_ptr m_impl; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/TracksterToSimClusterAssociatorBaseImpl.h b/SimDataFormats/Associations/interface/TracksterToSimClusterAssociatorBaseImpl.h index 236fd1dd3a81c..0c75ec32e9f0c 100644 --- a/SimDataFormats/Associations/interface/TracksterToSimClusterAssociatorBaseImpl.h +++ b/SimDataFormats/Associations/interface/TracksterToSimClusterAssociatorBaseImpl.h @@ -17,7 +17,7 @@ #include "SimDataFormats/CaloAnalysis/interface/SimClusterFwd.h" -namespace hgcal { +namespace ticl { typedef edm::AssociationMap< edm::OneToManyWithQualityGeneric>> @@ -33,17 +33,15 @@ namespace hgcal { virtual ~TracksterToSimClusterAssociatorBaseImpl(); /// Associate a Trackster to SimClusters - virtual hgcal::RecoToSimCollectionTracksters associateRecoToSim( - const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const; + virtual ticl::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const; /// Associate a SimCluster to Tracksters - virtual hgcal::SimToRecoCollectionTracksters associateSimToReco( - const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH) const; + virtual ticl::SimToRecoCollectionTracksters associateSimToReco(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH) const; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h b/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h index bf48e3e766396..301922fc32779 100644 --- a/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h +++ b/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h @@ -11,11 +11,11 @@ // forward declarations -namespace hgcal { +namespace ticl { class TracksterToSimTracksterAssociator { public: - TracksterToSimTracksterAssociator(std::unique_ptr); + TracksterToSimTracksterAssociator(std::unique_ptr); TracksterToSimTracksterAssociator() = default; TracksterToSimTracksterAssociator(TracksterToSimTracksterAssociator &&) = default; TracksterToSimTracksterAssociator &operator=(TracksterToSimTracksterAssociator &&) = default; @@ -27,18 +27,16 @@ namespace hgcal { // ---------- const member functions --------------------- /// Associate a Trackster to SimClusters - hgcal::RecoToSimCollectionSimTracksters associateRecoToSim( - const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sTCH) const { + ticl::RecoToSimCollectionSimTracksters associateRecoToSim(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sTCH) const { return m_impl->associateRecoToSim(tCH, lCCH, sTCH); }; /// Associate a SimCluster to Tracksters - hgcal::SimToRecoCollectionSimTracksters associateSimToReco( - const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sTCH) const { + ticl::SimToRecoCollectionSimTracksters associateSimToReco(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sTCH) const { return m_impl->associateSimToReco(tCH, lCCH, sTCH); } @@ -46,6 +44,6 @@ namespace hgcal { // ---------- member data -------------------------------- std::unique_ptr m_impl; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociatorBaseImpl.h b/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociatorBaseImpl.h index 08839cc729cc6..70645def48314 100644 --- a/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociatorBaseImpl.h +++ b/SimDataFormats/Associations/interface/TracksterToSimTracksterAssociatorBaseImpl.h @@ -17,7 +17,7 @@ #include "SimDataFormats/CaloAnalysis/interface/SimClusterFwd.h" -namespace hgcal { +namespace ticl { typedef edm::AssociationMap< edm::OneToManyWithQualityGeneric>> @@ -34,17 +34,17 @@ namespace hgcal { virtual ~TracksterToSimTracksterAssociatorBaseImpl(); /// Associate a Trackster to SimClusters - virtual hgcal::RecoToSimCollectionSimTracksters associateRecoToSim( + virtual ticl::RecoToSimCollectionSimTracksters associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sTCH) const; /// Associate a SimCluster to Tracksters - virtual hgcal::SimToRecoCollectionSimTracksters associateSimToReco( + virtual ticl::SimToRecoCollectionSimTracksters associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sTCH) const; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociator.h b/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociator.h index 5162e2bd08ec2..d66ed0685b5f9 100644 --- a/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociator.h +++ b/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociator.h @@ -9,11 +9,11 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { class TracksterToSimTracksterHitLCAssociator { public: - TracksterToSimTracksterHitLCAssociator(std::unique_ptr); + TracksterToSimTracksterHitLCAssociator(std::unique_ptr); TracksterToSimTracksterHitLCAssociator() = default; TracksterToSimTracksterHitLCAssociator(TracksterToSimTracksterHitLCAssociator &&) = default; TracksterToSimTracksterHitLCAssociator &operator=(TracksterToSimTracksterHitLCAssociator &&) = default; @@ -22,36 +22,34 @@ namespace hgcal { ~TracksterToSimTracksterHitLCAssociator() = default; - hgcal::association_t makeConnections(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH, - const edm::Handle &cPCH, - const edm::Handle &sTCH) const { + ticl::association_t makeConnections(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH, + const edm::Handle &cPCH, + const edm::Handle &sTCH) const { return m_impl->makeConnections(tCH, lCCH, sCCH, cPCH, sTCH); } /// Associate a Trackster to SimClusters - hgcal::RecoToSimCollectionSimTracksters associateRecoToSim( - const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH, - const edm::Handle &cPCH, - const edm::Handle &sTCH) const { + ticl::RecoToSimCollectionSimTracksters associateRecoToSim(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH, + const edm::Handle &cPCH, + const edm::Handle &sTCH) const { return m_impl->associateRecoToSim(tCH, lCCH, sCCH, cPCH, sTCH); }; /// Associate a SimCluster to Tracksters - hgcal::SimToRecoCollectionSimTracksters associateSimToReco( - const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH, - const edm::Handle &cPCH, - const edm::Handle &sTCH) const { + ticl::SimToRecoCollectionSimTracksters associateSimToReco(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH, + const edm::Handle &cPCH, + const edm::Handle &sTCH) const { return m_impl->associateSimToReco(tCH, lCCH, sCCH, cPCH, sTCH); } private: std::unique_ptr m_impl; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociatorBaseImpl.h b/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociatorBaseImpl.h index 405657555f032..c9aea02a7b355 100644 --- a/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociatorBaseImpl.h +++ b/SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociatorBaseImpl.h @@ -10,7 +10,7 @@ typedef std::vector SimClusterCollection; #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h" -namespace hgcal { +namespace ticl { enum validationType { Linking = 0, PatternRecognition, PatternRecognition_CP }; @@ -31,14 +31,14 @@ namespace hgcal { /// Destructor virtual ~TracksterToSimTracksterHitLCAssociatorBaseImpl(); - hgcal::association_t makeConnections(const edm::Handle &tCH, - const edm::Handle &lCCH, - const edm::Handle &sCCH, - const edm::Handle &cPCH, - const edm::Handle &sTCH) const; + ticl::association_t makeConnections(const edm::Handle &tCH, + const edm::Handle &lCCH, + const edm::Handle &sCCH, + const edm::Handle &cPCH, + const edm::Handle &sTCH) const; /// Associate a Trackster to SimClusters - virtual hgcal::RecoToSimCollectionSimTracksters associateRecoToSim( + virtual ticl::RecoToSimCollectionSimTracksters associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, @@ -46,13 +46,13 @@ namespace hgcal { const edm::Handle &sTCH) const; /// Associate a SimCluster to Tracksters - virtual hgcal::SimToRecoCollectionSimTracksters associateSimToReco( + virtual ticl::SimToRecoCollectionSimTracksters associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, const edm::Handle &cPCH, const edm::Handle &sTCH) const; }; -} // namespace hgcal +} // namespace ticl #endif diff --git a/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociator.cc b/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociator.cc index 38d74d2b4e12f..78ee7e394e2b0 100644 --- a/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociator.cc +++ b/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociator.cc @@ -2,6 +2,6 @@ #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h" -hgcal::LayerClusterToCaloParticleAssociator::LayerClusterToCaloParticleAssociator( - std::unique_ptr ptr) +ticl::LayerClusterToCaloParticleAssociator::LayerClusterToCaloParticleAssociator( + std::unique_ptr ptr) : m_impl(std::move(ptr)) {} diff --git a/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociatorBaseImpl.cc b/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociatorBaseImpl.cc index ccc25fdd7bac4..ef1319232f42d 100644 --- a/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociatorBaseImpl.cc +++ b/SimDataFormats/Associations/src/LayerClusterToCaloParticleAssociatorBaseImpl.cc @@ -2,18 +2,18 @@ #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { LayerClusterToCaloParticleAssociatorBaseImpl::LayerClusterToCaloParticleAssociatorBaseImpl(){}; LayerClusterToCaloParticleAssociatorBaseImpl::~LayerClusterToCaloParticleAssociatorBaseImpl(){}; - hgcal::RecoToSimCollection LayerClusterToCaloParticleAssociatorBaseImpl::associateRecoToSim( + ticl::RecoToSimCollection LayerClusterToCaloParticleAssociatorBaseImpl::associateRecoToSim( const edm::Handle &cCCH, const edm::Handle &cPCH) const { - return hgcal::RecoToSimCollection(); + return ticl::RecoToSimCollection(); } - hgcal::SimToRecoCollection LayerClusterToCaloParticleAssociatorBaseImpl::associateSimToReco( + ticl::SimToRecoCollection LayerClusterToCaloParticleAssociatorBaseImpl::associateSimToReco( const edm::Handle &cCCH, const edm::Handle &cPCH) const { - return hgcal::SimToRecoCollection(); + return ticl::SimToRecoCollection(); } -} // namespace hgcal +} // namespace ticl diff --git a/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociator.cc b/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociator.cc index cca007e3af4ab..2d1ac9c97a69e 100644 --- a/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociator.cc +++ b/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociator.cc @@ -2,6 +2,6 @@ #include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h" -hgcal::LayerClusterToSimClusterAssociator::LayerClusterToSimClusterAssociator( - std::unique_ptr ptr) +ticl::LayerClusterToSimClusterAssociator::LayerClusterToSimClusterAssociator( + std::unique_ptr ptr) : m_impl(std::move(ptr)) {} diff --git a/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociatorBaseImpl.cc b/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociatorBaseImpl.cc index 5590214fda76f..acba47cf47e07 100644 --- a/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociatorBaseImpl.cc +++ b/SimDataFormats/Associations/src/LayerClusterToSimClusterAssociatorBaseImpl.cc @@ -2,18 +2,18 @@ #include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { LayerClusterToSimClusterAssociatorBaseImpl::LayerClusterToSimClusterAssociatorBaseImpl(){}; LayerClusterToSimClusterAssociatorBaseImpl::~LayerClusterToSimClusterAssociatorBaseImpl(){}; - hgcal::RecoToSimCollectionWithSimClusters LayerClusterToSimClusterAssociatorBaseImpl::associateRecoToSim( + ticl::RecoToSimCollectionWithSimClusters LayerClusterToSimClusterAssociatorBaseImpl::associateRecoToSim( const edm::Handle &cCCH, const edm::Handle &sCCH) const { - return hgcal::RecoToSimCollectionWithSimClusters(); + return ticl::RecoToSimCollectionWithSimClusters(); } - hgcal::SimToRecoCollectionWithSimClusters LayerClusterToSimClusterAssociatorBaseImpl::associateSimToReco( + ticl::SimToRecoCollectionWithSimClusters LayerClusterToSimClusterAssociatorBaseImpl::associateSimToReco( const edm::Handle &cCCH, const edm::Handle &sCCH) const { - return hgcal::SimToRecoCollectionWithSimClusters(); + return ticl::SimToRecoCollectionWithSimClusters(); } -} // namespace hgcal +} // namespace ticl diff --git a/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociator.cc b/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociator.cc index 16bd0b27bbd7d..21ca5bf52d152 100644 --- a/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociator.cc +++ b/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociator.cc @@ -2,6 +2,6 @@ #include "SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociator.h" -hgcal::LayerClusterToSimTracksterAssociator::LayerClusterToSimTracksterAssociator( - std::unique_ptr ptr) +ticl::LayerClusterToSimTracksterAssociator::LayerClusterToSimTracksterAssociator( + std::unique_ptr ptr) : m_impl(std::move(ptr)) {} diff --git a/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociatorBaseImpl.cc b/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociatorBaseImpl.cc index d873282791428..4354cf017e248 100644 --- a/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociatorBaseImpl.cc +++ b/SimDataFormats/Associations/src/LayerClusterToSimTracksterAssociatorBaseImpl.cc @@ -2,28 +2,28 @@ #include "SimDataFormats/Associations/interface/LayerClusterToSimTracksterAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { LayerClusterToSimTracksterAssociatorBaseImpl::LayerClusterToSimTracksterAssociatorBaseImpl(){}; LayerClusterToSimTracksterAssociatorBaseImpl::~LayerClusterToSimTracksterAssociatorBaseImpl(){}; - hgcal::RecoToSimTracksterCollection LayerClusterToSimTracksterAssociatorBaseImpl::associateRecoToSim( + ticl::RecoToSimTracksterCollection LayerClusterToSimTracksterAssociatorBaseImpl::associateRecoToSim( const edm::Handle &cCCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::RecoToSimCollection &lCToCPs, + const ticl::RecoToSimCollection &lCToCPs, const edm::Handle &sCCH, - const hgcal::RecoToSimCollectionWithSimClusters &lCToSCs) const { - return hgcal::RecoToSimTracksterCollection(); + const ticl::RecoToSimCollectionWithSimClusters &lCToSCs) const { + return ticl::RecoToSimTracksterCollection(); } - hgcal::SimTracksterToRecoCollection LayerClusterToSimTracksterAssociatorBaseImpl::associateSimToReco( + ticl::SimTracksterToRecoCollection LayerClusterToSimTracksterAssociatorBaseImpl::associateSimToReco( const edm::Handle &cCCH, const edm::Handle &sTCH, const edm::Handle &cPCH, - const hgcal::SimToRecoCollection &cPToLCs, + const ticl::SimToRecoCollection &cPToLCs, const edm::Handle &sCCH, - const hgcal::SimToRecoCollectionWithSimClusters &sCToLCs) const { - return hgcal::SimTracksterToRecoCollection(); + const ticl::SimToRecoCollectionWithSimClusters &sCToLCs) const { + return ticl::SimTracksterToRecoCollection(); } -} // namespace hgcal +} // namespace ticl diff --git a/SimDataFormats/Associations/src/TracksterToSimClusterAssociator.cc b/SimDataFormats/Associations/src/TracksterToSimClusterAssociator.cc index 791ab3acfecf1..86edc22ff26e4 100644 --- a/SimDataFormats/Associations/src/TracksterToSimClusterAssociator.cc +++ b/SimDataFormats/Associations/src/TracksterToSimClusterAssociator.cc @@ -2,6 +2,6 @@ #include "SimDataFormats/Associations/interface/TracksterToSimClusterAssociator.h" -hgcal::TracksterToSimClusterAssociator::TracksterToSimClusterAssociator( - std::unique_ptr ptr) +ticl::TracksterToSimClusterAssociator::TracksterToSimClusterAssociator( + std::unique_ptr ptr) : m_impl(std::move(ptr)) {} diff --git a/SimDataFormats/Associations/src/TracksterToSimClusterAssociatorBaseImpl.cc b/SimDataFormats/Associations/src/TracksterToSimClusterAssociatorBaseImpl.cc index a049ff94788e5..08ba2f2de9fb9 100644 --- a/SimDataFormats/Associations/src/TracksterToSimClusterAssociatorBaseImpl.cc +++ b/SimDataFormats/Associations/src/TracksterToSimClusterAssociatorBaseImpl.cc @@ -2,22 +2,22 @@ #include "SimDataFormats/Associations/interface/TracksterToSimClusterAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { TracksterToSimClusterAssociatorBaseImpl::TracksterToSimClusterAssociatorBaseImpl(){}; TracksterToSimClusterAssociatorBaseImpl::~TracksterToSimClusterAssociatorBaseImpl(){}; - hgcal::RecoToSimCollectionTracksters TracksterToSimClusterAssociatorBaseImpl::associateRecoToSim( + ticl::RecoToSimCollectionTracksters TracksterToSimClusterAssociatorBaseImpl::associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH) const { - return hgcal::RecoToSimCollectionTracksters(); + return ticl::RecoToSimCollectionTracksters(); } - hgcal::SimToRecoCollectionTracksters TracksterToSimClusterAssociatorBaseImpl::associateSimToReco( + ticl::SimToRecoCollectionTracksters TracksterToSimClusterAssociatorBaseImpl::associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH) const { - return hgcal::SimToRecoCollectionTracksters(); + return ticl::SimToRecoCollectionTracksters(); } -} // namespace hgcal +} // namespace ticl diff --git a/SimDataFormats/Associations/src/TracksterToSimTracksterAssociator.cc b/SimDataFormats/Associations/src/TracksterToSimTracksterAssociator.cc index 1ed56d7610c2b..5c2702084dd11 100644 --- a/SimDataFormats/Associations/src/TracksterToSimTracksterAssociator.cc +++ b/SimDataFormats/Associations/src/TracksterToSimTracksterAssociator.cc @@ -2,6 +2,6 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h" -hgcal::TracksterToSimTracksterAssociator::TracksterToSimTracksterAssociator( - std::unique_ptr ptr) +ticl::TracksterToSimTracksterAssociator::TracksterToSimTracksterAssociator( + std::unique_ptr ptr) : m_impl(std::move(ptr)) {} diff --git a/SimDataFormats/Associations/src/TracksterToSimTracksterAssociatorBaseImpl.cc b/SimDataFormats/Associations/src/TracksterToSimTracksterAssociatorBaseImpl.cc index fd2d725092ce7..82ab31d4630df 100644 --- a/SimDataFormats/Associations/src/TracksterToSimTracksterAssociatorBaseImpl.cc +++ b/SimDataFormats/Associations/src/TracksterToSimTracksterAssociatorBaseImpl.cc @@ -2,22 +2,22 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { TracksterToSimTracksterAssociatorBaseImpl::TracksterToSimTracksterAssociatorBaseImpl(){}; TracksterToSimTracksterAssociatorBaseImpl::~TracksterToSimTracksterAssociatorBaseImpl(){}; - hgcal::RecoToSimCollectionSimTracksters TracksterToSimTracksterAssociatorBaseImpl::associateRecoToSim( + ticl::RecoToSimCollectionSimTracksters TracksterToSimTracksterAssociatorBaseImpl::associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sTCH) const { - return hgcal::RecoToSimCollectionSimTracksters(); + return ticl::RecoToSimCollectionSimTracksters(); } - hgcal::SimToRecoCollectionSimTracksters TracksterToSimTracksterAssociatorBaseImpl::associateSimToReco( + ticl::SimToRecoCollectionSimTracksters TracksterToSimTracksterAssociatorBaseImpl::associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sTCH) const { - return hgcal::SimToRecoCollectionSimTracksters(); + return ticl::SimToRecoCollectionSimTracksters(); } -} // namespace hgcal +} // namespace ticl diff --git a/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociator.cc b/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociator.cc index 8ff90ed3d7123..fa7d4b61fc695 100644 --- a/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociator.cc +++ b/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociator.cc @@ -1,5 +1,5 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociator.h" -hgcal::TracksterToSimTracksterHitLCAssociator::TracksterToSimTracksterHitLCAssociator( - std::unique_ptr ptr) +ticl::TracksterToSimTracksterHitLCAssociator::TracksterToSimTracksterHitLCAssociator( + std::unique_ptr ptr) : m_impl(std::move(ptr)) {} diff --git a/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociatorBaseImpl.cc b/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociatorBaseImpl.cc index 6b169b9724e41..83e1a9fc52a44 100644 --- a/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociatorBaseImpl.cc +++ b/SimDataFormats/Associations/src/TracksterToSimTracksterHitLCAssociatorBaseImpl.cc @@ -1,34 +1,34 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociatorBaseImpl.h" -namespace hgcal { +namespace ticl { TracksterToSimTracksterHitLCAssociatorBaseImpl::TracksterToSimTracksterHitLCAssociatorBaseImpl(){}; TracksterToSimTracksterHitLCAssociatorBaseImpl::~TracksterToSimTracksterHitLCAssociatorBaseImpl(){}; - hgcal::association_t TracksterToSimTracksterHitLCAssociatorBaseImpl::makeConnections( + ticl::association_t TracksterToSimTracksterHitLCAssociatorBaseImpl::makeConnections( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, const edm::Handle &cPCH, const edm::Handle &sTCH) const { - return hgcal::association_t(); + return ticl::association_t(); } - hgcal::RecoToSimCollectionSimTracksters TracksterToSimTracksterHitLCAssociatorBaseImpl::associateRecoToSim( + ticl::RecoToSimCollectionSimTracksters TracksterToSimTracksterHitLCAssociatorBaseImpl::associateRecoToSim( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, const edm::Handle &cPCH, const edm::Handle &sTCH) const { - return hgcal::RecoToSimCollectionSimTracksters(); + return ticl::RecoToSimCollectionSimTracksters(); } - hgcal::SimToRecoCollectionSimTracksters TracksterToSimTracksterHitLCAssociatorBaseImpl::associateSimToReco( + ticl::SimToRecoCollectionSimTracksters TracksterToSimTracksterHitLCAssociatorBaseImpl::associateSimToReco( const edm::Handle &tCH, const edm::Handle &lCCH, const edm::Handle &sCCH, const edm::Handle &cPCH, const edm::Handle &sTCH) const { - return hgcal::SimToRecoCollectionSimTracksters(); + return ticl::SimToRecoCollectionSimTracksters(); } -} // namespace hgcal +} // namespace ticl diff --git a/SimDataFormats/Associations/src/classes_def.xml b/SimDataFormats/Associations/src/classes_def.xml index 88a0fcf6b56b7..492d07eb55140 100644 --- a/SimDataFormats/Associations/src/classes_def.xml +++ b/SimDataFormats/Associations/src/classes_def.xml @@ -10,26 +10,26 @@ - - + + - - + + - - + + - - + + - - + + - - + + @@ -41,14 +41,14 @@ - + - - + + - + @@ -56,28 +56,28 @@ - + - - + + - + - + - - + + - + @@ -111,26 +111,26 @@ - + - - + + - + - + - - + + - + diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index 48fc3dc52f7b0..414523acdfc05 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -89,10 +89,10 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { edm::EDGetTokenT> simVertices_; std::vector>> clustersMaskTokens_; edm::EDGetTokenT> hitMap_; - edm::EDGetTokenT associatorMapRtS; - edm::EDGetTokenT associatorMapStR; - edm::EDGetTokenT associatorMapSimtR; - edm::EDGetTokenT associatorMapRtSim; + edm::EDGetTokenT associatorMapRtS; + edm::EDGetTokenT associatorMapStR; + edm::EDGetTokenT associatorMapSimtR; + edm::EDGetTokenT associatorMapRtSim; std::unique_ptr histoProducerAlgo_; private: diff --git a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h index 184b0987bbf46..91d568e18e922 100644 --- a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h +++ b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h @@ -271,8 +271,8 @@ class HGVHistoProducerAlgo { std::vector const& cPSelectedIndices, std::unordered_map const&, unsigned int layers, - const hgcal::RecoToSimCollection& recSimColl, - const hgcal::SimToRecoCollection& simRecColl) const; + const ticl::RecoToSimCollection& recSimColl, + const ticl::SimToRecoCollection& simRecColl) const; void layerClusters_to_SimClusters(const Histograms& histograms, const int count, edm::Handle clusterHandle, @@ -283,8 +283,8 @@ class HGVHistoProducerAlgo { const std::vector& mask, std::unordered_map const&, unsigned int layers, - const hgcal::RecoToSimCollectionWithSimClusters& recSimColl, - const hgcal::SimToRecoCollectionWithSimClusters& simRecColl) const; + const ticl::RecoToSimCollectionWithSimClusters& recSimColl, + const ticl::SimToRecoCollectionWithSimClusters& simRecColl) const; void tracksters_to_SimTracksters(const Histograms& histograms, const int count, const ticl::TracksterCollection& Tracksters, @@ -319,8 +319,8 @@ class HGVHistoProducerAlgo { std::map cummatbudg, unsigned int layers, std::vector thicknesses, - const hgcal::RecoToSimCollection& recSimColl, - const hgcal::SimToRecoCollection& simRecColl) const; + const ticl::RecoToSimCollection& recSimColl, + const ticl::SimToRecoCollection& simRecColl) const; void fill_simCluster_histos(const Histograms& histograms, std::vector const& simClusters, unsigned int layers, @@ -335,8 +335,8 @@ class HGVHistoProducerAlgo { const std::vector& mask, std::unordered_map const& hitMap, unsigned int layers, - const hgcal::RecoToSimCollectionWithSimClusters& recSimColl, - const hgcal::SimToRecoCollectionWithSimClusters& simRecColl) const; + const ticl::RecoToSimCollectionWithSimClusters& recSimColl, + const ticl::SimToRecoCollectionWithSimClusters& simRecColl) const; void fill_cluster_histos(const Histograms& histograms, const int count, const reco::CaloCluster& cluster) const; void fill_trackster_histos(const Histograms& histograms, const int count, diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 3750312898480..0436b812eb5da 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -44,8 +44,8 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) clustersMaskTokens_.push_back(consumes>(itag)); } - associatorMapSimtR = consumes(associatorSim_); - associatorMapRtSim = consumes(associatorSim_); + associatorMapSimtR = consumes(associatorSim_); + associatorMapRtSim = consumes(associatorSim_); simTrackstersMap_ = consumes>>(edm::InputTag("ticlSimTracksters")); @@ -62,8 +62,8 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) simTracksters_ = consumes(label_simTS); simTracksters_fromCPs_ = consumes(label_simTSFromCP); - associatorMapRtS = consumes(associator_); - associatorMapStR = consumes(associator_); + associatorMapRtS = consumes(associator_); + associatorMapStR = consumes(associator_); cpSelector = CaloParticleSelector(pset.getParameter("ptMinCP"), pset.getParameter("ptMaxCP"), @@ -280,10 +280,10 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, tools_->setGeometry(*geom); histoProducerAlgo_->setRecHitTools(tools_); - edm::Handle simtorecoCollectionH; + edm::Handle simtorecoCollectionH; event.getByToken(associatorMapStR, simtorecoCollectionH); auto simRecColl = *simtorecoCollectionH; - edm::Handle recotosimCollectionH; + edm::Handle recotosimCollectionH; event.getByToken(associatorMapRtS, recotosimCollectionH); auto recSimColl = *recotosimCollectionH; @@ -346,10 +346,10 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, for (unsigned int ws = 0; ws < label_clustersmask.size(); ws++) { const auto& inputClusterMask = event.get(clustersMaskTokens_[ws]); - edm::Handle simtorecoCollectionH; + edm::Handle simtorecoCollectionH; event.getByToken(associatorMapSimtR, simtorecoCollectionH); auto simRecColl = *simtorecoCollectionH; - edm::Handle recotosimCollectionH; + edm::Handle recotosimCollectionH; event.getByToken(associatorMapRtSim, recotosimCollectionH); auto recSimColl = *recotosimCollectionH; diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index ff64fba9959bd..4db5eb98a375e 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1705,8 +1705,8 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simClusterAssociation_hist const std::vector& mask, std::unordered_map const& hitMap, unsigned int layers, - const hgcal::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, - const hgcal::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap) const { + const ticl::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, + const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap) const { //Each event to be treated as two events: an event in +ve endcap, //plus another event in -ve endcap. In this spirit there will be //a layer variable (layerid) that maps the layers in : @@ -1745,8 +1745,8 @@ void HGVHistoProducerAlgo::layerClusters_to_CaloParticles(const Histograms& hist std::vector const& cPSelectedIndices, std::unordered_map const& hitMap, unsigned int layers, - const hgcal::RecoToSimCollection& cpsInLayerClusterMap, - const hgcal::SimToRecoCollection& cPOnLayerMap) const { + const ticl::RecoToSimCollection& cpsInLayerClusterMap, + const ticl::SimToRecoCollection& cPOnLayerMap) const { const auto nLayerClusters = clusters.size(); std::unordered_map> detIdToCaloParticleId_Map; @@ -2005,8 +2005,8 @@ void HGVHistoProducerAlgo::layerClusters_to_SimClusters( const std::vector& mask, std::unordered_map const& hitMap, unsigned int layers, - const hgcal::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, - const hgcal::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap) const { + const ticl::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, + const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap) const { // Here fill the plots to compute the different metrics linked to // reco-level, namely fake-rate and merge-rate. In this loop should *not* // restrict only to the selected SimClusters. @@ -2185,8 +2185,8 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr std::map cummatbudg, unsigned int layers, std::vector thicknesses, - const hgcal::RecoToSimCollection& cpsInLayerClusterMap, - const hgcal::SimToRecoCollection& cPOnLayerMap) const { + const ticl::RecoToSimCollection& cpsInLayerClusterMap, + const ticl::SimToRecoCollection& cPOnLayerMap) const { //Each event to be treated as two events: an event in +ve endcap, //plus another event in -ve endcap. In this spirit there will be //a layer variable (layerid) that maps the layers in : From 6ac13787bcea7a9cb3b06d075b86ed2eee9e915f Mon Sep 17 00:00:00 2001 From: brusale Date: Fri, 1 Dec 2023 16:41:33 +0100 Subject: [PATCH 005/301] restrict to hits in HGCal --- .../src/HGVHistoProducerAlgo.cc | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index 4db5eb98a375e..99e8d632fcc9b 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1612,49 +1612,47 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simCluster_histos(const Hi for (const auto& hAndF : sc.hits_and_fractions()) { const DetId sh_detid = hAndF.first; - //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. - int layerid = - recHitTools_->getLayerWithOffset(sh_detid) + layers * ((recHitTools_->zside(sh_detid) + 1) >> 1) - 1; - //zside that the current cluster belongs to. - int zside = recHitTools_->zside(sh_detid); - - //add the simCluster to the relevant layer. A SimCluster may give contribution to several layers. - if (occurenceSCinlayer[layerid] == 0) { - tnscpl[layerid]++; - } - occurenceSCinlayer[layerid]++; - - if (sh_detid.det() == DetId::Forward || sh_detid.det() == DetId::HGCalEE || sh_detid.det() == DetId::HGCalHSi) { - thickness = recHitTools_->getSiThickness(sh_detid); - } else if (sh_detid.det() == DetId::HGCalHSc) { - thickness = -1; - } else { - LogDebug("HGCalValidator") << "These are HGCal simClusters, you shouldn't be here !!! " << layerid << "\n"; - continue; - } + if (sh_detid.det() == DetId::Forward || sh_detid.det() == DetId::HGCalEE || sh_detid.det() == DetId::HGCalHSi || + sh_detid.det() == DetId::HGCalHSc) { + //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. + int layerid = + recHitTools_->getLayerWithOffset(sh_detid) + layers * ((recHitTools_->zside(sh_detid) + 1) >> 1) - 1; + //zside that the current cluster belongs to. + int zside = recHitTools_->zside(sh_detid); + + //add the simCluster to the relevant layer. A SimCluster may give contribution to several layers. + if (occurenceSCinlayer[layerid] == 0) { + tnscpl[layerid]++; + } + occurenceSCinlayer[layerid]++; - if ((thickness == 120.) && (zside > 0.)) { - nthhits120p++; - } else if ((thickness == 120.) && (zside < 0.)) { - nthhits120m++; - } else if ((thickness == 200.) && (zside > 0.)) { - nthhits200p++; - } else if ((thickness == 200.) && (zside < 0.)) { - nthhits200m++; - } else if ((thickness == 300.) && (zside > 0.)) { - nthhits300p++; - } else if ((thickness == 300.) && (zside < 0.)) { - nthhits300m++; - } else if ((thickness == -1) && (zside > 0.)) { - nthhitsscintp++; - } else if ((thickness == -1) && (zside < 0.)) { - nthhitsscintm++; - } else { //assert(0); - LogDebug("HGCalValidator") - << " You are running a geometry that contains thicknesses different than the normal ones. " - << "\n"; + if (sh_detid.det() == DetId::HGCalHSc) + thickness = -1; + else + thickness = recHitTools_->getSiThickness(sh_detid); + + if ((thickness == 120.) && (zside > 0.)) { + nthhits120p++; + } else if ((thickness == 120.) && (zside < 0.)) { + nthhits120m++; + } else if ((thickness == 200.) && (zside > 0.)) { + nthhits200p++; + } else if ((thickness == 200.) && (zside < 0.)) { + nthhits200m++; + } else if ((thickness == 300.) && (zside > 0.)) { + nthhits300p++; + } else if ((thickness == 300.) && (zside < 0.)) { + nthhits300m++; + } else if ((thickness == -1) && (zside > 0.)) { + nthhitsscintp++; + } else if ((thickness == -1) && (zside < 0.)) { + nthhitsscintm++; + } else { //assert(0); + LogDebug("HGCalValidator") + << " You are running a geometry that contains thicknesses different than the normal ones. " + << "\n"; + } } - } //end of loop through hits //Check for simultaneously having hits of different kind. Checking at least two combinations is sufficient. @@ -1674,7 +1672,6 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simCluster_histos(const Hi //This is a cluster with hits of one kind tnscpthminus[std::to_string((int)thickness)]++; } - } //end of loop through SimClusters of the event //Per layer : Loop 0->99 From 18a8509ff32e47ba94911c4f0eff0682b6ddf1f8 Mon Sep 17 00:00:00 2001 From: brusale Date: Mon, 11 Dec 2023 13:48:07 +0100 Subject: [PATCH 006/301] generalize LCToCP and LCToSC associators --- .../LCToCPAssociatorByEnergyScoreImpl.cc | 71 +++++++++----- .../LCToCPAssociatorByEnergyScoreImpl.h | 16 +++- .../LCToCPAssociatorByEnergyScoreProducer.cc | 95 ++++++++++--------- .../LCToCPAssociatorByEnergyScoreProducer.h | 50 ++++++++++ .../LCToSCAssociatorByEnergyScoreImpl.cc | 76 +++++++++------ .../LCToSCAssociatorByEnergyScoreImpl.h | 15 ++- .../LCToSCAssociatorByEnergyScoreProducer.cc | 94 +++++++++--------- .../LCToSCAssociatorByEnergyScoreProducer.h | 50 ++++++++++ .../python/hgcHitAssociation_cfi.py | 4 +- 9 files changed, 322 insertions(+), 149 deletions(-) create mode 100644 SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h create mode 100644 SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index a7fdebbcf5790..3eba2cccd0add 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -9,16 +9,23 @@ #include "SimCalorimetry/HGCalAssociatorProducers/interface/AssociatorTools.h" -LCToCPAssociatorByEnergyScoreImpl::LCToCPAssociatorByEnergyScoreImpl( +template +LCToCPAssociatorByEnergyScoreImpl::LCToCPAssociatorByEnergyScoreImpl( edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map* hitMap) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter) { - layers_ = recHitTools_->lastLayerBH(); + const std::unordered_map* hitMap, + std::vector& hits) + : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter), hits_(hits) { + + if constexpr (std::is_same_v) + layers_ = recHitTools_->lastLayerBH(); + else + layers_ = 6; } -ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( +template +ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& cCCH, const edm::Handle& cPCH) const { // Get collections const auto& clusters = *cCCH.product(); @@ -56,11 +63,17 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( const SimClusterRefVector& simClusterRefVector = caloParticles[cpId].simClusters(); for (const auto& it_sc : simClusterRefVector) { const SimCluster& simCluster = (*(it_sc)); - const auto& hits_and_fractions = simCluster.hits_and_fractions(); + std::vector> hits_and_fractions; + if constexpr (std::is_same_v) + hits_and_fractions = simCluster.endcap_hits_and_fractions(); + else + hits_and_fractions = simCluster.barrel_hits_and_fractions(); for (const auto& it_haf : hits_and_fractions) { const auto hitid = (it_haf.first); - const auto cpLayerId = - recHitTools_->getLayerWithOffset(hitid) + layers_ * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; + unsigned int cpLayerId = recHitTools_->getLayerWithOffset(hitid); + if constexpr (std::is_same_v) + cpLayerId += layers_ * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; + const auto itcheck = hitMap_->find(hitid); if (itcheck != hitMap_->end()) { auto hit_find_it = detIdToCaloParticleId_Map.find(hitid); @@ -77,7 +90,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( detIdToCaloParticleId_Map[hitid].emplace_back(cpId, it_haf.second); } } - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); cPOnLayer[cpId][cpLayerId].energy += it_haf.second * hit->energy(); // We need to compress the hits and fractions in order to have a // reasonable score between CP and LC. Imagine, for example, that a @@ -149,12 +162,13 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( const std::vector>& hits_and_fractions = clusters[lcId].hitsAndFractions(); unsigned int numberOfHitsInLC = hits_and_fractions.size(); const auto firstHitDetId = hits_and_fractions[0].first; - int lcLayerId = - recHitTools_->getLayerWithOffset(firstHitDetId) + layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; - + unsigned int lcLayerId = recHitTools_->getLayerWithOffset(firstHitDetId); + if constexpr (std::is_same_v) + lcLayerId += layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; for (unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) { const auto rh_detid = hits_and_fractions[hitId].first; const auto rhFraction = hits_and_fractions[hitId].second; + auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid); if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) { detIdToLayerClusterId_Map[rh_detid] = std::vector(); @@ -165,7 +179,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_CP != detIdToCaloParticleId_Map.end()) { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); for (auto& h : hit_find_in_CP->second) { cPOnLayer[h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[lcId].first += h.fraction * hit->energy(); cpsInLayerCluster[lcId].emplace_back(h.clusterId, 0.f); @@ -179,9 +193,9 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( const auto& hits_and_fractions = clusters[lcId].hitsAndFractions(); unsigned int numberOfHitsInLC = hits_and_fractions.size(); const auto firstHitDetId = hits_and_fractions[0].first; - int lcLayerId = - recHitTools_->getLayerWithOffset(firstHitDetId) + layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; - + int lcLayerId = recHitTools_->getLayerWithOffset(firstHitDetId); + if constexpr (std::is_same_v) + lcLayerId += layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; // This vector will store, for each hit in the Layercluster, the index of // the CaloParticle that contributed the most, in terms of energy, to it. // Special values are: @@ -226,7 +240,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( hitsToCaloParticleId[hitId] -= 1; } else { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = static_cast(itcheck->second); auto maxCPEnergyInLC = 0.f; auto maxCPId = -1; for (auto& h : hit_find_in_CP->second) { @@ -350,17 +364,19 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( // It is the inverse of the denominator of the LCToCP score formula. Observe that this is the sum of the squares. float invLayerClusterEnergyWeight = 0.f; for (auto const& haf : hits_and_fractions) { - invLayerClusterEnergyWeight += - (haf.second * hitMap_->at(haf.first)->energy()) * (haf.second * hitMap_->at(haf.first)->energy()); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + invLayerClusterEnergyWeight += (haf.second * hit->energy()) * + (haf.second * hit->energy()); } invLayerClusterEnergyWeight = 1.f / invLayerClusterEnergyWeight; for (unsigned int i = 0; i < numberOfHitsInLC; ++i) { DetId rh_detid = hits_and_fractions[i].first; float rhFraction = hits_and_fractions[i].second; + bool hitWithNoCP = (detIdToCaloParticleId_Map.find(rh_detid) == detIdToCaloParticleId_Map.end()); auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& cpPair : cpsInLayerCluster[lcId]) { @@ -417,12 +433,14 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( // Compute the correct normalization. Observe that this is the sum of the squares. float invCPEnergyWeight = 0.f; for (auto const& haf : cPOnLayer[cpId][layerId].hits_and_fractions) { - invCPEnergyWeight += std::pow(haf.second * hitMap_->at(haf.first)->energy(), 2); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + invCPEnergyWeight += std::pow(haf.second * hit->energy(), 2); } invCPEnergyWeight = 1.f / invCPEnergyWeight; for (unsigned int i = 0; i < CPNumberOfHits; ++i) { auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[i].first; auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[i].second; + bool hitWithNoLC = false; if (cpFraction == 0.f) continue; //hopefully this should never happen @@ -430,7 +448,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) hitWithNoLC = true; auto itcheck = hitMap_->find(cp_hitDetId); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) { unsigned int layerClusterId = lcPair.first; @@ -473,7 +491,8 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( return {cpsInLayerCluster, cPOnLayer}; } -ticl::RecoToSimCollection LCToCPAssociatorByEnergyScoreImpl::associateRecoToSim( +template +ticl::RecoToSimCollection LCToCPAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& cCCH, const edm::Handle& cPCH) const { ticl::RecoToSimCollection returnValue(productGetter_); const auto& links = makeConnections(cCCH, cPCH); @@ -493,7 +512,8 @@ ticl::RecoToSimCollection LCToCPAssociatorByEnergyScoreImpl::associateRecoToSim( return returnValue; } -ticl::SimToRecoCollection LCToCPAssociatorByEnergyScoreImpl::associateSimToReco( +template +ticl::SimToRecoCollection LCToCPAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& cCCH, const edm::Handle& cPCH) const { ticl::SimToRecoCollection returnValue(productGetter_); const auto& links = makeConnections(cCCH, cPCH); @@ -511,3 +531,6 @@ ticl::SimToRecoCollection LCToCPAssociatorByEnergyScoreImpl::associateSimToReco( } return returnValue; } + +template class LCToCPAssociatorByEnergyScoreImpl; +template class LCToCPAssociatorByEnergyScoreImpl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h index a88fc23df05d9..b718ed0248095 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h @@ -7,6 +7,8 @@ #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "DataFormats/HGCRecHit/interface/HGCRecHit.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" @@ -62,12 +64,15 @@ namespace ticl { typedef std::tuple association; } // namespace ticl +template class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticleAssociatorBaseImpl { public: explicit LCToCPAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *); + const std::unordered_map *, + std::vector& hits); + ticl::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, const edm::Handle &cPCH) const override; @@ -78,9 +83,16 @@ class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticl private: const bool hardScatterOnly_; std::shared_ptr recHitTools_; - const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; unsigned layers_; edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &cCH, const edm::Handle &cPCH) const; + std::vector hits_; }; + +extern template class LCToCPAssociatorByEnergyScoreImpl; +extern template class LCToCPAssociatorByEnergyScoreImpl; + +using HGCalLCToCPAssociatorByEnergyScoreImpl = LCToCPAssociatorByEnergyScoreImpl; +using BarrelLCToCPAssociatorByEnergyScoreImpl = LCToCPAssociatorByEnergyScoreImpl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index 1a3fcedc156c5..ef8b82f3be93d 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -1,67 +1,72 @@ -// Original author: Marco Rovere +#include "LCToCPAssociatorByEnergyScoreProducer.h" -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/global/EDProducer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/EDGetToken.h" -#include "FWCore/Utilities/interface/ESGetToken.h" - -#include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h" -#include "LCToCPAssociatorByEnergyScoreImpl.h" - -class LCToCPAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { -public: - explicit LCToCPAssociatorByEnergyScoreProducer(const edm::ParameterSet &); - ~LCToCPAssociatorByEnergyScoreProducer() override; - - static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); +template +LCToCPAssociatorByEnergyScoreProducer::LCToCPAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) + : hitMap_(consumes>(ps.getParameter("hitMapTag"))), + caloGeometry_(esConsumes()), + hardScatterOnly_(ps.getParameter("hardScatterOnly")), + hits_label_(ps.getParameter>("hits")) { -private: - void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; - edm::EDGetTokenT> hitMap_; - edm::ESGetToken caloGeometry_; - const bool hardScatterOnly_; - std::shared_ptr rhtools_; -}; + for (auto& label : hits_label_) { + if constexpr (std::is_same_v) + hgcal_hits_token_.push_back(consumes(label)); + else + hits_token_.push_back(consumes>(label)); + } -LCToCPAssociatorByEnergyScoreProducer::LCToCPAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) - : hitMap_(consumes>(ps.getParameter("hitMapTag"))), - caloGeometry_(esConsumes()), - hardScatterOnly_(ps.getParameter("hardScatterOnly")) { rhtools_.reset(new hgcal::RecHitTools()); // Register the product produces(); } -LCToCPAssociatorByEnergyScoreProducer::~LCToCPAssociatorByEnergyScoreProducer() {} +template +LCToCPAssociatorByEnergyScoreProducer::~LCToCPAssociatorByEnergyScoreProducer() {} -void LCToCPAssociatorByEnergyScoreProducer::produce(edm::StreamID, - edm::Event &iEvent, - const edm::EventSetup &es) const { +template +void LCToCPAssociatorByEnergyScoreProducer::produce(edm::StreamID, + edm::Event &iEvent, + const edm::EventSetup &es) const { edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); + std::vector hits; + if constexpr (std::is_same_v) { + for (auto& token : hgcal_hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + } else { + for (auto& token : hits_token_) { + edm::Handle> hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + } const auto hitMap = &iEvent.get(hitMap_); - auto impl = - std::make_unique(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); + auto impl = std::make_unique>( + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap, hits); auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } -void LCToCPAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { +template +void LCToCPAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { edm::ParameterSetDescription desc; - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); desc.add("hardScatterOnly", true); - - cfg.add("layerClusterAssociatorByEnergyScore", desc); + if constexpr (std::is_same_v) { + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); + } else { + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "barrelRecHitMap")); + desc.add>("hits", {edm::InputTag("particleFlowRecHitECAL", ""), + edm::InputTag("particleFlowRecHitHBHE", ""), + edm::InputTag("particleFlowRecHitHO", "")}); + + } + cfg.addWithDefaultLabel(desc); } - -//define this as a plug-in -DEFINE_FWK_MODULE(LCToCPAssociatorByEnergyScoreProducer); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h new file mode 100644 index 0000000000000..d58e54c37aca0 --- /dev/null +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h @@ -0,0 +1,50 @@ +#ifndef SimCalorimetry_HGCalAssociatorProducers_LCToCPAssociatorByEnergyScoreProducer_H +#define SimCalorimetry_HGCalAssociatorProducers_LCToCPAssociatorByEnergyScoreProducer_H + +// Original author: Marco Rovere + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "HLTrigger/HLTcore/interface/defaultModuleLabel.h" +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +#include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h" +#include "LCToCPAssociatorByEnergyScoreImpl.h" + +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" + +template +class LCToCPAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { +public: + explicit LCToCPAssociatorByEnergyScoreProducer(const edm::ParameterSet &); + ~LCToCPAssociatorByEnergyScoreProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; + edm::EDGetTokenT> hitMap_; + edm::ESGetToken caloGeometry_; + const bool hardScatterOnly_; + std::shared_ptr rhtools_; + std::vector hits_label_; + std::vector> hgcal_hits_token_; + std::vector>> hits_token_; +}; + +template class LCToCPAssociatorByEnergyScoreProducer; +template class LCToCPAssociatorByEnergyScoreProducer; + +using HGCalLCToCPAssociatorByEnergyScoreProducer = LCToCPAssociatorByEnergyScoreProducer; +DEFINE_FWK_MODULE(HGCalLCToCPAssociatorByEnergyScoreProducer); +using BarrelLCToCPAssociatorByEnergyScoreProducer = LCToCPAssociatorByEnergyScoreProducer; +DEFINE_FWK_MODULE(BarrelLCToCPAssociatorByEnergyScoreProducer); + +#endif diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index 01e2b290d321f..d1af4cc9aa8d4 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -3,16 +3,23 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" -LCToSCAssociatorByEnergyScoreImpl::LCToSCAssociatorByEnergyScoreImpl( +template +LCToSCAssociatorByEnergyScoreImpl::LCToSCAssociatorByEnergyScoreImpl( edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map* hitMap) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter) { - layers_ = recHitTools_->lastLayerBH(); + const std::unordered_map* hitMap, + std::vector& hits) + : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter), hits_(hits) { + + if constexpr (std::is_same_v) + layers_ = recHitTools_->lastLayerBH(); + else + layers_ = 6; //EB + 4 HB + HO } -ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( +template +ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( const edm::Handle& cCCH, const edm::Handle& sCCH) const { // Get collections const auto& clusters = *cCCH.product(); @@ -57,12 +64,16 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // in the CaloParticle's case was necessary due to the multiple SimClusters of a single CaloParticle. std::unordered_map> detIdToSimClusterId_Map; for (const auto& scId : sCIndices) { - const auto& hits_and_fractions = simClusters[scId].hits_and_fractions(); + std::vector> hits_and_fractions = simClusters[scId].hits_and_fractions(); + if constexpr (std::is_same_v) + hits_and_fractions = simClusters[scId].endcap_hits_and_fractions(); + else + hits_and_fractions = simClusters[scId].barrel_hits_and_fractions(); for (const auto& it_haf : hits_and_fractions) { const auto hitid = (it_haf.first); - const auto scLayerId = - recHitTools_->getLayerWithOffset(hitid) + layers_ * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; - + unsigned int scLayerId = recHitTools_->getLayer(hitid); + if constexpr (std::is_same_v) + scLayerId += layers_ * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; const auto itcheck = hitMap_->find(hitid); if (itcheck != hitMap_->end()) { auto hit_find_it = detIdToSimClusterId_Map.find(hitid); @@ -70,8 +81,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( detIdToSimClusterId_Map[hitid] = std::vector(); } detIdToSimClusterId_Map[hitid].emplace_back(scId, it_haf.second); - - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); lcsInSimCluster[scId][scLayerId].energy += it_haf.second * hit->energy(); lcsInSimCluster[scId][scLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second); } @@ -137,9 +147,9 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( const std::vector>& hits_and_fractions = clusters[lcId].hitsAndFractions(); unsigned int numberOfHitsInLC = hits_and_fractions.size(); const auto firstHitDetId = hits_and_fractions[0].first; - int lcLayerId = - recHitTools_->getLayerWithOffset(firstHitDetId) + layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; - + int lcLayerId = recHitTools_->getLayer(firstHitDetId); + if constexpr (std::is_same_v) + lcLayerId += layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; for (unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) { const auto rh_detid = hits_and_fractions[hitId].first; const auto rhFraction = hits_and_fractions[hitId].second; @@ -154,7 +164,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_SC != detIdToSimClusterId_Map.end()) { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); //Loops through all the simclusters that have the layer cluster rechit under study //Here is time to update the lcsInSimCluster and connect the SimCluster with all //the layer clusters that have the current rechit detid matched. @@ -175,9 +185,9 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( const auto& hits_and_fractions = clusters[lcId].hitsAndFractions(); unsigned int numberOfHitsInLC = hits_and_fractions.size(); const auto firstHitDetId = hits_and_fractions[0].first; - int lcLayerId = - recHitTools_->getLayerWithOffset(firstHitDetId) + layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; - + int lcLayerId = recHitTools_->getLayer(firstHitDetId); + if constexpr (std::is_same_v) + lcLayerId += layers_ * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; // This vector will store, for each hit in the Layercluster, the index of // the SimCluster that contributed the most, in terms of energy, to it. // Special values are: @@ -223,7 +233,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( hitsToSimClusterId[hitId] -= 1; } else { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); auto maxSCEnergyInLC = 0.f; auto maxSCId = -1; //Loop through all the linked SimClusters @@ -307,10 +317,11 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << lcsInSimCluster[sc][sclay].energy << std::endl; double tot_energy = 0.; for (auto const& haf : lcsInSimCluster[sc][sclay].hits_and_fractions) { + const HIT* hit = &(hits_[itcheck->second]); LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Tot Sum haf: " << tot_energy << std::endl; for (auto const& lc : lcsInSimCluster[sc][sclay].layerClusterIdToEnergyAndScore) { @@ -322,13 +333,14 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToSCAssociatorByEnergyScoreImpl") << "Improved detIdToSimClusterId_Map INFO" << std::endl; for (auto const& sc : detIdToSimClusterId_Map) { + const HIT* hit = &(hits_[itcheck->second]); LogDebug("LCToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)sc.first << " we have found the following connections with SimClusters:" << std::endl; for (auto const& sclu : sc.second) { LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " SimCluster Id: " << sclu.clusterId << " with fraction: " << sclu.fraction - << " and energy: " << sclu.fraction * hitMap_->at(sc.first)->energy() << std::endl; + << " and energy: " << sclu.fraction * hit->energy() << std::endl; } } #endif @@ -358,8 +370,8 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // It is the inverse of the denominator of the LCToSC score formula. Observe that this is the sum of the squares. float invLayerClusterEnergyWeight = 0.f; for (auto const& haf : hits_and_fractions) { - invLayerClusterEnergyWeight += - (haf.second * hitMap_->at(haf.first)->energy()) * (haf.second * hitMap_->at(haf.first)->energy()); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + invLayerClusterEnergyWeight += (haf.second * hit->energy()) * (haf.second * hit->energy()); } invLayerClusterEnergyWeight = 1.f / invLayerClusterEnergyWeight; for (unsigned int i = 0; i < numberOfHitsInLC; ++i) { @@ -369,7 +381,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( bool hitWithSC = (detIdToSimClusterId_Map.find(rh_detid) != detIdToSimClusterId_Map.end()); auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& scPair : scsInLayerCluster[lcId]) { @@ -438,7 +450,8 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // Compute the correct normalization. Observe that this is the sum of the squares. float invSCEnergyWeight = 0.f; for (auto const& haf : lcsInSimCluster[scId][layerId].hits_and_fractions) { - invSCEnergyWeight += std::pow(haf.second * hitMap_->at(haf.first)->energy(), 2); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + invSCEnergyWeight += std::pow(haf.second * hit->energy(), 2); } invSCEnergyWeight = 1.f / invSCEnergyWeight; for (unsigned int i = 0; i < SCNumberOfHits; ++i) { @@ -452,7 +465,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_LC != detIdToLayerClusterId_Map.end()) hitWithLC = true; auto itcheck = hitMap_->find(sc_hitDetId); - const HGCRecHit* hit = itcheck->second; + const HIT* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& lcPair : lcsInSimCluster[scId][layerId].layerClusterIdToEnergyAndScore) { unsigned int layerClusterId = lcPair.first; @@ -496,7 +509,8 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( return {scsInLayerCluster, lcsInSimCluster}; } -ticl::RecoToSimCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateRecoToSim( +template +ticl::RecoToSimCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateRecoToSim( const edm::Handle& cCCH, const edm::Handle& sCCH) const { ticl::RecoToSimCollectionWithSimClusters returnValue(productGetter_); const auto& links = makeConnections(cCCH, sCCH); @@ -516,7 +530,8 @@ ticl::RecoToSimCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::asso return returnValue; } -ticl::SimToRecoCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateSimToReco( +template +ticl::SimToRecoCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::associateSimToReco( const edm::Handle& cCCH, const edm::Handle& sCCH) const { ticl::SimToRecoCollectionWithSimClusters returnValue(productGetter_); const auto& links = makeConnections(cCCH, sCCH); @@ -534,3 +549,6 @@ ticl::SimToRecoCollectionWithSimClusters LCToSCAssociatorByEnergyScoreImpl::asso } return returnValue; } + +template class LCToSCAssociatorByEnergyScoreImpl; +template class LCToSCAssociatorByEnergyScoreImpl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h index b0a5182e239fe..1b17035fcbaa3 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h @@ -7,6 +7,8 @@ #include "DataFormats/ForwardDetId/interface/HGCalDetId.h" #include "DataFormats/HGCRecHit/interface/HGCRecHit.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" #include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h" #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" @@ -59,12 +61,14 @@ namespace ticl { typedef std::tuple association; } // namespace ticl +template class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterAssociatorBaseImpl { public: explicit LCToSCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *); + const std::unordered_map *, + std::vector& hits); ticl::RecoToSimCollectionWithSimClusters associateRecoToSim( const edm::Handle &cCH, @@ -77,9 +81,16 @@ class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterA private: const bool hardScatterOnly_; std::shared_ptr recHitTools_; - const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; unsigned layers_; edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &cCH, const edm::Handle &sCCH) const; + std::vector hits_; }; + +extern template class LCToSCAssociatorByEnergyScoreImpl; +extern template class LCToSCAssociatorByEnergyScoreImpl; + +using HGCalLCToSCAssociatorByEnergyScoreImpl = LCToSCAssociatorByEnergyScoreImpl; +using BarrelLCToSCAssociatorByEnergyScoreImpl = LCToSCAssociatorByEnergyScoreImpl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 9ada5ed00adea..5171af322fa38 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -1,67 +1,71 @@ -// Original author: Leonardo Cristella +#include "LCToSCAssociatorByEnergyScoreProducer.h" -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/global/EDProducer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/EDGetToken.h" -#include "FWCore/Utilities/interface/ESGetToken.h" - -#include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h" -#include "LCToSCAssociatorByEnergyScoreImpl.h" - -class LCToSCAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { -public: - explicit LCToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &); - ~LCToSCAssociatorByEnergyScoreProducer() override; - - static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); +template +LCToSCAssociatorByEnergyScoreProducer::LCToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) + : hitMap_(consumes>(ps.getParameter("hitMapTag"))), + caloGeometry_(esConsumes()), + hardScatterOnly_(ps.getParameter("hardScatterOnly")), + hits_label_(ps.getParameter>("hits")) { -private: - void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; - edm::EDGetTokenT> hitMap_; - edm::ESGetToken caloGeometry_; - const bool hardScatterOnly_; - std::shared_ptr rhtools_; -}; + for (auto& label : hits_label_) { + if constexpr (std::is_same_v) + hgcal_hits_token_.push_back(consumes(label)); + else + hits_token_.push_back(consumes>(label)); + } -LCToSCAssociatorByEnergyScoreProducer::LCToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) - : hitMap_(consumes>(ps.getParameter("hitMapTag"))), - caloGeometry_(esConsumes()), - hardScatterOnly_(ps.getParameter("hardScatterOnly")) { rhtools_.reset(new hgcal::RecHitTools()); // Register the product produces(); } -LCToSCAssociatorByEnergyScoreProducer::~LCToSCAssociatorByEnergyScoreProducer() {} +template +LCToSCAssociatorByEnergyScoreProducer::~LCToSCAssociatorByEnergyScoreProducer() {} -void LCToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, - edm::Event &iEvent, - const edm::EventSetup &es) const { +template +void LCToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, + edm::Event &iEvent, + const edm::EventSetup &es) const { edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); + std::vector hits; + if constexpr (std::is_same_v) { + for (auto& token : hgcal_hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + } else { + for (auto& token : hits_token_) { + edm::Handle> hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + } const auto hitMap = &iEvent.get(hitMap_); - auto impl = - std::make_unique(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); + auto impl = std::make_unique>( + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap, hits); auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } -void LCToSCAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { +template +void LCToSCAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { edm::ParameterSetDescription desc; - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); desc.add("hardScatterOnly", true); - - cfg.add("simClusterAssociatorByEnergyScore", desc); + if constexpr (std::is_same_v) { + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); + } else { + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "barrelRecHitMap")); + desc.add>("hits", {edm::InputTag("particleFlowRecHitECAL", ""), + edm::InputTag("particleFlowRecHitHBHE", ""), + edm::InputTag("particleFlowRecHitHO", "")}); + } + cfg.addWithDefaultLabel(desc); } - -//define this as a plug-in -DEFINE_FWK_MODULE(LCToSCAssociatorByEnergyScoreProducer); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h new file mode 100644 index 0000000000000..18dab5dc109bc --- /dev/null +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h @@ -0,0 +1,50 @@ +#ifndef SimCalorimetry_HGCalAssociatorProducers_LCToSCAssociatorByEnergyScoreProducer_H +#define SimCalorimetry_HGCalAssociatorProducers_LCToSCAssociatorByEnergyScoreProducer_H + +// Original author: Leonardo Cristella + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/defaultModuleLabel.h" +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +#include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h" +#include "LCToSCAssociatorByEnergyScoreImpl.h" + +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" + +template +class LCToSCAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { +public: + explicit LCToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &); + ~LCToSCAssociatorByEnergyScoreProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; + edm::EDGetTokenT> hitMap_; + edm::ESGetToken caloGeometry_; + const bool hardScatterOnly_; + std::shared_ptr rhtools_; + std::vector hits_label_; + std::vector> hgcal_hits_token_; + std::vector>> hits_token_; +}; + +template class LCToSCAssociatorByEnergyScoreProducer; +template class LCToSCAssociatorByEnergyScoreProducer; + +using HGCalLCToSCAssociatorByEnergyScoreProducer = LCToSCAssociatorByEnergyScoreProducer; +DEFINE_FWK_MODULE(HGCalLCToSCAssociatorByEnergyScoreProducer); +using BarrelLCToSCAssociatorByEnergyScoreProducer = LCToSCAssociatorByEnergyScoreProducer; +DEFINE_FWK_MODULE(BarrelLCToSCAssociatorByEnergyScoreProducer); + +#endif diff --git a/SimCalorimetry/HGCalSimProducers/python/hgcHitAssociation_cfi.py b/SimCalorimetry/HGCalSimProducers/python/hgcHitAssociation_cfi.py index 50513c49e9384..ebe7be82c5df2 100644 --- a/SimCalorimetry/HGCalSimProducers/python/hgcHitAssociation_cfi.py +++ b/SimCalorimetry/HGCalSimProducers/python/hgcHitAssociation_cfi.py @@ -1,3 +1,3 @@ -from SimCalorimetry.HGCalAssociatorProducers.layerClusterAssociatorByEnergyScore_cfi import layerClusterAssociatorByEnergyScore as lcAssocByEnergyScoreProducer +from SimCalorimetry.HGCalAssociatorProducers.hgCalLCToCPAssociatorByEnergyScoreProducer_cfi import hgCalLCToCPAssociatorByEnergyScoreProducer as lcAssocByEnergyScoreProducer -from SimCalorimetry.HGCalAssociatorProducers.simClusterAssociatorByEnergyScore_cfi import simClusterAssociatorByEnergyScore as scAssocByEnergyScoreProducer +from SimCalorimetry.HGCalAssociatorProducers.hgCalLCToSCAssociatorByEnergyScoreProducer_cfi import hgCalLCToSCAssociatorByEnergyScoreProducer as scAssocByEnergyScoreProducer From f3c8a1c47c677fcc92cfdb987420ec697e649598 Mon Sep 17 00:00:00 2001 From: brusale Date: Fri, 22 Dec 2023 17:27:52 +0100 Subject: [PATCH 007/301] generalize hitMap to the barrel region --- DataFormats/HGCRecHit/src/classes_def.xml | 5 + .../python/hgcalLocalReco_cff.py | 5 +- .../plugins/RecHitMapProducer.cc | 107 ++++++++++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc diff --git a/DataFormats/HGCRecHit/src/classes_def.xml b/DataFormats/HGCRecHit/src/classes_def.xml index ec119ff72394a..6e0f82f7a2bad 100644 --- a/DataFormats/HGCRecHit/src/classes_def.xml +++ b/DataFormats/HGCRecHit/src/classes_def.xml @@ -22,6 +22,7 @@ + @@ -39,4 +40,8 @@ + + + + diff --git a/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py b/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py index 6c2dae6d18644..8b0e5ff45aaf7 100644 --- a/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py +++ b/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py @@ -3,7 +3,8 @@ from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHit_cfi import * from RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi import * -from RecoLocalCalo.HGCalRecProducers.hgcalRecHitMapProducer_cfi import hgcalRecHitMapProducer +#from RecoLocalCalo.HGCalRecProducers.hgcalRecHitMapProducer_cfi import hgcalRecHitMapProducer +from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer # patch particle flow clusters for HGC into local reco sequence # (for now until global reco is going with some sort of clustering) @@ -14,7 +15,7 @@ hgcalLocalRecoTask = cms.Task( HGCalUncalibRecHit, HGCalRecHit, - hgcalRecHitMapProducer, + recHitMapProducer, hgcalLayerClustersEE, hgcalLayerClustersHSi, hgcalLayerClustersHSci, diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc new file mode 100644 index 0000000000000..281a1efd81254 --- /dev/null +++ b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc @@ -0,0 +1,107 @@ +// user include files +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" + +class RecHitMapProducer : public edm::global::EDProducer<> { +public: + RecHitMapProducer(const edm::ParameterSet&); + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + +private: + const edm::EDGetTokenT hits_ee_token_; + const edm::EDGetTokenT hits_fh_token_; + const edm::EDGetTokenT hits_bh_token_; + const edm::EDGetTokenT hits_eb_token_; + const edm::EDGetTokenT hits_hb_token_; + const edm::EDGetTokenT hits_ho_token_; + bool hgcalOnly_; +}; + +DEFINE_FWK_MODULE(RecHitMapProducer); + +using DetIdRecHitMap = std::unordered_map; + +RecHitMapProducer::RecHitMapProducer(const edm::ParameterSet& ps) + : hits_ee_token_(consumes(ps.getParameter("EEInput"))), + hits_fh_token_(consumes(ps.getParameter("FHInput"))), + hits_bh_token_(consumes(ps.getParameter("BHInput"))), + hits_eb_token_(consumes(ps.getParameter("EBInput"))), + hits_hb_token_(consumes(ps.getParameter("HBInput"))), + hits_ho_token_(consumes(ps.getParameter("HOInput"))), + hgcalOnly_(ps.getParameter("hgcalOnly")) { + produces("hgcalRecHitMap"); + if (!hgcalOnly_) + produces("barrelRecHitMap"); +} + +void RecHitMapProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("EEInput", {"HGCalRecHit", "HGCEERecHits"}); + desc.add("FHInput", {"HGCalRecHit", "HGCHEFRecHits"}); + desc.add("BHInput", {"HGCalRecHit", "HGCHEBRecHits"}); + desc.add("EBInput", {"particleFlowRecHitECAL", ""}); + desc.add("HBInput", {"particleFlowRecHitHBHE", ""}); + desc.add("HOInput", {"particleFlowRecHitHO", ""}); + desc.add("hgcalOnly", true); + descriptions.add("recHitMapProducer", desc); +} + +void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const { + auto hitMapHGCal = std::make_unique(); + const auto& ee_hits = evt.get(hits_ee_token_); + const auto& fh_hits = evt.get(hits_fh_token_); + const auto& bh_hits = evt.get(hits_bh_token_); + + for (unsigned int i = 0; i < ee_hits.size(); ++i) { + hitMapHGCal->emplace(ee_hits[i].detid(), i); + } + auto size = ee_hits.size(); + + for (unsigned int i = 0; i < fh_hits.size(); ++i) { + hitMapHGCal->emplace(fh_hits[i].detid(), i+size); + } + size += fh_hits.size(); + + for (unsigned int i = 0; i < bh_hits.size(); ++i) { + hitMapHGCal->emplace(bh_hits[i].detid(), i+size); + } + + evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); + + if (!hgcalOnly_) { + auto hitMapBarrel = std::make_unique(); + const auto& eb_hits = evt.get(hits_eb_token_); + const auto& hb_hits = evt.get(hits_hb_token_); + const auto& ho_hits = evt.get(hits_ho_token_); + size = 0; + + for (unsigned int i = 0; i < eb_hits.size(); ++i) { + hitMapBarrel->emplace(eb_hits[i].detId(), i); + } + size += eb_hits.size(); + + for (unsigned int i = 0; i < hb_hits.size(); ++i) { + hitMapBarrel->emplace(hb_hits[i].detId(), i+size); + } + size += hb_hits.size(); + + for (unsigned int i = 0; i < ho_hits.size(); ++i) { + hitMapBarrel->emplace(ho_hits[i].detId(), i+size); + } + evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); + } +} From f404f06f1e51d53439735c5c5f9a4bd71b1256bd Mon Sep 17 00:00:00 2001 From: brusale Date: Fri, 22 Dec 2023 17:32:36 +0100 Subject: [PATCH 008/301] include barrel in getLayer --- RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc index 2477e728795f5..ecd0f9e050678 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc @@ -140,7 +140,7 @@ const CaloSubdetectorGeometry* RecHitTools::getSubdetectorGeometry(const DetId& GlobalPoint RecHitTools::getPosition(const DetId& id) const { auto geom = getSubdetectorGeometry(id); GlobalPoint position; - if (id.det() == DetId::Hcal) { + if (id.det() == DetId::Hcal || id.det() == DetId::Ecal) { position = geom->getGeometry(id)->getPosition(); } else { auto hg = static_cast(geom); @@ -367,8 +367,13 @@ unsigned int RecHitTools::getLayer(const DetId& id) const { layer = HFNoseDetId(id).layer(); } else if (id.det() == DetId::Forward) { layer = HGCalDetId(id).layer(); - } else if (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) { - layer = HcalDetId(id).depth(); + } else if (id.det() == DetId::Hcal && id.subdetId() != HcalEmpty) { + if (id.subdetId() == HcalBarrel) + layer = HcalDetId(id).depth(); + else if (id.subdetId() == HcalOuter) + layer = HcalDetId(id).depth() + 1; + } else if (id.det() == DetId::Ecal) { + layer = 0; } return layer; } From fcea800c43719234bd28ac3443810ed6fd3fa953 Mon Sep 17 00:00:00 2001 From: brusale Date: Fri, 22 Dec 2023 17:33:34 +0100 Subject: [PATCH 009/301] add barrel/endcap hits and fractions --- .../CaloAnalysis/interface/SimCluster.h | 43 +++++++++++++++++++ .../CaloAnalysis/src/classes_def.xml | 4 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index 99679d69cd67e..eb66f750f5db0 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -9,6 +9,8 @@ #include "SimDataFormats/Track/interface/SimTrack.h" #include +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" // // Forward declarations // @@ -175,6 +177,13 @@ class SimCluster { void addRecHitAndFraction(uint32_t hit, float fraction) { hits_.emplace_back(hit); fractions_.emplace_back(fraction); + if ((hit >= firstDetIdEB_ && hit < firstDetIdEE_) || (hit >= firstDetIdHB_ && hit < firstDetIdHE_) || (hit >= firstDetIdHO_ && hit < firstDetIdHcalForward_)) { + barrel_hits_.emplace_back(hit); + barrel_fractions_.emplace_back(fraction); + } else if ((hit >= firstDetIdEE_ && hit < lastDetIdES_) || (hit >= firstDetIdHE_ && hit < firstDetIdHO_) || (hit >= firstDetIdHcalForward_ && hit < lastDetIdHcalForward_) || (hit >= firstDetIdHGCal_)) { + endcap_hits_.emplace_back(hit); + endcap_fractions_.emplace_back(fraction); + } } /** @brief add rechit energy */ @@ -188,6 +197,24 @@ class SimCluster { } return result; } + + /** @brief Returns list of rechit IDs and fractions in the barrel for this SimCluster */ + std::vector> barrel_hits_and_fractions() const { + std::vector> result; + for (size_t i = 0; i < barrel_hits_.size(); ++i) { + result.emplace_back(barrel_hits_[i], barrel_fractions_[i]); + } + return result; + } + + /** @brief Returns list of rechit IDs and fractions in the endcap for this SimCluster */ + std::vector> endcap_hits_and_fractions() const { + std::vector> result; + for (size_t i = 0; i < endcap_hits_.size(); ++i) { + result.emplace_back(endcap_hits_[i], endcap_fractions_[i]); + } + return result; + } /** @brief Returns list of rechit IDs and energies for this SimCluster */ std::vector> hits_and_energies() const { @@ -226,6 +253,10 @@ class SimCluster { float simhit_energy_{0.f}; std::vector hits_; std::vector fractions_; + std::vector barrel_hits_; + std::vector endcap_hits_; + std::vector barrel_fractions_; + std::vector endcap_fractions_; std::vector energies_; math::XYZTLorentzVectorF theMomentum_; @@ -233,6 +264,18 @@ class SimCluster { /// references to G4 and reco::GenParticle tracks std::vector g4Tracks_; reco::GenParticleRefVector genParticles_; + +private: + uint32_t firstDetIdEB_ = (3 << 28) + (1 << 25); + uint32_t firstDetIdEE_ = (3 << 28) + (2 << 25); + uint32_t lastDetIdES_ = (3 << 28) + (4 << 25); + uint32_t firstDetIdHB_ = (4 << 28) + (1 << 25); + uint32_t firstDetIdHE_ = (4 << 28) + (2 << 25); + uint32_t firstDetIdHO_ = (4 << 28) + (3 << 25); + uint32_t firstDetIdHcalForward_ = (4 << 28) + (4 << 25); + uint32_t lastDetIdHcalForward_ = (4 << 28) + (5 << 25); + uint32_t firstDetIdHGCal_ = 5 << 28; + }; #endif // SimDataFormats_SimCluster_H diff --git a/SimDataFormats/CaloAnalysis/src/classes_def.xml b/SimDataFormats/CaloAnalysis/src/classes_def.xml index b6e0514584153..ee329dfce2ed8 100644 --- a/SimDataFormats/CaloAnalysis/src/classes_def.xml +++ b/SimDataFormats/CaloAnalysis/src/classes_def.xml @@ -17,7 +17,9 @@ - + + + From e074f0ec1b09e4f63bdcaa72c02e4924fdbcec7f Mon Sep 17 00:00:00 2001 From: brusale Date: Fri, 22 Dec 2023 17:34:37 +0100 Subject: [PATCH 010/301] adjust validation to work with new associators and hitmaps --- .../python/caloTruthProducer_cfi.py | 23 ++--- .../interface/HGCalValidator.h | 8 +- .../interface/HGVHistoProducerAlgo.h | 35 ++++--- .../HGCalValidation/plugins/HGCalValidator.cc | 35 +++++-- .../python/HGCalValidator_cfi.py | 1 + .../src/HGVHistoProducerAlgo.cc | 94 +++++++++++-------- 6 files changed, 111 insertions(+), 85 deletions(-) diff --git a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py index 5cc586f2b3759..0696591ad7b32 100644 --- a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py +++ b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py @@ -18,6 +18,12 @@ cms.InputTag('g4SimHits','HGCHitsHEfront'), cms.InputTag('g4SimHits','HGCHitsHEback') ), +# hcal = cms.VInputTag(cms.InputTag('g4SimHits','HcalHits')), +# ecal = cms.VInputTag( +# cms.InputTag('g4SimHits','EcalHitsEE'), +# cms.InputTag('g4SimHits','EcalHitsEB'), +# cms.InputTag('g4SimHits','EcalHitsES') +# ) ), simTrackCollection = cms.InputTag('g4SimHits'), simVertexCollection = cms.InputTag('g4SimHits'), @@ -53,20 +59,3 @@ from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(caloParticles, cms.PSet()) # don't allow this to run in fastsim -from Configuration.Eras.Modifier_phase2_common_cff import phase2_common -phase2_common.toModify( - caloParticles, - simHitCollections = cms.PSet( - hgc = cms.VInputTag( - cms.InputTag('g4SimHits', 'HGCHitsEE'), - cms.InputTag('g4SimHits', 'HGCHitsHEfront'), - cms.InputTag('g4SimHits', 'HGCHitsHEback'), - ), - hcal = cms.VInputTag(cms.InputTag('g4SimHits', 'HcalHits')), - ecal = cms.VInputTag( - cms.InputTag('g4SimHits', 'EcalHitsEB') - ) - ) -) - - diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index 414523acdfc05..be113e19f648b 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -56,7 +56,8 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { std::vector const& simVertices, std::vector& selected_cPeff, unsigned int layers, - std::unordered_map const&) const; + std::unordered_map const&, + std::vector const& hits) const; protected: edm::ESGetToken caloGeomToken_; @@ -88,13 +89,14 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { edm::EDGetTokenT> label_cp_fake; edm::EDGetTokenT> simVertices_; std::vector>> clustersMaskTokens_; - edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::EDGetTokenT associatorMapRtS; edm::EDGetTokenT associatorMapStR; edm::EDGetTokenT associatorMapSimtR; edm::EDGetTokenT associatorMapRtSim; std::unique_ptr histoProducerAlgo_; - + std::vector hits_label_; + std::vector> hits_token_; private: CaloParticleSelector cpSelector; std::shared_ptr tools_; diff --git a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h index 91d568e18e922..f36168377d651 100644 --- a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h +++ b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h @@ -269,10 +269,11 @@ class HGVHistoProducerAlgo { std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const&, + std::unordered_map const&, unsigned int layers, const ticl::RecoToSimCollection& recSimColl, - const ticl::SimToRecoCollection& simRecColl) const; + const ticl::SimToRecoCollection& simRecColl, + std::vector const& hits) const; void layerClusters_to_SimClusters(const Histograms& histograms, const int count, edm::Handle clusterHandle, @@ -281,10 +282,11 @@ class HGVHistoProducerAlgo { std::vector const& simClusters, std::vector const& sCIndices, const std::vector& mask, - std::unordered_map const&, + std::unordered_map const&, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& recSimColl, - const ticl::SimToRecoCollectionWithSimClusters& simRecColl) const; + const ticl::SimToRecoCollectionWithSimClusters& simRecColl, + std::vector const& hits) const; void tracksters_to_SimTracksters(const Histograms& histograms, const int count, const ticl::TracksterCollection& Tracksters, @@ -298,15 +300,17 @@ class HGVHistoProducerAlgo { std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const&, - unsigned int layers) const; + std::unordered_map const&, + unsigned int layers, + std::vector const& hits) const; void fill_info_histos(const Histograms& histograms, unsigned int layers) const; void fill_caloparticle_histos(const Histograms& histograms, int pdgid, const CaloParticle& caloparticle, std::vector const& simVertices, unsigned int layers, - std::unordered_map const&) const; + std::unordered_map const&, + std::vector const& hits) const; void fill_generic_cluster_histos(const Histograms& histograms, const int count, edm::Handle clusterHandle, @@ -315,12 +319,13 @@ class HGVHistoProducerAlgo { std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const&, + std::unordered_map const&, std::map cummatbudg, unsigned int layers, std::vector thicknesses, const ticl::RecoToSimCollection& recSimColl, - const ticl::SimToRecoCollection& simRecColl) const; + const ticl::SimToRecoCollection& simRecColl, + std::vector const& hits) const; void fill_simCluster_histos(const Histograms& histograms, std::vector const& simClusters, unsigned int layers, @@ -333,10 +338,11 @@ class HGVHistoProducerAlgo { std::vector const& simClusters, std::vector const& sCIndices, const std::vector& mask, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& recSimColl, - const ticl::SimToRecoCollectionWithSimClusters& simRecColl) const; + const ticl::SimToRecoCollectionWithSimClusters& simRecColl, + std::vector const& hits) const; void fill_cluster_histos(const Histograms& histograms, const int count, const reco::CaloCluster& cluster) const; void fill_trackster_histos(const Histograms& histograms, const int count, @@ -350,14 +356,15 @@ class HGVHistoProducerAlgo { std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const&, - unsigned int layers) const; + std::unordered_map const&, + unsigned int layers, + std::vector const& hits) const; double distance2(const double x1, const double y1, const double x2, const double y2) const; double distance(const double x1, const double y1, const double x2, const double y2) const; void setRecHitTools(std::shared_ptr recHitTools); - DetId findmaxhit(const reco::CaloCluster& cluster, std::unordered_map const&) const; + DetId findmaxhit(const reco::CaloCluster& cluster, std::unordered_map const&, std::vector const& hits) const; struct detIdInfoInCluster { bool operator==(const detIdInfoInCluster& o) const { return clusterId == o.clusterId; }; diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 0436b812eb5da..7d0e7088eb4e0 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -30,11 +30,15 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) label_TSToCPLinking_(pset.getParameter("label_TSToCPLinking")), label_TSToSTSPR_(pset.getParameter("label_TSToSTSPR")), label_clustersmask(pset.getParameter>("LayerClustersInputMask")), - cummatbudinxo_(pset.getParameter("cummatbudinxo")) { + cummatbudinxo_(pset.getParameter("cummatbudinxo")), + hits_label_(pset.getParameter>("hits")) { //In this way we can easily generalize to associations between other objects also. const edm::InputTag& label_cp_effic_tag = pset.getParameter("label_cp_effic"); const edm::InputTag& label_cp_fake_tag = pset.getParameter("label_cp_fake"); + for (auto& label : hits_label_) { + hits_token_.push_back(consumes(label)); + } label_cp_effic = consumes>(label_cp_effic_tag); label_cp_fake = consumes>(label_cp_fake_tag); @@ -49,7 +53,7 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) simTrackstersMap_ = consumes>>(edm::InputTag("ticlSimTracksters")); - hitMap_ = consumes>(edm::InputTag("hgcalRecHitMapProducer")); + hitMap_ = consumes>(edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); simClusters_ = consumes>(pset.getParameter("label_scl")); @@ -226,7 +230,8 @@ void HGCalValidator::cpParametersAndSelection(const Histograms& histograms, std::vector const& simVertices, std::vector& selected_cPeff, unsigned int layers, - std::unordered_map const& hitMap) const { + std::unordered_map const& hitMap, + std::vector const& hits) const { selected_cPeff.reserve(cPeff.size()); size_t j = 0; @@ -237,7 +242,7 @@ void HGCalValidator::cpParametersAndSelection(const Histograms& histograms, selected_cPeff.push_back(j); if (doCaloParticlePlots_) { histoProducerAlgo_->fill_caloparticle_histos( - histograms.histoProducerAlgo, id, caloParticle, simVertices, layers, hitMap); + histograms.histoProducerAlgo, id, caloParticle, simVertices, layers, hitMap, hits); } } ++j; @@ -287,9 +292,16 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, event.getByToken(associatorMapRtS, recotosimCollectionH); auto recSimColl = *recotosimCollectionH; - edm::Handle> hitMapHandle; + edm::Handle> hitMapHandle; event.getByToken(hitMap_, hitMapHandle); - const std::unordered_map* hitMap = &*hitMapHandle; + const std::unordered_map* hitMap = &*hitMapHandle; + + std::vector hits; + for (auto& token : hits_token_) { + edm::Handle hitsHandle; + event.getByToken(token, hitsHandle); + hits.insert(hits.end(), (*hitsHandle).begin(), (*hitsHandle).end()); + } //Some general info on layers etc. if (SaveGeneralInfo_) { @@ -307,7 +319,7 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, // HGCRecHit are given to select the SimHits which are also reconstructed LogTrace("HGCalValidator") << "\n# of CaloParticles: " << caloParticles.size() << "\n" << std::endl; std::vector selected_cPeff; - cpParametersAndSelection(histograms, caloParticles, simVertices, selected_cPeff, totallayers_to_monitor_, *hitMap); + cpParametersAndSelection(histograms, caloParticles, simVertices, selected_cPeff, totallayers_to_monitor_, *hitMap, hits); //get collections from the event //simClusters @@ -364,7 +376,8 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, *hitMap, totallayers_to_monitor_, recSimColl, - simRecColl); + simRecColl, + hits); //General Info on simClusters LogTrace("HGCalValidator") << "\n# of SimClusters: " << nSimClusters @@ -390,7 +403,8 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, totallayers_to_monitor_, thicknesses_to_monitor_, recSimColl, - simRecColl); + simRecColl, + hits); for (unsigned int layerclusterIndex = 0; layerclusterIndex < clusters.size(); layerclusterIndex++) { histoProducerAlgo_->fill_cluster_histos(histograms.histoProducerAlgo, w, clusters[layerclusterIndex]); @@ -429,7 +443,8 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, cPIndices, selected_cPeff, *hitMap, - totallayers_to_monitor_); + totallayers_to_monitor_, + hits); } } //end of loop over Trackster input labels } diff --git a/Validation/HGCalValidation/python/HGCalValidator_cfi.py b/Validation/HGCalValidation/python/HGCalValidator_cfi.py index db5ce31023bff..fbff6504ea56c 100644 --- a/Validation/HGCalValidation/python/HGCalValidator_cfi.py +++ b/Validation/HGCalValidation/python/HGCalValidator_cfi.py @@ -21,6 +21,7 @@ # selection of CP for evaluation of efficiency # CaloParticleSelectionForEfficiency, + hits = cms.VInputTag([cms.InputTag("HGCalRecHit", "HGCEERecHits"), cms.InputTag("HGCalRecHit", "HGCHEFRecHits"), cms.InputTag("HGCalRecHit", "HGCHEBRecHits")]), ### reco input configuration ### #2DLayerClusters, PFClusters, Tracksters label_lcl = layerClusterCaloParticleAssociation.label_lc, diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index 99e8d632fcc9b..dc19d50e182e9 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1442,7 +1442,8 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms const CaloParticle& caloParticle, std::vector const& simVertices, unsigned int layers, - std::unordered_map const& hitMap) const { + std::unordered_map const& hitMap, + std::vector const& hits) const { const auto eta = getEta(caloParticle.eta()); if (histograms.h_caloparticle_eta.count(pdgid)) { histograms.h_caloparticle_eta.at(pdgid)->Fill(eta); @@ -1489,13 +1490,13 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms // set to 0 if matched RecHit not found int layerId_matched_min = 999; int layerId_matched_max = 0; - std::unordered_map::const_iterator itcheck = hitMap.find(hitDetId); + std::unordered_map::const_iterator itcheck = hitMap.find(hitDetId); if (itcheck != hitMap.end()) { layerId_matched_min = layerId; layerId_matched_max = layerId; simHits_matched++; - const auto hitEn = itcheck->second->energy(); + const auto hitEn = (hits[itcheck->second]).energy(); hitEnergyWeight_invSum += pow(hitEn, 2); const auto hitFr = h_and_f.second; const auto hitEnFr = hitEn * hitFr; @@ -1556,7 +1557,7 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms } for (auto const& haf : haf_cp) { - const auto hitEn = hitMap.find(haf.first)->second->energy(); + const auto hitEn = (hits[hitMap.find(haf.first)->second]).energy(); const auto weight = pow(hitEn, 2); histograms.h_caloparticle_fractions.at(pdgid)->Fill(haf.second, weight * hitEnergyWeight_invSum); histograms.h_caloparticle_fractions_weight.at(pdgid)->Fill(haf.second, weight * hitEnergyWeight_invSum, weight); @@ -1700,10 +1701,11 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simClusterAssociation_hist std::vector const& simClusters, std::vector const& sCIndices, const std::vector& mask, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, - const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap) const { + const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap, + std::vector const& hits) const { //Each event to be treated as two events: an event in +ve endcap, //plus another event in -ve endcap. In this spirit there will be //a layer variable (layerid) that maps the layers in : @@ -1723,7 +1725,8 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simClusterAssociation_hist hitMap, layers, scsInLayerClusterMap, - lcsInSimClusterMap); + lcsInSimClusterMap, + hits); } void HGVHistoProducerAlgo::fill_cluster_histos(const Histograms& histograms, @@ -1740,10 +1743,11 @@ void HGVHistoProducerAlgo::layerClusters_to_CaloParticles(const Histograms& hist std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollection& cpsInLayerClusterMap, - const ticl::SimToRecoCollection& cPOnLayerMap) const { + const ticl::SimToRecoCollection& cPOnLayerMap, + std::vector const& hits) const { const auto nLayerClusters = clusters.size(); std::unordered_map> detIdToCaloParticleId_Map; @@ -1801,8 +1805,8 @@ void HGVHistoProducerAlgo::layerClusters_to_CaloParticles(const Histograms& hist const DetId rh_detid = hits_and_fractions[iHit].first; const auto rhFraction = hits_and_fractions[iHit].second; - std::unordered_map::const_iterator itcheck = hitMap.find(rh_detid); - const HGCRecHit* hit = itcheck->second; + std::unordered_map::const_iterator itcheck = hitMap.find(rh_detid); + const HGCRecHit* hit = &(hits[itcheck->second]); if (detIdToLayerClusterId_Map.find(rh_detid) == detIdToLayerClusterId_Map.end()) { detIdToLayerClusterId_Map[rh_detid] = std::vector(); @@ -1926,9 +1930,9 @@ void HGVHistoProducerAlgo::layerClusters_to_CaloParticles(const Histograms& hist const DetId hitid = (it_haf.first); const auto hitLayerId = recHitTools_->getLayerWithOffset(hitid) + layers * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; - std::unordered_map::const_iterator itcheck = hitMap.find(hitid); + std::unordered_map::const_iterator itcheck = hitMap.find(hitid); if (itcheck != hitMap.end()) { - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits[itcheck->second]); cPEnergyOnLayer[hitLayerId] += it_haf.second * hit->energy(); } } @@ -2000,10 +2004,11 @@ void HGVHistoProducerAlgo::layerClusters_to_SimClusters( std::vector const& sC, std::vector const& sCIndices, const std::vector& mask, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, - const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap) const { + const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap, + std::vector const& hits) const { // Here fill the plots to compute the different metrics linked to // reco-level, namely fake-rate and merge-rate. In this loop should *not* // restrict only to the selected SimClusters. @@ -2099,9 +2104,9 @@ void HGVHistoProducerAlgo::layerClusters_to_SimClusters( const DetId hitid = (it_haf.first); const auto scLayerId = recHitTools_->getLayerWithOffset(hitid) + layers * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; - std::unordered_map::const_iterator itcheck = hitMap.find(hitid); + std::unordered_map::const_iterator itcheck = hitMap.find(hitid); if (itcheck != hitMap.end()) { - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits[itcheck->second]); sCEnergyOnLayer[scLayerId] += it_haf.second * hit->energy(); } } @@ -2178,12 +2183,13 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, std::map cummatbudg, unsigned int layers, std::vector thicknesses, const ticl::RecoToSimCollection& cpsInLayerClusterMap, - const ticl::SimToRecoCollection& cPOnLayerMap) const { + const ticl::SimToRecoCollection& cPOnLayerMap, + std::vector const& hits) const { //Each event to be treated as two events: an event in +ve endcap, //plus another event in -ve endcap. In this spirit there will be //a layer variable (layerid) that maps the layers in : @@ -2218,7 +2224,8 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr hitMap, layers, cpsInLayerClusterMap, - cPOnLayerMap); + cPOnLayerMap, + hits); //To find out the total amount of energy clustered per layer //Initialize with zeros because I see clear gives weird numbers. @@ -2242,7 +2249,7 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr const auto seedid = lcId.seed(); const double seedx = recHitTools_->getPosition(seedid).x(); const double seedy = recHitTools_->getPosition(seedid).y(); - DetId maxid = findmaxhit(lcId, hitMap); + DetId maxid = findmaxhit(lcId, hitMap, hits); // const DetId maxid = lcId.max(); double maxx = recHitTools_->getPosition(maxid).x(); @@ -2323,7 +2330,7 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr << "\n"; } - std::unordered_map::const_iterator itcheck = hitMap.find(rh_detid); + std::unordered_map::const_iterator itcheck = hitMap.find(rh_detid); if (itcheck == hitMap.end()) { std::ostringstream st1; if ((rh_detid.det() == DetId::HGCalEE) || (rh_detid.det() == DetId::HGCalHSi)) { @@ -2338,8 +2345,7 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr continue; } - const HGCRecHit* hit = itcheck->second; - + const HGCRecHit* hit = &(hits[itcheck->second]); //Here for the per cell plots //---- const double hit_x = recHitTools_->getPosition(rh_detid).x(); @@ -2503,8 +2509,9 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const& hitMap, - unsigned int layers) const { + std::unordered_map const& hitMap, + unsigned int layers, + std::vector const& hits) const { const auto nTracksters = tracksters.size(); const auto nSimTracksters = simTSs.size(); @@ -2632,7 +2639,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( detIdSimTSId_Map[elemId].emplace_back(HGVHistoProducerAlgo::detIdInfoInCluster{iSTS, elemFr}); } } - const auto hitEn = itcheck->second->energy(); + const auto hitEn = (hits[itcheck->second]).energy(); //Since the current hit from sim cluster has a reconstructed hit with the same detid, //fill the cPOnLayer[caloparticle][layer] object with energy (sum of all rechits energy times fraction //of the relevant simhit) and keep the hit (detid and fraction) that contributed. @@ -2781,7 +2788,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( hitsToCaloParticleId[iHit] -= 1; } else { // Since the hit is belonging to the layer cluster, it must be also in the rechits map - const auto hitEn = hitMap.find(rh_detid)->second->energy(); + const auto hitEn = (hits[hitMap.find(rh_detid)->second]).energy(); //const auto layerId = //recHitTools_->getLayerWithOffset(rh_detid) + layers * ((recHitTools_->zside(rh_detid) + 1) >> 1) - 1; //0; @@ -2909,6 +2916,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( // Compute the correct normalization float tracksterEnergy = 0.f, invTracksterEnergyWeight = 0.f; for (const auto& haf : tst_hitsAndFractions) { + const HGCRecHit* hit = &(hits[hitMap.at(haf.first)]); float hitFr = 0.f; if (valType == 0) { hitFr = haf.second; @@ -2917,8 +2925,8 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( const auto iLC = std::find(tst.vertices().begin(), tst.vertices().end(), lcId); hitFr = 1.f / tst.vertex_multiplicity(std::distance(std::begin(tst.vertices()), iLC)); } - tracksterEnergy += hitFr * hitMap.at(haf.first)->energy(); - invTracksterEnergyWeight += pow(hitFr * hitMap.at(haf.first)->energy(), 2); + tracksterEnergy += hitFr * hit->energy(); + invTracksterEnergyWeight += pow(hitFr * hit->energy(), 2); } if (invTracksterEnergyWeight) invTracksterEnergyWeight = 1.f / invTracksterEnergyWeight; @@ -2940,7 +2948,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( bool hitWithNoSTS = false; if (detIdSimTSId_Map.find(elemId) == detIdSimTSId_Map.end()) hitWithNoSTS = true; - const HGCRecHit* hit = hitMap.find(rh_detid)->second; + const HGCRecHit* hit = &(hits[hitMap.find(rh_detid)->second]); const auto hitEnergyWeight = pow(hit->energy(), 2); for (auto& stsPair : stsInTrackster[tstId]) { @@ -3048,8 +3056,9 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( for (const auto& haf : hafLC) { const auto lcId = getLCId(sts.vertices(), layerClusters, haf.first); const auto iLC = std::find(sts.vertices().begin(), sts.vertices().end(), lcId); + const HGCRecHit* hit = &(hits[hitMap.at(haf.first)]); SimEnergy_LC += - hitMap.at(haf.first)->energy() / sts.vertex_multiplicity(std::distance(std::begin(sts.vertices()), iLC)); + hit->energy() / sts.vertex_multiplicity(std::distance(std::begin(sts.vertices()), iLC)); } auto iSim = sts.seedIndex(); @@ -3100,7 +3109,8 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( // Need to loop on the simOnLayer data structure since this is the // only one that has the compressed information for multiple usage // of the same DetId by different SimClusters by a single CaloParticle. - SimEnergyWeight += pow(haf.second * hitMap.at(hitDetId)->energy(), 2); + const HGCRecHit* hit = &(hits[hitMap.at(hitDetId)]); + SimEnergyWeight += pow(haf.second * hit->energy(), 2); const auto lcId = getLCId(sts.vertices(), layerClusters, hitDetId); float cpFraction = 0.f; @@ -3116,7 +3126,6 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( bool hitWithNoTS = false; if (detIdToTracksterId_Map.find(hitDetId) == detIdToTracksterId_Map.end()) hitWithNoTS = true; - const HGCRecHit* hit = hitMap.find(hitDetId)->second; const auto hitEnergyWeight = pow(hit->energy(), 2); hitsEnergyWeight += pow(cpFraction, 2) * hitEnergyWeight; @@ -3328,8 +3337,9 @@ void HGVHistoProducerAlgo::fill_trackster_histos( std::vector const& cP, std::vector const& cPIndices, std::vector const& cPSelectedIndices, - std::unordered_map const& hitMap, - unsigned int layers) const { + std::unordered_map const& hitMap, + unsigned int layers, + std::vector const& hits) const { //Each event to be treated as two events: //an event in +ve endcap, plus another event in -ve endcap. @@ -3510,7 +3520,8 @@ void HGVHistoProducerAlgo::fill_trackster_histos( cPIndices, cPSelectedIndices, hitMap, - layers); + layers, + hits); // Pattern recognition tracksters_to_SimTracksters(histograms, @@ -3527,7 +3538,8 @@ void HGVHistoProducerAlgo::fill_trackster_histos( cPIndices, cPSelectedIndices, hitMap, - layers); + layers, + hits); } double HGVHistoProducerAlgo::distance2(const double x1, @@ -3550,7 +3562,8 @@ void HGVHistoProducerAlgo::setRecHitTools(std::shared_ptr re } DetId HGVHistoProducerAlgo::findmaxhit(const reco::CaloCluster& cluster, - std::unordered_map const& hitMap) const { + std::unordered_map const& hitMap, + std::vector const& hits) const { const auto& hits_and_fractions = cluster.hitsAndFractions(); DetId themaxid; @@ -3559,8 +3572,7 @@ DetId HGVHistoProducerAlgo::findmaxhit(const reco::CaloCluster& cluster, it_haf != hits_and_fractions.end(); ++it_haf) { const DetId rh_detid = it_haf->first; - const auto hitEn = hitMap.find(rh_detid)->second->energy(); - + const auto hitEn = (hits[hitMap.find(rh_detid)->second]).energy(); if (maxene < hitEn) { maxene = hitEn; themaxid = rh_detid; From 949095969e88e65c634a163b80fe328f9e6181fb Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 20 Mar 2024 16:12:18 +0100 Subject: [PATCH 011/301] enable cps in phase2_common modifier --- .../python/caloTruthProducer_cfi.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py index 0696591ad7b32..3115dd13b81d1 100644 --- a/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py +++ b/SimGeneral/MixingModule/python/caloTruthProducer_cfi.py @@ -59,3 +59,20 @@ from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toReplaceWith(caloParticles, cms.PSet()) # don't allow this to run in fastsim +from Configuration.Eras.Modifier_phase2_common_cff import phase2_common +phase2_common.toModify( + caloParticles, + simHitCollections = cms.PSet( + hgc = cms.VInputTag( + cms.InputTag('g4SimHits', 'HGCHitsEE'), + cms.InputTag('g4SimHits', 'HGCHitsHEfront'), + cms.InputTag('g4SimHits', 'HGCHitsHEback'), + ), + hcal = cms.VInputTag(cms.InputTag('g4SimHits', 'HcalHits')), + ecal = cms.VInputTag( + cms.InputTag('g4SimHits', 'EcalHitsEB') + ) + ) +) + + From 0247d27afe0c649d7e094293703e2fa22ee8041e Mon Sep 17 00:00:00 2001 From: brusale Date: Thu, 21 Mar 2024 10:25:25 +0100 Subject: [PATCH 012/301] update MtdSimCluster classversion --- SimDataFormats/CaloAnalysis/src/classes_def.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SimDataFormats/CaloAnalysis/src/classes_def.xml b/SimDataFormats/CaloAnalysis/src/classes_def.xml index ee329dfce2ed8..74e90da2522c3 100644 --- a/SimDataFormats/CaloAnalysis/src/classes_def.xml +++ b/SimDataFormats/CaloAnalysis/src/classes_def.xml @@ -30,7 +30,8 @@ - + + From 79f27d73b43e8506765e494456c080715c9a1860 Mon Sep 17 00:00:00 2001 From: brusale Date: Thu, 21 Mar 2024 15:01:24 +0100 Subject: [PATCH 013/301] apply code-format --- .../HGCalRecAlgos/src/RecHitTools.cc | 8 +++--- .../plugins/RecHitMapProducer.cc | 14 +++++----- .../LCToCPAssociatorByEnergyScoreImpl.cc | 12 +++++---- .../LCToCPAssociatorByEnergyScoreImpl.h | 5 ++-- .../LCToCPAssociatorByEnergyScoreProducer.cc | 26 +++++++++---------- .../LCToCPAssociatorByEnergyScoreProducer.h | 4 +-- .../LCToSCAssociatorByEnergyScoreImpl.cc | 12 +++++---- .../LCToSCAssociatorByEnergyScoreImpl.h | 4 +-- .../LCToSCAssociatorByEnergyScoreProducer.cc | 25 +++++++++--------- .../LCToSCAssociatorByEnergyScoreProducer.h | 2 +- .../CaloAnalysis/interface/SimCluster.h | 11 ++++---- .../interface/HGCalValidator.h | 3 ++- .../interface/HGVHistoProducerAlgo.h | 16 +++++++----- .../HGCalValidation/plugins/HGCalValidator.cc | 12 +++++---- .../src/HGVHistoProducerAlgo.cc | 25 +++++++++--------- 15 files changed, 94 insertions(+), 85 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc index ecd0f9e050678..aa5558010448c 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc @@ -368,10 +368,10 @@ unsigned int RecHitTools::getLayer(const DetId& id) const { } else if (id.det() == DetId::Forward) { layer = HGCalDetId(id).layer(); } else if (id.det() == DetId::Hcal && id.subdetId() != HcalEmpty) { - if (id.subdetId() == HcalBarrel) - layer = HcalDetId(id).depth(); - else if (id.subdetId() == HcalOuter) - layer = HcalDetId(id).depth() + 1; + if (id.subdetId() == HcalBarrel) + layer = HcalDetId(id).depth(); + else if (id.subdetId() == HcalOuter) + layer = HcalDetId(id).depth() + 1; } else if (id.det() == DetId::Ecal) { layer = 0; } diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc index 281a1efd81254..c7ce542f39bc3 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc @@ -44,7 +44,7 @@ RecHitMapProducer::RecHitMapProducer(const edm::ParameterSet& ps) hits_ho_token_(consumes(ps.getParameter("HOInput"))), hgcalOnly_(ps.getParameter("hgcalOnly")) { produces("hgcalRecHitMap"); - if (!hgcalOnly_) + if (!hgcalOnly_) produces("barrelRecHitMap"); } @@ -70,14 +70,14 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event hitMapHGCal->emplace(ee_hits[i].detid(), i); } auto size = ee_hits.size(); - + for (unsigned int i = 0; i < fh_hits.size(); ++i) { - hitMapHGCal->emplace(fh_hits[i].detid(), i+size); + hitMapHGCal->emplace(fh_hits[i].detid(), i + size); } size += fh_hits.size(); for (unsigned int i = 0; i < bh_hits.size(); ++i) { - hitMapHGCal->emplace(bh_hits[i].detid(), i+size); + hitMapHGCal->emplace(bh_hits[i].detid(), i + size); } evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); @@ -88,19 +88,19 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event const auto& hb_hits = evt.get(hits_hb_token_); const auto& ho_hits = evt.get(hits_ho_token_); size = 0; - + for (unsigned int i = 0; i < eb_hits.size(); ++i) { hitMapBarrel->emplace(eb_hits[i].detId(), i); } size += eb_hits.size(); for (unsigned int i = 0; i < hb_hits.size(); ++i) { - hitMapBarrel->emplace(hb_hits[i].detId(), i+size); + hitMapBarrel->emplace(hb_hits[i].detId(), i + size); } size += hb_hits.size(); for (unsigned int i = 0; i < ho_hits.size(); ++i) { - hitMapBarrel->emplace(ho_hits[i].detId(), i+size); + hitMapBarrel->emplace(ho_hits[i].detId(), i + size); } evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index 3eba2cccd0add..fa4601ffc789f 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -14,10 +14,13 @@ LCToCPAssociatorByEnergyScoreImpl::LCToCPAssociatorByEnergyScoreImpl( edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map* hitMap, + const std::unordered_map* hitMap, std::vector& hits) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter), hits_(hits) { - + : hardScatterOnly_(hardScatterOnly), + recHitTools_(recHitTools), + hitMap_(hitMap), + productGetter_(&productGetter), + hits_(hits) { if constexpr (std::is_same_v) layers_ = recHitTools_->lastLayerBH(); else @@ -365,8 +368,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( float invLayerClusterEnergyWeight = 0.f; for (auto const& haf : hits_and_fractions) { const HIT* hit = &(hits_[hitMap_->at(haf.first)]); - invLayerClusterEnergyWeight += (haf.second * hit->energy()) * - (haf.second * hit->energy()); + invLayerClusterEnergyWeight += (haf.second * hit->energy()) * (haf.second * hit->energy()); } invLayerClusterEnergyWeight = 1.f / invLayerClusterEnergyWeight; for (unsigned int i = 0; i < numberOfHitsInLC; ++i) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h index b718ed0248095..2b4a6f50aec91 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h @@ -70,9 +70,8 @@ class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticl explicit LCToCPAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *, - std::vector& hits); - + const std::unordered_map *, + std::vector &hits); ticl::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, const edm::Handle &cPCH) const override; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index ef8b82f3be93d..88c153f9973df 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -6,11 +6,10 @@ LCToCPAssociatorByEnergyScoreProducer::LCToCPAssociatorByEnergyScoreProduce caloGeometry_(esConsumes()), hardScatterOnly_(ps.getParameter("hardScatterOnly")), hits_label_(ps.getParameter>("hits")) { - - for (auto& label : hits_label_) { + for (auto &label : hits_label_) { if constexpr (std::is_same_v) hgcal_hits_token_.push_back(consumes(label)); - else + else hits_token_.push_back(consumes>(label)); } @@ -32,13 +31,13 @@ void LCToCPAssociatorByEnergyScoreProducer::produce(edm::StreamID, std::vector hits; if constexpr (std::is_same_v) { - for (auto& token : hgcal_hits_token_) { + for (auto &token : hgcal_hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); } } else { - for (auto& token : hits_token_) { + for (auto &token : hits_token_) { edm::Handle> hits_handle; iEvent.getByToken(token, hits_handle); hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); @@ -58,15 +57,16 @@ void LCToCPAssociatorByEnergyScoreProducer::fillDescriptions(edm::Configura desc.add("hardScatterOnly", true); if constexpr (std::is_same_v) { desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); - desc.add>("hits", {edm::InputTag("HGCalRecHit", "HGCEERecHits"), - edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), - edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); - } else { + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); + } else { desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "barrelRecHitMap")); - desc.add>("hits", {edm::InputTag("particleFlowRecHitECAL", ""), - edm::InputTag("particleFlowRecHitHBHE", ""), - edm::InputTag("particleFlowRecHitHO", "")}); - + desc.add>("hits", + {edm::InputTag("particleFlowRecHitECAL", ""), + edm::InputTag("particleFlowRecHitHBHE", ""), + edm::InputTag("particleFlowRecHitHO", "")}); } cfg.addWithDefaultLabel(desc); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h index d58e54c37aca0..258d753db6f1e 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h @@ -20,7 +20,7 @@ #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" -template +template class LCToCPAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { public: explicit LCToCPAssociatorByEnergyScoreProducer(const edm::ParameterSet &); @@ -35,7 +35,7 @@ class LCToCPAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { const bool hardScatterOnly_; std::shared_ptr rhtools_; std::vector hits_label_; - std::vector> hgcal_hits_token_; + std::vector> hgcal_hits_token_; std::vector>> hits_token_; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index d1af4cc9aa8d4..e884013f9b968 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -10,8 +10,11 @@ LCToSCAssociatorByEnergyScoreImpl::LCToSCAssociatorByEnergyScoreImpl( std::shared_ptr recHitTools, const std::unordered_map* hitMap, std::vector& hits) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter), hits_(hits) { - + : hardScatterOnly_(hardScatterOnly), + recHitTools_(recHitTools), + hitMap_(hitMap), + productGetter_(&productGetter), + hits_(hits) { if constexpr (std::is_same_v) layers_ = recHitTools_->lastLayerBH(); else @@ -318,9 +321,8 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( double tot_energy = 0.; for (auto const& haf : lcsInSimCluster[sc][sclay].hits_and_fractions) { const HIT* hit = &(hits_[itcheck->second]); - LogDebug("LCToSCAssociatorByEnergyScoreImpl") - << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hit->energy() << std::endl; + LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" + << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); } LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Tot Sum haf: " << tot_energy << std::endl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h index 1b17035fcbaa3..17cce52e500f0 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h @@ -67,8 +67,8 @@ class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterA explicit LCToSCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *, - std::vector& hits); + const std::unordered_map *, + std::vector &hits); ticl::RecoToSimCollectionWithSimClusters associateRecoToSim( const edm::Handle &cCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 5171af322fa38..1b2f381fe2cd3 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -6,11 +6,10 @@ LCToSCAssociatorByEnergyScoreProducer::LCToSCAssociatorByEnergyScoreProduce caloGeometry_(esConsumes()), hardScatterOnly_(ps.getParameter("hardScatterOnly")), hits_label_(ps.getParameter>("hits")) { - - for (auto& label : hits_label_) { + for (auto &label : hits_label_) { if constexpr (std::is_same_v) hgcal_hits_token_.push_back(consumes(label)); - else + else hits_token_.push_back(consumes>(label)); } @@ -32,13 +31,13 @@ void LCToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, std::vector hits; if constexpr (std::is_same_v) { - for (auto& token : hgcal_hits_token_) { + for (auto &token : hgcal_hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); } } else { - for (auto& token : hits_token_) { + for (auto &token : hits_token_) { edm::Handle> hits_handle; iEvent.getByToken(token, hits_handle); hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); @@ -58,14 +57,16 @@ void LCToSCAssociatorByEnergyScoreProducer::fillDescriptions(edm::Configura desc.add("hardScatterOnly", true); if constexpr (std::is_same_v) { desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); - desc.add>("hits", {edm::InputTag("HGCalRecHit", "HGCEERecHits"), - edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), - edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); - } else { + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); + } else { desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "barrelRecHitMap")); - desc.add>("hits", {edm::InputTag("particleFlowRecHitECAL", ""), - edm::InputTag("particleFlowRecHitHBHE", ""), - edm::InputTag("particleFlowRecHitHO", "")}); + desc.add>("hits", + {edm::InputTag("particleFlowRecHitECAL", ""), + edm::InputTag("particleFlowRecHitHBHE", ""), + edm::InputTag("particleFlowRecHitHO", "")}); } cfg.addWithDefaultLabel(desc); } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h index 18dab5dc109bc..1bf22895c439e 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h @@ -20,7 +20,7 @@ #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" -template +template class LCToSCAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { public: explicit LCToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &); diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index eb66f750f5db0..7b1d0d475a7f4 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -177,10 +177,12 @@ class SimCluster { void addRecHitAndFraction(uint32_t hit, float fraction) { hits_.emplace_back(hit); fractions_.emplace_back(fraction); - if ((hit >= firstDetIdEB_ && hit < firstDetIdEE_) || (hit >= firstDetIdHB_ && hit < firstDetIdHE_) || (hit >= firstDetIdHO_ && hit < firstDetIdHcalForward_)) { + if ((hit >= firstDetIdEB_ && hit < firstDetIdEE_) || (hit >= firstDetIdHB_ && hit < firstDetIdHE_) || + (hit >= firstDetIdHO_ && hit < firstDetIdHcalForward_)) { barrel_hits_.emplace_back(hit); barrel_fractions_.emplace_back(fraction); - } else if ((hit >= firstDetIdEE_ && hit < lastDetIdES_) || (hit >= firstDetIdHE_ && hit < firstDetIdHO_) || (hit >= firstDetIdHcalForward_ && hit < lastDetIdHcalForward_) || (hit >= firstDetIdHGCal_)) { + } else if ((hit >= firstDetIdEE_ && hit < lastDetIdES_) || (hit >= firstDetIdHE_ && hit < firstDetIdHO_) || + (hit >= firstDetIdHcalForward_ && hit < lastDetIdHcalForward_) || (hit >= firstDetIdHGCal_)) { endcap_hits_.emplace_back(hit); endcap_fractions_.emplace_back(fraction); } @@ -197,8 +199,8 @@ class SimCluster { } return result; } - - /** @brief Returns list of rechit IDs and fractions in the barrel for this SimCluster */ + + /** @brief Returns list of rechit IDs and fractions in the barrel for this SimCluster */ std::vector> barrel_hits_and_fractions() const { std::vector> result; for (size_t i = 0; i < barrel_hits_.size(); ++i) { @@ -275,7 +277,6 @@ class SimCluster { uint32_t firstDetIdHcalForward_ = (4 << 28) + (4 << 25); uint32_t lastDetIdHcalForward_ = (4 << 28) + (5 << 25); uint32_t firstDetIdHGCal_ = 5 << 28; - }; #endif // SimDataFormats_SimCluster_H diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index be113e19f648b..b00e5100d56df 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -56,7 +56,7 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { std::vector const& simVertices, std::vector& selected_cPeff, unsigned int layers, - std::unordered_map const&, + std::unordered_map const&, std::vector const& hits) const; protected: @@ -97,6 +97,7 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { std::unique_ptr histoProducerAlgo_; std::vector hits_label_; std::vector> hits_token_; + private: CaloParticleSelector cpSelector; std::shared_ptr tools_; diff --git a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h index f36168377d651..4b3cdafb6a58a 100644 --- a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h +++ b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h @@ -272,7 +272,7 @@ class HGVHistoProducerAlgo { std::unordered_map const&, unsigned int layers, const ticl::RecoToSimCollection& recSimColl, - const ticl::SimToRecoCollection& simRecColl, + const ticl::SimToRecoCollection& simRecColl, std::vector const& hits) const; void layerClusters_to_SimClusters(const Histograms& histograms, const int count, @@ -285,7 +285,7 @@ class HGVHistoProducerAlgo { std::unordered_map const&, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& recSimColl, - const ticl::SimToRecoCollectionWithSimClusters& simRecColl, + const ticl::SimToRecoCollectionWithSimClusters& simRecColl, std::vector const& hits) const; void tracksters_to_SimTracksters(const Histograms& histograms, const int count, @@ -301,7 +301,7 @@ class HGVHistoProducerAlgo { std::vector const& cPIndices, std::vector const& cPSelectedIndices, std::unordered_map const&, - unsigned int layers, + unsigned int layers, std::vector const& hits) const; void fill_info_histos(const Histograms& histograms, unsigned int layers) const; void fill_caloparticle_histos(const Histograms& histograms, @@ -324,7 +324,7 @@ class HGVHistoProducerAlgo { unsigned int layers, std::vector thicknesses, const ticl::RecoToSimCollection& recSimColl, - const ticl::SimToRecoCollection& simRecColl, + const ticl::SimToRecoCollection& simRecColl, std::vector const& hits) const; void fill_simCluster_histos(const Histograms& histograms, std::vector const& simClusters, @@ -341,7 +341,7 @@ class HGVHistoProducerAlgo { std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& recSimColl, - const ticl::SimToRecoCollectionWithSimClusters& simRecColl, + const ticl::SimToRecoCollectionWithSimClusters& simRecColl, std::vector const& hits) const; void fill_cluster_histos(const Histograms& histograms, const int count, const reco::CaloCluster& cluster) const; void fill_trackster_histos(const Histograms& histograms, @@ -357,14 +357,16 @@ class HGVHistoProducerAlgo { std::vector const& cPIndices, std::vector const& cPSelectedIndices, std::unordered_map const&, - unsigned int layers, + unsigned int layers, std::vector const& hits) const; double distance2(const double x1, const double y1, const double x2, const double y2) const; double distance(const double x1, const double y1, const double x2, const double y2) const; void setRecHitTools(std::shared_ptr recHitTools); - DetId findmaxhit(const reco::CaloCluster& cluster, std::unordered_map const&, std::vector const& hits) const; + DetId findmaxhit(const reco::CaloCluster& cluster, + std::unordered_map const&, + std::vector const& hits) const; struct detIdInfoInCluster { bool operator==(const detIdInfoInCluster& o) const { return clusterId == o.clusterId; }; diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 7d0e7088eb4e0..5dc82508ee8cb 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -30,7 +30,7 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) label_TSToCPLinking_(pset.getParameter("label_TSToCPLinking")), label_TSToSTSPR_(pset.getParameter("label_TSToSTSPR")), label_clustersmask(pset.getParameter>("LayerClustersInputMask")), - cummatbudinxo_(pset.getParameter("cummatbudinxo")), + cummatbudinxo_(pset.getParameter("cummatbudinxo")), hits_label_(pset.getParameter>("hits")) { //In this way we can easily generalize to associations between other objects also. const edm::InputTag& label_cp_effic_tag = pset.getParameter("label_cp_effic"); @@ -53,7 +53,8 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) simTrackstersMap_ = consumes>>(edm::InputTag("ticlSimTracksters")); - hitMap_ = consumes>(edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + hitMap_ = + consumes>(edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); simClusters_ = consumes>(pset.getParameter("label_scl")); @@ -230,7 +231,7 @@ void HGCalValidator::cpParametersAndSelection(const Histograms& histograms, std::vector const& simVertices, std::vector& selected_cPeff, unsigned int layers, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, std::vector const& hits) const { selected_cPeff.reserve(cPeff.size()); @@ -319,7 +320,8 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, // HGCRecHit are given to select the SimHits which are also reconstructed LogTrace("HGCalValidator") << "\n# of CaloParticles: " << caloParticles.size() << "\n" << std::endl; std::vector selected_cPeff; - cpParametersAndSelection(histograms, caloParticles, simVertices, selected_cPeff, totallayers_to_monitor_, *hitMap, hits); + cpParametersAndSelection( + histograms, caloParticles, simVertices, selected_cPeff, totallayers_to_monitor_, *hitMap, hits); //get collections from the event //simClusters @@ -376,7 +378,7 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, *hitMap, totallayers_to_monitor_, recSimColl, - simRecColl, + simRecColl, hits); //General Info on simClusters diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index dc19d50e182e9..98570925c54e7 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1442,7 +1442,7 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms const CaloParticle& caloParticle, std::vector const& simVertices, unsigned int layers, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, std::vector const& hits) const { const auto eta = getEta(caloParticle.eta()); if (histograms.h_caloparticle_eta.count(pdgid)) { @@ -1704,7 +1704,7 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simClusterAssociation_hist std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, - const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap, + const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap, std::vector const& hits) const { //Each event to be treated as two events: an event in +ve endcap, //plus another event in -ve endcap. In this spirit there will be @@ -1725,7 +1725,7 @@ void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simClusterAssociation_hist hitMap, layers, scsInLayerClusterMap, - lcsInSimClusterMap, + lcsInSimClusterMap, hits); } @@ -2007,7 +2007,7 @@ void HGVHistoProducerAlgo::layerClusters_to_SimClusters( std::unordered_map const& hitMap, unsigned int layers, const ticl::RecoToSimCollectionWithSimClusters& scsInLayerClusterMap, - const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap, + const ticl::SimToRecoCollectionWithSimClusters& lcsInSimClusterMap, std::vector const& hits) const { // Here fill the plots to compute the different metrics linked to // reco-level, namely fake-rate and merge-rate. In this loop should *not* @@ -2188,7 +2188,7 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histogr unsigned int layers, std::vector thicknesses, const ticl::RecoToSimCollection& cpsInLayerClusterMap, - const ticl::SimToRecoCollection& cPOnLayerMap, + const ticl::SimToRecoCollection& cPOnLayerMap, std::vector const& hits) const { //Each event to be treated as two events: an event in +ve endcap, //plus another event in -ve endcap. In this spirit there will be @@ -2510,7 +2510,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( std::vector const& cPIndices, std::vector const& cPSelectedIndices, std::unordered_map const& hitMap, - unsigned int layers, + unsigned int layers, std::vector const& hits) const { const auto nTracksters = tracksters.size(); const auto nSimTracksters = simTSs.size(); @@ -2948,7 +2948,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( bool hitWithNoSTS = false; if (detIdSimTSId_Map.find(elemId) == detIdSimTSId_Map.end()) hitWithNoSTS = true; - const HGCRecHit* hit = &(hits[hitMap.find(rh_detid)->second]); + const HGCRecHit* hit = &(hits[hitMap.find(rh_detid)->second]); const auto hitEnergyWeight = pow(hit->energy(), 2); for (auto& stsPair : stsInTrackster[tstId]) { @@ -3057,8 +3057,7 @@ void HGVHistoProducerAlgo::tracksters_to_SimTracksters( const auto lcId = getLCId(sts.vertices(), layerClusters, haf.first); const auto iLC = std::find(sts.vertices().begin(), sts.vertices().end(), lcId); const HGCRecHit* hit = &(hits[hitMap.at(haf.first)]); - SimEnergy_LC += - hit->energy() / sts.vertex_multiplicity(std::distance(std::begin(sts.vertices()), iLC)); + SimEnergy_LC += hit->energy() / sts.vertex_multiplicity(std::distance(std::begin(sts.vertices()), iLC)); } auto iSim = sts.seedIndex(); @@ -3338,7 +3337,7 @@ void HGVHistoProducerAlgo::fill_trackster_histos( std::vector const& cPIndices, std::vector const& cPSelectedIndices, std::unordered_map const& hitMap, - unsigned int layers, + unsigned int layers, std::vector const& hits) const { //Each event to be treated as two events: //an event in +ve endcap, plus another event in -ve endcap. @@ -3520,7 +3519,7 @@ void HGVHistoProducerAlgo::fill_trackster_histos( cPIndices, cPSelectedIndices, hitMap, - layers, + layers, hits); // Pattern recognition @@ -3538,7 +3537,7 @@ void HGVHistoProducerAlgo::fill_trackster_histos( cPIndices, cPSelectedIndices, hitMap, - layers, + layers, hits); } @@ -3562,7 +3561,7 @@ void HGVHistoProducerAlgo::setRecHitTools(std::shared_ptr re } DetId HGVHistoProducerAlgo::findmaxhit(const reco::CaloCluster& cluster, - std::unordered_map const& hitMap, + std::unordered_map const& hitMap, std::vector const& hits) const { const auto& hits_and_fractions = cluster.hitsAndFractions(); From 6cd274cfff0842491942ff14fde45078e0c2b00c Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 27 Mar 2024 17:09:16 +0100 Subject: [PATCH 014/301] rearrange barrel/endcap hits and fractions --- .../CaloAnalysis/interface/SimCluster.h | 39 ++++++------------- .../CaloAnalysis/src/classes_def.xml | 6 ++- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index 7b1d0d475a7f4..b83f09c5f2a9f 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -11,6 +11,8 @@ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" +#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" + // // Forward declarations // @@ -177,15 +179,6 @@ class SimCluster { void addRecHitAndFraction(uint32_t hit, float fraction) { hits_.emplace_back(hit); fractions_.emplace_back(fraction); - if ((hit >= firstDetIdEB_ && hit < firstDetIdEE_) || (hit >= firstDetIdHB_ && hit < firstDetIdHE_) || - (hit >= firstDetIdHO_ && hit < firstDetIdHcalForward_)) { - barrel_hits_.emplace_back(hit); - barrel_fractions_.emplace_back(fraction); - } else if ((hit >= firstDetIdEE_ && hit < lastDetIdES_) || (hit >= firstDetIdHE_ && hit < firstDetIdHO_) || - (hit >= firstDetIdHcalForward_ && hit < lastDetIdHcalForward_) || (hit >= firstDetIdHGCal_)) { - endcap_hits_.emplace_back(hit); - endcap_fractions_.emplace_back(fraction); - } } /** @brief add rechit energy */ @@ -203,8 +196,11 @@ class SimCluster { /** @brief Returns list of rechit IDs and fractions in the barrel for this SimCluster */ std::vector> barrel_hits_and_fractions() const { std::vector> result; - for (size_t i = 0; i < barrel_hits_.size(); ++i) { - result.emplace_back(barrel_hits_[i], barrel_fractions_[i]); + for (size_t i = 0; i < hits_.size(); ++i) { + DetId detid(hits_[i]); + if (detid.subdetId() != EcalBarrel && detid.subdetId() != HcalBarrel && detid.subdetId() != HcalOuter) + continue; + result.emplace_back(hits_[i], fractions_[i]); } return result; } @@ -212,8 +208,11 @@ class SimCluster { /** @brief Returns list of rechit IDs and fractions in the endcap for this SimCluster */ std::vector> endcap_hits_and_fractions() const { std::vector> result; - for (size_t i = 0; i < endcap_hits_.size(); ++i) { - result.emplace_back(endcap_hits_[i], endcap_fractions_[i]); + for (size_t i = 0; i < hits_.size(); ++i) { + DetId detid(hits_[i]); + if (detid.subdetId() == EcalBarrel || detid.subdetId() == HcalBarrel || detid.subdetId() == HcalOuter) + continue; + result.emplace_back(hits_[i], fractions_[i]); } return result; } @@ -255,10 +254,6 @@ class SimCluster { float simhit_energy_{0.f}; std::vector hits_; std::vector fractions_; - std::vector barrel_hits_; - std::vector endcap_hits_; - std::vector barrel_fractions_; - std::vector endcap_fractions_; std::vector energies_; math::XYZTLorentzVectorF theMomentum_; @@ -267,16 +262,6 @@ class SimCluster { std::vector g4Tracks_; reco::GenParticleRefVector genParticles_; -private: - uint32_t firstDetIdEB_ = (3 << 28) + (1 << 25); - uint32_t firstDetIdEE_ = (3 << 28) + (2 << 25); - uint32_t lastDetIdES_ = (3 << 28) + (4 << 25); - uint32_t firstDetIdHB_ = (4 << 28) + (1 << 25); - uint32_t firstDetIdHE_ = (4 << 28) + (2 << 25); - uint32_t firstDetIdHO_ = (4 << 28) + (3 << 25); - uint32_t firstDetIdHcalForward_ = (4 << 28) + (4 << 25); - uint32_t lastDetIdHcalForward_ = (4 << 28) + (5 << 25); - uint32_t firstDetIdHGCal_ = 5 << 28; }; #endif // SimDataFormats_SimCluster_H diff --git a/SimDataFormats/CaloAnalysis/src/classes_def.xml b/SimDataFormats/CaloAnalysis/src/classes_def.xml index 74e90da2522c3..f855030468142 100644 --- a/SimDataFormats/CaloAnalysis/src/classes_def.xml +++ b/SimDataFormats/CaloAnalysis/src/classes_def.xml @@ -17,7 +17,8 @@ - + + @@ -30,7 +31,8 @@ - + + From 82bb01e85f30daa167f5338bd24dba2635eb261a Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 27 Mar 2024 17:22:50 +0100 Subject: [PATCH 015/301] remove old hitMap --- .../python/hgcalLocalReco_cff.py | 1 - .../plugins/HGCalRecHitMapProducer.cc | 66 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitMapProducer.cc diff --git a/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py b/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py index 8b0e5ff45aaf7..41effadbfb0b2 100644 --- a/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py +++ b/RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py @@ -3,7 +3,6 @@ from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHit_cfi import * from RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi import * -#from RecoLocalCalo.HGCalRecProducers.hgcalRecHitMapProducer_cfi import hgcalRecHitMapProducer from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer # patch particle flow clusters for HGC into local reco sequence diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitMapProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitMapProducer.cc deleted file mode 100644 index f73ab2b87ffff..0000000000000 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalRecHitMapProducer.cc +++ /dev/null @@ -1,66 +0,0 @@ -// user include files -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/global/EDProducer.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" - -#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" - -class HGCalRecHitMapProducer : public edm::global::EDProducer<> { -public: - HGCalRecHitMapProducer(const edm::ParameterSet&); - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; - -private: - const edm::EDGetTokenT hits_ee_token_; - const edm::EDGetTokenT hits_fh_token_; - const edm::EDGetTokenT hits_bh_token_; -}; - -DEFINE_FWK_MODULE(HGCalRecHitMapProducer); - -using DetIdRecHitMap = std::unordered_map; - -HGCalRecHitMapProducer::HGCalRecHitMapProducer(const edm::ParameterSet& ps) - : hits_ee_token_(consumes(ps.getParameter("EEInput"))), - hits_fh_token_(consumes(ps.getParameter("FHInput"))), - hits_bh_token_(consumes(ps.getParameter("BHInput"))) { - produces(); -} - -void HGCalRecHitMapProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add("EEInput", {"HGCalRecHit", "HGCEERecHits"}); - desc.add("FHInput", {"HGCalRecHit", "HGCHEFRecHits"}); - desc.add("BHInput", {"HGCalRecHit", "HGCHEBRecHits"}); - descriptions.add("hgcalRecHitMapProducer", desc); -} - -void HGCalRecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const { - auto hitMap = std::make_unique(); - const auto& ee_hits = evt.get(hits_ee_token_); - const auto& fh_hits = evt.get(hits_fh_token_); - const auto& bh_hits = evt.get(hits_bh_token_); - - for (const auto& hit : ee_hits) { - hitMap->emplace(hit.detid(), &hit); - } - - for (const auto& hit : fh_hits) { - hitMap->emplace(hit.detid(), &hit); - } - - for (const auto& hit : bh_hits) { - hitMap->emplace(hit.detid(), &hit); - } - evt.put(std::move(hitMap)); -} From 6c4707ddf6f38bed8104e2164d8daa7e0e4b7937 Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 27 Mar 2024 17:52:03 +0100 Subject: [PATCH 016/301] fix LogDebug in associators and code-format --- .../LCToCPAssociatorByEnergyScoreImpl.cc | 26 +++++++++++-------- .../LCToSCAssociatorByEnergyScoreImpl.cc | 15 ++++++----- .../CaloAnalysis/interface/SimCluster.h | 1 - 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index fa4601ffc789f..ec3cd224bf502 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -8,6 +8,7 @@ #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" #include "SimCalorimetry/HGCalAssociatorProducers/interface/AssociatorTools.h" +#include "DataFormats/EcalDetId/interface/EBDetId.h" template LCToCPAssociatorByEnergyScoreImpl::LCToCPAssociatorByEnergyScoreImpl( @@ -78,6 +79,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( cpLayerId += layers_ * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; const auto itcheck = hitMap_->find(hitid); + if (itcheck != hitMap_->end()) { auto hit_find_it = detIdToCaloParticleId_Map.find(hitid); if (hit_find_it == detIdToCaloParticleId_Map.end()) { @@ -126,10 +128,10 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl; double tot_energy = 0.; for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) { - LogDebug("LCToCPAssociatorByEnergyScoreImpl") - << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + const HIT* hit = &(hits_[hitMap_->at(DetId(haf.first))]); + LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" + << haf.second << "/" << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " Tot Sum haf: " << tot_energy << std::endl; for (auto const& lc : cPOnLayer[cp][cpp].layerClusterIdToEnergyAndScore) { @@ -144,10 +146,11 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToCPAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)cp.first << " we have found the following connections with CaloParticles:" << std::endl; + const HIT* hit = &(hits_[hitMap_->at(cp.first)]); for (auto const& cpp : cp.second) { LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " CaloParticle Id: " << cpp.clusterId << " with fraction: " << cpp.fraction - << " and energy: " << cpp.fraction * hitMap_->at(cp.first)->energy() << std::endl; + << " and energy: " << cpp.fraction * hit->energy() << std::endl; } } #endif @@ -243,7 +246,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( hitsToCaloParticleId[hitId] -= 1; } else { const auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = static_cast(itcheck->second); + const HIT* hit = &(hits_[itcheck->first]); auto maxCPEnergyInLC = 0.f; auto maxCPId = -1; for (auto& h : hit_find_in_CP->second) { @@ -317,10 +320,10 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl; double tot_energy = 0.; for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) { - LogDebug("LCToCPAssociatorByEnergyScoreImpl") - << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" + << haf.second << "/" << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " Tot Sum haf: " << tot_energy << std::endl; for (auto const& lc : cPOnLayer[cp][cpp].layerClusterIdToEnergyAndScore) { @@ -335,10 +338,11 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToCPAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)cp.first << " we have found the following connections with CaloParticles:" << std::endl; + const HIT* hit = &(hits_[hitMap_->at(cp.first)]); for (auto const& cpp : cp.second) { LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " CaloParticle Id: " << cpp.clusterId << " with fraction: " << cpp.fraction - << " and energy: " << cpp.fraction * hitMap_->at(cp.first)->energy() << std::endl; + << " and energy: " << cpp.fraction * hit->energy() << std::endl; } } #endif diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index e884013f9b968..aca445573d64a 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -105,10 +105,10 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << lcsInSimCluster[sc][sclay].energy << std::endl; double tot_energy = 0.; for (auto const& haf : lcsInSimCluster[sc][sclay].hits_and_fractions) { - LogDebug("LCToSCAssociatorByEnergyScoreImpl") - << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" + << haf.second << "/" << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Tot Sum haf: " << tot_energy << std::endl; for (auto const& lc : lcsInSimCluster[sc][sclay].layerClusterIdToEnergyAndScore) { @@ -127,10 +127,11 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // specific detId there are more that one SimClusters contributing with fractions less than 1. // This is important since it effects the score computation, since the fraction is also in the // denominator of the score formula. + const HIT* hit = &(hits_[hitMap_->at(sc.first)]); for (auto const& sclu : sc.second) { LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " SimCluster Id: " << sclu.clusterId << " with fraction: " << sclu.fraction - << " and energy: " << sclu.fraction * hitMap_->at(sc.first)->energy() << std::endl; + << " and energy: " << sclu.fraction * hit->energy() << std::endl; } } #endif @@ -320,7 +321,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << lcsInSimCluster[sc][sclay].energy << std::endl; double tot_energy = 0.; for (auto const& haf : lcsInSimCluster[sc][sclay].hits_and_fractions) { - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = &(hits_[hitMap_->at(haf.first)]); LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -335,7 +336,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToSCAssociatorByEnergyScoreImpl") << "Improved detIdToSimClusterId_Map INFO" << std::endl; for (auto const& sc : detIdToSimClusterId_Map) { - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = &(hits_[hitMap_->at(sc.first)]); LogDebug("LCToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)sc.first << " we have found the following connections with SimClusters:" << std::endl; diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index b83f09c5f2a9f..71f9b367bce63 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -261,7 +261,6 @@ class SimCluster { /// references to G4 and reco::GenParticle tracks std::vector g4Tracks_; reco::GenParticleRefVector genParticles_; - }; #endif // SimDataFormats_SimCluster_H From 6ab4a0c7d2340a1c944cac5ef4ed8a8c3936f17a Mon Sep 17 00:00:00 2001 From: brusale Date: Tue, 2 Apr 2024 09:47:32 +0200 Subject: [PATCH 017/301] use new hitmap --- .../EgammaTools/interface/EgammaPCAHelper.h | 14 ++++- .../interface/HGCalEgammaIDHelper.h | 3 +- .../HGCalElectronIDValueMapProducer.cc | 2 +- .../plugins/HGCalPhotonIDValueMapProducer.cc | 2 +- .../python/slimmedEgammaHGC_cff.py | 4 +- RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc | 27 +++++++-- .../EgammaTools/src/HGCalEgammaIDHelper.cc | 4 +- .../TICL/python/customiseTICLFromReco.py | 4 +- .../LCToCPAssociatorByEnergyScoreImpl.cc | 5 +- ...MultiClusterAssociatorByEnergyScoreImpl.cc | 29 ++++++---- .../MultiClusterAssociatorByEnergyScoreImpl.h | 6 +- ...iClusterAssociatorByEnergyScoreProducer.cc | 31 ++++++++-- .../TSToSCAssociatorByEnergyScoreImpl.cc | 49 +++++++++------- .../TSToSCAssociatorByEnergyScoreImpl.h | 6 +- .../TSToSCAssociatorByEnergyScoreProducer.cc | 31 ++++++++-- .../TSToSimTSAssociatorByEnergyScoreImpl.cc | 12 +++- .../TSToSimTSAssociatorByEnergyScoreImpl.h | 6 +- ...SToSimTSAssociatorByEnergyScoreProducer.cc | 30 ++++++++-- ...ToSimTSHitLCAssociatorByEnergyScoreImpl.cc | 15 +++-- ...SToSimTSHitLCAssociatorByEnergyScoreImpl.h | 6 +- ...mTSHitLCAssociatorByEnergyScoreProducer.cc | 30 ++++++++-- .../plugins/HGCalShowerSeparation.cc | 58 ++++++++++++------- .../python/standalone_onlyTICL_fromRECO.py | 2 +- 23 files changed, 267 insertions(+), 109 deletions(-) diff --git a/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h b/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h index a2165a4078635..19abef0ce30f2 100644 --- a/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h +++ b/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h @@ -43,10 +43,15 @@ namespace hgcal { const TPrincipal &pcaResult(); /// to set once per event - void setHitMap(const std::unordered_map *hitMap); - const std::unordered_map *getHitMap() { return hitMap_; } + //void setHitMap(const std::unordered_map *hitMap); + //const std::unordered_map *getHitMap() { return hitMap_; } + void setHitMap(const std::unordered_map *hitMap); + const std::unordered_map *getHitMap() { return hitMap_; } void setRecHitTools(const hgcal::RecHitTools *recHitTools); + void setRecHits(edm::Handle recHitHandleEE, + edm::Handle recHitHandleFH, + edm::Handle recHitHandleBH); inline void setdEdXWeights(const std::vector &dEdX) { dEdXWeights_ = dEdX; } @@ -85,7 +90,8 @@ namespace hgcal { std::vector invThicknessCorrection_; const reco::CaloCluster *theCluster_; - const std::unordered_map *hitMap_; + // const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; std::vector theSpots_; int pcaIteration_; unsigned int maxlayer_; @@ -101,6 +107,8 @@ namespace hgcal { std::unique_ptr pca_; const hgcal::RecHitTools *recHitTools_; ShowerDepth showerDepth_; + + std::vector hits_; }; } // namespace hgcal diff --git a/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h b/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h index 0aa4f36c226bd..225c3a37e9600 100644 --- a/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h +++ b/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h @@ -80,7 +80,8 @@ class HGCalEgammaIDHelper { edm::EDGetTokenT recHitsEE_; edm::EDGetTokenT recHitsFH_; edm::EDGetTokenT recHitsBH_; - edm::EDGetTokenT> hitMap_; + //edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::ESGetToken caloGeometry_; hgcal::RecHitTools recHitTools_; bool debug_; diff --git a/RecoEgamma/EgammaTools/plugins/HGCalElectronIDValueMapProducer.cc b/RecoEgamma/EgammaTools/plugins/HGCalElectronIDValueMapProducer.cc index fa27b01ef9de6..5a09cf8f82097 100644 --- a/RecoEgamma/EgammaTools/plugins/HGCalElectronIDValueMapProducer.cc +++ b/RecoEgamma/EgammaTools/plugins/HGCalElectronIDValueMapProducer.cc @@ -231,7 +231,7 @@ void HGCalElectronIDValueMapProducer::fillDescriptions(edm::ConfigurationDescrip desc.add("EERecHits", edm::InputTag("HGCalRecHit", "HGCEERecHits")); desc.add("FHRecHits", edm::InputTag("HGCalRecHit", "HGCHEFRecHits")); desc.add("BHRecHits", edm::InputTag("HGCalRecHit", "HGCHEBRecHits")); - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); descriptions.add("hgcalElectronIDValueMap", desc); } diff --git a/RecoEgamma/EgammaTools/plugins/HGCalPhotonIDValueMapProducer.cc b/RecoEgamma/EgammaTools/plugins/HGCalPhotonIDValueMapProducer.cc index 5f1f05c527475..e1b2d20f86c6c 100644 --- a/RecoEgamma/EgammaTools/plugins/HGCalPhotonIDValueMapProducer.cc +++ b/RecoEgamma/EgammaTools/plugins/HGCalPhotonIDValueMapProducer.cc @@ -215,7 +215,7 @@ void HGCalPhotonIDValueMapProducer::fillDescriptions(edm::ConfigurationDescripti desc.add("EERecHits", edm::InputTag("HGCalRecHit", "HGCEERecHits")); desc.add("FHRecHits", edm::InputTag("HGCalRecHit", "HGCHEFRecHits")); desc.add("BHRecHits", edm::InputTag("HGCalRecHit", "HGCHEBRecHits")); - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); descriptions.add("hgcalPhotonIDValueMap", desc); } diff --git a/RecoEgamma/EgammaTools/python/slimmedEgammaHGC_cff.py b/RecoEgamma/EgammaTools/python/slimmedEgammaHGC_cff.py index 22cb1c51deea2..bedd135263d5c 100644 --- a/RecoEgamma/EgammaTools/python/slimmedEgammaHGC_cff.py +++ b/RecoEgamma/EgammaTools/python/slimmedEgammaHGC_cff.py @@ -4,7 +4,7 @@ from RecoEgamma.EgammaTools.hgcalElectronIDValueMap_cff import hgcalElectronIDValueMap from PhysicsTools.PatAlgos.PATElectronProducer_cfi import PATElectronProducer from PhysicsTools.PatAlgos.slimming.slimmedElectrons_cfi import slimmedElectrons -from RecoLocalCalo.HGCalRecProducers.hgcalRecHitMapProducer_cfi import hgcalRecHitMapProducer +from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer hgcElectronID = hgcalElectronIDValueMap.clone( electrons = "cleanedEcalDrivenGsfElectronsHGC", @@ -111,7 +111,7 @@ ) slimmedEgammaHGCTask = cms.Task( - hgcalRecHitMapProducer, + recHitMapProducer, slimmedElectronsHGCTask, slimmedPhotonsHGCTask ) diff --git a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc index 43fc19676ffcb..d4b205264cdfa 100644 --- a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc +++ b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc @@ -24,11 +24,25 @@ EGammaPCAHelper::EGammaPCAHelper() debug_ = false; } -void EGammaPCAHelper::setHitMap(const std::unordered_map* hitMap) { +//void EGammaPCAHelper::setHitMap(const std::unordered_map* hitMap) { +void EGammaPCAHelper::setHitMap(const std::unordered_map* hitMap) { hitMap_ = hitMap; pcaIteration_ = 0; } +void EGammaPCAHelper::setRecHits(edm::Handle recHitHandleEE, + edm::Handle recHitHandleFH, + edm::Handle recHitHandleBH) { + auto sizeEE = (*recHitHandleEE).size(); + auto sizeFH = (*recHitHandleFH).size(); + auto sizeBH = (*recHitHandleBH).size(); + hits_.reserve(sizeEE + sizeFH + sizeBH); + + hits_.insert(hits_.end(), (*recHitHandleEE).begin(), (*recHitHandleEE).end()); + hits_.insert(hits_.end(), (*recHitHandleFH).begin(), (*recHitHandleFH).end()); + hits_.insert(hits_.end(), (*recHitHandleBH).begin(), (*recHitHandleBH).end()); +} + void EGammaPCAHelper::setRecHitTools(const hgcal::RecHitTools* recHitTools) { recHitTools_ = recHitTools; maxlayer_ = recHitTools_->lastLayerBH(); @@ -71,15 +85,17 @@ void EGammaPCAHelper::storeRecHits(const std::vector>& h unsigned int layer = recHitTools_->getLayerWithOffset(hf[j].first); const DetId rh_detid = hf[j].first; - std::unordered_map::const_iterator itcheck = hitMap_->find(rh_detid); + //std::unordered_map::const_iterator itcheck = hitMap_->find(rh_detid); + std::unordered_map::const_iterator itcheck = hitMap_->find(rh_detid); if (itcheck == hitMap_->end()) { edm::LogWarning("EgammaPCAHelper") << " Big problem, unable to find a hit " << rh_detid.rawId() << " " << rh_detid.det() << " " << HGCalDetId(rh_detid) << std::endl; continue; } if (debug_) { - std::cout << "DetId " << rh_detid.rawId() << " " << layer << " " << itcheck->second->energy() << std::endl; - std::cout << " Hit " << itcheck->second << " " << itcheck->second->energy() << std::endl; + const HGCRecHit* hit = &(hits_[itcheck->second]); + std::cout << "DetId " << rh_detid.rawId() << " " << layer << " " << hit->energy() << std::endl; + std::cout << " Hit " << hit << " " << hit->energy() << std::endl; } float fraction = hf[j].second; @@ -94,7 +110,8 @@ void EGammaPCAHelper::storeRecHits(const std::vector>& h if (pcavars[2] == 0.) edm::LogWarning("EgammaPCAHelper") << " Problem, hit with z =0 "; else { - Spot mySpot(rh_detid, itcheck->second->energy(), pcavars, layer, fraction, mip); + const HGCRecHit* hit = &(hits_[itcheck->second]); + Spot mySpot(rh_detid, hit->energy(), pcavars, layer, fraction, mip); theSpots_.push_back(mySpot); } } diff --git a/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc b/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc index 30bd1f180048b..2f21b39cc7699 100644 --- a/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc +++ b/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc @@ -15,7 +15,8 @@ HGCalEgammaIDHelper::HGCalEgammaIDHelper(const edm::ParameterSet& iConfig, edm:: recHitsEE_ = iC.consumes(eeRecHitInputTag_); recHitsFH_ = iC.consumes(fhRecHitInputTag_); recHitsBH_ = iC.consumes(bhRecHitInputTag_); - hitMap_ = iC.consumes>(hitMapInputTag_); + //hitMap_ = iC.consumes>(hitMapInputTag_); + hitMap_ = iC.consumes>(hitMapInputTag_); caloGeometry_ = iC.esConsumes(); pcaHelper_.setdEdXWeights(dEdXWeights_); debug_ = iConfig.getUntrackedParameter("debug", false); @@ -30,6 +31,7 @@ void HGCalEgammaIDHelper::eventInit(const edm::Event& iEvent, const edm::EventSe pcaHelper_.setRecHitTools(&recHitTools_); isoHelper_.setRecHitTools(&recHitTools_); pcaHelper_.setHitMap(&iEvent.get(hitMap_)); + pcaHelper_.setRecHits(recHitHandleEE, recHitHandleFH, recHitHandleBH); isoHelper_.setRecHits(recHitHandleEE, recHitHandleFH, recHitHandleBH); } diff --git a/RecoHGCal/TICL/python/customiseTICLFromReco.py b/RecoHGCal/TICL/python/customiseTICLFromReco.py index 60f2fa260cf6e..0b447844c09ec 100644 --- a/RecoHGCal/TICL/python/customiseTICLFromReco.py +++ b/RecoHGCal/TICL/python/customiseTICLFromReco.py @@ -5,7 +5,7 @@ from RecoHGCal.TICL.ticlDumper_cfi import ticlDumper # Validation from Validation.HGCalValidation.HGCalValidator_cfi import * -from RecoLocalCalo.HGCalRecProducers.hgcalRecHitMapProducer_cfi import hgcalRecHitMapProducer +from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer # Load DNN ESSource from RecoTracker.IterativeTracking.iterativeTk_cff import trackdnn_source @@ -32,7 +32,7 @@ def customiseTICLFromReco(process): process.ticlIterationsTask, process.ticlTracksterMergeTask) # Validation - process.TICL_ValidationProducers = cms.Task(process.hgcalRecHitMapProducer, + process.TICL_ValidationProducers = cms.Task(process.recHitMapProducer, process.lcAssocByEnergyScoreProducer, process.layerClusterCaloParticleAssociationProducer, process.scAssocByEnergyScoreProducer, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index ec3cd224bf502..4d541cdb6f295 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -226,7 +226,6 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( std::unordered_map occurrencesCPinLC; unsigned int numberOfNoiseHitsInLC = 0; std::unordered_map CPEnergyInLC; - for (unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) { const auto rh_detid = hits_and_fractions[hitId].first; const auto rhFraction = hits_and_fractions[hitId].second; @@ -245,8 +244,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) { hitsToCaloParticleId[hitId] -= 1; } else { - const auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = &(hits_[itcheck->first]); + const HIT* hit = &(hits_[hitMap_->at(rh_detid)]); auto maxCPEnergyInLC = 0.f; auto maxCPId = -1; for (auto& h : hit_find_in_CP->second) { @@ -261,7 +259,6 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( hitsToCaloParticleId[hitId] = maxCPId; } } // End loop over hits on a LayerCluster - for (const auto& c : hitsToCaloParticleId) { if (c < 0) { numberOfNoiseHitsInLC++; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc index adf6371e9ea1a..27ff8092d50a8 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc @@ -14,8 +14,13 @@ MultiClusterAssociatorByEnergyScoreImpl::MultiClusterAssociatorByEnergyScoreImpl edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map*& hitMap) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter) { + const std::unordered_map*& hitMap, + std::vector& hits) + : hardScatterOnly_(hardScatterOnly), + recHitTools_(recHitTools), + hitMap_(hitMap), + hits_(hits), + productGetter_(&productGetter) { layers_ = recHitTools_->lastLayerBH(); } @@ -90,7 +95,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( detIdToCaloParticleId_Map[hitid].emplace_back(cpId, it_haf.second); } } - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); //Since the current hit from sim cluster has a reconstructed hit with the same detid, //fill the cPOnLayer[caloparticle][layer] object with energy (sum of all recHits energy times fraction //of the relevant simHit) and keep the hit (detid and fraction) that contributed. @@ -126,10 +131,11 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl; double tot_energy = 0.; for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) { + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << " Tot Sum haf: " << tot_energy << std::endl; for (auto const& mc : cPOnLayer[cp][cpp].multiClusterIdToEnergyAndScore) { @@ -141,13 +147,14 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << "detIdToCaloParticleId_Map INFO" << std::endl; for (auto const& cp : detIdToCaloParticleId_Map) { + const HGCRecHit* hit = &(hits_[hitMap_->at(cp.first)]); LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)cp.first << " we have found the following connections with CaloParticles:" << std::endl; for (auto const& cpp : cp.second) { LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << " CaloParticle Id: " << cpp.clusterId << " with fraction: " << cpp.fraction - << " and energy: " << cpp.fraction * hitMap_->at(cp.first)->energy() << std::endl; + << " and energy: " << cpp.fraction * hit->energy() << std::endl; } } #endif @@ -218,7 +225,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( //Since the hit is belonging to the layer cluster, it must also be in the recHits map. const auto itcheck = hitMap_->find(rh_detid); - const auto hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); //Make a map that will connect a detid (that belongs to a recHit of the layer cluster under study, //no need to save others) with: @@ -365,8 +372,8 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( // Compute the correct normalization float invMultiClusterEnergyWeight = 0.f; for (auto const& haf : mClusters[mcId].hitsAndFractions()) { - invMultiClusterEnergyWeight += - (haf.second * hitMap_->at(haf.first)->energy()) * (haf.second * hitMap_->at(haf.first)->energy()); + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + invMultiClusterEnergyWeight += (haf.second * hit->energy()) * (haf.second * hit->energy()); } invMultiClusterEnergyWeight = 1.f / invMultiClusterEnergyWeight; @@ -377,7 +384,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( bool hitWithNoCP = (detIdToCaloParticleId_Map.find(rh_detid) == detIdToCaloParticleId_Map.end()); auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& cpPair : cpsInMultiCluster[mcId]) { @@ -451,7 +458,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_MCL == detIdToMultiClusterId_Map.end()) hitWithNoMCL = true; auto itcheck = hitMap_->find(cp_hitDetId); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& mcPair : cPOnLayer[cpId][layerId].multiClusterIdToEnergyAndScore) { unsigned int multiClusterId = mcPair.first; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h index c49bf4c48c641..3e3db77cbe462 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h @@ -49,7 +49,8 @@ class MultiClusterAssociatorByEnergyScoreImpl : public hgcal::MultiClusterToCalo explicit MultiClusterAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *&); + const std::unordered_map *&, + std::vector &hits); hgcal::RecoToSimCollectionWithMultiClusters associateRecoToSim( const edm::Handle &mCCH, @@ -62,7 +63,8 @@ class MultiClusterAssociatorByEnergyScoreImpl : public hgcal::MultiClusterToCalo private: const bool hardScatterOnly_; std::shared_ptr recHitTools_; - const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; hgcal::association makeConnections(const edm::Handle &mCCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc index b0ffb0ce9f8b6..866efe832bd35 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc @@ -14,6 +14,8 @@ #include "SimDataFormats/Associations/interface/MultiClusterToCaloParticleAssociator.h" #include "MultiClusterAssociatorByEnergyScoreImpl.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" + class MultiClusterAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { public: explicit MultiClusterAssociatorByEnergyScoreProducer(const edm::ParameterSet &); @@ -23,16 +25,22 @@ class MultiClusterAssociatorByEnergyScoreProducer : public edm::global::EDProduc private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; - edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::ESGetToken caloGeometry_; const bool hardScatterOnly_; std::shared_ptr rhtools_; + std::vector hits_label_; + std::vector> hits_token_; }; MultiClusterAssociatorByEnergyScoreProducer::MultiClusterAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) - : hitMap_(consumes>(ps.getParameter("hitMapTag"))), + : hitMap_(consumes>(ps.getParameter("hitMapTag"))), caloGeometry_(esConsumes()), - hardScatterOnly_(ps.getParameter("hardScatterOnly")) { + hardScatterOnly_(ps.getParameter("hardScatterOnly")), + hits_label_(ps.getParameter>("hits")) { + for (auto &label : hits_label_) { + hits_token_.push_back(consumes(label)); + } rhtools_.reset(new hgcal::RecHitTools()); // Register the product @@ -47,17 +55,28 @@ void MultiClusterAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - const std::unordered_map *hitMap = &iEvent.get(hitMap_); + std::vector hits; + for (auto &token : hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + + const std::unordered_map *hitMap = &iEvent.get(hitMap_); auto impl = std::make_unique( - iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap, hits); auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } void MultiClusterAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { edm::ParameterSetDescription desc; - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); desc.add("hardScatterOnly", true); cfg.add("multiClusterAssociatorByEnergyScore", desc); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc index 395e6bcb0851f..942aa6880ec52 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc @@ -7,8 +7,13 @@ TSToSCAssociatorByEnergyScoreImpl::TSToSCAssociatorByEnergyScoreImpl( edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map* hitMap) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter) { + const std::unordered_map* hitMap, + std::vector& hits) + : hardScatterOnly_(hardScatterOnly), + recHitTools_(recHitTools), + hitMap_(hitMap), + hits_(hits), + productGetter_(&productGetter) { layers_ = recHitTools_->lastLayerBH(); } @@ -63,7 +68,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( } detIdToSimClusterId_Map[hitid].emplace_back(scId, it_haf.second); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); tssInSimCluster[scId].energy += it_haf.second * hit->energy(); tssInSimCluster[scId].hits_and_fractions.emplace_back(hitid, it_haf.second); } @@ -81,10 +86,10 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\t# of clusters:\t" << layerClusters.size() << std::endl; double tot_energy = 0.; for (auto const& haf : tssInSimCluster[sc].hits_and_fractions) { - LogDebug("TSToSCAssociatorByEnergyScoreImpl") - << "\tHits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tHits/fraction/energy: " << (uint32_t)haf.first << "/" + << haf.second << "/" << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tTot Sum haf: " << tot_energy << std::endl; for (auto const& ts : tssInSimCluster[sc].tracksterIdToEnergyAndScore) { @@ -95,13 +100,14 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "detIdToSimClusterId_Map INFO" << std::endl; for (auto const& detId : detIdToSimClusterId_Map) { + const HGCRecHit* hit = &(hits_[hitMap_->at(detId.first)]); LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)detId.first << " we have found the following connections with SimClusters:" << std::endl; for (auto const& sc : detId.second) { LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tSimCluster Id: " << sc.clusterId << " with fraction: " << sc.fraction - << " and energy: " << sc.fraction * hitMap_->at(detId.first)->energy() << std::endl; + << " and energy: " << sc.fraction * hit->energy() << std::endl; } } #endif @@ -136,7 +142,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_SC != detIdToSimClusterId_Map.end()) { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); //Loops through all the simclusters that have the layer cluster rechit under study //Here is time to update the tssInSimCluster and connect the SimCluster with all //the Tracksters that have the current rechit detid matched. @@ -204,7 +210,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( hitsToSimClusterId[hitId] -= 1; } else { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); auto maxSCEnergyInLC = 0.f; auto maxSCId = -1; //Loop through all the linked SimClusters @@ -279,10 +285,10 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tEnergy:\t" << tssInSimCluster[sc].energy << std::endl; double tot_energy = 0.; for (auto const& haf : tssInSimCluster[sc].hits_and_fractions) { - LogDebug("TSToSCAssociatorByEnergyScoreImpl") - << "\tHits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" - << haf.second * hitMap_->at(haf.first)->energy() << std::endl; - tot_energy += haf.second * hitMap_->at(haf.first)->energy(); + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tHits/fraction/energy: " << (uint32_t)haf.first << "/" + << haf.second << "/" << haf.second * hit->energy() << std::endl; + tot_energy += haf.second * hit->energy(); } LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tTot Sum haf: " << tot_energy << std::endl; for (auto const& ts : tssInSimCluster[sc].tracksterIdToEnergyAndScore) { @@ -293,13 +299,14 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "Improved detIdToSimClusterId_Map INFO" << std::endl; for (auto const& sc : detIdToSimClusterId_Map) { + const HGCRecHit* hit = &(hits_[hitMap_->at(sc.first)]); LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)sc.first << " we have found the following connections with SimClusters:" << std::endl; for (auto const& sclu : sc.second) { LogDebug("TSToSCAssociatorByEnergyScoreImpl") << " SimCluster Id: " << sclu.clusterId << " with fraction: " << sclu.fraction - << " and energy: " << sclu.fraction * hitMap_->at(sc.first)->energy() << std::endl; + << " and energy: " << sclu.fraction * hit->energy() << std::endl; } } #endif @@ -332,8 +339,9 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( const auto& hits_and_fractions = layerClusters[lcId].hitsAndFractions(); // Compute the correct normalization for (auto const& haf : hits_and_fractions) { - invTracksterEnergyWeight += (lcFractionInTs * haf.second * hitMap_->at(haf.first)->energy()) * - (lcFractionInTs * haf.second * hitMap_->at(haf.first)->energy()); + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + invTracksterEnergyWeight += + (lcFractionInTs * haf.second * hit->energy()) * (lcFractionInTs * haf.second * hit->energy()); } } invTracksterEnergyWeight = 1.f / invTracksterEnergyWeight; @@ -351,7 +359,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( const bool hitWithSC = (detIdToSimClusterId_Map.find(rh_detid) != detIdToSimClusterId_Map.end()); const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& scPair : scsInTrackster[tsId]) { @@ -419,7 +427,8 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( #endif // Compute the correct normalization for (auto const& haf : tssInSimCluster[scId].hits_and_fractions) { - invSCEnergyWeight += std::pow(haf.second * hitMap_->at(haf.first)->energy(), 2); + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + invSCEnergyWeight += std::pow(haf.second * hit->energy(), 2); } invSCEnergyWeight = 1.f / invSCEnergyWeight; @@ -434,7 +443,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_LC != detIdToLayerClusterId_Map.end()) hitWithLC = true; const auto itcheck = hitMap_->find(sc_hitDetId); - const HGCRecHit* hit = itcheck->second; + const HGCRecHit* hit = &(hits_[itcheck->second]); float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& tsPair : tssInSimCluster[scId].tracksterIdToEnergyAndScore) { unsigned int tsId = tsPair.first; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h index 470a68496fb96..c1b324a7c0cdb 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h @@ -42,7 +42,8 @@ class TSToSCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimClusterAsso explicit TSToSCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *); + const std::unordered_map *, + std::vector &hits); ticl::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, const edm::Handle &lCCH, @@ -55,7 +56,8 @@ class TSToSCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimClusterAsso private: const bool hardScatterOnly_; std::shared_ptr recHitTools_; - const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &tCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc index e97af3baa97ef..026edc2bcaa0a 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc @@ -14,6 +14,8 @@ #include "SimDataFormats/Associations/interface/TracksterToSimClusterAssociator.h" #include "TSToSCAssociatorByEnergyScoreImpl.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" + class TSToSCAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { public: explicit TSToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &); @@ -23,18 +25,24 @@ class TSToSCAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; - edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::ESGetToken caloGeometry_; const bool hardScatterOnly_; std::shared_ptr rhtools_; + std::vector hits_label_; + std::vector> hits_token_; }; TSToSCAssociatorByEnergyScoreProducer::TSToSCAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) - : hitMap_(consumes>(ps.getParameter("hitMapTag"))), + : hitMap_(consumes>(ps.getParameter("hitMapTag"))), caloGeometry_(esConsumes()), - hardScatterOnly_(ps.getParameter("hardScatterOnly")) { + hardScatterOnly_(ps.getParameter("hardScatterOnly")), + hits_label_(ps.getParameter>("hits")) { rhtools_.reset(new hgcal::RecHitTools()); + for (auto &label : hits_label_) { + hits_token_.push_back(consumes(label)); + } // Register the product produces(); } @@ -47,17 +55,28 @@ void TSToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); + std::vector hits; + for (auto &token : hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + const auto hitMap = &iEvent.get(hitMap_); - auto impl = - std::make_unique(iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); + auto impl = std::make_unique( + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap, hits); auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } void TSToSCAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { edm::ParameterSetDescription desc; - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); desc.add("hardScatterOnly", true); cfg.add("tracksterAssociatorByEnergyScore", desc); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc index d7e57d37af419..c32142a99e694 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc @@ -6,8 +6,13 @@ TSToSimTSAssociatorByEnergyScoreImpl::TSToSimTSAssociatorByEnergyScoreImpl( edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map* hitMap) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter) { + const std::unordered_map* hitMap, + std::vector& hits) + : hardScatterOnly_(hardScatterOnly), + recHitTools_(recHitTools), + hitMap_(hitMap), + hits_(hits), + productGetter_(&productGetter) { layers_ = recHitTools_->lastLayerBH(); } @@ -310,7 +315,8 @@ ticl::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( const auto& hits_and_fractions = layerClusters[lcId].hitsAndFractions(); // Compute the correct normalization for (auto const& haf : hits_and_fractions) { - invTracksterEnergyWeight += std::pow(lcFractionInTs * haf.second * hitMap_->at(haf.first)->energy(), 2); + const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + invTracksterEnergyWeight += std::pow(lcFractionInTs * haf.second * hit->energy(), 2); } } invTracksterEnergyWeight = 1.f / invTracksterEnergyWeight; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h index 31d87944dd5c8..e473b0460ddef 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h @@ -68,7 +68,8 @@ class TSToSimTSAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTrackste explicit TSToSimTSAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *); + const std::unordered_map *, + std::vector &hits); ticl::RecoToSimCollectionSimTracksters associateRecoToSim( const edm::Handle &tCH, @@ -83,7 +84,8 @@ class TSToSimTSAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTrackste private: const bool hardScatterOnly_; std::shared_ptr recHitTools_; - const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &tCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc index 4e45ea6cab404..9f9359104520e 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc @@ -14,6 +14,8 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterAssociator.h" #include "TSToSimTSAssociatorByEnergyScoreImpl.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" + class TSToSimTSAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { public: explicit TSToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &); @@ -23,18 +25,25 @@ class TSToSimTSAssociatorByEnergyScoreProducer : public edm::global::EDProducer< private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; - edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::ESGetToken caloGeometry_; const bool hardScatterOnly_; std::shared_ptr rhtools_; + std::vector hits_label_; + std::vector> hits_token_; }; TSToSimTSAssociatorByEnergyScoreProducer::TSToSimTSAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) - : hitMap_(consumes>(ps.getParameter("hitMapTag"))), + : hitMap_(consumes>(ps.getParameter("hitMapTag"))), caloGeometry_(esConsumes()), - hardScatterOnly_(ps.getParameter("hardScatterOnly")) { + hardScatterOnly_(ps.getParameter("hardScatterOnly")), + hits_label_(ps.getParameter>("hits")) { rhtools_.reset(new hgcal::RecHitTools()); + for (auto &label : hits_label_) { + hits_token_.push_back(consumes(label)); + } + // Register the product produces(); } @@ -47,17 +56,28 @@ void TSToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); + std::vector hits; + for (auto &token : hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + const auto hitMap = &iEvent.get(hitMap_); auto impl = std::make_unique( - iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap, hits); auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } void TSToSimTSAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { edm::ParameterSetDescription desc; - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); desc.add("hardScatterOnly", true); cfg.add("simTracksterAssociatorByEnergyScore", desc); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc index ad01e43799c11..5ab1bfea56eba 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc @@ -8,8 +8,13 @@ TSToSimTSHitLCAssociatorByEnergyScoreImpl::TSToSimTSHitLCAssociatorByEnergyScore edm::EDProductGetter const& productGetter, bool hardScatterOnly, std::shared_ptr recHitTools, - const std::unordered_map* hitMap) - : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), productGetter_(&productGetter) { + const std::unordered_map* hitMap, + std::vector& hits) + : hardScatterOnly_(hardScatterOnly), + recHitTools_(recHitTools), + hitMap_(hitMap), + hits_(hits), + productGetter_(&productGetter) { layers_ = recHitTools_->lastLayerBH(); } @@ -132,7 +137,8 @@ ticl::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( } } - float hitEnergy = hitMap_->find(hitId)->second->energy(); + const HGCRecHit* hit = &(hits_[hitMap_->find(hitId)->second]); + float hitEnergy = hit->energy(); float hitEnergySquared = hitEnergy * hitEnergy; float simFractionSquared = simFraction * simFraction; denominator_simToReco[i] += simFractionSquared * hitEnergySquared; @@ -171,7 +177,8 @@ ticl::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( if (found != detIdToRecoTSId_Map[hitId].end()) recoFraction = found->second; - float hitEnergy = hitMap_->find(hitId)->second->energy(); + const HGCRecHit* hit = &(hits_[hitMap_->find(hitId)->second]); + float hitEnergy = hit->energy(); float hitEnergySquared = hitEnergy * hitEnergy; float recoFractionSquared = recoFraction * recoFraction; denominator_recoToSim[i] += recoFractionSquared * hitEnergySquared; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h index 1cefea40c7b65..81fecf9b9a5f1 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h @@ -47,7 +47,8 @@ class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTra explicit TSToSimTSHitLCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &, bool, std::shared_ptr, - const std::unordered_map *); + const std::unordered_map *, + std::vector &hits); ticl::association_t makeConnections(const edm::Handle &tCH, const edm::Handle &lCCH, @@ -72,7 +73,8 @@ class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTra private: const bool hardScatterOnly_; std::shared_ptr recHitTools_; - const std::unordered_map *hitMap_; + const std::unordered_map *hitMap_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc index 28d105ede79d3..490aea19d2502 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc @@ -14,6 +14,8 @@ #include "SimDataFormats/Associations/interface/TracksterToSimTracksterHitLCAssociator.h" #include "TSToSimTSHitLCAssociatorByEnergyScoreImpl.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" + class TSToSimTSHitLCAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> { public: explicit TSToSimTSHitLCAssociatorByEnergyScoreProducer(const edm::ParameterSet &); @@ -23,18 +25,25 @@ class TSToSimTSHitLCAssociatorByEnergyScoreProducer : public edm::global::EDProd private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; - edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::ESGetToken caloGeometry_; const bool hardScatterOnly_; std::shared_ptr rhtools_; + std::vector hits_label_; + std::vector> hits_token_; }; TSToSimTSHitLCAssociatorByEnergyScoreProducer::TSToSimTSHitLCAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps) - : hitMap_(consumes>(ps.getParameter("hitMapTag"))), + : hitMap_(consumes>(ps.getParameter("hitMapTag"))), caloGeometry_(esConsumes()), - hardScatterOnly_(ps.getParameter("hardScatterOnly")) { + hardScatterOnly_(ps.getParameter("hardScatterOnly")), + hits_label_(ps.getParameter>("hits")) { rhtools_.reset(new hgcal::RecHitTools()); + for (auto &label : hits_label_) { + hits_token_.push_back(consumes(label)); + } + // Register the product produces(); } @@ -47,17 +56,28 @@ void TSToSimTSHitLCAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); + std::vector hits; + for (auto &token : hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + const auto hitMap = &iEvent.get(hitMap_); auto impl = std::make_unique( - iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap); + iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap, hits); auto toPut = std::make_unique(std::move(impl)); iEvent.put(std::move(toPut)); } void TSToSimTSHitLCAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) { edm::ParameterSetDescription desc; - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); desc.add("hardScatterOnly", true); cfg.add("simTracksterHitLCAssociatorByEnergyScore", desc); diff --git a/Validation/HGCalValidation/plugins/HGCalShowerSeparation.cc b/Validation/HGCalValidation/plugins/HGCalShowerSeparation.cc index 6c81a1886c9e0..2c9704a5541df 100644 --- a/Validation/HGCalValidation/plugins/HGCalShowerSeparation.cc +++ b/Validation/HGCalValidation/plugins/HGCalShowerSeparation.cc @@ -44,15 +44,18 @@ class HGCalShowerSeparation : public DQMEDAnalyzer { void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; void analyze(const edm::Event&, const edm::EventSetup&) override; - void fillWithRecHits(std::unordered_map&, DetId, unsigned int, float, int&, float&); + void fillWithRecHits(std::unordered_map&, DetId, unsigned int, float, int&, float&); - edm::EDGetTokenT> hitMap_; + edm::EDGetTokenT> hitMap_; edm::EDGetTokenT> caloParticles_; const edm::ESGetToken tok_geom_; + std::vector hits_label; + std::vector> hits_token_; int debug_; bool filterOnEnergyAndCaloP_; hgcal::RecHitTools recHitTools_; + std::vector hits_; MonitorElement* eta1_; MonitorElement* eta2_; @@ -81,8 +84,13 @@ HGCalShowerSeparation::HGCalShowerSeparation(const edm::ParameterSet& iConfig) filterOnEnergyAndCaloP_(iConfig.getParameter("filterOnEnergyAndCaloP")) { auto hitMapInputTag = iConfig.getParameter("hitMapTag"); auto caloParticles = iConfig.getParameter("caloParticles"); - hitMap_ = consumes>(hitMapInputTag); + hitMap_ = consumes>(hitMapInputTag); caloParticles_ = consumes>(caloParticles); + auto hits_label_ = iConfig.getParameter>("hits"); + + for (auto& label : hits_label_) { + hits_token_.push_back(consumes(label)); + } } void HGCalShowerSeparation::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const&) { @@ -148,10 +156,16 @@ void HGCalShowerSeparation::bookHistograms(DQMStore::IBooker& ibooker, edm::Run void HGCalShowerSeparation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { recHitTools_.setGeometry(iSetup.getData(tok_geom_)); + for (auto& token : hits_token_) { + edm::Handle hits_handle; + iEvent.getByToken(token, hits_handle); + hits_.insert(hits_.end(), (*hits_handle).begin(), (*hits_handle).end()); + } + const edm::Handle>& caloParticleHandle = iEvent.getHandle(caloParticles_); const std::vector& caloParticles = *(caloParticleHandle.product()); - edm::Handle> hitMapHandle; + edm::Handle> hitMapHandle; iEvent.getByToken(hitMap_, hitMapHandle); const auto hitmap = *hitMapHandle; @@ -181,8 +195,10 @@ void HGCalShowerSeparation::analyze(const edm::Event& iEvent, const edm::EventSe const SimCluster& simCluster = (*(it_sc)); const std::vector>& hits_and_fractions = simCluster.hits_and_fractions(); for (const auto& it_haf : hits_and_fractions) { - if (hitmap.count(it_haf.first)) - energy += hitmap.at(it_haf.first)->energy() * it_haf.second; + if (hitmap.count(it_haf.first)) { + const HGCRecHit* hit = &(hits_[hitmap.at(it_haf.first)]); + energy += hit->energy() * it_haf.second; + } } //hits and fractions } // simcluster if (count == 1) { @@ -236,25 +252,23 @@ void HGCalShowerSeparation::analyze(const edm::Event& iEvent, const edm::EventSe distance -= half_point; auto idealDistance = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (hitmap.count(it_haf.first)) { - profileOnLayer_[hitlayer]->Fill(10. * (globalx - half_point_x), - 10. * (globaly - half_point_y), - hitmap.at(it_haf.first)->energy() * it_haf.second); - profileOnLayer_[55]->Fill(10. * (globalx - half_point_x), - 10. * (globaly - half_point_y), - hitmap.at(it_haf.first)->energy() * it_haf.second); - globalProfileOnLayer_[hitlayer]->Fill(globalx, globaly, hitmap.at(it_haf.first)->energy() * it_haf.second); - globalProfileOnLayer_[55]->Fill(globalx, globaly, hitmap.at(it_haf.first)->energy() * it_haf.second); - layerEnergy_->Fill(hitlayer, hitmap.at(it_haf.first)->energy()); - layerDistance_->Fill(hitlayer, std::abs(10. * distance), hitmap.at(it_haf.first)->energy() * it_haf.second); + const HGCRecHit* hit = &(hits_[hitmap.at(it_haf.first)]); + profileOnLayer_[hitlayer]->Fill( + 10. * (globalx - half_point_x), 10. * (globaly - half_point_y), hit->energy() * it_haf.second); + profileOnLayer_[55]->Fill( + 10. * (globalx - half_point_x), 10. * (globaly - half_point_y), hit->energy() * it_haf.second); + globalProfileOnLayer_[hitlayer]->Fill(globalx, globaly, hit->energy() * it_haf.second); + globalProfileOnLayer_[55]->Fill(globalx, globaly, hit->energy() * it_haf.second); + layerEnergy_->Fill(hitlayer, hit->energy()); + layerDistance_->Fill(hitlayer, std::abs(10. * distance), hit->energy() * it_haf.second); etaPhi_->Fill(global.eta(), global.phi()); distanceOnLayer_[hitlayer]->Fill(10. * distance); //, idealDistanceOnLayer_[hitlayer]->Fill(10. * idealDistance); //, idealDeltaXY_[hitlayer]->Fill(10. * (x1 - x2), 10. * (y1 - y2)); //, centers_[hitlayer]->Fill(10. * half_point_x, 10. * half_point_y); //, IfLogTrace(debug_ > 0, "HGCalShowerSeparation") - << ">>> " << distance << " " << hitlayer << " " << hitmap.at(it_haf.first)->energy() * it_haf.second - << std::endl; - showerProfile_->Fill(10. * distance, hitlayer, hitmap.at(it_haf.first)->energy() * it_haf.second); + << ">>> " << distance << " " << hitlayer << " " << hit->energy() * it_haf.second << std::endl; + showerProfile_->Fill(10. * distance, hitlayer, hit->energy() * it_haf.second); } } // end simHit } // end simCluster @@ -269,7 +283,11 @@ void HGCalShowerSeparation::fillDescriptions(edm::ConfigurationDescriptions& des desc.add("debug", 1); desc.add("filterOnEnergyAndCaloP", false); desc.add("caloParticles", edm::InputTag("mix", "MergedCaloTruth")); - desc.add("hitMapTag", edm::InputTag("hgcalRecHitMapProducer")); + desc.add("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); + desc.add>("hits", + {edm::InputTag("HGCalRecHit", "HGCEERecHits"), + edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), + edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); descriptions.add("hgcalShowerSeparationDefault", desc); } diff --git a/Validation/HGCalValidation/test/python/standalone_onlyTICL_fromRECO.py b/Validation/HGCalValidation/test/python/standalone_onlyTICL_fromRECO.py index 3331db3a598de..c60496c1b3530 100644 --- a/Validation/HGCalValidation/test/python/standalone_onlyTICL_fromRECO.py +++ b/Validation/HGCalValidation/test/python/standalone_onlyTICL_fromRECO.py @@ -126,7 +126,7 @@ process.ticl_step = cms.Path(process.ticl_seq) process.ticl_prevalidation_step = cms.Path(process.globalPrevalidationHGCal) -process.ticl_validation = cms.Sequence(process.hgcalLayerClusters+process.hgcalRecHitMapProducer+process.hgcalValidatorSequence) +process.ticl_validation = cms.Sequence(process.hgcalLayerClusters+process.recHitMapProducer+process.hgcalValidatorSequence) process.ticl_validation_step = cms.EndPath(process.ticl_validation) process.ticl_FEVToutput_step = cms.EndPath(process.ticl_FEVToutput) process.DQMoutput_step = cms.EndPath(process.DQMoutput) From 651f6003e75b2e7a65d4221ce92f12badc0a1fad Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Thu, 11 Apr 2024 14:54:19 -0500 Subject: [PATCH 018/301] Revert "Workaround to produce exactly same data products in Serial and CUDA backends in Alpaka modules possibly used at HLT" --- .../plugins/alpaka/EcalRawToDigiPortable.cc | 8 -------- .../AlpakaCore/interface/alpaka/ProducerBase.h | 6 ------ .../plugins/alpaka/EcalUncalibRecHitProducerPortable.cc | 8 -------- .../plugins/alpaka/SiPixelRawToCluster.cc | 7 ------- .../SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc | 9 +-------- .../plugins/alpaka/PFClusterSoAProducer.cc | 8 +------- .../plugins/alpaka/CaloRecHitSoAProducer.cc | 7 +------ .../plugins/alpaka/PFRecHitSoAProducer.cc | 5 ----- RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc | 9 +-------- .../plugins/alpaka/PixelVertexProducerAlpaka.cc | 7 +------ .../plugins/alpaka/BeamSpotDeviceProducer.cc | 7 +------ 11 files changed, 6 insertions(+), 75 deletions(-) diff --git a/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc b/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc index 2722942f25b97..7739cf15c0ab3 100644 --- a/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc +++ b/EventFilter/EcalRawToDigi/plugins/alpaka/EcalRawToDigiPortable.cc @@ -64,14 +64,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { fedsToUnpack_{ps.getParameter>("FEDs")} { config_.maxChannelsEB = ps.getParameter("maxChannelsEB"); config_.maxChannelsEE = ps.getParameter("maxChannelsEE"); - - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct", - ps.getParameter("digisLabelEB")); - producesTemporarily("edm::DeviceProduct", - ps.getParameter("digisLabelEE")); -#endif } void EcalRawToDigiPortable::produce(device::Event& event, device::EventSetup const& setup) { diff --git a/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h b/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h index b0f2d50011ef0..25088489ad89f 100644 --- a/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h +++ b/HeterogeneousCore/AlpakaCore/interface/alpaka/ProducerBase.h @@ -58,12 +58,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { return ProducerBaseAdaptor(*this, std::move(instanceName)); } - // For a workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed - void producesTemporarily(std::string const& iTypeName, std::string instanceName = std::string()) { - auto td = edm::TypeWithDict::byName(iTypeName); - Base::template produces(edm::TypeID(td.typeInfo()), std::move(instanceName)); - } - static void prevalidate(edm::ConfigurationDescriptions& descriptions) { Base::prevalidate(descriptions); cms::alpakatools::module_backend_config(descriptions); diff --git a/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc b/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc index be36fad7b190f..d0f06f3caf186 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/alpaka/EcalUncalibRecHitProducerPortable.cc @@ -87,14 +87,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { multifitParametersToken_{esConsumes()}, ebDigisSizeHostBuf_{cms::alpakatools::make_host_buffer()}, eeDigisSizeHostBuf_{cms::alpakatools::make_host_buffer()} { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct", - ps.getParameter("recHitsLabelEB")); - producesTemporarily("edm::DeviceProduct", - ps.getParameter("recHitsLabelEE")); -#endif - std::pair EBtimeFitLimits, EEtimeFitLimits; EBtimeFitLimits.first = ps.getParameter("EBtimeFitLimits_Lower"); EBtimeFitLimits.second = ps.getParameter("EBtimeFitLimits_Upper"); diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc index 8a74cc67767d3..8f14c50f09263 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/alpaka/SiPixelRawToCluster.cc @@ -94,13 +94,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { static_cast(iConfig.getParameter("VCaltoElectronGain_L1")), static_cast(iConfig.getParameter("VCaltoElectronOffset")), static_cast(iConfig.getParameter("VCaltoElectronOffset_L1"))} { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); - producesTemporarily("edm::DeviceProduct"); - producesTemporarily("edm::DeviceProduct"); -#endif - if (includeErrors_) { digiErrorPutToken_ = produces(); fmtErrorToken_ = produces(); diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc index ad23762f3bca2..46fd8a6b8c2ca 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/alpaka/SiPixelRecHitAlpaka.cc @@ -60,14 +60,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { tBeamSpot(consumes(iConfig.getParameter("beamSpot"))), tokenClusters_(consumes(iConfig.getParameter("src"))), tokenDigi_(consumes(iConfig.getParameter("src"))), - tokenHit_(produces()) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - if constexpr (std::is_same_v) { - producesTemporarily("edm::DeviceProduct"); - } -#endif - } + tokenHit_(produces()) {} template void SiPixelRecHitAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc index 6af4c9f17496d..6017f539364ec 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/alpaka/PFClusterSoAProducer.cc @@ -25,13 +25,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { outputPFClusterSoA_Token_{produces()}, outputPFRHFractionSoA_Token_{produces()}, synchronise_(config.getParameter("synchronise")), - pfRecHitFractionAllocation_(config.getParameter("pfRecHitFractionAllocation")) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); - producesTemporarily("edm::DeviceProduct"); -#endif - } + pfRecHitFractionAllocation_(config.getParameter("pfRecHitFractionAllocation")) {} void produce(device::Event& event, device::EventSetup const& setup) override { const reco::PFClusterParamsDeviceCollection& params = setup.getData(pfClusParamsToken); diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc index c9e7646f519b9..4b483b0c6a987 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc @@ -25,12 +25,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { CaloRecHitSoAProducer(edm::ParameterSet const& config) : recHitsToken_(consumes(config.getParameter("src"))), deviceToken_(produces()), - synchronise_(config.getUntrackedParameter("synchronise")) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); -#endif - } + synchronise_(config.getUntrackedParameter("synchronise")) {} void produce(edm::StreamID sid, device::Event& event, device::EventSetup const&) const override { const edm::SortedCollection& recHits = event.get(recHitsToken_); diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc index af3df8a442333..34cb54d550333 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitSoAProducer.cc @@ -22,11 +22,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { : topologyToken_(esConsumes(config.getParameter("topology"))), pfRecHitsToken_(produces()), synchronise_(config.getUntrackedParameter("synchronise")) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); -#endif - const std::vector producers = config.getParameter>("producers"); recHitsToken_.reserve(producers.size()); for (const edm::ParameterSet& producer : producers) { diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc index 6d402f29a24da..c16aed2e0b1e8 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtuplet.cc @@ -58,14 +58,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { cpeToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter("CPE")))), tokenHit_(consumes(iConfig.getParameter("pixelRecHitSrc"))), tokenTrack_(produces()), - deviceAlgo_(iConfig) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - if constexpr (std::is_same_v) { - producesTemporarily("edm::DeviceProduct"); - } -#endif - } + deviceAlgo_(iConfig) {} template void CAHitNtupletAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc b/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc index 0da09be7ca235..d572a181ccf85 100644 --- a/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc +++ b/RecoTracker/PixelVertexFinding/plugins/alpaka/PixelVertexProducerAlpaka.cc @@ -64,12 +64,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { ptMin_(conf.getParameter("PtMin")), // 0.5 GeV ptMax_(conf.getParameter("PtMax")), // 75. Onsumes tokenDeviceTrack_(consumes(conf.getParameter("pixelTrackSrc"))), - tokenDeviceVertex_(produces()) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); -#endif - } + tokenDeviceVertex_(produces()) {} template void PixelVertexProducerAlpaka::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc b/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc index 03c15013632d8..bd597164827fa 100644 --- a/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc +++ b/RecoVertex/BeamSpotProducer/plugins/alpaka/BeamSpotDeviceProducer.cc @@ -15,12 +15,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { class BeamSpotDeviceProducer : public global::EDProducer<> { public: BeamSpotDeviceProducer(edm::ParameterSet const& config) - : legacyToken_{consumes(config.getParameter("src"))}, deviceToken_{produces()} { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); -#endif - } + : legacyToken_{consumes(config.getParameter("src"))}, deviceToken_{produces()} {} void produce(edm::StreamID, device::Event& event, device::EventSetup const& setup) const override { reco::BeamSpot const& beamspot = event.get(legacyToken_); From 6ca6c2605f222246f45ae425622a24c221a8dedf Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Apr 2024 12:36:35 +0200 Subject: [PATCH 019/301] fix MC Kshort sequence --- .../python/TrackingDataMCValidation_Standalone_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py b/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py index 5dfdebb02870b..6c94d59f19fd7 100644 --- a/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py +++ b/DQM/TrackingMonitorSource/python/TrackingDataMCValidation_Standalone_cff.py @@ -178,7 +178,7 @@ * selectedPrimaryVertices * KShortEventSelector * KshortTracks - * standaloneTrackMonitorK0 + * standaloneTrackMonitorK0MC * KshortMonitor) standaloneValidationLambdas = cms.Sequence( From 5e9ff21cc6ab88c52ef3d37bd3f8cf95c65035c1 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Apr 2024 12:36:58 +0200 Subject: [PATCH 020/301] fix sign of cosPhi3D, make code more readable --- .../plugins/StandaloneTrackMonitor.cc | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc b/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc index e1dc903f3443a..0f7e80a9d568e 100644 --- a/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc +++ b/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc @@ -1836,17 +1836,18 @@ void StandaloneTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup c theMainVtx = *theClosestVertex; } if (theMainVtx.isValid()) { - const math::XYZPoint theMainVtxPos( - theMainVtx.position().x(), theMainVtx.position().y(), theMainVtx.position().z()); - const math::XYZPoint myVertex( - mumuTransientVtx.position().x(), mumuTransientVtx.position().y(), mumuTransientVtx.position().z()); - const math::XYZPoint deltaVtx( - theMainVtxPos.x() - myVertex.x(), theMainVtxPos.y() - myVertex.y(), theMainVtxPos.z() - myVertex.z()); - double cosphi3D = - (Zp.Px() * deltaVtx.x() + Zp.Py() * deltaVtx.y() + Zp.Pz() * deltaVtx.z()) / - (sqrt(Zp.Px() * Zp.Px() + Zp.Py() * Zp.Py() + Zp.Pz() * Zp.Pz()) * - sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z())); - cosPhi3DdileptonH_->Fill(cosphi3D, wfac); + const auto& mainVertexPos = theMainVtx.position(); + const auto& myVertexPos = mumuTransientVtx.position(); + + const double deltaX = myVertexPos.x() - mainVertexPos.x(); + const double deltaY = myVertexPos.y() - mainVertexPos.y(); + const double deltaZ = myVertexPos.z() - mainVertexPos.z(); + + const double deltaNorm = sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + const double zpNorm = sqrt(Zp.Px() * Zp.Px() + Zp.Py() * Zp.Py() + Zp.Pz() * Zp.Pz()); + + const double cosPhi3D = (Zp.Px() * deltaX + Zp.Py() * deltaY + Zp.Pz() * deltaZ) / (zpNorm * deltaNorm); + cosPhi3DdileptonH_->Fill(cosPhi3D, wfac); } } } From 918ef7c884c08f7e280dcbb135713c6314043780 Mon Sep 17 00:00:00 2001 From: brusale Date: Tue, 16 Apr 2024 11:29:34 +0200 Subject: [PATCH 021/301] avoid multiple copies of rechits --- .../EgammaTools/interface/EgammaPCAHelper.h | 5 +--- .../interface/HGCalEgammaIDHelper.h | 1 - RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc | 27 ++++++++++--------- .../EgammaTools/src/HGCalEgammaIDHelper.cc | 1 - .../LCToCPAssociatorByEnergyScoreImpl.cc | 25 ++++++++--------- .../LCToCPAssociatorByEnergyScoreImpl.h | 4 +-- .../LCToCPAssociatorByEnergyScoreProducer.cc | 11 +++++--- .../plugins/LCToCPAssociatorEDProducer.cc | 2 ++ .../LCToSCAssociatorByEnergyScoreImpl.cc | 24 ++++++++--------- .../LCToSCAssociatorByEnergyScoreImpl.h | 4 +-- .../LCToSCAssociatorByEnergyScoreProducer.cc | 10 ++++--- ...MultiClusterAssociatorByEnergyScoreImpl.cc | 16 +++++------ .../MultiClusterAssociatorByEnergyScoreImpl.h | 4 +-- ...iClusterAssociatorByEnergyScoreProducer.cc | 6 +++-- .../TSToSCAssociatorByEnergyScoreImpl.cc | 24 ++++++++--------- .../TSToSCAssociatorByEnergyScoreImpl.h | 4 +-- .../TSToSCAssociatorByEnergyScoreProducer.cc | 6 +++-- .../TSToSimTSAssociatorByEnergyScoreImpl.cc | 4 +-- .../TSToSimTSAssociatorByEnergyScoreImpl.h | 4 +-- ...SToSimTSAssociatorByEnergyScoreProducer.cc | 6 +++-- ...ToSimTSHitLCAssociatorByEnergyScoreImpl.cc | 6 ++--- ...SToSimTSHitLCAssociatorByEnergyScoreImpl.h | 4 +-- ...mTSHitLCAssociatorByEnergyScoreProducer.cc | 6 +++-- 23 files changed, 111 insertions(+), 93 deletions(-) diff --git a/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h b/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h index 19abef0ce30f2..a98dadd741423 100644 --- a/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h +++ b/RecoEgamma/EgammaTools/interface/EgammaPCAHelper.h @@ -43,8 +43,6 @@ namespace hgcal { const TPrincipal &pcaResult(); /// to set once per event - //void setHitMap(const std::unordered_map *hitMap); - //const std::unordered_map *getHitMap() { return hitMap_; } void setHitMap(const std::unordered_map *hitMap); const std::unordered_map *getHitMap() { return hitMap_; } @@ -90,7 +88,6 @@ namespace hgcal { std::vector invThicknessCorrection_; const reco::CaloCluster *theCluster_; - // const std::unordered_map *hitMap_; const std::unordered_map *hitMap_; std::vector theSpots_; int pcaIteration_; @@ -108,7 +105,7 @@ namespace hgcal { const hgcal::RecHitTools *recHitTools_; ShowerDepth showerDepth_; - std::vector hits_; + std::vector hits_; }; } // namespace hgcal diff --git a/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h b/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h index 225c3a37e9600..a13c092a08d4c 100644 --- a/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h +++ b/RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h @@ -80,7 +80,6 @@ class HGCalEgammaIDHelper { edm::EDGetTokenT recHitsEE_; edm::EDGetTokenT recHitsFH_; edm::EDGetTokenT recHitsBH_; - //edm::EDGetTokenT> hitMap_; edm::EDGetTokenT> hitMap_; edm::ESGetToken caloGeometry_; hgcal::RecHitTools recHitTools_; diff --git a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc index d4b205264cdfa..e20e9fe91ef38 100644 --- a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc +++ b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc @@ -24,7 +24,6 @@ EGammaPCAHelper::EGammaPCAHelper() debug_ = false; } -//void EGammaPCAHelper::setHitMap(const std::unordered_map* hitMap) { void EGammaPCAHelper::setHitMap(const std::unordered_map* hitMap) { hitMap_ = hitMap; pcaIteration_ = 0; @@ -33,14 +32,18 @@ void EGammaPCAHelper::setHitMap(const std::unordered_map recHitHandleEE, edm::Handle recHitHandleFH, edm::Handle recHitHandleBH) { - auto sizeEE = (*recHitHandleEE).size(); - auto sizeFH = (*recHitHandleFH).size(); - auto sizeBH = (*recHitHandleBH).size(); - hits_.reserve(sizeEE + sizeFH + sizeBH); - - hits_.insert(hits_.end(), (*recHitHandleEE).begin(), (*recHitHandleEE).end()); - hits_.insert(hits_.end(), (*recHitHandleFH).begin(), (*recHitHandleFH).end()); - hits_.insert(hits_.end(), (*recHitHandleBH).begin(), (*recHitHandleBH).end()); + + unsigned int total_size = recHitHandleEE->size() + recHitHandleFH->size() + recHitHandleBH->size(); + hits_.resize(total_size); + unsigned int firstIndex = 0; + + for (const auto& handle : {recHitHandleEE, recHitHandleFH, recHitHandleBH}) { + unsigned int collection_size = handle->size(); + for (unsigned int i = 0; i < collection_size; ++i) { + hits_[firstIndex + i ] = &(*handle)[i]; + } + firstIndex += collection_size; + } } void EGammaPCAHelper::setRecHitTools(const hgcal::RecHitTools* recHitTools) { @@ -85,15 +88,15 @@ void EGammaPCAHelper::storeRecHits(const std::vector>& h unsigned int layer = recHitTools_->getLayerWithOffset(hf[j].first); const DetId rh_detid = hf[j].first; - //std::unordered_map::const_iterator itcheck = hitMap_->find(rh_detid); std::unordered_map::const_iterator itcheck = hitMap_->find(rh_detid); if (itcheck == hitMap_->end()) { edm::LogWarning("EgammaPCAHelper") << " Big problem, unable to find a hit " << rh_detid.rawId() << " " << rh_detid.det() << " " << HGCalDetId(rh_detid) << std::endl; continue; } + if (debug_) { - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; std::cout << "DetId " << rh_detid.rawId() << " " << layer << " " << hit->energy() << std::endl; std::cout << " Hit " << hit << " " << hit->energy() << std::endl; } @@ -110,7 +113,7 @@ void EGammaPCAHelper::storeRecHits(const std::vector>& h if (pcavars[2] == 0.) edm::LogWarning("EgammaPCAHelper") << " Problem, hit with z =0 "; else { - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; Spot mySpot(rh_detid, hit->energy(), pcavars, layer, fraction, mip); theSpots_.push_back(mySpot); } diff --git a/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc b/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc index 2f21b39cc7699..711dadae42962 100644 --- a/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc +++ b/RecoEgamma/EgammaTools/src/HGCalEgammaIDHelper.cc @@ -15,7 +15,6 @@ HGCalEgammaIDHelper::HGCalEgammaIDHelper(const edm::ParameterSet& iConfig, edm:: recHitsEE_ = iC.consumes(eeRecHitInputTag_); recHitsFH_ = iC.consumes(fhRecHitInputTag_); recHitsBH_ = iC.consumes(bhRecHitInputTag_); - //hitMap_ = iC.consumes>(hitMapInputTag_); hitMap_ = iC.consumes>(hitMapInputTag_); caloGeometry_ = iC.esConsumes(); pcaHelper_.setdEdXWeights(dEdXWeights_); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index 4d541cdb6f295..0acfe7126a5c3 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -16,7 +16,7 @@ LCToCPAssociatorByEnergyScoreImpl::LCToCPAssociatorByEnergyScoreImpl( bool hardScatterOnly, std::shared_ptr recHitTools, const std::unordered_map* hitMap, - std::vector& hits) + const std::vector& hits) : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), @@ -95,7 +95,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( detIdToCaloParticleId_Map[hitid].emplace_back(cpId, it_haf.second); } } - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; cPOnLayer[cpId][cpLayerId].energy += it_haf.second * hit->energy(); // We need to compress the hits and fractions in order to have a // reasonable score between CP and LC. Imagine, for example, that a @@ -128,7 +128,8 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl; double tot_energy = 0.; for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(DetId(haf.first))]); + //const HIT* hit = &(hits_[hitMap_->at(DetId(haf.first))]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -146,7 +147,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToCPAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)cp.first << " we have found the following connections with CaloParticles:" << std::endl; - const HIT* hit = &(hits_[hitMap_->at(cp.first)]); + const HIT* hit = hits_[hitMap_->at(cp.first)]; for (auto const& cpp : cp.second) { LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " CaloParticle Id: " << cpp.clusterId << " with fraction: " << cpp.fraction @@ -185,7 +186,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_CP != detIdToCaloParticleId_Map.end()) { const auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; for (auto& h : hit_find_in_CP->second) { cPOnLayer[h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[lcId].first += h.fraction * hit->energy(); cpsInLayerCluster[lcId].emplace_back(h.clusterId, 0.f); @@ -244,7 +245,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) { hitsToCaloParticleId[hitId] -= 1; } else { - const HIT* hit = &(hits_[hitMap_->at(rh_detid)]); + const HIT* hit = hits_[hitMap_->at(rh_detid)]; auto maxCPEnergyInLC = 0.f; auto maxCPId = -1; for (auto& h : hit_find_in_CP->second) { @@ -317,7 +318,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl; double tot_energy = 0.; for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -335,7 +336,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToCPAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)cp.first << " we have found the following connections with CaloParticles:" << std::endl; - const HIT* hit = &(hits_[hitMap_->at(cp.first)]); + const HIT* hit = hits_[hitMap_->at(cp.first)]; for (auto const& cpp : cp.second) { LogDebug("LCToCPAssociatorByEnergyScoreImpl") << " CaloParticle Id: " << cpp.clusterId << " with fraction: " << cpp.fraction @@ -368,7 +369,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( // It is the inverse of the denominator of the LCToCP score formula. Observe that this is the sum of the squares. float invLayerClusterEnergyWeight = 0.f; for (auto const& haf : hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; invLayerClusterEnergyWeight += (haf.second * hit->energy()) * (haf.second * hit->energy()); } invLayerClusterEnergyWeight = 1.f / invLayerClusterEnergyWeight; @@ -379,7 +380,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( bool hitWithNoCP = (detIdToCaloParticleId_Map.find(rh_detid) == detIdToCaloParticleId_Map.end()); auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& cpPair : cpsInLayerCluster[lcId]) { @@ -436,7 +437,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( // Compute the correct normalization. Observe that this is the sum of the squares. float invCPEnergyWeight = 0.f; for (auto const& haf : cPOnLayer[cpId][layerId].hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; invCPEnergyWeight += std::pow(haf.second * hit->energy(), 2); } invCPEnergyWeight = 1.f / invCPEnergyWeight; @@ -451,7 +452,7 @@ ticl::association LCToCPAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) hitWithNoLC = true; auto itcheck = hitMap_->find(cp_hitDetId); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) { unsigned int layerClusterId = lcPair.first; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h index 2b4a6f50aec91..ceadbc52cb3ba 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.h @@ -71,7 +71,7 @@ class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticl bool, std::shared_ptr, const std::unordered_map *, - std::vector &hits); + const std::vector &hits); ticl::RecoToSimCollection associateRecoToSim(const edm::Handle &cCH, const edm::Handle &cPCH) const override; @@ -87,7 +87,7 @@ class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticl edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &cCH, const edm::Handle &cPCH) const; - std::vector hits_; + std::vector hits_; }; extern template class LCToCPAssociatorByEnergyScoreImpl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index 88c153f9973df..9bf4387cc0f82 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -29,20 +29,25 @@ void LCToCPAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - std::vector hits; + std::vector hits; if constexpr (std::is_same_v) { for (auto &token : hgcal_hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } } else { for (auto &token : hits_token_) { edm::Handle> hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } } + const auto hitMap = &iEvent.get(hitMap_); auto impl = std::make_unique>( diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc index e68cf40315c16..07cc3ff3355a5 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc @@ -23,6 +23,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h" #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" #include "FWCore/Utilities/interface/EDGetToken.h" diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index aca445573d64a..3d5a3bb4f2869 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -9,7 +9,7 @@ LCToSCAssociatorByEnergyScoreImpl::LCToSCAssociatorByEnergyScoreImpl( bool hardScatterOnly, std::shared_ptr recHitTools, const std::unordered_map* hitMap, - std::vector& hits) + std::vector& hits) : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), @@ -84,7 +84,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( detIdToSimClusterId_Map[hitid] = std::vector(); } detIdToSimClusterId_Map[hitid].emplace_back(scId, it_haf.second); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; lcsInSimCluster[scId][scLayerId].energy += it_haf.second * hit->energy(); lcsInSimCluster[scId][scLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second); } @@ -105,7 +105,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << lcsInSimCluster[sc][sclay].energy << std::endl; double tot_energy = 0.; for (auto const& haf : lcsInSimCluster[sc][sclay].hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -127,7 +127,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // specific detId there are more that one SimClusters contributing with fractions less than 1. // This is important since it effects the score computation, since the fraction is also in the // denominator of the score formula. - const HIT* hit = &(hits_[hitMap_->at(sc.first)]); + const HIT* hit = hits_[hitMap_->at(sc.first)]; for (auto const& sclu : sc.second) { LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " SimCluster Id: " << sclu.clusterId << " with fraction: " << sclu.fraction @@ -168,7 +168,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_SC != detIdToSimClusterId_Map.end()) { const auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; //Loops through all the simclusters that have the layer cluster rechit under study //Here is time to update the lcsInSimCluster and connect the SimCluster with all //the layer clusters that have the current rechit detid matched. @@ -237,7 +237,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( hitsToSimClusterId[hitId] -= 1; } else { const auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; auto maxSCEnergyInLC = 0.f; auto maxSCId = -1; //Loop through all the linked SimClusters @@ -321,7 +321,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << lcsInSimCluster[sc][sclay].energy << std::endl; double tot_energy = 0.; for (auto const& haf : lcsInSimCluster[sc][sclay].hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; LogDebug("LCToSCAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -336,7 +336,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("LCToSCAssociatorByEnergyScoreImpl") << "Improved detIdToSimClusterId_Map INFO" << std::endl; for (auto const& sc : detIdToSimClusterId_Map) { - const HIT* hit = &(hits_[hitMap_->at(sc.first)]); + const HIT* hit = hits_[hitMap_->at(sc.first)]; LogDebug("LCToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)sc.first << " we have found the following connections with SimClusters:" << std::endl; @@ -373,7 +373,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // It is the inverse of the denominator of the LCToSC score formula. Observe that this is the sum of the squares. float invLayerClusterEnergyWeight = 0.f; for (auto const& haf : hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; invLayerClusterEnergyWeight += (haf.second * hit->energy()) * (haf.second * hit->energy()); } invLayerClusterEnergyWeight = 1.f / invLayerClusterEnergyWeight; @@ -384,7 +384,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( bool hitWithSC = (detIdToSimClusterId_Map.find(rh_detid) != detIdToSimClusterId_Map.end()); auto itcheck = hitMap_->find(rh_detid); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& scPair : scsInLayerCluster[lcId]) { @@ -453,7 +453,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( // Compute the correct normalization. Observe that this is the sum of the squares. float invSCEnergyWeight = 0.f; for (auto const& haf : lcsInSimCluster[scId][layerId].hits_and_fractions) { - const HIT* hit = &(hits_[hitMap_->at(haf.first)]); + const HIT* hit = hits_[hitMap_->at(haf.first)]; invSCEnergyWeight += std::pow(haf.second * hit->energy(), 2); } invSCEnergyWeight = 1.f / invSCEnergyWeight; @@ -468,7 +468,7 @@ ticl::association LCToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_LC != detIdToLayerClusterId_Map.end()) hitWithLC = true; auto itcheck = hitMap_->find(sc_hitDetId); - const HIT* hit = &(hits_[itcheck->second]); + const HIT* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& lcPair : lcsInSimCluster[scId][layerId].layerClusterIdToEnergyAndScore) { unsigned int layerClusterId = lcPair.first; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h index 17cce52e500f0..98d7a6335a252 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.h @@ -68,7 +68,7 @@ class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterA bool, std::shared_ptr, const std::unordered_map *, - std::vector &hits); + std::vector &hits); ticl::RecoToSimCollectionWithSimClusters associateRecoToSim( const edm::Handle &cCH, @@ -86,7 +86,7 @@ class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterA edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &cCH, const edm::Handle &sCCH) const; - std::vector hits_; + std::vector hits_; }; extern template class LCToSCAssociatorByEnergyScoreImpl; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 1b2f381fe2cd3..e83dbc43a6123 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -29,18 +29,22 @@ void LCToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - std::vector hits; + std::vector hits; if constexpr (std::is_same_v) { for (auto &token : hgcal_hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } } else { for (auto &token : hits_token_) { edm::Handle> hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } } const auto hitMap = &iEvent.get(hitMap_); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc index 27ff8092d50a8..9ff216da1b771 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.cc @@ -15,7 +15,7 @@ MultiClusterAssociatorByEnergyScoreImpl::MultiClusterAssociatorByEnergyScoreImpl bool hardScatterOnly, std::shared_ptr recHitTools, const std::unordered_map*& hitMap, - std::vector& hits) + std::vector& hits) : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), @@ -95,7 +95,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( detIdToCaloParticleId_Map[hitid].emplace_back(cpId, it_haf.second); } } - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; //Since the current hit from sim cluster has a reconstructed hit with the same detid, //fill the cPOnLayer[caloparticle][layer] object with energy (sum of all recHits energy times fraction //of the relevant simHit) and keep the hit (detid and fraction) that contributed. @@ -131,7 +131,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl; double tot_energy = 0.; for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; @@ -147,7 +147,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << "detIdToCaloParticleId_Map INFO" << std::endl; for (auto const& cp : detIdToCaloParticleId_Map) { - const HGCRecHit* hit = &(hits_[hitMap_->at(cp.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(cp.first)]; LogDebug("MultiClusterAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)cp.first << " we have found the following connections with CaloParticles:" << std::endl; @@ -225,7 +225,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( //Since the hit is belonging to the layer cluster, it must also be in the recHits map. const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; //Make a map that will connect a detid (that belongs to a recHit of the layer cluster under study, //no need to save others) with: @@ -372,7 +372,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( // Compute the correct normalization float invMultiClusterEnergyWeight = 0.f; for (auto const& haf : mClusters[mcId].hitsAndFractions()) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; invMultiClusterEnergyWeight += (haf.second * hit->energy()) * (haf.second * hit->energy()); } invMultiClusterEnergyWeight = 1.f / invMultiClusterEnergyWeight; @@ -384,7 +384,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( bool hitWithNoCP = (detIdToCaloParticleId_Map.find(rh_detid) == detIdToCaloParticleId_Map.end()); auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& cpPair : cpsInMultiCluster[mcId]) { @@ -458,7 +458,7 @@ hgcal::association MultiClusterAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_MCL == detIdToMultiClusterId_Map.end()) hitWithNoMCL = true; auto itcheck = hitMap_->find(cp_hitDetId); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& mcPair : cPOnLayer[cpId][layerId].multiClusterIdToEnergyAndScore) { unsigned int multiClusterId = mcPair.first; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h index 3e3db77cbe462..ecfa818775a14 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreImpl.h @@ -50,7 +50,7 @@ class MultiClusterAssociatorByEnergyScoreImpl : public hgcal::MultiClusterToCalo bool, std::shared_ptr, const std::unordered_map *&, - std::vector &hits); + std::vector &hits); hgcal::RecoToSimCollectionWithMultiClusters associateRecoToSim( const edm::Handle &mCCH, @@ -64,7 +64,7 @@ class MultiClusterAssociatorByEnergyScoreImpl : public hgcal::MultiClusterToCalo const bool hardScatterOnly_; std::shared_ptr recHitTools_; const std::unordered_map *hitMap_; - std::vector hits_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; hgcal::association makeConnections(const edm::Handle &mCCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc index 866efe832bd35..75d76eb56c9c8 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/MultiClusterAssociatorByEnergyScoreProducer.cc @@ -55,11 +55,13 @@ void MultiClusterAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - std::vector hits; + std::vector hits; for (auto &token : hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } const std::unordered_map *hitMap = &iEvent.get(hitMap_); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc index 942aa6880ec52..445d9ee12335e 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.cc @@ -8,7 +8,7 @@ TSToSCAssociatorByEnergyScoreImpl::TSToSCAssociatorByEnergyScoreImpl( bool hardScatterOnly, std::shared_ptr recHitTools, const std::unordered_map* hitMap, - std::vector& hits) + std::vector& hits) : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), @@ -68,7 +68,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( } detIdToSimClusterId_Map[hitid].emplace_back(scId, it_haf.second); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; tssInSimCluster[scId].energy += it_haf.second * hit->energy(); tssInSimCluster[scId].hits_and_fractions.emplace_back(hitid, it_haf.second); } @@ -86,7 +86,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\t# of clusters:\t" << layerClusters.size() << std::endl; double tot_energy = 0.; for (auto const& haf : tssInSimCluster[sc].hits_and_fractions) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tHits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -100,7 +100,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "detIdToSimClusterId_Map INFO" << std::endl; for (auto const& detId : detIdToSimClusterId_Map) { - const HGCRecHit* hit = &(hits_[hitMap_->at(detId.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(detId.first)]; LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)detId.first << " we have found the following connections with SimClusters:" << std::endl; @@ -142,7 +142,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_SC != detIdToSimClusterId_Map.end()) { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; //Loops through all the simclusters that have the layer cluster rechit under study //Here is time to update the tssInSimCluster and connect the SimCluster with all //the Tracksters that have the current rechit detid matched. @@ -210,7 +210,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( hitsToSimClusterId[hitId] -= 1; } else { const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; auto maxSCEnergyInLC = 0.f; auto maxSCId = -1; //Loop through all the linked SimClusters @@ -285,7 +285,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tEnergy:\t" << tssInSimCluster[sc].energy << std::endl; double tot_energy = 0.; for (auto const& haf : tssInSimCluster[sc].hits_and_fractions) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "\tHits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/" << haf.second * hit->energy() << std::endl; tot_energy += haf.second * hit->energy(); @@ -299,7 +299,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "Improved detIdToSimClusterId_Map INFO" << std::endl; for (auto const& sc : detIdToSimClusterId_Map) { - const HGCRecHit* hit = &(hits_[hitMap_->at(sc.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(sc.first)]; LogDebug("TSToSCAssociatorByEnergyScoreImpl") << "For detId: " << (uint32_t)sc.first << " we have found the following connections with SimClusters:" << std::endl; @@ -339,7 +339,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( const auto& hits_and_fractions = layerClusters[lcId].hitsAndFractions(); // Compute the correct normalization for (auto const& haf : hits_and_fractions) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; invTracksterEnergyWeight += (lcFractionInTs * haf.second * hit->energy()) * (lcFractionInTs * haf.second * hit->energy()); } @@ -359,7 +359,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( const bool hitWithSC = (detIdToSimClusterId_Map.find(rh_detid) != detIdToSimClusterId_Map.end()); const auto itcheck = hitMap_->find(rh_detid); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& scPair : scsInTrackster[tsId]) { @@ -427,7 +427,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( #endif // Compute the correct normalization for (auto const& haf : tssInSimCluster[scId].hits_and_fractions) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; invSCEnergyWeight += std::pow(haf.second * hit->energy(), 2); } invSCEnergyWeight = 1.f / invSCEnergyWeight; @@ -443,7 +443,7 @@ ticl::association TSToSCAssociatorByEnergyScoreImpl::makeConnections( if (hit_find_in_LC != detIdToLayerClusterId_Map.end()) hitWithLC = true; const auto itcheck = hitMap_->find(sc_hitDetId); - const HGCRecHit* hit = &(hits_[itcheck->second]); + const HGCRecHit* hit = hits_[itcheck->second]; float hitEnergyWeight = hit->energy() * hit->energy(); for (auto& tsPair : tssInSimCluster[scId].tracksterIdToEnergyAndScore) { unsigned int tsId = tsPair.first; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h index c1b324a7c0cdb..539c4d36b8a2b 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreImpl.h @@ -43,7 +43,7 @@ class TSToSCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimClusterAsso bool, std::shared_ptr, const std::unordered_map *, - std::vector &hits); + std::vector &hits); ticl::RecoToSimCollectionTracksters associateRecoToSim(const edm::Handle &tCH, const edm::Handle &lCCH, @@ -57,7 +57,7 @@ class TSToSCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimClusterAsso const bool hardScatterOnly_; std::shared_ptr recHitTools_; const std::unordered_map *hitMap_; - std::vector hits_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &tCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc index 026edc2bcaa0a..4992162b0eea1 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSCAssociatorByEnergyScoreProducer.cc @@ -55,11 +55,13 @@ void TSToSCAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - std::vector hits; + std::vector hits; for (auto &token : hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } const auto hitMap = &iEvent.get(hitMap_); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc index c32142a99e694..ca85ecdc93153 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.cc @@ -7,7 +7,7 @@ TSToSimTSAssociatorByEnergyScoreImpl::TSToSimTSAssociatorByEnergyScoreImpl( bool hardScatterOnly, std::shared_ptr recHitTools, const std::unordered_map* hitMap, - std::vector& hits) + std::vector& hits) : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), @@ -315,7 +315,7 @@ ticl::association TSToSimTSAssociatorByEnergyScoreImpl::makeConnections( const auto& hits_and_fractions = layerClusters[lcId].hitsAndFractions(); // Compute the correct normalization for (auto const& haf : hits_and_fractions) { - const HGCRecHit* hit = &(hits_[hitMap_->at(haf.first)]); + const HGCRecHit* hit = hits_[hitMap_->at(haf.first)]; invTracksterEnergyWeight += std::pow(lcFractionInTs * haf.second * hit->energy(), 2); } } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h index e473b0460ddef..1c1748613f23c 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreImpl.h @@ -69,7 +69,7 @@ class TSToSimTSAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTrackste bool, std::shared_ptr, const std::unordered_map *, - std::vector &hits); + std::vector &hits); ticl::RecoToSimCollectionSimTracksters associateRecoToSim( const edm::Handle &tCH, @@ -85,7 +85,7 @@ class TSToSimTSAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTrackste const bool hardScatterOnly_; std::shared_ptr recHitTools_; const std::unordered_map *hitMap_; - std::vector hits_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; ticl::association makeConnections(const edm::Handle &tCH, diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc index 9f9359104520e..102f7c8b4c90c 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSAssociatorByEnergyScoreProducer.cc @@ -56,11 +56,13 @@ void TSToSimTSAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - std::vector hits; + std::vector hits; for (auto &token : hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } const auto hitMap = &iEvent.get(hitMap_); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc index 5ab1bfea56eba..8b9677ea2d1ea 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.cc @@ -9,7 +9,7 @@ TSToSimTSHitLCAssociatorByEnergyScoreImpl::TSToSimTSHitLCAssociatorByEnergyScore bool hardScatterOnly, std::shared_ptr recHitTools, const std::unordered_map* hitMap, - std::vector& hits) + std::vector& hits) : hardScatterOnly_(hardScatterOnly), recHitTools_(recHitTools), hitMap_(hitMap), @@ -137,7 +137,7 @@ ticl::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( } } - const HGCRecHit* hit = &(hits_[hitMap_->find(hitId)->second]); + const HGCRecHit* hit = hits_[hitMap_->find(hitId)->second]; float hitEnergy = hit->energy(); float hitEnergySquared = hitEnergy * hitEnergy; float simFractionSquared = simFraction * simFraction; @@ -177,7 +177,7 @@ ticl::association_t TSToSimTSHitLCAssociatorByEnergyScoreImpl::makeConnections( if (found != detIdToRecoTSId_Map[hitId].end()) recoFraction = found->second; - const HGCRecHit* hit = &(hits_[hitMap_->find(hitId)->second]); + const HGCRecHit* hit = hits_[hitMap_->find(hitId)->second]; float hitEnergy = hit->energy(); float hitEnergySquared = hitEnergy * hitEnergy; float recoFractionSquared = recoFraction * recoFraction; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h index 81fecf9b9a5f1..447fa5a27eac9 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreImpl.h @@ -48,7 +48,7 @@ class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTra bool, std::shared_ptr, const std::unordered_map *, - std::vector &hits); + std::vector &hits); ticl::association_t makeConnections(const edm::Handle &tCH, const edm::Handle &lCCH, @@ -74,7 +74,7 @@ class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTra const bool hardScatterOnly_; std::shared_ptr recHitTools_; const std::unordered_map *hitMap_; - std::vector hits_; + std::vector hits_; unsigned layers_; edm::EDProductGetter const *productGetter_; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc index 490aea19d2502..6c5f2124f73b6 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/TSToSimTSHitLCAssociatorByEnergyScoreProducer.cc @@ -56,11 +56,13 @@ void TSToSimTSHitLCAssociatorByEnergyScoreProducer::produce(edm::StreamID, edm::ESHandle geom = es.getHandle(caloGeometry_); rhtools_->setGeometry(*geom); - std::vector hits; + std::vector hits; for (auto &token : hits_token_) { edm::Handle hits_handle; iEvent.getByToken(token, hits_handle); - hits.insert(hits.end(), (*hits_handle).begin(), (*hits_handle).end()); + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } const auto hitMap = &iEvent.get(hitMap_); From b0887def2e74cef438955ac27c55ff95e6742c7c Mon Sep 17 00:00:00 2001 From: brusale Date: Wed, 17 Apr 2024 10:18:26 +0200 Subject: [PATCH 022/301] fix dictionaries definition --- DataFormats/DetId/src/classes.h | 1 + DataFormats/DetId/src/classes_def.xml | 4 +++- DataFormats/HGCRecHit/src/classes_def.xml | 3 --- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DataFormats/DetId/src/classes.h b/DataFormats/DetId/src/classes.h index f2a2aca56dadf..e2a9ab8a16e00 100644 --- a/DataFormats/DetId/src/classes.h +++ b/DataFormats/DetId/src/classes.h @@ -1,5 +1,6 @@ #include "DataFormats/DetId/interface/DetId.h" #include +#include #include #include "DataFormats/DetId/interface/DetIdVector.h" diff --git a/DataFormats/DetId/src/classes_def.xml b/DataFormats/DetId/src/classes_def.xml index 6d4fabdebddec..460f90b9835ac 100644 --- a/DataFormats/DetId/src/classes_def.xml +++ b/DataFormats/DetId/src/classes_def.xml @@ -14,5 +14,7 @@ - + + + diff --git a/DataFormats/HGCRecHit/src/classes_def.xml b/DataFormats/HGCRecHit/src/classes_def.xml index 6e0f82f7a2bad..319f0fe142654 100644 --- a/DataFormats/HGCRecHit/src/classes_def.xml +++ b/DataFormats/HGCRecHit/src/classes_def.xml @@ -41,7 +41,4 @@ - - - From 27029e249117ed60cd7d37a8b6e9a43b9b4be6e5 Mon Sep 17 00:00:00 2001 From: brusale Date: Thu, 18 Apr 2024 08:59:08 +0200 Subject: [PATCH 023/301] apply code-format --- RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc index e20e9fe91ef38..ba206f7f72639 100644 --- a/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc +++ b/RecoEgamma/EgammaTools/src/EgammaPCAHelper.cc @@ -32,7 +32,6 @@ void EGammaPCAHelper::setHitMap(const std::unordered_map recHitHandleEE, edm::Handle recHitHandleFH, edm::Handle recHitHandleBH) { - unsigned int total_size = recHitHandleEE->size() + recHitHandleFH->size() + recHitHandleBH->size(); hits_.resize(total_size); unsigned int firstIndex = 0; @@ -40,7 +39,7 @@ void EGammaPCAHelper::setRecHits(edm::Handle recHitHandleEE for (const auto& handle : {recHitHandleEE, recHitHandleFH, recHitHandleBH}) { unsigned int collection_size = handle->size(); for (unsigned int i = 0; i < collection_size; ++i) { - hits_[firstIndex + i ] = &(*handle)[i]; + hits_[firstIndex + i] = &(*handle)[i]; } firstIndex += collection_size; } @@ -94,7 +93,7 @@ void EGammaPCAHelper::storeRecHits(const std::vector>& h << rh_detid.det() << " " << HGCalDetId(rh_detid) << std::endl; continue; } - + if (debug_) { const HGCRecHit* hit = hits_[itcheck->second]; std::cout << "DetId " << rh_detid.rawId() << " " << layer << " " << hit->energy() << std::endl; From bcbcf6926a2217a2a873d7bdc7f7daa614c4b815 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 18 Apr 2024 13:13:44 -0500 Subject: [PATCH 024/301] Moved code to edm::streamer namespace --- .../StreamerIO/plugins/DQMStreamerReader.cc | 9 +- .../StreamerIO/plugins/DQMStreamerReader.h | 12 +- .../test/DQMStreamerOutputRepackerTest.cc | 7 +- .../Utilities/interface/DAQSourceModelsFRD.h | 12 +- .../interface/DAQSourceModelsScoutingRun3.h | 6 +- .../interface/FedRawDataInputSource.h | 2 +- .../Utilities/plugins/FRDOutputModule.cc | 2 + .../Utilities/plugins/FRDStreamSource.cc | 2 + .../plugins/GlobalEvFOutputModule.cc | 17 +- .../plugins/RawEventFileWriterForBU.cc | 1 + .../plugins/RawEventFileWriterForBU.h | 8 +- .../plugins/RawEventOutputModuleForBU.h | 8 +- .../Utilities/src/DAQSourceModelsFRD.cc | 2 + .../src/DAQSourceModelsScoutingRun3.cc | 2 + EventFilter/Utilities/src/EvFDaqDirector.cc | 1 + .../Utilities/src/FedRawDataInputSource.cc | 1 + IOPool/Streamer/bin/CalcAdler32.cpp | 2 + IOPool/Streamer/bin/CatStreamerFiles.cpp | 5 +- IOPool/Streamer/bin/DiagStreamerFile.cpp | 429 +++++++++--------- IOPool/Streamer/interface/ClassFiller.h | 4 +- IOPool/Streamer/interface/DumpTools.h | 26 +- IOPool/Streamer/interface/EventMessage.h | 116 ++--- IOPool/Streamer/interface/EventMsgBuilder.h | 61 +-- IOPool/Streamer/interface/FRDEventMessage.h | 197 ++++---- IOPool/Streamer/interface/FRDFileHeader.h | 123 ++--- IOPool/Streamer/interface/InitMessage.h | 175 +++---- IOPool/Streamer/interface/InitMsgBuilder.h | 56 +-- IOPool/Streamer/interface/MsgHeader.h | 81 ++-- IOPool/Streamer/interface/MsgTools.h | 145 +++--- IOPool/Streamer/interface/StreamSerializer.h | 94 ++-- IOPool/Streamer/interface/StreamerInputFile.h | 4 +- .../Streamer/interface/StreamerInputModule.h | 4 +- .../Streamer/interface/StreamerInputSource.h | 10 +- .../Streamer/interface/StreamerOutputFile.h | 49 +- .../Streamer/interface/StreamerOutputModule.h | 4 +- .../interface/StreamerOutputModuleBase.h | 64 +-- .../interface/StreamerOutputModuleCommon.h | 108 ++--- IOPool/Streamer/plugins/Module.cc | 8 +- IOPool/Streamer/src/ClassFiller.cc | 4 +- IOPool/Streamer/src/DumpTools.cc | 348 +++++++------- IOPool/Streamer/src/EventMessage.cc | 2 + IOPool/Streamer/src/EventMsgBuilder.cc | 4 +- IOPool/Streamer/src/FRDEventMessage.cc | 2 + IOPool/Streamer/src/InitMessage.cc | 2 + IOPool/Streamer/src/InitMsgBuilder.cc | 2 + IOPool/Streamer/src/StreamSerializer.cc | 4 +- IOPool/Streamer/src/StreamerFileReader.cc | 4 +- IOPool/Streamer/src/StreamerFileReader.h | 62 +-- IOPool/Streamer/src/StreamerFileWriter.cc | 5 +- IOPool/Streamer/src/StreamerFileWriter.h | 34 +- IOPool/Streamer/src/StreamerInputFile.cc | 4 +- IOPool/Streamer/src/StreamerInputSource.cc | 4 +- IOPool/Streamer/src/StreamerOutputFile.cc | 131 +++--- .../Streamer/src/StreamerOutputModuleBase.cc | 4 +- .../src/StreamerOutputModuleCommon.cc | 4 +- IOPool/Streamer/test/EventMessageTest.cpp | 2 + IOPool/Streamer/test/ReadStreamerFile.cpp | 14 +- IOPool/Streamer/test/WriteStreamerFile.cpp | 2 + 58 files changed, 1283 insertions(+), 1212 deletions(-) diff --git a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc index 745301e0a6744..97aef9ff623b0 100644 --- a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc +++ b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc @@ -18,6 +18,7 @@ #include namespace dqmservices { + using namespace edm::streamer; DQMStreamerReader::DQMStreamerReader(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc) : StreamerInputSource(pset, desc), @@ -87,7 +88,7 @@ namespace dqmservices { std::string path = entry.get_data_path(); file_.lumi_ = entry; - file_.streamFile_ = std::make_unique(path); + file_.streamFile_ = std::make_unique(path); InitMsgView const* header = getHeaderMsg(); if (isFirstFile_) { @@ -179,11 +180,11 @@ namespace dqmservices { EventMsgView const* DQMStreamerReader::getEventMsg() { auto next = file_.streamFile_->next(); - if (edm::StreamerInputFile::Next::kFile == next) { + if (StreamerInputFile::Next::kFile == next) { return nullptr; } - if (edm::StreamerInputFile::Next::kStop == next) { + if (StreamerInputFile::Next::kStop == next) { return nullptr; } @@ -437,7 +438,7 @@ namespace dqmservices { desc.addUntracked("inputFileTransitionsEachEvent", false); DQMFileIterator::fillDescription(desc); - edm::StreamerInputSource::fillDescription(desc); + StreamerInputSource::fillDescription(desc); edm::EventSkipperByID::fillDescription(desc); descriptions.add("source", desc); diff --git a/DQMServices/StreamerIO/plugins/DQMStreamerReader.h b/DQMServices/StreamerIO/plugins/DQMStreamerReader.h index b84dad02816c9..547f1f8cbfa17 100644 --- a/DQMServices/StreamerIO/plugins/DQMStreamerReader.h +++ b/DQMServices/StreamerIO/plugins/DQMStreamerReader.h @@ -16,7 +16,7 @@ namespace dqmservices { - class DQMStreamerReader : public edm::StreamerInputSource { + class DQMStreamerReader : public edm::streamer::StreamerInputSource { public: DQMStreamerReader(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc); ~DQMStreamerReader() override; @@ -41,14 +41,14 @@ namespace dqmservices { bool openNextFileImp_(); - InitMsgView const* getHeaderMsg(); - EventMsgView const* getEventMsg(); + edm::streamer::InitMsgView const* getHeaderMsg(); + edm::streamer::EventMsgView const* getEventMsg(); - EventMsgView const* prepareNextEvent(); + edm::streamer::EventMsgView const* prepareNextEvent(); bool isFirstFile_ = true; bool prepareNextFile(); - bool acceptEvent(const EventMsgView*); + bool acceptEvent(const edm::streamer::EventMsgView*); DQMFileIterator fiterator_; unsigned int processedEventPerLs_ = 0; @@ -66,7 +66,7 @@ namespace dqmservices { bool setMatchTriggerSel(std::vector const& tnames); struct OpenFile { - std::unique_ptr streamFile_; + std::unique_ptr streamFile_; DQMFileIterator::LumiEntry lumi_; bool open() { return (streamFile_.get() != nullptr); } diff --git a/DQMServices/StreamerIO/test/DQMStreamerOutputRepackerTest.cc b/DQMServices/StreamerIO/test/DQMStreamerOutputRepackerTest.cc index 7b83a3c603155..48723ec412ddc 100644 --- a/DQMServices/StreamerIO/test/DQMStreamerOutputRepackerTest.cc +++ b/DQMServices/StreamerIO/test/DQMStreamerOutputRepackerTest.cc @@ -26,8 +26,9 @@ #include "IOPool/Streamer/interface/StreamerOutputModuleBase.h" namespace dqmservices { + using namespace edm::streamer; - class DQMStreamerOutputRepackerTest : public edm::StreamerOutputModuleBase { + class DQMStreamerOutputRepackerTest : public StreamerOutputModuleBase { public: explicit DQMStreamerOutputRepackerTest(edm::ParameterSet const& ps); ~DQMStreamerOutputRepackerTest() override; @@ -64,7 +65,7 @@ namespace dqmservices { }; // end-of-class-def DQMStreamerOutputRepackerTest::DQMStreamerOutputRepackerTest(edm::ParameterSet const& ps) - : edm::one::OutputModuleBase::OutputModuleBase(ps), edm::StreamerOutputModuleBase(ps) { + : edm::one::OutputModuleBase::OutputModuleBase(ps), StreamerOutputModuleBase(ps) { outputPath_ = ps.getUntrackedParameter("outputPath"); streamLabel_ = ps.getUntrackedParameter("streamLabel"); @@ -168,7 +169,7 @@ namespace dqmservices { void DQMStreamerOutputRepackerTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - edm::StreamerOutputModuleBase::fillDescription(desc); + StreamerOutputModuleBase::fillDescription(desc); desc.addUntracked("outputPath", "./output/")->setComment("File output path."); diff --git a/EventFilter/Utilities/interface/DAQSourceModelsFRD.h b/EventFilter/Utilities/interface/DAQSourceModelsFRD.h index c3e1c896ab623..15a45c23c37f4 100644 --- a/EventFilter/Utilities/interface/DAQSourceModelsFRD.h +++ b/EventFilter/Utilities/interface/DAQSourceModelsFRD.h @@ -24,9 +24,9 @@ class DataModeFRD : public DataMode { detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset)); } - uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; } + uint32_t headerSize() const override { return edm::streamer::FRDHeaderVersionSize[detectedFRDversion_]; } - bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; } + bool versionCheck() const override { return detectedFRDversion_ <= edm::streamer::FRDHeaderMaxVersion; } uint64_t dataBlockSize() const override { return event_->size(); } @@ -76,7 +76,7 @@ class DataModeFRD : public DataMode { std::vector> daqProvenanceHelpers_; uint16_t detectedFRDversion_ = 0; size_t headerSize_ = 0; - std::unique_ptr event_; + std::unique_ptr event_; uint32_t crc_ = 0; unsigned char* dataBlockAddr_ = nullptr; size_t dataBlockMax_ = 0; @@ -106,9 +106,9 @@ class DataModeFRDStriped : public DataMode { detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset)); } - uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; } + uint32_t headerSize() const override { return edm::streamer::FRDHeaderVersionSize[detectedFRDversion_]; } - bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; } + bool versionCheck() const override { return detectedFRDversion_ <= edm::streamer::FRDHeaderMaxVersion; } uint64_t dataBlockSize() const override { //just get first event size @@ -186,7 +186,7 @@ class DataModeFRDStriped : public DataMode { uint16_t detectedFRDversion_ = 0; size_t fileHeaderSize_ = 0; size_t headerSize_ = 0; - std::vector> events_; + std::vector> events_; std::string crcMsg_; unsigned char* dataBlockAddr_ = nullptr; std::vector dataBlockAddrs_; diff --git a/EventFilter/Utilities/interface/DAQSourceModelsScoutingRun3.h b/EventFilter/Utilities/interface/DAQSourceModelsScoutingRun3.h index a3c8bd43c5fc7..1eff0fdb1bada 100644 --- a/EventFilter/Utilities/interface/DAQSourceModelsScoutingRun3.h +++ b/EventFilter/Utilities/interface/DAQSourceModelsScoutingRun3.h @@ -31,8 +31,8 @@ class DataModeScoutingRun3 : public DataMode { void detectVersion(unsigned char* fileBuf, uint32_t fileHeaderOffset) override { detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset)); } - uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; } - bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; } + uint32_t headerSize() const override { return edm::streamer::FRDHeaderVersionSize[detectedFRDversion_]; } + bool versionCheck() const override { return detectedFRDversion_ <= edm::streamer::FRDHeaderMaxVersion; } uint64_t dataBlockSize() const override { // get event size from the first data source (main) @@ -113,7 +113,7 @@ class DataModeScoutingRun3 : public DataMode { uint16_t detectedFRDversion_ = 0; size_t fileHeaderSize_ = 0; size_t headerSize_ = 0; - std::vector> events_; + std::vector> events_; unsigned char* dataBlockAddr_ = nullptr; std::vector dataBlockAddrs_; std::vector dataBlockMaxAddrs_; diff --git a/EventFilter/Utilities/interface/FedRawDataInputSource.h b/EventFilter/Utilities/interface/FedRawDataInputSource.h index 9b5189d1e5f37..687ce0e50148c 100644 --- a/EventFilter/Utilities/interface/FedRawDataInputSource.h +++ b/EventFilter/Utilities/interface/FedRawDataInputSource.h @@ -115,7 +115,7 @@ class FedRawDataInputSource : public edm::RawInputSource { const edm::DaqProvenanceHelper daqProvenanceHelper_; - std::unique_ptr event_; + std::unique_ptr event_; edm::EventID eventID_; edm::ProcessHistoryID processHistoryID_; diff --git a/EventFilter/Utilities/plugins/FRDOutputModule.cc b/EventFilter/Utilities/plugins/FRDOutputModule.cc index 65bf2a59ded6a..5b5b9fe43bfc9 100644 --- a/EventFilter/Utilities/plugins/FRDOutputModule.cc +++ b/EventFilter/Utilities/plugins/FRDOutputModule.cc @@ -22,6 +22,8 @@ #include "IOPool/Streamer/interface/FRDFileHeader.h" #include "EventFilter/Utilities/interface/crc32c.h" +using namespace edm::streamer; + FRDOutputModule::FRDOutputModule(edm::ParameterSet const& ps) : edm::one::OutputModuleBase::OutputModuleBase(ps), edm::one::OutputModule(ps), diff --git a/EventFilter/Utilities/plugins/FRDStreamSource.cc b/EventFilter/Utilities/plugins/FRDStreamSource.cc index 884eeb985c523..ff9dca127864b 100644 --- a/EventFilter/Utilities/plugins/FRDStreamSource.cc +++ b/EventFilter/Utilities/plugins/FRDStreamSource.cc @@ -17,6 +17,8 @@ #include "EventFilter/Utilities/plugins/FRDStreamSource.h" #include "EventFilter/Utilities/interface/crc32c.h" +using namespace edm::streamer; + FRDStreamSource::FRDStreamSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc) : ProducerSourceFromFiles(pset, desc, true), verifyAdler32_(pset.getUntrackedParameter("verifyAdler32", true)), diff --git a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc index a9f42ba645172..6bbf40317ebae 100644 --- a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc +++ b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc @@ -38,6 +38,7 @@ typedef edm::detail::TriggerResultsBasedEventSelector::handle_t Trig; namespace evf { + using namespace edm::streamer; class FastMonitoringService; @@ -155,7 +156,7 @@ namespace evf { typedef edm::global::OutputModule, edm::LuminosityBlockCache, - edm::StreamCache, + edm::StreamCache, edm::ExternalWork> GlobalEvFOutputModuleType; @@ -166,7 +167,7 @@ namespace evf { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - std::unique_ptr beginStream(edm::StreamID) const final; + std::unique_ptr beginStream(edm::StreamID) const final; std::shared_ptr globalBeginRun(edm::RunForOutput const& run) const final; @@ -184,7 +185,7 @@ namespace evf { Trig getTriggerResults(edm::EDGetTokenT const& token, edm::EventForOutput const& e) const; - edm::StreamerOutputModuleCommon::Parameters commonParameters_; + StreamerOutputModuleCommon::Parameters commonParameters_; std::string streamLabel_; edm::EDGetTokenT trToken_; edm::EDGetTokenT psetToken_; @@ -286,7 +287,7 @@ namespace evf { GlobalEvFOutputModule::GlobalEvFOutputModule(edm::ParameterSet const& ps) : edm::global::OutputModuleBase(ps), GlobalEvFOutputModuleType(ps), - commonParameters_(edm::StreamerOutputModuleCommon::parameters(ps)), + commonParameters_(StreamerOutputModuleCommon::parameters(ps)), streamLabel_(ps.getParameter("@module_label")), trToken_(consumes(edm::InputTag("TriggerResults"))), psetToken_(consumes( @@ -333,15 +334,15 @@ namespace evf { void GlobalEvFOutputModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - edm::StreamerOutputModuleCommon::fillDescription(desc); + StreamerOutputModuleCommon::fillDescription(desc); GlobalEvFOutputModuleType::fillDescription(desc); desc.addUntracked("psetMap", {"hltPSetMap"}) ->setComment("Optionally allow the map of ParameterSets to be calculated externally."); descriptions.add("globalEvfOutputModule", desc); } - std::unique_ptr GlobalEvFOutputModule::beginStream(edm::StreamID) const { - return std::make_unique( + std::unique_ptr GlobalEvFOutputModule::beginStream(edm::StreamID) const { + return std::make_unique( commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel()); } @@ -349,7 +350,7 @@ namespace evf { //create run Cache holding JSON file writer and variables auto jsonDef = std::make_unique(streamLabel_, false); jsonDef->updateDestination(streamLabel_); - edm::StreamerOutputModuleCommon streamerCommon( + StreamerOutputModuleCommon streamerCommon( commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel()); //output INI file (non-const). This doesn't require globalBeginRun to be finished diff --git a/EventFilter/Utilities/plugins/RawEventFileWriterForBU.cc b/EventFilter/Utilities/plugins/RawEventFileWriterForBU.cc index 8b4aacc084057..f5745a159efd3 100644 --- a/EventFilter/Utilities/plugins/RawEventFileWriterForBU.cc +++ b/EventFilter/Utilities/plugins/RawEventFileWriterForBU.cc @@ -17,6 +17,7 @@ #include "IOPool/Streamer/interface/FRDFileHeader.h" using namespace jsoncollector; +using namespace edm::streamer; //TODO:get run directory information from DaqDirector diff --git a/EventFilter/Utilities/plugins/RawEventFileWriterForBU.h b/EventFilter/Utilities/plugins/RawEventFileWriterForBU.h index 056082fe36a7c..6bdcefa7d5dd8 100644 --- a/EventFilter/Utilities/plugins/RawEventFileWriterForBU.h +++ b/EventFilter/Utilities/plugins/RawEventFileWriterForBU.h @@ -24,9 +24,9 @@ class RawEventFileWriterForBU { explicit RawEventFileWriterForBU(std::string const& fileName); ~RawEventFileWriterForBU(); - void doOutputEvent(FRDEventMsgView const& msg); + void doOutputEvent(edm::streamer::FRDEventMsgView const& msg); - uint32 adler32() const { return (adlerb_ << 16) | adlera_; } + edm::streamer::uint32 adler32() const { return (adlerb_ << 16) | adlera_; } void start() {} void stop(); @@ -82,8 +82,8 @@ class RawEventFileWriterForBU { int microSleep_; unsigned int frdFileVersion_; - uint32 adlera_; - uint32 adlerb_; + edm::streamer::uint32 adlera_; + edm::streamer::uint32 adlerb_; unsigned int lumiOpen_ = 0; unsigned int lumiClosed_ = 0; diff --git a/EventFilter/Utilities/plugins/RawEventOutputModuleForBU.h b/EventFilter/Utilities/plugins/RawEventOutputModuleForBU.h index 60dd6d01f7e01..d504d922fe28c 100644 --- a/EventFilter/Utilities/plugins/RawEventOutputModuleForBU.h +++ b/EventFilter/Utilities/plugins/RawEventOutputModuleForBU.h @@ -75,6 +75,8 @@ RawEventOutputModuleForBU::~RawEventOutputModuleForBU() {} template void RawEventOutputModuleForBU::write(edm::EventForOutput const& e) { + using namespace edm::streamer; + unsigned int ls = e.luminosityBlock(); if (totevents > 0 && totevents % numEventsPerFile_ == 0) { index_++; @@ -89,8 +91,8 @@ void RawEventOutputModuleForBU::write(edm::EventForOutput const& e) { e.getByToken(token_, fedBuffers); // determine the expected size of the FRDEvent IN BYTES !!!!! - assert(frdVersion_ <= FRDHeaderMaxVersion); - int headerSize = FRDHeaderVersionSize[frdVersion_]; + assert(frdVersion_ <= edm::streamer::FRDHeaderMaxVersion); + int headerSize = edm::streamer::FRDHeaderVersionSize[frdVersion_]; int expectedSize = headerSize; int nFeds = frdVersion_ < 3 ? 1024 : FEDNumbering::lastFEDId() + 1; @@ -156,7 +158,7 @@ void RawEventOutputModuleForBU::write(edm::EventForOutput const& e) { } // create the FRDEventMsgView and use the template consumer to write it out - FRDEventMsgView msg(workBuffer.get()->data()); + edm::streamer::FRDEventMsgView msg(workBuffer.get()->data()); writtensize += msg.size(); templateConsumer_->doOutputEvent(msg); diff --git a/EventFilter/Utilities/src/DAQSourceModelsFRD.cc b/EventFilter/Utilities/src/DAQSourceModelsFRD.cc index 2784cef60ec55..22afae18caa4c 100644 --- a/EventFilter/Utilities/src/DAQSourceModelsFRD.cc +++ b/EventFilter/Utilities/src/DAQSourceModelsFRD.cc @@ -29,6 +29,8 @@ #include "DataFormats/Provenance/interface/Timestamp.h" #include "EventFilter/Utilities/interface/crc32c.h" +using namespace edm::streamer; + void DataModeFRD::readEvent(edm::EventPrincipal& eventPrincipal) { std::unique_ptr rawData(new FEDRawDataCollection); bool tcdsInRange; diff --git a/EventFilter/Utilities/src/DAQSourceModelsScoutingRun3.cc b/EventFilter/Utilities/src/DAQSourceModelsScoutingRun3.cc index f856fdbed66ef..fff4240566716 100644 --- a/EventFilter/Utilities/src/DAQSourceModelsScoutingRun3.cc +++ b/EventFilter/Utilities/src/DAQSourceModelsScoutingRun3.cc @@ -1,5 +1,7 @@ #include "EventFilter//Utilities/interface/DAQSourceModelsScoutingRun3.h" +using namespace edm::streamer; + void DataModeScoutingRun3::makeDirectoryEntries(std::vector const& baseDirs, std::vector const& numSources, std::string const& runDir) { diff --git a/EventFilter/Utilities/src/EvFDaqDirector.cc b/EventFilter/Utilities/src/EvFDaqDirector.cc index 2344195c6efd9..1715780e74bf8 100644 --- a/EventFilter/Utilities/src/EvFDaqDirector.cc +++ b/EventFilter/Utilities/src/EvFDaqDirector.cc @@ -30,6 +30,7 @@ //#define DEBUG using namespace jsoncollector; +using namespace edm::streamer; namespace evf { diff --git a/EventFilter/Utilities/src/FedRawDataInputSource.cc b/EventFilter/Utilities/src/FedRawDataInputSource.cc index ad3b51661cd64..91feced0591d1 100644 --- a/EventFilter/Utilities/src/FedRawDataInputSource.cc +++ b/EventFilter/Utilities/src/FedRawDataInputSource.cc @@ -47,6 +47,7 @@ #include "EventFilter/Utilities/interface/reader.h" using namespace evf::FastMonState; +using namespace edm::streamer; FedRawDataInputSource::FedRawDataInputSource(edm::ParameterSet const& pset, edm::InputSourceDescription const& desc) : edm::RawInputSource(pset, desc), diff --git a/IOPool/Streamer/bin/CalcAdler32.cpp b/IOPool/Streamer/bin/CalcAdler32.cpp index 2280a9e2110ce..21ec335bdc82c 100644 --- a/IOPool/Streamer/bin/CalcAdler32.cpp +++ b/IOPool/Streamer/bin/CalcAdler32.cpp @@ -8,6 +8,8 @@ #include int main(int argc, char* argv[]) { + using namespace edm::streamer; + if (argc < 2) { std::cerr << "No command line argument given, expected path/filename.\n"; return 1; diff --git a/IOPool/Streamer/bin/CatStreamerFiles.cpp b/IOPool/Streamer/bin/CatStreamerFiles.cpp index b42a9a8a35251..8902ba66cf936 100644 --- a/IOPool/Streamer/bin/CatStreamerFiles.cpp +++ b/IOPool/Streamer/bin/CatStreamerFiles.cpp @@ -9,6 +9,7 @@ // Utility to concatenate streamer files outside of the framework // Mimics the behavior of DAQ // Largely copied from DiagStreamerFile +using namespace edm::streamer; void help(); void mergefile(StreamerOutputFile&, std::string const&, bool); @@ -45,7 +46,7 @@ void mergefile(StreamerOutputFile& stream_output, std::string const& filename, b uint32 num_events(0); try { - edm::StreamerInputFile stream_reader(filename); + StreamerInputFile stream_reader(filename); std::cout << "Trying to Read The Init message from Streamer File: " << std::endl << filename << std::endl; InitMsgView const* init = stream_reader.startMessage(); @@ -56,7 +57,7 @@ void mergefile(StreamerOutputFile& stream_output, std::string const& filename, b std::cout << "Trying to read the Event messages" << std::endl; EventMsgView const* eview(nullptr); - while (edm::StreamerInputFile::Next::kEvent == stream_reader.next()) { + while (StreamerInputFile::Next::kEvent == stream_reader.next()) { eview = stream_reader.currentRecord(); ++num_events; stream_output.write(*eview); diff --git a/IOPool/Streamer/bin/DiagStreamerFile.cpp b/IOPool/Streamer/bin/DiagStreamerFile.cpp index bc60a60ada633..f701f077c10f3 100644 --- a/IOPool/Streamer/bin/DiagStreamerFile.cpp +++ b/IOPool/Streamer/bin/DiagStreamerFile.cpp @@ -36,16 +36,19 @@ #include #include -bool compares_bad(EventMsgView const* eview1, EventMsgView const* eview2); -bool uncompressBuffer(unsigned char* inputBuffer, - unsigned int inputSize, - std::vector& outputBuffer, - unsigned int expectedFullSize); -bool test_chksum(EventMsgView const* eview); -bool test_uncompress(EventMsgView const* eview, std::vector& dest); -void readfile(std::string filename, std::string outfile); -void help(); +using namespace edm::streamer; +namespace { + bool compares_bad(EventMsgView const* eview1, EventMsgView const* eview2); + bool uncompressBuffer(unsigned char* inputBuffer, + unsigned int inputSize, + std::vector& outputBuffer, + unsigned int expectedFullSize); + bool test_chksum(EventMsgView const* eview); + bool test_uncompress(EventMsgView const* eview, std::vector& dest); + void readfile(std::string filename, std::string outfile); + void help(); +} // namespace //========================================================================== int main(int argc, char* argv[]) { if (argc < 2) { @@ -66,231 +69,233 @@ int main(int argc, char* argv[]) { return 0; } -//========================================================================== -void help() { - std::cout << "Usage: DiagStreamerFile streamer_file_name" - << " [output_file_name]" << std::endl; -} -//========================================================================== -void readfile(std::string filename, std::string outfile) { - uint32 num_events(0); - uint32 num_badevents(0); - uint32 num_baduncompress(0); - uint32 num_badchksum(0); - uint32 num_goodevents(0); - uint32 num_duplevents(0); - std::vector compress_buffer(7000000); - std::map seenEventMap; - bool output(false); - if (outfile != "/dev/null") { - output = true; +namespace { + //========================================================================== + void help() { + std::cout << "Usage: DiagStreamerFile streamer_file_name" + << " [output_file_name]" << std::endl; } - StreamerOutputFile stream_output(outfile); - try { - // ----------- init - edm::StreamerInputFile stream_reader(filename); - //if(output) StreamerOutputFile stream_output(outfile); - - std::cout << "Trying to Read The Init message from Streamer File: " << std::endl << filename << std::endl; - InitMsgView const* init = stream_reader.startMessage(); - std::cout << "\n\n-------------INIT Message---------------------" << std::endl; - std::cout << "Dump the Init Message from Streamer:-" << std::endl; - dumpInitView(init); - if (output) { - stream_output.write(*init); + //========================================================================== + void readfile(std::string filename, std::string outfile) { + uint32 num_events(0); + uint32 num_badevents(0); + uint32 num_baduncompress(0); + uint32 num_badchksum(0); + uint32 num_goodevents(0); + uint32 num_duplevents(0); + std::vector compress_buffer(7000000); + std::map seenEventMap; + bool output(false); + if (outfile != "/dev/null") { + output = true; } + StreamerOutputFile stream_output(outfile); + try { + // ----------- init + StreamerInputFile stream_reader(filename); + //if(output) StreamerOutputFile stream_output(outfile); - // ------- event - std::cout << "\n\n-------------EVENT Messages-------------------" << std::endl; + std::cout << "Trying to Read The Init message from Streamer File: " << std::endl << filename << std::endl; + InitMsgView const* init = stream_reader.startMessage(); + std::cout << "\n\n-------------INIT Message---------------------" << std::endl; + std::cout << "Dump the Init Message from Streamer:-" << std::endl; + dumpInitView(init); + if (output) { + stream_output.write(*init); + } - bool first_event(true); - std::unique_ptr firstEvtView(nullptr); - std::vector savebuf(0); - EventMsgView const* eview(nullptr); - seenEventMap.clear(); + // ------- event + std::cout << "\n\n-------------EVENT Messages-------------------" << std::endl; - while (edm::StreamerInputFile::Next::kEvent == stream_reader.next()) { - eview = stream_reader.currentRecord(); - ++num_events; - bool good_event(true); - if (seenEventMap.find(eview->event()) == seenEventMap.end()) { - seenEventMap.insert(std::make_pair(eview->event(), 1)); - } else { - ++seenEventMap[eview->event()]; - ++num_duplevents; - std::cout << "??????? duplicate event Id for count " << num_events << " event number " << eview->event() - << " seen " << seenEventMap[eview->event()] << " times" << std::endl; - } - if (first_event) { - std::cout << "----------dumping first EVENT-----------" << std::endl; - dumpEventView(eview); - first_event = false; - unsigned char* src = (unsigned char*)eview->startAddress(); - unsigned int srcSize = eview->size(); - savebuf.resize(srcSize); - std::copy(src, src + srcSize, &(savebuf)[0]); - firstEvtView = std::make_unique(&(savebuf)[0]); - //firstEvtView, reset(new EventMsgView((void*)eview->startAddress())); - if (!test_chksum(eview)) { - std::cout << "checksum error for count " << num_events << " event number " << eview->event() - << " from host name " << eview->hostName() << std::endl; - ++num_badchksum; - std::cout << "----------dumping bad checksum EVENT-----------" << std::endl; - dumpEventView(eview); - good_event = false; - } - if (!test_uncompress(eview, compress_buffer)) { - std::cout << "uncompress error for count " << num_events << " event number " << firstEvtView->event() - << std::endl; - ++num_baduncompress; - std::cout << "----------dumping bad uncompress EVENT-----------" << std::endl; - dumpEventView(firstEvtView.get()); - good_event = false; - } - } else { - if (compares_bad(firstEvtView.get(), eview)) { - std::cout << "Bad event at count " << num_events << " dumping event " << std::endl - << "----------dumping bad EVENT-----------" << std::endl; - dumpEventView(eview); - ++num_badevents; - good_event = false; + bool first_event(true); + std::unique_ptr firstEvtView(nullptr); + std::vector savebuf(0); + EventMsgView const* eview(nullptr); + seenEventMap.clear(); + + while (StreamerInputFile::Next::kEvent == stream_reader.next()) { + eview = stream_reader.currentRecord(); + ++num_events; + bool good_event(true); + if (seenEventMap.find(eview->event()) == seenEventMap.end()) { + seenEventMap.insert(std::make_pair(eview->event(), 1)); + } else { + ++seenEventMap[eview->event()]; + ++num_duplevents; + std::cout << "??????? duplicate event Id for count " << num_events << " event number " << eview->event() + << " seen " << seenEventMap[eview->event()] << " times" << std::endl; } - if (!test_chksum(eview)) { - std::cout << "checksum error for count " << num_events << " event number " << eview->event() - << " from host name " << eview->hostName() << std::endl; - ++num_badchksum; - std::cout << "----------dumping bad checksum EVENT-----------" << std::endl; + if (first_event) { + std::cout << "----------dumping first EVENT-----------" << std::endl; dumpEventView(eview); - good_event = false; + first_event = false; + unsigned char* src = (unsigned char*)eview->startAddress(); + unsigned int srcSize = eview->size(); + savebuf.resize(srcSize); + std::copy(src, src + srcSize, &(savebuf)[0]); + firstEvtView = std::make_unique(&(savebuf)[0]); + //firstEvtView, reset(new EventMsgView((void*)eview->startAddress())); + if (!test_chksum(eview)) { + std::cout << "checksum error for count " << num_events << " event number " << eview->event() + << " from host name " << eview->hostName() << std::endl; + ++num_badchksum; + std::cout << "----------dumping bad checksum EVENT-----------" << std::endl; + dumpEventView(eview); + good_event = false; + } + if (!test_uncompress(eview, compress_buffer)) { + std::cout << "uncompress error for count " << num_events << " event number " << firstEvtView->event() + << std::endl; + ++num_baduncompress; + std::cout << "----------dumping bad uncompress EVENT-----------" << std::endl; + dumpEventView(firstEvtView.get()); + good_event = false; + } + } else { + if (compares_bad(firstEvtView.get(), eview)) { + std::cout << "Bad event at count " << num_events << " dumping event " << std::endl + << "----------dumping bad EVENT-----------" << std::endl; + dumpEventView(eview); + ++num_badevents; + good_event = false; + } + if (!test_chksum(eview)) { + std::cout << "checksum error for count " << num_events << " event number " << eview->event() + << " from host name " << eview->hostName() << std::endl; + ++num_badchksum; + std::cout << "----------dumping bad checksum EVENT-----------" << std::endl; + dumpEventView(eview); + good_event = false; + } + if (!test_uncompress(eview, compress_buffer)) { + std::cout << "uncompress error for count " << num_events << " event number " << eview->event() << std::endl; + ++num_baduncompress; + std::cout << "----------dumping bad uncompress EVENT-----------" << std::endl; + dumpEventView(eview); + good_event = false; + } } - if (!test_uncompress(eview, compress_buffer)) { - std::cout << "uncompress error for count " << num_events << " event number " << eview->event() << std::endl; - ++num_baduncompress; - std::cout << "----------dumping bad uncompress EVENT-----------" << std::endl; - dumpEventView(eview); - good_event = false; + if (good_event) { + if (output) { + ++num_goodevents; + stream_output.write(*eview); + } + //dumpEventView(eview); } - } - if (good_event) { - if (output) { - ++num_goodevents; - stream_output.write(*eview); + if ((num_events % 50) == 0) { + std::cout << "Read " << num_events << " events, and " << num_badevents << " events with bad headers, and " + << num_badchksum << " events with bad check sum, and " << num_baduncompress + << " events with bad uncompress" << std::endl; + if (output) + std::cout << "Wrote " << num_goodevents << " good events " << std::endl; } - //dumpEventView(eview); - } - if ((num_events % 50) == 0) { - std::cout << "Read " << num_events << " events, and " << num_badevents << " events with bad headers, and " - << num_badchksum << " events with bad check sum, and " << num_baduncompress - << " events with bad uncompress" << std::endl; - if (output) - std::cout << "Wrote " << num_goodevents << " good events " << std::endl; } - } - std::cout << std::endl - << "------------END--------------" << std::endl - << "read " << num_events << " events" << std::endl - << "and " << num_badevents << " events with bad headers" << std::endl - << "and " << num_badchksum << " events with bad check sum" << std::endl - << "and " << num_baduncompress << " events with bad uncompress" << std::endl - << "and " << num_duplevents << " duplicated event Id" << std::endl; + std::cout << std::endl + << "------------END--------------" << std::endl + << "read " << num_events << " events" << std::endl + << "and " << num_badevents << " events with bad headers" << std::endl + << "and " << num_badchksum << " events with bad check sum" << std::endl + << "and " << num_baduncompress << " events with bad uncompress" << std::endl + << "and " << num_duplevents << " duplicated event Id" << std::endl; - if (output) { - std::cout << "Wrote " << num_goodevents << " good events " << std::endl; - } + if (output) { + std::cout << "Wrote " << num_goodevents << " good events " << std::endl; + } - } catch (cms::Exception& e) { - std::cerr << "Exception caught: " << e.what() << std::endl - << "After reading " << num_events << " events, and " << num_badevents << " events with bad headers" - << std::endl - << "and " << num_badchksum << " events with bad check sum" << std::endl - << "and " << num_baduncompress << " events with bad uncompress" << std::endl - << "and " << num_duplevents << " duplicated event Id" << std::endl; + } catch (cms::Exception& e) { + std::cerr << "Exception caught: " << e.what() << std::endl + << "After reading " << num_events << " events, and " << num_badevents << " events with bad headers" + << std::endl + << "and " << num_badchksum << " events with bad check sum" << std::endl + << "and " << num_baduncompress << " events with bad uncompress" << std::endl + << "and " << num_duplevents << " duplicated event Id" << std::endl; + } } -} -//========================================================================== -bool compares_bad(EventMsgView const* eview1, EventMsgView const* eview2) { - bool is_bad(false); - if (eview1->code() != eview2->code()) { - std::cout << "non-matching EVENT message code " << std::endl; - is_bad = true; - } - if (eview1->protocolVersion() != eview2->protocolVersion()) { - std::cout << "non-matching EVENT message protocol version" << std::endl; - is_bad = true; - } - if (eview1->run() != eview2->run()) { - std::cout << "non-matching run number " << std::endl; - is_bad = true; - } - if (eview1->lumi() != eview2->lumi()) { - std::cout << "non-matching lumi number" << std::endl; - is_bad = true; - } - if (eview1->outModId() != eview2->outModId()) { - std::cout << "non-matching output module id" << std::endl; - is_bad = true; - } - if (eview1->hltCount() != eview2->hltCount()) { - std::cout << "non-matching HLT count" << std::endl; - is_bad = true; - } - if (eview1->l1Count() != eview2->l1Count()) { - std::cout << "non-matching L1 count" << std::endl; - is_bad = true; + //========================================================================== + bool compares_bad(EventMsgView const* eview1, EventMsgView const* eview2) { + bool is_bad(false); + if (eview1->code() != eview2->code()) { + std::cout << "non-matching EVENT message code " << std::endl; + is_bad = true; + } + if (eview1->protocolVersion() != eview2->protocolVersion()) { + std::cout << "non-matching EVENT message protocol version" << std::endl; + is_bad = true; + } + if (eview1->run() != eview2->run()) { + std::cout << "non-matching run number " << std::endl; + is_bad = true; + } + if (eview1->lumi() != eview2->lumi()) { + std::cout << "non-matching lumi number" << std::endl; + is_bad = true; + } + if (eview1->outModId() != eview2->outModId()) { + std::cout << "non-matching output module id" << std::endl; + is_bad = true; + } + if (eview1->hltCount() != eview2->hltCount()) { + std::cout << "non-matching HLT count" << std::endl; + is_bad = true; + } + if (eview1->l1Count() != eview2->l1Count()) { + std::cout << "non-matching L1 count" << std::endl; + is_bad = true; + } + return is_bad; } - return is_bad; -} -//========================================================================== -bool test_chksum(EventMsgView const* eview) { - uint32_t adler32_chksum = cms::Adler32((char const*)eview->eventData(), eview->eventLength()); - //std::cout << "Adler32 checksum of event = " << adler32_chksum << std::endl; - //std::cout << "Adler32 checksum from header = " << eview->adler32_chksum() << std::endl; - //std::cout << "event from host name = " << eview->hostName() << std::endl; - if ((uint32)adler32_chksum != eview->adler32_chksum()) { - std::cout << "Bad chekcsum: Adler32 checksum of event data = " << adler32_chksum - << " from header = " << eview->adler32_chksum() << " host name = " << eview->hostName() << std::endl; - return false; + //========================================================================== + bool test_chksum(EventMsgView const* eview) { + uint32_t adler32_chksum = cms::Adler32((char const*)eview->eventData(), eview->eventLength()); + //std::cout << "Adler32 checksum of event = " << adler32_chksum << std::endl; + //std::cout << "Adler32 checksum from header = " << eview->adler32_chksum() << std::endl; + //std::cout << "event from host name = " << eview->hostName() << std::endl; + if ((uint32)adler32_chksum != eview->adler32_chksum()) { + std::cout << "Bad chekcsum: Adler32 checksum of event data = " << adler32_chksum + << " from header = " << eview->adler32_chksum() << " host name = " << eview->hostName() << std::endl; + return false; + } + return true; } - return true; -} -//========================================================================== -bool test_uncompress(EventMsgView const* eview, std::vector& dest) { - unsigned long origsize = eview->origDataSize(); - bool success = false; - if (origsize != 0 && origsize != 78) { - // compressed - success = uncompressBuffer( - const_cast((unsigned char const*)eview->eventData()), eview->eventLength(), dest, origsize); - } else { - // uncompressed anyway - success = true; + //========================================================================== + bool test_uncompress(EventMsgView const* eview, std::vector& dest) { + unsigned long origsize = eview->origDataSize(); + bool success = false; + if (origsize != 0 && origsize != 78) { + // compressed + success = uncompressBuffer( + const_cast((unsigned char const*)eview->eventData()), eview->eventLength(), dest, origsize); + } else { + // uncompressed anyway + success = true; + } + return success; } - return success; -} -//========================================================================== -bool uncompressBuffer(unsigned char* inputBuffer, - unsigned int inputSize, - std::vector& outputBuffer, - unsigned int expectedFullSize) { - unsigned long origSize = expectedFullSize; - unsigned long uncompressedSize = expectedFullSize * 1.1; - outputBuffer.resize(uncompressedSize); - int ret = uncompress(&outputBuffer[0], &uncompressedSize, inputBuffer, inputSize); - if (ret == Z_OK) { - // check the length against original uncompressed length - if (origSize != uncompressedSize) { - std::cout << "Problem with uncompress, original size = " << origSize << " uncompress size = " << uncompressedSize - << std::endl; + //========================================================================== + bool uncompressBuffer(unsigned char* inputBuffer, + unsigned int inputSize, + std::vector& outputBuffer, + unsigned int expectedFullSize) { + unsigned long origSize = expectedFullSize; + unsigned long uncompressedSize = expectedFullSize * 1.1; + outputBuffer.resize(uncompressedSize); + int ret = uncompress(&outputBuffer[0], &uncompressedSize, inputBuffer, inputSize); + if (ret == Z_OK) { + // check the length against original uncompressed length + if (origSize != uncompressedSize) { + std::cout << "Problem with uncompress, original size = " << origSize + << " uncompress size = " << uncompressedSize << std::endl; + return false; + } + } else { + std::cout << "Problem with uncompress, return value = " << ret << std::endl; return false; } - } else { - std::cout << "Problem with uncompress, return value = " << ret << std::endl; - return false; + return true; } - return true; -} +} // namespace diff --git a/IOPool/Streamer/interface/ClassFiller.h b/IOPool/Streamer/interface/ClassFiller.h index 7abe6a2298d8f..2820724d6acfd 100644 --- a/IOPool/Streamer/interface/ClassFiller.h +++ b/IOPool/Streamer/interface/ClassFiller.h @@ -11,7 +11,7 @@ #include #include -namespace edm { +namespace edm::streamer { class RootDebug { public: RootDebug(int flevel, int rlevel) : flevel_(flevel), rlevel_(rlevel), old_(gDebug) { @@ -33,6 +33,6 @@ namespace edm { TClass* getTClass(const std::type_info& ti); bool loadCap(const std::string& name, std::vector& missingDictionaries); void doBuildRealData(const std::string& name); -} // namespace edm +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/DumpTools.h b/IOPool/Streamer/interface/DumpTools.h index aa8cd5e4fbdae..61670c1f4595b 100644 --- a/IOPool/Streamer/interface/DumpTools.h +++ b/IOPool/Streamer/interface/DumpTools.h @@ -9,17 +9,17 @@ #include "IOPool/Streamer/interface/InitMessage.h" #include "IOPool/Streamer/interface/EventMessage.h" #include "IOPool/Streamer/interface/FRDEventMessage.h" - -void dumpInitHeader(const InitMsgView* view); -void dumpInitView(const InitMsgView* view); -void dumpStartMsg(const InitMsgView* view); -void dumpInitVerbose(const InitMsgView* view); -void dumpInit(uint8* buf); -void printBits(unsigned char c); -void dumpEventHeader(const EventMsgView* eview); -void dumpEventView(const EventMsgView* eview); -void dumpEventIndex(const EventMsgView* eview); -void dumpEvent(uint8* buf); -void dumpFRDEventView(const FRDEventMsgView* fview); - +namespace edm::streamer { + void dumpInitHeader(const InitMsgView* view); + void dumpInitView(const InitMsgView* view); + void dumpStartMsg(const InitMsgView* view); + void dumpInitVerbose(const InitMsgView* view); + void dumpInit(uint8* buf); + void printBits(unsigned char c); + void dumpEventHeader(const EventMsgView* eview); + void dumpEventView(const EventMsgView* eview); + void dumpEventIndex(const EventMsgView* eview); + void dumpEvent(uint8* buf); + void dumpFRDEventView(const FRDEventMsgView* fview); +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/EventMessage.h b/IOPool/Streamer/interface/EventMessage.h index be9b108fe20f6..1fdb9499a8e08 100644 --- a/IOPool/Streamer/interface/EventMessage.h +++ b/IOPool/Streamer/interface/EventMessage.h @@ -55,62 +55,62 @@ Protocol Version 11: identical to version 10, except event changed from 4 bytes #include "IOPool/Streamer/interface/MsgTools.h" #include "IOPool/Streamer/interface/MsgHeader.h" - -// ----------------------- event message ------------------------ - -struct EventHeader { - Header header_; - uint8 protocolVersion_; - char_uint32 run_; - char_uint64 event_; - char_uint32 lumi_; - char_uint32 origDataSize_; - char_uint32 outModId_; - char_uint32 droppedEventsCount_; -}; - -class EventMsgView { -public: - EventMsgView(void* buf); - - uint32 code() const { return head_.code(); } - uint32 size() const { return head_.size(); } - - const uint8* eventData() const { return event_start_; } - uint8* startAddress() const { return buf_; } - uint32 eventLength() const { return event_len_; } - uint32 headerSize() const { return event_start_ - buf_; } - uint32 protocolVersion() const; - uint32 run() const; - uint64 event() const; - uint32 lumi() const; - uint32 origDataSize() const; - uint32 outModId() const; - uint32 droppedEventsCount() const; - - void l1TriggerBits(std::vector& put_here) const; - void hltTriggerBits(uint8* put_here) const; - - uint32 hltCount() const { return hlt_bits_count_; } - uint32 l1Count() const { return l1_bits_count_; } - uint32 adler32_chksum() const { return adler32_chksum_; } - std::string hostName() const; - uint32 hostName_len() const { return host_name_len_; } - -private: - uint8* buf_; - HeaderView head_; - - uint8* hlt_bits_start_; - uint32 hlt_bits_count_; - uint8* l1_bits_start_; - uint32 l1_bits_count_; - uint8* event_start_; - uint32 event_len_; - uint32 adler32_chksum_; - uint8* host_name_start_; - uint32 host_name_len_; - bool v2Detected_; -}; - +namespace edm::streamer { + // ----------------------- event message ------------------------ + + struct EventHeader { + Header header_; + uint8 protocolVersion_; + char_uint32 run_; + char_uint64 event_; + char_uint32 lumi_; + char_uint32 origDataSize_; + char_uint32 outModId_; + char_uint32 droppedEventsCount_; + }; + + class EventMsgView { + public: + EventMsgView(void* buf); + + uint32 code() const { return head_.code(); } + uint32 size() const { return head_.size(); } + + const uint8* eventData() const { return event_start_; } + uint8* startAddress() const { return buf_; } + uint32 eventLength() const { return event_len_; } + uint32 headerSize() const { return event_start_ - buf_; } + uint32 protocolVersion() const; + uint32 run() const; + uint64 event() const; + uint32 lumi() const; + uint32 origDataSize() const; + uint32 outModId() const; + uint32 droppedEventsCount() const; + + void l1TriggerBits(std::vector& put_here) const; + void hltTriggerBits(uint8* put_here) const; + + uint32 hltCount() const { return hlt_bits_count_; } + uint32 l1Count() const { return l1_bits_count_; } + uint32 adler32_chksum() const { return adler32_chksum_; } + std::string hostName() const; + uint32 hostName_len() const { return host_name_len_; } + + private: + uint8* buf_; + HeaderView head_; + + uint8* hlt_bits_start_; + uint32 hlt_bits_count_; + uint8* l1_bits_start_; + uint32 l1_bits_count_; + uint8* event_start_; + uint32 event_len_; + uint32 adler32_chksum_; + uint8* host_name_start_; + uint32 host_name_len_; + bool v2Detected_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/EventMsgBuilder.h b/IOPool/Streamer/interface/EventMsgBuilder.h index d222e0790d629..04600ca99e79f 100644 --- a/IOPool/Streamer/interface/EventMsgBuilder.h +++ b/IOPool/Streamer/interface/EventMsgBuilder.h @@ -5,37 +5,38 @@ // ------------------ event message builder ---------------- -class EventMsgBuilder { -public: - EventMsgBuilder(void* buf, - uint32 size, - uint32 run, - uint64 event, - uint32 lumi, - uint32 outModId, - uint32 droppedEventsCount, - std::vector& l1_bits, - uint8* hlt_bits, - uint32 hlt_bit_count, - uint32 adler32_chksum, - const char* host_name); +namespace edm::streamer { + class EventMsgBuilder { + public: + EventMsgBuilder(void* buf, + uint32 size, + uint32 run, + uint64 event, + uint32 lumi, + uint32 outModId, + uint32 droppedEventsCount, + std::vector& l1_bits, + uint8* hlt_bits, + uint32 hlt_bit_count, + uint32 adler32_chksum, + const char* host_name); - void setOrigDataSize(uint32); - uint8* startAddress() const { return buf_; } - void setEventLength(uint32 len); - void setBufAddr(uint8* buf_addr) { buf_ = buf_addr; } - void setEventAddr(uint8* event_addr) { event_addr_ = event_addr; } - uint8* eventAddr() const { return event_addr_; } - uint32 headerSize() const { return event_addr_ - buf_; } - uint32 size() const; - uint32 bufferSize() const { return size_; } + void setOrigDataSize(uint32); + uint8* startAddress() const { return buf_; } + void setEventLength(uint32 len); + void setBufAddr(uint8* buf_addr) { buf_ = buf_addr; } + void setEventAddr(uint8* event_addr) { event_addr_ = event_addr; } + uint8* eventAddr() const { return event_addr_; } + uint32 headerSize() const { return event_addr_ - buf_; } + uint32 size() const; + uint32 bufferSize() const { return size_; } - static uint32 computeHeaderSize(uint32 l1t_bit_count, uint32 hlt_bit_count); - -private: - uint8* buf_; - uint32 size_; - uint8* event_addr_; -}; + static uint32 computeHeaderSize(uint32 l1t_bit_count, uint32 hlt_bit_count); + private: + uint8* buf_; + uint32 size_; + uint8* event_addr_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/FRDEventMessage.h b/IOPool/Streamer/interface/FRDEventMessage.h index 8087389c42c61..729a958171b5e 100644 --- a/IOPool/Streamer/interface/FRDEventMessage.h +++ b/IOPool/Streamer/interface/FRDEventMessage.h @@ -71,102 +71,103 @@ #include -struct FRDEventHeader_V6 { - uint16 version_; - uint16 flags_; - uint32 run_; - uint32 lumi_; - uint32 event_; - uint32 eventSize_; - uint32 crc32c_; -}; - -struct FRDEventHeader_V5 { - uint32 version_; - uint32 run_; - uint32 lumi_; - uint32 event_; - uint32 eventSize_; - uint32 crc32c_; -}; - -struct FRDEventHeader_V4 { - uint32 version_; - uint32 run_; - uint32 lumi_; - uint32 eventLow_; - uint32 eventHigh_; - uint32 eventSize_; - uint32 paddingSize_; - uint32 adler32_; -}; - -struct FRDEventHeader_V3 { - uint32 version_; - uint32 run_; - uint32 lumi_; - uint32 event_; - uint32 eventSize_; - uint32 paddingSize_; - uint32 adler32_; -}; - -struct FRDEventHeader_V2 { - uint32 version_; - uint32 run_; - uint32 lumi_; - uint32 event_; -}; - -struct FRDEventHeader_V1 { - uint32 run_; - uint32 event_; -}; - -const uint16 FRDEVENT_MASK_ISGENDATA = 1; - -constexpr size_t FRDHeaderMaxVersion = 6; -constexpr std::array FRDHeaderVersionSize{{0, - 2 * sizeof(uint32), - (4 + 1024) * sizeof(uint32), - 7 * sizeof(uint32), - 8 * sizeof(uint32), - 6 * sizeof(uint32), - 6 * sizeof(uint32)}}; - -class FRDEventMsgView { -public: - FRDEventMsgView(void* buf); - - uint8* startAddress() const { return buf_; } - void* payload() const { return payload_; } - uint32 size() const { return size_; } - - uint16 version() const { return version_; } - uint16 flags() const { return flags_; } - uint32 run() const { return run_; } - uint32 lumi() const { return lumi_; } - uint64 event() const { return event_; } - uint32 eventSize() const { return eventSize_; } - uint32 paddingSize() const { return paddingSize_; } - uint32 adler32() const { return adler32_; } - uint32 crc32c() const { return crc32c_; } - - bool isRealData() const { return !(flags_ & FRDEVENT_MASK_ISGENDATA); } - -private: - uint8* buf_; - void* payload_; - uint32 size_; - uint16 version_; - uint16 flags_; - uint32 run_; - uint32 lumi_; - uint64 event_; - uint32 eventSize_; - uint32 paddingSize_; - uint32 adler32_; - uint32 crc32c_; -}; - +namespace edm::streamer { + struct FRDEventHeader_V6 { + uint16 version_; + uint16 flags_; + uint32 run_; + uint32 lumi_; + uint32 event_; + uint32 eventSize_; + uint32 crc32c_; + }; + + struct FRDEventHeader_V5 { + uint32 version_; + uint32 run_; + uint32 lumi_; + uint32 event_; + uint32 eventSize_; + uint32 crc32c_; + }; + + struct FRDEventHeader_V4 { + uint32 version_; + uint32 run_; + uint32 lumi_; + uint32 eventLow_; + uint32 eventHigh_; + uint32 eventSize_; + uint32 paddingSize_; + uint32 adler32_; + }; + + struct FRDEventHeader_V3 { + uint32 version_; + uint32 run_; + uint32 lumi_; + uint32 event_; + uint32 eventSize_; + uint32 paddingSize_; + uint32 adler32_; + }; + + struct FRDEventHeader_V2 { + uint32 version_; + uint32 run_; + uint32 lumi_; + uint32 event_; + }; + + struct FRDEventHeader_V1 { + uint32 run_; + uint32 event_; + }; + + const uint16 FRDEVENT_MASK_ISGENDATA = 1; + + constexpr size_t FRDHeaderMaxVersion = 6; + constexpr std::array FRDHeaderVersionSize{{0, + 2 * sizeof(uint32), + (4 + 1024) * sizeof(uint32), + 7 * sizeof(uint32), + 8 * sizeof(uint32), + 6 * sizeof(uint32), + 6 * sizeof(uint32)}}; + + class FRDEventMsgView { + public: + FRDEventMsgView(void* buf); + + uint8* startAddress() const { return buf_; } + void* payload() const { return payload_; } + uint32 size() const { return size_; } + + uint16 version() const { return version_; } + uint16 flags() const { return flags_; } + uint32 run() const { return run_; } + uint32 lumi() const { return lumi_; } + uint64 event() const { return event_; } + uint32 eventSize() const { return eventSize_; } + uint32 paddingSize() const { return paddingSize_; } + uint32 adler32() const { return adler32_; } + uint32 crc32c() const { return crc32c_; } + + bool isRealData() const { return !(flags_ & FRDEVENT_MASK_ISGENDATA); } + + private: + uint8* buf_; + void* payload_; + uint32 size_; + uint16 version_; + uint16 flags_; + uint32 run_; + uint32 lumi_; + uint64 event_; + uint32 eventSize_; + uint32 paddingSize_; + uint32 adler32_; + uint32 crc32c_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/FRDFileHeader.h b/IOPool/Streamer/interface/FRDFileHeader.h index 32a5c5c629bbf..4ad388f8f5f2a 100644 --- a/IOPool/Streamer/interface/FRDFileHeader.h +++ b/IOPool/Streamer/interface/FRDFileHeader.h @@ -18,77 +18,78 @@ * * */ -constexpr std::array FRDFileHeader_id{{0x52, 0x41, 0x57, 0x5f}}; -constexpr std::array FRDFileVersion_1{{0x30, 0x30, 0x30, 0x31}}; -constexpr std::array FRDFileVersion_2{{0x30, 0x30, 0x30, 0x32}}; +namespace edm::streamer { + constexpr std::array FRDFileHeader_id{{0x52, 0x41, 0x57, 0x5f}}; + constexpr std::array FRDFileVersion_1{{0x30, 0x30, 0x30, 0x31}}; + constexpr std::array FRDFileVersion_2{{0x30, 0x30, 0x30, 0x32}}; -struct FRDFileHeaderIdentifier { - FRDFileHeaderIdentifier(const std::array& id, const std::array& version) - : id_(id), version_(version) {} + struct FRDFileHeaderIdentifier { + FRDFileHeaderIdentifier(const std::array& id, const std::array& version) + : id_(id), version_(version) {} - std::array id_; - std::array version_; -}; + std::array id_; + std::array version_; + }; -struct FRDFileHeaderContent_v1 { - FRDFileHeaderContent_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize) - : headerSize_(sizeof(FRDFileHeaderContent_v1) + sizeof(FRDFileHeaderIdentifier)), - eventCount_(eventCount), - lumiSection_(lumiSection), - fileSize_(fileSize) {} + struct FRDFileHeaderContent_v1 { + FRDFileHeaderContent_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize) + : headerSize_(sizeof(FRDFileHeaderContent_v1) + sizeof(FRDFileHeaderIdentifier)), + eventCount_(eventCount), + lumiSection_(lumiSection), + fileSize_(fileSize) {} - uint16_t headerSize_; - uint16_t eventCount_; - uint32_t lumiSection_; - uint64_t fileSize_; -}; + uint16_t headerSize_; + uint16_t eventCount_; + uint32_t lumiSection_; + uint64_t fileSize_; + }; -struct FRDFileHeader_v1 { - FRDFileHeader_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize) - : id_(FRDFileHeader_id, FRDFileVersion_1), c_(eventCount, lumiSection, fileSize) {} + struct FRDFileHeader_v1 { + FRDFileHeader_v1(uint16_t eventCount, uint32_t lumiSection, uint64_t fileSize) + : id_(FRDFileHeader_id, FRDFileVersion_1), c_(eventCount, lumiSection, fileSize) {} - FRDFileHeaderIdentifier id_; - FRDFileHeaderContent_v1 c_; -}; + FRDFileHeaderIdentifier id_; + FRDFileHeaderContent_v1 c_; + }; -struct FRDFileHeaderContent_v2 { - FRDFileHeaderContent_v2( - uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize) - : headerSize_(sizeof(FRDFileHeaderContent_v2) + sizeof(FRDFileHeaderIdentifier)), - dataType_(dataType), - eventCount_(eventCount), - runNumber_(runNumber), - lumiSection_(lumiSection), - fileSize_(fileSize) {} + struct FRDFileHeaderContent_v2 { + FRDFileHeaderContent_v2( + uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize) + : headerSize_(sizeof(FRDFileHeaderContent_v2) + sizeof(FRDFileHeaderIdentifier)), + dataType_(dataType), + eventCount_(eventCount), + runNumber_(runNumber), + lumiSection_(lumiSection), + fileSize_(fileSize) {} - uint16_t headerSize_; - uint16_t dataType_; - uint32_t eventCount_; - uint32_t runNumber_; - uint32_t lumiSection_; - uint64_t fileSize_; -}; + uint16_t headerSize_; + uint16_t dataType_; + uint32_t eventCount_; + uint32_t runNumber_; + uint32_t lumiSection_; + uint64_t fileSize_; + }; -struct FRDFileHeader_v2 { - FRDFileHeader_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize) - : id_(FRDFileHeader_id, FRDFileVersion_2), c_(dataType, eventCount, runNumber, lumiSection, fileSize) {} + struct FRDFileHeader_v2 { + FRDFileHeader_v2(uint16_t dataType, uint16_t eventCount, uint32_t runNumber, uint32_t lumiSection, uint64_t fileSize) + : id_(FRDFileHeader_id, FRDFileVersion_2), c_(dataType, eventCount, runNumber, lumiSection, fileSize) {} - FRDFileHeaderIdentifier id_; - FRDFileHeaderContent_v2 c_; -}; + FRDFileHeaderIdentifier id_; + FRDFileHeaderContent_v2 c_; + }; -inline uint16_t getFRDFileHeaderVersion(const std::array& id, const std::array& version) { - size_t i; - for (i = 0; i < 4; i++) - if (id[i] != FRDFileHeader_id[i]) - return 0; //not FRD file header - uint16_t ret = 0; - for (i = 0; i < 4; i++) { - if (version[i] > '9' || version[i] < '0') - return 0; //NaN sequence - ret = ret * 10 + (uint16_t)(version[i] - '0'); + inline uint16_t getFRDFileHeaderVersion(const std::array& id, const std::array& version) { + size_t i; + for (i = 0; i < 4; i++) + if (id[i] != FRDFileHeader_id[i]) + return 0; //not FRD file header + uint16_t ret = 0; + for (i = 0; i < 4; i++) { + if (version[i] > '9' || version[i] < '0') + return 0; //NaN sequence + ret = ret * 10 + (uint16_t)(version[i] - '0'); + } + return ret; } - return ret; -} - +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/InitMessage.h b/IOPool/Streamer/interface/InitMessage.h index 2858d367927c8..08d3b945bbfd0 100644 --- a/IOPool/Streamer/interface/InitMessage.h +++ b/IOPool/Streamer/interface/InitMessage.h @@ -36,91 +36,92 @@ Protocol Version 11: identical to version 10, but incremented to keep in sync wi #include "IOPool/Streamer/interface/MsgTools.h" #include "IOPool/Streamer/interface/MsgHeader.h" -struct Version { - Version(const uint8* pset) : protocol_(11) { std::copy(pset, pset + sizeof(pset_id_), &pset_id_[0]); } - - uint8 protocol_; // version of the protocol - unsigned char pset_id_[16]; // parameter set ID -}; - -struct InitHeader { - InitHeader(const Header& h, uint32 run, const Version& v, uint32 init_header_size = 0, uint32 event_header_size = 0) - : header_(h), version_(v) { - convert(run, run_); - convert(init_header_size, init_header_size_); - convert(event_header_size, event_header_size_); - } - - Header header_; - Version version_; - char_uint32 run_; - char_uint32 init_header_size_; - char_uint32 event_header_size_; -}; - -class InitMsgView { -public: - InitMsgView(void* buf); - - uint32 code() const { return head_.code(); } - uint32 size() const { return head_.size(); } - uint8* startAddress() const { return buf_; } - - uint32 run() const; - uint32 protocolVersion() const; - void pset(uint8* put_here) const; - std::string releaseTag() const; - std::string processName() const; - std::string outputModuleLabel() const; - uint32 outputModuleId() const { return outputModuleId_; } - - void hltTriggerNames(Strings& save_here) const; - void hltTriggerSelections(Strings& save_here) const; - void l1TriggerNames(Strings& save_here) const; - - uint32 get_hlt_bit_cnt() const { return hlt_trig_count_; } - uint32 get_l1_bit_cnt() const { return l1_trig_count_; } - - // needed for streamer file - uint32 descLength() const { return desc_len_; } - const uint8* descData() const { return desc_start_; } - uint32 headerSize() const { return desc_start_ - buf_; } - uint32 eventHeaderSize() const; - uint32 adler32_chksum() const { return adler32_chksum_; } - std::string hostName() const; - uint32 hostName_len() const { return host_name_len_; } - -private: - uint8* buf_; - HeaderView head_; - - uint8* release_start_; // points to the string - uint32 release_len_; - - uint8* processName_start_; // points to the string - uint32 processName_len_; - - uint8* outputModuleLabel_start_; // points to the string - uint32 outputModuleLabel_len_; - uint32 outputModuleId_; - - uint8* hlt_trig_start_; // points to the string - uint32 hlt_trig_count_; // number of strings - uint32 hlt_trig_len_; // length of strings character array only - uint8* hlt_select_start_; // points to the string - uint32 hlt_select_count_; // number of strings - uint32 hlt_select_len_; // length of strings character array only - uint8* l1_trig_start_; // points to the string - uint32 l1_trig_count_; // number of strings - uint32 l1_trig_len_; // length of strings character array only - uint32 adler32_chksum_; - uint8* host_name_start_; - uint32 host_name_len_; - - // does not need to be present in the message sent over the network, - // but is needed for the index file - uint8* desc_start_; // point to the bytes - uint32 desc_len_; -}; - +namespace edm::streamer { + struct Version { + Version(const uint8* pset) : protocol_(11) { std::copy(pset, pset + sizeof(pset_id_), &pset_id_[0]); } + + uint8 protocol_; // version of the protocol + unsigned char pset_id_[16]; // parameter set ID + }; + + struct InitHeader { + InitHeader(const Header& h, uint32 run, const Version& v, uint32 init_header_size = 0, uint32 event_header_size = 0) + : header_(h), version_(v) { + convert(run, run_); + convert(init_header_size, init_header_size_); + convert(event_header_size, event_header_size_); + } + + Header header_; + Version version_; + char_uint32 run_; + char_uint32 init_header_size_; + char_uint32 event_header_size_; + }; + + class InitMsgView { + public: + InitMsgView(void* buf); + + uint32 code() const { return head_.code(); } + uint32 size() const { return head_.size(); } + uint8* startAddress() const { return buf_; } + + uint32 run() const; + uint32 protocolVersion() const; + void pset(uint8* put_here) const; + std::string releaseTag() const; + std::string processName() const; + std::string outputModuleLabel() const; + uint32 outputModuleId() const { return outputModuleId_; } + + void hltTriggerNames(Strings& save_here) const; + void hltTriggerSelections(Strings& save_here) const; + void l1TriggerNames(Strings& save_here) const; + + uint32 get_hlt_bit_cnt() const { return hlt_trig_count_; } + uint32 get_l1_bit_cnt() const { return l1_trig_count_; } + + // needed for streamer file + uint32 descLength() const { return desc_len_; } + const uint8* descData() const { return desc_start_; } + uint32 headerSize() const { return desc_start_ - buf_; } + uint32 eventHeaderSize() const; + uint32 adler32_chksum() const { return adler32_chksum_; } + std::string hostName() const; + uint32 hostName_len() const { return host_name_len_; } + + private: + uint8* buf_; + HeaderView head_; + + uint8* release_start_; // points to the string + uint32 release_len_; + + uint8* processName_start_; // points to the string + uint32 processName_len_; + + uint8* outputModuleLabel_start_; // points to the string + uint32 outputModuleLabel_len_; + uint32 outputModuleId_; + + uint8* hlt_trig_start_; // points to the string + uint32 hlt_trig_count_; // number of strings + uint32 hlt_trig_len_; // length of strings character array only + uint8* hlt_select_start_; // points to the string + uint32 hlt_select_count_; // number of strings + uint32 hlt_select_len_; // length of strings character array only + uint8* l1_trig_start_; // points to the string + uint32 l1_trig_count_; // number of strings + uint32 l1_trig_len_; // length of strings character array only + uint32 adler32_chksum_; + uint8* host_name_start_; + uint32 host_name_len_; + + // does not need to be present in the message sent over the network, + // but is needed for the index file + uint8* desc_start_; // point to the bytes + uint32 desc_len_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/InitMsgBuilder.h b/IOPool/Streamer/interface/InitMsgBuilder.h index 90b15ab6c1435..56d4bbbfc22d0 100644 --- a/IOPool/Streamer/interface/InitMsgBuilder.h +++ b/IOPool/Streamer/interface/InitMsgBuilder.h @@ -5,34 +5,34 @@ #include "IOPool/Streamer/interface/InitMessage.h" // ----------------- init ------------------- +namespace edm::streamer { + class InitMsgBuilder { + public: + InitMsgBuilder(void* msg_mem, + uint32 size, + uint32 run, + const Version& v, + const char* release_tag, + const char* process_name, + const char* output_module_label, + uint32 output_module_id, + const Strings& hlt_names, + const Strings& hlt_selections, + const Strings& l1_names, + uint32 adler32_chksum); -class InitMsgBuilder { -public: - InitMsgBuilder(void* msg_mem, - uint32 size, - uint32 run, - const Version& v, - const char* release_tag, - const char* process_name, - const char* output_module_label, - uint32 output_module_id, - const Strings& hlt_names, - const Strings& hlt_selections, - const Strings& l1_names, - uint32 adler32_chksum); - - uint8* startAddress() const { return buf_; } - void setDataLength(uint32 registry_length); - uint8* dataAddress() const { return data_addr_; } - uint32 headerSize() const { return data_addr_ - buf_; } - uint32 size() const; - uint32 run() const; /** Required by EOF Record Builder */ - uint32 bufferSize() const { return size_; } - -private: - uint8* buf_; - uint32 size_; - uint8* data_addr_; -}; + uint8* startAddress() const { return buf_; } + void setDataLength(uint32 registry_length); + uint8* dataAddress() const { return data_addr_; } + uint32 headerSize() const { return data_addr_ - buf_; } + uint32 size() const; + uint32 run() const; /** Required by EOF Record Builder */ + uint32 bufferSize() const { return size_; } + private: + uint8* buf_; + uint32 size_; + uint8* data_addr_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/MsgHeader.h b/IOPool/Streamer/interface/MsgHeader.h index eb84f7747cb36..6568174fedfe1 100644 --- a/IOPool/Streamer/interface/MsgHeader.h +++ b/IOPool/Streamer/interface/MsgHeader.h @@ -3,50 +3,51 @@ #include "IOPool/Streamer/interface/MsgTools.h" // as it is in memory of file -struct Header { - Header(uint32 code, uint32 size) : code_(code) { convert(size, size_); } +namespace edm::streamer { + struct Header { + Header(uint32 code, uint32 size) : code_(code) { convert(size, size_); } - uint8 code_; // type of the message - char_uint32 size_; // of entire message including all headers + uint8 code_; // type of the message + char_uint32 size_; // of entire message including all headers - // 20-Jul-2006, KAB: added enumeration for message types - enum Codes { - INVALID = 0, - INIT = 1, - EVENT = 2, - DONE = 3, // EOFRECORD = 4 is no longer used - HEADER_REQUEST = 5, - EVENT_REQUEST = 6, - CONS_REG_REQUEST = 7, - CONS_REG_RESPONSE = 8, - DQM_INIT = 9, - DQM_EVENT = 10, - DQMEVENT_REQUEST = 11, - INIT_SET = 12, - NEW_INIT_AVAILABLE = 13, - ERROR_EVENT = 14, - FILE_CLOSE_REQUEST = 15, - SPARE1 = 16, - SPARE2 = 17, - PADDING = 255 //reserved for padding + // 20-Jul-2006, KAB: added enumeration for message types + enum Codes { + INVALID = 0, + INIT = 1, + EVENT = 2, + DONE = 3, // EOFRECORD = 4 is no longer used + HEADER_REQUEST = 5, + EVENT_REQUEST = 6, + CONS_REG_REQUEST = 7, + CONS_REG_RESPONSE = 8, + DQM_INIT = 9, + DQM_EVENT = 10, + DQMEVENT_REQUEST = 11, + INIT_SET = 12, + NEW_INIT_AVAILABLE = 13, + ERROR_EVENT = 14, + FILE_CLOSE_REQUEST = 15, + SPARE1 = 16, + SPARE2 = 17, + PADDING = 255 //reserved for padding + }; }; -}; -// as we need to see it -class HeaderView { -public: - HeaderView(void* buf) { - Header* h = (Header*)buf; - code_ = h->code_; - size_ = convert32(h->size_); - } + // as we need to see it + class HeaderView { + public: + HeaderView(void* buf) { + Header* h = (Header*)buf; + code_ = h->code_; + size_ = convert32(h->size_); + } - uint32 code() const { return code_; } - uint32 size() const { return size_; } - -private: - uint32 code_; - uint32 size_; -}; + uint32 code() const { return code_; } + uint32 size() const { return size_; } + private: + uint32 code_; + uint32 size_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/MsgTools.h b/IOPool/Streamer/interface/MsgTools.h index 7411b945c76de..75495a1072c60 100644 --- a/IOPool/Streamer/interface/MsgTools.h +++ b/IOPool/Streamer/interface/MsgTools.h @@ -7,88 +7,89 @@ #include #include "FWCore/Utilities/interface/Algorithms.h" -// could just use the c99 names here from stdint.h -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; -typedef unsigned long long uint64; -typedef unsigned char char_uint64[sizeof(uint64)]; -typedef unsigned char char_uint32[sizeof(uint32)]; -typedef unsigned char char_uint16[sizeof(uint16)]; -typedef std::vector Strings; +namespace edm::streamer { + // could just use the c99 names here from stdint.h + typedef unsigned char uint8; + typedef unsigned short uint16; + typedef unsigned int uint32; + typedef unsigned long long uint64; + typedef unsigned char char_uint64[sizeof(uint64)]; + typedef unsigned char char_uint32[sizeof(uint32)]; + typedef unsigned char char_uint16[sizeof(uint16)]; + typedef std::vector Strings; -inline uint64 convert64(char_uint64 v) { - // first four bytes are code, LSB first - unsigned long long a = v[0], b = v[1], c = v[2], d = v[3]; - unsigned long long e = v[4], f = v[5], g = v[6], h = v[7]; - a |= (b << 8) | (c << 16) | (d << 24) | (e << 32) | (f << 40) | (g << 48) | (h << 56); - return a; -} + inline uint64 convert64(char_uint64 v) { + // first four bytes are code, LSB first + unsigned long long a = v[0], b = v[1], c = v[2], d = v[3]; + unsigned long long e = v[4], f = v[5], g = v[6], h = v[7]; + a |= (b << 8) | (c << 16) | (d << 24) | (e << 32) | (f << 40) | (g << 48) | (h << 56); + return a; + } -inline uint32 convert32(char_uint32 v) { - // first four bytes are code, LSB first - unsigned int a = v[0], b = v[1], c = v[2], d = v[3]; - a |= (b << 8) | (c << 16) | (d << 24); - return a; -} + inline uint32 convert32(char_uint32 v) { + // first four bytes are code, LSB first + unsigned int a = v[0], b = v[1], c = v[2], d = v[3]; + a |= (b << 8) | (c << 16) | (d << 24); + return a; + } -inline uint16 convert16(char_uint16 v) { - // first four bytes are code, LSB first - unsigned int a = v[0], b = v[1]; - a |= (b << 8); - return a; -} + inline uint16 convert16(char_uint16 v) { + // first four bytes are code, LSB first + unsigned int a = v[0], b = v[1]; + a |= (b << 8); + return a; + } -inline void convert(uint32 i, char_uint32 v) { - v[0] = i & 0xff; - v[1] = (i >> 8) & 0xff; - v[2] = (i >> 16) & 0xff; - v[3] = (i >> 24) & 0xff; -} + inline void convert(uint32 i, char_uint32 v) { + v[0] = i & 0xff; + v[1] = (i >> 8) & 0xff; + v[2] = (i >> 16) & 0xff; + v[3] = (i >> 24) & 0xff; + } -inline void convert(uint16 i, char_uint16 v) { - v[0] = i & 0xff; - v[1] = (i >> 8) & 0xff; -} + inline void convert(uint16 i, char_uint16 v) { + v[0] = i & 0xff; + v[1] = (i >> 8) & 0xff; + } -inline void convert(uint64 li, char_uint64 v) { - v[0] = li & 0xff; - v[1] = (li >> 8) & 0xff; - v[2] = (li >> 16) & 0xff; - v[3] = (li >> 24) & 0xff; - v[4] = (li >> 32) & 0xff; - v[5] = (li >> 40) & 0xff; - v[6] = (li >> 48) & 0xff; - v[7] = (li >> 56) & 0xff; -} + inline void convert(uint64 li, char_uint64 v) { + v[0] = li & 0xff; + v[1] = (li >> 8) & 0xff; + v[2] = (li >> 16) & 0xff; + v[3] = (li >> 24) & 0xff; + v[4] = (li >> 32) & 0xff; + v[5] = (li >> 40) & 0xff; + v[6] = (li >> 48) & 0xff; + v[7] = (li >> 56) & 0xff; + } -namespace MsgTools { + namespace MsgTools { - inline uint8* fillNames(const Strings& names, uint8* pos) { - uint32 sz = names.size(); - convert(sz, pos); // save number of strings - uint8* len_pos = pos + sizeof(char_uint32); // area for length - pos = len_pos + sizeof(char_uint32); // area for full string of names - bool first = true; + inline uint8* fillNames(const Strings& names, uint8* pos) { + uint32 sz = names.size(); + convert(sz, pos); // save number of strings + uint8* len_pos = pos + sizeof(char_uint32); // area for length + pos = len_pos + sizeof(char_uint32); // area for full string of names + bool first = true; - for (Strings::const_iterator beg = names.begin(); beg != names.end(); ++beg) { - if (first) - first = false; - else - *pos++ = ' '; - pos = edm::copy_all(*beg, pos); + for (Strings::const_iterator beg = names.begin(); beg != names.end(); ++beg) { + if (first) + first = false; + else + *pos++ = ' '; + pos = edm::copy_all(*beg, pos); + } + convert((uint32)(pos - len_pos - sizeof(char_uint32)), len_pos); + return pos; } - convert((uint32)(pos - len_pos - sizeof(char_uint32)), len_pos); - return pos; - } - inline void getNames(uint8* from, uint32 from_len, Strings& to) { - // not the most efficient way to do this - std::istringstream ist(std::string(reinterpret_cast(from), from_len)); - typedef std::istream_iterator Iter; - std::copy(Iter(ist), Iter(), std::back_inserter(to)); - } - -} // namespace MsgTools + inline void getNames(uint8* from, uint32 from_len, Strings& to) { + // not the most efficient way to do this + std::istringstream ist(std::string(reinterpret_cast(from), from_len)); + typedef std::istream_iterator Iter; + std::copy(Iter(ist), Iter(), std::back_inserter(to)); + } + } // namespace MsgTools +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamSerializer.h b/IOPool/Streamer/interface/StreamSerializer.h index 1e84f4651096f..2169b0cb675c8 100644 --- a/IOPool/Streamer/interface/StreamSerializer.h +++ b/IOPool/Streamer/interface/StreamSerializer.h @@ -19,55 +19,57 @@ #include "DataFormats/Streamer/interface/StreamedProducts.h" #include "FWCore/Utilities/interface/get_underlying_safe.h" -// Data structure to be shared by all output modules for event serialization -struct SerializeDataBuffer { - typedef std::vector SBuffer; - static constexpr int init_size = 0; //will be allocated on first event - static constexpr unsigned int reserve_size = 50000; - - SerializeDataBuffer() - : comp_buf_(reserve_size + init_size), - curr_event_size_(), - curr_space_used_(), - rootbuf_(TBuffer::kWrite, init_size), - ptr_((unsigned char *)rootbuf_.Buffer()), - header_buf_(), - adler32_chksum_(0) {} - - // This object caches the results of the last INIT or event - // serialization operation. You get access to the data using the - // following member functions. - - unsigned char const *bufferPointer() const { return get_underlying_safe(ptr_); } - unsigned char *&bufferPointer() { return get_underlying_safe(ptr_); } - unsigned int currentSpaceUsed() const { return curr_space_used_; } - unsigned int currentEventSize() const { return curr_event_size_; } - uint32_t adler32_chksum() const { return adler32_chksum_; } - - void clearHeaderBuffer() { - header_buf_.clear(); - header_buf_.shrink_to_fit(); - rootbuf_.Reset(); - rootbuf_.Expand(init_size); //shrink TBuffer to size 0 after resetting TBuffer length - } - - std::vector comp_buf_; // space for compressed data - unsigned int curr_event_size_; - unsigned int curr_space_used_; // less than curr_event_size_ if compressed - TBufferFile rootbuf_; - edm::propagate_const ptr_; // set to the place where the last event stored - SBuffer header_buf_; // place for INIT message creation and streamer event header - uint32_t adler32_chksum_; // adler32 check sum for the (compressed) data -}; - -class EventMsgBuilder; -class InitMsgBuilder; namespace edm { - enum StreamerCompressionAlgo { UNCOMPRESSED = 0, ZLIB = 1, LZMA = 2, ZSTD = 4 }; - class EventForOutput; class ModuleCallingContext; class ThinnedAssociationsHelper; +} // namespace edm + +// Data structure to be shared by all output modules for event serialization +namespace edm::streamer { + struct SerializeDataBuffer { + typedef std::vector SBuffer; + static constexpr int init_size = 0; //will be allocated on first event + static constexpr unsigned int reserve_size = 50000; + + SerializeDataBuffer() + : comp_buf_(reserve_size + init_size), + curr_event_size_(), + curr_space_used_(), + rootbuf_(TBuffer::kWrite, init_size), + ptr_((unsigned char *)rootbuf_.Buffer()), + header_buf_(), + adler32_chksum_(0) {} + + // This object caches the results of the last INIT or event + // serialization operation. You get access to the data using the + // following member functions. + + unsigned char const *bufferPointer() const { return get_underlying_safe(ptr_); } + unsigned char *&bufferPointer() { return get_underlying_safe(ptr_); } + unsigned int currentSpaceUsed() const { return curr_space_used_; } + unsigned int currentEventSize() const { return curr_event_size_; } + uint32_t adler32_chksum() const { return adler32_chksum_; } + + void clearHeaderBuffer() { + header_buf_.clear(); + header_buf_.shrink_to_fit(); + rootbuf_.Reset(); + rootbuf_.Expand(init_size); //shrink TBuffer to size 0 after resetting TBuffer length + } + + std::vector comp_buf_; // space for compressed data + unsigned int curr_event_size_; + unsigned int curr_space_used_; // less than curr_event_size_ if compressed + TBufferFile rootbuf_; + edm::propagate_const ptr_; // set to the place where the last event stored + SBuffer header_buf_; // place for INIT message creation and streamer event header + uint32_t adler32_chksum_; // adler32 check sum for the (compressed) data + }; + + class EventMsgBuilder; + class InitMsgBuilder; + enum StreamerCompressionAlgo { UNCOMPRESSED = 0, ZLIB = 1, LZMA = 2, ZSTD = 4 }; class StreamSerializer { public: @@ -119,6 +121,6 @@ namespace edm { edm::propagate_const tc_; }; -} // namespace edm +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamerInputFile.h b/IOPool/Streamer/interface/StreamerInputFile.h index 033d558f07184..a969cecba2fbc 100644 --- a/IOPool/Streamer/interface/StreamerInputFile.h +++ b/IOPool/Streamer/interface/StreamerInputFile.h @@ -16,6 +16,8 @@ namespace edm { class EventSkipperByID; class FileCatalogItem; +} // namespace edm +namespace edm::streamer { class StreamerInputFile { public: /**Reads a Streamer file */ @@ -96,6 +98,6 @@ namespace edm { bool endOfFile_; }; -} // namespace edm +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamerInputModule.h b/IOPool/Streamer/interface/StreamerInputModule.h index e43fb69d2cd1f..360ee89c66624 100644 --- a/IOPool/Streamer/interface/StreamerInputModule.h +++ b/IOPool/Streamer/interface/StreamerInputModule.h @@ -15,7 +15,7 @@ #include #include -namespace edm { +namespace edm::streamer { template class StreamerInputModule : public StreamerInputSource { /** @@ -78,6 +78,6 @@ namespace edm { return Next::kEvent; } -} // namespace edm +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamerInputSource.h b/IOPool/Streamer/interface/StreamerInputSource.h index 460c969c39b41..2d7354b94b2e5 100644 --- a/IOPool/Streamer/interface/StreamerInputSource.h +++ b/IOPool/Streamer/interface/StreamerInputSource.h @@ -20,13 +20,15 @@ #include #include -class InitMsgView; -class EventMsgView; - namespace edm { class BranchIDListHelper; class ParameterSetDescription; class ThinnedAssociationsHelper; +} // namespace edm + +namespace edm::streamer { + class InitMsgView; + class EventMsgView; class StreamerInputSource : public RawInputSource { public: @@ -124,6 +126,6 @@ namespace edm { std::string processName_; unsigned int protocolVersion_; }; //end-of-class-def -} // namespace edm +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamerOutputFile.h b/IOPool/Streamer/interface/StreamerOutputFile.h index 0bae650e7f83b..837e33ea1c496 100644 --- a/IOPool/Streamer/interface/StreamerOutputFile.h +++ b/IOPool/Streamer/interface/StreamerOutputFile.h @@ -20,48 +20,49 @@ #include #include -class StreamerOutputFile -/** +namespace edm::streamer { + class StreamerOutputFile + /** Class for doing Streamer Write operations */ -{ -public: - explicit StreamerOutputFile(const std::string& name, uint32 padding = 0); - /** + { + public: + explicit StreamerOutputFile(const std::string& name, uint32 padding = 0); + /** CTOR, takes file path name as argument */ - ~StreamerOutputFile(); + ~StreamerOutputFile(); - void write(const InitMsgBuilder&); - /** + void write(const InitMsgBuilder&); + /** Performs write on InitMsgBuilder type, Header + Blob, both are written out. */ - void write(const InitMsgView&); + void write(const InitMsgView&); - void writeInitFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize); + void writeInitFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize); - uint64 write(const EventMsgBuilder&); - /** + uint64 write(const EventMsgBuilder&); + /** Performs write on EventMsgBuilder type, Header + Blob, both are written out. RETURNS the Offset in Stream while at which EventForOutputwas written. */ - uint64 write(const EventMsgView&); - - uint64 writeEventFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize); + uint64 write(const EventMsgView&); - uint32 adler32() const { return streamerfile_->adler32(); } + uint64 writeEventFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize); - void close() { streamerfile_->close(); } + uint32 adler32() const { return streamerfile_->adler32(); } -private: - void writeEventHeader(const EventMsgView& ineview); - void writeStart(const InitMsgView& inview); + void close() { streamerfile_->close(); } -private: - edm::propagate_const> streamerfile_; -}; + private: + void writeEventHeader(const EventMsgView& ineview); + void writeStart(const InitMsgView& inview); + private: + edm::propagate_const> streamerfile_; + }; +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamerOutputModule.h b/IOPool/Streamer/interface/StreamerOutputModule.h index 2359418e7e1b2..a03007bca82f6 100644 --- a/IOPool/Streamer/interface/StreamerOutputModule.h +++ b/IOPool/Streamer/interface/StreamerOutputModule.h @@ -5,7 +5,7 @@ #include "FWCore/Utilities/interface/propagate_const.h" #include "IOPool/Streamer/interface/StreamerOutputModuleBase.h" -namespace edm { +namespace edm::streamer { template class StreamerOutputModule : public StreamerOutputModuleBase { /** Consumers are suppose to provide @@ -74,6 +74,6 @@ namespace edm { Consumer::fillDescription(desc); descriptions.add("streamerOutput", desc); } -} // namespace edm +} // namespace edm::streamer #endif diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index 6e3b4f5a6e329..6c88edecfbe26 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -10,42 +10,44 @@ //#include //#include -class InitMsgBuilder; -class EventMsgBuilder; namespace edm { class ParameterSetDescription; typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; - class StreamerOutputModuleBase : public one::OutputModule, - StreamerOutputModuleCommon { - public: - explicit StreamerOutputModuleBase(ParameterSet const& ps); - ~StreamerOutputModuleBase() override; - static void fillDescription(ParameterSetDescription& desc); - - private: - void beginRun(RunForOutput const&) override; - void endRun(RunForOutput const&) override; - void beginJob() override; - void endJob() override; - void writeRun(RunForOutput const&) override; - void writeLuminosityBlock(LuminosityBlockForOutput const&) override; - void write(EventForOutput const& e) override; - - virtual void start() = 0; - virtual void stop() = 0; - virtual void doOutputHeader(InitMsgBuilder const& init_message) = 0; - virtual void doOutputEvent(EventMsgBuilder const& msg) = 0; - - Trig getTriggerResults(EDGetTokenT const& token, EventForOutput const& e) const; - - private: - edm::EDGetTokenT trToken_; - edm::EDGetTokenT psetToken_; - - }; //end-of-class-def - + namespace streamer { + class InitMsgBuilder; + class EventMsgBuilder; + + class StreamerOutputModuleBase : public one::OutputModule, + StreamerOutputModuleCommon { + public: + explicit StreamerOutputModuleBase(ParameterSet const& ps); + ~StreamerOutputModuleBase() override; + static void fillDescription(ParameterSetDescription& desc); + + private: + void beginRun(RunForOutput const&) override; + void endRun(RunForOutput const&) override; + void beginJob() override; + void endJob() override; + void writeRun(RunForOutput const&) override; + void writeLuminosityBlock(LuminosityBlockForOutput const&) override; + void write(EventForOutput const& e) override; + + virtual void start() = 0; + virtual void stop() = 0; + virtual void doOutputHeader(InitMsgBuilder const& init_message) = 0; + virtual void doOutputEvent(EventMsgBuilder const& msg) = 0; + + Trig getTriggerResults(EDGetTokenT const& token, EventForOutput const& e) const; + + private: + edm::EDGetTokenT trToken_; + edm::EDGetTokenT psetToken_; + + }; //end-of-class-def + } // namespace streamer } // namespace edm #endif diff --git a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h index 68ecb1d8e208f..165248c08b75e 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h @@ -9,8 +9,6 @@ #include #include -class InitMsgBuilder; -class EventMsgBuilder; namespace edm { class ParameterSet; class ParameterSetDescription; @@ -18,74 +16,78 @@ namespace edm { class ThinnedAssociationsHelper; class TriggerResults; - class StreamerOutputModuleCommon { - public: - struct Parameters { - Strings hltTriggerSelections; - std::string compressionAlgoStr; - int compressionLevel; - int lumiSectionInterval; - bool useCompression; - }; + namespace streamer { + class InitMsgBuilder; + class EventMsgBuilder; - static Parameters parameters(ParameterSet const& ps); + class StreamerOutputModuleCommon { + public: + struct Parameters { + Strings hltTriggerSelections; + std::string compressionAlgoStr; + int compressionLevel; + int lumiSectionInterval; + bool useCompression; + }; - explicit StreamerOutputModuleCommon(Parameters const& p, - SelectedProducts const* selections, - std::string const& moduleLabel); + static Parameters parameters(ParameterSet const& ps); - explicit StreamerOutputModuleCommon(ParameterSet const& ps, - SelectedProducts const* selections, - std::string const& moduleLabel) - : StreamerOutputModuleCommon(parameters(ps), selections, moduleLabel) {} + explicit StreamerOutputModuleCommon(Parameters const& p, + SelectedProducts const* selections, + std::string const& moduleLabel); - ~StreamerOutputModuleCommon(); - static void fillDescription(ParameterSetDescription& desc); + explicit StreamerOutputModuleCommon(ParameterSet const& ps, + SelectedProducts const* selections, + std::string const& moduleLabel) + : StreamerOutputModuleCommon(parameters(ps), selections, moduleLabel) {} - std::unique_ptr serializeRegistry(SerializeDataBuffer& sbuf, - BranchIDLists const& branchLists, - ThinnedAssociationsHelper const& helper, - std::string const& processName, - std::string const& moduleLabel, - ParameterSetID const& toplevel, - SendJobHeader::ParameterSetMap const* psetMap); + ~StreamerOutputModuleCommon(); + static void fillDescription(ParameterSetDescription& desc); - std::unique_ptr serializeEvent(SerializeDataBuffer& sbuf, - EventForOutput const& e, - Handle const& triggerResults, - ParameterSetID const& selectorCfg); + std::unique_ptr serializeRegistry(SerializeDataBuffer& sbuf, + BranchIDLists const& branchLists, + ThinnedAssociationsHelper const& helper, + std::string const& processName, + std::string const& moduleLabel, + ParameterSetID const& toplevel, + SendJobHeader::ParameterSetMap const* psetMap); - SerializeDataBuffer* getSerializerBuffer(); + std::unique_ptr serializeEvent(SerializeDataBuffer& sbuf, + EventForOutput const& e, + Handle const& triggerResults, + ParameterSetID const& selectorCfg); - protected: - std::unique_ptr serializerBuffer_; + SerializeDataBuffer* getSerializerBuffer(); - private: - void setHltMask(EventForOutput const& e, - Handle const& triggerResults, - std::vector& hltbits) const; + protected: + std::unique_ptr serializerBuffer_; - StreamSerializer serializer_; + private: + void setHltMask(EventForOutput const& e, + Handle const& triggerResults, + std::vector& hltbits) const; - int maxEventSize_; - bool useCompression_; - std::string compressionAlgoStr_; - int compressionLevel_; + StreamSerializer serializer_; - StreamerCompressionAlgo compressionAlgo_; + int maxEventSize_; + bool useCompression_; + std::string compressionAlgoStr_; + int compressionLevel_; - // test luminosity sections - int lumiSectionInterval_; - double timeInSecSinceUTC; + StreamerCompressionAlgo compressionAlgo_; - unsigned int hltsize_; - char host_name_[255]; + // test luminosity sections + int lumiSectionInterval_; + double timeInSecSinceUTC; - Strings hltTriggerSelections_; - uint32 outputModuleId_; + unsigned int hltsize_; + char host_name_[255]; - }; //end-of-class-def + Strings hltTriggerSelections_; + uint32 outputModuleId_; + }; //end-of-class-def + } // namespace streamer } // namespace edm #endif diff --git a/IOPool/Streamer/plugins/Module.cc b/IOPool/Streamer/plugins/Module.cc index 1651269774805..178739af68aa5 100644 --- a/IOPool/Streamer/plugins/Module.cc +++ b/IOPool/Streamer/plugins/Module.cc @@ -8,11 +8,11 @@ //new module to read events from Streamer files #include "IOPool/Streamer/src/StreamerFileReader.h" -typedef edm::StreamerOutputModule EventStreamFileWriter; -typedef edm::StreamerFileReader NewEventStreamFileReader; +using EventStreamFileWriter = edm::streamer::StreamerOutputModule; +using NewEventStreamFileReader = edm::streamer::StreamerFileReader; -using edm::StreamerFileReader; -using edm::StreamerFileWriter; +using edm::streamer::StreamerFileReader; +using edm::streamer::StreamerFileWriter; DEFINE_FWK_INPUT_SOURCE(NewEventStreamFileReader); diff --git a/IOPool/Streamer/src/ClassFiller.cc b/IOPool/Streamer/src/ClassFiller.cc index 4eaa9fe34bfa1..3313878ca1a06 100644 --- a/IOPool/Streamer/src/ClassFiller.cc +++ b/IOPool/Streamer/src/ClassFiller.cc @@ -11,7 +11,7 @@ #include #include -namespace edm { +namespace edm::streamer { bool loadCap(std::string const& name, std::vector& missingDictionaries) { FDEBUG(1) << "Loading dictionary for " << name << "\n"; @@ -64,4 +64,4 @@ namespace edm { TypeID const type(ti); return getRootClass(type.className()); } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/DumpTools.cc b/IOPool/Streamer/src/DumpTools.cc index 977c7c393b975..eecbb7c49b13d 100644 --- a/IOPool/Streamer/src/DumpTools.cc +++ b/IOPool/Streamer/src/DumpTools.cc @@ -16,190 +16,192 @@ using namespace edm; -void dumpInitHeader(const InitMsgView* view) { - std::cout << "code = " << view->code() << ", " - << "size = " << view->size() << "\n" - << "run = " << view->run() << ", " - << "proto = " << view->protocolVersion() << "\n" - << "release = " << view->releaseTag() << "\n" - << "processName = " << view->processName() << "\n"; - if (view->protocolVersion() >= 5) { - std::cout << "outModuleLabel = " << view->outputModuleLabel() << "\n"; +namespace edm::streamer { + void dumpInitHeader(const InitMsgView* view) { + std::cout << "code = " << view->code() << ", " + << "size = " << view->size() << "\n" + << "run = " << view->run() << ", " + << "proto = " << view->protocolVersion() << "\n" + << "release = " << view->releaseTag() << "\n" + << "processName = " << view->processName() << "\n"; + if (view->protocolVersion() >= 5) { + std::cout << "outModuleLabel = " << view->outputModuleLabel() << "\n"; + } + if (view->protocolVersion() >= 6) { + std::cout << "outputModuleId=0x" << std::hex << view->outputModuleId() << std::dec << std::endl; + } + if (view->protocolVersion() >= 8) { + std::cout << "Checksum for Registry data = " << view->adler32_chksum() << " Hostname = " << view->hostName() + << std::endl; + } + + //PSet 16 byte non-printable representation, stored in message. + uint8 vpset[16]; + view->pset(vpset); + + //Lets convert it to printable hex form + std::string pset_str(vpset, vpset + sizeof(vpset)); + pset_str += '\0'; + cms::Digest dig(pset_str); + cms::MD5Result r1 = dig.digest(); + std::string hexy = r1.toString(); + std::cout << "PSetID= " << hexy << std::endl; + + Strings vhltnames, vhltselections, vl1names; + view->hltTriggerNames(vhltnames); + if (view->protocolVersion() >= 5) { + view->hltTriggerSelections(vhltselections); + } + view->l1TriggerNames(vl1names); + + std::cout << "HLT names :- \n "; + edm::copy_all(vhltnames, std::ostream_iterator(std::cout, "\n")); + + if (view->protocolVersion() >= 5) { + std::cout << "HLT selections :- \n "; + edm::copy_all(vhltselections, std::ostream_iterator(std::cout, "\n")); + } + + std::cout << "L1 names :- \n "; + edm::copy_all(vl1names, std::ostream_iterator(std::cout, "\n")); + std::cout << "\n"; + std::cout.flush(); } - if (view->protocolVersion() >= 6) { - std::cout << "outputModuleId=0x" << std::hex << view->outputModuleId() << std::dec << std::endl; + + void dumpInitView(const InitMsgView* view) { + dumpInitHeader(view); + std::cout << "desc len = " << view->descLength() << "\n"; + //const uint8* pos = view->descData(); + //std::copy(pos,pos+view->descLength(),std::ostream_iterator(std::cout,"")); + //std::cout << "\n"; + std::cout.flush(); } - if (view->protocolVersion() >= 8) { - std::cout << "Checksum for Registry data = " << view->adler32_chksum() << " Hostname = " << view->hostName() - << std::endl; + + void dumpStartMsg(const InitMsgView* view) { + dumpInitHeader(view); + std::cout.flush(); } - //PSet 16 byte non-printable representation, stored in message. - uint8 vpset[16]; - view->pset(vpset); - - //Lets convert it to printable hex form - std::string pset_str(vpset, vpset + sizeof(vpset)); - pset_str += '\0'; - cms::Digest dig(pset_str); - cms::MD5Result r1 = dig.digest(); - std::string hexy = r1.toString(); - std::cout << "PSetID= " << hexy << std::endl; - - Strings vhltnames, vhltselections, vl1names; - view->hltTriggerNames(vhltnames); - if (view->protocolVersion() >= 5) { - view->hltTriggerSelections(vhltselections); + void dumpInitVerbose(const InitMsgView* view) { + std::cout << ">>>>> INIT Message Dump (begin) >>>>>" << std::endl; + dumpInitHeader(view); + + TClass* desc = getTClass(typeid(SendJobHeader)); + TBufferFile xbuf(TBuffer::kRead, view->descLength(), (char*)view->descData(), kFALSE); + std::unique_ptr sd((SendJobHeader*)xbuf.ReadObjectAny(desc)); + + if (sd.get() == nullptr) { + std::cout << "Unable to determine the product registry - " + << "Registry deserialization error." << std::endl; + } else { + std::cout << "Branch Descriptions:" << std::endl; + SendDescs const& descs = sd->descs(); + SendDescs::const_iterator iDesc(descs.begin()), eDesc(descs.end()); + while (iDesc != eDesc) { + BranchDescription branchDesc = *iDesc; + branchDesc.init(); + //branchDesc.write(std::cout); + std::cout << branchDesc.branchName() << std::endl; + iDesc++; + } + } + + std::cout << "<<<<< INIT Message Dump (end) <<<<<" << std::endl; + std::cout.flush(); } - view->l1TriggerNames(vl1names); - std::cout << "HLT names :- \n "; - edm::copy_all(vhltnames, std::ostream_iterator(std::cout, "\n")); + void dumpInit(uint8* buf) { + InitMsgView view(buf); + dumpInitHeader(&view); - if (view->protocolVersion() >= 5) { - std::cout << "HLT selections :- \n "; - edm::copy_all(vhltselections, std::ostream_iterator(std::cout, "\n")); + std::cout << "desc len = " << view.descLength() << "\n"; + //const uint8* pos = view.descData(); + //std::copy(pos,pos+view.descLength(),std::ostream_iterator(std::cout,"")); + //std::cout << "\n"; + std::cout.flush(); } - std::cout << "L1 names :- \n "; - edm::copy_all(vl1names, std::ostream_iterator(std::cout, "\n")); - std::cout << "\n"; - std::cout.flush(); -} - -void dumpInitView(const InitMsgView* view) { - dumpInitHeader(view); - std::cout << "desc len = " << view->descLength() << "\n"; - //const uint8* pos = view->descData(); - //std::copy(pos,pos+view->descLength(),std::ostream_iterator(std::cout,"")); - //std::cout << "\n"; - std::cout.flush(); -} - -void dumpStartMsg(const InitMsgView* view) { - dumpInitHeader(view); - std::cout.flush(); -} - -void dumpInitVerbose(const InitMsgView* view) { - std::cout << ">>>>> INIT Message Dump (begin) >>>>>" << std::endl; - dumpInitHeader(view); - - TClass* desc = getTClass(typeid(SendJobHeader)); - TBufferFile xbuf(TBuffer::kRead, view->descLength(), (char*)view->descData(), kFALSE); - std::unique_ptr sd((SendJobHeader*)xbuf.ReadObjectAny(desc)); - - if (sd.get() == nullptr) { - std::cout << "Unable to determine the product registry - " - << "Registry deserialization error." << std::endl; - } else { - std::cout << "Branch Descriptions:" << std::endl; - SendDescs const& descs = sd->descs(); - SendDescs::const_iterator iDesc(descs.begin()), eDesc(descs.end()); - while (iDesc != eDesc) { - BranchDescription branchDesc = *iDesc; - branchDesc.init(); - //branchDesc.write(std::cout); - std::cout << branchDesc.branchName() << std::endl; - iDesc++; + void printBits(unsigned char c) { + for (int i = 7; i >= 0; --i) { + int bit = ((c >> i) & 1); + std::cout << " " << bit; } } - std::cout << "<<<<< INIT Message Dump (end) <<<<<" << std::endl; - std::cout.flush(); -} - -void dumpInit(uint8* buf) { - InitMsgView view(buf); - dumpInitHeader(&view); - - std::cout << "desc len = " << view.descLength() << "\n"; - //const uint8* pos = view.descData(); - //std::copy(pos,pos+view.descLength(),std::ostream_iterator(std::cout,"")); - //std::cout << "\n"; - std::cout.flush(); -} - -void printBits(unsigned char c) { - for (int i = 7; i >= 0; --i) { - int bit = ((c >> i) & 1); - std::cout << " " << bit; + void dumpEventHeader(const EventMsgView* eview) { + std::cout << "code=" << eview->code() << "\n" + << "size=" << eview->size() << "\n" + << "protocolVersion=" << eview->protocolVersion() << "\n" + << "run=" << eview->run() << "\n" + << "event=" << eview->event() << "\n" + << "lumi=" << eview->lumi() << "\n" + << "origDataSize=" << eview->origDataSize() << "\n" + << "outModId=0x" << std::hex << eview->outModId() << std::dec << "\n" + << "adler32 chksum= " << eview->adler32_chksum() << "\n" + << "host name= " << eview->hostName() << "\n" + << "event length=" << eview->eventLength() << "\n" + << "droppedEventsCount=" << eview->droppedEventsCount() << "\n"; + + std::vector l1_out; + eview->l1TriggerBits(l1_out); + + std::cout << "\nl1 size= " << l1_out.size() << "\n l1 bits=\n"; + edm::copy_all(l1_out, std::ostream_iterator(std::cout, " ")); + + std::vector hlt_out; + if (eview->hltCount() > 0) { + hlt_out.resize(1 + (eview->hltCount() - 1) / 4); + } + eview->hltTriggerBits(&hlt_out[0]); + + std::cout << "\nhlt Count:" << eview->hltCount(); + std::cout << "\nhlt bits=\n("; + for (int i = (hlt_out.size() - 1); i != -1; --i) + printBits(hlt_out[i]); + std::cout << ")\n"; + std::cout.flush(); + } + + void dumpEventView(const EventMsgView* eview) { + dumpEventHeader(eview); + //const uint8* edata = eview->eventData(); + //std::cout << "\nevent data=\n("; + //std::copy(&edata[0],&edata[0]+eview->eventLength(), + // std::ostream_iterator(std::cout,"")); + //std::cout << ")\n"; + std::cout.flush(); + } + + void dumpEventIndex(const EventMsgView* eview) { + dumpEventHeader(eview); + std::cout.flush(); + } + + void dumpEvent(uint8* buf) { + EventMsgView eview(buf); + + dumpEventHeader(&eview); + + //const uint8* edata = eview.eventData(); + //std::cout << "\nevent data=\n("; + //std::copy(&edata[0],&edata[0]+eview.eventLength(), + // std::ostream_iterator(std::cout,"")); + //std::cout << ")\n"; + std::cout.flush(); } -} - -void dumpEventHeader(const EventMsgView* eview) { - std::cout << "code=" << eview->code() << "\n" - << "size=" << eview->size() << "\n" - << "protocolVersion=" << eview->protocolVersion() << "\n" - << "run=" << eview->run() << "\n" - << "event=" << eview->event() << "\n" - << "lumi=" << eview->lumi() << "\n" - << "origDataSize=" << eview->origDataSize() << "\n" - << "outModId=0x" << std::hex << eview->outModId() << std::dec << "\n" - << "adler32 chksum= " << eview->adler32_chksum() << "\n" - << "host name= " << eview->hostName() << "\n" - << "event length=" << eview->eventLength() << "\n" - << "droppedEventsCount=" << eview->droppedEventsCount() << "\n"; - - std::vector l1_out; - eview->l1TriggerBits(l1_out); - - std::cout << "\nl1 size= " << l1_out.size() << "\n l1 bits=\n"; - edm::copy_all(l1_out, std::ostream_iterator(std::cout, " ")); - - std::vector hlt_out; - if (eview->hltCount() > 0) { - hlt_out.resize(1 + (eview->hltCount() - 1) / 4); + + void dumpFRDEventView(const FRDEventMsgView* fview) { + std::cout << "\n>>>>> FRDEvent Message Dump (begin) >>>>>" << std::endl; + std::cout.flush(); + + std::cout << "size = " << fview->size() << "\n" + << "version = " << fview->version() << "\n" + << "run = " << fview->run() << "\n" + << "lumi = " << fview->lumi() << "\n" + << "event = " << fview->event() << "\n"; + std::cout.flush(); + + std::cout << ">>>>> FRDEvent Message Dump (end) >>>>>" << std::endl; + std::cout.flush(); } - eview->hltTriggerBits(&hlt_out[0]); - - std::cout << "\nhlt Count:" << eview->hltCount(); - std::cout << "\nhlt bits=\n("; - for (int i = (hlt_out.size() - 1); i != -1; --i) - printBits(hlt_out[i]); - std::cout << ")\n"; - std::cout.flush(); -} - -void dumpEventView(const EventMsgView* eview) { - dumpEventHeader(eview); - //const uint8* edata = eview->eventData(); - //std::cout << "\nevent data=\n("; - //std::copy(&edata[0],&edata[0]+eview->eventLength(), - // std::ostream_iterator(std::cout,"")); - //std::cout << ")\n"; - std::cout.flush(); -} - -void dumpEventIndex(const EventMsgView* eview) { - dumpEventHeader(eview); - std::cout.flush(); -} - -void dumpEvent(uint8* buf) { - EventMsgView eview(buf); - - dumpEventHeader(&eview); - - //const uint8* edata = eview.eventData(); - //std::cout << "\nevent data=\n("; - //std::copy(&edata[0],&edata[0]+eview.eventLength(), - // std::ostream_iterator(std::cout,"")); - //std::cout << ")\n"; - std::cout.flush(); -} - -void dumpFRDEventView(const FRDEventMsgView* fview) { - std::cout << "\n>>>>> FRDEvent Message Dump (begin) >>>>>" << std::endl; - std::cout.flush(); - - std::cout << "size = " << fview->size() << "\n" - << "version = " << fview->version() << "\n" - << "run = " << fview->run() << "\n" - << "lumi = " << fview->lumi() << "\n" - << "event = " << fview->event() << "\n"; - std::cout.flush(); - - std::cout << ">>>>> FRDEvent Message Dump (end) >>>>>" << std::endl; - std::cout.flush(); -} +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/EventMessage.cc b/IOPool/Streamer/src/EventMessage.cc index 87e3530b5577c..0a9365ee7e4d4 100644 --- a/IOPool/Streamer/src/EventMessage.cc +++ b/IOPool/Streamer/src/EventMessage.cc @@ -1,6 +1,8 @@ #include "IOPool/Streamer/interface/EventMessage.h" #include "FWCore/Utilities/interface/Exception.h" +using namespace edm::streamer; + EventMsgView::EventMsgView(void* buf) : buf_((uint8*)buf), head_(buf), v2Detected_(false) { // 29-Jan-2008, KAB - adding an explicit version number. // We'll start with 5 to match the new version of the INIT message. diff --git a/IOPool/Streamer/src/EventMsgBuilder.cc b/IOPool/Streamer/src/EventMsgBuilder.cc index 16a64e89d2cdf..31fcf478276c1 100644 --- a/IOPool/Streamer/src/EventMsgBuilder.cc +++ b/IOPool/Streamer/src/EventMsgBuilder.cc @@ -5,7 +5,9 @@ #include #include -#define MAX_HOSTNAME_LEN 25 +static constexpr int MAX_HOSTNAME_LEN = 25; + +using namespace edm::streamer; EventMsgBuilder::EventMsgBuilder(void* buf, uint32 size, diff --git a/IOPool/Streamer/src/FRDEventMessage.cc b/IOPool/Streamer/src/FRDEventMessage.cc index 0811b3e59fbbf..a6c586d0eda03 100644 --- a/IOPool/Streamer/src/FRDEventMessage.cc +++ b/IOPool/Streamer/src/FRDEventMessage.cc @@ -12,6 +12,8 @@ #include "IOPool/Streamer/interface/FRDEventMessage.h" #include "FWCore/Utilities/interface/Exception.h" +using namespace edm::streamer; + /** * Constructor for the FRD event message viewer. */ diff --git a/IOPool/Streamer/src/InitMessage.cc b/IOPool/Streamer/src/InitMessage.cc index 338019471d291..d731fc224fe5a 100644 --- a/IOPool/Streamer/src/InitMessage.cc +++ b/IOPool/Streamer/src/InitMessage.cc @@ -4,6 +4,8 @@ #include #include +using namespace edm::streamer; + InitMsgView::InitMsgView(void* buf) : buf_((uint8*)buf), head_(buf), diff --git a/IOPool/Streamer/src/InitMsgBuilder.cc b/IOPool/Streamer/src/InitMsgBuilder.cc index f41bc86205c73..904fc1b0ab9e9 100644 --- a/IOPool/Streamer/src/InitMsgBuilder.cc +++ b/IOPool/Streamer/src/InitMsgBuilder.cc @@ -6,6 +6,8 @@ #include #include +using namespace edm::streamer; + InitMsgBuilder::InitMsgBuilder(void* buf, uint32 size, uint32 run, diff --git a/IOPool/Streamer/src/StreamSerializer.cc b/IOPool/Streamer/src/StreamSerializer.cc index 69048593cfa2e..0ac0993a1c897 100644 --- a/IOPool/Streamer/src/StreamSerializer.cc +++ b/IOPool/Streamer/src/StreamSerializer.cc @@ -30,7 +30,7 @@ #include #include -namespace edm { +namespace edm::streamer { /** * Creates a translator instance for the specified product registry. @@ -426,4 +426,4 @@ namespace edm { return resultSize; } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerFileReader.cc b/IOPool/Streamer/src/StreamerFileReader.cc index 85c10a63c4279..32f58476f7002 100644 --- a/IOPool/Streamer/src/StreamerFileReader.cc +++ b/IOPool/Streamer/src/StreamerFileReader.cc @@ -10,7 +10,7 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Sources/interface/EventSkipperByID.h" -namespace edm { +namespace edm::streamer { StreamerFileReader::StreamerFileReader(ParameterSet const& pset, InputSourceDescription const& desc) : StreamerInputSource(pset, desc), @@ -124,4 +124,4 @@ namespace edm { EventSkipperByID::fillDescription(desc); descriptions.add("source", desc); } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerFileReader.h b/IOPool/Streamer/src/StreamerFileReader.h index 446bdd3cab3f4..3661a6440535e 100644 --- a/IOPool/Streamer/src/StreamerFileReader.h +++ b/IOPool/Streamer/src/StreamerFileReader.h @@ -18,35 +18,39 @@ namespace edm { class FileCatalogItem; struct InputSourceDescription; class ParameterSet; - class StreamerInputFile; - class StreamerFileReader : public StreamerInputSource { - public: - StreamerFileReader(ParameterSet const& pset, InputSourceDescription const& desc); - ~StreamerFileReader() override; - - static void fillDescriptions(ConfigurationDescriptions& descriptions); - - private: - InitMsgView const* getHeader(); - EventMsgView const* getNextEvent(); - bool newHeader(); - - Next checkNext() override; - void skip(int toSkip) override; - void genuineReadFile() override; - void genuineCloseFile() override; - void reset_() override; - - std::shared_ptr eventSkipperByID() const { return get_underlying_safe(eventSkipperByID_); } - std::shared_ptr& eventSkipperByID() { return get_underlying_safe(eventSkipperByID_); } - - std::vector streamerNames_; // names of Streamer files - edm::propagate_const> streamReader_; - edm::propagate_const> eventSkipperByID_; - int initialNumberOfEventsToSkip_; - int prefetchMBytes_; - bool isFirstFile_ = true; - }; + namespace streamer { + class StreamerInputFile; + class StreamerFileReader : public StreamerInputSource { + public: + StreamerFileReader(ParameterSet const& pset, InputSourceDescription const& desc); + ~StreamerFileReader() override; + + static void fillDescriptions(ConfigurationDescriptions& descriptions); + + private: + InitMsgView const* getHeader(); + EventMsgView const* getNextEvent(); + bool newHeader(); + + Next checkNext() override; + void skip(int toSkip) override; + void genuineReadFile() override; + void genuineCloseFile() override; + void reset_() override; + + std::shared_ptr eventSkipperByID() const { + return get_underlying_safe(eventSkipperByID_); + } + std::shared_ptr& eventSkipperByID() { return get_underlying_safe(eventSkipperByID_); } + + std::vector streamerNames_; // names of Streamer files + edm::propagate_const> streamReader_; + edm::propagate_const> eventSkipperByID_; + int initialNumberOfEventsToSkip_; + int prefetchMBytes_; + bool isFirstFile_ = true; + }; + } // namespace streamer } // namespace edm #endif diff --git a/IOPool/Streamer/src/StreamerFileWriter.cc b/IOPool/Streamer/src/StreamerFileWriter.cc index 52234ff7d769b..eeac63e10af54 100644 --- a/IOPool/Streamer/src/StreamerFileWriter.cc +++ b/IOPool/Streamer/src/StreamerFileWriter.cc @@ -1,7 +1,8 @@ #include "IOPool/Streamer/src/StreamerFileWriter.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -namespace edm { +namespace edm::streamer { + StreamerFileWriter::StreamerFileWriter(edm::ParameterSet const& ps) : stream_writer_(new StreamerOutputFile(ps.getUntrackedParameter("fileName"), ps.getUntrackedParameter("padding"))) {} @@ -38,4 +39,4 @@ namespace edm { desc.addUntracked("padding", 0) ->setComment("For testing: INIT and event block size will be rounded to this size padded with 0xff bytes."); } -} //namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerFileWriter.h b/IOPool/Streamer/src/StreamerFileWriter.h index a0f75964cc598..e8213fe0fab12 100644 --- a/IOPool/Streamer/src/StreamerFileWriter.h +++ b/IOPool/Streamer/src/StreamerFileWriter.h @@ -18,27 +18,29 @@ namespace edm { class ParameterSetDescription; - class StreamerFileWriter { - public: - explicit StreamerFileWriter(edm::ParameterSet const& ps); - explicit StreamerFileWriter(std::string const& fileName); - ~StreamerFileWriter(); + namespace streamer { + class StreamerFileWriter { + public: + explicit StreamerFileWriter(edm::ParameterSet const& ps); + explicit StreamerFileWriter(std::string const& fileName); + ~StreamerFileWriter(); - static void fillDescription(ParameterSetDescription& desc); + static void fillDescription(ParameterSetDescription& desc); - void doOutputHeader(InitMsgBuilder const& init_message); - void doOutputHeader(InitMsgView const& init_message); + void doOutputHeader(InitMsgBuilder const& init_message); + void doOutputHeader(InitMsgView const& init_message); - void doOutputEvent(EventMsgBuilder const& msg); - void doOutputEvent(EventMsgView const& msg); + void doOutputEvent(EventMsgBuilder const& msg); + void doOutputEvent(EventMsgView const& msg); - void start() {} - void stop(){}; + void start() {} + void stop(){}; - uint32 get_adler32() const { return stream_writer_->adler32(); } + uint32 get_adler32() const { return stream_writer_->adler32(); } - private: - edm::propagate_const> stream_writer_; - }; + private: + edm::propagate_const> stream_writer_; + }; + } // namespace streamer } // namespace edm #endif diff --git a/IOPool/Streamer/src/StreamerInputFile.cc b/IOPool/Streamer/src/StreamerInputFile.cc index 09da2ea8d1ee0..ec88f1f969e92 100644 --- a/IOPool/Streamer/src/StreamerInputFile.cc +++ b/IOPool/Streamer/src/StreamerInputFile.cc @@ -14,7 +14,7 @@ #include #include -namespace edm { +namespace edm::streamer { StreamerInputFile::~StreamerInputFile() { closeStreamerFile(); } @@ -380,4 +380,4 @@ namespace edm { LogAbsolute("fileAction") << std::setprecision(0) << TimeOfDay() << msg << currentFileName_; FlushMessageLog(); } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerInputSource.cc b/IOPool/Streamer/src/StreamerInputSource.cc index 9f9021c4a4962..88f75037ec0d4 100644 --- a/IOPool/Streamer/src/StreamerInputSource.cc +++ b/IOPool/Streamer/src/StreamerInputSource.cc @@ -37,7 +37,7 @@ #include #include -namespace edm { +namespace edm::streamer { namespace { int const init_size = 1024 * 1024; } @@ -511,4 +511,4 @@ namespace edm { void StreamerInputSource::EventPrincipalHolder::setEventPrincipal(EventPrincipal* ep) { eventPrincipal_ = ep; } void StreamerInputSource::fillDescription(ParameterSetDescription& desc) { RawInputSource::fillDescription(desc); } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerOutputFile.cc b/IOPool/Streamer/src/StreamerOutputFile.cc index 0ee1470cf26ab..65b67c74a8bdd 100644 --- a/IOPool/Streamer/src/StreamerOutputFile.cc +++ b/IOPool/Streamer/src/StreamerOutputFile.cc @@ -1,83 +1,88 @@ #include "IOPool/Streamer/interface/StreamerOutputFile.h" #include "FWCore/Utilities/interface/Exception.h" -StreamerOutputFile::~StreamerOutputFile() {} +namespace edm::streamer { + StreamerOutputFile::~StreamerOutputFile() {} -StreamerOutputFile::StreamerOutputFile(const std::string& name, uint32 padding) - : streamerfile_(std::make_shared(name, padding)) { - streamerfile_->set_do_adler(true); -} + StreamerOutputFile::StreamerOutputFile(const std::string& name, uint32 padding) + : streamerfile_(std::make_shared(name, padding)) { + streamerfile_->set_do_adler(true); + } -uint64 StreamerOutputFile::write(const EventMsgBuilder& ineview) { - EventMsgView tmpView(ineview.startAddress()); - return write(tmpView); -} + uint64 StreamerOutputFile::write(const EventMsgBuilder& ineview) { + EventMsgView tmpView(ineview.startAddress()); + return write(tmpView); + } -uint64 StreamerOutputFile::write(const EventMsgView& ineview) { - /** Offset where current event starts */ - uint64 offset_to_return = streamerfile_->current_offset(); + uint64 StreamerOutputFile::write(const EventMsgView& ineview) { + /** Offset where current event starts */ + uint64 offset_to_return = streamerfile_->current_offset(); - writeEventHeader(ineview); - bool ret = streamerfile_->write((const char*)ineview.eventData(), ineview.size() - ineview.headerSize(), true); - if (ret) { - throw cms::Exception("OutputFile", "write(EventMsgView)") - << "Error writing streamer event data to " << streamerfile_->fileName() << ". Possibly the output disk " - << "is full?" << std::endl; + writeEventHeader(ineview); + bool ret = streamerfile_->write((const char*)ineview.eventData(), ineview.size() - ineview.headerSize(), true); + if (ret) { + throw cms::Exception("OutputFile", "write(EventMsgView)") + << "Error writing streamer event data to " << streamerfile_->fileName() << ". Possibly the output disk " + << "is full?" << std::endl; + } + return offset_to_return; } - return offset_to_return; -} -uint64 StreamerOutputFile::writeEventFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize) { - /** Offset where current event starts */ - uint64 offset_to_return = streamerfile_->current_offset(); + uint64 StreamerOutputFile::writeEventFragment(uint32 fragIndex, + uint32 fragCount, + const char* dataPtr, + uint32 dataSize) { + /** Offset where current event starts */ + uint64 offset_to_return = streamerfile_->current_offset(); - bool ret = streamerfile_->write(dataPtr, dataSize); - if (ret) { - throw cms::Exception("OutputFile", "writeEventFragment()") - << "Error writing streamer event data to " << streamerfile_->fileName() << ". Possibly the output disk " - << "is full?" << std::endl; + bool ret = streamerfile_->write(dataPtr, dataSize); + if (ret) { + throw cms::Exception("OutputFile", "writeEventFragment()") + << "Error writing streamer event data to " << streamerfile_->fileName() << ". Possibly the output disk " + << "is full?" << std::endl; + } + return offset_to_return; } - return offset_to_return; -} -void StreamerOutputFile::writeEventHeader(const EventMsgView& ineview) { - bool ret = streamerfile_->write((const char*)ineview.startAddress(), ineview.headerSize()); - if (ret) { - throw cms::Exception("OutputFile", "writeEventHeader") - << "Error writing streamer event data to " << streamerfile_->fileName() << ". Possibly the output disk " - << "is full?" << std::endl; + void StreamerOutputFile::writeEventHeader(const EventMsgView& ineview) { + bool ret = streamerfile_->write((const char*)ineview.startAddress(), ineview.headerSize()); + if (ret) { + throw cms::Exception("OutputFile", "writeEventHeader") + << "Error writing streamer event data to " << streamerfile_->fileName() << ". Possibly the output disk " + << "is full?" << std::endl; + } } -} -void StreamerOutputFile::write(const InitMsgBuilder& inview) { - InitMsgView tmpView(inview.startAddress()); - return write(tmpView); -} + void StreamerOutputFile::write(const InitMsgBuilder& inview) { + InitMsgView tmpView(inview.startAddress()); + return write(tmpView); + } -void StreamerOutputFile::write(const InitMsgView& inview) { - writeStart(inview); - bool ret = streamerfile_->write((const char*)inview.descData(), inview.size() - inview.headerSize(), true); - if (ret) { - throw cms::Exception("OutputFile", "write(InitMsgView)") - << "Error writing streamer header data to " << streamerfile_->fileName() << ". Possibly the output disk " - << "is full?" << std::endl; + void StreamerOutputFile::write(const InitMsgView& inview) { + writeStart(inview); + bool ret = streamerfile_->write((const char*)inview.descData(), inview.size() - inview.headerSize(), true); + if (ret) { + throw cms::Exception("OutputFile", "write(InitMsgView)") + << "Error writing streamer header data to " << streamerfile_->fileName() << ". Possibly the output disk " + << "is full?" << std::endl; + } } -} -void StreamerOutputFile::writeInitFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize) { - bool ret = streamerfile_->write((const char*)dataPtr, dataSize); - if (ret) { - throw cms::Exception("OutputFile", "writeInitFragment()") - << "Error writing streamer header data to " << streamerfile_->fileName() << ". Possibly the output disk " - << "is full?" << std::endl; + void StreamerOutputFile::writeInitFragment(uint32 fragIndex, uint32 fragCount, const char* dataPtr, uint32 dataSize) { + bool ret = streamerfile_->write((const char*)dataPtr, dataSize); + if (ret) { + throw cms::Exception("OutputFile", "writeInitFragment()") + << "Error writing streamer header data to " << streamerfile_->fileName() << ". Possibly the output disk " + << "is full?" << std::endl; + } } -} -void StreamerOutputFile::writeStart(const InitMsgView& inview) { - bool ret = streamerfile_->write((const char*)inview.startAddress(), inview.headerSize()); - if (ret) { - throw cms::Exception("OutputFile", "writeStart") - << "Error writing streamer header data to " << streamerfile_->fileName() << ". Possibly the output disk " - << "is full?" << std::endl; + void StreamerOutputFile::writeStart(const InitMsgView& inview) { + bool ret = streamerfile_->write((const char*)inview.startAddress(), inview.headerSize()); + if (ret) { + throw cms::Exception("OutputFile", "writeStart") + << "Error writing streamer header data to " << streamerfile_->fileName() << ". Possibly the output disk " + << "is full?" << std::endl; + } } -} +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index 6ba9fda6e917b..ebfa10bdeed1e 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -12,7 +12,7 @@ #include "zlib.h" -namespace edm { +namespace edm::streamer { StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) : one::OutputModuleBase::OutputModuleBase(ps), one::OutputModule(ps), @@ -71,4 +71,4 @@ namespace edm { desc.addUntracked("psetMap", {"hltPSetMap"}) ->setComment("Optionally allow the map of ParameterSets to be calculated externally."); } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc index bc79452fcc75e..ab3e987af168c 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc @@ -22,7 +22,7 @@ #include #include -namespace edm { +namespace edm::streamer { StreamerOutputModuleCommon::Parameters StreamerOutputModuleCommon::parameters(ParameterSet const& ps) { Parameters ret; ret.hltTriggerSelections = EventSelector::getEventSelectionVString(ps); @@ -300,4 +300,4 @@ namespace edm { } return ptr; } -} // namespace edm +} // namespace edm::streamer diff --git a/IOPool/Streamer/test/EventMessageTest.cpp b/IOPool/Streamer/test/EventMessageTest.cpp index 2004eecfb1f4f..e9512dae99b95 100644 --- a/IOPool/Streamer/test/EventMessageTest.cpp +++ b/IOPool/Streamer/test/EventMessageTest.cpp @@ -23,6 +23,8 @@ Disclaimer: Most of the code here is randomly written during #include "zlib.h" int main() try { + using namespace edm::streamer; + typedef std::vector Buffer; Buffer buf(2024); Buffer buf2(2024); diff --git a/IOPool/Streamer/test/ReadStreamerFile.cpp b/IOPool/Streamer/test/ReadStreamerFile.cpp index d9dcf17fbcc99..0e2eedbf19138 100644 --- a/IOPool/Streamer/test/ReadStreamerFile.cpp +++ b/IOPool/Streamer/test/ReadStreamerFile.cpp @@ -38,11 +38,13 @@ Disclaimer: Most of the code here is randomly written during #include +using namespace edm::streamer; + int readSingleStream(bool verbose) { try { // ----------- init std::string initfilename = "teststreamfile.dat"; - edm::StreamerInputFile stream_reader(initfilename); + StreamerInputFile stream_reader(initfilename); std::cout << "Trying to Read The Init message from Streamer File: " << initfilename << std::endl; InitMsgView const* init = stream_reader.startMessage(); @@ -54,7 +56,7 @@ int readSingleStream(bool verbose) { // ------- event - while (edm::StreamerInputFile::Next::kEvent == stream_reader.next()) { + while (StreamerInputFile::Next::kEvent == stream_reader.next()) { EventMsgView const* eview = stream_reader.currentRecord(); if (verbose) { std::cout << "----------EVENT-----------" << std::endl; @@ -80,7 +82,7 @@ int readMultipleStreams(bool verbose) { edm::InputFileCatalog catalog(streamFiles, ""); - edm::StreamerInputFile stream_reader(catalog.fileCatalogItems()); + StreamerInputFile stream_reader(catalog.fileCatalogItems()); std::cout << "Trying to Read The Init message from Streamer File: " << "teststreamfile.dat" << std::endl; @@ -92,7 +94,7 @@ int readMultipleStreams(bool verbose) { dumpInitView(init); } - while (edm::StreamerInputFile::Next::kStop != stream_reader.next()) { + while (StreamerInputFile::Next::kStop != stream_reader.next()) { if (stream_reader.newHeader()) { std::cout << "File Boundary has just been crossed, a new file is read" << std::endl; std::cout << "A new INIT Message is available" << std::endl; @@ -126,7 +128,7 @@ int readInvalidLFN(bool verbose) { edm::InputFileCatalog catalog(streamFiles, ""); - edm::StreamerInputFile stream_reader(catalog.fileCatalogItems()); + StreamerInputFile stream_reader(catalog.fileCatalogItems()); std::cout << "Trying to Read The Init message from Streamer File: " << "teststreamfile.dat" << std::endl; @@ -138,7 +140,7 @@ int readInvalidLFN(bool verbose) { dumpInitView(init); } - while (edm::StreamerInputFile::Next::kStop != stream_reader.next()) { + while (StreamerInputFile::Next::kStop != stream_reader.next()) { if (stream_reader.newHeader()) { std::cout << "File Boundary has just been crossed, a new file is read" << std::endl; std::cout << "A new INIT Message is available" << std::endl; diff --git a/IOPool/Streamer/test/WriteStreamerFile.cpp b/IOPool/Streamer/test/WriteStreamerFile.cpp index e6c2d57207ada..b9792a7d2750e 100644 --- a/IOPool/Streamer/test/WriteStreamerFile.cpp +++ b/IOPool/Streamer/test/WriteStreamerFile.cpp @@ -28,6 +28,8 @@ Disclaimer: Most of the code here is randomly written during #define NO_OF_EVENTS 10 +using namespace edm::streamer; + int main() try { typedef std::vector Buffer; Buffer buf(1024); From 193e3b1edc6543e2be7247d9664ca3bf77b5a8d4 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 19:08:44 +0200 Subject: [PATCH 025/301] RPCDigisV cleanup unused validation plots, unused variables, follow naming conventions --- .../MuonRPCDigis/interface/RPCDigiValid.h | 47 +----- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 158 ++---------------- 2 files changed, 20 insertions(+), 185 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index 52d6ead104a0b..d6dc808dd2e77 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -20,7 +20,7 @@ class RPCDigiValid : public DQMEDAnalyzer { public: RPCDigiValid(const edm::ParameterSet &ps); - ~RPCDigiValid() override; + ~RPCDigiValid() override = default; protected: void analyze(const edm::Event &e, const edm::EventSetup &c) override; @@ -29,47 +29,9 @@ class RPCDigiValid : public DQMEDAnalyzer { private: MonitorElement *xyview; MonitorElement *rzview; - MonitorElement *Res; - MonitorElement *ResWmin2; - MonitorElement *ResWmin1; - MonitorElement *ResWzer0; - MonitorElement *ResWplu1; - MonitorElement *ResWplu2; MonitorElement *BxDist; MonitorElement *StripProf; - // barrel layers residuals - MonitorElement *ResLayer1_barrel; - MonitorElement *ResLayer2_barrel; - MonitorElement *ResLayer3_barrel; - MonitorElement *ResLayer4_barrel; - MonitorElement *ResLayer5_barrel; - MonitorElement *ResLayer6_barrel; - - // members for EndCap's disks: - MonitorElement *ResDmin1; - MonitorElement *ResDmin2; - MonitorElement *ResDmin3; - MonitorElement *ResDplu1; - MonitorElement *ResDplu2; - MonitorElement *ResDplu3; - - // endcap layters residuals - MonitorElement *Res_Endcap1_Ring2_A; - MonitorElement *Res_Endcap1_Ring2_B; - MonitorElement *Res_Endcap1_Ring2_C; - - MonitorElement *Res_Endcap23_Ring2_A; - MonitorElement *Res_Endcap23_Ring2_B; - MonitorElement *Res_Endcap23_Ring2_C; - - MonitorElement *Res_Endcap123_Ring3_A; - MonitorElement *Res_Endcap123_Ring3_B; - MonitorElement *Res_Endcap123_Ring3_C; - - // 4 endcap - MonitorElement *ResDmin4; - MonitorElement *ResDplu4; MonitorElement *BxDisc_4Plus; MonitorElement *BxDisc_4Min; MonitorElement *xyvDplu4; @@ -78,12 +40,9 @@ class RPCDigiValid : public DQMEDAnalyzer { // Timing information MonitorElement *hDigiTimeAll, *hDigiTime, *hDigiTimeIRPC, *hDigiTimeNoIRPC; - std::string outputFile_; - std::string digiLabel; - // Tokens for accessing run data. Used for passing to edm::Event. - stanislav - edm::EDGetTokenT simHitToken; - edm::EDGetTokenT rpcDigiToken; + edm::EDGetTokenT simHitToken_; + edm::EDGetTokenT rpcDigiToken_; edm::ESGetToken rpcGeomToken_; }; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index cfac3ea4f78ad..b57cc8f004635 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -1,6 +1,7 @@ +#include "Validation/MuonRPCDigis/interface/RPCDigiValid.h" + #include "FWCore/Utilities/interface/InputTag.h" #include "SimDataFormats/CrossingFrame/interface/MixCollection.h" -#include "Validation/MuonRPCDigis/interface/RPCDigiValid.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" @@ -19,37 +20,31 @@ RPCDigiValid::RPCDigiValid(const ParameterSet &ps) { // configuration. The second param is default value module, instance and // process labels may be passed in a single string if separated by colon ':' // (@see the edm::InputTag constructor documentation) - simHitToken = consumes( + simHitToken_ = consumes( ps.getUntrackedParameter("simHitTag", edm::InputTag("g4SimHits:MuonRPCHits"))); - rpcDigiToken = consumes( + rpcDigiToken_ = consumes( ps.getUntrackedParameter("rpcDigiTag", edm::InputTag("simMuonRPCDigis"))); - outputFile_ = ps.getUntrackedParameter("outputFile", "rpcDigiValidPlots.root"); - rpcGeomToken_ = esConsumes(); } -RPCDigiValid::~RPCDigiValid() {} - void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { // Get the RPC Geometry auto rpcGeom = eventSetup.getHandle(rpcGeomToken_); - edm::Handle simHit; - edm::Handle rpcDigis; - event.getByToken(simHitToken, simHit); - event.getByToken(rpcDigiToken, rpcDigis); - - // Loop on simhits - PSimHitContainer::const_iterator simIt; + edm::Handle simHitHandle; + edm::Handle rpcDigisHandle; + event.getByToken(simHitToken_, simHitHandle); + event.getByToken(rpcDigiToken_, rpcDigisHandle); // loop over Simhit std::map> allsims; - for (simIt = simHit->begin(); simIt != simHit->end(); simIt++) { - RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId(); + for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { + RPCDetId Rsid = simIt->detUnitId(); const RPCRoll *soll = dynamic_cast(rpcGeom->roll(Rsid)); - int ptype = simIt->particleType(); + if (!soll) continue; + const int ptype = simIt->particleType(); if (ptype == 13 || ptype == -13) { std::vector buff; @@ -61,10 +56,10 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { allsims[Rsid] = buff; } - GlobalPoint p = soll->toGlobal(simIt->localPosition()); + const GlobalPoint p = soll->toGlobal(simIt->localPosition()); - double sim_x = p.x(); - double sim_y = p.y(); + const double sim_x = p.x(); + const double sim_y = p.y(); xyview->Fill(sim_x, sim_y); @@ -80,8 +75,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { rzview->Fill(p.z(), p.perp()); } // loop over Digis - RPCDigiCollection::DigiRangeIterator detUnitIt; - for (detUnitIt = rpcDigis->begin(); detUnitIt != rpcDigis->end(); ++detUnitIt) { + for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { const RPCDetId Rsid = (*detUnitIt).first; const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); @@ -91,8 +85,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { sims = allsims[Rsid]; } - int ndigi = 0; - for (RPCDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) { + for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { StripProf->Fill(digiIt->strip()); BxDist->Fill(digiIt->bx()); // bx for 4 endcaps @@ -115,87 +108,6 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { hDigiTimeNoIRPC->Fill(digiTime); } } - - if (sims.size() == 1 && ndigi == 1) { - double dis = roll->centreOfStrip(range.first->strip()).x() - sims[0]; - Res->Fill(dis); - - if (Rsid.region() == 0) { - if (Rsid.ring() == -2) - ResWmin2->Fill(dis); - else if (Rsid.ring() == -1) - ResWmin1->Fill(dis); - else if (Rsid.ring() == 0) - ResWzer0->Fill(dis); - else if (Rsid.ring() == 1) - ResWplu1->Fill(dis); - else if (Rsid.ring() == 2) - ResWplu2->Fill(dis); - // barrel layers - if (Rsid.station() == 1 && Rsid.layer() == 1) - ResLayer1_barrel->Fill(dis); - if (Rsid.station() == 1 && Rsid.layer() == 2) - ResLayer2_barrel->Fill(dis); - if (Rsid.station() == 2 && Rsid.layer() == 1) - ResLayer3_barrel->Fill(dis); - if (Rsid.station() == 2 && Rsid.layer() == 2) - ResLayer4_barrel->Fill(dis); - if (Rsid.station() == 3) - ResLayer5_barrel->Fill(dis); - if (Rsid.station() == 4) - ResLayer6_barrel->Fill(dis); - } - // endcap layers residuals - if (Rsid.region() != 0) { - if (Rsid.ring() == 2) { - if (abs(Rsid.station()) == 1) { - if (Rsid.roll() == 1) - Res_Endcap1_Ring2_A->Fill(dis); - if (Rsid.roll() == 2) - Res_Endcap1_Ring2_B->Fill(dis); - if (Rsid.roll() == 3) - Res_Endcap1_Ring2_C->Fill(dis); - } - if (abs(Rsid.station()) == 2 || abs(Rsid.station()) == 3) { - if (Rsid.roll() == 1) - Res_Endcap23_Ring2_A->Fill(dis); - if (Rsid.roll() == 2) - Res_Endcap23_Ring2_B->Fill(dis); - if (Rsid.roll() == 3) - Res_Endcap23_Ring2_C->Fill(dis); - } - } - if (Rsid.ring() == 3) { - if (Rsid.roll() == 1) - Res_Endcap123_Ring3_A->Fill(dis); - if (Rsid.roll() == 2) - Res_Endcap123_Ring3_B->Fill(dis); - if (Rsid.roll() == 3) - Res_Endcap123_Ring3_C->Fill(dis); - } - } - - if (Rsid.region() == (+1)) { - if (Rsid.station() == 1) - ResDplu1->Fill(dis); - else if (Rsid.station() == 2) - ResDplu2->Fill(dis); - else if (Rsid.station() == 3) - ResDplu3->Fill(dis); - else if (Rsid.station() == 4) - ResDplu4->Fill(dis); - } - if (Rsid.region() == (-1)) { - if (Rsid.station() == 1) - ResDmin1->Fill(dis); - else if (Rsid.station() == 2) - ResDmin2->Fill(dis); - else if (Rsid.station() == 3) - ResDmin3->Fill(dis); - else if (Rsid.station() == 4) - ResDmin4->Fill(dis); - } - } } } @@ -208,19 +120,6 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.); rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.); - Res = booker.book1D("Digi_SimHit_difference", "Digi_SimHit_difference", 300, -8, 8); - ResWmin2 = booker.book1D("W_Min2_Residuals", "W_Min2_Residuals", 400, -8, 8); - ResWmin1 = booker.book1D("W_Min1_Residuals", "W_Min1_Residuals", 400, -8, 8); - ResWzer0 = booker.book1D("W_Zer0_Residuals", "W_Zer0_Residuals", 400, -8, 8); - ResWplu1 = booker.book1D("W_Plu1_Residuals", "W_Plu1_Residuals", 400, -8, 8); - ResWplu2 = booker.book1D("W_Plu2_Residuals", "W_Plu2_Residuals", 400, -8, 8); - - ResLayer1_barrel = booker.book1D("ResLayer1_barrel", "ResLayer1_barrel", 400, -8, 8); - ResLayer2_barrel = booker.book1D("ResLayer2_barrel", "ResLayer2_barrel", 400, -8, 8); - ResLayer3_barrel = booker.book1D("ResLayer3_barrel", "ResLayer3_barrel", 400, -8, 8); - ResLayer4_barrel = booker.book1D("ResLayer4_barrel", "ResLayer4_barrel", 400, -8, 8); - ResLayer5_barrel = booker.book1D("ResLayer5_barrel", "ResLayer5_barrel", 400, -8, 8); - ResLayer6_barrel = booker.book1D("ResLayer6_barrel", "ResLayer6_barrel", 400, -8, 8); BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); @@ -228,29 +127,6 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); - // endcap residuals - ResDmin1 = booker.book1D("Disk_Min1_Residuals", "Disk_Min1_Residuals", 400, -8, 8); - ResDmin2 = booker.book1D("Disk_Min2_Residuals", "Disk_Min2_Residuals", 400, -8, 8); - ResDmin3 = booker.book1D("Disk_Min3_Residuals", "Disk_Min3_Residuals", 400, -8, 8); - ResDplu1 = booker.book1D("Disk_Plu1_Residuals", "Disk_Plu1_Residuals", 400, -8, 8); - ResDplu2 = booker.book1D("Disk_Plu2_Residuals", "Disk_Plu2_Residuals", 400, -8, 8); - ResDplu3 = booker.book1D("Disk_Plu3_Residuals", "Disk_Plu3_Residuals", 400, -8, 8); - - ResDmin4 = booker.book1D("Disk_Min4_Residuals", "Disk_Min4_Residuals", 400, -8, 8); - ResDplu4 = booker.book1D("Disk_Plu4_Residuals", "Disk_Plu4_Residuals", 400, -8, 8); - - Res_Endcap1_Ring2_A = booker.book1D("Res_Endcap1_Ring2_A", "Res_Endcap1_Ring2_A", 400, -8, 8); - Res_Endcap1_Ring2_B = booker.book1D("Res_Endcap1_Ring2_B", "Res_Endcap1_Ring2_B", 400, -8, 8); - Res_Endcap1_Ring2_C = booker.book1D("Res_Endcap1_Ring2_C", "Res_Endcap1_Ring2_C", 400, -8, 8); - - Res_Endcap23_Ring2_A = booker.book1D("Res_Endcap23_Ring2_A", "Res_Endcap23_Ring2_A", 400, -8, 8); - Res_Endcap23_Ring2_B = booker.book1D("Res_Endcap23_Ring2_B", "Res_Endcap23_Ring2_B", 400, -8, 8); - Res_Endcap23_Ring2_C = booker.book1D("Res_Endcap23_Ring2_C", "Res_Endcap23_Ring2_C", 400, -8, 8); - - Res_Endcap123_Ring3_A = booker.book1D("Res_Endcap123_Ring3_A", "Res_Endcap123_Ring3_A", 400, -8, 8); - Res_Endcap123_Ring3_B = booker.book1D("Res_Endcap123_Ring3_B", "Res_Endcap123_Ring3_B", 400, -8, 8); - Res_Endcap123_Ring3_C = booker.book1D("Res_Endcap123_Ring3_C", "Res_Endcap123_Ring3_C", 400, -8, 8); - // Timing informations hDigiTimeAll = booker.book1D("DigiTimeAll", "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5); From 1ce2b6f075d26c6c5a6483b462909e5a63306a2b Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 19:23:18 +0200 Subject: [PATCH 026/301] remove unused variable, due to removal of residual plots --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 38 ++++++--------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index b57cc8f004635..d2005263cae07 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -38,38 +38,22 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { event.getByToken(rpcDigiToken_, rpcDigisHandle); // loop over Simhit - std::map> allsims; - for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { - RPCDetId Rsid = simIt->detUnitId(); - const RPCRoll *soll = dynamic_cast(rpcGeom->roll(Rsid)); - if (!soll) continue; - const int ptype = simIt->particleType(); - - if (ptype == 13 || ptype == -13) { - std::vector buff; - if (allsims.find(Rsid) != allsims.end()) { - buff = allsims[Rsid]; - } - - buff.push_back(simIt->localPosition().x()); - - allsims[Rsid] = buff; - } - const GlobalPoint p = soll->toGlobal(simIt->localPosition()); - - const double sim_x = p.x(); - const double sim_y = p.y(); + const RPCDetId Rsid = simIt->detUnitId(); + const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + if (!roll) + continue; - xyview->Fill(sim_x, sim_y); + const GlobalPoint p = roll->toGlobal(simIt->localPosition()); + xyview->Fill(p.x(), p.y()); if (Rsid.region() == (+1)) { if (Rsid.station() == 4) { - xyvDplu4->Fill(sim_x, sim_y); + xyvDplu4->Fill(p.x(), p.y()); } } else if (Rsid.region() == (-1)) { if (Rsid.station() == 4) { - xyvDmin4->Fill(sim_x, sim_y); + xyvDmin4->Fill(p.x(), p.y()); } } rzview->Fill(p.z(), p.perp()); @@ -78,12 +62,10 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { const RPCDetId Rsid = (*detUnitIt).first; const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + if (!roll) + continue; const RPCDigiCollection::Range &range = (*detUnitIt).second; - std::vector sims; - if (allsims.find(Rsid) != allsims.end()) { - sims = allsims[Rsid]; - } for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { StripProf->Fill(digiIt->strip()); From 308c88930eee9222af350a07d9ba0c677004857c Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:28:48 +0200 Subject: [PATCH 027/301] add simHit position and strip profiles splited by regions --- .../MuonRPCDigis/interface/RPCDigiValid.h | 17 +++- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 92 +++++++++++++------ 2 files changed, 75 insertions(+), 34 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index d6dc808dd2e77..c7c41118ae3b7 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -27,15 +27,22 @@ class RPCDigiValid : public DQMEDAnalyzer { void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; private: - MonitorElement *xyview; - MonitorElement *rzview; + // RZ and XY views + MonitorElement *hRZ_; + + MonitorElement *hXY_Barrel_; + std::map hXY_Endcap_; + + // Strip profile + MonitorElement *hStripProf; + MonitorElement *hStripProf_RB12_, *hStripProf_RB34_; + MonitorElement *hStripProf_Endcap_, *hStripProf_IRPC_; + + // Bunch crossing distributions MonitorElement *BxDist; - MonitorElement *StripProf; MonitorElement *BxDisc_4Plus; MonitorElement *BxDisc_4Min; - MonitorElement *xyvDplu4; - MonitorElement *xyvDmin4; // Timing information MonitorElement *hDigiTimeAll, *hDigiTime, *hDigiTimeIRPC, *hDigiTimeNoIRPC; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index d2005263cae07..2d6c6a0d4ae1d 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -10,6 +10,7 @@ #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h" #include +#include using namespace std; using namespace edm; @@ -39,43 +40,63 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { // loop over Simhit for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { - const RPCDetId Rsid = simIt->detUnitId(); - const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + const RPCDetId rsid = simIt->detUnitId(); + const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); if (!roll) continue; - - const GlobalPoint p = roll->toGlobal(simIt->localPosition()); - xyview->Fill(p.x(), p.y()); - - if (Rsid.region() == (+1)) { - if (Rsid.station() == 4) { - xyvDplu4->Fill(p.x(), p.y()); - } - } else if (Rsid.region() == (-1)) { - if (Rsid.station() == 4) { - xyvDmin4->Fill(p.x(), p.y()); - } + const int region = rsid.region(); + const GlobalPoint gp = roll->toGlobal(simIt->localPosition()); + + hRZ_->Fill(gp.z(), gp.perp()); + + if (region == 0) { + // Barrel + hXY_Barrel_->Fill(gp.x(), gp.y()); + } else { + // Endcap + const int disk = region * rsid.station(); + auto match = hXY_Endcap_.find(disk); + if (match != hXY_Endcap_.end()) + match->second->Fill(gp.x(), gp.y()); } - rzview->Fill(p.z(), p.perp()); } // loop over Digis for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { - const RPCDetId Rsid = (*detUnitIt).first; - const RPCRoll *roll = dynamic_cast(rpcGeom->roll(Rsid)); + const RPCDetId rsid = (*detUnitIt).first; + const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); if (!roll) continue; + const int region = rsid.region(); const RPCDigiCollection::Range &range = (*detUnitIt).second; for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { - StripProf->Fill(digiIt->strip()); + // Strip profile + const int strip = digiIt->strip(); + hStripProf->Fill(strip); + + if (region == 0) { + // Barrel + const int station = rsid.station(); + if (station == 1 or station == 2) + hStripProf_RB12_->Fill(strip); + else if (station == 3 or station == 4) + hStripProf_RB34_->Fill(strip); + } else { + const int ring = rsid.ring(); + if (ring == 1) + hStripProf_IRPC_->Fill(strip); + else + hStripProf_Endcap_->Fill(strip); + } + BxDist->Fill(digiIt->bx()); // bx for 4 endcaps - if (Rsid.region() == (+1)) { - if (Rsid.station() == 4) + if (rsid.region() == (+1)) { + if (rsid.station() == 4) BxDisc_4Plus->Fill(digiIt->bx()); - } else if (Rsid.region() == (-1)) { - if (Rsid.station() == 4) + } else if (rsid.region() == (-1)) { + if (rsid.station() == 4) BxDisc_4Min->Fill(digiIt->bx()); } @@ -96,16 +117,29 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run, edm::EventSetup const &eSetup) { booker.setCurrentFolder("RPCDigisV/RPCDigis"); - xyview = booker.book2D("X_Vs_Y_View", "X_Vs_Y_View", 155, -775., 775., 155, -775., 775.); - - xyvDplu4 = booker.book2D("Dplu4_XvsY", "Dplu4_XvsY", 155, -775., 775., 155, -775., 775.); - xyvDmin4 = booker.book2D("Dmin4_XvsY", "Dmin4_XvsY", 155, -775., 775., 155, -775., 775.); + // RZ plot + hRZ_ = booker.book2D("RZ", "RZ", 220, -1100., 1100., 60, 0., 780.); + + // XY plots + const int nbinsXY = 155; + const double xmaxXY = 775; + hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + for (int disk = 1; disk <= 4; ++disk) { + const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); + const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); + hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + } - rzview = booker.book2D("R_Vs_Z_View", "R_Vs_Z_View", 216, -1080., 1080., 52, 260., 780.); + // Strip profile + hStripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); + hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 50, 0, 50); + hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); + hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); + // Bunch crossing BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); - StripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); - BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); From 29e51f3a4f0ac8f54400ca8d45cfbdf28eb51369 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:39:30 +0200 Subject: [PATCH 028/301] rename variable to follow convention --- .../MuonRPCDigis/interface/RPCDigiValid.h | 11 +++-- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 42 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index c7c41118ae3b7..d2810302fa83a 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -34,18 +34,17 @@ class RPCDigiValid : public DQMEDAnalyzer { std::map hXY_Endcap_; // Strip profile - MonitorElement *hStripProf; + MonitorElement *hStripProf_; MonitorElement *hStripProf_RB12_, *hStripProf_RB34_; MonitorElement *hStripProf_Endcap_, *hStripProf_IRPC_; // Bunch crossing distributions - MonitorElement *BxDist; - - MonitorElement *BxDisc_4Plus; - MonitorElement *BxDisc_4Min; + MonitorElement *hBxDist_; + MonitorElement *hBxDisc_4Plus_; + MonitorElement *hBxDisc_4Min_; // Timing information - MonitorElement *hDigiTimeAll, *hDigiTime, *hDigiTimeIRPC, *hDigiTimeNoIRPC; + MonitorElement *hDigiTimeAll_, *hDigiTime_, *hDigiTimeIRPC_, *hDigiTimeNoIRPC_; // Tokens for accessing run data. Used for passing to edm::Event. - stanislav edm::EDGetTokenT simHitToken_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 2d6c6a0d4ae1d..87b2e225b1bc8 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -76,39 +76,39 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { hStripProf->Fill(strip); if (region == 0) { - // Barrel const int station = rsid.station(); if (station == 1 or station == 2) hStripProf_RB12_->Fill(strip); else if (station == 3 or station == 4) hStripProf_RB34_->Fill(strip); } else { - const int ring = rsid.ring(); - if (ring == 1) + if (roll->isIRPC()) hStripProf_IRPC_->Fill(strip); else hStripProf_Endcap_->Fill(strip); } - BxDist->Fill(digiIt->bx()); + // Bunch crossing + const int bx = digiIt->bx(); + hBxDist_->Fill(bx); // bx for 4 endcaps - if (rsid.region() == (+1)) { - if (rsid.station() == 4) - BxDisc_4Plus->Fill(digiIt->bx()); - } else if (rsid.region() == (-1)) { - if (rsid.station() == 4) - BxDisc_4Min->Fill(digiIt->bx()); + if (rsid.station() == 4) { + if (region == 1) { + hBxDisc_4Plus_->Fill(bx); + } else if (region == -1) { + hBxDisc_4Min_->Fill(bx); + } } // Fill timing information const double digiTime = digiIt->hasTime() ? digiIt->time() : digiIt->bx() * 25; - hDigiTimeAll->Fill(digiTime); + hDigiTimeAll_->Fill(digiTime); if (digiIt->hasTime()) { - hDigiTime->Fill(digiTime); + hDigiTime_->Fill(digiTime); if (roll->isIRPC()) - hDigiTimeIRPC->Fill(digiTime); + hDigiTimeIRPC_->Fill(digiTime); else - hDigiTimeNoIRPC->Fill(digiTime); + hDigiTimeNoIRPC_->Fill(digiTime); } } } @@ -139,14 +139,14 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); // Bunch crossing - BxDist = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); - BxDisc_4Plus = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); - BxDisc_4Min = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); + hBxDist_ = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); + hBxDisc_4Plus_ = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); + hBxDisc_4Min_ = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); // Timing informations - hDigiTimeAll = + hDigiTimeAll_ = booker.book1D("DigiTimeAll", "Digi time including present electronics;Digi time (ns)", 100, -12.5, 12.5); - hDigiTime = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5); - hDigiTimeIRPC = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); - hDigiTimeNoIRPC = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); + hDigiTime_ = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5); + hDigiTimeIRPC_ = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); + hDigiTimeNoIRPC_ = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); } From 10e8478ccc4a367954a26c2f07d4ab846c382508 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:40:51 +0200 Subject: [PATCH 029/301] fix typo --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 87b2e225b1bc8..63df420fbbc4e 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -73,7 +73,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { for (auto digiIt = range.first; digiIt != range.second; ++digiIt) { // Strip profile const int strip = digiIt->strip(); - hStripProf->Fill(strip); + hStripProf_->Fill(strip); if (region == 0) { const int station = rsid.station(); @@ -132,7 +132,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run } // Strip profile - hStripProf = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); + hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); hStripProf_RB34_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 50, 0, 50); hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); From 4d3e7019800953a6c6e147c732bda4052527790c Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 3 May 2024 20:59:15 +0200 Subject: [PATCH 030/301] fix typo --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 63df420fbbc4e..d781eef650316 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -134,7 +134,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run // Strip profile hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); - hStripProf_RB34_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 50, 0, 50); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 50, 0, 50); hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); From 01b9d5da6285ff891e9c8a94fd0a51d2cd80337d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 24 Apr 2024 13:08:55 -0500 Subject: [PATCH 031/301] Moved event meta-data storage in streamer files The event meta-data (e.g. BranchLists) is now added as an EventMsg before the following EventMsg for which it applies. This added EventMsg contains no data products. When seen, the added EventMsg is handled as an artificial file boundary in order to cause the needed stream synchronization. This change is needed to handle how HLT merges parts of streamer files which might have different meta-data. --- .../interface/WatcherSource.h | 2 +- .../interface/WatcherStreamFileReader.h | 15 +++--- .../src/WatcherStreamFileReader.cc | 27 ++++++----- .../EcalLaserSorting/test/RunStreamer.sh | 15 ++++-- .../EcalLaserSorting/test/streamIn_cfg.py | 36 ++++++++++++++- .../StreamerIO/plugins/DQMStreamerReader.cc | 37 +++++++++++++-- .../StreamerIO/plugins/DQMStreamerReader.h | 9 ++-- .../Streamer/interface/StreamedProducts.h | 30 ++++++++---- DataFormats/Streamer/src/classes_def.xml | 6 ++- .../plugins/GlobalEvFOutputModule.cc | 14 ++++-- IOPool/Streamer/interface/EventMessage.h | 1 + IOPool/Streamer/interface/StreamSerializer.h | 24 +++++++--- .../Streamer/interface/StreamerInputModule.h | 46 +++++++++++++++---- .../Streamer/interface/StreamerInputSource.h | 18 ++++++-- .../interface/StreamerOutputModuleBase.h | 1 + .../interface/StreamerOutputModuleCommon.h | 14 +++++- IOPool/Streamer/plugins/Module.cc | 3 -- IOPool/Streamer/src/EventMessage.cc | 16 ++++--- IOPool/Streamer/src/StreamSerializer.cc | 43 ++++++++++++----- IOPool/Streamer/src/StreamerFileReader.cc | 43 +++++++++++++++-- IOPool/Streamer/src/StreamerFileReader.h | 2 + IOPool/Streamer/src/StreamerInputSource.cc | 43 ++++++++++++----- .../Streamer/src/StreamerOutputModuleBase.cc | 12 +++-- .../src/StreamerOutputModuleCommon.cc | 46 +++++++++++++------ ...RefProductIDMetadataConsistencyStreamer.sh | 2 +- 25 files changed, 376 insertions(+), 129 deletions(-) diff --git a/CalibCalorimetry/EcalLaserSorting/interface/WatcherSource.h b/CalibCalorimetry/EcalLaserSorting/interface/WatcherSource.h index 45cbeb8190ef7..791a830305b3f 100644 --- a/CalibCalorimetry/EcalLaserSorting/interface/WatcherSource.h +++ b/CalibCalorimetry/EcalLaserSorting/interface/WatcherSource.h @@ -4,6 +4,6 @@ #include "CalibCalorimetry/EcalLaserSorting/interface/WatcherStreamFileReader.h" #include "IOPool/Streamer/interface/StreamerInputModule.h" -typedef edm::StreamerInputModule WatcherSource; +typedef edm::streamer::StreamerInputModule WatcherSource; #endif //WatcherSourceModule_H not defined diff --git a/CalibCalorimetry/EcalLaserSorting/interface/WatcherStreamFileReader.h b/CalibCalorimetry/EcalLaserSorting/interface/WatcherStreamFileReader.h index ce77f03ec9d82..a4f7870a72c7f 100644 --- a/CalibCalorimetry/EcalLaserSorting/interface/WatcherStreamFileReader.h +++ b/CalibCalorimetry/EcalLaserSorting/interface/WatcherStreamFileReader.h @@ -1,5 +1,5 @@ -#ifndef IOPool_Streamer_StreamerFileReader_h -#define IOPool_Streamer_StreamerFileReader_h +#ifndef CalibCalorimetry_EcalLaserSorting_WatcherStreamFileReader_h +#define CalibCalorimetry_EcalLaserSorting_WatcherStreamFileReader_h #include "IOPool/Streamer/interface/InitMessage.h" #include "IOPool/Streamer/interface/EventMessage.h" @@ -19,7 +19,7 @@ * This protection is obviously not full proof, especially to transfer lag. */ -namespace edm { +namespace edm::streamer { class StreamerInputFile; } @@ -28,15 +28,16 @@ class WatcherStreamFileReader { WatcherStreamFileReader(edm::ParameterSet const& pset); ~WatcherStreamFileReader(); - const InitMsgView* getHeader(); - const EventMsgView* getNextEvent(); + const edm::streamer::InitMsgView* getHeader(); + const edm::streamer::EventMsgView* getNextEvent(); const bool newHeader(); - edm::StreamerInputFile* getInputFile(); + edm::streamer::StreamerInputFile* getInputFile(); void closeFile(); private: + void moveJustReadFile(); /** Directory to look for streamer files */ std::string inputDir_; @@ -59,7 +60,7 @@ class WatcherStreamFileReader { /** Cached input file stream */ - std::unique_ptr streamerInputFile_; + std::unique_ptr streamerInputFile_; std::string fileName_; diff --git a/CalibCalorimetry/EcalLaserSorting/src/WatcherStreamFileReader.cc b/CalibCalorimetry/EcalLaserSorting/src/WatcherStreamFileReader.cc index 262ebe485333e..56b6126931b50 100644 --- a/CalibCalorimetry/EcalLaserSorting/src/WatcherStreamFileReader.cc +++ b/CalibCalorimetry/EcalLaserSorting/src/WatcherStreamFileReader.cc @@ -19,6 +19,7 @@ //using namespace edm; using namespace std; +using namespace edm::streamer; //std::string WatcherStreamFileReader::fileName_; @@ -153,13 +154,10 @@ WatcherStreamFileReader::WatcherStreamFileReader(edm::ParameterSet const& pset) WatcherStreamFileReader::~WatcherStreamFileReader() {} -const bool WatcherStreamFileReader::newHeader() { - edm::StreamerInputFile* inputFile = getInputFile(); - return inputFile ? inputFile->newHeader() : false; -} +const bool WatcherStreamFileReader::newHeader() { return getInputFile() != nullptr; } const InitMsgView* WatcherStreamFileReader::getHeader() { - edm::StreamerInputFile* inputFile = getInputFile(); + StreamerInputFile* inputFile = getInputFile(); //TODO: shall better send an exception... if (inputFile == nullptr) { @@ -177,21 +175,20 @@ const InitMsgView* WatcherStreamFileReader::getHeader() { const EventMsgView* WatcherStreamFileReader::getNextEvent() { if (end_) { - closeFile(); + moveJustReadFile(); return nullptr; } - edm::StreamerInputFile* inputFile; - - //go to next input file, till no new event is found - while ((inputFile = getInputFile()) != nullptr && inputFile->next() != edm::StreamerInputFile::Next::kEvent) { - closeFile(); + StreamerInputFile* inputFile; + if ((inputFile = getInputFile()) != nullptr and inputFile->next() == StreamerInputFile::Next::kStop) { + moveJustReadFile(); + return nullptr; } return inputFile == nullptr ? nullptr : inputFile->currentRecord(); } -edm::StreamerInputFile* WatcherStreamFileReader::getInputFile() { +StreamerInputFile* WatcherStreamFileReader::getInputFile() { char* lineptr = nullptr; size_t n = 0; static stringstream cmd; @@ -379,7 +376,7 @@ edm::StreamerInputFile* WatcherStreamFileReader::getInputFile() { cout << "[WatcherSource " << now() << "]" << " Opening file " << fileName_ << "\n" << flush; - streamerInputFile_ = std::make_unique(fileName_); + streamerInputFile_ = std::make_unique(fileName_); ofstream f(".watcherfile"); f << fileName_; @@ -392,7 +389,9 @@ edm::StreamerInputFile* WatcherStreamFileReader::getInputFile() { return streamerInputFile_.get(); } -void WatcherStreamFileReader::closeFile() { +void WatcherStreamFileReader::closeFile() {} + +void WatcherStreamFileReader::moveJustReadFile() { if (streamerInputFile_.get() == nullptr) return; //delete the streamer input file: diff --git a/CalibCalorimetry/EcalLaserSorting/test/RunStreamer.sh b/CalibCalorimetry/EcalLaserSorting/test/RunStreamer.sh index f404bfdc23298..0dd340c27dbc7 100755 --- a/CalibCalorimetry/EcalLaserSorting/test/RunStreamer.sh +++ b/CalibCalorimetry/EcalLaserSorting/test/RunStreamer.sh @@ -10,30 +10,35 @@ echo "LOCAL_TEST_DIR = $SCRAM_TEST_PATH" RC=0 mkdir inDir +echo "test padding" cmsRun ${SCRAM_TEST_PATH}/streamOutPadding_cfg.py > outp 2>&1 || die "cmsRun streamOutPadding_cfg.py" $? cp teststreamfile.dat teststreamfile.padding mv teststreamfile.dat inDir/ -timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py > inp 2>&1 || die "cmsRun streamIn_cfg.py" $? +timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py > inp 2>&1 || die "cmsRun streamIn_cfg.py with padding" $? rm -rf inDir mkdir inDir + +echo "test original" cmsRun ${SCRAM_TEST_PATH}/streamOut_cfg.py > out 2>&1 || die "cmsRun streamOut_cfg.py" $? cp teststreamfile.dat teststreamfile.original mv teststreamfile.dat inDir -timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py > in 2>&1 || die "cmsRun streamIn_cfg.py" $? +timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py > in 2>&1 || die "cmsRun streamIn_cfg.py original" $? +echo "test original and alt" rm watcherSourceToken cp teststreamfile.original inDir/teststreamfile.dat cmsRun ${SCRAM_TEST_PATH}/streamOutAlt_cfg.py > outAlt 2>&1 || die "cmsRun streamOutAlt_cfg.py" $? mv teststreamfile_alt.dat inDir -timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py >alt 2>&1 || die "cmsRun streamIn_cfg.py" $? +timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py --alt >alt 2>&1 || die "cmsRun streamIn_cfg.py alt" $? #timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamInAlt_cfg.py > alt 2>&1 || die "cmsRun streamInAlt_cfg.py" $? +echo "test ext" rm watcherSourceToken cp teststreamfile.original inDir/teststreamfile.dat -cmsRun ${SCRAM_TEST_PATH}/streamOutExt_cfg.py > outExt 2>&1 || die "cmsRun streamOutExt_cfg.py" $? +cmsRun ${SCRAM_TEST_PATH}/streamOutExt_cfg.py > outExt 2>&1 || die "cmsRun streamOutExt_cfg.py" $? mv teststreamfile_ext.dat inDir -timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py > ext 2>&1 || die "cmsRun streamIn_cfg.py" $? +timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamIn_cfg.py --ext > ext 2>&1 || die "cmsRun streamIn_cfg.py ext" $? #timeout --signal SIGTERM 180 cmsRun ${SCRAM_TEST_PATH}/streamInExt_cfg.py > ext 2>&1 || die "cmsRun streamInExt_cfg.py" $? # echo "CHECKSUM = 1" > out diff --git a/CalibCalorimetry/EcalLaserSorting/test/streamIn_cfg.py b/CalibCalorimetry/EcalLaserSorting/test/streamIn_cfg.py index 03a986f7a1052..ec6d8e24671c7 100644 --- a/CalibCalorimetry/EcalLaserSorting/test/streamIn_cfg.py +++ b/CalibCalorimetry/EcalLaserSorting/test/streamIn_cfg.py @@ -1,5 +1,16 @@ import FWCore.ParameterSet.Config as cms +import argparse +import sys + +parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test streamer input') + +parser.add_argument("--alt", help="Have filter succeed", action="store_true") +parser.add_argument("--ext", help="Switch the order of dependencies", action="store_true") + +args = parser.parse_args() + + process = cms.Process("TRANSFER") import FWCore.Framework.test.cmsExceptionsFatal_cff @@ -26,8 +37,31 @@ product_to_get = cms.string('m1') ) +ids = [cms.EventID(1,0,0), cms.EventID(1,1,0)] +for e in range(10123456789, 10123456839): + ids.append(cms.EventID(1,1,e)) +if args.alt: + for e in range(15123456789, 15123456839): + ids.append(cms.EventID(1,1,e)) + +if args.ext: + ids.append(cms.EventID(1,1,0)) + ids.append(cms.EventID(1,0,0)) + ids.append(cms.EventID(1,0,0)) + ids.append(cms.EventID(1,1,0)) + for e in range(20123456789, 20123456839): + ids.append(cms.EventID(1,1,e)) + +ids.append(cms.EventID(1,1,0)) +ids.append(cms.EventID(1,0,0)) + +process.check = cms.EDAnalyzer("RunLumiEventChecker", + eventSequence = cms.untracked.VEventID(ids) +) + + process.out = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string('myout.root') ) -process.end = cms.EndPath(process.a1*process.out) +process.end = cms.EndPath(process.a1*process.out*process.check) diff --git a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc index 97aef9ff623b0..1de5c8563e799 100644 --- a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc +++ b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc @@ -82,6 +82,13 @@ namespace dqmservices { fiterator_.logFileAction("DQMStreamerReader initialised."); } + void DQMStreamerReader::setupMetaData(edm::streamer::InitMsgView const& msg, bool subsequent) { + deserializeAndMergeWithRegistry(msg, subsequent); + auto event = getEventMsg(); + assert(event and event->isEventMetaData()); + deserializeEventMetaData(*event); + updateEventMetaData(); + } void DQMStreamerReader::openFileImp_(const DQMFileIterator::LumiEntry& entry) { processedEventPerLs_ = 0; @@ -92,7 +99,7 @@ namespace dqmservices { InitMsgView const* header = getHeaderMsg(); if (isFirstFile_) { - deserializeAndMergeWithRegistry(*header, false); + setupMetaData(*header, false); } // dump the list of HLT trigger name from the header @@ -136,9 +143,14 @@ namespace dqmservices { return; } + if (artificialFileBoundary_) { + updateEventMetaData(); + artificialFileBoundary_ = false; + return; + } //Get header/init from reader InitMsgView const* header = getHeaderMsg(); - deserializeAndMergeWithRegistry(*header, true); + setupMetaData(*header, true); } bool DQMStreamerReader::openNextFileImp_() { @@ -286,6 +298,25 @@ namespace dqmservices { // this means end of file, so close the file closeFileImp_("eof"); } else { + //NOTE: at this point need to see if meta data checksum changed. If it did + // we need to issue a 'new File' transition + if (eview->isEventMetaData()) { + auto lastEventMetaData = presentEventMetaDataChecksum(); + if (eventMetaDataChecksum(*eview) != lastEventMetaData) { + deserializeEventMetaData(*eview); + artificialFileBoundary_ = true; + return nullptr; + } else { + //skipping + eview = getEventMsg(); + assert( (eview==nullptr) or (not eview->isEventMetaData())); + if (eview == nullptr) { + closeFileImp_("eof"); + continue; + } + } + } + if (!acceptEvent(eview)) { continue; } else { @@ -304,7 +335,7 @@ namespace dqmservices { try { EventMsgView const* eview = prepareNextEvent(); if (eview == nullptr) { - if (file_.streamFile_ and file_.streamFile_->newHeader()) { + if (artificialFileBoundary_ or (file_.streamFile_ and file_.streamFile_->newHeader())) { return Next::kFile; } return Next::kStop; diff --git a/DQMServices/StreamerIO/plugins/DQMStreamerReader.h b/DQMServices/StreamerIO/plugins/DQMStreamerReader.h index 547f1f8cbfa17..bf13f51784fb1 100644 --- a/DQMServices/StreamerIO/plugins/DQMStreamerReader.h +++ b/DQMServices/StreamerIO/plugins/DQMStreamerReader.h @@ -1,13 +1,11 @@ #ifndef DQMServices_StreamerIO_DQMStreamerReader_h #define DQMServices_StreamerIO_DQMStreamerReader_h -#include "FWCore/ServiceRegistry/interface/Service.h" #include "IOPool/Streamer/interface/StreamerInputSource.h" #include "IOPool/Streamer/interface/StreamerInputFile.h" #include "IOPool/Streamer/interface/MsgTools.h" #include "DQMFileIterator.h" -#include "DQMMonitoringService.h" #include "TriggerSelector.h" #include @@ -44,6 +42,7 @@ namespace dqmservices { edm::streamer::InitMsgView const* getHeaderMsg(); edm::streamer::EventMsgView const* getEventMsg(); + void setupMetaData(edm::streamer::InitMsgView const& msg, bool subsequent); edm::streamer::EventMsgView const* prepareNextEvent(); bool isFirstFile_ = true; @@ -65,6 +64,9 @@ namespace dqmservices { bool matchTriggerSel_ = false; bool setMatchTriggerSel(std::vector const& tnames); + //If the event meta data changes while reading a file, we need to + // cause a file transition to happen to allow synchronous update + bool artificialFileBoundary_ = false; struct OpenFile { std::unique_ptr streamFile_; DQMFileIterator::LumiEntry lumi_; @@ -75,9 +77,6 @@ namespace dqmservices { std::shared_ptr eventSkipperByID_; std::shared_ptr triggerSelector_; - - /* this is for monitoring */ - edm::Service mon_; }; } // namespace dqmservices diff --git a/DataFormats/Streamer/interface/StreamedProducts.h b/DataFormats/Streamer/interface/StreamedProducts.h index 2bc6e2a2d64e4..68f78a5431c70 100644 --- a/DataFormats/Streamer/interface/StreamedProducts.h +++ b/DataFormats/Streamer/interface/StreamedProducts.h @@ -67,6 +67,9 @@ namespace edm { typedef std::vector SendProds; // ------------------------------------------ + // Contains either Event data or meta data about an Event. The header of the + // message contains which way an instance of this class is to be interpreted + // via the use of EventMsgView::isEventMetaData() class SendEvent { public: @@ -74,17 +77,29 @@ namespace edm { SendEvent(EventAuxiliary const& aux, ProcessHistory const& processHistory, EventSelectionIDVector const& eventSelectionIDs, - BranchListIndexes const& branchListIndexes) + BranchListIndexes const& branchListIndexes, + BranchIDLists const& branchIDLists, + ThinnedAssociationsHelper const& thinnedAssociationsHelper, + uint32_t metaDataChecksum) : aux_(aux), processHistory_(processHistory), eventSelectionIDs_(eventSelectionIDs), branchListIndexes_(branchListIndexes), - products_() {} + branchIDLists_(branchIDLists), + thinnedAssociationsHelper_(thinnedAssociationsHelper), + products_(), + metaDataChecksum_(metaDataChecksum) {} EventAuxiliary const& aux() const { return aux_; } SendProds const& products() const { return products_; } ProcessHistory const& processHistory() const { return processHistory_; } EventSelectionIDVector const& eventSelectionIDs() const { return eventSelectionIDs_; } BranchListIndexes const& branchListIndexes() const { return branchListIndexes_; } + //This will only hold values for EventMetaData messages + BranchIDLists const& branchIDLists() const { return branchIDLists_; } + //This will only hold values for EventMetaData messages + ThinnedAssociationsHelper const& thinnedAssociationsHelper() const { return thinnedAssociationsHelper_; } + //This is the adler32 checksum of the EventMetaData associated with this Event + uint32_t metaDataChecksum() const { return metaDataChecksum_; } SendProds& products() { return products_; } private: @@ -92,7 +107,10 @@ namespace edm { ProcessHistory processHistory_; EventSelectionIDVector eventSelectionIDs_; BranchListIndexes branchListIndexes_; + BranchIDLists branchIDLists_; + ThinnedAssociationsHelper thinnedAssociationsHelper_; SendProds products_; + uint32_t metaDataChecksum_; // other tables necessary for provenance lookup }; @@ -105,21 +123,13 @@ namespace edm { SendJobHeader() {} SendDescs const& descs() const { return descs_; } ParameterSetMap const& processParameterSet() const { return processParameterSet_; } - BranchIDLists const& branchIDLists() const { return branchIDLists_; } - ThinnedAssociationsHelper const& thinnedAssociationsHelper() const { return thinnedAssociationsHelper_; } void push_back(BranchDescription const& bd) { descs_.push_back(bd); } void setParameterSetMap(ParameterSetMap const& psetMap) { processParameterSet_ = psetMap; } - void setBranchIDLists(BranchIDLists const& bidlists) { branchIDLists_ = bidlists; } - void setThinnedAssociationsHelper(ThinnedAssociationsHelper const& v) { thinnedAssociationsHelper_ = v; } void initializeTransients(); private: SendDescs descs_; ParameterSetMap processParameterSet_; - BranchIDLists branchIDLists_; - ThinnedAssociationsHelper thinnedAssociationsHelper_; - // trigger bit descriptions will be added here and permanent - // provenance values }; } // namespace edm diff --git a/DataFormats/Streamer/src/classes_def.xml b/DataFormats/Streamer/src/classes_def.xml index 9451393a99d33..e0b30db038f98 100644 --- a/DataFormats/Streamer/src/classes_def.xml +++ b/DataFormats/Streamer/src/classes_def.xml @@ -7,10 +7,12 @@ - + + - + + diff --git a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc index 6bbf40317ebae..76e51ce04ef26 100644 --- a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc +++ b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc @@ -359,14 +359,11 @@ namespace evf { StreamerOutputFile stream_writer_preamble(openIniFileName); uint32 preamble_adler32 = 1; - edm::BranchIDLists const* bidlPtr = branchIDLists(); auto psetMapHandle = run.getHandle(psetToken_); std::unique_ptr init_message = streamerCommon.serializeRegistry(*streamerCommon.getSerializerBuffer(), - *bidlPtr, - *thinnedAssociationsHelper(), OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID(), @@ -430,7 +427,16 @@ namespace evf { edm::LuminosityBlockForOutput const& iLB) const { auto openDatFilePath = edm::Service()->getOpenDatFilePath(iLB.luminosityBlock(), streamLabel_); - return std::make_shared(openDatFilePath, iLB.luminosityBlock()); + auto ret = std::make_shared(openDatFilePath, iLB.luminosityBlock()); + + StreamerOutputModuleCommon streamerCommon( + commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel()); + + auto msg = streamerCommon.serializeEventMetaData( + *streamerCommon.getSerializerBuffer(), *branchIDLists(), *thinnedAssociationsHelper()); + + ret->doOutputEvent(*msg); + return ret; } void GlobalEvFOutputModule::acquire(edm::StreamID id, diff --git a/IOPool/Streamer/interface/EventMessage.h b/IOPool/Streamer/interface/EventMessage.h index 1fdb9499a8e08..bf12c1189430b 100644 --- a/IOPool/Streamer/interface/EventMessage.h +++ b/IOPool/Streamer/interface/EventMessage.h @@ -87,6 +87,7 @@ namespace edm::streamer { uint32 origDataSize() const; uint32 outModId() const; uint32 droppedEventsCount() const; + bool isEventMetaData() const; void l1TriggerBits(std::vector& put_here) const; void hltTriggerBits(uint8* put_here) const; diff --git a/IOPool/Streamer/interface/StreamSerializer.h b/IOPool/Streamer/interface/StreamSerializer.h index 2169b0cb675c8..14b85e366b06c 100644 --- a/IOPool/Streamer/interface/StreamSerializer.h +++ b/IOPool/Streamer/interface/StreamSerializer.h @@ -75,22 +75,26 @@ namespace edm::streamer { public: StreamSerializer(SelectedProducts const *selections); - int serializeRegistry(SerializeDataBuffer &data_buffer, - const BranchIDLists &branchIDLists, - ThinnedAssociationsHelper const &thinnedAssociationsHelper); + int serializeRegistry(SerializeDataBuffer &data_buffer); - int serializeRegistry(SerializeDataBuffer &data_buffer, - const BranchIDLists &branchIDLists, - ThinnedAssociationsHelper const &thinnedAssociationsHelper, - SendJobHeader::ParameterSetMap const &psetMap); + int serializeRegistry(SerializeDataBuffer &data_buffer, SendJobHeader::ParameterSetMap const &psetMap); int serializeEvent(SerializeDataBuffer &data_buffer, EventForOutput const &event, ParameterSetID const &selectorConfig, + uint32_t metaDataChecksum, StreamerCompressionAlgo compressionAlgo, int compression_level, unsigned int reserveSize) const; + ///data_buffer.adler32_chksum_ is the meta data checksum to pass to subsequent events + int serializeEventMetaData(SerializeDataBuffer &data_buffer, + const BranchIDLists &branchIDLists, + ThinnedAssociationsHelper const &thinnedAssociationsHelper, + StreamerCompressionAlgo compressionAlgo, + int compression_level, + unsigned int reserveSize) const; + /** * Compresses the data in the specified input buffer into the * specified output buffer. Returns the size of the compressed data @@ -117,6 +121,12 @@ namespace edm::streamer { bool addHeader = true); private: + int serializeEventCommon(SerializeDataBuffer &data_buffer, + edm::SendEvent const &iEvent, + StreamerCompressionAlgo compressionAlgo, + int compression_level, + unsigned int reserveSize) const; + SelectedProducts const *selections_; edm::propagate_const tc_; }; diff --git a/IOPool/Streamer/interface/StreamerInputModule.h b/IOPool/Streamer/interface/StreamerInputModule.h index 360ee89c66624..fd7fc86f042d9 100644 --- a/IOPool/Streamer/interface/StreamerInputModule.h +++ b/IOPool/Streamer/interface/StreamerInputModule.h @@ -30,24 +30,49 @@ namespace edm::streamer { private: void genuineCloseFile() override { + if (didArtificialFile_) { + didArtificialFile_ = false; + + return; + } if (pr_.get() != nullptr) pr_->closeFile(); } + void setupMetaData() { + InitMsgView const* header = pr_->getHeader(); + assert(header); + deserializeAndMergeWithRegistry(*header); + + //NOTE: should read first Event to get the meta data + auto eview = pr_->getNextEvent(); + assert(eview); + assert(eview->isEventMetaData()); + deserializeEventMetaData(*eview); + updateEventMetaData(); + } + void genuineReadFile() override { if (isFirstFile_) { isFirstFile_ = false; return; } - InitMsgView const* header = pr_->getHeader(); - deserializeAndMergeWithRegistry(*header); + if (didArtificialFile_) { + //update the event meta data + didArtificialFile_ = false; + updateEventMetaData(); + + return; + } + setupMetaData(); } Next checkNext() override; edm::propagate_const> pr_; bool isFirstFile_ = true; + bool didArtificialFile_ = false; }; //end-of-class-def template @@ -59,21 +84,26 @@ namespace edm::streamer { //prod_reg_(&productRegistry()), pr_(new Producer(pset)) { //Get header/init from Producer - InitMsgView const* header = pr_->getHeader(); - deserializeAndMergeWithRegistry(*header); + setupMetaData(); } template StreamerInputSource::Next StreamerInputModule::checkNext() { EventMsgView const* eview = pr_->getNextEvent(); - if (pr_->newHeader()) { - FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl; - return Next::kFile; - } if (eview == nullptr) { + if (pr_->newHeader()) { + FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl; + return Next::kFile; + } return Next::kStop; } + if (eview->isEventMetaData()) { + //we lie and say there is a new file since we need to synchronize to update the meta data + deserializeEventMetaData(*eview); + didArtificialFile_ = true; + return Next::kFile; + } deserializeEvent(*eview); return Next::kEvent; } diff --git a/IOPool/Streamer/interface/StreamerInputSource.h b/IOPool/Streamer/interface/StreamerInputSource.h index 2d7354b94b2e5..d3092bbabbac3 100644 --- a/IOPool/Streamer/interface/StreamerInputSource.h +++ b/IOPool/Streamer/interface/StreamerInputSource.h @@ -40,13 +40,18 @@ namespace edm::streamer { void deserializeAndMergeWithRegistry(InitMsgView const& initView, bool subsequent = false); + //If eventView is a meta data event then this returns its checksum + uint32_t eventMetaDataChecksum(EventMsgView const& eventView) const; + //Should be called right after this message has been read + void deserializeEventMetaData(EventMsgView const& eventView); void deserializeEvent(EventMsgView const& eventView); - static void mergeIntoRegistry(SendJobHeader const& header, - ProductRegistry&, - BranchIDListHelper&, - ThinnedAssociationsHelper&, - bool subsequent); + uint32_t presentEventMetaDataChecksum() const { return eventMetaDataChecksum_; } + //This can only be called during a new file transition as it updates state that requires + // framework synchronization. + void updateEventMetaData(); + + static void mergeIntoRegistry(SendJobHeader const& header, ProductRegistry&, bool subsequent); /** * Detect if buffer starts with "XZ\0" which means it is compressed in LZMA format @@ -89,6 +94,8 @@ namespace edm::streamer { void resetAfterEndRun(); private: + void deserializeEventCommon(EventMsgView const& eventView, bool isMetaData); + class EventPrincipalHolder : public EDProductGetter { public: EventPrincipalHolder(); @@ -125,6 +132,7 @@ namespace edm::streamer { std::string processName_; unsigned int protocolVersion_; + uint32_t eventMetaDataChecksum_ = 0; }; //end-of-class-def } // namespace edm::streamer diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index 6c88edecfbe26..eedade18f4ac0 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -45,6 +45,7 @@ namespace edm { private: edm::EDGetTokenT trToken_; edm::EDGetTokenT psetToken_; + bool lastCallWasBeginRun_ = false; }; //end-of-class-def } // namespace streamer diff --git a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h index 165248c08b75e..a0b3f4e35338d 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h @@ -45,13 +45,15 @@ namespace edm { static void fillDescription(ParameterSetDescription& desc); std::unique_ptr serializeRegistry(SerializeDataBuffer& sbuf, - BranchIDLists const& branchLists, - ThinnedAssociationsHelper const& helper, std::string const& processName, std::string const& moduleLabel, ParameterSetID const& toplevel, SendJobHeader::ParameterSetMap const* psetMap); + std::unique_ptr serializeEventMetaData(SerializeDataBuffer& sbuf, + BranchIDLists const& branchLists, + ThinnedAssociationsHelper const& helper); + std::unique_ptr serializeEvent(SerializeDataBuffer& sbuf, EventForOutput const& e, Handle const& triggerResults, @@ -63,6 +65,13 @@ namespace edm { std::unique_ptr serializerBuffer_; private: + std::unique_ptr serializeEventCommon(uint32 run, + uint32 lumi, + uint64 event, + std::vector hltbits, + unsigned int hltsize, + SerializeDataBuffer& sbuf); + void setHltMask(EventForOutput const& e, Handle const& triggerResults, std::vector& hltbits) const; @@ -86,6 +95,7 @@ namespace edm { Strings hltTriggerSelections_; uint32 outputModuleId_; + uint32_t eventMetaDataChecksum_ = 0; }; //end-of-class-def } // namespace streamer } // namespace edm diff --git a/IOPool/Streamer/plugins/Module.cc b/IOPool/Streamer/plugins/Module.cc index 178739af68aa5..9d3d1c786d99a 100644 --- a/IOPool/Streamer/plugins/Module.cc +++ b/IOPool/Streamer/plugins/Module.cc @@ -11,9 +11,6 @@ using EventStreamFileWriter = edm::streamer::StreamerOutputModule; using NewEventStreamFileReader = edm::streamer::StreamerFileReader; -using edm::streamer::StreamerFileReader; -using edm::streamer::StreamerFileWriter; - DEFINE_FWK_INPUT_SOURCE(NewEventStreamFileReader); DEFINE_FWK_MODULE(EventStreamFileWriter); diff --git a/IOPool/Streamer/src/EventMessage.cc b/IOPool/Streamer/src/EventMessage.cc index 0a9365ee7e4d4..570d1e8eb704a 100644 --- a/IOPool/Streamer/src/EventMessage.cc +++ b/IOPool/Streamer/src/EventMessage.cc @@ -66,41 +66,43 @@ EventMsgView::EventMsgView(void* buf) : buf_((uint8*)buf), head_(buf), v2Detecte } uint32 EventMsgView::protocolVersion() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return h->protocolVersion_; } uint32 EventMsgView::run() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return convert32(h->run_); } uint64 EventMsgView::event() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return convert64(h->event_); } uint32 EventMsgView::lumi() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return convert32(h->lumi_); } uint32 EventMsgView::origDataSize() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return convert32(h->origDataSize_); } uint32 EventMsgView::outModId() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return convert32(h->outModId_); } uint32 EventMsgView::droppedEventsCount() const { - EventHeader* h = (EventHeader*)buf_; + EventHeader* h = reinterpret_cast(buf_); return convert32(h->droppedEventsCount_); return 0; } +bool EventMsgView::isEventMetaData() const { return run() == 0; } + void EventMsgView::l1TriggerBits(std::vector& put_here) const { put_here.clear(); put_here.resize(l1_bits_count_); diff --git a/IOPool/Streamer/src/StreamSerializer.cc b/IOPool/Streamer/src/StreamSerializer.cc index 0ac0993a1c897..545934e200116 100644 --- a/IOPool/Streamer/src/StreamSerializer.cc +++ b/IOPool/Streamer/src/StreamSerializer.cc @@ -42,17 +42,13 @@ namespace edm::streamer { * Serializes the product registry (that was specified to the constructor) * into the specified InitMessage. */ - int StreamSerializer::serializeRegistry(SerializeDataBuffer &data_buffer, - const BranchIDLists &branchIDLists, - ThinnedAssociationsHelper const &thinnedAssociationsHelper) { + int StreamSerializer::serializeRegistry(SerializeDataBuffer &data_buffer) { SendJobHeader::ParameterSetMap psetMap; pset::Registry::instance()->fillMap(psetMap); - return serializeRegistry(data_buffer, branchIDLists, thinnedAssociationsHelper, psetMap); + return serializeRegistry(data_buffer, psetMap); } int StreamSerializer::serializeRegistry(SerializeDataBuffer &data_buffer, - const BranchIDLists &branchIDLists, - ThinnedAssociationsHelper const &thinnedAssociationsHelper, SendJobHeader::ParameterSetMap const &psetMap) { FDEBUG(6) << "StreamSerializer::serializeRegistry" << std::endl; SendJobHeader sd; @@ -64,8 +60,6 @@ namespace edm::streamer { FDEBUG(9) << "StreamOutput got product = " << selection.first->className() << std::endl; } Service reg; - sd.setBranchIDLists(branchIDLists); - sd.setThinnedAssociationsHelper(thinnedAssociationsHelper); sd.setParameterSetMap(psetMap); data_buffer.rootbuf_.Reset(); @@ -132,12 +126,19 @@ namespace edm::streamer { int StreamSerializer::serializeEvent(SerializeDataBuffer &data_buffer, EventForOutput const &event, ParameterSetID const &selectorConfig, + uint32_t metaDataChecksum, StreamerCompressionAlgo compressionAlgo, int compression_level, unsigned int reserveSize) const { EventSelectionIDVector selectionIDs = event.eventSelectionIDs(); selectionIDs.push_back(selectorConfig); - SendEvent se(event.eventAuxiliary(), event.processHistory(), selectionIDs, event.branchListIndexes()); + SendEvent se(event.eventAuxiliary(), + event.processHistory(), + selectionIDs, + event.branchListIndexes(), + {}, + {}, + metaDataChecksum); // Loop over EDProducts, fill the provenance, and write. @@ -172,7 +173,25 @@ namespace edm::streamer { } } } + return serializeEventCommon(data_buffer, se, compressionAlgo, compression_level, reserveSize); + } + + int StreamSerializer::serializeEventMetaData(SerializeDataBuffer &data_buffer, + const BranchIDLists &branchIDLists, + ThinnedAssociationsHelper const &thinnedAssociationsHelper, + StreamerCompressionAlgo compressionAlgo, + int compression_level, + unsigned int reserveSize) const { + SendEvent se({}, {}, {}, {}, branchIDLists, thinnedAssociationsHelper, 0); + + return serializeEventCommon(data_buffer, se, compressionAlgo, compression_level, reserveSize); + } + int StreamSerializer::serializeEventCommon(SerializeDataBuffer &data_buffer, + edm::SendEvent const &se, + StreamerCompressionAlgo compressionAlgo, + int compression_level, + unsigned int reserveSize) const { data_buffer.rootbuf_.Reset(); RootDebug tracer(10, 10); @@ -182,7 +201,7 @@ namespace edm::streamer { case 0: // failure { throw cms::Exception("StreamTranslation", "Event serialization failed") - << "StreamSerializer failed to serialize event: " << event.id(); + << "StreamSerializer failed to serialize event: " << se.aux().id(); break; } case 1: // succcess @@ -191,14 +210,14 @@ namespace edm::streamer { { throw cms::Exception("StreamTranslation", "Event serialization truncated") << "StreamSerializer module attempted to serialize an event\n" - << "that is to big for the allocated buffers: " << event.id(); + << "that is to big for the allocated buffers: " << se.aux().id(); break; } default: // unknown { throw cms::Exception("StreamTranslation", "Event serialization failed") << "StreamSerializer module got an unknown error code\n" - << " while attempting to serialize event: " << event.id(); + << " while attempting to serialize event: " << se.aux().id(); break; } } diff --git a/IOPool/Streamer/src/StreamerFileReader.cc b/IOPool/Streamer/src/StreamerFileReader.cc index 32f58476f7002..d9b0eeb80e3dd 100644 --- a/IOPool/Streamer/src/StreamerFileReader.cc +++ b/IOPool/Streamer/src/StreamerFileReader.cc @@ -10,6 +10,7 @@ #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Sources/interface/EventSkipperByID.h" +#include namespace edm::streamer { StreamerFileReader::StreamerFileReader(ParameterSet const& pset, InputSourceDescription const& desc) @@ -39,13 +40,22 @@ namespace edm::streamer { << "No fileNames were specified\n"; } isFirstFile_ = true; - InitMsgView const* header = getHeader(); - deserializeAndMergeWithRegistry(*header, false); + updateMetaData(false); if (initialNumberOfEventsToSkip_) { skip(initialNumberOfEventsToSkip_); } } + void StreamerFileReader::updateMetaData(bool subsequent) { + InitMsgView const* header = getHeader(); + deserializeAndMergeWithRegistry(*header, subsequent); + //NOTE: should read first Event to get the meta data and then set 'artificial file' + auto eview = getNextEvent(); + assert(eview and eview->isEventMetaData()); + deserializeEventMetaData(*eview); + updateEventMetaData(); + } + StreamerFileReader::Next StreamerFileReader::checkNext() { EventMsgView const* eview = getNextEvent(); @@ -55,6 +65,23 @@ namespace edm::streamer { } return Next::kStop; } + if (eview->isEventMetaData()) { + if (presentEventMetaDataChecksum() != eventMetaDataChecksum(*eview)) { + //we lie and say there is a new file since we need to synchronize to update the meta data + didArtificialFile_ = true; + deserializeEventMetaData(*eview); + return Next::kFile; + } else { + //skip this meta data + eview = getNextEvent(); + if (eview == nullptr) { + if (newHeader()) { + return Next::kFile; + } + return Next::kStop; + } + } + } deserializeEvent(*eview); return Next::kEvent; } @@ -73,6 +100,9 @@ namespace edm::streamer { } void StreamerFileReader::genuineCloseFile() { + if (didArtificialFile_) { + return; + } if (streamReader_.get() != nullptr) streamReader_->closeStreamerFile(); } @@ -83,12 +113,17 @@ namespace edm::streamer { isFirstFile_ = false; return; } + if (didArtificialFile_) { + //update the event meta data + didArtificialFile_ = false; + updateEventMetaData(); + return; + } streamReader_->openNextFile(); // FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl; // A new file has been opened and we must compare Heraders here !! //Get header/init from reader - InitMsgView const* header = getHeader(); - deserializeAndMergeWithRegistry(*header, true); + updateMetaData(true); } bool StreamerFileReader::newHeader() { return streamReader_->newHeader(); } diff --git a/IOPool/Streamer/src/StreamerFileReader.h b/IOPool/Streamer/src/StreamerFileReader.h index 3661a6440535e..0d734e458082e 100644 --- a/IOPool/Streamer/src/StreamerFileReader.h +++ b/IOPool/Streamer/src/StreamerFileReader.h @@ -31,6 +31,7 @@ namespace edm { InitMsgView const* getHeader(); EventMsgView const* getNextEvent(); bool newHeader(); + void updateMetaData(bool subsequent); Next checkNext() override; void skip(int toSkip) override; @@ -49,6 +50,7 @@ namespace edm { int initialNumberOfEventsToSkip_; int prefetchMBytes_; bool isFirstFile_ = true; + bool didArtificialFile_ = false; }; } // namespace streamer } // namespace edm diff --git a/IOPool/Streamer/src/StreamerInputSource.cc b/IOPool/Streamer/src/StreamerInputSource.cc index 88f75037ec0d4..160d3698ec993 100644 --- a/IOPool/Streamer/src/StreamerInputSource.cc +++ b/IOPool/Streamer/src/StreamerInputSource.cc @@ -56,11 +56,7 @@ namespace edm::streamer { StreamerInputSource::~StreamerInputSource() {} // --------------------------------------- - void StreamerInputSource::mergeIntoRegistry(SendJobHeader const& header, - ProductRegistry& reg, - BranchIDListHelper& branchIDListHelper, - ThinnedAssociationsHelper& thinnedHelper, - bool subsequent) { + void StreamerInputSource::mergeIntoRegistry(SendJobHeader const& header, ProductRegistry& reg, bool subsequent) { SendDescs const& descs = header.descs(); FDEBUG(6) << "mergeIntoRegistry: Product List: " << std::endl; @@ -72,8 +68,6 @@ namespace edm::streamer { if (!mergeInfo.empty()) { throw cms::Exception("MismatchedInput", "RootInputFileSequence::previousEvent()") << mergeInfo; } - branchIDListHelper.updateFromInput(header.branchIDLists()); - thinnedHelper.updateFromPrimaryInput(header.thinnedAssociationsHelper()); } else { declareStreamers(descs); buildClassCache(descs); @@ -81,8 +75,6 @@ namespace edm::streamer { if (!reg.frozen()) { reg.updateFromInput(descs); } - branchIDListHelper.updateFromInput(header.branchIDLists()); - thinnedHelper.updateFromPrimaryInput(header.thinnedAssociationsHelper()); } } @@ -166,7 +158,7 @@ namespace edm::streamer { */ void StreamerInputSource::deserializeAndMergeWithRegistry(InitMsgView const& initView, bool subsequent) { std::unique_ptr sd = deserializeRegistry(initView); - mergeIntoRegistry(*sd, productRegistryUpdate(), *branchIDListHelper(), *thinnedAssociationsHelper(), subsequent); + mergeIntoRegistry(*sd, productRegistryUpdate(), subsequent); if (subsequent) { adjustEventToNewProductRegistry_ = true; } @@ -179,10 +171,26 @@ namespace edm::streamer { } } + void StreamerInputSource::updateEventMetaData() { + branchIDListHelper()->updateFromInput(sendEvent_->branchIDLists()); + thinnedAssociationsHelper()->updateFromPrimaryInput(sendEvent_->thinnedAssociationsHelper()); + } + + uint32_t StreamerInputSource::eventMetaDataChecksum(EventMsgView const& eventView) const { + return eventView.adler32_chksum(); + } + + void StreamerInputSource::deserializeEventMetaData(EventMsgView const& eventView) { + deserializeEventCommon(eventView, true); + } /** * Deserializes the specified event message. */ void StreamerInputSource::deserializeEvent(EventMsgView const& eventView) { + deserializeEventCommon(eventView, false); + } + + void StreamerInputSource::deserializeEventCommon(EventMsgView const& eventView, bool isMetaData) { if (eventView.code() != Header::EVENT) throw cms::Exception("StreamTranslation", "Event deserialization error") << "received wrong message type: expected EVENT, got " << eventView.code() << "\n"; @@ -199,7 +207,7 @@ namespace edm::streamer { //std::cout << "Adler32 checksum of event = " << adler32_chksum << std::endl; //std::cout << "Adler32 checksum from header = " << eventView.adler32_chksum() << " " // << "host name = " << eventView.hostName() << " len = " << eventView.hostName_len() << std::endl; - if ((uint32)adler32_chksum != eventView.adler32_chksum()) { + if (static_cast(adler32_chksum) != eventView.adler32_chksum()) { // skip event (based on option?) or throw exception? throw cms::Exception("StreamDeserialization", "Checksum error") << " chksum from event = " << adler32_chksum << " from header = " << eventView.adler32_chksum() @@ -250,13 +258,24 @@ namespace edm::streamer { setRefCoreStreamer(); ; }); - sendEvent_ = std::unique_ptr((SendEvent*)xbuf_.ReadObjectAny(tc_)); + sendEvent_ = std::unique_ptr(reinterpret_cast(xbuf_.ReadObjectAny(tc_))); } if (sendEvent_.get() == nullptr) { throw cms::Exception("StreamTranslation", "Event deserialization error") << "got a null event from input stream\n"; } + + if (isMetaData) { + eventMetaDataChecksum_ = adler32_chksum; + return; + } + + if (sendEvent_->metaDataChecksum() != eventMetaDataChecksum_) { + throw cms::Exception("StreamTranslation") << " meta data checksum from event " << sendEvent_->metaDataChecksum() + << " does not match last read meta data " << eventMetaDataChecksum_; + } + processHistoryRegistryForUpdate().registerProcessHistory(sendEvent_->processHistory()); FDEBUG(5) << "Got event: " << sendEvent_->aux().id() << " " << sendEvent_->products().size() << std::endl; diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index ebfa10bdeed1e..6b17eaece784e 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -30,14 +30,14 @@ namespace edm::streamer { std::unique_ptr init_message = serializeRegistry(*getSerializerBuffer(), - *branchIDLists(), - *thinnedAssociationsHelper(), OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID(), psetMapHandle.isValid() ? psetMapHandle.product() : nullptr); doOutputHeader(*init_message); + lastCallWasBeginRun_ = true; + serializerBuffer_->clearHeaderBuffer(); } @@ -54,7 +54,13 @@ namespace edm::streamer { void StreamerOutputModuleBase::write(EventForOutput const& e) { Handle const& triggerResults = getTriggerResults(trToken_, e); - std::unique_ptr msg = serializeEvent(*getSerializerBuffer(), e, triggerResults, selectorConfig()); + if (lastCallWasBeginRun_) { + auto msg = serializeEventMetaData(*getSerializerBuffer(), *branchIDLists(), *thinnedAssociationsHelper()); + doOutputEvent(*msg); + lastCallWasBeginRun_ = false; + } + auto msg = serializeEvent(*getSerializerBuffer(), e, triggerResults, selectorConfig()); + doOutputEvent(*msg); // You can't use msg in StreamerOutputModuleBase after this point } diff --git a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc index ab3e987af168c..da1912e9882e9 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc @@ -111,16 +111,14 @@ namespace edm::streamer { std::unique_ptr StreamerOutputModuleCommon::serializeRegistry( SerializeDataBuffer& sbuf, - const BranchIDLists& branchLists, - ThinnedAssociationsHelper const& helper, std::string const& processName, std::string const& moduleLabel, ParameterSetID const& toplevel, SendJobHeader::ParameterSetMap const* psetMap) { if (psetMap) { - serializer_.serializeRegistry(sbuf, branchLists, helper, *psetMap); + serializer_.serializeRegistry(sbuf, *psetMap); } else { - serializer_.serializeRegistry(sbuf, branchLists, helper); + serializer_.serializeRegistry(sbuf); } // resize header_buf_ to reflect space used in serializer_ + header // I just added an overhead for header of 50000 for now @@ -219,11 +217,6 @@ namespace edm::streamer { constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; //Lets Build the Event Message first - //Following is strictly DUMMY Data for L! Trig and will be replaced with actual - // once figured out, there is no logic involved here. - std::vector l1bit = {true, true, false}; - //End of dummy data - std::vector hltbits; setHltMask(e, triggerResults, hltbits); @@ -237,23 +230,50 @@ namespace edm::streamer { // what about overflows? lumi = static_cast(timeInSec / std::abs(lumiSectionInterval_)) + 1; } + serializer_.serializeEvent( + sbuf, e, selectorCfg, eventMetaDataChecksum_, compressionAlgo_, compressionLevel_, reserve_size); - serializer_.serializeEvent(sbuf, e, selectorCfg, compressionAlgo_, compressionLevel_, reserve_size); + return serializeEventCommon(e.id().run(), lumi, e.id().event(), hltbits, hltsize_, sbuf); + } + std::unique_ptr StreamerOutputModuleCommon::serializeEventMetaData( + SerializeDataBuffer& sbuf, BranchIDLists const& branchLists, ThinnedAssociationsHelper const& helper) { + constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; + //Lets Build the Event Message first + + std::vector hltbits; + serializer_.serializeEventMetaData(sbuf, branchLists, helper, compressionAlgo_, compressionLevel_, reserve_size); + eventMetaDataChecksum_ = sbuf.adler32_chksum_; + + return serializeEventCommon(0, 0, 0, hltbits, 0, sbuf); + } + + std::unique_ptr StreamerOutputModuleCommon::serializeEventCommon(uint32 run, + uint32 lumi, + uint64 event, + std::vector hltbits, + unsigned int hltsize, + SerializeDataBuffer& sbuf) { // resize header_buf_ to reserved size on first written event + constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; if (sbuf.header_buf_.size() < reserve_size) sbuf.header_buf_.resize(reserve_size); + //Following is strictly DUMMY Data for L! Trig and will be replaced with actual + // once figured out, there is no logic involved here. + std::vector l1bit = {true, true, false}; + //End of dummy data + auto msg = std::make_unique(&sbuf.header_buf_[0], sbuf.comp_buf_.size(), - e.id().run(), - e.id().event(), + run, + event, lumi, outputModuleId_, 0, l1bit, (uint8*)&hltbits[0], - hltsize_, + hltsize, (uint32)sbuf.adler32_chksum(), host_name_); diff --git a/IOPool/Streamer/test/run_TestRefProductIDMetadataConsistencyStreamer.sh b/IOPool/Streamer/test/run_TestRefProductIDMetadataConsistencyStreamer.sh index 7ba360b52f072..972f0250cb077 100755 --- a/IOPool/Streamer/test/run_TestRefProductIDMetadataConsistencyStreamer.sh +++ b/IOPool/Streamer/test/run_TestRefProductIDMetadataConsistencyStreamer.sh @@ -25,4 +25,4 @@ CatStreamerFiles refconsistency_cat.dat refconsistency_1.dat refconsistency_10.d echo # ... fails -runFailure ${SCRAM_TEST_PATH}/testModuleTypeResolverRefTest_cfg.py --input moduletyperesolver_ref_cat.dat +runSuccess ${SCRAM_TEST_PATH}/testRefProductIDMetadataConsistencyStreamerTest_cfg.py --input refconsistency_cat.dat From d9b3643633eea6c6933a4f17e941698eaa28a249 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Thu, 9 May 2024 13:48:51 -0500 Subject: [PATCH 032/301] Cache EventMetaData in GlobalEvFOutputModule - event meta data is cached at begin job or when new file is opened - refactored StreamerOutputModuleCommon to be two classes so buffer could be handled separately for the caching - added many unit tests to show GlobalEvFOutputModule properly writes the expected events and the data products are correct --- .../StreamerIO/plugins/DQMStreamerReader.cc | 2 +- .../plugins/GlobalEvFOutputModule.cc | 110 ++++-- EventFilter/Utilities/test/BuildFile.xml | 1 + EventFilter/Utilities/test/RunBUFU.sh | 2 +- .../Utilities/test/TestReadingStreamerFile.sh | 203 +++++++++++ .../Utilities/test/mergeStreamerFile_cfg.py | 59 ++++ .../Utilities/test/readStreamerFile_cfg.py | 41 +++ EventFilter/Utilities/test/test_dqmstream.py | 34 ++ .../Utilities/test/writeStreamerFile_cfg.py | 74 ++++ .../src/BranchIDListsModifierProducer.cc | 52 +++ FWCore/Modules/src/RunLumiEventChecker.cc | 24 +- IOPool/Streamer/interface/StreamSerializer.h | 4 +- .../interface/StreamerOutputModuleCommon.h | 54 +-- .../interface/StreamerOutputMsgBuilders.h | 93 ++++++ IOPool/Streamer/src/StreamSerializer.cc | 4 +- .../Streamer/src/StreamerOutputModuleBase.cc | 9 +- .../src/StreamerOutputModuleCommon.cc | 282 +--------------- .../Streamer/src/StreamerOutputMsgBuilders.cc | 315 ++++++++++++++++++ 18 files changed, 1001 insertions(+), 362 deletions(-) create mode 100755 EventFilter/Utilities/test/TestReadingStreamerFile.sh create mode 100644 EventFilter/Utilities/test/mergeStreamerFile_cfg.py create mode 100644 EventFilter/Utilities/test/readStreamerFile_cfg.py create mode 100644 EventFilter/Utilities/test/writeStreamerFile_cfg.py create mode 100644 FWCore/Modules/src/BranchIDListsModifierProducer.cc create mode 100644 IOPool/Streamer/interface/StreamerOutputMsgBuilders.h create mode 100644 IOPool/Streamer/src/StreamerOutputMsgBuilders.cc diff --git a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc index 1de5c8563e799..44de7ce0251b9 100644 --- a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc +++ b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc @@ -309,7 +309,7 @@ namespace dqmservices { } else { //skipping eview = getEventMsg(); - assert( (eview==nullptr) or (not eview->isEventMetaData())); + assert((eview == nullptr) or (not eview->isEventMetaData())); if (eview == nullptr) { closeFileImp_("eof"); continue; diff --git a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc index 76e51ce04ef26..c499de2780701 100644 --- a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc +++ b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc @@ -22,7 +22,7 @@ #include "IOPool/Streamer/interface/StreamerOutputFile.h" #include "FWCore/Framework/interface/global/OutputModule.h" -#include "IOPool/Streamer/interface/StreamerOutputModuleCommon.h" +#include "IOPool/Streamer/interface/StreamerOutputMsgBuilders.h" #include "FWCore/Utilities/interface/EDGetToken.h" #include "DataFormats/Streamer/interface/StreamedProducts.h" @@ -42,13 +42,35 @@ namespace evf { class FastMonitoringService; + struct MetaDataCache { + MetaDataCache(StreamerOutputMsgBuilders const& builders, + edm::BranchIDLists const& branchLists, + edm::ThinnedAssociationsHelper const helper) + : buffer_() { + auto ret = builders.serializeEventMetaData(buffer_, branchLists, helper); + builder_ = std::move(ret.first); + checksum_ = ret.second; + } + SerializeDataBuffer buffer_; + std::unique_ptr builder_; + uint32_t checksum_; + }; + class GlobalEvFOutputEventWriter { public: - explicit GlobalEvFOutputEventWriter(std::string const& filePath, unsigned int ls) - : filePath_(filePath), ls_(ls), accepted_(0), stream_writer_events_(new StreamerOutputFile(filePath)) {} + explicit GlobalEvFOutputEventWriter(std::string const& filePath, + unsigned int ls, + std::shared_ptr iMetaData) + : filePath_(filePath), + ls_(ls), + accepted_(0), + stream_writer_events_(new StreamerOutputFile(filePath)), + meta_(std::move(iMetaData)) {} ~GlobalEvFOutputEventWriter() {} + void setMetaCache(std::shared_ptr iMetaData) { meta_ = std::move(iMetaData); } + bool close() { stream_writer_events_->close(); return (discarded_ || edm::Service()->lumisectionDiscarded(ls_)); @@ -69,9 +91,14 @@ namespace evf { return; } auto group = iHolder.group(); - writeQueue_.push(*group, [holder = std::move(iHolder), msg = msg.release(), this]() { + writeQueue_.push(*group, [holder = std::move(iHolder), msg = msg.release(), this]() mutable { try { std::unique_ptr own(msg); + if (meta_) { + auto m = std::move(meta_); + assert(m->builder_); + doOutputEvent(*m->builder_); + } doOutputEvent(*msg); //msg is written and discarded at this point } catch (...) { auto tmp = holder; @@ -117,6 +144,7 @@ namespace evf { const unsigned ls_; std::atomic accepted_; edm::propagate_const> stream_writer_events_; + std::shared_ptr meta_; edm::SerialTaskQueue writeQueue_; bool discarded_ = false; }; @@ -156,7 +184,8 @@ namespace evf { typedef edm::global::OutputModule, edm::LuminosityBlockCache, - edm::StreamCache, + edm::StreamCache, + edm::WatchInputFiles, edm::ExternalWork> GlobalEvFOutputModuleType; @@ -167,7 +196,7 @@ namespace evf { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - std::unique_ptr beginStream(edm::StreamID) const final; + std::unique_ptr beginStream(edm::StreamID) const final; std::shared_ptr globalBeginRun(edm::RunForOutput const& run) const final; @@ -179,19 +208,31 @@ namespace evf { void writeRun(edm::RunForOutput const&) final {} void globalEndRun(edm::RunForOutput const&) const final {} + void respondToOpenInputFile(edm::FileBlock const&) final; + void respondToCloseInputFile(edm::FileBlock const&) final {} + + void beginJob() final; + void cacheEventMetaData(); + std::shared_ptr globalBeginLuminosityBlock( edm::LuminosityBlockForOutput const& iLB) const final; void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const& iLB) const final; Trig getTriggerResults(edm::EDGetTokenT const& token, edm::EventForOutput const& e) const; - StreamerOutputModuleCommon::Parameters commonParameters_; + StreamerOutputMsgBuilders::Parameters commonParameters_; + std::unique_ptr msgBuilders_; std::string streamLabel_; edm::EDGetTokenT trToken_; edm::EDGetTokenT psetToken_; evf::FastMonitoringService* fms_; + std::shared_ptr metaDataCache_; + //if a new file appears and has different meta data but the same lumi, we need + // to update the writer to write out the new meta data + mutable std::atomic lastWriter_ = nullptr; + unsigned int presentBranchIDListSize_ = 0; }; //end-of-class-def GlobalEvFOutputJSONDef::GlobalEvFOutputJSONDef(std::string const& streamLabel, bool writeJsd) { @@ -287,7 +328,7 @@ namespace evf { GlobalEvFOutputModule::GlobalEvFOutputModule(edm::ParameterSet const& ps) : edm::global::OutputModuleBase(ps), GlobalEvFOutputModuleType(ps), - commonParameters_(StreamerOutputModuleCommon::parameters(ps)), + commonParameters_(StreamerOutputMsgBuilders::parameters(ps)), streamLabel_(ps.getParameter("@module_label")), trToken_(consumes(edm::InputTag("TriggerResults"))), psetToken_(consumes( @@ -334,24 +375,21 @@ namespace evf { void GlobalEvFOutputModule::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - StreamerOutputModuleCommon::fillDescription(desc); + StreamerOutputMsgBuilders::fillDescription(desc); GlobalEvFOutputModuleType::fillDescription(desc); desc.addUntracked("psetMap", {"hltPSetMap"}) ->setComment("Optionally allow the map of ParameterSets to be calculated externally."); descriptions.add("globalEvfOutputModule", desc); } - std::unique_ptr GlobalEvFOutputModule::beginStream(edm::StreamID) const { - return std::make_unique( - commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel()); + std::unique_ptr GlobalEvFOutputModule::beginStream(edm::StreamID) const { + return std::make_unique(); } std::shared_ptr GlobalEvFOutputModule::globalBeginRun(edm::RunForOutput const& run) const { //create run Cache holding JSON file writer and variables auto jsonDef = std::make_unique(streamLabel_, false); jsonDef->updateDestination(streamLabel_); - StreamerOutputModuleCommon streamerCommon( - commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel()); //output INI file (non-const). This doesn't require globalBeginRun to be finished const std::string openIniFileName = edm::Service()->getOpenInitFilePath(streamLabel_); @@ -362,12 +400,13 @@ namespace evf { auto psetMapHandle = run.getHandle(psetToken_); + SerializeDataBuffer buffer; std::unique_ptr init_message = - streamerCommon.serializeRegistry(*streamerCommon.getSerializerBuffer(), - OutputModule::processName(), - description().moduleLabel(), - moduleDescription().mainParameterSetID(), - psetMapHandle.isValid() ? psetMapHandle.product() : nullptr); + msgBuilders_->serializeRegistry(buffer, + OutputModule::processName(), + description().moduleLabel(), + moduleDescription().mainParameterSetID(), + psetMapHandle.isValid() ? psetMapHandle.product() : nullptr); //Let us turn it into a View InitMsgView view(init_message->startAddress()); @@ -398,9 +437,6 @@ namespace evf { } src.close(); - //clear serialization buffers - streamerCommon.getSerializerBuffer()->clearHeaderBuffer(); - //free output buffer needed only for the file write outBuf.reset(); @@ -427,16 +463,29 @@ namespace evf { edm::LuminosityBlockForOutput const& iLB) const { auto openDatFilePath = edm::Service()->getOpenDatFilePath(iLB.luminosityBlock(), streamLabel_); - auto ret = std::make_shared(openDatFilePath, iLB.luminosityBlock()); + auto ret = std::make_shared(openDatFilePath, iLB.luminosityBlock(), metaDataCache_); + lastWriter_ = ret.get(); + return ret; + } - StreamerOutputModuleCommon streamerCommon( + void GlobalEvFOutputModule::beginJob() { + msgBuilders_ = std::make_unique( commonParameters_, &keptProducts()[edm::InEvent], description().moduleLabel()); - auto msg = streamerCommon.serializeEventMetaData( - *streamerCommon.getSerializerBuffer(), *branchIDLists(), *thinnedAssociationsHelper()); + cacheEventMetaData(); + } - ret->doOutputEvent(*msg); - return ret; + void GlobalEvFOutputModule::respondToOpenInputFile(edm::FileBlock const&) { + if (branchIDLists()->size() != presentBranchIDListSize_) { + cacheEventMetaData(); + if (lastWriter_) { + lastWriter_.load()->setMetaCache(metaDataCache_); + } + } + } + + void GlobalEvFOutputModule::cacheEventMetaData() { + metaDataCache_ = std::make_shared(*msgBuilders_, *branchIDLists(), *thinnedAssociationsHelper()); } void GlobalEvFOutputModule::acquire(edm::StreamID id, @@ -444,9 +493,10 @@ namespace evf { edm::WaitingTaskWithArenaHolder iHolder) const { edm::Handle const& triggerResults = getTriggerResults(trToken_, e); - auto streamerCommon = streamCache(id); + std::cout << " writing Event " << moduleDescription().moduleLabel() << std::endl; + auto buffer = streamCache(id); std::unique_ptr msg = - streamerCommon->serializeEvent(*streamerCommon->getSerializerBuffer(), e, triggerResults, selectorConfig()); + msgBuilders_->serializeEvent(*buffer, e, triggerResults, selectorConfig(), metaDataCache_->checksum_); auto lumiWriter = luminosityBlockCache(e.getLuminosityBlock().index()); const_cast(lumiWriter) diff --git a/EventFilter/Utilities/test/BuildFile.xml b/EventFilter/Utilities/test/BuildFile.xml index 7ad2f437052ef..f63c46b41a74b 100644 --- a/EventFilter/Utilities/test/BuildFile.xml +++ b/EventFilter/Utilities/test/BuildFile.xml @@ -11,3 +11,4 @@ + diff --git a/EventFilter/Utilities/test/RunBUFU.sh b/EventFilter/Utilities/test/RunBUFU.sh index 18d892f94dfc8..55f6dc298ead4 100755 --- a/EventFilter/Utilities/test/RunBUFU.sh +++ b/EventFilter/Utilities/test/RunBUFU.sh @@ -50,7 +50,7 @@ cat data/run${runnumber}/run${runnumber}_ls0001_streamDQM_pid*.dat >> dqmdisk/ru find dqmdisk echo '{"data": [12950, 1620, 0, "run'${runnumber}'_ls0001_streamDQM_test.dat", 40823782, 1999348078, 135, 13150, 0, "Failsafe"]}' > dqmdisk/run${runnumber}/run${runnumber}_ls0001_streamDQM_test.jsn -CMDLINE_STARTDQM="cmsRun test_dqmstream.py runInputDir=./dqmdisk runNumber=100101" +CMDLINE_STARTDQM="cmsRun test_dqmstream.py runInputDir=./dqmdisk runNumber=100101 maxLS=1 eventsPerLS=35" ${CMDLINE_STARTDQM} > out_2_dqm.log 2>&1 || diedqm "${CMDLINE_STARTDQM}" $? $OUTDIR rm -rf $OUTDIR/{ramdisk,data,*.log} diff --git a/EventFilter/Utilities/test/TestReadingStreamerFile.sh b/EventFilter/Utilities/test/TestReadingStreamerFile.sh new file mode 100755 index 0000000000000..b0b7845b45455 --- /dev/null +++ b/EventFilter/Utilities/test/TestReadingStreamerFile.sh @@ -0,0 +1,203 @@ +#!/bin/bash +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function diewrite { echo Failure $1: status $2 ; echo "" ; echo "----- Error -----"; echo ""; cat out_2_write.log; rm -rf $3/{ramdisk,data,*.py}; exit $2 ; } +function dieread { echo Failure $1: status $2 ; echo "" ; echo "----- Error -----"; echo ""; cat out_2_read.log; rm -rf $3/{ramdisk,data,*.py}; exit $2 ; } +function diemerge { echo Failure $1: status $2 ; echo "" ; echo "----- Error -----"; echo ""; cat out_2_merge.log; rm -rf $3/{ramdisk,data,*.py}; exit $2 ; } + + + +if [ -z ${SCRAM_TEST_PATH} ]; then +SCRAM_TEST_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +fi +echo "SCRAM_TEST_PATH = ${SCRAM_TEST_PATH}" + +RC=0 +P=$$ +PREFIX=results_${USER}${P} +OUTDIR=${PWD}/${PREFIX} + +echo "OUT_TMP_DIR = $OUTDIR" + +mkdir ${OUTDIR} +cp ${SCRIPTDIR}/writeStreamerFile_cfg.py ${OUTDIR} +cp ${SCRIPTDIR}/readStreamerFile_cfg.py ${OUTDIR} +cp ${SCRIPTDIR}/mergeStreamerFile_cfg.py ${OUTDIR} +cd ${OUTDIR} + +rm -rf $OUTDIR/{ramdisk,data,*.log} + +runnumber="100101" + +############################### +echo "Running test on reading single file" +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=10" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + +rm -rf data +########################## +echo "Running test on reading two separate files" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test1.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test1.dat + +rm -rf data + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test2.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test2.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test1.dat --input test2.dat --runNumber=${runnumber} --numEvents=20" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + +rm -rf data +############################# +echo "Running test on reading two separate files with different BranchIDLists" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test1.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test1.dat + +rm -rf data + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber} --changeBranchIDLists T" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test2.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test2.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test1.dat --input test2.dat --runNumber=${runnumber} --numEvents=20" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + +rm -rf data +########################## + +echo "Running test one concatenated file" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=20" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR +#cat out_2_read.log + +rm -rf data +############################# +echo "Running test on concatenated file from jobs with different BranchIDLists" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber} --changeBranchIDLists T" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=20" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR +#cat out_2_read.log + +rm -rf data + +########################### +echo "Test merging streamers using cmsRun" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test1.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test1.dat + +rm -rf data + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test2.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test2.dat + +rm -rf data + + +CMDLINE_MERGE="cmsRun mergeStreamerFile_cfg.py --input test1.dat --input test2.dat --runNumber=${runnumber}" +${CMDLINE_MERGE} > out_2_merge.log 2>&1 || diemerge "${CMDLINE_MERGE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_merge_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_merge_pid*.dat >> test.dat + + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=20" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + +rm -rf data +############################# +echo "Test merging files with different BranchIDLists" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test1.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test1.dat + +rm -rf data + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber} --changeBranchIDLists T" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test2.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test2.dat + +rm -rf data + +CMDLINE_MERGE="cmsRun mergeStreamerFile_cfg.py --input test1.dat --input test2.dat --runNumber=${runnumber}" +${CMDLINE_MERGE} > out_2_merge.log 2>&1 || diemerge "${CMDLINE_MERGE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_merge_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_merge_pid*.dat >> test.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=20" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + + +############################ + +#no failures, clean up everything including logs if there are no errors +echo "Completed sucessfully" +#rm -rf $OUTDIR/{ramdisk,data,*.py,*.log} +rm -rf $OUTDIR + +exit ${RC} + diff --git a/EventFilter/Utilities/test/mergeStreamerFile_cfg.py b/EventFilter/Utilities/test/mergeStreamerFile_cfg.py new file mode 100644 index 0000000000000..274e2a4f322f8 --- /dev/null +++ b/EventFilter/Utilities/test/mergeStreamerFile_cfg.py @@ -0,0 +1,59 @@ +import FWCore.ParameterSet.Config as cms +from argparse import ArgumentParser + +parser = ArgumentParser(description='Test merge using GlobalEvFOutputModule') +parser.add_argument("--input", action="append", default=[], help="Input files") +parser.add_argument("--numThreads", help="number of threads to use", type=int, default=3) +parser.add_argument("--numFwkStreams", help="number of cmsRun streams", type=int, default=2) +parser.add_argument("--changeBranchIDLists", help="modify the branchIDLists", type=bool, default=False) +parser.add_argument("--runNumber", help="run number to use", type=int, default=100101) +parser.add_argument("--buBaseDir", help="BU base directory", type=str, default="ramdisk") +parser.add_argument("--fuBaseDir", help="FU base directory", type=str, default="data") +parser.add_argument("--fffBaseDir", help="FFF base directory", type=str, default=".") + +args = parser.parse_args() + +#try to create 'ramdisk' directory +try: + os.makedirs(args.fffBaseDir+"/"+args.buBaseDir+"/run"+str(args.runNumber).zfill(6)) +except:pass +#try to create 'data' directory +try: + os.makedirs(args.fffBaseDir+"/"+args.fuBaseDir+"/run"+str(args.runNumber).zfill(6)) +except Exception as ex: + print(str(ex)) + pass + + +process = cms.Process("MERGE") + +if len(args.input) == 0: + parser.error("No input files") + +process.source = cms.Source("NewEventStreamFileReader", + fileNames = cms.untracked.vstring(["file:"+f for f in args.input]) +) + +process.options = dict(numberOfThreads = args.numThreads, + numberOfStreams = args.numFwkStreams) + +process.merge = cms.OutputModule("GlobalEvFOutputModule", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring()), + outputCommands = cms.untracked.vstring("keep *") +) + +process.ep = cms.EndPath(process.merge) + +process.EvFDaqDirector = cms.Service("EvFDaqDirector", + useFileBroker = cms.untracked.bool(False), + fileBrokerHostFromCfg = cms.untracked.bool(True), + fileBrokerHost = cms.untracked.string("htcp40.cern.ch"), + runNumber = cms.untracked.uint32(args.runNumber), + baseDir = cms.untracked.string(args.fffBaseDir+"/"+args.fuBaseDir), + buBaseDir = cms.untracked.string(args.fffBaseDir+"/"+args.buBaseDir), + directorIsBU = cms.untracked.bool(False), +) + +process.FastMonitoringService = cms.Service("FastMonitoringService", + sleepTime = cms.untracked.int32(1) +) diff --git a/EventFilter/Utilities/test/readStreamerFile_cfg.py b/EventFilter/Utilities/test/readStreamerFile_cfg.py new file mode 100644 index 0000000000000..3dffce4d75a33 --- /dev/null +++ b/EventFilter/Utilities/test/readStreamerFile_cfg.py @@ -0,0 +1,41 @@ +import FWCore.ParameterSet.Config as cms +import argparse +import sys + +process = cms.Process("READ") + + +parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test output of GlobalEvFOutputModule') +parser.add_argument("--input", action="append", default=[], help="Input files") +parser.add_argument("--runNumber", type=int, default=1, help="expected run number") +parser.add_argument("--numEvents", type=int, default=10, help="expected number of events") +args = parser.parse_args() +if len(args.input) == 0: + parser.error("No input files") + +process.source = cms.Source("NewEventStreamFileReader", + fileNames = cms.untracked.vstring(["file:"+f for f in args.input]) +) + +process.tester = cms.EDAnalyzer("OtherThingAnalyzer", + other = cms.untracked.InputTag("otherThing","testUserTag") +) + +rn = args.runNumber +lumi = 1 +transitions = [cms.EventID(rn,0,0),cms.EventID(rn,lumi,0)] +evid = 1 + +for ev in range(0, args.numEvents): + transitions.append(cms.EventID(rn,lumi,evid)) + evid += 1 +transitions.append(cms.EventID(rn,lumi,0)) #end lumi +transitions.append(cms.EventID(rn,0,0)) #end run + +process.test = cms.EDAnalyzer("RunLumiEventChecker", + eventSequence = cms.untracked.VEventID(*transitions), + unorderedEvents = cms.untracked.bool(True) +) + + +process.e = cms.EndPath(process.tester+process.test) diff --git a/EventFilter/Utilities/test/test_dqmstream.py b/EventFilter/Utilities/test/test_dqmstream.py index 474b7d0bd3ec4..eb02c94a8dc83 100644 --- a/EventFilter/Utilities/test/test_dqmstream.py +++ b/EventFilter/Utilities/test/test_dqmstream.py @@ -19,6 +19,16 @@ VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Directory where the DQM files will appear.") +options.register('eventsPerLS', + 35, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Max LS to generate (0 to disable limit)") +options.register ('maxLS', + 2, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Max LS to generate (0 to disable limit)") options.parseArguments() @@ -42,3 +52,27 @@ SelectEvents = cms.untracked.vstring("HLT*Mu*","HLT_*Physics*") ) +#make a list of all the EventIDs that were seen by the previous job, +# given the filter is semi-random we do not know which of these will +# be the actual first event written +rn = options.runNumber +transitions = [cms.EventID(rn,0,0)] +evid = 1 +for lumi in range(1, options.maxLS+1): + transitions.append(cms.EventID(rn,lumi,0)) + for ev in range(0, options.eventsPerLS): + transitions.append(cms.EventID(rn,lumi,evid)) + evid += 1 + transitions.append(cms.EventID(rn,lumi,0)) #end lumi +transitions.append(cms.EventID(rn,0,0)) #end run + +#only see 1 event as process.source.minEventsPerLumi == 1 +process.test = cms.EDAnalyzer("RunLumiEventChecker", + eventSequence = cms.untracked.VEventID(*transitions), + unorderedEvents = cms.untracked.bool(True), + minNumberOfEvents = cms.untracked.uint32(1+2+2), + maxNumberOfEvents = cms.untracked.uint32(1+2+2) +) + +process.p = cms.Path(process.test) + diff --git a/EventFilter/Utilities/test/writeStreamerFile_cfg.py b/EventFilter/Utilities/test/writeStreamerFile_cfg.py new file mode 100644 index 0000000000000..d747a97b98ad1 --- /dev/null +++ b/EventFilter/Utilities/test/writeStreamerFile_cfg.py @@ -0,0 +1,74 @@ +import FWCore.ParameterSet.Config as cms +from argparse import ArgumentParser + +parser = ArgumentParser(description='Test GlobalEvFOutputModule') +parser.add_argument("--numEvents", help="number of events to process", type=int, default=10) +parser.add_argument("--startEvent", help="start event number", type=int, default=1) +parser.add_argument("--runNumber", help="run number to use", type=int, default=100101) +parser.add_argument("--numThreads", help="number of threads to use", type=int, default=3) +parser.add_argument("--numFwkStreams", help="number of cmsRun streams", type=int, default=2) +parser.add_argument("--changeBranchIDLists", help="modify the branchIDLists", type=bool, default=False) + +parser.add_argument("--buBaseDir", help="BU base directory", type=str, default="ramdisk") +parser.add_argument("--fuBaseDir", help="FU base directory", type=str, default="data") +parser.add_argument("--fffBaseDir", help="FFF base directory", type=str, default=".") + +args = parser.parse_args() + +#try to create 'ramdisk' directory +try: + os.makedirs(args.fffBaseDir+"/"+args.buBaseDir+"/run"+str(args.runNumber).zfill(6)) +except:pass +#try to create 'data' directory +try: + os.makedirs(args.fffBaseDir+"/"+args.fuBaseDir+"/run"+str(args.runNumber).zfill(6)) +except Exception as ex: + print(str(ex)) + pass + + +process = cms.Process("WRITE") + +process.source = cms.Source("EmptySource", + firstRun=cms.untracked.uint32(args.runNumber), + firstEvent=cms.untracked.uint32(args.startEvent) +) + +process.maxEvents.input = args.numEvents +process.options = dict(numberOfThreads = args.numThreads, + numberOfStreams = args.numFwkStreams) + +process.intprod = cms.EDProducer("BranchIDListsModifierProducer", + makeExtraProduct=cms.untracked.bool(args.changeBranchIDLists)) + +process.thing = cms.EDProducer("ThingProducer") + +process.otherThing = cms.EDProducer("OtherThingProducer", + thingTag=cms.InputTag("thing")) + +process.t = cms.Task( + process.intprod, + process.thing, + process.otherThing +) + +process.streamA = cms.OutputModule("GlobalEvFOutputModule", + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring()), + outputCommands = cms.untracked.vstring("keep *") +) + +process.ep = cms.EndPath(process.streamA, process.t) + +process.EvFDaqDirector = cms.Service("EvFDaqDirector", + useFileBroker = cms.untracked.bool(False), + fileBrokerHostFromCfg = cms.untracked.bool(True), + fileBrokerHost = cms.untracked.string("htcp40.cern.ch"), + runNumber = cms.untracked.uint32(args.runNumber), + baseDir = cms.untracked.string(args.fffBaseDir+"/"+args.fuBaseDir), + buBaseDir = cms.untracked.string(args.fffBaseDir+"/"+args.buBaseDir), + directorIsBU = cms.untracked.bool(False), +) + +process.FastMonitoringService = cms.Service("FastMonitoringService", + sleepTime = cms.untracked.int32(1) +) diff --git a/FWCore/Modules/src/BranchIDListsModifierProducer.cc b/FWCore/Modules/src/BranchIDListsModifierProducer.cc new file mode 100644 index 0000000000000..5a9591b28e275 --- /dev/null +++ b/FWCore/Modules/src/BranchIDListsModifierProducer.cc @@ -0,0 +1,52 @@ +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" + +#include "FWCore/Utilities/interface/EDPutToken.h" + +#include "DataFormats/TestObjects/interface/ToyProducts.h" + +class BranchIDListsModifierProducer : public edm::global::EDProducer<> { +public: + BranchIDListsModifierProducer(edm::ParameterSet const& iPSet); + + void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const; + + static void fillDescriptions(edm::ConfigurationDescriptions& iDesc); + +private: + edm::EDPutTokenT const token_; + edm::EDPutTokenT extraToken_; + bool const extraProduct_; +}; + +BranchIDListsModifierProducer::BranchIDListsModifierProducer(edm::ParameterSet const& iPSet) + : token_(produces()), extraProduct_(iPSet.getUntrackedParameter("makeExtraProduct")) { + if (extraProduct_) { + extraToken_ = produces("extra"); + } +} + +void BranchIDListsModifierProducer::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const { + iEvent.emplace(token_, 1); + if (extraProduct_) { + iEvent.emplace(extraToken_, 2); + } +} + +void BranchIDListsModifierProducer::fillDescriptions(edm::ConfigurationDescriptions& iDesc) { + edm::ParameterSetDescription ps; + ps.setComment( + "Module which can cause the BranchIDLists to change even when the top level PSet remains the same.\n" + "Used for multi-file merge tests."); + + ps.addUntracked("makeExtraProduct", false)->setComment("If set to true will produce an extra product"); + + iDesc.addDefault(ps); +} + +DEFINE_FWK_MODULE(BranchIDListsModifierProducer); diff --git a/FWCore/Modules/src/RunLumiEventChecker.cc b/FWCore/Modules/src/RunLumiEventChecker.cc index e1da77f4fcd1c..15a00f5f3297e 100644 --- a/FWCore/Modules/src/RunLumiEventChecker.cc +++ b/FWCore/Modules/src/RunLumiEventChecker.cc @@ -67,6 +67,8 @@ class RunLumiEventChecker // ----------member data --------------------------- std::vector ids_; mutable std::atomic index_; + unsigned int minNEvents_ = 0; + unsigned int maxNEvents_ = 0; bool unorderedEvents_; }; @@ -84,6 +86,8 @@ class RunLumiEventChecker RunLumiEventChecker::RunLumiEventChecker(edm::ParameterSet const& iConfig) : ids_(iConfig.getUntrackedParameter>("eventSequence")), index_(0), + minNEvents_(iConfig.getUntrackedParameter("minNumberOfEvents")), + maxNEvents_(iConfig.getUntrackedParameter("maxNumberOfEvents")), unorderedEvents_(iConfig.getUntrackedParameter("unorderedEvents")) { //now do what ever initialization is needed } @@ -144,9 +148,16 @@ void RunLumiEventChecker::beginJob() {} // ------------ method called once each job just after ending the event loop ------------ void RunLumiEventChecker::endJob() { - if (index_ != ids_.size()) { + if (maxNEvents_ == 0 and index_ != ids_.size()) { throw cms::Exception("WrongNumberOfEvents") - << "Saw " << index_ << " events but was supposed to see " << ids_.size() << "\n"; + << "Saw " << index_ << " (begin runs)+(begin lumis)+events+(end lumis)+(end runs) but was supposed to see " + << ids_.size() << "\n"; + } + if (maxNEvents_ != 0 and (index_ < minNEvents_ or index_ > maxNEvents_)) { + throw cms::Exception("WrongNumberOfEvents") + << "Saw " << index_ + << " (begin runs)+(begin lumis)+events+(end lumis)+(end runs) but was supposed to see between " << minNEvents_ + << " and " << maxNEvents_; } } @@ -154,7 +165,14 @@ void RunLumiEventChecker::endJob() { void RunLumiEventChecker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.addUntracked>("eventSequence"); - desc.addUntracked("unorderedEvents", false); + desc.addUntracked("minNumberOfEvents", 0) + ->setComment( + "minimum number of Events that must be seen. If max is 0 then this will be ignored and all Events must be " + "present"); + desc.addUntracked("maxNumberOfEvents", 0) + ->setComment("maximum number of Events that must be seen. If set to 0, min and max are ignored"); + desc.addUntracked("unorderedEvents", false) + ->setComment("set to true if events are not guaranteed to be in same order as 'eventSequence' specifies."); descriptions.add("runLumiEventIDChecker", desc); } diff --git a/IOPool/Streamer/interface/StreamSerializer.h b/IOPool/Streamer/interface/StreamSerializer.h index 14b85e366b06c..adc83b09c34a8 100644 --- a/IOPool/Streamer/interface/StreamSerializer.h +++ b/IOPool/Streamer/interface/StreamSerializer.h @@ -75,9 +75,9 @@ namespace edm::streamer { public: StreamSerializer(SelectedProducts const *selections); - int serializeRegistry(SerializeDataBuffer &data_buffer); + int serializeRegistry(SerializeDataBuffer &data_buffer) const; - int serializeRegistry(SerializeDataBuffer &data_buffer, SendJobHeader::ParameterSetMap const &psetMap); + int serializeRegistry(SerializeDataBuffer &data_buffer, SendJobHeader::ParameterSetMap const &psetMap) const; int serializeEvent(SerializeDataBuffer &data_buffer, EventForOutput const &event, diff --git a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h index a0b3f4e35338d..7c6a2fbb830b5 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleCommon.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleCommon.h @@ -3,7 +3,7 @@ #include "IOPool/Streamer/interface/MsgTools.h" #include "FWCore/Common/interface/TriggerNames.h" -#include "IOPool/Streamer/interface/StreamSerializer.h" +#include "IOPool/Streamer/interface/StreamerOutputMsgBuilders.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Streamer/interface/StreamedProducts.h" #include @@ -22,13 +22,7 @@ namespace edm { class StreamerOutputModuleCommon { public: - struct Parameters { - Strings hltTriggerSelections; - std::string compressionAlgoStr; - int compressionLevel; - int lumiSectionInterval; - bool useCompression; - }; + using Parameters = StreamerOutputMsgBuilders::Parameters; static Parameters parameters(ParameterSet const& ps); @@ -44,56 +38,24 @@ namespace edm { ~StreamerOutputModuleCommon(); static void fillDescription(ParameterSetDescription& desc); - std::unique_ptr serializeRegistry(SerializeDataBuffer& sbuf, - std::string const& processName, + std::unique_ptr serializeRegistry(std::string const& processName, std::string const& moduleLabel, ParameterSetID const& toplevel, SendJobHeader::ParameterSetMap const* psetMap); - std::unique_ptr serializeEventMetaData(SerializeDataBuffer& sbuf, - BranchIDLists const& branchLists, + std::unique_ptr serializeEventMetaData(BranchIDLists const& branchLists, ThinnedAssociationsHelper const& helper); - std::unique_ptr serializeEvent(SerializeDataBuffer& sbuf, - EventForOutput const& e, + std::unique_ptr serializeEvent(EventForOutput const& e, Handle const& triggerResults, ParameterSetID const& selectorCfg); - SerializeDataBuffer* getSerializerBuffer(); - protected: - std::unique_ptr serializerBuffer_; + void clearHeaderBuffer() { buffer_.clearHeaderBuffer(); } private: - std::unique_ptr serializeEventCommon(uint32 run, - uint32 lumi, - uint64 event, - std::vector hltbits, - unsigned int hltsize, - SerializeDataBuffer& sbuf); - - void setHltMask(EventForOutput const& e, - Handle const& triggerResults, - std::vector& hltbits) const; - - StreamSerializer serializer_; - - int maxEventSize_; - bool useCompression_; - std::string compressionAlgoStr_; - int compressionLevel_; - - StreamerCompressionAlgo compressionAlgo_; - - // test luminosity sections - int lumiSectionInterval_; - double timeInSecSinceUTC; - - unsigned int hltsize_; - char host_name_[255]; - - Strings hltTriggerSelections_; - uint32 outputModuleId_; + SerializeDataBuffer buffer_; + StreamerOutputMsgBuilders builders_; uint32_t eventMetaDataChecksum_ = 0; }; //end-of-class-def diff --git a/IOPool/Streamer/interface/StreamerOutputMsgBuilders.h b/IOPool/Streamer/interface/StreamerOutputMsgBuilders.h new file mode 100644 index 0000000000000..caed77c0c4a9a --- /dev/null +++ b/IOPool/Streamer/interface/StreamerOutputMsgBuilders.h @@ -0,0 +1,93 @@ +#ifndef IOPool_Streamer_StreamerOutputMsgBuilders_h +#define IOPool_Streamer_StreamerOutputMsgBuilders_h + +#include "IOPool/Streamer/interface/MsgTools.h" +#include "FWCore/Common/interface/TriggerNames.h" +#include "IOPool/Streamer/interface/StreamSerializer.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Streamer/interface/StreamedProducts.h" +#include +#include + +namespace edm { + class EventForOutput; + class ThinnedAssociationsHelper; + class TriggerResults; + class ParameterSet; + class ParameterSetDescription; + + namespace streamer { + class InitMsgBuilder; + class EventMsgBuilder; + + class StreamerOutputMsgBuilders { + public: + struct Parameters { + Strings hltTriggerSelections; + std::string compressionAlgoStr; + int compressionLevel; + int lumiSectionInterval; + bool useCompression; + }; + + static Parameters parameters(ParameterSet const& ps); + + explicit StreamerOutputMsgBuilders(Parameters const& p, + SelectedProducts const* selections, + std::string const& moduleLabel); + + ~StreamerOutputMsgBuilders(); + static void fillDescription(ParameterSetDescription& desc); + + std::unique_ptr serializeRegistry(SerializeDataBuffer& sbuf, + std::string const& processName, + std::string const& moduleLabel, + ParameterSetID const& toplevel, + SendJobHeader::ParameterSetMap const* psetMap) const; + + std::pair, uint32_t> serializeEventMetaData( + SerializeDataBuffer& sbuf, BranchIDLists const& branchLists, ThinnedAssociationsHelper const& helper) const; + + std::unique_ptr serializeEvent(SerializeDataBuffer& sbuf, + EventForOutput const& e, + Handle const& triggerResults, + ParameterSetID const& selectorCfg, + uint32_t eventMetaDataChecksum) const; + + private: + std::unique_ptr serializeEventCommon(uint32 run, + uint32 lumi, + uint64 event, + std::vector hltbits, + unsigned int hltsize, + SerializeDataBuffer& sbuf) const; + + void setHltMask(EventForOutput const& e, + Handle const& triggerResults, + std::vector& hltbits) const; + + StreamSerializer serializer_; + + int maxEventSize_; + bool useCompression_; + std::string compressionAlgoStr_; + int compressionLevel_; + + StreamerCompressionAlgo compressionAlgo_; + + // test luminosity sections + int lumiSectionInterval_; + double timeInSecSinceUTC; + + unsigned int hltsize_; + char host_name_[255]; + + Strings hltTriggerSelections_; + uint32 outputModuleId_; + + uint32_t eventMetaDataChecksum_ = 0; + }; //end-of-class-def + } // namespace streamer +} // namespace edm + +#endif diff --git a/IOPool/Streamer/src/StreamSerializer.cc b/IOPool/Streamer/src/StreamSerializer.cc index 545934e200116..76b4cd2aaa411 100644 --- a/IOPool/Streamer/src/StreamSerializer.cc +++ b/IOPool/Streamer/src/StreamSerializer.cc @@ -42,14 +42,14 @@ namespace edm::streamer { * Serializes the product registry (that was specified to the constructor) * into the specified InitMessage. */ - int StreamSerializer::serializeRegistry(SerializeDataBuffer &data_buffer) { + int StreamSerializer::serializeRegistry(SerializeDataBuffer &data_buffer) const { SendJobHeader::ParameterSetMap psetMap; pset::Registry::instance()->fillMap(psetMap); return serializeRegistry(data_buffer, psetMap); } int StreamSerializer::serializeRegistry(SerializeDataBuffer &data_buffer, - SendJobHeader::ParameterSetMap const &psetMap) { + SendJobHeader::ParameterSetMap const &psetMap) const { FDEBUG(6) << "StreamSerializer::serializeRegistry" << std::endl; SendJobHeader sd; diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index 6b17eaece784e..14afc99d7d30c 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -29,8 +29,7 @@ namespace edm::streamer { auto psetMapHandle = iRun.getHandle(psetToken_); std::unique_ptr init_message = - serializeRegistry(*getSerializerBuffer(), - OutputModule::processName(), + serializeRegistry(OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID(), psetMapHandle.isValid() ? psetMapHandle.product() : nullptr); @@ -38,7 +37,7 @@ namespace edm::streamer { doOutputHeader(*init_message); lastCallWasBeginRun_ = true; - serializerBuffer_->clearHeaderBuffer(); + clearHeaderBuffer(); } void StreamerOutputModuleBase::endRun(RunForOutput const&) { stop(); } @@ -55,11 +54,11 @@ namespace edm::streamer { Handle const& triggerResults = getTriggerResults(trToken_, e); if (lastCallWasBeginRun_) { - auto msg = serializeEventMetaData(*getSerializerBuffer(), *branchIDLists(), *thinnedAssociationsHelper()); + auto msg = serializeEventMetaData(*branchIDLists(), *thinnedAssociationsHelper()); doOutputEvent(*msg); lastCallWasBeginRun_ = false; } - auto msg = serializeEvent(*getSerializerBuffer(), e, triggerResults, selectorConfig()); + auto msg = serializeEvent(e, triggerResults, selectorConfig()); doOutputEvent(*msg); // You can't use msg in StreamerOutputModuleBase after this point } diff --git a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc index da1912e9882e9..377906cbe69a9 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleCommon.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleCommon.cc @@ -24,300 +24,38 @@ namespace edm::streamer { StreamerOutputModuleCommon::Parameters StreamerOutputModuleCommon::parameters(ParameterSet const& ps) { - Parameters ret; - ret.hltTriggerSelections = EventSelector::getEventSelectionVString(ps); - ret.compressionAlgoStr = ps.getUntrackedParameter("compression_algorithm"); - ret.compressionLevel = ps.getUntrackedParameter("compression_level"); - ret.lumiSectionInterval = ps.getUntrackedParameter("lumiSection_interval"); - ret.useCompression = ps.getUntrackedParameter("use_compression"); - return ret; + return StreamerOutputMsgBuilders::parameters(ps); } StreamerOutputModuleCommon::StreamerOutputModuleCommon(Parameters const& p, SelectedProducts const* selections, std::string const& moduleLabel) - : - - serializer_(selections), - useCompression_(p.useCompression), - compressionAlgoStr_(p.compressionAlgoStr), - compressionLevel_(p.compressionLevel), - lumiSectionInterval_(p.lumiSectionInterval), - hltsize_(0), - host_name_(), - hltTriggerSelections_(), - outputModuleId_(0) { - //limits initially set for default ZLIB option - int minCompressionLevel = 1; - int maxCompressionLevel = 9; - - // test luminosity sections - struct timeval now; - struct timezone dummyTZ; - gettimeofday(&now, &dummyTZ); - timeInSecSinceUTC = static_cast(now.tv_sec) + (static_cast(now.tv_usec) / 1000000.0); - - if (useCompression_ == true) { - if (compressionAlgoStr_ == "ZLIB") { - compressionAlgo_ = ZLIB; - } else if (compressionAlgoStr_ == "LZMA") { - compressionAlgo_ = LZMA; - minCompressionLevel = 0; - } else if (compressionAlgoStr_ == "ZSTD") { - compressionAlgo_ = ZSTD; - maxCompressionLevel = 20; - } else if (compressionAlgoStr_ == "UNCOMPRESSED") { - compressionLevel_ = 0; - useCompression_ = false; - compressionAlgo_ = UNCOMPRESSED; - } else - throw cms::Exception("StreamerOutputModuleCommon", "Compression type unknown") - << "Unknown compression algorithm " << compressionAlgoStr_; - - if (compressionLevel_ < minCompressionLevel) { - FDEBUG(9) << "Compression Level = " << compressionLevel_ << " no compression" << std::endl; - compressionLevel_ = 0; - useCompression_ = false; - compressionAlgo_ = UNCOMPRESSED; - } else if (compressionLevel_ > maxCompressionLevel) { - FDEBUG(9) << "Compression Level = " << compressionLevel_ << " using max compression level " - << maxCompressionLevel << std::endl; - compressionLevel_ = maxCompressionLevel; - compressionAlgo_ = UNCOMPRESSED; - } - } else - compressionAlgo_ = UNCOMPRESSED; - - int got_host = gethostname(host_name_, 255); - if (got_host != 0) - strncpy(host_name_, "noHostNameFoundOrTooLong", sizeof(host_name_)); - //loadExtraClasses(); - - // 25-Jan-2008, KAB - pull out the trigger selection request - // which we need for the INIT message - hltTriggerSelections_ = p.hltTriggerSelections; - - Strings const& hltTriggerNames = edm::getAllTriggerNames(); - hltsize_ = hltTriggerNames.size(); - - //Checksum of the module label - uLong crc = crc32(0L, Z_NULL, 0); - Bytef const* buf = (Bytef const*)(moduleLabel.data()); - crc = crc32(crc, buf, moduleLabel.length()); - outputModuleId_ = static_cast(crc); - } + : builders_(p, selections, moduleLabel) {} StreamerOutputModuleCommon::~StreamerOutputModuleCommon() {} std::unique_ptr StreamerOutputModuleCommon::serializeRegistry( - SerializeDataBuffer& sbuf, std::string const& processName, std::string const& moduleLabel, ParameterSetID const& toplevel, SendJobHeader::ParameterSetMap const* psetMap) { - if (psetMap) { - serializer_.serializeRegistry(sbuf, *psetMap); - } else { - serializer_.serializeRegistry(sbuf); - } - // resize header_buf_ to reflect space used in serializer_ + header - // I just added an overhead for header of 50000 for now - unsigned int src_size = sbuf.currentSpaceUsed(); - unsigned int new_size = src_size + 50000; - if (sbuf.header_buf_.size() < new_size) - sbuf.header_buf_.resize(new_size); - - //Build the INIT Message - //Following values are strictly DUMMY and will be replaced - // once available with Utility function etc. - uint32 run = 1; - - //Get the Process PSet ID - - //In case we need to print it - // cms::Digest dig(toplevel.compactForm()); - // cms::MD5Result r1 = dig.digest(); - // std::string hexy = r1.toString(); - // std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl; - - //L1 stays dummy as of today - Strings l1_names; //3 - l1_names.push_back("t1"); - l1_names.push_back("t10"); - l1_names.push_back("t2"); - - Strings const& hltTriggerNames = edm::getAllTriggerNames(); - - auto init_message = std::make_unique(&sbuf.header_buf_[0], - sbuf.header_buf_.size(), - run, - Version((uint8 const*)toplevel.compactForm().c_str()), - getReleaseVersion().c_str(), - processName.c_str(), - moduleLabel.c_str(), - outputModuleId_, - hltTriggerNames, - hltTriggerSelections_, - l1_names, - (uint32)sbuf.adler32_chksum()); - - // copy data into the destination message - unsigned char* src = sbuf.bufferPointer(); - std::copy(src, src + src_size, init_message->dataAddress()); - init_message->setDataLength(src_size); - return init_message; - } - - void StreamerOutputModuleCommon::setHltMask(EventForOutput const& e, - Handle const& triggerResults, - std::vector& hltbits) const { - hltbits.clear(); - - std::vector vHltState; - - if (triggerResults.isValid()) { - for (std::vector::size_type i = 0; i != hltsize_; ++i) { - vHltState.push_back(((triggerResults->at(i)).state())); - } - } else { - // We fill all Trigger bits to valid state. - for (std::vector::size_type i = 0; i != hltsize_; ++i) { - vHltState.push_back(hlt::Pass); - } - } - - //Pack into member hltbits - if (!vHltState.empty()) { - unsigned int packInOneByte = 4; - unsigned int sizeOfPackage = 1 + ((vHltState.size() - 1) / packInOneByte); //Two bits per HLT - - hltbits.resize(sizeOfPackage); - std::fill(hltbits.begin(), hltbits.end(), 0); - - for (std::vector::size_type i = 0; i != vHltState.size(); ++i) { - unsigned int whichByte = i / packInOneByte; - unsigned int indxWithinByte = i % packInOneByte; - hltbits[whichByte] = hltbits[whichByte] | (vHltState[i] << (indxWithinByte * 2)); - } - } - - //This is Just a printing code. - //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl; - //for(unsigned int i=0; i != hltbits_.size() ; ++i) { - // printBits(hltbits_[i]); - //} - //std::cout << "\n"; + return builders_.serializeRegistry(buffer_, processName, moduleLabel, toplevel, psetMap); } std::unique_ptr StreamerOutputModuleCommon::serializeEvent( - SerializeDataBuffer& sbuf, - EventForOutput const& e, - Handle const& triggerResults, - ParameterSetID const& selectorCfg) { - constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; - //Lets Build the Event Message first - - std::vector hltbits; - setHltMask(e, triggerResults, hltbits); - - uint32 lumi = e.luminosityBlock(); - if (lumiSectionInterval_ != 0) { - struct timeval now; - struct timezone dummyTZ; - gettimeofday(&now, &dummyTZ); - double timeInSec = - static_cast(now.tv_sec) + (static_cast(now.tv_usec) / 1000000.0) - timeInSecSinceUTC; - // what about overflows? - lumi = static_cast(timeInSec / std::abs(lumiSectionInterval_)) + 1; - } - serializer_.serializeEvent( - sbuf, e, selectorCfg, eventMetaDataChecksum_, compressionAlgo_, compressionLevel_, reserve_size); - - return serializeEventCommon(e.id().run(), lumi, e.id().event(), hltbits, hltsize_, sbuf); + EventForOutput const& e, Handle const& triggerResults, ParameterSetID const& selectorCfg) { + return builders_.serializeEvent(buffer_, e, triggerResults, selectorCfg, eventMetaDataChecksum_); } std::unique_ptr StreamerOutputModuleCommon::serializeEventMetaData( - SerializeDataBuffer& sbuf, BranchIDLists const& branchLists, ThinnedAssociationsHelper const& helper) { - constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; - //Lets Build the Event Message first - - std::vector hltbits; - serializer_.serializeEventMetaData(sbuf, branchLists, helper, compressionAlgo_, compressionLevel_, reserve_size); - eventMetaDataChecksum_ = sbuf.adler32_chksum_; - - return serializeEventCommon(0, 0, 0, hltbits, 0, sbuf); - } - - std::unique_ptr StreamerOutputModuleCommon::serializeEventCommon(uint32 run, - uint32 lumi, - uint64 event, - std::vector hltbits, - unsigned int hltsize, - SerializeDataBuffer& sbuf) { - // resize header_buf_ to reserved size on first written event - constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; - if (sbuf.header_buf_.size() < reserve_size) - sbuf.header_buf_.resize(reserve_size); - - //Following is strictly DUMMY Data for L! Trig and will be replaced with actual - // once figured out, there is no logic involved here. - std::vector l1bit = {true, true, false}; - //End of dummy data - - auto msg = std::make_unique(&sbuf.header_buf_[0], - sbuf.comp_buf_.size(), - run, - event, - lumi, - outputModuleId_, - 0, - l1bit, - (uint8*)&hltbits[0], - hltsize, - (uint32)sbuf.adler32_chksum(), - host_name_); - - // 50000 bytes is reserved for header as has been the case with previous version which did one extra copy of event data - uint32 headerSize = msg->headerSize(); - if (headerSize > reserve_size) - throw cms::Exception("StreamerOutputModuleCommon", "Header Overflow") - << " header of size " << headerSize << "bytes is too big to fit into the reserved buffer space"; - - //set addresses to other buffer and copy constructed header there - msg->setBufAddr(&sbuf.comp_buf_[reserve_size - headerSize]); - msg->setEventAddr(sbuf.bufferPointer()); - std::copy(&sbuf.header_buf_[0], &sbuf.header_buf_[headerSize], (char*)(&sbuf.comp_buf_[reserve_size - headerSize])); - - unsigned int src_size = sbuf.currentSpaceUsed(); - msg->setEventLength(src_size); //compressed size - if (useCompression_) - msg->setOrigDataSize( - sbuf.currentEventSize()); //uncompressed size (or 0 if no compression -> streamer input source requires this) - else - msg->setOrigDataSize(0); - - return msg; + BranchIDLists const& branchLists, ThinnedAssociationsHelper const& helper) { + auto ret = builders_.serializeEventMetaData(buffer_, branchLists, helper); + eventMetaDataChecksum_ = ret.second; + return std::move(ret.first); } void StreamerOutputModuleCommon::fillDescription(ParameterSetDescription& desc) { - desc.addUntracked("max_event_size", 7000000)->setComment("Obsolete parameter."); - desc.addUntracked("use_compression", true) - ->setComment("If True, compression will be used to write streamer file."); - desc.addUntracked("compression_algorithm", "ZLIB") - ->setComment("Compression algorithm to use: UNCOMPRESSED, ZLIB, LZMA or ZSTD"); - desc.addUntracked("compression_level", 1)->setComment("Compression level to use on serialized ROOT events"); - desc.addUntracked("lumiSection_interval", 0) - ->setComment( - "If 0, use lumi section number from event.\n" - "If not 0, the interval in seconds between fake lumi sections."); + StreamerOutputMsgBuilders::fillDescription(desc); } - SerializeDataBuffer* StreamerOutputModuleCommon::getSerializerBuffer() { - auto* ptr = serializerBuffer_.get(); - if (!ptr) { - serializerBuffer_ = std::make_unique(); - ptr = serializerBuffer_.get(); - } - return ptr; - } } // namespace edm::streamer diff --git a/IOPool/Streamer/src/StreamerOutputMsgBuilders.cc b/IOPool/Streamer/src/StreamerOutputMsgBuilders.cc new file mode 100644 index 0000000000000..0abedde6cfe6d --- /dev/null +++ b/IOPool/Streamer/src/StreamerOutputMsgBuilders.cc @@ -0,0 +1,315 @@ +#include "IOPool/Streamer/interface/StreamerOutputMsgBuilders.h" + +#include "IOPool/Streamer/interface/InitMsgBuilder.h" +#include "IOPool/Streamer/interface/EventMsgBuilder.h" +#include "FWCore/Framework/interface/EventForOutput.h" +#include "FWCore/Framework/interface/EventSelector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/DebugMacros.h" +#include "FWCore/Version/interface/GetReleaseVersion.h" +#include "DataFormats/Common/interface/TriggerResults.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" +#include "DataFormats/Provenance/interface/ParameterSetID.h" +#include "DataFormats/Provenance/interface/SelectedProducts.h" +#include "FWCore/Framework/interface/getAllTriggerNames.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace edm::streamer { + StreamerOutputMsgBuilders::Parameters StreamerOutputMsgBuilders::parameters(ParameterSet const& ps) { + Parameters ret; + ret.hltTriggerSelections = EventSelector::getEventSelectionVString(ps); + ret.compressionAlgoStr = ps.getUntrackedParameter("compression_algorithm"); + ret.compressionLevel = ps.getUntrackedParameter("compression_level"); + ret.lumiSectionInterval = ps.getUntrackedParameter("lumiSection_interval"); + ret.useCompression = ps.getUntrackedParameter("use_compression"); + return ret; + } + + StreamerOutputMsgBuilders::StreamerOutputMsgBuilders(Parameters const& p, + SelectedProducts const* selections, + std::string const& moduleLabel) + : + + serializer_(selections), + useCompression_(p.useCompression), + compressionAlgoStr_(p.compressionAlgoStr), + compressionLevel_(p.compressionLevel), + lumiSectionInterval_(p.lumiSectionInterval), + hltsize_(0), + host_name_(), + hltTriggerSelections_(), + outputModuleId_(0) { + //limits initially set for default ZLIB option + int minCompressionLevel = 1; + int maxCompressionLevel = 9; + + // test luminosity sections + struct timeval now; + struct timezone dummyTZ; + gettimeofday(&now, &dummyTZ); + timeInSecSinceUTC = static_cast(now.tv_sec) + (static_cast(now.tv_usec) / 1000000.0); + + if (useCompression_ == true) { + if (compressionAlgoStr_ == "ZLIB") { + compressionAlgo_ = ZLIB; + } else if (compressionAlgoStr_ == "LZMA") { + compressionAlgo_ = LZMA; + minCompressionLevel = 0; + } else if (compressionAlgoStr_ == "ZSTD") { + compressionAlgo_ = ZSTD; + maxCompressionLevel = 20; + } else if (compressionAlgoStr_ == "UNCOMPRESSED") { + compressionLevel_ = 0; + useCompression_ = false; + compressionAlgo_ = UNCOMPRESSED; + } else + throw cms::Exception("StreamerOutputMsgBuilders", "Compression type unknown") + << "Unknown compression algorithm " << compressionAlgoStr_; + + if (compressionLevel_ < minCompressionLevel) { + FDEBUG(9) << "Compression Level = " << compressionLevel_ << " no compression" << std::endl; + compressionLevel_ = 0; + useCompression_ = false; + compressionAlgo_ = UNCOMPRESSED; + } else if (compressionLevel_ > maxCompressionLevel) { + FDEBUG(9) << "Compression Level = " << compressionLevel_ << " using max compression level " + << maxCompressionLevel << std::endl; + compressionLevel_ = maxCompressionLevel; + compressionAlgo_ = UNCOMPRESSED; + } + } else + compressionAlgo_ = UNCOMPRESSED; + + int got_host = gethostname(host_name_, 255); + if (got_host != 0) + strncpy(host_name_, "noHostNameFoundOrTooLong", sizeof(host_name_)); + //loadExtraClasses(); + + // 25-Jan-2008, KAB - pull out the trigger selection request + // which we need for the INIT message + hltTriggerSelections_ = p.hltTriggerSelections; + + Strings const& hltTriggerNames = edm::getAllTriggerNames(); + hltsize_ = hltTriggerNames.size(); + + //Checksum of the module label + uLong crc = crc32(0L, Z_NULL, 0); + Bytef const* buf = (Bytef const*)(moduleLabel.data()); + crc = crc32(crc, buf, moduleLabel.length()); + outputModuleId_ = static_cast(crc); + } + + StreamerOutputMsgBuilders::~StreamerOutputMsgBuilders() {} + + std::unique_ptr StreamerOutputMsgBuilders::serializeRegistry( + SerializeDataBuffer& sbuf, + std::string const& processName, + std::string const& moduleLabel, + ParameterSetID const& toplevel, + SendJobHeader::ParameterSetMap const* psetMap) const { + if (psetMap) { + serializer_.serializeRegistry(sbuf, *psetMap); + } else { + serializer_.serializeRegistry(sbuf); + } + // resize header_buf_ to reflect space used in serializer_ + header + // I just added an overhead for header of 50000 for now + unsigned int src_size = sbuf.currentSpaceUsed(); + unsigned int new_size = src_size + 50000; + if (sbuf.header_buf_.size() < new_size) + sbuf.header_buf_.resize(new_size); + + //Build the INIT Message + //Following values are strictly DUMMY and will be replaced + // once available with Utility function etc. + uint32 run = 1; + + //Get the Process PSet ID + + //In case we need to print it + // cms::Digest dig(toplevel.compactForm()); + // cms::MD5Result r1 = dig.digest(); + // std::string hexy = r1.toString(); + // std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl; + + //L1 stays dummy as of today + Strings l1_names; //3 + l1_names.push_back("t1"); + l1_names.push_back("t10"); + l1_names.push_back("t2"); + + Strings const& hltTriggerNames = edm::getAllTriggerNames(); + + auto init_message = std::make_unique(&sbuf.header_buf_[0], + sbuf.header_buf_.size(), + run, + Version((uint8 const*)toplevel.compactForm().c_str()), + getReleaseVersion().c_str(), + processName.c_str(), + moduleLabel.c_str(), + outputModuleId_, + hltTriggerNames, + hltTriggerSelections_, + l1_names, + (uint32)sbuf.adler32_chksum()); + + // copy data into the destination message + unsigned char* src = sbuf.bufferPointer(); + std::copy(src, src + src_size, init_message->dataAddress()); + init_message->setDataLength(src_size); + return init_message; + } + + void StreamerOutputMsgBuilders::setHltMask(EventForOutput const& e, + Handle const& triggerResults, + std::vector& hltbits) const { + hltbits.clear(); + + std::vector vHltState; + + if (triggerResults.isValid()) { + for (std::vector::size_type i = 0; i != hltsize_; ++i) { + vHltState.push_back(((triggerResults->at(i)).state())); + } + } else { + // We fill all Trigger bits to valid state. + for (std::vector::size_type i = 0; i != hltsize_; ++i) { + vHltState.push_back(hlt::Pass); + } + } + + //Pack into member hltbits + if (!vHltState.empty()) { + unsigned int packInOneByte = 4; + unsigned int sizeOfPackage = 1 + ((vHltState.size() - 1) / packInOneByte); //Two bits per HLT + + hltbits.resize(sizeOfPackage); + std::fill(hltbits.begin(), hltbits.end(), 0); + + for (std::vector::size_type i = 0; i != vHltState.size(); ++i) { + unsigned int whichByte = i / packInOneByte; + unsigned int indxWithinByte = i % packInOneByte; + hltbits[whichByte] = hltbits[whichByte] | (vHltState[i] << (indxWithinByte * 2)); + } + } + + //This is Just a printing code. + //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl; + //for(unsigned int i=0; i != hltbits_.size() ; ++i) { + // printBits(hltbits_[i]); + //} + //std::cout << "\n"; + } + + std::unique_ptr StreamerOutputMsgBuilders::serializeEvent( + SerializeDataBuffer& sbuf, + EventForOutput const& e, + Handle const& triggerResults, + ParameterSetID const& selectorCfg, + uint32_t eventMetaDataChecksum) const { + constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; + //Lets Build the Event Message first + + std::vector hltbits; + setHltMask(e, triggerResults, hltbits); + + uint32 lumi = e.luminosityBlock(); + if (lumiSectionInterval_ != 0) { + struct timeval now; + struct timezone dummyTZ; + gettimeofday(&now, &dummyTZ); + double timeInSec = + static_cast(now.tv_sec) + (static_cast(now.tv_usec) / 1000000.0) - timeInSecSinceUTC; + // what about overflows? + lumi = static_cast(timeInSec / std::abs(lumiSectionInterval_)) + 1; + } + serializer_.serializeEvent( + sbuf, e, selectorCfg, eventMetaDataChecksum, compressionAlgo_, compressionLevel_, reserve_size); + + return serializeEventCommon(e.id().run(), lumi, e.id().event(), hltbits, hltsize_, sbuf); + } + + std::pair, uint32_t> StreamerOutputMsgBuilders::serializeEventMetaData( + SerializeDataBuffer& sbuf, BranchIDLists const& branchLists, ThinnedAssociationsHelper const& helper) const { + constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; + //Lets Build the Event Message first + + std::vector hltbits; + serializer_.serializeEventMetaData(sbuf, branchLists, helper, compressionAlgo_, compressionLevel_, reserve_size); + auto eventMetaDataChecksum = sbuf.adler32_chksum_; + + return std::make_pair(serializeEventCommon(0, 0, 0, hltbits, 0, sbuf), eventMetaDataChecksum); + } + + std::unique_ptr StreamerOutputMsgBuilders::serializeEventCommon(uint32 run, + uint32 lumi, + uint64 event, + std::vector hltbits, + unsigned int hltsize, + SerializeDataBuffer& sbuf) const { + // resize header_buf_ to reserved size on first written event + constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size; + if (sbuf.header_buf_.size() < reserve_size) + sbuf.header_buf_.resize(reserve_size); + + //Following is strictly DUMMY Data for L! Trig and will be replaced with actual + // once figured out, there is no logic involved here. + std::vector l1bit = {true, true, false}; + //End of dummy data + + auto msg = std::make_unique(&sbuf.header_buf_[0], + sbuf.comp_buf_.size(), + run, + event, + lumi, + outputModuleId_, + 0, + l1bit, + (uint8*)&hltbits[0], + hltsize, + (uint32)sbuf.adler32_chksum(), + host_name_); + + // 50000 bytes is reserved for header as has been the case with previous version which did one extra copy of event data + uint32 headerSize = msg->headerSize(); + if (headerSize > reserve_size) + throw cms::Exception("StreamerOutputMsgBuilders", "Header Overflow") + << " header of size " << headerSize << "bytes is too big to fit into the reserved buffer space"; + + //set addresses to other buffer and copy constructed header there + msg->setBufAddr(&sbuf.comp_buf_[reserve_size - headerSize]); + msg->setEventAddr(sbuf.bufferPointer()); + std::copy(&sbuf.header_buf_[0], &sbuf.header_buf_[headerSize], (char*)(&sbuf.comp_buf_[reserve_size - headerSize])); + + unsigned int src_size = sbuf.currentSpaceUsed(); + msg->setEventLength(src_size); //compressed size + if (useCompression_) + msg->setOrigDataSize( + sbuf.currentEventSize()); //uncompressed size (or 0 if no compression -> streamer input source requires this) + else + msg->setOrigDataSize(0); + + return msg; + } + + void StreamerOutputMsgBuilders::fillDescription(ParameterSetDescription& desc) { + desc.addUntracked("max_event_size", 7000000)->setComment("Obsolete parameter."); + desc.addUntracked("use_compression", true) + ->setComment("If True, compression will be used to write streamer file."); + desc.addUntracked("compression_algorithm", "ZLIB") + ->setComment("Compression algorithm to use: UNCOMPRESSED, ZLIB, LZMA or ZSTD"); + desc.addUntracked("compression_level", 1)->setComment("Compression level to use on serialized ROOT events"); + desc.addUntracked("lumiSection_interval", 0) + ->setComment( + "If 0, use lumi section number from event.\n" + "If not 0, the interval in seconds between fake lumi sections."); + } +} // namespace edm::streamer From 32a9e7b97e4b489fe907346a6b1f1dff66d03287 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 15:34:45 +0200 Subject: [PATCH 033/301] add r-phi plots, refine binnings --- .../MuonRPCDigis/interface/RPCDigiValid.h | 3 +- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 37 +++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index d2810302fa83a..a12cd30fe7934 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -31,7 +31,8 @@ class RPCDigiValid : public DQMEDAnalyzer { MonitorElement *hRZ_; MonitorElement *hXY_Barrel_; - std::map hXY_Endcap_; + std::map hXY_Endcap_; // X-Y plots for Endcap, by station + std::map hRPhi_; // R-phi plots for Barrel, by layers // Strip profile MonitorElement *hStripProf_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index d781eef650316..544864c136a6f 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -52,6 +52,14 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { if (region == 0) { // Barrel hXY_Barrel_->Fill(gp.x(), gp.y()); + + const int station = rsid.station(); + const int layer = rsid.layer(); + const int stla = (station <= 2) ? (2 * (station - 1) + layer) : (station + 2); + + auto match = hRPhi_.find(stla); + if (match != hRPhi_.end()) + match->second->Fill(gp.z(), gp.phi()); } else { // Endcap const int disk = region * rsid.station(); @@ -117,24 +125,37 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run, edm::EventSetup const &eSetup) { booker.setCurrentFolder("RPCDigisV/RPCDigis"); + // Define binnings of 2D-histograms + const double maxZ = 1100; + const int nbinsZ = 220; // bin width: 10cm + const double maxXY = 800; + const int nbinsXY = 160; // bin width: 10cm + const double minR = 100, maxR = 800; + const int nbinsR = 70; // bin width: 10cm + const int nbinsPhi = 180; // bin width: 2 degree + // RZ plot - hRZ_ = booker.book2D("RZ", "RZ", 220, -1100., 1100., 60, 0., 780.); + hRZ_ = booker.book2D("RZ", "RZ", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); // XY plots - const int nbinsXY = 155; - const double xmaxXY = 775; - hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); - hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); - hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -xmaxXY, xmaxXY, nbinsXY, -xmaxXY, xmaxXY); + hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + } + + // Z-phi plots + for (int layer = 1; layer <= 6; ++layer) { + const std::string meName = fmt::format("RPhi_Layer{:1d}", layer); + hRPhi_[layer] = booker.book2D(meName, meName, nbinsZ, -maxZ, maxZ, nbinsPhi, 0, TMath::TwoPi()); } // Strip profile hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); - hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 100, 0, 100); - hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 50, 0, 50); + hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 92, 0, 92); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 62, 0, 62); hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); From 26482add56976cddf3c2af28be59e33792384733 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 17:51:19 +0200 Subject: [PATCH 034/301] refine bin range, set axis titles --- .../MuonRPCDigis/interface/RPCDigiValid.h | 2 +- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index a12cd30fe7934..2b9cb52fd9c60 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -32,7 +32,7 @@ class RPCDigiValid : public DQMEDAnalyzer { MonitorElement *hXY_Barrel_; std::map hXY_Endcap_; // X-Y plots for Endcap, by station - std::map hRPhi_; // R-phi plots for Barrel, by layers + std::map hZPhi_; // R-phi plots for Barrel, by layers // Strip profile MonitorElement *hStripProf_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 544864c136a6f..339da8a49f26a 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -57,9 +57,11 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { const int layer = rsid.layer(); const int stla = (station <= 2) ? (2 * (station - 1) + layer) : (station + 2); - auto match = hRPhi_.find(stla); - if (match != hRPhi_.end()) - match->second->Fill(gp.z(), gp.phi()); + auto match = hZPhi_.find(stla); + if (match != hZPhi_.end()) { + const double phiInDeg = gp.phi() / TMath::Pi() * 180; + match->second->Fill(gp.z(), phiInDeg); + } } else { // Endcap const int disk = region * rsid.station(); @@ -131,36 +133,41 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run const double maxXY = 800; const int nbinsXY = 160; // bin width: 10cm const double minR = 100, maxR = 800; - const int nbinsR = 70; // bin width: 10cm - const int nbinsPhi = 180; // bin width: 2 degree + const int nbinsR = 70; // bin width: 10cm + const int nbinsPhi = 90; // bin width: 4 degree + const double maxBarrelZ = 700; + const int nbinsBarrelZ = 140; // bin width: 10cm // RZ plot - hRZ_ = booker.book2D("RZ", "RZ", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); + hRZ_ = booker.book2D("RZ", "RZ;Z (cm);R (cm)", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); // XY plots hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); - hXY_Endcap_[disk] = booker.book2D(meNameP, meNameP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); - hXY_Endcap_[-disk] = booker.book2D(meNameN, meNameN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + const std::string meTitleP = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", disk); + const std::string meTitleN = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", -disk); + hXY_Endcap_[disk] = booker.book2D(meNameP, meTitleP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + hXY_Endcap_[-disk] = booker.book2D(meNameN, meTitleN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); } // Z-phi plots for (int layer = 1; layer <= 6; ++layer) { - const std::string meName = fmt::format("RPhi_Layer{:1d}", layer); - hRPhi_[layer] = booker.book2D(meName, meName, nbinsZ, -maxZ, maxZ, nbinsPhi, 0, TMath::TwoPi()); + const std::string meName = fmt::format("ZPhi_Layer{:1d}", layer); + const std::string meTitle = fmt::format("Z-#phi view of Layer{:1d};Z (cm);#phi (degree)", layer); + hZPhi_[layer] = booker.book2D(meName, meName, nbinsBarrelZ, -maxBarrelZ, maxBarrelZ, nbinsPhi, -180, 180); } // Strip profile - hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile", 100, 0, 100); - hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2", 92, 0, 92); - hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4", 62, 0, 62); - hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap", 40, 0, 40); - hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC", 100, 0, 100); + hStripProf_ = booker.book1D("Strip_Profile", "Strip_Profile;Strip Number", 100, 0, 100); + hStripProf_RB12_ = booker.book1D("Strip_Profile_RB12", "Strip Profile RB1 and RB2;Strip Number", 92, 0, 92); + hStripProf_RB34_ = booker.book1D("Strip_Profile_RB34", "Strip Profile RB3 and RB4;Strip Number", 62, 0, 62); + hStripProf_Endcap_ = booker.book1D("Strip_Profile_Endcap", "Strip Profile Endcap;Strip Number", 40, 0, 40); + hStripProf_IRPC_ = booker.book1D("Strip_Profile_IRPC", "Strip Profile IRPC;Strip Number", 100, 0, 100); // Bunch crossing - hBxDist_ = booker.book1D("Bunch_Crossing", "Bunch_Crossing", 20, -10., 10.); + hBxDist_ = booker.book1D("Bunch_Crossing", "Bunch Crossing;Bunch crossing", 20, -10., 10.); hBxDisc_4Plus_ = booker.book1D("BxDisc_4Plus", "BxDisc_4Plus", 20, -10., 10.); hBxDisc_4Min_ = booker.book1D("BxDisc_4Min", "BxDisc_4Min", 20, -10., 10.); From 995cbfb999a8fedc8b38285fe2ef0e058c441367 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 18:30:42 +0200 Subject: [PATCH 035/301] use barePhi rather than phi for globalPoint --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 339da8a49f26a..68a881e124507 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -59,7 +59,7 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { auto match = hZPhi_.find(stla); if (match != hZPhi_.end()) { - const double phiInDeg = gp.phi() / TMath::Pi() * 180; + const double phiInDeg = 180. * gp.barePhi() / TMath::Pi(); match->second->Fill(gp.z(), phiInDeg); } } else { From 4fb7d015948fde5fe1250cc2efe714031ec46680 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 10 May 2024 19:44:38 +0200 Subject: [PATCH 036/301] fix typo --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 68a881e124507..9a50005c656d6 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -139,15 +139,15 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run const int nbinsBarrelZ = 140; // bin width: 10cm // RZ plot - hRZ_ = booker.book2D("RZ", "RZ;Z (cm);R (cm)", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); + hRZ_ = booker.book2D("RZ", "R-Z view;Z (cm);R (cm)", nbinsZ, -maxZ, maxZ, nbinsR, minR, maxR); // XY plots - hXY_Barrel_ = booker.book2D("XY_Barrel", "XY_Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); + hXY_Barrel_ = booker.book2D("XY_Barrel", "X-Y view of Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); - const std::string meTitleP = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", disk); - const std::string meTitleN = fmt::format("XY view of Endcap{:+1d};X (cm);Y (cm)", -disk); + const std::string meTitleP = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", disk); + const std::string meTitleN = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", -disk); hXY_Endcap_[disk] = booker.book2D(meNameP, meTitleP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); hXY_Endcap_[-disk] = booker.book2D(meNameN, meTitleN, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); } @@ -156,7 +156,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run for (int layer = 1; layer <= 6; ++layer) { const std::string meName = fmt::format("ZPhi_Layer{:1d}", layer); const std::string meTitle = fmt::format("Z-#phi view of Layer{:1d};Z (cm);#phi (degree)", layer); - hZPhi_[layer] = booker.book2D(meName, meName, nbinsBarrelZ, -maxBarrelZ, maxBarrelZ, nbinsPhi, -180, 180); + hZPhi_[layer] = booker.book2D(meName, meTitle, nbinsBarrelZ, -maxBarrelZ, maxBarrelZ, nbinsPhi, -180, 180); } // Strip profile From 9baf68e6eba4169a8004ba30d818b7ca4f57c23f Mon Sep 17 00:00:00 2001 From: Giovanni Date: Tue, 9 Apr 2024 17:24:50 +0200 Subject: [PATCH 037/301] Fix input links in Correlator Layer1 Endcap TM18 VU13P design --- .../python/l1ctLayer1_patternWriters_cff.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py index b71e76d8b0c51..8abd7b438ae64 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py @@ -222,9 +222,13 @@ inputFileName = cms.string("l1HGCalTM18-inputs-vu9p"), gttLatency = cms.uint32(167), # shorter, to fit 6 events in 1024 lines maxLinesPerInputFile = cms.uint32(1024+167), # anything beyond 986 will be nulls + gmtLink = 4*27+0, + gttLink = 4*27+3, ) hgcalWriterVU13PTM18WriterConfig = hgcalWriterVU9PTM18WriterConfig.clone( inputFileName = cms.string("l1HGCalTM18-inputs-vu13p"), + gmtLink = 4*28+0, + gttLink = 4*28+3, ) for ie in range(2): for iphi in range(9): @@ -234,7 +238,10 @@ for iphi in range(3): isec, ilink = 3*ie+iphi, 2*iphi+ie hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) - hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(13+ilink),4*(13+ilink)+4) + if ilink < 3: + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + else: + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(14+ilink),4*(14+ilink)+4) hgcalTM18WriterConfigs = [ hgcalWriterOutputTM18WriterConfig, From de40c50b14ff19f84f671ee72171fbc9f3d2f029 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Sat, 13 Apr 2024 15:16:31 +0200 Subject: [PATCH 038/301] Update Correlator Layer 1 pattern writers --- .../L1TCorrelatorLayer1PatternFileWriter.h | 3 +- .../middle_buffer_multififo_regionizer_ref.h | 8 +- .../python/l1ctLayer1_patternWriters_cff.py | 109 +++++++++++++----- .../L1TCorrelatorLayer1PatternFileWriter.cc | 105 ++++++++++++----- .../test/make_l1ct_binaryFiles_cfg.py | 27 ++++- 5 files changed, 181 insertions(+), 71 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h b/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h index 0a10bc16d4866..94c414cf91b36 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h @@ -30,10 +30,11 @@ class L1TCorrelatorLayer1PatternFileWriter { const unsigned int tfTmuxFactor_ = 18, tfLinksFactor_ = 1; // numbers not really configurable in current architecture const unsigned int hgcTmuxFactor_ = 18, hgcLinksFactor_ = 4; // not really configurable in current architecture const unsigned int gctTmuxFactor_ = 1, gctSectors_ = 3; // not really configurable in current architecture - const unsigned int gctLinksEcal_ = 1, gctLinksHad_ = 2; // could be made configurable later const unsigned int gmtTmuxFactor_ = 18, gmtLinksFactor_ = 1; // not really configurable in current architecture const unsigned int gttTmuxFactor_ = 6, gttLinksFactor_ = 1; // not really configurable in current architecture const unsigned int tfTimeslices_, hgcTimeslices_, gctTimeslices_, gmtTimeslices_, gttTimeslices_; + uint32_t gctLinksEcal_, gctLinksHad_; + bool gctSingleLink_; uint32_t gmtNumberOfMuons_; uint32_t gttNumberOfPVs_; uint32_t gttLatency_; diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h index b53d34f05a6f3..74cd59ac49ae5 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h @@ -85,6 +85,10 @@ namespace l1ct { void reset(); + static void encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to); + static void encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to); + static void decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em); + protected: const unsigned int NTK_SECTORS, NCALO_SECTORS; const unsigned int NTK_LINKS, HCAL_LINKS, ECAL_LINKS, NMU_LINKS; @@ -115,10 +119,6 @@ namespace l1ct { const std::vector>& had_in, std::vector& links, std::vector& valid); - - void encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to); - void encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to); - void decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em); }; } // namespace l1ct diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py index 8abd7b438ae64..876f7c2efab73 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py @@ -21,6 +21,8 @@ maxLinesPerOutputFile = cms.uint32(1024), eventsPerFile = cms.uint32(_eventsPerFile), tfTimeSlices = cms.VPSet(), + gctNLinksEcal = cms.uint32(1), + gctNLinksHad = cms.uint32(2), gctSectors = cms.VPSet(), gmtTimeSlices = cms.VPSet(), gmtNumberOfMuons = cms.uint32(12), @@ -51,7 +53,8 @@ outputFileName = cms.string("l1BarrelPhi1Serenity-outputs") ) barrelSerenityVU13PPhi1Config = barrelSerenityPhi1Config.clone( - gttLink = cms.int32(4*31+3), + gttLink = cms.int32(4*25+3), + gmtTimeSlices = cms.VPSet(*[cms.PSet(gmtLink = cms.int32(4*18+t)) for t in range(3)]), inputFileName = cms.string("l1BarrelPhi1Serenity-inputs-vu13p"), ) for t in range(3): @@ -65,8 +68,9 @@ for i,s in enumerate([0,1]): barrelSerenityVU9PPhi1Config.gctSectors[s].gctLinksHad = [3*i+4*18, 3*i+4*18+1] barrelSerenityVU9PPhi1Config.gctSectors[s].gctLinksEcal = [3*i+4*18+2] - barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksHad = [3*i+4*18, 3*i+4*18+1] - barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksEcal = [3*i+4*18+2] + gctLinks = list(range(4*17,4*17+4)) + list(range(4*19,4*19+2)) + barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksHad = [gctLinks[3*i], gctLinks[3*i+1]] + barrelSerenityVU13PPhi1Config.gctSectors[s].gctLinksEcal = [gctLinks[3*i+2]] barrelWriterConfigs = barrelWriterOutputOnlyPhiConfigs @@ -115,19 +119,22 @@ hgcalNegVU9PWriterConfig = _hgcalNegWriterConfig.clone() for t in range(3): hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # neg - hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*2)) for i in range(4) ] # pos, left quads - hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*25)) for i in range(5) ] # pos, right quads - hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*2)) for i in range(4) ] # neg, left quads - hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*25)) for i in range(5) ] # neg, right quads + hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*1)) for i in range(4) ] # pos, left quads + hgcalPosVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*26)) for i in range(5) ] # pos, right quads + hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*1)) for i in range(4) ] # neg, left quads + hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*26)) for i in range(5) ] # neg, right quads hgcalNegVU9PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # pos - hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg - hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*11+12*i+4*t+j for j in range(4)])) for i in range(3) ] # pos - hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*11+12*i+4*t+j for j in range(4)])) for i in range(3) ] # neg - hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # pos - hgcalPosVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4+t) - hgcalNegVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4+t) -hgcalPosVU9PWriterConfig.gttLink = 4+3 -hgcalNegVU9PWriterConfig.gttLink = 4+3 + hgcQuads = [list(range(4*i,4*i+4)) for i in [10,11,12,13]] + hgcQuads += [[4*14+1,4*14+2,4*14+3,4*15+3]] # mixed quad + hgcQuads += [list(range(4*i,4*i+4)) for i in [16,17,18,19]] + hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg + hgcalPosVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # pos + hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # neg + hgcalNegVU9PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # pos + hgcalPosVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*15+((t+2)%3)) + hgcalNegVU9PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*15+((t+2)%3)) +hgcalPosVU9PWriterConfig.gttLink = 4*14+0 +hgcalNegVU9PWriterConfig.gttLink = 4*14+0 hgcalPosVU9PWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-vu9p") hgcalNegVU9PWriterConfig.inputFileName = cms.string("l1HGCalNeg-inputs-vu9p") ## Current configurations for VU13P @@ -140,15 +147,15 @@ hgcalNegVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*0)) for i in range(5) ] # neg, left quads hgcalNegVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(3*i+t+4*28)) for i in range(4) ] # neg, right quads hgcalNegVU13PWriterConfig.tfTimeSlices[t].tfSectors += [ cms.PSet(tfLink = cms.int32(-1)) for i in range(9) ] # pos + hgcQuads = [list(range(4*i,4*i+4)) for i in [12,13,14, 16,17, 19,20,21,22]] hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # neg - for isec,q0 in (0,12),(1,17),(2,20): - hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # pos - hgcalNegVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # neg + hgcalPosVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # pos + hgcalNegVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*hgcQuads[3*i+t])) for i in range(3) ] # neg hgcalNegVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(-1,-1,-1,-1)) for i in range(3) ] # pos - hgcalPosVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*27+t) - hgcalNegVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*27+t) -hgcalPosVU13PWriterConfig.gttLink = 4*27+3 -hgcalNegVU13PWriterConfig.gttLink = 4*27+3 + hgcalPosVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*18+t) + hgcalNegVU13PWriterConfig.gmtTimeSlices[t].gmtLink = cms.int32(4*18+t) +hgcalPosVU13PWriterConfig.gttLink = 4*25+3 +hgcalNegVU13PWriterConfig.gttLink = 4*25+3 hgcalPosVU13PWriterConfig.inputFileName = cms.string("l1HGCalPos-inputs-vu13p") hgcalNegVU13PWriterConfig.inputFileName = cms.string("l1HGCalNeg-inputs-vu13p") @@ -190,8 +197,8 @@ hgcalNoTKVU13PWriterConfig = _hgcalNoTKWriterConfig.clone() for t in range(3): for isec in range(6): - q0 = 3*isec + 6 - hgcalNoTKVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] # pos + q0 = 3*isec + (6 if isec < 3 else 8) + hgcalNoTKVU13PWriterConfig.hgcTimeSlices[t].hgcSectors += [ cms.PSet(hgcLinks = cms.vint32(*[4*q0+4*t+j for j in range(4)])) ] hgcalNoTKVU13PWriterConfig.inputFileName = cms.string("l1HGCalNoTK-inputs-vu13p") # vu9p uses the same cabling for now hgcalNoTKWriterConfigs = [ @@ -200,7 +207,42 @@ ] ##################################################################################################################### -## HGCal TM18 configuration +## TM18 configuration +_barrelSerenityTM18 = _barrelWriterOutputOnly.clone( + tmuxFactor = cms.uint32(18), + tfTimeSlices = None, + tfSectors = cms.VPSet(*[cms.PSet(tfLink = cms.int32(-1)) for i in range(18)]), + gmtTimeSlices = None, + gmtLink = cms.int32(4*18+0), + gttLink = 4*28+3, + eventsPerFile = 4, +) +barrelSerenityOutputTM18WriterConfig = _barrelSerenityTM18.clone( + outputRegions = cms.vuint32(*range(54)), + outputBoard = cms.int32(0), + outputFileName = cms.string("l1BarrelSerenityTM18-outputs") +) +barrelSerenityVU13PTM18WriterConfig = _barrelSerenityTM18.clone( + inputFileName = cms.string("l1BarrelSerenityTM18-inputs-vu13p"), + gttLatency = cms.uint32(167), # shorter, to fit 6 events in 1024 lines + maxLinesPerInputFile = cms.uint32(1024+167), # anything beyond 986 will be nulls + gctNLinksEcal = 1, + gctNLinksHad = 1, + gctSectors = cms.VPSet(*[cms.PSet( + gctLinksHad = cms.vint32(4*18+1+s), + gctLinksEcal = cms.vint32(4*18+1+s), + ) for s in range(3)]), +) +for ie in range(2): + for iphi in range(9): + isec = 9*ie+iphi + barrelSerenityVU13PTM18WriterConfig.tfSectors[isec].tfLink = (isec if isec < 12 else (4*30+(isec-12))) + +barrelSerenityTM18WriterConfigs = [ + barrelSerenityOutputTM18WriterConfig, + barrelSerenityVU13PTM18WriterConfig +] + _hgcalWriterTM18 = _hgcalWriterConfig.clone( tmuxFactor = cms.uint32(18), tfTimeSlices = None, @@ -210,7 +252,7 @@ gmtTimeSlices = None, gmtLink = cms.int32(4*27+0), gttLink = 4*27+3, - eventsPerFile = 6, + eventsPerFile = 4, ) hgcalWriterOutputTM18WriterConfig = _hgcalWriterTM18.clone( outputFileName = cms.string("l1HGCalTM18-outputs"), @@ -222,24 +264,29 @@ inputFileName = cms.string("l1HGCalTM18-inputs-vu9p"), gttLatency = cms.uint32(167), # shorter, to fit 6 events in 1024 lines maxLinesPerInputFile = cms.uint32(1024+167), # anything beyond 986 will be nulls - gmtLink = 4*27+0, - gttLink = 4*27+3, + gmtLink = 4*15+2, + gttLink = 0, ) hgcalWriterVU13PTM18WriterConfig = hgcalWriterVU9PTM18WriterConfig.clone( inputFileName = cms.string("l1HGCalTM18-inputs-vu13p"), - gmtLink = 4*28+0, + gmtLink = 4*18+0, gttLink = 4*28+3, ) for ie in range(2): for iphi in range(9): isec, ilink = 9*ie+iphi, 2*iphi+ie - hgcalWriterVU9PTM18WriterConfig.tfSectors[isec].tfLink = (ilink if ilink < 12 else (4*28+(ilink-12))) + hgcalWriterVU9PTM18WriterConfig.tfSectors[isec].tfLink = (ilink+2 if ilink < 10 else (4*28+(ilink-10))) hgcalWriterVU13PTM18WriterConfig.tfSectors[isec].tfLink = (ilink if ilink < 12 else (4*30+(ilink-12))) for iphi in range(3): isec, ilink = 3*ie+iphi, 2*iphi+ie - hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + if ilink < 2: + hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + else: + hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(14+ilink),4*(14+ilink)+4) if ilink < 3: hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + elif ilink < 5: + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(13+ilink),4*(13+ilink)+4) else: hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(14+ilink),4*(14+ilink)+4) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc index e39f86c267216..fe9c70f857ecf 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc +++ b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc @@ -1,4 +1,5 @@ #include "L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/ParameterSet/interface/allowedValues.h" #include @@ -28,6 +29,10 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const } if (partition_ == Partition::Barrel) { auto sectorConfig = iConfig.getParameter>("gctSectors"); + gctLinksEcal_ = iConfig.getParameter("gctNLinksEcal"); + gctLinksHad_ = iConfig.getParameter("gctNLinksHad"); + gctSingleLink_ = false; + bool gctHasMultiLink = false; if (sectorConfig.size() != gctSectors_) throw cms::Exception("Configuration", "Bad number of GCT sectors"); for (unsigned int iS = 0; iS < gctSectors_; ++iS) { @@ -36,16 +41,24 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const if (linksEcal.size() != gctLinksEcal_ || linksHad.size() != gctLinksHad_) throw cms::Exception("Configuration", "Bad number of GCT links"); unsigned int iLink = 0; - for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { - if (linksHad[i] != -1) - channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksHad[i]); - } - for (unsigned int i = 0; i < gctLinksEcal_; ++i) { - if (linksEcal[i] != -1) - channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksEcal[i]); + if (!(gctLinksEcal_ == 1 && gctLinksHad_ == 1 && linksEcal[0] == linksHad[0] && linksEcal[0] != -1)) { + for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { + if (linksHad[i] != -1) + channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksHad[i]); + } + for (unsigned int i = 0; i < gctLinksEcal_; ++i) { + if (linksEcal[i] != -1) + channelIdsInput_[l1t::demo::LinkId{"gct", iLink + 10 * iS}].push_back(linksEcal[i]); + } + gctHasMultiLink = true; + } else { // single link combining ecal and hcal + channelIdsInput_[l1t::demo::LinkId{"gct", 10 * iS}].push_back(linksEcal[0]); + gctSingleLink_ = true; } channelSpecsInput_["gct"] = {tmuxFactor_ * gctTimeslices_, 0}; } + if (gctSingleLink_ && gctHasMultiLink) + throw cms::Exception("Configuration", "Some GCT sectors have a single link, others have multiple."); } if (partition_ == Partition::HGCal || partition_ == Partition::HGCalNoTk) { configTimeSlices(iConfig, "hgc", eventTemplate.raw.hgcalcluster.size(), hgcTimeslices_, hgcLinksFactor_); @@ -89,9 +102,11 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const nEgammaObjectsOut_ = iConfig.getParameter("nEgammaObjectsOut"); if (outputLinkEgamma_ != -1) { channelIdsOutput_[l1t::demo::LinkId{"egamma", 0}].push_back(outputLinkEgamma_); - if (partition_ == Partition::HGCal && tmuxFactor_ == 18) { - // the format is different, as we put together both endcaps - channelSpecsOutput_["egamma"] = {tmuxFactor_, nOutputFramesPerBX_ * tmuxFactor_ / 2 - 3 * nEgammaObjectsOut_}; + if (tmuxFactor_ == 18) { + // the format is different, as we put together multiple endcaps or slices + unsigned int nboards = (partition_ == Partition::Barrel) ? 3 : 2; + channelSpecsOutput_["egamma"] = {tmuxFactor_, + nOutputFramesPerBX_ * tmuxFactor_ / nboards - 3 * nEgammaObjectsOut_}; } else { outputBoard_ = iConfig.getParameter("outputBoard"); channelSpecsOutput_["egamma"] = {tmuxFactor_, nOutputFramesPerBX_ * tmuxFactor_ - 3 * nEgammaObjectsOut_}; @@ -143,7 +158,10 @@ std::unique_ptr L1TCorrelatorLayer1PatternFileWri edm::ParameterSetDescription gctSectorPSD; gctSectorPSD.add>("gctLinksEcal"); gctSectorPSD.add>("gctLinksHad"); - return std::make_unique>>("gctSectors", gctSectorPSD, true); + return std::make_unique>>( + "gctSectors", gctSectorPSD, true) and + edm::ParameterDescription("gctNLinksEcal", 1, true) and + edm::ParameterDescription("gctNLinksHad", 2, true); } std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeHGC() { return describeTimeSlices("hgc"); @@ -360,24 +378,44 @@ void L1TCorrelatorLayer1PatternFileWriter::writeBarrelGCT(const l1ct::Event& eve continue; const auto& had = event.decoded.hadcalo[iS]; const auto& ecal = event.decoded.emcalo[iS]; - unsigned int iLink = 0, nHad = had.size(), nEcal = ecal.size(); - for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { - ret.clear(); - for (unsigned int iHad = i; iHad < nHad; iHad += gctLinksHad_) { - ret.emplace_back(had[iHad].pack()); + if (!gctSingleLink_) { + unsigned int iLink = 0, nHad = had.size(), nEcal = ecal.size(); + for (unsigned int i = 0; i < gctLinksHad_; ++i, ++iLink) { + ret.clear(); + for (unsigned int iHad = i; iHad < nHad; iHad += gctLinksHad_) { + ret.emplace_back(had[iHad].pack()); + } + if (ret.empty()) + ret.emplace_back(0); + out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); } - if (ret.empty()) - ret.emplace_back(0); - out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); - } - for (unsigned int i = 0; i < gctLinksEcal_; ++i, ++iLink) { - ret.clear(); - for (unsigned int iEcal = i; iEcal < nEcal; iEcal += gctLinksEcal_) { - ret.emplace_back(ecal[iEcal].pack()); + for (unsigned int i = 0; i < gctLinksEcal_; ++i, ++iLink) { + ret.clear(); + for (unsigned int iEcal = i; iEcal < nEcal; iEcal += gctLinksEcal_) { + ret.emplace_back(ecal[iEcal].pack()); + } + if (ret.empty()) + ret.emplace_back(0); + out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); } - if (ret.empty()) - ret.emplace_back(0); - out.add(l1t::demo::LinkId{"gct", iS * 10 + iLink}, ret); + } else { + const unsigned int NCLK_EM = 54, NCLK_TOT = 3 * NCLK_EM; + l1ct::HadCaloObjEmu tmp; + ret.resize(std::min(NCLK_EM + had.size(), NCLK_TOT)); + for (unsigned int iclock = 0, nem = ecal.size(); iclock < NCLK_EM; ++iclock) { + if (iclock < nem) { + l1ct::MiddleBufferMultififoRegionizerEmulator::encode(ecal[iclock], tmp); + ret[iclock] = tmp.pack(); + } else { + ret[iclock] = 0; + } + } + for (unsigned int ihad = 0, iclock = NCLK_EM, nhad = had.size(); iclock < NCLK_TOT && ihad < nhad; + ++iclock, ++ihad) { + l1ct::MiddleBufferMultififoRegionizerEmulator::encode(had[ihad], tmp); + ret[iclock] = tmp.pack(); + } + out.add(l1t::demo::LinkId{"gct", iS * 10}, ret); } } } @@ -435,11 +473,14 @@ void L1TCorrelatorLayer1PatternFileWriter::writeEgamma(const l1ct::OutputBoard& void L1TCorrelatorLayer1PatternFileWriter::writeEgamma(const l1ct::Event& event, l1t::demo::EventData& out) { std::vector> ret; - if (partition_ == Partition::HGCal && tmuxFactor_ == 18) { - // the format is different, as we put together both endcaps - writeEgamma(event.board_out[0], ret); - ret.resize(nOutputFramesPerBX_ * tmuxFactor_ / 2, ap_uint<64>(0)); - writeEgamma(event.board_out[1], ret); + if (tmuxFactor_ == 18) { + // the format is different, as we put together all boards + unsigned int nboards = event.board_out.size(); + unsigned int npad = nOutputFramesPerBX_ * tmuxFactor_ / nboards; + for (unsigned int board = 0; board < nboards; ++board) { + ret.resize(board * npad, ap_uint<64>(0)); + writeEgamma(event.board_out[board], ret); + } } else { writeEgamma(event.board_out[outputBoard_], ret); } diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index 2191018d20618..c34694d6f1975 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -9,7 +9,8 @@ parser.add_argument("--dumpFilesOFF", help="switch on dump file production", action="store_true", default=False) parser.add_argument("--patternFilesOFF", help="switch on Layer-1 pattern file production", action="store_true", default=False) parser.add_argument("--serenity", help="use Serenity settigns as default everwhere, i.e. also for barrel", action="store_true", default=False) -parser.add_argument("--tm18", help="Add TM18 emulators for the endcaps", action="store_true", default=False) +parser.add_argument("--tm18", help="Add TM18 emulators", action="store_true", default=False) +parser.add_argument("--split18", help="Make 3 TM18 layer 1 pattern files", action="store_true", default=False) args = parser.parse_args() @@ -205,12 +206,32 @@ if not args.patternFilesOFF: process.l1tLayer1HGCalTM18.patternWriters = cms.untracked.VPSet(*hgcalTM18WriterConfigs) process.l1tLayer1HGCalNoTKTM18.patternWriters = cms.untracked.VPSet(hgcalNoTKOutputTM18WriterConfig) - process.l1tLayer1BarrelSerenityTM18.patternWriters = cms.untracked.VPSet() + process.l1tLayer1BarrelSerenityTM18.patternWriters = cms.untracked.VPSet(*barrelSerenityTM18WriterConfigs) process.l1tLayer2EGTM18.writeInPattern = True process.l1tLayer2EGTM18.writeOutPattern = True - if not args.dumpFilesOFF: for det in "HGCalTM18", "HGCalNoTKTM18", "BarrelSerenityTM18": getattr(process, 'l1tLayer1'+det).dumpFileName = cms.untracked.string("TTbar_PU200_"+det+".dump") + if args.split18 and not args.patternFilesOFF: + from FWCore.Modules.preScaler_cfi import preScaler + for tmSlice, psOffset in (0,1), (6,2), (12,0): + setattr(process, f"preTM{tmSlice}", preScaler.clone(prescaleFactor = 3, prescaleOffset = psOffset)) + for det in "HGCalTM18", "HGCalNoTKTM18", "BarrelSerenityTM18": + tsmod = getattr(process, 'l1tLayer1'+det).clone() + tsmod.dumpFileName = cms.untracked.string("") + setattr(process, f"l1tLayer1{det}TS{tmSlice}", tsmod) + setattr(process, f"Write_{det}TS{tmSlice}", cms.Path(getattr(process, f"preTM{tmSlice}")+tsmod)) + getattr(process, f'l1tLayer1HGCalTM18TS{tmSlice}').patternWriters = cms.untracked.VPSet( + hgcalWriterOutputTM18WriterConfig.clone(outputFileName = f"l1HGCalTM18-outputs-ts{tmSlice}"), + hgcalWriterVU9PTM18WriterConfig.clone(inputFileName = f"l1HGCalTM18-inputs-vu9p-ts{tmSlice}"), + hgcalWriterVU13PTM18WriterConfig.clone(inputFileName = f"l1HGCalTM18-inputs-vu13p-ts{tmSlice}") + ) + getattr(process, f'l1tLayer1HGCalNoTKTM18TS{tmSlice}').patternWriters = cms.untracked.VPSet( + hgcalNoTKOutputTM18WriterConfig.clone(outputFileName = f"l1HGCalTM18-outputs-ts{tmSlice}"), + ) + getattr(process, f'l1tLayer1BarrelSerenityTM18TS{tmSlice}').patternWriters = cms.untracked.VPSet( + barrelSerenityOutputTM18WriterConfig.clone(outputFileName = f"l1BarrelSerenityTM18-outputs-ts{tmSlice}"), + barrelSerenityVU13PTM18WriterConfig.clone(inputFileName = f"l1BarrelSerenityTM18-inputs-vu13p-ts{tmSlice}") + ) process.source.fileNames = [ '/store/cmst3/group/l1tr/cerminar/14_0_X/fpinputs_131X/v3/TTbar_PU200/inputs131X_1.root' ] From ca309a6dfd209157bd49a1fa0e03a2a53eb0bce8 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 13 May 2024 09:55:56 +0200 Subject: [PATCH 039/301] Update to 1008 events to avoid incomplete pattern files after TMUXing --- .../Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index c34694d6f1975..efa54b34fd770 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -29,7 +29,7 @@ process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.load("FWCore.MessageLogger.MessageLogger_cfi") process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True), allowUnscheduled = cms.untracked.bool(False) ) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000)) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1008)) process.MessageLogger.cerr.FwkReport.reportEvery = 1 process.source = cms.Source("PoolSource", From 28b00418eb208c2987e42ebbe45a3cdd25b9cef7 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 13 May 2024 12:23:53 +0200 Subject: [PATCH 040/301] Drop on input old l1tKMTFTracks --- .../Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index efa54b34fd770..f6fa74b4ddfea 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -38,7 +38,8 @@ "drop l1tPFClusters_*_*_*", "drop l1tPFTracks_*_*_*", "drop l1tPFCandidates_*_*_*", - "drop l1tTkPrimaryVertexs_*_*_*"), + "drop l1tTkPrimaryVertexs_*_*_*", + "drop l1tKMTFTracks_*_*_*"), skipEvents = cms.untracked.uint32(0), ) From 38b546f4fab25614bf2f9c6ea7b92823fc548ba1 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Mon, 13 May 2024 12:29:36 +0200 Subject: [PATCH 041/301] reduce bins along phi-axis --- Validation/MuonRPCDigis/src/RPCDigiValid.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 9a50005c656d6..8ede470d311f1 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -134,7 +134,7 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run const int nbinsXY = 160; // bin width: 10cm const double minR = 100, maxR = 800; const int nbinsR = 70; // bin width: 10cm - const int nbinsPhi = 90; // bin width: 4 degree + const int nbinsPhi = 72; // bin width: 5 degree const double maxBarrelZ = 700; const int nbinsBarrelZ = 140; // bin width: 10cm From d6d45f7dc045928f634d54578de7d88c7bf4f3bc Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 16 May 2024 17:26:19 +0200 Subject: [PATCH 042/301] Enable SoA range checking by default --- DataFormats/SoATemplate/interface/SoACommon.h | 4 ++-- DataFormats/SoATemplate/interface/SoALayout.h | 8 ++++---- DataFormats/SoATemplate/interface/SoAView.h | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DataFormats/SoATemplate/interface/SoACommon.h b/DataFormats/SoATemplate/interface/SoACommon.h index 49f5049377b44..a72dc3a32ba65 100644 --- a/DataFormats/SoATemplate/interface/SoACommon.h +++ b/DataFormats/SoATemplate/interface/SoACommon.h @@ -72,13 +72,13 @@ namespace cms::soa { namespace RestrictQualify { constexpr bool enabled = true; constexpr bool disabled = false; - constexpr bool Default = disabled; + constexpr bool Default = enabled; } // namespace RestrictQualify namespace RangeChecking { constexpr bool enabled = true; constexpr bool disabled = false; - constexpr bool Default = disabled; + constexpr bool Default = enabled; } // namespace RangeChecking template diff --git a/DataFormats/SoATemplate/interface/SoALayout.h b/DataFormats/SoATemplate/interface/SoALayout.h index 24370c189cc2d..6d1f520c38d2b 100644 --- a/DataFormats/SoATemplate/interface/SoALayout.h +++ b/DataFormats/SoATemplate/interface/SoALayout.h @@ -456,8 +456,8 @@ \ template \ + bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ + bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ struct ViewTemplateFreeParams; \ \ /* dump the SoA internal structure */ \ @@ -539,7 +539,7 @@ using ConstViewTemplate = ConstViewTemplateFreeParams; \ \ - using ConstView = ConstViewTemplate; \ + using ConstView = ConstViewTemplate; \ \ /* Generate the mutable View template */ \ _GENERATE_SOA_TRIVIAL_VIEW(CLASS, \ @@ -552,7 +552,7 @@ template \ using ViewTemplate = ViewTemplateFreeParams; \ \ - using View = ViewTemplate; \ + using View = ViewTemplate; \ \ /* Trivial constuctor */ \ CLASS() \ diff --git a/DataFormats/SoATemplate/interface/SoAView.h b/DataFormats/SoATemplate/interface/SoAView.h index f219bd137a0cc..30ced1e890e0d 100644 --- a/DataFormats/SoATemplate/interface/SoAView.h +++ b/DataFormats/SoATemplate/interface/SoAView.h @@ -492,8 +492,8 @@ namespace cms::soa { #define _GENERATE_SOA_VIEW_PART_0(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ template \ + bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ + bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ struct VIEW : public CONST_VIEW { \ /* Declare the parametrized layouts as the default */ \ /*BOOST_PP_SEQ_CAT(_ITERATE_ON_ALL(_DECLARE_VIEW_LAYOUT_PARAMETRIZED_TEMPLATE, ~, LAYOUTS_LIST)) */ \ @@ -671,8 +671,8 @@ namespace cms::soa { #define _GENERATE_SOA_CONST_VIEW_PART_0(CONST_VIEW, VIEW, LAYOUTS_LIST, VALUE_LIST) \ template \ + bool RESTRICT_QUALIFY = cms::soa::RestrictQualify::Default, \ + bool RANGE_CHECKING = cms::soa::RangeChecking::Default> \ struct CONST_VIEW { \ /* these could be moved to an external type trait to free up the symbol names */ \ using self_type = CONST_VIEW; From d0500155aea583dc2cabc364973eebd892c7a8e5 Mon Sep 17 00:00:00 2001 From: Srecko Date: Tue, 14 May 2024 02:16:39 +0200 Subject: [PATCH 043/301] removing mss --- DQMServices/FileIO/plugins/DQMFileSaverPB.cc | 4 ++-- EventFilter/Utilities/interface/FastMonitoringService.h | 9 +++------ EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc | 2 +- EventFilter/Utilities/plugins/modules.cc | 4 +--- EventFilter/Utilities/src/DAQSource.cc | 4 ++-- EventFilter/Utilities/src/EvFDaqDirector.cc | 2 +- EventFilter/Utilities/src/FastMonitoringService.cc | 8 +------- EventFilter/Utilities/src/FedRawDataInputSource.cc | 4 ++-- .../JSONMonitoring/plugins/HLTriggerJSONMonitoring.cc | 4 ++-- .../JSONMonitoring/plugins/L1TriggerJSONMonitoring.cc | 4 ++-- 10 files changed, 17 insertions(+), 28 deletions(-) diff --git a/DQMServices/FileIO/plugins/DQMFileSaverPB.cc b/DQMServices/FileIO/plugins/DQMFileSaverPB.cc index 779092f68a1ef..2b90f6545a2c5 100644 --- a/DQMServices/FileIO/plugins/DQMFileSaverPB.cc +++ b/DQMServices/FileIO/plugins/DQMFileSaverPB.cc @@ -74,7 +74,7 @@ void DQMFileSaverPB::saveLumi(const FileParameters& fp) const { std::string openHistoFilePathName; std::string histoFilePathName; - evf::FastMonitoringService* fms = nullptr; + evf::FastMonitoringService * fms = nullptr; edm::Service store; // create the files names @@ -104,7 +104,7 @@ void DQMFileSaverPB::saveLumi(const FileParameters& fp) const { edm::Service()->getOpenProtocolBufferHistogramFilePath(fp.lumi_, streamLabel_); histoFilePathName = edm::Service()->getProtocolBufferHistogramFilePath(fp.lumi_, streamLabel_); - fms = (evf::FastMonitoringService*)(edm::Service().operator->()); + fms = edm::Service().operator->(); } bool abortFlag = false; diff --git a/EventFilter/Utilities/interface/FastMonitoringService.h b/EventFilter/Utilities/interface/FastMonitoringService.h index 94c61334ee267..b1526a8b01c42 100644 --- a/EventFilter/Utilities/interface/FastMonitoringService.h +++ b/EventFilter/Utilities/interface/FastMonitoringService.h @@ -13,7 +13,7 @@ #include -#include "EventFilter/Utilities/interface/MicroStateService.h" +#include "EventFilter/Utilities/interface/FastMonitoringService.h" #include #include @@ -33,9 +33,6 @@ At snapshot time only (every few seconds) we do the map lookup to produce snapshot. The general counters and status variables (event number, number of processed events, number of passed and stored events, luminosity section etc.) are also monitored here. - - N.B. MicroStateService is referenced by a common base class which is now trivial. - It's complete removal will be completed in the future commit. */ class FedRawDataInputSource; @@ -164,7 +161,7 @@ namespace evf { //reserve output module space constexpr int nReservedModules = 128; - class FastMonitoringService : public MicroStateService { + class FastMonitoringService { public: // the names of the states - some of them are never reached in an online app static const edm::ModuleDescription specialMicroStateNames[FastMonState::mCOUNT]; @@ -172,7 +169,7 @@ namespace evf { static const std::string inputStateNames[FastMonState::inCOUNT]; // Reserved names for microstates FastMonitoringService(const edm::ParameterSet&, edm::ActivityRegistry&); - ~FastMonitoringService() override; + ~FastMonitoringService(); static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); std::string makeModuleLegendaJson(); diff --git a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc index a9f42ba645172..e4fee70cb9a52 100644 --- a/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc +++ b/EventFilter/Utilities/plugins/GlobalEvFOutputModule.cc @@ -326,7 +326,7 @@ namespace evf { //create JSD GlobalEvFOutputJSONDef(streamLabel_, true); - fms_ = (evf::FastMonitoringService*)(edm::Service().operator->()); + fms_ = (evf::FastMonitoringService*)(edm::Service().operator->()); } GlobalEvFOutputModule::~GlobalEvFOutputModule() {} diff --git a/EventFilter/Utilities/plugins/modules.cc b/EventFilter/Utilities/plugins/modules.cc index f0213d4fb2693..32f6fe5c7ad54 100644 --- a/EventFilter/Utilities/plugins/modules.cc +++ b/EventFilter/Utilities/plugins/modules.cc @@ -17,14 +17,12 @@ using namespace edm::serviceregistry; using namespace evf; -typedef edm::serviceregistry::AllArgsMaker FastMonitoringServiceMaker; -DEFINE_FWK_SERVICE_MAKER(FastMonitoringService, FastMonitoringServiceMaker); - typedef RawEventOutputModuleForBU RawStreamFileWriterForBU; DEFINE_FWK_MODULE(RawStreamFileWriterForBU); DEFINE_FWK_MODULE(FRDOutputModule); DEFINE_FWK_SERVICE(EvFBuildingThrottle); DEFINE_FWK_SERVICE(EvFDaqDirector); +DEFINE_FWK_SERVICE(FastMonitoringService); DEFINE_FWK_MODULE(ExceptionGenerator); DEFINE_FWK_MODULE(EvFFEDSelector); DEFINE_FWK_MODULE(EvFFEDExcluder); diff --git a/EventFilter/Utilities/src/DAQSource.cc b/EventFilter/Utilities/src/DAQSource.cc index dde1577ac4bb0..bea445872efea 100644 --- a/EventFilter/Utilities/src/DAQSource.cc +++ b/EventFilter/Utilities/src/DAQSource.cc @@ -132,12 +132,12 @@ DAQSource::DAQSource(edm::ParameterSet const& pset, edm::InputSourceDescription //get handles to DaqDirector and FastMonitoringService because getting them isn't possible in readSupervisor thread if (fileListMode_) { try { - fms_ = static_cast(edm::Service().operator->()); + fms_ = static_cast(edm::Service().operator->()); } catch (cms::Exception const&) { edm::LogInfo("DAQSource") << "No FastMonitoringService found in the configuration"; } } else { - fms_ = static_cast(edm::Service().operator->()); + fms_ = static_cast(edm::Service().operator->()); if (!fms_) { throw cms::Exception("DAQSource") << "FastMonitoringService not found"; } diff --git a/EventFilter/Utilities/src/EvFDaqDirector.cc b/EventFilter/Utilities/src/EvFDaqDirector.cc index 2344195c6efd9..28a956dd21337 100644 --- a/EventFilter/Utilities/src/EvFDaqDirector.cc +++ b/EventFilter/Utilities/src/EvFDaqDirector.cc @@ -836,7 +836,7 @@ namespace evf { bool& setExceptionState) { if (previousFileSize_ != 0) { if (!fms_) { - fms_ = (FastMonitoringService*)(edm::Service().operator->()); + fms_ = (FastMonitoringService*)(edm::Service().operator->()); } if (fms_) fms_->accumulateFileSize(ls, previousFileSize_); diff --git a/EventFilter/Utilities/src/FastMonitoringService.cc b/EventFilter/Utilities/src/FastMonitoringService.cc index 5d90ec9e5dd42..d31379220d095 100644 --- a/EventFilter/Utilities/src/FastMonitoringService.cc +++ b/EventFilter/Utilities/src/FastMonitoringService.cc @@ -195,8 +195,7 @@ namespace evf { }; FastMonitoringService::FastMonitoringService(const edm::ParameterSet& iPS, edm::ActivityRegistry& reg) - : MicroStateService(iPS, reg), - fmt_(new FastMonitoringThread()), + : fmt_(new FastMonitoringThread()), tbbMonitoringMode_(iPS.getUntrackedParameter("tbbMonitoringMode", true)), tbbConcurrencyTracker_(iPS.getUntrackedParameter("tbbConcurrencyTracker", true) && tbbMonitoringMode_), sleepTime_(iPS.getUntrackedParameter("sleepTime", 1)), @@ -1047,9 +1046,4 @@ namespace evf { fmt_->jsonMonitor_->snap(ls); } - //compatibility - MicroStateService::MicroStateService(const edm::ParameterSet& iPS, edm::ActivityRegistry& reg) {} - - MicroStateService::~MicroStateService() {} - } //end namespace evf diff --git a/EventFilter/Utilities/src/FedRawDataInputSource.cc b/EventFilter/Utilities/src/FedRawDataInputSource.cc index ad3b51661cd64..3860720f245b8 100644 --- a/EventFilter/Utilities/src/FedRawDataInputSource.cc +++ b/EventFilter/Utilities/src/FedRawDataInputSource.cc @@ -122,12 +122,12 @@ FedRawDataInputSource::FedRawDataInputSource(edm::ParameterSet const& pset, edm: //get handles to DaqDirector and FastMonitoringService because getting them isn't possible in readSupervisor thread if (fileListMode_) { try { - fms_ = static_cast(edm::Service().operator->()); + fms_ = static_cast(edm::Service().operator->()); } catch (cms::Exception const&) { edm::LogInfo("FedRawDataInputSource") << "No FastMonitoringService found in the configuration"; } } else { - fms_ = static_cast(edm::Service().operator->()); + fms_ = static_cast(edm::Service().operator->()); if (!fms_) { throw cms::Exception("FedRawDataInputSource") << "FastMonitoringService not found"; } diff --git a/HLTrigger/JSONMonitoring/plugins/HLTriggerJSONMonitoring.cc b/HLTrigger/JSONMonitoring/plugins/HLTriggerJSONMonitoring.cc index 33d6a07b94c3e..9ea38a106bb74 100644 --- a/HLTrigger/JSONMonitoring/plugins/HLTriggerJSONMonitoring.cc +++ b/HLTrigger/JSONMonitoring/plugins/HLTriggerJSONMonitoring.cc @@ -428,9 +428,9 @@ void HLTriggerJSONMonitoring::globalEndLuminosityBlockSummary(edm::LuminosityBlo unsigned int run = lumi.run(); bool writeFiles = true; - if (edm::Service().isAvailable()) { + if (edm::Service().isAvailable()) { evf::FastMonitoringService* fms = - (evf::FastMonitoringService*)(edm::Service().operator->()); + (evf::FastMonitoringService*)(edm::Service().operator->()); if (fms) writeFiles = fms->shouldWriteFiles(ls); } diff --git a/HLTrigger/JSONMonitoring/plugins/L1TriggerJSONMonitoring.cc b/HLTrigger/JSONMonitoring/plugins/L1TriggerJSONMonitoring.cc index 572d22dab0049..0fe392fb80ec4 100644 --- a/HLTrigger/JSONMonitoring/plugins/L1TriggerJSONMonitoring.cc +++ b/HLTrigger/JSONMonitoring/plugins/L1TriggerJSONMonitoring.cc @@ -364,9 +364,9 @@ void L1TriggerJSONMonitoring::globalEndLuminosityBlockSummary(edm::LuminosityBlo unsigned int run = lumi.run(); bool writeFiles = true; - if (edm::Service().isAvailable()) { + if (edm::Service().isAvailable()) { evf::FastMonitoringService* fms = - (evf::FastMonitoringService*)(edm::Service().operator->()); + (evf::FastMonitoringService*)(edm::Service().operator->()); if (fms) writeFiles = fms->shouldWriteFiles(ls); } From 706461889fa6042101af30e4cc4c3858acb14b1a Mon Sep 17 00:00:00 2001 From: Srecko Date: Thu, 16 May 2024 23:50:40 +0200 Subject: [PATCH 044/301] code-format --- DQMServices/FileIO/plugins/DQMFileSaverPB.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMServices/FileIO/plugins/DQMFileSaverPB.cc b/DQMServices/FileIO/plugins/DQMFileSaverPB.cc index 2b90f6545a2c5..7c8e68d1f9444 100644 --- a/DQMServices/FileIO/plugins/DQMFileSaverPB.cc +++ b/DQMServices/FileIO/plugins/DQMFileSaverPB.cc @@ -74,7 +74,7 @@ void DQMFileSaverPB::saveLumi(const FileParameters& fp) const { std::string openHistoFilePathName; std::string histoFilePathName; - evf::FastMonitoringService * fms = nullptr; + evf::FastMonitoringService* fms = nullptr; edm::Service store; // create the files names From 02825cb8b79afcca0737c758b5cd9188ea10859a Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 17 May 2024 02:01:47 +0200 Subject: [PATCH 045/301] First working version for CMSSW integration of sexaquark simulation code. --- .../data/particles_sexaq_1p5_GeV.txt | 5 + .../data/particles_sexaq_1p7_GeV.txt | 5 + .../data/particles_sexaq_1p85_GeV.txt | 5 + .../data/particles_sexaq_1p8_GeV.txt | 5 + .../data/particles_sexaq_1p9_GeV.txt | 5 + .../data/particles_sexaq_2_GeV.txt | 5 + .../data/particles_sexaq_2p1_GeV.txt | 5 + SimG4Core/CustomPhysics/interface/G4AntiSQ.h | 65 ++++ SimG4Core/CustomPhysics/interface/G4SQ.h | 28 ++ .../interface/G4SQInelasticCrossSection.h | 42 +++ .../interface/G4SQInelasticProcess.h | 46 +++ .../CustomPhysics/interface/G4SQLoopProcess.h | 48 +++ .../interface/G4SQLoopProcessDiscr.h | 54 ++++ .../interface/G4SQNeutronAnnih.h | 37 +++ .../CustomPhysics/src/CustomPhysicsList.cc | 23 ++ SimG4Core/CustomPhysics/src/G4AntiSQ.cc | 59 ++++ SimG4Core/CustomPhysics/src/G4SQ.cc | 59 ++++ .../src/G4SQInelasticCrossSection.cc | 56 ++++ .../CustomPhysics/src/G4SQInelasticProcess.cc | 293 ++++++++++++++++++ .../CustomPhysics/src/G4SQLoopProcess.cc | 64 ++++ .../CustomPhysics/src/G4SQLoopProcessDiscr.cc | 82 +++++ .../CustomPhysics/src/G4SQNeutronAnnih.cc | 281 +++++++++++++++++ .../test/Sexaquark_RunIIFall18GenSim_cfg.py | 151 +++++++++ 23 files changed, 1423 insertions(+) create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt create mode 100644 SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt create mode 100644 SimG4Core/CustomPhysics/interface/G4AntiSQ.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQ.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h create mode 100644 SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h create mode 100644 SimG4Core/CustomPhysics/src/G4AntiSQ.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQ.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc create mode 100644 SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc create mode 100644 SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt new file mode 100644 index 0000000000000..50ac2b0b97746 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p5_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.5 # sexaq + -1020000020 1.5 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt new file mode 100644 index 0000000000000..fa23fb09c07b8 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p7_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.7 # sexaq + -1020000020 1.7 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt new file mode 100644 index 0000000000000..ea95c99f27bc0 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p85_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.85 # sexaq + -1020000020 1.85 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt new file mode 100644 index 0000000000000..57bac395ef3d9 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.8 # sexaq + -1020000020 1.8 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt new file mode 100644 index 0000000000000..8695d8fbfaf79 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_1p9_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 1.9 # sexaq + -1020000020 1.9 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt new file mode 100644 index 0000000000000..9325990519485 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_2_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 2.0 # sexaq + -1020000020 2.0 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt b/SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt new file mode 100644 index 0000000000000..23b308cddb3a1 --- /dev/null +++ b/SimG4Core/CustomPhysics/data/particles_sexaq_2p1_GeV.txt @@ -0,0 +1,5 @@ +Block MASS # +# PDG code mass particle + 1020000020 2.1 # sexaq + -1020000020 2.1 # anti_sexaq +Block diff --git a/SimG4Core/CustomPhysics/interface/G4AntiSQ.h b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h new file mode 100644 index 0000000000000..93716063261c3 --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h @@ -0,0 +1,65 @@ +// +// ******************************************************************** +// * License and Disclaimer * +// * * +// * The Geant4 software is copyright of the Copyright Holders of * +// * the Geant4 Collaboration. It is provided under the terms and * +// * conditions of the Geant4 Software License, included in the file * +// * LICENSE and available at http://cern.ch/geant4/license . These * +// * include a list of copyright holders. * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. Please see the license in the file LICENSE and URL above * +// * for the full disclaimer and the limitation of liability. * +// * * +// * This code implementation is the result of the scientific and * +// * technical work of the GEANT4 collaboration. * +// * By using, copying, modifying or distributing the software (or * +// * any work based on the software) you agree to acknowledge its * +// * use in resulting scientific publications, and indicate your * +// * acceptance of all terms of the Geant4 Software license. * +// ******************************************************************** +// +// +// $Id: G4AntiSQ.hh 67971 2013-03-13 10:13:24Z gcosmo $ +// +// +// ------------------------------------------------------------ +// GEANT 4 class header file +// +// History: first implementation, based on object model of +// 4-th April 1996, G.Cosmo +// **************************************************************** +// New implementation as a utility class M.Asai, 26 July 2004 +// ---------------------------------------------------------------- + +#ifndef G4AntiSQ_h +#define G4AntiSQ_h 1 + +#include "globals.hh" +#include "G4ios.hh" +#include "G4ParticleDefinition.hh" + +// ###################################################################### +// ### ANTI-SEXAQUARK ### +// ###################################################################### + + +class G4AntiSQ : public G4ParticleDefinition { + + private: + static G4AntiSQ* theInstance; + G4AntiSQ(){} + ~G4AntiSQ(){} + + public: + static G4AntiSQ* Definition(double mass); + //static G4AntiSQ* AntiSQDefinition(double mass); + static G4AntiSQ* AntiSQ(double mass); + +}; + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQ.h b/SimG4Core/CustomPhysics/interface/G4SQ.h new file mode 100644 index 0000000000000..6277916684f1f --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQ.h @@ -0,0 +1,28 @@ + +#ifndef G4SQ_h +#define G4SQ_h 1 + +#include "globals.hh" +#include "G4ios.hh" +#include "G4ParticleDefinition.hh" + +// ###################################################################### +// ### SEXAQUARK ### +// ###################################################################### + + +class G4SQ : public G4ParticleDefinition { + + private: + static G4SQ* theInstance; + G4SQ(){} + ~G4SQ(){} + + public: + static G4SQ* Definition(double mass); +// static G4SQ* SQDefinition(double mass); + static G4SQ* SQ(double mass); + +}; + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h new file mode 100644 index 0000000000000..2a5c5881dfba5 --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h @@ -0,0 +1,42 @@ + +#ifndef G4SQInelasticCrossSection_h +#define G4SQInelasticCrossSection_h + + +#include "globals.hh" +#include "G4VCrossSectionDataSet.hh" + + +class G4NistManager; +class G4SQ; +class G4AntiSQ; + + +class G4SQInelasticCrossSection : public G4VCrossSectionDataSet +{ +public: + + G4SQInelasticCrossSection(double mass); + + ~G4SQInelasticCrossSection(); + + virtual + G4bool IsElementApplicable(const G4DynamicParticle* aPart, + G4int Z, const G4Material*); + + virtual + G4double GetElementCrossSection(const G4DynamicParticle*, + G4int Z, const G4Material*); + + G4double GetSQCrossSection(G4double kineticEnergy, G4int Z); + +private: + + G4NistManager* nist; + G4SQ * theSQ; + G4AntiSQ * theAntiSQ; + +}; + +#endif + diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h new file mode 100644 index 0000000000000..6530d267c16fb --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h @@ -0,0 +1,46 @@ +#ifndef SimG4Core_CustomPhysics_G4SQInelasticProcess_h +#define SimG4Core_CustomPhysics_G4SQInelasticProcess_h 1 + + +#include "G4HadronicProcess.hh" + + +class G4ParticleDefinition; + + +class G4SQInelasticProcess : public G4HadronicProcess +{ + + public: + + G4SQInelasticProcess(double mass, const G4String& processName="SQInelastic"); + + ~G4SQInelasticProcess(); + + G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override; + + // generic PostStepDoIt recommended for all derived classes + virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack, + const G4Step& aStep); + + G4SQInelasticProcess& operator=(const G4SQInelasticProcess& right); + G4SQInelasticProcess(const G4SQInelasticProcess&); + + protected: + + // Check the result for catastrophic energy non-conservation + G4HadFinalState* CheckResult(const G4HadProjectile& thePro, + const G4Nucleus& targetNucleus, + G4HadFinalState* result); + + private: + + G4ParticleDefinition* theParticle; + + G4Nucleus targetNucleus; + G4HadronicInteraction* theInteraction = nullptr; + +}; + +#endif + diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h new file mode 100644 index 0000000000000..224fb8a1b9fbf --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h @@ -0,0 +1,48 @@ +#ifndef G4SQLoopProcess_h +#define G4SQLoopProcess_h 1 + +#include "G4VContinuousProcess.hh" +#include "globals.hh" +#include "G4Track.hh" +#include "G4ParticleChange.hh" + + +class G4Step; +class G4ParticleDefinition; + + +class G4SQLoopProcess : public G4VContinuousProcess { + + public: + + G4SQLoopProcess(const G4String& name = "SQLooper", + G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcess(); + + + public: + + virtual G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); + virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection); + virtual void StartTracking(G4Track * aTrack); + + protected: + + virtual G4double GetContinuousStepLimit(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& currentSafety); + + private: + + G4SQLoopProcess(G4SQLoopProcess &); + G4SQLoopProcess & operator=(const G4SQLoopProcess &right); + + protected: + + G4ParticleChange* fParticleChange; + + private: + + G4ThreeVector posini; +}; + + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h new file mode 100644 index 0000000000000..f7a192b24bb7a --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h @@ -0,0 +1,54 @@ +#ifndef G4SQLoopProcessDiscr_h +#define G4SQLoopProcessDiscr_h 1 + +#include "G4VDiscreteProcess.hh" +#include "globals.hh" +#include "G4Track.hh" +#include "G4ParticleChange.hh" +#include "G4ParticleChangeForTransport.hh" +#include "G4SQ.h" +#include "G4AntiSQ.h" + + +class G4Step; +class G4ParticleDefinition; + + +class G4SQLoopProcessDiscr : public G4VDiscreteProcess { + + public: + + G4SQLoopProcessDiscr(double mass, + const G4String& name = "SQLooper", + G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcessDiscr(); + + + public: + + virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); + virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition); + virtual G4double GetMeanFreePath(const G4Track&, G4double,G4ForceCondition*); + void SetTimeLimit(G4double); + virtual void StartTracking(G4Track * aTrack); + private: + + G4SQLoopProcessDiscr(G4SQLoopProcessDiscr &); + G4SQLoopProcessDiscr & operator=(const G4SQLoopProcessDiscr &right); + + protected: + + //G4ParticleChangeForTransport* fParticleChange; + G4ParticleChange* fParticleChange; + double GenMass; + + private: + + G4ThreeVector posini; + G4double globaltimeini; + + +}; + + +#endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h new file mode 100644 index 0000000000000..e565d3b490781 --- /dev/null +++ b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h @@ -0,0 +1,37 @@ + +#ifndef G4SQNeutronAnnih_h +#define G4SQNeutronAnnih_h 1 + +#include "globals.hh" +#include "G4HadronicInteraction.hh" +#include "G4HadProjectile.hh" +#include "G4Nucleus.hh" +#include "G4IonTable.hh" + +class G4ParticleDefinition; + + +class G4SQNeutronAnnih : public G4HadronicInteraction { + + public: + + G4SQNeutronAnnih(double mass); + + virtual ~G4SQNeutronAnnih(); + + G4double momDistr(G4double x_in); + + virtual G4HadFinalState * ApplyYourself( + const G4HadProjectile & aTrack, + G4Nucleus & targetNucleus); + + private: + + G4ParticleDefinition* theSQ; + G4ParticleDefinition* theK0S; + G4ParticleDefinition* theAntiL; + G4ParticleDefinition* theProton; + +}; + +#endif diff --git a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc index 0992e0fed1333..ed0c9b3d0db6e 100644 --- a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc +++ b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc @@ -20,6 +20,12 @@ #include "SimG4Core/CustomPhysics/interface/CMSQGSPSIMPBuilder.h" #include "SimG4Core/CustomPhysics/interface/CMSSIMPInelasticProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h" +#include "SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" + using namespace CLHEP; G4ThreadLocal std::unique_ptr CustomPhysicsList::myHelper; @@ -99,6 +105,23 @@ void CustomPhysicsList::ConstructProcess() { CMSDarkPairProductionProcess* darkGamma = new CMSDarkPairProductionProcess(dfactor); pmanager->AddDiscreteProcess(darkGamma); } + if (particle->GetParticleName() == "anti_sexaq") { + + // here the different sexaquark interactions get defined + G4SQInelasticProcess * sqInelPr = new G4SQInelasticProcess(particle->GetPDGMass()/GeV); + G4SQNeutronAnnih * sqModel = new G4SQNeutronAnnih(particle->GetPDGMass()/GeV); + sqInelPr->RegisterMe(sqModel); + G4SQInelasticCrossSection * sqInelXS = new G4SQInelasticCrossSection(particle->GetPDGMass()/GeV); + sqInelPr->AddDataSet(sqInelXS); + pmanager->AddDiscreteProcess(sqInelPr); + // add also the looping needed to simulate flat interaction probability + G4SQLoopProcess * sqLoopPr = new G4SQLoopProcess(); + pmanager->AddContinuousProcess(sqLoopPr); + G4SQLoopProcessDiscr * sqLoopPrDiscr = new G4SQLoopProcessDiscr(particle->GetPDGMass()/GeV); + pmanager->AddDiscreteProcess(sqLoopPrDiscr); + } else if (particle->GetParticleName() == "sexaq"){ + edm::LogInfo("CustomPhysics") << " No pmanager implemented for sexaq, only for anti_sexaq"; + } } } } diff --git a/SimG4Core/CustomPhysics/src/G4AntiSQ.cc b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc new file mode 100644 index 0000000000000..227f34b862bb3 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc @@ -0,0 +1,59 @@ + +#include "SimG4Core/CustomPhysics/interface/G4AntiSQ.h" +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "G4ParticleTable.hh" + +#include "G4PhaseSpaceDecayChannel.hh" +#include "G4DecayTable.hh" + +// ###################################################################### +// ### ANTI-SEXAQUARK ### +// ###################################################################### + +G4AntiSQ* G4AntiSQ::theInstance = 0; + +G4AntiSQ* G4AntiSQ::Definition(double mass) +{ + if (theInstance !=0) return theInstance; + const G4String name = "anti_sexaq"; + // search in particle table] + G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition* anInstance = pTable->FindParticle(name); + if (anInstance ==0) + { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, + 0, +1, 0, + 0, 0, 0, + "baryon", 0, -2, -1020000020, + true, -1.0, NULL, + false, "sexaq"); + + + } + theInstance = reinterpret_cast(anInstance); + return theInstance; +} + +//G4AntiSQ* G4AntiSQ::AntiSQDefinition(double mass) +//{ +// return Definition(mass); +//} + +G4AntiSQ* G4AntiSQ::AntiSQ(double mass) +{ + return Definition(mass * GeV); // will use correct mass if instance exists +} + + diff --git a/SimG4Core/CustomPhysics/src/G4SQ.cc b/SimG4Core/CustomPhysics/src/G4SQ.cc new file mode 100644 index 0000000000000..0fb963364282c --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQ.cc @@ -0,0 +1,59 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "G4ParticleTable.hh" + +#include "G4PhaseSpaceDecayChannel.hh" +#include "G4DecayTable.hh" + +// ###################################################################### +// ### SEXAQUARK ### +// ###################################################################### + +G4SQ* G4SQ::theInstance = 0; + +G4SQ* G4SQ::Definition(double mass) +{ + if (theInstance !=0) return theInstance; + const G4String name = "sexaq"; + // search in particle table] + G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition* anInstance = pTable->FindParticle(name); + if (anInstance ==0) + { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, + 0, +1, 0, + 0, 0, 0, + "baryon", 0, +2, 1020000020, + true, -1.0, NULL, + false, "sexaq"); + + + } + theInstance = reinterpret_cast(anInstance); + return theInstance; +} + +//G4SQ* G4SQ::SQDefinition(double mass) +//{ +// return Definition(mass); +//} + +G4SQ* G4SQ::SQ(double mass) +{ + return Definition(mass * GeV); // will use correct mass if instance exists +} + + diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc new file mode 100644 index 0000000000000..f1f22dab3ce9d --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc @@ -0,0 +1,56 @@ + +#include "G4SystemOfUnits.hh" +#include "G4DynamicParticle.hh" +#include "G4NistManager.hh" + +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" +#include "SimG4Core/CustomPhysics/interface/G4AntiSQ.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" + +G4SQInelasticCrossSection::G4SQInelasticCrossSection(double mass) + : G4VCrossSectionDataSet("SQ-neutron") +{ + nist = G4NistManager::Instance(); + theSQ = G4SQ::SQ(mass); + theAntiSQ = G4AntiSQ::AntiSQ(mass); +} + + +G4SQInelasticCrossSection::~G4SQInelasticCrossSection() +{} + + +G4bool G4SQInelasticCrossSection::IsElementApplicable( + const G4DynamicParticle* aPart, + G4int Z, const G4Material*) +{ + return ((0 < Z) && + (aPart->GetDefinition() == theSQ || + aPart->GetDefinition() == theAntiSQ) + ); +} + + +G4double G4SQInelasticCrossSection::GetElementCrossSection( + const G4DynamicParticle* aPart, + G4int Z, const G4Material*) +{ + // return zero for particle instead of antiparticle + // sexaquark interaction with matter expected really tiny + if (aPart->GetDefinition() != theAntiSQ) return 0; + + // zero crosssection for particle at rest + if(aPart->GetKineticEnergy() <= 0.0) { return 0.0; } + + //I don't want to interact on hydrogen + if(Z <= 1){return 0.0;} + + // get the atomic weight (to estimate nr neutrons) + G4double A = nist->GetAtomicMassAmu(Z); + + // put the X section low for the antiS to get a flat interaction rate, + // but also make it scale with the number of neutrons in the material + // because we are going to interact on neutrons, not on protons + return (100.*(A-(G4double)Z)/(G4double)Z)*millibarn; + +} diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc new file mode 100644 index 0000000000000..62bc218335f00 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc @@ -0,0 +1,293 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h" +#include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" + +#include "G4Types.hh" +#include "G4SystemOfUnits.hh" +#include "G4HadProjectile.hh" +#include "G4ElementVector.hh" +#include "G4Track.hh" +#include "G4Step.hh" +#include "G4Element.hh" +#include "G4ParticleChange.hh" +#include "G4NucleiProperties.hh" +#include "G4Nucleus.hh" + +#include "G4HadronicException.hh" +#include "G4HadronicProcessStore.hh" +#include "G4HadronicInteraction.hh" + +#include "G4ParticleDefinition.hh" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + +G4SQInelasticProcess::G4SQInelasticProcess(double mass, const G4String& processName) + : G4HadronicProcess(processName, fHadronic) +{ + AddDataSet(new G4SQInelasticCrossSection(mass)); + theParticle = G4SQ::SQ(mass); +} + + +G4SQInelasticProcess::~G4SQInelasticProcess() +{ +} + + +G4bool G4SQInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) +{ + return theParticle->GetParticleType() == aP.GetParticleType(); +} + + +G4VParticleChange* +G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) +{ + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Particle is going to interact at position" << aTrack.GetPosition()/cm + << " momentumdirection eta: " << aTrack.GetMomentumDirection().eta() + << " interacting in material : " << aTrack.GetMaterial() << std::endl; + + // if primary is not Alive then do nothing + theTotalResult->Clear(); + theTotalResult->Initialize(aTrack); + theTotalResult->ProposeWeight(aTrack.GetWeight()); + if(aTrack.GetTrackStatus() != fAlive) { + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "No interaction because primary is not alive" << std::endl; + return theTotalResult; + } + + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Start a possible interaction?" << std::endl; + + if(aTrack.GetPosition().rho()/centimeter < 1) { + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "FYI: the rho of the track is < 1cm and it's still going to interact..." << std::endl; + } + + // Find cross section at end of step and check if <= 0 + // + G4DynamicParticle* aParticle = const_cast(aTrack.GetDynamicParticle()); + + G4Material* aMaterial = aTrack.GetMaterial(); + + const G4Element* anElement = 0; + try + { + anElement = theCrossSectionDataStore->SampleZandA(aParticle, + aMaterial, + targetNucleus); + } + catch(G4HadronicException & aR) + { + G4ExceptionDescription ed; + aR.Report(ed); + DumpState(aTrack,"SampleZandA",ed); + ed << " PostStepDoIt failed on element selection" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had003", FatalException, + ed); + } + + // check only for charged particles + if(aParticle->GetDefinition()->GetPDGCharge() != 0.0) { + if (GetElementCrossSection(aParticle, anElement, aMaterial) <= 0.0) { + // No interaction + return theTotalResult; + } + } + + // Next check for illegal track status + // + if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) { + if (aTrack.GetTrackStatus() == fStopAndKill || + aTrack.GetTrackStatus() == fKillTrackAndSecondaries || + aTrack.GetTrackStatus() == fPostponeToNextEvent) { + G4ExceptionDescription ed; + ed << "G4SQInelasticProcess: track in unusable state - " + << aTrack.GetTrackStatus() << G4endl; + ed << "G4SQInelasticProcess: returning unchanged track " << G4endl; + DumpState(aTrack,"PostStepDoIt",ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had004", JustWarning, ed); + } + // No warning for fStopButAlive which is a legal status here + return theTotalResult; + } + + // Go on to regular case + // + G4double originalEnergy = aParticle->GetKineticEnergy(); + G4double kineticEnergy = originalEnergy; + + // Get kinetic energy per nucleon for ions + if(aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5) + kineticEnergy/=aParticle->GetParticleDefinition()->GetBaryonNumber(); + + try + { + theInteraction = GetHadronicInteractionList().at(0); +// theInteraction = GetHadronicInteractionList()[0]; +// ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement ); + } + catch(G4HadronicException & aE) + { + G4ExceptionDescription ed; + aE.Report(ed); + ed << "Target element "<GetName()<<" Z= " + << targetNucleus.GetZ_asInt() << " A= " + << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack,"ChooseHadronicInteraction",ed); + ed << " No HadronicInteraction found out" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had005", FatalException, + ed); + } + + // Initialize the hadronic projectile from the track + thePro.Initialise(aTrack); + + G4HadFinalState* result = 0; + G4int reentryCount = 0; + + + do + { + try + { + // Call the interaction + result = theInteraction->ApplyYourself( thePro, targetNucleus); + ++reentryCount; + } + catch(G4HadronicException & aR) + { + G4ExceptionDescription ed; + aR.Report(ed); + ed << "Call for " << theInteraction->GetModelName() << G4endl; + ed << "Target element "<GetName()<<" Z= " + << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack,"ApplyYourself",ed); + ed << " ApplyYourself failed" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, + ed); + } + + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Call for " << theInteraction->GetModelName() + << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Target element "<< anElement->GetName() + << " Z=" << targetNucleus.GetZ_asInt() + << " A=" << targetNucleus.GetA_asInt() + << std::endl; + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "Nr of secondaries: " << result->GetNumberOfSecondaries() << std::endl + << "Momentum change and E deeposit: " << result->GetMomentumChange() << " " << result->GetLocalEnergyDeposit() << std::endl + << "Track position and vertex: " << aTrack.GetPosition() << " " << aTrack.GetVertexPosition() << std::endl; + + float r = aTrack.GetPosition().perp(); + float z = fabs(aTrack.GetPosition().z()); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "In tracker volume? " + << (r<(100*cm) && z<(200*cm)? " YES! " : " NO! ") + << "r=" << r/cm << " z=" << z/cm << std::endl; + + // Check the result for catastrophic energy non-conservation + result = CheckResult(thePro,targetNucleus, result); + if(reentryCount>100) { + G4ExceptionDescription ed; + ed << "Call for " << theInteraction->GetModelName() << G4endl; + ed << "Target element "<GetName()<<" Z= " + << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack,"ApplyYourself",ed); + ed << " ApplyYourself does not completed after 100 attempts" << G4endl; + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, + ed); + } + } + while(!result); + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "=== Anti-sexaquark interaction succeeded!" << std::endl; + result->SetTrafoToLab(thePro.GetTrafoToLab()); + + ClearNumberOfInteractionLengthLeft(); + + FillResult(result, aTrack); + + if (epReportLevel != 0) { + CheckEnergyMomentumConservation(aTrack, targetNucleus); + } + return theTotalResult; +} + + +G4HadFinalState* G4SQInelasticProcess::CheckResult(const G4HadProjectile & aPro,const G4Nucleus &aNucleus, G4HadFinalState * result) +{ + // check for catastrophic energy non-conservation, to re-sample the interaction + + G4HadronicInteraction * theModel = GetHadronicInteractionList()[0]; + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - " << theModel << std::endl; + + G4double nuclearMass(0); + if (theModel){ + + // Compute final-state total energy + G4double finalE(0.); + G4int nSec = result->GetNumberOfSecondaries(); + + nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(), + aNucleus.GetZ_asInt()); + if (result->GetStatusChange() != stopAndKill) { + // Interaction didn't complete, returned "do nothing" state => reset nucleus + // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus + finalE=result->GetLocalEnergyDeposit() + + aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange(); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - interaction not complete: " << finalE << std::endl; + if( nSec == 0 ){ + // Since there are no secondaries, there is no recoil nucleus. + // To check energy balance we must neglect the initial nucleus too. + nuclearMass=0.0; + } + } + for (G4int i = 0; i < nSec; i++) { + finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy(); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - secondary pdgId / E : " + << result->GetSecondary(i)->GetParticle()->GetPDGcode() << "\t" + << result->GetSecondary(i)->GetParticle()->GetTotalEnergy() / GeV + << std::endl; + } + G4double deltaE = nuclearMass + aPro.GetTotalEnergy() - finalE; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - Total E: " << finalE / GeV << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - Energy balance: " << deltaE / GeV << std::endl; + + std::pair checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute) + if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){ + // do not delete result, this is a pointer to a data member; + G4ExceptionDescription desc; + desc << "Warning: Bad energy non-conservation detected, will " + << (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl + << " Process / Model: " << GetProcessName()<< " / " << theModel->GetModelName() << G4endl + << " Primary: " << aPro.GetDefinition()->GetParticleName() + << " (" << aPro.GetDefinition()->GetPDGEncoding() << ")," + << " E= " << aPro.Get4Momentum().e() + << ", target nucleus (" << aNucleus.GetZ_asInt() << ","<< aNucleus.GetA_asInt() << ")" << G4endl + << " E(initial - final) = " << deltaE << " MeV." << G4endl; + G4Exception("G4SQInelasticProcess:CheckResult()", "had012", epReportLevel<0 ? EventMustBeAborted : JustWarning,desc); + } + } + return result; +} + diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc new file mode 100644 index 0000000000000..6faee989be02f --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc @@ -0,0 +1,64 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h" +#include "G4SystemOfUnits.hh" +#include "G4Step.hh" +#include "G4ParticleDefinition.hh" +#include "G4VParticleChange.hh" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + + + +G4SQLoopProcess::G4SQLoopProcess(const G4String& name, G4ProcessType type) + : G4VContinuousProcess(name, type) +{ + fParticleChange = new G4ParticleChange(); +} + + +G4SQLoopProcess::~G4SQLoopProcess() +{ + delete fParticleChange; +} + + +G4VParticleChange* G4SQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) +{ + + if(track.GetPosition()==posini) + edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") + << "G4SQLoopProcess::AlongStepDoIt: G4SQLoopProcess::AlongStepDoIt MomentumDirection " << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition()/cm << " trackId " << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime()/ns << " TotalEnergy: " << track.GetTotalEnergy()/GeV << " Velocity " << track.GetVelocity()/m/ns << std::endl; + + fParticleChange->Clear(); + fParticleChange->Initialize(track); + fParticleChange->ProposeWeight(track.GetWeight()); + //Sbar not passing the following criteria are not of interest. They will not be reconstructable. A cut like this is required otherwise you will get Sbar infinitely looping. + if(fabs(track.GetMomentumDirection().eta())>999. || fabs(track.GetPosition().z()) > 160*centimeter){ + edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") + << "Particle getting killed because too large z"<< std::endl; + fParticleChange->ProposeTrackStatus(fStopAndKill); + } + + return fParticleChange; +} + + +G4double G4SQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection) +{ + return 1.*centimeter; +} + + +G4double G4SQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double , G4double , G4double& ) +{ + return 1.*centimeter; // seems irrelevant +} + + +void G4SQLoopProcess::StartTracking(G4Track * aTrack) +{ + posini = aTrack->GetPosition(); +} + + diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc new file mode 100644 index 0000000000000..85d51fac962f1 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc @@ -0,0 +1,82 @@ + +#include "SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h" +#include "G4SystemOfUnits.hh" +#include "G4Step.hh" +#include "G4ParticleDefinition.hh" +#include "G4VParticleChange.hh" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + + +G4SQLoopProcessDiscr::G4SQLoopProcessDiscr(double mass, const G4String& name, G4ProcessType type) + : G4VDiscreteProcess(name, type) +{ + fParticleChange = new G4ParticleChange(); + fParticleChange->ClearDebugFlag(); + GenMass = mass; +} + + +G4SQLoopProcessDiscr::~G4SQLoopProcessDiscr() +{ + delete fParticleChange; +} + + +G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) +{ + + G4Track * mytr = const_cast(&track); + mytr->SetPosition(posini); + if(mytr->GetGlobalTime()/ns>4990) + edm::LogWarning("G4SQLoopProcess::AlongStepDoIt") + << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl; + + fParticleChange->Clear(); + fParticleChange->Initialize(track); + + //adding secondary antiS + fParticleChange->SetNumberOfSecondaries(1); + G4DynamicParticle* replacementParticle= new G4DynamicParticle(G4AntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy()); + fParticleChange->AddSecondary(replacementParticle,globaltimeini); + + //killing original AntiS + fParticleChange->ProposeTrackStatus(fStopAndKill); + + // note SL: this way of working makes a very long history of the track, + // which all get saved recursively in SimTracks. If the cross section + // is too low such that 10's of thousands of iterations are needed, then + // this becomes too heavy to swallow writing out this history. + // So if we ever need very small cross sections, then we really need + // to change this way of working such that we can throw away all original + // tracks and only save the one that interacted. + + return fParticleChange; +} + + +G4double G4SQLoopProcessDiscr::PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition) +{ + *condition = NotForced; + G4double intLength = DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position + G4Track * mytr = const_cast(&track); + if(sqrt(pow(mytr->GetPosition().rho(),2))>2.45*centimeter){//this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed +// updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018 + intLength = 0.0;//0 interaction length means particle will directly interact. + } + return intLength; +} + +G4double G4SQLoopProcessDiscr::GetMeanFreePath(const G4Track&,G4double, + G4ForceCondition*) +{ + return DBL_MAX; +} + + +void G4SQLoopProcessDiscr::StartTracking(G4Track * aTrack) +{ + posini = aTrack->GetPosition(); + globaltimeini = aTrack->GetGlobalTime(); + +} diff --git a/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc new file mode 100644 index 0000000000000..6ed99739e5148 --- /dev/null +++ b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc @@ -0,0 +1,281 @@ + +#include "G4PhysicalConstants.hh" +#include "G4SystemOfUnits.hh" +#include "G4ParticleTable.hh" +#include "G4ParticleDefinition.hh" +#include "Randomize.hh" +#include "G4NucleiProperties.hh" +#include +#include "TMath.h" + +#include "SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h" +#include "SimG4Core/CustomPhysics/interface/G4SQ.h" + + +G4SQNeutronAnnih::G4SQNeutronAnnih(double mass) : G4HadronicInteraction("SexaQuark-neutron annihilation") +{ + SetMinEnergy( 0.0*GeV ); + SetMaxEnergy( 100.*TeV ); + + theSQ = G4SQ::SQ(mass); + theK0S = G4KaonZeroShort::KaonZeroShort(); + theAntiL = G4AntiLambda::AntiLambda(); + theProton = G4Proton::Proton();//proton only used when the particle which the sexaquark hits is a deutereon and the neutron dissapears, so what stays behind is a proton +} + + +G4SQNeutronAnnih::~G4SQNeutronAnnih() +{} + + + +//9Be momentum distribution from Jan Ryckebusch +G4double G4SQNeutronAnnih::momDistr(G4double x_in){ + +const int n_entries = 50; + +G4double CDF_k[n_entries] = { +0, +0.1, +0.2, +0.3, +0.4, +0.5, +0.6, +0.7, +0.8, +0.9, +1, +1.1, +1.2, +1.3, +1.4, +1.5, +1.6, +1.7, +1.8, +1.9, +2, +2.1, +2.2, +2.3, +2.4, +2.5, +2.6, +2.7, +2.8, +2.9, +3, +3.1, +3.2, +3.3, +3.4, +3.5, +3.6, +3.7, +3.8, +3.9, +4., +4.1, +4.2, +4.3, +4.4, +4.5, +4.6, +4.7, +4.8, +4.9 +}; + +G4double x[n_entries] = { +0, +0.0038033182, +0.0187291764, +0.0510409777, +0.1048223609, +0.1807862863, +0.2756514534, +0.3825832103, +0.4926859745, +0.5970673837, +0.6887542272, +0.7637748784, +0.8212490273, +0.8627259608, +0.8911605331, +0.9099115186, +0.9220525854, +0.9300190818, +0.9355376091, +0.9397242185, +0.9432387722, +0.946438928, +0.9495023924, +0.9525032995, +0.9554669848, +0.9583936672, +0.9612770117, +0.9641067202, +0.9668727859, +0.9695676121, +0.9721815799, +0.9747092981, +0.9771426396, +0.9794740235, +0.9816956807, +0.9838003583, +0.9857816165, +0.9876331761, +0.9893513365, +0.9909333198, +0.992378513, +0.9936885054, +0.9948665964, +0.9959179448, +0.9968491104, +0.9976680755, +0.9983832508, +0.9990041784, +0.9995400073, +1 +}; + + //now interpolate the above points for x_in + G4double result = 9999; + for(int i = 0; i < n_entries; i++){ + if(x[i] > x_in) { + result = (CDF_k[i]-CDF_k[i-1])/(x[i]-x[i-1])*(x_in-x[i-1])+CDF_k[i-1]; + break; + } + } + //ROOT::Math::Interpolator inter(n_entries, ROOT::Math::Interpolation::kAKIMA); + //inter.SetData(n_entries,x,CDF_k); + //result = inter.Eval(x_in); + + return result; + //return 1; + +} + + + + + +G4HadFinalState* G4SQNeutronAnnih::ApplyYourself( + const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) +{ + theParticleChange.Clear(); + const G4HadProjectile* aParticle = &aTrack; + G4double ekin = aParticle->GetKineticEnergy(); + + + G4int A = targetNucleus.GetA_asInt(); + G4int Z = targetNucleus.GetZ_asInt(); + + + G4double m_K0S = G4KaonZeroShort::KaonZeroShort()->GetPDGMass(); + G4double m_L = G4AntiLambda::AntiLambda()->GetPDGMass(); + + G4cout << "----> G4SQNeutronAnnih <-----" << G4endl; + + //G4double plab = aParticle->GetTotalMomentum(); + +// G4cout << "G4SQNeutronAnnih: Incident particle p (GeV), total Energy (GeV), particle name, eta =" +// << plab/GeV << " " +// << aParticle->GetTotalEnergy()/GeV << " " +// << aParticle->GetDefinition()->GetParticleName() << " " +// << aParticle->Get4Momentum() << G4endl; + + // Scattered particle referred to axis of incident particle + //const G4ParticleDefinition* theParticle = aParticle->GetDefinition(); + + //G4int projPDG = theParticle->GetPDGEncoding(); +// if (verboseLevel > 1) +// G4cout << "G4SQNeutronAnnih: for " << theParticle->GetParticleName() +// << " PDGcode= " << projPDG << " on nucleus Z= " << Z +// << " A= " << A << " N= " << N +// << G4endl; + + G4LorentzVector lv1 = aParticle->Get4Momentum(); + G4cout << "The neutron Fermi momentum (mag, x, y, z) " << targetNucleus.GetFermiMomentum().mag()/MeV << " " << targetNucleus.GetFermiMomentum().x()/MeV << " " << targetNucleus.GetFermiMomentum().y()/MeV << " " << targetNucleus.GetFermiMomentum().z()/MeV << std::endl; + + //calculate fermi momentum + + G4double k_neutron = momDistr(G4UniformRand()); + G4double momentum_neutron = 0.1973*GeV*k_neutron; + + G4double theta_neutron = TMath::ACos(2*G4UniformRand()-1); + G4double phi_neutron = 2.*TMath::Pi()*G4UniformRand(); + + G4double p_neutron_x = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Cos(phi_neutron); + G4double p_neutron_y = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Sin(phi_neutron); + G4double p_neutron_z = momentum_neutron*TMath::Cos(theta_neutron); + + + //G4LorentzVector lv0(targetNucleus.GetFermiMomentum(), sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + targetNucleus.GetFermiMomentum().mag2() ) ); + G4LorentzVector lv0(p_neutron_x, p_neutron_y, p_neutron_z, sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + momentum_neutron*momentum_neutron ) ); + + //const G4Nucleus* aNucleus = &targetNucleus; + G4double BENeutronInNucleus = 0; + if(A != 0)BENeutronInNucleus = G4NucleiProperties::GetBindingEnergy( A, Z)/(A); + + G4cout << "BE of nucleon in the nucleus (GeV): " << BENeutronInNucleus/GeV << G4endl; + + G4LorentzVector lvBE(0,0,0,BENeutronInNucleus/GeV); + G4LorentzVector lv = lv0 + lv1 - lvBE; + + // kinematiacally impossible ? + G4double etot = lv0.e() + lv1.e() - lvBE.e(); + if(etot < theK0S->GetPDGMass() + theAntiL->GetPDGMass()) { + theParticleChange.SetEnergyChange(ekin); + theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit()); + return &theParticleChange; + } + + float newIonMass = targetNucleus.AtomicMass(A-1,Z)*931.5*MeV; ; + G4LorentzVector nlvIon(0,0,0,newIonMass); + + G4double theta_KS0_star = TMath::ACos(2*G4UniformRand()-1); + G4double phi_KS0_star = 2.*TMath::Pi()*G4UniformRand(); + + G4double p_K0S_star_x = TMath::Sin(theta_KS0_star)*TMath::Cos(phi_KS0_star); + G4double p_K0S_star_y = TMath::Sin(theta_KS0_star)*TMath::Sin(phi_KS0_star); + G4double p_K0S_star_z = TMath::Cos(theta_KS0_star); + + G4ThreeVector p(p_K0S_star_x,p_K0S_star_y,p_K0S_star_z); + double m0 = lv.m(); + double m0_2 = m0*m0; + double m1_2 = m_K0S*m_K0S; + double m2_2 = m_L*m_L; + + p *= 0.5/m0 * sqrt ( m0_2*m0_2 + m1_2*m1_2 + m2_2*m2_2 - 2*m0_2*m1_2 - 2*m0_2*m2_2 - 2*m1_2*m2_2); + double p2 = p.mag2(); + + G4LorentzVector nlvK0S( p, sqrt (p2 + m1_2)); + G4LorentzVector nlvAntiL(-p, sqrt (p2 + m2_2)); + + // Boost out of the rest frame. + nlvK0S.boost (lv.boostVector ()); + nlvAntiL.boost (lv.boostVector ()); + + // now move to implement the interaction + theParticleChange.SetStatusChange(stopAndKill); + //theParticleChange.SetEnergyChange(ekin); // was 0.0 + + + + G4DynamicParticle * aSec1 = new G4DynamicParticle(theK0S, nlvK0S); + theParticleChange.AddSecondary(aSec1); + G4DynamicParticle * aSec2 = new G4DynamicParticle(theAntiL, nlvAntiL); + theParticleChange.AddSecondary(aSec2); + + const G4ParticleDefinition* theRemainingNucleusDef = theProton; + if(A != 1) theRemainingNucleusDef = G4IonTable::GetIonTable()->GetIon(Z,A-1); + G4DynamicParticle * aSec3 = new G4DynamicParticle(theRemainingNucleusDef, nlvIon); + theParticleChange.AddSecondary(aSec3); + + // return as is; we don't care about what happens to the nucleus + return &theParticleChange; + +} + diff --git a/SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py b/SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py new file mode 100644 index 0000000000000..6b45056624f01 --- /dev/null +++ b/SimG4Core/CustomPhysics/test/Sexaquark_RunIIFall18GenSim_cfg.py @@ -0,0 +1,151 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: Configuration/GenProduction/python/BPH-RunIIFall18GS-00369-fragment.py --python_filename BPH-RunIIFall18GS-00369_1_cfg.py --eventcontent RAWSIM --datatier GEN-SIM --fileout file:BPH-RunIIFall18GS-00369.root --conditions 102X_upgrade2018_realistic_v11 --beamspot Realistic25ns13TeVEarly2018Collision --step GEN,SIM --geometry DB:Extended --era Run2_2018 --no_exec --mc -n 1000 +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras +from FWCore.ParameterSet.VarParsing import VarParsing + +process = cms.Process('SIM',eras.Run3_2023) +options = VarParsing ('analysis') +options.outputFile = 'file:sexaq_sim.root' +#options.inputFiles = 'root://cmsxrootd.hep.wisc.edu//store/user/wvetens/crmc_Sexaq/crmc/Sexaquark_13TeV_trial_4_1p8GeV/0/crmc_Sexaq_1.root' +options.inputFiles = 'file:crmc_Sexaq_1.root' +options.maxEvents= 100 +options.parseArguments() + +# 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('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.GeometrySimDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +# Vtx Smearing done in hepmc 2 gen step +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic25ns13TeVEarly2018Collision_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('RecoVertex.BeamSpotProducer.BeamSpot_cfi') + +# Lengthy message logs - uncomment to debug +#process.MessageLogger = cms.Service("MessageLogger", +# destinations = cms.untracked.vstring('cout'), +# cout = cms.untracked.PSet( +# threshold = cms.untracked.string('INFO') +# ) +#) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(options.maxEvents) + #input = cms.untracked.int32(-1) +) + +# Input source + +#process.source = cms.Source("EmptySource") +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring(options.inputFiles), + skipEvents = cms.untracked.uint32(0), + duplicateCheckMode = cms.untracked.string ("noDuplicateCheck") +) + + +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +) + +# Output definition + +process.RAWSIMoutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(1), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(20971520), + fileName = cms.untracked.string(options.outputFile), + outputCommands = process.RAWSIMEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition +process.RAWSIMoutput.outputCommands += ("keep *_genParticlesPlusGEANT_*_*",) + +# Other statements +#process.XMLFromDBSource.label = cms.string("Extended") +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '102X_upgrade2018_realistic_v11', '') +#process.GlobalTag = GlobalTag(process.GlobalTag, '140X_mcRun3_2024_realistic_v14', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '140X_mcRun3_2023_realistic_v3', '') +#process.GlobalTag = GlobalTag(process.GlobalTag, '140X_mcRun3_2022_realistic_v3', '') + + + +process.genParticlesPlusGEANT = cms.EDProducer("GenPlusSimParticleProducer", + src = cms.InputTag("g4SimHits"), + setStatus = cms.int32(8), # set status = 8 for GEANT GPs + particleTypes = cms.vstring(), + filter = cms.vstring(), + genParticles = cms.InputTag("genParticles") # original genParticle list +) + +from SimG4Core.CustomPhysics.CustomPhysics_cfi import customPhysicsSetup +process.g4SimHits.Physics.type = cms.string('SimG4Core/Physics/CustomPhysics') +process.g4SimHits.Physics.RHadronDummyFlip = cms.bool(False) +process.g4SimHits.Physics.Verbosity = 1 +process.g4SimHits.Physics = cms.PSet( + process.g4SimHits.Physics, #keep all default value and add others + customPhysicsSetup + ) +process.g4SimHits.Physics.particlesDef = cms.FileInPath('SimG4Core/CustomPhysics/data/particles_sexaq_1p8_GeV.txt') + + +## Vtx Smearing done in hepmc 2 gen step +process.VtxSmeared.src = cms.InputTag("source", "generator") +process.genParticles.src = cms.InputTag("generatorSmeared") +process.g4SimHits.HepMCProductLabel = cms.InputTag("generatorSmeared") +process.g4SimHits.Generator.HepMCProductLabel = cms.InputTag("generatorSmeared") + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +#moved beamspot and vtx smearing to hepmc2gen step +#process.simulation_step = cms.Path(process.offlineBeamSpot*process.generatorSmeared*process.psim*process.genParticlesPlusGEANT) +process.simulation_step = cms.Path(process.psim*process.genParticlesPlusGEANT) +#process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.RAWSIMoutput_step = cms.EndPath(process.RAWSIMoutput) + +# Schedule definition +#process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.endjob_step,process.RAWSIMoutput_step) +process.schedule = cms.Schedule(process.generation_step,process.simulation_step,process.endjob_step,process.RAWSIMoutput_step) + +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) +## filter all path with the production filter sequence +#for path in process.paths: +# getattr(process,path)._seq = process.ProductionFilterSequence * getattr(process,path)._seq + +from Configuration.DataProcessing.Utils import addMonitoring +process = addMonitoring(process) + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) + +# End adding early deletion +# For debug: +#print process.dumpPython() From 3f21c2850a7ae2a12b3318ffa6a6e23eb5d98035 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 16 May 2024 13:47:25 +0200 Subject: [PATCH 046/301] use constexpr --- .../LutNetworkFixedPointRegression2Outputs.h | 6 +-- .../interface/LutNeuronLayerFixedPoint.h | 12 ++--- .../src/PtAssignmentNNRegression.cc | 44 +++++++++---------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/L1Trigger/L1TMuonOverlapPhase2/interface/LutNetworkFixedPointRegression2Outputs.h b/L1Trigger/L1TMuonOverlapPhase2/interface/LutNetworkFixedPointRegression2Outputs.h index 2b8af4c021806..a205fd888066b 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/interface/LutNetworkFixedPointRegression2Outputs.h +++ b/L1Trigger/L1TMuonOverlapPhase2/interface/LutNetworkFixedPointRegression2Outputs.h @@ -63,9 +63,9 @@ namespace lutNN { LutLayer1; LutLayer1 lutLayer1; - static const unsigned int noHitCntShift = layer1_output_I; //FIXME should be layer1_output_I ??? + static constexpr unsigned int noHitCntShift = layer1_output_I; //FIXME should be layer1_output_I ??? - static const int layer2_input_F = layer1_lut_F; + static constexpr int layer2_input_F = layer1_lut_F; typedef LutNeuronLayerFixedPoint class LutNeuronLayerFixedPoint { public: - static const int input_W = input_I + input_F; - static const int lut_W = lut_I + lut_F; + static constexpr int input_W = input_I + input_F; + static constexpr int lut_W = lut_I + lut_F; //the lut out values sum //static const int lutOutSum_I = lut_I + ceil(log2(inputSize)); //MB: ceil(log2(inputSize)) is not constexpr which makes issue for code-checks - static const int lutOutSum_I = lut_I + ceillog2(inputSize); - static const int lutOutSum_W = lutOutSum_I + lut_F; + static constexpr int lutOutSum_I = lut_I + ceillog2(inputSize); + static constexpr int lutOutSum_W = lutOutSum_I + lut_F; - static const int output_W = output_I + lut_F; + static constexpr int output_W = output_I + lut_F; //static_assert( (1<, inputSize> inputArrayType; diff --git a/L1Trigger/L1TMuonOverlapPhase2/src/PtAssignmentNNRegression.cc b/L1Trigger/L1TMuonOverlapPhase2/src/PtAssignmentNNRegression.cc index 2cc74c4e51b18..ce3cdb6972343 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/src/PtAssignmentNNRegression.cc +++ b/L1Trigger/L1TMuonOverlapPhase2/src/PtAssignmentNNRegression.cc @@ -21,35 +21,35 @@ #include namespace lutNN { - static const int input_I = 10; - static const int input_F = 4; - static const std::size_t networkInputSize = 18; + static constexpr int input_I = 10; + static constexpr int input_F = 4; + static constexpr std::size_t networkInputSize = 18; - static const int layer1_neurons = 16; - static const int layer1_lut_I = 3; - static const int layer1_lut_F = 13; + static constexpr int layer1_neurons = 16; + static constexpr int layer1_lut_I = 3; + static constexpr int layer1_lut_F = 13; - static const int layer1_output_I = 4; + static constexpr int layer1_output_I = 4; //4 bits are for the count of the noHit layers which goes to the input of the layer2 - static const int layer2_input_I = 8; + static constexpr int layer2_input_I = 8; - static const int layer2_neurons = 9; - static const int layer2_lut_I = 5; - static const int layer2_lut_F = 11; + static constexpr int layer2_neurons = 9; + static constexpr int layer2_lut_I = 5; + static constexpr int layer2_lut_F = 11; - static const int layer3_input_I = 5; + static constexpr int layer3_input_I = 5; - static const int layer3_0_inputCnt = 8; - static const int layer3_0_lut_I = 5; - static const int layer3_0_lut_F = 11; - static const int output0_I = 8; - static const int output0_F = 2; + static constexpr int layer3_0_inputCnt = 8; + static constexpr int layer3_0_lut_I = 5; + static constexpr int layer3_0_lut_F = 11; + static constexpr int output0_I = 8; + static constexpr int output0_F = 2; - static const int layer3_1_inputCnt = 1; - static const int layer3_1_lut_I = 4; - static const int layer3_1_lut_F = 11; - static const int output1_I = 8; - static const int output1_F = 0; //Does not matter in principle - it is not used + static constexpr int layer3_1_inputCnt = 1; + static constexpr int layer3_1_lut_I = 4; + static constexpr int layer3_1_lut_F = 11; + static constexpr int output1_I = 8; + static constexpr int output1_F = 0; //Does not matter in principle - it is not used typedef LutNetworkFixedPointRegression2Outputs Date: Fri, 17 May 2024 11:24:45 +0200 Subject: [PATCH 047/301] Code cleanup after code checks --- SimG4Core/CustomPhysics/interface/G4AntiSQ.h | 23 +- SimG4Core/CustomPhysics/interface/G4SQ.h | 21 +- .../interface/G4SQInelasticCrossSection.h | 22 +- .../interface/G4SQInelasticProcess.h | 29 +- .../CustomPhysics/interface/G4SQLoopProcess.h | 61 ++-- .../interface/G4SQLoopProcessDiscr.h | 61 ++-- .../interface/G4SQNeutronAnnih.h | 27 +- .../CustomPhysics/src/CustomPhysicsList.cc | 13 +- SimG4Core/CustomPhysics/src/G4AntiSQ.cc | 47 +-- SimG4Core/CustomPhysics/src/G4SQ.cc | 47 +-- .../src/G4SQInelasticCrossSection.cc | 39 +-- .../CustomPhysics/src/G4SQInelasticProcess.cc | 270 ++++++--------- .../CustomPhysics/src/G4SQLoopProcess.cc | 55 ++-- .../CustomPhysics/src/G4SQLoopProcessDiscr.cc | 64 ++-- .../CustomPhysics/src/G4SQNeutronAnnih.cc | 311 +++++++----------- 15 files changed, 430 insertions(+), 660 deletions(-) diff --git a/SimG4Core/CustomPhysics/interface/G4AntiSQ.h b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h index 93716063261c3..d131d566af6a0 100644 --- a/SimG4Core/CustomPhysics/interface/G4AntiSQ.h +++ b/SimG4Core/CustomPhysics/interface/G4AntiSQ.h @@ -26,7 +26,7 @@ // // $Id: G4AntiSQ.hh 67971 2013-03-13 10:13:24Z gcosmo $ // -// +// // ------------------------------------------------------------ // GEANT 4 class header file // @@ -47,19 +47,16 @@ // ### ANTI-SEXAQUARK ### // ###################################################################### - class G4AntiSQ : public G4ParticleDefinition { - - private: - static G4AntiSQ* theInstance; - G4AntiSQ(){} - ~G4AntiSQ(){} - - public: - static G4AntiSQ* Definition(double mass); - //static G4AntiSQ* AntiSQDefinition(double mass); - static G4AntiSQ* AntiSQ(double mass); - +private: + static G4AntiSQ* theInstance; + G4AntiSQ() {} + ~G4AntiSQ() {} + +public: + static G4AntiSQ* Definition(double mass); + //static G4AntiSQ* AntiSQDefinition(double mass); + static G4AntiSQ* AntiSQ(double mass); }; #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQ.h b/SimG4Core/CustomPhysics/interface/G4SQ.h index 6277916684f1f..e23968e0f4486 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQ.h +++ b/SimG4Core/CustomPhysics/interface/G4SQ.h @@ -10,19 +10,16 @@ // ### SEXAQUARK ### // ###################################################################### - class G4SQ : public G4ParticleDefinition { - - private: - static G4SQ* theInstance; - G4SQ(){} - ~G4SQ(){} - - public: - static G4SQ* Definition(double mass); -// static G4SQ* SQDefinition(double mass); - static G4SQ* SQ(double mass); - +private: + static G4SQ* theInstance; + G4SQ() {} + ~G4SQ() {} + +public: + static G4SQ* Definition(double mass); + // static G4SQ* SQDefinition(double mass); + static G4SQ* SQ(double mass); }; #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h index 2a5c5881dfba5..31e1ee6f65638 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h @@ -2,41 +2,29 @@ #ifndef G4SQInelasticCrossSection_h #define G4SQInelasticCrossSection_h - #include "globals.hh" #include "G4VCrossSectionDataSet.hh" - class G4NistManager; class G4SQ; class G4AntiSQ; - -class G4SQInelasticCrossSection : public G4VCrossSectionDataSet -{ +class G4SQInelasticCrossSection : public G4VCrossSectionDataSet { public: - G4SQInelasticCrossSection(double mass); ~G4SQInelasticCrossSection(); - virtual - G4bool IsElementApplicable(const G4DynamicParticle* aPart, - G4int Z, const G4Material*); + virtual G4bool IsElementApplicable(const G4DynamicParticle* aPart, G4int Z, const G4Material*); - virtual - G4double GetElementCrossSection(const G4DynamicParticle*, - G4int Z, const G4Material*); + virtual G4double GetElementCrossSection(const G4DynamicParticle*, G4int Z, const G4Material*); G4double GetSQCrossSection(G4double kineticEnergy, G4int Z); private: - G4NistManager* nist; - G4SQ * theSQ; - G4AntiSQ * theAntiSQ; - + G4SQ* theSQ; + G4AntiSQ* theAntiSQ; }; #endif - diff --git a/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h index 6530d267c16fb..f3039d458c940 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h +++ b/SimG4Core/CustomPhysics/interface/G4SQInelasticProcess.h @@ -1,46 +1,33 @@ #ifndef SimG4Core_CustomPhysics_G4SQInelasticProcess_h #define SimG4Core_CustomPhysics_G4SQInelasticProcess_h 1 - - -#include "G4HadronicProcess.hh" +#include "G4HadronicProcess.hh" class G4ParticleDefinition; - -class G4SQInelasticProcess : public G4HadronicProcess -{ - - public: - - G4SQInelasticProcess(double mass, const G4String& processName="SQInelastic"); +class G4SQInelasticProcess : public G4HadronicProcess { +public: + G4SQInelasticProcess(double mass, const G4String& processName = "SQInelastic"); ~G4SQInelasticProcess(); G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override; // generic PostStepDoIt recommended for all derived classes - virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack, - const G4Step& aStep); + virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack, const G4Step& aStep); G4SQInelasticProcess& operator=(const G4SQInelasticProcess& right); G4SQInelasticProcess(const G4SQInelasticProcess&); - protected: - +protected: // Check the result for catastrophic energy non-conservation - G4HadFinalState* CheckResult(const G4HadProjectile& thePro, - const G4Nucleus& targetNucleus, - G4HadFinalState* result); - - private: + G4HadFinalState* CheckResult(const G4HadProjectile& thePro, const G4Nucleus& targetNucleus, G4HadFinalState* result); +private: G4ParticleDefinition* theParticle; G4Nucleus targetNucleus; G4HadronicInteraction* theInteraction = nullptr; - }; #endif - diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h index 224fb8a1b9fbf..737c4738584c0 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcess.h @@ -6,43 +6,38 @@ #include "G4Track.hh" #include "G4ParticleChange.hh" - class G4Step; class G4ParticleDefinition; - class G4SQLoopProcess : public G4VContinuousProcess { - - public: - - G4SQLoopProcess(const G4String& name = "SQLooper", - G4ProcessType type = fUserDefined); - virtual ~G4SQLoopProcess(); - - - public: - - virtual G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); - virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection); - virtual void StartTracking(G4Track * aTrack); - - protected: - - virtual G4double GetContinuousStepLimit(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& currentSafety); - - private: - - G4SQLoopProcess(G4SQLoopProcess &); - G4SQLoopProcess & operator=(const G4SQLoopProcess &right); - - protected: - - G4ParticleChange* fParticleChange; - - private: - - G4ThreeVector posini; +public: + G4SQLoopProcess(const G4String& name = "SQLooper", G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcess(); + +public: + virtual G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&); + virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4double currentMinimumStep, + G4double& proposedSafety, + G4GPILSelection* selection); + virtual void StartTracking(G4Track* aTrack); + +protected: + virtual G4double GetContinuousStepLimit(const G4Track& track, + G4double previousStepSize, + G4double currentMinimumStep, + G4double& currentSafety); + +private: + G4SQLoopProcess(G4SQLoopProcess&); + G4SQLoopProcess& operator=(const G4SQLoopProcess& right); + +protected: + G4ParticleChange* fParticleChange; + +private: + G4ThreeVector posini; }; - #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h index f7a192b24bb7a..25d7296cb4c8b 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h +++ b/SimG4Core/CustomPhysics/interface/G4SQLoopProcessDiscr.h @@ -9,46 +9,35 @@ #include "G4SQ.h" #include "G4AntiSQ.h" - class G4Step; class G4ParticleDefinition; - class G4SQLoopProcessDiscr : public G4VDiscreteProcess { - - public: - - G4SQLoopProcessDiscr(double mass, - const G4String& name = "SQLooper", - G4ProcessType type = fUserDefined); - virtual ~G4SQLoopProcessDiscr(); - - - public: - - virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); - virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition); - virtual G4double GetMeanFreePath(const G4Track&, G4double,G4ForceCondition*); - void SetTimeLimit(G4double); - virtual void StartTracking(G4Track * aTrack); - private: - - G4SQLoopProcessDiscr(G4SQLoopProcessDiscr &); - G4SQLoopProcessDiscr & operator=(const G4SQLoopProcessDiscr &right); - - protected: - - //G4ParticleChangeForTransport* fParticleChange; - G4ParticleChange* fParticleChange; - double GenMass; - - private: - - G4ThreeVector posini; - G4double globaltimeini; - - +public: + G4SQLoopProcessDiscr(double mass, const G4String& name = "SQLooper", G4ProcessType type = fUserDefined); + virtual ~G4SQLoopProcessDiscr(); + +public: + virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&); + virtual G4double PostStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4ForceCondition* condition); + virtual G4double GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*); + void SetTimeLimit(G4double); + virtual void StartTracking(G4Track* aTrack); + +private: + G4SQLoopProcessDiscr(G4SQLoopProcessDiscr&); + G4SQLoopProcessDiscr& operator=(const G4SQLoopProcessDiscr& right); + +protected: + //G4ParticleChangeForTransport* fParticleChange; + G4ParticleChange* fParticleChange; + double GenMass; + +private: + G4ThreeVector posini; + G4double globaltimeini; }; - #endif diff --git a/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h index e565d3b490781..403697305d771 100644 --- a/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h +++ b/SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h @@ -10,28 +10,21 @@ class G4ParticleDefinition; - class G4SQNeutronAnnih : public G4HadronicInteraction { +public: + G4SQNeutronAnnih(double mass); - public: - - G4SQNeutronAnnih(double mass); - - virtual ~G4SQNeutronAnnih(); - - G4double momDistr(G4double x_in); - - virtual G4HadFinalState * ApplyYourself( - const G4HadProjectile & aTrack, - G4Nucleus & targetNucleus); + virtual ~G4SQNeutronAnnih(); - private: + G4double momDistr(G4double x_in); - G4ParticleDefinition* theSQ; - G4ParticleDefinition* theK0S; - G4ParticleDefinition* theAntiL; - G4ParticleDefinition* theProton; + virtual G4HadFinalState* ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& targetNucleus); +private: + G4ParticleDefinition* theSQ; + G4ParticleDefinition* theK0S; + G4ParticleDefinition* theAntiL; + G4ParticleDefinition* theProton; }; #endif diff --git a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc index ed0c9b3d0db6e..983cc2045ee2d 100644 --- a/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc +++ b/SimG4Core/CustomPhysics/src/CustomPhysicsList.cc @@ -106,20 +106,19 @@ void CustomPhysicsList::ConstructProcess() { pmanager->AddDiscreteProcess(darkGamma); } if (particle->GetParticleName() == "anti_sexaq") { - // here the different sexaquark interactions get defined - G4SQInelasticProcess * sqInelPr = new G4SQInelasticProcess(particle->GetPDGMass()/GeV); - G4SQNeutronAnnih * sqModel = new G4SQNeutronAnnih(particle->GetPDGMass()/GeV); + G4SQInelasticProcess* sqInelPr = new G4SQInelasticProcess(particle->GetPDGMass() / GeV); + G4SQNeutronAnnih* sqModel = new G4SQNeutronAnnih(particle->GetPDGMass() / GeV); sqInelPr->RegisterMe(sqModel); - G4SQInelasticCrossSection * sqInelXS = new G4SQInelasticCrossSection(particle->GetPDGMass()/GeV); + G4SQInelasticCrossSection* sqInelXS = new G4SQInelasticCrossSection(particle->GetPDGMass() / GeV); sqInelPr->AddDataSet(sqInelXS); pmanager->AddDiscreteProcess(sqInelPr); // add also the looping needed to simulate flat interaction probability - G4SQLoopProcess * sqLoopPr = new G4SQLoopProcess(); + G4SQLoopProcess* sqLoopPr = new G4SQLoopProcess(); pmanager->AddContinuousProcess(sqLoopPr); - G4SQLoopProcessDiscr * sqLoopPrDiscr = new G4SQLoopProcessDiscr(particle->GetPDGMass()/GeV); + G4SQLoopProcessDiscr* sqLoopPrDiscr = new G4SQLoopProcessDiscr(particle->GetPDGMass() / GeV); pmanager->AddDiscreteProcess(sqLoopPrDiscr); - } else if (particle->GetParticleName() == "sexaq"){ + } else if (particle->GetParticleName() == "sexaq") { edm::LogInfo("CustomPhysics") << " No pmanager implemented for sexaq, only for anti_sexaq"; } } diff --git a/SimG4Core/CustomPhysics/src/G4AntiSQ.cc b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc index 227f34b862bb3..487f89dfb9154 100644 --- a/SimG4Core/CustomPhysics/src/G4AntiSQ.cc +++ b/SimG4Core/CustomPhysics/src/G4AntiSQ.cc @@ -13,47 +13,36 @@ G4AntiSQ* G4AntiSQ::theInstance = 0; -G4AntiSQ* G4AntiSQ::Definition(double mass) -{ - if (theInstance !=0) return theInstance; +G4AntiSQ* G4AntiSQ::Definition(double mass) { + if (theInstance != 0) + return theInstance; const G4String name = "anti_sexaq"; // search in particle table] G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* anInstance = pTable->FindParticle(name); - if (anInstance ==0) - { - // create particle - // - // Arguments for constructor are as follows - // name mass width charge - // 2*spin parity C-conjugation - // 2*Isospin 2*Isospin3 G-parity - // type lepton number baryon number PDG encoding - // stable lifetime decay table - // shortlived subType anti_encoding - - anInstance = new G4ParticleDefinition( - name, mass, 0, 0.0, - 0, +1, 0, - 0, 0, 0, - "baryon", 0, -2, -1020000020, - true, -1.0, NULL, - false, "sexaq"); - + if (anInstance == 0) { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, 0, +1, 0, 0, 0, 0, "baryon", 0, -2, -1020000020, true, -1.0, NULL, false, "sexaq"); } theInstance = reinterpret_cast(anInstance); return theInstance; } //G4AntiSQ* G4AntiSQ::AntiSQDefinition(double mass) -//{ +//{ // return Definition(mass); //} -G4AntiSQ* G4AntiSQ::AntiSQ(double mass) -{ - return Definition(mass * GeV); // will use correct mass if instance exists +G4AntiSQ* G4AntiSQ::AntiSQ(double mass) { + return Definition(mass * GeV); // will use correct mass if instance exists } - - diff --git a/SimG4Core/CustomPhysics/src/G4SQ.cc b/SimG4Core/CustomPhysics/src/G4SQ.cc index 0fb963364282c..5f5b0f2e99657 100644 --- a/SimG4Core/CustomPhysics/src/G4SQ.cc +++ b/SimG4Core/CustomPhysics/src/G4SQ.cc @@ -13,47 +13,36 @@ G4SQ* G4SQ::theInstance = 0; -G4SQ* G4SQ::Definition(double mass) -{ - if (theInstance !=0) return theInstance; +G4SQ* G4SQ::Definition(double mass) { + if (theInstance != 0) + return theInstance; const G4String name = "sexaq"; // search in particle table] G4ParticleTable* pTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* anInstance = pTable->FindParticle(name); - if (anInstance ==0) - { - // create particle - // - // Arguments for constructor are as follows - // name mass width charge - // 2*spin parity C-conjugation - // 2*Isospin 2*Isospin3 G-parity - // type lepton number baryon number PDG encoding - // stable lifetime decay table - // shortlived subType anti_encoding - - anInstance = new G4ParticleDefinition( - name, mass, 0, 0.0, - 0, +1, 0, - 0, 0, 0, - "baryon", 0, +2, 1020000020, - true, -1.0, NULL, - false, "sexaq"); - + if (anInstance == 0) { + // create particle + // + // Arguments for constructor are as follows + // name mass width charge + // 2*spin parity C-conjugation + // 2*Isospin 2*Isospin3 G-parity + // type lepton number baryon number PDG encoding + // stable lifetime decay table + // shortlived subType anti_encoding + anInstance = new G4ParticleDefinition( + name, mass, 0, 0.0, 0, +1, 0, 0, 0, 0, "baryon", 0, +2, 1020000020, true, -1.0, NULL, false, "sexaq"); } theInstance = reinterpret_cast(anInstance); return theInstance; } //G4SQ* G4SQ::SQDefinition(double mass) -//{ +//{ // return Definition(mass); //} -G4SQ* G4SQ::SQ(double mass) -{ - return Definition(mass * GeV); // will use correct mass if instance exists +G4SQ* G4SQ::SQ(double mass) { + return Definition(mass * GeV); // will use correct mass if instance exists } - - diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc index f1f22dab3ce9d..1741c0ce2ffdb 100644 --- a/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticCrossSection.cc @@ -7,43 +7,33 @@ #include "SimG4Core/CustomPhysics/interface/G4AntiSQ.h" #include "SimG4Core/CustomPhysics/interface/G4SQInelasticCrossSection.h" -G4SQInelasticCrossSection::G4SQInelasticCrossSection(double mass) - : G4VCrossSectionDataSet("SQ-neutron") -{ +G4SQInelasticCrossSection::G4SQInelasticCrossSection(double mass) : G4VCrossSectionDataSet("SQ-neutron") { nist = G4NistManager::Instance(); theSQ = G4SQ::SQ(mass); theAntiSQ = G4AntiSQ::AntiSQ(mass); } +G4SQInelasticCrossSection::~G4SQInelasticCrossSection() {} -G4SQInelasticCrossSection::~G4SQInelasticCrossSection() -{} - - -G4bool G4SQInelasticCrossSection::IsElementApplicable( - const G4DynamicParticle* aPart, - G4int Z, const G4Material*) -{ - return ((0 < Z) && - (aPart->GetDefinition() == theSQ || - aPart->GetDefinition() == theAntiSQ) - ); +G4bool G4SQInelasticCrossSection::IsElementApplicable(const G4DynamicParticle* aPart, G4int Z, const G4Material*) { + return ((0 < Z) && (aPart->GetDefinition() == theSQ || aPart->GetDefinition() == theAntiSQ)); } - -G4double G4SQInelasticCrossSection::GetElementCrossSection( - const G4DynamicParticle* aPart, - G4int Z, const G4Material*) -{ +G4double G4SQInelasticCrossSection::GetElementCrossSection(const G4DynamicParticle* aPart, G4int Z, const G4Material*) { // return zero for particle instead of antiparticle // sexaquark interaction with matter expected really tiny - if (aPart->GetDefinition() != theAntiSQ) return 0; + if (aPart->GetDefinition() != theAntiSQ) + return 0; // zero crosssection for particle at rest - if(aPart->GetKineticEnergy() <= 0.0) { return 0.0; } + if (aPart->GetKineticEnergy() <= 0.0) { + return 0.0; + } //I don't want to interact on hydrogen - if(Z <= 1){return 0.0;} + if (Z <= 1) { + return 0.0; + } // get the atomic weight (to estimate nr neutrons) G4double A = nist->GetAtomicMassAmu(Z); @@ -51,6 +41,5 @@ G4double G4SQInelasticCrossSection::GetElementCrossSection( // put the X section low for the antiS to get a flat interaction rate, // but also make it scale with the number of neutrons in the material // because we are going to interact on neutrons, not on protons - return (100.*(A-(G4double)Z)/(G4double)Z)*millibarn; - + return (100. * (A - (G4double)Z) / (G4double)Z) * millibarn; } diff --git a/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc index 62bc218335f00..3c3e1c8e152cd 100644 --- a/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc +++ b/SimG4Core/CustomPhysics/src/G4SQInelasticProcess.cc @@ -22,79 +22,59 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" - G4SQInelasticProcess::G4SQInelasticProcess(double mass, const G4String& processName) - : G4HadronicProcess(processName, fHadronic) -{ + : G4HadronicProcess(processName, fHadronic) { AddDataSet(new G4SQInelasticCrossSection(mass)); theParticle = G4SQ::SQ(mass); } +G4SQInelasticProcess::~G4SQInelasticProcess() {} -G4SQInelasticProcess::~G4SQInelasticProcess() -{ -} - - -G4bool G4SQInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) -{ - return theParticle->GetParticleType() == aP.GetParticleType(); +G4bool G4SQInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) { + return theParticle->GetParticleType() == aP.GetParticleType(); } - -G4VParticleChange* -G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) -{ - +G4VParticleChange* G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) { edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Particle is going to interact at position" << aTrack.GetPosition()/cm - << " momentumdirection eta: " << aTrack.GetMomentumDirection().eta() - << " interacting in material : " << aTrack.GetMaterial() << std::endl; + << "Particle is going to interact at position" << aTrack.GetPosition() / cm + << " momentumdirection eta: " << aTrack.GetMomentumDirection().eta() + << " interacting in material : " << aTrack.GetMaterial() << std::endl; // if primary is not Alive then do nothing theTotalResult->Clear(); theTotalResult->Initialize(aTrack); theTotalResult->ProposeWeight(aTrack.GetWeight()); - if(aTrack.GetTrackStatus() != fAlive) { - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "No interaction because primary is not alive" << std::endl; + if (aTrack.GetTrackStatus() != fAlive) { + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "No interaction because primary is not alive" << std::endl; return theTotalResult; } + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "Start a possible interaction?" << std::endl; - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Start a possible interaction?" << std::endl; - - if(aTrack.GetPosition().rho()/centimeter < 1) { + if (aTrack.GetPosition().rho() / centimeter < 1) { edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "FYI: the rho of the track is < 1cm and it's still going to interact..." << std::endl; + << "FYI: the rho of the track is < 1cm and it's still going to interact..." << std::endl; } // Find cross section at end of step and check if <= 0 // - G4DynamicParticle* aParticle = const_cast(aTrack.GetDynamicParticle()); + G4DynamicParticle* aParticle = const_cast(aTrack.GetDynamicParticle()); G4Material* aMaterial = aTrack.GetMaterial(); const G4Element* anElement = 0; - try - { - anElement = theCrossSectionDataStore->SampleZandA(aParticle, - aMaterial, - targetNucleus); - } - catch(G4HadronicException & aR) - { + try { + anElement = theCrossSectionDataStore->SampleZandA(aParticle, aMaterial, targetNucleus); + } catch (G4HadronicException& aR) { G4ExceptionDescription ed; aR.Report(ed); - DumpState(aTrack,"SampleZandA",ed); + DumpState(aTrack, "SampleZandA", ed); ed << " PostStepDoIt failed on element selection" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had003", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had003", FatalException, ed); } // check only for charged particles - if(aParticle->GetDefinition()->GetPDGCharge() != 0.0) { + if (aParticle->GetDefinition()->GetPDGCharge() != 0.0) { if (GetElementCrossSection(aParticle, anElement, aMaterial) <= 0.0) { // No interaction return theTotalResult; @@ -104,14 +84,12 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) // Next check for illegal track status // if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) { - if (aTrack.GetTrackStatus() == fStopAndKill || - aTrack.GetTrackStatus() == fKillTrackAndSecondaries || + if (aTrack.GetTrackStatus() == fStopAndKill || aTrack.GetTrackStatus() == fKillTrackAndSecondaries || aTrack.GetTrackStatus() == fPostponeToNextEvent) { G4ExceptionDescription ed; - ed << "G4SQInelasticProcess: track in unusable state - " - << aTrack.GetTrackStatus() << G4endl; + ed << "G4SQInelasticProcess: track in unusable state - " << aTrack.GetTrackStatus() << G4endl; ed << "G4SQInelasticProcess: returning unchanged track " << G4endl; - DumpState(aTrack,"PostStepDoIt",ed); + DumpState(aTrack, "PostStepDoIt", ed); G4Exception("G4SQInelasticProcess::PostStepDoIt", "had004", JustWarning, ed); } // No warning for fStopButAlive which is a legal status here @@ -124,26 +102,21 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) G4double kineticEnergy = originalEnergy; // Get kinetic energy per nucleon for ions - if(aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5) - kineticEnergy/=aParticle->GetParticleDefinition()->GetBaryonNumber(); + if (aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5) + kineticEnergy /= aParticle->GetParticleDefinition()->GetBaryonNumber(); - try - { + try { theInteraction = GetHadronicInteractionList().at(0); -// theInteraction = GetHadronicInteractionList()[0]; -// ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement ); - } - catch(G4HadronicException & aE) - { + // theInteraction = GetHadronicInteractionList()[0]; + // ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement ); + } catch (G4HadronicException& aE) { G4ExceptionDescription ed; aE.Report(ed); - ed << "Target element "<GetName()<<" Z= " - << targetNucleus.GetZ_asInt() << " A= " - << targetNucleus.GetA_asInt() << G4endl; - DumpState(aTrack,"ChooseHadronicInteraction",ed); + ed << "Target element " << anElement->GetName() << " Z= " << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack, "ChooseHadronicInteraction", ed); ed << " No HadronicInteraction found out" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had005", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had005", FatalException, ed); } // Initialize the hadronic projectile from the track @@ -152,69 +125,53 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) G4HadFinalState* result = 0; G4int reentryCount = 0; - - do - { - try - { + do { + try { // Call the interaction - result = theInteraction->ApplyYourself( thePro, targetNucleus); + result = theInteraction->ApplyYourself(thePro, targetNucleus); ++reentryCount; - } - catch(G4HadronicException & aR) - { + } catch (G4HadronicException& aR) { G4ExceptionDescription ed; aR.Report(ed); ed << "Call for " << theInteraction->GetModelName() << G4endl; - ed << "Target element "<GetName()<<" Z= " - << targetNucleus.GetZ_asInt() - << " A= " << targetNucleus.GetA_asInt() << G4endl; - DumpState(aTrack,"ApplyYourself",ed); + ed << "Target element " << anElement->GetName() << " Z= " << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack, "ApplyYourself", ed); ed << " ApplyYourself failed" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, ed); } - - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Call for " << theInteraction->GetModelName() - << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "Call for " << theInteraction->GetModelName() << std::endl; edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Target element "<< anElement->GetName() - << " Z=" << targetNucleus.GetZ_asInt() - << " A=" << targetNucleus.GetA_asInt() - << std::endl; + << "Target element " << anElement->GetName() << " Z=" << targetNucleus.GetZ_asInt() + << " A=" << targetNucleus.GetA_asInt() << std::endl; edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "Nr of secondaries: " << result->GetNumberOfSecondaries() << std::endl - << "Momentum change and E deeposit: " << result->GetMomentumChange() << " " << result->GetLocalEnergyDeposit() << std::endl - << "Track position and vertex: " << aTrack.GetPosition() << " " << aTrack.GetVertexPosition() << std::endl; + << "Nr of secondaries: " << result->GetNumberOfSecondaries() << std::endl + << "Momentum change and E deeposit: " << result->GetMomentumChange() << " " << result->GetLocalEnergyDeposit() + << std::endl + << "Track position and vertex: " << aTrack.GetPosition() << " " << aTrack.GetVertexPosition() << std::endl; float r = aTrack.GetPosition().perp(); float z = fabs(aTrack.GetPosition().z()); edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "In tracker volume? " - << (r<(100*cm) && z<(200*cm)? " YES! " : " NO! ") - << "r=" << r/cm << " z=" << z/cm << std::endl; + << "In tracker volume? " << (r < (100 * cm) && z < (200 * cm) ? " YES! " : " NO! ") << "r=" << r / cm + << " z=" << z / cm << std::endl; // Check the result for catastrophic energy non-conservation - result = CheckResult(thePro,targetNucleus, result); - if(reentryCount>100) { + result = CheckResult(thePro, targetNucleus, result); + if (reentryCount > 100) { G4ExceptionDescription ed; ed << "Call for " << theInteraction->GetModelName() << G4endl; - ed << "Target element "<GetName()<<" Z= " - << targetNucleus.GetZ_asInt() - << " A= " << targetNucleus.GetA_asInt() << G4endl; - DumpState(aTrack,"ApplyYourself",ed); + ed << "Target element " << anElement->GetName() << " Z= " << targetNucleus.GetZ_asInt() + << " A= " << targetNucleus.GetA_asInt() << G4endl; + DumpState(aTrack, "ApplyYourself", ed); ed << " ApplyYourself does not completed after 100 attempts" << G4endl; - G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, - ed); + G4Exception("G4SQInelasticProcess::PostStepDoIt", "had006", FatalException, ed); } - } - while(!result); + } while (!result); - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "=== Anti-sexaquark interaction succeeded!" << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "=== Anti-sexaquark interaction succeeded!" << std::endl; result->SetTrafoToLab(thePro.GetTrafoToLab()); ClearNumberOfInteractionLengthLeft(); @@ -227,67 +184,58 @@ G4SQInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) return theTotalResult; } +G4HadFinalState* G4SQInelasticProcess::CheckResult(const G4HadProjectile& aPro, + const G4Nucleus& aNucleus, + G4HadFinalState* result) { + // check for catastrophic energy non-conservation, to re-sample the interaction -G4HadFinalState* G4SQInelasticProcess::CheckResult(const G4HadProjectile & aPro,const G4Nucleus &aNucleus, G4HadFinalState * result) -{ - // check for catastrophic energy non-conservation, to re-sample the interaction - - G4HadronicInteraction * theModel = GetHadronicInteractionList()[0]; - - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - " << theModel << std::endl; - - G4double nuclearMass(0); - if (theModel){ - - // Compute final-state total energy - G4double finalE(0.); - G4int nSec = result->GetNumberOfSecondaries(); - - nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(), - aNucleus.GetZ_asInt()); - if (result->GetStatusChange() != stopAndKill) { - // Interaction didn't complete, returned "do nothing" state => reset nucleus - // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus - finalE=result->GetLocalEnergyDeposit() + - aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange(); - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - interaction not complete: " << finalE << std::endl; - if( nSec == 0 ){ - // Since there are no secondaries, there is no recoil nucleus. - // To check energy balance we must neglect the initial nucleus too. - nuclearMass=0.0; - } - } - for (G4int i = 0; i < nSec; i++) { - finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy(); - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - secondary pdgId / E : " - << result->GetSecondary(i)->GetParticle()->GetPDGcode() << "\t" - << result->GetSecondary(i)->GetParticle()->GetTotalEnergy() / GeV - << std::endl; - } - G4double deltaE = nuclearMass + aPro.GetTotalEnergy() - finalE; - edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - Total E: " << finalE / GeV << std::endl; + G4HadronicInteraction* theModel = GetHadronicInteractionList()[0]; + + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "checkresult - " << theModel << std::endl; + + G4double nuclearMass(0); + if (theModel) { + // Compute final-state total energy + G4double finalE(0.); + G4int nSec = result->GetNumberOfSecondaries(); + + nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(), aNucleus.GetZ_asInt()); + if (result->GetStatusChange() != stopAndKill) { + // Interaction didn't complete, returned "do nothing" state => reset nucleus + // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus + finalE = result->GetLocalEnergyDeposit() + aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange(); edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") - << "checkresult - Energy balance: " << deltaE / GeV << std::endl; - - std::pair checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute) - if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){ - // do not delete result, this is a pointer to a data member; - G4ExceptionDescription desc; - desc << "Warning: Bad energy non-conservation detected, will " - << (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl - << " Process / Model: " << GetProcessName()<< " / " << theModel->GetModelName() << G4endl - << " Primary: " << aPro.GetDefinition()->GetParticleName() - << " (" << aPro.GetDefinition()->GetPDGEncoding() << ")," - << " E= " << aPro.Get4Momentum().e() - << ", target nucleus (" << aNucleus.GetZ_asInt() << ","<< aNucleus.GetA_asInt() << ")" << G4endl - << " E(initial - final) = " << deltaE << " MeV." << G4endl; - G4Exception("G4SQInelasticProcess:CheckResult()", "had012", epReportLevel<0 ? EventMustBeAborted : JustWarning,desc); + << "checkresult - interaction not complete: " << finalE << std::endl; + if (nSec == 0) { + // Since there are no secondaries, there is no recoil nucleus. + // To check energy balance we must neglect the initial nucleus too. + nuclearMass = 0.0; } - } - return result; + } + for (G4int i = 0; i < nSec; i++) { + finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy(); + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") + << "checkresult - secondary pdgId / E : " << result->GetSecondary(i)->GetParticle()->GetPDGcode() << "\t" + << result->GetSecondary(i)->GetParticle()->GetTotalEnergy() / GeV << std::endl; + } + G4double deltaE = nuclearMass + aPro.GetTotalEnergy() - finalE; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "checkresult - Total E: " << finalE / GeV << std::endl; + edm::LogInfo("G4SQInelasticProcess::PostStepDoIt") << "checkresult - Energy balance: " << deltaE / GeV << std::endl; + + std::pair checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute) + if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first * aPro.GetKineticEnergy()) { + // do not delete result, this is a pointer to a data member; + G4ExceptionDescription desc; + desc << "Warning: Bad energy non-conservation detected, will " + << (epReportLevel < 0 ? "abort the event" : "re-sample the interaction") << G4endl + << " Process / Model: " << GetProcessName() << " / " << theModel->GetModelName() << G4endl + << " Primary: " << aPro.GetDefinition()->GetParticleName() << " (" << aPro.GetDefinition()->GetPDGEncoding() + << ")," + << " E= " << aPro.Get4Momentum().e() << ", target nucleus (" << aNucleus.GetZ_asInt() << "," + << aNucleus.GetA_asInt() << ")" << G4endl << " E(initial - final) = " << deltaE << " MeV." << G4endl; + G4Exception( + "G4SQInelasticProcess:CheckResult()", "had012", epReportLevel < 0 ? EventMustBeAborted : JustWarning, desc); + } + } + return result; } - diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc index 6faee989be02f..3e9f81c26643c 100644 --- a/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcess.cc @@ -7,58 +7,43 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" - - - -G4SQLoopProcess::G4SQLoopProcess(const G4String& name, G4ProcessType type) - : G4VContinuousProcess(name, type) -{ +G4SQLoopProcess::G4SQLoopProcess(const G4String& name, G4ProcessType type) : G4VContinuousProcess(name, type) { fParticleChange = new G4ParticleChange(); } +G4SQLoopProcess::~G4SQLoopProcess() { delete fParticleChange; } -G4SQLoopProcess::~G4SQLoopProcess() -{ - delete fParticleChange; -} - - -G4VParticleChange* G4SQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) -{ - - if(track.GetPosition()==posini) +G4VParticleChange* G4SQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) { + if (track.GetPosition() == posini) edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") - << "G4SQLoopProcess::AlongStepDoIt: G4SQLoopProcess::AlongStepDoIt MomentumDirection " << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition()/cm << " trackId " << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime()/ns << " TotalEnergy: " << track.GetTotalEnergy()/GeV << " Velocity " << track.GetVelocity()/m/ns << std::endl; + << "G4SQLoopProcess::AlongStepDoIt: G4SQLoopProcess::AlongStepDoIt MomentumDirection " + << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition() / cm << " trackId " + << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime() / ns + << " TotalEnergy: " << track.GetTotalEnergy() / GeV << " Velocity " << track.GetVelocity() / m / ns + << std::endl; fParticleChange->Clear(); fParticleChange->Initialize(track); fParticleChange->ProposeWeight(track.GetWeight()); //Sbar not passing the following criteria are not of interest. They will not be reconstructable. A cut like this is required otherwise you will get Sbar infinitely looping. - if(fabs(track.GetMomentumDirection().eta())>999. || fabs(track.GetPosition().z()) > 160*centimeter){ - edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") - << "Particle getting killed because too large z"<< std::endl; + if (fabs(track.GetMomentumDirection().eta()) > 999. || fabs(track.GetPosition().z()) > 160 * centimeter) { + edm::LogInfo("G4SQLoopProcess::AlongStepDoIt") << "Particle getting killed because too large z" << std::endl; fParticleChange->ProposeTrackStatus(fStopAndKill); } return fParticleChange; } - -G4double G4SQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4double currentMinimumStep, G4double& proposedSafety, G4GPILSelection* selection) -{ - return 1.*centimeter; +G4double G4SQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4double currentMinimumStep, + G4double& proposedSafety, + G4GPILSelection* selection) { + return 1. * centimeter; } - -G4double G4SQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double , G4double , G4double& ) -{ - return 1.*centimeter; // seems irrelevant +G4double G4SQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double, G4double, G4double&) { + return 1. * centimeter; // seems irrelevant } - -void G4SQLoopProcess::StartTracking(G4Track * aTrack) -{ - posini = aTrack->GetPosition(); -} - - +void G4SQLoopProcess::StartTracking(G4Track* aTrack) { posini = aTrack->GetPosition(); } diff --git a/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc index 85d51fac962f1..9e8b2fadc9714 100644 --- a/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc +++ b/SimG4Core/CustomPhysics/src/G4SQLoopProcessDiscr.cc @@ -7,38 +7,30 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" - G4SQLoopProcessDiscr::G4SQLoopProcessDiscr(double mass, const G4String& name, G4ProcessType type) - : G4VDiscreteProcess(name, type) -{ + : G4VDiscreteProcess(name, type) { fParticleChange = new G4ParticleChange(); fParticleChange->ClearDebugFlag(); GenMass = mass; } +G4SQLoopProcessDiscr::~G4SQLoopProcessDiscr() { delete fParticleChange; } -G4SQLoopProcessDiscr::~G4SQLoopProcessDiscr() -{ - delete fParticleChange; -} - - -G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) -{ - - G4Track * mytr = const_cast(&track); - mytr->SetPosition(posini); - if(mytr->GetGlobalTime()/ns>4990) +G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) { + G4Track* mytr = const_cast(&track); + mytr->SetPosition(posini); + if (mytr->GetGlobalTime() / ns > 4990) edm::LogWarning("G4SQLoopProcess::AlongStepDoIt") - << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl; + << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl; fParticleChange->Clear(); fParticleChange->Initialize(track); //adding secondary antiS - fParticleChange->SetNumberOfSecondaries(1); - G4DynamicParticle* replacementParticle= new G4DynamicParticle(G4AntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy()); - fParticleChange->AddSecondary(replacementParticle,globaltimeini); + fParticleChange->SetNumberOfSecondaries(1); + G4DynamicParticle* replacementParticle = + new G4DynamicParticle(G4AntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy()); + fParticleChange->AddSecondary(replacementParticle, globaltimeini); //killing original AntiS fParticleChange->ProposeTrackStatus(fStopAndKill); @@ -54,29 +46,25 @@ G4VParticleChange* G4SQLoopProcessDiscr::PostStepDoIt(const G4Track& track, cons return fParticleChange; } - -G4double G4SQLoopProcessDiscr::PostStepGetPhysicalInteractionLength(const G4Track& track, G4double previousStepSize, G4ForceCondition* condition) -{ - *condition = NotForced; - G4double intLength = DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position - G4Track * mytr = const_cast(&track); - if(sqrt(pow(mytr->GetPosition().rho(),2))>2.45*centimeter){//this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed -// updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018 - intLength = 0.0;//0 interaction length means particle will directly interact. - } +G4double G4SQLoopProcessDiscr::PostStepGetPhysicalInteractionLength(const G4Track& track, + G4double previousStepSize, + G4ForceCondition* condition) { + *condition = NotForced; + G4double intLength = + DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position + G4Track* mytr = const_cast(&track); + if (sqrt(pow(mytr->GetPosition().rho(), 2)) > + 2.45 * + centimeter) { //this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed + // updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018 + intLength = 0.0; //0 interaction length means particle will directly interact. + } return intLength; } -G4double G4SQLoopProcessDiscr::GetMeanFreePath(const G4Track&,G4double, - G4ForceCondition*) -{ - return DBL_MAX; -} +G4double G4SQLoopProcessDiscr::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*) { return DBL_MAX; } - -void G4SQLoopProcessDiscr::StartTracking(G4Track * aTrack) -{ +void G4SQLoopProcessDiscr::StartTracking(G4Track* aTrack) { posini = aTrack->GetPosition(); globaltimeini = aTrack->GetGlobalTime(); - } diff --git a/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc index 6ed99739e5148..2daa6ae26e722 100644 --- a/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc +++ b/SimG4Core/CustomPhysics/src/G4SQNeutronAnnih.cc @@ -11,271 +11,208 @@ #include "SimG4Core/CustomPhysics/interface/G4SQNeutronAnnih.h" #include "SimG4Core/CustomPhysics/interface/G4SQ.h" +G4SQNeutronAnnih::G4SQNeutronAnnih(double mass) : G4HadronicInteraction("SexaQuark-neutron annihilation") { + SetMinEnergy(0.0 * GeV); + SetMaxEnergy(100. * TeV); -G4SQNeutronAnnih::G4SQNeutronAnnih(double mass) : G4HadronicInteraction("SexaQuark-neutron annihilation") -{ - SetMinEnergy( 0.0*GeV ); - SetMaxEnergy( 100.*TeV ); - - theSQ = G4SQ::SQ(mass); - theK0S = G4KaonZeroShort::KaonZeroShort(); + theSQ = G4SQ::SQ(mass); + theK0S = G4KaonZeroShort::KaonZeroShort(); theAntiL = G4AntiLambda::AntiLambda(); - theProton = G4Proton::Proton();//proton only used when the particle which the sexaquark hits is a deutereon and the neutron dissapears, so what stays behind is a proton + theProton = G4Proton:: + Proton(); //proton only used when the particle which the sexaquark hits is a deutereon and the neutron dissapears, so what stays behind is a proton } - -G4SQNeutronAnnih::~G4SQNeutronAnnih() -{} - - +G4SQNeutronAnnih::~G4SQNeutronAnnih() {} //9Be momentum distribution from Jan Ryckebusch -G4double G4SQNeutronAnnih::momDistr(G4double x_in){ - -const int n_entries = 50; - -G4double CDF_k[n_entries] = { -0, -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8, -0.9, -1, -1.1, -1.2, -1.3, -1.4, -1.5, -1.6, -1.7, -1.8, -1.9, -2, -2.1, -2.2, -2.3, -2.4, -2.5, -2.6, -2.7, -2.8, -2.9, -3, -3.1, -3.2, -3.3, -3.4, -3.5, -3.6, -3.7, -3.8, -3.9, -4., -4.1, -4.2, -4.3, -4.4, -4.5, -4.6, -4.7, -4.8, -4.9 -}; - -G4double x[n_entries] = { -0, -0.0038033182, -0.0187291764, -0.0510409777, -0.1048223609, -0.1807862863, -0.2756514534, -0.3825832103, -0.4926859745, -0.5970673837, -0.6887542272, -0.7637748784, -0.8212490273, -0.8627259608, -0.8911605331, -0.9099115186, -0.9220525854, -0.9300190818, -0.9355376091, -0.9397242185, -0.9432387722, -0.946438928, -0.9495023924, -0.9525032995, -0.9554669848, -0.9583936672, -0.9612770117, -0.9641067202, -0.9668727859, -0.9695676121, -0.9721815799, -0.9747092981, -0.9771426396, -0.9794740235, -0.9816956807, -0.9838003583, -0.9857816165, -0.9876331761, -0.9893513365, -0.9909333198, -0.992378513, -0.9936885054, -0.9948665964, -0.9959179448, -0.9968491104, -0.9976680755, -0.9983832508, -0.9990041784, -0.9995400073, -1 -}; +G4double G4SQNeutronAnnih::momDistr(G4double x_in) { + const int n_entries = 50; + + G4double CDF_k[n_entries] = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, + 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, + 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4., 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9}; + + G4double x[n_entries] = {0, + 0.0038033182, + 0.0187291764, + 0.0510409777, + 0.1048223609, + 0.1807862863, + 0.2756514534, + 0.3825832103, + 0.4926859745, + 0.5970673837, + 0.6887542272, + 0.7637748784, + 0.8212490273, + 0.8627259608, + 0.8911605331, + 0.9099115186, + 0.9220525854, + 0.9300190818, + 0.9355376091, + 0.9397242185, + 0.9432387722, + 0.946438928, + 0.9495023924, + 0.9525032995, + 0.9554669848, + 0.9583936672, + 0.9612770117, + 0.9641067202, + 0.9668727859, + 0.9695676121, + 0.9721815799, + 0.9747092981, + 0.9771426396, + 0.9794740235, + 0.9816956807, + 0.9838003583, + 0.9857816165, + 0.9876331761, + 0.9893513365, + 0.9909333198, + 0.992378513, + 0.9936885054, + 0.9948665964, + 0.9959179448, + 0.9968491104, + 0.9976680755, + 0.9983832508, + 0.9990041784, + 0.9995400073, + 1}; //now interpolate the above points for x_in G4double result = 9999; - for(int i = 0; i < n_entries; i++){ - if(x[i] > x_in) { - result = (CDF_k[i]-CDF_k[i-1])/(x[i]-x[i-1])*(x_in-x[i-1])+CDF_k[i-1]; - break; + for (int i = 0; i < n_entries; i++) { + if (x[i] > x_in) { + result = (CDF_k[i] - CDF_k[i - 1]) / (x[i] - x[i - 1]) * (x_in - x[i - 1]) + CDF_k[i - 1]; + break; } - } + } //ROOT::Math::Interpolator inter(n_entries, ROOT::Math::Interpolation::kAKIMA); //inter.SetData(n_entries,x,CDF_k); //result = inter.Eval(x_in); return result; //return 1; - } - - - - -G4HadFinalState* G4SQNeutronAnnih::ApplyYourself( - const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) -{ +G4HadFinalState* G4SQNeutronAnnih::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& targetNucleus) { theParticleChange.Clear(); const G4HadProjectile* aParticle = &aTrack; G4double ekin = aParticle->GetKineticEnergy(); - G4int A = targetNucleus.GetA_asInt(); G4int Z = targetNucleus.GetZ_asInt(); - G4double m_K0S = G4KaonZeroShort::KaonZeroShort()->GetPDGMass(); - G4double m_L = G4AntiLambda::AntiLambda()->GetPDGMass(); + G4double m_L = G4AntiLambda::AntiLambda()->GetPDGMass(); - G4cout << "----> G4SQNeutronAnnih <-----" << G4endl; + G4cout << "----> G4SQNeutronAnnih <-----" << G4endl; //G4double plab = aParticle->GetTotalMomentum(); -// G4cout << "G4SQNeutronAnnih: Incident particle p (GeV), total Energy (GeV), particle name, eta =" -// << plab/GeV << " " -// << aParticle->GetTotalEnergy()/GeV << " " -// << aParticle->GetDefinition()->GetParticleName() << " " -// << aParticle->Get4Momentum() << G4endl; + // G4cout << "G4SQNeutronAnnih: Incident particle p (GeV), total Energy (GeV), particle name, eta =" + // << plab/GeV << " " + // << aParticle->GetTotalEnergy()/GeV << " " + // << aParticle->GetDefinition()->GetParticleName() << " " + // << aParticle->Get4Momentum() << G4endl; // Scattered particle referred to axis of incident particle //const G4ParticleDefinition* theParticle = aParticle->GetDefinition(); //G4int projPDG = theParticle->GetPDGEncoding(); -// if (verboseLevel > 1) -// G4cout << "G4SQNeutronAnnih: for " << theParticle->GetParticleName() -// << " PDGcode= " << projPDG << " on nucleus Z= " << Z -// << " A= " << A << " N= " << N -// << G4endl; + // if (verboseLevel > 1) + // G4cout << "G4SQNeutronAnnih: for " << theParticle->GetParticleName() + // << " PDGcode= " << projPDG << " on nucleus Z= " << Z + // << " A= " << A << " N= " << N + // << G4endl; G4LorentzVector lv1 = aParticle->Get4Momentum(); - G4cout << "The neutron Fermi momentum (mag, x, y, z) " << targetNucleus.GetFermiMomentum().mag()/MeV << " " << targetNucleus.GetFermiMomentum().x()/MeV << " " << targetNucleus.GetFermiMomentum().y()/MeV << " " << targetNucleus.GetFermiMomentum().z()/MeV << std::endl; + G4cout << "The neutron Fermi momentum (mag, x, y, z) " << targetNucleus.GetFermiMomentum().mag() / MeV << " " + << targetNucleus.GetFermiMomentum().x() / MeV << " " << targetNucleus.GetFermiMomentum().y() / MeV << " " + << targetNucleus.GetFermiMomentum().z() / MeV << std::endl; //calculate fermi momentum - G4double k_neutron = momDistr(G4UniformRand()); - G4double momentum_neutron = 0.1973*GeV*k_neutron; - - G4double theta_neutron = TMath::ACos(2*G4UniformRand()-1); - G4double phi_neutron = 2.*TMath::Pi()*G4UniformRand(); + G4double k_neutron = momDistr(G4UniformRand()); + G4double momentum_neutron = 0.1973 * GeV * k_neutron; - G4double p_neutron_x = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Cos(phi_neutron); - G4double p_neutron_y = momentum_neutron*TMath::Sin(theta_neutron)*TMath::Sin(phi_neutron); - G4double p_neutron_z = momentum_neutron*TMath::Cos(theta_neutron); + G4double theta_neutron = TMath::ACos(2 * G4UniformRand() - 1); + G4double phi_neutron = 2. * TMath::Pi() * G4UniformRand(); + G4double p_neutron_x = momentum_neutron * TMath::Sin(theta_neutron) * TMath::Cos(phi_neutron); + G4double p_neutron_y = momentum_neutron * TMath::Sin(theta_neutron) * TMath::Sin(phi_neutron); + G4double p_neutron_z = momentum_neutron * TMath::Cos(theta_neutron); //G4LorentzVector lv0(targetNucleus.GetFermiMomentum(), sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + targetNucleus.GetFermiMomentum().mag2() ) ); - G4LorentzVector lv0(p_neutron_x, p_neutron_y, p_neutron_z, sqrt( pow(G4Neutron::Neutron()->GetPDGMass(),2) + momentum_neutron*momentum_neutron ) ); + G4LorentzVector lv0(p_neutron_x, + p_neutron_y, + p_neutron_z, + sqrt(pow(G4Neutron::Neutron()->GetPDGMass(), 2) + momentum_neutron * momentum_neutron)); //const G4Nucleus* aNucleus = &targetNucleus; G4double BENeutronInNucleus = 0; - if(A != 0)BENeutronInNucleus = G4NucleiProperties::GetBindingEnergy( A, Z)/(A); + if (A != 0) + BENeutronInNucleus = G4NucleiProperties::GetBindingEnergy(A, Z) / (A); - G4cout << "BE of nucleon in the nucleus (GeV): " << BENeutronInNucleus/GeV << G4endl; + G4cout << "BE of nucleon in the nucleus (GeV): " << BENeutronInNucleus / GeV << G4endl; - G4LorentzVector lvBE(0,0,0,BENeutronInNucleus/GeV); - G4LorentzVector lv = lv0 + lv1 - lvBE; + G4LorentzVector lvBE(0, 0, 0, BENeutronInNucleus / GeV); + G4LorentzVector lv = lv0 + lv1 - lvBE; // kinematiacally impossible ? G4double etot = lv0.e() + lv1.e() - lvBE.e(); - if(etot < theK0S->GetPDGMass() + theAntiL->GetPDGMass()) { + if (etot < theK0S->GetPDGMass() + theAntiL->GetPDGMass()) { theParticleChange.SetEnergyChange(ekin); theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit()); return &theParticleChange; } - float newIonMass = targetNucleus.AtomicMass(A-1,Z)*931.5*MeV; ; - G4LorentzVector nlvIon(0,0,0,newIonMass); + float newIonMass = targetNucleus.AtomicMass(A - 1, Z) * 931.5 * MeV; + ; + G4LorentzVector nlvIon(0, 0, 0, newIonMass); - G4double theta_KS0_star = TMath::ACos(2*G4UniformRand()-1); - G4double phi_KS0_star = 2.*TMath::Pi()*G4UniformRand(); + G4double theta_KS0_star = TMath::ACos(2 * G4UniformRand() - 1); + G4double phi_KS0_star = 2. * TMath::Pi() * G4UniformRand(); - G4double p_K0S_star_x = TMath::Sin(theta_KS0_star)*TMath::Cos(phi_KS0_star); - G4double p_K0S_star_y = TMath::Sin(theta_KS0_star)*TMath::Sin(phi_KS0_star); + G4double p_K0S_star_x = TMath::Sin(theta_KS0_star) * TMath::Cos(phi_KS0_star); + G4double p_K0S_star_y = TMath::Sin(theta_KS0_star) * TMath::Sin(phi_KS0_star); G4double p_K0S_star_z = TMath::Cos(theta_KS0_star); - G4ThreeVector p(p_K0S_star_x,p_K0S_star_y,p_K0S_star_z); + G4ThreeVector p(p_K0S_star_x, p_K0S_star_y, p_K0S_star_z); double m0 = lv.m(); - double m0_2 = m0*m0; - double m1_2 = m_K0S*m_K0S; - double m2_2 = m_L*m_L; + double m0_2 = m0 * m0; + double m1_2 = m_K0S * m_K0S; + double m2_2 = m_L * m_L; - p *= 0.5/m0 * sqrt ( m0_2*m0_2 + m1_2*m1_2 + m2_2*m2_2 - 2*m0_2*m1_2 - 2*m0_2*m2_2 - 2*m1_2*m2_2); + p *= 0.5 / m0 * sqrt(m0_2 * m0_2 + m1_2 * m1_2 + m2_2 * m2_2 - 2 * m0_2 * m1_2 - 2 * m0_2 * m2_2 - 2 * m1_2 * m2_2); double p2 = p.mag2(); - G4LorentzVector nlvK0S( p, sqrt (p2 + m1_2)); - G4LorentzVector nlvAntiL(-p, sqrt (p2 + m2_2)); + G4LorentzVector nlvK0S(p, sqrt(p2 + m1_2)); + G4LorentzVector nlvAntiL(-p, sqrt(p2 + m2_2)); // Boost out of the rest frame. - nlvK0S.boost (lv.boostVector ()); - nlvAntiL.boost (lv.boostVector ()); + nlvK0S.boost(lv.boostVector()); + nlvAntiL.boost(lv.boostVector()); // now move to implement the interaction theParticleChange.SetStatusChange(stopAndKill); //theParticleChange.SetEnergyChange(ekin); // was 0.0 - - - G4DynamicParticle * aSec1 = new G4DynamicParticle(theK0S, nlvK0S); + G4DynamicParticle* aSec1 = new G4DynamicParticle(theK0S, nlvK0S); theParticleChange.AddSecondary(aSec1); - G4DynamicParticle * aSec2 = new G4DynamicParticle(theAntiL, nlvAntiL); + G4DynamicParticle* aSec2 = new G4DynamicParticle(theAntiL, nlvAntiL); theParticleChange.AddSecondary(aSec2); const G4ParticleDefinition* theRemainingNucleusDef = theProton; - if(A != 1) theRemainingNucleusDef = G4IonTable::GetIonTable()->GetIon(Z,A-1); - G4DynamicParticle * aSec3 = new G4DynamicParticle(theRemainingNucleusDef, nlvIon); + if (A != 1) + theRemainingNucleusDef = G4IonTable::GetIonTable()->GetIon(Z, A - 1); + G4DynamicParticle* aSec3 = new G4DynamicParticle(theRemainingNucleusDef, nlvIon); theParticleChange.AddSecondary(aSec3); // return as is; we don't care about what happens to the nucleus return &theParticleChange; - } - From e8ae2ea8f708be19a317f4ce8872dba27601714f Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Mon, 20 May 2024 11:13:47 +0200 Subject: [PATCH 048/301] Extend the SoA unit test to check for out-of-range access --- DataFormats/SoATemplate/test/SoAUnitTests.cc | 37 +++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/DataFormats/SoATemplate/test/SoAUnitTests.cc b/DataFormats/SoATemplate/test/SoAUnitTests.cc index b0c27f85a3322..a7f469618dfb2 100644 --- a/DataFormats/SoATemplate/test/SoAUnitTests.cc +++ b/DataFormats/SoATemplate/test/SoAUnitTests.cc @@ -2,7 +2,8 @@ #include #define CATCH_CONFIG_MAIN -#include "catch.hpp" +#include + #include "DataFormats/SoATemplate/interface/SoALayout.h" // clang-format off @@ -16,11 +17,16 @@ GENERATE_SOA_LAYOUT(SimpleLayoutTemplate, using SimpleLayout = SimpleLayoutTemplate<>; TEST_CASE("SoATemplate") { + // number of elements const std::size_t slSize = 10; + // size in bytes const std::size_t slBufferSize = SimpleLayout::computeDataSize(slSize); + // memory buffer aligned according to the layout requirements std::unique_ptr slBuffer{ reinterpret_cast(aligned_alloc(SimpleLayout::alignment, slBufferSize)), std::free}; + // SoA layout SimpleLayout sl{slBuffer.get(), slSize}; + SECTION("Row wide copies, row") { SimpleLayout::View slv{sl}; SimpleLayout::ConstView slcv{sl}; @@ -100,4 +106,33 @@ TEST_CASE("SoATemplate") { t += tx; } } + + SECTION("Range checking View") { + // Enable range checking + using View = SimpleLayout::ViewTemplate; + View slv{sl}; + int underflow = -1; + int overflow = slv.metadata().size(); + // Check for under-and overflow in the row accessor + REQUIRE_THROWS_AS(slv[underflow], std::out_of_range); + REQUIRE_THROWS_AS(slv[overflow], std::out_of_range); + // Check for under-and overflow in the element accessors + REQUIRE_THROWS_AS(slv.x(underflow), std::out_of_range); + REQUIRE_THROWS_AS(slv.x(overflow), std::out_of_range); + } + + SECTION("Range checking ConstView") { + // Enable range checking + using ConstView = + SimpleLayout::ConstViewTemplate; + ConstView slcv{sl}; + int underflow = -1; + int overflow = slcv.metadata().size(); + // Check for under-and overflow in the row accessor + REQUIRE_THROWS_AS(slcv[underflow], std::out_of_range); + REQUIRE_THROWS_AS(slcv[overflow], std::out_of_range); + // Check for under-and overflow in the element accessors + REQUIRE_THROWS_AS(slcv.x(underflow), std::out_of_range); + REQUIRE_THROWS_AS(slcv.x(overflow), std::out_of_range); + } } From 41ec1c45a18a90de5acab6986708253f5059d11e Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 21 May 2024 11:56:10 -0500 Subject: [PATCH 049/301] bin L1TQ variable --- .../L1TrackTrigger/interface/TTTrack.h | 1 + .../interface/TTTrack_TrackWord.h | 14 +- .../L1TrackTrigger/src/TTTrack_TrackWord.cc | 6 +- .../plugins/L1FPGATrackProducer.cc | 7 +- .../plugins/ProducerKFout.cc | 16 ++- .../TrackTrigger/interface/L1TrackQuality.h | 41 ++---- .../python/TrackQualityParams_cfi.py | 17 +-- L1Trigger/TrackTrigger/src/L1TrackQuality.cc | 128 ++---------------- 8 files changed, 54 insertions(+), 176 deletions(-) diff --git a/DataFormats/L1TrackTrigger/interface/TTTrack.h b/DataFormats/L1TrackTrigger/interface/TTTrack.h index 19ceec4c53453..bbc9147c134d3 100644 --- a/DataFormats/L1TrackTrigger/interface/TTTrack.h +++ b/DataFormats/L1TrackTrigger/interface/TTTrack.h @@ -372,6 +372,7 @@ double TTTrack::chi2ZRed() const { return theChi2_Z_ / (theStubRefs.size() - 2.); } +/// prompt track quality MVA template double TTTrack::trkMVA1() const { return theTrkMVA1_; diff --git a/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h b/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h index f08b0100fe1d6..e191bfd1aa79a 100644 --- a/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h +++ b/DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h @@ -103,8 +103,10 @@ class TTTrack_TrackWord { {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 20.0, 50.0}}; static constexpr std::array bendChi2Bins = { {0.0, 0.75, 1.0, 1.5, 2.25, 3.5, 5.0, 20.0}}; - static constexpr std::array mvaQualityBins = { - {0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.750, 0.875}}; + + // Bin edges for TQ MVA + static constexpr std::array tqMVABins = { + {0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.750, 0.875}}; // Sector constants static constexpr unsigned int nSectors = 9; @@ -144,7 +146,7 @@ class TTTrack_TrackWord { double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector); TTTrack_TrackWord(unsigned int valid, unsigned int rInv, @@ -226,8 +228,8 @@ class TTTrack_TrackWord { double getBendChi2() const { return bendChi2Bins[getBendChi2Bits()]; } unsigned int getHitPattern() const { return getHitPatternBits(); } unsigned int getNStubs() const { return countSetBits(getHitPatternBits()); } - double getMVAQuality() const { return mvaQualityBins[getMVAQualityBits()]; } - unsigned int getMVAOther() const { return getMVAOtherBits(); } + double getMVAQuality() const { return tqMVABins[getMVAQualityBits()]; } + double getMVAOther() const { return getMVAOtherBits(); } // ----------member functions (setters) ------------ void setTrackWord(unsigned int valid, @@ -239,7 +241,7 @@ class TTTrack_TrackWord { double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector); void setTrackWord(unsigned int valid, diff --git a/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc b/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc index f4428e0cf8d55..c76b77a587aeb 100644 --- a/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc +++ b/DataFormats/L1TrackTrigger/src/TTTrack_TrackWord.cc @@ -36,7 +36,7 @@ TTTrack_TrackWord::TTTrack_TrackWord(unsigned int valid, double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector) { setTrackWord(valid, momentum, POCA, rInv, chi2RPhi, chi2RZ, bendChi2, hitPattern, mvaQuality, mvaOther, sector); } @@ -66,7 +66,7 @@ void TTTrack_TrackWord::setTrackWord(unsigned int valid, double bendChi2, unsigned int hitPattern, double mvaQuality, - unsigned int mvaOther, + double mvaOther, unsigned int sector) { // first, derive quantities to be packed float rPhi = localPhi(momentum.phi(), sector); // this needs to be phi relative to the center of the sector @@ -85,7 +85,7 @@ void TTTrack_TrackWord::setTrackWord(unsigned int valid, chi2rz_t chi2RZ_ = getBin(chi2RZ, chi2RZBins); bendChi2_t bendChi2_ = getBin(bendChi2, bendChi2Bins); hit_t hitPattern_ = hitPattern; - qualityMVA_t mvaQuality_ = getBin(mvaQuality, mvaQualityBins); + qualityMVA_t mvaQuality_ = getBin(mvaQuality, tqMVABins); otherMVA_t mvaOther_ = mvaOther; // pack the track word diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 789ee15ba8cf1..d7fd496b1c152 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -739,7 +739,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe aTrack.setStubPtConsistency( StubPtConsistency::getConsistency(aTrack, theTrackerGeom, tTopo, settings_.bfield(), settings_.nHelixPar())); - // set TTTrack word first to allow Track Quality MVA to read variables: + // set track word before TQ MVA calculated which uses track word variables aTrack.setTrackWordBits(); if (trackQuality_) { @@ -751,7 +751,10 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe // trackQualityModel_->setBonusFeatures(hph.bonusFeatures()); // } - // set TTTrack word + // test track word + //aTrack.testTrackWordBits(); + + // set track word again to set MVA variable from TTTrack into track word aTrack.setTrackWordBits(); // test track word //aTrack.testTrackWordBits(); diff --git a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc index 3c23f8d342d08..62c098afba9b4 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/ProducerKFout.cc @@ -78,13 +78,14 @@ namespace trklet { int partialTrackWordBits_; - // Helper function to convert floating chi2 to chi2 bin + // Helper function to convert floating value to bin template unsigned int digitise(const T& bins, double value, double factor) { unsigned int bin = 0; for (unsigned int i = 0; i < bins.size() - 1; i++) { if (value * factor > bins[i] && value * factor <= bins[i + 1]) - bin = i; + break; + bin++; } return bin; } @@ -200,7 +201,7 @@ namespace trklet { StreamsTrack outputStreamsTracks(setup_->numRegions() * setup_->tfpNumChannel()); // Setup containers for track quality - float tempTQMVA = 0.0; + float tempTQMVAPreSig = 0.0; // Due to ap_fixed implementation in CMSSW this 10,5 must be specified at compile time, TODO make this a changeable parameter std::vector> trackQuality_inputs = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; @@ -295,10 +296,11 @@ namespace trklet { digitise(TTTrack_TrackWord::chi2RZBins, tempchi2rz, (double)setup_->kfoutchi2rzConv())}; // Run BDT emulation and package output into 3 bits - - tempTQMVA = trackQualityModel_->runEmulatedTQ(trackQuality_inputs); - tempTQMVA = std::trunc(tempTQMVA * ap_fixed_rescale); - TTBV tqMVA(digitise(tqBins_, tempTQMVA, 1.0), TTTrack_TrackWord::TrackBitWidths::kMVAQualitySize, false); + // output needs sigmoid transformation applied + tempTQMVAPreSig = trackQualityModel_->runEmulatedTQ(trackQuality_inputs); + TTBV tqMVA(digitise(L1TrackQuality::getTqMVAPreSigBins(), tempTQMVAPreSig, 1.0), + TTTrack_TrackWord::TrackBitWidths::kMVAQualitySize, + false); // Build 32 bit partial tracks for outputting in 64 bit packets // 12 + 3 + 7 + 3 + 6 diff --git a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h index 0d697687a812f..1107ed3e74fbb 100644 --- a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h +++ b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h @@ -20,7 +20,6 @@ C.Brown 28/07/20 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h" #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" -#include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h" #include #include "conifer.h" @@ -28,9 +27,6 @@ C.Brown 28/07/20 class L1TrackQuality { public: - // Enum class used for determining prediction behaviour in setL1TrackQuality - enum class QualityAlgorithm { Cut, GBDT, GBDT_cpp, NN, None }; - //Default Constructor L1TrackQuality(); @@ -49,36 +45,29 @@ class L1TrackQuality { // and a single output to be returned which is then used to fill the bits in the Track Word for situations // where a TTTrack datatype is unavailable to be passed to the track quality float runEmulatedTQ(std::vector> inputFeatures); - // To set private member data - void setCutParameters(std::string const& AlgorithmString, - float maxZ0, - float maxEta, - float chi2dofMax, - float bendchi2Max, - float minPt, - int nStubmin); - void setONNXModel(std::string const& AlgorithmString, - edm::FileInPath const& ONNXmodel, - std::string const& ONNXInputName, - std::vector const& featureNames); + void setModel(edm::FileInPath const& model, std::vector const& featureNames); void setBonusFeatures(std::vector bonusFeatures); + // TQ MVA bin conversions + static constexpr double invSigmoid(double value) { return -log(1. / value - 1.); } + static constexpr std::array getTqMVAPreSigBins() { + return {{-16., + invSigmoid(TTTrack_TrackWord::tqMVABins[1]), + invSigmoid(TTTrack_TrackWord::tqMVABins[2]), + invSigmoid(TTTrack_TrackWord::tqMVABins[3]), + invSigmoid(TTTrack_TrackWord::tqMVABins[4]), + invSigmoid(TTTrack_TrackWord::tqMVABins[5]), + invSigmoid(TTTrack_TrackWord::tqMVABins[6]), + invSigmoid(TTTrack_TrackWord::tqMVABins[7])}}; + } + private: // Private Member Data - QualityAlgorithm qualityAlgorithm_ = QualityAlgorithm::None; - edm::FileInPath ONNXmodel_; - std::string ONNXInputName_; + edm::FileInPath model_; std::vector featureNames_; - float maxZ0_; - float maxEta_; - float chi2dofMax_; - float bendchi2Max_; - float minPt_; - int nStubsmin_; bool useHPH_; std::vector bonusFeatures_; - std::unique_ptr runTime_; }; #endif diff --git a/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py b/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py index f5928d461da40..e1e8f6cdb5ec2 100644 --- a/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py +++ b/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py @@ -1,24 +1,11 @@ import FWCore.ParameterSet.Config as cms -TrackQualityParams = cms.PSet(qualityAlgorithm = cms.string("GBDT_cpp"), #None, Cut, NN, GBDT, GBDT_cpp - # This emulation GBDT is optimised for the HYBRID_NEWKF emulation and works with the emulation of the KF out module +TrackQualityParams = cms.PSet(# This emulation GBDT is optimised for the HYBRID_NEWKF emulation and works with the emulation of the KF out module # It is compatible with the HYBRID simulation and will give equivilant performance with this workflow - ONNXmodel = cms.FileInPath("L1Trigger/TrackTrigger/data/L1_TrackQuality_GBDT_emulation_digitized.json"), - # The ONNX model should be found at this path, if you want a local version of the model: - # git clone https://github.com/cms-data/L1Trigger-TrackTrigger.git L1Trigger/TrackTrigger/data - ONNXInputName = cms.string("feature_input"), + model = cms.FileInPath("L1Trigger/TrackTrigger/data/L1_TrackQuality_GBDT_emulation_digitized.json"), #Vector of strings of training features, in the order that the model was trained with featureNames = cms.vstring(["tanl", "z0_scaled", "bendchi2_bin", "nstub", "nlaymiss_interior", "chi2rphi_bin", "chi2rz_bin"]), - # Parameters for cut based classifier, optimized for L1 Track MET - # (Table 3.7 The Phase-2 Upgrade of the CMS Level-1 Trigger http://cds.cern.ch/record/2714892) - maxZ0 = cms.double ( 15. ) , # in cm - maxEta = cms.double ( 2.4 ) , - chi2dofMax = cms.double( 40. ), - bendchi2Max = cms.double( 2.4 ), - minPt = cms.double( 2. ), # in GeV - nStubsmin = cms.int32( 4 ), - tqemu_bins = cms.vint32( [-480, -62, -35, -16, 0, 16, 35, 62, 480] ), tqemu_TanlScale = cms.double( 128.0), tqemu_Z0Scale = cms.double( 64.0 ), ) diff --git a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc index f3472beab34b6..7296cb385e665 100644 --- a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc +++ b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc @@ -10,26 +10,9 @@ C.Brown & C.Savard 07/2020 L1TrackQuality::L1TrackQuality() {} L1TrackQuality::L1TrackQuality(const edm::ParameterSet& qualityParams) : useHPH_(false), bonusFeatures_() { - std::string AlgorithmString = qualityParams.getParameter("qualityAlgorithm"); // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers - if (AlgorithmString == "Cut") { - setCutParameters(AlgorithmString, - (float)qualityParams.getParameter("maxZ0"), - (float)qualityParams.getParameter("maxEta"), - (float)qualityParams.getParameter("chi2dofMax"), - (float)qualityParams.getParameter("bendchi2Max"), - (float)qualityParams.getParameter("minPt"), - qualityParams.getParameter("nStubsmin")); - } - - else { - setONNXModel(AlgorithmString, - qualityParams.getParameter("ONNXmodel"), - qualityParams.getParameter("ONNXInputName"), - qualityParams.getParameter>("featureNames")); - if ((AlgorithmString == "GBDT") || (AlgorithmString == "NN")) - runTime_ = std::make_unique(this->ONNXmodel_.fullPath()); - } + setModel(qualityParams.getParameter("model"), + qualityParams.getParameter>("featureNames")); } std::vector L1TrackQuality::featureTransform(TTTrack& aTrack, @@ -101,117 +84,28 @@ std::vector L1TrackQuality::featureTransform(TTTrack& aTrack) { - if (this->qualityAlgorithm_ == QualityAlgorithm::Cut) { - // Get Track parameters - float trk_pt = aTrack.momentum().perp(); - float trk_bend_chi2 = aTrack.stubPtConsistency(); - float trk_z0 = aTrack.z0(); - float trk_eta = aTrack.momentum().eta(); - float trk_chi2 = aTrack.chi2(); - const auto& stubRefs = aTrack.getStubRefs(); - int nStubs = stubRefs.size(); - - float classification = 0.0; // Default classification is 0 - - if (trk_pt >= this->minPt_ && abs(trk_z0) < this->maxZ0_ && abs(trk_eta) < this->maxEta_ && - trk_chi2 < this->chi2dofMax_ && trk_bend_chi2 < this->bendchi2Max_ && nStubs >= this->nStubsmin_) - classification = 1.0; - // Classification updated to 1 if conditions are met - - aTrack.settrkMVA1(classification); - } - - else if (this->qualityAlgorithm_ == QualityAlgorithm::GBDT_cpp) { - // load in bdt - conifer::BDT bdt(this->ONNXmodel_.fullPath()); - - // collect features and classify using bdt - std::vector inputs = featureTransform(aTrack, this->featureNames_); - std::vector output = bdt.decision_function(inputs); - aTrack.settrkMVA1(1. / (1. + exp(-output.at(0)))); // need logistic sigmoid fcn applied to xgb output - } - - else if ((this->qualityAlgorithm_ == QualityAlgorithm::NN) || (this->qualityAlgorithm_ == QualityAlgorithm::GBDT)) { - // Setup ONNX input and output names and arrays - std::vector ortinput_names; - std::vector ortoutput_names; - - cms::Ort::FloatArrays ortinput; - cms::Ort::FloatArrays ortoutputs; - - std::vector Transformed_features = featureTransform(aTrack, this->featureNames_); - // cms::Ort::ONNXRuntime runTime(this->ONNXmodel_.fullPath()); //Setup ONNX runtime - - ortinput_names.push_back(this->ONNXInputName_); - ortoutput_names = runTime_->getOutputNames(); - - //ONNX runtime recieves a vector of vectors of floats so push back the input - // vector of float to create a 1,1,21 ortinput - ortinput.push_back(Transformed_features); - - // batch_size 1 as only one set of transformed features is being processed - int batch_size = 1; - // Run classification - ortoutputs = runTime_->run(ortinput_names, ortinput, {}, ortoutput_names, batch_size); - - if (this->qualityAlgorithm_ == QualityAlgorithm::NN) { - aTrack.settrkMVA1(ortoutputs[0][0]); - } - - else if (this->qualityAlgorithm_ == QualityAlgorithm::GBDT) { - aTrack.settrkMVA1(ortoutputs[1][1]); - } - // Slight differences in the ONNX models of the GBDTs and NNs mean different - // indices of the ortoutput need to be accessed - } + // load in bdt + conifer::BDT bdt(this->model_.fullPath()); - else { - aTrack.settrkMVA1(-999); - } + // collect features and classify using bdt + std::vector inputs = featureTransform(aTrack, this->featureNames_); + std::vector output = bdt.decision_function(inputs); + aTrack.settrkMVA1(1. / (1. + exp(-output.at(0)))); } float L1TrackQuality::runEmulatedTQ(std::vector> inputFeatures) { // load in bdt - conifer::BDT, ap_fixed<10, 5>> bdt(this->ONNXmodel_.fullPath()); + conifer::BDT, ap_fixed<10, 5>> bdt(this->model_.fullPath()); // collect features and classify using bdt std::vector> output = bdt.decision_function(inputFeatures); return output.at(0).to_float(); // need logistic sigmoid fcn applied to xgb output } -void L1TrackQuality::setCutParameters(std::string const& AlgorithmString, - float maxZ0, - float maxEta, - float chi2dofMax, - float bendchi2Max, - float minPt, - int nStubmin) { - qualityAlgorithm_ = QualityAlgorithm::Cut; - maxZ0_ = maxZ0; - maxEta_ = maxEta; - chi2dofMax_ = chi2dofMax; - bendchi2Max_ = bendchi2Max; - minPt_ = minPt; - nStubsmin_ = nStubmin; -} - -void L1TrackQuality::setONNXModel(std::string const& AlgorithmString, - edm::FileInPath const& ONNXmodel, - std::string const& ONNXInputName, - std::vector const& featureNames) { +void L1TrackQuality::setModel(edm::FileInPath const& model, std::vector const& featureNames) { //Convert algorithm string to Enum class for track by track comparison - if (AlgorithmString == "NN") { - qualityAlgorithm_ = QualityAlgorithm::NN; - } else if (AlgorithmString == "GBDT") { - qualityAlgorithm_ = QualityAlgorithm::GBDT; - } else if (AlgorithmString == "GBDT_cpp") { - qualityAlgorithm_ = QualityAlgorithm::GBDT_cpp; - } else { - qualityAlgorithm_ = QualityAlgorithm::None; - } - ONNXmodel_ = ONNXmodel; - ONNXInputName_ = ONNXInputName; + model_ = model; featureNames_ = featureNames; } From de1c193254c5bf7e236f1282a171b499c59ee116 Mon Sep 17 00:00:00 2001 From: Sunil Dogra Date: Wed, 22 May 2024 03:14:20 +0200 Subject: [PATCH 050/301] Clean offline DQM of Photon smin triggers and adding DisplaedPhoton --- DQMOffline/Trigger/python/PhotonMonitor_cff.py | 13 +++++-------- .../analyses/hltExoticaDisplacedDiPhoton_cff.py | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/DQMOffline/Trigger/python/PhotonMonitor_cff.py b/DQMOffline/Trigger/python/PhotonMonitor_cff.py index 9d3ccdf44c41d..339ca9585c7f9 100644 --- a/DQMOffline/Trigger/python/PhotonMonitor_cff.py +++ b/DQMOffline/Trigger/python/PhotonMonitor_cff.py @@ -51,6 +51,10 @@ numGenericTriggerEventPSet = dict(hltPaths = ["HLT_Photon60_R9Id90_CaloIdL_IsoL_DisplacedIdL_PFHT350_v*"]) ) +CscCluster50_Photon20Unseeded = hltPhotonmonitoring.clone( + FolderName = 'HLT/EGM/Photon/CscCluster50_Photon20Unseeded/', + numGenericTriggerEventPSet = dict(hltPaths = ["HLT_CscCluster50_Photon20Unseeded_v*"]) +) from DQMOffline.Trigger.ObjMonitor_cfi import hltobjmonitoring @@ -108,6 +112,7 @@ + SinglePhoton165_R9Id90_HE10_IsoM_monitoring + Photon50_R9Id90_HE10_IsoM_EBOnly_PFJetsMJJ300DEta3_PFMET50_monitoring + Photon75_R9Id90_HE10_IsoM_EBOnly_PFJetsMJJ300DEta3_monitoring + + CscCluster50_Photon20Unseeded ) @@ -157,13 +162,6 @@ numGenericTriggerEventPSet = dict(hltPaths = ["HLT_DiPhoton10Time1p4ns_v*"]), ) -DiPhoton10sminlt0p1_monitoring = hltPhotonmonitoring.clone( - FolderName = 'HLT/EXO/DiPhoton/DiPhoton10sminlt0p1/', - nphotons = 2, - photonSelection = "(pt > 10 && abs(eta)<1.4442 && hadTowOverEm<0.12 && full5x5_sigmaIetaIeta()<0.015 && full5x5_r9>.5)||(pt > 10 && abs(eta)<2.5 && abs(eta)>1.5556 && hadTowOverEm<0.12 && full5x5_sigmaIetaIeta()<0.035 && full5x5_r9>.8)", - numGenericTriggerEventPSet = dict(hltPaths = ["HLT_DiPhoton10sminlt0p1_v*"]), -) - higgsHLTDiphotonMonitoring = cms.Sequence( DiphotonMass90_monitoring +DiphotonMass95_monitoring @@ -171,5 +169,4 @@ +Diphoton3018_monitoring +Diphoton2214_monitoring +DiPhoton10Time1p4ns_monitoring - +DiPhoton10sminlt0p1_monitoring ) diff --git a/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py b/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py index 6c3b79309c24b..f3e2ba03f8254 100644 --- a/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py +++ b/HLTriggerOffline/Exotica/python/analyses/hltExoticaDisplacedDiPhoton_cff.py @@ -3,7 +3,6 @@ DisplacedDiPhotonPSet = cms.PSet( hltPathsToCheck = cms.vstring( "HLT_DiPhoton10Time1p4ns_v", # New for Run3 (introduced in HLT V1.3) - "HLT_DiPhoton10sminlt0p1_v", # New for Run3 (introduced in HLT V1.3) ), recElecLabel = cms.InputTag("gedGsfElectrons"), # -- Analysis specific cuts From a1c0bf2d39ed26ce018d244bc12e010afc5e148b Mon Sep 17 00:00:00 2001 From: Sunil Dogra Date: Wed, 22 May 2024 04:37:05 +0200 Subject: [PATCH 051/301] Clean offline DQM of Photon smin triggers and adding DisplaedPhoton --- DQMOffline/Trigger/python/PhotonMonitor_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQMOffline/Trigger/python/PhotonMonitor_cff.py b/DQMOffline/Trigger/python/PhotonMonitor_cff.py index 339ca9585c7f9..47f91494fb1b8 100644 --- a/DQMOffline/Trigger/python/PhotonMonitor_cff.py +++ b/DQMOffline/Trigger/python/PhotonMonitor_cff.py @@ -52,7 +52,7 @@ ) CscCluster50_Photon20Unseeded = hltPhotonmonitoring.clone( - FolderName = 'HLT/EGM/Photon/CscCluster50_Photon20Unseeded/', + FolderName = 'HLT/EXO/DisplacedPhoton/CscCluster50_Photon20Unseeded/', numGenericTriggerEventPSet = dict(hltPaths = ["HLT_CscCluster50_Photon20Unseeded_v*"]) ) From c0077e6fee38c54565309252d4a9150f9fb9674d Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 19 Jan 2024 17:01:26 +0100 Subject: [PATCH 052/301] add Era_Run3_2024,Era_Run3_2025, Tier0 reco scenario for 2024, and change default era in PyReleaseValidation --- .../python/Impl/ppEra_Run3_2024.py | 29 +++++++++++++++++++ .../DataProcessing/python/RecoTLR.py | 5 ++++ .../DataProcessing/test/run_CfgTest_5.sh | 2 +- .../DataProcessing/test/run_CfgTest_8.sh | 2 +- .../Eras/python/Era_Run3_2024_cff.py | 5 ++++ .../Eras/python/Era_Run3_2025_cff.py | 5 ++++ .../python/upgradeWorkflowComponents.py | 2 +- .../StandardSequences/python/Eras.py | 2 ++ 8 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py create mode 100644 Configuration/Eras/python/Era_Run3_2024_cff.py create mode 100644 Configuration/Eras/python/Era_Run3_2025_cff.py diff --git a/Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py b/Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py new file mode 100644 index 0000000000000..39066c53b405e --- /dev/null +++ b/Configuration/DataProcessing/python/Impl/ppEra_Run3_2024.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +""" +_ppEra_Run3_2024_ +Scenario supporting proton collisions for 2024 +""" + +import os +import sys + +from Configuration.DataProcessing.Reco import Reco +import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Era_Run3_2024_cff import Run3_2024 + +from Configuration.DataProcessing.Impl.pp import pp + +class ppEra_Run3_2024(pp): + def __init__(self): + pp.__init__(self) + self.recoSeq='' + self.cbSc='pp' + self.eras=Run3_2024 + self.promptCustoms += [ 'Configuration/DataProcessing/RecoTLR.customisePostEra_Run3_2024' ] + self.expressCustoms += [ 'Configuration/DataProcessing/RecoTLR.customisePostEra_Run3_2024' ] + self.visCustoms += [ 'Configuration/DataProcessing/RecoTLR.customisePostEra_Run3_2024' ] + """ + _ppEra_Run3_2024_ + Implement configuration building for data processing for proton + collision data taking for Run3_2024 + """ diff --git a/Configuration/DataProcessing/python/RecoTLR.py b/Configuration/DataProcessing/python/RecoTLR.py index 4539242659b77..5eb8b3576eb1a 100644 --- a/Configuration/DataProcessing/python/RecoTLR.py +++ b/Configuration/DataProcessing/python/RecoTLR.py @@ -95,6 +95,11 @@ def customisePostEra_Run3_2023(process): customisePostEra_Run3(process) return process +def customisePostEra_Run3_2024(process): + #start with a repeat of 2023 + customisePostEra_Run3_2023(process) + return process + def customisePostEra_Run3_express_trackingOnly(process): #start with a repeat of 2018 customisePostEra_Run2_2018_express_trackingOnly(process) diff --git a/Configuration/DataProcessing/test/run_CfgTest_5.sh b/Configuration/DataProcessing/test/run_CfgTest_5.sh index 552fbf82c123f..c930630845844 100755 --- a/Configuration/DataProcessing/test/run_CfgTest_5.sh +++ b/Configuration/DataProcessing/test/run_CfgTest_5.sh @@ -10,7 +10,7 @@ function die { echo $1: status $2 ; exit $2; } function runTest { echo $1 ; python3 $1 || die "Failure for configuration: $1" $?; } -declare -a arr=("AlCaLumiPixels" "AlCaTestEnable" "cosmicsEra_Run2_2018" "hcalnzsEra_Run2_2018" "ppEra_Run2_2018" "hcalnzsEra_Run2_2018_highBetaStar" "hcalnzsEra_Run2_2018_pp_on_AA" "ppEra_Run2_2018_highBetaStar" "ppEra_Run2_2018_pp_on_AA" "cosmicsHybridEra_Run2_2018" "cosmicsEra_Run3" "hcalnzsEra_Run3" "ppEra_Run3" "AlCaLumiPixels_Run3" "AlCaPhiSymEcal_Nano" "AlCaPPS_Run3" "ppEra_Run3_pp_on_PbPb" "hcalnzsEra_Run3_pp_on_PbPb" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters" "ppEra_Run3_2023" "ppEra_Run3_pp_on_PbPb_2023" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters_2023") +declare -a arr=("AlCaLumiPixels" "AlCaTestEnable" "cosmicsEra_Run2_2018" "hcalnzsEra_Run2_2018" "ppEra_Run2_2018" "hcalnzsEra_Run2_2018_highBetaStar" "hcalnzsEra_Run2_2018_pp_on_AA" "ppEra_Run2_2018_highBetaStar" "ppEra_Run2_2018_pp_on_AA" "cosmicsHybridEra_Run2_2018" "cosmicsEra_Run3" "hcalnzsEra_Run3" "ppEra_Run3" "AlCaLumiPixels_Run3" "AlCaPhiSymEcal_Nano" "AlCaPPS_Run3" "ppEra_Run3_pp_on_PbPb" "hcalnzsEra_Run3_pp_on_PbPb" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters" "ppEra_Run3_2023" "ppEra_Run3_pp_on_PbPb_2023" "ppEra_Run3_pp_on_PbPb_approxSiStripClusters_2023" "ppEra_Run3_2024") for scenario in "${arr[@]}" do runTest "${SCRAM_TEST_PATH}/RunPromptReco.py --scenario $scenario --reco --aod --dqmio --global-tag GLOBALTAG --lfn=/store/whatever --alcareco TkAlMinBias+SiStripCalMinBias" diff --git a/Configuration/DataProcessing/test/run_CfgTest_8.sh b/Configuration/DataProcessing/test/run_CfgTest_8.sh index afadfcac01943..62bc5c078b29b 100755 --- a/Configuration/DataProcessing/test/run_CfgTest_8.sh +++ b/Configuration/DataProcessing/test/run_CfgTest_8.sh @@ -10,7 +10,7 @@ function die { echo $1: status $2 ; exit $2; } function runTest { echo $1 ; python3 $1 || die "Failure for configuration: $1" $?; } -declare -a arr=("ppEra_Run3" "ppEra_Run3_2023" "ppEra_Run3_2023_repacked") +declare -a arr=("ppEra_Run3" "ppEra_Run3_2023" "ppEra_Run3_2023_repacked" "ppEra_Run3_2024") for scenario in "${arr[@]}" do runTest "${SCRAM_TEST_PATH}/RunPromptReco.py --scenario $scenario --reco --aod --miniaod --nanoaod --dqmio --global-tag GLOBALTAG --lfn=/store/whatever --alcareco TkAlMinBias+SiStripCalMinBias" diff --git a/Configuration/Eras/python/Era_Run3_2024_cff.py b/Configuration/Eras/python/Era_Run3_2024_cff.py new file mode 100644 index 0000000000000..2a3224b13b01c --- /dev/null +++ b/Configuration/Eras/python/Era_Run3_2024_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run3_2023_cff import Run3_2023 + +Run3_2024 = cms.ModifierChain(Run3_2023) diff --git a/Configuration/Eras/python/Era_Run3_2025_cff.py b/Configuration/Eras/python/Era_Run3_2025_cff.py new file mode 100644 index 0000000000000..b0a96316cd88b --- /dev/null +++ b/Configuration/Eras/python/Era_Run3_2025_cff.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run3_2024_cff import Run3_2024 + +Run3_2025 = cms.ModifierChain(Run3_2024) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 5bec79747cba4..84bbab0aeafca 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -2856,7 +2856,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2024_realistic', 'HLTmenu': '@relval2024', - 'Era' : 'Run3', + 'Era' : 'Run3_2024', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['GenSim','Digi','RecoNano','HARVESTNano','ALCA'], }, diff --git a/Configuration/StandardSequences/python/Eras.py b/Configuration/StandardSequences/python/Eras.py index 52e9a364b5393..96dad3849ece6 100644 --- a/Configuration/StandardSequences/python/Eras.py +++ b/Configuration/StandardSequences/python/Eras.py @@ -35,6 +35,8 @@ def __init__(self): 'Run2_2018_noMkFit', 'Run3', 'Run3_2023', + 'Run3_2024', + 'Run3_2025', 'Run3_noMkFit', 'Run3_pp_on_PbPb', 'Run3_pp_on_PbPb_approxSiStripClusters', From 1057daa33b6f6892b757345a909d1e764c945260 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Jan 2024 14:51:20 +0100 Subject: [PATCH 053/301] exclude era Run3_2024 from being modified by UpgradeWorkflow_DDDDB --- .../PyReleaseValidation/python/upgradeWorkflowComponents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 84bbab0aeafca..3f2ea70bef3e8 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -2707,7 +2707,7 @@ def condition(self, fragment, stepList, key, hasHarvest): class UpgradeWorkflow_DDDDB(UpgradeWorkflow): def setup_(self, step, stepName, stepDict, k, properties): the_era = stepDict[step][k]['--era'] - if 'Run3' in the_era and '2023' not in the_era and 'Fast' not in the_era and "Pb" not in the_era: + if 'Run3' in the_era and '2023' not in the_era and '2024' not in the_era and 'Fast' not in the_era and "Pb" not in the_era: # retain any other eras tmp_eras = the_era.split(',') tmp_eras[tmp_eras.index("Run3")] = 'Run3_DDD' From 880ab431d2d03c168d4d1128904d929822ebfca8 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 22 May 2024 10:13:54 +0200 Subject: [PATCH 054/301] make era and Tier0 scenarios for Run3_2024 inherit directly from Run3 --- Configuration/DataProcessing/python/RecoTLR.py | 2 +- Configuration/Eras/python/Era_Run3_2024_cff.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Configuration/DataProcessing/python/RecoTLR.py b/Configuration/DataProcessing/python/RecoTLR.py index 5eb8b3576eb1a..997fe5f31d00b 100644 --- a/Configuration/DataProcessing/python/RecoTLR.py +++ b/Configuration/DataProcessing/python/RecoTLR.py @@ -97,7 +97,7 @@ def customisePostEra_Run3_2023(process): def customisePostEra_Run3_2024(process): #start with a repeat of 2023 - customisePostEra_Run3_2023(process) + customisePostEra_Run3(process) return process def customisePostEra_Run3_express_trackingOnly(process): diff --git a/Configuration/Eras/python/Era_Run3_2024_cff.py b/Configuration/Eras/python/Era_Run3_2024_cff.py index 2a3224b13b01c..6dc5f3a1b6e03 100644 --- a/Configuration/Eras/python/Era_Run3_2024_cff.py +++ b/Configuration/Eras/python/Era_Run3_2024_cff.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms -from Configuration.Eras.Era_Run3_2023_cff import Run3_2023 +from Configuration.Eras.Era_Run3_cff import Run3 -Run3_2024 = cms.ModifierChain(Run3_2023) +Run3_2024 = cms.ModifierChain(Run3) From df2704a049eab473461db22293fdfa1827c5a64e Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 22 May 2024 13:05:36 -0500 Subject: [PATCH 055/301] Handle case of no events in streamer files --- .../StreamerIO/plugins/DQMStreamerReader.cc | 5 +- EventFilter/Utilities/test/RunBUFU.sh | 21 +++++++ .../Utilities/test/TestReadingStreamerFile.sh | 55 +++++++++++++++++++ .../Utilities/test/readStreamerFile_cfg.py | 5 +- EventFilter/Utilities/test/startFU.py | 20 ++++++- EventFilter/Utilities/test/test_dqmstream.py | 9 ++- EventFilter/Utilities/test/unittest_FU.py | 20 ++++++- .../Utilities/test/writeStreamerFile_cfg.py | 15 ++++- IOPool/Streamer/src/StreamerFileReader.cc | 7 ++- 9 files changed, 144 insertions(+), 13 deletions(-) diff --git a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc index 44de7ce0251b9..906db29d4259e 100644 --- a/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc +++ b/DQMServices/StreamerIO/plugins/DQMStreamerReader.cc @@ -85,7 +85,10 @@ namespace dqmservices { void DQMStreamerReader::setupMetaData(edm::streamer::InitMsgView const& msg, bool subsequent) { deserializeAndMergeWithRegistry(msg, subsequent); auto event = getEventMsg(); - assert(event and event->isEventMetaData()); + //file might be empty + if (not event) + return; + assert(event->isEventMetaData()); deserializeEventMetaData(*event); updateEventMetaData(); } diff --git a/EventFilter/Utilities/test/RunBUFU.sh b/EventFilter/Utilities/test/RunBUFU.sh index 55f6dc298ead4..dab4ffb5bb59b 100755 --- a/EventFilter/Utilities/test/RunBUFU.sh +++ b/EventFilter/Utilities/test/RunBUFU.sh @@ -55,6 +55,27 @@ ${CMDLINE_STARTDQM} > out_2_dqm.log 2>&1 || diedqm "${CMDLINE_STARTDQM}" $? $OUT rm -rf $OUTDIR/{ramdisk,data,*.log} +################### +echo "Running test with FRD file header v1 (no index JSONs) and empty files" +CMDLINE_STARTBU="cmsRun startBU.py runNumber=${runnumber} fffBaseDir=${OUTDIR} maxLS=2 fedMeanSize=128 eventsPerFile=20 eventsPerLS=35 frdFileVersion=1" +#CMDLINE_STARTFU="cmsRun startFU.py runNumber=${runnumber} fffBaseDir=${OUTDIR}" +CMDLINE_STARTFU="cmsRun ${FUSCRIPT} runNumber=${runnumber} fffBaseDir=${OUTDIR} numEventsToWrite=0" +${CMDLINE_STARTBU} > out_2_bu.log 2>&1 || diebu "${CMDLINE_STARTBU}" $? $OUTDIR +${CMDLINE_STARTFU} > out_2_fu.log 2>&1 || diefu "${CMDLINE_STARTFU}" $? $OUTDIR + +#prepare DQM files +mkdir dqmdisk/run${runnumber} -p +cat data/run${runnumber}/run${runnumber}_ls0000_streamDQM_pid*.ini > dqmdisk/run${runnumber}/run${runnumber}_ls0001_streamDQM_test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamDQM_pid*.dat >> dqmdisk/run${runnumber}/run${runnumber}_ls0001_streamDQM_test.dat +find dqmdisk +echo '{"data": [12950, 1620, 0, "run'${runnumber}'_ls0001_streamDQM_test.dat", 40823782, 1999348078, 135, 13150, 0, "Failsafe"]}' > dqmdisk/run${runnumber}/run${runnumber}_ls0001_streamDQM_test.jsn + +CMDLINE_STARTDQM="cmsRun test_dqmstream.py runInputDir=./dqmdisk runNumber=100101 maxLS=1 eventsPerLS=0" +${CMDLINE_STARTDQM} > out_2_dqm.log 2>&1 || diedqm "${CMDLINE_STARTDQM}" $? $OUTDIR + +rm -rf $OUTDIR/{ramdisk,data,*.log} + +################ echo "Running test with FRD file header v2" CMDLINE_STARTBU="cmsRun startBU.py runNumber=${runnumber} fffBaseDir=${OUTDIR} maxLS=2 fedMeanSize=128 eventsPerFile=20 eventsPerLS=35 frdFileVersion=2" CMDLINE_STARTFU="cmsRun unittest_FU.py runNumber=${runnumber} fffBaseDir=${OUTDIR}" diff --git a/EventFilter/Utilities/test/TestReadingStreamerFile.sh b/EventFilter/Utilities/test/TestReadingStreamerFile.sh index b0b7845b45455..e0bf841fa31ae 100755 --- a/EventFilter/Utilities/test/TestReadingStreamerFile.sh +++ b/EventFilter/Utilities/test/TestReadingStreamerFile.sh @@ -192,6 +192,61 @@ CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runn ${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR +############################### +echo "Running test on reading single empty file" +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=0 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=0" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + +rm -rf data +########################## +echo "Running test on reading two separate empty files" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --runNumber=${runnumber} --numEvents=0" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test1.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test1.dat + +rm -rf data + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=10 --startEvent=11 --runNumber=${runnumber} --numEvents=0" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test2.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test2.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test1.dat --input test2.dat --runNumber=${runnumber} --numEvents=0" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR + +rm -rf data +########################## + +echo "Running test one concatenated empty file" + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=0 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +CMDLINE_WRITE="cmsRun writeStreamerFile_cfg.py --numEvents=0 --startEvent=11 --runNumber=${runnumber}" +${CMDLINE_WRITE} > out_2_write.log 2>&1 || diewrite "${CMDLINE_WRITE}" $? $OUTDIR + +#prepare file to read +ls -1 data/run${runnumber}/run${runnumber}_ls0000_streamA_pid*.ini | head -1 | xargs cat > test.dat +cat data/run${runnumber}/run${runnumber}_ls0001_streamA_pid*.dat >> test.dat + +CMDLINE_READ="cmsRun readStreamerFile_cfg.py --input test.dat --runNumber=${runnumber} --numEvents=0" +${CMDLINE_READ} > out_2_read.log 2>&1 || dieread "${CMDLINE_READ}" $? $OUTDIR +#cat out_2_read.log + +rm -rf data ############################ #no failures, clean up everything including logs if there are no errors diff --git a/EventFilter/Utilities/test/readStreamerFile_cfg.py b/EventFilter/Utilities/test/readStreamerFile_cfg.py index 3dffce4d75a33..b7dc7b98a0ff4 100644 --- a/EventFilter/Utilities/test/readStreamerFile_cfg.py +++ b/EventFilter/Utilities/test/readStreamerFile_cfg.py @@ -31,7 +31,10 @@ evid += 1 transitions.append(cms.EventID(rn,lumi,0)) #end lumi transitions.append(cms.EventID(rn,0,0)) #end run - + +if args.numEvents == 0: + transitions = [] + process.test = cms.EDAnalyzer("RunLumiEventChecker", eventSequence = cms.untracked.VEventID(*transitions), unorderedEvents = cms.untracked.bool(True) diff --git a/EventFilter/Utilities/test/startFU.py b/EventFilter/Utilities/test/startFU.py index 03cf3e1798af2..b08755167d004 100644 --- a/EventFilter/Utilities/test/startFU.py +++ b/EventFilter/Utilities/test/startFU.py @@ -41,14 +41,22 @@ VarParsing.VarParsing.varType.int, # string, int, or float "Number of CMSSW streams") +options.register ('numEventsToWrite', + -1, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of Events to process. -1 means all.") + options.parseArguments() cmsswbase = os.path.expandvars("$CMSSW_BASE/") process = cms.Process("TESTFU") process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) + input = cms.untracked.int32(options.numEventsToWrite) ) +if options.numEventsToWrite == 0: + process.maxEvents.input = 1 process.options = cms.untracked.PSet( numberOfThreads = cms.untracked.uint32(options.numThreads), @@ -104,6 +112,12 @@ lvl1Labels = cms.vstring( 'Default' ) ) +#used in case where we write no events +process.pre = cms.EDFilter("PrescaleEventFilter", offset = cms.uint32(0), prescale=cms.uint32(1)) +if options.numEventsToWrite: + process.pre.offset = 2 + process.pre.prescale = 4 + process.filter1 = cms.EDFilter("HLTPrescaler", L1GtReadoutRecordTag = cms.InputTag( "hltGtDigis" ) ) @@ -124,8 +138,8 @@ process.tcdsRawToDigi = EventFilter.OnlineMetaDataRawToDigi.tcdsRawToDigi_cfi.tcdsRawToDigi.clone() process.tcdsRawToDigi.InputLabel = cms.InputTag("rawDataCollector") -process.HLT_Physics = cms.Path(process.a*process.tcdsRawToDigi*process.filter1) -process.HLT_Muon = cms.Path(process.b*process.filter2) +process.HLT_Physics = cms.Path(process.a*process.tcdsRawToDigi*process.filter1*process.pre) +process.HLT_Muon = cms.Path(process.b*process.filter2*process.pre) process.streamA = cms.OutputModule("GlobalEvFOutputModule", SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'HLT_Physics' )) diff --git a/EventFilter/Utilities/test/test_dqmstream.py b/EventFilter/Utilities/test/test_dqmstream.py index eb02c94a8dc83..cd9d2e85742cc 100644 --- a/EventFilter/Utilities/test/test_dqmstream.py +++ b/EventFilter/Utilities/test/test_dqmstream.py @@ -65,7 +65,8 @@ evid += 1 transitions.append(cms.EventID(rn,lumi,0)) #end lumi transitions.append(cms.EventID(rn,0,0)) #end run - + + #only see 1 event as process.source.minEventsPerLumi == 1 process.test = cms.EDAnalyzer("RunLumiEventChecker", eventSequence = cms.untracked.VEventID(*transitions), @@ -73,6 +74,10 @@ minNumberOfEvents = cms.untracked.uint32(1+2+2), maxNumberOfEvents = cms.untracked.uint32(1+2+2) ) - +if options.eventsPerLS == 0: + process.test.eventSequence = [] + process.test.minNumberOfEvents = 0 + process.test.maxNumberOfEvents = 0 + process.p = cms.Path(process.test) diff --git a/EventFilter/Utilities/test/unittest_FU.py b/EventFilter/Utilities/test/unittest_FU.py index aa99c931a8b80..31cdacfd9b90e 100644 --- a/EventFilter/Utilities/test/unittest_FU.py +++ b/EventFilter/Utilities/test/unittest_FU.py @@ -41,6 +41,12 @@ VarParsing.VarParsing.varType.int, # string, int, or float "Number of CMSSW streams") +options.register ('numEventsToWrite', + -1, # default value + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, # string, int, or float + "Number of Events to process. -1 means all.") + options.parseArguments() @@ -48,8 +54,10 @@ process = cms.Process("TESTFU") process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) + input = cms.untracked.int32(options.numEventsToWrite) ) +if options.numEventsToWrite == 0: + process.maxEvents.input = 1 process.options = cms.untracked.PSet( numberOfThreads = cms.untracked.uint32(options.numThreads), @@ -115,6 +123,12 @@ lvl1Labels = cms.vstring( 'Default' ) ) +#used in case where we write no events +process.pre = cms.EDFilter("PrescaleEventFilter", offset = cms.uint32(0), prescale=cms.uint32(1)) +if options.numEventsToWrite: + process.pre.offset = 2 + process.pre.prescale = 4 + process.filter1 = cms.EDFilter("HLTPrescaler", L1GtReadoutRecordTag = cms.InputTag( "hltGtDigis" ) ) @@ -135,8 +149,8 @@ process.tcdsRawToDigi = EventFilter.OnlineMetaDataRawToDigi.tcdsRawToDigi_cfi.tcdsRawToDigi.clone() process.tcdsRawToDigi.InputLabel = cms.InputTag("rawDataCollector") -process.HLT_Physics = cms.Path(process.a*process.tcdsRawToDigi*process.filter1) -process.HLT_Muon = cms.Path(process.b*process.filter2) +process.HLT_Physics = cms.Path(process.a*process.tcdsRawToDigi*process.filter1*process.pre) +process.HLT_Muon = cms.Path(process.b*process.filter2*process.pre) process.streamA = cms.OutputModule("GlobalEvFOutputModule", SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring( 'HLT_Physics' )) diff --git a/EventFilter/Utilities/test/writeStreamerFile_cfg.py b/EventFilter/Utilities/test/writeStreamerFile_cfg.py index d747a97b98ad1..7081bb8b1263e 100644 --- a/EventFilter/Utilities/test/writeStreamerFile_cfg.py +++ b/EventFilter/Utilities/test/writeStreamerFile_cfg.py @@ -34,7 +34,11 @@ firstEvent=cms.untracked.uint32(args.startEvent) ) -process.maxEvents.input = args.numEvents +if args.numEvents != 0: + process.maxEvents.input = args.numEvents +else: + process.maxEvents.input = 1 + process.options = dict(numberOfThreads = args.numThreads, numberOfStreams = args.numFwkStreams) @@ -52,8 +56,15 @@ process.otherThing ) + +process.filter = cms.EDFilter("PrescaleEventFilter", offset = cms.uint32(0), prescale=cms.uint32(1)) +if args.numEvents == 0: + process.filter.offset = 2 + process.filter.prescale = 4 +process.p = cms.Path(process.filter) + process.streamA = cms.OutputModule("GlobalEvFOutputModule", - SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring()), + SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring("p")), outputCommands = cms.untracked.vstring("keep *") ) diff --git a/IOPool/Streamer/src/StreamerFileReader.cc b/IOPool/Streamer/src/StreamerFileReader.cc index d9b0eeb80e3dd..e9b8a47d40b37 100644 --- a/IOPool/Streamer/src/StreamerFileReader.cc +++ b/IOPool/Streamer/src/StreamerFileReader.cc @@ -51,7 +51,12 @@ namespace edm::streamer { deserializeAndMergeWithRegistry(*header, subsequent); //NOTE: should read first Event to get the meta data and then set 'artificial file' auto eview = getNextEvent(); - assert(eview and eview->isEventMetaData()); + + //if no events then file must be empty + if (eview == nullptr) + return; + + assert(eview->isEventMetaData()); deserializeEventMetaData(*eview); updateEventMetaData(); } From 029b11c2adba6e493f36b6be3c3c9d188863ddc9 Mon Sep 17 00:00:00 2001 From: Nicola Amapane Date: Thu, 23 May 2024 09:55:51 +0200 Subject: [PATCH 056/301] revive MF and XML geom visualization --- Fireworks/Geometry/plugins/DisplayGeom.cc | 70 ++++++++++++------- .../Geometry/python/cmsRun_displayGeom_cfg.py | 9 +-- .../python/cmsRun_displayProdMFGeom_cfg.py | 39 +++++------ .../test/Visualization/displayMFGeom_cfg.py | 63 ++++++++--------- 4 files changed, 92 insertions(+), 89 deletions(-) diff --git a/Fireworks/Geometry/plugins/DisplayGeom.cc b/Fireworks/Geometry/plugins/DisplayGeom.cc index 6738ac8213303..fc288ddaba9cc 100644 --- a/Fireworks/Geometry/plugins/DisplayGeom.cc +++ b/Fireworks/Geometry/plugins/DisplayGeom.cc @@ -55,6 +55,8 @@ class DisplayGeom : public edm::one::EDAnalyzer<> { explicit DisplayGeom(const edm::ParameterSet&); ~DisplayGeom() override; + static void fillDescriptions(edm::ConfigurationDescriptions&); + protected: TEveGeoTopNode* make_node(const TString& path, Int_t vis_level, Bool_t global_cs); @@ -70,7 +72,9 @@ class DisplayGeom : public edm::one::EDAnalyzer<> { int m_level; - bool m_MF; + typedef std::vector vstring; + vstring m_nodes; + int m_MF_component; std::vector m_MF_plane_d0; std::vector m_MF_plane_d1; @@ -93,14 +97,12 @@ DEFINE_FWK_MODULE(DisplayGeom); DisplayGeom::DisplayGeom(const edm::ParameterSet& iConfig) : m_eve(), m_geomList(nullptr), + m_level(iConfig.getUntrackedParameter("level")), + m_nodes(iConfig.getUntrackedParameter("nodes")), m_MF_component(0), m_geomWatcher(this, &DisplayGeom::remakeGeometry), m_displayGeomToken(esConsumes()) { - m_level = iConfig.getUntrackedParameter("level", 2); // Geometry level to visualize - - m_MF = iConfig.getUntrackedParameter("MF", false); // Show the MF geometry, instead of detector geometry - - std::string component = iConfig.getUntrackedParameter("MF_component", "NONE"); + std::string component = iConfig.getUntrackedParameter("MF_component"); boost::algorithm::to_upper(component); if (component == "NONE") { @@ -121,18 +123,18 @@ DisplayGeom::DisplayGeom(const edm::ParameterSet& iConfig) if (m_MF_component != -1) { m_magFieldToken = esConsumes(); - } - if (m_MF_component == 0) { - m_MF_plane_d0 = iConfig.getUntrackedParameter >("MF_plane_d0", std::vector(3, 0.0)); - m_MF_plane_d1 = iConfig.getParameter >("MF_plane_d1"); - m_MF_plane_d2 = iConfig.getParameter >("MF_plane_d2"); + m_MF_plane_d0 = iConfig.getUntrackedParameter >("MF_plane_d0"); + m_MF_plane_d1 = iConfig.getUntrackedParameter >("MF_plane_d1"); + m_MF_plane_d2 = iConfig.getUntrackedParameter >("MF_plane_d2"); - m_MF_plane_N1 = iConfig.getUntrackedParameter("MF_plane_N", 100); - m_MF_plane_N2 = iConfig.getUntrackedParameter("MF_plane_N2", m_MF_plane_N1); + m_MF_plane_N1 = iConfig.getUntrackedParameter("MF_plane_N"); + m_MF_plane_N2 = iConfig.getUntrackedParameter("MF_plane_N2"); + if (m_MF_plane_N2 < 0) + m_MF_plane_N2 = m_MF_plane_N1; - m_MF_plane_draw_dir = iConfig.getUntrackedParameter("MF_plane_draw_dir", true); - m_MF_isPickable = iConfig.getUntrackedParameter("MF_pickable", true); + m_MF_plane_draw_dir = iConfig.getUntrackedParameter("MF_plane_draw_dir"); + m_MF_isPickable = iConfig.getUntrackedParameter("MF_pickable"); } } @@ -183,7 +185,7 @@ void DisplayGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu } else if (m_MF_component == 4) { //BR minval = -4000, maxval = 4000; } else if (m_MF_component == 5) { //Bphi - minval = -1000, maxval = 1000; + minval = -200, maxval = 200; } TEveRGBAPalette* pal = new TEveRGBAPalette(minval, maxval); @@ -276,7 +278,7 @@ void DisplayGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu } } - TEveScene* eps = gEve->SpawnNewScene("FillStyleScene"); + TEveScene* eps = gEve->SpawnNewScene("MF Map"); gEve->GetDefaultViewer()->AddScene(eps); eps->GetGLScene()->SetStyle(TGLRnrCtx::kFill); eps->AddElement(q); @@ -304,6 +306,7 @@ void DisplayGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu // m_eve->AddElement(ps); } } + m_eve->getManager()->FullRedraw3D(true, true); } // ------------ method called once each job just before starting event loop ------------ @@ -324,14 +327,29 @@ void DisplayGeom::remakeGeometry(const DisplayGeomRecord& dgRec) { TEveGeoManagerHolder _tgeo(const_cast(&dgRec.get(m_displayGeomToken))); - // To have a full one, all detectors in one top-node: - // make_node("/cms:World_1/cms:CMSE_1", 4, kTRUE); - - if (m_MF) { - make_node("/cms:World_1", m_level, kTRUE); - } else { - make_node("/cms:World_1/cms:CMSE_1/tracker:Tracker_1", m_level, kTRUE); - make_node("/cms:World_1/cms:CMSE_1/caloBase:CALO_1", m_level, kTRUE); - make_node("/cms:World_1/cms:CMSE_1/muonBase:MUON_1", m_level, kTRUE); + for (std::string& aNode : m_nodes) { + make_node(aNode, m_level, kTRUE); } } + +void DisplayGeom::fillDescriptions(edm::ConfigurationDescriptions& conf) { + edm::ParameterSetDescription desc; + desc.addUntracked("nodes", vstring{"tracker:Tracker_1", "muonBase:MUON_1", "caloBase:CALO_1"}) + ->setComment("List of nodes to visualize"); + ; + desc.addUntracked("level", 4)->setComment("Levels into the geometry hierarchy visualized at startup"); + desc.addUntracked("MF_component", "None") + ->setComment("Component of the MF to show: 'None', 'B', 'AbsBZ', 'AbsBR', 'AbsBphi', 'BR', 'Bphi'"); + desc.addUntracked >("MF_plane_d0", std::vector{0., -900., -2400.}) + ->setComment("1st corner of MF map"); + desc.addUntracked >("MF_plane_d1", std::vector{0., -900., 2400.}) + ->setComment("2nd corner of MF map"); + desc.addUntracked >("MF_plane_d2", std::vector{0., 900., -2400.}) + ->setComment("3rd corner of MF map"); + desc.addUntracked("MF_plane_N", 200)->setComment("Number of bins for the MF map in 1st coord"); + desc.addUntracked("MF_plane_N2", -1)->setComment("Number of bins for the MF map in 2nd coord"); + desc.addUntracked("MF_plane_draw_dir", true)->setComment("Draw MF direction arrows (slow)"); + desc.addUntracked("MF_pickable", false)->setComment("MF values are pickable (slow)"); + + conf.add("DisplayGeom", desc); +} diff --git a/Fireworks/Geometry/python/cmsRun_displayGeom_cfg.py b/Fireworks/Geometry/python/cmsRun_displayGeom_cfg.py index 5247c384710fc..3c8ce10659bfc 100644 --- a/Fireworks/Geometry/python/cmsRun_displayGeom_cfg.py +++ b/Fireworks/Geometry/python/cmsRun_displayGeom_cfg.py @@ -10,9 +10,7 @@ process = cms.Process("DISPLAY") -process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") - - +process.load("Geometry.CMSCommonData.cmsExtendedGeometry2023XML_cfi") process.source = cms.Source("EmptySource") @@ -26,9 +24,8 @@ level = cms.untracked.int32(8) )) -process.dump = cms.EDAnalyzer( - "DisplayGeom" - +process.dump = cms.EDAnalyzer("DisplayGeom", +# nodes = cms.untracked.vstring("tracker:Tracker_1", "muonBase:MUON_1", "caloBase:CALO_1") ) process.p = cms.Path(process.dump) diff --git a/Fireworks/Geometry/python/cmsRun_displayProdMFGeom_cfg.py b/Fireworks/Geometry/python/cmsRun_displayProdMFGeom_cfg.py index 8e6dda6273f02..cd6f9ae4c9a38 100644 --- a/Fireworks/Geometry/python/cmsRun_displayProdMFGeom_cfg.py +++ b/Fireworks/Geometry/python/cmsRun_displayProdMFGeom_cfg.py @@ -10,26 +10,21 @@ process = cms.Process("DISPLAY") -process.load("Configuration.StandardSequences.GeometryExtended_cff") -process.load("Configuration.StandardSequences.MagneticField_38T_cff") +process.load("MagneticField.Engine.volumeBasedMagneticField_160812_cfi") process.XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", - geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/normal/cmsextent.xml', - 'Geometry/CMSCommonData/data/cms.xml', - 'Geometry/CMSCommonData/data/cmsMagneticField.xml', - 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_1103l.xml', - 'Geometry/CMSCommonData/data/materials.xml'), - rootNodeName = cms.string('cms:MCMS') -) - - - - + geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/normal/cmsextent.xml', + 'Geometry/CMSCommonData/data/cms.xml', + 'Geometry/CMSCommonData/data/cmsMagneticField.xml', + 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_1.xml', + 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_2.xml', + 'Geometry/CMSCommonData/data/materials.xml'), + rootNodeName = cms.string('cms:World') + ) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) - ) - +) process.source = cms.Source("EmptySource") @@ -45,22 +40,22 @@ process.dump = cms.EDAnalyzer("DisplayGeom", + nodes = cms.untracked.vstring("cmsMagneticField:MAGF_1"), level = cms.untracked.int32(2), - MF = cms.untracked.int32(True), #Display the MF geometry instead of detector geometry MF_component = cms.untracked.string("B"), #Field map: None, B, AbsBZ, AbsBR, AvsBphi, BR, Bphi - MF_pickable = cms.untracked.bool(True), #Field map: pickable values + MF_pickable = cms.untracked.bool(False), #Field map: pickable values #Field map on ZY plane @ X=0 MF_plane_d0 = cms.untracked.vdouble(0, -900, -2000), - MF_plane_d1 = cms.vdouble(0, -900., 2000), - MF_plane_d2 = cms.vdouble(0, 900., -2000.), + MF_plane_d1 = cms.untracked.vdouble(0, -900., 2000), + MF_plane_d2 = cms.untracked.vdouble(0, 900., -2000.), #Field map on XY plane @ Z=0 # MF_plane_d0 = cms.untracked.vdouble(-900, -900, 0.), -# MF_plane_d1 = cms.vdouble(-900, 900, 0.), -# MF_plane_d2 = cms.vdouble(900, -900, 0.), +# MF_plane_d1 = cms.untracked.vdouble(-900, 900, 0.), +# MF_plane_d2 = cms.untracked.vdouble(900, -900, 0.), - MF_plane_N = cms.untracked.uint32(500), #Field map bins + MF_plane_N = cms.untracked.int32(500), #Field map bins MF_plane_draw_dir = cms.untracked.int32(False) ) diff --git a/MagneticField/GeomBuilder/test/Visualization/displayMFGeom_cfg.py b/MagneticField/GeomBuilder/test/Visualization/displayMFGeom_cfg.py index 663190f93be8c..42cf7e673c727 100644 --- a/MagneticField/GeomBuilder/test/Visualization/displayMFGeom_cfg.py +++ b/MagneticField/GeomBuilder/test/Visualization/displayMFGeom_cfg.py @@ -10,31 +10,25 @@ process = cms.Process("DISPLAY") -#process.load("Configuration.StandardSequences.GeometryExtended_cff") -#process.load("Configuration.StandardSequences.MagneticField_38T_cff") process.load("MagneticField.Engine.volumeBasedMagneticField_160812_cfi") MFGeom=True; -if MFGeom: - process.XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", +process.XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/normal/cmsextent.xml', - 'Geometry/CMSCommonData/data/cms.xml', - 'Geometry/CMSCommonData/data/cmsMagneticField.xml', -# 'MagneticField/GeomBuilder/data/test.xml', - # for 090322 and older -# 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_1103l.xml', + 'Geometry/CMSCommonData/data/cms.xml', + 'Geometry/CMSCommonData/data/cmsMagneticField.xml', + # for 090322 and older +# 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_1103l.xml', - - # for 160812 + # for 160812 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_1.xml', 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_2.xml', 'Geometry/CMSCommonData/data/materials.xml'), - rootNodeName = cms.string('cmsMagneticField:MAGF') - ) -else : - process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") + # rootNodeName = cms.string('cmsMagneticField:MAGF') + rootNodeName = cms.string('cms:World') +) @@ -71,50 +65,49 @@ process.dump = cms.EDAnalyzer("DisplayGeom", -# process.dump.level = cms.untracked.int32(2), - MF = cms.untracked.int32(MFGeom), #Display the MF geometry instead of detector geometry + nodes = cms.untracked.vstring("cmsMagneticField:MAGF_1"), + level = cms.untracked.int32(2), MF_component = cms.untracked.string("B"), #Field map: None, B, AbsBZ, AbsBR, AvsBphi, BR, Bphi - MF_pickable = cms.untracked.bool(False), #Field map: pickable values - + MF_pickable = cms.untracked.bool(False), #Field map: pickable values #Field map on ZY plane @ X=0 (Top-right quarter) # MF_plane_d0 = cms.untracked.vdouble(0, 0, 0), -# MF_plane_d1 = cms.vdouble(0, 0., 2000), -# MF_plane_d2 = cms.vdouble(0, 900., 0.), +# MF_plane_d1 = cms.untracked.vdouble(0, 0., 2000), +# MF_plane_d2 = cms.untracked.vdouble(0, 900., 0.), #Field map on ZY plane @ X=0 (full CMS) MF_plane_d0 = cms.untracked.vdouble(0, -900, -2400), - MF_plane_d1 = cms.vdouble(0, -900., 2400), - MF_plane_d2 = cms.vdouble(0, 900., -2400.), + MF_plane_d1 = cms.untracked.vdouble(0, -900., 2400), + MF_plane_d2 = cms.untracked.vdouble(0, 900., -2400.), #Field map on XY plane @ Z=0 # MF_plane_d0 = cms.untracked.vdouble(-900, -900, 0.), -# MF_plane_d1 = cms.vdouble(-900, 900, 0.), -# MF_plane_d2 = cms.vdouble(900, -900, 0.), +# MF_plane_d1 = cms.untracked.vdouble(-900, 900, 0.), +# MF_plane_d2 = cms.untracked.vdouble(900, -900, 0.), #Field map on XY plane @ S3chimney # MF_plane_d0 = cms.untracked.vdouble(-900, -900, -165.), -# MF_plane_d1 = cms.vdouble(-900, 900, -165.), -# MF_plane_d2 = cms.vdouble(900, -900, -165.), +# MF_plane_d1 = cms.untracked.vdouble(-900, 900, -165.), +# MF_plane_d2 = cms.untracked.vdouble(900, -900, -165.), #Field map on XY plane @ S11 feet # MF_plane_d0 = cms.untracked.vdouble(0, -900, 0), -# MF_plane_d1 = cms.vdouble(0, 0, 0), -# MF_plane_d2 = cms.vdouble(900, -900, 0), +# MF_plane_d1 = cms.untracked.vdouble(0, 0, 0), +# MF_plane_d2 = cms.untracked.vdouble(900, -900, 0), #XY plane @ Z_SECTION # MF_plane_d0 = cms.untracked.vdouble(-900, -900, Z_SECTION), -# MF_plane_d1 = cms.vdouble(-900, 900, Z_SECTION), -# MF_plane_d2 = cms.vdouble(900, -900, Z_SECTION), +# MF_plane_d1 = cms.untracked.vdouble(-900, 900, Z_SECTION), +# MF_plane_d2 = cms.untracked.vdouble(900, -900, Z_SECTION), #CASTOR detail # MF_plane_d0 = cms.untracked.vdouble(-200, -200, -1519.49571429), -# MF_plane_d1 = cms.vdouble(-200, 200, -1519.49571429), -# MF_plane_d2 = cms.vdouble(200, -200, -1519.49571429), +# MF_plane_d1 = cms.untracked.vdouble(-200, 200, -1519.49571429), +# MF_plane_d2 = cms.untracked.vdouble(200, -200, -1519.49571429), - MF_plane_N = cms.untracked.uint32(1000), #Field map bins -# MF_plane_N2 = cms.untracked.uint32(500), + MF_plane_N = cms.untracked.int32(1000), #Field map bins +# MF_plane_N2 = cms.untracked.int32(500), MF_plane_draw_dir = cms.untracked.int32(False) ) From 4b8a313549a76ba6931bcf27f4d1a412f01d82c8 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Thu, 23 May 2024 10:12:07 +0200 Subject: [PATCH 057/301] AMPTInterface: Fix used uninitialized warnings --- .../AMPTInterface/src/hipyset1.35.f | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/GeneratorInterface/AMPTInterface/src/hipyset1.35.f b/GeneratorInterface/AMPTInterface/src/hipyset1.35.f index bddcf5cef5e57..ffceb0ec249d2 100644 --- a/GeneratorInterface/AMPTInterface/src/hipyset1.35.f +++ b/GeneratorInterface/AMPTInterface/src/hipyset1.35.f @@ -500,6 +500,8 @@ SUBROUTINE LUPREP(IP) C...Rearrange parton shower product listing along strings: begin loop. I1=N + DO 101 J=1,5 + 101 DPC(J)=0 DO 130 MQGST=1,2 DO 120 I=MAX(1,IP),N IF(K(I,1).NE.3) GOTO 120 @@ -3459,6 +3461,11 @@ SUBROUTINE LUSHOW(IP1,IP2,QMAX) PT2MIN=MAX(0.5*PARJ(82),1.1*PARJ(81))**2 ALAMS=PARJ(81)**2 ALFM=LOG(PT2MIN/ALAMS) + DO 101 I=1,4 + ISI(I)=0 + IPA(I)=0 + KFLD(I)=0 + 101 CONTINUE C...Store positions of shower initiating partons. M3JC=0 @@ -9582,6 +9589,8 @@ SUBROUTINE PYMULT(MMUL) XI=0. YI=0. XK=0.5 + XF=1. + YF=1. IIT=0 130 IF(IIT.EQ.0) THEN XK=2.*XK @@ -9877,6 +9886,9 @@ SUBROUTINE PYMULT(MMUL) IF(RFLAV.LT.PARP(85).AND.NSTR.GE.1) THEN C....Choose relevant string pieces to place gluons on. + IST1=0 + IST2=0 + ISTM=0 DO 210 I=N+1,N+2 DMIN=1E8 DO 200 ISTR=1,NSTR @@ -11248,6 +11260,7 @@ SUBROUTINE PYWIDT(KFLR,RMAS,WDTP,WDTE) C...H0 -> gamma + gamma; quark, charged lepton and W loop contributions ETARE=0. ETAIM=0. + EJ=0. DO 150 J=1,3*MSTP(1)+1 IF(J.LE.2*MSTP(1)) THEN EJ=KCHG(J,1)/3. @@ -11289,7 +11302,9 @@ SUBROUTINE PYWIDT(KFLR,RMAS,WDTP,WDTE) ELSEIF(I.EQ.15) THEN C...H0 -> gamma + Z0; quark, charged lepton and W loop contributions ETARE=0. - ETAIM=0. + ETAIM=0. + VJ=0. + EJ=0. DO 160 J=1,3*MSTP(1)+1 IF(J.LE.2*MSTP(1)) THEN EJ=KCHG(J,1)/3. @@ -11304,7 +11319,7 @@ SUBROUTINE PYWIDT(KFLR,RMAS,WDTP,WDTE) VJ=AJ-4.*EJ*XW EPS=(2.*PMAS(10+JL,1)/RMAS)**2 EPSP=(2.*PMAS(10+JL,1)/PMAS(23,1))**2 - ELSE + ELSE EPS=(2.*PMAS(24,1)/RMAS)**2 EPSP=(2.*PMAS(24,1)/PMAS(23,1))**2 ENDIF From 080d8c6a669f3172a63481ed07cd1e811dcd17ca Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 10:23:48 +0200 Subject: [PATCH 058/301] add long-track bonus to CkfTrajectoryBuilder --- .../python/MuonCkfTrajectoryBuilder_cfi.py | 2 ++ .../CkfPattern/interface/CkfTrajectoryBuilder.h | 2 ++ .../CkfPattern/python/CkfTrajectoryBuilder_cfi.py | 2 ++ RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc | 12 ++++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py b/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py index 42fce0618221a..8e54dc7fabc4d 100644 --- a/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py +++ b/RecoMuon/L3TrackFinder/python/MuonCkfTrajectoryBuilder_cfi.py @@ -19,6 +19,8 @@ rescaleErrorIfFail = cms.double(1.0), propagatorOpposite = cms.string('PropagatorWithMaterialOpposite'), lostHitPenalty = cms.double(30.0), + foundHitBonus = cms.double(0.0), + minHitForDoubleBonus = cms.int32(9999), #this is present in HLT config, appears to be dummy # appendToDataLabel = cms.string( "" ), #safety cone size diff --git a/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h b/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h index 209978eb9dd2d..c5d7b8e0d8df7 100644 --- a/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h +++ b/RecoTracker/CkfPattern/interface/CkfTrajectoryBuilder.h @@ -63,6 +63,8 @@ class CkfTrajectoryBuilder : public BaseCkfTrajectoryBuilder { int theMaxCand; /**< Maximum number of trajectory candidates to propagate to the next layer. */ float theLostHitPenalty; /**< Chi**2 Penalty for each lost hit. */ + float theFoundHitBonus; /**< Chi**2 Bonus for each found hit. */ + int theMinHitForDoubleBonus; /**< minimun number of hits to double the bonus above */ bool theIntermediateCleaning; /**< Tells whether an intermediary cleaning stage should take place during TB. */ bool theAlwaysUseInvalidHits; diff --git a/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py b/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py index d4df8e456eb83..8d360b9497e44 100644 --- a/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py +++ b/RecoTracker/CkfPattern/python/CkfTrajectoryBuilder_cfi.py @@ -20,6 +20,8 @@ propagatorOpposite = cms.string('PropagatorWithMaterialOpposite'), # propagatorOpposite = cms.string('PropagatorWithMaterialParabolicMfOpposite'), lostHitPenalty = cms.double(30.0), + foundHitBonus = cms.double(10.0), + minHitForDoubleBonus = cms.int32(8), #SharedSeedCheck = cms.bool(False), seedAs5DHit = cms.bool(False) ) diff --git a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc index 3680471fd89de..dbfb957650e29 100644 --- a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc +++ b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc @@ -40,6 +40,8 @@ CkfTrajectoryBuilder::CkfTrajectoryBuilder(const edm::ParameterSet& conf, : BaseCkfTrajectoryBuilder(conf, iC, std::move(filter)) { theMaxCand = conf.getParameter("maxCand"); theLostHitPenalty = conf.getParameter("lostHitPenalty"); + theFoundHitBonus = conf.getParameter("foundHitBonus"); + theMinHitForDoubleBonus = conf.getParameter("minHitForDoubleBounus"); theIntermediateCleaning = conf.getParameter("intermediateCleaning"); theAlwaysUseInvalidHits = conf.getParameter("alwaysUseInvalidHits"); } @@ -48,6 +50,8 @@ void CkfTrajectoryBuilder::fillPSetDescription(edm::ParameterSetDescription& iDe BaseCkfTrajectoryBuilder::fillPSetDescription(iDesc); iDesc.add("maxCand", 5); iDesc.add("lostHitPenalty", 30.); + iDesc.add("foundHitBonus", 10.); + iDesc.add("minHitForDoubleBounus", 8); iDesc.add("intermediateCleaning", true); iDesc.add("alwaysUseInvalidHits", true); @@ -104,10 +108,14 @@ unsigned int CkfTrajectoryBuilder::limitedCandidates(const std::shared_ptr theMinHitForDoubleBonus ? bonus : 0; + return a.chiSquared() + a.lostHits() * theLostHitPenalty - bonus * a.foundHits(); }; + auto trajCandLess = [&](TempTrajectory const& a, TempTrajectory const& b) { return score(a) < score(b); }; + while (!candidates.empty()) { newCand.clear(); bool full = 0; From eab7107f187e072d0f0f1e403c81c5ff5d4df217 Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 10:40:39 +0200 Subject: [PATCH 059/301] cleanup --- .../CkfPattern/plugins/TrajectoryLessByFoundHits.h | 14 -------------- .../CkfPattern/plugins/TrajectorySegmentBuilder.cc | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h diff --git a/RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h b/RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h deleted file mode 100644 index 77f81ba420db7..0000000000000 --- a/RecoTracker/CkfPattern/plugins/TrajectoryLessByFoundHits.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TrajectoryLessByFoundHits_h_ -#define TrajectoryLessByFoundHits_h_ - -#include "TrackingTools/PatternTools/interface/Trajectory.h" -#include - -inline bool lessByFoundHits(const Trajectory& a, const Trajectory& b) { return a.foundHits() < b.foundHits(); } -inline bool lessByFoundHits(const TempTrajectory& a, const TempTrajectory& b) { return a.foundHits() < b.foundHits(); } - -struct TrajectoryLessByFoundHits { - bool operator()(const Trajectory& a, const Trajectory& b) const { return a.foundHits() < b.foundHits(); } - bool operator()(const TempTrajectory& a, const TempTrajectory& b) const { return a.foundHits() < b.foundHits(); } -}; -#endif diff --git a/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc b/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc index df1d438e1f869..fc9fff86b720b 100644 --- a/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc +++ b/RecoTracker/CkfPattern/plugins/TrajectorySegmentBuilder.cc @@ -13,7 +13,6 @@ #include "TrackingTools/MeasurementDet/interface/TrajectoryMeasurementGroup.h" #include "TrackingTools/DetLayers/interface/DetGroup.h" #include "TrackingTools/DetLayers/interface/DetLayer.h" -#include "TrajectoryLessByFoundHits.h" #include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h" #include "TrackingTools/DetLayers/interface/GeomDetCompatibilityChecker.h" #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h" @@ -482,7 +481,8 @@ void TrajectorySegmentBuilder::cleanCandidates(vector& candidate int index[NC]; for (int i = 0; i != NC; ++i) index[i] = i; - std::sort(index, index + NC, [&candidates](int i, int j) { return lessByFoundHits(candidates[i], candidates[j]); }); + std::sort( + index, index + NC, [&candidates](int i, int j) { return candidates[i].foundHits() < candidates[j].foundHits(); }); // cout << "SortedCandidates.foundHits"; // for (auto i1 : index) // cout << " " << candidates[i1].foundHits(); From 9b8c5d13b1543d727a519fa3f333f33551a60519 Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 12:08:49 +0200 Subject: [PATCH 060/301] fix misspellings --- .../python/trajectoryBuilderForConversions_cfi.py | 2 ++ RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py b/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py index 183650f43c4b9..c8d064187a5e7 100644 --- a/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py +++ b/RecoEgamma/EgammaPhotonProducers/python/trajectoryBuilderForConversions_cfi.py @@ -17,6 +17,8 @@ trajectoryFilter = dict(refToPSet_ = 'TrajectoryFilterForConversions'), maxCand = 5, lostHitPenalty = 30., + foundHitBonus = 10., + minHitForDoubleBonus = 8, intermediateCleaning = True, alwaysUseInvalidHits = True, seedAs5DHit = False diff --git a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc index dbfb957650e29..8c8215044628a 100644 --- a/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc +++ b/RecoTracker/CkfPattern/src/CkfTrajectoryBuilder.cc @@ -41,7 +41,7 @@ CkfTrajectoryBuilder::CkfTrajectoryBuilder(const edm::ParameterSet& conf, theMaxCand = conf.getParameter("maxCand"); theLostHitPenalty = conf.getParameter("lostHitPenalty"); theFoundHitBonus = conf.getParameter("foundHitBonus"); - theMinHitForDoubleBonus = conf.getParameter("minHitForDoubleBounus"); + theMinHitForDoubleBonus = conf.getParameter("minHitForDoubleBonus"); theIntermediateCleaning = conf.getParameter("intermediateCleaning"); theAlwaysUseInvalidHits = conf.getParameter("alwaysUseInvalidHits"); } @@ -51,7 +51,7 @@ void CkfTrajectoryBuilder::fillPSetDescription(edm::ParameterSetDescription& iDe iDesc.add("maxCand", 5); iDesc.add("lostHitPenalty", 30.); iDesc.add("foundHitBonus", 10.); - iDesc.add("minHitForDoubleBounus", 8); + iDesc.add("minHitForDoubleBonus", 8); iDesc.add("intermediateCleaning", true); iDesc.add("alwaysUseInvalidHits", true); From 3457dcbef74177b64bf427a1258f6fd8f657f2b6 Mon Sep 17 00:00:00 2001 From: Vincenzo Innocente Date: Thu, 23 May 2024 15:13:39 +0200 Subject: [PATCH 061/301] introduce HLT modifier --- HLTrigger/Configuration/python/customizeHLTforCMSSW.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index b35dfef990fec..a888039d66c0f 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -268,6 +268,14 @@ def customizeHLTfor44576(process): break return process + +def customizeHLTfor45023(process): + for pset in process.psets.values(): + if hasattr(pset, 'ComponentType') and pset.ComponentType == 'CkfTrajectoryBuilder': + pset.foundHitBonus = cms.double(0.0) + pset.minHitForDoubleBonus = cms.int32(9999) + return process + # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): @@ -278,5 +286,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"): process = checkHLTfor43774(process) process = customizeHLTfor44576(process) + process = customizeHLTfor45023(process) return process From 5f5deb314a1e58404c6e094184a33578d43521e3 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Thu, 23 May 2024 16:13:57 +0200 Subject: [PATCH 062/301] recover the residual plots, probably with different names --- .../MuonRPCDigis/interface/RPCDigiValid.h | 10 ++ Validation/MuonRPCDigis/src/RPCDigiValid.cc | 99 ++++++++++++++++++- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/Validation/MuonRPCDigis/interface/RPCDigiValid.h b/Validation/MuonRPCDigis/interface/RPCDigiValid.h index 2b9cb52fd9c60..b7896a53b6c4c 100644 --- a/Validation/MuonRPCDigis/interface/RPCDigiValid.h +++ b/Validation/MuonRPCDigis/interface/RPCDigiValid.h @@ -47,6 +47,16 @@ class RPCDigiValid : public DQMEDAnalyzer { // Timing information MonitorElement *hDigiTimeAll_, *hDigiTime_, *hDigiTimeIRPC_, *hDigiTimeNoIRPC_; + // Multiplicity plots + MonitorElement *hNSimHitPerRoll_, *hNDigiPerRoll_; + + // Residual plots + MonitorElement *hRes_; + std::map hResBarrelLayers_; + std::map hResBarrelWheels_; + std::map hResEndcapDisks_; + std::map hResEndcapRings_; + // Tokens for accessing run data. Used for passing to edm::Event. - stanislav edm::EDGetTokenT simHitToken_; edm::EDGetTokenT rpcDigiToken_; diff --git a/Validation/MuonRPCDigis/src/RPCDigiValid.cc b/Validation/MuonRPCDigis/src/RPCDigiValid.cc index 8ede470d311f1..6ae4f5921d34f 100644 --- a/Validation/MuonRPCDigis/src/RPCDigiValid.cc +++ b/Validation/MuonRPCDigis/src/RPCDigiValid.cc @@ -39,11 +39,17 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { event.getByToken(rpcDigiToken_, rpcDigisHandle); // loop over Simhit + std::map> detToSimHitXsMap; for (auto simIt = simHitHandle->begin(); simIt != simHitHandle->end(); ++simIt) { const RPCDetId rsid = simIt->detUnitId(); const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); if (!roll) continue; + + if (detToSimHitXsMap.find(roll) == detToSimHitXsMap.end()) + detToSimHitXsMap[roll] = std::vector(); + detToSimHitXsMap[roll].push_back(simIt->localPosition().x()); + const int region = rsid.region(); const GlobalPoint gp = roll->toGlobal(simIt->localPosition()); @@ -70,7 +76,12 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { match->second->Fill(gp.x(), gp.y()); } } + for (auto detToSimHitXs : detToSimHitXsMap) { + hNSimHitPerRoll_->Fill(detToSimHitXs.second.size()); + } + // loop over Digis + std::map> detToDigiXsMap; for (auto detUnitIt = rpcDigisHandle->begin(); detUnitIt != rpcDigisHandle->end(); ++detUnitIt) { const RPCDetId rsid = (*detUnitIt).first; const RPCRoll *roll = dynamic_cast(rpcGeom->roll(rsid)); @@ -120,6 +131,56 @@ void RPCDigiValid::analyze(const Event &event, const EventSetup &eventSetup) { else hDigiTimeNoIRPC_->Fill(digiTime); } + + // Keep digi position + const double digiX = roll->centreOfStrip(digiIt->strip()).x(); + if (detToDigiXsMap.find(roll) == detToDigiXsMap.end()) + detToDigiXsMap[roll] = std::vector(); + detToDigiXsMap[roll].push_back(digiX); + } + } + for (auto detToDigiXs : detToDigiXsMap) { + const auto digiXs = detToDigiXs.second; + const int nDigi = digiXs.size(); + hNDigiPerRoll_->Fill(nDigi); + + // Fill residual plots, only for nDigi==1 and nSimHit==1 + const auto roll = detToDigiXs.first; + const auto detId = roll->id(); + if (nDigi != 1) + continue; + if (detToSimHitXsMap.find(roll) == detToSimHitXsMap.end()) + continue; + + const auto simHitXs = detToSimHitXsMap[roll]; + const int nSimHit = simHitXs.size(); + if (nSimHit != 1) + continue; + + const double dx = digiXs[0] - simHitXs[0]; + hRes_->Fill(dx); + if (roll->isBarrel()) { + const int wheel = detId.ring(); // ring() is wheel number for Barrel + const int station = detId.station(); + const int layer = detId.layer(); + const int stla = (station <= 2) ? (2 * (station - 1) + layer) : (station + 2); + + auto matchLayer = hResBarrelLayers_.find(stla); + if (matchLayer != hResBarrelLayers_.end()) + matchLayer->second->Fill(dx); + + auto matchWheel = hResBarrelWheels_.find(wheel); + if (matchWheel != hResBarrelWheels_.end()) + matchWheel->second->Fill(dx); + } else { + const int disk = detId.region() * detId.station(); + auto matchDisk = hResEndcapDisks_.find(disk); + if (matchDisk != hResEndcapDisks_.end()) + matchDisk->second->Fill(dx); + + auto matchRing = hResEndcapRings_.find(detId.ring()); + if (matchRing != hResEndcapRings_.end()) + matchRing->second->Fill(dx); } } } @@ -144,8 +205,8 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run // XY plots hXY_Barrel_ = booker.book2D("XY_Barrel", "X-Y view of Barrel", nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); for (int disk = 1; disk <= 4; ++disk) { - const std::string meNameP = fmt::format("XY_EndcapP{:1d}", disk); - const std::string meNameN = fmt::format("XY_EndcapN{:1d}", disk); + const std::string meNameP = fmt::format("XY_Endcap_p{:1d}", disk); + const std::string meNameN = fmt::format("XY_Endcap_m{:1d}", disk); const std::string meTitleP = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", disk); const std::string meTitleN = fmt::format("X-Y view of Endcap{:+1d};X (cm);Y (cm)", -disk); hXY_Endcap_[disk] = booker.book2D(meNameP, meTitleP, nbinsXY, -maxXY, maxXY, nbinsXY, -maxXY, maxXY); @@ -177,4 +238,38 @@ void RPCDigiValid::bookHistograms(DQMStore::IBooker &booker, edm::Run const &run hDigiTime_ = booker.book1D("DigiTime", "Digi time only with timing information;Digi time (ns)", 100, -12.5, 12.5); hDigiTimeIRPC_ = booker.book1D("DigiTimeIRPC", "IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); hDigiTimeNoIRPC_ = booker.book1D("DigiTimeNoIRPC", "non-IRPC Digi time;Digi time (ns)", 100, -12.5, 12.5); + + // SimHit and Digi multiplicity per roll + hNSimHitPerRoll_ = booker.book1D("NSimHitPerRoll", "SimHit multiplicity per Roll;Multiplicity", 10, 0, 10); + hNDigiPerRoll_ = booker.book1D("NDigiPerRoll", "Digi multiplicity per Roll;Multiplicity", 10, 0, 10); + + // Residual of SimHit-Digi x-position + hRes_ = booker.book1D("Digi_SimHit_Difference", "Digi-SimHit difference;dx (cm)", 100, -8, 8); + + for (int layer = 1; layer <= 6; ++layer) { + const std::string meName = fmt::format("Residual_Barrel_Layer{:1d}", layer); + const std::string meTitle = fmt::format("Residual of Barrel Layer{:1d};dx (cm)", layer); + hResBarrelLayers_[layer] = booker.book1D(meName, meTitle, 100, -8, 8); + } + + hResBarrelWheels_[-2] = booker.book1D("Residual_Barrel_Wheel_m2", "Residual of Barrel Wheel-2;dx (cm)", 100, -8, 8); + hResBarrelWheels_[-1] = booker.book1D("Residual_Barrel_Wheel_m1", "Residual of Barrel Wheel-1;dx (cm)", 100, -8, 8); + hResBarrelWheels_[+0] = booker.book1D("Residual_Barrel_Wheel_00", "Residual of Barrel Wheel 0;dx (cm)", 100, -8, 8); + hResBarrelWheels_[+1] = booker.book1D("Residual_Barrel_Wheel_p1", "Residual of Barrel Wheel+1;dx (cm)", 100, -8, 8); + hResBarrelWheels_[+2] = booker.book1D("Residual_Barrel_Wheel_p2", "Residual of Barrel Wheel+2;dx (cm)", 100, -8, 8); + + for (int disk = 1; disk <= 4; ++disk) { + const std::string meNameP = fmt::format("Residual_Endcap_Disk_p{:1d}", disk); + const std::string meNameN = fmt::format("Residual_Endcap_Disk_m{:1d}", disk); + const std::string meTitleP = fmt::format("Residual of Endcap Disk{:+1d};dx (cm)", disk); + const std::string meTitleN = fmt::format("Residual of Endcap Disk{:+1d};dx (cm)", -disk); + hResEndcapDisks_[+disk] = booker.book1D(meNameP, meTitleP, 100, -8, 8); + hResEndcapDisks_[-disk] = booker.book1D(meNameN, meTitleN, 100, -8, 8); + } + + for (int ring = 1; ring <= 3; ++ring) { + const std::string meName = fmt::format("Residual_Endcap_Ring{:1d}", ring); + const std::string meTitle = fmt::format("Residual of Endcap Ring{:1d};dx (cm)", ring); + hResEndcapRings_[ring] = booker.book1D(meName, meTitle, 100, -8, 8); + } } From 08b87bec92fcd3fc783e2c138df65c21ac03c1d2 Mon Sep 17 00:00:00 2001 From: Alessandro Lapertosa Date: Thu, 23 May 2024 16:53:15 +0200 Subject: [PATCH 063/301] Disabled ROCs for Online DQM Pixel Summary --- DQM/SiPixelPhase1Summary/src/SiPixelPhase1Summary.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DQM/SiPixelPhase1Summary/src/SiPixelPhase1Summary.cc b/DQM/SiPixelPhase1Summary/src/SiPixelPhase1Summary.cc index 9a80f5c832e78..22259f69eea25 100644 --- a/DQM/SiPixelPhase1Summary/src/SiPixelPhase1Summary.cc +++ b/DQM/SiPixelPhase1Summary/src/SiPixelPhase1Summary.cc @@ -272,6 +272,7 @@ void SiPixelPhase1Summary::fillSummaries(DQMStore::IBooker& iBooker, DQMStore::I //Fill the dead ROC summary std::vector trendOrder = {layer1, layer2, layer3, layer4, ring1, ring2}; std::vector nRocsPerTrend = {1536, 3584, 5632, 8192, 4224, 6528}; + std::vector nDisabledRocs = {12, 128, 240, 320, 96, 120}; for (unsigned int i = 0; i < trendOrder.size(); i++) { int xBin = i < 4 ? 1 : 2; int yBin = i % 4 + 1; @@ -321,7 +322,9 @@ void SiPixelPhase1Summary::fillSummaries(DQMStore::IBooker& iBooker, DQMStore::I // Filled ROCs = Total number - dead ROCs numFilledROCs = nRocsPerTrend[i] - numDeadROCs; //Fill with fraction of filled ROCs (with digis) - fracFilledROCs = numFilledROCs / nRocsPerTrend[i]; + fracFilledROCs = numFilledROCs / (nRocsPerTrend[i] - nDisabledRocs[i]); + if (fracFilledROCs > 1) + fracFilledROCs = 1; deadROCSummary->setBinContent(xBin, yBin, fracFilledROCs); deadROCSummary->setBinContent(2, 3, -1); deadROCSummary->setBinContent(2, 4, -1); From b215850f036265114194201bc7ea75938d1d2ba8 Mon Sep 17 00:00:00 2001 From: Michal Bluj Date: Thu, 23 May 2024 17:50:24 +0200 Subject: [PATCH 064/301] Set 3 instead of 4 OMTF track sub-address as expected by uGMT --- L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc index 7a8b0545d3c69..530cdb876d66a 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc @@ -294,7 +294,8 @@ std::vector OMTFProcessor::getFinalcan //check if it matters if it needs to be here as well trackAddr[1] = myCand->getRefLayer(); trackAddr[2] = myCand->getDisc(); - trackAddr[3] = myCand->getGpResultUnconstr().getPdfSumUnconstr(); + //TODO: uGMT expects only 3 sub-addresses, so not set 4th. This is anyway currently not used. + //trackAddr[3] = myCand->getGpResultUnconstr().getPdfSumUnconstr(); if (candidate.hwPt() > 0 || candidate.hwPtUnconstrained() > 0) { candidate.setTrackAddress(trackAddr); candidate.setTFIdentifiers(iProcessor, mtfType); From 2c86f7138bf114e62f72523db7bbbe02ea461364 Mon Sep 17 00:00:00 2001 From: Salavat Date: Thu, 23 May 2024 19:21:16 +0200 Subject: [PATCH 065/301] mask fix --- DataFormats/HcalDetId/interface/HcalZDCDetId.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/HcalDetId/interface/HcalZDCDetId.h b/DataFormats/HcalDetId/interface/HcalZDCDetId.h index c1124664c5f63..16723e09aea8f 100644 --- a/DataFormats/HcalDetId/interface/HcalZDCDetId.h +++ b/DataFormats/HcalDetId/interface/HcalZDCDetId.h @@ -24,7 +24,7 @@ class HcalZDCDetId : public DetId { public: static constexpr uint32_t kZDCChannelMask1 = 0xF; - static constexpr uint32_t kZDCChannelMask2 = 0x7F; + static constexpr uint32_t kZDCChannelMask2 = 0x3F; static constexpr uint32_t kZDCSectionMask = 0x3; static constexpr uint32_t kZDCSectionOffset = 4; static constexpr uint32_t kZDCZsideMask = 0x40; From 948fd546f27c1de7a31d2acc101fec20b9a89774 Mon Sep 17 00:00:00 2001 From: Karol Bunkowski Date: Thu, 23 May 2024 19:52:05 +0200 Subject: [PATCH 066/301] possibility of configuring the OMTF emulator directly from XMLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OMTFReconstruction.h and OMTFReconstruction.cc The possibility of configuring the OMTF emulator directly from the config XML is added. When both patternsXMLFile and configXMLFile are given from the python config of the simOmtfDigis or simOmtfPhase2Digis, the L1TMuonOverlapParams are read directly from these files, and the L1TMuonOverlapPhase1ParamsESProducer is not needed. Otherwise, the L1TMuonOverlapParams are obtained from the eventSetup (so from the DB, or from the L1TMuonOverlapPhase1ParamsESProducer - if it is defined). L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py is removed, as when it is used, the L1TMuonOverlapPhase1 gets this config as well. L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py is moved to simOmtfPhase2Digis_cfi.py, as this is the default configuration (besides, there should be only one cfi for a given module). L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc line trackAddr[3] = myCand->getGpResultUnconstr().getPdfSumUnconstr(); is removed, as uGMT expects 3 entries in the TrackAddress (when there were 4, uGMT was generating a warning). L1Trigger/L1TMuonOverlapPhase2/test - runMuonOverlap*.py are corrected --- .../interface/Omtf/OMTFReconstruction.h | 2 + .../src/Omtf/OMTFProcessor.cc | 8 +- .../src/Omtf/OMTFReconstruction.cc | 80 ++++--- .../python/fakeOmtfParamsPhase2_cff.py | 17 -- .../python/simOmtfPhase2Digis_cfi.py | 29 +-- .../python/simOmtfPhase2Digis_extrapol_cfi.py | 57 ----- ...OverlapPatternGeneratorClassProb_phase2.py | 39 +--- ...uonOverlapPatternGenerator_displ_phase2.py | 47 +--- .../runMuonOverlapPatternGenerator_phase2.py | 216 +++++++++--------- .../expert/runMuonOverlap_NN_Regression_FP.py | 61 ++--- .../test/runMuonOverlap.py | 97 +++----- 11 files changed, 258 insertions(+), 395 deletions(-) delete mode 100644 L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py delete mode 100644 L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h index b4a1ffa0f0e87..868077a7f755a 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h @@ -67,6 +67,8 @@ class OMTFReconstruction { int bxMin, bxMax; ///OMTF objects + //omtfParams are created only if they are read from the xml file in beginRun(). If the params goes from eventSetup, omtfParams are null + unique_ptr omtfParams; unique_ptr omtfConfig; unique_ptr inputMaker; diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc index 7a8b0545d3c69..cc54c465a2201 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc @@ -95,7 +95,6 @@ void OMTFProcessor::init(const edm::ParameterSet& edmCfg, edm edm::LogVerbatim("OMTFReconstruction") << "useFloatingPointExtrapolation " << useFloatingPointExtrapolation << std::endl; - edm::LogVerbatim("OMTFReconstruction") << "extrapolFactorsFilename " << extrapolFactorsFilename << std::endl; } template @@ -294,7 +293,6 @@ std::vector OMTFProcessor::getFinalcan //check if it matters if it needs to be here as well trackAddr[1] = myCand->getRefLayer(); trackAddr[2] = myCand->getDisc(); - trackAddr[3] = myCand->getGpResultUnconstr().getPdfSumUnconstr(); if (candidate.hwPt() > 0 || candidate.hwPtUnconstrained() > 0) { candidate.setTrackAddress(trackAddr); candidate.setTFIdentifiers(iProcessor, mtfType); @@ -909,8 +907,8 @@ void OMTFProcessor::loadExtrapolFactors(const std::string& fi int iLayer = lutNode.second.get(".Layer"); std::string keyType = lutNode.second.get(".KeyType"); - edm::LogVerbatim("OMTFReconstruction") - << "iRefLayer " << iRefLayer << " iLayer " << iLayer << " keyType " << keyType << std::endl; + LogTrace("OMTFReconstruction") << "iRefLayer " << iRefLayer << " iLayer " << iLayer << " keyType " << keyType + << std::endl; auto& valueNodes = lutNode.second; for (boost::property_tree::ptree::value_type& valueNode : valueNodes) { @@ -918,7 +916,7 @@ void OMTFProcessor::loadExtrapolFactors(const std::string& fi int key = valueNode.second.get(".key"); float value = valueNode.second.get(".value"); extrapolFactors.at(iRefLayer).at(iLayer)[key] = value; - edm::LogVerbatim("OMTFReconstruction") << "key " << key << " value " << value << std::endl; + LogTrace("OMTFReconstruction") << "key " << key << " value " << value << std::endl; } } } diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc index 66bc9e0d809d2..c125f7f515648 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc @@ -64,8 +64,6 @@ void OMTFReconstruction::beginRun(edm::Run const& run, const MuonGeometryTokens& muonGeometryTokens, const edm::ESGetToken& magneticFieldEsToken, const edm::ESGetToken& propagatorEsToken) { - const L1TMuonOverlapParams* omtfParams = nullptr; - std::string processorType = "OMTFProcessor"; //GoldenPatternWithStat GoldenPattern if (edmParameterSet.exists("processorType")) { processorType = edmParameterSet.getParameter("processorType"); @@ -73,22 +71,29 @@ void OMTFReconstruction::beginRun(edm::Run const& run, bool buildPatternsFromXml = (edmParameterSet.exists("patternsXMLFile") || edmParameterSet.exists("patternsXMLFiles")); + bool readConfigFromXml = edmParameterSet.exists("configXMLFile"); + + if (buildPatternsFromXml != readConfigFromXml) + throw cms::Exception( + "OMTFReconstruction::beginRun: buildPatternsFromXml != readConfigFromXml - both patternsXMLFiles and " + "configXMLFile should be defined (or not) for the simOmtDigis or simOmtfPhase2Digis"); + edm::LogVerbatim("OMTFReconstruction") << "OMTFReconstruction::beginRun " << run.id() << " buildPatternsFromXml: " << buildPatternsFromXml << std::endl; //if the buildPatternsFromXml == false - we are making the omtfConfig and omtfProc for every run, //as the configuration my change between the runs, - //if buildPatternsFromXml == true - we assume the the entire configuration comes from phyton, - //so we do it only for the first run - if (omtfProc == nullptr || buildPatternsFromXml == false) { + if (buildPatternsFromXml == false) { if (omtfParamsRecordWatcher.check(eventSetup)) { edm::LogVerbatim("OMTFReconstruction") << "retrieving omtfParams from EventSetup" << std::endl; - omtfParams = &(eventSetup.getData(omtfParamsEsToken)); - if (!omtfParams) { - edm::LogError("OMTFReconstruction") << "Could not retrieve parameters from Event Setup" << std::endl; + const L1TMuonOverlapParams* omtfParamsFromES = &(eventSetup.getData(omtfParamsEsToken)); + if (!omtfParamsFromES) { + edm::LogError("OMTFReconstruction") << "Could not retrieve omtfParams from Event Setup" << std::endl; + throw cms::Exception("OMTFReconstruction::beginRun: Could not retrieve omtfParams from Event Setup"); } - omtfConfig->configure(omtfParams); + + omtfConfig->configure(omtfParamsFromES); //the parameters can be overwritten from the python config omtfConfig->configureFromEdmParameterSet(edmParameterSet); @@ -96,19 +101,45 @@ void OMTFReconstruction::beginRun(edm::Run const& run, inputMaker->initialize(edmParameterSet, eventSetup, muonGeometryTokens); //patterns from the edm::EventSetup are reloaded every beginRun - if (buildPatternsFromXml == false) { - edm::LogVerbatim("OMTFReconstruction") << "getting patterns from EventSetup" << std::endl; - if (processorType == "OMTFProcessor") { - omtfProc = std::make_unique >( - omtfConfig.get(), edmParameterSet, eventSetup, omtfParams); - omtfProc->printInfo(); - } + //therefore OMTFProcessor is re-created here + edm::LogVerbatim("OMTFReconstruction") << "getting patterns from EventSetup" << std::endl; + if (processorType == "OMTFProcessor") { + omtfProc = std::make_unique >( + omtfConfig.get(), edmParameterSet, eventSetup, omtfParamsFromES); + omtfProc->printInfo(); } } } - //if we read the patterns directly from the xml, we do it only once, at the beginning of the first run, not every run + //if buildPatternsFromXml == true - the entire configuration (patterns and hwToLogicLayer) comes from phyton, + //so we read it only once, at the beginning of the first run, not every run if (omtfProc == nullptr && buildPatternsFromXml) { + std::string fName = edmParameterSet.getParameter("configXMLFile").fullPath(); + + edm::LogVerbatim("OMTFReconstruction") + << "OMTFReconstruction::beginRun - reading config from file: " << fName << std::endl; + + XMLConfigReader xmlConfigReader; + xmlConfigReader.setConfigFile(fName); + + omtfParams.reset(new L1TMuonOverlapParams()); + xmlConfigReader.readConfig(omtfParams.get()); + + //getPatternsVersion() parses the entire patterns xml - si it is very inefficient + //moreover, PatternsVersion is not used anywhere + //Therefore we we dont use xmlPatternReader.getPatternsVersion(); but set patternsVersion to 0 + unsigned int patternsVersion = 0; + unsigned int fwVersion = omtfParams->fwVersion(); + omtfParams->setFwVersion((fwVersion << 16) + patternsVersion); + + omtfConfig->configure(omtfParams.get()); + + //the parameters can be overwritten from the python config + omtfConfig->configureFromEdmParameterSet(edmParameterSet); + + inputMaker->initialize(edmParameterSet, eventSetup, muonGeometryTokens); + + //reading patterns from the xml---------------------------------------------------------- std::vector patternsXMLFiles; if (edmParameterSet.exists("patternsXMLFile")) { @@ -122,8 +153,6 @@ void OMTFReconstruction::beginRun(edm::Run const& run, for (auto& patternsXMLFile : patternsXMLFiles) edm::LogVerbatim("OMTFReconstruction") << "reading patterns from " << patternsXMLFile << std::endl; - XMLConfigReader xmlReader; - std::string patternType = "GoldenPattern"; //GoldenPatternWithStat GoldenPattern if (edmParameterSet.exists("patternType")) { patternType = edmParameterSet.getParameter("patternType"); @@ -136,15 +165,14 @@ void OMTFReconstruction::beginRun(edm::Run const& run, omtfConfig.get(), edmParameterSet, eventSetup, - xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false)); + xmlConfigReader.readPatterns(*omtfParams, patternsXMLFiles, false)); } else { //in principle should not happen throw cms::Exception("OMTFReconstruction::beginRun: omtfParams is nullptr"); } } - edm::LogVerbatim("OMTFReconstruction") - << "OMTFProcessor constructed. processorType " << processorType << ". GoldenPattern type: " << patternType - << " nProcessors " << omtfConfig->nProcessors() << std::endl; + edm::LogVerbatim("OMTFReconstruction") << "OMTFProcessor constructed. processorType " << processorType + << ". GoldenPattern type: " << patternType << std::endl; } else if (patternType == "GoldenPatternWithStat") { //pattern generation is only possible if the processor is constructed only once per job //PatternGenerator modifies the patterns!!! @@ -154,7 +182,7 @@ void OMTFReconstruction::beginRun(edm::Run const& run, omtfConfig.get(), edmParameterSet, eventSetup, - xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false)); + xmlConfigReader.readPatterns(*omtfParams, patternsXMLFiles, false)); } else { //in principle should not happen throw cms::Exception("OMTFReconstruction::beginRun: omtfParams is nullptr"); } @@ -205,7 +233,7 @@ void OMTFReconstruction::addObservers( if (edmParameterSet.getParameter("eventCaptureDebug")) { observers.emplace_back(std::make_unique( edmParameterSet, omtfConfig.get(), candidateSimMuonMatcher, muonGeometryTokens - //, &(omtfProcGoldenPat->getPatterns() ) + //&(omtfProcGoldenPat->getPatterns() ), //watch out, will crash if the proc is re-constructed from the DB after L1TMuonOverlapParamsRcd change )); } @@ -228,7 +256,7 @@ void OMTFReconstruction::addObservers( if (edmParameterSet.getParameter("eventCaptureDebug")) { observers.emplace_back(std::make_unique( edmParameterSet, omtfConfig.get(), candidateSimMuonMatcher, muonGeometryTokens - //&(omtfProcGoldenPat->getPatterns() ) + //&(omtfProcGoldenPat->getPatterns() ), //watch out, will crash if the proc is re-constructed from the DB after L1TMuonOverlapParamsRcd change )); } diff --git a/L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py b/L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py deleted file mode 100644 index 421e4becc9d33..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase2/python/fakeOmtfParamsPhase2_cff.py +++ /dev/null @@ -1,17 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -omtfParamsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonOverlapParamsRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) -) - -###OMTF ESProducer. Fills CondFormats from XML files. -omtfParamsPhase2 = cms.ESProducer( - "L1TMuonOverlapPhase1ParamsESProducer", - patternsXMLFiles = cms.VPSet( - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt_classProb17_recalib2_minDP0.xml")), - ), - configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209.xml"), -) diff --git a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py b/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py index 4d09684bc869c..c27335f7bf28b 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py +++ b/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_cfi.py @@ -1,16 +1,19 @@ import FWCore.ParameterSet.Config as cms - ###OMTF emulator configuration -simOmtfPhase2Digis = cms.EDProducer("L1TMuonOverlapPhase2TrackProducer", - +simOmtfPhase2Digis = cms.EDProducer("L1TMuonOverlapPhase2TrackProducer", srcDTPh = cms.InputTag('simDtTriggerPrimitiveDigis'), srcDTTh = cms.InputTag('simDtTriggerPrimitiveDigis'), srcCSC = cms.InputTag('simCscTriggerPrimitiveDigis','MPCSORTED'), srcRPC = cms.InputTag('simMuonRPCDigis'), srcDTPhPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), - - simTracksTag = cms.InputTag('g4SimHits'), + srcDTThPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), + + ## XML / PATTERNS file: + configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209.xml"), + patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt_classProb17_recalib2_minDP0.xml"), + extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQual_ValueP1Scale_t20.xml"), + dumpResultToXML = cms.bool(False), dumpDetailedResultToXML = cms.bool(False), XMLDumpFileName = cms.string("TestEvents.xml"), @@ -18,7 +21,7 @@ readEventsFromXML = cms.bool(False), eventsXMLFiles = cms.vstring("TestEvents.xml"), - + dropRPCPrimitives = cms.bool(False), dropCSCPrimitives = cms.bool(False), @@ -42,13 +45,13 @@ stubEtaEncoding = cms.string("valueP1Scale"), #TODO change to valueP1Scale when InputMakerPhase2 is modifiwed - usePhiBExtrapolationFromMB1 = cms.bool(False), - usePhiBExtrapolationFromMB2 = cms.bool(False), - useStubQualInExtr = cms.bool(False), - useEndcapStubsRInExtr = cms.bool(False), + usePhiBExtrapolationFromMB1 = cms.bool(True), + usePhiBExtrapolationFromMB2 = cms.bool(True), + useStubQualInExtr = cms.bool(True), + useEndcapStubsRInExtr = cms.bool(True), useFloatingPointExtrapolation = cms.bool(False), - + sorterType = cms.string("byLLH"), - ghostBusterType = cms.string("GhostBusterPreferRefDt"), # byLLH byRefLayer GhostBusterPreferRefDt - goldenPatternResultFinalizeFunction = cms.int32(9) + ghostBusterType = cms.string("byRefLayer"), # byLLH byRefLayer GhostBusterPreferRefDt + goldenPatternResultFinalizeFunction = cms.int32(10) ) diff --git a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py b/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py deleted file mode 100644 index 141fd8c3094f7..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase2/python/simOmtfPhase2Digis_extrapol_cfi.py +++ /dev/null @@ -1,57 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -###OMTF emulator configuration -simOmtfPhase2Digis = cms.EDProducer("L1TMuonOverlapPhase2TrackProducer", - - srcDTPh = cms.InputTag('simDtTriggerPrimitiveDigis'), - srcDTTh = cms.InputTag('simDtTriggerPrimitiveDigis'), - srcCSC = cms.InputTag('simCscTriggerPrimitiveDigis','MPCSORTED'), - srcRPC = cms.InputTag('simMuonRPCDigis'), - srcDTPhPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), - srcDTThPhase2 = cms.InputTag('dtTriggerPhase2PrimitiveDigis'), - - dumpResultToXML = cms.bool(False), - dumpDetailedResultToXML = cms.bool(False), - XMLDumpFileName = cms.string("TestEvents.xml"), - dumpGPToXML = cms.bool(False), - readEventsFromXML = cms.bool(False), - eventsXMLFiles = cms.vstring("TestEvents.xml"), - - - dropRPCPrimitives = cms.bool(False), - dropCSCPrimitives = cms.bool(False), - - dropDTPrimitives = cms.bool(True), - usePhase2DTPrimitives = cms.bool(True), #if usePhase2DTPrimitives is True, dropDTPrimitives must be True as well - - processorType = cms.string("OMTFProcessor"), - - #if commented the default values are 0-0 - #-3 to 4 is the range of the OMTF DAQ readout, so should be used e.g. in the DQM data to emulator comparison - bxMin = cms.int32(0), - bxMax = cms.int32(0), - - noHitValueInPdf = cms.bool(True), - minDtPhiQuality = cms.int32(2), - minDtPhiBQuality = cms.int32(4), - - dtRefHitMinQuality = cms.int32(4), - - dtPhiBUnitsRad = cms.int32(1024), #2048 is the orginal phase2 scale, 512 is the phase1 scale - - stubEtaEncoding = cms.string("valueP1Scale"), #TODO change to valueP1Scale when InputMakerPhase2 is modifiwed - - usePhiBExtrapolationFromMB1 = cms.bool(True), - usePhiBExtrapolationFromMB2 = cms.bool(True), - useStubQualInExtr = cms.bool(True), - useEndcapStubsRInExtr = cms.bool(True), - useFloatingPointExtrapolation = cms.bool(False), - - ## XML / PATTERNS file: - patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt_classProb17_recalib2_minDP0.xml"), - extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQual_ValueP1Scale_t20.xml"), - - sorterType = cms.string("byLLH"), - ghostBusterType = cms.string("byRefLayer"), # byLLH byRefLayer GhostBusterPreferRefDt - goldenPatternResultFinalizeFunction = cms.int32(10) -) diff --git a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py index 26d85b1882c8d..1424f262809c4 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py +++ b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGeneratorClassProb_phase2.py @@ -11,12 +11,14 @@ verbose = True -versionIn = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu_iPt_and_OneOverPt" +versionIn = "ExtraplMB1nadMB2DTQualAndRFixedP_ValueP1Scale_t25c__mcWaw2023_OneOverPt_and_iPt2_mcWaw2023_OneOverPt_and_iPt2" #versionIn = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_SingleMu_mcWaw2023_OneOverPt" #versionIn = "ExtraplMB1nadMB2DTQualAndEtaValueP1Scale_t18" #versionIn = "0x00011_oldSample_3_30Files" -versionOut = versionIn + "_classProb17_recalib2_minDP0" +#versionOut = versionIn + "_classProb17_recalib2" #_classProb17_recalib2_minDP0 + +versionOut = "ExtraplMB1nadMB2DTQualAndRFixedP_ValueP1Scale_t25c_" + "_classProb17_recalib2" if verbose: process.MessageLogger = cms.Service("MessageLogger", @@ -50,25 +52,22 @@ #SkipEvent = cms.untracked.vstring('ProductNotFound') ) -# PostLS1 geometry used -process.load('Configuration.Geometry.GeometryExtended2015Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2015_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') # import of standard configurations 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.GeometryExtended2026D41Reco_cff') -#process.load('Configuration.Geometry.GeometryExtended2026D41_cff') + process.load('Configuration.StandardSequences.MagneticField_cff') #process.load('Configuration.StandardSequences.SimL1Emulator_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') -process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') path = '/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/' #old sample, but very big #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v2/' #new sample, but small and more noisy @@ -112,21 +111,6 @@ process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1)) - -####Event Setup Producer -process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff') -process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0009_patGen.xml") -process.omtfParams.patternsXMLFiles = cms.VPSet( - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")), ) - -process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter", - toGet = cms.VPSet( - cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'), - data = cms.vstring('L1TMuonOverlapParams')) - ), - verbose = cms.untracked.bool(False) -) - #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) ) ####OMTF Emulator @@ -138,7 +122,7 @@ process.simOmtfDigis.dumpResultToXML = cms.bool(False) process.simOmtfDigis.eventCaptureDebug = cms.bool(False) -process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml") +process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_template.xml") #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb1_recalib.xml") #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb11_recalib2.xml") #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0009_oldSample_3_10Files_classProb2.xml") @@ -157,7 +141,7 @@ #process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00011_oldSample_3_30Files_layerStat.root") #process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2_t14.root") #process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2FullAlgo_t16.root") -process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase2/test/expert/Patterns_layerStat/Patterns_layerStat_" + versionIn + ".root") +process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_layerStat_" + versionIn + ".root") process.simOmtfDigis.patternType = cms.string("GoldenPatternWithStat") process.simOmtfDigis.generatePatterns = cms.bool(True) @@ -179,8 +163,7 @@ #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") -process.L1TMuonSeq = cms.Sequence( process.esProd - + process.simOmtfDigis +process.L1TMuonSeq = cms.Sequence( process.simOmtfDigis #+ process.dumpED #+ process.dumpES ) diff --git a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py index 1088d85b80877..85e275437f247 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py +++ b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_displ_phase2.py @@ -52,25 +52,23 @@ #SkipEvent = cms.untracked.vstring('ProductNotFound') ) -# PostLS1 geometry used -process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D86_cff') - # import of standard configurations 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.GeometryExtended2026D41Reco_cff') -#process.load('Configuration.Geometry.GeometryExtended2026D41_cff') +#process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +#process.load('FWCore.MessageService.MessageLogger_cfi') +#process.load('Configuration.EventContent.EventContent_cff') +#process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D95Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') +#process.load('Configuration.StandardSequences.RawToDigi_cff') #process.load('Configuration.StandardSequences.SimL1Emulator_cff') +#process.load('Configuration.StandardSequences.SimPhase2L1GlobalTriggerEmulator_cff') +#process.load('L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.prototypeSeeds') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') -process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '131X_mcRun4_realistic_v9', '') chosenFiles = [] @@ -173,32 +171,10 @@ process.dtTriggerPhase2PrimitiveDigis.dump = False process.dtTriggerPhase2PrimitiveDigis.scenario = 0 -####Event Setup Producer -process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff') -process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209_patGen.xml") - -process.omtfParams.patternsXMLFiles = cms.VPSet( - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0003.xml")), - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0009_oldSample_3_10Files_classProb1.xml") ), - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")), - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb17_recalib2.xml")), - #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2_t10_classProb17_recalib2.xml")), - ) - - - -process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter", - toGet = cms.VPSet( - cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'), - data = cms.vstring('L1TMuonOverlapParams')) - ), - verbose = cms.untracked.bool(False) -) - #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) ) ####OMTF Emulator -process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_extrapol_cfi') +process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_cfi') #needed by candidateSimMuonMatcher process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") @@ -268,8 +244,7 @@ #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") -process.L1TMuonSeq = cms.Sequence( process.esProd - + process.simOmtfPhase2Digis +process.L1TMuonSeq = cms.Sequence( process.simOmtfPhase2Digis #+ process.dumpED #+ process.dumpES ) diff --git a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py index 418ee3886df5d..c2a761120ceb1 100644 --- a/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py +++ b/L1Trigger/L1TMuonOverlapPhase2/test/expert/runMuonOverlapPatternGenerator_phase2.py @@ -13,10 +13,18 @@ verbose = True -filesNameLike = sys.argv[2] +filesNameLike = sys.argv[1] -version = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu" +runDebug = "DEBUG" # or "INFO" DEBUG + +#version = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_v1_SingleMu" #version = "noExtrapl_ValueP1Scale_t18_qualConverted_min4_ipT1_deltaPhiVsPhiRef_fixedDTScale" +version = "ExtraplMB1nadMB2DTQualAndRFixedP_ValueP1Scale_DT_4_4_t25c_" + filesNameLike + +regeneratedL1DT = True + +if not regeneratedL1DT : + version = version + "_noDTReGen" if verbose: process.MessageLogger = cms.Service("MessageLogger", @@ -50,114 +58,109 @@ #SkipEvent = cms.untracked.vstring('ProductNotFound') ) -# PostLS1 geometry used -process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D86_cff') - # import of standard configurations 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.GeometryExtended2026D41Reco_cff') -#process.load('Configuration.Geometry.GeometryExtended2026D41_cff') +#process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +#process.load('FWCore.MessageService.MessageLogger_cfi') +#process.load('Configuration.EventContent.EventContent_cff') +#process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D95Reco_cff') process.load('Configuration.StandardSequences.MagneticField_cff') +#process.load('Configuration.StandardSequences.RawToDigi_cff') #process.load('Configuration.StandardSequences.SimL1Emulator_cff') +#process.load('Configuration.StandardSequences.SimPhase2L1GlobalTriggerEmulator_cff') +#process.load('L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.prototypeSeeds') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') -process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '131X_mcRun4_realistic_v9', '') chosenFiles = [] cscBx = 8 - -if filesNameLike == 'mcWaw2023' : +fileCnt = 100000 #1000 +if filesNameLike == 'mcWaw2023_OneOverPt_and_iPt2': cscBx = 8 - - file_cnt = 100000 - for iPt in [0, 1, 2] : - for charge in [0, 2] : - path = "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch" + str(charge) + "_iPt" + str(iPt) + "_12_5_2_p1_04_04_2023/12_5_2_p1_04_04_2023/" - #path = '/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt1_12_5_2_p1_04_04_2023/12_5_2_p1_04_04_2023/230404_084317/0000/' - - root_files = [] - for root, dirs, files in os.walk(path): - for file in fnmatch.filter(files, 'SingleMu*.root'): - root_files.append(os.path.join(root, file)) - - file_num = 0 - for root_file in root_files : - if isfile(root_file) : - chosenFiles.append('file://' + root_file) - file_num += 1 - else : - print("file not found!!!!!!!: " + root_file) - - if file_num >= file_cnt : - break + matchUsingPropagation = False + paths = [ + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_20_04_2023/", "fileCnt" : 500}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_20_04_2023/", "fileCnt" : 500}, #500 files + # + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_14_04_2023/", "fileCnt" : 500}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_14_04_2023/", "fileCnt" : 500}, #500 files + # + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + # + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_22_02_2023/", "fileCnt" : 500}, #200 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_22_02_2023/", "fileCnt" : 500}, #200 files + # + # {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_15_02_2023/", "fileCnt" : 500}, ##100 files + # {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_15_02_2023/", "fileCnt" : 500}, ##100 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt2_12_5_2_p1_04_04_2023/", "fileCnt" : 200}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_iPt2_12_5_2_p1_04_04_2023/", "fileCnt" : 200}, #500 files + ] + +if filesNameLike == 'mcWaw2023_iPt1': + cscBx = 8 + matchUsingPropagation = False + paths = [ + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_20_04_2023/", #500 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_20_04_2023/", #500 files + # + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_14_04_2023/", #500 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_14_04_2023/", #500 files + # + #{"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + #{"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_04_04_2023/", "fileCnt" : 500}, #500 files + # + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_22_02_2023/", #200 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_22_02_2023/", #200 files + # + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_15_02_2023/", ##100 files + # "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_15_02_2023/", ##100 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt1_12_5_2_p1_04_04_2023/", "fileCnt" : 100}, #500 files + {"path": "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch2_iPt1_12_5_2_p1_04_04_2023/", "fileCnt" : 100}, #500 files + ] + + +print("input data paths", paths) + +if(runDebug == "DEBUG") : + fileCnt = 1; + +for path in paths : + root_files = [] + for root, dirs, files in os.walk(path["path"]): + for file in fnmatch.filter(files, '*.root'): + root_files.append(os.path.join(root, file)) - + file_num = 0 + for root_file in root_files : + if isfile(root_file) : + chosenFiles.append('file://' + root_file) + file_num += 1 + else : + print("file not found!!!!!!!: " + root_file) + + if file_num >= path["fileCnt"] : + break + if file_num >= fileCnt : + break - paths = ["/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch0_iPt0_12_5_2_p1_22_02_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_22_02_2023/SingleMu_ch2_iPt0_12_5_2_p1_22_02_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch0_iPt0_12_5_2_p1_15_02_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_15_02_2023/SingleMu_ch2_iPt0_12_5_2_p1_15_02_2023/"] - - for path in paths : - root_files = [] - for root, dirs, files in os.walk(path): - for file in fnmatch.filter(files, 'SingleMu*.root'): - root_files.append(os.path.join(root, file)) - - file_num = 0 - for root_file in root_files : - if isfile(root_file) : - chosenFiles.append('file://' + root_file) - file_num += 1 - else : - print("file not found!!!!!!!: " + root_file) - - if file_num >= file_cnt : - break - -if filesNameLike == 'mcWaw2023_OneOverPt' : - cscBx = 8 - - file_cnt = 100000 - paths = ["/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_20_04_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_20_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_20_04_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch0_OneOverPt_12_5_2_p1_14_04_2023/", - "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_14_04_2023/SingleMu_ch2_OneOverPt_12_5_2_p1_14_04_2023/"] - - for path in paths : - root_files = [] - for root, dirs, files in os.walk(path): - for file in fnmatch.filter(files, 'SingleMu*.root'): - root_files.append(os.path.join(root, file)) - - file_num = 0 - for root_file in root_files : - if isfile(root_file) : - chosenFiles.append('file://' + root_file) - file_num += 1 - else : - print("file not found!!!!!!!: " + root_file) - - if file_num >= file_cnt : - break - print("chosenFiles") for chFile in chosenFiles: print(chFile) -print("number of chosen files:", len(chosenFiles)) + +print("chosen file count", len(chosenFiles) ) if len(chosenFiles) == 0 : - print("no files selected!!!!!!!!!!!!!!! (argumetn should be e.g. 20_p") - exit + print("no files selected!!!!!!!!!!!!!!!") + exit + +print("running version", version) # input files (up to 255 files accepted) process.source = cms.Source('PoolSource', @@ -187,24 +190,14 @@ process.dtTriggerPhase2PrimitiveDigis.dump = False process.dtTriggerPhase2PrimitiveDigis.scenario = 0 -####Event Setup Producer -process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff') -process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0209_patGen.xml") -process.omtfParams.patternsXMLFiles = cms.VPSet( - cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")), ) - -process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter", - toGet = cms.VPSet( - cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'), - data = cms.vstring('L1TMuonOverlapParams')) - ), - verbose = cms.untracked.bool(False) -) +# STD aelow are the defoult values +#process.dtTriggerPhase2PrimitiveDigis.algo = 0 ## initial grouping +#process.dtTriggerPhase2PrimitiveDigis.df_extended = 0 #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) ) ####OMTF Emulator -process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_extrapol_cfi') +process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_cfi') #needed by candidateSimMuonMatcher process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") @@ -223,7 +216,7 @@ process.simOmtfPhase2Digis.dumpResultToXML = cms.bool(False) process.simOmtfPhase2Digis.eventCaptureDebug = cms.bool(False) -process.simOmtfPhase2Digis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml") +process.simOmtfPhase2Digis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_template.xml") #process.simOmtfPhase2Digis.patternsXMLFiles = cms.VPSet(cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_plus_v1.xml")), # cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_minus_v1.xml")) #) @@ -243,7 +236,7 @@ process.simOmtfPhase2Digis.minCSCStubRME12 = cms.int32(410) #[cm] process.simOmtfPhase2Digis.minCSCStubR = cms.int32(500) #[cm] -process.simOmtfPhase2Digis.minDtPhiQuality = cms.int32(2) +process.simOmtfPhase2Digis.minDtPhiQuality = cms.int32(4) process.simOmtfPhase2Digis.minDtPhiBQuality = cms.int32(4) process.simOmtfPhase2Digis.dtRefHitMinQuality = cms.int32(4) @@ -254,7 +247,7 @@ process.simOmtfPhase2Digis.useStubQualInExtr = cms.bool(True) process.simOmtfPhase2Digis.useEndcapStubsRInExtr = cms.bool(True) process.simOmtfPhase2Digis.useFloatingPointExtrapolation = cms.bool(False) -#process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("ExtrapolationFactors_ExtraplMB1nadMB2DTQualAndEta_ValueP1Scale_t20_SingleMu_iPt_100files_mcWaw2023.xml") +process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQualAndR_EtaValueP1Scale_t25c.xml") process.simOmtfPhase2Digis.stubEtaEncoding = cms.string("valueP1Scale") @@ -263,13 +256,18 @@ #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") -process.L1TMuonSeq = cms.Sequence( process.esProd - + process.simOmtfPhase2Digis +process.L1TMuonSeq = cms.Sequence( process.simOmtfPhase2Digis #+ process.dumpED #+ process.dumpES ) -process.L1TMuonPath = cms.Path(process.L1TMuonSeq) +if not regeneratedL1DT : + process.L1TMuonPath = cms.Path(process.L1TMuonSeq) ########################################<<<<< Date: Thu, 23 May 2024 09:30:02 -0500 Subject: [PATCH 067/301] Added ModuleAllocMonitor Service This uses the AllocMonitor system to monitor the memory usage done by each module as well as the source and memory released at end of event. --- PerfTools/AllocMonitor/plugins/BuildFile.xml | 1 + .../plugins/ModuleAllocMonitor.cc | 198 +++ .../AllocMonitor/plugins/ThreadAllocInfo.h | 52 + .../plugins/moduleAlloc_setupFile.cc | 1027 +++++++++++ .../plugins/moduleAlloc_setupFile.h | 37 + .../plugins/monitor_file_utilities.cc | 32 + .../plugins/monitor_file_utilities.h | 43 + .../scripts/edmModuleAllocMonitorAnalyze.py | 1524 +++++++++++++++++ PerfTools/AllocMonitor/test/BuildFile.xml | 2 + .../AllocMonitor/test/moduleAlloc_cfg.py | 50 + PerfTools/AllocMonitor/test/runModuleAlloc.sh | 52 + .../test/unittest_output/allEDModules.log | 110 ++ .../test/unittest_output/allESModules.log | 12 + .../test/unittest_output/allTransitions.log | 43 + .../unittest_output/only_ed_EDModules.log | 24 + .../unittest_output/only_ed_ESModules.log | 0 .../unittest_output/only_es_EDModules.log | 0 .../unittest_output/only_es_ESModules.log | 10 + .../unittest_output/skipEvents_EDModules.log | 48 + .../unittest_output/skipEvents_ESModules.log | 0 .../skipEvents_Transitions.log | 39 + 21 files changed, 3304 insertions(+) create mode 100644 PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc create mode 100644 PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h create mode 100644 PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc create mode 100644 PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.h create mode 100644 PerfTools/AllocMonitor/plugins/monitor_file_utilities.cc create mode 100644 PerfTools/AllocMonitor/plugins/monitor_file_utilities.h create mode 100644 PerfTools/AllocMonitor/scripts/edmModuleAllocMonitorAnalyze.py create mode 100644 PerfTools/AllocMonitor/test/moduleAlloc_cfg.py create mode 100755 PerfTools/AllocMonitor/test/runModuleAlloc.sh create mode 100644 PerfTools/AllocMonitor/test/unittest_output/allEDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/allESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/allTransitions.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_ed_EDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_ed_ESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_es_EDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/only_es_ESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/skipEvents_EDModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/skipEvents_ESModules.log create mode 100644 PerfTools/AllocMonitor/test/unittest_output/skipEvents_Transitions.log diff --git a/PerfTools/AllocMonitor/plugins/BuildFile.xml b/PerfTools/AllocMonitor/plugins/BuildFile.xml index f7306fd1ae1f7..f8e81afbfe9b6 100644 --- a/PerfTools/AllocMonitor/plugins/BuildFile.xml +++ b/PerfTools/AllocMonitor/plugins/BuildFile.xml @@ -1,3 +1,4 @@ + diff --git a/PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc b/PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc new file mode 100644 index 0000000000000..be3d19059847f --- /dev/null +++ b/PerfTools/AllocMonitor/plugins/ModuleAllocMonitor.cc @@ -0,0 +1,198 @@ +// -*- C++ -*- +// +// Package: PerfTools/AllocMonitor +// Class : EventProcessingAllocMonitor +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Mon, 21 Aug 2023 20:31:57 GMT +// + +// system include files +#include + +// user include files +#include "PerfTools/AllocMonitor/interface/AllocMonitorBase.h" +#include "PerfTools/AllocMonitor/interface/AllocMonitorRegistry.h" +#include "FWCore/Framework/interface/ComponentDescription.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" +#include "FWCore/ServiceRegistry/interface/ServiceMaker.h" +#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" + +#include "moduleAlloc_setupFile.h" +#include "ThreadAllocInfo.h" + +namespace { + using namespace edm::service::moduleAlloc; + class MonitorAdaptor : public cms::perftools::AllocMonitorBase { + public: + static void startOnThread() { threadAllocInfo().reset(); } + static ThreadAllocInfo const& stopOnThread() { + auto& t = threadAllocInfo(); + if (not t.active_) { + t.reset(); + } else { + t.deactivate(); + } + return t; + } + + private: + static ThreadAllocInfo& threadAllocInfo() { + thread_local ThreadAllocInfo s_info; + return s_info; + } + void allocCalled(size_t iRequested, size_t iActual) final { + auto& allocInfo = threadAllocInfo(); + if (not allocInfo.active_) { + return; + } + allocInfo.nAllocations_ += 1; + allocInfo.requested_ += iRequested; + + if (allocInfo.maxSingleAlloc_ < iRequested) { + allocInfo.maxSingleAlloc_ = iRequested; + } + + allocInfo.presentActual_ += iActual; + if (allocInfo.presentActual_ > static_cast(allocInfo.maxActual_)) { + allocInfo.maxActual_ = allocInfo.presentActual_; + } + } + void deallocCalled(size_t iActual) final { + auto& allocInfo = threadAllocInfo(); + if (not allocInfo.active_) { + return; + } + + allocInfo.nDeallocations_ += 1; + allocInfo.presentActual_ -= iActual; + if (allocInfo.presentActual_ < 0) { + if (allocInfo.minActual_ == 0 or allocInfo.minActual_ > allocInfo.presentActual_) { + allocInfo.minActual_ = allocInfo.presentActual_; + } + } + } + }; + +} // namespace + +namespace edm::service::moduleAlloc { + Filter::Filter(std::vector const* moduleIDs) : moduleIDs_{moduleIDs} {} + + bool Filter::startOnThread(int moduleID) const { + if (not globalKeep_.load()) { + return false; + } + if (keepModuleInfo(moduleID)) { + MonitorAdaptor::startOnThread(); + return true; + } + return false; + } + + const ThreadAllocInfo* Filter::stopOnThread(int moduleID) const { + if (not globalKeep_.load()) { + return nullptr; + } + + if (keepModuleInfo(moduleID)) { + return &MonitorAdaptor::stopOnThread(); + } + return nullptr; + } + + bool Filter::startOnThread() const { + if (not globalKeep_.load()) { + return false; + } + MonitorAdaptor::startOnThread(); + return true; + } + + const ThreadAllocInfo* Filter::stopOnThread() const { + if (not globalKeep_.load()) { + return nullptr; + } + return &MonitorAdaptor::stopOnThread(); + } + + void Filter::setGlobalKeep(bool iShouldKeep) { globalKeep_.store(iShouldKeep); } + + bool Filter::keepModuleInfo(int moduleID) const { + if ((nullptr == moduleIDs_) or (moduleIDs_->empty()) or + (std::binary_search(moduleIDs_->begin(), moduleIDs_->end(), moduleID))) { + return true; + } + return false; + } +} // namespace edm::service::moduleAlloc + +class ModuleAllocMonitor { +public: + ModuleAllocMonitor(edm::ParameterSet const& iPS, edm::ActivityRegistry& iAR) + : moduleNames_(iPS.getUntrackedParameter>("moduleNames")), + nEventsToSkip_(iPS.getUntrackedParameter("nEventsToSkip")), + filter_(&moduleIDs_) { + (void)cms::perftools::AllocMonitorRegistry::instance().createAndRegisterMonitor(); + + if (nEventsToSkip_ > 0) { + filter_.setGlobalKeep(false); + } + if (not moduleNames_.empty()) { + iAR.watchPreModuleConstruction([this](auto const& description) { + auto found = std::find(moduleNames_.begin(), moduleNames_.end(), description.moduleLabel()); + if (found != moduleNames_.end()) { + moduleIDs_.push_back(description.id()); + std::sort(moduleIDs_.begin(), moduleIDs_.end()); + } + }); + + iAR.watchPostESModuleRegistration([this](auto const& iDescription) { + auto label = iDescription.label_; + if (label.empty()) { + label = iDescription.type_; + } + auto found = std::find(moduleNames_.begin(), moduleNames_.end(), label); + if (found != moduleNames_.end()) { + //NOTE: we want the id to start at 1 not 0 + moduleIDs_.push_back(-1 * (iDescription.id_ + 1)); + std::sort(moduleIDs_.begin(), moduleIDs_.end()); + } + }); + } + if (nEventsToSkip_ > 0) { + iAR.watchPreSourceEvent([this](auto) { + ++nEventsStarted_; + if (nEventsStarted_ > nEventsToSkip_) { + filter_.setGlobalKeep(true); + } + }); + } + edm::service::moduleAlloc::setupFile(iPS.getUntrackedParameter("fileName"), iAR, &filter_); + } + + static void fillDescriptions(edm::ConfigurationDescriptions& iDesc) { + edm::ParameterSetDescription ps; + ps.addUntracked("fileName"); + ps.addUntracked>("moduleNames", std::vector()); + ps.addUntracked("nEventsToSkip", 0); + iDesc.addDefault(ps); + } + +private: + bool forThisModule(unsigned int iID) { + return (moduleNames_.empty() or std::binary_search(moduleIDs_.begin(), moduleIDs_.end(), iID)); + } + std::vector moduleNames_; + std::vector moduleIDs_; + unsigned int nEventsToSkip_ = 0; + std::atomic nEventsStarted_{0}; + edm::service::moduleAlloc::Filter filter_; +}; + +DEFINE_FWK_SERVICE(ModuleAllocMonitor); diff --git a/PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h b/PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h new file mode 100644 index 0000000000000..868cf917a37f9 --- /dev/null +++ b/PerfTools/AllocMonitor/plugins/ThreadAllocInfo.h @@ -0,0 +1,52 @@ +#ifndef PerfTools_AllocMonitor_ThreadAllocInfo_h +#define PerfTools_AllocMonitor_ThreadAllocInfo_h +// -*- C++ -*- +// +// Package: PerfTools/AllocMonitor +// Class : ThreadAllocInfo +// +/**\class ThreadAllocInfo ThreadAllocInfo.h "ThreadAllocInfo.h" + + Description: information about per module allocations + + Usage: + + +*/ +// +// Original Author: Christopher Jones +// Created: Fri, 10 May 2024 14:48:59 GMT +// + +// system include files + +// user include files + +// forward declarations + +namespace edm::service::moduleAlloc { + struct ThreadAllocInfo { + size_t requested_ = 0; + long long presentActual_ = 0; + size_t maxActual_ = 0; + long long minActual_ = 0; + size_t maxSingleAlloc_ = 0; + size_t nAllocations_ = 0; + size_t nDeallocations_ = 0; + bool active_ = false; + + void reset() { + requested_ = 0; + presentActual_ = 0; + maxActual_ = 0; + minActual_ = 0; + maxSingleAlloc_ = 0; + nAllocations_ = 0; + nDeallocations_ = 0; + active_ = true; + } + + void deactivate() { active_ = false; } + }; +} // namespace edm::service::moduleAlloc +#endif diff --git a/PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc b/PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc new file mode 100644 index 0000000000000..cd271170ac036 --- /dev/null +++ b/PerfTools/AllocMonitor/plugins/moduleAlloc_setupFile.cc @@ -0,0 +1,1027 @@ +#include "moduleAlloc_setupFile.h" +#include "monitor_file_utilities.h" + +#include + +#include +#include +#include +#include + +#include "FWCore/Concurrency/interface/ThreadSafeOutputFileStream.h" + +#include "DataFormats/Provenance/interface/EventID.h" +#include "DataFormats/Provenance/interface/LuminosityBlockID.h" +#include "DataFormats/Provenance/interface/ModuleDescription.h" +#include "DataFormats/Provenance/interface/RunID.h" +#include "DataFormats/Provenance/interface/Timestamp.h" + +#include "FWCore/ServiceRegistry/interface/GlobalContext.h" +#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" +#include "FWCore/ServiceRegistry/interface/ESModuleCallingContext.h" +#include "FWCore/ServiceRegistry/interface/PathContext.h" +#include "FWCore/ServiceRegistry/interface/ProcessContext.h" +#include "FWCore/ServiceRegistry/interface/StreamContext.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" + +#include "FWCore/Framework/interface/IOVSyncValue.h" +#include "FWCore/Framework/interface/ESRecordsToProductResolverIndices.h" + +#include "FWCore/Utilities/interface/TimingServiceBase.h" + +#include "ThreadAllocInfo.h" + +using namespace edm::moduleAlloc::monitor_file_utilities; + +namespace { + using duration_t = std::chrono::microseconds; + using clock_t = std::chrono::steady_clock; + auto const now = clock_t::now; + + enum class Step : char { + preSourceTransition = 'S', + postSourceTransition = 's', + preModuleEventAcquire = 'A', + postModuleEventAcquire = 'a', + preModuleTransition = 'M', + preEventReadFromSource = 'R', + postEventReadFromSource = 'r', + preModuleEventDelayedGet = 'D', + postModuleEventDelayedGet = 'd', + postModuleTransition = 'm', + preESModule = 'N', + postESModule = 'n', + preESModuleAcquire = 'B', + postESModuleAcquire = 'b', + preFrameworkTransition = 'F', + postFrameworkTransition = 'f' + }; + + constexpr bool isPostTransition(Step s) { + switch (s) { + case Step::postSourceTransition: + case Step::postModuleEventAcquire: + case Step::postEventReadFromSource: + case Step::postModuleEventDelayedGet: + case Step::postModuleTransition: + case Step::postESModule: + case Step::postESModuleAcquire: + case Step::postFrameworkTransition: + return true; + default: + return false; + } + return false; + } + + enum class Phase : short { + destruction = -16, + endJob = -12, + endStream = -11, + writeProcessBlock = -10, + endProcessBlock = -9, + globalWriteRun = -7, + globalEndRun = -6, + streamEndRun = -5, + globalWriteLumi = -4, + globalEndLumi = -3, + streamEndLumi = -2, + clearEvent = -1, + Event = 0, + streamBeginLumi = 2, + globalBeginLumi = 3, + streamBeginRun = 5, + globalBeginRun = 6, + accessInputProcessBlock = 8, + beginProcessBlock = 9, + openFile = 10, + beginStream = 11, + beginJob = 12, + esSync = 13, + esSyncEnqueue = 14, + getNextTransition = 15, + construction = 16, + startTracing = 17 + }; + + std::ostream& operator<<(std::ostream& os, Step const s) { + os << static_cast>(s); + return os; + } + + std::ostream& operator<<(std::ostream& os, Phase const s) { + os << static_cast>(s); + return os; + } + + template + std::string assembleMessage(ARGS const... args) { + std::ostringstream oss; + oss << S; + concatenate(oss, args...); + oss << '\n'; + return oss.str(); + } + + template + std::string assembleAllocMessage(edm::service::moduleAlloc::ThreadAllocInfo const& info, ARGS const... args) { + std::ostringstream oss; + oss << S; + concatenate(oss, args...); + concatenate(oss, + info.nAllocations_, + info.nDeallocations_, + info.presentActual_, + info.minActual_, + info.maxActual_, + info.maxSingleAlloc_); + oss << '\n'; + return oss.str(); + } + + Phase toTransitionImpl(edm::StreamContext const& iContext) { + using namespace edm; + switch (iContext.transition()) { + case StreamContext::Transition::kBeginStream: + return Phase::beginStream; + case StreamContext::Transition::kBeginRun: + return Phase::streamBeginRun; + case StreamContext::Transition::kBeginLuminosityBlock: + return Phase::streamBeginLumi; + case StreamContext::Transition::kEvent: + return Phase::Event; + case StreamContext::Transition::kEndLuminosityBlock: + return Phase::streamEndLumi; + case StreamContext::Transition::kEndRun: + return Phase::streamEndRun; + case StreamContext::Transition::kEndStream: + return Phase::endStream; + default: + break; + } + assert(false); + return Phase::Event; + } + + auto toTransition(edm::StreamContext const& iContext) -> std::underlying_type_t { + return static_cast>(toTransitionImpl(iContext)); + } + + Phase toTransitionImpl(edm::GlobalContext const& iContext) { + using namespace edm; + switch (iContext.transition()) { + case GlobalContext::Transition::kBeginProcessBlock: + return Phase::beginProcessBlock; + case GlobalContext::Transition::kAccessInputProcessBlock: + return Phase::accessInputProcessBlock; + case GlobalContext::Transition::kBeginRun: + return Phase::globalBeginRun; + case GlobalContext::Transition::kBeginLuminosityBlock: + return Phase::globalBeginLumi; + case GlobalContext::Transition::kEndLuminosityBlock: + return Phase::globalEndLumi; + case GlobalContext::Transition::kWriteLuminosityBlock: + return Phase::globalWriteLumi; + case GlobalContext::Transition::kEndRun: + return Phase::globalEndRun; + case GlobalContext::Transition::kWriteRun: + return Phase::globalWriteRun; + case GlobalContext::Transition::kEndProcessBlock: + return Phase::endProcessBlock; + case GlobalContext::Transition::kWriteProcessBlock: + return Phase::writeProcessBlock; + default: + break; + } + assert(false); + return Phase::Event; + } + auto toTransition(edm::GlobalContext const& iContext) -> std::underlying_type_t { + return static_cast>(toTransitionImpl(iContext)); + } + + unsigned int toTransitionIndex(edm::GlobalContext const& iContext) { + if (iContext.transition() == edm::GlobalContext::Transition::kBeginProcessBlock or + iContext.transition() == edm::GlobalContext::Transition::kEndProcessBlock or + iContext.transition() == edm::GlobalContext::Transition::kWriteProcessBlock or + iContext.transition() == edm::GlobalContext::Transition::kAccessInputProcessBlock) { + return 0; + } + if (iContext.transition() == edm::GlobalContext::Transition::kBeginRun or + iContext.transition() == edm::GlobalContext::Transition::kEndRun or + iContext.transition() == edm::GlobalContext::Transition::kWriteRun) { + return iContext.runIndex(); + } + return iContext.luminosityBlockIndex(); + } + + using namespace edm::service::moduleAlloc; + + template + struct ESModuleState { + ESModuleState(std::shared_ptr logFile, + decltype(now()) beginTime, + std::shared_ptr> recordIndices, + Filter const* iFilter) + : logFile_{logFile}, recordIndices_{recordIndices}, beginTime_{beginTime}, filter_(iFilter) {} + + void operator()(edm::eventsetup::EventSetupRecordKey const& iKey, + edm::ESModuleCallingContext const& iContext) const { + using namespace edm; + auto const t = std::chrono::duration_cast(now() - beginTime_).count(); + auto top = iContext.getTopModuleCallingContext(); + short int phase = 0; + unsigned long phaseID = 0xFFFFFFFF; + if (top->type() == ParentContext::Type::kGlobal) { + auto global = top->globalContext(); + phase = toTransition(*global); + phaseID = toTransitionIndex(*global); + } else if (top->type() == ParentContext::Type::kStream) { + auto stream = top->getStreamContext(); + phase = toTransition(*stream); + phaseID = stream_id(*stream); + } else if (top->type() == ParentContext::Type::kPlaceInPath) { + auto stream = top->getStreamContext(); + phase = toTransition(*stream); + phaseID = stream_id(*stream); + } + auto recordIndex = findRecordIndices(iKey); + if constexpr (isPostTransition(S)) { + auto info = filter_->stopOnThread(-1 * (iContext.componentDescription()->id_ + 1)); + if (info) { + auto msg = assembleAllocMessage( + *info, phase, phaseID, iContext.componentDescription()->id_ + 1, recordIndex, iContext.callID(), t); + logFile_->write(std::move(msg)); + } + } else { + if (filter_->startOnThread(-1 * (iContext.componentDescription()->id_ + 1))) { + auto msg = assembleMessage( + phase, phaseID, iContext.componentDescription()->id_ + 1, recordIndex, iContext.callID(), t); + logFile_->write(std::move(msg)); + } + } + } + + private: + int findRecordIndices(edm::eventsetup::EventSetupRecordKey const& iKey) const { + auto index = std::type_index(iKey.type().value()); + auto itFind = std::find(recordIndices_->begin(), recordIndices_->end(), index); + return itFind - recordIndices_->begin(); + } + + std::shared_ptr logFile_; + std::shared_ptr> recordIndices_; + decltype(now()) beginTime_; + Filter const* filter_; + }; + + template + struct GlobalEDModuleState { + GlobalEDModuleState(std::shared_ptr logFile, + decltype(now()) beginTime, + Filter const* iFilter) + : logFile_{logFile}, beginTime_{beginTime}, filter_(iFilter) {} + + void operator()(edm::GlobalContext const& gc, edm::ModuleCallingContext const& mcc) { + using namespace edm; + auto const t = std::chrono::duration_cast(now() - beginTime_).count(); + if constexpr (isPostTransition(S)) { + auto id = module_id(mcc); + auto info = filter_->stopOnThread(id); + if (info) { + auto msg = assembleAllocMessage(*info, toTransition(gc), toTransitionIndex(gc), id, module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } else { + auto id = module_id(mcc); + if (filter_->startOnThread(id)) { + auto msg = assembleMessage(toTransition(gc), toTransitionIndex(gc), module_id(mcc), module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } + } + + private: + std::shared_ptr logFile_; + decltype(now()) beginTime_; + Filter const* filter_; + }; + + template + struct StreamEDModuleState { + StreamEDModuleState(std::shared_ptr logFile, + decltype(now()) beginTime, + Filter const* iFilter) + : logFile_{logFile}, beginTime_{beginTime}, filter_(iFilter) {} + + void operator()(edm::StreamContext const& sc, edm::ModuleCallingContext const& mcc) { + using namespace edm; + auto const t = std::chrono::duration_cast(now() - beginTime_).count(); + if constexpr (isPostTransition(S)) { + auto id = module_id(mcc); + auto info = filter_->stopOnThread(id); + if (info) { + auto msg = + assembleAllocMessage(*info, toTransition(sc), stream_id(sc), module_id(mcc), module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } else { + auto id = module_id(mcc); + if (filter_->startOnThread(id)) { + auto msg = assembleMessage(toTransition(sc), stream_id(sc), id, module_callid(mcc), t); + logFile_->write(std::move(msg)); + } + } + } + + private: + std::shared_ptr logFile_; + decltype(now()) beginTime_; + Filter const* filter_; + }; + + struct ModuleCtrDtr { + long long beginConstruction = 0; + long long endConstruction = 0; + edm::service::moduleAlloc::ThreadAllocInfo constructionAllocInfo; + long long beginDestruction = 0; + long long endDestruction = 0; + edm::service::moduleAlloc::ThreadAllocInfo destructionAllocInfo; + }; +} // namespace + +namespace edm::service::moduleAlloc { + void setupFile(std::string const& iFileName, edm::ActivityRegistry& iRegistry, Filter const* iFilter) { + auto beginModuleAlloc = now(); + using namespace std::chrono; + + if (iFileName.empty()) { + return; + } + + auto logFile = std::make_shared(iFileName); + + auto beginTime = TimingServiceBase::jobStartTime(); + + auto esModuleLabelsPtr = std::make_shared>(); + auto& esModuleLabels = *esModuleLabelsPtr; + //acquire names for all the ED and ES modules + iRegistry.watchPostESModuleRegistration([&esModuleLabels](auto const& iDescription) { + if (esModuleLabels.size() <= iDescription.id_ + 1) { + esModuleLabels.resize(iDescription.id_ + 2); + } + //NOTE: we want the id to start at 1 not 0 + if (not iDescription.label_.empty()) { + esModuleLabels[iDescription.id_ + 1] = iDescription.label_; + } else { + esModuleLabels[iDescription.id_ + 1] = iDescription.type_; + } + }); + auto moduleCtrDtrPtr = std::make_shared>(); + auto& moduleCtrDtr = *moduleCtrDtrPtr; + auto moduleLabelsPtr = std::make_shared>(); + auto& moduleLabels = *moduleLabelsPtr; + iRegistry.watchPreModuleConstruction( + [&moduleLabels, &moduleCtrDtr, beginTime, iFilter](ModuleDescription const& md) { + auto const t = duration_cast(now() - beginTime).count(); + + auto const mid = md.id(); + if (mid < moduleLabels.size()) { + moduleLabels[mid] = md.moduleLabel(); + moduleCtrDtr[mid].beginConstruction = t; + } else { + moduleLabels.resize(mid + 1); + moduleLabels.back() = md.moduleLabel(); + moduleCtrDtr.resize(mid + 1); + moduleCtrDtr.back().beginConstruction = t; + } + iFilter->startOnThread(mid); + }); + iRegistry.watchPostModuleConstruction([&moduleCtrDtr, beginTime, iFilter](auto const& md) { + auto const t = duration_cast(now() - beginTime).count(); + moduleCtrDtr[md.id()].endConstruction = t; + auto alloc = iFilter->stopOnThread(md.id()); + if (alloc) { + moduleCtrDtr[md.id()].constructionAllocInfo = *alloc; + } + }); + + auto addDataInDtr = std::make_shared(false); + iRegistry.watchPreModuleDestruction([&moduleCtrDtr, beginTime, iFilter, addDataInDtr, logFile](auto const& md) { + auto const t = duration_cast(now() - beginTime).count(); + if (*addDataInDtr) { + if (iFilter->keepModuleInfo(md.id())) { + auto bmsg = assembleMessage( + static_cast>(Phase::destruction), 0, md.id(), 0, 0, 0, t); + logFile->write(std::move(bmsg)); + } + } else { + moduleCtrDtr[md.id()].beginDestruction = t; + } + iFilter->startOnThread(md.id()); + }); + iRegistry.watchPostModuleDestruction([&moduleCtrDtr, beginTime, iFilter, addDataInDtr, logFile](auto const& md) { + auto const t = duration_cast(now() - beginTime).count(); + if (not *addDataInDtr) { + moduleCtrDtr[md.id()].endDestruction = t; + } + auto info = iFilter->stopOnThread(md.id()); + if (info) { + if (*addDataInDtr) { + if (iFilter->keepModuleInfo(md.id())) { + auto emsg = assembleAllocMessage( + *info, static_cast>(Phase::destruction), 0, md.id(), 0, 0, 0, t); + logFile->write(std::move(emsg)); + } + + } else { + moduleCtrDtr[md.id()].destructionAllocInfo = *info; + } + } + }); + + auto sourceCtrPtr = std::make_shared(); + auto& sourceCtr = *sourceCtrPtr; + iRegistry.watchPreSourceConstruction([&sourceCtr, beginTime, iFilter](auto const&) { + auto const t = duration_cast(now() - beginTime).count(); + sourceCtr.beginConstruction = t; + iFilter->startOnThread(); + }); + iRegistry.watchPostSourceConstruction([&sourceCtr, beginTime, iFilter](auto const&) { + auto const t = duration_cast(now() - beginTime).count(); + sourceCtr.endConstruction = t; + auto info = iFilter->stopOnThread(); + if (info) { + sourceCtr.constructionAllocInfo = *info; + } + }); + + auto recordIndices = std::make_shared>(); + iRegistry.watchEventSetupConfiguration( + [logFile, recordIndices](auto const& recordsToResolvers, auto const&) mutable { + std::ostringstream oss; + + auto recordKeys = recordsToResolvers.recordKeys(); + std::sort(recordKeys.begin(), recordKeys.end()); + std::vector recordNames; + //want id to start at 1 not 0 + recordNames.reserve(recordKeys.size() + 1); + recordNames.emplace_back(""); + recordIndices->reserve(recordKeys.size() + 1); + recordIndices->push_back(std::type_index(typeid(void))); + for (auto const& r : recordKeys) { + recordNames.push_back(r.name()); + recordIndices->push_back(std::type_index(r.type().value())); + } + + moduleIdToLabel(oss, recordNames, 'R', "Record ID", "Record name"); + logFile->write(oss.str()); + }); + + iRegistry.watchPreBeginJob([logFile, + iFilter, + moduleLabelsPtr, + esModuleLabelsPtr, + moduleCtrDtrPtr, + sourceCtrPtr, + beginTime, + beginModuleAlloc, + addDataInDtr](auto&, auto&) mutable { + *addDataInDtr = true; + { + std::ostringstream oss; + moduleIdToLabel(oss, *moduleLabelsPtr, 'M', "EDModule ID", "Module label"); + logFile->write(oss.str()); + moduleLabelsPtr.reset(); + } + { + std::ostringstream oss; + moduleIdToLabel(oss, *esModuleLabelsPtr, 'N', "ESModule ID", "ESModule label"); + logFile->write(oss.str()); + esModuleLabelsPtr.reset(); + } + { + auto const moduleAllocStart = duration_cast(beginModuleAlloc - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::startTracing), 0, 0, 0, 0, moduleAllocStart); + logFile->write(std::move(msg)); + } + if (not iFilter->globalKeep()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + return; + } + //NOTE: the source construction can run concurently with module construction so we need to properly + // interleave its timing in with the modules + auto srcBeginConstruction = sourceCtrPtr->beginConstruction; + auto srcEndConstruction = sourceCtrPtr->endConstruction; + auto srcAllocInfo = sourceCtrPtr->constructionAllocInfo; + sourceCtrPtr.reset(); + auto handleSource = + [&srcBeginConstruction, &srcEndConstruction, &logFile, &srcAllocInfo](long long iTime) mutable { + if (srcBeginConstruction != 0 and srcBeginConstruction < iTime) { + auto bmsg = assembleMessage( + static_cast>(Phase::construction), 0, srcBeginConstruction); + logFile->write(std::move(bmsg)); + srcBeginConstruction = 0; + } + if (srcEndConstruction != 0 and srcEndConstruction < iTime) { + auto bmsg = assembleAllocMessage( + srcAllocInfo, static_cast>(Phase::construction), 0, srcEndConstruction); + logFile->write(std::move(bmsg)); + srcEndConstruction = 0; + } + }; + { + std::sort(moduleCtrDtrPtr->begin(), moduleCtrDtrPtr->end(), [](auto const& l, auto const& r) { + return l.beginConstruction < r.beginConstruction; + }); + int id = 0; + for (auto const& ctr : *moduleCtrDtrPtr) { + if (ctr.beginConstruction != 0) { + handleSource(ctr.beginConstruction); + if (iFilter->keepModuleInfo(id)) { + auto bmsg = assembleMessage( + static_cast>(Phase::construction), 0, id, 0, ctr.beginConstruction); + logFile->write(std::move(bmsg)); + } + handleSource(ctr.endConstruction); + if (iFilter->keepModuleInfo(id)) { + auto const& allocInfo = ctr.constructionAllocInfo; + auto emsg = assembleAllocMessage( + allocInfo, + static_cast>(Phase::construction), + 0, + id, + 0, + ctr.endConstruction); + logFile->write(std::move(emsg)); + } + } + ++id; + } + id = 0; + std::sort(moduleCtrDtrPtr->begin(), moduleCtrDtrPtr->end(), [](auto const& l, auto const& r) { + return l.beginDestruction < r.beginDestruction; + }); + for (auto const& dtr : *moduleCtrDtrPtr) { + if (dtr.beginDestruction != 0) { + handleSource(dtr.beginDestruction); + if (iFilter->keepModuleInfo(id)) { + auto bmsg = assembleMessage( + static_cast>(Phase::destruction), 0, id, 0, 0, 0, dtr.beginDestruction); + logFile->write(std::move(bmsg)); + } + handleSource(dtr.endDestruction); + if (iFilter->keepModuleInfo(id)) { + auto emsg = assembleAllocMessage( + dtr.destructionAllocInfo, + static_cast>(Phase::destruction), + 0, + id, + 0, + 0, + 0, + dtr.endDestruction); + logFile->write(std::move(emsg)); + } + } + ++id; + } + moduleCtrDtrPtr.reset(); + } + auto const t = duration_cast(now() - beginTime).count(); + handleSource(t); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + iRegistry.watchPostBeginJob([logFile, beginTime]() { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + + iRegistry.watchPreEndJob([logFile, beginTime]() { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::endJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + iRegistry.watchPostEndJob([logFile, beginTime]() { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::endJob), 0, 0, 0, 0, t); + logFile->write(std::move(msg)); + }); + + iRegistry.watchPreEvent([logFile, beginTime](auto const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage(static_cast>(Phase::Event), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + }); + iRegistry.watchPostEvent([logFile, beginTime](auto const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = + assembleMessage(static_cast>(Phase::Event), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + }); + + iRegistry.watchPreClearEvent([logFile, beginTime, iFilter](auto const& sc) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = + assembleMessage(static_cast>(Phase::clearEvent), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostClearEvent([logFile, beginTime, iFilter](auto const& sc) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, + static_cast>(Phase::clearEvent), + stream_id(sc), + sc.eventID().run(), + sc.eventID().luminosityBlock(), + sc.eventID().event(), + t); + logFile->write(std::move(msg)); + } + }); + + { + auto preGlobal = [logFile, beginTime](GlobalContext const& gc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage(toTransition(gc), + toTransitionIndex(gc), + gc.luminosityBlockID().run(), + gc.luminosityBlockID().luminosityBlock(), + 0, + t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPreBeginProcessBlock(preGlobal); + iRegistry.watchPreEndProcessBlock(preGlobal); + iRegistry.watchPreWriteProcessBlock(preGlobal); + iRegistry.watchPreAccessInputProcessBlock(preGlobal); + iRegistry.watchPreGlobalBeginRun(preGlobal); + iRegistry.watchPreGlobalBeginLumi(preGlobal); + iRegistry.watchPreGlobalEndLumi(preGlobal); + iRegistry.watchPreGlobalWriteLumi(preGlobal); + iRegistry.watchPreGlobalEndRun(preGlobal); + iRegistry.watchPreGlobalWriteRun(preGlobal); + } + { + auto postGlobal = [logFile, beginTime](GlobalContext const& gc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage(toTransition(gc), + toTransitionIndex(gc), + gc.luminosityBlockID().run(), + gc.luminosityBlockID().luminosityBlock(), + 0, + t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPostBeginProcessBlock(postGlobal); + iRegistry.watchPostEndProcessBlock(postGlobal); + iRegistry.watchPostWriteProcessBlock(postGlobal); + iRegistry.watchPostAccessInputProcessBlock(postGlobal); + iRegistry.watchPostGlobalBeginRun(postGlobal); + iRegistry.watchPostGlobalBeginLumi(postGlobal); + iRegistry.watchPostGlobalEndLumi(postGlobal); + iRegistry.watchPostGlobalWriteLumi(postGlobal); + iRegistry.watchPostGlobalEndRun(postGlobal); + iRegistry.watchPostGlobalWriteRun(postGlobal); + } + { + auto preStream = [logFile, beginTime](StreamContext const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + toTransition(sc), stream_id(sc), sc.eventID().run(), sc.eventID().luminosityBlock(), 0, t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPreStreamBeginRun(preStream); + iRegistry.watchPreStreamBeginLumi(preStream); + iRegistry.watchPreStreamEndLumi(preStream); + iRegistry.watchPreStreamEndRun(preStream); + } + { + auto postStream = [logFile, beginTime](StreamContext const& sc) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + toTransition(sc), stream_id(sc), sc.eventID().run(), sc.eventID().luminosityBlock(), 0, t); + logFile->write(std::move(msg)); + }; + iRegistry.watchPostStreamBeginRun(postStream); + iRegistry.watchPostStreamBeginLumi(postStream); + iRegistry.watchPostStreamEndLumi(postStream); + iRegistry.watchPostStreamEndRun(postStream); + } + { + iRegistry.watchPreOpenFile([logFile, beginTime, iFilter](std::string const&) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::openFile), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostOpenFile([logFile, beginTime, iFilter](std::string const&) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::openFile), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPreSourceEvent([logFile, beginTime, iFilter](StreamID id) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::Event), id.value(), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceEvent([logFile, beginTime, iFilter](StreamID id) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::Event), id.value(), t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreSourceRun([logFile, beginTime, iFilter](RunIndex id) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::globalBeginRun), id.value(), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceRun([logFile, beginTime, iFilter](RunIndex id) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::globalBeginRun), id.value(), t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreSourceLumi([logFile, beginTime, iFilter](auto id) { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::globalBeginLumi), id.value(), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceLumi([logFile, beginTime, iFilter](auto id) { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::globalBeginLumi), id.value(), t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreSourceNextTransition([logFile, beginTime, iFilter]() { + if (iFilter->startOnThread()) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::getNextTransition), t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostSourceNextTransition([logFile, beginTime, iFilter]() { + auto info = iFilter->stopOnThread(); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::getNextTransition), t); + logFile->write(std::move(msg)); + } + }); + + //ED Modules + iRegistry.watchPreModuleBeginJob([logFile, beginTime, iFilter](auto const& md) { + if (iFilter->startOnThread(md.id())) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::beginJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostModuleBeginJob([logFile, beginTime, iFilter](auto const& md) { + auto info = iFilter->stopOnThread(md.id()); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::beginJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreModuleBeginStream(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleBeginStream( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleEndStream(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEndStream(StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleEndJob([logFile, beginTime, iFilter](auto const& md) { + if (iFilter->startOnThread(md.id())) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleMessage( + static_cast>(Phase::endJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + iRegistry.watchPostModuleEndJob([logFile, beginTime, iFilter](auto const& md) { + auto info = iFilter->stopOnThread(md.id()); + if (info) { + auto const t = duration_cast(now() - beginTime).count(); + auto msg = assembleAllocMessage( + *info, static_cast>(Phase::endJob), 0, md.id(), 0, t); + logFile->write(std::move(msg)); + } + }); + + iRegistry.watchPreModuleEvent(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEvent(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleEventAcquire( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEventAcquire( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleEventDelayedGet( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEventDelayedGet( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreEventReadFromSource( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostEventReadFromSource( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleTransform(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleTransform(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleTransformAcquiring( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleTransformAcquiring( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleStreamBeginRun( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamBeginRun( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleStreamEndRun(StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamEndRun( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleStreamBeginLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamBeginLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleStreamEndLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleStreamEndLumi( + StreamEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleBeginProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleBeginProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleAccessInputProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleAccessInputProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleEndProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleEndProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleGlobalBeginRun( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalBeginRun( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleGlobalEndRun(GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalEndRun( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleGlobalBeginLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalBeginLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPreModuleGlobalEndLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleGlobalEndLumi( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleWriteProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleWriteProcessBlock( + GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleWriteRun(GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleWriteRun(GlobalEDModuleState(logFile, beginTime, iFilter)); + + iRegistry.watchPreModuleWriteLumi(GlobalEDModuleState(logFile, beginTime, iFilter)); + iRegistry.watchPostModuleWriteLumi(GlobalEDModuleState(logFile, beginTime, iFilter)); + + //ES Modules + iRegistry.watchPreESModule(ESModuleState(logFile, beginTime, recordIndices, iFilter)); + iRegistry.watchPostESModule(ESModuleState(logFile, beginTime, recordIndices, iFilter)); + iRegistry.watchPreESModuleAcquire( + ESModuleState(logFile, beginTime, recordIndices, iFilter)); + iRegistry.watchPostESModuleAcquire( + ESModuleState(logFile, beginTime, recordIndices, iFilter)); + } + + std::ostringstream oss; + oss << "# Transition Type Symbol\n"; + oss << "#------------------------ ------\n"; + oss << "# startTracing " << Phase::startTracing << "\n" + << "# construction " << Phase::construction << "\n" + << "# getNextTransition " << Phase::getNextTransition << "\n" + << "# beginJob " << Phase::beginJob << "\n" + << "# beginStream " << Phase::beginStream << "\n" + << "# openFile " << Phase::openFile << "\n" + << "# beginProcessBlock " << Phase::beginProcessBlock << "\n" + << "# accessInputProcessBlock " << Phase::accessInputProcessBlock << "\n" + << "# globalBeginRun " << Phase::globalBeginRun << "\n" + << "# streamBeginRun " << Phase::streamBeginRun << "\n" + << "# globalBeginLumi " << Phase::globalBeginLumi << "\n" + << "# streamBeginLumi " << Phase::streamBeginLumi << "\n" + << "# Event " << Phase::Event << "\n" + << "# clearEvent " << Phase::clearEvent << "\n" + << "# streamEndLumi " << Phase::streamEndLumi << "\n" + << "# globalEndLumi " << Phase::globalEndLumi << "\n" + << "# globalWriteLumi " << Phase::globalWriteLumi << "\n" + << "# streamEndRun " << Phase::streamEndRun << "\n" + << "# globalEndRun " << Phase::globalEndRun << "\n" + << "# globalWriteRun " << Phase::globalWriteRun << "\n" + << "# endProcessBlock " << Phase::endProcessBlock << "\n" + << "# writeProcessBlock " << Phase::writeProcessBlock << "\n" + << "# endStream " << Phase::endStream << "\n" + << "# endJob " << Phase::endJob << "\n" + << "# destruction " << Phase::destruction << "\n\n"; + constexpr std::string_view kTransition = " "; + constexpr std::string_view kTransitionInfo = " "; + constexpr std::string_view kTime = "