|
45 | 45 | #include "TROOT.h" |
46 | 46 | #include "ReconstructionDataFormats/MatchInfoTOF.h" |
47 | 47 | #include "DataFormatsTOF/Cluster.h" |
| 48 | +#include "DataFormatsFT0/RecPoints.h" |
48 | 49 |
|
49 | 50 | using namespace o2::globaltracking; |
50 | 51 | using GTrackID = o2::dataformats::GlobalTrackID; |
@@ -206,25 +207,86 @@ class TPCTimeSeries : public Task |
206 | 207 | indicesITSTPC[tracksITSTPC[i].getRefTPC().getIndex()] = {i, idxVtx}; |
207 | 208 | } |
208 | 209 |
|
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 |
210 | 211 |
|
211 | 212 | // get matches to TOF in case skimmed data is produced |
212 | 213 | if (mUnbinnedWriter) { |
213 | 214 | // getLTIntegralOut(), ///< L,TOF integral calculated during the propagation |
214 | 215 | // getSignal() mSignal = 0.0; ///< TOF time in ps |
215 | 216 | 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}); |
217 | 218 | const std::vector<gsl::span<const o2::dataformats::MatchInfoTOF>> tofMatches{recoData.getTPCTOFMatches(), recoData.getTPCTRDTOFMatches(), recoData.getITSTPCTOFMatches(), recoData.getITSTPCTRDTOFMatches()}; |
218 | 219 |
|
| 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 | + |
219 | 236 | // loop over ITS-TPC-TRD-TOF and ITS-TPC-TOF tracks an store for each ITS-TPC track the TOF track index |
220 | 237 | for (const auto& tofMatch : tofMatches) { |
221 | 238 | for (const auto& tpctofmatch : tofMatch) { |
222 | 239 | auto refTPC = recoData.getTPCContributorGID(tpctofmatch.getTrackRef()); |
223 | 240 | if (refTPC.isIndexSet()) { |
224 | 241 | 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; |
226 | 251 | 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}; |
228 | 290 | } |
229 | 291 | } |
230 | 292 | } |
@@ -1055,7 +1117,7 @@ class TPCTimeSeries : public Task |
1055 | 1117 | return isGoodTrack; |
1056 | 1118 | } |
1057 | 1119 |
|
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) |
1059 | 1121 | { |
1060 | 1122 | const auto& trackFull = tracksTPC[iTrk]; |
1061 | 1123 | const bool isGoodTrack = checkTrack(trackFull); |
@@ -1444,6 +1506,7 @@ class TPCTimeSeries : public Task |
1444 | 1506 | << "mDeltaTTOFTPC=" << std::get<5>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF |
1445 | 1507 | << "vertexTime=" << vertexTime /// time stamp assigned to the vertex |
1446 | 1508 | << "trackTime0=" << trackTime0 /// time stamp assigned to the track |
| 1509 | + << "TOFmask=" << std::get<6>(idxTPCTrackToTOFCluster[iTrk]) /// delta T- TPC TOF |
1447 | 1510 | // TPC delta param |
1448 | 1511 | << "deltaTPCParamInOutTgl=" << deltaTPCParamInOutTgl |
1449 | 1512 | << "deltaTPCParamInOutQPt=" << deltaTPCParamInOutQPt |
@@ -1751,14 +1814,19 @@ class TPCTimeSeries : public Task |
1751 | 1814 | } |
1752 | 1815 | }; |
1753 | 1816 |
|
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) |
1755 | 1818 | { |
1756 | 1819 | auto dataRequest = std::make_shared<DataRequest>(); |
1757 | 1820 | bool useMC = false; |
1758 | 1821 | GTrackID::mask_t srcTracks = GTrackID::getSourcesMask("TPC,ITS,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF") & src; |
1759 | 1822 | srcTracks.set(GTrackID::TPC); // TPC must be always there |
1760 | 1823 | dataRequest->requestTracks(srcTracks, useMC); |
1761 | 1824 | dataRequest->requestClusters(GTrackID::getSourcesMask("TPC"), useMC); |
| 1825 | + |
| 1826 | + if (useft0) { |
| 1827 | + dataRequest->requestFT0RecPoints(false); |
| 1828 | + } |
| 1829 | + |
1762 | 1830 | bool tpcOnly = srcTracks == GTrackID::getSourcesMask("TPC"); |
1763 | 1831 | if (!tpcOnly) { |
1764 | 1832 | dataRequest->requestPrimaryVertices(useMC); |
|
0 commit comments