diff --git a/core/qa/CbmQaTask.cxx b/core/qa/CbmQaTask.cxx index 58a6ffc7fc66c1d9e1ec136544c4c5d1c18e7cc1..4dbd7da02c90741763cd16f01d9f3c6d3813ce71 100644 --- a/core/qa/CbmQaTask.cxx +++ b/core/qa/CbmQaTask.cxx @@ -44,6 +44,7 @@ void CbmQaTask::Exec(Option_t* /*option*/) int nEvents = fpBrEvents->GetEntriesFast(); for (int iEvt = 0; iEvt < nEvents; ++iEvt) { fpCurrentEvent = static_cast<CbmEvent*>(fpBrEvents->At(iEvt)); + assert(fpCurrentEvent); this->InitTimeSlice(); this->FillHistograms(); fNofEvents.SetVal(fNofEvents.GetVal() + 1); diff --git a/reco/L1/CbmCaMCModule.cxx b/reco/L1/CbmCaMCModule.cxx index 70ad4f373067520a11524c1fc393292620d3adcd..6195dbc621a372810448e7c341a493fd4b271955 100644 --- a/reco/L1/CbmCaMCModule.cxx +++ b/reco/L1/CbmCaMCModule.cxx @@ -80,6 +80,8 @@ try { auto mcManager = dynamic_cast<CbmMCDataManager*>(fairManager->GetObject("MCDataManager")); assert(mcManager); + fpTimeSlice = dynamic_cast<CbmTimeSlice*>(fairManager->GetObject("TimeSlice.")); + fpMCEventList = dynamic_cast<CbmMCEventList*>(fairManager->GetObject("MCEventList.")); fpMCEventHeader = mcManager->GetObject("MCEventHeader."); fpMCTracks = mcManager->InitBranch("MCTrack"); @@ -259,8 +261,11 @@ void MCModule::MatchRecoAndMC() this->MatchPointsAndHits<ca::EDetectorID::kMuch>(); this->MatchPointsAndHits<ca::EDetectorID::kTrd>(); this->MatchPointsAndHits<ca::EDetectorID::kTof>(); + LOG(info) << "DBG 1"; this->MatchRecoAndMCTracks(); + LOG(info) << "DBG 2"; this->InitTrackInfo(); + LOG(info) << "DBG 3"; for (const auto& trkMC : fpMCData->GetTrackContainer()) { if (trkMC.IsReconstructable()) { fMonitor.IncrementCounter(EMonitorKey::kMcTrackReconstructable); diff --git a/reco/L1/CbmCaMCModule.h b/reco/L1/CbmCaMCModule.h index 6ed20f34f3e14a6b6e400e8298dbcdde57720465..9d1216fadc7ffb94ada6a4cdc9209f26e5e261f6 100644 --- a/reco/L1/CbmCaMCModule.h +++ b/reco/L1/CbmCaMCModule.h @@ -467,6 +467,9 @@ namespace cbm::ca return; } + if ((*fpvFstHitId)[static_cast<int>(DetID)] == (*fpvFstHitId)[static_cast<int>(DetID) + 1]) { + return; + } for (int iH = (*fpvFstHitId)[static_cast<int>(DetID)]; iH < (*fpvFstHitId)[static_cast<int>(DetID) + 1]; ++iH) { auto& hit = (*fpvQaHits)[iH]; auto [iBestP, vAllP] = MatchHitWithMc<DetID>(hit.ExtIndex); diff --git a/reco/L1/CbmCaTimeSliceReader.cxx b/reco/L1/CbmCaTimeSliceReader.cxx index d5e8d35e4cef5bd2982cfbdecfa5e63804240580..9a13939d4f72d0e1420e12a9b6acce7ff8d6c746 100644 --- a/reco/L1/CbmCaTimeSliceReader.cxx +++ b/reco/L1/CbmCaTimeSliceReader.cxx @@ -188,9 +188,13 @@ catch (const std::logic_error& error) { // void TimeSliceReader::ReadEvent(CbmEvent* pEvent) { - fpEvent = pEvent; + static int iEvt = 0; + fpEvent = pEvent; + LOG(info) << "READ HITS"; this->ReadHits(); + LOG(info) << "READ TRACKS"; this->ReadRecoTracks(); + LOG(info) << "Evt. " << iEvt++ << " is read"; } @@ -229,12 +233,12 @@ void TimeSliceReader::ReadRecoTracks() track.Hits.reserve(pInputTrack->GetTotalNofHits()); for (int iH = 0; iH < pInputTrack->GetNofMvdHits(); ++iH) { int iHext = pInputTrack->GetMvdHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext]; track.Hits.push_back(iHint); } // iH for (int iH = 0; iH < pInputTrack->GetNofStsHits(); ++iH) { int iHext = pInputTrack->GetStsHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext]; track.Hits.push_back(iHint); } // iH } // iT @@ -262,13 +266,13 @@ void TimeSliceReader::ReadRecoTracks() if (fvbUseDet[ca::EDetectorID::kMvd]) { for (int iH = 0; iH < pStsTrack->GetNofMvdHits(); ++iH) { int iHext = pStsTrack->GetMvdHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext]; track.Hits.push_back(iHint); } } for (int iH = 0; iH < pStsTrack->GetNofStsHits(); ++iH) { int iHext = pStsTrack->GetStsHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext]; track.Hits.push_back(iHint); } } @@ -281,7 +285,7 @@ void TimeSliceReader::ReadRecoTracks() auto* pMuchTrack = static_cast<CbmMuchTrack*>(fpBrMuchTracks->At(iMuchTrkId)); for (int iH = 0; iH < pMuchTrack->GetNofHits(); ++iH) { int iHext = pMuchTrack->GetHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kMuch][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kMuch][iHext]; track.Hits.push_back(iHint); } } @@ -294,7 +298,7 @@ void TimeSliceReader::ReadRecoTracks() const auto* pTrdTrack = static_cast<const CbmTrdTrack*>(fpBrTrdTracks->At(iTrdTrkId)); for (int iH = 0; iH < pTrdTrack->GetNofHits(); ++iH) { int iHext = pTrdTrack->GetHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kTrd][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kTrd][iHext]; track.Hits.push_back(iHint); } // iH } @@ -307,7 +311,7 @@ void TimeSliceReader::ReadRecoTracks() const auto* pTofTrack = static_cast<const CbmTofTrack*>(fpBrTofTracks->At(iTofTrkId)); for (int iH = 0; iH < pTofTrack->GetNofHits(); ++iH) { int iHext = pTofTrack->GetHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kTof][iHext]; + int iHint = fvmHitExtToIntIndexMap[ca::EDetectorID::kTof][iHext]; track.Hits.push_back(iHint); } // iH } // if iTofTrkId > -1 @@ -330,7 +334,7 @@ void TimeSliceReader::RegisterIODataManager(std::shared_ptr<ca::DataManager>& pI void TimeSliceReader::SortQaHits() { int nStationsActive = fpParameters->GetNstationsActive(); - ca::Vector<CbmL1HitDebugInfo> vNewHits(fpvQaHits->size()); + ca::Vector<CbmL1HitDebugInfo> vNewHits{"TimeSliceReader::SortQaHits(): vNewHits", fpvQaHits->size()}; std::vector<int> vHitFstIndexes(nStationsActive + 1, 0); std::vector<int> vNofHitsStored(nStationsActive, 0); @@ -340,13 +344,14 @@ void TimeSliceReader::SortQaHits() for (int iSt = 0; iSt < nStationsActive; ++iSt) { vHitFstIndexes[iSt + 1] += vHitFstIndexes[iSt]; } - for (const auto& hit : (*fpvQaHits)) { int iSt = hit.GetStationId(); vNewHits[vHitFstIndexes[iSt] + (vNofHitsStored[iSt]++)] = hit; } + auto name = fpvQaHits->GetName(); std::swap(vNewHits, (*fpvQaHits)); + fpvQaHits->SetName(name); } // --------------------------------------------------------------------------------------------------------------------- @@ -395,6 +400,8 @@ void TimeSliceReader::ReadHits() fNofHits = std::accumulate(fvNofHitsUsed.cbegin(), fvNofHitsUsed.cend(), 0); + LOG(info) << "CA: N hits used/tot = " << fNofHits << "/" << nHitsTot; + // Update number of hit keys in input data object if (fpIODataManager) { fpIODataManager->SetNhitKeys(fNofHitKeys); @@ -408,12 +415,11 @@ void TimeSliceReader::ReadHits() // Update maps of ext->int hit indexes // NOTE: fvpHitIds must be initialized, if we want to read tracks from the file if (fpvHitIds) { - auto ResetIndexMap = [&, idx = 0](auto& v) mutable { v.reset(fvNofHitsTotal[idx++]); }; - std::for_each(fvvHitExtToIntIndexMap.begin(), fvvHitExtToIntIndexMap.end(), ResetIndexMap); - + auto ResetIndexMap = [&](auto& m) mutable { m.clear(); }; + std::for_each(fvmHitExtToIntIndexMap.begin(), fvmHitExtToIntIndexMap.end(), ResetIndexMap); for (int iH = 0; iH < fNofHits; ++iH) { const auto& hit = (*fpvQaHits)[iH]; - fvvHitExtToIntIndexMap[hit.Det][hit.ExtIndex] = iH; + fvmHitExtToIntIndexMap[hit.Det][hit.ExtIndex] = iH; } } } diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h index 1a1a0b51c42a1a3942ecb56689e2381792c60d24..2b8df810e2bb7255bd5829f392018253bbc86028 100644 --- a/reco/L1/CbmCaTimeSliceReader.h +++ b/reco/L1/CbmCaTimeSliceReader.h @@ -183,7 +183,7 @@ namespace cbm::ca std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object // Maps of hit indexes: ext -> int - DetIdArr_t<ca::Vector<int>> fvvHitExtToIntIndexMap; ///< Hit index map ext -> int + DetIdArr_t<std::unordered_map<int, int>> fvmHitExtToIntIndexMap; ///< Hit index map ext -> int DetIdArr_t<int> fvNofHitsTotal = {{0}}; ///< Total hit number in detector DetIdArr_t<int> fvNofHitsUsed = {{0}}; ///< Number of used hits in detector @@ -217,13 +217,16 @@ int cbm::ca::TimeSliceReader::ReadHitsForDetector() } // Detector is entirelly not used const auto* pDetInterface = fvpDetInterface[DetID]; - int nHitsTot = fvpBrHits[DetID]->GetEntriesFast(); // total number of hits provided by hit finder + int nHitsTot = fpEvent ? fpEvent->GetNofData(kCbmHitType[DetID]) : fvpBrHits[DetID]->GetEntriesFast(); int nHitsStored = 0; // number of hits used in tracking fFirstHitKey = fNofHitKeys; for (int iH = 0; iH < nHitsTot; ++iH) { int iHext = fpEvent ? fpEvent->GetIndex(kCbmHitType[DetID], iH) : iH; + if (iHext < 0) { + continue; + } tools::HitRecord hitRecord; auto* pHit = static_cast<Hit_t*>(fvpBrHits[DetID]->At(iHext)); diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 66deb50637cd5a4d1b8522a44654bc7e4097925c..80564cb6fe3e5168427cb86d9080f97fe95aed86 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -750,6 +750,9 @@ InitStatus CbmL1::Init() void CbmL1::Reconstruct(CbmEvent* event) { + LOG(info) << "\n\n\n\n\n !!!!! EVENT = " << event << "\n\n\n\n\n"; + + ca::TrackingMonitorData monitorData; fvSelectedMcEvents.clear(); diff --git a/reco/L1/qa/CbmCaOutputQa.cxx b/reco/L1/qa/CbmCaOutputQa.cxx index d99cac0f811165ace17dac580ec16f2b1163adef..198937bdc459290d11a8e684e189c43a6379da49 100644 --- a/reco/L1/qa/CbmCaOutputQa.cxx +++ b/reco/L1/qa/CbmCaOutputQa.cxx @@ -932,12 +932,15 @@ InitStatus OutputQa::InitTimeSlice() int nHits = 0; int nRecoTracks = 0; + LOG(info) << "\n\n\n\n\n !!!!! EVENT = " << this->GetCurrentEvent() << "\n\n\n\n\n"; // Read reconstructed input fpTSReader->ReadEvent(this->GetCurrentEvent()); nHits = fvHits.size(); nRecoTracks = fvRecoTracks.size(); + LOG(info) << "Reco hits: " << nHits << ", reco tracks: " << nRecoTracks; + fMonitor.IncrementCounter(EMonitorKey::kTrack, nRecoTracks); fMonitor.IncrementCounter(EMonitorKey::kHit, nHits);