Skip to content

Commit 38a4549

Browse files
committed
Add residuals for external detectors unless --skip-ext-det-residuals is passed
The unbinned residuals got channel data member which holds ITS chipID, TRD chamber ID or TOF pad within the sector resp. The convention for non-TPC rows: 160-165: TRD layers 170: TOF 180-186: ITS layers The getters isTPC(), isTRD(), isTOF() and isITS() can be used to query the residual type and getDetID() will return 0,1,2 and 3 for ITS, TPC, TRD and TOF points resp. Also, getX() and getAlpha() will provide the tracking frame X and alpha of the residual. These getters, when acting on the non-TPC residuals require initialized geometry helpers. The initialization can be done manually via static method o2::tpc::UnbinnedResid::init(long timeStamp = -1) which will load from the CCDB the geometry corresponding to the requested timestamp (-1 : now). If the initialization was not done in advance then it will be done internally at the 1st query of getX() or getAlpha(), with the timestamp = -1.
1 parent 3e1afe2 commit 38a4549

File tree

6 files changed

+382
-79
lines changed

6 files changed

+382
-79
lines changed

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/include/TPCInterpolationWorkflow/TPCInterpolationSpec.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ namespace tpc
3838
class TPCInterpolationDPL : public Task
3939
{
4040
public:
41-
TPCInterpolationDPL(std::shared_ptr<o2::globaltracking::DataRequest> dr, o2::dataformats::GlobalTrackID::mask_t src, o2::dataformats::GlobalTrackID::mask_t srcMap, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput) : mDataRequest(dr), mSources(src), mSourcesMap(srcMap), mGGCCDBRequest(gr), mUseMC(useMC), mProcessITSTPConly(processITSTPConly), mSendTrackData(sendTrackData), mDebugOutput(debugOutput) {}
41+
TPCInterpolationDPL(std::shared_ptr<o2::globaltracking::DataRequest> dr, o2::dataformats::GlobalTrackID::mask_t src, o2::dataformats::GlobalTrackID::mask_t srcMap, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC,
42+
bool processITSTPConly, bool sendTrackData, bool debugOutput, bool extDetResid) : mDataRequest(dr), mSources(src), mSourcesMap(srcMap), mGGCCDBRequest(gr), mUseMC(useMC), mProcessITSTPConly(processITSTPConly), mSendTrackData(sendTrackData), mDebugOutput(debugOutput), mExtDetResid(extDetResid) {}
4243
~TPCInterpolationDPL() override = default;
4344
void init(InitContext& ic) final;
4445
void run(ProcessingContext& pc) final;
@@ -58,14 +59,16 @@ class TPCInterpolationDPL : public Task
5859
bool mProcessITSTPConly{false}; ///< should also tracks without outer point (ITS-TPC only) be processed?
5960
bool mProcessSeeds{false}; ///< process not only most complete track, but also its shorter parts
6061
bool mDebugOutput{false}; ///< add more information to the output (track points of ITS, TRD and TOF)
62+
bool mExtDetResid{true}; ///< produce unbinned residuals for external detectors
6163
bool mSendTrackData{false}; ///< if true, not only the clusters but also corresponding track data will be sent
6264
uint32_t mSlotLength{600u}; ///< the length of one calibration slot required to calculate max number of tracks per TF
6365
int mMatCorr{2}; ///< the material correction to be used for track interpolation
6466
TStopwatch mTimer;
6567
};
6668

6769
/// create a processor spec
68-
framework::DataProcessorSpec getTPCInterpolationSpec(o2::dataformats::GlobalTrackID::mask_t srcCls, o2::dataformats::GlobalTrackID::mask_t srcVtx, o2::dataformats::GlobalTrackID::mask_t srcTrk, o2::dataformats::GlobalTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput);
70+
framework::DataProcessorSpec getTPCInterpolationSpec(o2::dataformats::GlobalTrackID::mask_t srcCls, o2::dataformats::GlobalTrackID::mask_t srcVtx, o2::dataformats::GlobalTrackID::mask_t srcTrk,
71+
o2::dataformats::GlobalTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput, bool extDetResid);
6972

