Skip to content

Commit f80f564

Browse files
committed
improve TOF infos in TPCtimeseries
1 parent 828216a commit f80f564

File tree

5 files changed

+90
-9
lines changed

5 files changed

+90
-9
lines changed

DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ class MatchInfoTOF
7575
double getT0true() const { return mT0true; }
7676
void setT0true(double val) { mT0true = val; }
7777

78+
enum QualityFlags { isMultiHitX = 0x1 << 0,
79+
isMultiHitZ = 0x1 << 1,
80+
badDy = 0x1 << 2,
81+
isMultiStrip = 0x1 << 3,
82+
isNotInPad = 0x1 << 4,
83+
chiGT3 = 0x1 << 5,
84+
chiGT5 = 0x1 << 6,
85+
hasT0sameBC = 0x1 << 7,
86+
hasT0_1BCbefore = 0x1 << 8,
87+
hasT0_2BCbefore = 0x1 << 9 };
88+
7889
private:
7990
int mIdLocal; // track id in sector of the pair track-TOFcluster
8091
float mChi2; // chi2 of the pair track-TOFcluster

Detectors/TPC/workflow/include/TPCWorkflow/TPCTimeSeriesSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace tpc
2323
static constexpr header::DataDescription getDataDescriptionTimeSeries() { return header::DataDescription{"TIMESERIES"}; }
2424
static constexpr header::DataDescription getDataDescriptionTPCTimeSeriesTFId() { return header::DataDescription{"ITPCTSTFID"}; }
2525

26-
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, o2::dataformats::GlobalTrackID::mask_t src);
26+
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, o2::dataformats::GlobalTrackID::mask_t src, bool useft0 = false);
2727

2828
} // end namespace tpc
2929
} // end namespace o2

Detectors/TPC/workflow/src/TPCTimeSeriesSpec.cxx

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "TROOT.h"
4646
#include "ReconstructionDataFormats/MatchInfoTOF.h"
4747
#include "DataFormatsTOF/Cluster.h"
48+
#include "DataFormatsFT0/RecPoints.h"
4849

4950
using namespace o2::globaltracking;
5051
using GTrackID = o2::dataformats::GlobalTrackID;
@@ -206,25 +207,86 @@ class TPCTimeSeries : public Task
206207
indicesITSTPC[tracksITSTPC[i].getRefTPC().getIndex()] = {i, idxVtx};
207208
}
208209

209-
std::vector<std::tuple<int, float, float, o2::track::TrackLTIntegral, double, float>> idxTPCTrackToTOFCluster; // store for each tpc track index the index to the TOF cluster
210+
std::vector<std::tuple<int, float, float, o2::track::TrackLTIntegral, double, float, unsigned int>> idxTPCTrackToTOFCluster; // store for each tpc track index the index to the TOF cluster
210211

