From 27aef636cf44d3c9a4143171e6dae25751e89f51 Mon Sep 17 00:00:00 2001 From: ChunzhengLab Date: Thu, 19 Jun 2025 22:33:42 +0200 Subject: [PATCH 1/2] should use the total eff but not only seed --- .../ITS3/macros/test/CheckChipResponseFile.C | 17 +++-- .../ITS3/simulation/src/ChipSimResponse.cxx | 73 ++++++++++--------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C b/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C index 5cacf2eab9900..4ce4cd28a361e 100644 --- a/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C +++ b/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C @@ -85,7 +85,7 @@ std::vector getCollectionSeediciencies(o2::its3::ChipSimResponse* resp, bool flipRow = false, flipCol = false; for (auto depth : depths) { auto rspmat = resp->getResponse(0.0, 0.0, - um2cm(depth) + resp->getDepthMin() + 1.e-9, + um2cm(depth) + 1.e-9, flipRow, flipCol); seed.push_back(rspmat ? rspmat->getValue(2, 2) : 0.f); } @@ -99,7 +99,7 @@ std::vector getShareValues(o2::its3::ChipSimResponse* resp, bool flipRow = false, flipCol = false; for (auto depth : depths) { auto rspmat = resp->getResponse(0.0, 0.0, - um2cm(depth) + resp->getDepthMin() + 1.e-9, + um2cm(depth) + 1.e-9, flipRow, flipCol); float s = 0; int npix = resp->getNPix(); @@ -121,7 +121,7 @@ std::vector getEffValues(o2::its3::ChipSimResponse* resp, bool flipRow = false, flipCol = false; for (auto depth : depths) { auto rspmat = resp->getResponse(0.0, 0.0, - um2cm(depth) + resp->getDepthMin() + 1.e-9, + um2cm(depth) + 1.e-9, flipRow, flipCol); float s = 0; int npix = resp->getNPix(); @@ -140,9 +140,12 @@ void CheckChipResponseFile() LoadRespFunc(); LOG(info) << "Response function loaded" << std::endl; - std::vector vecDepth(50); - for (int i = 0; i < 50; ++i) - vecDepth[i] = i; + std::vector vecDepth; + int numPoints = 100; + for (int i = 0; i < numPoints; ++i) { + float value = -50 + i * (100.0f / (numPoints - 1)); + vecDepth.push_back(value); + } int colors[] = {kOrange + 7, kRed + 1, kAzure + 4}; struct RespInfo { @@ -156,7 +159,7 @@ void CheckChipResponseFile() {mAlpSimResp1, "ALPIDE Vbb=-3V", colors[2]}}; TCanvas* c1 = new TCanvas("c1", "c1", 800, 600); - TH1* frame = c1->DrawFrame(-1, -0.049, 50, 1.049); + TH1* frame = c1->DrawFrame(-50, -0.049, 50, 1.049); frame->SetTitle(";Depth(um);Charge Collection Seed / Share / Eff"); TLegend* leg = new TLegend(0.15, 0.5, 0.4, 0.85); leg->SetFillStyle(0); diff --git a/Detectors/Upgrades/ITS3/simulation/src/ChipSimResponse.cxx b/Detectors/Upgrades/ITS3/simulation/src/ChipSimResponse.cxx index 1c4f08438d4f2..72b291fb0d653 100644 --- a/Detectors/Upgrades/ITS3/simulation/src/ChipSimResponse.cxx +++ b/Detectors/Upgrades/ITS3/simulation/src/ChipSimResponse.cxx @@ -25,61 +25,66 @@ void ChipSimResponse::initData(int tableNumber, std::string dataPath, const bool void ChipSimResponse::computeCentreFromData() { - std::vector zVec, qVec; const int npix = o2::itsmft::AlpideRespSimMat::getNPix(); + std::vector zVec, effVec; + zVec.reserve(mNBinDpt); + effVec.reserve(mNBinDpt); for (int iz = 0; iz < mNBinDpt; ++iz) { - size_t bin = iz + mNBinDpt * (0 + mNBinRow * 0); - const auto& mat = mData[bin]; - float val = mat.getValue(npix / 2, npix / 2); - float gz = mDptMin + iz / mStepInvDpt; - zVec.push_back(gz); - qVec.push_back(val); + int rev = mNBinDpt - 1 - iz; + float z = mDptMin + iz / mStepInvDpt; + float sum = 0.f; + const auto& mat = mData[rev]; + for (int ix = 0; ix < npix; ++ix) { + for (int iy = 0; iy < npix; ++iy) { + sum += mat.getValue(ix, iy); + } + } + zVec.push_back(z); + effVec.push_back(sum); } - std::vector> zqPairs; - for (size_t i = 0; i < zVec.size(); ++i) { - zqPairs.emplace_back(zVec[i], qVec[i]); - } - std::sort(zqPairs.begin(), zqPairs.end()); - zVec.clear(); - qVec.clear(); - for (auto& p : zqPairs) { - zVec.push_back(p.first); - qVec.push_back(p.second); - } + struct Bin { + float z0, z1, q0, q1, dq; + }; + std::vector bins; + bins.reserve(zVec.size() - 1); - struct BinInfo { float z0, z1, q0, q1, dq; }; - std::vector bins; float totQ = 0.f; for (size_t i = 0; i + 1 < zVec.size(); ++i) { float z0 = zVec[i], z1 = zVec[i + 1]; - float q0 = qVec[i], q1 = qVec[i + 1]; - float dz = z1 - z0; - float dq = 0.5f * (q0 + q1) * dz; + float q0 = effVec[i], q1 = effVec[i + 1]; + float dq = 0.5f * (q0 + q1) * (z1 - z0); bins.push_back({z0, z1, q0, q1, dq}); totQ += dq; } - if (totQ <= 0.f) { mRespCentreDep = 0.f; return; } + + if (totQ <= 0.f) { + mRespCentreDep = mDptMin; + return; + } float halfQ = 0.5f * totQ; float cumQ = 0.f; - for (const auto& b : bins) { - if (cumQ + b.dq < halfQ) { cumQ += b.dq; continue; } - float qSlope = (b.q1 - b.q0) / (b.z1 - b.z0); + for (auto& b : bins) { + if (cumQ + b.dq < halfQ) { + cumQ += b.dq; + continue; + } float dz = b.z1 - b.z0; - float A = qSlope * 0.5f; - float B = b.q0; - float C = cumQ - halfQ; - float disc = B * B - 4.f * A * C; + float slope = (b.q1 - b.q0) / dz; + float disc = b.q0 * b.q0 - 2.f * slope * (cumQ - halfQ); + float x; - if (disc >= 0.f && std::abs(A) > 1.e-12f) - x = (-B + std::sqrt(disc)) / (2.f * A); - else + if (disc >= 0.f && std::abs(slope) > 1e-6f) { + x = (-b.q0 + std::sqrt(disc)) / slope; + } else { x = (halfQ - cumQ) / b.q0; + } x = std::clamp(x, 0.f, dz); mRespCentreDep = b.z0 + x; return; } + mRespCentreDep = mDptMax; } From 17e14c1c035ec9e84ba46bd9b1c90006b81a6104 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 23 Jun 2025 11:09:55 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- .../ITS3/macros/test/CheckChipResponseFile.C | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C b/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C index 4ce4cd28a361e..32d5bad87ce21 100644 --- a/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C +++ b/Detectors/Upgrades/ITS3/macros/test/CheckChipResponseFile.C @@ -57,25 +57,25 @@ void LoadRespFunc() std::string AptsFile = "$(O2_ROOT)/share/Detectors/Upgrades/ITS3/data/ITS3ChipResponseData/APTSResponseData.root"; std::string AlpideFile = "$(O2_ROOT)/share/Detectors/ITSMFT/data/AlpideResponseData/AlpideResponseData.root"; - std::cout<<"=====================\n"; + std::cout << "=====================\n"; LOGP(info, "ALPIDE Vbb=0V response"); mAlpSimResp0 = loadResponse(AlpideFile, "response0"); // Vbb=0V mAlpSimResp0->computeCentreFromData(); mAlpSimResp0->print(); LOGP(info, "Response Centre {}", mAlpSimResp0->getRespCentreDep()); - std::cout<<"=====================\n"; + std::cout << "=====================\n"; LOGP(info, "ALPIDE Vbb=-3V response"); mAlpSimResp1 = loadResponse(AlpideFile, "response1"); // Vbb=-3V mAlpSimResp1->computeCentreFromData(); mAlpSimResp1->print(); LOGP(info, "Response Centre {}", mAlpSimResp1->getRespCentreDep()); - std::cout<<"=====================\n"; + std::cout << "=====================\n"; LOGP(info, "APTS response"); mAptSimResp1 = loadResponse(AptsFile, "response1"); // APTS mAptSimResp1->computeCentreFromData(); mAptSimResp1->print(); LOGP(info, "Response Centre {}", mAptSimResp1->getRespCentreDep()); - std::cout<<"=====================\n"; + std::cout << "=====================\n"; } std::vector getCollectionSeediciencies(o2::its3::ChipSimResponse* resp, @@ -143,8 +143,8 @@ void CheckChipResponseFile() std::vector vecDepth; int numPoints = 100; for (int i = 0; i < numPoints; ++i) { - float value = -50 + i * (100.0f / (numPoints - 1)); - vecDepth.push_back(value); + float value = -50 + i * (100.0f / (numPoints - 1)); + vecDepth.push_back(value); } int colors[] = {kOrange + 7, kRed + 1, kAzure + 4};