From 2d83f1da141ac8fa12971ebc428dcc84f4a0effd Mon Sep 17 00:00:00 2001 From: Francesco Noferini Date: Mon, 14 Jun 2021 17:34:38 +0200 Subject: [PATCH 1/7] generalize TOF matcher --- .../ReconstructionDataFormats/MatchInfoTOF.h | 12 +- .../include/GlobalTracking/MatchTOF.h | 153 +--- Detectors/GlobalTracking/src/MatchTOF.cxx | 773 +++++------------- .../src/TOFMatcherSpec.cxx | 60 +- .../src/tof-matcher-workflow.cxx | 5 +- .../tofworkflow/src/RecoWorkflowSpec.cxx | 12 +- .../src/RecoWorkflowWithTPCSpec.cxx | 18 +- .../TOF/workflowIO/src/TOFCalibWriterSpec.cxx | 4 +- .../workflowIO/src/TOFMatchedWriterSpec.cxx | 4 +- 9 files changed, 320 insertions(+), 721 deletions(-) diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h index ea0ba1e1f94d9..db8694a5a331c 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h @@ -29,7 +29,13 @@ class MatchInfoTOF using evIdx = o2::dataformats::EvIndex; public: - MatchInfoTOF(evIdx evIdxTOFCl, float chi2, o2::track::TrackLTIntegral trkIntLT, evGIdx evIdxTrack, float dt = 0, float z = 0) : mEvIdxTOFCl(evIdxTOFCl), mChi2(chi2), mIntLT(trkIntLT), mEvIdxTrack(evIdxTrack), mDeltaT(dt), mZatTOF(z){}; + enum TrackType : int8_t { TPC = 0, + ITSTPC, + TPCTRD, + ITSTPCTRD, + SIZE }; + + MatchInfoTOF(evIdx evIdxTOFCl, float chi2, o2::track::TrackLTIntegral trkIntLT, evGIdx evIdxTrack, TrackType trkType, float dt = 0, float z = 0) : mEvIdxTOFCl(evIdxTOFCl), mChi2(chi2), mIntLT(trkIntLT), mEvIdxTrack(evIdxTrack), mTrackType(trkType), mDeltaT(dt), mZatTOF(z){}; MatchInfoTOF() = default; void setEvIdxTOFCl(evIdx index) { mEvIdxTOFCl = index; } void setEvIdxTrack(evGIdx index) { mEvIdxTrack = index; } @@ -43,6 +49,9 @@ class MatchInfoTOF void setChi2(int chi2) { mChi2 = chi2; } float getChi2() const { return mChi2; } + void setTrackType(TrackType value) { mTrackType = value; } + TrackType getTrackType() const { return mTrackType; } + o2::track::TrackLTIntegral& getLTIntegralOut() { return mIntLT; } const o2::track::TrackLTIntegral& getLTIntegralOut() const { return mIntLT; } void print() const; @@ -59,6 +68,7 @@ class MatchInfoTOF evGIdx mEvIdxTrack; ///< EvIdx for track (first: ev index; second: track global index) float mZatTOF = 0.0; ///< Z position at TOF float mDeltaT = 0.0; ///< tTOF - TPC (microsec) + TrackType mTrackType; //! track type (TPC, ITSTPC, TPCTRD, ITSTPCTRD) ClassDefNV(MatchInfoTOF, 2); }; diff --git a/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h b/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h index ca2118de741a5..d2ff6dfb1f4a0 100644 --- a/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h +++ b/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h @@ -41,12 +41,6 @@ // from FIT #include "DataFormatsFT0/RecPoints.h" -#ifdef _ALLOW_DEBUG_TREES_ -//#define _ALLOW_TOF_DEBUG_ -#endif - -class TTree; - namespace o2 { @@ -82,14 +76,7 @@ class MatchTOF public: ///< perform matching for provided input - void run(); - - ///< fill output tree - void fill(); - - ///< perform all initializations - void init(); - void initTPConly(); + virtual void run(); void setCosmics() { @@ -98,42 +85,12 @@ class MatchTOF mTimeTolerance = 50e3; } + void setHighPurity(bool value = true) { mSetHighPurity = value; } + ///< attach DPL data and run - void run(const gsl::span& trackArray, const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab, const gsl::span& itstpclab); - void run(const gsl::span& trackArray, const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab, const gsl::span& tpclab); - - ///< set tree/chain containing tracks - void setInputTreeTracks(TTree* tree) { mInputTreeTracks = tree; } - - ///< set tree/chain containing TPC tracks - void setInputTreeTPCTracks(TTree* tree) { mTreeTPCTracks = tree; } - - ///< set tree/chain containing TOF clusters - void setInputTreeTOFClusters(TTree* tree) { mTreeTOFClusters = tree; } - - ///< set output tree to write matched tracks - void setOutputTree(TTree* tr) { mOutputTree = tr; } - - ///< set output tree to write calibration infos - void setOutputTreeCalib(TTree* tr) { mOutputTreeCalib = tr; } - - ///< set input branch names for the input from the tree - void setTrackBranchName(const std::string& nm) { mTracksBranchName = nm; } - void setTPCTrackBranchName(const std::string& nm) { mTPCTracksBranchName = nm; } - void setTPCMCTruthBranchName(const std::string& nm) { mTPCMCTruthBranchName = nm; } - void setTOFMCTruthBranchName(const std::string& nm) { mTOFMCTruthBranchName = nm; } - void setTOFClusterBranchName(const std::string& nm) { mTOFClusterBranchName = nm; } - void setOutTOFMCTruthBranchName(const std::string& nm) { mOutTOFMCTruthBranchName = nm; } - void setOutTracksBranchName(const std::string& nm) { mOutTracksBranchName = nm; } - void setOutCalibBranchName(const std::string& nm) { mOutCalibBranchName = nm; } - - ///< get input branch names for the input from the tree - const std::string& getTracksBranchName() const { return mTracksBranchName; } - const std::string& getTPCTracksBranchName() const { return mTPCTracksBranchName; } - const std::string& getTPCMCTruthBranchName() const { return mTPCMCTruthBranchName; } - const std::string& getTOFMCTruthBranchName() const { return mTOFMCTruthBranchName; } - const std::string& getTOFClusterBranchName() const { return mTOFClusterBranchName; } - const std::string& getOutTOFMCTruthBranchName() const { return mOutTOFMCTruthBranchName; } + void setTOFClusterArray(const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab); + void setTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab); + void setITSTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab); ///< print settings void print() const; @@ -174,18 +131,10 @@ class MatchTOF } } - ///< get the name of output debug file - const std::string& getDebugTreeFileName() const { return mDebugTreeFileName; } - - ///< fill matching debug tree - void fillTOFmatchTree(const char* tname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, float intLength, float intTimePion, float timeTOF); - void fillTOFmatchTreeWithLabels(const char* tname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, int TPClabelTrackID, int TPClabelEventID, int TPClabelSourceID, int TOFlabelTrackID0, int TOFlabelEventID0, int TOFlabelSourceID0, int TOFlabelTrackID1, int TOFlabelEventID1, int TOFlabelSourceID1, int TOFlabelTrackID2, int TOFlabelEventID2, int TOFlabelSourceID2, float intLength, float intTimePion, float timeTOF); - void dumpWinnerMatches(); - - std::vector& getMatchedTrackVector() { return mMatchedTracks; } + std::vector& getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType index) { return mMatchedTracks[index]; } std::vector& getCalibVector() { return mCalibInfoTOF; } - std::vector& getMatchedTOFLabelsVector() { return mOutTOFLabels; } ///< get vector of TOF label of matched tracks + std::vector& getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType index) { return mOutTOFLabels[index]; } ///< get vector of TOF label of matched tracks // this method is deprecated void setFITRecPoints(const std::vector* recpoints) @@ -224,7 +173,7 @@ class MatchTOF void makeConstrainedTPCTracks(V& container) { checkRefitter(); - int nmatched = mMatchedTracks.size(), nconstrained = 0; + int nmatched = mMatchedTracks[o2::dataformats::MatchInfoTOF::TrackType::TPC].size(), nconstrained = 0; container.resize(nmatched); for (unsigned i = 0; i < nmatched; i++) { if (makeConstrainedTPCTrack(i, container[nconstrained])) { @@ -234,19 +183,15 @@ class MatchTOF container.resize(nconstrained); } - private: - void attachInputTrees(); - void attachInputTreesTPConly(); - bool prepareTracks(); - bool prepareTPCTracks(); - bool prepareTOFClusters(); - bool loadTracksNextChunk(); - bool loadTPCTracksNextChunk(); - bool loadTOFClustersNextChunk(); - - void doMatching(int sec); + protected: + virtual bool prepareTracks(); + virtual bool prepareTPCTracks(); + virtual bool prepareTOFClusters(); + + void doMatching(int sec, o2::dataformats::MatchInfoTOF::TrackType type = o2::dataformats::MatchInfoTOF::TrackType::ITSTPC); void doMatchingForTPC(int sec); void selectBestMatches(); + void selectBestMatchesHP(); bool propagateToRefX(o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, o2::track::TrackLTIntegral& intLT); bool propagateToRefXWithoutCov(o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz); @@ -258,14 +203,14 @@ class MatchTOF // Data members + // for derived class + int mCurrTracksTreeEntry = 0; ///< current tracks tree entry loaded to memory bool mSAInitDone = false; ///< flag that standalone init already done bool mWFInputAttached = false; ///< flag that the standalone input is attached + Bool_t mIsworkflowON = kFALSE; ///< flag used in the standalone mode float mXRef = Geo::RMIN; ///< reference radius to propage tracks for matching - int mCurrTracksTreeEntry = 0; ///< current tracks tree entry loaded to memory - int mCurrTOFClustersTreeEntry = 0; ///< current TOF clusters tree entry loaded to memory - bool mMCTruthON = false; ///< flag availability of MC truth ///========== Parameters to be set externally, e.g. from CCDB ==================== @@ -281,24 +226,20 @@ class MatchTOF float mSpaceTolerance = 10; ///< tolerance in cm for track-TOF time bracket matching int mSigmaTimeCut = 30.; ///< number of sigmas to cut on time when matching the track to the TOF cluster - TTree* mInputTreeTracks = nullptr; ///< input tree for tracks - TTree* mTreeTPCTracks = nullptr; ///< input tree for TPC tracks - TTree* mTreeTOFClusters = nullptr; ///< input tree for TOF clusters - - bool mIsITSused = true; - - TTree* mOutputTree = nullptr; ///< output tree for matched tracks - - TTree* mOutputTreeCalib = nullptr; ///< output tree for calibration infos + bool mIsITSTPCused = false; + bool mIsTPCused = false; + bool mIsTPCTRDused = false; + bool mIsITSTPCTRDused = false; + bool mSetHighPurity = false; ///>>>------ these are input arrays which should not be modified by the matching code // since this info is provided by external device - gsl::span mTracksArrayInp; ///< input tracks - std::vector* mTracksArrayInpVect; ///< input tracks (vector to read from tree) - gsl::span mTPCTracksArrayInp; ///< input TPC tracks - std::vector* mTPCTracksArrayInpVect; ///< input tracks (vector to read from tree) - gsl::span mTOFClustersArrayInp; ///< input TOF clusters - std::vector* mTOFClustersArrayInpVect; ///< input TOF clusters (vector to read from tree) + gsl::span mITSTPCTracksArrayInp; ///< input tracks + std::vector* mITSTPCTracksArrayInpVect; ///< input tracks (vector to read from tree) + gsl::span mTPCTracksArrayInp; ///< input TPC tracks + std::vector* mTPCTracksArrayInpVect; ///< input tracks (vector to read from tree) + gsl::span mTOFClustersArrayInp; ///< input TOF clusters + std::vector* mTOFClustersArrayInpVect; ///< input TOF clusters (vector to read from tree) /// data needed for refit of time-constrained TPC tracks gsl::span mTPCTrackClusIdx; ///< input TPC track cluster indices span @@ -311,24 +252,23 @@ class MatchTOF o2::dataformats::MCTruthContainer* mTOFClusLabelsPtr; ///< input TOF clusters MC labels (pointer to read from tree) std::vector mTracksLblWork; /// mTPCLabels; ///< TPC label of input tracks - std::vector* mTPCLabelsVect; ///< TPC label of input tracks (vector to read from tree) + gsl::span mTPCLabels[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< TPC label of input tracks + std::vector* mTPCLabelsVect[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< TPC label of input tracks (vector to read from tree) gsl::span mFITRecPoints; ///< FIT recpoints /// <<<----- /// mTracksWork; /// mTracksWork[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; /// mExtraTPCFwdTime; /// mLTinfos; /// mTOFClusWork; /// mSideTPC; ///, o2::constants::math::NSectors> mTracksSectIndexCache; - ///< per sector indices of track entry in mTPCTracksWork - std::array, o2::constants::math::NSectors> mTPCTracksSectIndexCache; + std::array, o2::constants::math::NSectors> mTracksSectIndexCache[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< per sector indices of TOF cluster entry in mTOFClusWork std::array, o2::constants::math::NSectors> mTOFClusSectIndexCache; @@ -340,24 +280,15 @@ class MatchTOF /// mMatchedTracks; - std::vector mMatchedTracks; // this is the output of the matching - std::vector mOutTOFLabels; ///< TOF label of matched tracks + std::vector mMatchedTracks[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; // this is the output of the matching + std::vector mOutTOFLabels[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< TOF label of matched tracks + + int mNumOfTracks[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; // number of tracks to be matched + std::vector mMatchedTracksIndex[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; // vector of indexes of the tracks to be matched - int mNumOfTracks; // number of tracks to be matched - std::vector mMatchedTracksIndex; // vector of indexes of the tracks to be matched int mNumOfClusters; // number of clusters to be matched int* mMatchedClustersIndex = nullptr; //[mNumOfClusters] - std::string mTracksBranchName = "TPCITS"; ///< name of branch containing input matched tracks - std::string mTPCTracksBranchName = "TPCTracks"; ///< name of branch containing actual TPC tracks - std::string mTPCMCTruthBranchName = "MatchMCTruth"; ///< name of branch containing TPC labels - std::string mTOFMCTruthBranchName = "TOFClusterMCTruth"; ///< name of branch containing TOF clusters labels - std::string mTOFClusterBranchName = "TOFCluster"; ///< name of branch containing input ITS clusters - std::string mOutTracksBranchName = "TOFMatchInfo"; ///< name of branch containing output matched tracks - std::string mOutCalibBranchName = "TOFCalibInfo"; ///< name of branch containing output calibration infos - std::string mOutTOFMCTruthBranchName = "MatchTOFMCTruth"; ///< name of branch containing TOF labels for output matched tracks - std::string mOutTPCTrackMCTruthBranchName = "TPCTracksMCTruth"; ///< name of branch containing TPC labels for input TPC tracks - std::unique_ptr mDBGOut; UInt_t mDBGFlags = 0; std::string mDebugTreeFileName = "dbg_matchTOF.root"; ///< name for the debug tree file @@ -365,11 +296,9 @@ class MatchTOF ///----------- aux stuff --------------/// static constexpr float MAXSNP = 0.85; // max snp of ITS or TPC track at xRef to be matched - Bool_t mIsworkflowON = kFALSE; - TStopwatch mTimerTot; TStopwatch mTimerDBG; - ClassDefNV(MatchTOF, 3); + ClassDefNV(MatchTOF, 1); }; } // namespace globaltracking } // namespace o2 diff --git a/Detectors/GlobalTracking/src/MatchTOF.cxx b/Detectors/GlobalTracking/src/MatchTOF.cxx index a9e4d479b7a2c..bc43097091bbd 100644 --- a/Detectors/GlobalTracking/src/MatchTOF.cxx +++ b/Detectors/GlobalTracking/src/MatchTOF.cxx @@ -44,6 +44,8 @@ using namespace o2::globaltracking; using evGIdx = o2::dataformats::EvIndex; using evIdx = o2::dataformats::EvIndex; +using trkType = o2::dataformats::MatchInfoTOF::TrackType; +using Cluster = o2::tof::Cluster; ClassImp(MatchTOF); @@ -53,10 +55,6 @@ void MatchTOF::run() ///< running the matching updateTimeDependentParams(); - if (!mWFInputAttached && !mSAInitDone) { - LOG(ERROR) << "run called with mSAInitDone=" << mSAInitDone << " and mWFInputAttached=" << mWFInputAttached; - throw std::runtime_error("standalone init was not done or workflow input was not yet attached"); - } mTimerTot.Start(); // we load all TOF clusters (to be checked if we need to split per time frame) @@ -66,224 +64,67 @@ void MatchTOF::run() LOGF(INFO, "Timing prepareTOFCluster: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); mTimerTot.Start(); - if (mIsworkflowON) { - LOG(DEBUG) << "Number of entries in track tree = " << mCurrTracksTreeEntry; - - if (mIsITSused) { - prepareTracks(); - } else { - prepareTPCTracks(); - } - - mMatchedTracks.clear(); - mOutTOFLabels.clear(); - - mTimerTot.Stop(); - LOGF(INFO, "Timing prepare tracks: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); - mTimerTot.Start(); - - for (int sec = o2::constants::math::NSectors; sec--;) { - LOG(INFO) << "Doing matching for sector " << sec << "..."; - if (mIsITSused) { - doMatching(sec); - } else { - doMatchingForTPC(sec); - } - LOG(INFO) << "...done. Now check the best matches"; - selectBestMatches(); - } + for (int i = 0; i < trkType::SIZE; i++) { + mNumOfTracks[i] = 0; + mMatchedTracks[i].clear(); + mTracksWork[i].clear(); + mOutTOFLabels[i].clear(); } - // we do the matching per entry of the TPCITS matched tracks tree - while (!mIsworkflowON && mCurrTracksTreeEntry + 1 < mInputTreeTracks->GetEntries()) { // we add "+1" because mCurrTracksTreeEntry starts from -1, and it is incremented in loadTracksNextChunk which is called by prepareTracks - LOG(DEBUG) << "Number of entries in track tree = " << mCurrTracksTreeEntry; + if (mIsworkflowON) { - if (mIsITSused) { + if (mIsITSTPCused) { prepareTracks(); - } else { + } + if (mIsTPCused) { prepareTPCTracks(); } - mMatchedTracks.clear(); - mOutTOFLabels.clear(); - mTimerTot.Stop(); LOGF(INFO, "Timing prepare tracks: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); mTimerTot.Start(); for (int sec = o2::constants::math::NSectors; sec--;) { + mMatchedTracksPairs.clear(); // new sector LOG(INFO) << "Doing matching for sector " << sec << "..."; - if (mIsITSused) { - doMatching(sec); - } else { + if (mIsITSTPCused) { + doMatching(sec, trkType::ITSTPC); + } + if (mIsTPCused) { doMatchingForTPC(sec); } LOG(INFO) << "...done. Now check the best matches"; selectBestMatches(); } - - mTimerTot.Stop(); - LOGF(INFO, "Timing Do Matching: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); - mTimerTot.Start(); - - fill(); } -#ifdef _ALLOW_TOF_DEBUG_ - if (mDBGFlags) - mDBGOut.reset(); -#endif - - mWFInputAttached = false; - mTimerTot.Stop(); LOGF(INFO, "Timing Do Matching: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); } - //______________________________________________ -void MatchTOF::fill() +void MatchTOF::setTOFClusterArray(const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab) { - mOutputTree->Fill(); - if (mOutputTreeCalib) { - mOutputTreeCalib->Fill(); - } -} - -//______________________________________________ -void MatchTOF::run(const gsl::span& trackArray, const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab, const gsl::span& itstpclab) -{ - mIsITSused = true; - mTracksArrayInp = trackArray; mTOFClustersArrayInp = clusterArray; - mIsworkflowON = kTRUE; mTOFClusLabels = toflab; - mTPCLabels = itstpclab; - - mMCTruthON = (mTOFClusLabels.getNElements() && mTPCLabels.size()); - mWFInputAttached = true; - mSAInitDone = true; - run(); -} -//______________________________________________ -void MatchTOF::run(const gsl::span& trackArray, const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab, const gsl::span& tpclab) -{ - mIsITSused = false; - mTPCTracksArrayInp = trackArray; - mTOFClustersArrayInp = clusterArray; mIsworkflowON = kTRUE; - mTOFClusLabels = toflab; - mTPCLabels = tpclab; - - mMCTruthON = (mTOFClusLabels.getNElements() && mTPCLabels.size()); + mMCTruthON = mTOFClusLabels.getNElements(); mWFInputAttached = true; mSAInitDone = true; - - run(); } //______________________________________________ -void MatchTOF::init() +void MatchTOF::setTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab) { - ///< initizalizations - mIsITSused = true; - - if (mSAInitDone) { - LOG(ERROR) << "Initialization was already done"; - return; - } - attachInputTrees(); - - // create output branch with track-tof matching - if (mOutputTree) { - mOutputTree->Branch(mOutTracksBranchName.data(), &mMatchedTracks); - LOG(INFO) << "Matched tracks will be stored in " << mOutTracksBranchName << " branch of tree " - << mOutputTree->GetName(); - if (mMCTruthON) { - mOutputTree->Branch(mOutTOFMCTruthBranchName.data(), &mOutTOFLabels); - LOG(INFO) << "TOF Tracks Labels branch: " << mOutTOFMCTruthBranchName; - } - - } else { - LOG(INFO) << "Output tree is not attached, matched tracks will not be stored"; - } - - // create output branch for calibration info - if (mOutputTreeCalib) { - mOutputTreeCalib->Branch(mOutCalibBranchName.data(), &mCalibInfoTOF); - LOG(INFO) << "Calib infos will be stored in " << mOutCalibBranchName << " branch of tree " - << mOutputTreeCalib->GetName(); - } else { - LOG(INFO) << "Calib Output tree is not attached, calib infos will not be stored"; - } - -#ifdef _ALLOW_TOF_DEBUG_ - // debug streamer - if (mDBGFlags) { - mDBGOut = std::make_unique(mDebugTreeFileName.data(), "recreate"); - } -#endif - - mSAInitDone = true; - - { - mTimerTot.Stop(); - mTimerTot.Reset(); - } - - print(); + mIsTPCused = true; + mTPCTracksArrayInp = trackArray; + mTPCLabels[trkType::TPC] = tpclab; } //______________________________________________ -void MatchTOF::initTPConly() +void MatchTOF::setITSTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab) { - ///< initizalizations - - mIsITSused = false; - - if (mSAInitDone) { - LOG(ERROR) << "Initialization was already done"; - return; - } - attachInputTreesTPConly(); - - // create output branch with track-tof matching - if (mOutputTree) { - mOutputTree->Branch(mOutTracksBranchName.data(), &mMatchedTracks); - LOG(INFO) << "Matched tracks will be stored in " << mOutTracksBranchName << " branch of tree " - << mOutputTree->GetName(); - if (mMCTruthON) { - mOutputTree->Branch(mOutTOFMCTruthBranchName.data(), &mOutTOFLabels); - LOG(INFO) << "TOF Tracks Labels branch: " << mOutTOFMCTruthBranchName; - } - - } else { - LOG(INFO) << "Output tree is not attached, matched tracks will not be stored"; - } - - // create output branch for calibration info - if (mOutputTreeCalib) { - mOutputTreeCalib->Branch(mOutCalibBranchName.data(), &mCalibInfoTOF); - LOG(INFO) << "Calib infos will be stored in " << mOutCalibBranchName << " branch of tree " - << mOutputTreeCalib->GetName(); - } else { - LOG(INFO) << "Calib Output tree is not attached, calib infos will not be stored"; - } - -#ifdef _ALLOW_TOF_DEBUG_ - // debug streamer - if (mDBGFlags) { - mDBGOut = std::make_unique(mDebugTreeFileName.data(), "recreate"); - } -#endif - - mSAInitDone = true; - - { - mTimerTot.Stop(); - mTimerTot.Reset(); - } - - print(); + mIsITSTPCused = true; + mITSTPCTracksArrayInp = trackArray; + mTPCLabels[trkType::ITSTPC] = tpclab; } - //______________________________________________ void MatchTOF::print() const { @@ -298,159 +139,56 @@ void MatchTOF::print() const LOG(INFO) << "**********************************************************************"; } - //______________________________________________ void MatchTOF::printCandidatesTOF() const { ///< print the candidates for the matching } - -//______________________________________________ -void MatchTOF::attachInputTrees() -{ - ///< attaching the input tree - LOG(DEBUG) << "attachInputTrees"; - if (!mInputTreeTracks) { - LOG(FATAL) << "Input tree with tracks is not set"; - } - - if (!mTreeTOFClusters) { - LOG(FATAL) << "TOF clusters data input tree is not set"; - } - - // input tracks (this is the pairs of ITS-TPC matches) - - if (!mInputTreeTracks->GetBranch(mTracksBranchName.data())) { - LOG(FATAL) << "Did not find tracks branch " << mTracksBranchName << " in the input tree"; - } - mInputTreeTracks->SetBranchAddress(mTracksBranchName.data(), &mTracksArrayInpVect); - LOG(INFO) << "Attached tracks " << mTracksBranchName << " branch with " << mInputTreeTracks->GetEntries() - << " entries"; - - // input TOF clusters - - if (!mTreeTOFClusters->GetBranch(mTOFClusterBranchName.data())) { - LOG(FATAL) << "Did not find TOF clusters branch " << mTOFClusterBranchName << " in the input tree"; - } - mTreeTOFClusters->SetBranchAddress(mTOFClusterBranchName.data(), &mTOFClustersArrayInpVect); - LOG(INFO) << "Attached TOF clusters " << mTOFClusterBranchName << " branch with " << mTreeTOFClusters->GetEntries() - << " entries"; - // is there MC info available ? - mMCTruthON = true; - if (mTreeTOFClusters->GetBranch(mTOFMCTruthBranchName.data())) { - mTOFClusLabelsPtr = &mTOFClusLabels; - mTreeTOFClusters->SetBranchAddress(mTOFMCTruthBranchName.data(), &mTOFClusLabelsPtr); - LOG(INFO) << "Found TOF Clusters MCLabels branch " << mTOFMCTruthBranchName; - } else { - mMCTruthON = false; - } - if (mInputTreeTracks->GetBranch(mTPCMCTruthBranchName.data())) { - mInputTreeTracks->SetBranchAddress(mTPCMCTruthBranchName.data(), &mTPCLabelsVect); - LOG(INFO) << "Found TPC tracks MCLabels branch " << mTPCMCTruthBranchName.data(); - } else { - mMCTruthON = false; - } - - mCurrTracksTreeEntry = -1; - mCurrTOFClustersTreeEntry = -1; -} -//______________________________________________ -void MatchTOF::attachInputTreesTPConly() -{ - ///< attaching the input tree - LOG(DEBUG) << "attachInputTrees"; - - if (!mTreeTPCTracks) { - LOG(FATAL) << "TPC tracks data input tree is not set"; - } - - if (!mTreeTOFClusters) { - LOG(FATAL) << "TOF clusters data input tree is not set"; - } - - // input tracks (this is the TPC tracks) - - if (!mTreeTPCTracks->GetBranch(mTPCTracksBranchName.data())) { - LOG(FATAL) << "Did not find tracks branch " << mTPCTracksBranchName << " in the input tree"; - } - mTreeTPCTracks->SetBranchAddress(mTPCTracksBranchName.data(), &mTPCTracksArrayInpVect); - LOG(INFO) << "Attached tracks " << mTPCTracksBranchName << " branch with " << mTreeTPCTracks->GetEntries() - << " entries"; - - // input TOF clusters - - if (!mTreeTOFClusters->GetBranch(mTOFClusterBranchName.data())) { - LOG(FATAL) << "Did not find TOF clusters branch " << mTOFClusterBranchName << " in the input tree"; - } - mTreeTOFClusters->SetBranchAddress(mTOFClusterBranchName.data(), &mTOFClustersArrayInpVect); - LOG(INFO) << "Attached TOF clusters " << mTOFClusterBranchName << " branch with " << mTreeTOFClusters->GetEntries() - << " entries"; - // is there MC info available ? - mMCTruthON = true; - if (mTreeTOFClusters->GetBranch(mTOFMCTruthBranchName.data())) { - mTOFClusLabelsPtr = &mTOFClusLabels; - mTreeTOFClusters->SetBranchAddress(mTOFMCTruthBranchName.data(), &mTOFClusLabelsPtr); - LOG(INFO) << "Found TOF Clusters MCLabels branch " << mTOFMCTruthBranchName; - } else { - mMCTruthON = false; - } - if (mTreeTPCTracks->GetBranch(mOutTPCTrackMCTruthBranchName.data())) { - mTreeTPCTracks->SetBranchAddress(mOutTPCTrackMCTruthBranchName.data(), &mTPCLabelsVect); - LOG(INFO) << "Found TPC tracks MCLabels branch " << mOutTPCTrackMCTruthBranchName; - } else { - mMCTruthON = false; - } - - mCurrTracksTreeEntry = -1; - mCurrTOFClustersTreeEntry = -1; -} - //______________________________________________ bool MatchTOF::prepareTracks() { ///< prepare the tracks that we want to match to TOF - if (!mIsworkflowON && !loadTracksNextChunk()) { + if (!mIsworkflowON) { return false; } - mNumOfTracks = mTracksArrayInp.size(); - if (mNumOfTracks == 0) { + mNumOfTracks[trkType::ITSTPC] = mITSTPCTracksArrayInp.size(); + if (mNumOfTracks[trkType::ITSTPC] == 0) { return false; // no tracks to be matched } - mMatchedTracksIndex.resize(mNumOfTracks); - std::fill(mMatchedTracksIndex.begin(), mMatchedTracksIndex.end(), -1); // initializing all to -1 + mMatchedTracksIndex[trkType::ITSTPC].resize(mNumOfTracks[trkType::ITSTPC]); + std::fill(mMatchedTracksIndex[trkType::ITSTPC].begin(), mMatchedTracksIndex[trkType::ITSTPC].end(), -1); // initializing all to -1 // copy the track params, propagate to reference X and build sector tables - mTracksWork.clear(); mLTinfos.clear(); - mTracksWork.reserve(mNumOfTracks); - mLTinfos.reserve(mNumOfTracks); + mTracksWork[trkType::ITSTPC].reserve(mNumOfTracks[trkType::ITSTPC]); + mLTinfos.reserve(mNumOfTracks[trkType::ITSTPC]); if (mMCTruthON) { mTracksLblWork.clear(); - mTracksLblWork.reserve(mNumOfTracks); + mTracksLblWork.reserve(mNumOfTracks[trkType::ITSTPC]); } for (int sec = o2::constants::math::NSectors; sec--;) { - mTracksSectIndexCache[sec].clear(); - mTracksSectIndexCache[sec].reserve(100 + 1.2 * mNumOfTracks / o2::constants::math::NSectors); + mTracksSectIndexCache[trkType::ITSTPC][sec].clear(); + mTracksSectIndexCache[trkType::ITSTPC][sec].reserve(100 + 1.2 * mNumOfTracks[trkType::ITSTPC] / o2::constants::math::NSectors); } float maxInvPt = abs(mBz) > 0.1 ? 1. / (abs(mBz) * 0.05) : 999.; - LOG(DEBUG) << "\n\nWe have %d tracks to try to match to TOF: " << mNumOfTracks; + LOG(DEBUG) << "\n\nWe have %d ITS-TPC tracks to try to match to TOF: " << mNumOfTracks[trkType::ITSTPC]; int nNotPropagatedToTOF = 0; - for (int it = 0; it < mNumOfTracks; it++) { - const o2::dataformats::TrackTPCITS& trcOrig = mTracksArrayInp[it]; // TODO: check if we cannot directly use the o2::track::TrackParCov class instead of o2::dataformats::TrackTPCITS, and then avoid the casting below; this is the track at the vertex + for (int it = 0; it < mNumOfTracks[trkType::ITSTPC]; it++) { + const o2::dataformats::TrackTPCITS& trcOrig = mITSTPCTracksArrayInp[it]; // TODO: check if we cannot directly use the o2::track::TrackParCov class instead of o2::dataformats::TrackTPCITS, and then avoid the casting below; this is the track at the vertex std::array globalPos; // create working copy of track param - mTracksWork.emplace_back(std::make_pair(trcOrig.getParamOut(), trcOrig.getTimeMUS())); //, mCurrTracksTreeEntry, it); + mTracksWork[trkType::ITSTPC].emplace_back(std::make_pair(trcOrig.getParamOut(), trcOrig.getTimeMUS())); mLTinfos.emplace_back(trcOrig.getLTIntegralOut()); // make a copy of the TPC track that we have to propagate //o2::tpc::TrackTPC* trc = new o2::tpc::TrackTPC(trcTPCOrig); // this would take the TPCout track - //auto& trc = mTracksWork.back(); // with this we take the TPCITS track propagated to the vertex - auto& trc = mTracksWork.back().first; // with this we take the TPCITS track propagated to the vertex - auto& intLT = mLTinfos.back(); // we get the integrated length from TPC-ITC outward propagation + //auto& trc = mTracksWork[trkType::ITSTPC].back(); // with this we take the TPCITS track propagated to the vertex + auto& trc = mTracksWork[trkType::ITSTPC].back().first; // with this we take the TPCITS track propagated to the vertex + auto& intLT = mLTinfos.back(); // we get the integrated length from TPC-ITC outward propagation if (trc.getX() < o2::constants::geom::XTPCOuterRef - 1.) { // tpc-its track outward propagation did not reach outer ref.radius, skip this track nNotPropagatedToTOF++; @@ -480,22 +218,22 @@ bool MatchTOF::prepareTracks() LOG(DEBUG) << "Radius xyz After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); LOG(DEBUG) << "The track will go to sector " << o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0])); - mTracksSectIndexCache[o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); + mTracksSectIndexCache[trkType::ITSTPC][o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); //delete trc; // Check: is this needed? } - LOG(INFO) << "Total number of tracks = " << mNumOfTracks << ", Number of tracks that failed to be propagated to TOF = " << nNotPropagatedToTOF; + LOG(INFO) << "Total number of tracks = " << mNumOfTracks[trkType::ITSTPC] << ", Number of tracks that failed to be propagated to TOF = " << nNotPropagatedToTOF; // sort tracks in each sector according to their time (increasing in time) for (int sec = o2::constants::math::NSectors; sec--;) { - auto& indexCache = mTracksSectIndexCache[sec]; + auto& indexCache = mTracksSectIndexCache[trkType::ITSTPC][sec]; LOG(INFO) << "Sorting sector" << sec << " | " << indexCache.size() << " tracks"; if (!indexCache.size()) { continue; } std::sort(indexCache.begin(), indexCache.end(), [this](int a, int b) { - auto& trcA = mTracksWork[a].second; - auto& trcB = mTracksWork[b].second; + auto& trcA = mTracksWork[trkType::ITSTPC][a].second; + auto& trcB = mTracksWork[trkType::ITSTPC][b].second; return ((trcA.getTimeStamp() - mSigmaTimeCut * trcA.getTimeStampError()) - (trcB.getTimeStamp() - mSigmaTimeCut * trcB.getTimeStampError()) < 0.); }); } // loop over tracks of single sector @@ -509,7 +247,7 @@ bool MatchTOF::prepareTracks() auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! for (int itrk = 0; itrk < cacheTrk.size(); itrk++){ itmp++; - auto& trc = mTracksWork[cacheTrk[itrk]]; + auto& trc = mTracksWork[trkType::ITSTPC][cacheTrk[itrk]]; trc.getXYZGlo(globalPos); //printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f\n", itrk, globalPos[0], globalPos[1], globalPos[2]); // Printf("The phi angle is %f", TMath::ATan2(globalPos[1], globalPos[0])); @@ -525,28 +263,27 @@ bool MatchTOF::prepareTPCTracks() { ///< prepare the tracks that we want to match to TOF - if (!mIsworkflowON && !loadTPCTracksNextChunk()) { + if (!mIsworkflowON) { return false; } - mNumOfTracks = mTPCTracksArrayInp.size(); - if (mNumOfTracks == 0) { + mNumOfTracks[trkType::TPC] = mTPCTracksArrayInp.size(); + if (mNumOfTracks[trkType::TPC] == 0) { return false; // no tracks to be matched } - mMatchedTracksIndex.resize(mNumOfTracks); - std::fill(mMatchedTracksIndex.begin(), mMatchedTracksIndex.end(), -1); // initializing all to -1 + mMatchedTracksIndex[trkType::TPC].resize(mNumOfTracks[trkType::TPC]); + std::fill(mMatchedTracksIndex[trkType::TPC].begin(), mMatchedTracksIndex[trkType::TPC].end(), -1); // initializing all to -1 // copy the track params, propagate to reference X and build sector tables - mTracksWork.clear(); - mTracksWork.reserve(mNumOfTracks); + mTracksWork[trkType::TPC].reserve(mNumOfTracks[trkType::TPC]); mSideTPC.clear(); - mSideTPC.reserve(mNumOfTracks); + mSideTPC.reserve(mNumOfTracks[trkType::TPC]); mExtraTPCFwdTime.clear(); - mExtraTPCFwdTime.reserve(mNumOfTracks); + mExtraTPCFwdTime.reserve(mNumOfTracks[trkType::TPC]); for (int sec = o2::constants::math::NSectors; sec--;) { - mTPCTracksSectIndexCache[sec].clear(); - mTPCTracksSectIndexCache[sec].reserve(100 + 1.2 * mNumOfTracks / o2::constants::math::NSectors); + mTracksSectIndexCache[trkType::TPC][sec].clear(); + mTracksSectIndexCache[trkType::TPC][sec].reserve(100 + 1.2 * mNumOfTracks[trkType::TPC] / o2::constants::math::NSectors); } float maxInvPt = abs(mBz) > 0.1 ? 1. / (abs(mBz) * 0.05) : 999.; @@ -554,9 +291,9 @@ bool MatchTOF::prepareTPCTracks() LOG(INFO) << "Max track Inv pT allowed = " << maxInvPt; LOG(INFO) << "Min track Nclusters allowed = " << nclustersMin; - LOG(DEBUG) << "\n\nWe have %d tracks to try to match to TOF: " << mNumOfTracks; + LOG(DEBUG) << "\n\nWe have %d TPC tracks to try to match to TOF: " << mNumOfTracks[trkType::TPC]; int nNotPropagatedToTOF = 0; - for (int it = 0; it < mNumOfTracks; it++) { + for (int it = 0; it < mNumOfTracks[trkType::TPC]; it++) { const o2::tpc::TrackTPC& trcOrig = mTPCTracksArrayInp[it]; // TODO: check if we cannot directly use the o2::track::TrackParCov class instead of o2::dataformats::TrackTPCITS, and then avoid the casting below; this is the track at the vertex std::array globalPos; @@ -572,11 +309,11 @@ bool MatchTOF::prepareTPCTracks() mSideTPC.push_back(trcOrig.hasASideClustersOnly() ? 1 : (trcOrig.hasCSideClustersOnly() ? -1 : 0)); mExtraTPCFwdTime.push_back((trcOrig.getDeltaTFwd() + 5) * mTPCTBinMUS + extraErr); + o2::track::TrackLTIntegral intLT0; //mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation // make a copy of the TPC track that we have to propagate - mTracksWork.emplace_back(std::make_pair(trcOrig.getOuterParam(), timeInfo)); // RS Why do we creat a track copy before deciding that the track should be propagated? - auto& trc = mTracksWork.back().first; - - o2::track::TrackLTIntegral intLT0{}; // we get the integrated length from TPC-ITC outward propagation + //o2::tpc::TrackTPC* trc = new o2::tpc::TrackTPC(trcTPCOrig); // this would take the TPCout track + mTracksWork[trkType::TPC].emplace_back(std::make_pair(trcOrig.getOuterParam(), timeInfo)); + auto& trc = mTracksWork[trkType::TPC].back().first; auto& intLT = mLTinfos.emplace_back(intLT0); if (trcOrig.getNClusters() < nclustersMin) { @@ -589,16 +326,7 @@ bool MatchTOF::prepareTPCTracks() continue; } - o2::base::Propagator::Instance()->estimateLTFast(intLT, trc); // init intLT with fast estimate - -#ifdef _ALLOW_TOF_DEBUG_ - // propagate to matching Xref - trc.getXYZGlo(globalPos); - LOG(INFO) << "Global coordinates Before propagating to 371 cm: globalPos[0] = " << globalPos[0] << ", globalPos[1] = " << globalPos[1] << ", globalPos[2] = " << globalPos[2]; - LOG(INFO) << "Radius xy Before propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1]); - LOG(INFO) << "Radius xyz Before propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); - // the "very rough" propagation worked; now we can propagate considering also the cov matrix -#endif + // printf("N clusters = %d\n",trcOrig.getNClusters()); if (!propagateToRefXWithoutCov(trc, mXRef, 10, mBz)) { // we first propagate to 371 cm without considering the covariance matrix nNotPropagatedToTOF++; @@ -620,29 +348,22 @@ bool MatchTOF::prepareTPCTracks() trc.getXYZGlo(globalPos); -#ifdef _ALLOW_TOF_DEBUG_ - LOG(INFO) << "Global coordinates After propagating to 371 cm: globalPos[0] = " << globalPos[0] << ", globalPos[1] = " << globalPos[1] << ", globalPos[2] = " << globalPos[2]; - LOG(INFO) << "Radius xy After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1]); - LOG(INFO) << "Radius xyz After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); - LOG(INFO) << "The track will go to sector " << o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0])); -#endif - - mTracksSectIndexCache[o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); + mTracksSectIndexCache[trkType::TPC][o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); //delete trc; // Check: is this needed? } - LOG(INFO) << "Total number of tracks = " << mNumOfTracks << ", Number of tracks that failed to be propagated to TOF = " << nNotPropagatedToTOF; + LOG(INFO) << "Total number of tracks = " << mNumOfTracks[trkType::TPC] << ", Number of tracks that failed to be propagated to TOF = " << nNotPropagatedToTOF; // sort tracks in each sector according to their time (increasing in time) for (int sec = o2::constants::math::NSectors; sec--;) { - auto& indexCache = mTracksSectIndexCache[sec]; + auto& indexCache = mTracksSectIndexCache[trkType::TPC][sec]; LOG(INFO) << "Sorting sector" << sec << " | " << indexCache.size() << " tracks"; if (!indexCache.size()) { continue; } std::sort(indexCache.begin(), indexCache.end(), [this](int a, int b) { - auto& trcA = mTracksWork[a].second; - auto& trcB = mTracksWork[b].second; + auto& trcA = mTracksWork[trkType::TPC][a].second; + auto& trcB = mTracksWork[trkType::TPC][b].second; return ((trcA.getTimeStamp() - trcA.getTimeStampError()) - (trcB.getTimeStamp() - trcB.getTimeStampError()) < 0.); }); @@ -658,8 +379,8 @@ bool MatchTOF::prepareTPCTracks() auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! for (int itrk = 0; itrk < cacheTrk.size(); itrk++){ itmp++; - auto& trc = mTracksWork[cacheTrk[itrk]].first; - auto& trcAttr = mTracksWork[cacheTrk[itrk]].second; + auto& trc = mTracksWork[trkType::TPC][cacheTrk[itrk]].first; + auto& trcAttr = mTracksWork[trkType::TPC][cacheTrk[itrk]].second; trc.getXYZGlo(globalPos); printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f -- timestamp = %f +/- %f\n", itrk, globalPos[0], globalPos[1], globalPos[2],trcAttr.getTimeStamp(),trcAttr.getTimeStampError()); // Printf("The phi angle is %f", TMath::ATan2(globalPos[1], globalPos[0])); @@ -689,20 +410,6 @@ bool MatchTOF::prepareTOFClusters() } mNumOfClusters = 0; - while (!mIsworkflowON && loadTOFClustersNextChunk()) { - int nClusterInCurrentChunk = mTOFClustersArrayInp.size(); - LOG(DEBUG) << "nClusterInCurrentChunk = " << nClusterInCurrentChunk; - mNumOfClusters += nClusterInCurrentChunk; - for (int it = 0; it < nClusterInCurrentChunk; it++) { - const Cluster& clOrig = mTOFClustersArrayInp[it]; - // create working copy of track param - mTOFClusWork.emplace_back(clOrig); - auto& cl = mTOFClusWork.back(); - cl.setEntryInTree(mCurrTOFClustersTreeEntry); - // cache work track index - mTOFClusSectIndexCache[cl.getSector()].push_back(mTOFClusWork.size() - 1); - } - } if (mIsworkflowON) { int nClusterInCurrentChunk = mTOFClustersArrayInp.size(); @@ -713,7 +420,6 @@ bool MatchTOF::prepareTOFClusters() // create working copy of track param mTOFClusWork.emplace_back(clOrig); auto& cl = mTOFClusWork.back(); - cl.setEntryInTree(mCurrTOFClustersTreeEntry); // cache work track index mTOFClusSectIndexCache[cl.getSector()].push_back(mTOFClusWork.size() - 1); } @@ -741,74 +447,13 @@ bool MatchTOF::prepareTOFClusters() return true; } - -//_____________________________________________________ -bool MatchTOF::loadTracksNextChunk() -{ - ///< load next chunk of tracks to be matched to TOF - while (++mCurrTracksTreeEntry < mInputTreeTracks->GetEntries()) { - mInputTreeTracks->GetEntry(mCurrTracksTreeEntry); - mTracksArrayInp = gsl::span{*mTracksArrayInpVect}; - LOG(INFO) << "Loading tracks entry " << mCurrTracksTreeEntry << " -> " << mTracksArrayInp.size() - << " tracks"; - if (!mTracksArrayInp.size()) { - continue; - } - if (mMCTruthON) { - mTPCLabels = gsl::span{*mTPCLabelsVect}; - } - return true; - } - --mCurrTracksTreeEntry; - return false; -} -//_____________________________________________________ -bool MatchTOF::loadTPCTracksNextChunk() -{ - ///< load next chunk of tracks to be matched to TOF - while (++mCurrTracksTreeEntry < mTreeTPCTracks->GetEntries()) { - mTreeTPCTracks->GetEntry(mCurrTracksTreeEntry); - mTPCTracksArrayInp = gsl::span{*mTPCTracksArrayInpVect}; - LOG(INFO) << "Loading TPC tracks entry " << mCurrTracksTreeEntry << " -> " << mTPCTracksArrayInp.size() - << " tracks"; - if (!mTPCTracksArrayInp.size()) { - continue; - } - return true; - } - --mCurrTracksTreeEntry; - return false; -} //______________________________________________ -bool MatchTOF::loadTOFClustersNextChunk() -{ - LOG(DEBUG) << "Loat clusters next chunck"; - ///< load next chunk of clusters to be matched to TOF - LOG(DEBUG) << "Loading TOF clusters: number of entries in tree = " << mTreeTOFClusters->GetEntries(); - while (++mCurrTOFClustersTreeEntry < mTreeTOFClusters->GetEntries()) { - mTreeTOFClusters->GetEntry(mCurrTOFClustersTreeEntry); - mTOFClustersArrayInp = gsl::span{*mTOFClustersArrayInpVect}; - LOG(DEBUG) << "Loading TOF clusters entry " << mCurrTOFClustersTreeEntry << " -> " << mTOFClustersArrayInp.size() - << " clusters"; - LOG(INFO) << "Loading TOF clusters entry " << mCurrTOFClustersTreeEntry << " -> " << mTOFClustersArrayInp.size() - << " clusters"; - if (!mTOFClustersArrayInp.size()) { - continue; - } - return true; - } - --mCurrTOFClustersTreeEntry; - return false; -} -//______________________________________________ -void MatchTOF::doMatching(int sec) +void MatchTOF::doMatching(int sec, trkType type) { ///< do the real matching per sector - mMatchedTracksPairs.clear(); // new sector - - auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! - auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! + auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! + auto& cacheTrk = mTracksSectIndexCache[type][sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! int nTracks = cacheTrk.size(), nTOFCls = cacheTOF.size(); LOG(INFO) << "Matching sector " << sec << ": number of tracks: " << nTracks << ", number of TOF clusters: " << nTOFCls; if (!nTracks || !nTOFCls) { @@ -833,30 +478,24 @@ void MatchTOF::doMatching(int sec) nStepsInsideSameStrip[ii] = 0; } int nStripsCrossedInPropagation = 0; // how many strips were hit during the propagation - auto& trackWork = mTracksWork[cacheTrk[itrk]]; + auto& trackWork = mTracksWork[type][cacheTrk[itrk]]; auto& trefTrk = trackWork.first; auto& intLT = mLTinfos[cacheTrk[itrk]]; // Printf("intLT (before doing anything): length = %f, time (Pion) = %f", intLT.getL(), intLT.getTOF(o2::track::PID::Pion)); - float minTrkTime = (trackWork.second.getTimeStamp() - mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6; // minimum time in ps - float maxTrkTime = (trackWork.second.getTimeStamp() + mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6; // maximum time in ps - int istep = 1; // number of steps - float step = 1.0; // step size in cm - //uncomment for local debug - /* - //trefTrk.getXYZGlo(posBeforeProp); - //float posBeforeProp[3] = {trefTrk.getX(), trefTrk.getY(), trefTrk.getZ()}; // in local ref system - //printf("Global coordinates: posBeforeProp[0] = %f, posBeforeProp[1] = %f, posBeforeProp[2] = %f\n", posBeforeProp[0], posBeforeProp[1], posBeforeProp[2]); - //Printf("Radius xy = %f", TMath::Sqrt(posBeforeProp[0]*posBeforeProp[0] + posBeforeProp[1]*posBeforeProp[1])); - //Printf("Radius xyz = %f", TMath::Sqrt(posBeforeProp[0]*posBeforeProp[0] + posBeforeProp[1]*posBeforeProp[1] + posBeforeProp[2]*posBeforeProp[2])); - */ - -#ifdef _ALLOW_TOF_DEBUG_ - if (mDBGFlags) { - (*mDBGOut) << "propOK" - << "track=" << trefTrk << "\n"; - } -#endif + float minTrkTime = (trackWork.second.getTimeStamp() - mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6; // minimum time in ps + float maxTrkTime = (trackWork.second.getTimeStamp() + mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6; // maximum time in ps + int istep = 1; // number of steps + float step = 1.0; // step size in cm + + //uncomment for local debug + /* + //trefTrk.getXYZGlo(posBeforeProp); + //float posBeforeProp[3] = {trefTrk.getX(), trefTrk.getY(), trefTrk.getZ()}; // in local ref system + //printf("Global coordinates: posBeforeProp[0] = %f, posBeforeProp[1] = %f, posBeforeProp[2] = %f\n", posBeforeProp[0], posBeforeProp[1], posBeforeProp[2]); + //Printf("Radius xy = %f", TMath::Sqrt(posBeforeProp[0]*posBeforeProp[0] + posBeforeProp[1]*posBeforeProp[1])); + //Printf("Radius xyz = %f", TMath::Sqrt(posBeforeProp[0]*posBeforeProp[0] + posBeforeProp[1]*posBeforeProp[1] + posBeforeProp[2]*posBeforeProp[2])); + */ // initializing for (int ii = 0; ii < 2; ii++) { @@ -876,6 +515,7 @@ void MatchTOF::doMatching(int sec) for (int ii = 0; ii < 3; ii++) { // we need to change the type... posFloat[ii] = pos[ii]; } + // uncomment below only for local debug; this will produce A LOT of output - one print per propagation step /* Printf("posFloat[0] = %f, posFloat[1] = %f, posFloat[2] = %f", posFloat[0], posFloat[1], posFloat[2]); @@ -895,20 +535,6 @@ void MatchTOF::doMatching(int sec) continue; } - // to reduce the active region of the strip -> uncomment these lines - // float yresidual = TMath::Abs(deltaPosTemp[1]); - // if(yresidual > 0.55){ - // reachedPoint += step; - // continue; - // } - - // printf("res %f %f %f -- %f %f %f (%d)\n",deltaPosTemp[0],deltaPosTemp[1],deltaPosTemp[2],pos[0],pos[1],pos[2],detIdTemp[2]); - - // if you want to exit from the strip matched uncomment this line - // reachedPoint += 3.0; // go out from the strip at the next step - - // printf("idet: %d %d %d %d %d\n",detIdTemp[0],detIdTemp[1],detIdTemp[2],detIdTemp[3],detIdTemp[4]); - // uncomment below only for local debug; this will produce A LOT of output - one print per propagation step //Printf("detIdTemp[0] = %d, detIdTemp[1] = %d, detIdTemp[2] = %d, detIdTemp[3] = %d, detIdTemp[4] = %d", detIdTemp[0], detIdTemp[1], detIdTemp[2], detIdTemp[3], detIdTemp[4]); // if (nStripsCrossedInPropagation == 0) { // print in case you have a useful propagation @@ -926,6 +552,7 @@ void MatchTOF::doMatching(int sec) // check if after the propagation we are in a TOF strip // we ended in a TOF strip // LOG(DEBUG) << "nStripsCrossedInPropagation = " << nStripsCrossedInPropagation << ", detId[nStripsCrossedInPropagation][0] = " << detId[nStripsCrossedInPropagation][0] << ", detIdTemp[0] = " << detIdTemp[0] << ", detId[nStripsCrossedInPropagation][1] = " << detId[nStripsCrossedInPropagation][1] << ", detIdTemp[1] = " << detIdTemp[1] << ", detId[nStripsCrossedInPropagation][2] = " << detId[nStripsCrossedInPropagation][2] << ", detIdTemp[2] = " << detIdTemp[2]; + if (nStripsCrossedInPropagation == 0 || // we are crossing a strip for the first time... (nStripsCrossedInPropagation >= 1 && (detId[nStripsCrossedInPropagation - 1][0] != detIdTemp[0] || detId[nStripsCrossedInPropagation - 1][1] != detIdTemp[1] || detId[nStripsCrossedInPropagation - 1][2] != detIdTemp[2]))) { // ...or we are crossing a new strip if (nStripsCrossedInPropagation == 0) { @@ -963,7 +590,7 @@ void MatchTOF::doMatching(int sec) // uncomment for debug purposes, to check tracks that did not cross any strip /* if (nStripsCrossedInPropagation == 0) { - auto labelTPCNoStripsCrossed = mTPCLabels->at(mTracksSectIndexCache[sec][itrk]); + auto labelTPCNoStripsCrossed = mTPCLabels[trkType::ITSTPC]->at(mTracksSectIndexCache[sec][itrk]); Printf("The current track (index = %d) never crossed a strip", cacheTrk[itrk]); Printf("TrackID = %d, EventID = %d, SourceID = %d", labelTPCNoStripsCrossed.getTrackID(), labelTPCNoStripsCrossed.getEventID(), labelTPCNoStripsCrossed.getSourceID()); printf("Global coordinates: pos[0] = %f, pos[1] = %f, pos[2] = %f\n", pos[0], pos[1], pos[2]); @@ -977,7 +604,6 @@ void MatchTOF::doMatching(int sec) deltaPos[imatch][0] /= nStepsInsideSameStrip[imatch]; deltaPos[imatch][1] /= nStepsInsideSameStrip[imatch]; deltaPos[imatch][2] /= nStepsInsideSameStrip[imatch]; - // LOG(DEBUG) << "matched strip " << imatch << ": deltaPos[0] = " << deltaPos[imatch][0] << ", deltaPos[1] = " << deltaPos[imatch][1] << ", deltaPos[2] = " << deltaPos[imatch][2] << ", residual (x, z) = " << TMath::Sqrt(deltaPos[imatch][0] * deltaPos[imatch][0] + deltaPos[imatch][2] * deltaPos[imatch][2]); } if (nStripsCrossedInPropagation == 0) { @@ -1051,22 +677,6 @@ void MatchTOF::doMatching(int sec) float res = TMath::Sqrt(resX * resX + resZ * resZ); LOG(DEBUG) << "resX = " << resX << ", resZ = " << resZ << ", res = " << res; -#ifdef _ALLOW_TOF_DEBUG_ - fillTOFmatchTree("match0", cacheTOF[itof], indices[0], indices[1], indices[2], indices[3], indices[4], cacheTrk[itrk], iPropagation, detId[iPropagation][0], detId[iPropagation][1], detId[iPropagation][2], detId[iPropagation][3], detId[iPropagation][4], resX, resZ, res, trackWork, trkLTInt[iPropagation].getL(), trkLTInt[iPropagation].getTOF(o2::track::PID::Pion), trefTOF.getTime()); - int tofLabelTrackID[3] = {-1, -1, -1}; - int tofLabelEventID[3] = {-1, -1, -1}; - int tofLabelSourceID[3] = {-1, -1, -1}; - if (mMCTruthON) { - const auto& labelsTOF = mTOFClusLabels.getLabels(mTOFClusSectIndexCache[indices[0]][itof]); - for (int ilabel = 0; ilabel < labelsTOF.size(); ilabel++) { - tofLabelTrackID[ilabel] = labelsTOF[ilabel].getTrackID(); - tofLabelEventID[ilabel] = labelsTOF[ilabel].getEventID(); - tofLabelSourceID[ilabel] = labelsTOF[ilabel].getSourceID(); - } - auto labelTPC = mTPCLabels[mTracksSectIndexCache[sec][itrk]]; - fillTOFmatchTreeWithLabels("matchPossibleWithLabels", cacheTOF[itof], indices[0], indices[1], indices[2], indices[3], indices[4], cacheTrk[itrk], iPropagation, detId[iPropagation][0], detId[iPropagation][1], detId[iPropagation][2], detId[iPropagation][3], detId[iPropagation][4], resX, resZ, res, trackWork, labelTPC.getTrackID(), labelTPC.getEventID(), labelTPC.getSourceID(), tofLabelTrackID[0], tofLabelEventID[0], tofLabelSourceID[0], tofLabelTrackID[1], tofLabelEventID[1], tofLabelSourceID[1], tofLabelTrackID[2], tofLabelEventID[2], tofLabelSourceID[2], trkLTInt[iPropagation].getL(), trkLTInt[iPropagation].getTOF(o2::track::PID::Pion), trefTOF.getTime()); - } -#endif if (indices[0] != detId[iPropagation][0]) { continue; } @@ -1077,38 +687,19 @@ void MatchTOF::doMatching(int sec) continue; } float chi2 = res; // TODO: take into account also the time! -#ifdef _ALLOW_TOF_DEBUG_ - fillTOFmatchTree("match1", cacheTOF[itof], indices[0], indices[1], indices[2], indices[3], indices[4], cacheTrk[itrk], iPropagation, detId[iPropagation][0], detId[iPropagation][1], detId[iPropagation][2], detId[iPropagation][3], detId[iPropagation][4], resX, resZ, res, trackWork, trkLTInt[iPropagation].getL(), trkLTInt[iPropagation].getTOF(o2::track::PID::Pion), trefTOF.getTime()); - if (mMCTruthON) { - auto labelTPC = mTPCLabels[mTracksSectIndexCache[sec][itrk]]; - fillTOFmatchTreeWithLabels("matchOkWithLabels", cacheTOF[itof], indices[0], indices[1], indices[2], indices[3], indices[4], cacheTrk[itrk], iPropagation, detId[iPropagation][0], detId[iPropagation][1], detId[iPropagation][2], detId[iPropagation][3], detId[iPropagation][4], resX, resZ, res, trackWork, labelTPC.getTrackID(), labelTPC.getEventID(), labelTPC.getSourceID(), tofLabelTrackID[0], tofLabelEventID[0], tofLabelSourceID[0], tofLabelTrackID[1], tofLabelEventID[1], tofLabelSourceID[1], tofLabelTrackID[2], tofLabelEventID[2], tofLabelSourceID[2], trkLTInt[iPropagation].getL(), trkLTInt[iPropagation].getTOF(o2::track::PID::Pion), trefTOF.getTime()); - } -#endif if (res < mSpaceTolerance) { // matching ok! - LOG(DEBUG) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[indices[0]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; + LOG(DEBUG) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[type][indices[0]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; foundCluster = true; // set event indexes (to be checked) evIdx eventIndexTOFCluster(trefTOF.getEntryInTree(), mTOFClusSectIndexCache[indices[0]][itof]); - evGIdx eventIndexTracks(mCurrTracksTreeEntry, {uint32_t(mTracksSectIndexCache[indices[0]][itrk]), o2::dataformats::GlobalTrackID::ITSTPC}); - mMatchedTracksPairs.emplace_back(eventIndexTOFCluster, chi2, trkLTInt[iPropagation], eventIndexTracks); // TODO: check if this is correct! - -#ifdef _ALLOW_TOF_DEBUG_ - if (mMCTruthON) { - const auto& labelsTOF = mTOFClusLabels.getLabels(mTOFClusSectIndexCache[indices[0]][itof]); - auto labelTPC = mTPCLabels[mTracksSectIndexCache[sec][itrk]]; - for (int ilabel = 0; ilabel < labelsTOF.size(); ilabel++) { - LOG(DEBUG) << "TOF label " << ilabel << labelsTOF[ilabel]; - } - LOG(DEBUG) << "TPC label " << labelTPC; - fillTOFmatchTreeWithLabels("matchOkWithLabelsInSpaceTolerance", cacheTOF[itof], indices[0], indices[1], indices[2], indices[3], indices[4], cacheTrk[itrk], iPropagation, detId[iPropagation][0], detId[iPropagation][1], detId[iPropagation][2], detId[iPropagation][3], detId[iPropagation][4], resX, resZ, res, trackWork, labelTPC.getTrackID(), labelTPC.getEventID(), labelTPC.getSourceID(), tofLabelTrackID[0], tofLabelEventID[0], tofLabelSourceID[0], tofLabelTrackID[1], tofLabelEventID[1], tofLabelSourceID[1], tofLabelTrackID[2], tofLabelEventID[2], tofLabelSourceID[2], trkLTInt[iPropagation].getL(), trkLTInt[iPropagation].getTOF(o2::track::PID::Pion), trefTOF.getTime()); - } -#endif + evGIdx eventIndexTracks(mCurrTracksTreeEntry, {uint32_t(mTracksSectIndexCache[type][indices[0]][itrk]), o2::dataformats::GlobalTrackID::ITSTPC}); + mMatchedTracksPairs.emplace_back(eventIndexTOFCluster, chi2, trkLTInt[iPropagation], eventIndexTracks, type); // TODO: check if this is correct! } } } if (!foundCluster && mMCTruthON) { - auto labelTPC = mTPCLabels[mTracksSectIndexCache[sec][itrk]]; + auto labelTPC = mTPCLabels[trkType::ITSTPC][mTracksSectIndexCache[type][sec][itrk]]; LOG(DEBUG) << "We did not find any TOF cluster for track " << cacheTrk[itrk] << " (label = " << labelTPC << ", pt = " << trefTrk.getPt(); } } @@ -1127,10 +718,9 @@ void MatchTOF::doMatchingForTPC(int sec) double BCgranularity = Geo::BC_TIME_INPS * bc_grouping; ///< do the real matching per sector - mMatchedTracksPairs.clear(); // new sector - auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! - auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! + auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! + auto& cacheTrk = mTracksSectIndexCache[trkType::TPC][sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! int nTracks = cacheTrk.size(), nTOFCls = cacheTOF.size(); LOG(INFO) << "Matching sector " << sec << ": number of tracks: " << nTracks << ", number of TOF clusters: " << nTOFCls; if (!nTracks || !nTOFCls) { @@ -1155,7 +745,7 @@ void MatchTOF::doMatchingForTPC(int sec) LOG(DEBUG) << "Trying to match %d tracks" << cacheTrk.size(); for (int itrk = 0; itrk < cacheTrk.size(); itrk++) { - auto& trackWork = mTracksWork[cacheTrk[itrk]]; + auto& trackWork = mTracksWork[trkType::TPC][cacheTrk[itrk]]; auto& trefTrk = trackWork.first; auto& intLT = mLTinfos[cacheTrk[itrk]]; @@ -1183,7 +773,7 @@ void MatchTOF::doMatchingForTPC(int sec) for (auto itof = itof0; itof < nTOFCls; itof++) { auto& trefTOF = mTOFClusWork[cacheTOF[itof]]; -// printf("clus time = %f\n",trefTOF.getTime()); + // printf("clus time = %f\n",trefTOF.getTime()); if (trefTOF.getTime() < minTrkTime) { // this cluster has a time that is too small for the current track, we will get to the next one itof0 = itof + 1; @@ -1232,8 +822,9 @@ void MatchTOF::doMatchingForTPC(int sec) // Printf("intLT (before doing anything): length = %f, time (Pion) = %f", intLT.getL(), intLT.getTOF(o2::track::PID::Pion)); int istep = 1; // number of steps float step = 1.0; // step size in cm - //uncomment for local debug - /* + + //uncomment for local debug + /* //trefTrk.getXYZGlo(posBeforeProp); //float posBeforeProp[3] = {trefTrk.getX(), trefTrk.getY(), trefTrk.getZ()}; // in local ref system //printf("Global coordinates: posBeforeProp[0] = %f, posBeforeProp[1] = %f, posBeforeProp[2] = %f\n", posBeforeProp[0], posBeforeProp[1], posBeforeProp[2]); @@ -1241,13 +832,6 @@ void MatchTOF::doMatchingForTPC(int sec) //Printf("Radius xyz = %f", TMath::Sqrt(posBeforeProp[0]*posBeforeProp[0] + posBeforeProp[1]*posBeforeProp[1] + posBeforeProp[2]*posBeforeProp[2])); */ -#ifdef _ALLOW_TOF_DEBUG_ - if (mDBGFlags) { - (*mDBGOut) << "propOK" - << "track=" << trefTrk << "\n"; - } -#endif - int detIdTemp[5] = {-1, -1, -1, -1, -1}; // TOF detector id at the current propagation point double reachedPoint = mXRef + istep * step; @@ -1268,11 +852,12 @@ void MatchTOF::doMatchingForTPC(int sec) for (int ii = 0; ii < 3; ii++) { // we need to change the type... posFloat[ii] = pos[ii]; } + // uncomment below only for local debug; this will produce A LOT of output - one print per propagation step /* - Printf("posFloat[0] = %f, posFloat[1] = %f, posFloat[2] = %f", posFloat[0], posFloat[1], posFloat[2]); - Printf("radius xy = %f", TMath::Sqrt(posFloat[0]*posFloat[0] + posFloat[1]*posFloat[1])); - Printf("radius xyz = %f", TMath::Sqrt(posFloat[0]*posFloat[0] + posFloat[1]*posFloat[1] + posFloat[2]*posFloat[2])); + Printf("posFloat[0] = %f, posFloat[1] = %f, posFloat[2] = %f", posFloat[0], posFloat[1], posFloat[2]); + Printf("radius xy = %f", TMath::Sqrt(posFloat[0]*posFloat[0] + posFloat[1]*posFloat[1])); + Printf("radius xyz = %f", TMath::Sqrt(posFloat[0]*posFloat[0] + posFloat[1]*posFloat[1] + posFloat[2]*posFloat[2])); */ reachedPoint += step; @@ -1339,7 +924,6 @@ void MatchTOF::doMatchingForTPC(int sec) deltaPos[ibc][imatch][0] /= nStepsInsideSameStrip[ibc][imatch]; deltaPos[ibc][imatch][1] /= nStepsInsideSameStrip[ibc][imatch]; deltaPos[ibc][imatch][2] /= nStepsInsideSameStrip[ibc][imatch]; - // LOG(DEBUG) << "matched strip " << imatch << ": deltaPos[0] = " << deltaPos[imatch][0] << ", deltaPos[1] = " << deltaPos[imatch][1] << ", deltaPos[2] = " << deltaPos[imatch][2] << ", residual (x, z) = " << TMath::Sqrt(deltaPos[imatch][0] * deltaPos[imatch][0] + deltaPos[imatch][2] * deltaPos[imatch][2]); } if (nStripsCrossedInPropagation[ibc] == 0) { @@ -1354,7 +938,7 @@ void MatchTOF::doMatchingForTPC(int sec) // compare the times of the track and the TOF clusters - remember that they both are ordered in time! if (trefTOF.getTime() < minTime) { // this cluster has a time that is too small for the current track, we will get to the next one - itof0 = itof + 1; // but for the next track that we will check, we will ignore this cluster (the time is anyway too small) + itof0 = itof + 1; // but for the next track that we will check, we will ignore this cluster (the time is anyway too small) continue; } if (trefTOF.getTime() > maxTime) { // no more TOF clusters can be matched to this track @@ -1432,17 +1016,17 @@ void MatchTOF::doMatchingForTPC(int sec) float chi2 = mIsCosmics ? resX : res; // TODO: take into account also the time! if (res < mSpaceTolerance) { // matching ok! - LOG(DEBUG) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[indices[0]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; + LOG(DEBUG) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[trkType::TPC][indices[0]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; foundCluster = true; // set event indexes (to be checked) evIdx eventIndexTOFCluster(trefTOF.getEntryInTree(), mTOFClusSectIndexCache[indices[0]][itof]); - evGIdx eventIndexTracks(mCurrTracksTreeEntry, {uint32_t(mTracksSectIndexCache[indices[0]][itrk]), o2::dataformats::GlobalTrackID::TPC}); - mMatchedTracksPairs.emplace_back(eventIndexTOFCluster, chi2, trkLTInt[ibc][iPropagation], eventIndexTracks, resZ / vdrift * side, trefTOF.getZ()); // TODO: check if this is correct! + evGIdx eventIndexTracks(mCurrTracksTreeEntry, {uint32_t(mTracksSectIndexCache[trkType::TPC][indices[0]][itrk]), o2::dataformats::GlobalTrackID::TPC}); + mMatchedTracksPairs.emplace_back(eventIndexTOFCluster, chi2, trkLTInt[ibc][iPropagation], eventIndexTracks, trkType::TPC, resZ / vdrift * side, trefTOF.getZ()); // TODO: check if this is correct! } } } if (!foundCluster && mMCTruthON) { - const auto& labelTPC = mTPCLabels[mTracksSectIndexCache[sec][itrk]]; + const auto& labelTPC = mTPCLabels[trkType::TPC][mTracksSectIndexCache[trkType::TPC][sec][itrk]]; LOG(DEBUG) << "We did not find any TOF cluster for track " << cacheTrk[itrk] << " (label = " << labelTPC << ", pt = " << trefTrk.getPt(); } } @@ -1477,6 +1061,10 @@ int MatchTOF::findFITIndex(int bc) //______________________________________________ void MatchTOF::selectBestMatches() { + if (mSetHighPurity) { + selectBestMatchesHP(); + return; + } ///< define the track-TOFcluster pair per sector LOG(INFO) << "Number of pair matched = " << mMatchedTracksPairs.size(); @@ -1486,15 +1074,17 @@ void MatchTOF::selectBestMatches() int i = 0; // then we take discard the pairs if their track or cluster was already matched (since they are ordered in chi2, we will take the best matching) for (const o2::dataformats::MatchInfoTOF& matchingPair : mMatchedTracksPairs) { - if (mMatchedTracksIndex[matchingPair.getTrackIndex()] != -1) { // the track was already filled + int trkType = (int)matchingPair.getTrackType(); + + if (mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()] != -1) { // the track was already filled continue; } - if (mMatchedClustersIndex[matchingPair.getTOFClIndex()] != -1) { // the track was already filled + if (mMatchedClustersIndex[matchingPair.getTOFClIndex()] != -1) { // the cluster was already filled continue; } - mMatchedTracksIndex[matchingPair.getTrackIndex()] = mMatchedTracks.size(); // index of the MatchInfoTOF correspoding to this track - mMatchedClustersIndex[matchingPair.getTOFClIndex()] = mMatchedTracksIndex[matchingPair.getTrackIndex()]; // index of the track that was matched to this cluster - mMatchedTracks.push_back(matchingPair); // array of MatchInfoTOF + mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()] = mMatchedTracks[trkType].size(); // index of the MatchInfoTOF correspoding to this track + mMatchedClustersIndex[matchingPair.getTOFClIndex()] = mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()]; // index of the track that was matched to this cluster + mMatchedTracks[trkType].push_back(matchingPair); // array of MatchInfoTOF // get fit info double t0info = 0; @@ -1515,7 +1105,7 @@ void MatchTOF::selectBestMatches() mTOFClusWork[matchingPair.getTOFClIndex()].getTot()); if (mMCTruthON) { const auto& labelsTOF = mTOFClusLabels.getLabels(matchingPair.getTOFClIndex()); - const auto& labelTPC = mTPCLabels[matchingPair.getTrackIndex()]; + const auto& labelTPC = mTPCLabels[trkType][matchingPair.getTrackIndex()]; // we want to store positive labels independently of how they are flagged from TPC,ITS people LOG(DEBUG) << "TPC label" << labelTPC; bool labelOk = false; // whether we have found or not the same TPC label of the track among the labels of the TOF cluster @@ -1523,7 +1113,7 @@ void MatchTOF::selectBestMatches() for (int ilabel = 0; ilabel < labelsTOF.size(); ilabel++) { LOG(DEBUG) << "TOF label " << ilabel << labelsTOF[ilabel]; if (labelsTOF[ilabel] == labelTPC) { // if we find one TOF cluster label that is the same as the TPC one, we are happy - even if it is not the first one - mOutTOFLabels.push_back(labelsTOF[ilabel]); + mOutTOFLabels[trkType].push_back(labelsTOF[ilabel]); labelOk = true; break; } @@ -1533,13 +1123,71 @@ void MatchTOF::selectBestMatches() if (!labelsTOF.size()) { throw std::runtime_error("TOF label not found since size of label is zero. This should not happen!!!!"); } - mOutTOFLabels.emplace_back(labelsTOF[0].getTrackID(), labelsTOF[0].getEventID(), labelsTOF[0].getSourceID(), true); + mOutTOFLabels[trkType].emplace_back(labelsTOF[0].getTrackID(), labelsTOF[0].getEventID(), labelsTOF[0].getSourceID(), true); } } i++; } } //______________________________________________ +void MatchTOF::selectBestMatchesHP() +{ + ///< define the track-TOFcluster pair per sector + float chi2SeparationCut = 1; + float chi2S = 3; + + LOG(INFO) << "Number of pair matched = " << mMatchedTracksPairs.size(); + + std::vector tmpMatch; + + // first, we sort according to the chi2 + std::sort(mMatchedTracksPairs.begin(), mMatchedTracksPairs.end(), [this](o2::dataformats::MatchInfoTOF& a, o2::dataformats::MatchInfoTOF& b) { return (a.getChi2() < b.getChi2()); }); + int i = 0; + // then we take discard the pairs if their track or cluster was already matched (since they are ordered in chi2, we will take the best matching) + for (const o2::dataformats::MatchInfoTOF& matchingPair : mMatchedTracksPairs) { + int trkType = (int)matchingPair.getTrackType(); + + bool discard = matchingPair.getChi2() > chi2S; + + if (mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()] != -1) { // the track was already filled, check if this competitor is not too close + auto winnerChi = tmpMatch[mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()]].getChi2(); + if (winnerChi < 0) { // the winner was already discarded as ambiguous + continue; + } + if (matchingPair.getChi2() - winnerChi < chi2SeparationCut) { // discard previously validated winner and it has too close competitor + tmpMatch[mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()]].setChi2(-1); + } + continue; + } + + if (mMatchedClustersIndex[matchingPair.getTOFClIndex()] != -1) { // the cluster was already filled, check if this competitor is not too close + auto winnerChi = tmpMatch[mMatchedClustersIndex[matchingPair.getTOFClIndex()]].getChi2(); + if (winnerChi < 0) { // the winner was already discarded as ambiguous + continue; + } + if (matchingPair.getChi2() - winnerChi < chi2SeparationCut) { // discard previously validated winner and it has too close competitor + tmpMatch[mMatchedClustersIndex[matchingPair.getTOFClIndex()]].setChi2(-1); + } + continue; + } + + if (!discard) { + mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()] = tmpMatch.size(); // index of the MatchInfoTOF correspoding to this track + mMatchedClustersIndex[matchingPair.getTOFClIndex()] = mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()]; // index of the track that was matched to this clus + tmpMatch.push_back(matchingPair); + } + } + + // now write final matches skipping disabled ones + for (auto& match : tmpMatch) { + if (match.getChi2() <= 0) { + continue; + } + int trkType = (int)match.getTrackType(); + mMatchedTracks[trkType].push_back(match); + } +} +//______________________________________________ bool MatchTOF::propagateToRefX(o2::track::TrackParCov& trc, float xRef, float stepInCm, o2::track::TrackLTIntegral& intLT) { // propagate track to matching reference X @@ -1628,47 +1276,6 @@ void MatchTOF::setDebugFlag(UInt_t flag, bool on) mDBGFlags &= ~flag; } } - -//_________________________________________________________ -void MatchTOF::fillTOFmatchTree(const char* trname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, float intLength, float intTimePion, float timeTOF) -{ - ///< fill debug tree for TOF tracks matching check - - mTimerDBG.Start(false); - - // Printf("************** Filling the debug tree with %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %f", cacheTOF, sectTOF, plateTOF, stripTOF, padXTOF, padZTOF, cacheeTrk, crossedStrip, sectPropagation, platePropagation, stripPropagation, padXPropagation, padZPropagation, resX, resZ, res); - - if (mDBGFlags) { - (*mDBGOut) << trname - << "clusterTOF=" << cacheTOF << "sectTOF=" << sectTOF << "plateTOF=" << plateTOF << "stripTOF=" << stripTOF << "padXTOF=" << padXTOF << "padZTOF=" << padZTOF - << "crossedStrip=" << crossedStrip << "sectPropagation=" << sectPropagation << "platePropagation=" << platePropagation << "stripPropagation=" << stripPropagation << "padXPropagation=" << padXPropagation - << "resX=" << resX << "resZ=" << resZ << "res=" << res << "track=" << trk.first << "intLength=" << intLength << "intTimePion=" << intTimePion << "timeTOF=" << timeTOF << "\n"; - } - mTimerDBG.Stop(); -} - -//_________________________________________________________ -void MatchTOF::fillTOFmatchTreeWithLabels(const char* trname, int cacheTOF, int sectTOF, int plateTOF, int stripTOF, int padXTOF, int padZTOF, int cacheeTrk, int crossedStrip, int sectPropagation, int platePropagation, int stripPropagation, int padXPropagation, int padZPropagation, float resX, float resZ, float res, matchTrack& trk, int TPClabelTrackID, int TPClabelEventID, int TPClabelSourceID, int TOFlabelTrackID0, int TOFlabelEventID0, int TOFlabelSourceID0, int TOFlabelTrackID1, int TOFlabelEventID1, int TOFlabelSourceID1, int TOFlabelTrackID2, int TOFlabelEventID2, int TOFlabelSourceID2, float intLength, float intTimePion, float timeTOF) -{ - ///< fill debug tree for TOF tracks matching check - - mTimerDBG.Start(false); - - if (mDBGFlags) { - (*mDBGOut) << trname - << "clusterTOF=" << cacheTOF << "sectTOF=" << sectTOF << "plateTOF=" << plateTOF << "stripTOF=" << stripTOF << "padXTOF=" << padXTOF << "padZTOF=" << padZTOF - << "crossedStrip=" << crossedStrip << "sectPropagation=" << sectPropagation << "platePropagation=" << platePropagation << "stripPropagation=" << stripPropagation << "padXPropagation=" << padXPropagation - << "resX=" << resX << "resZ=" << resZ << "res=" << res << "track=" << trk.first - << "TPClabelTrackID=" << TPClabelTrackID << "TPClabelEventID=" << TPClabelEventID << "TPClabelSourceID=" << TPClabelSourceID - << "TOFlabelTrackID0=" << TOFlabelTrackID0 << "TOFlabelEventID0=" << TOFlabelEventID0 << "TOFlabelSourceID0=" << TOFlabelSourceID0 - << "TOFlabelTrackID1=" << TOFlabelTrackID1 << "TOFlabelEventID1=" << TOFlabelEventID1 << "TOFlabelSourceID1=" << TOFlabelSourceID1 - << "TOFlabelTrackID2=" << TOFlabelTrackID2 << "TOFlabelEventID2=" << TOFlabelEventID2 << "TOFlabelSourceID2=" << TOFlabelSourceID2 - << "intLength=" << intLength << "intTimePion=" << intTimePion << "timeTOF=" << timeTOF - << "\n"; - } - mTimerDBG.Stop(); -} - //______________________________________________ void MatchTOF::updateTimeDependentParams() { @@ -1685,15 +1292,15 @@ void MatchTOF::updateTimeDependentParams() //_________________________________________________________ bool MatchTOF::makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCTOF& trConstr) { - auto& match = mMatchedTracks[matchedID]; + auto& match = mMatchedTracks[trkType::TPC][matchedID]; const auto& tpcTrOrig = mTPCTracksArrayInp[match.getTrackIndex()]; const auto& tofCl = mTOFClustersArrayInp[match.getTOFClIndex()]; const auto& intLT = match.getLTIntegralOut(); // correct the time of the track - auto timeTOFMUS = (tofCl.getTime() - intLT.getTOF(tpcTrOrig.getPID())) * 1e-6; // tof time in \mus, FIXME: account for time of flight to R TOF - auto timeTOFTB = timeTOFMUS * mTPCTBinMUSInv; // TOF time in TPC timebins - auto deltaTBins = timeTOFTB - tpcTrOrig.getTime0(); // time shift in timeBins - float timeErr = 0.010; // assume 10 ns error FIXME + auto timeTOFMUS = (tofCl.getTime() - intLT.getTOF(tpcTrOrig.getPID())) * 1e-6; // tof time in \mus, FIXME: account for time of flight to R TOF + auto timeTOFTB = timeTOFMUS * mTPCTBinMUSInv; // TOF time in TPC timebins + auto deltaTBins = timeTOFTB - tpcTrOrig.getTime0(); // time shift in timeBins + float timeErr = 0.010; // assume 10 ns error FIXME auto dzCorr = deltaTBins * mTPCBin2Z; if (mTPCClusterIdxStruct) { // refit was requested diff --git a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx index 553a93ea5f3c9..01ea79a4f01a3 100644 --- a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx @@ -105,6 +105,16 @@ void TOFMatcherSpec::run(ProcessingContext& pc) recoData.collectData(pc, *mDataRequest.get()); const auto clustersRO = pc.inputs().get>("tofcluster"); + LOG(INFO) << "isTrackSourceLoaded: TPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPC); + LOG(INFO) << "isTrackSourceLoaded: ITSTPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPC); + LOG(INFO) << "isTrackSourceLoaded: TPCTRD -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRD); + LOG(INFO) << "isTrackSourceLoaded: ITSTPCTRD -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRD); + + bool isTPCused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPC); + bool isITSTPCused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPC); + bool isTPCTRDused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRD); + bool isITSTPCTRDused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRD); + if (mUseFIT) { // Note: the particular variable will go out of scope, but the span is passed by copy to the // worker and the underlying memory is valid throughout the whole computation @@ -114,17 +124,49 @@ void TOFMatcherSpec::run(ProcessingContext& pc) } o2::dataformats::MCTruthContainer toflab; + gsl::span tpclab; + gsl::span itstpclab; + gsl::span tpctrdlab; + gsl::span itstpctrdlab; if (mUseMC) { const auto toflabel = pc.inputs().get*>("tofclusterlabel"); toflab = std::move(*toflabel); } - //mMatcher.run(tracksRO, clustersRO, toflab, itstpclab); + mMatcher.setTOFClusterArray(clustersRO, toflab); - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector()); - if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector()); + if (isTPCused) { + const auto tracksTPC = recoData.getTPCTracks(); + if (mUseMC) { + tpclab = recoData.getTPCTracksMCLabels(); + } + mMatcher.setTPCTrackArray(tracksTPC, tpclab); } + + if (isITSTPCused) { + const auto tracksITSTPC = recoData.getTPCITSTracks(); + if (mUseMC) { + itstpclab = recoData.getTPCITSTracksMCLabels(); + } + mMatcher.setITSTPCTrackArray(tracksITSTPC, itstpclab); + } + + mMatcher.run(); + + if (isTPCused) { + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); + if (mUseMC) { + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); + } + } + + if (isITSTPCused) { + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); + if (mUseMC) { + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); + } + } + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); mTimer.Stop(); @@ -153,9 +195,15 @@ DataProcessorSpec getTOFMatcherSpec(GTrackID::mask_t src, bool useMC, bool useFI inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); } - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_2", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_3", 0, Lifetime::Timeframe); if (useMC) { - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_2", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_3", 0, Lifetime::Timeframe); } outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); diff --git a/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx b/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx index d29b0413a14e6..f2eb4e7d068ed 100644 --- a/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx @@ -39,7 +39,7 @@ void customize(std::vector& workflowOptions) {"disable-mc", o2::framework::VariantType::Bool, false, {"disable MC propagation even if available"}}, {"disable-root-input", o2::framework::VariantType::Bool, false, {"disable root-files input reader"}}, {"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writer"}}, - {"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources to use"}}, + {"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources to use: allowed TPC,ITS-TPC,TPC-TRD,ITS-TPC-TRD (all)"}}, {"use-fit", o2::framework::VariantType::Bool, false, {"enable access to fit info for calibration"}}, {"use-ccdb", o2::framework::VariantType::Bool, false, {"enable access to ccdb tof calibration objects"}}, {"output-type", o2::framework::VariantType::String, "matching-info,calib-info", {"matching-info, calib-info"}}, @@ -57,7 +57,8 @@ void customize(std::vector& workflowOptions) WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) { WorkflowSpec specs; - GID::mask_t alowedSources = GID::getSourcesMask("ITS,TPC,ITS-TPC,TPC-TOF,ITS-TPC-TOF"); + GID::mask_t alowedSources = GID::getSourcesMask("TPC,ITS-TPC"); + // GID::mask_t alowedSources = GID::getSourcesMask("TPC,ITS-TPC,TPC-TRD,ITS-TPC-TRD"); // Update the (declared) parameters if changed from the command line o2::conf::ConfigurableParam::updateFromString(configcontext.options().get("configKeyValues")); diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx index da519603b76a7..77288366b6ddc 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx @@ -97,7 +97,9 @@ class TOFDPLRecoWorkflowTask toflab = std::move(*toflabel); } - mMatcher.run(tracksRO, clustersRO, toflab, itstpclab); + mMatcher.setTOFClusterArray(clustersRO, toflab); + mMatcher.setITSTPCTrackArray(tracksRO, itstpclab); + mMatcher.run(); // in run_match_tof aggiugnere esplicitamente la chiamata a fill del tree (nella classe MatchTOF) e il metodo per leggere i vettori di output @@ -106,9 +108,9 @@ class TOFDPLRecoWorkflowTask // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; // send matching-info - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector()); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector()); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); } pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); mTimer.Stop(); @@ -140,9 +142,9 @@ o2::framework::DataProcessorSpec getTOFRecoWorkflowSpec(bool useMC, bool useFIT) inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); } - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe); if (useMC) { - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe); } outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx index d55dcde324c7f..81074d8f559c6 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx @@ -112,9 +112,11 @@ class TOFDPLRecoWorkflowWithTPCTask mMatcher.setTPCClustersInp(&inputsTPCclusters->clusterIndex); } - mMatcher.run(tracksRO, clustersRO, toflab, tpclab); + mMatcher.setTOFClusterArray(clustersRO, toflab); + mMatcher.setTPCTrackArray(tracksRO, tpclab); + mMatcher.run(); - auto nmatch = mMatcher.getMatchedTrackVector().size(); + auto nmatch = mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::TPC).size(); if (mDoTPCRefit) { LOG(INFO) << "Refitting " << nmatch << " matched TPC tracks with TOF time info"; } else { @@ -130,11 +132,11 @@ class TOFDPLRecoWorkflowWithTPCTask // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; // send matching-info - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFOS_TPC", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector()); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHTOF_TPC", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector()); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); } - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA_TPC", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); mTimer.Stop(); } @@ -169,13 +171,13 @@ o2::framework::DataProcessorSpec getTOFRecoWorkflowWithTPCSpec(bool useMC, bool inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); } - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFOS_TPC", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe); outputs.emplace_back(OutputLabel{"tpctofTracks"}, o2::header::gDataOriginTOF, "TOFTRACKS_TPC", 0, Lifetime::Timeframe); if (useMC) { - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHTOF_TPC", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe); } - outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA_TPC", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); return DataProcessorSpec{ "TOFRecoWorkflowWithTPC", diff --git a/Detectors/TOF/workflowIO/src/TOFCalibWriterSpec.cxx b/Detectors/TOF/workflowIO/src/TOFCalibWriterSpec.cxx index 4084278a4dc89..b89f15d3cbad5 100644 --- a/Detectors/TOF/workflowIO/src/TOFCalibWriterSpec.cxx +++ b/Detectors/TOF/workflowIO/src/TOFCalibWriterSpec.cxx @@ -41,11 +41,11 @@ DataProcessorSpec getTOFCalibWriterSpec(const char* outdef, bool toftpc) auto logger = [](CalibInfosType const& indata) { LOG(INFO) << "RECEIVED MATCHED SIZE " << indata.size(); }; - o2::header::DataDescription ddCalib{"CALIBDATA"}, ddCalib_tpc{"CALIBDATA_TPC"}; + o2::header::DataDescription ddCalib{"CALIBDATA"}; return MakeRootTreeWriterSpec("TOFCalibWriter", outdef, "calibTOF", - BranchDefinition{InputSpec{"input", o2::header::gDataOriginTOF, toftpc ? ddCalib_tpc : ddCalib, 0}, + BranchDefinition{InputSpec{"input", o2::header::gDataOriginTOF, ddCalib, 0}, "TOFCalibInfo", "calibinfo-branch-name", 1, diff --git a/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx b/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx index a2dc22849588b..bed6689f8a060 100644 --- a/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx +++ b/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx @@ -47,8 +47,8 @@ DataProcessorSpec getTOFMatchedWriterSpec(bool useMC, const char* outdef, bool w auto loggerTofLabels = [](LabelsType const& labeltof) { LOG(INFO) << "TOF LABELS GOT " << labeltof.size() << " LABELS "; }; - o2::header::DataDescription ddMatchInfo{"MATCHINFOS"}, ddMatchInfo_tpc{"MATCHINFOS_TPC"}, - ddMCMatchTOF{"MCMATCHTOF"}, ddMCMatchTOF_tpc{"MCMATCHTOF_TPC"}; + o2::header::DataDescription ddMatchInfo{"MATCHINFO_1"}, ddMatchInfo_tpc{"MATCHINFO_0"}, + ddMCMatchTOF{"MCMATCHINFO_1"}, ddMCMatchTOF_tpc{"MCMATCHINFO_0"}; return MakeRootTreeWriterSpec(writeTOFTPC ? "TOFMatchedWriter_TPC" : "TOFMatchedWriter", outdef, From 39d14cf0909243cd6f09ad96b0af638855056f4a Mon Sep 17 00:00:00 2001 From: Francesco Noferini Date: Tue, 15 Jun 2021 11:21:16 +0200 Subject: [PATCH 2/7] add MatchInfoTOFReco class --- DataFormats/Reconstruction/CMakeLists.txt | 2 + .../ReconstructionDataFormats/MatchInfoTOF.h | 12 +---- .../MatchInfoTOFReco.h | 48 +++++++++++++++++++ .../Reconstruction/src/MatchInfoTOFReco.cxx | 18 +++++++ .../src/ReconstructionDataFormatsLinkDef.h | 2 + .../include/GlobalTracking/MatchTOF.h | 28 +++++------ Detectors/GlobalTracking/src/MatchTOF.cxx | 12 ++--- .../GlobalTrackingWorkflow/TOFMatcherSpec.h | 2 +- .../src/TOFMatcherSpec.cxx | 8 ++-- .../include/TOFWorkflow/RecoWorkflowSpec.h | 2 +- .../TOFWorkflow/RecoWorkflowWithTPCSpec.h | 2 +- .../tofworkflow/src/RecoWorkflowSpec.cxx | 4 +- .../src/RecoWorkflowWithTPCSpec.cxx | 6 +-- 13 files changed, 103 insertions(+), 43 deletions(-) create mode 100644 DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h create mode 100644 DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx diff --git a/DataFormats/Reconstruction/CMakeLists.txt b/DataFormats/Reconstruction/CMakeLists.txt index 3f0b132c802f1..f1cab92d49352 100644 --- a/DataFormats/Reconstruction/CMakeLists.txt +++ b/DataFormats/Reconstruction/CMakeLists.txt @@ -18,6 +18,7 @@ o2_add_library(ReconstructionDataFormats src/Vertex.cxx src/PrimaryVertex.cxx src/MatchInfoTOF.cxx + src/MatchInfoTOFReco.cxx src/TrackLTIntegral.cxx src/PID.cxx src/DCA.cxx @@ -43,6 +44,7 @@ o2_target_root_dictionary( include/ReconstructionDataFormats/Vertex.h include/ReconstructionDataFormats/PrimaryVertex.h include/ReconstructionDataFormats/MatchInfoTOF.h + include/ReconstructionDataFormats/MatchInfoTOFReco.h include/ReconstructionDataFormats/TrackLTIntegral.h include/ReconstructionDataFormats/PID.h include/ReconstructionDataFormats/DCA.h diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h index db8694a5a331c..ea0ba1e1f94d9 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOF.h @@ -29,13 +29,7 @@ class MatchInfoTOF using evIdx = o2::dataformats::EvIndex; public: - enum TrackType : int8_t { TPC = 0, - ITSTPC, - TPCTRD, - ITSTPCTRD, - SIZE }; - - MatchInfoTOF(evIdx evIdxTOFCl, float chi2, o2::track::TrackLTIntegral trkIntLT, evGIdx evIdxTrack, TrackType trkType, float dt = 0, float z = 0) : mEvIdxTOFCl(evIdxTOFCl), mChi2(chi2), mIntLT(trkIntLT), mEvIdxTrack(evIdxTrack), mTrackType(trkType), mDeltaT(dt), mZatTOF(z){}; + MatchInfoTOF(evIdx evIdxTOFCl, float chi2, o2::track::TrackLTIntegral trkIntLT, evGIdx evIdxTrack, float dt = 0, float z = 0) : mEvIdxTOFCl(evIdxTOFCl), mChi2(chi2), mIntLT(trkIntLT), mEvIdxTrack(evIdxTrack), mDeltaT(dt), mZatTOF(z){}; MatchInfoTOF() = default; void setEvIdxTOFCl(evIdx index) { mEvIdxTOFCl = index; } void setEvIdxTrack(evGIdx index) { mEvIdxTrack = index; } @@ -49,9 +43,6 @@ class MatchInfoTOF void setChi2(int chi2) { mChi2 = chi2; } float getChi2() const { return mChi2; } - void setTrackType(TrackType value) { mTrackType = value; } - TrackType getTrackType() const { return mTrackType; } - o2::track::TrackLTIntegral& getLTIntegralOut() { return mIntLT; } const o2::track::TrackLTIntegral& getLTIntegralOut() const { return mIntLT; } void print() const; @@ -68,7 +59,6 @@ class MatchInfoTOF evGIdx mEvIdxTrack; ///< EvIdx for track (first: ev index; second: track global index) float mZatTOF = 0.0; ///< Z position at TOF float mDeltaT = 0.0; ///< tTOF - TPC (microsec) - TrackType mTrackType; //! track type (TPC, ITSTPC, TPCTRD, ITSTPCTRD) ClassDefNV(MatchInfoTOF, 2); }; diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h new file mode 100644 index 0000000000000..95d4e16cfd485 --- /dev/null +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h @@ -0,0 +1,48 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file MatchInfoTOFReco.h +/// \brief Class to temporary store the output of the matching to TOF in reconstruction + +#ifndef ALICEO2_MATCHINFOTOFRECO_H +#define ALICEO2_MATCHINFOTOFRECO_H + +#include "ReconstructionDataFormats/MatchInfoTOF.h" + +namespace o2 +{ +namespace dataformats +{ +class MatchInfoTOFReco : public MatchInfoTOF +{ + using evGIdx = o2::dataformats::EvIndex; + using evIdx = o2::dataformats::EvIndex; + + public: + enum TrackType : int8_t { TPC = 0, + ITSTPC, + TPCTRD, + ITSTPCTRD, + SIZE }; + + MatchInfoTOFReco(evIdx evIdxTOFCl, float chi2, o2::track::TrackLTIntegral trkIntLT, evGIdx evIdxTrack, TrackType trkType, float dt = 0, float z = 0) : MatchInfoTOF(evIdxTOFCl, chi2, trkIntLT, evIdxTrack, dt, z), mTrackType(trkType){}; + + MatchInfoTOFReco() = default; + + void setTrackType(TrackType value) { mTrackType = value; } + TrackType getTrackType() const { return mTrackType; } + + private: + TrackType mTrackType; ///< track type (TPC, ITSTPC, TPCTRD, ITSTPCTRD) + ClassDefNV(MatchInfoTOFReco, 1); +}; +} // namespace dataformats +} // namespace o2 +#endif diff --git a/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx b/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx new file mode 100644 index 0000000000000..8801575abbfe2 --- /dev/null +++ b/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx @@ -0,0 +1,18 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file MatchInfoTOFReco.cxx +/// \brief Class to temporary store the output of the matching to TOF in reconstruction + +#include "ReconstructionDataFormats/MatchInfoTOFReco.h" + +using namespace o2::dataformats; + +ClassImp(o2::dataformats::MatchInfoTOFReco); diff --git a/DataFormats/Reconstruction/src/ReconstructionDataFormatsLinkDef.h b/DataFormats/Reconstruction/src/ReconstructionDataFormatsLinkDef.h index c7e31a3a08bec..843c51ab0d5b2 100644 --- a/DataFormats/Reconstruction/src/ReconstructionDataFormatsLinkDef.h +++ b/DataFormats/Reconstruction/src/ReconstructionDataFormatsLinkDef.h @@ -36,6 +36,8 @@ #pragma link C++ class o2::dataformats::MatchInfoTOF + ; #pragma link C++ class std::vector < o2::dataformats::MatchInfoTOF> + ; +#pragma link C++ class o2::dataformats::MatchInfoTOFReco + ; +#pragma link C++ class std::vector < o2::dataformats::MatchInfoTOFReco> + ; #pragma link C++ class o2::dataformats::TrackTPCTOF + ; #pragma link C++ class std::vector < o2::dataformats::TrackTPCTOF> + ; diff --git a/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h b/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h index d2ff6dfb1f4a0..8808b7fa5c835 100644 --- a/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h +++ b/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h @@ -25,7 +25,7 @@ #include "ReconstructionDataFormats/Track.h" #include "ReconstructionDataFormats/TrackTPCITS.h" #include "ReconstructionDataFormats/TrackTPCTOF.h" -#include "ReconstructionDataFormats/MatchInfoTOF.h" +#include "ReconstructionDataFormats/MatchInfoTOFReco.h" #include "ReconstructionDataFormats/GlobalTrackID.h" #include "DataFormatsTOF/CalibInfoTOF.h" #include "CommonDataFormat/EvIndex.h" @@ -131,10 +131,10 @@ class MatchTOF } } - std::vector& getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType index) { return mMatchedTracks[index]; } + std::vector& getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType index) { return mMatchedTracks[index]; } std::vector& getCalibVector() { return mCalibInfoTOF; } - std::vector& getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType index) { return mOutTOFLabels[index]; } ///< get vector of TOF label of matched tracks + std::vector& getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType index) { return mOutTOFLabels[index]; } ///< get vector of TOF label of matched tracks // this method is deprecated void setFITRecPoints(const std::vector* recpoints) @@ -173,7 +173,7 @@ class MatchTOF void makeConstrainedTPCTracks(V& container) { checkRefitter(); - int nmatched = mMatchedTracks[o2::dataformats::MatchInfoTOF::TrackType::TPC].size(), nconstrained = 0; + int nmatched = mMatchedTracks[o2::dataformats::MatchInfoTOFReco::TrackType::TPC].size(), nconstrained = 0; container.resize(nmatched); for (unsigned i = 0; i < nmatched; i++) { if (makeConstrainedTPCTrack(i, container[nconstrained])) { @@ -188,7 +188,7 @@ class MatchTOF virtual bool prepareTPCTracks(); virtual bool prepareTOFClusters(); - void doMatching(int sec, o2::dataformats::MatchInfoTOF::TrackType type = o2::dataformats::MatchInfoTOF::TrackType::ITSTPC); + void doMatching(int sec, o2::dataformats::MatchInfoTOFReco::TrackType type = o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC); void doMatchingForTPC(int sec); void selectBestMatches(); void selectBestMatchesHP(); @@ -252,15 +252,15 @@ class MatchTOF o2::dataformats::MCTruthContainer* mTOFClusLabelsPtr; ///< input TOF clusters MC labels (pointer to read from tree) std::vector mTracksLblWork; /// mTPCLabels[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< TPC label of input tracks - std::vector* mTPCLabelsVect[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< TPC label of input tracks (vector to read from tree) + gsl::span mTPCLabels[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< TPC label of input tracks + std::vector* mTPCLabelsVect[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< TPC label of input tracks (vector to read from tree) gsl::span mFITRecPoints; ///< FIT recpoints /// <<<----- /// mTracksWork[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; /// mTracksWork[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; /// mExtraTPCFwdTime; /// mLTinfos; /// mSideTPC; ///, o2::constants::math::NSectors> mTracksSectIndexCache[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; + std::array, o2::constants::math::NSectors> mTracksSectIndexCache[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< per sector indices of TOF cluster entry in mTOFClusWork std::array, o2::constants::math::NSectors> mTOFClusSectIndexCache; /// mMatchedTracksPairs; + std::vector mMatchedTracksPairs; /// mCalibInfoTOF; /// mMatchedTracks; - std::vector mMatchedTracks[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; // this is the output of the matching - std::vector mOutTOFLabels[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; ///< TOF label of matched tracks + std::vector mMatchedTracks[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; // this is the output of the matching + std::vector mOutTOFLabels[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< TOF label of matched tracks - int mNumOfTracks[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; // number of tracks to be matched - std::vector mMatchedTracksIndex[o2::dataformats::MatchInfoTOF::TrackType::SIZE]; // vector of indexes of the tracks to be matched + int mNumOfTracks[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; // number of tracks to be matched + std::vector mMatchedTracksIndex[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; // vector of indexes of the tracks to be matched int mNumOfClusters; // number of clusters to be matched int* mMatchedClustersIndex = nullptr; //[mNumOfClusters] diff --git a/Detectors/GlobalTracking/src/MatchTOF.cxx b/Detectors/GlobalTracking/src/MatchTOF.cxx index bc43097091bbd..a79bd2ea3b6b8 100644 --- a/Detectors/GlobalTracking/src/MatchTOF.cxx +++ b/Detectors/GlobalTracking/src/MatchTOF.cxx @@ -44,7 +44,7 @@ using namespace o2::globaltracking; using evGIdx = o2::dataformats::EvIndex; using evIdx = o2::dataformats::EvIndex; -using trkType = o2::dataformats::MatchInfoTOF::TrackType; +using trkType = o2::dataformats::MatchInfoTOFReco::TrackType; using Cluster = o2::tof::Cluster; ClassImp(MatchTOF); @@ -1070,10 +1070,10 @@ void MatchTOF::selectBestMatches() LOG(INFO) << "Number of pair matched = " << mMatchedTracksPairs.size(); // first, we sort according to the chi2 - std::sort(mMatchedTracksPairs.begin(), mMatchedTracksPairs.end(), [this](o2::dataformats::MatchInfoTOF& a, o2::dataformats::MatchInfoTOF& b) { return (a.getChi2() < b.getChi2()); }); + std::sort(mMatchedTracksPairs.begin(), mMatchedTracksPairs.end(), [this](o2::dataformats::MatchInfoTOFReco& a, o2::dataformats::MatchInfoTOFReco& b) { return (a.getChi2() < b.getChi2()); }); int i = 0; // then we take discard the pairs if their track or cluster was already matched (since they are ordered in chi2, we will take the best matching) - for (const o2::dataformats::MatchInfoTOF& matchingPair : mMatchedTracksPairs) { + for (const o2::dataformats::MatchInfoTOFReco& matchingPair : mMatchedTracksPairs) { int trkType = (int)matchingPair.getTrackType(); if (mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()] != -1) { // the track was already filled @@ -1138,13 +1138,13 @@ void MatchTOF::selectBestMatchesHP() LOG(INFO) << "Number of pair matched = " << mMatchedTracksPairs.size(); - std::vector tmpMatch; + std::vector tmpMatch; // first, we sort according to the chi2 - std::sort(mMatchedTracksPairs.begin(), mMatchedTracksPairs.end(), [this](o2::dataformats::MatchInfoTOF& a, o2::dataformats::MatchInfoTOF& b) { return (a.getChi2() < b.getChi2()); }); + std::sort(mMatchedTracksPairs.begin(), mMatchedTracksPairs.end(), [this](o2::dataformats::MatchInfoTOFReco& a, o2::dataformats::MatchInfoTOFReco& b) { return (a.getChi2() < b.getChi2()); }); int i = 0; // then we take discard the pairs if their track or cluster was already matched (since they are ordered in chi2, we will take the best matching) - for (const o2::dataformats::MatchInfoTOF& matchingPair : mMatchedTracksPairs) { + for (const o2::dataformats::MatchInfoTOFReco& matchingPair : mMatchedTracksPairs) { int trkType = (int)matchingPair.getTrackType(); bool discard = matchingPair.getChi2() > chi2S; diff --git a/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h b/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h index d5e1f8f54f6d0..10171c735ea1e 100644 --- a/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h +++ b/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h @@ -15,7 +15,7 @@ #define O2_TOF_MATCHER_SPEC #include "Framework/DataProcessorSpec.h" -#include "ReconstructionDataFormats/MatchInfoTOF.h" +#include "ReconstructionDataFormats/MatchInfoTOFReco.h" using namespace o2::framework; diff --git a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx index 01ea79a4f01a3..794e1a996d63e 100644 --- a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx @@ -154,16 +154,16 @@ void TOFMatcherSpec::run(ProcessingContext& pc) mMatcher.run(); if (isTPCused) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); } } if (isITSTPCused) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); } } diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h b/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h index ffad01cb111aa..712a5a8d5c9ff 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h @@ -13,7 +13,7 @@ #define TOF_RECOWORKFLOW_H_ #include "Framework/DataProcessorSpec.h" -#include "ReconstructionDataFormats/MatchInfoTOF.h" +#include "ReconstructionDataFormats/MatchInfoTOFReco.h" namespace o2 { diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h b/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h index 342a68c3b6c1e..609ffd05fac0b 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h @@ -13,7 +13,7 @@ #define TOF_RECOWORKFLOWWITHTPC_H_ #include "Framework/DataProcessorSpec.h" -#include "ReconstructionDataFormats/MatchInfoTOF.h" +#include "ReconstructionDataFormats/MatchInfoTOFReco.h" namespace o2 { diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx index 77288366b6ddc..44606a0596873 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx @@ -108,9 +108,9 @@ class TOFDPLRecoWorkflowTask // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; // send matching-info - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::ITSTPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); } pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); mTimer.Stop(); diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx index 81074d8f559c6..7283129807ea9 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx @@ -116,7 +116,7 @@ class TOFDPLRecoWorkflowWithTPCTask mMatcher.setTPCTrackArray(tracksRO, tpclab); mMatcher.run(); - auto nmatch = mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::TPC).size(); + auto nmatch = mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC).size(); if (mDoTPCRefit) { LOG(INFO) << "Refitting " << nmatch << " matched TPC tracks with TOF time info"; } else { @@ -132,9 +132,9 @@ class TOFDPLRecoWorkflowWithTPCTask // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; // send matching-info - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOF::TrackType::TPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); } pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); mTimer.Stop(); From d504bc1794900e85f8041b13d6be1e9bcd4a1970 Mon Sep 17 00:00:00 2001 From: Francesco Noferini Date: Wed, 16 Jun 2021 11:27:14 +0200 Subject: [PATCH 3/7] cleanup TOF reco workflow --- .../MatchInfoTOFReco.h | 7 +- Detectors/AOD/CMakeLists.txt | 1 - Detectors/CTF/workflow/CMakeLists.txt | 5 +- Detectors/GlobalTracking/CMakeLists.txt | 4 +- .../include/GlobalTracking/MatchTOF.h | 111 ++-- Detectors/GlobalTracking/src/MatchTOF.cxx | 611 ++++++++---------- Detectors/GlobalTrackingWorkflow/README.md | 2 +- .../GlobalTrackingWorkflow/TOFMatcherSpec.h | 2 +- .../src/TOFMatcherSpec.cxx | 83 +-- .../src/tof-matcher-workflow.cxx | 26 +- .../tofworkflow/CMakeLists.txt | 24 +- .../include/TOFWorkflow/RecoWorkflowSpec.h | 28 - .../TOFWorkflow/RecoWorkflowWithTPCSpec.h | 28 - .../tofworkflow/src/RecoWorkflowSpec.cxx | 161 ----- .../src/RecoWorkflowWithTPCSpec.cxx | 192 ------ .../tofworkflow/src/tof-calibinfo-reader.cxx | 3 - .../tofworkflow/src/tof-matcher-global.cxx | 164 ----- .../tofworkflow/src/tof-matcher-tpc.cxx | 166 ----- .../tofworkflow/src/tof-reco-workflow.cxx | 42 +- Detectors/TOF/base/src/Geo.cxx | 2 +- macro/CMakeLists.txt | 8 - macro/checkTOFMatching.C | 2 +- macro/run_match_tof.C | 88 --- prodtests/full-system-test/dpl-workflow.sh | 4 +- prodtests/sim_challenge.sh | 14 +- 25 files changed, 405 insertions(+), 1373 deletions(-) delete mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h delete mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h delete mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx delete mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx delete mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-global.cxx delete mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-tpc.cxx delete mode 100644 macro/run_match_tof.C diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h index 95d4e16cfd485..fda17c3501747 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h @@ -26,11 +26,14 @@ class MatchInfoTOFReco : public MatchInfoTOF using evIdx = o2::dataformats::EvIndex; public: - enum TrackType : int8_t { TPC = 0, + enum TrackType : int8_t { UNCONS = 0, + CONSTR, + SIZE, + TPC = 0, ITSTPC, TPCTRD, ITSTPCTRD, - SIZE }; + SIZEALL }; MatchInfoTOFReco(evIdx evIdxTOFCl, float chi2, o2::track::TrackLTIntegral trkIntLT, evGIdx evIdxTrack, TrackType trkType, float dt = 0, float z = 0) : MatchInfoTOF(evIdxTOFCl, chi2, trkIntLT, evIdxTrack, dt, z), mTrackType(trkType){}; diff --git a/Detectors/AOD/CMakeLists.txt b/Detectors/AOD/CMakeLists.txt index 9d329980bbb80..0187e7835e7a2 100644 --- a/Detectors/AOD/CMakeLists.txt +++ b/Detectors/AOD/CMakeLists.txt @@ -25,7 +25,6 @@ o2_add_library( O2::MFTWorkflow O2::SimulationDataFormat O2::Steer - O2::TOFWorkflow O2::TPCWorkflow O2::CCDB O2::MathUtils diff --git a/Detectors/CTF/workflow/CMakeLists.txt b/Detectors/CTF/workflow/CMakeLists.txt index 82e1f21192514..0462350a3ee21 100644 --- a/Detectors/CTF/workflow/CMakeLists.txt +++ b/Detectors/CTF/workflow/CMakeLists.txt @@ -25,7 +25,7 @@ o2_add_library(CTFWorkflow O2::DataFormatsPHOS O2::DataFormatsCPV O2::DataFormatsZDC - O2::DataFormatsHMP + O2::DataFormatsHMP O2::DataFormatsParameters O2::ITSMFTWorkflow O2::TPCWorkflow @@ -33,14 +33,13 @@ o2_add_library(CTFWorkflow O2::FT0Workflow O2::FV0Workflow O2::FDDWorkflow - O2::TOFWorkflow O2::MCHWorkflow O2::MIDWorkflow O2::EMCALWorkflow O2::PHOSWorkflow O2::CPVWorkflow O2::ZDCWorkflow - O2::HMPIDWorkflow + O2::HMPIDWorkflow O2::Algorithm O2::CommonUtils) diff --git a/Detectors/GlobalTracking/CMakeLists.txt b/Detectors/GlobalTracking/CMakeLists.txt index cde8c5b8df64c..11db4b6cf5a4f 100644 --- a/Detectors/GlobalTracking/CMakeLists.txt +++ b/Detectors/GlobalTracking/CMakeLists.txt @@ -11,7 +11,8 @@ o2_add_library( GlobalTracking - SOURCES src/MatchTPCITS.cxx src/MatchTOF.cxx + SOURCES src/MatchTPCITS.cxx + src/MatchTOF.cxx src/MatchTPCITSParams.cxx src/MatchCosmics.cxx src/MatchCosmicsParams.cxx @@ -30,6 +31,7 @@ o2_add_library( O2::TPCReconstruction O2::TOFBase O2::TOFCalibration + O2::TOFWorkflowUtils O2::SimConfig O2::DataFormatsFT0 O2::DataFormatsGlobalTracking diff --git a/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h b/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h index 8808b7fa5c835..49738c9d45a14 100644 --- a/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h +++ b/Detectors/GlobalTracking/include/GlobalTracking/MatchTOF.h @@ -37,6 +37,7 @@ #include "DataFormatsTPC/TrackTPC.h" #include "ReconstructionDataFormats/PID.h" #include "TPCFastTransform.h" +#include "CommonDataFormat/InteractionRecord.h" // from FIT #include "DataFormatsFT0/RecPoints.h" @@ -44,6 +45,11 @@ namespace o2 { +namespace globaltracking +{ +class RecoContainer; +} + namespace dataformats { template @@ -73,10 +79,11 @@ class MatchTOF using evIdx = o2::dataformats::EvIndex; using timeEst = o2::dataformats::TimeStampWithError; using matchTrack = std::pair; + using trkType = o2::dataformats::MatchInfoTOFReco::TrackType; public: ///< perform matching for provided input - virtual void run(); + void run(const o2::globaltracking::RecoContainer& inp); void setCosmics() { @@ -87,11 +94,6 @@ class MatchTOF void setHighPurity(bool value = true) { mSetHighPurity = value; } - ///< attach DPL data and run - void setTOFClusterArray(const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab); - void setTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab); - void setITSTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab); - ///< print settings void print() const; void printCandidatesTOF() const; @@ -131,22 +133,10 @@ class MatchTOF } } - std::vector& getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType index) { return mMatchedTracks[index]; } + std::vector& getMatchedTrackVector(trkType index) { return mMatchedTracks[index]; } std::vector& getCalibVector() { return mCalibInfoTOF; } - std::vector& getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType index) { return mOutTOFLabels[index]; } ///< get vector of TOF label of matched tracks - - // this method is deprecated - void setFITRecPoints(const std::vector* recpoints) - { - if (recpoints) { - mFITRecPoints = {recpoints->data(), recpoints->size()}; - } - } - void setFITRecPoints(gsl::span recpoints) - { - mFITRecPoints = recpoints; - } + std::vector& getMatchedTOFLabelsVector(trkType index) { return mOutTOFLabels[index]; } ///< get vector of TOF label of matched tracks ///< set input TPC tracks cluster indices void setTPCTrackClusIdxInp(const gsl::span inp) @@ -166,14 +156,18 @@ class MatchTOF mTPCClusterIdxStruct = inp; } + void setFIT(bool value = true) { mIsFIT = value; } int findFITIndex(int bc); + void checkRefitter(); + bool makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCTOF& trConstr); + ///< populate externally provided container by TOF-time-constrained TPC tracks template void makeConstrainedTPCTracks(V& container) { checkRefitter(); - int nmatched = mMatchedTracks[o2::dataformats::MatchInfoTOFReco::TrackType::TPC].size(), nconstrained = 0; + int nmatched = mMatchedTracks[trkType::TPC].size(), nconstrained = 0; container.resize(nmatched); for (unsigned i = 0; i < nmatched; i++) { if (makeConstrainedTPCTrack(i, container[nconstrained])) { @@ -183,12 +177,17 @@ class MatchTOF container.resize(nconstrained); } - protected: - virtual bool prepareTracks(); - virtual bool prepareTPCTracks(); - virtual bool prepareTOFClusters(); - - void doMatching(int sec, o2::dataformats::MatchInfoTOFReco::TrackType type = o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC); + private: + bool prepareFITData(); + int prepareInteractionTimes(); + bool prepareTPCData(); + void addTPCSeed(const o2::tpc::TrackTPC& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID); + void addITSTPCSeed(const o2::dataformats::TrackTPCITS& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID); + // void addTPCTRDSeed(const o2::track::TrackParCov& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID); + // void addITSTPCTRDSeed(const o2::track::TrackParCov& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID); + bool prepareTOFClusters(); + + void doMatching(int sec); void doMatchingForTPC(int sec); void selectBestMatches(); void selectBestMatchesHP(); @@ -196,25 +195,25 @@ class MatchTOF bool propagateToRefXWithoutCov(o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz); void updateTimeDependentParams(); - void checkRefitter(); - bool makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCTOF& trConstr); + + void splitOutputs(); //================================================================ // Data members + const o2::globaltracking::RecoContainer* mRecoCont = nullptr; + o2::InteractionRecord mStartIR{0, 0}; ///< IR corresponding to the start of the TF // for derived class - int mCurrTracksTreeEntry = 0; ///< current tracks tree entry loaded to memory - bool mSAInitDone = false; ///< flag that standalone init already done - bool mWFInputAttached = false; ///< flag that the standalone input is attached - Bool_t mIsworkflowON = kFALSE; ///< flag used in the standalone mode + int mCurrTracksTreeEntry = 0; ///< current tracks tree entry loaded to memory float mXRef = Geo::RMIN; ///< reference radius to propage tracks for matching bool mMCTruthON = false; ///< flag availability of MC truth ///========== Parameters to be set externally, e.g. from CCDB ==================== - float mBz = 0; ///< nominal Bz + float mBz = 0; ///< nominal Bz + float mMaxInvPt = 999.; ///< derived from nominal Bz // to be done later float mTPCTBinMUS = 0.; ///< TPC time bin duration in microseconds @@ -226,20 +225,21 @@ class MatchTOF float mSpaceTolerance = 10; ///< tolerance in cm for track-TOF time bracket matching int mSigmaTimeCut = 30.; ///< number of sigmas to cut on time when matching the track to the TOF cluster + bool mIsFIT = false; bool mIsITSTPCused = false; bool mIsTPCused = false; bool mIsTPCTRDused = false; bool mIsITSTPCTRDused = false; bool mSetHighPurity = false; + // from ruben + gsl::span mTPCTracksArray; ///< input TPC tracks span + ///>>>------ these are input arrays which should not be modified by the matching code // since this info is provided by external device - gsl::span mITSTPCTracksArrayInp; ///< input tracks - std::vector* mITSTPCTracksArrayInpVect; ///< input tracks (vector to read from tree) - gsl::span mTPCTracksArrayInp; ///< input TPC tracks - std::vector* mTPCTracksArrayInpVect; ///< input tracks (vector to read from tree) - gsl::span mTOFClustersArrayInp; ///< input TOF clusters - std::vector* mTOFClustersArrayInpVect; ///< input TOF clusters (vector to read from tree) + // std::vector mITSTPCTracksArrayInp; ///< input tracks + std::vector mTPCTracksArrayInp; ///< input TPC tracks + gsl::span mTOFClustersArrayInp; ///< input TOF clusters /// data needed for refit of time-constrained TPC tracks gsl::span mTPCTrackClusIdx; ///< input TPC track cluster indices span @@ -248,27 +248,25 @@ class MatchTOF std::unique_ptr mTPCTransform; ///< TPC cluster transformation std::unique_ptr mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction - o2::dataformats::MCTruthContainer mTOFClusLabels; ///< input TOF clusters MC labels - o2::dataformats::MCTruthContainer* mTOFClusLabelsPtr; ///< input TOF clusters MC labels (pointer to read from tree) - std::vector mTracksLblWork; ///* mTOFClusLabels; ///< input TOF clusters MC labels (pointer to read from tree) + std::vector mTracksLblWork[trkType::SIZE]; /// mTPCLabels[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< TPC label of input tracks - std::vector* mTPCLabelsVect[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< TPC label of input tracks (vector to read from tree) + int mNotPropagatedToTOF[trkType::SIZE]; ///< number of tracks failing in propagation - gsl::span mFITRecPoints; ///< FIT recpoints + gsl::span mFITRecPoints; ///< FIT recpoints /// <<<----- /// mTracksWork[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; /// mTracksWork[trkType::SIZE]; /// mExtraTPCFwdTime; /// mLTinfos; /// mTOFClusWork; /// mSideTPC; /// mExtraTPCFwdTime; /// mLTinfos[trkType::SIZE]; /// mTOFClusWork; /// mSideTPC; ///, o2::constants::math::NSectors> mTracksSectIndexCache[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; + std::array, o2::constants::math::NSectors> mTracksSectIndexCache[trkType::SIZE]; ///< per sector indices of TOF cluster entry in mTOFClusWork std::array, o2::constants::math::NSectors> mTOFClusSectIndexCache; @@ -280,11 +278,12 @@ class MatchTOF /// mMatchedTracks; - std::vector mMatchedTracks[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; // this is the output of the matching - std::vector mOutTOFLabels[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; ///< TOF label of matched tracks + std::vector mMatchedTracks[trkType::SIZE]; // this is the output of the matching -> UNCONS, CONSTR + std::vector mMatchedTracksAll[trkType::SIZEALL]; // this is the output of the matching -> TPC, ITS-TPC, TPC-TRD, ITS-TPC-TRD + std::vector mOutTOFLabels[trkType::SIZE]; ///< TOF label of matched tracks + std::vector mOutTOFLabelsAll[trkType::SIZEALL]; ///< TOF label of matched tracks - int mNumOfTracks[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; // number of tracks to be matched - std::vector mMatchedTracksIndex[o2::dataformats::MatchInfoTOFReco::TrackType::SIZE]; // vector of indexes of the tracks to be matched + std::vector mMatchedTracksIndex[trkType::SIZE]; // vector of indexes of the tracks to be matched int mNumOfClusters; // number of clusters to be matched int* mMatchedClustersIndex = nullptr; //[mNumOfClusters] diff --git a/Detectors/GlobalTracking/src/MatchTOF.cxx b/Detectors/GlobalTracking/src/MatchTOF.cxx index a79bd2ea3b6b8..c3fe595cec87e 100644 --- a/Detectors/GlobalTracking/src/MatchTOF.cxx +++ b/Detectors/GlobalTracking/src/MatchTOF.cxx @@ -41,91 +41,75 @@ #include "TPCBase/ParameterElectronics.h" #include "TPCReconstruction/TPCFastTransformHelperO2.h" +#include "DataFormatsGlobalTracking/RecoContainer.h" +#include "DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h" + using namespace o2::globaltracking; using evGIdx = o2::dataformats::EvIndex; using evIdx = o2::dataformats::EvIndex; using trkType = o2::dataformats::MatchInfoTOFReco::TrackType; using Cluster = o2::tof::Cluster; +using GTrackID = o2::dataformats::GlobalTrackID; ClassImp(MatchTOF); //______________________________________________ -void MatchTOF::run() +void MatchTOF::run(const o2::globaltracking::RecoContainer& inp) { ///< running the matching + mRecoCont = &inp; + mStartIR = inp.startIR; updateTimeDependentParams(); mTimerTot.Start(); - // we load all TOF clusters (to be checked if we need to split per time frame) - prepareTOFClusters(); - mTimerTot.Stop(); LOGF(INFO, "Timing prepareTOFCluster: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); mTimerTot.Start(); for (int i = 0; i < trkType::SIZE; i++) { - mNumOfTracks[i] = 0; mMatchedTracks[i].clear(); mTracksWork[i].clear(); mOutTOFLabels[i].clear(); } - if (mIsworkflowON) { + if (!prepareTOFClusters()) { // check cluster before of tracks to see also if MC is required + return; + } - if (mIsITSTPCused) { - prepareTracks(); + if (!prepareTPCData() || !prepareFITData()) { + return; + } + + mTimerTot.Stop(); + LOGF(INFO, "Timing prepare tracks: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); + mTimerTot.Start(); + + for (int sec = o2::constants::math::NSectors; sec--;) { + mMatchedTracksPairs.clear(); // new sector + LOG(INFO) << "Doing matching for sector " << sec << "..."; + if (mIsITSTPCused || mIsTPCTRDused || mIsITSTPCTRDused) { + doMatching(sec); } if (mIsTPCused) { - prepareTPCTracks(); + doMatchingForTPC(sec); } + LOG(INFO) << "...done. Now check the best matches"; + selectBestMatches(); + } - mTimerTot.Stop(); - LOGF(INFO, "Timing prepare tracks: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); - mTimerTot.Start(); + // re-arrange outputs from constrained/unconstrained to the 4 cases (TPC, ITS-TPC, TPC-TRD, ITS-TPC-TRD) to be implemented as soon as TPC-TRD and ITS-TPC-TRD tracks available + // splitOutputs(); - for (int sec = o2::constants::math::NSectors; sec--;) { - mMatchedTracksPairs.clear(); // new sector - LOG(INFO) << "Doing matching for sector " << sec << "..."; - if (mIsITSTPCused) { - doMatching(sec, trkType::ITSTPC); - } - if (mIsTPCused) { - doMatchingForTPC(sec); - } - LOG(INFO) << "...done. Now check the best matches"; - selectBestMatches(); - } - } + mIsTPCused = false; + mIsITSTPCused = false; + mIsTPCTRDused = false; + mIsITSTPCTRDused = false; mTimerTot.Stop(); LOGF(INFO, "Timing Do Matching: Cpu: %.3e s Real: %.3e s in %d slots", mTimerTot.CpuTime(), mTimerTot.RealTime(), mTimerTot.Counter() - 1); } //______________________________________________ -void MatchTOF::setTOFClusterArray(const gsl::span& clusterArray, const o2::dataformats::MCTruthContainer& toflab) -{ - mTOFClustersArrayInp = clusterArray; - mTOFClusLabels = toflab; - mIsworkflowON = kTRUE; - mMCTruthON = mTOFClusLabels.getNElements(); - mWFInputAttached = true; - mSAInitDone = true; -} -//______________________________________________ -void MatchTOF::setTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab) -{ - mIsTPCused = true; - mTPCTracksArrayInp = trackArray; - mTPCLabels[trkType::TPC] = tpclab; -} -//______________________________________________ -void MatchTOF::setITSTPCTrackArray(const gsl::span& trackArray, const gsl::span& tpclab) -{ - mIsITSTPCused = true; - mITSTPCTracksArrayInp = trackArray; - mTPCLabels[trkType::ITSTPC] = tpclab; -} -//______________________________________________ void MatchTOF::print() const { ///< print the settings @@ -144,256 +128,219 @@ void MatchTOF::printCandidatesTOF() const { ///< print the candidates for the matching } -//______________________________________________ -bool MatchTOF::prepareTracks() +//_____________________________________________________ +bool MatchTOF::prepareFITData() { - ///< prepare the tracks that we want to match to TOF - - if (!mIsworkflowON) { - return false; - } - - mNumOfTracks[trkType::ITSTPC] = mITSTPCTracksArrayInp.size(); - if (mNumOfTracks[trkType::ITSTPC] == 0) { - return false; // no tracks to be matched - } - mMatchedTracksIndex[trkType::ITSTPC].resize(mNumOfTracks[trkType::ITSTPC]); - std::fill(mMatchedTracksIndex[trkType::ITSTPC].begin(), mMatchedTracksIndex[trkType::ITSTPC].end(), -1); // initializing all to -1 - - // copy the track params, propagate to reference X and build sector tables - mLTinfos.clear(); - mTracksWork[trkType::ITSTPC].reserve(mNumOfTracks[trkType::ITSTPC]); - mLTinfos.reserve(mNumOfTracks[trkType::ITSTPC]); - if (mMCTruthON) { - mTracksLblWork.clear(); - mTracksLblWork.reserve(mNumOfTracks[trkType::ITSTPC]); - } - for (int sec = o2::constants::math::NSectors; sec--;) { - mTracksSectIndexCache[trkType::ITSTPC][sec].clear(); - mTracksSectIndexCache[trkType::ITSTPC][sec].reserve(100 + 1.2 * mNumOfTracks[trkType::ITSTPC] / o2::constants::math::NSectors); + // If available, read FIT Info + if (mIsFIT) { + mFITRecPoints = mRecoCont->getFT0RecPoints(); + // prepareInteractionTimes(); } + return true; +} +//______________________________________________ +int MatchTOF::prepareInteractionTimes() +{ + // do nothing. If you think it can be useful have a look at MatchTPCITS + return 0; +} +//______________________________________________ +bool MatchTOF::prepareTPCData() +{ + mNotPropagatedToTOF[trkType::UNCONS] = 0; + mNotPropagatedToTOF[trkType::CONSTR] = 0; - float maxInvPt = abs(mBz) > 0.1 ? 1. / (abs(mBz) * 0.05) : 999.; + mTPCTracksArrayInp.clear(); - LOG(DEBUG) << "\n\nWe have %d ITS-TPC tracks to try to match to TOF: " << mNumOfTracks[trkType::ITSTPC]; - int nNotPropagatedToTOF = 0; - for (int it = 0; it < mNumOfTracks[trkType::ITSTPC]; it++) { - const o2::dataformats::TrackTPCITS& trcOrig = mITSTPCTracksArrayInp[it]; // TODO: check if we cannot directly use the o2::track::TrackParCov class instead of o2::dataformats::TrackTPCITS, and then avoid the casting below; this is the track at the vertex - std::array globalPos; + for (int it = 0; it < trkType::SIZE; it++) { + mMatchedTracksIndex[it].clear(); - // create working copy of track param - mTracksWork[trkType::ITSTPC].emplace_back(std::make_pair(trcOrig.getParamOut(), trcOrig.getTimeMUS())); - mLTinfos.emplace_back(trcOrig.getLTIntegralOut()); - // make a copy of the TPC track that we have to propagate - //o2::tpc::TrackTPC* trc = new o2::tpc::TrackTPC(trcTPCOrig); // this would take the TPCout track - //auto& trc = mTracksWork[trkType::ITSTPC].back(); // with this we take the TPCITS track propagated to the vertex - auto& trc = mTracksWork[trkType::ITSTPC].back().first; // with this we take the TPCITS track propagated to the vertex - auto& intLT = mLTinfos.back(); // we get the integrated length from TPC-ITC outward propagation - - if (trc.getX() < o2::constants::geom::XTPCOuterRef - 1.) { // tpc-its track outward propagation did not reach outer ref.radius, skip this track - nNotPropagatedToTOF++; - continue; - } + mLTinfos[it].clear(); - // propagate to matching Xref - trc.getXYZGlo(globalPos); - LOG(DEBUG) << "Global coordinates Before propagating to 371 cm: globalPos[0] = " << globalPos[0] << ", globalPos[1] = " << globalPos[1] << ", globalPos[2] = " << globalPos[2]; - LOG(DEBUG) << "Radius xy Before propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1]); - LOG(DEBUG) << "Radius xyz Before propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); - if (!propagateToRefXWithoutCov(trc, mXRef, 2, mBz)) { // we first propagate to 371 cm without considering the covariance matrix - nNotPropagatedToTOF++; - continue; + if (mMCTruthON) { + mTracksLblWork[it].clear(); } - - // the "rough" propagation worked; now we can propagate considering also the cov matrix - if (!propagateToRefX(trc, mXRef, 2, intLT) || TMath::Abs(trc.getZ()) > Geo::MAXHZTOF) { // we check that the propagation with the cov matrix worked; CHECK: can it happen that it does not if the propagation without the errors succeeded? - nNotPropagatedToTOF++; - continue; + for (int sec = o2::constants::math::NSectors; sec--;) { + mTracksSectIndexCache[it][sec].clear(); } + } - trc.getXYZGlo(globalPos); + auto creator = [this](auto& trk, GTrackID gid, float time0, float terr) { + const int nclustersMin = 0; + if constexpr (isTPCTrack()) { + if (trk.getNClusters() < nclustersMin) { + return true; + } - LOG(DEBUG) << "Global coordinates After propagating to 371 cm: globalPos[0] = " << globalPos[0] << ", globalPos[1] = " << globalPos[1] << ", globalPos[2] = " << globalPos[2]; - LOG(DEBUG) << "Radius xy After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1]); - LOG(DEBUG) << "Radius xyz After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); - LOG(DEBUG) << "The track will go to sector " << o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0])); + if (std::abs(trk.getQ2Pt()) > mMaxInvPt) { + return true; + } + this->addTPCSeed(trk, gid, gid.getIndex()); + } + if constexpr (isTPCITSTrack()) { + if (trk.getParamOut().getX() < o2::constants::geom::XTPCOuterRef - 1.) { + return true; + } + this->addITSTPCSeed(trk, gid, gid.getIndex()); + } + return true; + }; + mRecoCont->createTracksVariadic(creator); - mTracksSectIndexCache[trkType::ITSTPC][o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); - //delete trc; // Check: is this needed? + for (int it = 0; it < trkType::SIZE; it++) { + mMatchedTracksIndex[it].resize(mTracksWork[it].size()); + std::fill(mMatchedTracksIndex[it].begin(), mMatchedTracksIndex[it].end(), -1); // initializing all to -1 } - LOG(INFO) << "Total number of tracks = " << mNumOfTracks[trkType::ITSTPC] << ", Number of tracks that failed to be propagated to TOF = " << nNotPropagatedToTOF; + if (mIsTPCused) { + LOG(INFO) << "Total number of TPC tracks = " << mTracksLblWork[trkType::UNCONS].size() << ", Number of UNCONSTRAINED tracks that failed to be propagated to TOF = " << mNotPropagatedToTOF[trkType::UNCONS]; - // sort tracks in each sector according to their time (increasing in time) - for (int sec = o2::constants::math::NSectors; sec--;) { - auto& indexCache = mTracksSectIndexCache[trkType::ITSTPC][sec]; - LOG(INFO) << "Sorting sector" << sec << " | " << indexCache.size() << " tracks"; - if (!indexCache.size()) { - continue; - } - std::sort(indexCache.begin(), indexCache.end(), [this](int a, int b) { - auto& trcA = mTracksWork[trkType::ITSTPC][a].second; - auto& trcB = mTracksWork[trkType::ITSTPC][b].second; - return ((trcA.getTimeStamp() - mSigmaTimeCut * trcA.getTimeStampError()) - (trcB.getTimeStamp() - mSigmaTimeCut * trcB.getTimeStampError()) < 0.); - }); - } // loop over tracks of single sector + // sort tracks in each sector according to their time (increasing in time) + for (int sec = o2::constants::math::NSectors; sec--;) { + auto& indexCache = mTracksSectIndexCache[trkType::UNCONS][sec]; + LOG(INFO) << "Sorting sector" << sec << " | " << indexCache.size() << " tracks"; + if (!indexCache.size()) { + continue; + } + std::sort(indexCache.begin(), indexCache.end(), [this](int a, int b) { + auto& trcA = mTracksWork[trkType::UNCONS][a].second; + auto& trcB = mTracksWork[trkType::UNCONS][b].second; + return ((trcA.getTimeStamp() - trcA.getTimeStampError()) - (trcB.getTimeStamp() - trcB.getTimeStampError()) < 0.); + }); + } // loop over tracks of single sector + } + if (mIsITSTPCused || mIsTPCTRDused || mIsITSTPCTRDused) { + LOG(INFO) << "Total number of TPC tracks = " << mTracksLblWork[trkType::CONSTR].size() << ", Number of CONSTRAINED tracks that failed to be propagated to TOF = " << mNotPropagatedToTOF[trkType::CONSTR]; - // Uncomment for local debug - /* - // printing the tracks - std::array globalPos; - int itmp = 0; - for (int sec = o2::constants::math::NSectors; sec--;) { - auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! - for (int itrk = 0; itrk < cacheTrk.size(); itrk++){ - itmp++; - auto& trc = mTracksWork[trkType::ITSTPC][cacheTrk[itrk]]; - trc.getXYZGlo(globalPos); - //printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f\n", itrk, globalPos[0], globalPos[1], globalPos[2]); - // Printf("The phi angle is %f", TMath::ATan2(globalPos[1], globalPos[0])); - } + // sort tracks in each sector according to their time (increasing in time) + for (int sec = o2::constants::math::NSectors; sec--;) { + auto& indexCache = mTracksSectIndexCache[trkType::CONSTR][sec]; + LOG(INFO) << "Sorting sector" << sec << " | " << indexCache.size() << " tracks"; + if (!indexCache.size()) { + continue; + } + std::sort(indexCache.begin(), indexCache.end(), [this](int a, int b) { + auto& trcA = mTracksWork[trkType::CONSTR][a].second; + auto& trcB = mTracksWork[trkType::CONSTR][b].second; + return ((trcA.getTimeStamp() - mSigmaTimeCut * trcA.getTimeStampError()) - (trcB.getTimeStamp() - mSigmaTimeCut * trcB.getTimeStampError()) < 0.); + }); + } // loop over tracks of single sector } - Printf("we have %d tracks",itmp); - */ return true; } //______________________________________________ -bool MatchTOF::prepareTPCTracks() +void MatchTOF::addITSTPCSeed(const o2::dataformats::TrackTPCITS& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID) { - ///< prepare the tracks that we want to match to TOF + mIsITSTPCused = true; - if (!mIsworkflowON) { - return false; - } + std::array globalPos; - mNumOfTracks[trkType::TPC] = mTPCTracksArrayInp.size(); - if (mNumOfTracks[trkType::TPC] == 0) { - return false; // no tracks to be matched - } - mMatchedTracksIndex[trkType::TPC].resize(mNumOfTracks[trkType::TPC]); - std::fill(mMatchedTracksIndex[trkType::TPC].begin(), mMatchedTracksIndex[trkType::TPC].end(), -1); // initializing all to -1 + // current track index + int it = mTracksWork[trkType::CONSTR].size(); - // copy the track params, propagate to reference X and build sector tables - mTracksWork[trkType::TPC].reserve(mNumOfTracks[trkType::TPC]); - mSideTPC.clear(); - mSideTPC.reserve(mNumOfTracks[trkType::TPC]); - mExtraTPCFwdTime.clear(); - mExtraTPCFwdTime.reserve(mNumOfTracks[trkType::TPC]); + auto trc = _tr.getParamOut(); + o2::track::TrackLTIntegral intLT0 = _tr.getLTIntegralOut(); - for (int sec = o2::constants::math::NSectors; sec--;) { - mTracksSectIndexCache[trkType::TPC][sec].clear(); - mTracksSectIndexCache[trkType::TPC][sec].reserve(100 + 1.2 * mNumOfTracks[trkType::TPC] / o2::constants::math::NSectors); + // propagate to matching Xref + trc.getXYZGlo(globalPos); + LOG(DEBUG) << "Global coordinates Before propagating to 371 cm: globalPos[0] = " << globalPos[0] << ", globalPos[1] = " << globalPos[1] << ", globalPos[2] = " << globalPos[2]; + LOG(DEBUG) << "Radius xy Before propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1]); + LOG(DEBUG) << "Radius xyz Before propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); + if (!propagateToRefXWithoutCov(trc, mXRef, 2, mBz)) { // we first propagate to 371 cm without considering the covariance matrix + mNotPropagatedToTOF[trkType::CONSTR]++; + return; } - float maxInvPt = abs(mBz) > 0.1 ? 1. / (abs(mBz) * 0.05) : 999.; - int nclustersMin = 0; - LOG(INFO) << "Max track Inv pT allowed = " << maxInvPt; - LOG(INFO) << "Min track Nclusters allowed = " << nclustersMin; + // the "rough" propagation worked; now we can propagate considering also the cov matrix + if (!propagateToRefX(trc, mXRef, 2, intLT0) || TMath::Abs(trc.getZ()) > Geo::MAXHZTOF) { // we check that the propagation with the cov matrix worked; CHECK: can it happen that it does not if the prop> + mNotPropagatedToTOF[trkType::CONSTR]++; + return; + } - LOG(DEBUG) << "\n\nWe have %d TPC tracks to try to match to TOF: " << mNumOfTracks[trkType::TPC]; - int nNotPropagatedToTOF = 0; - for (int it = 0; it < mNumOfTracks[trkType::TPC]; it++) { - const o2::tpc::TrackTPC& trcOrig = mTPCTracksArrayInp[it]; // TODO: check if we cannot directly use the o2::track::TrackParCov class instead of o2::dataformats::TrackTPCITS, and then avoid the casting below; this is the track at the vertex - std::array globalPos; + trc.getXYZGlo(globalPos); - // create working copy of track param - timeEst timeInfo; - // set - float extraErr = 0; - if (mIsCosmics) { - extraErr = 100; - } - timeInfo.setTimeStamp(trcOrig.getTime0() * mTPCTBinMUS); - timeInfo.setTimeStampError((trcOrig.getDeltaTBwd() + 5) * mTPCTBinMUS + extraErr); - mSideTPC.push_back(trcOrig.hasASideClustersOnly() ? 1 : (trcOrig.hasCSideClustersOnly() ? -1 : 0)); - mExtraTPCFwdTime.push_back((trcOrig.getDeltaTFwd() + 5) * mTPCTBinMUS + extraErr); - - o2::track::TrackLTIntegral intLT0; //mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation - // make a copy of the TPC track that we have to propagate - //o2::tpc::TrackTPC* trc = new o2::tpc::TrackTPC(trcTPCOrig); // this would take the TPCout track - mTracksWork[trkType::TPC].emplace_back(std::make_pair(trcOrig.getOuterParam(), timeInfo)); - auto& trc = mTracksWork[trkType::TPC].back().first; - auto& intLT = mLTinfos.emplace_back(intLT0); - - if (trcOrig.getNClusters() < nclustersMin) { - nNotPropagatedToTOF++; - continue; - } + LOG(DEBUG) << "Global coordinates After propagating to 371 cm: globalPos[0] = " << globalPos[0] << ", globalPos[1] = " << globalPos[1] << ", globalPos[2] = " << globalPos[2]; + LOG(DEBUG) << "Radius xy After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1]); + LOG(DEBUG) << "Radius xyz After propagating to 371 cm = " << TMath::Sqrt(globalPos[0] * globalPos[0] + globalPos[1] * globalPos[1] + globalPos[2] * globalPos[2]); + LOG(DEBUG) << "The track will go to sector " << o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0])); - if (std::abs(trc.getQ2Pt()) > maxInvPt) { // tpc-its track outward propagation did not reach outer ref.radius, skip this track - nNotPropagatedToTOF++; - continue; - } + // create working copy of track param + mTracksWork[trkType::CONSTR].emplace_back(std::make_pair(trc, _tr.getTimeMUS())); + mLTinfos[trkType::CONSTR].emplace_back(intLT0); - // printf("N clusters = %d\n",trcOrig.getNClusters()); + if (mMCTruthON) { + mTracksLblWork[trkType::CONSTR].emplace_back(mRecoCont->getTPCITSTrackMCLabel(srcGID)); + } - if (!propagateToRefXWithoutCov(trc, mXRef, 10, mBz)) { // we first propagate to 371 cm without considering the covariance matrix - nNotPropagatedToTOF++; - continue; - } + mTracksSectIndexCache[trkType::CONSTR][o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); + //delete trc; // Check: is this needed? +} +//______________________________________________ +void MatchTOF::addTPCSeed(const o2::tpc::TrackTPC& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID) +{ + mIsTPCused = true; - if (trc.getX() < o2::constants::geom::XTPCOuterRef - 1.) { - if (!propagateToRefX(trc, o2::constants::geom::XTPCOuterRef, 10, intLT) || TMath::Abs(trc.getZ()) > Geo::MAXHZTOF) { // we check that the propagation with the cov matrix worked; CHECK: can it happen that it does not if the propagation without the errors succeeded? - nNotPropagatedToTOF++; - continue; - } - } + std::array globalPos; - // the "rough" propagation worked; now we can propagate considering also the cov matrix - if (!propagateToRefX(trc, mXRef, 2, intLT) || TMath::Abs(trc.getZ()) > Geo::MAXHZTOF) { // we check that the propagation with the cov matrix worked; CHECK: can it happen that it does not if the propagation without the errors succeeded? - nNotPropagatedToTOF++; - continue; - } + // current track index + int it = mTracksWork[trkType::UNCONS].size(); + + // create working copy of track param + timeEst timeInfo; + // set + float extraErr = 0; + if (mIsCosmics) { + extraErr = 100; + } - trc.getXYZGlo(globalPos); + auto trc = _tr.getOuterParam(); - mTracksSectIndexCache[trkType::TPC][o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); - //delete trc; // Check: is this needed? + if (!propagateToRefXWithoutCov(trc, mXRef, 10, mBz)) { // we first propagate to 371 cm without considering the covariance matri + mNotPropagatedToTOF[trkType::UNCONS]++; + return; } - LOG(INFO) << "Total number of tracks = " << mNumOfTracks[trkType::TPC] << ", Number of tracks that failed to be propagated to TOF = " << nNotPropagatedToTOF; + o2::track::TrackLTIntegral intLT0; //mTPCTracksWork.back().getLTIntegralOut(); // we get the integrated length from TPC-ITC outward propagation - // sort tracks in each sector according to their time (increasing in time) - for (int sec = o2::constants::math::NSectors; sec--;) { - auto& indexCache = mTracksSectIndexCache[trkType::TPC][sec]; - LOG(INFO) << "Sorting sector" << sec << " | " << indexCache.size() << " tracks"; - if (!indexCache.size()) { - continue; + if (trc.getX() < o2::constants::geom::XTPCOuterRef - 1.) { + if (!propagateToRefX(trc, o2::constants::geom::XTPCOuterRef, 10, intLT0) || TMath::Abs(trc.getZ()) > Geo::MAXHZTOF) { // we check that the propagation with the cov matrix worked; CHECK: can it happ + mNotPropagatedToTOF[trkType::UNCONS]++; + return; } - std::sort(indexCache.begin(), indexCache.end(), [this](int a, int b) { - auto& trcA = mTracksWork[trkType::TPC][a].second; - auto& trcB = mTracksWork[trkType::TPC][b].second; - return ((trcA.getTimeStamp() - trcA.getTimeStampError()) - (trcB.getTimeStamp() - trcB.getTimeStampError()) < 0.); - }); + } - } // loop over tracks of single sector + // the "rough" propagation worked; now we can propagate considering also the cov matrix + if (!propagateToRefX(trc, mXRef, 2, intLT0) || TMath::Abs(trc.getZ()) > Geo::MAXHZTOF) { // we check that the propagation with the cov matrix worked; CHECK: can it happen that it does not if the prop> + mNotPropagatedToTOF[trkType::UNCONS]++; + return; + } - // Uncomment for local debug - /* - // printing the tracks - std::array globalPos; - int itmp = 0; - for (int sec = o2::constants::math::NSectors; sec--;) { - Printf("sector %d", sec); - auto& cacheTrk = mTracksSectIndexCache[sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! - for (int itrk = 0; itrk < cacheTrk.size(); itrk++){ - itmp++; - auto& trc = mTracksWork[trkType::TPC][cacheTrk[itrk]].first; - auto& trcAttr = mTracksWork[trkType::TPC][cacheTrk[itrk]].second; - trc.getXYZGlo(globalPos); - printf("Track %d: Global coordinates After propagating to 371 cm: globalPos[0] = %f, globalPos[1] = %f, globalPos[2] = %f -- timestamp = %f +/- %f\n", itrk, globalPos[0], globalPos[1], globalPos[2],trcAttr.getTimeStamp(),trcAttr.getTimeStampError()); - // Printf("The phi angle is %f", TMath::ATan2(globalPos[1], globalPos[0])); - } + timeInfo.setTimeStamp(_tr.getTime0() * mTPCTBinMUS); + timeInfo.setTimeStampError((_tr.getDeltaTBwd() + 5) * mTPCTBinMUS + extraErr); + mSideTPC.push_back(_tr.hasASideClustersOnly() ? 1 : (_tr.hasCSideClustersOnly() ? -1 : 0)); + mExtraTPCFwdTime.push_back((_tr.getDeltaTFwd() + 5) * mTPCTBinMUS + extraErr); + + mTracksWork[trkType::UNCONS].emplace_back(std::make_pair(trc, timeInfo)); + mTPCTracksArrayInp.emplace_back(_tr); + + if (mMCTruthON) { + mTracksLblWork[trkType::UNCONS].emplace_back(mRecoCont->getTPCTrackMCLabel(srcGID)); } - Printf("we have %d tracks",itmp); -*/ + mLTinfos[trkType::UNCONS].emplace_back(intLT0); - return true; + trc.getXYZGlo(globalPos); + + mTracksSectIndexCache[trkType::UNCONS][o2::math_utils::angle2Sector(TMath::ATan2(globalPos[1], globalPos[0]))].push_back(it); + //delete trc; // Check: is this needed? } //______________________________________________ bool MatchTOF::prepareTOFClusters() { + mTOFClustersArrayInp = mRecoCont->getTOFClusters(); + mTOFClusLabels = mRecoCont->getTOFClustersMCLabels(); + mMCTruthON = mTOFClusLabels && mTOFClusLabels->getNElements(); + ///< prepare the tracks that we want to match to TOF // copy the track params, propagate to reference X and build sector tables @@ -411,18 +358,16 @@ bool MatchTOF::prepareTOFClusters() mNumOfClusters = 0; - if (mIsworkflowON) { - int nClusterInCurrentChunk = mTOFClustersArrayInp.size(); - LOG(DEBUG) << "nClusterInCurrentChunk = " << nClusterInCurrentChunk; - mNumOfClusters += nClusterInCurrentChunk; - for (int it = 0; it < nClusterInCurrentChunk; it++) { - const Cluster& clOrig = mTOFClustersArrayInp[it]; - // create working copy of track param - mTOFClusWork.emplace_back(clOrig); - auto& cl = mTOFClusWork.back(); - // cache work track index - mTOFClusSectIndexCache[cl.getSector()].push_back(mTOFClusWork.size() - 1); - } + int nClusterInCurrentChunk = mTOFClustersArrayInp.size(); + LOG(DEBUG) << "nClusterInCurrentChunk = " << nClusterInCurrentChunk; + mNumOfClusters += nClusterInCurrentChunk; + for (int it = 0; it < nClusterInCurrentChunk; it++) { + const Cluster& clOrig = mTOFClustersArrayInp[it]; + // create working copy of track param + mTOFClusWork.emplace_back(clOrig); + auto& cl = mTOFClusWork.back(); + // cache work track index + mTOFClusSectIndexCache[cl.getSector()].push_back(mTOFClusWork.size() - 1); } // sort clusters in each sector according to their time (increasing in time) @@ -448,8 +393,9 @@ bool MatchTOF::prepareTOFClusters() return true; } //______________________________________________ -void MatchTOF::doMatching(int sec, trkType type) +void MatchTOF::doMatching(int sec) { + trkType type = trkType::CONSTR; ///< do the real matching per sector auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! @@ -480,7 +426,7 @@ void MatchTOF::doMatching(int sec, trkType type) int nStripsCrossedInPropagation = 0; // how many strips were hit during the propagation auto& trackWork = mTracksWork[type][cacheTrk[itrk]]; auto& trefTrk = trackWork.first; - auto& intLT = mLTinfos[cacheTrk[itrk]]; + auto& intLT = mLTinfos[type][cacheTrk[itrk]]; // Printf("intLT (before doing anything): length = %f, time (Pion) = %f", intLT.getL(), intLT.getTOF(o2::track::PID::Pion)); float minTrkTime = (trackWork.second.getTimeStamp() - mSigmaTimeCut * trackWork.second.getTimeStampError()) * 1.E6; // minimum time in ps @@ -584,20 +530,6 @@ void MatchTOF::doMatching(int sec, trkType type) nStepsInsideSameStrip[nStripsCrossedInPropagation - 1]++; } } - // LOG(DEBUG) << "while done, we propagated track " << itrk << " in %d strips" << nStripsCrossedInPropagation; - // LOG(INFO) << "while done, we propagated track " << itrk << " in %d strips" << nStripsCrossedInPropagation; - - // uncomment for debug purposes, to check tracks that did not cross any strip - /* - if (nStripsCrossedInPropagation == 0) { - auto labelTPCNoStripsCrossed = mTPCLabels[trkType::ITSTPC]->at(mTracksSectIndexCache[sec][itrk]); - Printf("The current track (index = %d) never crossed a strip", cacheTrk[itrk]); - Printf("TrackID = %d, EventID = %d, SourceID = %d", labelTPCNoStripsCrossed.getTrackID(), labelTPCNoStripsCrossed.getEventID(), labelTPCNoStripsCrossed.getSourceID()); - printf("Global coordinates: pos[0] = %f, pos[1] = %f, pos[2] = %f\n", pos[0], pos[1], pos[2]); - printf("detIdTemp[0] = %d, detIdTemp[1] = %d, detIdTemp[2] = %d, detIdTemp[3] = %d, detIdTemp[4] = %d\n", detIdTemp[0], detIdTemp[1], detIdTemp[2], detIdTemp[3], detIdTemp[4]); - printf("deltaPosTemp[0] = %f, deltaPosTemp[1] = %f, deltaPosTemp[2] = %f\n", deltaPosTemp[0], deltaPosTemp[1], deltaPosTemp[2]); - } - */ for (Int_t imatch = 0; imatch < nStripsCrossedInPropagation; imatch++) { // we take as residual the average of the residuals along the propagation in the same strip @@ -698,10 +630,6 @@ void MatchTOF::doMatching(int sec, trkType type) } } } - if (!foundCluster && mMCTruthON) { - auto labelTPC = mTPCLabels[trkType::ITSTPC][mTracksSectIndexCache[type][sec][itrk]]; - LOG(DEBUG) << "We did not find any TOF cluster for track " << cacheTrk[itrk] << " (label = " << labelTPC << ", pt = " << trefTrk.getPt(); - } } return; } @@ -718,9 +646,8 @@ void MatchTOF::doMatchingForTPC(int sec) double BCgranularity = Geo::BC_TIME_INPS * bc_grouping; ///< do the real matching per sector - - auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! - auto& cacheTrk = mTracksSectIndexCache[trkType::TPC][sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! + auto& cacheTOF = mTOFClusSectIndexCache[sec]; // array of cached TOF cluster indices for this sector; reminder: they are ordered in time! + auto& cacheTrk = mTracksSectIndexCache[trkType::UNCONS][sec]; // array of cached tracks indices for this sector; reminder: they are ordered in time! int nTracks = cacheTrk.size(), nTOFCls = cacheTOF.size(); LOG(INFO) << "Matching sector " << sec << ": number of tracks: " << nTracks << ", number of TOF clusters: " << nTOFCls; if (!nTracks || !nTOFCls) { @@ -745,23 +672,20 @@ void MatchTOF::doMatchingForTPC(int sec) LOG(DEBUG) << "Trying to match %d tracks" << cacheTrk.size(); for (int itrk = 0; itrk < cacheTrk.size(); itrk++) { - auto& trackWork = mTracksWork[trkType::TPC][cacheTrk[itrk]]; + auto& trackWork = mTracksWork[trkType::UNCONS][cacheTrk[itrk]]; auto& trefTrk = trackWork.first; - auto& intLT = mLTinfos[cacheTrk[itrk]]; + auto& intLT = mLTinfos[trkType::UNCONS][cacheTrk[itrk]]; BCcand.clear(); nStripsCrossedInPropagation.clear(); int side = mSideTPC[cacheTrk[itrk]]; - // look at BC candidates for the track itof0 = 0; double minTrkTime = (trackWork.second.getTimeStamp() - trackWork.second.getTimeStampError()) * 1.E6; // minimum time in ps minTrkTime = int(minTrkTime / BCgranularity) * BCgranularity; // align min to a BC double maxTrkTime = (trackWork.second.getTimeStamp() + mExtraTPCFwdTime[cacheTrk[itrk]]) * 1.E6; // maximum time in ps - // printf("trk time %f - %f (max shift +/- %f cm)\n",minTrkTime,maxTrkTime,trackWork.second.getTimeStampError()*vdrift ); - if (mIsCosmics) { for (double tBC = minTrkTime; tBC < maxTrkTime; tBC += BCgranularity) { unsigned long ibc = (unsigned long)(tBC * Geo::BC_TIME_INPS_INV); @@ -773,8 +697,6 @@ void MatchTOF::doMatchingForTPC(int sec) for (auto itof = itof0; itof < nTOFCls; itof++) { auto& trefTOF = mTOFClusWork[cacheTOF[itof]]; - // printf("clus time = %f\n",trefTOF.getTime()); - if (trefTOF.getTime() < minTrkTime) { // this cluster has a time that is too small for the current track, we will get to the next one itof0 = itof + 1; continue; @@ -806,8 +728,6 @@ void MatchTOF::doMatchingForTPC(int sec) } } - // printf("BC = %ld\n",BCcand.size()); - detId.clear(); detId.reserve(BCcand.size()); trkLTInt.clear(); @@ -817,8 +737,6 @@ void MatchTOF::doMatchingForTPC(int sec) nStepsInsideSameStrip.clear(); nStepsInsideSameStrip.reserve(BCcand.size()); - // printf("%d) ts_error = %f -- z_error = %f\n", itrk, trackWork.second.getTimeStampError(), trackWork.second.getTimeStampError() * vdrift); - // Printf("intLT (before doing anything): length = %f, time (Pion) = %f", intLT.getL(), intLT.getTOF(o2::track::PID::Pion)); int istep = 1; // number of steps float step = 1.0; // step size in cm @@ -1016,19 +934,15 @@ void MatchTOF::doMatchingForTPC(int sec) float chi2 = mIsCosmics ? resX : res; // TODO: take into account also the time! if (res < mSpaceTolerance) { // matching ok! - LOG(DEBUG) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[trkType::TPC][indices[0]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; + LOG(DEBUG) << "MATCHING FOUND: We have a match! between track " << mTracksSectIndexCache[trkType::UNCONS][indices[0]][itrk] << " and TOF cluster " << mTOFClusSectIndexCache[indices[0]][itof]; foundCluster = true; // set event indexes (to be checked) evIdx eventIndexTOFCluster(trefTOF.getEntryInTree(), mTOFClusSectIndexCache[indices[0]][itof]); - evGIdx eventIndexTracks(mCurrTracksTreeEntry, {uint32_t(mTracksSectIndexCache[trkType::TPC][indices[0]][itrk]), o2::dataformats::GlobalTrackID::TPC}); - mMatchedTracksPairs.emplace_back(eventIndexTOFCluster, chi2, trkLTInt[ibc][iPropagation], eventIndexTracks, trkType::TPC, resZ / vdrift * side, trefTOF.getZ()); // TODO: check if this is correct! + evGIdx eventIndexTracks(mCurrTracksTreeEntry, {uint32_t(mTracksSectIndexCache[trkType::UNCONS][indices[0]][itrk]), o2::dataformats::GlobalTrackID::TPC}); + mMatchedTracksPairs.emplace_back(eventIndexTOFCluster, chi2, trkLTInt[ibc][iPropagation], eventIndexTracks, trkType::UNCONS, resZ / vdrift * side, trefTOF.getZ()); // TODO: check if this is correct! } } } - if (!foundCluster && mMCTruthON) { - const auto& labelTPC = mTPCLabels[trkType::TPC][mTracksSectIndexCache[trkType::TPC][sec][itrk]]; - LOG(DEBUG) << "We did not find any TOF cluster for track " << cacheTrk[itrk] << " (label = " << labelTPC << ", pt = " << trefTrk.getPt(); - } } } return; @@ -1072,10 +986,10 @@ void MatchTOF::selectBestMatches() // first, we sort according to the chi2 std::sort(mMatchedTracksPairs.begin(), mMatchedTracksPairs.end(), [this](o2::dataformats::MatchInfoTOFReco& a, o2::dataformats::MatchInfoTOFReco& b) { return (a.getChi2() < b.getChi2()); }); int i = 0; + // then we take discard the pairs if their track or cluster was already matched (since they are ordered in chi2, we will take the best matching) for (const o2::dataformats::MatchInfoTOFReco& matchingPair : mMatchedTracksPairs) { int trkType = (int)matchingPair.getTrackType(); - if (mMatchedTracksIndex[trkType][matchingPair.getTrackIndex()] != -1) { // the track was already filled continue; } @@ -1101,30 +1015,19 @@ void MatchTOF::selectBestMatches() // add also calibration infos mCalibInfoTOF.emplace_back(mTOFClusWork[matchingPair.getTOFClIndex()].getMainContributingChannel(), int(mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() * 1E12), // add time stamp - mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() - mLTinfos[matchingPair.getTrackIndex()].getTOF(o2::track::PID::Pion) - t0info, + mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() - mLTinfos[trkType][matchingPair.getTrackIndex()].getTOF(o2::track::PID::Pion) - t0info, mTOFClusWork[matchingPair.getTOFClIndex()].getTot()); if (mMCTruthON) { - const auto& labelsTOF = mTOFClusLabels.getLabels(matchingPair.getTOFClIndex()); - const auto& labelTPC = mTPCLabels[trkType][matchingPair.getTrackIndex()]; - // we want to store positive labels independently of how they are flagged from TPC,ITS people - LOG(DEBUG) << "TPC label" << labelTPC; - bool labelOk = false; // whether we have found or not the same TPC label of the track among the labels of the TOF cluster - - for (int ilabel = 0; ilabel < labelsTOF.size(); ilabel++) { - LOG(DEBUG) << "TOF label " << ilabel << labelsTOF[ilabel]; - if (labelsTOF[ilabel] == labelTPC) { // if we find one TOF cluster label that is the same as the TPC one, we are happy - even if it is not the first one - mOutTOFLabels[trkType].push_back(labelsTOF[ilabel]); - labelOk = true; - break; - } - } - if (!labelOk) { - // we have not found the track label among those associated to the TOF cluster --> fake match! We will associate the label of the main channel, but negative - if (!labelsTOF.size()) { - throw std::runtime_error("TOF label not found since size of label is zero. This should not happen!!!!"); + const auto& labelsTOF = mTOFClusLabels->getLabels(matchingPair.getTOFClIndex()); + auto& labelTrack = mTracksLblWork[trkType][matchingPair.getTrackIndex()]; + // we have not found the track label among those associated to the TOF cluster --> fake match! We will associate the label of the main channel, but negative + bool fake = true; + for (auto& lbl : labelsTOF) { + if (labelTrack == lbl) { // compares src, evID, trID, ignores fake flag. + fake = false; } - mOutTOFLabels[trkType].emplace_back(labelsTOF[0].getTrackID(), labelsTOF[0].getEventID(), labelsTOF[0].getSourceID(), true); } + mOutTOFLabels[trkType].emplace_back(labelsTOF[0].getTrackID(), labelsTOF[0].getEventID(), labelsTOF[0].getSourceID(), fake); } i++; } @@ -1133,7 +1036,7 @@ void MatchTOF::selectBestMatches() void MatchTOF::selectBestMatchesHP() { ///< define the track-TOFcluster pair per sector - float chi2SeparationCut = 1; + float chi2SeparationCut = 2; float chi2S = 3; LOG(INFO) << "Number of pair matched = " << mMatchedTracksPairs.size(); @@ -1179,12 +1082,42 @@ void MatchTOF::selectBestMatchesHP() } // now write final matches skipping disabled ones - for (auto& match : tmpMatch) { - if (match.getChi2() <= 0) { + for (auto& matchingPair : tmpMatch) { + if (matchingPair.getChi2() <= 0) { continue; } - int trkType = (int)match.getTrackType(); - mMatchedTracks[trkType].push_back(match); + int trkType = (int)matchingPair.getTrackType(); + mMatchedTracks[trkType].push_back(matchingPair); + + // get fit info + double t0info = 0; + + if (mFITRecPoints.size() > 0) { + int index = findFITIndex(mTOFClusWork[matchingPair.getTOFClIndex()].getBC()); + + if (index > -1) { + o2::InteractionRecord ir = mFITRecPoints[index].getInteractionRecord(); + t0info = ir.bc2ns() * 1E3; + } + } + + // add also calibration infos + mCalibInfoTOF.emplace_back(mTOFClusWork[matchingPair.getTOFClIndex()].getMainContributingChannel(), + int(mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() * 1E12), // add time stamp + mTOFClusWork[matchingPair.getTOFClIndex()].getTimeRaw() - mLTinfos[trkType][matchingPair.getTrackIndex()].getTOF(o2::track::PID::Pion) - t0info, + mTOFClusWork[matchingPair.getTOFClIndex()].getTot()); + if (mMCTruthON) { + const auto& labelsTOF = mTOFClusLabels->getLabels(matchingPair.getTOFClIndex()); + auto& labelTrack = mTracksLblWork[trkType][matchingPair.getTrackIndex()]; + // we have not found the track label among those associated to the TOF cluster --> fake match! We will associate the label of the main channel, but negative + bool fake = true; + for (auto& lbl : labelsTOF) { + if (labelTrack == lbl) { // compares src, evID, trID, ignores fake flag. + fake = false; + } + } + mOutTOFLabels[trkType].emplace_back(labelsTOF[0].getTrackID(), labelsTOF[0].getEventID(), labelsTOF[0].getSourceID(), fake); + } } } //______________________________________________ @@ -1287,6 +1220,7 @@ void MatchTOF::updateTimeDependentParams() mTPCBin2Z = mTPCTBinMUS * gasParam.DriftV; mBz = o2::base::Propagator::Instance()->getNominalBz(); + mMaxInvPt = abs(mBz) > 0.1 ? 1. / (abs(mBz) * 0.05) : 999.; } //_________________________________________________________ @@ -1348,7 +1282,22 @@ bool MatchTOF::makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCT return true; } - +//_________________________________________________________ +void MatchTOF::splitOutputs() +{ + mMatchedTracksAll[trkType::TPC].clear(); + mMatchedTracksAll[trkType::ITSTPC].clear(); + mMatchedTracksAll[trkType::TPCTRD].clear(); + mMatchedTracksAll[trkType::ITSTPCTRD].clear(); + mOutTOFLabelsAll[trkType::TPC].clear(); + mOutTOFLabelsAll[trkType::ITSTPC].clear(); + mOutTOFLabelsAll[trkType::TPCTRD].clear(); + mOutTOFLabelsAll[trkType::ITSTPCTRD].clear(); + + // copy unconstrained to tpc + + // split constrained to the three cases +} //_________________________________________________________ void MatchTOF::checkRefitter() { diff --git a/Detectors/GlobalTrackingWorkflow/README.md b/Detectors/GlobalTrackingWorkflow/README.md index cb7f7b70de840..4add05b9a97db 100644 --- a/Detectors/GlobalTrackingWorkflow/README.md +++ b/Detectors/GlobalTrackingWorkflow/README.md @@ -22,7 +22,7 @@ o2-tpc-reco-workflow --tpc-digit-reader '--infile tpcdigits.root' --input-type o2-its-reco-workflow --trackerCA --tracking-mode cosmics --shm-segment-size 10000000000 --run | tee recITS.log o2-tpcits-match-workflow --tpc-track-reader tpctracks.root --tpc-native-cluster-reader "--infile tpc-native-clusters.root" --shm-segment-size 10000000000 --run | tee recTPCITS.log o2-tof-reco-workflow --shm-segment-size 10000000000 --run | tee recTOF.log -o2-tof-matcher-tpc --shm-segment-size 10000000000 --run | tee recTOF_TPC.log +o2-tof-matcher-workflow --shm-segment-size 10000000000 --run | tee recTOF_Tracks.log o2-cosmics-match-workflow --shm-segment-size 10000000000 --run | tee cosmics.log ``` diff --git a/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h b/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h index 10171c735ea1e..2ef95e15d41f6 100644 --- a/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h +++ b/Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h @@ -25,7 +25,7 @@ namespace globaltracking { /// create a processor spec -framework::DataProcessorSpec getTOFMatcherSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool useFIT); +framework::DataProcessorSpec getTOFMatcherSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool useFIT, bool tpcRefit, bool highpur); } // namespace globaltracking } // namespace o2 diff --git a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx index 794e1a996d63e..9e184e50b37b1 100644 --- a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx @@ -39,12 +39,6 @@ #include "GlobalTracking/MatchTOF.h" #include "GlobalTrackingWorkflow/TOFMatcherSpec.h" -// from FIT -#include "DataFormatsFT0/RecPoints.h" - -#include // for make_shared, make_unique, unique_ptr -#include - using namespace o2::framework; // using MCLabelsTr = gsl::span; // using GTrackID = o2::dataformats::GlobalTrackID; @@ -62,7 +56,7 @@ namespace globaltracking class TOFMatcherSpec : public Task { public: - TOFMatcherSpec(std::shared_ptr dr, bool useMC, bool useFIT) : mDataRequest(dr), mUseMC(useMC), mUseFIT(useFIT) {} + TOFMatcherSpec(std::shared_ptr dr, bool useMC, bool useFIT, bool tpcRefit, bool highpur) : mDataRequest(dr), mUseMC(useMC), mUseFIT(useFIT), mDoTPCRefit(tpcRefit), mSetHighPurity(highpur) {} ~TOFMatcherSpec() override = default; void init(InitContext& ic) final; void run(ProcessingContext& pc) final; @@ -72,6 +66,8 @@ class TOFMatcherSpec : public Task std::shared_ptr mDataRequest; bool mUseMC = true; bool mUseFIT = false; + bool mDoTPCRefit = false; + bool mSetHighPurity = false; MatchTOF mMatcher; ///< Cluster finder TStopwatch mTimer; }; @@ -95,6 +91,9 @@ void TOFMatcherSpec::init(InitContext& ic) } else { LOG(INFO) << "Material LUT " << matLUTFile << " file is absent, only TGeo can be used"; } + if (mSetHighPurity) { + mMatcher.setHighPurity(); + } } void TOFMatcherSpec::run(ProcessingContext& pc) @@ -103,7 +102,6 @@ void TOFMatcherSpec::run(ProcessingContext& pc) RecoContainer recoData; recoData.collectData(pc, *mDataRequest.get()); - const auto clustersRO = pc.inputs().get>("tofcluster"); LOG(INFO) << "isTrackSourceLoaded: TPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPC); LOG(INFO) << "isTrackSourceLoaded: ITSTPC -> " << recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPC); @@ -115,49 +113,24 @@ void TOFMatcherSpec::run(ProcessingContext& pc) bool isTPCTRDused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::TPCTRD); bool isITSTPCTRDused = recoData.isTrackSourceLoaded(o2::dataformats::GlobalTrackID::Source::ITSTPCTRD); - if (mUseFIT) { - // Note: the particular variable will go out of scope, but the span is passed by copy to the - // worker and the underlying memory is valid throughout the whole computation - auto recPoints = std::move(pc.inputs().get>("fitrecpoints")); - mMatcher.setFITRecPoints(recPoints); - LOG(INFO) << "TOF Reco Workflow pulled " << recPoints.size() << " FIT RecPoints"; - } - - o2::dataformats::MCTruthContainer toflab; - gsl::span tpclab; - gsl::span itstpclab; - gsl::span tpctrdlab; - gsl::span itstpctrdlab; - if (mUseMC) { - const auto toflabel = pc.inputs().get*>("tofclusterlabel"); - toflab = std::move(*toflabel); - } + mMatcher.setFIT(mUseFIT); - mMatcher.setTOFClusterArray(clustersRO, toflab); - - if (isTPCused) { - const auto tracksTPC = recoData.getTPCTracks(); - if (mUseMC) { - tpclab = recoData.getTPCTracksMCLabels(); - } - mMatcher.setTPCTrackArray(tracksTPC, tpclab); - } - - if (isITSTPCused) { - const auto tracksITSTPC = recoData.getTPCITSTracks(); - if (mUseMC) { - itstpclab = recoData.getTPCITSTracksMCLabels(); - } - mMatcher.setITSTPCTrackArray(tracksITSTPC, itstpclab); - } - - mMatcher.run(); + mMatcher.run(recoData); if (isTPCused) { pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); if (mUseMC) { pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); } + + auto nmatch = mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC).size(); + if (mDoTPCRefit) { + LOG(INFO) << "Refitting " << nmatch << " matched TPC tracks with TOF time info"; + } else { + LOG(INFO) << "Shifting Z for " << nmatch << " matched TPC tracks according to TOF time info"; + } + auto& tracksTPCTOF = pc.outputs().make>(OutputRef{"tpctofTracks"}, nmatch); + mMatcher.makeConstrainedTPCTracks(tracksTPCTOF); } if (isITSTPCused) { @@ -178,23 +151,17 @@ void TOFMatcherSpec::endOfStream(EndOfStreamContext& ec) mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); } -DataProcessorSpec getTOFMatcherSpec(GTrackID::mask_t src, bool useMC, bool useFIT) +DataProcessorSpec getTOFMatcherSpec(GTrackID::mask_t src, bool useMC, bool useFIT, bool tpcRefit, bool highpur) { auto dataRequest = std::make_shared(); dataRequest->requestTracks(src, useMC); - - std::vector inputs = dataRequest->inputs; - std::vector outputs; - - inputs.emplace_back("tofcluster", o2::header::gDataOriginTOF, "CLUSTERS", 0, Lifetime::Timeframe); - if (useMC) { - inputs.emplace_back("tofclusterlabel", o2::header::gDataOriginTOF, "CLUSTERSMCTR", 0, Lifetime::Timeframe); - } - + dataRequest->requestClusters(GTrackID::getSourceMask(GTrackID::TOF), useMC); if (useFIT) { - inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); + dataRequest->requestClusters(GTrackID::getSourceMask(GTrackID::FT0), false); } + std::vector outputs; + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe); outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe); outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_2", 0, Lifetime::Timeframe); @@ -207,11 +174,13 @@ DataProcessorSpec getTOFMatcherSpec(GTrackID::mask_t src, bool useMC, bool useFI } outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); + outputs.emplace_back(OutputLabel{"tpctofTracks"}, o2::header::gDataOriginTOF, "TOFTRACKS_TPC", 0, Lifetime::Timeframe); + return DataProcessorSpec{ "tof-matcher", - inputs, + dataRequest->inputs, outputs, - AlgorithmSpec{adaptFromTask(dataRequest, useMC, useFIT)}, + AlgorithmSpec{adaptFromTask(dataRequest, useMC, useFIT, tpcRefit, highpur)}, Options{ {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}}}}; } diff --git a/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx b/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx index f2eb4e7d068ed..b11a21e2f6263 100644 --- a/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/tof-matcher-workflow.cxx @@ -42,6 +42,7 @@ void customize(std::vector& workflowOptions) {"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of sources to use: allowed TPC,ITS-TPC,TPC-TRD,ITS-TPC-TRD (all)"}}, {"use-fit", o2::framework::VariantType::Bool, false, {"enable access to fit info for calibration"}}, {"use-ccdb", o2::framework::VariantType::Bool, false, {"enable access to ccdb tof calibration objects"}}, + {"high-purity", o2::framework::VariantType::Bool, false, {"enable high purity matching cuts"}}, {"output-type", o2::framework::VariantType::String, "matching-info,calib-info", {"matching-info, calib-info"}}, {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}}; @@ -70,7 +71,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) auto disableRootOut = configcontext.options().get("disable-root-output"); auto useFIT = configcontext.options().get("use-fit"); auto useCCDB = configcontext.options().get("use-ccdb"); - bool writeTOFTPC = false; + auto highpur = configcontext.options().get("high-purity"); bool writematching = 0; bool writecalib = 0; @@ -94,26 +95,31 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) LOG(INFO) << "TOF use-fit = " << useFIT; LOG(INFO) << "TOF disable-root-input = " << disableRootIn; LOG(INFO) << "TOF disable-root-output = " << disableRootOut; + LOG(INFO) << "TOF matching enable high-purity = " << highpur; GID::mask_t src = alowedSources & GID::getSourcesMask(configcontext.options().get("track-sources")); - GID::mask_t dummy; + GID::mask_t mcmaskcl; GID::mask_t nonemask = GID::getSourcesMask(GID::NONE); + GID::mask_t clustermask = GID::getSourcesMask("TOF"); + if (useFIT) { + clustermask |= GID::getSourceMask(GID::FT0); + } - o2::globaltracking::InputHelper::addInputSpecs(configcontext, specs, nonemask, nonemask, src, useMC, dummy); // only tracks needed - - if (!disableRootIn) { // input data loaded from root files - LOG(INFO) << "Insert TOF Cluster Reader"; - specs.emplace_back(o2::tof::getClusterReaderSpec(useMC)); + if (useMC) { + mcmaskcl |= GID::getSourceMask(GID::TOF); } - specs.emplace_back(o2::globaltracking::getTOFMatcherSpec(src, useMC, useFIT)); + o2::globaltracking::InputHelper::addInputSpecs(configcontext, specs, clustermask, nonemask, src, useMC, mcmaskcl); + + specs.emplace_back(o2::globaltracking::getTOFMatcherSpec(src, useMC, useFIT, false, highpur)); // doTPCrefit not yet supported (need to load TPC clusters?) if (!disableRootOut) { if (writematching) { - specs.emplace_back(o2::tof::getTOFMatchedWriterSpec(useMC, "o2match_toftpc.root", writeTOFTPC)); + specs.emplace_back(o2::tof::getTOFMatchedWriterSpec(useMC, "o2match_tof_tpc.root", 1)); + specs.emplace_back(o2::tof::getTOFMatchedWriterSpec(useMC, "o2match_tof_itstpc.root", 0)); } if (writecalib) { - specs.emplace_back(o2::tof::getTOFCalibWriterSpec("o2calib_toftpc.root", writeTOFTPC)); + specs.emplace_back(o2::tof::getTOFCalibWriterSpec("o2calib_tof.root", 0)); } } diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/CMakeLists.txt b/Detectors/GlobalTrackingWorkflow/tofworkflow/CMakeLists.txt index 5de38a868f929..41c505506d76f 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/CMakeLists.txt +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/CMakeLists.txt @@ -9,30 +9,14 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2_add_library(TOFWorkflow - SOURCES src/RecoWorkflowSpec.cxx - src/RecoWorkflowWithTPCSpec.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::TOFBase O2::DataFormatsTOF O2::TOFReconstruction - O2::GlobalTracking O2::GlobalTrackingWorkflowReaders O2::TOFWorkflowIO O2::TOFWorkflowUtils - O2::TOFCalibration O2::DataFormatsFT0 O2::FT0Reconstruction O2::FT0Workflow - O2::TPCWorkflow O2::ITSWorkflow) - o2_add_executable(reco-workflow COMPONENT_NAME tof SOURCES src/tof-reco-workflow.cxx - PUBLIC_LINK_LIBRARIES O2::TOFWorkflow) - -o2_add_executable(matcher-global - COMPONENT_NAME tof - SOURCES src/tof-matcher-global.cxx - PUBLIC_LINK_LIBRARIES O2::TOFWorkflow) - -o2_add_executable(matcher-tpc - COMPONENT_NAME tof - SOURCES src/tof-matcher-tpc.cxx - PUBLIC_LINK_LIBRARIES O2::TOFWorkflow) + PUBLIC_LINK_LIBRARIES O2::Framework O2::TOFBase O2::DataFormatsTOF O2::TOFReconstruction + O2::TOFWorkflowIO O2::TOFWorkflowUtils + O2::TOFCalibration) o2_add_executable(calib-reader COMPONENT_NAME tof SOURCES src/tof-calibinfo-reader.cxx - PUBLIC_LINK_LIBRARIES O2::TOFWorkflow) + PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsTOF O2::TOFBase O2::TOFWorkflowIO O2::TOFWorkflowUtils O2::TOFCalibration) diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h b/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h deleted file mode 100644 index 712a5a8d5c9ff..0000000000000 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowSpec.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#ifndef TOF_RECOWORKFLOW_H_ -#define TOF_RECOWORKFLOW_H_ - -#include "Framework/DataProcessorSpec.h" -#include "ReconstructionDataFormats/MatchInfoTOFReco.h" - -namespace o2 -{ -namespace tof -{ - -o2::framework::DataProcessorSpec getTOFRecoWorkflowSpec(bool useMC, bool useFIT); - -} // end namespace tof -} // end namespace o2 - -#endif /* TOF_RECOWORKFLOW_H_ */ diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h b/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h deleted file mode 100644 index 609ffd05fac0b..0000000000000 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/include/TOFWorkflow/RecoWorkflowWithTPCSpec.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#ifndef TOF_RECOWORKFLOWWITHTPC_H_ -#define TOF_RECOWORKFLOWWITHTPC_H_ - -#include "Framework/DataProcessorSpec.h" -#include "ReconstructionDataFormats/MatchInfoTOFReco.h" - -namespace o2 -{ -namespace tof -{ - -o2::framework::DataProcessorSpec getTOFRecoWorkflowWithTPCSpec(bool useMC, bool useFIT, bool doTPCRefit, bool iscosmics); - -} // end namespace tof -} // end namespace o2 - -#endif /* TOF_RECOWORKFLOWWITHTPC_H_ */ diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx deleted file mode 100644 index 44606a0596873..0000000000000 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#include "TOFWorkflow/RecoWorkflowSpec.h" -#include "Framework/ConfigParamRegistry.h" -#include "Framework/ControlService.h" -#include "Framework/DataProcessorSpec.h" -#include "Framework/DataRefUtils.h" -#include "Framework/Lifetime.h" -#include "Framework/Task.h" -#include "Framework/SerializationMethods.h" -#include "Headers/DataHeader.h" -#include "DataFormatsTOF/Cluster.h" -#include "GlobalTracking/MatchTOF.h" -#include "ReconstructionDataFormats/TrackTPCITS.h" -#include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsCommonDataFormats/NameConf.h" -#include -#include "TStopwatch.h" - -// from FIT -#include "DataFormatsFT0/RecPoints.h" - -#include // for make_shared, make_unique, unique_ptr -#include - -using namespace o2::framework; - -namespace o2 -{ -namespace tof -{ - -// use the tasking system of DPL -// just need to implement 2 special methods init + run (there is no need to inherit from anything) -class TOFDPLRecoWorkflowTask -{ - using evIdx = o2::dataformats::EvIndex; - using MatchOutputType = std::vector; - - bool mUseMC = true; - bool mUseFIT = false; - - public: - explicit TOFDPLRecoWorkflowTask(bool useMC, bool useFIT) : mUseMC(useMC), mUseFIT(useFIT) {} - - void init(framework::InitContext& ic) - { - // nothing special to be set up - o2::base::GeometryManager::loadGeometry(); - o2::base::Propagator::initFieldFromGRP(); - std::string matLUTPath = ic.options().get("material-lut-path"); - std::string matLUTFile = o2::base::NameConf::getMatLUTFileName(matLUTPath); - if (o2::utils::Str::pathExists(matLUTFile)) { - auto* lut = o2::base::MatLayerCylSet::loadFromFile(matLUTFile); - o2::base::Propagator::Instance()->setMatLUT(lut); - LOG(INFO) << "Loaded material LUT from " << matLUTFile; - } else { - LOG(INFO) << "Material LUT " << matLUTFile << " file is absent, only TGeo can be used"; - } - - mTimer.Stop(); - mTimer.Reset(); - } - - void run(framework::ProcessingContext& pc) - { - mTimer.Start(false); - //>>>---------- attach input data --------------->>> - const auto clustersRO = pc.inputs().get>("tofcluster"); - const auto tracksRO = pc.inputs().get>("globaltrack"); - - if (mUseFIT) { - // Note: the particular variable will go out of scope, but the span is passed by copy to the - // worker and the underlying memory is valid throughout the whole computation - auto recPoints = std::move(pc.inputs().get>("fitrecpoints")); - mMatcher.setFITRecPoints(recPoints); - LOG(INFO) << "TOF Reco Workflow pulled " << recPoints.size() << " FIT RecPoints"; - } - - // we do a copy of the input but we are looking for a way to avoid it (current problem in conversion form unique_ptr to *) - - gsl::span itstpclab; - o2::dataformats::MCTruthContainer toflab; - if (mUseMC) { - const auto toflabel = pc.inputs().get*>("tofclusterlabel"); - itstpclab = pc.inputs().get>("itstpclabel"); - toflab = std::move(*toflabel); - } - - mMatcher.setTOFClusterArray(clustersRO, toflab); - mMatcher.setITSTPCTrackArray(tracksRO, itstpclab); - mMatcher.run(); - - // in run_match_tof aggiugnere esplicitamente la chiamata a fill del tree (nella classe MatchTOF) e il metodo per leggere i vettori di output - - //... - // LOG(INFO) << "TOF CLUSTERER : TRANSFORMED " << digits->size() - // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; - - // send matching-info - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); - if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); - } - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); - mTimer.Stop(); - } - - void endOfStream(EndOfStreamContext& ec) - { - LOGF(INFO, "TOF Matching total timing: Cpu: %.3e Real: %.3e s in %d slots", - mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); - } - - private: - o2::globaltracking::MatchTOF mMatcher; ///< Cluster finder - TStopwatch mTimer; -}; - -o2::framework::DataProcessorSpec getTOFRecoWorkflowSpec(bool useMC, bool useFIT) -{ - std::vector inputs; - std::vector outputs; - inputs.emplace_back("tofcluster", o2::header::gDataOriginTOF, "CLUSTERS", 0, Lifetime::Timeframe); - inputs.emplace_back("globaltrack", "GLO", "TPCITS", 0, Lifetime::Timeframe); - if (useMC) { - inputs.emplace_back("tofclusterlabel", o2::header::gDataOriginTOF, "CLUSTERSMCTR", 0, Lifetime::Timeframe); - inputs.emplace_back("itstpclabel", "GLO", "TPCITS_MC", 0, Lifetime::Timeframe); - } - - if (useFIT) { - inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); - } - - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe); - if (useMC) { - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe); - } - outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); - - return DataProcessorSpec{ - "TOFRecoWorkflow", - inputs, - outputs, - AlgorithmSpec{adaptFromTask(useMC, useFIT)}, - Options{ - {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}}}}; -} - -} // end namespace tof -} // end namespace o2 diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx deleted file mode 100644 index 7283129807ea9..0000000000000 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowWithTPCSpec.cxx +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#include "TOFWorkflow/RecoWorkflowWithTPCSpec.h" -#include "DataFormatsTPC/WorkflowHelper.h" -#include "Framework/ConfigParamRegistry.h" -#include "Framework/ControlService.h" -#include "Framework/DataProcessorSpec.h" -#include "Framework/DataRefUtils.h" -#include "Framework/Lifetime.h" -#include "Framework/Task.h" -#include "Framework/SerializationMethods.h" -#include "Headers/DataHeader.h" -#include "DataFormatsTOF/Cluster.h" -#include "GlobalTracking/MatchTOF.h" -#include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/Propagator.h" -#include "DetectorsCommonDataFormats/NameConf.h" -#include -#include "TStopwatch.h" - -// from FIT -#include "DataFormatsFT0/RecPoints.h" - -#include // for make_shared, make_unique, unique_ptr -#include - -using namespace o2::framework; - -namespace o2 -{ -namespace tof -{ - -// use the tasking system of DPL -// just need to implement 2 special methods init + run (there is no need to inherit from anything) -class TOFDPLRecoWorkflowWithTPCTask -{ - using evIdx = o2::dataformats::EvIndex; - using MatchOutputType = std::vector; - - bool mUseMC = true; - bool mUseFIT = false; - bool mDoTPCRefit = false; - bool mIsCosmics = false; - - public: - explicit TOFDPLRecoWorkflowWithTPCTask(bool useMC, bool useFIT, bool doTPCRefit, bool iscosmics) : mUseMC(useMC), mUseFIT(useFIT), mDoTPCRefit(doTPCRefit), mIsCosmics(iscosmics) {} - - void init(framework::InitContext& ic) - { - // nothing special to be set up - o2::base::GeometryManager::loadGeometry(); - o2::base::Propagator::initFieldFromGRP(); - std::string matLUTPath = ic.options().get("material-lut-path"); - std::string matLUTFile = o2::base::NameConf::getMatLUTFileName(matLUTPath); - if (o2::utils::Str::pathExists(matLUTFile)) { - auto* lut = o2::base::MatLayerCylSet::loadFromFile(matLUTFile); - o2::base::Propagator::Instance()->setMatLUT(lut); - LOG(INFO) << "Loaded material LUT from " << matLUTFile; - } else { - LOG(INFO) << "Material LUT " << matLUTFile << " file is absent, only TGeo can be used"; - } - - mTimer.Stop(); - mTimer.Reset(); - } - - void run(framework::ProcessingContext& pc) - { - if (mIsCosmics) { - mMatcher.setCosmics(); - } - mMatcher.print(); - - mTimer.Start(false); - //>>>---------- attach input data --------------->>> - const auto clustersRO = pc.inputs().get>("tofcluster"); - const auto tracksRO = pc.inputs().get>("tracks"); - - if (mUseFIT) { - // Note: the particular variable will go out of scope, but the span is passed by copy to the - // worker and the underlying memory is valid throughout the whole computation - auto recPoints = std::move(pc.inputs().get>("fitrecpoints")); - mMatcher.setFITRecPoints(recPoints); - LOG(INFO) << "TOF Reco WorkflowWithTPC pulled " << recPoints.size() << " FIT RecPoints"; - } - - // we do a copy of the input but we are looking for a way to avoid it (current problem in conversion form unique_ptr to *) - - o2::dataformats::MCTruthContainer toflab; - gsl::span tpclab; - if (mUseMC) { - const auto toflabel = pc.inputs().get*>("tofclusterlabel"); - tpclab = pc.inputs().get>("tpctracklabel"); - toflab = std::move(*toflabel); - } - - std::decay_t inputsTPCclusters; - if (mDoTPCRefit) { - mMatcher.setTPCTrackClusIdxInp(pc.inputs().get>("trackTPCClRefs")); - mMatcher.setTPCClustersSharingMap(pc.inputs().get>("clusTPCshmap")); - inputsTPCclusters = o2::tpc::getWorkflowTPCInput(pc); - mMatcher.setTPCClustersInp(&inputsTPCclusters->clusterIndex); - } - - mMatcher.setTOFClusterArray(clustersRO, toflab); - mMatcher.setTPCTrackArray(tracksRO, tpclab); - mMatcher.run(); - - auto nmatch = mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC).size(); - if (mDoTPCRefit) { - LOG(INFO) << "Refitting " << nmatch << " matched TPC tracks with TOF time info"; - } else { - LOG(INFO) << "Shifting Z for " << nmatch << " matched TPC tracks according to TOF time info"; - } - auto& tracksTPCTOF = pc.outputs().make>(OutputRef{"tpctofTracks"}, nmatch); - mMatcher.makeConstrainedTPCTracks(tracksTPCTOF); - - // in run_match_tof aggiugnere esplicitamente la chiamata a fill del tree (nella classe MatchTOF) e il metodo per leggere i vettori di output - - //... - // LOG(INFO) << "TOF CLUSTERER : TRANSFORMED " << digits->size() - // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; - - // send matching-info - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); - if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); - } - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); - mTimer.Stop(); - } - - void endOfStream(EndOfStreamContext& ec) - { - LOGF(INFO, "TOF Matching total timing: Cpu: %.3e Real: %.3e s in %d slots", - mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); - } - - private: - o2::globaltracking::MatchTOF mMatcher; ///< Cluster finder - TStopwatch mTimer; -}; - -o2::framework::DataProcessorSpec getTOFRecoWorkflowWithTPCSpec(bool useMC, bool useFIT, bool doTPCRefit, bool iscosmics) -{ - std::vector inputs; - std::vector outputs; - inputs.emplace_back("tofcluster", o2::header::gDataOriginTOF, "CLUSTERS", 0, Lifetime::Timeframe); - inputs.emplace_back("tracks", o2::header::gDataOriginTPC, "TRACKS", 0, Lifetime::Timeframe); - if (doTPCRefit) { - inputs.emplace_back("trackTPCClRefs", o2::header::gDataOriginTPC, "CLUSREFS", 0, Lifetime::Timeframe); - inputs.emplace_back("clusTPC", ConcreteDataTypeMatcher{o2::header::gDataOriginTPC, "CLUSTERNATIVE"}, Lifetime::Timeframe); - inputs.emplace_back("clusTPCshmap", o2::header::gDataOriginTPC, "CLSHAREDMAP", 0, Lifetime::Timeframe); - } - if (useMC) { - inputs.emplace_back("tofclusterlabel", o2::header::gDataOriginTOF, "CLUSTERSMCTR", 0, Lifetime::Timeframe); - inputs.emplace_back("tpctracklabel", o2::header::gDataOriginTPC, "TRACKSMCLBL", 0, Lifetime::Timeframe); - } - - if (useFIT) { - inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); - } - - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe); - outputs.emplace_back(OutputLabel{"tpctofTracks"}, o2::header::gDataOriginTOF, "TOFTRACKS_TPC", 0, Lifetime::Timeframe); - - if (useMC) { - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe); - } - outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); - - return DataProcessorSpec{ - "TOFRecoWorkflowWithTPC", - inputs, - outputs, - AlgorithmSpec{adaptFromTask(useMC, useFIT, doTPCRefit, iscosmics)}, - Options{ - {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}}}}; -} - -} // end namespace tof -} // end namespace o2 diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-calibinfo-reader.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-calibinfo-reader.cxx index 59d91d63ae8db..c6c3ef42096c8 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-calibinfo-reader.cxx +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-calibinfo-reader.cxx @@ -15,12 +15,9 @@ /// @brief Basic DPL workflow for TOF reconstruction starting from digits #include "DetectorsBase/Propagator.h" -#include "GlobalTrackingWorkflowReaders/TrackTPCITSReaderSpec.h" #include "TOFWorkflowIO/CalibInfoReaderSpec.h" #include "Framework/WorkflowSpec.h" #include "Framework/ConfigParamSpec.h" -#include "TOFWorkflow/RecoWorkflowSpec.h" -#include "Algorithm/RangeTokenizer.h" #include "FairLogger.h" #include "CommonUtils/ConfigurableParam.h" #include "DetectorsCommonDataFormats/NameConf.h" diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-global.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-global.cxx deleted file mode 100644 index b0a0bbe7c6656..0000000000000 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-global.cxx +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/// @file tof-reco-workflow.cxx -/// @author Francesco Noferini -/// @since 2019-05-22 -/// @brief Basic DPL workflow for TOF reconstruction starting from digits - -#include "DetectorsBase/Propagator.h" -#include "GlobalTrackingWorkflowReaders/TrackTPCITSReaderSpec.h" -#include "TOFWorkflowIO/ClusterReaderSpec.h" -#include "TOFWorkflowIO/TOFMatchedWriterSpec.h" -#include "TOFWorkflowIO/TOFCalibWriterSpec.h" -#include "Framework/WorkflowSpec.h" -#include "Framework/ConfigParamSpec.h" -#include "TOFWorkflow/RecoWorkflowSpec.h" -#include "Algorithm/RangeTokenizer.h" -#include "FairLogger.h" -#include "CommonUtils/ConfigurableParam.h" -#include "DetectorsCommonDataFormats/NameConf.h" -#include "DetectorsRaw/HBFUtilsInitializer.h" - -// FIT -#include "FT0Workflow/RecPointReaderSpec.h" - -#include -#include -#include - -// add workflow options, note that customization needs to be declared before -// including Framework/runDataProcessing -void customize(std::vector& workflowOptions) -{ - std::vector options{ - {"input-type", o2::framework::VariantType::String, "clusters,tracks", {"clusters, tracks, fit"}}, - {"output-type", o2::framework::VariantType::String, "matching-info,calib-info", {"matching-info, calib-info"}}, - {"disable-mc", o2::framework::VariantType::Bool, false, {"disable sending of MC information, TBI"}}, - {"tof-sectors", o2::framework::VariantType::String, "0-17", {"TOF sector range, e.g. 5-7,8,9 ,TBI"}}, - {"tof-lanes", o2::framework::VariantType::Int, 1, {"number of parallel lanes up to the matcher, TBI"}}, - {"use-ccdb", o2::framework::VariantType::Bool, false, {"enable access to ccdb tof calibration objects"}}, - {"use-fit", o2::framework::VariantType::Bool, false, {"enable access to fit info for calibration"}}, - {"input-desc", o2::framework::VariantType::String, "CRAWDATA", {"Input specs description string"}}, - {"disable-root-input", o2::framework::VariantType::Bool, false, {"disable root-files input readers"}}, - {"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writers"}}, - {"configKeyValues", o2::framework::VariantType::String, "", {"Semicolon separated key=value strings ..."}}}; - - o2::raw::HBFUtilsInitializer::addConfigOption(options); - - std::swap(workflowOptions, options); -} - -#include "Framework/runDataProcessing.h" // the main driver - -using namespace o2::framework; - -/// The workflow executable for the stand alone TOF reconstruction workflow -/// The basic workflow for TOF reconstruction is defined in RecoWorkflow.cxx -/// and contains the following default processors -/// - digit reader -/// - clusterer -/// - cluster raw decoder -/// - track-TOF matcher -/// -/// The default workflow can be customized by specifying input and output types -/// e.g. digits, raw, clusters. -/// -/// MC info is processed by default, disabled by using command line option `--disable-mc` -/// -/// This function hooks up the the workflow specifications into the DPL driver. -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec specs; - o2::conf::ConfigurableParam::updateFromString(cfgc.options().get("configKeyValues")); - - // the lane configuration defines the subspecification ids to be distributed among the lanes. - auto nLanes = cfgc.options().get("tof-lanes"); - auto inputType = cfgc.options().get("input-type"); - auto outputType = cfgc.options().get("output-type"); - - bool writematching = 0; - bool writecalib = 0; - - if (outputType.rfind("matching-info") < outputType.size()) { - writematching = 1; - } - if (outputType.rfind("calib-info") < outputType.size()) { - writecalib = 1; - } - - bool clusterinput = 0; - bool trackinput = 0; - bool fitinput = 0; - - if (inputType.rfind("clusters") < inputType.size()) { - clusterinput = 1; - } - if (inputType.rfind("tracks") < inputType.size()) { - trackinput = 1; - } - auto useMC = !cfgc.options().get("disable-mc"); - auto useCCDB = cfgc.options().get("use-ccdb"); - auto useFIT = cfgc.options().get("use-fit"); - bool disableRootInput = cfgc.options().get("disable-root-input"); - bool disableRootOutput = cfgc.options().get("disable-root-output"); - - if (inputType.rfind("fit") < inputType.size()) { - fitinput = 1; - useFIT = 1; - } - - LOG(INFO) << "TOF RECO WORKFLOW configuration"; - LOG(INFO) << "TOF input = " << cfgc.options().get("input-type"); - LOG(INFO) << "TOF output = " << cfgc.options().get("output-type"); - LOG(INFO) << "TOF sectors = " << cfgc.options().get("tof-sectors"); - LOG(INFO) << "TOF disable-mc = " << cfgc.options().get("disable-mc"); - LOG(INFO) << "TOF lanes = " << cfgc.options().get("tof-lanes"); - LOG(INFO) << "TOF use-ccdb = " << cfgc.options().get("use-ccdb"); - LOG(INFO) << "TOF use-fit = " << cfgc.options().get("use-fit"); - LOG(INFO) << "TOF disable-root-input = " << disableRootInput; - LOG(INFO) << "TOF disable-root-output = " << disableRootOutput; - - if (!disableRootInput) { // input data loaded from root files - if (clusterinput) { - LOG(INFO) << "Insert TOF Cluster Reader"; - specs.emplace_back(o2::tof::getClusterReaderSpec(useMC)); - } - if (trackinput) { - LOG(INFO) << "Insert ITS-TPC Track Reader"; - specs.emplace_back(o2::globaltracking::getTrackTPCITSReaderSpec(useMC)); - } - - if (fitinput) { - LOG(INFO) << "Insert FIT RecPoint Reader"; - specs.emplace_back(o2::ft0::getRecPointReaderSpec(useMC)); - } - } - LOG(INFO) << "Insert TOF Matching"; - specs.emplace_back(o2::tof::getTOFRecoWorkflowSpec(useMC, useFIT)); - - if (!disableRootOutput) { - if (writematching) { - LOG(INFO) << "Insert TOF Matched Info Writer"; - specs.emplace_back(o2::tof::getTOFMatchedWriterSpec(useMC)); - } - if (writecalib) { - LOG(INFO) << "Insert TOF Calib Info Writer"; - specs.emplace_back(o2::tof::getTOFCalibWriterSpec()); - } - } - LOG(INFO) << "Number of active devices = " << specs.size(); - - // configure dpl timer to inject correct firstTFOrbit: start from the 1st orbit of TF containing 1st sampled orbit - o2::raw::HBFUtilsInitializer hbfIni(cfgc, specs); - - return std::move(specs); -} diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-tpc.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-tpc.cxx deleted file mode 100644 index c703d274a4851..0000000000000 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-matcher-tpc.cxx +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/// @file tof-reco-workflow.cxx -/// @author Francesco Noferini -/// @since 2019-05-22 -/// @brief Basic DPL workflow for TOF reconstruction starting from digits - -#include "DetectorsBase/Propagator.h" -#include "TOFWorkflowIO/ClusterReaderSpec.h" -#include "TOFWorkflowIO/TOFMatchedWriterSpec.h" -#include "TOFWorkflowIO/TOFCalibWriterSpec.h" -#include "Framework/WorkflowSpec.h" -#include "Framework/ConfigParamSpec.h" -#include "TOFWorkflow/RecoWorkflowWithTPCSpec.h" -#include "Algorithm/RangeTokenizer.h" -#include "FairLogger.h" -#include "CommonUtils/ConfigurableParam.h" -#include "DetectorsCommonDataFormats/NameConf.h" -#include "TPCReaderWorkflow/TrackReaderSpec.h" -#include "TPCReaderWorkflow/ClusterReaderSpec.h" -#include "TPCWorkflow/ClusterSharingMapSpec.h" -#include "DetectorsRaw/HBFUtilsInitializer.h" - -// GRP -#include "DataFormatsParameters/GRPObject.h" - -// FIT -#include "FT0Workflow/RecPointReaderSpec.h" - -#include -#include -#include - -// add workflow options, note that customization needs to be declared before -// including Framework/runDataProcessing -void customize(std::vector& workflowOptions) -{ - std::vector options{ - {"output-type", o2::framework::VariantType::String, "matching-info", {"matching-info, calib-info"}}, - {"disable-mc", o2::framework::VariantType::Bool, false, {"disable sending of MC information, TBI"}}, - {"tof-sectors", o2::framework::VariantType::String, "0-17", {"TOF sector range, e.g. 5-7,8,9 ,TBI"}}, - {"tof-lanes", o2::framework::VariantType::Int, 1, {"number of parallel lanes up to the matcher, TBI"}}, - {"use-ccdb", o2::framework::VariantType::Bool, false, {"enable access to ccdb tof calibration objects"}}, - {"use-fit", o2::framework::VariantType::Bool, false, {"enable access to fit info for calibration"}}, - {"input-desc", o2::framework::VariantType::String, "CRAWDATA", {"Input specs description string"}}, - {"tpc-refit", o2::framework::VariantType::Bool, false, {"refit matched TPC tracks"}}, - {"disable-root-input", o2::framework::VariantType::Bool, false, {"disable root-files input readers"}}, - {"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writers"}}, - {"cosmics", o2::framework::VariantType::Bool, false, {"reco for cosmics"}}, - {"configKeyValues", o2::framework::VariantType::String, "", {"Semicolon separated key=value strings ..."}}}; - - o2::raw::HBFUtilsInitializer::addConfigOption(options); - - std::swap(workflowOptions, options); -} - -#include "Framework/runDataProcessing.h" // the main driver - -using namespace o2::framework; - -/// The workflow executable for the stand alone TOF reconstruction workflow -/// The basic workflow for TOF reconstruction is defined in RecoWorkflow.cxx -/// and contains the following default processors -/// - digit reader -/// - clusterer -/// - cluster raw decoder -/// - track-TOF matcher -/// -/// The default workflow can be customized by specifying input and output types -/// e.g. digits, raw, clusters. -/// -/// MC info is processed by default, disabled by using command line option `--disable-mc` -/// -/// This function hooks up the the workflow specifications into the DPL driver. -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec specs; - o2::conf::ConfigurableParam::updateFromString(cfgc.options().get("configKeyValues")); - - // the lane configuration defines the subspecification ids to be distributed among the lanes. - auto nLanes = cfgc.options().get("tof-lanes"); - auto outputType = cfgc.options().get("output-type"); - - bool writematching = 0; - bool writecalib = 0; - - if (outputType.rfind("matching-info") < outputType.size()) { - writematching = 1; - } - if (outputType.rfind("calib-info") < outputType.size()) { - writecalib = 1; - } - - auto useMC = !cfgc.options().get("disable-mc"); - auto useCCDB = cfgc.options().get("use-ccdb"); - auto useFIT = cfgc.options().get("use-fit"); - auto doTPCRefit = cfgc.options().get("tpc-refit"); - bool disableRootInput = cfgc.options().get("disable-root-input"); - bool disableRootOutput = cfgc.options().get("disable-root-output"); - auto isCosmics = cfgc.options().get("cosmics"); - - LOG(INFO) << "TOF RECO WORKFLOW configuration"; - LOG(INFO) << "TOF output = " << cfgc.options().get("output-type"); - LOG(INFO) << "TOF sectors = " << cfgc.options().get("tof-sectors"); - LOG(INFO) << "TOF disable-mc = " << cfgc.options().get("disable-mc"); - LOG(INFO) << "TOF lanes = " << cfgc.options().get("tof-lanes"); - LOG(INFO) << "TOF use-ccdb = " << cfgc.options().get("use-ccdb"); - LOG(INFO) << "TOF use-fit = " << cfgc.options().get("use-fit"); - LOG(INFO) << "TOF tpc-refit = " << cfgc.options().get("tpc-refit"); - LOG(INFO) << "TOF disable-root-input = " << disableRootInput; - LOG(INFO) << "TOF disable-root-output = " << disableRootOutput; - - // useMC = false; - // LOG(INFO) << "TOF disable MC forced"; - // writecalib = false; - // LOG(INFO) << "TOF CalibInfo disabled (forced)"; - - if (!disableRootInput) { // input data loaded from root files - LOG(INFO) << "Insert TOF Cluster Reader"; - specs.emplace_back(o2::tof::getClusterReaderSpec(useMC)); - - LOG(INFO) << "Insert TPC Track Reader"; - specs.emplace_back(o2::tpc::getTPCTrackReaderSpec(useMC)); - - if (doTPCRefit) { - LOG(INFO) << "Insert TPC Cluster Reader"; - specs.emplace_back(o2::tpc::getClusterReaderSpec(false)); - specs.emplace_back(o2::tpc::getClusterSharingMapSpec()); - } - - if (useFIT) { - LOG(INFO) << "Insert FIT RecPoint Reader"; - specs.emplace_back(o2::ft0::getRecPointReaderSpec(useMC)); - } - } - - LOG(INFO) << "Insert TOF Matching"; - specs.emplace_back(o2::tof::getTOFRecoWorkflowWithTPCSpec(useMC, useFIT, doTPCRefit, isCosmics)); - - if (!disableRootOutput) { - if (writematching) { - LOG(INFO) << "Insert TOF Matched Info Writer"; - specs.emplace_back(o2::tof::getTOFMatchedWriterSpec(useMC, "o2match_toftpc.root", true)); - } - if (writecalib) { - LOG(INFO) << "Insert TOF Calib Info Writer"; - specs.emplace_back(o2::tof::getTOFCalibWriterSpec("o2calib_toftpc.root", true)); - } - } - - LOG(INFO) << "Number of active devices = " << specs.size(); - - // configure dpl timer to inject correct firstTFOrbit: start from the 1st orbit of TF containing 1st sampled orbit - o2::raw::HBFUtilsInitializer hbfIni(cfgc, specs); - - return std::move(specs); -} diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-reco-workflow.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-reco-workflow.cxx index 77b234b7d2cfc..a70432dd8b9d7 100644 --- a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-reco-workflow.cxx +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/tof-reco-workflow.cxx @@ -15,30 +15,22 @@ /// @brief Basic DPL workflow for TOF reconstruction starting from digits #include "DetectorsBase/Propagator.h" -#include "GlobalTrackingWorkflowReaders/TrackTPCITSReaderSpec.h" #include "TOFWorkflowIO/DigitReaderSpec.h" #include "TOFWorkflowIO/TOFDigitWriterSpec.h" #include "TOFWorkflowIO/ClusterReaderSpec.h" #include "TOFWorkflowUtils/TOFClusterizerSpec.h" #include "TOFWorkflowIO/TOFClusterWriterSpec.h" -#include "TOFWorkflowIO/TOFMatchedWriterSpec.h" -#include "TOFWorkflowIO/TOFCalibWriterSpec.h" #include "TOFWorkflowIO/TOFRawWriterSpec.h" #include "TOFWorkflowUtils/CompressedDecodingTask.h" #include "TOFWorkflowUtils/EntropyEncoderSpec.h" #include "TOFWorkflowUtils/EntropyDecoderSpec.h" #include "Framework/WorkflowSpec.h" #include "Framework/ConfigParamSpec.h" -#include "TOFWorkflow/RecoWorkflowSpec.h" -#include "Algorithm/RangeTokenizer.h" #include "FairLogger.h" #include "CommonUtils/ConfigurableParam.h" #include "DetectorsCommonDataFormats/NameConf.h" #include "DetectorsRaw/HBFUtilsInitializer.h" -// FIT -#include "FT0Workflow/RecPointReaderSpec.h" - #include #include #include @@ -49,12 +41,11 @@ void customize(std::vector& workflowOptions) { std::vector options{ {"input-type", o2::framework::VariantType::String, "digits", {"digits, raw, clusters"}}, - {"output-type", o2::framework::VariantType::String, "clusters,matching-info,calib-info", {"digits, clusters, matching-info, calib-info, raw, ctf"}}, + {"output-type", o2::framework::VariantType::String, "clusters", {"digits, clusters, raw, ctf"}}, {"disable-mc", o2::framework::VariantType::Bool, false, {"disable sending of MC information, TBI"}}, {"tof-sectors", o2::framework::VariantType::String, "0-17", {"TOF sector range, e.g. 5-7,8,9 ,TBI"}}, {"tof-lanes", o2::framework::VariantType::Int, 1, {"number of parallel lanes up to the matcher, TBI"}}, {"use-ccdb", o2::framework::VariantType::Bool, false, {"enable access to ccdb tof calibration objects"}}, - {"use-fit", o2::framework::VariantType::Bool, false, {"enable access to fit info for calibration"}}, {"input-desc", o2::framework::VariantType::String, "CRAWDATA", {"Input specs description string"}}, {"disable-root-input", o2::framework::VariantType::Bool, false, {"disable root-files input readers"}}, {"disable-root-output", o2::framework::VariantType::Bool, false, {"disable root-files output writers"}}, @@ -98,8 +89,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) auto outputType = cfgc.options().get("output-type"); bool writecluster = 0; - bool writematching = 0; - bool writecalib = 0; bool writedigit = 0; bool writeraw = 0; bool writectf = 0; @@ -108,12 +97,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) if (outputType.rfind("clusters") < outputType.size()) { writecluster = 1; } - if (outputType.rfind("matching-info") < outputType.size()) { - writematching = 1; - } - if (outputType.rfind("calib-info") < outputType.size()) { - writecalib = 1; - } if (outputType.rfind("digits") < outputType.size()) { writedigit = 1; } @@ -142,7 +125,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) auto useMC = !cfgc.options().get("disable-mc"); auto useCCDB = cfgc.options().get("use-ccdb"); - auto useFIT = cfgc.options().get("use-fit"); bool disableRootInput = cfgc.options().get("disable-root-input") || rawinput; bool disableRootOutput = cfgc.options().get("disable-root-output"); bool conetmode = cfgc.options().get("conet-mode"); @@ -157,7 +139,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) LOG(INFO) << "TOF disable-mc = " << cfgc.options().get("disable-mc"); LOG(INFO) << "TOF lanes = " << cfgc.options().get("tof-lanes"); LOG(INFO) << "TOF use-ccdb = " << cfgc.options().get("use-ccdb"); - LOG(INFO) << "TOF use-fit = " << cfgc.options().get("use-fit"); LOG(INFO) << "TOF disable-root-input = " << disableRootInput; LOG(INFO) << "TOF disable-root-output = " << disableRootOutput; LOG(INFO) << "TOF conet-mode = " << conetmode; @@ -199,27 +180,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) } } - if (useFIT && !disableRootInput) { - specs.emplace_back(o2::ft0::getRecPointReaderSpec(useMC)); - } - - if (writematching || writecalib) { - if (!disableRootInput) { - LOG(INFO) << "Insert ITS-TPC Track Reader"; - specs.emplace_back(o2::globaltracking::getTrackTPCITSReaderSpec(useMC)); - } - LOG(INFO) << "Insert TOF Matching"; - specs.emplace_back(o2::tof::getTOFRecoWorkflowSpec(useMC, useFIT)); - - if (writematching && !disableRootOutput) { - LOG(INFO) << "Insert TOF Matched Info Writer"; - specs.emplace_back(o2::tof::getTOFMatchedWriterSpec(useMC)); - } - if (writecalib && !disableRootOutput) { - LOG(INFO) << "Insert TOF Calib Info Writer"; - specs.emplace_back(o2::tof::getTOFCalibWriterSpec()); - } - } if (writectf) { LOG(INFO) << "Insert TOF CTF encoder"; specs.emplace_back(o2::tof::getEntropyEncoderSpec()); diff --git a/Detectors/TOF/base/src/Geo.cxx b/Detectors/TOF/base/src/Geo.cxx index 823da6217ab9c..9be33f4a76a7c 100644 --- a/Detectors/TOF/base/src/Geo.cxx +++ b/Detectors/TOF/base/src/Geo.cxx @@ -40,7 +40,7 @@ void Geo::Init() LOG(INFO) << "tof::Geo: Initialization of TOF rotation parameters"; if (!gGeoManager) { - LOG(WARNING) << " no TGeo! Loading it"; + LOG(INFO) << " no TGeo! Loading it"; o2::base::GeometryManager::loadGeometry(); } diff --git a/macro/CMakeLists.txt b/macro/CMakeLists.txt index f97caed8db21f..97ffe710215e0 100644 --- a/macro/CMakeLists.txt +++ b/macro/CMakeLists.txt @@ -47,7 +47,6 @@ install(FILES CheckDigits_mft.C run_cmp2digit_tof.C compareTOFDigits.C compareTOFClusters.C - run_match_tof.C run_primary_vertexer_ITS.C run_rawdecoding_its.C run_rawdecoding_mft.C @@ -297,13 +296,6 @@ o2_add_test_root_macro(compareTOFClusters.C PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF LABELS tof) -# FIXME: move to subsystem dir -o2_add_test_root_macro(run_match_tof.C - PUBLIC_LINK_LIBRARIES O2::Field O2::DataFormatsParameters - O2::DetectorsBase - O2::GlobalTracking - LABELS tof COMPILE_ONLY) - # FIXME: move to subsystem dir o2_add_test_root_macro(run_primary_vertexer_ITS.C PUBLIC_LINK_LIBRARIES O2::DataFormatsITSMFT diff --git a/macro/checkTOFMatching.C b/macro/checkTOFMatching.C index 90acd4ebf48e1..f5b1deffe6378 100644 --- a/macro/checkTOFMatching.C +++ b/macro/checkTOFMatching.C @@ -24,7 +24,7 @@ void checkTOFMatching(bool batchMode = true) // macro to check the matching TOF-ITSTPC tracks // getting TOF info - TFile* fmatchTOF = new TFile("o2match_tof.root"); + TFile* fmatchTOF = new TFile("o2match_tof_itstpc.root"); TTree* matchTOF = (TTree*)fmatchTOF->Get("matchTOF"); std::vector* TOFMatchInfo; TOFMatchInfo = new std::vector; diff --git a/macro/run_match_tof.C b/macro/run_match_tof.C deleted file mode 100644 index dcb7fe5f4eb4d..0000000000000 --- a/macro/run_match_tof.C +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#if !defined(__CLING__) || defined(__ROOTCLING__) -#define MS_GSL_V3 -#include -#include -#include -#include -#include -#include - -#include "Field/MagneticField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/Propagator.h" - -#include "GlobalTracking/MatchTOF.h" -#endif - -#define _ALLOW_DEBUG_TREES_ // to allow debug and control tree output - -void run_match_tof(std::string path = "./", std::string outputfile = "o2match_tof.root", - std::string outputfileCalib = "o2calib_tof.root", - std::string inputTracksTPCITS = "o2match_itstpc.root", - std::string inputTracksTPC = "tpctracks.root", - std::string inputClustersTOF = "tofclusters.root", - std::string inputGRP = "o2sim_grp.root") -{ - - o2::globaltracking::MatchTOF matching; - - if (path.back() != '/') { - path += '/'; - } - - //>>>---------- attach input data --------------->>> - TChain tracks("matchTPCITS"); - tracks.AddFile((path + inputTracksTPCITS).data()); - matching.setInputTreeTracks(&tracks); - - TChain tpcTracks("events"); - tpcTracks.AddFile((path + inputTracksTPC).data()); - matching.setInputTreeTPCTracks(&tpcTracks); - matching.setTPCTrackBranchName("TPCTracks"); - - TChain tofClusters("o2sim"); - tofClusters.AddFile((path + inputClustersTOF).data()); - matching.setInputTreeTOFClusters(&tofClusters); - - //<<<---------- attach input data ---------------<<< - - // create/attach output tree - TFile outFile((path + outputfile).data(), "recreate"); - TTree outTree("matchTOF", "Matched TOF-tracks"); - matching.setOutputTree(&outTree); - TFile outFileCalib((path + outputfileCalib).data(), "recreate"); - TTree outTreeCalib("calibTOF", "Calib TOF infos"); - matching.setOutputTreeCalib(&outTreeCalib); - -#ifdef _ALLOW_DEBUG_TREES_ - matching.setDebugTreeFileName(path + matching.getDebugTreeFileName()); - matching.setDebugFlag(o2::globaltracking::MatchTOF::MatchTreeAll); -#endif - - //-------- init geometry and field --------// - o2::base::GeometryManager::loadGeometry(path); - o2::base::Propagator::initFieldFromGRP(path + inputGRP); - - matching.init(); - - matching.run(); - - outFile.cd(); - outTree.Write(); - outFile.Close(); - outFileCalib.cd(); - outTreeCalib.Write(); - outFileCalib.Close(); -} diff --git a/prodtests/full-system-test/dpl-workflow.sh b/prodtests/full-system-test/dpl-workflow.sh index 2e45eb77f2206..35fa4ea7d100d 100755 --- a/prodtests/full-system-test/dpl-workflow.sh +++ b/prodtests/full-system-test/dpl-workflow.sh @@ -36,7 +36,7 @@ GPU_OUTPUT=tracks,clusters GPU_CONFIG= GPU_CONFIG_KEY= TOF_INPUT=raw -TOF_OUTPUT=clusters,matching-info +TOF_OUTPUT=clusters ITS_CONFIG= ITS_CONFIG_KEY= TRD_CONFIG= @@ -128,7 +128,7 @@ WORKFLOW+="o2-trd-global-tracking $ARGS_ALL --disable-root-input --disable-root- # Workflows disabled in sync mode if [ $SYNCMODE == 0 ]; then - WORKFLOW+="o2-tof-matcher-tpc $ARGS_ALL --disable-root-input --disable-root-output $DISABLE_MC | " + WORKFLOW+="o2-tof-matcher-workflow $ARGS_ALL --disable-root-input --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-mid-reco-workflow $ARGS_ALL --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-mft-reco-workflow $ARGS_ALL --clusters-from-upstream $DISABLE_MC --disable-root-output | " WORKFLOW+="o2-primary-vertexing-workflow $ARGS_ALL $DISABLE_MC --disable-root-input --disable-root-output --validate-with-ft0 | " diff --git a/prodtests/sim_challenge.sh b/prodtests/sim_challenge.sh index 68449e925e908..13849eb779fc4 100755 --- a/prodtests/sim_challenge.sh +++ b/prodtests/sim_challenge.sh @@ -156,21 +156,21 @@ if [ "$doreco" == "1" ]; then taskwrapper trdMatch.log o2-trd-global-tracking $gloOpt echo "Return status of itstpcMatch: $?" - echo "Running ITSTPC-TOF macthing flow" + echo "Running TOF reco flow to produce clusters" #needs results of TOF digitized data and results of o2-tpcits-match-workflow - taskwrapper tofMatch.log o2-tof-reco-workflow $gloOpt + taskwrapper tofReco.log o2-tof-reco-workflow $gloOpt echo "Return status of its-tpc-tof match: $?" - echo "Running TPC-TOF macthing flow" - #needs results of TOF clusters data from o2-tof-reco-workflow and results of o2-tpc-reco-workflow - taskwrapper tofMatchTPC.log o2-tof-matcher-tpc $gloOpt - echo "Return status of o2-tof-matcher-tpc: $?" - echo "Running primary vertex finding flow" #needs results of TPC-ITS matching and FIT workflows taskwrapper pvfinder.log o2-primary-vertexing-workflow $gloOpt echo "Return status of primary vertexing: $?" + echo "Running Track-TOF macthing flow" + #needs results of TOF clusters data from o2-tof-reco-workflow and results of o2-tpc-reco-workflow and ITS-TPC matching + taskwrapper tofMatchTracks.log o2-tof-matcher-workflow $gloOpt + echo "Return status of o2-tof-matcher-workflow: $?" + echo "Running TOF matching QA" #need results of ITSTPC-TOF matching (+ TOF clusters and ITS-TPC tracks) taskwrapper tofmatch_qa.log root -b -q -l $O2_ROOT/share/macro/checkTOFMatching.C From e7fb9c92fbaf76dcc11735f1c95f39fd50c2ffc1 Mon Sep 17 00:00:00 2001 From: Ivana Hrivnacova Date: Wed, 23 Jun 2021 13:52:31 +0200 Subject: [PATCH 4/7] =?UTF-8?q?Updated=20copyright=20headers=20in=20all=20?= =?UTF-8?q?files=20with=20new=20text=20=E2=80=A6=20(#6430)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated copyright headers in all files with new text agreed in the O2 project --- DataFormats/Detectors/ZDC/src/RecEventAux.cxx | 9 +- .../tofworkflow/src/RecoWorkflowSpec.cxx | 159 ++++++++++++++++++ .../ZDCWorkflow/ZDCRecoWriterDPLSpec.h | 9 +- 3 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx diff --git a/DataFormats/Detectors/ZDC/src/RecEventAux.cxx b/DataFormats/Detectors/ZDC/src/RecEventAux.cxx index 7e774ff4ec6fe..85cf2751852e2 100644 --- a/DataFormats/Detectors/ZDC/src/RecEventAux.cxx +++ b/DataFormats/Detectors/ZDC/src/RecEventAux.cxx @@ -1,8 +1,9 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. // -// See http://alice-o2.web.cern.ch/license for full licensing information. +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". // // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization diff --git a/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx new file mode 100644 index 0000000000000..da519603b76a7 --- /dev/null +++ b/Detectors/GlobalTrackingWorkflow/tofworkflow/src/RecoWorkflowSpec.cxx @@ -0,0 +1,159 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "TOFWorkflow/RecoWorkflowSpec.h" +#include "Framework/ConfigParamRegistry.h" +#include "Framework/ControlService.h" +#include "Framework/DataProcessorSpec.h" +#include "Framework/DataRefUtils.h" +#include "Framework/Lifetime.h" +#include "Framework/Task.h" +#include "Framework/SerializationMethods.h" +#include "Headers/DataHeader.h" +#include "DataFormatsTOF/Cluster.h" +#include "GlobalTracking/MatchTOF.h" +#include "ReconstructionDataFormats/TrackTPCITS.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsCommonDataFormats/NameConf.h" +#include +#include "TStopwatch.h" + +// from FIT +#include "DataFormatsFT0/RecPoints.h" + +#include // for make_shared, make_unique, unique_ptr +#include + +using namespace o2::framework; + +namespace o2 +{ +namespace tof +{ + +// use the tasking system of DPL +// just need to implement 2 special methods init + run (there is no need to inherit from anything) +class TOFDPLRecoWorkflowTask +{ + using evIdx = o2::dataformats::EvIndex; + using MatchOutputType = std::vector; + + bool mUseMC = true; + bool mUseFIT = false; + + public: + explicit TOFDPLRecoWorkflowTask(bool useMC, bool useFIT) : mUseMC(useMC), mUseFIT(useFIT) {} + + void init(framework::InitContext& ic) + { + // nothing special to be set up + o2::base::GeometryManager::loadGeometry(); + o2::base::Propagator::initFieldFromGRP(); + std::string matLUTPath = ic.options().get("material-lut-path"); + std::string matLUTFile = o2::base::NameConf::getMatLUTFileName(matLUTPath); + if (o2::utils::Str::pathExists(matLUTFile)) { + auto* lut = o2::base::MatLayerCylSet::loadFromFile(matLUTFile); + o2::base::Propagator::Instance()->setMatLUT(lut); + LOG(INFO) << "Loaded material LUT from " << matLUTFile; + } else { + LOG(INFO) << "Material LUT " << matLUTFile << " file is absent, only TGeo can be used"; + } + + mTimer.Stop(); + mTimer.Reset(); + } + + void run(framework::ProcessingContext& pc) + { + mTimer.Start(false); + //>>>---------- attach input data --------------->>> + const auto clustersRO = pc.inputs().get>("tofcluster"); + const auto tracksRO = pc.inputs().get>("globaltrack"); + + if (mUseFIT) { + // Note: the particular variable will go out of scope, but the span is passed by copy to the + // worker and the underlying memory is valid throughout the whole computation + auto recPoints = std::move(pc.inputs().get>("fitrecpoints")); + mMatcher.setFITRecPoints(recPoints); + LOG(INFO) << "TOF Reco Workflow pulled " << recPoints.size() << " FIT RecPoints"; + } + + // we do a copy of the input but we are looking for a way to avoid it (current problem in conversion form unique_ptr to *) + + gsl::span itstpclab; + o2::dataformats::MCTruthContainer toflab; + if (mUseMC) { + const auto toflabel = pc.inputs().get*>("tofclusterlabel"); + itstpclab = pc.inputs().get>("itstpclabel"); + toflab = std::move(*toflabel); + } + + mMatcher.run(tracksRO, clustersRO, toflab, itstpclab); + + // in run_match_tof aggiugnere esplicitamente la chiamata a fill del tree (nella classe MatchTOF) e il metodo per leggere i vettori di output + + //... + // LOG(INFO) << "TOF CLUSTERER : TRANSFORMED " << digits->size() + // << " DIGITS TO " << mClustersArray.size() << " CLUSTERS"; + + // send matching-info + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector()); + if (mUseMC) { + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector()); + } + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe}, mMatcher.getCalibVector()); + mTimer.Stop(); + } + + void endOfStream(EndOfStreamContext& ec) + { + LOGF(INFO, "TOF Matching total timing: Cpu: %.3e Real: %.3e s in %d slots", + mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); + } + + private: + o2::globaltracking::MatchTOF mMatcher; ///< Cluster finder + TStopwatch mTimer; +}; + +o2::framework::DataProcessorSpec getTOFRecoWorkflowSpec(bool useMC, bool useFIT) +{ + std::vector inputs; + std::vector outputs; + inputs.emplace_back("tofcluster", o2::header::gDataOriginTOF, "CLUSTERS", 0, Lifetime::Timeframe); + inputs.emplace_back("globaltrack", "GLO", "TPCITS", 0, Lifetime::Timeframe); + if (useMC) { + inputs.emplace_back("tofclusterlabel", o2::header::gDataOriginTOF, "CLUSTERSMCTR", 0, Lifetime::Timeframe); + inputs.emplace_back("itstpclabel", "GLO", "TPCITS_MC", 0, Lifetime::Timeframe); + } + + if (useFIT) { + inputs.emplace_back("fitrecpoints", o2::header::gDataOriginFT0, "RECPOINTS", 0, Lifetime::Timeframe); + } + + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe); + if (useMC) { + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHTOF", 0, Lifetime::Timeframe); + } + outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBDATA", 0, Lifetime::Timeframe); + + return DataProcessorSpec{ + "TOFRecoWorkflow", + inputs, + outputs, + AlgorithmSpec{adaptFromTask(useMC, useFIT)}, + Options{ + {"material-lut-path", VariantType::String, "", {"Path of the material LUT file"}}}}; +} + +} // end namespace tof +} // end namespace o2 diff --git a/Detectors/ZDC/workflow/include/ZDCWorkflow/ZDCRecoWriterDPLSpec.h b/Detectors/ZDC/workflow/include/ZDCWorkflow/ZDCRecoWriterDPLSpec.h index 89f5748b40b21..a09083f69373b 100644 --- a/Detectors/ZDC/workflow/include/ZDCWorkflow/ZDCRecoWriterDPLSpec.h +++ b/Detectors/ZDC/workflow/include/ZDCWorkflow/ZDCRecoWriterDPLSpec.h @@ -1,8 +1,9 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. // -// See http://alice-o2.web.cern.ch/license for full licensing information. +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". // // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization From 5d052780349c574b8d6a7739084baf75069f1217 Mon Sep 17 00:00:00 2001 From: Francesco Noferini Date: Thu, 24 Jun 2021 14:44:34 +0200 Subject: [PATCH 5/7] fix copyrights new TOF classes --- .../include/ReconstructionDataFormats/MatchInfoTOFReco.h | 9 +++++---- DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h index fda17c3501747..35ab341e46ee0 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/MatchInfoTOFReco.h @@ -1,8 +1,9 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. // -// See http://alice-o2.web.cern.ch/license for full licensing information. +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". // // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization diff --git a/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx b/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx index 8801575abbfe2..b8de445df5234 100644 --- a/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx +++ b/DataFormats/Reconstruction/src/MatchInfoTOFReco.cxx @@ -1,8 +1,9 @@ -// Copyright CERN and copyright holders of ALICE O2. This software is -// distributed under the terms of the GNU General Public License v3 (GPL -// Version 3), copied verbatim in the file "COPYING". +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. // -// See http://alice-o2.web.cern.ch/license for full licensing information. +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". // // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization From 5d9e0f08a8c81c7674d084a8655136ac5b8ebcfa Mon Sep 17 00:00:00 2001 From: shahoian Date: Thu, 24 Jun 2021 16:31:53 +0200 Subject: [PATCH 6/7] Fixes --- .../src/TOFMatcherSpec.cxx | 16 ++++++++-------- .../TOF/workflowIO/src/TOFMatchedReaderSpec.cxx | 2 +- .../TOF/workflowIO/src/TOFMatchedWriterSpec.cxx | 4 ++-- prodtests/full-system-test/dpl-workflow.sh | 4 ++++ prodtests/sim_challenge.sh | 17 +++++++++++------ 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx index 9e184e50b37b1..8f67c904566a3 100644 --- a/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx @@ -118,9 +118,9 @@ void TOFMatcherSpec::run(ProcessingContext& pc) mMatcher.run(recoData); if (isTPCused) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFOS_TPC", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFOS_TPC", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC)); } auto nmatch = mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC).size(); @@ -134,9 +134,9 @@ void TOFMatcherSpec::run(ProcessingContext& pc) } if (isITSTPCused) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe}, mMatcher.getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); if (mUseMC) { - pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); + pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "MCMATCHINFOS", 0, Lifetime::Timeframe}, mMatcher.getMatchedTOFLabelsVector(o2::dataformats::MatchInfoTOFReco::TrackType::ITSTPC)); } } @@ -162,13 +162,13 @@ DataProcessorSpec getTOFMatcherSpec(GTrackID::mask_t src, bool useMC, bool useFI std::vector outputs; - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_0", 0, Lifetime::Timeframe); - outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_1", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFOS_TPC", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFOS", 0, Lifetime::Timeframe); outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_2", 0, Lifetime::Timeframe); outputs.emplace_back(o2::header::gDataOriginTOF, "MATCHINFO_3", 0, Lifetime::Timeframe); if (useMC) { - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_0", 0, Lifetime::Timeframe); - outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_1", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFOS_TPC", 0, Lifetime::Timeframe); + outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFOS", 0, Lifetime::Timeframe); outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_2", 0, Lifetime::Timeframe); outputs.emplace_back(o2::header::gDataOriginTOF, "MCMATCHINFO_3", 0, Lifetime::Timeframe); } diff --git a/Detectors/TOF/workflowIO/src/TOFMatchedReaderSpec.cxx b/Detectors/TOF/workflowIO/src/TOFMatchedReaderSpec.cxx index 06b76f470eb87..07426540392a9 100644 --- a/Detectors/TOF/workflowIO/src/TOFMatchedReaderSpec.cxx +++ b/Detectors/TOF/workflowIO/src/TOFMatchedReaderSpec.cxx @@ -104,7 +104,7 @@ DataProcessorSpec getTOFMatchedReaderSpec(bool useMC, bool tpcmatch, bool readTr outputs, AlgorithmSpec{adaptFromTask(useMC, tpcmatch, readTracks)}, Options{ - {"tof-matched-infile", VariantType::String, tpcmatch ? "o2match_toftpc.root" : "o2match_tof.root", {"Name of the input file"}}, + {"tof-matched-infile", VariantType::String, tpcmatch ? "o2match_tof_tpc.root" : "o2match_tof_itstpc.root", {"Name of the input file"}}, {"input-dir", VariantType::String, "none", {"Input directory"}}, {"treename", VariantType::String, "matchTOF", {"Name of top-level TTree"}}, }}; diff --git a/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx b/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx index bed6689f8a060..ca488913b32ae 100644 --- a/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx +++ b/Detectors/TOF/workflowIO/src/TOFMatchedWriterSpec.cxx @@ -47,8 +47,8 @@ DataProcessorSpec getTOFMatchedWriterSpec(bool useMC, const char* outdef, bool w auto loggerTofLabels = [](LabelsType const& labeltof) { LOG(INFO) << "TOF LABELS GOT " << labeltof.size() << " LABELS "; }; - o2::header::DataDescription ddMatchInfo{"MATCHINFO_1"}, ddMatchInfo_tpc{"MATCHINFO_0"}, - ddMCMatchTOF{"MCMATCHINFO_1"}, ddMCMatchTOF_tpc{"MCMATCHINFO_0"}; + o2::header::DataDescription ddMatchInfo{"MATCHINFOS"}, ddMatchInfo_tpc{"MATCHINFOS_TPC"}, + ddMCMatchTOF{"MCMATCHINFOS"}, ddMCMatchTOF_tpc{"MCMATCHINFOS_TPC"}; return MakeRootTreeWriterSpec(writeTOFTPC ? "TOFMatchedWriter_TPC" : "TOFMatchedWriter", outdef, diff --git a/prodtests/full-system-test/dpl-workflow.sh b/prodtests/full-system-test/dpl-workflow.sh index 35fa4ea7d100d..07a6a1d4a2efd 100755 --- a/prodtests/full-system-test/dpl-workflow.sh +++ b/prodtests/full-system-test/dpl-workflow.sh @@ -128,6 +128,8 @@ WORKFLOW+="o2-trd-global-tracking $ARGS_ALL --disable-root-input --disable-root- # Workflows disabled in sync mode if [ $SYNCMODE == 0 ]; then + WORKFLOW+="o2-tof-matcher-workflow $ARGS_ALL --disable-root-input --disable-root-output $DISABLE_MC --track-sources \"TPC,ITS-TPC\" | " + WORKFLOW+="o2-tof-matcher-workflow $ARGS_ALL --disable-root-input --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-mid-reco-workflow $ARGS_ALL --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-mft-reco-workflow $ARGS_ALL --clusters-from-upstream $DISABLE_MC --disable-root-output | " @@ -139,6 +141,8 @@ fi # Workflows disabled in async mode if [ $CTFINPUT == 0 ]; then + WORKFLOW+="o2-tof-matcher-workflow $ARGS_ALL --disable-root-input --disable-root-output $DISABLE_MC --track-sources \"ITS-TPC\" | " + WORKFLOW+="o2-phos-reco-workflow $ARGS_ALL --input-type raw --output-type cells --disable-root-input --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-cpv-reco-workflow $ARGS_ALL --input-type raw --output-type clusters --disable-root-input --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-emcal-reco-workflow $ARGS_ALL --input-type raw --output-type cells --disable-root-output $DISABLE_MC --pipeline EMCALRawToCellConverterSpec:$N_EMC | " diff --git a/prodtests/sim_challenge.sh b/prodtests/sim_challenge.sh index 13849eb779fc4..4e0c9755514cc 100755 --- a/prodtests/sim_challenge.sh +++ b/prodtests/sim_challenge.sh @@ -159,12 +159,7 @@ if [ "$doreco" == "1" ]; then echo "Running TOF reco flow to produce clusters" #needs results of TOF digitized data and results of o2-tpcits-match-workflow taskwrapper tofReco.log o2-tof-reco-workflow $gloOpt - echo "Return status of its-tpc-tof match: $?" - - echo "Running primary vertex finding flow" - #needs results of TPC-ITS matching and FIT workflows - taskwrapper pvfinder.log o2-primary-vertexing-workflow $gloOpt - echo "Return status of primary vertexing: $?" + echo "Return status of tof cluster reco : $?" echo "Running Track-TOF macthing flow" #needs results of TOF clusters data from o2-tof-reco-workflow and results of o2-tpc-reco-workflow and ITS-TPC matching @@ -176,6 +171,16 @@ if [ "$doreco" == "1" ]; then taskwrapper tofmatch_qa.log root -b -q -l $O2_ROOT/share/macro/checkTOFMatching.C echo "Return status of TOF matching qa: $?" + echo "Running primary vertex finding flow" + #needs results of TPC-ITS matching and FIT workflows + taskwrapper pvfinder.log o2-primary-vertexing-workflow $gloOpt + echo "Return status of primary vertexing: $?" + + echo "Running secondary vertex finding flow" + #needs results of all trackers + P.Vertexer + taskwrapper svfinder.log o2-secondary-vertexing-workflow $gloOpt + echo "Return status of secondary vertexing: $?" + echo "Running ZDC reconstruction" #need ZDC digits taskwrapper zdcreco.log o2-zdc-digits-reco $gloOpt From d5caa83e16e466a91a85ec4119772ccad3dfe0c4 Mon Sep 17 00:00:00 2001 From: Francesco Noferini Date: Fri, 25 Jun 2021 11:49:21 +0200 Subject: [PATCH 7/7] fix for checks --- prodtests/full-system-test/dpl-workflow.sh | 2 +- prodtests/sim_challenge.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/prodtests/full-system-test/dpl-workflow.sh b/prodtests/full-system-test/dpl-workflow.sh index 07a6a1d4a2efd..3891165ea951d 100755 --- a/prodtests/full-system-test/dpl-workflow.sh +++ b/prodtests/full-system-test/dpl-workflow.sh @@ -142,7 +142,7 @@ fi # Workflows disabled in async mode if [ $CTFINPUT == 0 ]; then WORKFLOW+="o2-tof-matcher-workflow $ARGS_ALL --disable-root-input --disable-root-output $DISABLE_MC --track-sources \"ITS-TPC\" | " - + WORKFLOW+="o2-phos-reco-workflow $ARGS_ALL --input-type raw --output-type cells --disable-root-input --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-cpv-reco-workflow $ARGS_ALL --input-type raw --output-type clusters --disable-root-input --disable-root-output $DISABLE_MC | " WORKFLOW+="o2-emcal-reco-workflow $ARGS_ALL --input-type raw --output-type cells --disable-root-output $DISABLE_MC --pipeline EMCALRawToCellConverterSpec:$N_EMC | " diff --git a/prodtests/sim_challenge.sh b/prodtests/sim_challenge.sh index 4e0c9755514cc..8c11b6876816d 100755 --- a/prodtests/sim_challenge.sh +++ b/prodtests/sim_challenge.sh @@ -180,7 +180,7 @@ if [ "$doreco" == "1" ]; then #needs results of all trackers + P.Vertexer taskwrapper svfinder.log o2-secondary-vertexing-workflow $gloOpt echo "Return status of secondary vertexing: $?" - + echo "Running ZDC reconstruction" #need ZDC digits taskwrapper zdcreco.log o2-zdc-digits-reco $gloOpt