Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 20 additions & 46 deletions PWGLF/TableProducer/Common/kinkBuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,9 @@
Configurable<bool> unlikeSignBkg{"unlikeSignBkg", false, "Use unlike sign background"};

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

// PDG codes

Expand Down Expand Up @@ -174,7 +171,6 @@
ccdb->setURL(ccdbPath);
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setFatalWhenNull(false);
fitter.setPropagateToPCA(true);
fitter.setMaxR(200.);
fitter.setMinParamChange(1e-3);
Expand All @@ -183,10 +179,6 @@
fitter.setMaxChi2(1e9);
fitter.setUseAbsDCA(true);

lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
int mat{static_cast<int>(cfgMaterialCorrection)};
fitter.setMatCorrType(static_cast<o2::base::Propagator::MatCorrType>(mat));

svCreator.setTimeMargin(customVertexerTimeMargin);
if (skipAmbiTracks) {
svCreator.setSkipAmbiTracks();
Expand All @@ -210,13 +202,18 @@
h2MothMassPt = qaRegistry.add<TH2>("h2MothMassPt", "; p_{T} (GeV/#it{c}); m (GeV/#it{c}^{2})", HistType::kTH2F, {ptAxis, massAxis});
h2ClsMapPtMoth = qaRegistry.add<TH2>("h2ClsMapPtMoth", "; p_{T} (GeV/#it{c}); ITS cluster map", HistType::kTH2F, {ptAxis, itsClusterMapAxis});
h2ClsMapPtDaug = qaRegistry.add<TH2>("h2ClsMapPtDaug", "; p_{T} (GeV/#it{c}); ITS cluster map", HistType::kTH2F, {ptAxis, itsClusterMapAxis});

for (int i = 0; i < 5; i++) {

Check failure on line 206 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i));
}
mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution");
}

template <typename T>
bool selectMothTrack(const T& candidate)
{
if (candidate.has_collision() && candidate.hasITS() && !candidate.hasTPC() && !candidate.hasTOF() && candidate.itsNCls() < 6 &&

Check failure on line 215 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
candidate.itsNClsInnerBarrel() == 3 && candidate.itsChi2NCl() < 36 && candidate.pt() > minPtMoth) {

Check failure on line 216 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return true;
}
return false;
Expand All @@ -234,8 +231,8 @@
}

bool isGoodTPCCand = false;
if (candidate.itsNClsInnerBarrel() == 0 && candidate.itsNCls() < 4 &&

Check failure on line 234 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
candidate.tpcNClsCrossedRows() > 0.8 * candidate.tpcNClsFindable() && candidate.tpcNClsFound() > nTPCClusMinDaug) {

Check failure on line 235 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
isGoodTPCCand = true;
}

Expand All @@ -247,7 +244,7 @@
}

template <class Tcolls, class Ttracks>
void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCsWithTimestamps const& bcs)
void fillCandidateData(const Tcolls& collisions, const Ttracks& tracks, aod::AmbiguousTracks const& ambiguousTracks, aod::BCs const& bcs)
{
svCreator.clearPools();
svCreator.fillBC2Coll(collisions, bcs);
Expand All @@ -274,7 +271,7 @@
auto trackDaug = tracks.rawIteratorAt(svCand.tr1Idx);

auto const& collision = trackMoth.template collision_as<Tcolls>();
auto const& bc = collision.template bc_as<aod::BCsWithTimestamps>();
auto const& bc = collision.template bc_as<aod::BCs>();
initCCDB(bc);

o2::dataformats::VertexBase primaryVertex;
Expand All @@ -283,9 +280,9 @@
kinkCand.primVtx = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()};

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

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

Expand Down Expand Up @@ -338,13 +335,13 @@

// get last layer hitted by the mother and the first layer hitted by the daughter
int lastLayerMoth = 0, firstLayerDaug = 0;
for (int i = 0; i < 7; i++) {

Check failure on line 338 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (trackMoth.itsClusterMap() & (1 << i)) {
lastLayerMoth = i;
}
}

for (int i = 0; i < 7; i++) {

Check failure on line 344 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (trackDaug.itsClusterMap() & (1 << i)) {
firstLayerDaug = i;
break;
Expand All @@ -359,13 +356,13 @@
continue;
}

for (int i = 0; i < 3; i++) {

Check failure on line 359 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
kinkCand.decVtx[i] -= kinkCand.primVtx[i];
}

propMothTrack.getPxPyPzGlo(kinkCand.momMoth);
propDaugTrack.getPxPyPzGlo(kinkCand.momDaug);
for (int i = 0; i < 3; i++) {

Check failure on line 365 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
kinkCand.momMoth[i] *= charge;
kinkCand.momDaug[i] *= charge;
}
Expand All @@ -375,7 +372,7 @@
kinkCand.kinkAngle = std::acos(spKink / (pMoth * pDaug));

std::array<float, 3> neutDauMom{0.f, 0.f, 0.f};
for (int i = 0; i < 3; i++) {

Check failure on line 375 in PWGLF/TableProducer/Common/kinkBuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
neutDauMom[i] = kinkCand.momMoth[i] - kinkCand.momDaug[i];
}

Expand All @@ -401,51 +398,28 @@
}
}