211212
// get matches to TOF in case skimmed data is produced
212213
if (mUnbinnedWriter) {
213214
// getLTIntegralOut(), ///< L,TOF integral calculated during the propagation
214215
// getSignal() mSignal = 0.0; ///< TOF time in ps
215216
o2::track::TrackLTIntegral defLT;
216-
idxTPCTrackToTOFCluster = std::vector<std::tuple<int, float, float, o2::track::TrackLTIntegral, double, float>>(tracksTPC.size(), {-1, -999, -999, defLT, 0, 0});
217+
idxTPCTrackToTOFCluster = std::vector<std::tuple<int, float, float, o2::track::TrackLTIntegral, double, float, unsigned int>>(tracksTPC.size(), {-1, -999, -999, defLT, 0, 0, 0});
217218
const std::vector<gsl::span<const o2::dataformats::MatchInfoTOF>> tofMatches{recoData.getTPCTOFMatches(), recoData.getTPCTRDTOFMatches(), recoData.getITSTPCTOFMatches(), recoData.getITSTPCTRDTOFMatches()};
218219

220+
const auto& ft0rec = recoData.getFT0RecPoints();
221+
// fill available FT0-AC event times vs BClong
222+
std::map<ULong64_t, short> t0array;
223+
for (const auto& t0 : ft0rec) {
224+
if (!(t0.isValidTime(1) && t0.isValidTime(2))) { // skip if !(A & C)
225+
continue;
226+
}
227+
228+
auto bclong = t0.mIntRecord.differenceInBC(recoData.startIR);
229+
if (t0array.find(bclong) == t0array.end()) { // add if it doesn't exist
230+
t0array.emplace(std::make_pair(bclong, t0.getCollisionTime(0)));
231+
}
232+
}
233+
234+
static const double BC_TIME_INPS_INV = 1E-3 / o2::constants::lhc::LHCBunchSpacingNS;
235+
219236
// loop over ITS-TPC-TRD-TOF and ITS-TPC-TOF tracks an store for each ITS-TPC track the TOF track index
220237
for (const auto& tofMatch : tofMatches) {
221238
for (const auto& tpctofmatch : tofMatch) {
222239
auto refTPC = recoData.getTPCContributorGID(tpctofmatch.getTrackRef());
223240
if (refTPC.isIndexSet()) {
224241
o2::track::TrackLTIntegral ltIntegral = tpctofmatch.getLTIntegralOut();
225-
double signal = tpctofmatch.getSignal();
242+
ULong64_t bclongtof = (tpctofmatch.getSignal() - 10000) * BC_TIME_INPS_INV;
243+
double t0 = 0; // bclongtof * o2::constants::lhc::LHCBunchSpacingNS * 1E3; // if you want to subtract also the BC uncomment this part (-> tofsignal can be a float)
244+
unsigned int mask = 0;
245+
if (!(t0array.find(bclongtof) == t0array.end())) { // subtract FT0-AC if it exists in the same BC
246+
t0 += t0array.find(bclongtof)->second;
247+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::hasT0sameBC; // 8th bit if FT0-AC in same BC
248+
}
249+
250+
double signal = tpctofmatch.getSignal() - t0;
226251
float deltaT = tpctofmatch.getDeltaT();
227-
idxTPCTrackToTOFCluster[refTPC] = {tpctofmatch.getIdxTOFCl(), tpctofmatch.getDXatTOF(), tpctofmatch.getDZatTOF(), ltIntegral, signal, deltaT};
252+
253+
float dy = tpctofmatch.getDYatTOF(); // residual orthogonal to the strip (it should be close to zero)
254+
bool isMultiHitZ = tpctofmatch.getHitPatternUpDown();
255+
bool isMultiHitX = tpctofmatch.getHitPatternLeftRight();
256+
bool isMultiStripMatch = tpctofmatch.getChi2() < 1E-9;
257+
float chi2 = tpctofmatch.getChi2();
258+
bool hasT0_1BCbefore = (t0array.find(bclongtof - 1) != t0array.end());
259+
bool hasT0_2BCbefore = (t0array.find(bclongtof - 2) != t0array.end());
260+
261+
if (isMultiHitX) { // 1nd bit on if multiple hits along X
262+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::isMultiHitX;
263+
}
264+
if (isMultiHitZ) { // 2nd bit on if multiple hits along Z
265+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::isMultiHitZ;
266+
}
267+
if (fabs(dy) > 0.5) { // 3rd bit on if Y-residual too large
268+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::badDy;
269+
}
270+
if (isMultiStripMatch) { // 4th bit on if two strips fired
271+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::isMultiStrip;
272+
}
273+
if (chi2 > 1E-4) { // 5th bit on if chi2 > 1E-4 -> not inside the pad
274+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::isNotInPad;
275+
}
276+
if (chi2 > 3) { // 6th bit on if chi2 > 3
277+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::chiGT3;
278+
}
279+
if (chi2 > 5) { // 7th bit on if chi2 > 5
280+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::chiGT5;
281+
}
282+
if (hasT0_1BCbefore) { // 9th bit if FT0-AC also BC before
283+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::hasT0_1BCbefore;
284+
}
285+
if (hasT0_2BCbefore) { // 10th bit if FT0-AC also 2BCs before
286+
mask |= o2::dataformats::MatchInfoTOF::QualityFlags::hasT0_1BCbefore;
287+
}
288+
289+
idxTPCTrackToTOFCluster[refTPC] = {tpctofmatch.getIdxTOFCl(), tpctofmatch.getDXatTOF(), tpctofmatch.getDZatTOF(), ltIntegral, signal, deltaT, mask};
228290
}
229291
}
230292
}
@@ -1055,7 +1117,7 @@ class TPCTimeSeries : public Task
10551117
return isGoodTrack;
10561118
}
10571119

