Skip to content

Commit 5d1e061

Browse files
committed
improve TOF infos in TPCtimeseries
1 parent b77f031 commit 5d1e061

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed

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: 62 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,74 @@ 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, 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, 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+
ULong64_t bclong = (t0.mIntRecord.orbit - processing_helpers::getFirstTForbit(pc)) * o2::constants::lhc::LHCMaxBunches + t0.mIntRecord.bc;
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+
if (!(t0array.find(bclongtof) == t0array.end())) { // subtract FT0-AC if it exists in the same BC
245+
t0 += t0array.find(bclongtof)->second;
246+
}
247+
248+
double signal = tpctofmatch.getSignal() - t0;
226249
float deltaT = tpctofmatch.getDeltaT();
227-
idxTPCTrackToTOFCluster[refTPC] = {tpctofmatch.getIdxTOFCl(), tpctofmatch.getDXatTOF(), tpctofmatch.getDZatTOF(), ltIntegral, signal, deltaT};
250+
251+
float dy = tpctofmatch.getDYatTOF(); // residual orthogonal to the strip (it should be close to zero)
252+
bool isMultiHitZ = tpctofmatch.getHitPatternUpDown();
253+
bool isMultiHitX = tpctofmatch.getHitPatternLeftRight();
254+
bool isMultiStripMatch = tpctofmatch.getChi2() < 1E-9;
255+
float chi2 = tpctofmatch.getChi2();
256+
257+
int mask = 0;
258+
if (isMultiHitX) { // 1nd bit on if multiple hits along X
259+
mask += 1;
260+
}
261+
if (isMultiHitZ) { // 2nd bit on if multiple hits along Z
262+
mask += 2;
263+
}
264+
if (fabs(dy) > 0.5) { // 3rd bit on if Y-residual too large
265+
mask += 4;
266+
}
267+
if (isMultiStripMatch) { // 4th bit on if two strips fired
268+
mask += 8;
269+
}
270+
if (chi2 > 3) { // 5th bit on if chi2 > 3
271+
mask += 16;
272+
}
273+
if (chi2 > 5) {
274+
mask += 32;
275+
}
276+
277+
idxTPCTrackToTOFCluster[refTPC] = {tpctofmatch.getIdxTOFCl(), tpctofmatch.getDXatTOF(), tpctofmatch.getDZatTOF(), ltIntegral, signal, deltaT, mask};
228278
}
229279
}
230280
}
@@ -1055,7 +1105,7 @@ class TPCTimeSeries : public Task
10551105
return isGoodTrack;
10561106
}
10571107

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)
1108+
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, int>>& idxTPCTrackToTOFCluster, const gsl::span<const o2::tof::Cluster> tofClusters)
10591109
{
10601110
const auto& trackFull = tracksTPC[iTrk];
10611111
const bool isGoodTrack = checkTrack(trackFull);
@@ -1444,6 +1494,7 @@ class TPCTimeSeries : public Task
14441494
<< "mDeltaTTOFTPC=" << std::get<5>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF
14451495
<< "vertexTime=" << vertexTime /// time stamp assigned to the vertex
14461496
<< "trackTime0=" << trackTime0 /// time stamp assigned to the track
1497+
<< "TOFmask=" << std::get<6>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF
14471498
// TPC delta param
14481499
<< "deltaTPCParamInOutTgl=" << deltaTPCParamInOutTgl
14491500
<< "deltaTPCParamInOutQPt=" << deltaTPCParamInOutQPt
@@ -1751,14 +1802,19 @@ class TPCTimeSeries : public Task
17511802
}
17521803
};
17531804

1754-
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, GTrackID::mask_t src)
1805+
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, GTrackID::mask_t src, bool useft0)
17551806
{
17561807
auto dataRequest = std::make_shared<DataRequest>();
17571808
bool useMC = false;
17581809
GTrackID::mask_t srcTracks = GTrackID::getSourcesMask("TPC,ITS,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF") & src;
17591810
srcTracks.set(GTrackID::TPC); // TPC must be always there
17601811
dataRequest->requestTracks(srcTracks, useMC);
17611812
dataRequest->requestClusters(GTrackID::getSourcesMask("TPC"), useMC);
1813+
1814+
if (useft0) {
1815+
dataRequest->requestFT0RecPoints(false);
1816+
}
1817+
17621818
bool tpcOnly = srcTracks == GTrackID::getSourcesMask("TPC");
17631819
if (!tpcOnly) {
17641820
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)