void initCCDB(aod::BCsWithTimestamps::iterator const& bc)
void initCCDB(aod::BCs::iterator const& bc)
{
if (mRunNumber == bc.runNumber()) {
return;
}
auto run3grp_timestamp = bc.timestamp();

o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(grpPath, run3grp_timestamp);
o2::parameters::GRPMagField* grpmag = 0x0;
if (grpo) {
o2::base::Propagator::initFieldFromGRP(grpo);
if (inputBz < -990) {
// Fetch magnetic field from ccdb for current collision
mBz = grpo->getNominalL3Field();
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG";
} else {
mBz = inputBz;
}
} else {
grpmag = ccdb->getForTimeStamp<o2::parameters::GRPMagField>(grpmagPath, run3grp_timestamp);
if (!grpmag) {
LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp;
}
o2::base::Propagator::initFieldFromGRP(grpmag);
if (inputBz < -990) {
// Fetch magnetic field from ccdb for current collision
mBz = std::lround(5.f * grpmag->getL3Current() / 30000.f);
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << mBz << " kZG";
} else {
mBz = inputBz;
}
}
mRunNumber = bc.runNumber();
LOG(info) << "Initializing CCDB for run " << mRunNumber;
o2::parameters::GRPMagField* grpmag = ccdb->getForRun<o2::parameters::GRPMagField>(grpmagPath, mRunNumber);
o2::base::Propagator::initFieldFromGRP(grpmag);
mBz = grpmag->getNominalL3Field();
fitter.setBz(mBz);

for (int i = 0; i < 5; i++) {
mBBparamsDaug[i] = cfgBetheBlochParams->get("Daughter", Form("p%i", i));
if (!lut) {
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
int mat{static_cast<int>(cfgMaterialCorrection)};
fitter.setMatCorrType(static_cast<o2::base::Propagator::MatCorrType>(mat));
}
mBBparamsDaug[5] = cfgBetheBlochParams->get("Daughter", "resolution");

fitter.setBz(mBz);
mRunNumber = bc.runNumber();
o2::base::Propagator::Instance()->setMatLUT(lut);
LOG(info) << "Task initialized for run " << mRunNumber << " with magnetic field " << mBz << " kZG";
}

void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const& bcs)
void process(aod::Collisions const& collisions, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCs const& bcs)
{

kinkCandidates.clear();
Expand Down
18 changes: 9 additions & 9 deletions PWGLF/Utils/svPoolCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ class svPoolCreator
o2::vertexing::DCAFitterN<2>* getFitter() { return &fitter; }
std::array<std::vector<TrackCand>, 4> getTrackCandPool() { return trackCandPool; }

template <typename C>
void fillBC2Coll(const C& collisions, aod::BCsWithTimestamps const&)
template <typename C, typename BC>
void fillBC2Coll(const C& collisions, BC const&)
{
for (unsigned i = 0; i < collisions.size(); i++) {
auto collision = collisions.rawIteratorAt(i);
if (!collision.has_bc()) {
continue;
}
bc2Coll[collision.template bc_as<aod::BCsWithTimestamps>().globalBC()] = i;
bc2Coll[collision.template bc_as<BC>().globalBC()] = i;
}
}

template <typename T, typename C>
void appendTrackCand(const T& trackCand, const C& collisions, int pdgHypo, o2::aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const&)
template <typename T, typename C, typename BC>
void appendTrackCand(const T& trackCand, const C& collisions, int pdgHypo, o2::aod::AmbiguousTracks const& ambiTracks, BC const&)
{
if (pdgHypo != track0Pdg && pdgHypo != track1Pdg) {
LOG(debug) << "Wrong pdg hypothesis";
Expand All @@ -97,18 +97,18 @@ class svPoolCreator
uint64_t globalBC = BcInvalid;
if (trackCand.has_collision()) {
if (trackCand.template collision_as<C>().has_bc()) {
globalBC = trackCand.template collision_as<C>().template bc_as<aod::BCsWithTimestamps>().globalBC();
globalBC = trackCand.template collision_as<C>().template bc_as<BC>().globalBC();
}
} else if (!skipAmbiTracks) {
for (const auto& ambTrack : ambiTracks) {
if (ambTrack.trackId() != trackCand.globalIndex()) {
continue;
}
if (!ambTrack.has_bc() || ambTrack.bc_as<aod::BCsWithTimestamps>().size() == 0) {
if (!ambTrack.has_bc() || ambTrack.bc_as<BC>().size() == 0) {
globalBC = BcInvalid;
break;
}
globalBC = ambTrack.bc_as<aod::BCsWithTimestamps>().begin().globalBC();
globalBC = ambTrack.bc_as<BC>().begin().globalBC();
break;
}
} else {
Expand All @@ -134,7 +134,7 @@ class svPoolCreator
const auto& collision = collisions.rawIteratorAt(i);
float collTime = collision.collisionTime();
float collTimeRes2 = collision.collisionTimeRes() * collision.collisionTimeRes();
uint64_t collBC = collision.template bc_as<aod::BCsWithTimestamps>().globalBC();
uint64_t collBC = collision.template bc_as<BC>().globalBC();
int collIdx = collision.globalIndex();
int64_t bcOffset = globalBC - static_cast<int64_t>(collBC);
if (static_cast<uint64_t>(std::abs(bcOffset)) > bOffsetMax) {
Expand Down
Loading