1058-
void fillDCA(const gsl::span<const TrackTPC> tracksTPC, const gsl::span<const o2::dataformats::TrackTPCITS> tracksITSTPC, const gsl::span<const o2::dataformats::PrimaryVertex> vertices, const int iTrk, const int iThread, const std::unordered_map<unsigned int, std::array<int, 2>>& indicesITSTPC, const gsl::span<const o2::its::TrackITS> tracksITS, const std::vector<std::tuple<int, float, float, o2::track::TrackLTIntegral, double, float>>& idxTPCTrackToTOFCluster, const gsl::span<const o2::tof::Cluster> tofClusters)
1120+
void fillDCA(const gsl::span<const TrackTPC> tracksTPC, const gsl::span<const o2::dataformats::TrackTPCITS> tracksITSTPC, const gsl::span<const o2::dataformats::PrimaryVertex> vertices, const int iTrk, const int iThread, const std::unordered_map<unsigned int, std::array<int, 2>>& indicesITSTPC, const gsl::span<const o2::its::TrackITS> tracksITS, const std::vector<std::tuple<int, float, float, o2::track::TrackLTIntegral, double, float, unsigned int>>& idxTPCTrackToTOFCluster, const gsl::span<const o2::tof::Cluster> tofClusters)
10591121
{
10601122
const auto& trackFull = tracksTPC[iTrk];
10611123
const bool isGoodTrack = checkTrack(trackFull);
@@ -1444,6 +1506,7 @@ class TPCTimeSeries : public Task
14441506
<< "mDeltaTTOFTPC=" << std::get<5>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF
14451507
<< "vertexTime=" << vertexTime /// time stamp assigned to the vertex
14461508
<< "trackTime0=" << trackTime0 /// time stamp assigned to the track
1509+
<< "TOFmask=" << std::get<6>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF
14471510
// TPC delta param
14481511
<< "deltaTPCParamInOutTgl=" << deltaTPCParamInOutTgl
14491512
<< "deltaTPCParamInOutQPt=" << deltaTPCParamInOutQPt
@@ -1751,14 +1814,19 @@ class TPCTimeSeries : public Task
17511814
}
17521815
};
17531816

1754-
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, GTrackID::mask_t src)
1817+
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, GTrackID::mask_t src, bool useft0)
17551818
{
17561819
auto dataRequest = std::make_shared<DataRequest>();
17571820
bool useMC = false;
17581821
GTrackID::mask_t srcTracks = GTrackID::getSourcesMask("TPC,ITS,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF") & src;
17591822
srcTracks.set(GTrackID::TPC); // TPC must be always there
17601823
dataRequest->requestTracks(srcTracks, useMC);
17611824
dataRequest->requestClusters(GTrackID::getSourcesMask("TPC"), useMC);
1825+
1826+
if (useft0) {
1827+
dataRequest->requestFT0RecPoints(false);
1828+
}
1829+
17621830
bool tpcOnly = srcTracks == GTrackID::getSourcesMask("TPC");
17631831
if (!tpcOnly) {
17641832
dataRequest->requestPrimaryVertices(useMC);

Detectors/TPC/workflow/src/tpc-time-series.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
2929
{"disable-root-output", VariantType::Bool, false, {"disable root-files output writers"}},
3030
{"enable-unbinned-root-output", VariantType::Bool, false, {"writing out unbinned track data"}},
3131
{"track-sources", VariantType::String, std::string{o2::dataformats::GlobalTrackID::ALL}, {"comma-separated list of sources to use"}},
32+
{"use-ft0", VariantType::Bool, false, {"enable FT0 rec-points"}},
3233
{"material-type", VariantType::Int, 2, {"Type for the material budget during track propagation: 0=None, 1=Geo, 2=LUT"}}};
3334
std::swap(workflowOptions, options);
3435
}
@@ -43,7 +44,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
4344
const bool enableUnbinnedWriter = config.options().get<bool>("enable-unbinned-root-output");
4445
auto src = o2::dataformats::GlobalTrackID::getSourcesMask(config.options().get<std::string>("track-sources"));
4546
auto materialType = static_cast<o2::base::Propagator::MatCorrType>(config.options().get<int>("material-type"));
46-
workflow.emplace_back(o2::tpc::getTPCTimeSeriesSpec(disableWriter, materialType, enableUnbinnedWriter, src));
47+
const bool useft0 = config.options().get<bool>("use-ft0");
48+
workflow.emplace_back(o2::tpc::getTPCTimeSeriesSpec(disableWriter, materialType, enableUnbinnedWriter, src, useft0));
4749
if (!disableWriter) {
4850
workflow.emplace_back(o2::tpc::getTPCTimeSeriesWriterSpec());
4951
}

prodtests/full-system-test/calib-workflow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if [[ $CALIB_ASYNC_EXTRACTTPCCURRENTS == 1 ]]; then
5454
add_W o2-tpc-integrate-cluster-workflow "${CONFIG_CTPTPC}"
5555
fi
5656
if [[ $CALIB_ASYNC_EXTRACTTIMESERIES == 1 ]] ; then
57-
CONFIG_TPCTIMESERIES=
57+
CONFIG_TPCTIMESERIES=" --use-ft0"
5858
: ${CALIB_ASYNC_SAMPLINGFACTORTIMESERIES:=0.001}
5959
if [[ ! -z ${CALIB_ASYNC_ENABLEUNBINNEDTIMESERIES:-} ]]; then
6060
CONFIG_TPCTIMESERIES+=" --enable-unbinned-root-output --sample-unbinned-tsallis --threads ${TPCTIMESERIES_THREADS:-1}"

0 commit comments

Comments
 (0)