Skip to content

Commit

Permalink
fix record name + missing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
tsusa authored and mmusich committed Feb 9, 2023
1 parent 50feacb commit 8e00de0
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ SiPixelLorentzAnglePCLHarvesterMCS::SiPixelLorentzAnglePCLHarvesterMCS(const edm
theFitRange_.first = fitRange_[0];
theFitRange_.second = fitRange_[1];
} else {
throw cms::Exception("SiPixelLorentzAnglePCLHarvesterMCS") << "Too many fit range parameters specified";
throw cms::Exception("SiPixelLorentzAnglePCLHarvesterMCS") << "Wrong number of fit range parameters specified";
}

if (fitParametersInitValues_.size() != 5) {
Expand Down Expand Up @@ -335,37 +335,43 @@ void SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob(DQMStore::IBooker& iBooker, D
nBins,
-0.5,
nBins - 0.5);
char binNameAlpha[256];
char binNameBeta[256];

std::string binNameAlpha;
std::string binNameBeta;

const auto& prefix_ = fmt::sprintf("%s/FPix", dqmDir_);
int histsCounter = 0;
int nHistoExpected = 0;
for (int r = 0; r < hists_.nRings_; ++r) {
for (int p = 0; p < hists_.nPanels_; ++p) {
for (int s = 0; s < hists_.nSides_; ++s) {
int idx = getIndex(false, r, p, s);
int idxBeta = getIndex(true, r, p, s);
nHistoExpected++;
hname = fmt::format("{}/R{}_P{}_z{}_alphaMean", dqmDir_, r + 1, p + 1, s + 1);
if ((hists_.h_fpixMean_[idx] = iGetter.get(hname)) == nullptr) {
edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob")
<< "Failed to retrieve " << hname << " histogram";
} else
histsCounter++;

nHistoExpected++;
hname = fmt::format("{}/R{}_P{}_z{}_betaMean", dqmDir_, r + 1, p + 1, s + 1);
if ((hists_.h_fpixMean_[idxBeta] = iGetter.get(hname)) == nullptr) {
edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob")
<< "Failed to retrieve " << hname << " histogram";
} else
histsCounter++;

nHistoExpected++;
hname = fmt::format("{}/R{}_P{}_z{}_alpha", prefix_, r + 1, p + 1, s + 1);
if ((hists_.h_fpixAngleSize_[idx] = iGetter.get(hname)) == nullptr) {
edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob")
<< "Failed to retrieve " << hname << " histogram";
} else
histsCounter++;

nHistoExpected++;
hname = fmt::format("{}/R{}_P{}_z{}_beta", prefix_, r + 1, p + 1, s + 1);
if ((hists_.h_fpixAngleSize_[idxBeta] = iGetter.get(hname)) == nullptr) {
edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob")
Expand All @@ -374,6 +380,7 @@ void SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob(DQMStore::IBooker& iBooker, D
histsCounter++;

for (int m = 0; m < 3; ++m) {
nHistoExpected++;
hname = fmt::format("{}/R{}_P{}_z{}_B{}", prefix_, r + 1, p + 1, s + 1, m);
if ((hists_.h_fpixMagField_[m][idx] = iGetter.get(hname)) == nullptr) {
edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob")
Expand All @@ -386,8 +393,8 @@ void SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob(DQMStore::IBooker& iBooker, D
int binAlpha = idx + 1;
int binBeta = idxBeta + 1;
char sign = s == 0 ? '-' : '+';
sprintf(binNameAlpha, "#alpha: R%d_P%d_z%c", r + 1, p + 1, sign);
sprintf(binNameBeta, "#beta:R%d_P%d_z%c", r + 1, p + 1, sign);
binNameAlpha = fmt::sprintf("#alpha: R%d_P%d_z%c", r + 1, p + 1, sign);
binNameBeta = fmt::sprintf("#beta:R%d_P%d_z%c", r + 1, p + 1, sign);
hists_.h_fpixMeanHistoFitStatus_->setBinLabel(binAlpha, binNameAlpha);
hists_.h_fpixMeanHistoFitStatus_->setBinLabel(binBeta, binNameBeta);
hists_.h_fpixMeanHistoFitStatus_->setBinContent(binAlpha, SiPixelLAHarvestMCS::kFitNotPerformed);
Expand All @@ -401,8 +408,7 @@ void SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob(DQMStore::IBooker& iBooker, D
}
}

// 56 -> 16 mean + 16 angleSize + 24 mag.filed histos
if (histsCounter != 56) {
if (histsCounter != nHistoExpected) {
edm::LogError("SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob")
<< "Failed to retrieve all histograms, expected 56 got " << histsCounter;
return;
Expand All @@ -422,11 +428,11 @@ void SiPixelLorentzAnglePCLHarvesterMCS::dqmEndJob(DQMStore::IBooker& iBooker, D
nBinsMuH,
-0.5,
nBinsMuH - 0.5);
char binName[256];
std::string binName;
for (int r = 0; r < hists_.nRings_; ++r) {
for (int p = 0; p < hists_.nPanels_; ++p) {
int idx = r * hists_.nPanels_ + p + 1;
sprintf(binName, "R%d_P%d", r + 1, p + 1);
binName = fmt::sprintf("R%d_P%d", r + 1, p + 1);
hists_.h_fpixFitStatusMuH_->setBinLabel(idx, binName);
hists_.h_fpixFitStatusMuH_->setBinContent(idx, SiPixelLAHarvestMCS::kFitNotPerformed);
hists_.h_fpixMuH_->setBinLabel(idx, binName);
Expand Down Expand Up @@ -625,7 +631,7 @@ void SiPixelLorentzAnglePCLHarvesterMCS::fillDescriptions(edm::ConfigurationDesc
desc.add<std::vector<double>>("fitParametersMuHFit", {0.08, 0.08, 0.08, 0.08})
->setComment("initial values for fit parameters (muH fit)");
desc.add<int>("minHitsCut", 1000)->setComment("cut on minimum number of on-track hits to accept measurement");
desc.add<std::string>("record", "SiPixelLorentzAngleRcd")->setComment("target DB record");
desc.add<std::string>("record", "SiPixelLorentzAngleRcdMCS")->setComment("target DB record");
descriptions.addWithDefaultLabel(desc);
}

Expand Down
115 changes: 54 additions & 61 deletions CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS
if (analysisType_ != eMinimumClusterSize)
continue;

LocalVector Bfield = theGeomDet->surface().toLocal(magField->inTesla(theGeomDet->surface().position()));
int theMagField = magField->nominalValue();
if (theMagField < 37 || theMagField > 39)
continue;
Expand Down Expand Up @@ -701,12 +700,14 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS
int idx = iHists.nSides_ * iHists.nPanels_ * ringIdx + iHists.nSides_ * panelIdx + sideIdx;
int idxBeta = iHists.betaStartIdx_ + idx;

double cotanAlpha = TMath::Tan(TMath::Pi() / 2. - trackhitF_.alpha);
double cotanBeta = TMath::Tan(TMath::Pi() / 2. - trackhitF_.beta);
double cotanAlpha = std::tan(M_PI / 2. - trackhitF_.alpha);
double cotanBeta = std::tan(M_PI / 2. - trackhitF_.beta);

LocalVector Bfield = theGeomDet->surface().toLocal(magField->inTesla(theGeomDet->surface().position()));
iHists.h_fpixMagField_[0][idx]->Fill(Bfield.x());
iHists.h_fpixMagField_[1][idx]->Fill(Bfield.y());
iHists.h_fpixMagField_[2][idx]->Fill(Bfield.z());

if (clustF_.size_y >= 2) {
iHists.h_fpixAngleSize_[idx]->Fill(cotanAlpha, clustF_.size_x);
}
Expand Down Expand Up @@ -772,8 +773,8 @@ void SiPixelLorentzAnglePCLWorker::dqmBeginRun(edm::Run const& run, edm::EventSe
void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
edm::Run const& run,
edm::EventSetup const& iSetup) {
char name[128];
char title[256];
std::string name;
std::string title;
if (analysisType_ == eGrazingAngle) {
// book the by partition monitoring
const auto maxSect = iHists.nlay * iHists.nModules_[iHists.nlay - 1] + (int)iHists.BPixnewDetIds_.size();
Expand All @@ -798,19 +799,16 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,

iHists.h_bySectOccupancy_->setBinLabel(i_index, binName);

sprintf(name, "h_mean_layer%i_module%i", i_layer, i_module);
sprintf(title,
"average drift vs depth layer%i module%i; production depth [#mum]; #LTdrift#GT [#mum]",
i_layer,
i_module);
name = fmt::sprintf("h_mean_layer%i_module%i", i_layer, i_module);
title = fmt::sprintf(
"average drift vs depth layer%i module%i; production depth [#mum]; #LTdrift#GT [#mum]", i_layer, i_module);
iHists.h_mean_[i_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_);
}
}
for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) {
sprintf(name, "h_BPixnew_mean_%s", iHists.BPixnewmodulename_[i].c_str());
sprintf(title,
"average drift vs depth %s; production depth [#mum]; #LTdrift#GT [#mum]",
iHists.BPixnewmodulename_[i].c_str());
name = fmt::sprintf("h_BPixnew_mean_%s", iHists.BPixnewmodulename_[i].c_str());
title = fmt::sprintf("average drift vs depth %s; production depth [#mum]; #LTdrift#GT [#mum]",
iHists.BPixnewmodulename_[i].c_str());
int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i;
iHists.h_mean_[new_index] = iBooker.book1D(name, title, hist_depth_, min_depth_, max_depth_);

Expand All @@ -826,30 +824,27 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
for (int i_module = 1; i_module <= iHists.nModules_[i_layer - 1]; i_module++) {
unsigned int i_index = i_module + (i_layer - 1) * iHists.nModules_[i_layer - 1];

sprintf(name, "h_drift_depth_adc_layer%i_module%i", i_layer, i_module);
sprintf(
title, "depth vs drift (ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
name = fmt::sprintf("h_drift_depth_adc_layer%i_module%i", i_layer, i_module);
title = fmt::sprintf(
"depth vs drift (ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
iHists.h_drift_depth_adc_[i_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_drift_depth_adc2_layer%i_module%i", i_layer, i_module);
sprintf(title,
"depth vs drift (ADC^{2}) layer%i module%i; drift [#mum]; production depth [#mum]",
i_layer,
i_module);
name = fmt::sprintf("h_drift_depth_adc2_layer%i_module%i", i_layer, i_module);
title = fmt::sprintf(
"depth vs drift (ADC^{2}) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
iHists.h_drift_depth_adc2_[i_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_drift_depth_noadc_layer%i_module%i", i_layer, i_module);
sprintf(title,
"depth vs drift (no ADC) layer%i module%i; drift [#mum]; production depth [#mum]",
i_layer,
i_module);
name = fmt::sprintf("h_drift_depth_noadc_layer%i_module%i", i_layer, i_module);
title = fmt::sprintf(
"depth vs drift (no ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
iHists.h_drift_depth_noadc_[i_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_drift_depth_layer%i_module%i", i_layer, i_module);
sprintf(title, "depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
name = fmt::sprintf("h_drift_depth_layer%i_module%i", i_layer, i_module);
title =
fmt::sprintf("depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
iHists.h_drift_depth_[i_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
}
Expand All @@ -860,55 +855,53 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
for (int i = 0; i < (int)iHists.BPixnewDetIds_.size(); i++) {
int new_index = iHists.nModules_[iHists.nlay - 1] + (iHists.nlay - 1) * iHists.nModules_[iHists.nlay - 1] + 1 + i;

sprintf(name, "h_BPixnew_drift_depth_adc_%s", iHists.BPixnewmodulename_[i].c_str());
sprintf(title,
"depth vs drift (ADC) %s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
name = fmt::sprintf("h_BPixnew_drift_depth_adc_%s", iHists.BPixnewmodulename_[i].c_str());
title = fmt::sprintf("depth vs drift (ADC) %s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
iHists.h_drift_depth_adc_[new_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_BPixnew_drift_depth_adc2_%s", iHists.BPixnewmodulename_[i].c_str());
sprintf(title,
"depth vs drift (ADC^{2}) %s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
name = fmt::sprintf("h_BPixnew_drift_depth_adc2_%s", iHists.BPixnewmodulename_[i].c_str());
title = fmt::sprintf("depth vs drift (ADC^{2}) %s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
iHists.h_drift_depth_adc2_[new_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_BPixnew_drift_depth_noadc_%s", iHists.BPixnewmodulename_[i].c_str());
sprintf(title,
"depth vs drift (no ADC)%s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
name = fmt::sprintf("h_BPixnew_drift_depth_noadc_%s", iHists.BPixnewmodulename_[i].c_str());
title = fmt::sprintf("depth vs drift (no ADC)%s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
iHists.h_drift_depth_noadc_[new_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);

sprintf(name, "h_BPixnew_drift_depth_%s", iHists.BPixnewmodulename_[i].c_str());
sprintf(title, "depth vs drift %s; drift [#mum]; production depth [#mum]", iHists.BPixnewmodulename_[i].c_str());
name = fmt::sprintf("h_BPixnew_drift_depth_%s", iHists.BPixnewmodulename_[i].c_str());
title = fmt::sprintf("depth vs drift %s; drift [#mum]; production depth [#mum]",
iHists.BPixnewmodulename_[i].c_str());
iHists.h_drift_depth_[new_index] =
iBooker.book2D(name, title, hist_drift_, min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
}
} // end if GrazinAngleAnalysis
else {
iBooker.setCurrentFolder(folder_);
char baseName[64];
char baseTitle[128];
std::string baseName;
std::string baseTitle;

for (int r = 0; r < iHists.nRings_; ++r) {
for (int p = 0; p < iHists.nPanels_; ++p) {
for (int s = 0; s < iHists.nSides_; ++s) {
sprintf(baseName, "R%d_P%d_z%d", r + 1, p + 1, s + 1);
baseName = fmt::sprintf("R%d_P%d_z%d", r + 1, p + 1, s + 1);
if (s == 0)
sprintf(baseTitle, "Ring%d_Panel%d_z-", r + 1, p + 1);
baseTitle = fmt::sprintf("Ring%d_Panel%d_z-", r + 1, p + 1);
else
sprintf(baseTitle, "Ring%d_Panel%d_z+", r + 1, p + 1);
baseTitle = fmt::sprintf("Ring%d_Panel%d_z+", r + 1, p + 1);

int idx = iHists.nSides_ * iHists.nPanels_ * r + iHists.nSides_ * p + s;
int idxBeta = iHists.betaStartIdx_ + idx;

sprintf(name, "%s_alphaMean", baseName);
sprintf(title, "%s_alphaMean;cot(#alpha); Average cluster size x (pixel)", baseTitle);
name = fmt::sprintf("%s_alphaMean", baseName);
title = fmt::sprintf("%s_alphaMean;cot(#alpha); Average cluster size x (pixel)", baseTitle);
iHists.h_fpixMean_[idx] = iBooker.book1D(name, title, 60, -3., 3.);
sprintf(name, "%s_betaMean", baseName);
sprintf(title, "%s_betaMean;cot(#beta); Average cluster size y (pixel)", baseTitle);
name = fmt::sprintf("%s_betaMean", baseName);
title = fmt::sprintf("%s_betaMean;cot(#beta); Average cluster size y (pixel)", baseTitle);
iHists.h_fpixMean_[idxBeta] = iBooker.book1D(name, title, 60, -3., 3.);

} // loop over sides
Expand All @@ -918,25 +911,25 @@ void SiPixelLorentzAnglePCLWorker::bookHistograms(DQMStore::IBooker& iBooker,
for (int r = 0; r < iHists.nRings_; ++r) {
for (int p = 0; p < iHists.nPanels_; ++p) {
for (int s = 0; s < iHists.nSides_; ++s) {
sprintf(baseName, "R%d_P%d_z%d", r + 1, p + 1, s + 1);
baseName = fmt::sprintf("R%d_P%d_z%d", r + 1, p + 1, s + 1);
if (s == 0)
sprintf(baseTitle, "Ring%d_Panel%d_z-", r + 1, p + 1);
baseTitle = fmt::sprintf("Ring%d_Panel%d_z-", r + 1, p + 1);
else
sprintf(baseTitle, "Ring%d_Panel%d_z+", r + 1, p + 1);
baseTitle = fmt::sprintf("Ring%d_Panel%d_z+", r + 1, p + 1);

int idx = iHists.nSides_ * iHists.nPanels_ * r + iHists.nSides_ * p + s;
int idxBeta = iHists.betaStartIdx_ + idx;

sprintf(name, "%s_alpha", baseName);
sprintf(title, "%s_alpha;cot(#alpha); Cluster size x (pixel)", baseTitle);
name = fmt::sprintf("%s_alpha", baseName);
title = fmt::sprintf("%s_alpha;cot(#alpha); Cluster size x (pixel)", baseTitle);
iHists.h_fpixAngleSize_[idx] = iBooker.book2D(name, title, 60, -3., 3., 10, 0.5, 10.5);
sprintf(name, "%s_beta", baseName);
sprintf(title, "%s_beta;cot(#beta); Cluster size y (pixel) ", baseTitle);
name = fmt::sprintf("%s_beta", baseName);
title = fmt::sprintf("%s_beta;cot(#beta); Cluster size y (pixel) ", baseTitle);
iHists.h_fpixAngleSize_[idxBeta] = iBooker.book2D(name, title, 60, -3., 3., 10, 0.5, 10.5);
for (int m = 0; m < 3; ++m) {
sprintf(name, "%s_B%d", baseName, m);
name = fmt::sprintf("%s_B%d", baseName, m);
char bComp = m == 0 ? 'x' : (m == 1 ? 'y' : 'z');
sprintf(title, "%s_magField%d;B_{%c} [T];Entries", baseTitle, m, bComp);
title = fmt::sprintf("%s_magField%d;B_{%c} [T];Entries", baseTitle, m, bComp);
iHists.h_fpixMagField_[m][idx] = iBooker.book1D(name, title, 10000, -5., 5.);
} // mag. field comps
} // loop over sides
Expand Down
Loading

0 comments on commit 8e00de0

Please sign in to comment.