Project
Loading...
Searching...
No Matches
TrackFitterSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#include "TrackFitterSpec.h"
18
19#include <stdexcept>
20#include <list>
21#include <vector>
22
23#include <gsl/span>
24
28#include "Framework/Lifetime.h"
29#include "Framework/Output.h"
30#include "Framework/Task.h"
31#include "Framework/Logger.h"
32
37#include "MCHTracking/Track.h"
40
41namespace o2
42{
43namespace mch
44{
45
46using namespace std;
47using namespace o2::framework;
48
50{
51 public:
52 //_________________________________________________________________________________________________
54 {
56 LOG(info) << "initializing track fitter";
57 auto l3Current = ic.options().get<float>("l3Current");
58 auto dipoleCurrent = ic.options().get<float>("dipoleCurrent");
59 mTrackFitter.initField(l3Current, dipoleCurrent);
60 mTrackFitter.smoothTracks(true);
62 }
63
64 //_________________________________________________________________________________________________
66 {
68
69 // get the input ROFs, tracks and attached clusters
70 auto rofsIn = pc.inputs().get<gsl::span<ROFRecord>>("rofsin");
71 auto tracksIn = pc.inputs().get<gsl::span<TrackMCH>>("tracksin");
72 auto clustersIn = pc.inputs().get<gsl::span<Cluster>>("clustersin");
73
74 // create the output messages for ROFs, refitted tracks and attached clusters
75 auto& rofsOut = pc.outputs().make<std::vector<ROFRecord>>(OutputRef{"rofsout"});
76 auto& tracksOut = pc.outputs().make<std::vector<TrackMCH>>(OutputRef{"tracksout"});
77 auto& clustersOut = pc.outputs().make<std::vector<Cluster>>(OutputRef{"clustersout"});
78
79 rofsOut.reserve(rofsIn.size());
80 for (const auto& rof : rofsIn) {
81
82 // loop over tracks of the current ROF
83 int trackOffset(tracksOut.size());
84 for (const auto& mchTrack : tracksIn.subspan(rof.getFirstIdx(), rof.getNEntries())) {
85
86 // get the clusters attached to the track
87 auto trackClusters = clustersIn.subspan(mchTrack.getFirstClusterIdx(), mchTrack.getNClusters());
88
89 // create the internal track
90 Track track{};
91 for (const auto& cluster : trackClusters) {
92 track.createParamAtCluster(cluster);
93 }
94
95 // refit the track
96 try {
97 mTrackFitter.fit(track);
98 } catch (exception const& e) {
99 LOG(error) << "Track fit failed: " << e.what();
100 continue;
101 }
102
103 // propagate the parameters to the MID
104 TrackParam paramAtMID(track.last());
105 if (!TrackExtrap::extrapToMID(paramAtMID)) {
106 LOG(error) << "propagation to MID failed --> track discarded";
107 continue;
108 }
109
110 // write the refitted track and attached clusters (same as those of the input track)
111 const auto& param = track.first();
112 tracksOut.emplace_back(param.getZ(), param.getParameters(), param.getCovariances(),
113 param.getTrackChi2(), clustersOut.size(), track.getNClusters(),
114 paramAtMID.getZ(), paramAtMID.getParameters(), paramAtMID.getCovariances(),
115 mchTrack.getTimeMUS());
116 clustersOut.insert(clustersOut.end(), trackClusters.begin(), trackClusters.end());
117 }
118
119 // write the current ROF with references to the associated tracks
120 rofsOut.emplace_back(rof.getBCData(), trackOffset, tracksOut.size() - trackOffset, rof.getBCWidth());
121 }
122 }
123
124 private:
125 TrackFitter mTrackFitter{};
126};
127
128//_________________________________________________________________________________________________
130{
131 return DataProcessorSpec{
132 specName,
133 Inputs{InputSpec{"rofsin", "MCH", "TRACKROFSIN", 0, Lifetime::Timeframe},
134 InputSpec{"tracksin", "MCH", "TRACKSIN", 0, Lifetime::Timeframe},
135 InputSpec{"clustersin", "MCH", "TRACKCLUSTERSIN", 0, Lifetime::Timeframe}},
136 Outputs{OutputSpec{OutputLabel{"rofsout"}, "MCH", "TRACKROFS", 0, Lifetime::Timeframe},
137 OutputSpec{OutputLabel{"tracksout"}, "MCH", "TRACKS", 0, Lifetime::Timeframe},
138 OutputSpec{OutputLabel{"clustersout"}, "MCH", "TRACKCLUSTERS", 0, Lifetime::Timeframe}},
139 AlgorithmSpec{adaptFromTask<TrackFitterTask>()},
140 Options{{"l3Current", VariantType::Float, -30000.0f, {"L3 current"}},
141 {"dipoleCurrent", VariantType::Float, -6000.0f, {"Dipole current"}}}};
142}
143
144} // namespace mch
145} // namespace o2
Definition of the MCH cluster minimal structure.
Definition of the MCH track for internal use.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
char error[CURL_ERROR_SIZE]
Definition of a class to fit a track to a set of clusters.
Definition of the MCH ROFrame record.
Definition of tools for track extrapolation.
Definition of a data processor to read, refit and send tracks with attached clusters.
Definition of the MCH track.
Definition of the MCH track parameters for internal use.
const char * specName
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
static void useExtrapV2(bool extrapV2=true)
Switch to Runge-Kutta extrapolation v2.
Definition TrackExtrap.h:51
static bool extrapToMID(TrackParam &trackParam)
void init(framework::InitContext &ic)
void run(framework::ProcessingContext &pc)
Class to fit a track to a set of clusters.
Definition TrackFitter.h:31
void initField(float l3Current, float dipoleCurrent)
void smoothTracks(bool smooth)
Enable/disable the smoother (and the saving of related parameters)
Definition TrackFitter.h:47
void fit(Track &track, bool smooth=true, bool finalize=true, std::list< TrackParam >::reverse_iterator *itStartingParam=nullptr, bool skipLocalChi2Calculation=false)
track parameters for internal use
Definition TrackParam.h:34
Double_t getZ() const
return Z coordinate (cm)
Definition TrackParam.h:47
const TMatrixD & getParameters() const
return track parameters
Definition TrackParam.h:81
const TMatrixD & getCovariances() const
track for internal use
Definition Track.h:33
GLenum GLfloat param
Definition glcorearb.h:271
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
o2::framework::DataProcessorSpec getTrackFitterSpec(const char *specName)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"