18#include <FairRootManager.h>
22#include <TClonesArray.h>
41 throw std::logic_error(
"MC event header branch is unavailable");
46 throw std::logic_error(Form(
"Hit branch is unavailable for %s",
kDetName[iD]));
49 throw std::logic_error(Form(
"MC point branch is unavailable for %s",
kDetName[iD]));
63 L_(info) << fName <<
": " << ToCbmModuleId(detID) <<
" " <<
fvbUseDet[detID];
79 canv->Divide(1, 2, 0.000001, 0.000001);
82 gPad->SetBottomMargin(0.000001);
83 gPad->SetRightMargin(0.05);
85 auto* ph_hit_xz =
dynamic_cast<TH2F*
>(
fph_hit_xz.back()->Clone(
"h_hit_xz_clone"));
86 ph_hit_xz->SetTitle(
";z [cm];x [cm]");
87 ph_hit_xz->Draw(
"col");
91 gPad->SetTopMargin(0.000001);
92 gPad->SetRightMargin(0.05);
94 auto* ph_hit_yz =
dynamic_cast<TH2F*
>(
fph_hit_yz.back()->Clone(
"h_hit_yz_clone"));
95 ph_hit_yz->SetTitle(
";z [cm];y [cm]");
96 ph_hit_yz->Draw(
"col");
100 auto LoBinEdge = [](TAxis* pAxis,
double val) {
return pAxis->GetBinLowEdge(pAxis->FindBin(val)); };
101 auto UpBinEdge = [](TAxis* pAxis,
double val) {
return pAxis->GetBinUpEdge(pAxis->FindBin(val)); };
106 using Unit_t = std::remove_reference_t<std::remove_cv_t<
decltype(unit)>>;
112 int nSt = unit.GetNofTrackingStations();
113 for (
int iSt = 0; iSt < nSt; ++iSt) {
114 int iStActive =
fpParameters->GetStationIndexActive(iSt, DetId);
115 Color_t boxColor = (iStActive < 0) ? kGray + 1 : kOrange + 2;
116 const char* detName = fmt::format(
"{}-{}", Unit_t::GetDetectorName(), iSt).c_str();
123 auto* pBox =
new TBox(zMin, xMin, zMax, xMax);
124 pBox->SetFillStyle(0);
125 pBox->SetLineWidth(2);
126 pBox->SetLineColor(boxColor);
128 auto* pText =
new TText(zMin, xMax, detName);
129 pText->SetTextColor(boxColor);
130 pText->SetTextSize(0.035);
131 pText->SetTextAngle(45);
140 auto* pBox =
new TBox(zMin, yMin, zMax, yMax);
141 pBox->SetFillStyle(0);
142 pBox->SetLineWidth(2);
143 pBox->SetLineColor(boxColor);
145 auto* pText =
new TText(zMin, yMax, detName);
146 pText->SetTextSize(0.035);
147 pText->SetTextColor(boxColor);
148 pText->SetTextAngle(45);
158template<cbm::algo::ca::EDetectorID DetID>
163 int nHits =
fvpBrHits[DetID]->GetEntriesFast();
166 for (
int iH = 0; iH < nHits; ++iH) {
167 const auto* pHit =
dynamic_cast<const Hit_t*
>(
fvpBrHits[DetID]->At(iH));
169 LOG(warn) << fName <<
": hit with iH = " << iH <<
" for detector " <<
kDetName[DetID] <<
" is not found";
171 auto address = pHit->GetAddress();
180 int iStLoc = pDetIfs->GetTrackingStationId(address);
185 int iStGeo =
fpParameters->GetStationIndexGeometry(iStLoc, DetID);
186 auto xHit = pHit->GetX();
187 auto yHit = pHit->GetY();
188 auto zHit = pHit->GetZ();
189 if (
fvXmin[DetID][iStLoc] > xHit) {
190 fvXmin[DetID][iStLoc] = xHit;
192 if (
fvXmax[DetID][iStLoc] < xHit) {
193 fvXmax[DetID][iStLoc] = xHit;
195 if (
fvYmin[DetID][iStLoc] > yHit) {
196 fvYmin[DetID][iStLoc] = yHit;
198 if (
fvYmax[DetID][iStLoc] < yHit) {
199 fvYmax[DetID][iStLoc] = yHit;
201 if (
fvZmin[DetID][iStLoc] > zHit) {
202 fvZmin[DetID][iStLoc] = zHit;
204 if (
fvZmax[DetID][iStLoc] < zHit) {
205 fvZmax[DetID][iStLoc] = zHit;
218 for (
int iE = 0; iE < nMCevents; ++iE) {
221 int nPoints =
fvpBrPoints[DetID]->Size(iFile, iEvent);
223 for (
int iP = 0; iP < nPoints; ++iP) {
224 const auto* pPoint =
dynamic_cast<const McPoint_t*
>(
fvpBrPoints[DetID]->Get(iFile, iEvent, iP));
226 LOG(error) << fName <<
": point with iFile=" << iFile <<
", iEvent=" << iEvent <<
", iP=" << iP
227 <<
" for detector " <<
kDetName[DetID] <<
" is not found";
230 auto address = pPoint->GetDetectorID();
232 int iStLoc = pDetIfs->GetTrackingStationId(address);
237 int iStGeo =
fpParameters->GetStationIndexGeometry(iStLoc, DetID);
238 auto xPoint = pPoint->FairMCPoint::GetX();
239 auto yPoint = pPoint->FairMCPoint::GetY();
240 auto zPoint = pPoint->FairMCPoint::GetZ();
280 LOG(info) << fName <<
": initializing... ";
287 auto pFairManager = FairRootManager::Instance();
288 assert(pFairManager);
297 throw std::runtime_error(
"RecoSetupManager was not initialize. Please, add it as task to your macro");
305 using Unit_t = std::remove_reference_t<std::remove_cv_t<
decltype(unit)>>;
310 int nSt = unit.GetNofTrackingStations();
311 fvXmin[DetId].resize(nSt, std::numeric_limits<double>::max());
312 fvXmax[DetId].resize(nSt, std::numeric_limits<double>::lowest());
313 fvYmin[DetId].resize(nSt, std::numeric_limits<double>::max());
314 fvYmax[DetId].resize(nSt, std::numeric_limits<double>::lowest());
315 fvZmin[DetId].resize(nSt, std::numeric_limits<double>::max());
316 fvZmax[DetId].resize(nSt, std::numeric_limits<double>::lowest());
321 fvpBrHits[detID] =
dynamic_cast<TClonesArray*
>(pFairManager->GetObject(brName));
326 return static_cast<bool>(
fvpBrHits[detID]);
329 auto InitPointBranch = [&](
const char* brName,
ca::EDetectorID detID) {
331 fvpBrPoints[detID] = pMcManager->InitBranch(brName);
375 constexpr int kNbinsZ = 300;
376 constexpr int kNbinsX = 200;
377 constexpr int kNbinsY = 200;
378 constexpr float kMinZ = -5.;
379 constexpr float kMaxZ = 350.;
380 constexpr float kMinX = -100.;
381 constexpr float kMaxX = 100.;
382 constexpr float kMinY = -100.;
383 constexpr float kMaxY = 100.;
385 for (
int iStGeo = 0; iStGeo <= nStGeo; ++iStGeo) {
386 auto [detID, iStLoc] =
fpParameters->GetStationIndexLocal(iStGeo);
390 TString sNsuff = (iStGeo == nStGeo) ?
"" : Form(
"_st_%s%d",
kDetName[detID], iStLoc);
391 TString sTsuff = (iStGeo == nStGeo) ?
"" : Form(
" in %s station %d",
kDetName[detID], iStLoc);
394 sF = Form(
"hit_occupancy%s", ((iStGeo == nStGeo) ?
"" : Form(
"/%s",
kDetName[detID])));
395 sN = Form(
"hit_xz%s", sNsuff.Data());
396 sT = Form(
"hit occupancy in xz-plane%s;z_{hit} [cm];x_{hit} [cm]", sTsuff.Data());
399 sN = Form(
"hit_yz%s", sNsuff.Data());
400 sT = Form(
"hit occupancy in yz-plane%s;z_{hit} [cm];y_{hit} [cm]", sTsuff.Data());
403 if (iStGeo < nStGeo) {
404 sN = Form(
"hit_xy%s", sNsuff.Data());
405 sT = Form(
"hit occupancy in xy-plane%s;x_{hit} [cm];y_{hit} [cm]", sTsuff.Data());
411 sF = Form(
"point_occupancy%s", ((iStGeo == nStGeo) ?
"" : Form(
"/%s",
kDetName[detID])));
412 sN = Form(
"point_xz%s", sNsuff.Data());
413 sT = Form(
"point occupancy in xz-plane%s;z_{point} [cm];x_{point} [cm]", sTsuff.Data());
416 sN = Form(
"point_yz%s", sNsuff.Data());
417 sT = Form(
"point occupancy in yz-plane%s;z_{point} [cm];y_{point} [cm]", sTsuff.Data());
420 if (iStGeo < nStGeo) {
421 sN = Form(
"point_xy%s", sNsuff.Data());
422 sT = Form(
"point occupancy in xy-plane%s;x_{point} [cm];y_{point} [cm]", sTsuff.Data());
429 auto CreateMaterialBudgetHistograms = [&](
const auto& kfSetup,
const TString& dir) {
430 for (
int iLayer = 0; iLayer < kfSetup.GetNofLayers(); ++iLayer) {
431 const auto& matMap{kfSetup.GetMaterial(iLayer)};
432 auto [detID, stationID] = kfSetup.GetIndexMap().GlobalToLocal(iLayer);
433 TString sN = Form(
"%s/mat_budget_%s_st%d", dir.Data(),
kDetName[detID], stationID);
435 Form(
"Material budget map for %s station %d;x [cm];y [cm]; X/X_{0} [%%]",
kDetName[detID], stationID);
436 auto nBins{matMap.GetNbins()};
437 auto xMin{-matMap.GetXYmax()};
438 auto xMax{+matMap.GetXYmax()};
440 for (
int iX = 0; iX < nBins; ++iX) {
441 for (
int iY = 0; iY < nBins; ++iY) {
442 pHist->SetBinContent(iX + 1, iY + 1, 100. * matMap.template GetBinThicknessX0<float>(iX, iY));
450 CreateMaterialBudgetHistograms(
fpParameters->GetGeometrySetup(),
"TrackingKFSetup/geometry");
452 CreateMaterialBudgetHistograms(
fpParameters->GetActiveSetup(),
"TrackingKFSetup/active");
454 LOG(info) << fName <<
": initializing... \033[1;32mDone\033[0m";
457catch (
const std::exception& e) {
458 LOG(error) << fName <<
": initializing... \033[1;31mFailed\033[0m\nReason: " << e.what();
Handles an instance of the CA-parameters as a shared pointer (header)
Implementation of L1DetectorID enum class for CBM.
A manager for setup representation in CBM reconstruction.
Task class creating and managing CbmMCDataArray objects.
Container class for MC events with number, file and start time.
T * MakeQaObject(TString sName, TString sTitle, Args... args)
void MakeQaDirectory(TString sName)
CbmQaTask(const char *name, int verbose, bool isMCUsed, ECbmRecoMode recoMode=ECbmRecoMode::Timeslice)
Constructor from parameters.
bool IsMCUsed() const
Returns flag, whether MC information is used or not in the task.
void PutSetupNameOnPad(double xMin, double yMin, double xMax, double yMax)
Puts setup title on the canvas.
static CbmSetup * Instance()
static int32_t GetSmType(uint32_t address)
const algo::RecoSetup & GetSetup() const
Setup accessor.
static RecoSetupManager * Instance()
Instance access.
void ForEachUnit(Visitor &&visitor) const
A for-each method, which is applied to each unit, if it has a value (constant access)
const RecoSetupUnit_t< ModuleId > * Get() const
Access to a reconstruction setup unit.
A container for all external parameters of the CA tracking algorithm.
static ParametersHandler & Instance()
Instance.
ParametersPtr_t Get() const
Accessor to the parameters shared pointer.
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
constexpr ECbmModuleId ToCbmModuleId(EDetectorID detID)
Conversion map from EDetectorID to ECbmModuleId.
constexpr EDetectorID ToCaDetectorID(ECbmModuleId modId)
Conversion map from EDetectorID to ECbmModuleId.
constexpr DetIdArr_t< const char * > kDetName
Names of detector subsystems.
std::tuple_element_t< static_cast< std::size_t >(DetID), std::tuple< Types... > > at