25#include <TStopwatch.h>
58#include <TLegendEntry.h>
90 : mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(
src), mDrawOnly(drawOnly), mPostProcOnly(postProcOnly)
102 bool refitPV(
o2::dataformats::PrimaryVertex& pv,
int vid);
104 bool processITSTrack(const
o2::its::
TrackITS& iTrack, const
o2::dataformats::PrimaryVertex& pv,
o2::checkresid::
Track& resTrack,
o2::track::
PID pid);
106 void fillHistos(const
o2::checkresid::
Track& trc);
107 void postProcessHistos();
110 o2::itsmft::ChipMappingITS mChipMap;
111 o2::globaltracking::RecoContainer* mRecoData =
nullptr;
113 bool mMeanVertexUpdated =
false;
114 float mITSROFrameLengthMUS = 0.
f;
115 o2::dataformats::MeanVertexObject mMeanVtx{};
117 std::vector<int16_t> mITSClusterSizes;
120 std::shared_ptr<DataRequest> mDataRequest;
121 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
122 std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
125 bool mDrawOnly =
false;
126 bool mPostProcOnly =
false;
128 bool mFillHistos =
true;
129 bool mFillTree =
true;
130 std::vector<std::unique_ptr<o2::HistoManager>> mHManV{};
131 std::vector<o2::dataformats::PrimaryVertex> mPVUsed;
139 mDraw = ic.
options().
get<
bool>(
"draw-report");
140 mFillHistos = !ic.
options().
get<
bool>(
"no-hist");
141 mFillTree = !ic.
options().
get<
bool>(
"no-tree");
142 mNThreads = ic.
options().
get<
int>(
"nthreads");
147 std::string nm =
params.outname;
157 if (!mDrawOnly && mFillHistos) {
160 if (!
params.ext_hm_list.empty()) {
164 if (vecNames.size() != vecLegends.size()) {
165 LOGP(warn,
"{} legend names provided for {} external histomanagers, will use file names as legends", vecLegends.size(), vecNames.size());
169 for (
const auto& vn : vecNames) {
170 LOGP(info,
"Loading external HistoManager {}", vn);
171 mHManV.emplace_back() = std::make_unique<o2::HistoManager>(
"", vn,
true);
172 auto hm = mHManV.back().get();
174 LOGP(
error,
"Failed to load histograms from {}", vn);
177 hm->SetName(useLeg ? vecLegends[cntH].c_str() : vn.c_str());
188 LOGP(warn,
"No OpenMP");
193 mDBGOut = std::make_unique<o2::utils::TreeStreamRedirector>(fmt::format(
"{}.root",
params.outname).c_str(),
"recreate");
211 for (
const auto& hm : mHManV) {
222 mRecoData = &recoData;
224 mRecoData = &recoData;
225 updateTimeDependentParams(pc);
234 static bool initOnceDone =
false;
241 if (!grp->isDetContinuousReadOut(DetID::ITS)) {
242 mITSROFrameLengthMUS = alpParams.roFrameLengthTrig / 1.e3;
244 mITSROFrameLengthMUS = alpParams.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS * 1
e-3;
247 geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G, o2::math_utils::TransformType::T2G));
251 if (mMeanVertexUpdated) {
252 mMeanVertexUpdated =
false;
261 LOGP(fatal,
"ITS data is not loaded");
268 mITSClustersArray.
init(nLr);
269 mITSClusterSizes.clear();
270 for (
int lr = 0; lr < nLr; lr++) {
276 mITSClustersArray.
getClusters().reserve(mITSClustersArray.
size() + clusITS.size());
277 mITSClusterSizes.reserve(mITSClusterSizes.size() + clusITS.size());
278 for (
const auto&
clu : clusITS) {
279 const auto pattID =
clu.getPatternID();
282 mITSClusterSizes.emplace_back(patt.
getNPixels());
284 mITSClusterSizes.emplace_back(mITSDict->
getNpixels(pattID));
296 static int TFCount = 0;
297 int nv = vtxRefs.size() - 1;
298 std::vector<std::vector<checkresid::Track>> slots;
300 slots.resize(mNThreads);
301 int nvGood = 0, nvUse = 0, nvRefFail = 0;
302 long pvFitDuration{};
303 for (
int iv = 0; iv < nv; iv++) {
304 const auto& vtref = vtxRefs[iv];
305 auto pve = pvvec[iv];
306 if (pve.getNContributors() <
params.minPVContributors) {
311 LOGP(
debug,
"Refitting PV#{} of {} tracks", iv, pve.getNContributors());
312 auto tStartPVF = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
313 bool res = refitPV(pve, iv);
314 pvFitDuration += std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count() - tStartPVF;
321 mPVUsed.push_back(pve);
322 const auto& itsContRefs = vtref.getITSGloContributors();
323 int idMinITSGlo = 0, idMaxITSGlo = 0;
324 if (
params.useITSGloContributors) {
325 if (itsContRefs.getFirstEntry() < vtref.getEntries() && itsContRefs.getEntries() == 0) {
326 LOGP(fatal,
"Usage of stored ITS global contributors is requested but they are missing");
328 idMinITSGlo = itsContRefs.getFirstEntry();
329 idMaxITSGlo = idMinITSGlo + itsContRefs.getEntries();
336 int idMin = vtref.getFirstEntryOfSource(is), idMax = idMin + vtref.getEntriesOfSource(is);
338 if (!dm[DetID::ITS]) {
342#pragma omp parallel for schedule(dynamic) num_threads(mNThreads)
344 for (
int i = idMin;
i < idMax;
i++) {
345 auto vid = trackIndex[
i];
346 bool pvCont = vid.isPVContributor();
347 if (!pvCont && (
params.pvcontribOnly ||
params.useITSGloContributors)) {
352 if (
params.useITSGloContributors) {
353 int id = idMinITSGlo + cntPVCont;
354 if (
id >= idMaxITSGlo) {
355 LOGP(fatal,
"Calculated GlobalContributor ITS track index {} exceeds number of stored indices {}",
id, itsContRefs.getEntries());
357 pidITS = trackIndex[
id].getSource();
366 const auto& itsTrack = mRecoData->
getITSTrack(gidITS);
367 if (itsTrack.getNClusters() <
params.minITSCl) {
371 if (!
params.useITSGloContributors) {
372 pidITS = trc.getPID();
374 auto pt = trc.getPt();
375 if (pt < params.minPt || pt >
params.maxPt) {
378 if (std::abs(trc.getTgl()) >
params.maxTgl) {
382 auto& accum = slots[omp_get_thread_num()];
384 auto& accum = slots[0];
386 auto& resTrack = accum.emplace_back();
388 if (!processITSTrack(itsTrack, pve, resTrack, pidITS)) {
396 for (
const auto& accum : slots) {
397 for (
const auto& tr : accum) {
399 (*mDBGOut) <<
"res" <<
"tr=" << tr <<
"\n";
407 (*mDBGOut) <<
"pvUsed" <<
"pv=" << mPVUsed <<
"\n";
410 for (
const auto& pv : mPVUsed) {
411 mHMan->
getHisto(20000 + 0)->Fill(pv.getX());
412 mHMan->
getHisto(20000 + 1)->Fill(pv.getY());
413 mHMan->
getHisto(20000 + 2)->Fill(pv.getZ());
414 mHMan->
getHisto(20000 + 3)->Fill(pv.getNContributors());
417 LOGP(info,
"processed {} PVs out of {} good vertices (out of {} in total), PV refits took {} mus, {} refits failed", nvUse, nvGood, nv, pvFitDuration, nvRefFail);
424 auto trFitInw = iTrack.getParamOut();
425 auto trFitOut = iTrack.getParamIn();
426 trFitInw.setPID(pid);
427 trFitOut.setPID(pid);
431 float bz = prop->getNominalBz();
432 std::array<const o2::BaseCluster<float>*, 8> clArr{};
433 std::array<int16_t, 8> clSizeArr{};
435 std::array<o2::track::TrackParCov, 8> extrapOut, extrapInw;
439 return refLin ? tr.rotate(
alpha, *refLin, bz) : tr.rotate(
alpha);
444 if (!rotateTrack(tr,
i == 0 ? pvAlpha : geom->getSensorRefAlpha(clArr[
i]->
getSensorID()), refLin) ||
445 !prop->propagateTo(tr, refLin, clArr[
i]->
getX(),
true)) {
449 if (!tr.update(*clArr[
i])) {
453 extrapDest[
i].invalidate();
459 auto inv2d = [](
float s00,
float s11,
float s01) -> std::array<float, 3> {
460 auto det = s00 * s11 - s01 * s01;
462 LOGP(
error,
"Singular det {}, input: {} {} {}", det, s00, s11, s01);
463 return {0.f, 0.f, 0.f};
466 return {s11 * det, s00 * det, -s01 * det};
470 if (!prop->propagateToDCA(pv, trFitOut, bz)) {
471 LOGP(
debug,
"Failed to propagateToDCA, {}", trFitOut.asString());
475 if (
params.addPVAsCluster) {
476 float cosAlp, sinAlp;
477 pvAlpha = trFitOut.getAlpha();
478 o2::math_utils::sincos(trFitOut.getAlpha(), sinAlp, cosAlp);
479 bcPV.
setXYZ(pv.getX() * cosAlp + pv.getY() * sinAlp, -pv.getX() * sinAlp + pv.getY() * cosAlp, pv.getZ());
480 bcPV.
setSigmaY2(0.5 * (pv.getSigmaX2() + pv.getSigmaY2()));
486 int nCl = iTrack.getNClusters();
487 for (
int i = 0;
i <
nCl;
i++) {
488 const auto& curClu = mITSClustersArray[itsClRefs[iTrack.
getClusterEntry(
i)]];
490 int llr = geom->getLayer(curClu.getSensorID());
491 if (clArr[1 + llr]) {
492 LOGP(
error,
"Cluster at lr {} was already assigned, old sens {}, new sens {}", llr, clArr[1 + llr]->
getSensorID(), curClu.getSensorID());
494 clArr[1 + geom->getLayer(curClu.getSensorID())] = &curClu;
495 clSizeArr[1 + geom->getLayer(curClu.getSensorID())] = mITSClusterSizes[itsClRefs[iTrack.
getClusterEntry(
i)]];
498 o2::track::TrackPar refLinIBOut0, refLinOBInw0, *refLinOBInw =
nullptr, *refLinIBOut =
nullptr;
499 if (
params.useStableRef) {
500 refLinOut = &(refLinOut0 = trFitOut);
501 refLinInw = &(refLinInw0 = trFitInw);
503 trFitOut.resetCovariance();
504 trFitOut.setCov(trFitOut.getQ2Pt() * trFitOut.getQ2Pt() * trFitOut.getCov()[14], 14);
505 trFitInw.resetCovariance();
506 trFitInw.setCov(trFitInw.getQ2Pt() * trFitInw.getQ2Pt() * trFitInw.getCov()[14], 14);
508 for (
int i = 0;
i <= 7;
i++) {
511 if (!(resOut = accountCluster(
i, extrapOut, trFitOut, refLinOut)) || !(resInw = accountCluster(7 -
i, extrapInw, trFitInw, refLinInw))) {
517 if (
i == 3 && resOut == 1 && resInw == 1 && (
params.doIBOB ||
params.doIBOBresiduals) &&
nCl == 7) {
518 if (
params.doIBOBresiduals) {
519 trIBOutForIOB = trFitOut;
520 trOBInwForIOB = trFitInw;
526 refLinIBOut = &(refLinIBOut0 = refLinOut0);
527 refLinOBInw = &(refLinOBInw0 = refLinInw0);
530 if (!resTrack.
trOBInw.getXatLabR(
params.rCompIBOB, xRref, bz) ||
531 !prop->propagateTo(resTrack.
trOBInw, refLinOBInw, xRref,
true) ||
532 !rotateTrack(resTrack.
trOBInw, resTrack.
trOBInw.getPhiPos(), refLinOBInw) ||
533 !rotateTrack(resTrack.
trIBOut, resTrack.
trOBInw.getAlpha(), refLinIBOut) ||
534 !prop->propagateTo(resTrack.
trIBOut, refLinIBOut, resTrack.
trOBInw.getX(),
true)) {
545 if (!rotateTrack(tr,
alpha,
nullptr) || !prop->propagateTo(tr,
nullptr, clArr[
i]->
getX(),
true)) {
546 return {0.f, 0.f, 0.f, 0.f};
548 return {clArr[
i]->getY() - tr.getY(), clArr[
i]->getZ() - tr.getZ(), tr.getSigmaY2() + clArr[
i]->getSigmaY2(), tr.getSigmaZ2() + clArr[
i]->getSigmaZ2()};
550 bool haveIOBTracks =
params.doIBOBresiduals &&
nCl == 7 && trIBOutForIOB.getX() > 1 && trOBInwForIOB.getX() > 1;
552 bool innerDone =
false;
554 for (
int i = 0;
i <= 7;
i++) {
557 const auto &tInw = extrapInw[
i], &tOut = extrapOut[
i];
558 auto wInw = inv2d(tInw.getSigmaY2(), tInw.getSigmaZ2(), tInw.getSigmaZY());
559 auto wOut = inv2d(tOut.getSigmaY2(), tOut.getSigmaZ2(), tOut.getSigmaZY());
560 if (wInw[0] == 0.f || wOut[0] == 0.f) {
563 std::array<float, 3> wTot = {wInw[0] + wOut[0], wInw[1] + wOut[1], wInw[2] + wOut[2]};
564 auto cTot = inv2d(wTot[0], wTot[1], wTot[2]);
565 auto ywi = wInw[0] * tInw.getY() + wInw[2] * tInw.getZ() + wOut[0] * tOut.getY() + wOut[2] * tOut.getZ();
566 auto zwi = wInw[2] * tInw.getY() + wInw[1] * tInw.getZ() + wOut[2] * tOut.getY() + wOut[1] * tOut.getZ();
567 auto yw = ywi * cTot[0] + zwi * cTot[2];
568 auto zw = ywi * cTot[2] + zwi * cTot[1];
570 auto phi =
i == 0 ? tInw.getPhi() : tInw.getPhiPos();
571 o2::math_utils::bringTo02Pi(phi);
572 std::array<float, 4> iob{0.f, 0.f, 0.f, 0.f};
576 iob = extrapIOB(trOBInwForIOB,
i);
578 iob = extrapIOB(trIBOutForIOB,
i);
581 resTrack.
points.emplace_back(clArr[
i]->
getY() - yw, clArr[
i]->getZ() - zw, cTot[0] + clArr[
i]->getSigmaY2(), cTot[1] + clArr[
i]->getSigmaZ2(),
582 iob[0], iob[1], iob[2], iob[3], phi, clArr[
i]->getZ(), 0.5 * (tInw.getSnp() + tOut.getSnp()), clSizeArr[
i], clArr[
i]->getSensorID(),
i - 1);
584 resTrack.
track = tInw;
588 LOGP(
debug,
"No cluster on lr {}",
i);
598 std::vector<o2::track::TrackParCov>
tracks;
599 std::vector<bool> useTrack;
600 std::vector<GTrackID> gidsITS;
601 int ntr = pv.getNContributors(), ntrIni = ntr;
603 useTrack.reserve(ntr);
604 gidsITS.reserve(ntr);
607 const auto& itsContRefs = vtref.getITSGloContributors();
608 if (
params.useITSGloContributors && itsContRefs.getEntries()) {
609 int itr = itsContRefs.getFirstEntry(), itLim = itr + itsContRefs.getEntries();
610 for (; itr < itLim; itr++) {
611 auto tid = trackIndex[itr];
612 tracks.emplace_back().setPID(tid.getSource());
616 int itr = vtref.getFirstEntry(), itLim = itr + vtref.getEntries();
617 for (; itr < itLim; itr++) {
618 auto tid = trackIndex[itr];
626 useTrack.resize(ntr);
628#pragma omp parallel for schedule(dynamic) num_threads(mNThreads)
630 for (
int itr = 0; itr < ntr; itr++) {
631 if (!(useTrack[itr] = refitITStrack(
tracks[itr], gidsITS[itr]))) {
636 for (
auto v : useTrack) {
640 LOGP(warn,
"Abandon vertex refit: NcontribNew = {} vs NcontribOld = {}", ntr, ntrIni);
643 LOGP(
debug,
"Original vtx: Nc:{} {}, chi2={}", pv.getNContributors(), pv.
asString(), pv.getChi2());
646 LOGP(
debug,
"Refitted vtx: Nc:{} {}, chi2={}", ntr, pv.
asString(), pv.getChi2());
647 if (pv.getChi2() < 0.f) {
648 LOGP(warn,
"Failed to refit PV {}", pvSave.asString());
661 track = trkITS.getParamOut();
662 track.resetCovariance();
665 auto nCl = trkITS.getNumberOfClusters();
668 float bz = prop->getNominalBz();
671 for (
int iCl = 0; iCl <
nCl; iCl++) {
672 const auto& cls = mITSClustersArray[itsClRefs[trkITS.getClusterEntry(iCl)]];
673 auto alpha = geom->getSensorRefAlpha(cls.getSensorID());
676 LOGP(
debug,
"refitITStrack failed on propagation to cl#{}, alpha={}, x={} | {}", iCl,
alpha, cls.getX(),
track.asString());
679 if (!
track.update(cls)) {
680 LOGP(
debug,
"refitITStrack failed on update with cl#{}, | {}", iCl,
track.asString());
691 int np = trc.
points.size();
692 auto pt = trc.
track.getPt();
693 if (pt < params.minPt || pt >
params.maxPt) {
696 auto tgl = trc.
track.getTgl();
698 auto fillLayerResid = [&](
int idOffset,
int il,
float phi,
float z,
float dy,
float dz,
float sig2y,
float sig2z) {
699 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100)->Fill(phi, dy);
700 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 1000)->Fill(
z, dy);
701 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 2000)->Fill(pt, dy);
702 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 3000)->Fill(tgl, dy);
704 auto pull = dy / std::sqrt(sig2y);
705 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 5)->Fill(phi, pull);
706 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 5 + 1000)->Fill(
z, pull);
707 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 5 + 2000)->Fill(pt, pull);
708 mHMan->
getHisto2F(idOffset + il * 10 + 0 * 100 + 5 + 3000)->Fill(tgl, pull);
710 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100)->Fill(phi, dz);
711 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 1000)->Fill(
z, dz);
712 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 2000)->Fill(pt, dz);
713 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 3000)->Fill(tgl, dz);
715 auto pull = dz / std::sqrt(sig2z);
716 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 5)->Fill(phi, pull);
717 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 5 + 1000)->Fill(
z, pull);
718 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 5 + 2000)->Fill(pt, pull);
719 mHMan->
getHisto2F(idOffset + il * 10 + 1 * 100 + 5 + 3000)->Fill(tgl, pull);
723 auto fillChipResid = [&](
int idOffset,
int il,
int lr,
int sens,
float dy,
float dz,
float sig2y,
float sig2z) {
724 if (sens >= 0 && geom->getLayer(sens) == lr) {
725 const int halfBarrel = geom->getHalfBarrel(sens);
726 const int chip = geom->getFirstChipIndex(lr) + geom->getChipIdInLayer(sens);
727 const int chipHistoID = idOffset + (2 * il + halfBarrel) * 100 + 15000;
728 if (halfBarrel >= 0 && halfBarrel < 2) {
729 mHMan->
getHisto2F(chipHistoID)->Fill(chip, dy);
730 mHMan->
getHisto2F(chipHistoID + 10)->Fill(chip, dz);
732 mHMan->
getHisto2F(chipHistoID + 5)->Fill(chip, dy / std::sqrt(sig2y));
735 mHMan->
getHisto2F(chipHistoID + 15)->Fill(chip, dz / std::sqrt(sig2z));
741 for (
int ip = 0; ip < np; ip++) {
742 const auto& pnt = trc.
points[ip];
743 int il = pnt.lr >= 0 ? pnt.lr + 1 : 0;
744 fillLayerResid(0, il, pnt.phi, pnt.z, pnt.dy, pnt.dz, pnt.sig2y, pnt.sig2z);
746 fillChipResid(0, il, pnt.lr, pnt.sens, pnt.dy, pnt.dz, pnt.sig2y, pnt.sig2z);
748 if (pnt.sig2yIOB > 0) {
749 fillLayerResid(100000, il, pnt.phi, pnt.z, pnt.dyIOB, pnt.dzIOB, pnt.sig2yIOB, pnt.sig2zIOB);
751 fillChipResid(100000, il, pnt.lr, pnt.sens, pnt.dyIOB, pnt.dzIOB, pnt.sig2yIOB, pnt.sig2zIOB);
757 for (
int ip = 0; ip < 5; ip++) {
763 float sg = trc.
trIBOut.getCovarElem(ip, ip) + trc.
trOBInw.getCovarElem(ip, ip);
765 auto pull =
d / std::sqrt(sg);
768 mHMan->
getHisto2F(12000 + ip * 10 + 5)->Fill(pt, pull);
769 mHMan->
getHisto2F(13000 + ip * 10 + 5)->Fill(trc.
track.getTgl(), pull);
775void CheckResidSpec::bookHistos()
778 mHManV.emplace_back() = std::make_unique<o2::HistoManager>(
"", fmt::format(
"{}_hman.root",
params.outname));
779 mHMan = mHManV.back().get();
780 mHMan->SetName(
params.outname.c_str());
781 auto defLogAxis = [](
float xMn,
float xMx,
int nbin) {
782 if (xMn <= 0 || xMx <= xMn || nbin < 2) {
783 LOGP(fatal,
"Wrong log axis request: xmin = {} xmax = {} nbins = {}", xMn, xMx, nbin);
785 auto dx = std::log(xMx / xMn) / nbin;
786 std::vector<double> xax(nbin + 1);
787 for (
int i = 0;
i <= nbin;
i++) {
788 xax[
i] = xMn * std::exp(dx *
i);
792 float minPt = std::max(0.1f,
params.minPt), maxPt = std::min(50.f,
params.maxPt);
793 auto ptax = defLogAxis(minPt, maxPt,
params.nBinsPt);
797 auto bookLayerResidHistos = [&](
int idOffset,
const std::string& suf,
bool bookVtx) {
798 const float dyzScale = idOffset ?
params.IOBScaleFactor : 1.f;
799 for (
int il = bookVtx ? 0 : 1; il < 8; il++) {
800 std::string lrName = il == 0 ?
"Vtx" : fmt::format(
"Lr{}", il - 1);
801 const float maxDYZ =
params.maxDYZ[il] * dyzScale;
802 for (
int iyz = 0; iyz < 2; iyz++) {
803 std::string dname = fmt::format(
"{}{}", iyz == 0 ?
"dy" :
"dz", suf), dtit =
fmt::
format(
"{}{}", iyz == 0 ?
"#DeltaY" :
"#DeltaZ", suf.
empty() ?
"" : (
"_" + suf));
804 auto h2 =
new TH2F(fmt::format(
"{}_{}_{}", dname, lrName,
"phi").c_str(), fmt::format(
"{}_{{{}}} vs {};#phi;{}", dtit, lrName,
"#phi", dtit).c_str(),
params.nBinsPhi, 0, TMath::Pi() * 2,
params.nBinsRes, -maxDYZ, maxDYZ);
805 mHMan->
addHisto(h2, idOffset + il * 10 + iyz * 100);
806 auto h2p =
new TH2F(fmt::format(
"{}_{}_{}_pull", dname, lrName,
"phi").c_str(), fmt::format(
"pull {}_{{{}}} vs {};#phi; pull{}", dtit, lrName,
"phi", dtit).c_str(),
params.nBinsPhi, 0, TMath::Pi() * 2,
params.nBinsRes, -
params.maxPull,
params.maxPull);
807 mHMan->
addHisto(h2p, idOffset + il * 10 + iyz * 100 + 5);
809 auto hz2 =
new TH2F(fmt::format(
"{}_{}_{}", dname, lrName,
"Z").c_str(), fmt::format(
"{}_{{{}}} vs {};Z;{}", dtit, lrName,
"Z", dtit).c_str(),
params.nBinsZ, -
params.zranges[il],
params.zranges[il],
params.nBinsRes, -maxDYZ, maxDYZ);
810 mHMan->
addHisto(hz2, idOffset + il * 10 + iyz * 100 + 1000);
811 auto hz2p =
new TH2F(fmt::format(
"{}_{}_{}_pull", dname, lrName,
"Z").c_str(), fmt::format(
"pull {}_{{{}}} vs {};Z; pull{}", dtit, lrName,
"Z", dtit).c_str(),
params.nBinsZ, -
params.zranges[il],
params.zranges[il],
params.nBinsRes, -
params.maxPull,
params.maxPull);
812 mHMan->
addHisto(hz2p, idOffset + il * 10 + iyz * 100 + 5 + 1000);
814 auto hpt2 =
new TH2F(fmt::format(
"{}_{}_{}", dname, lrName,
"Pt").c_str(), fmt::format(
"{}_{{{}}} vs {};p_{{T}};{}", dtit, lrName,
"p_{T}", dtit).c_str(),
params.nBinsPt, ptax.data(),
params.nBinsRes, -maxDYZ, maxDYZ);
815 mHMan->
addHisto(hpt2, idOffset + il * 10 + iyz * 100 + 2000);
816 auto hpt2p =
new TH2F(fmt::format(
"{}_{}_{}_pull", dname, lrName,
"Pt").c_str(), fmt::format(
"pull {}_{{{}}} vs {};p_{{T}}; pull{}", dtit, lrName,
"p_{T}", dtit).c_str(),
params.nBinsPt, ptax.data(),
params.nBinsRes, -
params.maxPull,
params.maxPull);
817 mHMan->
addHisto(hpt2p, idOffset + il * 10 + iyz * 100 + 5 + 2000);
819 auto htgl2 =
new TH2F(fmt::format(
"{}_{}_{}", dname, lrName,
"tgl").c_str(), fmt::format(
"{}_{{{}}} vs {};tg#lambda;{}", dtit, lrName,
"tg#lambda", dtit).c_str(),
params.nBinsTgl, -
params.maxTgl,
params.maxTgl,
params.nBinsRes, -maxDYZ, maxDYZ);
820 mHMan->
addHisto(htgl2, idOffset + il * 10 + iyz * 100 + 3000);
821 auto htgl2p =
new TH2F(fmt::format(
"{}_{}_{}_pull", dname, lrName,
"tgl").c_str(), fmt::format(
"pull {}_{{{}}} vs {};tg#lambda; pull{}", dtit, lrName,
"tg#lambda", dtit).c_str(),
params.nBinsTgl, -
params.maxTgl,
params.maxTgl,
params.nBinsRes, -
params.maxPull,
params.maxPull);
822 mHMan->
addHisto(htgl2p, idOffset + il * 10 + iyz * 100 + 5 + 3000);
825 const int ilr = il - 1;
827 for (
int ib = 0; ib < 2; ++ib) {
829 auto hc2 =
new TH2F(fmt::format(
"{}_{}_{}", dname, lrName, ib).c_str(), fmt::format(
"{} Lr{} HB{};chip;{}", dname, lrName, ib, dtit).c_str(), nChips, startChip - 0.5, startChip - 0.5 + nChips,
params.nBinsRes, -maxDYZ, maxDYZ);
830 mHMan->
addHisto(hc2, idOffset + (2 * il + ib) * 100 + iyz * 10 + 15000);
831 auto hc2p =
new TH2F(fmt::format(
"{}_{}_{}_pull", dname, lrName, ib).c_str(), fmt::format(
"{} Lr{} HB{} pull;chip;pull{}", dname, lrName, ib, dtit).c_str(), nChips, startChip - 0.5, startChip - 0.5 + nChips,
params.nBinsRes, -
params.maxPull,
params.maxPull);
832 mHMan->
addHisto(hc2p, idOffset + (2 * il + ib) * 100 + iyz * 10 + 5 + 15000);
838 bookLayerResidHistos(0,
"",
true);
839 if (
params.doIBOBresiduals) {
840 bookLayerResidHistos(100000,
"IOB",
true);
843 for (
int ip = 0; ip < 5; ip++) {
844 auto h2 =
new TH2F(fmt::format(
"dPar{}_IBOBphi", ip).c_str(), fmt::format(
"#Delta par{} IB-OB vs phi;#phi;#Delta par{}", ip, ip).c_str(),
params.nBinsPhi, 0, TMath::Pi() * 2,
params.nBinsRes, -
params.maxDPar[ip],
params.maxDPar[ip]);
845 mHMan->
addHisto(h2, 10000 + ip * 10);
846 auto h2p =
new TH2F(fmt::format(
"dPar{}_IBOBphi_pull", ip).c_str(), fmt::format(
"pull #Delta par{} IB-OB vs phi;#phi;pull #Delta par{}", ip, ip).c_str(),
params.nBinsPhi, 0, TMath::Pi() * 2,
params.nBinsRes, -
params.maxPull,
params.maxPull);
847 mHMan->
addHisto(h2p, 10000 + ip * 10 + 5);
849 auto hz2 =
new TH2F(fmt::format(
"dPar{}_IBOBz", ip).c_str(), fmt::format(
"#Delta par{} IB-OB vs Z;Z;#Delta par{}", ip, ip).c_str(),
params.nBinsZ, -20., 20.,
params.nBinsRes, -
params.maxDPar[ip],
params.maxDPar[ip]);
850 mHMan->
addHisto(hz2, 11000 + ip * 10);
851 auto hz2p =
new TH2F(fmt::format(
"dPar{}_IBOBz_pull", ip).c_str(), fmt::format(
"pull #Delta par{} IB-OB vs Z;Z;pull #Delta par{}", ip, ip).c_str(),
params.nBinsZ, -20., 20.,
params.nBinsRes, -
params.maxPull,
params.maxPull);
852 mHMan->
addHisto(hz2p, 11000 + ip * 10 + 5);
854 auto hpt2 =
new TH2F(fmt::format(
"dPar{}_IBOBpt", ip).c_str(), fmt::format(
"#Delta par{} IB-OB vs pT;p_{{T}};#Delta par{}", ip, ip).c_str(),
params.nBinsPt, ptax.data(),
params.nBinsRes, -
params.maxDPar[ip],
params.maxDPar[ip]);
855 mHMan->
addHisto(hpt2, 12000 + ip * 10);
856 auto hpt2p =
new TH2F(fmt::format(
"dPar{}_IBOBpt_pull", ip).c_str(), fmt::format(
"pull #Delta par{} IB-OB vs pT;p_{{T}};pull #Delta par{}", ip, ip).c_str(),
params.nBinsPt, ptax.data(),
params.nBinsRes, -
params.maxPull,
params.maxPull);
857 mHMan->
addHisto(hpt2p, 12000 + ip * 10 + 5);
859 auto htgl2 =
new TH2F(fmt::format(
"dPar{}_IBOBtgl", ip).c_str(), fmt::format(
"#Delta par{} IB-OB vs tg#lambda;tg#lambda;#Delta par{}", ip, ip).c_str(),
params.nBinsTgl, -
params.maxTgl,
params.maxTgl,
params.nBinsRes, -
params.maxDPar[ip],
params.maxDPar[ip]);
860 mHMan->
addHisto(htgl2, 13000 + ip * 10);
861 auto htgl2p =
new TH2F(fmt::format(
"dPar{}_IBOBtgl_pull", ip).c_str(), fmt::format(
"pull #Delta par{} IB-OB vs tg#lambda;tg#lambda;pull #Delta par{}", ip, ip).c_str(),
params.nBinsTgl, -
params.maxTgl,
params.maxTgl,
params.nBinsRes, -
params.maxPull,
params.maxPull);
862 mHMan->
addHisto(htgl2p, 13000 + ip * 10 + 5);
868 mHMan->
addHisto(
new TH1F(
"pvN",
"PV Contributors;Nc;",
params.maxHPVN, 1.5,
params.maxHPVN + 1.5), 20000 + 3);
871void CheckResidSpec::postProcessHistos()
873 printf(
"Fitting histos\n");
875 if (mHManV.empty()) {
876 LOGP(warn,
"nothing to process");
879 mHMan = mHManV[0].get();
882 auto gs =
new TF1(
"gs",
"gaus", -1, 1);
883 int maxH = mPostProcOnly ? mHManV.size() : 1;
885 for (
int ihm = 0; ihm < maxH; ihm++) {
886 auto* histm = mHManV[ihm].get();
890 auto fitSlices = [&](
int id) {
891 auto h2 = histm->getHisto2F(
id);
892 if (!h2 || h2->GetEntries() <
params.minHistoStat2Fit) {
895 h2->FitSlicesY(gs, 0, -1, 0,
"QNR", &arr);
897 TH1* hmean = (TH1*)arr.RemoveAt(1);
899 hmean->SetTitle(Form(
"<%s>", h2->GetTitle()));
900 histm->addHisto(hmean,
id + 1);
902 TH1* hsig = (TH1*)arr.RemoveAt(2);
904 hsig->SetTitle(Form(
"#sigma(%s)", h2->GetTitle()));
905 histm->addHisto(hsig,
id + 2);
908 for (
int ioffs = 0; ioffs <= 3; ioffs++) {
909 int offs = ioffs * 1000;
910 for (
int iht = 0; iht < 2; iht++) {
911 int offsV = iht == 0 ? 0 : 5;
912 for (
int idOffset : {0, 100000}) {
913 for (
int il = 0; il < 8; il++) {
914 for (
int iyz = 0; iyz < 2; iyz++) {
915 fitSlices(idOffset + il * 10 + iyz * 100 + offsV + offs);
919 for (
int ip = 0; ip < 5; ip++) {
920 fitSlices(10000 + ip * 10 + offsV + offs);
924 for (
int idOffset : {0, 100000}) {
925 for (
int il = 1; il < 8; il++) {
926 for (
int ib = 0; ib < 2; ib++) {
927 for (
int iyz = 0; iyz < 2; iyz++) {
928 for (
int iht = 0; iht < 2; iht++) {
929 const int offsV = iht == 0 ? 0 : 5;
930 fitSlices(idOffset + (2 * il + ib) * 100 + iyz * 10 + offsV + 15000);
940void CheckResidSpec::drawHistos()
943 gStyle->SetTitleX(0.3);
944 gStyle->SetTitleY(0.88);
945 gStyle->SetTitleW(0.25);
946 gStyle->SetOptStat(0);
948 int nhm = mHManV.size();
949 std::array<unsigned int, 3> hcol{EColor::kRed, EColor::kBlue, EColor::kGreen + 2};
953 bool useColors = colorNames.size() == hmNames.size() && !colorNames.empty();
954 bool useMarkers = markerIDs.size() == hmNames.size() && !markerIDs.empty();
956 LOGP(warn,
"{} color names provided for {} external histomanagers, will use automatic colors", colorNames.size(), hmNames.size());
959 LOGP(warn,
"{} marker IDs provided for {} external histomanagers, will use automatic markers", markerIDs.size(), hmNames.size());
961 constexpr std::array<std::pair<std::string_view, int>, 15> rootColors{{
962 {
"kWhite", EColor::kWhite},
963 {
"kBlack", EColor::kBlack},
964 {
"kGray", EColor::kGray},
965 {
"kRed", EColor::kRed},
966 {
"kGreen", EColor::kGreen},
967 {
"kBlue", EColor::kBlue},
968 {
"kYellow", EColor::kYellow},
969 {
"kMagenta", EColor::kMagenta},
970 {
"kCyan", EColor::kCyan},
971 {
"kOrange", EColor::kOrange},
972 {
"kSpring", EColor::kSpring},
973 {
"kTeal", EColor::kTeal},
974 {
"kAzure", EColor::kAzure},
975 {
"kViolet", EColor::kViolet},
976 {
"kPink", EColor::kPink},
978 auto parseColor = [&rootColors](
const std::string& token) -> std::optional<int> {
981 for (
unsigned char ch : token) {
982 if (!std::isspace(ch)) {
986 for (
const auto& [
name,
value] : rootColors) {
990 const auto increment = std::string_view(
normalized).substr(
name.size());
991 if (increment.empty()) {
994 if (increment.size() < 2 || (increment.front() !=
'+' && increment.front() !=
'-')) {
998 const auto*
begin = increment.data() + 1;
999 const auto*
end = increment.data() + increment.size();
1001 if (
error != std::errc{} || parsedEnd !=
end) {
1002 return std::nullopt;
1004 const auto signedOffset = increment.front() ==
'-' ? -
static_cast<long long>(
offset) : static_cast<
long long>(
offset);
1005 const auto color =
static_cast<long long>(
value) + signedOffset;
1006 if (
color < std::numeric_limits<int>::min() ||
color > std::numeric_limits<int>::max()) {
1007 return std::nullopt;
1009 return static_cast<int>(
color);
1011 return std::nullopt;
1013 std::vector<int> colors;
1015 for (
const auto& colorName : colorNames) {
1016 auto color = parseColor(colorName);
1018 LOGP(warn,
"Unrecognized EColor name '{}', will use automatic colors", colorName);
1022 colors.push_back(*
color);
1025 std::vector<int> markers;
1027 for (
const auto& markerID : markerIDs) {
1029 const auto*
begin = markerID.data();
1030 const auto*
end =
begin + markerID.size();
1032 if (
error != std::errc{} || parsedEnd !=
end) {
1033 LOGP(warn,
"Unrecognized marker ID '{}', will use automatic markers", markerID);
1037 markers.push_back(
marker);
1040 std::unique_ptr<TLegend> lg;
1041 lg = std::make_unique<TLegend>(0.12, 0.13, 0.9, 0.13 + std::min(0.5f, nhm * 0.2f / 3.f));
1042 lg->SetFillStyle(0);
1043 lg->SetBorderSize(0);
1044 for (
int i = 0;
i < nhm;
i++) {
1045 auto hman = mHManV[
i].get();
1046 if (!hman || hman->GetLast() < 1) {
1049 const int marker = useMarkers ? markers[
i] : 20 +
i + (
i % 2) * 4;
1050 const int color = useColors ? colors[
i] : hcol[
i % hcol.size()];
1051 hman->setMarkerStyle(
marker, 0.5);
1052 hman->setColor(
color);
1053 auto le = lg->AddEntry(hman->getHisto(1), hman->GetName(),
"lp");
1054 le->SetTextColor(
color);
1056 TCanvas cly(
"cly",
"", 600, 800), clz(
"clz",
"", 600, 800), clpar(
"clpar",
"", 600, 800);
1057 TCanvas czly(
"czly",
"", 600, 800), czlz(
"czlz",
"", 600, 800), czlpar(
"czlpar",
"", 600, 800);
1058 TCanvas cchip(
"cchip",
"", 600, 800);
1059 constexpr std::array<const char*, 4> chipTitles{
"#DeltaY",
"pull #DeltaY",
"#DeltaZ",
"pull #DeltaZ"};
1060 auto AddLabel = [](
const char* txt,
float x = 0.1,
float y = 0.9,
int color = kBlack,
float size = 0.04) {
1061 TLatex* lt =
new TLatex(
x,
y, txt);
1063 lt->SetTextColor(
color);
1064 lt->SetTextSize(
size);
1069 auto drawResLr = [
this](TCanvas& canv,
int offs,
const float resMM[8],
bool logX) {
1072 int nh = this->mHManV.size();
1073 for (
int i = 0;
i < 8;
i++) {
1076 for (
int j = 0;
j < nh;
j++) {
1077 auto hman = this->mHManV[
j].get();
1078 if (!hman || hman->GetLast() < 1) {
1081 if (
auto histo = hman->getHisto(10 *
i + offs)) {
1082 histo->Draw(same ?
"same" :
"");
1084 histo->SetMinimum(-resMM[
i]);
1085 histo->SetMaximum(resMM[
i]);
1091 gPad->SetLogx(logX);
1095 auto drawResPar = [
this](TCanvas& canv,
int offs,
const float resMM[8],
bool logX) {
1098 int nh = this->mHManV.size();
1099 for (
int i = 0;
i < 5;
i++) {
1102 for (
int j = 0;
j < nh;
j++) {
1103 auto hman = this->mHManV[
j].get();
1104 if (!hman || hman->GetLast() < 1) {
1107 if (
auto histo = hman->getHisto(10 *
i + offs)) {
1108 histo->Draw(same ?
"same" :
"");
1110 histo->SetMinimum(-resMM[
i]);
1111 histo->SetMaximum(resMM[
i]);
1117 gPad->SetLogx(logX);
1122 auto drawLrResidPages = [&](
const std::string& pdfName,
int idOffset) {
1123 const float dyzScale = idOffset ?
params.IOBScaleFactor : 1.f;
1124 std::array<float, 8> resMMY, resMMZ;
1125 for (
int i = 0;
i < 8;
i++) {
1126 resMMY[
i] =
params.resMMLrY[
i] * dyzScale;
1127 resMMZ[
i] =
params.resMMLrZ[
i] * dyzScale;
1129 drawResLr(cly, idOffset + 1, resMMY.data(),
false);
1132 AddLabel(
"Y residuals", 0.1, 0.95);
1133 cly.Print(pdfName.c_str());
1135 drawResLr(clz, idOffset + 101, resMMZ.data(),
false);
1138 AddLabel(
"Z residuals", 0.1, 0.95);
1139 clz.Print(pdfName.c_str());
1141 drawResLr(czly, idOffset + 1001, resMMY.data(),
false);
1144 AddLabel(
"Y residuals", 0.1, 0.95);
1145 czly.Print(pdfName.c_str());
1147 drawResLr(czlz, idOffset + 1101, resMMZ.data(),
false);
1150 AddLabel(
"Z residuals", 0.1, 0.95);
1151 czlz.Print(pdfName.c_str());
1153 drawResLr(czly, idOffset + 2001, resMMY.data(),
true);
1156 AddLabel(
"Y residuals", 0.1, 0.95);
1157 czly.Print(pdfName.c_str());
1159 drawResLr(czlz, idOffset + 2101, resMMZ.data(),
true);
1162 AddLabel(
"Z residuals", 0.1, 0.95);
1163 czlz.Print(pdfName.c_str());
1165 drawResLr(czly, idOffset + 3001, resMMY.data(),
false);
1168 AddLabel(
"Y residuals", 0.1, 0.95);
1169 czly.Print(pdfName.c_str());
1171 drawResLr(czlz, idOffset + 3101, resMMZ.data(),
false);
1174 AddLabel(
"Z residuals", 0.1, 0.95);
1175 czlz.Print(pdfName.c_str());
1178 const std::string mainPdf = fmt::format(
"{}_hman.pdf",
params.outname);
1179 cly.Print(Form(
"%s[", mainPdf.c_str()));
1180 drawLrResidPages(mainPdf, 0);
1182 drawResPar(clpar, 10001,
params.resMMPar,
false);
1185 AddLabel(
"IB-OB tracks params differences at R = 12 cm", 0.2, 0.8);
1186 clpar.Print(mainPdf.c_str());
1188 drawResPar(czlpar, 11001,
params.resMMPar,
false);
1191 AddLabel(
"IB-OB tracks params differences at R = 12 cm", 0.2, 0.8);
1192 czlpar.Print(mainPdf.c_str());
1194 drawResPar(czlpar, 12001,
params.resMMPar,
true);
1197 AddLabel(
"IB-OB tracks params differences at R = 12 cm", 0.2, 0.8);
1198 czlpar.Print(mainPdf.c_str());
1200 drawResPar(czlpar, 13001,
params.resMMPar,
false);
1203 AddLabel(
"IB-OB tracks params differences at R = 12 cm", 0.2, 0.8);
1204 czlpar.Print(mainPdf.c_str());
1206 auto getHMinMax = [
this](
int id,
float marginFrac,
float maxDev,
int roundToMicrons) -> std::tuple<float, float, float> {
1207 float maxV = std::numeric_limits<float>::lowest(), minV = std::numeric_limits<float>::max();
1208 const int nh = this->mHManV.size();
1209 for (
int j = 0;
j < nh;
j++) {
1210 if (!this->mHManV[
j]) {
1213 if (
auto histo = this->mHManV[
j]->getHisto(
id); histo !=
nullptr) {
1214 const int nb = histo->GetNbinsX();
1215 for (
int ib = 1; ib <= nb; ib++) {
1216 float v = histo->GetBinContent(ib);
1217 maxV = std::max(maxV,
v);
1218 minV = std::min(minV,
v);
1223 return {0.f, 1.f, 0.1f};
1225 auto delta = maxV - minV;
1226 maxV += delta * marginFrac;
1227 minV -= delta * marginFrac;
1228 if (roundToMicrons > 0) {
1229 maxV = ((
int(std::ceil(maxV * 1e4)) / roundToMicrons + 1) * roundToMicrons) * 1
e-4;
1230 minV = ((
int(std::floor(minV * 1e4)) / roundToMicrons - 1) * roundToMicrons) * 1
e-4;
1232 minV = std::max(minV, -maxDev);
1233 maxV = std::min(maxV, maxDev);
1234 return {minV, maxV, std::max(std::abs(minV), std::abs(maxV))};
1236 auto collectSpread = [](TH1* hin, TH1* hout) {
1237 const int nb = hin->GetNbinsX();
1238 for (
int ib = 1; ib <= nb; ib++) {
1239 if (hin->GetBinError(ib) != 0) {
1240 hout->Fill(hin->GetBinContent(ib));
1243 hout->SetLineColor(hin->GetLineColor());
1244 hout->SetMarkerColor(hin->GetMarkerColor());
1245 hout->SetMarkerStyle(hin->GetMarkerStyle());
1247 int nh = this->mHManV.size();
1249 auto drawChipPages = [&](
const std::string& pdfName,
int idOffset) {
1250 for (
int il = 1; il < 8; ++il) {
1251 for (
int iht = 0; iht < 2; iht++) {
1252 for (
int ib = 0; ib < 3; ib++) {
1253 if (iht == 1 && ib < 2) {
1256 for (
int iyz = 0; iyz < 2; iyz++) {
1258 cchip.Divide(1, ib == 2 ? 2 : 4);
1259 bool havePage =
false;
1260 for (
int iv = 0; iv < 2; iv++) {
1261 const float yRange = (iyz == 0 ?
params.resMMLrY[il] :
params.resMMLrZ[il]) * (idOffset ?
params.IOBScaleFactor : 1.f);
1262 const int baseID = idOffset + 15000 + iyz * 10 + 2 * il * 100 + iht * 5 + 1 + iv;
1264 auto [minV, maxV, absMax] = getHMinMax(baseID, 0.15, (iv == 0 ? 2 : 8) * yRange, 10);
1265 auto [minV1, maxV1, absMax1] = getHMinMax(baseID + 100, 0.15, (iv == 0 ? 2 : 8) * yRange, 10);
1266 minV = std::min(minV, minV1);
1267 maxV = std::max(maxV, maxV1);
1268 absMax = std::max(absMax, absMax1);
1270 minV = iv ? 0.f : -
params.maxPull;
1271 maxV = absMax =
params.maxPull;
1274 TH1* firstAuto =
nullptr;
1275 float maxAuto = 0.f;
1276 for (
int j = 0;
j < nh;
j++) {
1277 auto hman = this->mHManV[
j].get();
1281 TH1* hmeans =
nullptr;
1282 for (
int hb = ib == 2 ? 0 : ib; hb < (ib == 2 ? 2 : ib + 1); hb++) {
1283 const int id = baseID + hb * 100;
1284 auto histo = hman->getHisto(
id);
1290 hmeans =
new TH1F(Form(
"%s_layer_spread", histo->GetName()), Form(
"Lr%d %s %s spread", il - 1, chipTitles[2 * iyz + iht], iv ?
"sigma" :
"mean"),
params.nBinsRes, iv == 0 ? minV :
std::
max(0.f, minV), maxV);
1291 hman->addHisto(hmeans, idOffset + 25000 + il * 100 + iyz * 10 + iht * 5 + iv);
1293 hmeans =
new TH1F(Form(
"%s_spread", histo->GetName()), Form(
"%s spread;#<Delta>", histo->GetTitle()),
params.nBinsRes, iv == 0 ? minV :
std::
max(0.f, minV), maxV);
1294 hman->addHisto(hmeans,
id + 2);
1298 hmeans->SetXTitle(iv ?
"<#sigma>, cm" :
"<#Delta>, cm");
1300 collectSpread(histo, hmeans);
1302 histo->SetMaximum(absMax);
1303 histo->SetMinimum(iv ? 0 : -absMax);
1305 histo->SetMarkerSize(0.3);
1306 histo->SetLineStyle(3);
1308 cchip.cd(2 * iv + 1);
1309 histo->Draw(drawn ?
"same" :
"");
1316 cchip.cd(ib == 2 ? iv + 1 : 2 * iv + 2);
1320 maxAuto = std::max(maxAuto, (
float)hmeans->GetMaximum());
1321 hmeans->Draw(drawn ?
"same" :
"");
1322 drawn = havePage =
true;
1325 firstAuto->SetMaximum(maxAuto * 1.25);
1331 cchip.Print(pdfName.c_str());
1338 drawChipPages(mainPdf, 0);
1339 cly.Print(Form(
"%s]", mainPdf.c_str()));
1342 bool haveIOB =
false;
1343 for (
const auto& hm : mHManV) {
1344 if (hm && hm->getHisto2F(100000 + 1 * 10)) {
1350 const std::string iobPdf = fmt::format(
"{}_iob_hman.pdf",
params.outname);
1351 cly.Print(Form(
"%s[", iobPdf.c_str()));
1352 drawLrResidPages(iobPdf, 100000);
1353 drawChipPages(iobPdf, 100000);
1354 cly.Print(Form(
"%s]", iobPdf.c_str()));
1361 if (mHManV.size()) {
1362 postProcessHistos();
1367 if (
auto nh = mHManV.size(); nh > 0 && !mPostProcOnly) {
1368 for (
int ihm = 0; ihm < nh; ihm++) {
1370 mHManV[ihm].get()->write();
1384 mMeanVertexUpdated =
true;
1388 LOG(info) <<
"cluster dictionary updated";
1396 std::vector<OutputSpec> outputs;
1397 auto dataRequest = std::make_shared<DataRequest>();
1398 dataRequest->setITSPerLayer(itsStag);
1399 if (!drawOnly && !postProcOnly) {
1401 dataRequest->requestTracks(srcTracks, useMC);
1402 dataRequest->requestClusters(srcClusters, useMC);
1403 dataRequest->requestPrimaryVertices(useMC);
1404 dataRequest->inputs.emplace_back(
"meanvtx",
"GLO",
"MEANVERTEX", 0, Lifetime::Condition,
ccdbParamSpec(
"GLO/Calib/MeanVertex", {}, 1));
1406 auto ggRequest = drawOnly ? std::make_shared<o2::base::GRPGeomRequest>(
false,
false,
false,
false,
false,
o2::base::GRPGeomRequest::None, dataRequest->inputs) : std::make_shared<o2::base::GRPGeomRequest>(
false,
1412 dataRequest->inputs,
true);
1416 {
"nthreads", VariantType::Int, 1, {
"number of threads"}},
1417 {
"no-tree", VariantType::Bool,
false, {
"do not fill residuals tree"}},
1418 {
"no-hist", VariantType::Bool,
false, {
"do not fill residuals histograms"}},
1419 {
"draw-report", VariantType::Bool,
false, {
"fill residuals report"}},
1427 AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly, postProcOnly)},
Container of the ITS/MFT clusters addressed by the composed (layer,index) ID.
Definition of the GeometryManager class.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions false
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc true
Helper for geometry and GRP related CCDB requests.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
char error[CURL_ERROR_SIZE]
Definition of the GeometryTGeo class.
std::vector< o2::its::TrackITS > tracks
Utility functions for MC particles.
Definition of the Names Generator class.
Wrapper container for different reconstructed object types.
o2::track::TrackParCov TrackParCov
Result of refitting TPC-ITS matched track.
Reference on ITS/MFT clusters set.
Referenc on track indices contributing to the vertex, with possibility chose tracks from specific sou...
void setSensorID(std::int16_t sid)
void setXYZ(T x, T y, T z)
int addHisto(TH1 *histo, int at=-1)
TH2F * getHisto2F(int id) const
TH1 * getHisto(int id) const
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
~CheckResidSpec() final=default
void run(ProcessingContext &pc) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
CheckResidSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, GTrackID::mask_t src, bool drawOnly, bool postProcOnly)
void init(InitContext &ic) final
static const CheckResidConfig & Instance()
static void updateFromString(std::string const &)
Static class with identifiers, bitmasks and names for ALICE detectors.
T get(const char *key) const
ServiceRegistryRef services()
ConfigParamRegistry const & options()
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static GeometryTGeo * Instance()
int getClusterEntry(int i) const
static constexpr int getNChipsOnLayer(int lr)
static constexpr int getFirstChipsOnLayer(int lr)
int getNPixels() const
Returns the number of fired pixels.
void beginLayer(int lr)
to be called once all the layers were filled
void init(int nLr)
< prepare for filling nLr layer slots, discarding the previous content
static constexpr unsigned short InvalidPatternID
int getNpixels(int n) const
Returns the number of fired pixels of the n_th element.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
void initMeanVertexConstraint()
PVertex refitVertexFull(const std::vector< bool > useTrack, const o2d::VertexBase &vtxSeed)
bool prepareVertexRefit(const TR &tracks, const o2d::VertexBase &vtxSeed)
void setMeanVertex(const o2d::MeanVertexObject *v)
GLfloat GLfloat GLfloat alpha
GLuint const GLchar * name
GLsizei const GLfloat * value
GLenum const GLfloat * params
GLint GLenum GLboolean normalized
GLint GLint GLsizei GLint GLenum format
GLdouble GLdouble GLdouble z
uint8_t int statusCode int
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly, bool postProcOnly, bool itsStag)
create a processor spec
o2::dataformats::GlobalTrackID GTrackID
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
constexpr int MaxITSLayers
constexpr unsigned int nChips
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const itsmft::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
o2::track::TrackParCov int int int float int nCl
const bool const int TrackITSInternal< NLayers > & track
const float const float const float bz
double * getX(double *xyDxy, int N)
double * getY(double *xyDxy, int N)
Enum< T >::Iterator begin(Enum< T >)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
o2::track::TrackPar track
o2::track::TrackParCov trIBOut
o2::track::TrackParCov trOBInw
std::vector< Point > points
auto getITSTracks() const
GTrackID getITSContributorGID(GTrackID source) const
bool isTrackSourceLoaded(int src) const
auto getITSTracksClusterRefs() const
auto getPrimaryVertices() const
auto getPrimaryVertexMatchedTracks() const
auto getPrimaryVertexMatchedTrackRefs() const
auto getITSClustersPatterns(int layer=0) const
const o2::track::TrackParCov & getTrackParam(GTrackID gidx) const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
const o2::its::TrackITS & getITSTrack(GTrackID gid) const
auto getITSClusters(int layer=0) const
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"