Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace tpc
static constexpr header::DataDescription getDataDescriptionTimeSeries() { return header::DataDescription{"TIMESERIES"}; }
static constexpr header::DataDescription getDataDescriptionTPCTimeSeriesTFId() { return header::DataDescription{"ITPCTSTFID"}; }

o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, o2::dataformats::GlobalTrackID::mask_t src);
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);

} // end namespace tpc
} // end namespace o2
Expand Down
68 changes: 62 additions & 6 deletions Detectors/TPC/workflow/src/TPCTimeSeriesSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "TROOT.h"
#include "ReconstructionDataFormats/MatchInfoTOF.h"
#include "DataFormatsTOF/Cluster.h"
#include "DataFormatsFT0/RecPoints.h"

using namespace o2::globaltracking;
using GTrackID = o2::dataformats::GlobalTrackID;
Expand Down Expand Up @@ -206,25 +207,74 @@ class TPCTimeSeries : public Task
indicesITSTPC[tracksITSTPC[i].getRefTPC().getIndex()] = {i, idxVtx};
}

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
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

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

const auto& ft0rec = recoData.getFT0RecPoints();
// fill available FT0-AC event times vs BClong
std::map<ULong64_t, short> t0array;
for (const auto& t0 : ft0rec) {
if (!(t0.isValidTime(1) && t0.isValidTime(2))) { // skip if !(A & C)
continue;
}

ULong64_t bclong = (t0.mIntRecord.orbit - processing_helpers::getFirstTForbit(pc)) * o2::constants::lhc::LHCMaxBunches + t0.mIntRecord.bc;
if (t0array.find(bclong) == t0array.end()) { // add if it doesn't exist
t0array.emplace(std::make_pair(bclong, t0.getCollisionTime(0)));
}
}

static const double BC_TIME_INPS_INV = 1E-3 / o2::constants::lhc::LHCBunchSpacingNS;

// loop over ITS-TPC-TRD-TOF and ITS-TPC-TOF tracks an store for each ITS-TPC track the TOF track index
for (const auto& tofMatch : tofMatches) {
for (const auto& tpctofmatch : tofMatch) {
auto refTPC = recoData.getTPCContributorGID(tpctofmatch.getTrackRef());
if (refTPC.isIndexSet()) {
o2::track::TrackLTIntegral ltIntegral = tpctofmatch.getLTIntegralOut();
double signal = tpctofmatch.getSignal();
ULong64_t bclongtof = (tpctofmatch.getSignal() - 10000) * BC_TIME_INPS_INV;
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)
if (!(t0array.find(bclongtof) == t0array.end())) { // subtract FT0-AC if it exists in the same BC
t0 += t0array.find(bclongtof)->second;
}

double signal = tpctofmatch.getSignal() - t0;
float deltaT = tpctofmatch.getDeltaT();
idxTPCTrackToTOFCluster[refTPC] = {tpctofmatch.getIdxTOFCl(), tpctofmatch.getDXatTOF(), tpctofmatch.getDZatTOF(), ltIntegral, signal, deltaT};

float dy = tpctofmatch.getDYatTOF(); // residual orthogonal to the strip (it should be close to zero)
bool isMultiHitZ = tpctofmatch.getHitPatternUpDown();
bool isMultiHitX = tpctofmatch.getHitPatternLeftRight();
bool isMultiStripMatch = tpctofmatch.getChi2() < 1E-9;
float chi2 = tpctofmatch.getChi2();

int mask = 0;
if (isMultiHitX) { // 1nd bit on if multiple hits along X
mask += 1;
}
if (isMultiHitZ) { // 2nd bit on if multiple hits along Z
mask += 2;
}
if (fabs(dy) > 0.5) { // 3rd bit on if Y-residual too large
mask += 4;
}
if (isMultiStripMatch) { // 4th bit on if two strips fired
mask += 8;
}
if (chi2 > 3) { // 5th bit on if chi2 > 3
mask += 16;
}
if (chi2 > 5) {
mask += 32;
}

idxTPCTrackToTOFCluster[refTPC] = {tpctofmatch.getIdxTOFCl(), tpctofmatch.getDXatTOF(), tpctofmatch.getDZatTOF(), ltIntegral, signal, deltaT, mask};
}
}
}
Expand Down Expand Up @@ -1055,7 +1105,7 @@ class TPCTimeSeries : public Task
return isGoodTrack;
}

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)
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)
{
const auto& trackFull = tracksTPC[iTrk];
const bool isGoodTrack = checkTrack(trackFull);
Expand Down Expand Up @@ -1444,6 +1494,7 @@ class TPCTimeSeries : public Task
<< "mDeltaTTOFTPC=" << std::get<5>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF
<< "vertexTime=" << vertexTime /// time stamp assigned to the vertex
<< "trackTime0=" << trackTime0 /// time stamp assigned to the track
<< "TOFmask=" << std::get<6>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF
// TPC delta param
<< "deltaTPCParamInOutTgl=" << deltaTPCParamInOutTgl
<< "deltaTPCParamInOutQPt=" << deltaTPCParamInOutQPt
Expand Down Expand Up @@ -1751,14 +1802,19 @@ class TPCTimeSeries : public Task
}
};

