From 34947e517fa7c26481fe7f36c9450e1ae0ec5a9c Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Fri, 19 Aug 2022 19:02:57 +0200 Subject: [PATCH] L1: Finalized the L1InputData object usage: the old input variables were removed --- reco/L1/CMakeLists.txt | 1 - reco/L1/CbmL1.cxx | 87 +--------- reco/L1/CbmL1.h | 8 +- reco/L1/CbmL1MCTrack.h | 4 +- reco/L1/CbmL1Performance.cxx | 2 +- reco/L1/CbmL1ReadEvent.cxx | 47 +----- reco/L1/L1Algo/L1Algo.cxx | 28 +--- reco/L1/L1Algo/L1Algo.h | 13 +- reco/L1/L1Algo/L1CATrackFinder.cxx | 18 +-- reco/L1/L1Algo/utils/L1AlgoDraw.cxx | 4 +- reco/L1/L1AlgoInputData.cxx | 241 ---------------------------- reco/L1/L1AlgoInputData.h | 109 ------------- 12 files changed, 32 insertions(+), 530 deletions(-) delete mode 100644 reco/L1/L1AlgoInputData.cxx delete mode 100644 reco/L1/L1AlgoInputData.h diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index 3def910df0..03f109afa6 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -110,7 +110,6 @@ CbmL1.cxx #CbmL1TrdTrackFinderSts.cxx CbmL1TrackMerger.cxx CbmL1TofMerger.cxx -L1AlgoInputData.cxx OffLineInterface/CbmL1RichENNRingFinder.cxx OffLineInterface/CbmL1RichENNRingFinderParallel.cxx OffLineInterface/CbmL1StsTrackFinder.cxx diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index eb0b058a86..1bb057fd7d 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -65,7 +65,6 @@ #include "L1Algo/L1Branch.h" #include "L1Algo/L1Field.h" #include "L1Algo/L1Hit.h" -#include "L1AlgoInputData.h" #include "L1Event.h" using std::cout; @@ -138,9 +137,6 @@ InitStatus CbmL1::ReInit() // InitStatus CbmL1::Init() { - - fpData = new L1AlgoInputData(); - if (fVerbose > 1) { char y[20] = " [0;33;44m"; // yellow char Y[20] = " [1;33;44m"; // yellow bold @@ -944,12 +940,7 @@ void CbmL1::Reconstruct(CbmEvent* event) while (areDataLeft) { - fpData->Clear(); - if (event) { - - //fpData->fStripFlag.clear(); - areDataLeft = false; TsStart = 0; TsLength = 2000000000; // TODO: Why this number was selected? (S.Zharko) @@ -958,70 +949,13 @@ void CbmL1::Reconstruct(CbmEvent* event) } if (fSTAPDataMode >= 2) { // 2,3 - // TODO: Rewrite it: - //fpData->ReadHitsFromFile(fSTAPDataDir.Data(), 1, fVerbose); - - // TODO: Rewrite it: - //fpAlgo->SetData(fpData->GetHits(), fpData->GetNstrips(), fpData->GetSFlag(), fpData->GetHitsStartIndex(), - // fpData->GetHitsStopIndex()); + LOG(fatal) << "L1: Sorry, at the moment standalone tracking module is unavailable. This functionality will be " + << "reimplemented soon."; } - else { - // TODO: There is no use in passing fpData into the ReadEvent function -> remove (S.Zharko) - ReadEvent(fpData, TsStart, TsLength, TsOverlap, FstHitinTs, areDataLeft, event); - } - - // Send data from IODataManager to L1Algo - fIODataManager.SendInputData(fpAlgo); - - // ******************************************************************************************** - if constexpr (0) { // correct hits on MC // dbg - TRandom3 random; - L1Vector<int> strips("CbmL1::strips"); - for (unsigned int iH = 0; iH < (*fpAlgo->vHits).size(); ++iH) { - L1Hit& h = const_cast<L1Hit&>((*fpAlgo->vHits)[iH]); -#ifdef USE_EVENT_NUMBER - h.n = -1; -#endif - if (fvExternalHits[iH].mcPointIds.size() == 0) continue; - - const CbmL1MCPoint& mcp = fvMCPoints[fvExternalHits[iH].mcPointIds[0]]; - -#ifdef USE_EVENT_NUMBER - h.n = mcp.event; -#endif - const int ista = h.iSt; - const L1Station& sta = fpAlgo->GetParameters()->GetStation(ista); - if (std::find(strips.begin(), strips.end(), h.f) != strips.end()) { // separate strips - (*fpAlgo->fStripFlag).push_back((*fpAlgo->fStripFlag)[h.f]); + // ----- Read data from branches and send data from IODataManager to L1Algo ---------------------------------------- + ReadEvent(TsStart, TsLength, TsOverlap, FstHitinTs, areDataLeft, event); - h.f = fpAlgo->fNstrips; - fpAlgo->fNstrips++; - } - strips.push_back(h.f); - if (std::find(strips.begin(), strips.end(), h.b) != strips.end()) { - (*fpAlgo->fStripFlag).push_back((*fpAlgo->fStripFlag)[h.b]); - h.b = fpAlgo->fNstrips; - fpAlgo->fNstrips++; - } - strips.push_back(h.b); - - double u = mcp.x * sta.frontInfo.cos_phi[0] + mcp.y * sta.frontInfo.sin_phi[0]; - double v = mcp.x * sta.backInfo.cos_phi[0] + mcp.y * sta.backInfo.sin_phi[0]; - -#if 1 // GAUSS - u += random.Gaus(0, sqrt(sta.frontInfo.sigma2)[0]); - v += random.Gaus(0, sqrt(sta.backInfo.sigma2)[0]); -#else // UNIFORM - u += 3.5 * sqrt(sta.frontInfo.sigma2)[0] * random.Uniform(-1, 1); - v += 3.5 * sqrt(sta.backInfo.sigma2)[0] * random.Uniform(-1, 1); -#endif - h.u = u; - h.v = v; - h.z = mcp.z; - } - } - // ******************************************************************************************** if (fPerformance) { HitMatch(); @@ -1031,15 +965,6 @@ void CbmL1::Reconstruct(CbmEvent* event) } } - if (fSTAPDataMode % 2 == 1) { // 1,3 - WriteSTAPAlgoData(); - WriteSTAPPerfData(); - }; - if (fSTAPDataMode >= 2) { // 2,3 - ReadSTAPAlgoData(); - ReadSTAPPerfData(); - }; - if ((fPerformance) && (fSTAPDataMode < 2)) { InputPerformance(); } // FieldApproxCheck(); @@ -1187,7 +1112,7 @@ void CbmL1::Reconstruct(CbmEvent* event) if (!fLegacyEventMode) cout << "CA Track Finder: " << fpAlgo->fCATime << " s/sub-ts" << endl << endl; } - + if (fPerformance) { @@ -1196,7 +1121,7 @@ void CbmL1::Reconstruct(CbmEvent* event) int fHit = 0; bool stop = 0; - ReadEvent(fpData, start, end, start, fHit, stop, event); + ReadEvent(start, end, start, fHit, stop, event); HitMatch(); // calculate the max number of Hits\mcPoints on continuous(consecutive) stations diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 3e0204c034..7a44a100e2 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -53,7 +53,6 @@ #include "L1EventEfficiencies.h" #include "L1IODataManager.h" -struct L1AlgoInputData; class L1Algo; class L1Event; class CbmL1ParticlesFinder; @@ -312,15 +311,14 @@ private: /// Read information about hits, mcPoints and mcTracks into L1 classes /// Repacks data from the external TClonesArray objects to the internal L1 arrays - /// \param fData_ Pointer to the target object containing L1Algo internal arrays of hits /// \param TsStart Reference to the time slice start time /// \param TsLength Reference to the time slice length /// \param TsOverlap Reference to the time slice overlap length (does not used at the moment) /// \param FstHitinTs Index of the first hit in the time-slice /// \param areDataLeft Flag: true - data were left after reading the sub-timeslice /// \param event Pointer to the current CbmEvent object - void ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, float& TsOverlap, int& FstHitinTs, - bool& areDataLeft, CbmEvent* event = NULL); + void ReadEvent(float& TsStart, float& TsLength, float& TsOverlap, int& FstHitinTs, bool& areDataLeft, + CbmEvent* event = NULL); /// Converts data from generic FairMCPoint based class to the CbmL1MCPoint (dummy method) /// \param MC Pointer to a target CbmL1MCPoint object @@ -421,8 +419,6 @@ public: private: static CbmL1* fpInstance; ///< Instance of CbmL1 - L1AlgoInputData* fpData = nullptr; ///< Pointer to the L1 tacking algorithm input object - int nMvdPoints = 0; // TODO: Should be removed (S.Zharko) L1Vector<CbmL1MCPoint> fvMCPoints = {"CbmL1::fvMCPoints"}; ///< Container of MC points diff --git a/reco/L1/CbmL1MCTrack.h b/reco/L1/CbmL1MCTrack.h index 269d5b2ba9..4793793d90 100644 --- a/reco/L1/CbmL1MCTrack.h +++ b/reco/L1/CbmL1MCTrack.h @@ -87,8 +87,8 @@ public: int mother_ID = -1; int pdg = -1; bool isSignal {0}; - L1Vector<int> Points {"CbmL1MCTrack::Points"}; // indices of pints in CbmL1::fvMCPoints - L1Vector<int> Hits {"CbmL1MCTrack::Hits"}; // indices of hits in algo->vHits or L1::vHits + L1Vector<int> Points {"CbmL1MCTrack::Points"}; // indices of pints in CbmL1::fvMCPoints + L1Vector<int> Hits {"CbmL1MCTrack::Hits"}; // indices of hits in algo->vHits or L1::vHits private: int nMCContStations = 0; // number of consecutive stations with mcPoints diff --git a/reco/L1/CbmL1Performance.cxx b/reco/L1/CbmL1Performance.cxx index c4ead6cfee..5c50447626 100644 --- a/reco/L1/CbmL1Performance.cxx +++ b/reco/L1/CbmL1Performance.cxx @@ -1338,7 +1338,7 @@ void CbmL1::TrackFitPerformance() } - { // last hit + { // last hit int iMC = fvHitPointIndexes[it->Hits.back()]; // TODO2: adapt to linking if (iMC < 0) continue; diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx index 52acdeebcc..f781e68b0e 100644 --- a/reco/L1/CbmL1ReadEvent.cxx +++ b/reco/L1/CbmL1ReadEvent.cxx @@ -42,7 +42,6 @@ #include "FairMCEventHeader.h" #include "L1Algo/L1Algo.h" -#include "L1AlgoInputData.h" //#include "CbmMvdHitMatch.h" @@ -175,14 +174,13 @@ struct TmpHit { } }; -void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, float& /*TsOverlap*/, int& FstHitinTs, - bool& areDataLeft, CbmEvent* event) +void CbmL1::ReadEvent(float& TsStart, float& TsLength, float& /*TsOverlap*/, int& FstHitinTs, bool& areDataLeft, + CbmEvent* event) { if (fVerbose >= 10) cout << "ReadEvent: start." << endl; areDataLeft = false; // no data left after reading the sub-timeslice - fData_->Clear(); // clear arrays for next event fvMCPoints.clear(); /* <CbmL1MCPoint> */ @@ -217,14 +215,6 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, tmpHits.reserve(nHitsTotal); } - // -- produce Sts hits from space points -- - - for (int i = 0; i < fNStations; i++) { - fData_->HitsStartIndex[i] = static_cast<L1HitIndex_t>(-1); - fData_->HitsStopIndex[i] = 0; - } - - nMvdPoints = 0; int nStsPoints = 0; int nTrdPoints = 0; @@ -1116,15 +1106,10 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, sort(tmpHits.begin(), tmpHits.end(), TmpHit::Compare); // ----- Save strips into L1Algo - fData_->fNstrips = NStrips; - fData_->fStripFlag.reset(NStrips, 0); int maxHitIndex = 0; for (int ih = 0; ih < nHits; ih++) { TmpHit& th = tmpHits[ih]; - char flag = th.iStation * 4; - fData_->fStripFlag[th.iStripF] = flag; - fData_->fStripFlag[th.iStripB] = flag; if (maxHitIndex < th.id) { maxHitIndex = th.id; } } // ih @@ -1132,12 +1117,9 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // ----- Fill and save fvExternalHits, fvHitStore and fvHitPointIndexes vectors as well as fpData->vHits - int nEffHits = 0; - fvSortedHitsIndexes.reset(maxHitIndex + 1); fvExternalHits.reserve(nHits); - fData_->vHits.reserve(nHits); fvHitStore.reserve(nHits); fvHitPointIndexes.reserve(nHits); @@ -1194,35 +1176,16 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // TODO: Here one should fill in the fvExternalHits[iHit].mcPointIds - fData_->vHits.push_back(h); fIODataManager.PushBackHit(h); - int iSt = th.iStation; - - if (fData_->HitsStartIndex[iSt] == static_cast<L1HitIndex_t>(-1)) { fData_->HitsStartIndex[iSt] = nEffHits; } - nEffHits++; - - fData_->HitsStopIndex[iSt] = nEffHits; - fvHitStore.push_back(s); fvHitPointIndexes.push_back(th.iMC); } - for (int i = 0; i < fNStations; i++) { - if (fData_->HitsStartIndex[i] == static_cast<L1HitIndex_t>(-1)) { - fData_->HitsStartIndex[i] = fData_->HitsStopIndex[i]; - } - } - - if (fVerbose >= 10) cout << "ReadEvent: mvd and sts are saved." << endl; - - /* - * Translate gathered hits data to the L1Algo object. TODO: raplace it with L1DataManager functionality (S.Zharko) - */ - - fpAlgo->SetData(fData_->GetHits(), fData_->GetNstrips(), fData_->GetSFlag(), fData_->GetHitsStartIndex(), - fData_->GetHitsStopIndex()); + if (fVerbose >= 1) cout << "ReadEvent: mvd and sts are saved." << endl; + // ----- Send data from IODataManager to L1Algo -------------------------------------------------------------------- + fIODataManager.SendInputData(fpAlgo); if (fPerformance) { if (fVerbose >= 10) cout << "HitMatch is done." << endl; diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index 3f9c221c39..081c7dd1be 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -106,31 +106,11 @@ void L1Algo::ReceiveInputData(L1InputData&& inputData) { // ----- Get input data ---------------------------------------------------------------------------------------------- fInputData = std::move(inputData); - // TODO: Reset here internal data (probably, we should have additional class for internal data) // ----- Reset data arrays ------------------------------------------------------------------------------------------- fvHitKeyFlags.reset(fInputData.GetNhitKeys()); -} - - -/// -void L1Algo::SetData(L1Vector<L1Hit>& Hits_, int nStrips_, L1Vector<unsigned char>& SFlag_, - const L1HitIndex_t* HitsStartIndex_, const L1HitIndex_t* HitsStopIndex_) -{ - // TODO: Remove (S.Zharko) - vHits = &Hits_; - fNstrips = nStrips_; - fStripFlag = &SFlag_; - - HitsStartIndex = HitsStartIndex_; - HitsStopIndex = HitsStopIndex_; - - // TODO: maximal array sizes need to be adjusted - // TODO: move to ReceiveInputData function (S.Zharko) - int nHits = vHits->size(); - - NHitsIsecAll = nHits; // TODO: Is it needed? - + int nHits = fInputData.GetNhits(); + NHitsIsecAll = nHits; vNotUsedHits_A.reset(nHits); vNotUsedHits_B.reset(nHits); vNotUsedHits_Buf.reset(nHits); @@ -142,14 +122,14 @@ void L1Algo::SetData(L1Vector<L1Hit>& Hits_, int nStrips_, L1Vector<unsigned cha RealIHit_v_buf2.reset(nHits); #ifdef _OPENMP - fStripToTrackLock.reset(fNstrips); + fStripToTrackLock.reset(fInputData.GetNhitKeys()); for (unsigned int j = 0; j < fStripToTrackLock.size(); j++) { omp_init_lock(&fStripToTrackLock[j]); } #endif fStripToTrack.clear(); - fStripToTrack.reserve(fNstrips); + fStripToTrack.reserve(fInputData.GetNhitKeys()); fHitFirstTriplet.reset(nHits); fHitNtriplets.reset(nHits); diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index bd609a58a9..bfa960d7bc 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -411,9 +411,6 @@ public: void Init(const bool UseHitErrors, const TrackingMode mode, const bool MissingHits); - void SetData(L1Vector<L1Hit>& Hits_, int nStrips_, L1Vector<unsigned char>& SFlag_, - const L1HitIndex_t* HitsStartIndex_, const L1HitIndex_t* HitsStopIndex_); - void PrintHits(); /// The main procedure - find tracks. @@ -464,23 +461,15 @@ private: "L1Algo::fvHitKeyFlags"}; ///< List of key flags: has been this hit or cluster already used public: - int fNstrips {0}; ///< number of strips - L1Vector<L1Hit>* vHits {nullptr}; ///< hits as a combination of front and back strips and z-position - L1Grid vGrid[L1Constants::size::kMaxNstations]; ///< + L1Grid vGrid[L1Constants::size::kMaxNstations]; ///< L1Grid vGridTime[L1Constants::size::kMaxNstations]; ///< - L1Vector<unsigned char>* fStripFlag {nullptr}; // information of hits station & using hits in tracks; - double fCATime {0.}; // time of track finding L1Vector<L1Track> fTracks {"L1Algo::fTracks"}; ///< reconstructed tracks L1Vector<L1HitIndex_t> fRecoHits {"L1Algo::fRecoHits"}; ///< packed hits of reconstructed tracks - const L1HitIndex_t* HitsStartIndex {nullptr}; // station-bounders in vHits array - const L1HitIndex_t* HitsStopIndex {nullptr}; // station-bounders in vHits array - - /// Created triplets vs station and thread index L1Vector<L1Triplet> fTriplets[L1Constants::size::kMaxNstations][L1Constants::size::kMaxNthreads] { {"L1Algo::fTriplets"}}; diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 5ce6bf683a..4ad0533ac1 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -1796,16 +1796,16 @@ void L1Algo::CATrackFinder() // #pragma omp parallel for reduction(+:nNotUsedHits) for (int ista = 0; ista < fNstations; ++ista) { - nNotUsedHits += (HitsStopIndex[ista] - HitsStartIndex[ista]); - HitsUnusedStartIndex[ista] = HitsStartIndex[ista]; - HitsUnusedStopIndex[ista] = HitsStopIndex[ista]; + nNotUsedHits += (fInputData.GetStopHitIndex(ista) - fInputData.GetStartHitIndex(ista)); + HitsUnusedStartIndex[ista] = fInputData.GetStartHitIndex(ista); + HitsUnusedStopIndex[ista] = fInputData.GetStopHitIndex(ista); } float lasttime = 0; float starttime = std::numeric_limits<float>::max(); for (int ist = 0; ist < fNstations; ++ist) - for (L1HitIndex_t ih = HitsStartIndex[ist]; ih < HitsStopIndex[ist]; ++ih) { + for (L1HitIndex_t ih = fInputData.GetStartHitIndex(ist); ih < fInputData.GetStopHitIndex(ist); ++ih) { const float& time = fInputData.GetHit(ih).t; if ((lasttime < time) && (!std::isinf(time))) lasttime = time; @@ -1853,7 +1853,7 @@ void L1Algo::CATrackFinder() for (int ist = 0; ist < fNstations; ++ist) - for (L1HitIndex_t ih = HitsStartIndex[ist]; ih < HitsStopIndex[ist]; ++ih) { + for (L1HitIndex_t ih = fInputData.GetStartHitIndex(ist); ih < fInputData.GetStopHitIndex(ist); ++ih) { const L1Hit& h = fInputData.GetHit(ih); //SetFUnUsed((*fStripFlag)[h.f]); //SetFUnUsed((*fStripFlag)[h.b]); @@ -1869,7 +1869,7 @@ void L1Algo::CATrackFinder() #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 5) #endif - for (L1HitIndex_t ih = HitsStartIndex[ista]; ih < HitsStopIndex[ista]; ++ih) { + for (L1HitIndex_t ih = fInputData.GetStartHitIndex(ista); ih < fInputData.GetStopHitIndex(ista); ++ih) { CreateHitPoint(vNotUsedHits_Buf[ih], vNotUsedHitsxy_B[ih]); } } @@ -2090,8 +2090,8 @@ void L1Algo::CATrackFinder() i1G_2) //schedule(dynamic, 2) #endif for (Tindex ip = fDupletPortionStopIndex[istal + 1]; ip < fDupletPortionStopIndex[istal]; ++ip) { - Tindex n_2 = 0; // number of doublets in portion - int NHitsSta = HitsStopIndex[istal] - HitsStartIndex[istal]; + Tindex n_2 = 0; /// number of doublets in portion + int NHitsSta = fInputData.GetStopHitIndex(istal) - fInputData.GetStartHitIndex(istal); lmDuplets[istal].reset(NHitsSta); lmDupletsG[istal].reset(NHitsSta); @@ -2220,7 +2220,7 @@ void L1Algo::CATrackFinder() fTrackCandidates[i].clear(); } - fStripToTrack.reset(fNstrips, -1); + fStripToTrack.reset(fInputData.GetNhitKeys(), -1); //== Loop over triplets with the required level, find and store track candidates diff --git a/reco/L1/L1Algo/utils/L1AlgoDraw.cxx b/reco/L1/L1Algo/utils/L1AlgoDraw.cxx index 477cea144e..c96d54dcb4 100644 --- a/reco/L1/L1Algo/utils/L1AlgoDraw.cxx +++ b/reco/L1/L1Algo/utils/L1AlgoDraw.cxx @@ -80,8 +80,8 @@ void L1AlgoDraw::InitL1Draw(L1Algo* algo_) } NStations = algo->GetParameters()->GetNstationsActive(); for (int i = 0; i < NStations; i++) { - HitsStartIndex[i] = algo->HitsStartIndex[i]; - HitsStopIndex[i] = algo->HitsStopIndex[i]; + HitsStartIndex[i] = algo->GetInputData()->GetStartHitIndex(i); + HitsStopIndex[i] = algo->GetInputData()->GetStopHitIndex(i); vStations[i] = algo->GetParameters()->GetStation(i); } } diff --git a/reco/L1/L1AlgoInputData.cxx b/reco/L1/L1AlgoInputData.cxx deleted file mode 100644 index 30dc4f4b0e..0000000000 --- a/reco/L1/L1AlgoInputData.cxx +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Maksym Zyzak [committer] */ - -#include "L1AlgoInputData.h" - -#include <cstring> -#include <iostream> -using namespace std; -using std::ios; -/* -L1AlgoInputData::L1AlgoInputData( const L1AlgoInputData& a) -{ - SetData( a.GetHits(), a.GetStsStrips(), a.GetStsStripsB(), - a.GetSFlag(), a.GetSFlagB(), a.GetHitsStartIndex(), a.GetHitsStopIndex()); -} - - -const L1AlgoInputData& L1AlgoInputData::operator=( const L1AlgoInputData& a) -{ - SetData( a.GetHits(), a.GetStsStrips(), a.GetStsStripsB(), - a.GetSFlag(), a.GetSFlagB(), a.GetHitsStartIndex(), a.GetHitsStopIndex()); - return a; -} - - -void L1AlgoInputData::SetData( const vector< L1Hit > & Hits_, - const vector< L1Strip > & StsStrips_, - const vector< L1Strip > & StsStripsB_, - const vector< unsigned char > & SFlag_, - const vector< unsigned char > & SFlagB_, - const L1HitIndex_t* HitsStartIndex_, - const L1HitIndex_t* HitsStopIndex_ ) -{ - vHits.resize(Hits_.size()); - vStsStrips.resize(StsStrips_.size()); - vStsStripsB.resize(StsStripsB_.size()); - fStripFlag.resize(SFlag_.size()); - fStripFlagB.resize(SFlagB_.size()); - - for(unsigned int i=0; i<Hits_.size(); ++i ) {vHits[i] = Hits_[i]; - -} - for(unsigned int i=0; i<StsStrips_.size(); ++i ) vStsStrips[i] = StsStrips_[i]; - for(unsigned int i=0; i<StsStripsB_.size(); ++i ) vStsStripsB[i] = StsStripsB_[i]; - for(unsigned int i=0; i<SFlag_.size(); ++i ) fStripFlag[i] = SFlag_[i]; - for(unsigned int i=0; i<SFlagB_.size(); ++i ) fStripFlagB[i] = SFlagB_[i]; - - for(unsigned int i=0; i<MaxNStations+1; ++i) HitsStartIndex[i] = HitsStartIndex_[i]; - - for(unsigned int i=0; i<MaxNStations+1; ++i) HitsStopIndex[i] = HitsStopIndex_[i]; -} - -*/ - -/****************************************************************************************************************/ - -void L1AlgoInputData::Clear() -{ - vHits.clear(); - fNstrips = 0; - fStripFlag.clear(); - { - for (int i = 0; i < kMaxNStations + 1; ++i) { - HitsStartIndex[i] = 0; - } - for (int i = 0; i < kMaxNStations + 1; ++i) { - HitsStopIndex[i] = 0; - } - } -} - -/****************************************************************************************************************/ - -istream& L1AlgoInputData::eatwhite(istream& is) // skip spaces -{ - char c; - while (is.get(c)) { - if (isspace(c) == 0) { - is.putback(c); - break; - } - } - return is; -} - -/****************************************************************************************************************/ - -bool L1AlgoInputData::ReadHitsFromFile(const char work_dir[100], const int maxNEvent, const int iVerbose) -{ - static int nEvent = 1; - static ifstream fadata; - static char fname[100]; - - if (nEvent == 1) { - strcpy(fname, work_dir); - strcat(fname, "data_algo.txt"); - fadata.open(fname); - } - if (!fadata.is_open()) return 0; - - if (nEvent <= maxNEvent) { - - vHits.clear(); - fNstrips = 0; - - fStripFlag.clear(); - - // check correct position in file - char s[] = "Event: "; - int nEv; - fadata >> s; - // cout << s<< " s"<<endl; - fadata >> nEv; - // cout << nEv<< " nEv"<<endl; - - if (nEv != nEvent) cout << "-E- CbmL1: Can't read event number " << nEvent << " from file " << fname << endl; - - int n; // number of elements - // read algo->vStsStrips - fadata >> n; - // cout << n<< " vStsStrips"<<endl; - fNstrips = n; - if (iVerbose >= 4) { - cout << "vStsStrips[" << n << "]" - << " have been read." << endl; - } - // read algo->fStripFlag - fadata >> n; - // cout << n<< " fStripFlagB"<<endl; - fStripFlag.reserve(n); - for (int i = 0; i < n; i++) { - int element; - fadata >> element; - fStripFlag.push_back(static_cast<unsigned char>(element)); - } - if (iVerbose >= 4) { - cout << "fStripFlag[" << n << "]" - << " have been read." << endl; - } - // read algo->vHits - fadata >> n; - // cout << n<< " vHits"<<endl; - int element_f; // for convert - int element_b; - int element_n; - for (int i = 0; i < n; i++) { - L1Hit element; - fadata >> element_f >> element_b >> element_n >> element.z >> element.u >> element.v >> element.t; - element.f = static_cast<L1HitIndex_t>(element_f); - element.b = static_cast<L1HitIndex_t>(element_b); -#ifdef USE_EVENT_NUMBER - element.n = static_cast<unsigned short int>(element_n); -#endif - vHits.push_back(element); - } - if (iVerbose >= 4) { - cout << "vHits[" << n << "]" - << " have been read." << endl; - } - // read HitsStartIndex and HitsStopIndex - n = 20; - for (int i = 0; i < n; i++) { - int tmp; - fadata >> tmp; - if (kMaxNStations + 1 > i) HitsStartIndex[i] = tmp; - // cout << " HitsStartIndex[i]"<< HitsStartIndex[i] << endl; - - // cout << tmp<< " tmp"<<endl; - } - for (int i = 0; i < n; i++) { - int tmp; - fadata >> tmp; - if (kMaxNStations + 1 > i) HitsStopIndex[i] = tmp; - // cout << " HitsStopIndex[i]"<< HitsStopIndex[i] << endl; - // cout << tmp<< " tmp"<<endl; - } - - if (iVerbose >= 2) { - cout << "-I- CbmL1: CATrackFinder data for event " << nEvent << " has been read from file " << fname - << " successfully." << endl; - } - // if (nEvent == maxNEvent) fadata.close(); - } - nEvent++; - return 1; -} // void L1AlgoInputData::ReadStAPAlgoData() - -/****************************************************************************************************************/ - -/* -void L1AlgoInputData::PrintHits() -{ - std::cout << "Event: " << std::endl; - - int n = vStsStrips.size(); // number of elements - std::cout << n << std::endl; - for (int i = 0; i < n; i++){ - std::cout << vStsStrips[i] << std::endl; - } - - n = vStsStripsB.size(); - std::cout << n << std::endl; - for (int i = 0; i < n; i++){ - std::cout << vStsStripsB[i] << std::endl; - } - - - n = fStripFlag.size(); - std::cout << n << std::endl; - for (int i = 0; i < n; i++){ - std::cout << static_cast<int>(fStripFlag[i]) << std::endl; - } - - n = fStripFlagB.size(); - std::cout << n << std::endl; - for (int i = 0; i < n; i++){ - std::cout << static_cast<int>(fStripFlagB[i]) << std::endl; - } - - n = vHits.size(); - std::cout << n << std::endl; - for (int i = 0; i < n; i++){ - std::cout << static_cast<int>(vHits[i].f) << " "; - std::cout << static_cast<int>(vHits[i].b) << " "; - std::cout << (vHits[i].z) << std::endl; - } - - n = 20; - for (int i = 0; i < n; i++){ - if (MaxNStations+1 > i) std::cout << HitsStartIndex[i] <<std::endl; - else std::cout << "0" <<std::endl; - } - for (int i = 0; i < n; i++){ - if (MaxNStations+1 > i) std::cout << HitsStopIndex[i] <<std::endl; - else std::cout << "0" <<std::endl; - } - -} // void L1AlgoInputData::ReadStAPAlgoData() - -*/ diff --git a/reco/L1/L1AlgoInputData.h b/reco/L1/L1AlgoInputData.h deleted file mode 100644 index 38f5ff51de..0000000000 --- a/reco/L1/L1AlgoInputData.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Maksym Zyzak [committer], Valentina Akishina */ - -#ifndef _L1AlgoInputData_h -#define _L1AlgoInputData_h - -#include <fstream> -#include <iostream> - -#include "L1Def.h" -#include "L1Hit.h" -#include "L1Vector.h" - -/// -/// Class L1AlgoInputData implements a container for keeping a vector of L1Algo internal hit structures (the -/// L1Hit objects), used for track reconstruction procedure. -/// -struct L1AlgoInputData { - static constexpr int kMaxNStations {25}; ///> max number of stations to be passed to the L1AlgoInputData object - // TODO: Why is it different to the value used in L1Algo (L1Constants::size::kMaxNstations)? (S.Zharko) - - /// Default constructor - L1AlgoInputData() = default; - - /// Default destructor - ~L1AlgoInputData() = default; - - /// Resets the object - /// For all the vectors the clear method is called, all other fields are set to zero - void Clear(); - - /// Gets number of the station strips - int GetNstrips() const { return fNstrips; } - - /// Gives an access to the underlying vector of L1Hit objects - L1Vector<L1Hit>& GetHits() { return vHits; } - - /// Gives an access to the vector of the strip flags - L1Vector<unsigned char>& GetSFlag() { return fStripFlag; } - - /// Gets an access of the start indexes for different stations - /// \return pointer to the first element of the array over the stations - const L1HitIndex_t* GetHitsStartIndex() const { return HitsStartIndex; } - - /// Gets an access of the stop indexes for different stations - /// \return pointer to the first element of the array over the stations - const L1HitIndex_t* GetHitsStopIndex() const { return HitsStopIndex; } - - /// Reads a vector of L1Hit object from file - /// The input text file must have the exactly "data_algo.txt" basename - /// \param work_dir path to the file data_algo.txt file, containing the L1Hit objects for different events - /// \param maxNEvent max number of events to be read from the data_algo.txt file - /// \param iVerbose verbosity level - /// \return success flag: - /// true - data was read and stored into this object - /// false - data was not read for some reason - bool ReadHitsFromFile(const char work_dir[100], const int maxNEvent, const int iVerbose); - - // void PrintHits(); - - // - // Redefinitions of the new\delete operators for using the alignment memmory - // - /// Placement new operator for single element - void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } - - /// Placement new operator for multiple elements - void* operator new[](size_t size, void* ptr) { return ::operator new(size, ptr); } - - /// New operator for single element - void* operator new(size_t size) { return _mm_malloc(size, 16); } - - /// New operator for multiple elements - void* operator new[](size_t size) { return _mm_malloc(size, 16); } - - /// Delete operator for single element - void operator delete(void* ptr, size_t) { _mm_free(ptr); } - - /// Delete operator for multiple elements - void operator delete[](void* ptr, size_t) { _mm_free(ptr); } - - // TODO: Where are the definitions? (S.Zharko) - - /// Copy constructor - L1AlgoInputData(const L1AlgoInputData& a); - - /// Copy assignment operator - const L1AlgoInputData& operator=(const L1AlgoInputData& a); - - // private: - // - // functionality - // - /// Skips spaces in the input stream (TODO: is it used somewhere? (S.Zharko)) - static std::istream& eatwhite(std::istream& is); // skip spaces - /// read data from data_algo.txt - /* - * Data fields (public) - */ - L1Vector<L1Hit> vHits {"L1AlgoInputData::vHits"}; ///< hits as a combination of front-, backstrips and z-position - int fNstrips {0}; ///> Number of strips in the station - L1Vector<unsigned char> fStripFlag {"L1AlgoInputData::fStripFlag"}; ///< hits station & used hits in tracks - L1HitIndex_t HitsStartIndex[kMaxNStations + 1] {0}; ///< Start indeces for a given station - L1HitIndex_t HitsStopIndex[kMaxNStations + 1] {0}; ///< Stop indeces for a given station - -} _fvecalignment; - -#endif // #ifndef _L1AlgoInputData_h -- GitLab