Skip to content

Commit 6c23010

Browse files
committed
Add extra info with charge and timing to unbinned residuals
1 parent db7170b commit 6c23010

File tree

9 files changed

+128
-12
lines changed

9 files changed

+128
-12
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ class ResidualAggregatorDevice : public o2::framework::Task
128128
updateTimeDependentParams(pc);
129129
std::chrono::duration<double, std::milli> ccdbUpdateTime = std::chrono::high_resolution_clock::now() - runStartTime;
130130

131-
// we always require the unbinned residuals and the associated track references
131+
// we always require the unbinned residuals and the associated detector info and track references
132132
auto residualsData = pc.inputs().get<gsl::span<o2::tpc::UnbinnedResid>>("unbinnedRes");
133+
auto residualsDataDet = pc.inputs().get<gsl::span<o2::tpc::DetInfoResid>>("detinfoRes");
133134
auto trackRefs = pc.inputs().get<gsl::span<o2::tpc::TrackDataCompact>>("trackRefs");
134135

135136
// track data input is optional
@@ -151,7 +152,7 @@ class ResidualAggregatorDevice : public o2::framework::Task
151152

152153
o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mAggregator->getCurrentTFInfo());
153154
LOG(detail) << "Processing TF " << mAggregator->getCurrentTFInfo().tfCounter << " with " << trkData->size() << " tracks and " << residualsData.size() << " unbinned residuals associated to them";
154-
mAggregator->process(residualsData, trackRefs, trkDataPtr, lumi);
155+
mAggregator->process(residualsData, residualsDataDet, trackRefs, trkDataPtr, lumi);
155156
std::chrono::duration<double, std::milli> runDuration = std::chrono::high_resolution_clock::now() - runStartTime;
156157
LOGP(debug, "Duration for run method: {} ms. From this taken for time dependent param update: {} ms",
157158
std::chrono::duration_cast<std::chrono::milliseconds>(runDuration).count(),
@@ -222,6 +223,7 @@ DataProcessorSpec getTPCResidualAggregatorSpec(bool trackInput, bool ctpInput, b
222223
auto& inputs = dataRequest->inputs;
223224
o2::tpc::VDriftHelper::requestCCDBInputs(inputs);
224225
inputs.emplace_back("unbinnedRes", "GLO", "UNBINNEDRES");
226+
inputs.emplace_back("detinfoRes", "GLO", "DETINFORES");
225227
inputs.emplace_back("trackRefs", "GLO", "TRKREFS");
226228
if (trackInput) {
227229
inputs.emplace_back("trkData", "GLO", "TRKDATA");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class TPCUnbinnedResidualReader : public o2::framework::Task
4343
std::string mInFileName;
4444
std::string mInTreeName;
4545
std::vector<UnbinnedResid> mUnbinnedResid, *mUnbinnedResidPtr = &mUnbinnedResid;
46+
std::vector<DetInfoResid> mDetInfoUnbRes, *mDetInfoUnbResPtr = &mDetInfoUnbRes;
4647
std::vector<TrackData> mTrackData, *mTrackDataPtr = &mTrackData;
4748
std::vector<TrackDataCompact> mTrackDataCompact, *mTrackDataCompactPtr = &mTrackDataCompact;
4849
};

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/src/TPCInterpolationSpec.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void TPCInterpolationDPL::run(ProcessingContext& pc)
143143
}
144144
}
145145
pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mInterpolation.getClusterResiduals());
146+
pc.outputs().snapshot(Output{"GLO", "DETINFORES", 0}, mInterpolation.getClusterResidualsDetInfo());
146147
pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mInterpolation.getTrackDataCompact());
147148
if (mSendTrackData) {
148149
pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mInterpolation.getReferenceTracks());
@@ -188,6 +189,7 @@ DataProcessorSpec getTPCInterpolationSpec(GTrackID::mask_t srcCls, GTrackID::mas
188189
}
189190
}
190191
outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
192+
outputs.emplace_back("GLO", "DETINFORES", 0, Lifetime::Timeframe);
191193
outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
192194
if (sendTrackData) {
193195
outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);

Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/src/TPCUnbinnedResidualReaderSpec.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ void TPCUnbinnedResidualReader::connectTree()
4444
assert(mTreeIn);
4545
mTreeIn->SetBranchAddress("residuals", &mUnbinnedResidPtr);
4646
mTreeIn->SetBranchAddress("trackRefs", &mTrackDataCompactPtr);
47+
if (mTreeIn->GetBranch("detInfo")) {
48+
mTreeIn->SetBranchAddress("detInfo", &mDetInfoUnbResPtr);
49+
} else {
50+
LOGP(warn, "No detInfo branch found in the unbinned residuals tree, empty vector will be sent");
51+
}
4752
if (mTrackInput) {
4853
mTreeIn->SetBranchAddress("tracks", &mTrackDataPtr);
4954
}
@@ -58,6 +63,7 @@ void TPCUnbinnedResidualReader::run(ProcessingContext& pc)
5863
LOG(info) << "Pushing " << mUnbinnedResid.size() << " unbinned residuals at entry " << currEntry;
5964
pc.outputs().snapshot(Output{"GLO", "UNBINNEDRES", 0}, mUnbinnedResid);
6065
pc.outputs().snapshot(Output{"GLO", "TRKREFS", 0}, mTrackDataCompact);
66+
pc.outputs().snapshot(Output{"GLO", "DETINFORES", 0}, mDetInfoUnbRes);
6167
if (mTrackInput) {
6268
LOG(info) << "Pushing " << mTrackData.size() << " reference tracks for these residuals";
6369
pc.outputs().snapshot(Output{"GLO", "TRKDATA", 0}, mTrackData);
@@ -73,6 +79,7 @@ DataProcessorSpec getUnbinnedTPCResidualsReaderSpec(bool trkInput)
7379
{
7480
std::vector<OutputSpec> outputs;
7581
outputs.emplace_back("GLO", "UNBINNEDRES", 0, Lifetime::Timeframe);
82+
outputs.emplace_back("GLO", "DETINFORES", 0, Lifetime::Timeframe);
7683
outputs.emplace_back("GLO", "TRKREFS", 0, Lifetime::Timeframe);
7784
if (trkInput) {
7885
outputs.emplace_back("GLO", "TRKDATA", 0, Lifetime::Timeframe);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct ResidualsContainer {
4949
void fillStatisticsBranches();
5050
uint64_t getNEntries() const { return nResidualsTotal; }
5151

52-
void fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const UnbinnedResid> resid, const gsl::span<const o2::tpc::TrackDataCompact> trkRefsIn, const gsl::span<const o2::tpc::TrackData>* trkDataIn, const o2::ctp::LumiInfo* lumiInput);
52+
void fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const UnbinnedResid> resid, const gsl::span<const DetInfoResid> detInfoRes, const gsl::span<const o2::tpc::TrackDataCompact> trkRefsIn, const gsl::span<const o2::tpc::TrackData>* trkDataIn, const o2::ctp::LumiInfo* lumiInput);
5353
void merge(ResidualsContainer* prev);
5454
void print();
5555
void writeToFile(bool closeFileAfterwards);
@@ -64,6 +64,7 @@ struct ResidualsContainer {
6464
std::vector<uint32_t> sumUnbinnedResid, *sumUnbinnedResidPtr{&sumUnbinnedResid}; ///< sum of unbinned residuals for each TF
6565
std::vector<o2::ctp::LumiInfo> lumi, *lumiPtr{&lumi}; ///< luminosity information from CTP per TF
6666
std::vector<UnbinnedResid> unbinnedRes, *unbinnedResPtr{&unbinnedRes}; ///< unbinned residuals which are sent to the aggregator
67+
std::vector<DetInfoResid> detInfoUnbRes, *detInfoUnbResPtr{&detInfoUnbRes}; ///< detector info associated to unbinned residuals which are sent to the aggregator
6768
std::vector<TrackData> trkData, *trkDataPtr{&trkData}; ///< track data and cluster ranges
6869
std::vector<TrackDataCompact> trackInfo, *trackInfoPtr{&trackInfo}; ///< allows to obtain track type for each unbinned residual downstream
6970
o2::ctp::LumiInfo lumiTF; ///< for each processed TF we store the lumi information in the tree of unbinned residuals

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,50 @@ struct UnbinnedResid {
101101
ClassDefNV(UnbinnedResid, 2);
102102
};
103103

104+
struct DetInfoResid { // detector info associated with residual
105+
uint32_t word = 0; // container interpreted in a different way depending on the detector type
106+
//
107+
// TPC view: qTot and qMax of the cluster
108+
uint16_t qTotTPC() const { return static_cast<uint16_t>(word & 0xFFFFu); }
109+
uint16_t qMaxTPC() const { return static_cast<uint16_t>((word >> 16) & 0xFFFFu); }
110+
void setTPC(uint16_t qTot, uint16_t qMax) { word = (static_cast<uint32_t>(qMax) << 16) | static_cast<uint32_t>(qTot); }
111+
//
112+
// TRD view: q0, q1, q2 + calibrated slope (truncated to in +-3.5 range)
113+
static constexpr uint32_t TRDQ0NB = 7, TRDQ1NB = 7, TRDQ2NB = 6, TRDSlpNB = 12;
114+
static constexpr uint32_t TRDQ0Msk = (1 << TRDQ0NB) - 1, TRDQ1Msk = (1 << TRDQ1NB) - 1, TRDQ2Msk = ((1 << TRDQ2NB) - 1), TRDSlpMsk = (1 << TRDSlpNB) - 1;
115+
static constexpr float TRDMaxSlope = 3.5, TRDSlope2Int = ((1 << TRDSlpNB) - 1) / (2 * TRDMaxSlope), TRDInt2Slope = 1.f / TRDSlope2Int;
116+
uint16_t q0TRD() const { return static_cast<uint16_t>(word & TRDQ0Msk); }
117+
uint16_t q1TRD() const { return static_cast<uint16_t>((word >> TRDQ0NB) & TRDQ1Msk); }
118+
uint16_t q2TRD() const { return static_cast<uint16_t>((word >> (TRDQ0NB + TRDQ1NB)) & TRDQ2Msk); }
119+
float slopeTRD() const { return ((word >> (TRDQ0NB + TRDQ1NB + TRDQ2NB)) & TRDSlpMsk) * TRDInt2Slope - TRDMaxSlope; }
120+
void setTRD(uint8_t q0, uint8_t q1, uint8_t q2, float slope)
121+
{
122+
float rslope = (slope + TRDMaxSlope) * TRDSlope2Int;
123+
if (rslope < 0.f) {
124+
rslope = 0;
125+
} else if (rslope > TRDSlpMsk) {
126+
rslope = TRDSlpMsk;
127+
}
128+
uint32_t slpI = std::round(rslope);
129+
word = (static_cast<uint32_t>(slpI << (TRDQ0NB + TRDQ1NB + TRDQ2NB)) |
130+
static_cast<uint32_t>((q2 & TRDQ2Msk) << (TRDQ0NB + TRDQ1NB)) |
131+
static_cast<uint32_t>((q1 & TRDQ1Msk) << TRDQ0NB) |
132+
static_cast<uint32_t>(q0 & TRDQ0Msk));
133+
}
134+
//
135+
// TOF view (time difference in \mus wrt seeding ITS-TPC track)
136+
float timeTOF() const { return std::bit_cast<float>(word); }
137+
void setTOF(float t) { word = std::bit_cast<uint32_t>(t); }
138+
//
139+
// No info for ITS is stored
140+
//
141+
// PV view (time difference in \mus wrt contributing ITS-TPC track)
142+
float timePV() const { return std::bit_cast<float>(word); }
143+
void setPV(float t) { word = std::bit_cast<uint32_t>(t); }
144+
145+
ClassDefNV(DetInfoResid, 1);
146+
};
147+
104148
/// Structure for the information required to associate each residual with a given track type (ITS-TPC-TRD-TOF, etc)
105149
struct TrackDataCompact {
106150
TrackDataCompact() = default;
@@ -296,10 +340,13 @@ class TrackInterpolation
296340

297341
void setExtDetResid(bool v) { mExtDetResid = v; }
298342

299-
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, TrackData* trkData = nullptr);
343+
int processTRDLayer(const o2::trd::TrackTRD& trkTRD, int iLayer, o2::track::TrackParCov& trkWork, std::array<float, 2>* trkltTRDYZ = nullptr,
344+
std::array<float, 3>* trkltTRDCov = nullptr, TrackData* trkData = nullptr,
345+
o2::trd::Tracklet64* trk64 = nullptr, o2::trd::CalibratedTracklet* trkCalib = nullptr);
300346

301347
// --------------------------------- output ---------------------------------------------
302348
std::vector<UnbinnedResid>& getClusterResiduals() { return mClRes; }
349+
std::vector<DetInfoResid>& getClusterResidualsDetInfo() { return mDetInfoRes; }
303350
std::vector<TrackDataCompact>& getTrackDataCompact() { return mTrackDataCompact; }
304351
std::vector<TrackDataExtended>& getTrackDataExtended() { return mTrackDataExtended; }
305352
std::vector<TrackData>& getReferenceTracks() { return mTrackData; }
@@ -348,6 +395,7 @@ class TrackInterpolation
348395
std::vector<TrackDataCompact> mTrackDataCompact{}; ///< required to connect each residual to a global track
349396
std::vector<TrackDataExtended> mTrackDataExtended{}; ///< full tracking information for debugging
350397
std::vector<UnbinnedResid> mClRes{}; ///< residuals for each available TPC cluster of all tracks
398+
std::vector<DetInfoResid> mDetInfoRes{}; ///< packed detector info associated with each residual
351399
std::vector<TrackData> mTrackDataUnfiltered{}; ///< same as mTrackData, but for all tracks before outlier filtering
352400
std::vector<TPCClusterResiduals> mClResUnfiltered{}; ///< same as mClRes, but for all residuals before outlier filtering
353401

Detectors/TPC/calibration/SpacePoints/src/ResidualAggregator.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void ResidualsContainer::init(const TrackResiduals* residualsEngine, std::string
124124
treeOutResidualsUnbinned->Branch("trackInfo", &trackInfoPtr);
125125
treeOutResidualsUnbinned->Branch("CTPLumi", &lumiTF);
126126
treeOutResidualsUnbinned->Branch("timeMS", &timeMS);
127+
treeOutResidualsUnbinned->Branch("detInfo", &detInfoUnbResPtr);
127128
}
128129
if (writeTrackData) {
129130
treeOutTrackData = std::make_unique<TTree>("trackData", "Track information incl cluster range ref");
@@ -170,7 +171,7 @@ void ResidualsContainer::fillStatisticsBranches()
170171
}
171172
}
172173

173-
void ResidualsContainer::fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const UnbinnedResid> resid, const gsl::span<const o2::tpc::TrackDataCompact> trkRefsIn, const gsl::span<const o2::tpc::TrackData>* trkDataIn, const o2::ctp::LumiInfo* lumiInput)
174+
void ResidualsContainer::fill(const o2::dataformats::TFIDInfo& ti, const gsl::span<const UnbinnedResid> resid, const gsl::span<const DetInfoResid> detInfoRes, const gsl::span<const o2::tpc::TrackDataCompact> trkRefsIn, const gsl::span<const o2::tpc::TrackData>* trkDataIn, const o2::ctp::LumiInfo* lumiInput)
174175
{
175176
// receives large vector of unbinned residuals and fills the sector-wise vectors
176177
// with binned residuals and statistics
@@ -185,13 +186,14 @@ void ResidualsContainer::fill(const o2::dataformats::TFIDInfo& ti, const gsl::sp
185186
firstSeenTF = ti.tfCounter;
186187
}
187188
for (const auto& residIn : resid) {
188-
++nUnbinnedResidualsInTF;
189189
bool counterIncremented = false;
190190
if (writeUnbinnedResiduals) {
191191
unbinnedRes.push_back(residIn);
192+
detInfoUnbRes.push_back(detInfoRes.size() ? detInfoRes[nUnbinnedResidualsInTF] : DetInfoResid{});
192193
++nResidualsTotal;
193194
counterIncremented = true;
194195
}
196+
++nUnbinnedResidualsInTF;
195197
if (!writeBinnedResid) {
196198
continue;
197199
}
@@ -247,6 +249,7 @@ void ResidualsContainer::fill(const o2::dataformats::TFIDInfo& ti, const gsl::sp
247249
timeMS = orbitReset + ti.tfCounter * o2::constants::lhc::LHCOrbitMUS * 1.e-3;
248250
treeOutResidualsUnbinned->Fill();
249251
unbinnedRes.clear();
252+
detInfoUnbRes.clear();
250253
trackInfo.clear();
251254
}
252255
tfOrbits.push_back(ti.firstTForbit);
@@ -338,6 +341,9 @@ void ResidualsContainer::merge(ResidualsContainer* prev)
338341
if (writeUnbinnedResiduals) {
339342
prev->treeOutResidualsUnbinned->SetBranchAddress("res", &unbinnedResPtr);
340343
prev->treeOutResidualsUnbinned->SetBranchAddress("trackInfo", &trackInfoPtr);
344+
prev->treeOutResidualsUnbinned->SetBranchAddress("CTPLumi", &lumiTF);
345+
prev->treeOutResidualsUnbinned->SetBranchAddress("timeMS", &timeMS);
346+
prev->treeOutResidualsUnbinned->SetBranchAddress("detInfo", &detInfoUnbResPtr);
341347
for (int i = 0; i < treeOutResidualsUnbinned->GetEntries(); ++i) {
342348
treeOutResidualsUnbinned->GetEntry(i);
343349
prev->treeOutResidualsUnbinned->Fill();

Detectors/TPC/calibration/SpacePoints/src/SpacePointCalibLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#pragma link C++ class o2::tpc::TrackResiduals::VoxRes + ;
3030
#pragma link C++ class o2::tpc::TrackResiduals::VoxStats + ;
3131
#pragma link C++ class o2::tpc::UnbinnedResid + ;
32+
#pragma link C++ class o2::tpc::DetInfoResid + ;
3233
#pragma link C++ class std::vector < o2::tpc::UnbinnedResid> + ;
34+
#pragma link C++ class std::vector < o2::tpc::DetInfoResid> + ;
3335
#pragma link C++ class std::vector < o2::tpc::TrackResiduals::LocalResid> + ;
3436
#pragma link C++ class std::vector < o2::tpc::TrackResiduals::VoxStats> + ;
3537
#pragma link C++ class o2::tpc::ResidualAggregator + ;

0 commit comments

Comments
 (0)