forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaserTrackFilterSpec.cxx
More file actions
105 lines (83 loc) · 2.74 KB
/
Copy pathLaserTrackFilterSpec.cxx
File metadata and controls
105 lines (83 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// @file LaserTrackFilterSpec.cxx
/// @brief Device to filter out laser tracks
#include <algorithm>
#include <iterator>
#include "DataFormatsTPC/TrackTPC.h"
#include "TPCCalibration/CalibLaserTracks.h"
#include "Framework/Task.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/ControlService.h"
#include "Framework/WorkflowSpec.h"
using namespace o2::framework;
namespace o2::tpc
{
class LaserTrackFilterDevice : public o2::framework::Task
{
public:
void init(o2::framework::InitContext& ic) final
{
}
void run(o2::framework::ProcessingContext& pc) final
{
const auto tracks = pc.inputs().get<gsl::span<TrackTPC>>("tracks");
std::copy_if(tracks.begin(), tracks.end(), std::back_inserter(mLaserTracks),
[this](const auto& track) { return isLaserTrackCandidate(track); });
LOGP(info, "Filtered {} laser track candidates out of {} total tpc tracks", mLaserTracks.size(), tracks.size());
sendOutput(pc.outputs());
}
void endOfStream(o2::framework::EndOfStreamContext& ec) final
{
}
private:
std::vector<TrackTPC> mLaserTracks;
//________________________________________________________________
void sendOutput(DataAllocator& output)
{
output.snapshot(Output{"TPC", "LASERTRACKS", 0}, mLaserTracks);
mLaserTracks.clear();
}
bool isLaserTrackCandidate(const TrackTPC& track)
{
if (track.getP() < 1) {
return false;
}
if (track.getNClusters() < 80) {
//return false;
}
if (track.hasBothSidesClusters()) {
return false;
}
const auto& parOutLtr = track.getOuterParam();
if (parOutLtr.getX() < 220) {
return false;
}
const int side = track.hasCSideClusters();
if (!CalibLaserTracks::hasNearbyLaserRod(parOutLtr, side)) {
return false;
}
return true;
}
};
DataProcessorSpec getLaserTrackFilter()
{
using device = o2::tpc::LaserTrackFilterDevice;
std::vector<OutputSpec> outputs;
outputs.emplace_back("TPC", "LASERTRACKS", 0, o2::framework::Lifetime::Timeframe);
return DataProcessorSpec{
"tpc-laser-track-filter",
Inputs{{"tracks", "TPC", "TRACKS", 0}},
outputs,
AlgorithmSpec{adaptFromTask<device>()},
Options{}};
}
} // namespace o2::tpc