15#include <TObjString.h>
17#include <TStopwatch.h>
56 : mDataRequest(dr), mGGCCDBRequest(gr), mTrackSrc(
src), mSkip(skip), mUseMC(useMC), mValidateWithIR(validateWithIR) {}
66 std::shared_ptr<DataRequest> mDataRequest;
67 std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
72 bool mValidateWithIR{
false};
73 float mITSROFrameLengthMUS = 0.;
74 float mITSROFBiasMUS = 0.;
84 auto dumpDir = ic.
options().
get<std::string>(
"pool-dumps-directory");
86 throw std::runtime_error(fmt::format(
"directory {} for raw data dumps does not exist", dumpDir));
94 double timeCPU0 = mTimer.CpuTime(), timeReal0 = mTimer.RealTime();
96 std::vector<PVertex> vertices;
97 std::vector<GIndex> vertexTrackIDs;
98 std::vector<V2TRef> v2tRefs;
99 std::vector<o2::MCEventLabel> lblVtx;
104 updateTimeDependentParams(pc);
106 std::vector<TrackWithTimeStamp>
tracks;
107 std::vector<o2::MCCompLabel> tracksMCInfo;
108 std::vector<o2d::GlobalTrackID> gids;
112 auto halfROFITS = 0.5 * mITSROFrameLengthMUS + mITSROFBiasMUS;
113 auto hw2ErrITS = 2.f / std::sqrt(12.f) * mITSROFrameLengthMUS;
115 auto creator = [maxTrackTimeError, hw2ErrITS, halfROFITS, trackMaxX, minIBHits, &
tracks, &gids, &recoData](
auto& _tr,
GTrackID _origID,
float t0,
float terr) {
116 if constexpr (isBarrelTrack<decltype(_tr)>()) {
117 if (!_origID.includesDet(DetID::ITS) || _tr.getX() > trackMaxX) {
121 if ((itsID.getSource() ==
GTrackID::ITS && o2::math_utils::numberOfBitsSet(recoData.
getITSTrack(itsID).getPattern() & 7) < minIBHits) ||
125 if constexpr (isITSTrack<decltype(_tr)>()) {
130 if (terr < maxTrackTimeError) {
132 gids.emplace_back(_origID);
144 static std::vector<InteractionCandidate> ft0Data;
145 if (mValidateWithIR) {
149 for (
const auto& ftRP : ft0all) {
152 float(ftRP.getInteractionRecord().differenceInBC(recoData.
startIR) * o2::constants::lhc::LHCBunchSpacingMUS),
153 float(ftRP.getTrigger().getAmplA() + ftRP.getTrigger().getAmplC()),
158 mVertexer.
process(
tracks, gids, ft0Data, vertices, vertexTrackIDs, v2tRefs, tracksMCInfo, lblVtx);
162 std::vector<bool> itsTrUPC(recoData.
getITSTracks().size());
163 for (
auto& rof : itsrofs) {
164 if (rof.getFlag(o2::itsmft::ROFRecord::VtxUPCMode)) {
165 for (
int i = rof.getFirstEntry();
i < rof.getFirstEntry() + rof.getNEntries();
i++) {
170 int nv = vertices.size();
171 for (
int iv = 0; iv < nv; iv++) {
172 int idMin = v2tRefs[iv].getFirstEntry(), idMax = idMin + v2tRefs[iv].getEntries();
173 int nits = 0, nitsUPC = 0;
174 for (
int id = idMin;
id < idMax;
id++) {
178 if (itsTrUPC[gid.getIndex()]) {
183 if (nitsUPC > nits / 2) {
200 LOGP(info,
"Found {} PVs, Time CPU/Real:{:.3f}/{:.3f} (DBScan: {:.4f}, Finder:{:.4f}, MADSel:{:.4f}, Rej.Debris:{:.4f}, Reattach:{:.4f}) | {} trials for {} TZ-clusters, max.trials: {}, Slowest TZ-cluster: {} ms of mult {} | NInitial:{}, Rejections: NoFilledBC:{}, NoIntCand:{}, Debris:{}, Quality:{}, ITSOnly:{}",
201 vertices.size(), mTimer.CpuTime() - timeCPU0, mTimer.RealTime() - timeReal0,
210 static bool first =
true;
219 md.SetOwnerKeyValue();
230 LOGF(info,
"Primary vertexing total timing: Cpu: %.3e Real: %.3e s in %d slots",
231 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
241 LOG(info) <<
"ITS Alpide param updated";
243 par.printKeyValues();
256 static bool initOnceDone =
false;
262 if (!grp->isDetContinuousReadOut(DetID::ITS)) {
263 mITSROFrameLengthMUS = alpParams.roFrameLengthTrig / 1.e3;
265 mITSROFrameLengthMUS = alpParams.roFrameLengthInBC * o2::constants::lhc::LHCBunchSpacingNS * 1e-3;
267 mITSROFBiasMUS = alpParams.roFrameBiasInBC * o2::constants::lhc::LHCBunchSpacingNS * 1e-3;
283 std::vector<OutputSpec> outputs;
284 auto dataRequest = std::make_shared<DataRequest>();
286 dataRequest->requestTracks(
src, useMC);
288 dataRequest->requestFT0RecPoints(
false);
291 outputs.emplace_back(
"GLO",
"PVTX", 0, Lifetime::Timeframe);
292 outputs.emplace_back(
"GLO",
"PVTX_CONTID", 0, Lifetime::Timeframe);
293 outputs.emplace_back(
"GLO",
"PVTX_CONTIDREFS", 0, Lifetime::Timeframe);
296 outputs.emplace_back(
"GLO",
"PVTX_MCTR", 0, Lifetime::Timeframe);
299 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
307 dataRequest->inputs.emplace_back(
"meanvtx",
"GLO",
"MEANVERTEX", 0, Lifetime::Condition,
ccdbParamSpec(
"GLO/Calib/MeanVertex", {}, 1));
309 outputs.emplace_back(
"META",
"PVERTEXER", 0, Lifetime::Sporadic);
315 AlgorithmSpec{adaptFromTask<PrimaryVertexingSpec>(dataRequest, ggRequest,
src, skip, validateWithFT0, useMC)},
316 Options{{
"pool-dumps-directory", VariantType::String,
"", {
"Destination directory for the tracks pool dumps"}}}};
Definition of the GeometryManager class.
Helper for geometry and GRP related CCDB requests.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
std::vector< o2::its::TrackITS > tracks
Definition of the Names Generator class.
Wrapper container for different reconstructed object types.
Result of refitting TPC-ITS matched track.
Reference on ITS/MFT clusters set.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string getConfigOutputFileName(const std::string &procName, const std::string &confName="", bool json=true)
static const PVertexerParams & Instance()
static std::string asJSON(std::string const &keyOnly="")
static void write(std::string const &filename, std::string const &keyOnly="")
Static class with identifiers, bitmasks and names for ALICE detectors.
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void setTrackSources(GTrackID::mask_t s)
auto getNIniFound() const
int process(const TR &tracks, const gsl::span< o2d::GlobalTrackID > gids, const gsl::span< InteractionCandidate > intCand, std::vector< PVertex > &vertices, std::vector< o2d::VtxTrackIndex > &vertexTrackIDs, std::vector< V2TRef > &v2tRefs, const gsl::span< const o2::MCCompLabel > lblTracks, std::vector< o2::MCEventLabel > &lblVtx)
auto getTotTrials() const
void setStartIR(const o2::InteractionRecord &ir)
set InteractionRecods for the beginning of the TF
auto getLongestClusterMult() const
auto getLongestClusterTimeMS() const
TStopwatch & getTimeDebris()
auto getMaxTrialsPerCluster() const
auto getNKilledITSOnly() const
TStopwatch & getTimeVertexing()
TStopwatch & getTimeMADSel()
auto getNKilledQuality() const
void setPoolDumpDirectory(const std::string &d)
auto getNTZClusters() const
auto getNKilledDebris() const
void setBunchFilling(const o2::BunchFilling &bf)
void setValidateWithIR(bool v)
TStopwatch & getTimeReAttach()
TStopwatch & getTimeDBScan()
auto getNKilledBCValid() const
void setMeanVertex(const o2d::MeanVertexObject *v)
void setITSROFrameLength(float v)
auto getNKilledIntCand() const
void run(ProcessingContext &pc) final
PrimaryVertexingSpec(std::shared_ptr< DataRequest > dr, std::shared_ptr< o2::base::GRPGeomRequest > gr, GTrackID::mask_t src, bool skip, bool validateWithIR, bool useMC)
~PrimaryVertexingSpec() override=default
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void init(InitContext &ic) final
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Defining ITS Vertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getPrimaryVertexingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool skip, bool validateWithFT0, bool useMC, bool useGeom)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string name
The name of the associated DataProcessorSpec.
size_t inputTimesliceId
The time pipelining id of this particular device.
bool isSelected(const RecPoints &rp) const
auto getITSTracks() const
GTrackID getITSContributorGID(GTrackID source) const
o2::InteractionRecord startIR
void createTracksVariadic(T creator, GTrackID::mask_t srcSel=GTrackID::getSourcesMask("all")) const
const o2::itsmft::TrkClusRef & getITSABRef(GTrackID gid) const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
void fillTrackMCLabels(const gsl::span< GTrackID > gids, std::vector< o2::MCCompLabel > &mcinfo) const
const o2::its::TrackITS & getITSTrack(GTrackID gid) const
auto getFT0RecPoints() const
auto getITSTracksROFRecords() const
uint16_t pattern
layers pattern
static bool pathIsDirectory(const std::string_view p)
generic track with timestamp
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"