7073
} // namespace tpc
7174
} // namespace o2

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/src/TPCInterpolationSpec.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ void TPCInterpolationDPL::updateTimeDependentParams(ProcessingContext& pc)
105105
}
106106
if (mDebugOutput) {
107107
mInterpolation.setDumpTrackPoints();
108-
mInterpolation.setITSClusterDictionary(mITSDict);
109108
}
109+
mInterpolation.setExtDetResid(mExtDetResid);
110+
mInterpolation.setITSClusterDictionary(mITSDict);
110111
}
111112

112113
void TPCInterpolationDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
@@ -158,7 +159,7 @@ void TPCInterpolationDPL::endOfStream(EndOfStreamContext& ec)
158159
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
159160
}
160161

161-
DataProcessorSpec getTPCInterpolationSpec(GTrackID::mask_t srcCls, GTrackID::mask_t srcVtx, GTrackID::mask_t srcTrk, GTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput)
162+
DataProcessorSpec getTPCInterpolationSpec(GTrackID::mask_t srcCls, GTrackID::mask_t srcVtx, GTrackID::mask_t srcTrk, GTrackID::mask_t srcTrkMap, bool useMC, bool processITSTPConly, bool sendTrackData, bool debugOutput, bool extDetResid)
162163
{
163164
auto dataRequest = std::make_shared<DataRequest>();
164165
std::vector<OutputSpec> outputs;
@@ -199,7 +200,7 @@ DataProcessorSpec getTPCInterpolationSpec(GTrackID::mask_t srcCls, GTrackID::mas
199200
"tpc-track-interpolation",
200201
dataRequest->inputs,
201202
outputs,
202-
AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput)},
203+
AlgorithmSpec{adaptFromTask<TPCInterpolationDPL>(dataRequest, srcTrk, srcTrkMap, ggRequest, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid)},
203204
Options{
204205
{"matCorrType", VariantType::Int, 2, {"material correction type (definition in Propagator.h)"}},
205206
{"sec-per-slot", VariantType::UInt32, 600u, {"number of seconds per calibration time slot (put 0 for infinite slot length)"}},

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/src/tpc-interpolation-workflow.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
4242
{"tracking-sources-map-extraction", VariantType::String, std::string{GID::ALL}, {"can be subset of \"tracking-sources\""}},
4343
{"send-track-data", VariantType::Bool, false, {"Send also the track information to the aggregator"}},
4444
{"debug-output", VariantType::Bool, false, {"Dump extended tracking information for debugging"}},
45+
{"skip-ext-det-residuals", VariantType::Bool, false, {"Do not produce residuals for external detectors"}},
4546
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
4647
o2::raw::HBFUtilsInitializer::addConfigOption(options);
4748
std::swap(workflowOptions, options);
@@ -104,8 +105,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
104105
useMC = false; // force disabling MC as long as it is not implemented
105106
auto sendTrackData = configcontext.options().get<bool>("send-track-data");
106107
auto debugOutput = configcontext.options().get<bool>("debug-output");
108+
auto extDetResid = !configcontext.options().get<bool>("skip-ext-det-residuals");
107109

108-
specs.emplace_back(o2::tpc::getTPCInterpolationSpec(srcClusters, srcVtx, srcTracks, srcTracksMap, useMC, processITSTPConly, sendTrackData, debugOutput));
110+
specs.emplace_back(o2::tpc::getTPCInterpolationSpec(srcClusters, srcVtx, srcTracks, srcTracksMap, useMC, processITSTPConly, sendTrackData, debugOutput, extDetResid));
109111
if (!configcontext.options().get<bool>("disable-root-output")) {
110112
specs.emplace_back(o2::tpc::getTPCResidualWriterSpec(sendTrackData, debugOutput));
111113
}

Detectors/TPC/calibration/SpacePoints/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ o2_add_library(SpacePoints
1919
O2::CommonUtils
2020
O2::TPCBase
2121
O2::TRDBase
22+
O2::TOFBase
2223
O2::TPCReconstruction
2324
O2::TPCFastTransformation
2425
O2::ITStracking

Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackInterpolation.h

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,49 @@ struct TPCClusterResiduals {
6767
/// (this is the data type which will be sent from the EPNs to the aggregator)
6868
struct UnbinnedResid {
6969
UnbinnedResid() = default;
70-
UnbinnedResid(float dyIn, float dzIn, float tgSlpIn, float yIn, float zIn, unsigned char rowIn, unsigned char secIn) : dy(static_cast<short>(dyIn * 0x7fff / param::MaxResid)),
71-
dz(static_cast<short>(dzIn * 0x7fff / param::MaxResid)),
72-
tgSlp(static_cast<short>(tgSlpIn * 0x7fff / param::MaxTgSlp)),
73-
y(static_cast<short>(yIn * 0x7fff / param::MaxY)),
74-
z(static_cast<short>(zIn * 0x7fff / param::MaxZ)),
75-
row(rowIn),
76-
sec(secIn) {}
77-
short dy; ///< residual in y
78-
short dz; ///< residual in z
79-
short tgSlp; ///< tan of the phi angle between padrow and track
80-
short y; ///< y position of the track, needed for binning
81-
short z; ///< z position of the track, needed for binning
82-
unsigned char row; ///< TPC pad row
83-
unsigned char sec; ///< TPC sector (0..35)
84-
ClassDefNV(UnbinnedResid, 1);
70+
UnbinnedResid(float dyIn, float dzIn, float tgSlpIn, float yIn, float zIn, unsigned char rowIn, unsigned char secIn, short chanIn = -1) : dy(static_cast<short>(dyIn * 0x7fff / param::MaxResid)),
71+
dz(static_cast<short>(dzIn * 0x7fff / param::MaxResid)),
72+
tgSlp(static_cast<short>(tgSlpIn * 0x7fff / param::MaxTgSlp)),
73+
y(static_cast<short>(yIn * 0x7fff / param::MaxY)),
74+
z(static_cast<short>(zIn * 0x7fff / param::MaxZ)),
75+
row(rowIn),
76+
sec(secIn),
77+
channel(chanIn) {}
78+
short dy{0}; ///< residual in y
79+
short dz{0}; ///< residual in z
80+
short tgSlp{0}; ///< tan of the phi angle between padrow and track
81+
short y{0}; ///< y position of the track, needed for binning
82+
short z{0}; ///< z position of the track, needed for binning
83+
unsigned char row{0}; ///< TPC pad row
84+
unsigned char sec{0}; ///< TPC sector (0..35)
85+
short channel{-1}; ///< extra channel info (ITS chip ID, TRD chamber, TOF main pad within the sector)
86+
87+
bool isTPC() const { return row < constants::MAXGLOBALPADROW; }
88+
bool isTRD() const { return row >= 160 && row < 166; }
89+
bool isTOF() const { return row == 170; }
90+
bool isITS() const { return row >= 180; }
91+
int getDetID() const { return isTPC() ? 1 : (isITS() ? 0 : (isTRD() ? 2 : (isTOF() ? 3 : -1))); }
92+
int getITSLayer() const { return row - 180; }
93+
int getTRDLayer() const { return row - 170; }
94+
float getAlpha() const;
95+
float getX() const;
96+
97+
static void init(long timestamp = -1);
98+
static void checkInitDone();
99+
static bool gInitDone;
100+
101+
ClassDefNV(UnbinnedResid, 2);
85102
};
86103

87104
/// Structure for the information required to associate each residual with a given track type (ITS-TPC-TRD-TOF, etc)
88105
struct TrackDataCompact {
89106
TrackDataCompact() = default;
90-
TrackDataCompact(uint32_t idx, uint8_t nRes, uint8_t source) : idxFirstResidual(idx), nResiduals(nRes), sourceId(source) {}
107+
TrackDataCompact(uint32_t idx, uint8_t nRes, uint8_t source, uint8_t nextraRes = 0) : idxFirstResidual(idx), nResiduals(nRes), sourceId(source), nExtDetResid(nextraRes) {}
91108
uint32_t idxFirstResidual; ///< the index of the first residual from this track
92-
uint8_t nResiduals; ///< total number of residuals associated to this track
109+
uint8_t nResiduals; ///< total number of TPC residuals associated to this track
110+
uint8_t nExtDetResid = 0; ///< number of external detectors (wrt TPC) residuals stored, on top of clIdx.getEntries
93111
uint8_t sourceId; ///< source ID obtained from the global track ID
94-
ClassDefNV(TrackDataCompact, 1);
112+
ClassDefNV(TrackDataCompact, 2);
95113
};
96114

97115
// TODO add to UnbinnedResid::sec flag if cluster was used or not
@@ -110,7 +128,8 @@ struct TrackDataExtended {
110128
std::vector<o2::trd::CalibratedTracklet> clsTRD{}; ///< the TRD space points (if available)
111129
o2::tof::Cluster clsTOF{}; ///< the TOF cluster (if available)
112130
o2::dataformats::RangeReference<> clIdx{}; ///< index of first cluster residual and total number of cluster residuals of this track
113-
ClassDefNV(TrackDataExtended, 2);
131+
uint8_t nExtDetResid = 0; ///< number of external detectors (to TPC) residuals stored, on top of clIdx.getEntries
132+
ClassDefNV(TrackDataExtended, 3);
114133
};
115134

116135
/// Structure filled for each track with track quality information and a vector with TPCClusterResiduals
@@ -121,12 +140,14 @@ struct TrackData {
121140
float chi2TPC{}; ///< chi2 of TPC track
122141
float chi2ITS{}; ///< chi2 of ITS track
123142
float chi2TRD{}; ///< chi2 of TRD track
143+
124144
unsigned short nClsTPC{}; ///< number of attached TPC clusters
125145
unsigned short nClsITS{}; ///< number of attached ITS clusters
126146
unsigned short nTrkltsTRD{}; ///< number of attached TRD tracklets
127147
unsigned short clAvailTOF{}; ///< whether or not track seed has a matched TOF cluster
128-
o2::dataformats::RangeReference<> clIdx{}; ///< index of first cluster residual and total number of cluster residuals of this track
129-
ClassDefNV(TrackData, 6);
148+
uint8_t nExtDetResid = 0; ///< number of external detectors (to TPC) residuals stored, on top of clIdx.getEntries
149+
o2::dataformats::RangeReference<> clIdx{}; ///< index of first cluster residual and total number of TPC cluster residuals of this track
150+
ClassDefNV(TrackData, 7);
130151
};
131152

132153
/// \class TrackInterpolation
@@ -265,6 +286,10 @@ class TrackInterpolation
265286
/// Set the centre of mass energy required for pT downsampling Tsalis function
266287
void setSqrtS(float s) { mSqrtS = s; }
267288

289+
void setExtDetResid(bool v) { mExtDetResid = v; }
290+
291+
int processTRDLayer(const o2::trd::TrackTRD& trkTRD, int iLayer, o2::track::TrackParCov& trkWork, std::array<float, 2>* trkltTRDYZ = nullptr, std::array<float, 3>* trkltTRDCov = nullptr);
292+
268293
// --------------------------------- output ---------------------------------------------
269294
std::vector<UnbinnedResid>& getClusterResiduals() { return mClRes; }
270295
std::vector<TrackDataCompact>& getTrackDataCompact() { return mTrackDataCompact; }
@@ -285,6 +310,7 @@ class TrackInterpolation
285310
int mMaxTracksPerTF{-1}; ///< max number of tracks to be processed per TF (-1 means there is no limit)
286311
int mAddTracksForMapPerTF{0}; ///< in case residuals from different track types are used for vDrift calibration and map creation this defines the statistics for the latter
287312
bool mDumpTrackPoints{false}; ///< dump also track points in ITS, TRD and TOF
313+
bool mExtDetResid{true}; ///< produce unbinned residuals for external detectors
288314
bool mProcessSeeds{false}; ///< in case for global tracks also their shorter parts are processed separately
289315
bool mProcessITSTPConly{false}; ///< flag, whether or not to extrapolate ITS-only through TPC
290316
o2::dataformats::GlobalTrackID::mask_t mSourcesConfigured; ///< the track sources taken into account for extra-/interpolation
@@ -297,6 +323,7 @@ class TrackInterpolation
297323
std::vector<o2::globaltracking::RecoContainer::GlobalIDSet> mGIDtables{}; ///< GIDs of contributors from single detectors for each seed
298324
std::vector<float> mTrackTimes{}; ///< time estimates for all input tracks in micro seconds
299325
std::vector<o2::track::TrackParCov> mSeeds{}; ///< seeding track parameters (ITS tracks)
326+
std::vector<int> mParentID{}; ///< entry of more global parent track for skimmed seeds (-1: no parent)
300327
std::map<int, int> mTrackTypes; ///< mapping of track source to array index in mTrackIndices
301328
std::array<std::vector<uint32_t>, 4> mTrackIndices; ///< keep GIDs of input tracks separately for each track type
302329
gsl::span<const TPCClRefElem> mTPCTracksClusIdx; ///< input TPC cluster indices from span

0 commit comments

Comments
 (0)