Skip to content

Commit 863dd60

Browse files
authored
[PWGLF] feat(kinkBuilder): use aod::BCs instead of aod::BCsWithTimestamps (#11460)
1 parent 1545b2d commit 863dd60

File tree

2 files changed

+29
-55
lines changed

2 files changed

+29
-55
lines changed

PWGLF/TableProducer/Common/kinkBuilder.cxx

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,9 @@ struct kinkBuilder {
122122
Configurable<bool> unlikeSignBkg{"unlikeSignBkg", false, "Use unlike sign background"};
123123

124124
// CCDB options
125-
Configurable<double> inputBz{"inputBz", -999, "bz field, -999 is automatic"};
126125
Configurable<std::string> ccdbPath{"ccdbPath", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
127-
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
128126
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
129127
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
130-
Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
131128

132129
// PDG codes
133130

@@ -174,7 +171,6 @@ struct kinkBuilder {
174171
ccdb->setURL(ccdbPath);
175172
ccdb->setCaching(true);
176173
ccdb->setLocalObjectValidityChecking();
177-
ccdb->setFatalWhenNull(false);
178174
fitter.setPropagateToPCA(true);
179175
fitter.setMaxR(200.);
180176
fitter.setMinParamChange(1e-3);
@@ -183,10 +179,6 @@ struct kinkBuilder {
183179
fitter.setMaxChi2(1e9);
184180
fitter.setUseAbsDCA(true);
185181

186-
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
187-
int mat{static_cast<int>(cfgMaterialCorrection)};
188-
fitter.setMatCorrType(static_cast<o2::base::Propagator::MatCorrType>(mat));
189-
190182
svCreator.setTimeMargin(customVertexerTimeMargin);
191183
if (skipAmbiTracks) {
192184
svCreator.setSkipAmbiTracks();
@@ -210,6 +202,11 @@ struct kinkBuilder {
210202
h2MothMassPt = qaRegistry.add<TH2>("h2MothMassPt", "; p_{T} (GeV/#it{c}); m (GeV/#it{c}^{2})", HistType::kTH2F, {ptAxis, massAxis});
211203
h2ClsMapPtMoth = qaRegistry.add<TH2>("h2ClsMapPtMoth", "; p_{T} (GeV/#it{c}); ITS cluster map", HistType::kTH2F, {ptAxis, itsClusterMapAxis});
212204
h2ClsMapPtDaug = qaRegistry.add<TH2>("h2ClsMapPtDaug", "; p_{T} (GeV/#it{c}); ITS cluster map", HistType::kTH2F, {ptAxis, itsClusterMapAxis});
205+
206+
for (int i = 0; i < 5; i++) {
207+
mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i));
208+
}
209+
mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution");
213210
}
214211

215212
template <typename T>
@@ -247,7 +244,7 @@ struct kinkBuilder {
247244
}
248245

249246
template <class Tcolls, class Ttracks>
250-
void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCsWithTimestamps const& bcs)
247+
void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCs const& bcs)
251248
{
252249
svCreator.clearPools();
253250
svCreator.fillBC2Coll(collisions, bcs);
@@ -274,7 +271,7 @@ struct kinkBuilder {
274271
auto trackDaug = tracks.rawIteratorAt(svCand.tr1Idx);
275272

276273
auto const& collision = trackMoth.template collision_as<Tcolls>();
277-
auto const& bc = collision.template bc_as<aod::BCsWithTimestamps>();
274+
auto const& bc = collision.template bc_as<aod::BCs>();
278275
initCCDB(bc);
279276

280277
o2::dataformats::VertexBase primaryVertex;
@@ -283,9 +280,9 @@ struct kinkBuilder {
283280
kinkCand.primVtx = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()};
284281

285282
o2::track::TrackParCov trackParCovMoth = getTrackParCov(trackMoth);
283+
o2::track::TrackParCov trackParCovMothPV{trackParCovMoth};
286284
o2::base::Propagator::Instance()->PropagateToXBxByBz(trackParCovMoth, LayerRadii[trackMoth.itsNCls() - 1]);
287285

288-
o2::track::TrackParCov trackParCovMothPV = getTrackParCov(trackMoth);
289286
std::array<float, 2> dcaInfoMoth;
290287
o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovMothPV, 2.f, static_cast<o2::base::Propagator::MatCorrType>(cfgMaterialCorrection.value), &dcaInfoMoth);
291288

@@ -401,51 +398,28 @@ struct kinkBuilder {
401398
}
402399
}
403400

404-
void initCCDB(aod::BCsWithTimestamps::iterator const& bc)
401+
void initCCDB(aod::BCs::iterator const& bc)
405402
{
406403
if (mRunNumber == bc.runNumber()) {
407404
return;
408405
}
409-
auto run3grp_timestamp = bc.timestamp();
410-
411-
o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(grpPath, run3grp_timestamp);
412-
o2::parameters::GRPMagField* grpmag = 0x0;
413-
if (grpo) {
414-
o2::base::Propagator::initFieldFromGRP(grpo);
415-
if (inputBz < -990) {
416-
// Fetch magnetic field from ccdb for current collision
417-
mBz = grpo->getNominalL3Field();
418-
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG";
419-
} else {
420-
mBz = inputBz;
421-
}
422-
} else {
423-
grpmag = ccdb->getForTimeStamp<o2::parameters::GRPMagField>(grpmagPath, run3grp_timestamp);
424-
if (!grpmag) {
425-
LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp;
426-
}
427-
o2::base::Propagator::initFieldFromGRP(grpmag);
428-
if (inputBz < -990) {
429-
// Fetch magnetic field from ccdb for current collision
430-
mBz = std::lround(5.f * grpmag->getL3Current() / 30000.f);
431-
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG";
432-
} else {
433-
mBz = inputBz;
434-
}
435-
}
406+
mRunNumber = bc.runNumber();
407+
LOG(info) << "Initializing CCDB for run " << mRunNumber;
408+
o2::parameters::GRPMagField* grpmag = ccdb->getForRun<o2::parameters::GRPMagField>(grpmagPath, mRunNumber);
409+
o2::base::Propagator::initFieldFromGRP(grpmag);
410+
mBz = grpmag->getNominalL3Field();
411+
fitter.setBz(mBz);
436412

437-
for (int i = 0; i < 5; i++) {
438-
mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i));
413+
if (!lut) {
414+
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
415+
int mat{static_cast<int>(cfgMaterialCorrection)};
416+
fitter.setMatCorrType(static_cast<o2::base::Propagator::MatCorrType>(mat));
439417
}
440-
mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution");
441-
442-
fitter.setBz(mBz);
443-
mRunNumber = bc.runNumber();
444418
o2::base::Propagator::Instance()->setMatLUT(lut);
445419
LOG(info) << "Task initialized for run " << mRunNumber << " with magnetic field " << mBz << " kZG";
446420
}
447421

448-
void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const& bcs)
422+
void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCs const& bcs)
449423
{
450424

451425
kinkCandidates.clear();

PWGLF/Utils/svPoolCreator.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ class svPoolCreator
7373
o2::vertexing::DCAFitterN<2>* getFitter() { return &fitter; }
7474
std::array<std::vector<TrackCand>, 4> getTrackCandPool() { return trackCandPool; }
7575

76-
template <typename C>
77-
void fillBC2Coll(const C& collisions, aod::BCsWithTimestamps const&)
76+
template <typename C, typename BC>
77+
void fillBC2Coll(const C& collisions, BC const&)
7878
{
7979
for (unsigned i = 0; i < collisions.size(); i++) {
8080
auto collision = collisions.rawIteratorAt(i);
8181
if (!collision.has_bc()) {
8282
continue;
8383
}
84-
bc2Coll[collision.template bc_as<aod::BCsWithTimestamps>().globalBC()] = i;
84+
bc2Coll[collision.template bc_as<BC>().globalBC()] = i;
8585
}
8686
}
8787

88-
template <typename T, typename C>
89-
void appendTrackCand(const T& trackCand, const C& collisions, int pdgHypo, o2::aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const&)
88+
template <typename T, typename C, typename BC>
89+
void appendTrackCand(const T& trackCand, const C& collisions, int pdgHypo, o2::aod::AmbiguousTracks const& ambiTracks, BC const&)
9090
{
9191
if (pdgHypo != track0Pdg && pdgHypo != track1Pdg) {
9292
LOG(debug) << "Wrong pdg hypothesis";
@@ -97,18 +97,18 @@ class svPoolCreator
9797
uint64_t globalBC = BcInvalid;
9898
if (trackCand.has_collision()) {
9999
if (trackCand.template collision_as<C>().has_bc()) {
100-
globalBC = trackCand.template collision_as<C>().template bc_as<aod::BCsWithTimestamps>().globalBC();
100+
globalBC = trackCand.template collision_as<C>().template bc_as<BC>().globalBC();
101101
}
102102
} else if (!skipAmbiTracks) {
103103
for (const auto& ambTrack : ambiTracks) {
104104
if (ambTrack.trackId() != trackCand.globalIndex()) {
105105
continue;
106106
}
107-
if (!ambTrack.has_bc() || ambTrack.bc_as<aod::BCsWithTimestamps>().size() == 0) {
107+
if (!ambTrack.has_bc() || ambTrack.bc_as<BC>().size() == 0) {
108108
globalBC = BcInvalid;
109109
break;
110110
}
111-
globalBC = ambTrack.bc_as<aod::BCsWithTimestamps>().begin().globalBC();
111+
globalBC = ambTrack.bc_as<BC>().begin().globalBC();
112112
break;
113113
}
114114
} else {
@@ -134,7 +134,7 @@ class svPoolCreator
134134
const auto& collision = collisions.rawIteratorAt(i);
135135
float collTime = collision.collisionTime();
136136
float collTimeRes2 = collision.collisionTimeRes() * collision.collisionTimeRes();
137-
uint64_t collBC = collision.template bc_as<aod::BCsWithTimestamps>().globalBC();
137+
uint64_t collBC = collision.template bc_as<BC>().globalBC();
138138
int collIdx = collision.globalIndex();
139139
int64_t bcOffset = globalBC - static_cast<int64_t>(collBC);
140140
if (static_cast<uint64_t>(std::abs(bcOffset)) > bOffsetMax) {

0 commit comments

Comments
 (0)