From dc0f55927c5f8cc878e03c1cae6b8cecf87847b4 Mon Sep 17 00:00:00 2001 From: Wei Wei Date: Wed, 17 Nov 2021 08:02:51 +0100 Subject: [PATCH 1/2] Modify calculations for the Lorentz angle --- .../src/SiPixelLorentzAnglePCLHarvester.cc | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc index a4ee5adcf7cfc..86a1250dc7d64 100644 --- a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc +++ b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc @@ -214,7 +214,8 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS << "p4" << "\t" << "e4" << "\t" << "p5" << "\t" << "e5" << "\t" << "chi2" << "\t" << "prob" << "\t" - << "newDetId" << std::endl; + << "newDetId" << "\t" << "tan(LA)" << "\t" + << "Error(LA)" << std::endl; // clang-format on std::unique_ptr LorentzAngle = std::make_unique(); @@ -228,6 +229,7 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS f1->SetParName(5, "quintic term"); double p1_simul_newmodule = 0.294044; + double half_width = 0.0285 / 2 * 10000; // pixel width in units of micro meter for (int j = 0; j < (int)hists.BPixnewDetIds_.size(); j++) { int new_index = j + 1 + hists.nModules_[hists.nlay - 1] + (hists.nlay - 1) * hists.nModules_[hists.nlay - 1]; @@ -268,12 +270,25 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS double chi2 = f1->GetChisquare(); double prob = f1->GetProb(); + double f1_halfwidth = p0 + p1 * half_width + p2 * pow(half_width, 2) + p3 * pow(half_width, 3) + + p4 * pow(half_width, 4) + p5 * pow(half_width, 5); + + double f1_zerowidth = p0; + + double tan_LA = + (f1_halfwidth - f1_zerowidth) / half_width; // tan_LA = (f1(x = half_width) - f1(x = 0)) / (half_width - 0) + double errsq_LA = (pow(e1, 2) + pow((half_width * e2), 2) + pow((half_width * half_width * e3), 2) + + pow((half_width * half_width * half_width * e4), 2) + + pow((half_width * half_width * half_width * half_width * e5), 2)) * + pow(tan_LA, 2); // Propagation of uncertainty + double error_LA = sqrt(errsq_LA); + edm::LogPrint("LorentzAngle") << std::setprecision(4) << hists.BPixnewModule_[j] << "\t" << hists.BPixnewLayer_[j] << "\t" << p0 << "\t" << e0 << "\t" << p1 << std::setprecision(3) << "\t" << e1 << "\t" << e1 / p1 * 100. << "\t" << (p1 - p1_simul_newmodule) / e1 << "\t" << p2 << "\t" << e2 << "\t" << p3 << "\t" << e3 << "\t" << p4 << "\t" << e4 << "\t" << p5 << "\t" << e5 << "\t" << chi2 << "\t" << prob << "\t" << hists.BPixnewDetIds_[j] - << std::endl; + << "\t" << tan_LA << "\t" << error_LA << std::endl; } double p1_simul[hists.nlay][hists.nModules_[hists.nlay - 1]]; @@ -335,12 +350,26 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS double chi2 = f1->GetChisquare(); double prob = f1->GetProb(); + double f1_halfwidth = p0 + p1 * half_width + p2 * pow(half_width, 2) + p3 * pow(half_width, 3) + + p4 * pow(half_width, 4) + p5 * pow(half_width, 5); + + double f1_zerowidth = p0; + + double tan_LA = + (f1_halfwidth - f1_zerowidth) / half_width; // tan_LA = (f1(x = half_width) - f1(x = 0)) / (half_width - 0) + double errsq_LA = (pow(e1, 2) + pow((half_width * e2), 2) + pow((half_width * half_width * e3), 2) + + pow((half_width * half_width * half_width * e4), 2) + + pow((half_width * half_width * half_width * half_width * e5), 2)) * + pow(tan_LA, 2); // Propagation of uncertainty + double error_LA = sqrt(errsq_LA); + edm::LogPrint("LorentzAngle") << std::setprecision(4) << i_module << "\t" << i_layer << "\t" << p0 << "\t" << e0 << "\t" << p1 << std::setprecision(3) << "\t" << e1 << "\t" << e1 / p1 * 100. << "\t" << (p1 - p1_simul[i_layer - 1][i_module - 1]) / e1 << "\t" << p2 << "\t" << e2 << "\t" << p3 << "\t" << e3 << "\t" << p4 << "\t" << e4 << "\t" << p5 << "\t" << e5 << "\t" << chi2 << "\t" << prob << "\t" - << "null" << std::endl; + << "null" + << "\t" << tan_LA << "\t" << error_LA << std::endl; const auto& detIdsToFill = hists.detIdsList.at(i_index); @@ -351,7 +380,7 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS // if the fit quality is OK if (prob > fitProbCut_) { for (const auto& id : detIdsToFill) { - bPixLorentzAnglePerTesla_ = p1 / theMagField; + bPixLorentzAnglePerTesla_ = tan_LA / theMagField; if (!LorentzAngle->putLorentzAngle(id, bPixLorentzAnglePerTesla_)) { edm::LogError("SiPixelLorentzAnglePCLHarvester") << "[SiPixelLorentzAnglePCLHarvester::dqmEndRun] detid already exists" << std::endl; From 43fcd1e103460624cca5321e67810c4a25f4b699 Mon Sep 17 00:00:00 2001 From: Wei Wei Date: Fri, 19 Nov 2021 06:15:35 +0100 Subject: [PATCH 2/2] Remove magic numbers --- .../src/SiPixelLorentzAnglePCLHarvester.cc | 10 +++++----- .../src/SiPixelLorentzAnglePCLWorker.cc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc index 86a1250dc7d64..264d518ffc97b 100644 --- a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc +++ b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc @@ -44,6 +44,7 @@ class SiPixelLorentzAnglePCLHarvester : public DQMEDHarvester { const double fitProbCut_; const std::string recordName_; std::unique_ptr f1; + float width_; SiPixelLorentzAngleCalibrationHistograms hists; const SiPixelLorentzAngle* currentLorentzAngle; @@ -106,6 +107,7 @@ void SiPixelLorentzAnglePCLHarvester::beginRun(const edm::Run& iRun, const edm:: for (auto det : geom->detsPXB()) { const PixelGeomDetUnit* pixelDet = dynamic_cast(det); + width_ = pixelDet->surface().bounds().thickness(); const auto& layer = tTopo->pxbLayer(pixelDet->geographicalId()); const auto& module = tTopo->pxbModule(pixelDet->geographicalId()); int i_index = module + (layer - 1) * hists.nModules_[layer - 1]; @@ -229,7 +231,7 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS f1->SetParName(5, "quintic term"); double p1_simul_newmodule = 0.294044; - double half_width = 0.0285 / 2 * 10000; // pixel width in units of micro meter + double half_width = width_ * 10000 / 2; // pixel half thickness in units of micro meter for (int j = 0; j < (int)hists.BPixnewDetIds_.size(); j++) { int new_index = j + 1 + hists.nModules_[hists.nlay - 1] + (hists.nlay - 1) * hists.nModules_[hists.nlay - 1]; @@ -279,8 +281,7 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS (f1_halfwidth - f1_zerowidth) / half_width; // tan_LA = (f1(x = half_width) - f1(x = 0)) / (half_width - 0) double errsq_LA = (pow(e1, 2) + pow((half_width * e2), 2) + pow((half_width * half_width * e3), 2) + pow((half_width * half_width * half_width * e4), 2) + - pow((half_width * half_width * half_width * half_width * e5), 2)) * - pow(tan_LA, 2); // Propagation of uncertainty + pow((half_width * half_width * half_width * half_width * e5), 2)); // Propagation of uncertainty double error_LA = sqrt(errsq_LA); edm::LogPrint("LorentzAngle") << std::setprecision(4) << hists.BPixnewModule_[j] << "\t" << hists.BPixnewLayer_[j] @@ -359,8 +360,7 @@ void SiPixelLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS (f1_halfwidth - f1_zerowidth) / half_width; // tan_LA = (f1(x = half_width) - f1(x = 0)) / (half_width - 0) double errsq_LA = (pow(e1, 2) + pow((half_width * e2), 2) + pow((half_width * half_width * e3), 2) + pow((half_width * half_width * half_width * e4), 2) + - pow((half_width * half_width * half_width * half_width * e5), 2)) * - pow(tan_LA, 2); // Propagation of uncertainty + pow((half_width * half_width * half_width * half_width * e5), 2)); // Propagation of uncertainty double error_LA = sqrt(errsq_LA); edm::LogPrint("LorentzAngle") << std::setprecision(4) << i_module << "\t" << i_layer << "\t" << p0 << "\t" << e0 diff --git a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc index 9e2c352e21333..3b51bbc2db87a 100644 --- a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc +++ b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc @@ -379,7 +379,7 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS const PixelTopology* topol = &(theGeomDet->specificTopology()); float ypitch_ = topol->pitch().second; - float width_ = 0.0285; + float width_ = theGeomDet->surface().bounds().thickness(); if (!topol) continue;