From b47789ccddb5c5e124e6990121757e51c07aad0c Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 16:57:54 +0200 Subject: [PATCH 01/19] Approximate clusters definition and producer --- DataFormats/SiStripCluster/src/classes.h | 2 ++ .../SiStripCluster/src/classes_def.xml | 17 ++++++++++ .../SiStripClusterizer/BuildFile.xml | 3 ++ .../SiStripClusters2ApproxClustersv1.h | 32 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h diff --git a/DataFormats/SiStripCluster/src/classes.h b/DataFormats/SiStripCluster/src/classes.h index 14554907b1ab7..e02fcb572130d 100644 --- a/DataFormats/SiStripCluster/src/classes.h +++ b/DataFormats/SiStripCluster/src/classes.h @@ -5,6 +5,8 @@ #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" + #include "DataFormats/Common/interface/ContainerMask.h" #endif // SISTRIPCLUSTER_CLASSES_H diff --git a/DataFormats/SiStripCluster/src/classes_def.xml b/DataFormats/SiStripCluster/src/classes_def.xml index 7b3d2bcfe7b93..39d4ced147004 100755 --- a/DataFormats/SiStripCluster/src/classes_def.xml +++ b/DataFormats/SiStripCluster/src/classes_def.xml @@ -23,4 +23,21 @@ + + + + + + + + + + + + + + + + + diff --git a/RecoLocalTracker/SiStripClusterizer/BuildFile.xml b/RecoLocalTracker/SiStripClusterizer/BuildFile.xml index 2ac07ebc90b7e..4873ec688a6d3 100644 --- a/RecoLocalTracker/SiStripClusterizer/BuildFile.xml +++ b/RecoLocalTracker/SiStripClusterizer/BuildFile.xml @@ -8,6 +8,9 @@ + + + diff --git a/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h b/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h new file mode 100644 index 0000000000000..99e9f3a749a23 --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h @@ -0,0 +1,32 @@ +#ifndef RecoLocalTracker_SiStripClusters2ApproxClustersv1_h +#define RecoLocalTracker_SiStripClusters2ApproxClustersv1_h + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/DetSetVector.h" + +#include +#include + +class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { + +public: + + explicit SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf); + void produce(edm::Event&, const edm::EventSetup&) override; + +private: + + edm::InputTag inputClusters; + edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; +}; + +DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1); +#endif + From 39fe9bbda49942044a6559d8910890ac96ec501f Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 17:52:25 +0200 Subject: [PATCH 02/19] Adding Approximated --- .../interface/SiStripApproximateClusterv1.h | 31 ++++++++++ .../SiStripClusters2ApproxClustersv1.cc | 51 ++++++++++++++++ .../SiStripClusters2ApproxClustersv1_cfi.py | 6 ++ .../test/SiStripApproximatedClustersDump.cc | 41 +++++++++++++ .../test/SiStripApproximatedClustersDump.h | 59 +++++++++++++++++++ SiStripApproximateClusterv2/BuildFile.xml | 7 +++ SiStripApproximateClusterv2/src/classes.h | 33 +++++++++++ 7 files changed, 228 insertions(+) create mode 100644 DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h create mode 100644 RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc create mode 100644 RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py create mode 100644 RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc create mode 100644 RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h create mode 100644 SiStripApproximateClusterv2/BuildFile.xml create mode 100755 SiStripApproximateClusterv2/src/classes.h diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h new file mode 100644 index 0000000000000..edb0faf004a12 --- /dev/null +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h @@ -0,0 +1,31 @@ +#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H +#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H + +#include +#include +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +class SiStripApproximateClusterv1 { +public: + + SiStripApproximateClusterv1() {} + + explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) { + baryWidth_ = barycenter; + baryWidth_ = baryWidth_ << 6; + if(width>0x3F) width=0x3F; + baryWidth_ += width; + } + + uint16_t barycenter() const {return (uint16_t)((baryWidth_ & 0xFFC0) >> 6);} + uint8_t width() const {return (uint8_t) (baryWidth_ & 0x3F);} + uint16_t baryWidth() const {return baryWidth_;} + uint8_t avgCharge() const{return avgCharge_;} + +private: + + uint16_t baryWidth_ = 0; + + uint8_t avgCharge_ = 0; +}; +#endif // DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc new file mode 100644 index 0000000000000..436fb84eff77a --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc @@ -0,0 +1,51 @@ +#include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h" +#include + + +SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){ + inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); + clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); + + produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >(); + +} + +void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ + std::unique_ptr > result(new edmNew::DetSetVector< SiStripApproximateClusterv1 > ); + + edm::Handle> clusterCollection; + e.getByToken(clusterToken, clusterCollection); + + uint32_t minID = 470444276; + int maxFirst = -1; + + for( edmNew::DetSetVector::const_iterator i = clusterCollection->begin(); i!=clusterCollection->end(); i++){ + + std::vector< SiStripApproximateClusterv1 > tempVec; + + edmNew::DetSetVector::FastFiller ff = edmNew::DetSetVector::FastFiller(*result, i->id()); + + for( edmNew::DetSet::const_iterator j = i->begin(); j!=i->end(); j++){ + + if(maxFirstfirstStrip()) maxFirst = j->firstStrip(); + if(minID>i->id()) minID = i->id(); + + uint8_t width = j->amplitudes().size(); + uint16_t barycenter = (uint16_t)j->barycenter(); + + int charge = 0; + for (unsigned k = 0; k < j->amplitudes().size(); k++) { + charge += (int)j->amplitudes()[k]; + } + + SiStripApproximateClusterv1 approxCluster = SiStripApproximateClusterv1( (uint8_t)(charge/width), barycenter, width ); + ff.push_back(approxCluster); + } + + + } + + e.put(std::move(result)); +} + + diff --git a/RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py b/RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py new file mode 100644 index 0000000000000..e001b7b6024d6 --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +SiStripClusters2ApproxClustersv1 = cms.EDProducer("SiStripClusters2ApproxClustersv1", + inputClusters = cms.InputTag("siStripClusters") +) + diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc new file mode 100644 index 0000000000000..4ed051760fb01 --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc @@ -0,0 +1,41 @@ +#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h" + + +SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::ParameterSet& conf) { + inputTagClusters = conf.getParameter< edm::InputTag >("approximatedClustersTag"); + clusterToken = consumes< edmNew::DetSetVector>(inputTagClusters); + + usesResource("TFileService"); + + outNtuple = fs->make("ApproxClusters", "ApproxClusters"); + outNtuple->Branch("event", &eventN, "event/i"); + outNtuple->Branch("detId", &detId, "detId/i"); + outNtuple->Branch("barycenter", &barycenter, "barycenter/F"); + outNtuple->Branch("width", &width, "width/b"); + outNtuple->Branch("charge", &avCharge, "charge/b"); +} + +SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {} + +void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) { + + edm::Handle> inClusters; + event.getByToken(clusterToken, inClusters); + + + for (edmNew::DetSetVector::const_iterator itApprox = inClusters->begin(); itApprox!= inClusters->end(); itApprox++) { + detId = itApprox->detId(); + eventN = event.id().event(); + + for (edmNew::DetSet::const_iterator itClusters = itApprox->begin(); itClusters!= itApprox->end(); itClusters++){ + + barycenter = itClusters->barycenter(); + width = itClusters->width(); + avCharge=itClusters->avgCharge(); + outNtuple->Fill(); + + } + } +} + + diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h new file mode 100644 index 0000000000000..1f0cd8a5a0625 --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h @@ -0,0 +1,59 @@ +#ifndef RecoLocalTracker_SiStripApproximatedClustersDump_h +#define RecoLocalTracker_SiStripApproximatedClustersDump_h + + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/Common/interface/DetSet.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "CommonTools/Utils/interface/TFileDirectory.h" + +#include +#include + +//ROOT inclusion +#include "TROOT.h" +#include "TFile.h" +#include "TNtuple.h" +#include "TTree.h" +#include "TMath.h" +#include "TList.h" +#include "TString.h" + +// +// class decleration +// + + +class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer { +public: + explicit SiStripApproximatedClustersDump(const edm::ParameterSet&); + ~SiStripApproximatedClustersDump() override; + + +private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + + edm::InputTag inputTagClusters; + edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; + + TTree* outNtuple; + edm::Service fs; + + uint32_t detId; + uint16_t barycenter; + uint16_t width; + uint8_t avCharge; + edm::EventNumber_t eventN; +}; + #endif diff --git a/SiStripApproximateClusterv2/BuildFile.xml b/SiStripApproximateClusterv2/BuildFile.xml new file mode 100644 index 0000000000000..b1e143419a339 --- /dev/null +++ b/SiStripApproximateClusterv2/BuildFile.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SiStripApproximateClusterv2/src/classes.h b/SiStripApproximateClusterv2/src/classes.h new file mode 100755 index 0000000000000..d2d00d13a9317 --- /dev/null +++ b/SiStripApproximateClusterv2/src/classes.h @@ -0,0 +1,33 @@ +#ifndef SISTRIPAPPROXIMATECLUSTERv2_CLASSES_H +#define SISTRIPAPPROXIMATECLUSTERv2_CLASSES_H + +#include "DataFormats/Common/interface/Wrapper.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/SiStripApproximateClusterv2/interface/SiStripApproximateClusterv2.h" +#include "DataFormats/Common/interface/ContainerMask.h" + +namespace DataFormats_SiStripApproximateClusterv2 { + struct dictionary2 { + + + edmNew::DetSetVector dsvn; + + edm::Wrapper< SiStripApproximateClusterv2 > dummy0; + edm::Wrapper< std::vector > dummy1; + + edm::Wrapper< edmNew::DetSetVector > dummy4_bis; + + edm::Wrapper > > dummy_w_cm1; + + std::vector,SiStripApproximateClusterv2,edmNew::DetSetVector::FindForDetSetVector> > dummy_v; + edmNew::DetSetVector,SiStripApproximateClusterv2,edmNew::DetSetVector::FindForDetSetVector> > dumm_dtvr; + edm::Wrapper,SiStripApproximateClusterv2,edmNew::DetSetVector::FindForDetSetVector> > > dumm_dtvr_w; + + + edm::Ref, SiStripApproximateClusterv2, edmNew::DetSetVector::FindForDetSetVector > refNew; + }; +} + + +#endif // SISTRIPAPPROXIMATECLUSTER_CLASSES_H From 461617875743e7f665d59a1de3149f4c0472f61b Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 18:03:11 +0200 Subject: [PATCH 03/19] Adding ClusterDump and test .py --- .../SiStripApproximatedClustersDump_cfi.py | 5 + ...ep2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py | 154 ++++++++++++++++++ ...Reco_RECO_ApproxClusters_streamerOutput.py | 146 +++++++++++++++++ 3 files changed, 305 insertions(+) create mode 100644 RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py create mode 100644 RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py create mode 100644 RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py diff --git a/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py b/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py new file mode 100644 index 0000000000000..581a8c83b3ce4 --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump", + approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv3") +) diff --git a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py new file mode 100644 index 0000000000000..96d5ca744826b --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py @@ -0,0 +1,154 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step2 --conditions 103X_dataRun2_Prompt_v2 -s RAW2DIGI,L1Reco,RECO --process reRECO -n 30 --data --era Run2_2018_pp_on_AA --eventcontent AOD --runUnscheduled --scenario pp --datatier AOD --repacked --filein file:out.root --fileout file:step2.root --no_exec +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018_pp_on_AA) + +# 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('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_DataMapper_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:/eos/cms/store/hidata/HIRun2018A/HIMinimumBias5/RAW/v1/000/326/573/00000/C4CDB29C-62C9-AF4D-B2A3-5D9793BE3832.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step2 nevts:30'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.outputClusters = cms.OutputModule("PoolOutputModule", + compressionAlgorithm = cms.untracked.string('ZLIB'), + compressionLevel = cms.untracked.int32(7), + eventAutoFlushCompressedSize = cms.untracked.int32(31457280), + fileName = cms.untracked.string('file:step2clusters.root'), + outputCommands = cms.untracked.vstring( + 'drop *', + 'keep *_*siStripClusters*_*_*' + ) +) + +process.outputCompressed = cms.OutputModule("PoolOutputModule", + compressionAlgorithm = cms.untracked.string('ZLIB'), + compressionLevel = cms.untracked.int32(7), + eventAutoFlushCompressedSize = cms.untracked.int32(31457280), + fileName = cms.untracked.string('file:step2approximated.root'), + outputCommands = cms.untracked.vstring( + 'drop *', + 'keep *_*SiStripClusters2ApproxClustersv1*_*_*', + 'keep *_*SiStripClusters2ApproxClustersv2*_*_*', + 'keep *_*SiStripClusters2ApproxClustersv3*_*_*' + ) +) + +process.TFileService = cms.Service("TFileService", + fileName=cms.string("step2approximated_Ntuple.root")) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '103X_dataRun2_Prompt_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') + +process.load('RecoLocalTracker.SiStripClusterizer.SiStripClusters2ApproxClustersv1_cfi') +process.load('RecoLocalTracker.SiStripClusterizer.SiStripApproximatedClustersDump_cfi') + + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.reconstruction_step = cms.Path(process.reconstruction) +process.approxClustersv1_step = cms.Path(process.SiStripClusters2ApproxClustersv1) +process.analyzer_step = cms.Path(process.SiStripApproximatedClustersDump) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.output_step = cms.EndPath(process.outputClusters+process.outputCompressed) + + + + +process.load('EventFilter.SiStripRawToDigi.SiStripDigiToRaw_cfi') +process.rawStep = process.SiStripDigiToRaw.clone( +InputDigis=cms.InputTag('siStripDigis', 'ZeroSuppressed'), +RawDataTag = cms.InputTag('StripRawDataCollector') + ) + +process.load('EventFilter.RawDataCollector.rawDataCollector_cfi') +process.StripRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStep'))) + +process.load('EventFilter.SiPixelRawToDigi.SiPixelDigiToRaw_cfi') +process.rawStepPix = process.siPixelRawData.clone( +InputLabel=cms.InputTag('siPixelDigis'), + ) +process.PixelRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStepPix'))) + +process.load('EventFilter.HcalRawToDigi.HcalDigiToRaw_cfi') +process.rawStepHCAL = process.hcalRawDataVME.clone( + HBHE = cms.untracked.InputTag("hcalDigis"), + HF = cms.untracked.InputTag("hcalDigis"), + HO = cms.untracked.InputTag("hcalDigis"), + ZDC = cms.untracked.InputTag("hcalDigis"), + TRIG = cms.untracked.InputTag("hcalDigis") +) +process.HCALRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStepHCAL'))) + +process.load('EventFilter.ESDigiToRaw.esDigiToRaw_cfi') +process.rawStepES = process.esDigiToRaw.clone( +Label = cms.string('ecalPreshowerDigis'), +) +process.ESRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStepES'))) + +process.rawPath = cms.Path(process.rawStep*process.rawStepPix*process.rawStepHCAL*process.rawStepES*process.StripRawDataCollector*process.PixelRawDataCollector*process.HCALRawDataCollector*process.ESRawDataCollector) + + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.approxClustersv1_step, process.analyzer_step, process.rawPath, process.endjob_step,process.output_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +from Configuration.Applications.ConfigBuilder import MassReplaceInputTag +MassReplaceInputTag(process, new="rawDataMapperByLabel", old="rawDataCollector") + +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# 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 \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py new file mode 100644 index 0000000000000..4d93b24ac6ded --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py @@ -0,0 +1,146 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step2 --conditions 103X_dataRun2_Prompt_v2 -s RAW2DIGI,L1Reco,RECO --process reRECO -n 30 --data --era Run2_2018_pp_on_AA --eventcontent AOD --runUnscheduled --scenario pp --datatier AOD --repacked --filein file:out.root --fileout file:step2.root --no_exec +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('reRECO',eras.Run2_2018_pp_on_AA) + +# 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('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.RawToDigi_DataMapper_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_Data_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:/eos/cms/store/hidata/HIRun2018A/HIMinimumBias5/RAW/v1/000/326/573/00000/C4CDB29C-62C9-AF4D-B2A3-5D9793BE3832.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step2 nevts:30'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.outputClusters = cms.OutputModule("EventStreamFileWriter", + fileName = cms.untracked.string('step2clusters.dat'), + compression_algorithm = cms.untracked.string('ZLIB'), + compression_level = cms.untracked.int32(7), + use_compression = cms.untracked.bool(True), + + outputCommands = cms.untracked.vstring( + 'drop *', + 'keep *_*siStripClusters*_*_*' + ) +) + +process.outputCompressed = cms.OutputModule("EventStreamFileWriter", + fileName = cms.untracked.string('step2approximated.dat'), + compression_algorithm = cms.untracked.string('ZLIB'), + compression_level = cms.untracked.int32(7), + use_compression = cms.untracked.bool(True), + + outputCommands = cms.untracked.vstring( + 'drop *', + 'keep *_*SiStripClusters2ApproxClustersv1*_*_*' + ) +) + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, '103X_dataRun2_Prompt_v2', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') + +process.load('RecoLocalTracker.SiStripClusterizer.SiStripClusters2ApproxClustersv1_cfi') + +# Path and EndPath definitions +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.reconstruction_step = cms.Path(process.reconstruction) +process.approxClusters_step = cms.Path(process.SiStripClusters2ApproxClustersv1) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.output_step = cms.EndPath(process.outputClusters+process.outputCompressed) + +process.load('EventFilter.SiStripRawToDigi.SiStripDigiToRaw_cfi') +process.rawStep = process.SiStripDigiToRaw.clone( +InputDigis=cms.InputTag('siStripDigis', 'ZeroSuppressed'), +RawDataTag = cms.InputTag('StripRawDataCollector') + ) + +process.load('EventFilter.RawDataCollector.rawDataCollector_cfi') +process.StripRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStep'))) + +process.load('EventFilter.SiPixelRawToDigi.SiPixelDigiToRaw_cfi') +process.rawStepPix = process.siPixelRawData.clone( +InputLabel=cms.InputTag('siPixelDigis'), + ) +process.PixelRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStepPix'))) + +process.load('EventFilter.HcalRawToDigi.HcalDigiToRaw_cfi') +process.rawStepHCAL = process.hcalRawDataVME.clone( + HBHE = cms.untracked.InputTag("hcalDigis"), + HF = cms.untracked.InputTag("hcalDigis"), + HO = cms.untracked.InputTag("hcalDigis"), + ZDC = cms.untracked.InputTag("hcalDigis"), + TRIG = cms.untracked.InputTag("hcalDigis") +) +process.HCALRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStepHCAL'))) + +process.load('EventFilter.ESDigiToRaw.esDigiToRaw_cfi') +process.rawStepES = process.esDigiToRaw.clone( +Label = cms.string('ecalPreshowerDigis'), +) +process.ESRawDataCollector = process.rawDataCollector.clone(RawCollectionList = cms.VInputTag( cms.InputTag('rawStepES'))) + +process.rawPath = cms.Path(process.rawStep*process.rawStepPix*process.rawStepHCAL*process.rawStepES*process.StripRawDataCollector*process.PixelRawDataCollector*process.HCALRawDataCollector*process.ESRawDataCollector) + + + + +# Schedule definition +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.approxClusters_step,process.rawPath, process.endjob_step,process.output_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +from Configuration.Applications.ConfigBuilder import MassReplaceInputTag +MassReplaceInputTag(process, new="rawDataMapperByLabel", old="rawDataCollector") + +#do not add changes to your config after this point (unless you know what you are doing) +from FWCore.ParameterSet.Utilities import convertToUnscheduled +process=convertToUnscheduled(process) + + +# Customisation from command line + +#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule +from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands +process = customiseLogErrorHarvesterUsingOutputCommands(process) + +# 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 \ No newline at end of file From 592f85990fbd00ff6426d47d2ff8103cac043df3 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 18:09:04 +0200 Subject: [PATCH 04/19] Including ClusterDump plugin --- RecoLocalTracker/SiStripClusterizer/test/SealModules.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc b/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc index 9664e88cff729..39ddea57fa0c7 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc @@ -9,9 +9,12 @@ #include "RecoLocalTracker/SiStripClusterizer/test/StripByStripTestDriver.h" #include "RecoLocalTracker/SiStripClusterizer/test/ClusterizerUnitTesterESProducer.h" #include "RecoLocalTracker/SiStripClusterizer/test/ClusterRefinerTagMCmerged.h" +#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h" DEFINE_FWK_MODULE(CompareClusters); DEFINE_FWK_MODULE(ClusterizerUnitTester); DEFINE_FWK_MODULE(StripByStripTestDriver); DEFINE_FWK_EVENTSETUP_MODULE(ClusterizerUnitTesterESProducer); DEFINE_FWK_MODULE(ClusterRefinerTagMCmerged); +DEFINE_FWK_MODULE(SiStripApproximatedClustersDump); + From 879fc14e9d7fbd4f81a20b041a9413f3d3f61c07 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 18:12:45 +0200 Subject: [PATCH 05/19] fising cluster dump config --- .../python/SiStripApproximatedClustersDump_cfi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py b/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py index 581a8c83b3ce4..13fcb34a9e880 100644 --- a/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py +++ b/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump", - approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv3") + approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv1") ) From 37babea606486eec766cfcaa223e726610ee82db Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 18:40:54 +0200 Subject: [PATCH 06/19] removing misplaced files --- SiStripApproximateClusterv2/BuildFile.xml | 7 ----- SiStripApproximateClusterv2/src/classes.h | 33 ----------------------- 2 files changed, 40 deletions(-) delete mode 100644 SiStripApproximateClusterv2/BuildFile.xml delete mode 100755 SiStripApproximateClusterv2/src/classes.h diff --git a/SiStripApproximateClusterv2/BuildFile.xml b/SiStripApproximateClusterv2/BuildFile.xml deleted file mode 100644 index b1e143419a339..0000000000000 --- a/SiStripApproximateClusterv2/BuildFile.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/SiStripApproximateClusterv2/src/classes.h b/SiStripApproximateClusterv2/src/classes.h deleted file mode 100755 index d2d00d13a9317..0000000000000 --- a/SiStripApproximateClusterv2/src/classes.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SISTRIPAPPROXIMATECLUSTERv2_CLASSES_H -#define SISTRIPAPPROXIMATECLUSTERv2_CLASSES_H - -#include "DataFormats/Common/interface/Wrapper.h" -#include "DataFormats/Common/interface/DetSetVectorNew.h" -#include "DataFormats/Common/interface/Ref.h" -#include "DataFormats/SiStripApproximateClusterv2/interface/SiStripApproximateClusterv2.h" -#include "DataFormats/Common/interface/ContainerMask.h" - -namespace DataFormats_SiStripApproximateClusterv2 { - struct dictionary2 { - - - edmNew::DetSetVector dsvn; - - edm::Wrapper< SiStripApproximateClusterv2 > dummy0; - edm::Wrapper< std::vector > dummy1; - - edm::Wrapper< edmNew::DetSetVector > dummy4_bis; - - edm::Wrapper > > dummy_w_cm1; - - std::vector,SiStripApproximateClusterv2,edmNew::DetSetVector::FindForDetSetVector> > dummy_v; - edmNew::DetSetVector,SiStripApproximateClusterv2,edmNew::DetSetVector::FindForDetSetVector> > dumm_dtvr; - edm::Wrapper,SiStripApproximateClusterv2,edmNew::DetSetVector::FindForDetSetVector> > > dumm_dtvr_w; - - - edm::Ref, SiStripApproximateClusterv2, edmNew::DetSetVector::FindForDetSetVector > refNew; - }; -} - - -#endif // SISTRIPAPPROXIMATECLUSTER_CLASSES_H From 1a03de54453f061192675b44a4aad8bb471a7bcb Mon Sep 17 00:00:00 2001 From: Ivan Amos Cali Date: Tue, 27 Apr 2021 18:51:55 +0200 Subject: [PATCH 07/19] Update RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc Co-authored-by: Marco Musich --- .../plugins/SiStripClusters2ApproxClustersv1.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc index 436fb84eff77a..9d2d4b474b6a8 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc @@ -13,8 +13,7 @@ SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::Pa void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ std::unique_ptr > result(new edmNew::DetSetVector< SiStripApproximateClusterv1 > ); - edm::Handle> clusterCollection; - e.getByToken(clusterToken, clusterCollection); + edm::Handle> clusterCollection = e.getHandle(clusterToken_) uint32_t minID = 470444276; int maxFirst = -1; @@ -48,4 +47,3 @@ void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup co e.put(std::move(result)); } - From 42d38fcdeefd534fe156fe61c03807ae1fb6f4fd Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 19:47:07 +0200 Subject: [PATCH 08/19] intermediate fixing --- .../SiStripClusters2ApproxClustersv1.h | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h diff --git a/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h b/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h deleted file mode 100644 index 99e9f3a749a23..0000000000000 --- a/RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef RecoLocalTracker_SiStripClusters2ApproxClustersv1_h -#define RecoLocalTracker_SiStripClusters2ApproxClustersv1_h - -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" -#include "DataFormats/Common/interface/DetSetVectorNew.h" -#include "DataFormats/Common/interface/DetSetVector.h" - -#include -#include - -class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { - -public: - - explicit SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf); - void produce(edm::Event&, const edm::EventSetup&) override; - -private: - - edm::InputTag inputClusters; - edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; -}; - -DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1); -#endif - From 1064acef5370399e67ffdcc00027f0fd6a98ffd8 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 27 Apr 2021 20:05:04 +0200 Subject: [PATCH 09/19] fixing approx plugin and fixing interface --- .../interface/SiStripApproximateClusterv1.h | 16 ++++------ .../SiStripClusters2ApproxClustersv1.cc | 32 +++++++++++++++++-- ...ep2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py | 4 +-- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h index edb0faf004a12..d35f5d0304205 100644 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h @@ -11,20 +11,18 @@ class SiStripApproximateClusterv1 { SiStripApproximateClusterv1() {} explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) { - baryWidth_ = barycenter; - baryWidth_ = baryWidth_ << 6; - if(width>0x3F) width=0x3F; - baryWidth_ += width; + barycenter_ = barycenter; + width_ = width; + if(width_>0x3F) width_=0x3F; } - uint16_t barycenter() const {return (uint16_t)((baryWidth_ & 0xFFC0) >> 6);} - uint8_t width() const {return (uint8_t) (baryWidth_ & 0x3F);} - uint16_t baryWidth() const {return baryWidth_;} + uint16_t barycenter() const {return barycenter_;} + uint8_t width() const {return width_;} uint8_t avgCharge() const{return avgCharge_;} private: - - uint16_t baryWidth_ = 0; + uint8_t width_=0; + uint16_t barycenter_ = 0; uint8_t avgCharge_ = 0; }; diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc index 9d2d4b474b6a8..6b5517fdcf97b 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc @@ -1,6 +1,33 @@ -#include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h" + + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/DetSetVector.h" + +#include +#include #include +class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { + +public: + + explicit SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf); + void produce(edm::Event&, const edm::EventSetup&) override; + +private: + + edm::InputTag inputClusters; + edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; +}; + + SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){ inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); @@ -13,7 +40,7 @@ SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::Pa void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ std::unique_ptr > result(new edmNew::DetSetVector< SiStripApproximateClusterv1 > ); - edm::Handle> clusterCollection = e.getHandle(clusterToken_) + edm::Handle> clusterCollection = e.getHandle(clusterToken); uint32_t minID = 470444276; int maxFirst = -1; @@ -47,3 +74,4 @@ void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup co e.put(std::move(result)); } +DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1); \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py index 96d5ca744826b..df81d1f2cb5fe 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py +++ b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py @@ -63,9 +63,7 @@ fileName = cms.untracked.string('file:step2approximated.root'), outputCommands = cms.untracked.vstring( 'drop *', - 'keep *_*SiStripClusters2ApproxClustersv1*_*_*', - 'keep *_*SiStripClusters2ApproxClustersv2*_*_*', - 'keep *_*SiStripClusters2ApproxClustersv3*_*_*' + 'keep *_*SiStripClusters2ApproxClustersv1*_*_*' ) ) From 11d59dea9301adaf3cf1940a88629a5a9c8b735b Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 28 Apr 2021 10:08:48 +0200 Subject: [PATCH 10/19] fillDescription adding --- .../interface/SiStripApproximateClusterv1.h | 13 +++-- .../SiStripClusters2ApproxClustersv1.cc | 51 ++++++++----------- .../test/SiStripApproximatedClustersDump.cc | 17 +++---- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h index d35f5d0304205..e8c7d654a8632 100644 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h @@ -1,15 +1,19 @@ #ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H #define DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H -#include #include -#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" class SiStripApproximateClusterv1 { public: SiStripApproximateClusterv1() {} - + explicit SiStripApproximateClusterv1(const SiStripCluster& cluster){ + barycenter_=static_cast(cluster.barycenter()); + width_=cluster.size(); + avgCharge_ = static_cast(cluster.charge()/cluster.size()); + } + explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) { barycenter_ = barycenter; width_ = width; @@ -21,9 +25,8 @@ class SiStripApproximateClusterv1 { uint8_t avgCharge() const{return avgCharge_;} private: - uint8_t width_=0; uint16_t barycenter_ = 0; - + uint8_t width_=0; uint8_t avgCharge_ = 0; }; #endif // DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc index 6b5517fdcf97b..32d366b84b53e 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc @@ -5,14 +5,16 @@ #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/DetSetVector.h" + #include #include -#include class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { @@ -20,6 +22,8 @@ class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { explicit SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf); void produce(edm::Event&, const edm::EventSetup&) override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: @@ -30,48 +34,37 @@ class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){ - inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); - clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); + //inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); + auto cc = setWhatProduced(this, conf.getParameter< edm::InputTag >("inputClusters")); - produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >(); + //clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); + clusterToken = cc.consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); + produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >(); } void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ - std::unique_ptr > result(new edmNew::DetSetVector< SiStripApproximateClusterv1 > ); - + auto result = std::make_unique >(); edm::Handle> clusterCollection = e.getHandle(clusterToken); - uint32_t minID = 470444276; - int maxFirst = -1; - - for( edmNew::DetSetVector::const_iterator i = clusterCollection->begin(); i!=clusterCollection->end(); i++){ + for ( const auto& detClusters : *clusterCollection ) { std::vector< SiStripApproximateClusterv1 > tempVec; + edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; - edmNew::DetSetVector::FastFiller ff = edmNew::DetSetVector::FastFiller(*result, i->id()); - - for( edmNew::DetSet::const_iterator j = i->begin(); j!=i->end(); j++){ - - if(maxFirstfirstStrip()) maxFirst = j->firstStrip(); - if(minID>i->id()) minID = i->id(); - - uint8_t width = j->amplitudes().size(); - uint16_t barycenter = (uint16_t)j->barycenter(); - - int charge = 0; - for (unsigned k = 0; k < j->amplitudes().size(); k++) { - charge += (int)j->amplitudes()[k]; - } - - SiStripApproximateClusterv1 approxCluster = SiStripApproximateClusterv1( (uint8_t)(charge/width), barycenter, width ); - ff.push_back(approxCluster); - } + for ( const auto& cluster : detClusters ) ff.push_back(SiStripApproximateClusterv1(cluster)); - } e.put(std::move(result)); } +void +SiStripClusters2ApproxClustersv1::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("inputClusters", edm::InputTag("siStripClusters")); + descriptions.add("SiStripClusters2ApproxClustersv1", desc); +} + + DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1); \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc index 4ed051760fb01..c73639b57ee3a 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc @@ -18,20 +18,17 @@ SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::Para SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {} void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) { - - edm::Handle> inClusters; - event.getByToken(clusterToken, inClusters); + edm::Handle> clusterCollection = event.getHandle(clusterToken); - for (edmNew::DetSetVector::const_iterator itApprox = inClusters->begin(); itApprox!= inClusters->end(); itApprox++) { - detId = itApprox->detId(); + for ( const auto& detClusters : *clusterCollection ) { + detId = detClusters.detId(); eventN = event.id().event(); - for (edmNew::DetSet::const_iterator itClusters = itApprox->begin(); itClusters!= itApprox->end(); itClusters++){ - - barycenter = itClusters->barycenter(); - width = itClusters->width(); - avCharge=itClusters->avgCharge(); + for ( const auto& cluster : detClusters ){ + barycenter = cluster.barycenter(); + width = cluster.width(); + avCharge=cluster.avgCharge(); outNtuple->Fill(); } From 6ef4f3c6eb67c524f034305d37e44e4cc042e620 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 28 Apr 2021 12:31:07 +0200 Subject: [PATCH 11/19] fixing fillDescriptors --- .../plugins/SiStripClusters2ApproxClustersv1.cc | 9 +++------ .../python/SiStripApproximatedClustersDump_cfi.py | 5 ----- .../python/SiStripClusters2ApproxClustersv1_cfi.py | 6 ------ .../test/SiStripApproximatedClustersDump.cc | 6 ++++++ .../test/SiStripApproximatedClustersDump.h | 6 ++++-- .../test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py | 9 +++++++-- ...RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py | 9 ++++++++- 7 files changed, 28 insertions(+), 22 deletions(-) delete mode 100644 RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py delete mode 100644 RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc index 32d366b84b53e..dafd0d497d4a9 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc @@ -34,11 +34,9 @@ class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){ - //inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); - auto cc = setWhatProduced(this, conf.getParameter< edm::InputTag >("inputClusters")); + inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); - //clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); - clusterToken = cc.consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); + clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >(); } @@ -59,8 +57,7 @@ void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup co e.put(std::move(result)); } -void -SiStripClusters2ApproxClustersv1::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void SiStripClusters2ApproxClustersv1::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("inputClusters", edm::InputTag("siStripClusters")); descriptions.add("SiStripClusters2ApproxClustersv1", desc); diff --git a/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py b/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py deleted file mode 100644 index 13fcb34a9e880..0000000000000 --- a/RecoLocalTracker/SiStripClusterizer/python/SiStripApproximatedClustersDump_cfi.py +++ /dev/null @@ -1,5 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump", - approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv1") -) diff --git a/RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py b/RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py deleted file mode 100644 index e001b7b6024d6..0000000000000 --- a/RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -SiStripClusters2ApproxClustersv1 = cms.EDProducer("SiStripClusters2ApproxClustersv1", - inputClusters = cms.InputTag("siStripClusters") -) - diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc index c73639b57ee3a..c1690da115ca1 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc @@ -35,4 +35,10 @@ void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm } } +void SiStripApproximatedClustersDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("approximatedClustersTag", edm::InputTag("SiStripClusters2ApproxClustersv1")); + descriptions.add("SiStripApproximatedClustersDump", desc); +} + diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h index 1f0cd8a5a0625..38665425eb588 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h @@ -6,7 +6,8 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" - +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Common/interface/DetSet.h" @@ -39,7 +40,8 @@ class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer Date: Thu, 29 Apr 2021 18:33:01 +0200 Subject: [PATCH 12/19] ranaming class + inplementing high resolution barycenter --- .../interface/SiStripApproximateCluster.h | 43 +++++++++++++++++++ DataFormats/SiStripCluster/src/classes.h | 2 +- .../SiStripCluster/src/classes_def.xml | 20 ++++----- .../SiStripClusters2ApproxClustersv1.cc | 12 +++--- .../test/SiStripApproximatedClustersDump.cc | 4 +- .../test/SiStripApproximatedClustersDump.h | 4 +- 6 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h new file mode 100644 index 0000000000000..33508f7732179 --- /dev/null +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h @@ -0,0 +1,43 @@ +#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTER_H +#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTER_H + +#include +#include +#include +#include + +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" + +class SiStripApproximateCluster { +public: + + SiStripApproximateCluster() {} + explicit SiStripApproximateCluster(const SiStripCluster& cluster){ + rawBarycenter_=static_cast(std::round(cluster.barycenter()*16)); + width_=cluster.size(); + if(width_>0x3F) width_=0x3F; + avgCharge_ = static_cast(cluster.charge()/cluster.size()); + + std::cout << " rawBaricenter " << rawBarycenter_ << " barycenter: " << this->barycenter() << " OrigBarycenter: " << cluster.barycenter() << " OrigBarycenterCasted: " << static_cast(cluster.barycenter()) << " ratio " << barycenter()/cluster.barycenter() << std::endl; + } + + /* + explicit SiStripApproximateCluster(uint8_t avgCharge, uint16_t barycenter, uint8_t width){ + barycenter_ = barycenter; + width_ = width; + if(width_>0x3F) width_=0x3F; + avgCharge_=avgCharge; + } +*/ + + float barycenter() const {return (float)rawBarycenter_/16;} + uint16_t rawBarycenter() const {return rawBarycenter_;} + uint8_t width() const {return width_;} + uint8_t avgCharge() const{return avgCharge_;} + +private: + uint16_t rawBarycenter_ = 0; + uint8_t width_=0; + uint8_t avgCharge_ = 0; +}; +#endif // DATAFORMATS_SiStripApproximateCluster_H diff --git a/DataFormats/SiStripCluster/src/classes.h b/DataFormats/SiStripCluster/src/classes.h index e02fcb572130d..40a776a39a016 100644 --- a/DataFormats/SiStripCluster/src/classes.h +++ b/DataFormats/SiStripCluster/src/classes.h @@ -5,7 +5,7 @@ #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" -#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" #include "DataFormats/Common/interface/ContainerMask.h" diff --git a/DataFormats/SiStripCluster/src/classes_def.xml b/DataFormats/SiStripCluster/src/classes_def.xml index 39d4ced147004..4482bb528c1ea 100755 --- a/DataFormats/SiStripCluster/src/classes_def.xml +++ b/DataFormats/SiStripCluster/src/classes_def.xml @@ -23,21 +23,21 @@ - - - + + + - + - + - - + + - - - + + + diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc index dafd0d497d4a9..d868aae20af57 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc @@ -7,7 +7,7 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/DetSetVector.h" @@ -37,20 +37,20 @@ SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::Pa inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); - produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >(); + produces< edmNew::DetSetVector< SiStripApproximateCluster > >(); } void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ - auto result = std::make_unique >(); + auto result = std::make_unique >(); edm::Handle> clusterCollection = e.getHandle(clusterToken); for ( const auto& detClusters : *clusterCollection ) { - std::vector< SiStripApproximateClusterv1 > tempVec; - edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; + std::vector< SiStripApproximateCluster > tempVec; + edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; - for ( const auto& cluster : detClusters ) ff.push_back(SiStripApproximateClusterv1(cluster)); + for ( const auto& cluster : detClusters ) ff.push_back(SiStripApproximateCluster(cluster)); } diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc index c1690da115ca1..62a31619a11fc 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc @@ -3,7 +3,7 @@ SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::ParameterSet& conf) { inputTagClusters = conf.getParameter< edm::InputTag >("approximatedClustersTag"); - clusterToken = consumes< edmNew::DetSetVector>(inputTagClusters); + clusterToken = consumes< edmNew::DetSetVector>(inputTagClusters); usesResource("TFileService"); @@ -18,7 +18,7 @@ SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::Para SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {} void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) { - edm::Handle> clusterCollection = event.getHandle(clusterToken); + edm::Handle> clusterCollection = event.getHandle(clusterToken); for ( const auto& detClusters : *clusterCollection ) { diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h index 38665425eb588..37e8d8442dd0d 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h @@ -13,7 +13,7 @@ #include "DataFormats/Common/interface/DetSet.h" #include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" -#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" @@ -47,7 +47,7 @@ class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer > clusterToken; + edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; TTree* outNtuple; edm::Service fs; From 89ca71afb80faad97146aa296e9bc380ffe77f92 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 30 Apr 2021 11:23:59 +0200 Subject: [PATCH 13/19] renaming class and adding extra res approx clusters --- .../interface/SiStripApproximateCluster.h | 15 +------ ...ripApproximateClusterHigherBarycenterRes.h | 40 +++++++++++++++++++ .../interface/SiStripApproximateClusterv1.h | 32 --------------- DataFormats/SiStripCluster/src/classes.h | 1 + .../SiStripCluster/src/classes_def.xml | 17 ++++++++ ...1.cc => SiStripClusters2ApproxClusters.cc} | 14 +++---- .../test/SiStripApproximatedClustersDump.cc | 2 +- ...ep2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py | 8 ++-- ...Reco_RECO_ApproxClusters_streamerOutput.py | 8 ++-- 9 files changed, 76 insertions(+), 61 deletions(-) create mode 100644 DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h delete mode 100644 DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h rename RecoLocalTracker/SiStripClusterizer/plugins/{SiStripClusters2ApproxClustersv1.cc => SiStripClusters2ApproxClusters.cc} (76%) diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h index 33508f7732179..ef13bf2feb49f 100644 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h @@ -13,25 +13,14 @@ class SiStripApproximateCluster { SiStripApproximateCluster() {} explicit SiStripApproximateCluster(const SiStripCluster& cluster){ - rawBarycenter_=static_cast(std::round(cluster.barycenter()*16)); + rawBarycenter_=static_cast(std::round(cluster.barycenter())); width_=cluster.size(); if(width_>0x3F) width_=0x3F; avgCharge_ = static_cast(cluster.charge()/cluster.size()); - - std::cout << " rawBaricenter " << rawBarycenter_ << " barycenter: " << this->barycenter() << " OrigBarycenter: " << cluster.barycenter() << " OrigBarycenterCasted: " << static_cast(cluster.barycenter()) << " ratio " << barycenter()/cluster.barycenter() << std::endl; } - /* - explicit SiStripApproximateCluster(uint8_t avgCharge, uint16_t barycenter, uint8_t width){ - barycenter_ = barycenter; - width_ = width; - if(width_>0x3F) width_=0x3F; - avgCharge_=avgCharge; - } -*/ - float barycenter() const {return (float)rawBarycenter_/16;} - uint16_t rawBarycenter() const {return rawBarycenter_;} + uint16_t barycenter() const {return rawBarycenter_;} uint8_t width() const {return width_;} uint8_t avgCharge() const{return avgCharge_;} diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h new file mode 100644 index 0000000000000..14d13523074fe --- /dev/null +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h @@ -0,0 +1,40 @@ +#ifndef DATAFORMATS_SiStripApproximateClusterHigherBarycenterRes_H +#define DATAFORMATS_SiStripApproximateClusterHigherBarycenterRes_H + +#include +#include +#include +#include + +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" + +class SiStripApproximateClusterHigherBarycenterRes { +public: + + SiStripApproximateClusterHigherBarycenterRes() {} + explicit SiStripApproximateClusterHigherBarycenterRes(const SiStripCluster& cluster){ + rawBarycenter_=static_cast(std::round(cluster.barycenter()*8)); + width_=cluster.size(); + if(width_>0x3F) width_=0x3F; + avgCharge_ = static_cast(cluster.charge()/cluster.size()); + + std::cout << " rawBaricenter " << rawBarycenter_ << + " barycenter: " << this->barycenter() << + " OrigBarycenter: " << cluster.barycenter() << + " OrigBarycenterCasted: " << static_cast(cluster.barycenter()) << + " OrigBarycenterCastedRounded: " << static_cast(cluster.barycenter())<< + " ratio " << barycenter()/cluster.barycenter() << std::endl; + } + + + float barycenter() const {return (float)rawBarycenter_/8;} + uint16_t rawBarycenter() const {return rawBarycenter_;} + uint8_t width() const {return width_;} + uint8_t avgCharge() const{return avgCharge_;} + +private: + uint16_t rawBarycenter_ = 0; + uint8_t width_=0; + uint8_t avgCharge_ = 0; +}; +#endif // DATAFORMATS_SiStripApproximateClusterHigherBarycenterRes_H diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h deleted file mode 100644 index e8c7d654a8632..0000000000000 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H -#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H - -#include -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" - -class SiStripApproximateClusterv1 { -public: - - SiStripApproximateClusterv1() {} - explicit SiStripApproximateClusterv1(const SiStripCluster& cluster){ - barycenter_=static_cast(cluster.barycenter()); - width_=cluster.size(); - avgCharge_ = static_cast(cluster.charge()/cluster.size()); - } - - explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) { - barycenter_ = barycenter; - width_ = width; - if(width_>0x3F) width_=0x3F; - } - - uint16_t barycenter() const {return barycenter_;} - uint8_t width() const {return width_;} - uint8_t avgCharge() const{return avgCharge_;} - -private: - uint16_t barycenter_ = 0; - uint8_t width_=0; - uint8_t avgCharge_ = 0; -}; -#endif // DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H diff --git a/DataFormats/SiStripCluster/src/classes.h b/DataFormats/SiStripCluster/src/classes.h index 40a776a39a016..2638c149a3883 100644 --- a/DataFormats/SiStripCluster/src/classes.h +++ b/DataFormats/SiStripCluster/src/classes.h @@ -6,6 +6,7 @@ #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h" #include "DataFormats/Common/interface/ContainerMask.h" diff --git a/DataFormats/SiStripCluster/src/classes_def.xml b/DataFormats/SiStripCluster/src/classes_def.xml index 4482bb528c1ea..b4af149c7a06e 100755 --- a/DataFormats/SiStripCluster/src/classes_def.xml +++ b/DataFormats/SiStripCluster/src/classes_def.xml @@ -40,4 +40,21 @@ + + + + + + + + + + + + + + + + + diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc similarity index 76% rename from RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc rename to RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc index d868aae20af57..a556a67e026d0 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc @@ -16,11 +16,11 @@ #include #include -class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { +class SiStripClusters2ApproxClusters: public edm::stream::EDProducer<> { public: - explicit SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf); + explicit SiStripClusters2ApproxClusters(const edm::ParameterSet& conf); void produce(edm::Event&, const edm::EventSetup&) override; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); @@ -33,7 +33,7 @@ class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> { -SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){ +SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(const edm::ParameterSet& conf){ inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); @@ -41,7 +41,7 @@ SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::Pa } -void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ +void SiStripClusters2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&){ auto result = std::make_unique >(); edm::Handle> clusterCollection = e.getHandle(clusterToken); @@ -57,11 +57,11 @@ void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup co e.put(std::move(result)); } -void SiStripClusters2ApproxClustersv1::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void SiStripClusters2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("inputClusters", edm::InputTag("siStripClusters")); - descriptions.add("SiStripClusters2ApproxClustersv1", desc); + descriptions.add("SiStripClusters2ApproxClusters", desc); } -DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1); \ No newline at end of file +DEFINE_FWK_MODULE(SiStripClusters2ApproxClusters); \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc index 62a31619a11fc..714078e10d1eb 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc @@ -37,7 +37,7 @@ void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm void SiStripApproximatedClustersDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("approximatedClustersTag", edm::InputTag("SiStripClusters2ApproxClustersv1")); + desc.add("approximatedClustersTag", edm::InputTag("SiStripClusters2ApproxClusters")); descriptions.add("SiStripApproximatedClustersDump", desc); } diff --git a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py index a6bf7e69a2e1a..e8b322f15d789 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py +++ b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py @@ -63,7 +63,7 @@ fileName = cms.untracked.string('file:step2approximated.root'), outputCommands = cms.untracked.vstring( 'drop *', - 'keep *_*SiStripClusters2ApproxClustersv1*_*_*' + 'keep *_*SiStripClusters2ApproxClusters*_*_*' ) ) @@ -78,19 +78,19 @@ process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') -process.SiStripClusters2ApproxClustersv1 = cms.EDProducer("SiStripClusters2ApproxClustersv1", +process.SiStripClusters2ApproxClusters = cms.EDProducer("SiStripClusters2ApproxClusters", inputClusters = cms.InputTag("siStripClusters") ) process.SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump", - approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv1") + approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClusters") ) # Path and EndPath definitions process.raw2digi_step = cms.Path(process.RawToDigi) process.L1Reco_step = cms.Path(process.L1Reco) process.reconstruction_step = cms.Path(process.reconstruction) -process.approxClustersv1_step = cms.Path(process.SiStripClusters2ApproxClustersv1) +process.approxClustersv1_step = cms.Path(process.SiStripClusters2ApproxClusters) process.analyzer_step = cms.Path(process.SiStripApproximatedClustersDump) process.endjob_step = cms.EndPath(process.endOfProcess) process.output_step = cms.EndPath(process.outputClusters+process.outputCompressed) diff --git a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py index d27fb304b9a62..bd42014de0630 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py +++ b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters_streamerOutput.py @@ -66,7 +66,7 @@ outputCommands = cms.untracked.vstring( 'drop *', - 'keep *_*SiStripClusters2ApproxClustersv1*_*_*' + 'keep *_*SiStripClusters2ApproxClusters*_*_*' ) ) @@ -75,19 +75,19 @@ #process.GlobalTag = GlobalTag(process.GlobalTag, '103X_dataRun2_Prompt_v2', '') process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') -process.SiStripClusters2ApproxClustersv1 = cms.EDProducer("SiStripClusters2ApproxClustersv1", +process.SiStripClusters2ApproxClusters = cms.EDProducer("SiStripClusters2ApproxClusters", inputClusters = cms.InputTag("siStripClusters") ) process.SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump", - approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv1") + approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClusters") ) # Path and EndPath definitions process.raw2digi_step = cms.Path(process.RawToDigi) process.L1Reco_step = cms.Path(process.L1Reco) process.reconstruction_step = cms.Path(process.reconstruction) -process.approxClusters_step = cms.Path(process.SiStripClusters2ApproxClustersv1) +process.approxClusters_step = cms.Path(process.SiStripClusters2ApproxClusters) process.analyzer_step = cms.Path(process.SiStripApproximatedClustersDump) process.endjob_step = cms.EndPath(process.endOfProcess) process.output_step = cms.EndPath(process.outputClusters+process.outputCompressed) From fd310e0870d29c43d0c736253b24dd1cd80821ec Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 10 May 2021 19:42:14 +0200 Subject: [PATCH 14/19] adding the AppoxToAppox producer after have created the 'fat' appox cluster format --- .../interface/SiStripApproximateCluster.h | 27 ++++-- ...ripApproximateClusterHigherBarycenterRes.h | 40 -------- DataFormats/SiStripCluster/src/classes.h | 2 - .../SiStripCluster/src/classes_def.xml | 17 ---- .../plugins/SiStripApprox2ApproxClusters.cc | 96 +++++++++++++++++++ ...ep2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py | 17 +++- 6 files changed, 127 insertions(+), 72 deletions(-) delete mode 100644 DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h create mode 100644 RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h index ef13bf2feb49f..cb40b9e7fca06 100644 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h @@ -12,21 +12,30 @@ class SiStripApproximateCluster { public: SiStripApproximateCluster() {} + + explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge){ + barycenter_= barycenter; + width_=width; + //if(width_>0x3F) width_=0x3F; + avgCharge_ = avgCharge; + } + explicit SiStripApproximateCluster(const SiStripCluster& cluster){ - rawBarycenter_=static_cast(std::round(cluster.barycenter())); + //barycenter_=std::round(cluster.barycenter()); + barycenter_=cluster.barycenter(); width_=cluster.size(); - if(width_>0x3F) width_=0x3F; - avgCharge_ = static_cast(cluster.charge()/cluster.size()); + //if(width_>0x3F) width_=0x3F; + avgCharge_ = cluster.charge()/cluster.size(); } - - uint16_t barycenter() const {return rawBarycenter_;} + float barycenter() const {return barycenter_;} uint8_t width() const {return width_;} - uint8_t avgCharge() const{return avgCharge_;} + float avgCharge() const{return avgCharge_;} + private: - uint16_t rawBarycenter_ = 0; - uint8_t width_=0; - uint8_t avgCharge_ = 0; + float barycenter_ = 0; + uint8_t width_=0; + float avgCharge_ = 0; }; #endif // DATAFORMATS_SiStripApproximateCluster_H diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h b/DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h deleted file mode 100644 index 14d13523074fe..0000000000000 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef DATAFORMATS_SiStripApproximateClusterHigherBarycenterRes_H -#define DATAFORMATS_SiStripApproximateClusterHigherBarycenterRes_H - -#include -#include -#include -#include - -#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" - -class SiStripApproximateClusterHigherBarycenterRes { -public: - - SiStripApproximateClusterHigherBarycenterRes() {} - explicit SiStripApproximateClusterHigherBarycenterRes(const SiStripCluster& cluster){ - rawBarycenter_=static_cast(std::round(cluster.barycenter()*8)); - width_=cluster.size(); - if(width_>0x3F) width_=0x3F; - avgCharge_ = static_cast(cluster.charge()/cluster.size()); - - std::cout << " rawBaricenter " << rawBarycenter_ << - " barycenter: " << this->barycenter() << - " OrigBarycenter: " << cluster.barycenter() << - " OrigBarycenterCasted: " << static_cast(cluster.barycenter()) << - " OrigBarycenterCastedRounded: " << static_cast(cluster.barycenter())<< - " ratio " << barycenter()/cluster.barycenter() << std::endl; - } - - - float barycenter() const {return (float)rawBarycenter_/8;} - uint16_t rawBarycenter() const {return rawBarycenter_;} - uint8_t width() const {return width_;} - uint8_t avgCharge() const{return avgCharge_;} - -private: - uint16_t rawBarycenter_ = 0; - uint8_t width_=0; - uint8_t avgCharge_ = 0; -}; -#endif // DATAFORMATS_SiStripApproximateClusterHigherBarycenterRes_H diff --git a/DataFormats/SiStripCluster/src/classes.h b/DataFormats/SiStripCluster/src/classes.h index 2638c149a3883..57f45748f7f2e 100644 --- a/DataFormats/SiStripCluster/src/classes.h +++ b/DataFormats/SiStripCluster/src/classes.h @@ -6,8 +6,6 @@ #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" -#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterHigherBarycenterRes.h" - #include "DataFormats/Common/interface/ContainerMask.h" #endif // SISTRIPCLUSTER_CLASSES_H diff --git a/DataFormats/SiStripCluster/src/classes_def.xml b/DataFormats/SiStripCluster/src/classes_def.xml index b4af149c7a06e..4482bb528c1ea 100755 --- a/DataFormats/SiStripCluster/src/classes_def.xml +++ b/DataFormats/SiStripCluster/src/classes_def.xml @@ -40,21 +40,4 @@ - - - - - - - - - - - - - - - - - diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc new file mode 100644 index 0000000000000..ec943c1ae2552 --- /dev/null +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc @@ -0,0 +1,96 @@ + + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/Common/interface/DetSetVector.h" + + +#include +#include + +class SiStripApprox2ApproxClusters: public edm::stream::EDProducer<> { + +public: + + explicit SiStripApprox2ApproxClusters(const edm::ParameterSet& conf); + void produce(edm::Event&, const edm::EventSetup&) override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + + edm::InputTag inputApproxClusters; + std::string approxVersion; + edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; +}; + + + +SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterSet& conf){ + inputApproxClusters = conf.getParameter< edm::InputTag >("inputApproxClusters"); + approxVersion = conf.getParameter< std::string >("approxVersion"); + + clusterToken = consumes< edmNew::DetSetVector< SiStripApproximateCluster > >(inputApproxClusters); + produces< edmNew::DetSetVector< SiStripApproximateCluster > >(); + +} + +void SiStripApprox2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&){ + auto result = std::make_unique >(); + edm::Handle> clusterCollection = e.getHandle(clusterToken); + + + for ( const auto& detClusters : *clusterCollection ) { + std::vector< SiStripApproximateCluster > tempVec; + edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; + + for ( const auto& cluster : detClusters ){ + float barycenter=cluster.barycenter(); + uint8_t width=cluster.width(); + float avgCharge=cluster.avgCharge(); + + if(approxVersion =="ORIGINAL"){ + barycenter=std::round(barycenter); + if(width>0x3F) width=0x3F; + avgCharge=std::round(avgCharge); + + } else if(approxVersion =="FULL_WIDTH"){ + barycenter=std::round(barycenter); + avgCharge=std::round(avgCharge); + + } else if(approxVersion =="BARY_RES_0.1"){ + barycenter=std::round(barycenter*10)/10; + if(width>0x3F) width=0x3F; + avgCharge=std::round(avgCharge); + + } else if(approxVersion =="BARY_CHARGE_RES_0.1"){ + barycenter=std::round(barycenter*10)/10; + if(width>0x3F) width=0x3F; + avgCharge=std::round(avgCharge*10)/10; + } + + ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge)); + } + } + + e.put(std::move(result)); +} + +void SiStripApprox2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("inputApproxClusters", edm::InputTag("siStripClusters")); + desc.add("approxVersion", std::string("ORIGINAL")); + + descriptions.add("SiStripApprox2ApproxClusters", desc); +} + + +DEFINE_FWK_MODULE(SiStripApprox2ApproxClusters); \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py index e8b322f15d789..a6d7de8416b05 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py +++ b/RecoLocalTracker/SiStripClusterizer/test/step2_RAW2DIGI_L1Reco_RECO_ApproxClusters.py @@ -63,7 +63,9 @@ fileName = cms.untracked.string('file:step2approximated.root'), outputCommands = cms.untracked.vstring( 'drop *', - 'keep *_*SiStripClusters2ApproxClusters*_*_*' + 'keep *_*SiStripClusters2ApproxClusters*_*_*', + 'keep *_*SiStripApprox2ApproxClusters*_*_*' + ) ) @@ -82,15 +84,22 @@ inputClusters = cms.InputTag("siStripClusters") ) +process.SiStripApprox2ApproxClusters = cms.EDProducer("SiStripApprox2ApproxClusters", + inputApproxClusters = cms.InputTag("SiStripClusters2ApproxClusters"), + approxVersion= cms.string("ORIGINAL") +) + process.SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump", - approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClusters") + #approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClusters") + approximatedClustersTag = cms.InputTag("SiStripApprox2ApproxClusters") ) # Path and EndPath definitions process.raw2digi_step = cms.Path(process.RawToDigi) process.L1Reco_step = cms.Path(process.L1Reco) process.reconstruction_step = cms.Path(process.reconstruction) -process.approxClustersv1_step = cms.Path(process.SiStripClusters2ApproxClusters) +process.approxClusters_step = cms.Path(process.SiStripClusters2ApproxClusters) +process.approxToApproxClusters_step=cms.Path(process.SiStripApprox2ApproxClusters) process.analyzer_step = cms.Path(process.SiStripApproximatedClustersDump) process.endjob_step = cms.EndPath(process.endOfProcess) process.output_step = cms.EndPath(process.outputClusters+process.outputCompressed) @@ -133,7 +142,7 @@ # Schedule definition -process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.approxClustersv1_step, process.analyzer_step, process.rawPath, process.endjob_step,process.output_step) +process.schedule = cms.Schedule(process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.approxClusters_step, process.approxToApproxClusters_step, process.analyzer_step, process.rawPath, process.endjob_step,process.output_step) from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask associatePatAlgosToolsTask(process) From 302f4dcbccef328a82335652e85fa039fd8d0b56 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 10 May 2021 19:50:34 +0200 Subject: [PATCH 15/19] code-format applied --- .../interface/SiStripApproximateCluster.h | 34 ++++--- .../plugins/SiStripApprox2ApproxClusters.cc | 88 +++++++++---------- .../SiStripClusterizer/test/SealModules.cc | 1 - .../test/SiStripApproximatedClustersDump.cc | 21 ++--- .../test/SiStripApproximatedClustersDump.h | 10 +-- 5 files changed, 69 insertions(+), 85 deletions(-) diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h index cb40b9e7fca06..95b712adba1b1 100644 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h @@ -8,34 +8,32 @@ #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" -class SiStripApproximateCluster { +class SiStripApproximateCluster { public: - SiStripApproximateCluster() {} - - explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge){ - barycenter_= barycenter; - width_=width; + + explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge) { + barycenter_ = barycenter; + width_ = width; //if(width_>0x3F) width_=0x3F; avgCharge_ = avgCharge; } - explicit SiStripApproximateCluster(const SiStripCluster& cluster){ + explicit SiStripApproximateCluster(const SiStripCluster& cluster) { //barycenter_=std::round(cluster.barycenter()); - barycenter_=cluster.barycenter(); - width_=cluster.size(); + barycenter_ = cluster.barycenter(); + width_ = cluster.size(); //if(width_>0x3F) width_=0x3F; - avgCharge_ = cluster.charge()/cluster.size(); + avgCharge_ = cluster.charge() / cluster.size(); } - float barycenter() const {return barycenter_;} - uint8_t width() const {return width_;} - float avgCharge() const{return avgCharge_;} - + float barycenter() const { return barycenter_; } + uint8_t width() const { return width_; } + float avgCharge() const { return avgCharge_; } private: - float barycenter_ = 0; - uint8_t width_=0; - float avgCharge_ = 0; + float barycenter_ = 0; + uint8_t width_ = 0; + float avgCharge_ = 0; }; -#endif // DATAFORMATS_SiStripApproximateCluster_H +#endif // DATAFORMATS_SiStripApproximateCluster_H diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc index ec943c1ae2552..608ac85b85bcf 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc @@ -12,71 +12,66 @@ #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/DetSetVector.h" - #include #include -class SiStripApprox2ApproxClusters: public edm::stream::EDProducer<> { - +class SiStripApprox2ApproxClusters : public edm::stream::EDProducer<> { public: - explicit SiStripApprox2ApproxClusters(const edm::ParameterSet& conf); void produce(edm::Event&, const edm::EventSetup&) override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - edm::InputTag inputApproxClusters; std::string approxVersion; - edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; + edm::EDGetTokenT> clusterToken; }; +SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterSet& conf) { + inputApproxClusters = conf.getParameter("inputApproxClusters"); + approxVersion = conf.getParameter("approxVersion"); - -SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterSet& conf){ - inputApproxClusters = conf.getParameter< edm::InputTag >("inputApproxClusters"); - approxVersion = conf.getParameter< std::string >("approxVersion"); - - clusterToken = consumes< edmNew::DetSetVector< SiStripApproximateCluster > >(inputApproxClusters); - produces< edmNew::DetSetVector< SiStripApproximateCluster > >(); - + clusterToken = consumes>(inputApproxClusters); + produces>(); } -void SiStripApprox2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&){ - auto result = std::make_unique >(); - edm::Handle> clusterCollection = e.getHandle(clusterToken); - +void SiStripApprox2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&) { + auto result = std::make_unique>(); + edm::Handle> clusterCollection = e.getHandle(clusterToken); - for ( const auto& detClusters : *clusterCollection ) { - std::vector< SiStripApproximateCluster > tempVec; + for (const auto& detClusters : *clusterCollection) { + std::vector tempVec; edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; - for ( const auto& cluster : detClusters ){ - float barycenter=cluster.barycenter(); - uint8_t width=cluster.width(); - float avgCharge=cluster.avgCharge(); - - if(approxVersion =="ORIGINAL"){ - barycenter=std::round(barycenter); - if(width>0x3F) width=0x3F; - avgCharge=std::round(avgCharge); - - } else if(approxVersion =="FULL_WIDTH"){ - barycenter=std::round(barycenter); - avgCharge=std::round(avgCharge); - - } else if(approxVersion =="BARY_RES_0.1"){ - barycenter=std::round(barycenter*10)/10; - if(width>0x3F) width=0x3F; - avgCharge=std::round(avgCharge); - - } else if(approxVersion =="BARY_CHARGE_RES_0.1"){ - barycenter=std::round(barycenter*10)/10; - if(width>0x3F) width=0x3F; - avgCharge=std::round(avgCharge*10)/10; + for (const auto& cluster : detClusters) { + float barycenter = cluster.barycenter(); + uint8_t width = cluster.width(); + float avgCharge = cluster.avgCharge(); + + if (approxVersion == "ORIGINAL") { + barycenter = std::round(barycenter); + if (width > 0x3F) + width = 0x3F; + avgCharge = std::round(avgCharge); + + } else if (approxVersion == "FULL_WIDTH") { + barycenter = std::round(barycenter); + avgCharge = std::round(avgCharge); + + } else if (approxVersion == "BARY_RES_0.1") { + barycenter = std::round(barycenter * 10) / 10; + if (width > 0x3F) + width = 0x3F; + avgCharge = std::round(avgCharge); + + } else if (approxVersion == "BARY_CHARGE_RES_0.1") { + barycenter = std::round(barycenter * 10) / 10; + if (width > 0x3F) + width = 0x3F; + avgCharge = std::round(avgCharge * 10) / 10; } - + ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge)); } } @@ -89,8 +84,7 @@ void SiStripApprox2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptio desc.add("inputApproxClusters", edm::InputTag("siStripClusters")); desc.add("approxVersion", std::string("ORIGINAL")); - descriptions.add("SiStripApprox2ApproxClusters", desc); + descriptions.add("SiStripApprox2ApproxClusters", desc); } - DEFINE_FWK_MODULE(SiStripApprox2ApproxClusters); \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc b/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc index 39ddea57fa0c7..7f0546d7754ca 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SealModules.cc @@ -17,4 +17,3 @@ DEFINE_FWK_MODULE(StripByStripTestDriver); DEFINE_FWK_EVENTSETUP_MODULE(ClusterizerUnitTesterESProducer); DEFINE_FWK_MODULE(ClusterRefinerTagMCmerged); DEFINE_FWK_MODULE(SiStripApproximatedClustersDump); - diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc index 714078e10d1eb..0fc0a3643258c 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.cc @@ -1,10 +1,9 @@ #include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h" - SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::ParameterSet& conf) { - inputTagClusters = conf.getParameter< edm::InputTag >("approximatedClustersTag"); - clusterToken = consumes< edmNew::DetSetVector>(inputTagClusters); - + inputTagClusters = conf.getParameter("approximatedClustersTag"); + clusterToken = consumes>(inputTagClusters); + usesResource("TFileService"); outNtuple = fs->make("ApproxClusters", "ApproxClusters"); @@ -18,19 +17,17 @@ SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::Para SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {} void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) { - edm::Handle> clusterCollection = event.getHandle(clusterToken); + edm::Handle> clusterCollection = event.getHandle(clusterToken); - - for ( const auto& detClusters : *clusterCollection ) { + for (const auto& detClusters : *clusterCollection) { detId = detClusters.detId(); eventN = event.id().event(); - - for ( const auto& cluster : detClusters ){ + + for (const auto& cluster : detClusters) { barycenter = cluster.barycenter(); width = cluster.width(); - avCharge=cluster.avgCharge(); + avCharge = cluster.avgCharge(); outNtuple->Fill(); - } } } @@ -40,5 +37,3 @@ void SiStripApproximatedClustersDump::fillDescriptions(edm::ConfigurationDescrip desc.add("approximatedClustersTag", edm::InputTag("SiStripClusters2ApproxClusters")); descriptions.add("SiStripApproximatedClustersDump", desc); } - - diff --git a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h index 37e8d8442dd0d..780f906a34bc1 100644 --- a/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h +++ b/RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h @@ -1,7 +1,6 @@ #ifndef RecoLocalTracker_SiStripApproximatedClustersDump_h #define RecoLocalTracker_SiStripApproximatedClustersDump_h - // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" @@ -35,27 +34,26 @@ // class decleration // - class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer { public: explicit SiStripApproximatedClustersDump(const edm::ParameterSet&); ~SiStripApproximatedClustersDump() override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: void analyze(const edm::Event&, const edm::EventSetup&) override; edm::InputTag inputTagClusters; - edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; + edm::EDGetTokenT > clusterToken; TTree* outNtuple; edm::Service fs; uint32_t detId; - uint16_t barycenter; + uint16_t barycenter; uint16_t width; uint8_t avCharge; edm::EventNumber_t eventN; }; - #endif +#endif From 8e613e10dec5567fa3ddf44e813694da679077a7 Mon Sep 17 00:00:00 2001 From: Ivan Amos Cali Date: Thu, 20 May 2021 16:07:55 +0200 Subject: [PATCH 16/19] Update RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc removing handle Co-authored-by: Joosep Pata --- .../plugins/SiStripApprox2ApproxClusters.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc index 608ac85b85bcf..7957a4448b83f 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc @@ -38,7 +38,7 @@ SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterS void SiStripApprox2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&) { auto result = std::make_unique>(); - edm::Handle> clusterCollection = e.getHandle(clusterToken); + const auto& clusters = event.get(clusterToken); for (const auto& detClusters : *clusterCollection) { std::vector tempVec; @@ -87,4 +87,4 @@ void SiStripApprox2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptio descriptions.add("SiStripApprox2ApproxClusters", desc); } -DEFINE_FWK_MODULE(SiStripApprox2ApproxClusters); \ No newline at end of file +DEFINE_FWK_MODULE(SiStripApprox2ApproxClusters); From 65c68311c13399ff578698db99f0ff6fc676b343 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 20 May 2021 16:20:04 +0200 Subject: [PATCH 17/19] fixing variable name --- .../SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc index 7957a4448b83f..5d7fb60af6429 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc @@ -36,12 +36,11 @@ SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterS produces>(); } -void SiStripApprox2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&) { +void SiStripApprox2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&) { auto result = std::make_unique>(); const auto& clusters = event.get(clusterToken); for (const auto& detClusters : *clusterCollection) { - std::vector tempVec; edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; for (const auto& cluster : detClusters) { From be7612ca1e7fb58f9b0ecaecdad3293e67a6850f Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 20 May 2021 20:13:18 +0200 Subject: [PATCH 18/19] added switch in Approx2Approx and fixes as per PR request --- .../interface/SiStripApproximateCluster.h | 3 - .../SiStripCluster/src/classes_def.xml | 5 +- .../SiStripClusterizer/BuildFile.xml | 4 +- .../plugins/SiStripApprox2ApproxClusters.cc | 67 ++++++++++--------- .../plugins/SiStripClusters2ApproxClusters.cc | 9 ++- 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h index 95b712adba1b1..3079f0d59be83 100644 --- a/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h +++ b/DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h @@ -15,15 +15,12 @@ class SiStripApproximateCluster { explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge) { barycenter_ = barycenter; width_ = width; - //if(width_>0x3F) width_=0x3F; avgCharge_ = avgCharge; } explicit SiStripApproximateCluster(const SiStripCluster& cluster) { - //barycenter_=std::round(cluster.barycenter()); barycenter_ = cluster.barycenter(); width_ = cluster.size(); - //if(width_>0x3F) width_=0x3F; avgCharge_ = cluster.charge() / cluster.size(); } diff --git a/DataFormats/SiStripCluster/src/classes_def.xml b/DataFormats/SiStripCluster/src/classes_def.xml index 4482bb528c1ea..7a280391ec737 100755 --- a/DataFormats/SiStripCluster/src/classes_def.xml +++ b/DataFormats/SiStripCluster/src/classes_def.xml @@ -23,7 +23,10 @@ - + + + + diff --git a/RecoLocalTracker/SiStripClusterizer/BuildFile.xml b/RecoLocalTracker/SiStripClusterizer/BuildFile.xml index 4873ec688a6d3..67361b25d730c 100644 --- a/RecoLocalTracker/SiStripClusterizer/BuildFile.xml +++ b/RecoLocalTracker/SiStripClusterizer/BuildFile.xml @@ -1,8 +1,10 @@ + + @@ -13,4 +15,4 @@ - + \ No newline at end of file diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc index 5d7fb60af6429..20f32123a0455 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc @@ -4,9 +4,9 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h" #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" #include "DataFormats/Common/interface/DetSetVectorNew.h" @@ -24,58 +24,65 @@ class SiStripApprox2ApproxClusters : public edm::stream::EDProducer<> { private: edm::InputTag inputApproxClusters; - std::string approxVersion; + uint8_t approxVersion; + std::string approxVersionS; edm::EDGetTokenT> clusterToken; }; SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterSet& conf) { inputApproxClusters = conf.getParameter("inputApproxClusters"); - approxVersion = conf.getParameter("approxVersion"); - + approxVersionS = conf.getParameter("approxVersion"); + + approxVersion=-1; + + if(approxVersionS=="ORIGINAL") approxVersion=0; + else if(approxVersionS=="FULL_WIDTH") approxVersion=1; + else if(approxVersionS=="BARY_RES_0.1") approxVersion=2; + else if(approxVersionS=="BARY_CHARGE_RES_0.1") approxVersion=3; + clusterToken = consumes>(inputApproxClusters); produces>(); } void SiStripApprox2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&) { auto result = std::make_unique>(); - const auto& clusters = event.get(clusterToken); + const auto& clusterCollection = event.get(clusterToken); - for (const auto& detClusters : *clusterCollection) { + for (const auto& detClusters : clusterCollection) { edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; for (const auto& cluster : detClusters) { float barycenter = cluster.barycenter(); uint8_t width = cluster.width(); float avgCharge = cluster.avgCharge(); - - if (approxVersion == "ORIGINAL") { - barycenter = std::round(barycenter); - if (width > 0x3F) - width = 0x3F; - avgCharge = std::round(avgCharge); - - } else if (approxVersion == "FULL_WIDTH") { - barycenter = std::round(barycenter); - avgCharge = std::round(avgCharge); - - } else if (approxVersion == "BARY_RES_0.1") { - barycenter = std::round(barycenter * 10) / 10; - if (width > 0x3F) - width = 0x3F; - avgCharge = std::round(avgCharge); - - } else if (approxVersion == "BARY_CHARGE_RES_0.1") { - barycenter = std::round(barycenter * 10) / 10; - if (width > 0x3F) - width = 0x3F; - avgCharge = std::round(avgCharge * 10) / 10; + + switch(approxVersion){ + case 0: //ORIGINAL + barycenter = std::round(barycenter); + if (width > 0x3F) width = 0x3F; + avgCharge = std::round(avgCharge); + break; + case 1: //FULL_WIDTH + barycenter = std::round(barycenter); + avgCharge = std::round(avgCharge); + break; + case 2: //BARY_RES_0.1 + barycenter = std::round(barycenter * 10) / 10; + if (width > 0x3F) width = 0x3F; + avgCharge = std::round(avgCharge); + break; + case 3: //BARY_CHARGE_RES_0.1 + barycenter = std::round(barycenter * 10) / 10; + if (width > 0x3F) width = 0x3F; + avgCharge = std::round(avgCharge * 10) / 10; + break; } - + ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge)); } } - e.put(std::move(result)); + event.put(std::move(result)); } void SiStripApprox2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc index a556a67e026d0..43b63aced8f2c 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc @@ -41,20 +41,19 @@ SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(const edm::Parame } -void SiStripClusters2ApproxClusters::produce(edm::Event& e, edm::EventSetup const&){ +void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&){ auto result = std::make_unique >(); - edm::Handle> clusterCollection = e.getHandle(clusterToken); + const auto& clusterCollection = event.get(clusterToken); - for ( const auto& detClusters : *clusterCollection ) { - std::vector< SiStripApproximateCluster > tempVec; + for ( const auto& detClusters : clusterCollection ) { edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; for ( const auto& cluster : detClusters ) ff.push_back(SiStripApproximateCluster(cluster)); } - e.put(std::move(result)); + event.put(std::move(result)); } void SiStripClusters2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { From 214e8b480498fe217f16ed74b08478aefaeede47 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 20 May 2021 20:24:45 +0200 Subject: [PATCH 19/19] code format --- .../plugins/SiStripApprox2ApproxClusters.cc | 53 +++++++++++-------- .../plugins/SiStripClusters2ApproxClusters.cc | 35 +++++------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc index 20f32123a0455..ea4f3aedaa44c 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripApprox2ApproxClusters.cc @@ -32,14 +32,18 @@ class SiStripApprox2ApproxClusters : public edm::stream::EDProducer<> { SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterSet& conf) { inputApproxClusters = conf.getParameter("inputApproxClusters"); approxVersionS = conf.getParameter("approxVersion"); - - approxVersion=-1; - - if(approxVersionS=="ORIGINAL") approxVersion=0; - else if(approxVersionS=="FULL_WIDTH") approxVersion=1; - else if(approxVersionS=="BARY_RES_0.1") approxVersion=2; - else if(approxVersionS=="BARY_CHARGE_RES_0.1") approxVersion=3; - + + approxVersion = -1; + + if (approxVersionS == "ORIGINAL") + approxVersion = 0; + else if (approxVersionS == "FULL_WIDTH") + approxVersion = 1; + else if (approxVersionS == "BARY_RES_0.1") + approxVersion = 2; + else if (approxVersionS == "BARY_CHARGE_RES_0.1") + approxVersion = 3; + clusterToken = consumes>(inputApproxClusters); produces>(); } @@ -55,29 +59,32 @@ void SiStripApprox2ApproxClusters::produce(edm::Event& event, edm::EventSetup co float barycenter = cluster.barycenter(); uint8_t width = cluster.width(); float avgCharge = cluster.avgCharge(); - - switch(approxVersion){ - case 0: //ORIGINAL - barycenter = std::round(barycenter); - if (width > 0x3F) width = 0x3F; + + switch (approxVersion) { + case 0: //ORIGINAL + barycenter = std::round(barycenter); + if (width > 0x3F) + width = 0x3F; avgCharge = std::round(avgCharge); - break; - case 1: //FULL_WIDTH + break; + case 1: //FULL_WIDTH barycenter = std::round(barycenter); avgCharge = std::round(avgCharge); - break; - case 2: //BARY_RES_0.1 + break; + case 2: //BARY_RES_0.1 barycenter = std::round(barycenter * 10) / 10; - if (width > 0x3F) width = 0x3F; + if (width > 0x3F) + width = 0x3F; avgCharge = std::round(avgCharge); - break; - case 3: //BARY_CHARGE_RES_0.1 + break; + case 3: //BARY_CHARGE_RES_0.1 barycenter = std::round(barycenter * 10) / 10; - if (width > 0x3F) width = 0x3F; + if (width > 0x3F) + width = 0x3F; avgCharge = std::round(avgCharge * 10) / 10; - break; + break; } - + ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge)); } } diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc index 43b63aced8f2c..2e311c92ca6a4 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClusters.cc @@ -12,45 +12,37 @@ #include "DataFormats/Common/interface/DetSetVectorNew.h" #include "DataFormats/Common/interface/DetSetVector.h" - #include #include -class SiStripClusters2ApproxClusters: public edm::stream::EDProducer<> { - +class SiStripClusters2ApproxClusters : public edm::stream::EDProducer<> { public: - explicit SiStripClusters2ApproxClusters(const edm::ParameterSet& conf); void produce(edm::Event&, const edm::EventSetup&) override; - + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - edm::InputTag inputClusters; - edm::EDGetTokenT< edmNew::DetSetVector > clusterToken; + edm::EDGetTokenT > clusterToken; }; +SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(const edm::ParameterSet& conf) { + inputClusters = conf.getParameter("inputClusters"); - -SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(const edm::ParameterSet& conf){ - inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); - - clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); - produces< edmNew::DetSetVector< SiStripApproximateCluster > >(); - + clusterToken = consumes >(inputClusters); + produces >(); } -void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&){ - auto result = std::make_unique >(); +void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&) { + auto result = std::make_unique >(); const auto& clusterCollection = event.get(clusterToken); - - for ( const auto& detClusters : clusterCollection ) { + for (const auto& detClusters : clusterCollection) { edmNew::DetSetVector::FastFiller ff{*result, detClusters.id()}; - for ( const auto& cluster : detClusters ) ff.push_back(SiStripApproximateCluster(cluster)); - + for (const auto& cluster : detClusters) + ff.push_back(SiStripApproximateCluster(cluster)); } event.put(std::move(result)); @@ -59,8 +51,7 @@ void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup void SiStripClusters2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("inputClusters", edm::InputTag("siStripClusters")); - descriptions.add("SiStripClusters2ApproxClusters", desc); + descriptions.add("SiStripClusters2ApproxClusters", desc); } - DEFINE_FWK_MODULE(SiStripClusters2ApproxClusters); \ No newline at end of file