55 std::shared_ptr<o2::base::GRPGeomRequest> mGRPGeomRequest;
57 std::vector<TrackTPC> mMIPTracks;
58 unsigned int mProcessEveryNthTF{1};
59 int mMaxTracksPerTF{-1};
60 uint32_t mTFCounter{0};
61 int mProcessNFirstTFs{0};
63 bool mSendDummy{
false};
65 bool acceptDCA(
const TrackTPC& track);
70 const double minP = ic.
options().
get<
double>(
"min-momentum");
71 const double maxP = ic.
options().
get<
double>(
"max-momentum");
72 const double mindEdx = ic.
options().
get<
double>(
"min-dedx");
73 const double maxdEdx = ic.
options().
get<
double>(
"max-dedx");
74 const int minClusters = std::max(10, ic.
options().
get<
int>(
"min-clusters"));
75 const auto cutLoopers = !ic.
options().
get<
bool>(
"dont-cut-loopers");
76 mSendDummy = ic.
options().
get<
bool>(
"send-dummy-data");
77 mMaxTracksPerTF = ic.
options().
get<
int>(
"maxTracksPerTF");
78 if (mMaxTracksPerTF > 0) {
79 mMIPTracks.reserve(mMaxTracksPerTF);
82 mProcessEveryNthTF = ic.
options().
get<
int>(
"processEveryNthTF");
83 if (mProcessEveryNthTF <= 0) {
84 mProcessEveryNthTF = 1;
86 mProcessNFirstTFs = ic.
options().
get<
int>(
"process-first-n-TFs");
88 if (mProcessEveryNthTF > 1) {
89 std::mt19937 rng(std::time(
nullptr));
90 std::uniform_int_distribution<std::mt19937::result_type> dist(1, mProcessEveryNthTF);
91 mTFCounter = dist(rng);
92 LOGP(info,
"Skipping first {} TFs", mProcessEveryNthTF - mTFCounter);
111 if ((mTFCounter++ % mProcessEveryNthTF) && (currentTF >= mProcessNFirstTFs)) {
112 LOGP(info,
"Skipping TF {}", currentTF);
120 const auto tracks = pc.
inputs().
get<gsl::span<TrackTPC>>(
"tracks");
121 const auto nTracks = tracks.size();
123 if ((mMaxTracksPerTF != -1) && (nTracks > mMaxTracksPerTF)) {
127 for (
size_t i = 0;
i < nTracks; ++
i) {
128 if (mCuts.
goodTrack(tracks[
i]) && acceptDCA(tracks[
i])) {
143 std::minstd_rand rng(std::time(
nullptr));
147 const int loopEnd = (mMaxTracksPerTF >
indices.size()) ?
indices.size() : mMaxTracksPerTF;
148 for (
int i = 0;
i < loopEnd; ++
i) {
149 mMIPTracks.emplace_back(tracks[
indices[
i]]);
152 std::copy_if(tracks.begin(), tracks.end(), std::back_inserter(mMIPTracks), [
this](
const auto& track) { return mCuts.goodTrack(track) && acceptDCA(track); });
155 LOGP(info,
"Filtered {} MIP tracks out of {} total tpc tracks", mMIPTracks.size(), tracks.size());
171 LOG(info) <<
"Finalizig MIP Tracks filter";
174bool MIPTrackFilterDevice::acceptDCA(
const TrackTPC& track)
184 const auto ok = propagator->propagateToDCABxByBz(refPoint, propTrack, 2., o2::base::Propagator::MatCorrType::USEMatCorrLUT, &dca);
185 const auto dcar = std::abs(dca[0]);
187 return ok && (dcar < mDCACut);
192 std::vector<OutputSpec> outputs;
195 std::vector<InputSpec> inputs;
196 inputs.emplace_back(
"tracks",
"TPC",
"TRACKS");
198 auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
208 "tpc-miptrack-filter",
211 adaptFromTask<MIPTrackFilterDevice>(ggRequest),
213 {
"min-momentum", VariantType::Double, 0.35, {
"minimum momentum cut"}},
214 {
"max-momentum", VariantType::Double, 0.55, {
"maximum momentum cut"}},
215 {
"min-dedx", VariantType::Double, 10., {
"minimum dEdx cut"}},
216 {
"max-dedx", VariantType::Double, 200., {
"maximum dEdx cut"}},
217 {
"min-clusters", VariantType::Int, 60, {
"minimum number of clusters in a track"}},
218 {
"processEveryNthTF", VariantType::Int, 1, {
"Using only a fraction of the data: 1: Use every TF, 10: Process only every tenth TF."}},
219 {
"maxTracksPerTF", VariantType::Int, -1, {
"Maximum number of processed tracks per TF (-1 for processing all tracks)"}},
220 {
"process-first-n-TFs", VariantType::Int, 1, {
"Number of first TFs which are not sampled"}},
221 {
"send-dummy-data", VariantType::Bool,
false, {
"Send empty data in case TF is skipped"}},
222 {
"dont-cut-loopers", VariantType::Bool,
false, {
"Do not cut loopers by comparing zout-zin"}},
223 {
"dca-cut", VariantType::Float, 3.f, {
"DCA cut in cm, < 0 to disable"}},
Utils and constants for calibration and related workflows.
Helper for geometry and GRP related CCDB requests.
Workflow to filter MIP tracks and streams them to other devices.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
T get(const char *key) const
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.
void endOfStream(EndOfStreamContext &eos) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
void run(ProcessingContext &pc) final
MIPTrackFilterDevice(std::shared_ptr< o2::base::GRPGeomRequest > gr)
void init(framework::InitContext &ic) final
void setCutLooper(bool cut)
try to remove looper cutting on (abs(z_out) - abs(z_in)) < -10), not very precise
void setdEdxMax(float dEdxMax)
void setNClusMin(float NClusMin)
void setdEdxMin(float dEdxMin)
bool goodTrack(o2::tpc::TrackTPC const &track)
GLsizei GLenum const void * indices
constexpr o2::header::DataOrigin gDataOriginTPC
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
uint32_t getCurrentTF(o2::framework::ProcessingContext &pc)
Global TPC definitions and constants.
o2::framework::DataProcessorSpec getMIPTrackFilterSpec()
create a processor spec
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"