Skip to content

Commit

Permalink
fix segmentation violation in SiStripHitEffFromCalibTree in ASAN_X
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Mar 22, 2023
1 parent ee96791 commit 76c3ff3
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class SiStripHitEffFromCalibTree : public ConditionDBWriter<SiStripBadStrip> {

// to be used everywhere
static constexpr int SiStripLayers = 22;
static constexpr double nBxInAnOrbit = 3565;

edm::Service<TFileService> fs;
SiStripDetInfo _detInfo;
Expand Down Expand Up @@ -179,6 +180,8 @@ class SiStripHitEffFromCalibTree : public ConditionDBWriter<SiStripBadStrip> {
vector<TH1F*> layertotal_vsPU;
vector<TH1F*> layerfound_vsCM;
vector<TH1F*> layertotal_vsCM;
vector<TH1F*> layerfound_vsBX;
vector<TH1F*> layertotal_vsBX;
int goodlayertotal[35];
int goodlayerfound[35];
int alllayertotal[35];
Expand Down Expand Up @@ -284,6 +287,11 @@ void SiStripHitEffFromCalibTree::algoAnalyze(const edm::Event& e, const edm::Eve
layertotal_vsPU.push_back(
fs->make<TH1F>(Form("layertotal_vsPU_layer_%i", (int)(ilayer)), lyrName.c_str(), 45, 0, 90));

layerfound_vsBX.push_back(fs->make<TH1F>(
Form("foundVsBx_layer%i", (int)ilayer), Form("layer %i", (int)ilayer), nBxInAnOrbit, 0, nBxInAnOrbit));
layertotal_vsBX.push_back(fs->make<TH1F>(
Form("totalVsBx_layer%i", (int)ilayer), Form("layer %i", (int)ilayer), nBxInAnOrbit, 0, nBxInAnOrbit));

if (_useCM) {
layerfound_vsCM.push_back(
fs->make<TH1F>(Form("layerfound_vsCM_layer_%i", (int)(ilayer)), lyrName.c_str(), 20, 0, 400));
Expand Down Expand Up @@ -1376,27 +1384,25 @@ void SiStripHitEffFromCalibTree::makeSummaryVsBx() {
nLayers = 20;

for (unsigned int ilayer = 1; ilayer < nLayers; ilayer++) {
TH1F* hfound = fs->make<TH1F>(Form("foundVsBx_layer%i", ilayer), Form("layer %i", ilayer), 3565, 0, 3565);
TH1F* htotal = fs->make<TH1F>(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<unsigned int, vector<int> >::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<TGraphAsymmErrors>(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<TGraphAsymmErrors>();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 76c3ff3

Please sign in to comment.