Skip to content

Commit 3da3994

Browse files
Bhawani Singhwiechula
authored andcommitted
[WIP] Adds: O2 DCA histograms in tracks task
1 parent f8df7a1 commit 3da3994

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

Detectors/TPC/qc/include/TPCQC/Tracks.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <string_view>
2222
#include <unordered_map>
2323
#include <memory>
24+
#include "CCDB/CcdbApi.h"
25+
#include "CCDB/BasicCCDBManager.h"
2426

2527
// root includes
2628
#include "TH1.h"
@@ -77,6 +79,13 @@ class Tracks
7779
mCutMinnCls = nClusterCut;
7880
mCutMindEdxTot = dEdxTot;
7981
}
82+
83+
// To set the runNumber
84+
void setRunNumber(int RunNumber)
85+
{
86+
runNumber = RunNumber;
87+
}
88+
8089
// Just for backward compatibility with crrent QC, temporary, will be removed in the next PR
8190
/// get 1D histograms
8291
std::vector<TH1F>& getHistograms1D() { return mHist1D; }
@@ -100,6 +109,7 @@ class Tracks
100109
float mCutAbsEta = 1.f; // Eta cut
101110
int mCutMinnCls = 60; // minimum N clusters
102111
float mCutMindEdxTot = 20.f; // dEdxTot min value
112+
int runNumber = -999; // runNumber
103113
std::unordered_map<std::string_view, std::unique_ptr<TH1>> mMapHist;
104114
std::vector<TH1F> mHist1D{}; ///< Initialize vector of 1D histograms
105115
std::vector<TH2F> mHist2D{}; ///< Initialize vector of 2D histograms

Detectors/TPC/qc/src/Tracks.cxx

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@
2121
// o2 includes
2222
#include "DataFormatsTPC/TrackTPC.h"
2323
#include "DataFormatsTPC/dEdxInfo.h"
24+
#include "GPUCommonArray.h"
25+
#include "DetectorsBase/Propagator.h"
26+
#include "DataFormatsParameters/GRPMagField.h"
27+
#include "TGeoManager.h"
2428
#include "TPCQC/Tracks.h"
2529
#include "TPCQC/Helpers.h"
2630

2731
ClassImp(o2::tpc::qc::Tracks);
2832

2933
using namespace o2::tpc::qc;
30-
34+
// DCA histograms
35+
const std::vector<std::string_view> types{"A_Pos", "A_Neg", "C_Pos", "C_Neg"};
3136
//______________________________________________________________________________
3237
void Tracks::initializeHistograms()
3338
{
@@ -78,6 +83,12 @@ void Tracks::initializeHistograms()
7883
mMapHist["hPhiAsideRatio"] = std::make_unique<TH1F>("hPhiAsideRatio", "Azimuthal angle, A side, ratio neg./pos. ;phi", 360, 0., 2 * M_PI);
7984
mMapHist["hPhiCsideRatio"] = std::make_unique<TH1F>("hPhiCsideRatio", "Azimuthal angle, C side, ratio neg./pos. ;phi", 360, 0., 2 * M_PI);
8085
mMapHist["hPtRatio"] = std::make_unique<TH1F>("hPtRatio", "Transverse momentum, ratio neg./pos. ;p_T", logPtBinning.size() - 1, logPtBinning.data());
86+
87+
// DCA Histograms
88+
for (const auto type : types) {
89+
mMapHist[fmt::format("hDCAr_{}", type).data()] = std::make_unique<TH2F>(fmt::format("hDCAr_{}", type).data(), fmt::format("DCAr {};phi;DCAr (cm)", type).data(), 360, 0, o2::math_utils::twoPid(), 100, -3., 3.);
90+
mMapHist[fmt::format("hDCAz_{}", type).data()] = std::make_unique<TH2F>(fmt::format("hDCAz_{}", type).data(), fmt::format("DCAz {};phi;DCAr (cm)", type).data(), 360, 0, o2::math_utils::twoPid(), 100, -3., 3.);
91+
}
8192
}
8293
//______________________________________________________________________________
8394
void Tracks::resetHistograms()
@@ -117,6 +128,45 @@ bool Tracks::processTrack(const o2::tpc::TrackTPC& track)
117128
mMapHist["hNClustersAfterCuts"]->Fill(nCls);
118129
mMapHist["hEta"]->Fill(eta);
119130

131+
auto& ccdbmgr = o2::ccdb::BasicCCDBManager::instance();
132+
ccdbmgr.setURL("https://alice-ccdb.cern.ch");
133+
auto runDuration = ccdbmgr.getRunDuration(runNumber);
134+
auto tRun = runDuration.first + (runDuration.second - runDuration.first) / 2; // time stamp for the middle of the run duration
135+
ccdbmgr.setTimestamp(tRun);
136+
137+
// CTP orbit reset time
138+
auto orbitResetTimeNS = ccdbmgr.get<std::vector<int64_t>>("CTP/Calib/OrbitReset");
139+
int64_t orbitResetTimeMS = (*orbitResetTimeNS)[0] * 1e-3;
140+
LOGP(info, "Orbit reset time in MS is {}", orbitResetTimeMS);
141+
142+
auto geoAligned = ccdbmgr.get<TGeoManager>("GLO/Config/GeometryAligned");
143+
auto magField = ccdbmgr.get<o2::parameters::GRPMagField>("GLO/Config/GRPMagField");
144+
const o2::base::MatLayerCylSet* matLut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdbmgr.get<o2::base::MatLayerCylSet>("GLO/Param/MatLUT"));
145+
auto propagator = o2::base::Propagator::Instance();
146+
propagator->setMatLUT(matLut);
147+
//---| propagate to 0,0,0 |---
148+
o2::gpu::gpustd::array<float, 2> dca;
149+
const o2::math_utils::Point3D<float> refPoint{0, 0, 0};
150+
//auto propTrack = TrackTPC(track);
151+
o2::track::TrackPar propTrack(track); // Should be cheaper than the one above
152+
bool useThisTrack = true;
153+
if (!propagator->propagateToDCABxByBz(refPoint, propTrack, 0.5, o2::base::Propagator::MatCorrType::USEMatCorrLUT, &dca)) {
154+
useThisTrack = false;
155+
}
156+
///fine grained propagation most probably not needed
157+
if (!propagator->propagateToDCABxByBz(refPoint, propTrack, 0.005, o2::base::Propagator::MatCorrType::USEMatCorrLUT, &dca)) {
158+
useThisTrack = false;
159+
}
160+
161+
if (useThisTrack)
162+
{
163+
// ---| fill histos |---
164+
const int type = (track.getQ2Pt() < 0) + 2 * track.hasCSideClustersOnly();
165+
const auto phi = o2::math_utils::to02PiGen(track.getPhi());
166+
mMapHist[fmt::format("hDCAr_{}", types[type]).data()]->Fill(phi, dca[0]);
167+
mMapHist[fmt::format("hDCAz_{}", types[type]).data()]->Fill(phi, dca[1]);
168+
}
169+
120170
if (hasASideOnly == 1) {
121171
mMapHist["hPhiAside"]->Fill(phi);
122172
} else if (hasCSideOnly == 1) {

0 commit comments

Comments
 (0)