o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, GTrackID::mask_t src)
o2::framework::DataProcessorSpec getTPCTimeSeriesSpec(const bool disableWriter, const o2::base::Propagator::MatCorrType matType, const bool enableUnbinnedWriter, GTrackID::mask_t src, bool useft0)
{
auto dataRequest = std::make_shared<DataRequest>();
bool useMC = false;
GTrackID::mask_t srcTracks = GTrackID::getSourcesMask("TPC,ITS,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF") & src;
srcTracks.set(GTrackID::TPC); // TPC must be always there
dataRequest->requestTracks(srcTracks, useMC);
dataRequest->requestClusters(GTrackID::getSourcesMask("TPC"), useMC);

if (useft0) {
dataRequest->requestFT0RecPoints(false);
}

bool tpcOnly = srcTracks == GTrackID::getSourcesMask("TPC");
if (!tpcOnly) {
dataRequest->requestPrimaryVertices(useMC);
Expand Down
4 changes: 3 additions & 1 deletion Detectors/TPC/workflow/src/tpc-time-series.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
{"disable-root-output", VariantType::Bool, false, {"disable root-files output writers"}},
{"enable-unbinned-root-output", VariantType::Bool, false, {"writing out unbinned track data"}},
{"track-sources", VariantType::String, std::string{o2::dataformats::GlobalTrackID::ALL}, {"comma-separated list of sources to use"}},
{"use-ft0", VariantType::Bool, false, {"enable FT0 rec-points"}},
{"material-type", VariantType::Int, 2, {"Type for the material budget during track propagation: 0=None, 1=Geo, 2=LUT"}}};
std::swap(workflowOptions, options);
}
Expand All @@ -43,7 +44,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
const bool enableUnbinnedWriter = config.options().get<bool>("enable-unbinned-root-output");
auto src = o2::dataformats::GlobalTrackID::getSourcesMask(config.options().get<std::string>("track-sources"));
auto materialType = static_cast<o2::base::Propagator::MatCorrType>(config.options().get<int>("material-type"));
workflow.emplace_back(o2::tpc::getTPCTimeSeriesSpec(disableWriter, materialType, enableUnbinnedWriter, src));
const bool useft0 = config.options().get<bool>("use-ft0");
workflow.emplace_back(o2::tpc::getTPCTimeSeriesSpec(disableWriter, materialType, enableUnbinnedWriter, src, useft0));
if (!disableWriter) {
workflow.emplace_back(o2::tpc::getTPCTimeSeriesWriterSpec());
}
Expand Down
Loading