Skip to content

Commit

Permalink
Merge branch 'dev' into refactor-analysis-managers
Browse files Browse the repository at this point in the history
  • Loading branch information
aalkin authored Feb 19, 2025
2 parents 5e06f1d + 3d967a1 commit ca45495
Show file tree
Hide file tree
Showing 29 changed files with 830 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <TStopwatch.h>
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h"
#include "DataFormatsITSMFT/TrkClusRef.h"
#include "DataFormatsCalibration/MeanVertexObject.h"
#include "ReconstructionDataFormats/TrackTPCITS.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"
Expand Down Expand Up @@ -113,7 +114,8 @@ void PrimaryVertexingSpec::run(ProcessingContext& pc)
return true; // just in case this selection was not done on RecoContainer filling level
}
auto itsID = recoData.getITSContributorGID(_origID);
if (!itsID.isSourceSet() || o2::math_utils::numberOfBitsSet(recoData.getITSTrack(itsID).getPattern() & 7) < minIBHits) {
if ((itsID.getSource() == GTrackID::ITS && o2::math_utils::numberOfBitsSet(recoData.getITSTrack(itsID).getPattern() & 7) < minIBHits) ||
(itsID.getSource() == GTrackID::ITSAB && o2::math_utils::numberOfBitsSet(recoData.getITSABRef(itsID).pattern & 7) < minIBHits)) { // do not accept ITSAB tracklets
return true;
}
if constexpr (isITSTrack<decltype(_tr)>()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct TrackingParameters {
int CellMinimumLevel();
int CellsPerRoad() const { return NLayers - 2; }
int TrackletsPerRoad() const { return NLayers - 1; }
std::string asString() const;

int NLayers = 7;
int DeltaROF = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper<VertexerPa

struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerParamConfig> {
// Use TGeo for mat. budget
static const int MaxIter = 4;
static const int MinTrackLenght = 4;
static const int MaxTrackLenght = 7;
bool useMatCorrTGeo = false; // use full geometry to corect for material budget accounting in the fits. Default is to use the material budget LUT.
bool useFastMaterial = false; // use faster material approximation for material budget accounting in the fits.
int deltaRof = 0; // configure the width of the window in ROFs to be considered for the tracking.
int minTrackLgtIter[MaxIter] = {}; // minimum track length at each iteration, used only if >0, otherwise use code defaults
float minPtIterLgt[MaxIter * (MaxTrackLenght - MinTrackLenght + 1)] = {}; // min.pT for given track length at this iteration, used only if >0, otherwise use code defaults
float sysErrY2[7] = {0}; // systematic error^2 in Y per layer
float sysErrZ2[7] = {0}; // systematic error^2 in Z per layer
float maxChi2ClusterAttachment = -1.f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class ITSTrackingInterface
mMode = mode;
}

auto getTracker() const { return mTracker.get(); }
auto getVertexer() const { return mVertexer.get(); }

TimeFrame* mTimeFrame = nullptr;

protected:
Expand Down
24 changes: 23 additions & 1 deletion Detectors/ITSMFT/ITS/tracking/src/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,31 @@ std::string asString(TrackingMode mode)
return "unknown";
}

std::string TrackingParameters::asString() const
{
std::string str = fmt::format("NZb:{} NPhB:{} NROFIt:{} PerVtx:{} DropFail:{} ClSh:{} TtklMinPt:{:.2f} MinCl:{}",
ZBins, PhiBins, nROFsPerIterations, PerPrimaryVertexProcessing, DropTFUponFailure, ClusterSharing, TrackletMinPt, MinTrackLength);
bool first = true;
for (int il = NLayers; il >= MinTrackLength; il--) {
int slot = NLayers - il;
if (slot < (int)MinPt.size() && MinPt[slot] > 0) {
if (first) {
first = false;
str += " MinPt: ";
}
str += fmt::format("L{}:{:.2f} ", il, MinPt[slot]);
}
}
str += " SystErrY/Z:";
for (size_t i = 0; i < SystErrorY2.size(); i++) {
str += fmt::format("{:.2e}/{:.2e} ", SystErrorY2[i], SystErrorZ2[i]);
}
return str;
}

std::ostream& operator<<(std::ostream& os, TrackingMode v)
{
os << asString(v);
return os;
}
} // namespace o2::its
} // namespace o2::its
1 change: 0 additions & 1 deletion Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ void Tracker::rectifyClusterIndices()
void Tracker::getGlobalConfiguration()
{
auto& tc = o2::its::TrackerParamConfig::Instance();
tc.printKeyValues(true, true);
if (tc.useMatCorrTGeo) {
mTraits->setCorrType(o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrTGeo);
} else if (tc.useFastMaterial) {
Expand Down
57 changes: 52 additions & 5 deletions Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "CommonDataFormat/IRFrame.h"
#include "DetectorsBase/GRPGeomHelper.h"
#include "ITStracking/TrackingConfigParam.h"
#include "Framework/DeviceSpec.h"

namespace o2
{
Expand All @@ -35,31 +36,55 @@ void ITSTrackingInterface::initialise()
mCosmicsProcessing = false;
std::vector<VertexingParameters> vertParams;
std::vector<TrackingParameters> trackParams;
const auto& trackConf = o2::its::TrackerParamConfig::Instance();
float bFactor = std::abs(o2::base::Propagator::Instance()->getNominalBz()) / 5.0066791;
if (mMode == TrackingMode::Unset) {
mMode = (TrackingMode)(o2::its::TrackerParamConfig::Instance().trackingMode);
mMode = (TrackingMode)(trackConf.trackingMode);
LOGP(info, "Tracking mode not set, trying to fetch it from configurable params to: {}", asString(mMode));
}
if (mMode == TrackingMode::Async) {
trackParams.resize(o2::its::TrackerParamConfig::Instance().doUPCIteration ? 4 : 3);
trackParams.resize(trackConf.doUPCIteration ? 4 : 3);
vertParams.resize(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice
trackParams[1].TrackletMinPt = 0.2f;
trackParams[1].CellDeltaTanLambdaSigma *= 2.;
trackParams[2].TrackletMinPt = 0.1f;
trackParams[2].CellDeltaTanLambdaSigma *= 4.;

trackParams[0].MinPt[0] = 1.f / 12; // 7cl

trackParams[1].MinPt[0] = 1.f / 12; // 7cl

trackParams[2].MinTrackLength = 4;
trackParams[2].MinPt[3] = 0.2f;
trackParams[2].MinPt[0] = 1.f / 12; // 7cl
trackParams[2].MinPt[1] = 1.f / 5; // 6cl
trackParams[2].MinPt[2] = 1.f / 1; // 5cl
trackParams[2].MinPt[3] = 1.f / 6; // 4cl

trackParams[2].StartLayerMask = (1 << 6) + (1 << 3);
if (o2::its::TrackerParamConfig::Instance().doUPCIteration) {
trackParams[3].MinTrackLength = 4;
trackParams[3].TrackletMinPt = 0.1f;
trackParams[3].CellDeltaTanLambdaSigma *= 4.;
trackParams[3].MinTrackLength = 4;
trackParams[3].DeltaROF = 0; // UPC specific setting
}
for (auto& param : trackParams) {
for (size_t ip = 0; ip < trackParams.size(); ip++) {
auto& param = trackParams[ip];
param.ZBins = 64;
param.PhiBins = 32;
param.CellsPerClusterLimit = 1.e3f;
param.TrackletsPerClusterLimit = 1.e3f;
// check if something was overridden via configurable params
if (ip < trackConf.MaxIter) {
if (trackConf.minTrackLgtIter[ip] > 0) {
param.MinTrackLength = trackConf.minTrackLgtIter[ip];
}
for (int ilg = trackConf.MaxTrackLenght; ilg >= trackConf.MinTrackLenght; ilg--) {
int lslot0 = (trackConf.MaxTrackLenght - ilg), lslot = lslot0 + ip * (trackConf.MaxTrackLenght - trackConf.MinTrackLenght + 1);
if (trackConf.minPtIterLgt[lslot] > 0.) {
param.MinPt[lslot0] = trackConf.minPtIterLgt[lslot];
}
}
}
}
LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes for tracking and {}/{} for vertexing", trackParams.size(), o2::its::VertexerParamConfig::Instance().nIterations, vertParams.size());
vertParams[1].phiCut = 0.015f;
Expand Down Expand Up @@ -95,6 +120,17 @@ void ITSTrackingInterface::initialise()
for (auto& params : trackParams) {
params.CorrType = o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrLUT;
}

// adjust pT settings to actual mag. field
for (size_t ip = 0; ip < trackParams.size(); ip++) {
auto& param = trackParams[ip];
for (int ilg = trackConf.MaxTrackLenght; ilg >= trackConf.MinTrackLenght; ilg--) {
int lslot = trackConf.MaxTrackLenght - ilg;
param.MinPt[lslot] *= bFactor;
param.TrackletMinPt *= bFactor;
}
}

mTracker->setParameters(trackParams);
mVertexer->setParameters(vertParams);
}
Expand Down Expand Up @@ -345,7 +381,18 @@ void ITSTrackingInterface::updateTimeDependentParams(framework::ProcessingContex
}
GeometryTGeo* geom = GeometryTGeo::Instance();
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::T2GRot, o2::math_utils::TransformType::T2G));
initialise();
getConfiguration(pc);
//
if (pc.services().get<const o2::framework::DeviceSpec>().inputTimesliceId == 0) { // print settings only for the 1st pipeling
o2::its::VertexerParamConfig::Instance().printKeyValues();
o2::its::TrackerParamConfig::Instance().printKeyValues();
const auto& trParams = mTracker->getParameters();
for (size_t it = 0; it < trParams.size(); it++) {
const auto& par = trParams[it];
LOGP(info, "recoIter#{} : {}", it, par.asString());
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ float Vertexer::clustersToVerticesHybrid(std::function<void(std::string s)> logg
void Vertexer::getGlobalConfiguration()
{
auto& vc = o2::its::VertexerParamConfig::Instance();
vc.printKeyValues(true, true);
auto& grc = o2::its::ITSGpuTrackingParamConfig::Instance();

// This is odd: we override only the parameters for the first iteration.
Expand Down
2 changes: 1 addition & 1 deletion Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void TrackerDPL::init(InitContext& ic)
mITSTrackingInterface.setTraitsFromProvider(mChainITS->GetITSVertexerTraits(),
mChainITS->GetITSTrackerTraits(),
mChainITS->GetITSTimeframe());
mITSTrackingInterface.initialise();
// mITSTrackingInterface.initialise() will be called from the ITSTrackingInterface::updateTimeDependentParams at 1st initialization since it needs some run conditions
}

void TrackerDPL::stop()
Expand Down
48 changes: 24 additions & 24 deletions Detectors/MUON/MCH/Align/src/AlignmentSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ class AlignmentTask
}

doReAlign = ic.options().get<bool>("do-realign");
if (doReAlign) {
LOG(info) << "Re-alignment mode";
}

if (mCCDBRequest) {
LOG(info) << "Loading magnetic field and reference geometry from CCDB";
Expand All @@ -181,9 +178,9 @@ class AlignmentTask
LOG(fatal) << "No GRP file";
}

auto geoIdealFile = ic.options().get<string>("geo-file-ideal");
if (std::filesystem::exists(geoIdealFile)) {
base::GeometryManager::loadGeometry(geoIdealFile.c_str());
IdealGeoFileName = ic.options().get<string>("geo-file-ideal");
if (std::filesystem::exists(IdealGeoFileName)) {
base::GeometryManager::loadGeometry(IdealGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
Expand All @@ -193,9 +190,9 @@ class AlignmentTask
LOG(fatal) << "No ideal geometry";
}

auto geoRefFile = ic.options().get<string>("geo-file-ref");
if (std::filesystem::exists(geoRefFile)) {
base::GeometryManager::loadGeometry(geoRefFile.c_str());
RefGeoFileName = ic.options().get<string>("geo-file-ref");
if (std::filesystem::exists(RefGeoFileName)) {
base::GeometryManager::loadGeometry(RefGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
Expand All @@ -204,6 +201,22 @@ class AlignmentTask
} else {
LOG(fatal) << "No reference geometry";
}

if (doReAlign) {
LOG(info) << "Re-alignment mode";
LOG(info) << "Loading re-alignment geometry";
NewGeoFileName = ic.options().get<string>("geo-file-new");
if (std::filesystem::exists(NewGeoFileName)) {
base::GeometryManager::loadGeometry(NewGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
transformNew[iDEN] = transformation(iDEN);
}
} else {
LOG(fatal) << "No re-alignment geometry";
}
}
}

auto doEvaluation = ic.options().get<bool>("do-evaluation");
Expand Down Expand Up @@ -387,21 +400,6 @@ class AlignmentTask
}
}

// Load new geometry if we need to do re-align
if (doReAlign) {
if (NewGeoFileName != "") {
LOG(info) << "Loading re-alignment geometry";
base::GeometryManager::loadGeometry(NewGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
transformNew[iDEN] = transformation(iDEN);
}
} else {
LOG(fatal) << "No re-alignment geometry";
}
}

if (!readFromRec) {
// Loading input data
LOG(info) << "Loading MCH tracks";
Expand Down Expand Up @@ -875,6 +873,7 @@ class AlignmentTask
const string mchFileName{"mchtracks.root"};
const string muonFileName{"muontracks.root"};
string outFileName{"Alignment"};
string IdealGeoFileName{""};
string RefGeoFileName{""};
string NewGeoFileName{""};
bool doAlign{false};
Expand Down Expand Up @@ -918,6 +917,7 @@ o2::framework::DataProcessorSpec getAlignmentSpec(bool disableCCDB)
outputSpecs,
AlgorithmSpec{o2::framework::adaptFromTask<AlignmentTask>(ccdbRequest)},
Options{{"geo-file-ref", VariantType::String, o2::base::NameConf::getAlignedGeomFileName(), {"Name of the reference geometry file"}},
{"geo-file-new", VariantType::String, "", {"Name of the new geometry file"}},
{"geo-file-ideal", VariantType::String, o2::base::NameConf::getGeomFileName(), {"Name of the ideal geometry file"}},
{"grp-file", VariantType::String, o2::base::NameConf::getGRPFileName(), {"Name of the grp file"}},
{"do-align", VariantType::Bool, false, {"Switch for alignment, otherwise only residuals will be stored"}},
Expand Down
6 changes: 5 additions & 1 deletion Framework/AnalysisSupport/src/RNTuplePlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Framework/RuntimeError.h"
#include "Framework/RootArrowFilesystem.h"
#include "Framework/Plugins.h"
#include "Framework/FairMQResizableBuffer.h"
#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleWriteOptions.hxx>
#include <ROOT/RNTupleWriter.hxx>
Expand Down Expand Up @@ -852,7 +853,10 @@ struct RNTupleObjectReadingImplementation : public RootArrowFactoryPlugin {
return new RootArrowFactory{
.options = [context]() { return context->format->DefaultWriteOptions(); },
.format = [context]() { return context->format; },
};
.deferredOutputStreamer = [](std::shared_ptr<arrow::dataset::FileFragment> fragment, const std::shared_ptr<arrow::ResizableBuffer>& buffer) -> std::shared_ptr<arrow::io::OutputStream> {
auto treeFragment = std::dynamic_pointer_cast<RNTupleFileFragment>(fragment);
return std::make_shared<FairMQOutputStream>(buffer);
}};
}
};

Expand Down
Loading

0 comments on commit ca45495

Please sign in to comment.