From 76c3ff3ded5f8e6220ed8180f2610bd57fd9e9f1 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 6 Mar 2023 17:29:48 +0100 Subject: [PATCH] fix segmentation violation in SiStripHitEffFromCalibTree in ASAN_X --- .../plugins/SiStripHitEffFromCalibTree.cc | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/CalibTracker/SiStripHitEfficiency/plugins/SiStripHitEffFromCalibTree.cc b/CalibTracker/SiStripHitEfficiency/plugins/SiStripHitEffFromCalibTree.cc index d51f2f36adb7b..7619a84bd51d0 100644 --- a/CalibTracker/SiStripHitEfficiency/plugins/SiStripHitEffFromCalibTree.cc +++ b/CalibTracker/SiStripHitEfficiency/plugins/SiStripHitEffFromCalibTree.cc @@ -119,6 +119,7 @@ class SiStripHitEffFromCalibTree : public ConditionDBWriter { // to be used everywhere static constexpr int SiStripLayers = 22; + static constexpr double nBxInAnOrbit = 3565; edm::Service fs; SiStripDetInfo _detInfo; @@ -179,6 +180,8 @@ class SiStripHitEffFromCalibTree : public ConditionDBWriter { vector layertotal_vsPU; vector layerfound_vsCM; vector layertotal_vsCM; + vector layerfound_vsBX; + vector layertotal_vsBX; int goodlayertotal[35]; int goodlayerfound[35]; int alllayertotal[35]; @@ -284,6 +287,11 @@ void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::Eve layertotal_vsPU.push_back( fs->make(Form("layertotal_vsPU_layer_%i", (int)(ilayer)), lyrName.c_str(), 45, 0, 90)); + layerfound_vsBX.push_back(fs->make( + Form("foundVsBx_layer%i", (int)ilayer), Form("layer %i", (int)ilayer), nBxInAnOrbit, 0, nBxInAnOrbit)); + layertotal_vsBX.push_back(fs->make( + Form("totalVsBx_layer%i", (int)ilayer), Form("layer %i", (int)ilayer), nBxInAnOrbit, 0, nBxInAnOrbit)); + if (_useCM) { layerfound_vsCM.push_back( fs->make(Form("layerfound_vsCM_layer_%i", (int)(ilayer)), lyrName.c_str(), 20, 0, 400)); @@ -1376,27 +1384,25 @@ void SiStripHitEffFromCalibTree::makeSummaryVsBx() { nLayers = 20; for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) { - TH1F* hfound = fs->make(Form("foundVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565); - TH1F* htotal = fs->make(Form("totalVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565); - for (unsigned int ibx = 0; ibx < 3566; ibx++) { - hfound->SetBinContent(ibx, 1e-6); - htotal->SetBinContent(ibx, 1); + layerfound_vsBX[ilayer]->SetBinContent(ibx, 1e-6); + layertotal_vsBX[ilayer]->SetBinContent(ibx, 1); } + map >::iterator iterMapvsBx; for (iterMapvsBx = layerfound_perBx.begin(); iterMapvsBx != layerfound_perBx.end(); ++iterMapvsBx) - hfound->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]); + layerfound_vsBX[ilayer]->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]); for (iterMapvsBx = layertotal_perBx.begin(); iterMapvsBx != layertotal_perBx.end(); ++iterMapvsBx) if (iterMapvsBx->second[ilayer] > 0) - htotal->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]); + layertotal_vsBX[ilayer]->SetBinContent(iterMapvsBx->first, iterMapvsBx->second[ilayer]); - hfound->Sumw2(); - htotal->Sumw2(); + layerfound_vsBX[ilayer]->Sumw2(); + layertotal_vsBX[ilayer]->Sumw2(); TGraphAsymmErrors* geff = fs->make(3564); geff->SetName(Form("effVsBx_layer%i", ilayer)); geff->SetTitle(fmt::format("Hit Efficiency vs bx - {}", ::layerName(ilayer, _showRings, nTEClayers)).c_str()); - geff->BayesDivide(hfound, htotal); + geff->BayesDivide(layerfound_vsBX[ilayer], layertotal_vsBX[ilayer]); //Average over trains TGraphAsymmErrors* geff_avg = fs->make(); @@ -1432,8 +1438,8 @@ void SiStripHitEffFromCalibTree::makeSummaryVsBx() { firstbx = ibx; } sum_bx += ibx; - found += hfound->GetBinContent(ibx); - total += htotal->GetBinContent(ibx); + found += layerfound_vsBX[ilayer]->GetBinContent(ibx); + total += layertotal_vsBX[ilayer]->GetBinContent(ibx); nbx++; previous_bx = ibx;