From 4295cb5f0a5bc7acf9ae5b2e351fdc2c19e08a2a Mon Sep 17 00:00:00 2001 From: Cesar Bernardes Date: Wed, 29 Aug 2018 00:52:09 +0200 Subject: [PATCH] Add consistent indentation and use consumes calls missing in the analyzers --- .../plugins/ClustersFromRawProducer.cc | 48 +- .../plugins/SiStripBaselineAnalyzer.cc | 442 +++++++++--------- .../plugins/SiStripBaselineComparator.cc | 149 +++--- .../plugins/SiStripHybridFormatAnalyzer.cc | 290 ++++++------ 4 files changed, 465 insertions(+), 464 deletions(-) diff --git a/RecoLocalTracker/SiStripClusterizer/plugins/ClustersFromRawProducer.cc b/RecoLocalTracker/SiStripClusterizer/plugins/ClustersFromRawProducer.cc index 60968d3179cec..c09201f3c5c51 100644 --- a/RecoLocalTracker/SiStripClusterizer/plugins/ClustersFromRawProducer.cc +++ b/RecoLocalTracker/SiStripClusterizer/plugins/ClustersFromRawProducer.cc @@ -52,28 +52,28 @@ namespace { // Check on FEDRawData pointer if UNLIKELY( !rawData.data() ) { - if (edm::isDebugEnabled()) { - edm::LogWarning(sistrip::mlRawToCluster_) - << "[ClustersFromRawProducer::" - << __func__ - << "]" - << " NULL pointer to FEDRawData for FED id " - << fedId; - } - return buffer; - } + if (edm::isDebugEnabled()) { + edm::LogWarning(sistrip::mlRawToCluster_) + << "[ClustersFromRawProducer::" + << __func__ + << "]" + << " NULL pointer to FEDRawData for FED id " + << fedId; + } + return buffer; + } // Check on FEDRawData size if UNLIKELY( !rawData.size() ) { - if (edm::isDebugEnabled()) { - edm::LogWarning(sistrip::mlRawToCluster_) - << "[ClustersFromRawProducer::" - << __func__ << "]" - << " FEDRawData has zero size for FED id " - << fedId; - } - return buffer; + if (edm::isDebugEnabled()) { + edm::LogWarning(sistrip::mlRawToCluster_) + << "[ClustersFromRawProducer::" + << __func__ << "]" + << " FEDRawData has zero size for FED id " + << fedId; } + return buffer; + } // construct FEDBuffer try { @@ -105,18 +105,18 @@ namespace { class ClusterFiller final : public StripClusterizerAlgorithm::output_t::Getter { public: - ClusterFiller(const FEDRawDataCollection& irawColl, - StripClusterizerAlgorithm & iclusterizer, - SiStripRawProcessingAlgorithms & irawAlgos, - bool idoAPVEmulatorCheck, + ClusterFiller(const FEDRawDataCollection& irawColl, + StripClusterizerAlgorithm & iclusterizer, + SiStripRawProcessingAlgorithms & irawAlgos, + bool idoAPVEmulatorCheck, bool hybridZeroSuppressed): rawColl(irawColl), clusterizer(iclusterizer), rawAlgos(irawAlgos), doAPVEmulatorCheck(idoAPVEmulatorCheck), hybridZeroSuppressed_(hybridZeroSuppressed){ - incTot(clusterizer.allDetIds().size()); - for (auto & d : done) d=nullptr; + incTot(clusterizer.allDetIds().size()); + for (auto & d : done) d=nullptr; } diff --git a/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineAnalyzer.cc b/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineAnalyzer.cc index 6111d8c8afe76..f1f14efd88fb4 100644 --- a/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineAnalyzer.cc +++ b/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineAnalyzer.cc @@ -74,52 +74,52 @@ // class SiStripBaselineAnalyzer : public edm::one::EDAnalyzer { - public: - explicit SiStripBaselineAnalyzer(const edm::ParameterSet&); - ~SiStripBaselineAnalyzer() override; - - - private: - void beginJob() override ; - void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override ; - - std::unique_ptr subtractorPed_; - edm::ESHandle pedestalsHandle; - std::vector pedestals; - uint32_t peds_cache_id; - - bool plotClusters_; - bool plotBaseline_; - bool plotBaselinePoints_; - bool plotRawDigi_; - bool plotDigis_; - bool plotAPVCM_; - bool plotPedestals_; - - edm::InputTag srcBaseline_; - edm::InputTag srcBaselinePoints_; - edm::InputTag srcAPVCM_; - edm::InputTag srcProcessedRawDigi_; - edm::InputTag srcDigis_; - edm::Service fs_; - - TH1F* h1BadAPVperEvent_; - - TH1F* h1ProcessedRawDigis_; - TH1F* h1Baseline_; - TH1F* h1Clusters_; - TH1F* h1APVCM_; - TH1F* h1Pedestals_; - - TCanvas* Canvas_; - std::vector vProcessedRawDigiHisto_; - std::vector vBaselineHisto_; - std::vector vBaselinePointsHisto_; - std::vector vClusterHisto_; - - uint16_t nModuletoDisplay_; - uint16_t actualModule_; + public: + explicit SiStripBaselineAnalyzer(const edm::ParameterSet&); + ~SiStripBaselineAnalyzer() override; + + + private: + void beginJob() override ; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override ; + + std::unique_ptr subtractorPed_; + edm::ESHandle pedestalsHandle; + std::vector pedestals; + uint32_t peds_cache_id; + + bool plotClusters_; + bool plotBaseline_; + bool plotBaselinePoints_; + bool plotRawDigi_; + bool plotDigis_; + bool plotAPVCM_; + bool plotPedestals_; + + edm::InputTag srcBaseline_; + edm::InputTag srcBaselinePoints_; + edm::InputTag srcAPVCM_; + edm::InputTag srcProcessedRawDigi_; + edm::InputTag srcDigis_; + edm::Service fs_; + + TH1F* h1BadAPVperEvent_; + + TH1F* h1ProcessedRawDigis_; + TH1F* h1Baseline_; + TH1F* h1Clusters_; + TH1F* h1APVCM_; + TH1F* h1Pedestals_; + + TCanvas* Canvas_; + std::vector vProcessedRawDigiHisto_; + std::vector vBaselineHisto_; + std::vector vBaselinePointsHisto_; + std::vector vClusterHisto_; + + uint16_t nModuletoDisplay_; + uint16_t actualModule_; }; @@ -174,201 +174,201 @@ SiStripBaselineAnalyzer::~SiStripBaselineAnalyzer() void SiStripBaselineAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& es) { - using namespace edm; - if(plotPedestals_&&actualModule_ ==0){ - uint32_t p_cache_id = es.get().cacheIdentifier(); - if(p_cache_id != peds_cache_id) { - es.get().get(pedestalsHandle); - peds_cache_id = p_cache_id; - } - - - std::vector detIdV; - pedestalsHandle->getDetIds(detIdV); - - for(uint32_t i=0; i < detIdV.size(); ++i){ - pedestals.clear(); - SiStripPedestals::Range pedestalsRange = pedestalsHandle->getRange(detIdV[i]); - pedestals.resize((pedestalsRange.second- pedestalsRange.first)*8/10); - pedestalsHandle->allPeds(pedestals, pedestalsRange); - for(uint32_t it=0; it < pedestals.size(); ++it) h1Pedestals_->Fill(pedestals[it]); - } - } - - if(plotAPVCM_){ - edm::Handle > moduleCM; - edm::InputTag CMLabel("siStripZeroSuppression:APVCM"); - e.getByLabel(srcAPVCM_,moduleCM); - - edm::DetSetVector::const_iterator itCMDetSetV =moduleCM->begin(); - for (; itCMDetSetV != moduleCM->end(); ++itCMDetSetV){ - edm::DetSet::const_iterator itCM= itCMDetSetV->begin(); - for(;itCM != itCMDetSetV->end(); ++itCM) h1APVCM_->Fill(itCM->adc()); - } - } + using namespace edm; + if(plotPedestals_&&actualModule_ ==0){ + uint32_t p_cache_id = es.get().cacheIdentifier(); + if(p_cache_id != peds_cache_id) { + es.get().get(pedestalsHandle); + peds_cache_id = p_cache_id; + } + + + std::vector detIdV; + pedestalsHandle->getDetIds(detIdV); + + for(uint32_t i=0; i < detIdV.size(); ++i){ + pedestals.clear(); + SiStripPedestals::Range pedestalsRange = pedestalsHandle->getRange(detIdV[i]); + pedestals.resize((pedestalsRange.second- pedestalsRange.first)*8/10); + pedestalsHandle->allPeds(pedestals, pedestalsRange); + for(uint32_t it=0; it < pedestals.size(); ++it) h1Pedestals_->Fill(pedestals[it]); + } + } + + if(plotAPVCM_){ + edm::Handle > moduleCM; + edm::InputTag CMLabel("siStripZeroSuppression:APVCM"); + e.getByLabel(srcAPVCM_,moduleCM); + + edm::DetSetVector::const_iterator itCMDetSetV =moduleCM->begin(); + for (; itCMDetSetV != moduleCM->end(); ++itCMDetSetV){ + edm::DetSet::const_iterator itCM= itCMDetSetV->begin(); + for(;itCM != itCMDetSetV->end(); ++itCM) h1APVCM_->Fill(itCM->adc()); + } + } - //if(!plotRawDigi_) return; - subtractorPed_->init(es); + //if(!plotRawDigi_) return; + subtractorPed_->init(es); - edm::Handle< edm::DetSetVector > moduleRawDigi; - if(plotRawDigi_) e.getByLabel(srcProcessedRawDigi_,moduleRawDigi); + edm::Handle< edm::DetSetVector > moduleRawDigi; + if(plotRawDigi_) e.getByLabel(srcProcessedRawDigi_,moduleRawDigi); - edm::Handle > moduleBaseline; - if(plotBaseline_) e.getByLabel(srcBaseline_, moduleBaseline); + edm::Handle > moduleBaseline; + if(plotBaseline_) e.getByLabel(srcBaseline_, moduleBaseline); - edm::Handle > moduleBaselinePoints; - if(plotBaselinePoints_) e.getByLabel(srcBaseline_, moduleBaselinePoints); - - edm::Handle >moduleDigis; - if(plotDigis_) e.getByLabel(srcDigis_, moduleDigis); - - edm::Handle > clusters; - if(plotClusters_){ - edm::InputTag clusLabel("siStripClusters"); - e.getByLabel(clusLabel, clusters); - } + edm::Handle > moduleBaselinePoints; + if(plotBaselinePoints_) e.getByLabel(srcBaseline_, moduleBaselinePoints); + + edm::Handle >moduleDigis; + if(plotDigis_) e.getByLabel(srcDigis_, moduleDigis); + + edm::Handle > clusters; + if(plotClusters_){ + edm::InputTag clusLabel("siStripClusters"); + e.getByLabel(clusLabel, clusters); + } - char detIds[20]; - char evs[20]; - char runs[20]; + char detIds[20]; + char evs[20]; + char runs[20]; - TFileDirectory sdProcessedRawDigis_= fs_->mkdir("ProcessedRawDigis"); - TFileDirectory sdBaseline_= fs_->mkdir("Baseline"); - TFileDirectory sdBaselinePoints_= fs_->mkdir("BaselinePoints"); - TFileDirectory sdClusters_= fs_->mkdir("Clusters"); - TFileDirectory sdDigis_= fs_->mkdir("Digis"); + TFileDirectory sdProcessedRawDigis_= fs_->mkdir("ProcessedRawDigis"); + TFileDirectory sdBaseline_= fs_->mkdir("Baseline"); + TFileDirectory sdBaselinePoints_= fs_->mkdir("BaselinePoints"); + TFileDirectory sdClusters_= fs_->mkdir("Clusters"); + TFileDirectory sdDigis_= fs_->mkdir("Digis"); - edm::DetSetVector::const_iterator itDSBaseline; - if(plotBaseline_) itDSBaseline = moduleBaseline->begin(); - edm::DetSetVector::const_iterator itRawDigis = moduleRawDigi->begin(); - - uint32_t NBabAPVs = moduleRawDigi->size(); - std::cout<< "Number of module with HIP in this event: " << NBabAPVs << std::endl; - h1BadAPVperEvent_->Fill(NBabAPVs); + edm::DetSetVector::const_iterator itDSBaseline; + if(plotBaseline_) itDSBaseline = moduleBaseline->begin(); + edm::DetSetVector::const_iterator itRawDigis = moduleRawDigi->begin(); + + uint32_t NBabAPVs = moduleRawDigi->size(); + std::cout<< "Number of module with HIP in this event: " << NBabAPVs << std::endl; + h1BadAPVperEvent_->Fill(NBabAPVs); - for (; itRawDigis != moduleRawDigi->end(); ++itRawDigis) { - if(actualModule_ > nModuletoDisplay_) return; - uint32_t detId = itRawDigis->id; - - if(plotBaseline_){ - //std::cout << "bas id: " << itDSBaseline->id << " raw id: " << detId << std::endl; - if(itDSBaseline->id != detId){ - std::cout << "Collections out of Synch. Something of fishy is going on ;-)" << std::endl; - return; - } - } + for (; itRawDigis != moduleRawDigi->end(); ++itRawDigis) { + if(actualModule_ > nModuletoDisplay_) return; + uint32_t detId = itRawDigis->id; + + if(plotBaseline_){ + //std::cout << "bas id: " << itDSBaseline->id << " raw id: " << detId << std::endl; + if(itDSBaseline->id != detId){ + std::cout << "Collections out of Synch. Something of fishy is going on ;-)" << std::endl; + return; + } + } - actualModule_++; - edm::RunNumber_t const run = e.id().run(); - edm::EventNumber_t const event = e.id().event(); - //std::cout << "processing module N: " << actualModule_<< " detId: " << detId << " event: "<< event << std::endl; + actualModule_++; + edm::RunNumber_t const run = e.id().run(); + edm::EventNumber_t const event = e.id().event(); + //std::cout << "processing module N: " << actualModule_<< " detId: " << detId << " event: "<< event << std::endl; - edm::DetSet::const_iterator itRaw = itRawDigis->begin(); - bool restAPV[6] = {false,false,false,false,false,false}; - int strip =0, totADC=0; - int minAPVRes = 7, maxAPVRes = -1; - for(;itRaw != itRawDigis->end(); ++itRaw, ++strip){ - float adc = itRaw->adc(); - totADC+= adc; - if(strip%127 ==0){ - //std::cout << "totADC " << totADC << std::endl; - int APV = strip/128; - if(totADC!= 0){ - restAPV[APV] = true; - totADC =0; - if(APV>maxAPVRes) maxAPVRes = APV; - if(APV::const_iterator itRaw = itRawDigis->begin(); + bool restAPV[6] = {false,false,false,false,false,false}; + int strip =0, totADC=0; + int minAPVRes = 7, maxAPVRes = -1; + for(;itRaw != itRawDigis->end(); ++itRaw, ++strip){ + float adc = itRaw->adc(); + totADC+= adc; + if(strip%127 ==0){ + //std::cout << "totADC " << totADC << std::endl; + int APV = strip/128; + if(totADC!= 0){ + restAPV[APV] = true; + totADC =0; + if(APV>maxAPVRes) maxAPVRes = APV; + if(APV(dHistoName,dHistoName, bins, minx, maxx); - - if(plotBaseline_){ - h1Baseline_ = sdBaseline_.make(dHistoName,dHistoName, bins, minx, maxx); - h1Baseline_->SetXTitle("strip#"); - h1Baseline_->SetYTitle("ADC"); - h1Baseline_->SetMaximum(1024.); - h1Baseline_->SetMinimum(-300.); - h1Baseline_->SetLineWidth(2); - h1Baseline_->SetLineStyle(2); - h1Baseline_->SetLineColor(2); - } - - if(plotClusters_){ - h1Clusters_ = sdClusters_.make(dHistoName,dHistoName, bins, minx, maxx); - - h1Clusters_->SetXTitle("strip#"); - h1Clusters_->SetYTitle("ADC"); - h1Clusters_->SetMaximum(1024.); - h1Clusters_->SetMinimum(-300.); - h1Clusters_->SetLineWidth(2); - h1Clusters_->SetLineStyle(2); - h1Clusters_->SetLineColor(3); - } - - h1ProcessedRawDigis_->SetXTitle("strip#"); - h1ProcessedRawDigis_->SetYTitle("ADC"); - h1ProcessedRawDigis_->SetMaximum(1024.); - h1ProcessedRawDigis_->SetMinimum(-300.); - h1ProcessedRawDigis_->SetLineWidth(2); - - std::vector ProcessedRawDigis(itRawDigis->size()); - subtractorPed_->subtract( *itRawDigis, ProcessedRawDigis); - - edm::DetSet::const_iterator itBaseline; - if(plotBaseline_) itBaseline = itDSBaseline->begin(); - std::vector::const_iterator itProcessedRawDigis; - - strip =0; - for(itProcessedRawDigis = ProcessedRawDigis.begin();itProcessedRawDigis != ProcessedRawDigis.end(); ++itProcessedRawDigis){ - if(restAPV[strip/128]){ - float adc = *itProcessedRawDigis; - h1ProcessedRawDigis_->Fill(strip, adc); - if(plotBaseline_){ - h1Baseline_->Fill(strip, itBaseline->adc()); - ++itBaseline; - } - } - ++strip; - } + sprintf(detIds,"%ul", detId); + sprintf(evs,"%llu", event); + sprintf(runs,"%u", run); + char* dHistoName = Form("Id:%s_run:%s_ev:%s",detIds, runs, evs); + h1ProcessedRawDigis_ = sdProcessedRawDigis_.make(dHistoName,dHistoName, bins, minx, maxx); + + if(plotBaseline_){ + h1Baseline_ = sdBaseline_.make(dHistoName,dHistoName, bins, minx, maxx); + h1Baseline_->SetXTitle("strip#"); + h1Baseline_->SetYTitle("ADC"); + h1Baseline_->SetMaximum(1024.); + h1Baseline_->SetMinimum(-300.); + h1Baseline_->SetLineWidth(2); + h1Baseline_->SetLineStyle(2); + h1Baseline_->SetLineColor(2); + } + + if(plotClusters_){ + h1Clusters_ = sdClusters_.make(dHistoName,dHistoName, bins, minx, maxx); + + h1Clusters_->SetXTitle("strip#"); + h1Clusters_->SetYTitle("ADC"); + h1Clusters_->SetMaximum(1024.); + h1Clusters_->SetMinimum(-300.); + h1Clusters_->SetLineWidth(2); + h1Clusters_->SetLineStyle(2); + h1Clusters_->SetLineColor(3); + } + + h1ProcessedRawDigis_->SetXTitle("strip#"); + h1ProcessedRawDigis_->SetYTitle("ADC"); + h1ProcessedRawDigis_->SetMaximum(1024.); + h1ProcessedRawDigis_->SetMinimum(-300.); + h1ProcessedRawDigis_->SetLineWidth(2); + + std::vector ProcessedRawDigis(itRawDigis->size()); + subtractorPed_->subtract( *itRawDigis, ProcessedRawDigis); + + edm::DetSet::const_iterator itBaseline; + if(plotBaseline_) itBaseline = itDSBaseline->begin(); + std::vector::const_iterator itProcessedRawDigis; + + strip =0; + for(itProcessedRawDigis = ProcessedRawDigis.begin();itProcessedRawDigis != ProcessedRawDigis.end(); ++itProcessedRawDigis){ + if(restAPV[strip/128]){ + float adc = *itProcessedRawDigis; + h1ProcessedRawDigis_->Fill(strip, adc); + if(plotBaseline_){ + h1Baseline_->Fill(strip, itBaseline->adc()); + ++itBaseline; + } + } + ++strip; + } - if(plotBaseline_) ++itDSBaseline; - if(plotClusters_){ - edmNew::DetSetVector::const_iterator itClusters = clusters->begin(); - for ( ; itClusters != clusters->end(); ++itClusters ){ - for ( edmNew::DetSet::const_iterator clus = itClusters->begin(); clus != itClusters->end(); ++clus){ - if(itClusters->id() == detId){ - int firststrip = clus->firstStrip(); - //std::cout << "Found cluster in detId " << detId << " " << firststrip << " " << clus->amplitudes().size() << " -----------------------------------------------" << std::endl; - strip=0; - for( auto itAmpl = clus->amplitudes().begin(); itAmpl != clus->amplitudes().end(); ++itAmpl){ - h1Clusters_->Fill(firststrip+strip, *itAmpl); - ++strip; - } - } - } - } + if(plotBaseline_) ++itDSBaseline; + if(plotClusters_){ + edmNew::DetSetVector::const_iterator itClusters = clusters->begin(); + for ( ; itClusters != clusters->end(); ++itClusters ){ + for ( edmNew::DetSet::const_iterator clus = itClusters->begin(); clus != itClusters->end(); ++clus){ + if(itClusters->id() == detId){ + int firststrip = clus->firstStrip(); + //std::cout << "Found cluster in detId " << detId << " " << firststrip << " " << clus->amplitudes().size() << " -----------------------------------------------" << std::endl; + strip=0; + for( auto itAmpl = clus->amplitudes().begin(); itAmpl != clus->amplitudes().end(); ++itAmpl){ + h1Clusters_->Fill(firststrip+strip, *itAmpl); + ++strip; + } + } + } } - } + } + } } diff --git a/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineComparator.cc b/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineComparator.cc index ae3eabe69c2e8..a1a8e454864df 100644 --- a/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineComparator.cc +++ b/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripBaselineComparator.cc @@ -75,36 +75,37 @@ // class SiStripBaselineComparator : public edm::EDAnalyzer { - public: - explicit SiStripBaselineComparator(const edm::ParameterSet&); - ~SiStripBaselineComparator() override; - - - private: - void beginJob() override ; - void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override ; - - edm::InputTag srcClusters_; - edm::InputTag srcClusters2_; - - edm::Service fs_; - + public: + explicit SiStripBaselineComparator(const edm::ParameterSet&); + ~SiStripBaselineComparator() override; + + + private: + void beginJob() override ; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override ; + + edm::EDGetTokenT > srcClusters_; + edm::EDGetTokenT > srcClusters2_; + - TH1F* h1_nOldClusters_; - TH1F* h1_nMatchedClusters_; - TH1F* h1_nSplitClusters_; - TProfile* h1_matchingMult_; - TProfile* h1_matchedWidth_; - TProfile* h1_matchedCharges_; + edm::Service fs_; + + + TH1F* h1_nOldClusters_; + TH1F* h1_nMatchedClusters_; + TH1F* h1_nSplitClusters_; + TProfile* h1_matchingMult_; + TProfile* h1_matchedWidth_; + TProfile* h1_matchedCharges_; }; SiStripBaselineComparator::SiStripBaselineComparator(const edm::ParameterSet& conf){ - srcClusters_ = conf.getParameter( "srcClusters" ); - srcClusters2_ = conf.getParameter( "srcClusters2" ); - + srcClusters_ = consumes >(conf.getParameter("srcClusters")); + srcClusters2_ = consumes >(conf.getParameter("srcClusters2")); + h1_nOldClusters_ = fs_->make("nOldClusters","nOldClusters;ClusterSize", 128, 0, 128); h1_nMatchedClusters_ = fs_->make("nMatchedClusters","nMatchedClusters;ClusterSize", 128, 0, 128); h1_nSplitClusters_ = fs_->make("nSplitClusters","nMatchedClusters;ClusterSize; n Split Clusters", 128, 0, 128); @@ -121,56 +122,56 @@ SiStripBaselineComparator::~SiStripBaselineComparator() void SiStripBaselineComparator::analyze(const edm::Event& e, const edm::EventSetup& es) { - edm::Handle > clusters; - e.getByLabel(srcClusters_,clusters); - edm::Handle > clusters2; - e.getByLabel(srcClusters2_,clusters2); - - edmNew::DetSetVector::const_iterator itClusters = clusters->begin(); - for ( ; itClusters != clusters->end(); ++itClusters ){ - for ( edmNew::DetSet::const_iterator clus = itClusters->begin(); clus != itClusters->end(); ++clus){ - h1_nOldClusters_->Fill(clus->amplitudes().size(),1); - int nMatched = 0; - int charge1 = 0; - for( auto itAmpl = clus->amplitudes().begin(); itAmpl != clus->amplitudes().end(); ++itAmpl) charge1 += *itAmpl; - std::vector< int > matchedWidths; - std::vector< int > matchedCharges; - - //scan other set of clusters - edmNew::DetSetVector::const_iterator itClusters2 = clusters2->begin(); - for ( ; itClusters2 != clusters2->end(); ++itClusters2 ){ - if(itClusters->id() != itClusters2->id()) continue; - for ( edmNew::DetSet::const_iterator clus2 = itClusters2->begin(); clus2 != itClusters2->end(); ++clus2){ - int charge2 = 0; - for( auto itAmpl = clus2->amplitudes().begin(); itAmpl != clus2->amplitudes().end(); ++itAmpl) charge2 += *itAmpl; - int strip=clus->firstStrip(); - for( auto itAmpl = clus->amplitudes().begin(); itAmpl != clus->amplitudes().end(); ++itAmpl){ - if(clus2->firstStrip() == strip){ - if(nMatched>0){ - if(nMatched==1) h1_nSplitClusters_->Fill(clus->amplitudes().size(),1); - matchedWidths.push_back(clus2->amplitudes().size()); - matchedCharges.push_back(charge2); - nMatched++; - } - if(nMatched==0){ - matchedWidths.push_back(clus2->amplitudes().size()); - matchedCharges.push_back(charge2); - nMatched++; - h1_nMatchedClusters_->Fill(clus->amplitudes().size(),1); - } - break; - } - ++strip; - } - } - } - for(int i = 0; iamplitudes().size()<1000) h1_matchedWidth_->Fill(clus->amplitudes().size(),matchedWidths.at(i)-clus->amplitudes().size()); - if(charge1 != 0 && matchedCharges.at(i)/(float)charge1<10000000) h1_matchedCharges_->Fill(clus->amplitudes().size(),matchedCharges.at(i)/(float)charge1); - } - if(nMatched>1) h1_matchingMult_->Fill(clus->amplitudes().size(),nMatched); - } - } + edm::Handle > clusters; + e.getByToken(srcClusters_,clusters); + edm::Handle > clusters2; + e.getByToken(srcClusters2_,clusters2); + + edmNew::DetSetVector::const_iterator itClusters = clusters->begin(); + for ( ; itClusters != clusters->end(); ++itClusters ){ + for ( edmNew::DetSet::const_iterator clus = itClusters->begin(); clus != itClusters->end(); ++clus){ + h1_nOldClusters_->Fill(clus->amplitudes().size(),1); + int nMatched = 0; + int charge1 = 0; + for( auto itAmpl = clus->amplitudes().begin(); itAmpl != clus->amplitudes().end(); ++itAmpl) charge1 += *itAmpl; + std::vector< int > matchedWidths; + std::vector< int > matchedCharges; + + //scan other set of clusters + edmNew::DetSetVector::const_iterator itClusters2 = clusters2->begin(); + for ( ; itClusters2 != clusters2->end(); ++itClusters2 ){ + if(itClusters->id() != itClusters2->id()) continue; + for ( edmNew::DetSet::const_iterator clus2 = itClusters2->begin(); clus2 != itClusters2->end(); ++clus2){ + int charge2 = 0; + for( auto itAmpl = clus2->amplitudes().begin(); itAmpl != clus2->amplitudes().end(); ++itAmpl) charge2 += *itAmpl; + int strip=clus->firstStrip(); + for( auto itAmpl = clus->amplitudes().begin(); itAmpl != clus->amplitudes().end(); ++itAmpl){ + if(clus2->firstStrip() == strip){ + if(nMatched>0){ + if(nMatched==1) h1_nSplitClusters_->Fill(clus->amplitudes().size(),1); + matchedWidths.push_back(clus2->amplitudes().size()); + matchedCharges.push_back(charge2); + nMatched++; + } + if(nMatched==0){ + matchedWidths.push_back(clus2->amplitudes().size()); + matchedCharges.push_back(charge2); + nMatched++; + h1_nMatchedClusters_->Fill(clus->amplitudes().size(),1); + } + break; + } + ++strip; + } + } + } + for(int i = 0; iamplitudes().size()<1000) h1_matchedWidth_->Fill(clus->amplitudes().size(),matchedWidths.at(i)-clus->amplitudes().size()); + if(charge1 != 0 && matchedCharges.at(i)/(float)charge1<10000000) h1_matchedCharges_->Fill(clus->amplitudes().size(),matchedCharges.at(i)/(float)charge1); + } + if(nMatched>1) h1_matchingMult_->Fill(clus->amplitudes().size(),nMatched); + } + } //clusters /* int nclust = 0; diff --git a/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripHybridFormatAnalyzer.cc b/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripHybridFormatAnalyzer.cc index 0d6809922a606..4a663a74fc56d 100644 --- a/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripHybridFormatAnalyzer.cc +++ b/RecoLocalTracker/SiStripZeroSuppression/plugins/SiStripHybridFormatAnalyzer.cc @@ -74,41 +74,41 @@ // class SiStripHybridFormatAnalyzer : public edm::EDAnalyzer { - public: - explicit SiStripHybridFormatAnalyzer(const edm::ParameterSet&); - ~SiStripHybridFormatAnalyzer() override; - - - private: - void beginJob() override ; - void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override ; - - edm::InputTag srcDigis_; - edm::InputTag srcAPVCM_; - edm::Service fs_; - - TH1F* h1Digis_; - TH1F* h1APVCM_; - TH1F* h1BadAPVperEvent_; - TH1F* h1BadAPVperModule_; - TH1F* h1BadAPVperModuleOnlyBadModule_; - TH1F* h1Pedestals_; - - TCanvas* Canvas_; - - TFileDirectory sdDigis_; - TFileDirectory sdMisc_; - - uint16_t nModuletoDisplay_; - uint16_t actualModule_; - - bool plotAPVCM_; - - //this to plot the pedestals distribution - edm::ESHandle pedestalsHandle; - std::vector pedestals; - uint32_t peds_cache_id; + public: + explicit SiStripHybridFormatAnalyzer(const edm::ParameterSet&); + ~SiStripHybridFormatAnalyzer() override; + + + private: + void beginJob() override ; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override ; + + edm::EDGetTokenT > srcDigis_; + edm::EDGetTokenT > srcAPVCM_; + edm::Service fs_; + + TH1F* h1Digis_; + TH1F* h1APVCM_; + TH1F* h1BadAPVperEvent_; + TH1F* h1BadAPVperModule_; + TH1F* h1BadAPVperModuleOnlyBadModule_; + TH1F* h1Pedestals_; + + TCanvas* Canvas_; + + TFileDirectory sdDigis_; + TFileDirectory sdMisc_; + + uint16_t nModuletoDisplay_; + uint16_t actualModule_; + + bool plotAPVCM_; + + //this to plot the pedestals distribution + edm::ESHandle pedestalsHandle; + std::vector pedestals; + uint32_t peds_cache_id; }; @@ -117,8 +117,8 @@ class SiStripHybridFormatAnalyzer : public edm::EDAnalyzer { SiStripHybridFormatAnalyzer::SiStripHybridFormatAnalyzer(const edm::ParameterSet& conf){ - srcDigis_ = conf.getParameter( "srcDigis" ); - srcAPVCM_ = conf.getParameter( "srcAPVCM" ); + srcDigis_ = consumes>(conf.getParameter("srcDigis")); + srcAPVCM_ = consumes>(conf.getParameter("srcAPVCM")); nModuletoDisplay_ = conf.getParameter( "nModuletoDisplay" ); plotAPVCM_ = conf.getParameter( "plotAPVCM" ); @@ -131,30 +131,30 @@ SiStripHybridFormatAnalyzer::SiStripHybridFormatAnalyzer(const edm::ParameterSet h1APVCM_->SetLineWidth(2); h1APVCM_->SetLineStyle(2); - h1BadAPVperEvent_ = sdMisc_.make("BadAPV/Event","BadAPV/Event", 72786, -0.5, 72785.5); - h1BadAPVperEvent_->SetXTitle("# Bad APVs"); - h1BadAPVperEvent_->SetYTitle("Entries"); - h1BadAPVperEvent_->SetLineWidth(2); - h1BadAPVperEvent_->SetLineStyle(2); - - h1BadAPVperModule_ = sdMisc_.make("BadAPV/Module","BadAPV/Module", 7, -0.5, 6.5); - h1BadAPVperModule_->SetXTitle("# Bad APVs"); - h1BadAPVperModule_->SetYTitle("Entries"); - h1BadAPVperModule_->SetLineWidth(2); - h1BadAPVperModule_->SetLineStyle(2); - - h1BadAPVperModuleOnlyBadModule_ = sdMisc_.make("BadAPV/Module Only Bad Modules","BadAPV/Module Only Bad Modules", 7, -0.5, 6.5); - h1BadAPVperModuleOnlyBadModule_->SetXTitle("# Bad APVs"); - h1BadAPVperModuleOnlyBadModule_->SetYTitle("Entries"); - h1BadAPVperModuleOnlyBadModule_->SetLineWidth(2); - h1BadAPVperModuleOnlyBadModule_->SetLineStyle(2); - - h1Pedestals_ = sdMisc_.make("Pedestals","Pedestals", 2048, -1023.5, 1023.5); - h1Pedestals_->SetXTitle("Pedestals [adc]"); - h1Pedestals_->SetYTitle("Entries"); - h1Pedestals_->SetLineWidth(2); - h1Pedestals_->SetLineStyle(2); - + h1BadAPVperEvent_ = sdMisc_.make("BadAPV/Event","BadAPV/Event", 72786, -0.5, 72785.5); + h1BadAPVperEvent_->SetXTitle("# Bad APVs"); + h1BadAPVperEvent_->SetYTitle("Entries"); + h1BadAPVperEvent_->SetLineWidth(2); + h1BadAPVperEvent_->SetLineStyle(2); + + h1BadAPVperModule_ = sdMisc_.make("BadAPV/Module","BadAPV/Module", 7, -0.5, 6.5); + h1BadAPVperModule_->SetXTitle("# Bad APVs"); + h1BadAPVperModule_->SetYTitle("Entries"); + h1BadAPVperModule_->SetLineWidth(2); + h1BadAPVperModule_->SetLineStyle(2); + + h1BadAPVperModuleOnlyBadModule_ = sdMisc_.make("BadAPV/Module Only Bad Modules","BadAPV/Module Only Bad Modules", 7, -0.5, 6.5); + h1BadAPVperModuleOnlyBadModule_->SetXTitle("# Bad APVs"); + h1BadAPVperModuleOnlyBadModule_->SetYTitle("Entries"); + h1BadAPVperModuleOnlyBadModule_->SetLineWidth(2); + h1BadAPVperModuleOnlyBadModule_->SetLineStyle(2); + + h1Pedestals_ = sdMisc_.make("Pedestals","Pedestals", 2048, -1023.5, 1023.5); + h1Pedestals_->SetXTitle("Pedestals [adc]"); + h1Pedestals_->SetYTitle("Entries"); + h1Pedestals_->SetLineWidth(2); + h1Pedestals_->SetLineStyle(2); + } @@ -168,97 +168,97 @@ SiStripHybridFormatAnalyzer::~SiStripHybridFormatAnalyzer() void SiStripHybridFormatAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& es) { - using namespace edm; - - //plotting pedestals - //------------------------------------------------------------------ - if(actualModule_ ==0){ - uint32_t p_cache_id = es.get().cacheIdentifier(); - if(p_cache_id != peds_cache_id) { - es.get().get(pedestalsHandle); - peds_cache_id = p_cache_id; - } - std::vector detIdV; - pedestalsHandle->getDetIds(detIdV); - - for(uint32_t i=0; i < detIdV.size(); ++i){ - pedestals.clear(); - SiStripPedestals::Range pedestalsRange = pedestalsHandle->getRange(detIdV[i]); - pedestals.resize((pedestalsRange.second- pedestalsRange.first)*8/10); - pedestalsHandle->allPeds(pedestals, pedestalsRange); - for(uint32_t it=0; it < pedestals.size(); ++it) h1Pedestals_->Fill(pedestals[it]); - } - } + using namespace edm; + + //plotting pedestals + //------------------------------------------------------------------ + if(actualModule_ ==0){ + uint32_t p_cache_id = es.get().cacheIdentifier(); + if(p_cache_id != peds_cache_id) { + es.get().get(pedestalsHandle); + peds_cache_id = p_cache_id; + } + std::vector detIdV; + pedestalsHandle->getDetIds(detIdV); + + for(uint32_t i=0; i < detIdV.size(); ++i){ + pedestals.clear(); + SiStripPedestals::Range pedestalsRange = pedestalsHandle->getRange(detIdV[i]); + pedestals.resize((pedestalsRange.second- pedestalsRange.first)*8/10); + pedestalsHandle->allPeds(pedestals, pedestalsRange); + for(uint32_t it=0; it < pedestals.size(); ++it) h1Pedestals_->Fill(pedestals[it]); + } + } - //plotting CMN - //------------------------------------------------------------------ + //plotting CMN + //------------------------------------------------------------------ - if(plotAPVCM_){ - edm::Handle > moduleCM; - e.getByLabel(srcAPVCM_,moduleCM); - - - edm::DetSetVector::const_iterator itCMDetSetV =moduleCM->begin(); - for (; itCMDetSetV != moduleCM->end(); ++itCMDetSetV){ - edm::DetSet::const_iterator itCM= itCMDetSetV->begin(); - for(;itCM != itCMDetSetV->end(); ++itCM) h1APVCM_->Fill(itCM->adc()); - } - } + if(plotAPVCM_){ + edm::Handle > moduleCM; + e.getByToken(srcAPVCM_,moduleCM); + + + edm::DetSetVector::const_iterator itCMDetSetV =moduleCM->begin(); + for (; itCMDetSetV != moduleCM->end(); ++itCMDetSetV){ + edm::DetSet::const_iterator itCM= itCMDetSetV->begin(); + for(;itCM != itCMDetSetV->end(); ++itCM) h1APVCM_->Fill(itCM->adc()); + } + } - //plotting digis histograms - //------------------------------------------------------------------ - uint32_t NBadAPVevent=0; + //plotting digis histograms + //------------------------------------------------------------------ + uint32_t NBadAPVevent=0; - edm::Handle >moduleDigis; - e.getByLabel(srcDigis_, moduleDigis); + edm::Handle >moduleDigis; + e.getByToken(srcDigis_, moduleDigis); - edm::DetSetVector::const_iterator itDigiDetSetV =moduleDigis->begin(); - for (; itDigiDetSetV != moduleDigis->end(); ++itDigiDetSetV){ - uint32_t detId = itDigiDetSetV->id; - edm::RunNumber_t const run = e.id().run(); - edm::EventNumber_t const event = e.id().event(); - - char detIds[20]; - char evs[20]; - char runs[20]; - - if(actualModule_ < nModuletoDisplay_){ - sprintf(detIds,"%ul", detId); - sprintf(evs,"%llu", event); - sprintf(runs,"%u", run); - char* dHistoName = Form("Id_%s_run_%s_ev_%s",detIds, runs, evs); - h1Digis_ = sdDigis_.make(dHistoName,dHistoName, 768, -0.5, 767.5); - h1Digis_->SetXTitle("strip #"); - h1Digis_->SetYTitle("adc"); - h1Digis_->SetLineWidth(2); - h1Digis_->SetLineStyle(2); - } - uint16_t stripsPerAPV[6]={0,0,0,0,0,0}; - edm::DetSet::const_iterator itDigi= itDigiDetSetV->begin(); - for(;itDigi != itDigiDetSetV->end(); ++itDigi){ - uint16_t strip = itDigi->strip(); - uint16_t adc = itDigi->adc(); - if(actualModule_ < nModuletoDisplay_) h1Digis_->Fill(strip, adc); - actualModule_++; - //std::cout << "detID " << detId << " strip " << strip << " adc " << adc << std::endl; - - stripsPerAPV[strip/128]++; - } - - uint16_t NBadAPVmodule=0; - for(uint16_t APVn=0; APVn<6; APVn++){ - if(stripsPerAPV[APVn]>64){ - NBadAPVevent++; - NBadAPVmodule++; - } - } - h1BadAPVperModule_->Fill(NBadAPVmodule); - if(NBadAPVmodule) h1BadAPVperModuleOnlyBadModule_->Fill(NBadAPVmodule); - } - h1BadAPVperEvent_->Fill(NBadAPVevent); + edm::DetSetVector::const_iterator itDigiDetSetV =moduleDigis->begin(); + for (; itDigiDetSetV != moduleDigis->end(); ++itDigiDetSetV){ + uint32_t detId = itDigiDetSetV->id; + edm::RunNumber_t const run = e.id().run(); + edm::EventNumber_t const event = e.id().event(); + + char detIds[20]; + char evs[20]; + char runs[20]; + if(actualModule_ < nModuletoDisplay_){ + sprintf(detIds,"%ul", detId); + sprintf(evs,"%llu", event); + sprintf(runs,"%u", run); + char* dHistoName = Form("Id_%s_run_%s_ev_%s",detIds, runs, evs); + h1Digis_ = sdDigis_.make(dHistoName,dHistoName, 768, -0.5, 767.5); + h1Digis_->SetXTitle("strip #"); + h1Digis_->SetYTitle("adc"); + h1Digis_->SetLineWidth(2); + h1Digis_->SetLineStyle(2); + } + uint16_t stripsPerAPV[6]={0,0,0,0,0,0}; + edm::DetSet::const_iterator itDigi= itDigiDetSetV->begin(); + for(;itDigi != itDigiDetSetV->end(); ++itDigi){ + uint16_t strip = itDigi->strip(); + uint16_t adc = itDigi->adc(); + if(actualModule_ < nModuletoDisplay_) h1Digis_->Fill(strip, adc); + actualModule_++; + //std::cout << "detID " << detId << " strip " << strip << " adc " << adc << std::endl; + + stripsPerAPV[strip/128]++; + } + + uint16_t NBadAPVmodule=0; + for(uint16_t APVn=0; APVn<6; APVn++){ + if(stripsPerAPV[APVn]>64){ + NBadAPVevent++; + NBadAPVmodule++; + } + } + h1BadAPVperModule_->Fill(NBadAPVmodule); + if(NBadAPVmodule) h1BadAPVperModuleOnlyBadModule_->Fill(NBadAPVmodule); + } + h1BadAPVperEvent_->Fill(NBadAPVevent); + } @@ -267,7 +267,7 @@ void SiStripHybridFormatAnalyzer::beginJob() { -actualModule_ =0; + actualModule_ =0; }