From a512c41cdff67dc4f54654decd3760a402824f6d Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Thu, 28 Jul 2022 17:33:54 +0200 Subject: [PATCH] L1: U and V coordinates and uncertainties conversion methods were refactored and moved from L1Algo to L1Station --- .../much/CbmMuchTrackingInterface.cxx | 4 +- reco/L1/CbmL1.cxx | 721 +++++++++--------- reco/L1/CbmL1.h | 344 +++++---- reco/L1/CbmL1Hit.h | 24 +- reco/L1/CbmL1MCTrack.cxx | 14 +- reco/L1/CbmL1MCTrack.h | 4 +- reco/L1/CbmL1Performance.cxx | 271 +++---- reco/L1/CbmL1ReadEvent.cxx | 551 ++++++------- reco/L1/CbmL1TrackFitter.cxx | 182 ----- reco/L1/L1Algo/L1Algo.cxx | 61 +- reco/L1/L1Algo/L1Algo.h | 20 +- reco/L1/L1Algo/L1CATrackFinder.cxx | 73 +- reco/L1/L1Algo/L1Constants.h | 16 +- reco/L1/L1Algo/L1Hit.h | 23 +- reco/L1/L1Algo/L1HitsSortHelper.cxx | 1 + reco/L1/L1Algo/L1InitManager.h | 4 +- reco/L1/L1Algo/L1Station.cxx | 8 +- reco/L1/L1Algo/L1Station.h | 75 +- reco/L1/L1Algo/L1Station.h.orig | 173 +++++ reco/L1/L1Algo/L1Track.h | 4 +- reco/L1/L1Algo/L1TrackExtender.cxx | 26 +- reco/L1/L1Algo/L1TrackFitter.cxx | 237 +++--- reco/L1/L1Algo/utils/L1AlgoDraw.cxx | 8 +- .../utils/L1AlgoEfficiencyPerformance.h | 22 +- reco/L1/L1Algo/utils/L1AlgoPulls.cxx | 4 +- reco/L1/L1AlgoInputData.h | 21 +- .../CbmL1GlobalTrackFinder.cxx | 20 +- .../OffLineInterface/CbmL1StsTrackFinder.cxx | 12 +- reco/L1/ParticleFinder/CbmL1PFFitter.cxx | 46 +- 29 files changed, 1538 insertions(+), 1431 deletions(-) delete mode 100644 reco/L1/CbmL1TrackFitter.cxx create mode 100644 reco/L1/L1Algo/L1Station.h.orig diff --git a/core/detectors/much/CbmMuchTrackingInterface.cxx b/core/detectors/much/CbmMuchTrackingInterface.cxx index d86cb2e3c4..dbce00539b 100644 --- a/core/detectors/much/CbmMuchTrackingInterface.cxx +++ b/core/detectors/much/CbmMuchTrackingInterface.cxx @@ -57,9 +57,9 @@ InitStatus CbmMuchTrackingInterface::Init() // Check initialization of the MuCh digi parameters file if (!fGeoScheme->IsInitialized()) { - LOG(fatal) << "CbmMuchTrackingInterface::Init: MuCh digi parameters were not intialized\n" + LOG(fatal) << "CbmMuchTrackingInterface::Init: MuCh digi parameters were not initialized\n" << "\033[4;1;32mNOTE\033[0m: For the MuCh digi parameters initialization please place the following " - << "code your macro:\n" + << "code to your macro:\n" << "\n\t// ----- MuCh digi parameters initialization --------------------------------------" << "\n\tif (CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch)) {" << "\n\t // Parameter file name" diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index bbd90eb1ab..00220d4a86 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -74,28 +74,31 @@ using std::ios; #include "KFTopoPerformance.h" -ClassImp(CbmL1) +ClassImp(CbmL1); - static L1Algo algo_static _fvecalignment; // TODO: gAlgo +static L1Algo gAlgo _fvecalignment; // TODO: gAlgo //L1AlgoInputData* fData_static _fvecalignment; -CbmL1* CbmL1::fInstance = 0; +CbmL1* CbmL1::fpInstance = 0; +// --------------------------------------------------------------------------------------------------------------------- +// CbmL1::CbmL1() : CbmL1("L1") {} - -CbmL1::CbmL1(const char* name, Int_t iVerbose, Int_t _fPerformance, int fSTAPDataMode_, TString fSTAPDataDir_, - int findParticleMode_) - : FairTask(name, iVerbose) - , fPerformance(_fPerformance) - , fSTAPDataMode(fSTAPDataMode_) - , fSTAPDataDir(fSTAPDataDir_) - , fFindParticlesMode(findParticleMode_) +// --------------------------------------------------------------------------------------------------------------------- +// +CbmL1::CbmL1(const char* name, Int_t verbose, Int_t performance, int dataMode, const TString& dataDir, + int findParticleMode) + : FairTask(name, verbose) + , fPerformance(performance) + , fSTAPDataMode(dataMode) + , fSTAPDataDir(dataDir) + , fFindParticlesMode(findParticleMode) { - if (!fInstance) fInstance = this; - if (!fpInitManager) { fpInitManager = algo_static.GetInitManager(); } + if (!fpInstance) fpInstance = this; + if (!fpInitManager) { fpInitManager = gAlgo.GetInitManager(); } if (!CbmTrackingDetectorInterfaceInit::Instance()) { LOG(fatal) << "CbmL1: CbmTrackingDetectorInterfaceInit instance was not found. Please, add it as a task to your " @@ -104,11 +107,15 @@ CbmL1::CbmL1(const char* name, Int_t iVerbose, Int_t _fPerformance, int fSTAPDat } } +// --------------------------------------------------------------------------------------------------------------------- +// CbmL1::~CbmL1() { - if (fInstance == this) fInstance = nullptr; + if (fpInstance == this) fpInstance = nullptr; } +// --------------------------------------------------------------------------------------------------------------------- +// void CbmL1::CheckDetectorPresence() { fUseMVD = fUseMVD && CbmSetup::Instance()->IsActive(ECbmModuleId::kMvd); @@ -118,19 +125,20 @@ void CbmL1::CheckDetectorPresence() fUseTOF = fUseTOF && CbmSetup::Instance()->IsActive(ECbmModuleId::kTof); } - -void CbmL1::SetParContainers() {} - +// --------------------------------------------------------------------------------------------------------------------- +// InitStatus CbmL1::ReInit() { SetParContainers(); return Init(); } +// --------------------------------------------------------------------------------------------------------------------- +// InitStatus CbmL1::Init() { - fData = new L1AlgoInputData(); + fpData = new L1AlgoInputData(); if (fVerbose > 1) { char y[20] = " [0;33;44m"; // yellow @@ -164,15 +172,16 @@ InitStatus CbmL1::Init() #endif } + fpAlgo = &gAlgo; fHistoDir = gROOT->mkdir("L1"); // turn on reconstruction in sub-detectors - fUseMVD = 1; - fUseSTS = 1; - fUseMUCH = 0; - fUseTRD = 0; - fUseTOF = 0; + fUseMVD = true; + fUseSTS = true; + fUseMUCH = false; + fUseTRD = false; + fUseTOF = false; FairRootManager* fairManager = FairRootManager::Instance(); { @@ -207,21 +216,21 @@ InitStatus CbmL1::Init() CheckDetectorPresence(); - fStsPoints = 0; - fMvdPoints = 0; - fMuchPoints = 0; - fTrdPoints = 0; - fTofPoints = 0; - fMCTracks = 0; + fpStsPoints = 0; + fpMvdPoints = 0; + fpMuchPoints = 0; + fpTrdPoints = 0; + fpTofPoints = 0; + fpMCTracks = 0; - listMvdHitMatches = 0; - fTrdHitMatches = 0; - listMuchHitMatches = 0; - fTofHitDigiMatches = 0; + fpMvdHitMatches = 0; + fpTrdHitMatches = 0; + fpMuchHitMatches = 0; + fpTofHitMatches = 0; - listStsClusters = 0; + fpStsClusters = 0; - vFileEvent.clear(); + fvFileEvent.clear(); if (!fLegacyEventMode) { // Time-slice mode selected LOG(info) << GetName() << ": running in time-slice mode."; @@ -235,119 +244,115 @@ InitStatus CbmL1::Init() LOG(info) << GetName() << ": running in event mode."; - listStsClusters = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsCluster")); - listStsHitMatch = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsHitMatch")); - listStsClusterMatch = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsClusterMatch")); + fpStsClusters = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsCluster")); + fpStsHitMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsHitMatch")); + fpStsClusterMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsClusterMatch")); - listStsHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsHit")); + fpStsHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("StsHit")); if (!fUseMUCH) { - fMuchPixelHits = 0; - - fDigisMuch = 0; - fDigiMatchesMuch = 0; - fClustersMuch = 0; - - fMuchPoints = 0; - listMuchHitMatches = 0; + fpMuchPixelHits = nullptr; + fpMuchDigis = nullptr; // NOTE: Used only with fPerformance = true + fpMuchDigiMatches = nullptr; // NOTE: Used only with fPerformance = true + fpMuchClusters = nullptr; // NOTE: Used only with fPerformance = true + fpMuchPoints = nullptr; // NOTE: Used only with fPerformance = true + fpMuchHitMatches = nullptr; // NOTE: Used only with fPerformance = true } else { - fMuchPixelHits = (TClonesArray*) fairManager->GetObject("MuchPixelHit"); + fpMuchPixelHits = (TClonesArray*) fairManager->GetObject("MuchPixelHit"); } if (!fUseTRD) { - fTrdPoints = 0; - fTrdHitMatches = 0; - listTrdHits = 0; + fpTrdPoints = nullptr; + fpTrdHitMatches = nullptr; + fpTrdHits = nullptr; } else { - listTrdHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("TrdHit")); + fpTrdHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("TrdHit")); } if (!fUseTOF) { - fTofPoints = 0; - fTofHitDigiMatches = 0; - fTofHits = 0; + fpTofPoints = nullptr; + fpTofHitMatches = nullptr; + fpTofHits = nullptr; } else { - fTofHits = (TClonesArray*) fairManager->GetObject("TofHit"); + fpTofHits = (TClonesArray*) fairManager->GetObject("TofHit"); } if (fPerformance) { CbmMCDataManager* mcManager = (CbmMCDataManager*) fairManager->GetObject("MCDataManager"); - if (NULL == mcManager) LOG(fatal) << GetName() << ": No CbmMCDataManager!"; + if (nullptr == mcManager) LOG(fatal) << GetName() << ": No CbmMCDataManager!"; - fMcEventHeader = mcManager->GetObject("MCEventHeader."); + fpMcEventHeader = mcManager->GetObject("MCEventHeader."); - fMCTracks = mcManager->InitBranch("MCTrack"); + fpMCTracks = mcManager->InitBranch("MCTrack"); - if (NULL == fMCTracks) LOG(fatal) << GetName() << ": No MCTrack data!"; - if (NULL == fMcEventHeader) LOG(fatal) << GetName() << ": No MC event header data!"; + if (nullptr == fpMCTracks) LOG(fatal) << GetName() << ": No MCTrack data!"; + if (nullptr == fpMcEventHeader) LOG(fatal) << GetName() << ": No MC event header data!"; if (!fLegacyEventMode) { - fEventList = (CbmMCEventList*) fairManager->GetObject("MCEventList."); - if (NULL == fEventList) LOG(fatal) << GetName() << ": No MCEventList data!"; + fpEventList = (CbmMCEventList*) fairManager->GetObject("MCEventList."); + if (nullptr == fpEventList) LOG(fatal) << GetName() << ": No MCEventList data!"; } if (fUseMVD) { - fMvdPoints = mcManager->InitBranch("MvdPoint"); - listMvdDigiMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdDigiMatch")); - listMvdHitMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdHitMatch")); - if (!listMvdHitMatches) { LOG(error) << "No listMvdHitMatches provided, performance is not done correctly"; } + fpMvdPoints = mcManager->InitBranch("MvdPoint"); + fpMvdDigiMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdDigiMatch")); + fpMvdHitMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdHitMatch")); + if (!fpMvdHitMatches) { LOG(error) << "No fpMvdHitMatches provided, performance is not done correctly"; } } if (fUseSTS) { - fStsPoints = mcManager->InitBranch("StsPoint"); - if (NULL == fStsPoints) LOG(fatal) << GetName() << ": No StsPoint data!"; + fpStsPoints = mcManager->InitBranch("StsPoint"); + if (nullptr == fpStsPoints) LOG(fatal) << GetName() << ": No StsPoint data!"; } if (!fUseTRD) { - fTrdPoints = 0; - fTrdHitMatches = 0; + fpTrdPoints = 0; + fpTrdHitMatches = 0; } else { - fTrdHitMatches = (TClonesArray*) fairManager->GetObject("TrdHitMatch"); - fTrdPoints = mcManager->InitBranch("TrdPoint"); + fpTrdHitMatches = (TClonesArray*) fairManager->GetObject("TrdHitMatch"); + fpTrdPoints = mcManager->InitBranch("TrdPoint"); } if (!fUseMUCH) { - fMuchPoints = 0; - listMuchHitMatches = 0; + fpMuchPoints = 0; + fpMuchHitMatches = 0; } else { - fDigisMuch = (TClonesArray*) fairManager->GetObject("MuchDigi"); - fDigiMatchesMuch = (TClonesArray*) fairManager->GetObject("MuchDigiMatch"); - fClustersMuch = (TClonesArray*) fairManager->GetObject("MuchCluster"); - fMuchPoints = mcManager->InitBranch("MuchPoint"); - listMuchHitMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MuchPixelHitMatch")); + fpMuchDigis = (TClonesArray*) fairManager->GetObject("MuchDigi"); + fpMuchDigiMatches = (TClonesArray*) fairManager->GetObject("MuchDigiMatch"); + fpMuchClusters = (TClonesArray*) fairManager->GetObject("MuchCluster"); + fpMuchPoints = mcManager->InitBranch("MuchPoint"); + fpMuchHitMatches = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MuchPixelHitMatch")); } if (!fUseTOF) { - fTofPoints = 0; - fTofHitDigiMatches = 0; + fpTofPoints = 0; + fpTofHitMatches = 0; } else { - fTofPoints = mcManager->InitBranch("TofPoint"); - fTofHitDigiMatches = static_cast<TClonesArray*>(fairManager->GetObject("TofHitMatch")); + fpTofPoints = mcManager->InitBranch("TofPoint"); + fpTofHitMatches = static_cast<TClonesArray*>(fairManager->GetObject("TofHitMatch")); } } else { } - if (!fUseMVD) { listMvdHits = 0; } + if (!fUseMVD) { fpMvdHits = 0; } else { - listMvdHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdHit")); + fpMvdHits = L1_DYNAMIC_CAST<TClonesArray*>(fairManager->GetObject("MvdHit")); } - NMvdStationsGeom = 0; - NStsStationsGeom = 0; - NMuchStationsGeom = 0; - NTrdStationsGeom = 0; - NTOFStationGeom = 0; - NStationGeom = 0; + fNMvdStationsGeom = 0; + fNStsStationsGeom = 0; + fNMuchStationsGeom = 0; + fNTrdStationsGeom = 0; + fNTofStationsGeom = 0; + fNStationsGeom = 0; - // TODO: Replace algo initialization in the constructor (S.Zharko) - algo = &algo_static; /************************** ** Field initialization ** @@ -381,14 +386,14 @@ InitStatus CbmL1::Init() ** Active tracking detector subsystems selection ** ***************************************************/ - fActiveTrackingDetectorIDs.clear(); + std::set<L1DetectorID> vActiveTrackingDetectorIDs {}; // Set of detectors active in tracking - if (fUseMVD) { fActiveTrackingDetectorIDs.insert(L1DetectorID::kMvd); } - if (fUseSTS) { fActiveTrackingDetectorIDs.insert(L1DetectorID::kSts); } - if (fUseMUCH) { fActiveTrackingDetectorIDs.insert(L1DetectorID::kMuch); } - if (fUseTRD) { fActiveTrackingDetectorIDs.insert(L1DetectorID::kTrd); } - if (fUseTOF) { fActiveTrackingDetectorIDs.insert(L1DetectorID::kTof); } - fpInitManager->SetActiveDetectorIDs(fActiveTrackingDetectorIDs); + if (fUseMVD) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kMvd); } + if (fUseSTS) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kSts); } + if (fUseMUCH) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kMuch); } + if (fUseTRD) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kTrd); } + if (fUseTOF) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kTof); } + fpInitManager->SetActiveDetectorIDs(vActiveTrackingDetectorIDs); /********************************************************************* ** Counting numbers of stations for different detector subsystems ** @@ -405,19 +410,19 @@ InitStatus CbmL1::Init() // indeces of hits in TOF if (fMissingHits) { tofInterface->FixHitsStationsMismatch(); } - NMvdStationsGeom = (fUseMVD) ? mvdInterface->GetNtrackingStations() : 0; - NStsStationsGeom = (fUseSTS) ? stsInterface->GetNtrackingStations() : 0; - NMuchStationsGeom = (fUseMUCH) ? muchInterface->GetNtrackingStations() : 0; - NTrdStationsGeom = (fUseTRD) ? trdInterface->GetNtrackingStations() : 0; - NTOFStationGeom = (fUseTOF) ? tofInterface->GetNtrackingStations() : 0; - NStationGeom = NMvdStationsGeom + NStsStationsGeom + NMuchStationsGeom + NTrdStationsGeom + NTOFStationGeom; + fNMvdStationsGeom = (fUseMVD) ? mvdInterface->GetNtrackingStations() : 0; + fNStsStationsGeom = (fUseSTS) ? stsInterface->GetNtrackingStations() : 0; + fNMuchStationsGeom = (fUseMUCH) ? muchInterface->GetNtrackingStations() : 0; + fNTrdStationsGeom = (fUseTRD) ? trdInterface->GetNtrackingStations() : 0; + fNTofStationsGeom = (fUseTOF) ? tofInterface->GetNtrackingStations() : 0; + fNStationsGeom = fNMvdStationsGeom + fNStsStationsGeom + fNMuchStationsGeom + fNTrdStationsGeom + fNTofStationsGeom; - // Provide crosscheck number of stations for the fpInitManager - fpInitManager->SetNstations(L1DetectorID::kMvd, NMvdStationsGeom); - fpInitManager->SetNstations(L1DetectorID::kSts, NStsStationsGeom); - fpInitManager->SetNstations(L1DetectorID::kMuch, NMuchStationsGeom); - fpInitManager->SetNstations(L1DetectorID::kTrd, NTrdStationsGeom); - fpInitManager->SetNstations(L1DetectorID::kTof, NTOFStationGeom); + // Provide crosscheck number of stations for the fpInitManagera + fpInitManager->SetNstations(L1DetectorID::kMvd, fNMvdStationsGeom); + fpInitManager->SetNstations(L1DetectorID::kSts, fNStsStationsGeom); + fpInitManager->SetNstations(L1DetectorID::kMuch, fNMuchStationsGeom); + fpInitManager->SetNstations(L1DetectorID::kTrd, fNTrdStationsGeom); + fpInitManager->SetNstations(L1DetectorID::kTof, fNTofStationsGeom); { if (fSTAPDataMode % 2 == 1) { // 1,3 @@ -478,7 +483,7 @@ InitStatus CbmL1::Init() /*** MVD stations info ***/ if (fUseMVD) { - for (int iSt = 0; iSt < NMvdStationsGeom; ++iSt) { + for (int iSt = 0; iSt < fNMvdStationsGeom; ++iSt) { auto stationInfo = L1BaseStationInfo(L1DetectorID::kMvd, iSt); stationInfo.SetStationType(1); // MVD stationInfo.SetTimeInfo(mvdInterface->IsTimeInfoProvided(iSt)); @@ -503,7 +508,7 @@ InitStatus CbmL1::Init() /*** STS stations info ***/ if (fUseSTS) { - for (int iSt = 0; iSt < NStsStationsGeom; ++iSt) { + for (int iSt = 0; iSt < fNStsStationsGeom; ++iSt) { auto stationInfo = L1BaseStationInfo(L1DetectorID::kSts, iSt); stationInfo.SetStationType(0); // STS stationInfo.SetTimeInfo(stsInterface->IsTimeInfoProvided(iSt)); @@ -528,7 +533,7 @@ InitStatus CbmL1::Init() /*** MuCh stations info ***/ if (fUseMUCH) { - for (int iSt = 0; iSt < NMuchStationsGeom; ++iSt) { + for (int iSt = 0; iSt < fNMuchStationsGeom; ++iSt) { auto stationInfo = L1BaseStationInfo(L1DetectorID::kMuch, iSt); stationInfo.SetStationType(2); // MuCh stationInfo.SetTimeInfo(muchInterface->IsTimeInfoProvided(iSt)); @@ -553,7 +558,7 @@ InitStatus CbmL1::Init() /*** TRD stations info ***/ if (fUseTRD) { - for (int iSt = 0; iSt < NTrdStationsGeom; ++iSt) { + for (int iSt = 0; iSt < fNTrdStationsGeom; ++iSt) { auto stationInfo = L1BaseStationInfo(L1DetectorID::kTrd, iSt); stationInfo.SetStationType((iSt == 1 || iSt == 3) ? 6 : 3); // MuCh stationInfo.SetTimeInfo(trdInterface->IsTimeInfoProvided(iSt)); @@ -588,7 +593,7 @@ InitStatus CbmL1::Init() /*** TOF stations info ***/ if (fUseTOF) { - for (int iSt = 0; iSt < NTOFStationGeom; ++iSt) { + for (int iSt = 0; iSt < fNTofStationsGeom; ++iSt) { auto stationInfo = L1BaseStationInfo(L1DetectorID::kTof, iSt); stationInfo.SetStationType(4); stationInfo.SetTimeInfo(tofInterface->IsTimeInfoProvided(iSt)); @@ -836,43 +841,34 @@ InitStatus CbmL1::Init() /**********************/ - algo->Init(fUseHitErrors, fTrackingMode, fMissingHits); + fpAlgo->Init(fUseHitErrors, fTrackingMode, fMissingHits); /*** Get numbers of active stations ***/ - NMvdStations = fpInitManager->GetNstationsActive(L1DetectorID::kMvd); - NStsStations = fpInitManager->GetNstationsActive(L1DetectorID::kSts); - NTrdStations = fpInitManager->GetNstationsActive(L1DetectorID::kTrd); - NMuchStations = fpInitManager->GetNstationsActive(L1DetectorID::kMuch); - NTOFStation = fpInitManager->GetNstationsActive(L1DetectorID::kTof); - NStation = fpInitManager->GetNstationsActive(); + fNMvdStations = fpInitManager->GetNstationsActive(L1DetectorID::kMvd); + fNStsStations = fpInitManager->GetNstationsActive(L1DetectorID::kSts); + fNTrdStations = fpInitManager->GetNstationsActive(L1DetectorID::kTrd); + fNMuchStations = fpInitManager->GetNstationsActive(L1DetectorID::kMuch); + fNTofStations = fpInitManager->GetNstationsActive(L1DetectorID::kTof); + fNStations = fpInitManager->GetNstationsActive(); LOG(info) << "----- Numbers of stations active in tracking -----"; - LOG(info) << " MVD: " << NMvdStations; - LOG(info) << " STS: " << NStsStations; - LOG(info) << " MuCh: " << NMuchStations; - LOG(info) << " TRD: " << NTrdStations; - LOG(info) << " ToF: " << NTOFStation; - LOG(info) << " Total: " << NStation; + LOG(info) << " MVD: " << fNMvdStations; + LOG(info) << " STS: " << fNStsStations; + LOG(info) << " MuCh: " << fNMuchStations; + LOG(info) << " TRD: " << fNTrdStations; + LOG(info) << " ToF: " << fNTofStations; + LOG(info) << " Total: " << fNStations; return kSUCCESS; } -void CbmL1::Exec(Option_t* /*option*/) {} - void CbmL1::Reconstruct(CbmEvent* event) { static int nevent = 0; - vFileEvent.clear(); - int nStsHits = 0; - if (fUseSTS && listStsHits) { nStsHits = listStsHits->GetEntriesFast(); } - - L1Vector<std::pair<double, int>> SortHits("CbmL1::SortHits"); - SortHits.reserve(nStsHits); - - float start_t = 10000000000; + fvFileEvent.clear(); // TODO: move these values to CbmL1Parameters namespace (S.Zharko) bool areDataLeft = true; // whole TS processed? @@ -881,38 +877,44 @@ void CbmL1::Reconstruct(CbmEvent* event) float TsOverlap = 15; // min length of overlap region int FstHitinTs = 0; // 1st hit index in TS + + // TODO: Refactor this part, check usage --------------------------------- + int nStsHits = (fUseSTS && fpStsHits ? fpStsHits->GetEntriesFast() : 0); + /// sort input hits by time + L1Vector<std::pair<double, int>> SortHits("CbmL1::SortHits"); + SortHits.reserve(nStsHits); + float start_t = 10000000000; for (Int_t j = 0; j < nStsHits; j++) { - CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(j)); + CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(j)); double t = sh->GetTime(); if (t < start_t) start_t = t; SortHits.push_back(std::pair<double, int>(t, j)); } - TsStart = start_t; ///reco TS start time is set to smallest hit time std::sort(SortHits.begin(), SortHits.end()); - StsIndex.clear(); - StsIndex.reserve(SortHits.size()); + fvSortedStsHitsIndexes.clear(); + fvSortedStsHitsIndexes.reserve(SortHits.size()); for (unsigned int i = 0; i < SortHits.size(); i++) { int j = SortHits[i].second; - StsIndex.push_back(j); + fvSortedStsHitsIndexes.push_back(j); }; - + // ----------------------------------------------------------------------- if (!fLegacyEventMode && fPerformance) { - int nofEvents = fEventList->GetNofEvents(); + int nofEvents = fpEventList->GetNofEvents(); for (int iE = 0; iE < nofEvents; iE++) { - int fileId = fEventList->GetFileIdByIndex(iE); - int eventId = fEventList->GetEventIdByIndex(iE); - vFileEvent.insert(DFSET::value_type(fileId, eventId)); + int fileId = fpEventList->GetFileIdByIndex(iE); + int eventId = fpEventList->GetEventIdByIndex(iE); + fvFileEvent.insert(DFSET::value_type(fileId, eventId)); } } else { Int_t iFile = FairRunAna::Instance()->GetEventHeader()->GetInputFileId(); Int_t iEvent = FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber(); - vFileEvent.insert(DFSET::value_type(iFile, iEvent)); + fvFileEvent.insert(DFSET::value_type(iFile, iEvent)); } if (fVerbose > 1) { cout << "\nCbmL1::Exec event " << ++nevent << " ...\n\n"; } @@ -921,17 +923,18 @@ void CbmL1::Reconstruct(CbmEvent* event) #endif // repack data - L1Vector<CbmL1Track> vRTracksCur("CbmL1::vRTracksCur"); // reconstructed tracks + L1Vector<CbmL1Track> vRTracksCur("CbmL1::vRTracksCur"); + // FIXME: Update the following code block in order to account for MuCh, TRD and TOF (S.Zharko) { int nHits = 0; int nSta = 1; - if (fUseMVD && listMvdHits) { - nHits += listMvdHits->GetEntriesFast(); - nSta += NMvdStations; + if (fUseMVD && fpMvdHits) { + nHits += fpMvdHits->GetEntriesFast(); + nSta += fNMvdStations; } - if (fUseSTS && listStsHits) { - nHits += listStsHits->GetEntriesFast(); - nSta += NStsStations; + if (fUseSTS && fpStsHits) { + nHits += fpStsHits->GetEntriesFast(); + nSta += fNStsStations; } vRTracksCur.reserve(10 + (2 * nHits) / nSta); } @@ -940,58 +943,60 @@ void CbmL1::Reconstruct(CbmEvent* event) while (areDataLeft) { - fData->Clear(); + fpData->Clear(); if (event) { - fData->fStripFlag.clear(); + fpData->fStripFlag.clear(); areDataLeft = false; TsStart = 0; - TsLength = 2000000000; + TsLength = 2000000000; // TODO: Why this number was selected? (S.Zharko) TsOverlap = 0; FstHitinTs = 0; } if (fSTAPDataMode >= 2) { // 2,3 - fData->ReadHitsFromFile(fSTAPDataDir.Data(), 1, fVerbose); + fpData->ReadHitsFromFile(fSTAPDataDir.Data(), 1, fVerbose); - algo->SetData(fData->GetHits(), fData->GetNstrips(), fData->GetSFlag(), fData->GetHitsStartIndex(), - fData->GetHitsStopIndex()); + fpAlgo->SetData(fpData->GetHits(), fpData->GetNstrips(), fpData->GetSFlag(), fpData->GetHitsStartIndex(), + fpData->GetHitsStopIndex()); } else { - ReadEvent(fData, TsStart, TsLength, TsOverlap, FstHitinTs, areDataLeft, event); + ReadEvent(fpData, TsStart, TsLength, TsOverlap, FstHitinTs, areDataLeft, event); } + + // ******************************************************************************************** if constexpr (0) { // correct hits on MC // dbg TRandom3 random; L1Vector<int> strips("CbmL1::strips"); - for (unsigned int iH = 0; iH < (*algo->vHits).size(); ++iH) { - L1Hit& h = const_cast<L1Hit&>((*algo->vHits)[iH]); + 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 (vHits[iH].mcPointIds.size() == 0) continue; + if (fvExternalHits[iH].mcPointIds.size() == 0) continue; - const CbmL1MCPoint& mcp = vMCPoints[vHits[iH].mcPointIds[0]]; + const CbmL1MCPoint& mcp = fvMCPoints[fvExternalHits[iH].mcPointIds[0]]; #ifdef USE_EVENT_NUMBER h.n = mcp.event; #endif - const int ista = (*algo->fStripFlag)[h.f] / 4; - const L1Station& sta = algo->GetParameters()->GetStation(ista); + const int ista = (*fpAlgo->fStripFlag)[h.f] / 4; + const L1Station& sta = fpAlgo->GetParameters()->GetStation(ista); if (std::find(strips.begin(), strips.end(), h.f) != strips.end()) { // separate strips - (*algo->fStripFlag).push_back((*algo->fStripFlag)[h.f]); + (*fpAlgo->fStripFlag).push_back((*fpAlgo->fStripFlag)[h.f]); - h.f = algo->fNstrips; - algo->fNstrips++; + h.f = fpAlgo->fNstrips; + fpAlgo->fNstrips++; } strips.push_back(h.f); if (std::find(strips.begin(), strips.end(), h.b) != strips.end()) { - (*algo->fStripFlag).push_back((*algo->fStripFlag)[h.b]); - h.b = algo->fNstrips; - algo->fNstrips++; + (*fpAlgo->fStripFlag).push_back((*fpAlgo->fStripFlag)[h.b]); + h.b = fpAlgo->fNstrips; + fpAlgo->fNstrips++; } strips.push_back(h.b); @@ -1010,11 +1015,12 @@ void CbmL1::Reconstruct(CbmEvent* event) h.z = mcp.z; } } + // ******************************************************************************************** if (fPerformance) { HitMatch(); // calculate the max number of Hits\mcPoints on continuous(consecutive) stations - for (auto it = vMCTracks.begin(); it != vMCTracks.end(); ++it) { + for (auto it = fvMCTracks.begin(); it != fvMCTracks.end(); ++it) { it->Init(); } } @@ -1034,38 +1040,39 @@ void CbmL1::Reconstruct(CbmEvent* event) // FieldApproxCheck(); // FieldIntegralCheck(); - for (unsigned int iH = 0; iH < (*algo->vHits).size(); ++iH) { + // TODO: Remove code below (S.Zharko) + for (unsigned int iH = 0; iH < (*fpAlgo->vHits).size(); ++iH) { #ifdef USE_EVENT_NUMBER - L1Hit& h = const_cast<L1Hit&>((*algo->vHits)[iH]); + L1Hit& h = const_cast<L1Hit&>((*fpAlgo->vHits)[iH]); h.n = -1; #endif - if (vHits[iH].mcPointIds.size() == 0) continue; + if (fvExternalHits[iH].mcPointIds.size() == 0) continue; #ifdef USE_EVENT_NUMBER - const CbmL1MCPoint& mcp = vMCPoints[vHits[iH].mcPointIds[0]]; + const CbmL1MCPoint& mcp = fvMCPoints[fvExternalHits[iH].mcPointIds[0]]; h.n = mcp.event; #endif } if (fVerbose > 1) { cout << "L1 Track finder..." << endl; } - algo->CATrackFinder(); + fpAlgo->CATrackFinder(); // IdealTrackFinder(); - fTrackingTime += algo->fCATime; + fTrackingTime += fpAlgo->fCATime; if (fVerbose > 1) { cout << "L1 Track finder ok" << endl; } - // algo->L1KFTrackFitter( fExtrapolateToTheEndOfSTS ); + // fpAlgo->L1KFTrackFitter( fExtrapolateToTheEndOfSTS ); { // track fit - L1FieldValue b = algo->GetParameters()->GetVertexFieldValue(); + L1FieldValue b = fpAlgo->GetParameters()->GetVertexFieldValue(); if ((fabs(b.x[0]) < 0.0000001) && (fabs(b.y[0]) < 0.0000001) && (fabs(b.z[0]) < 0.0000001)) { - algo->KFTrackFitter_simple(); + fpAlgo->KFTrackFitter_simple(); } else { if (L1Algo::TrackingMode::kGlobal == fTrackingMode || L1Algo::TrackingMode::kMcbm == fTrackingMode) { - algo->L1KFTrackFitterMuch(); + fpAlgo->L1KFTrackFitterMuch(); } else { - algo->L1KFTrackFitter(); + fpAlgo->L1KFTrackFitter(); } } } @@ -1078,7 +1085,7 @@ void CbmL1::Reconstruct(CbmEvent* event) float TsStart_new = TsStart + TsLength - TsOverlap; - for (L1Vector<L1Track>::iterator it = algo->fTracks.begin(); it != algo->fTracks.end(); it++) { + for (L1Vector<L1Track>::iterator it = fpAlgo->fTracks.begin(); it != fpAlgo->fTracks.end(); it++) { CbmL1Track t; for (int i = 0; i < 7; i++) @@ -1104,17 +1111,17 @@ void CbmL1::Reconstruct(CbmEvent* event) for (int i = 0; i < it->NHits; i++) { int start_hit1 = start_hit; - if (algo->fRecoHits[start_hit1] > vHits.size() - 1) start_hit++; + if (fpAlgo->fRecoHits[start_hit1] > fvExternalHits.size() - 1) start_hit++; else if (!fLegacyEventMode) { - t.Hits.push_back(((*algo->vHits)[algo->fRecoHits[start_hit]]).ID); + t.Hits.push_back(((*fpAlgo->vHits)[fpAlgo->fRecoHits[start_hit]]).ID); } else { - t.Hits.push_back(algo->fRecoHits[start_hit]); + t.Hits.push_back(fpAlgo->fRecoHits[start_hit]); } - HitsLocal.push_back(algo->fRecoHits[start_hit++]); + HitsLocal.push_back(fpAlgo->fRecoHits[start_hit++]); } - t.mass = algo->fDefaultMass; // pion mass + t.mass = fpAlgo->fDefaultMass; // pion mass t.is_electron = 0; t.SetId(vRTracksCur.size()); @@ -1125,21 +1132,21 @@ void CbmL1::Reconstruct(CbmEvent* event) for (unsigned int i = 0; i < HitsLocal.size(); i++) { - // if ((*ih) > int(vHits.size() - 1)) { + // if ((*ih) > int(fvExternalHits.size() - 1)) { // indd = 1; // break; // } - if (vHits[HitsLocal[i]].t >= (TsStart + TsLength - TsOverlap)) { + if (fvExternalHits[HitsLocal[i]].t >= (TsStart + TsLength - TsOverlap)) { isInOverlap = 1; - if (TsStart_new > vHits[HitsLocal[i]].t) TsStart_new = vHits[HitsLocal[i]].t; + if (TsStart_new > fvExternalHits[HitsLocal[i]].t) TsStart_new = fvExternalHits[HitsLocal[i]].t; } - int nMCPoints = vHits[HitsLocal[i]].mcPointIds.size(); + int nMCPoints = fvExternalHits[HitsLocal[i]].mcPointIds.size(); for (int iP = 0; iP < nMCPoints; iP++) { - int iMC = vHits[HitsLocal[i]].mcPointIds[iP]; - if (iMC > int(vMCPoints.size() - 1)) { - // cout << " iMC " << iMC << " vMCPoints.size() " << vMCPoints.size() << endl; + int iMC = fvExternalHits[HitsLocal[i]].mcPointIds[iP]; + if (iMC > int(fvMCPoints.size() - 1)) { + // cout << " iMC " << iMC << " fvMCPoints.size() " << fvMCPoints.size() << endl; indd = 1; } } @@ -1153,27 +1160,27 @@ void CbmL1::Reconstruct(CbmEvent* event) /// set strips as unused for (unsigned int i = 0; i < HitsLocal.size(); i++) { - algo->SetFUnUsed(const_cast<unsigned char&>((*algo->fStripFlag)[vHits[HitsLocal[i]].f])); - algo->SetFUnUsed(const_cast<unsigned char&>((*algo->fStripFlag)[vHits[HitsLocal[i]].b])); + fpAlgo->SetFUnUsed(const_cast<unsigned char&>((*fpAlgo->fStripFlag)[fvExternalHits[HitsLocal[i]].f])); + fpAlgo->SetFUnUsed(const_cast<unsigned char&>((*fpAlgo->fStripFlag)[fvExternalHits[HitsLocal[i]].b])); } } vRTracksCur.push_back(t); } - for (int i = 0; i < nStsHits; i++) { + for (int i = 0; i < nStsHits; ++i) { - CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(StsIndex[i])); + CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(fvSortedStsHitsIndexes[i])); float time = sh->GetTime(); if (TsStart_new <= time) { - FstHitinTs = i; + FstHitinTs = i; // TODO: shouldn't it be in the fLegacyEventMode == true only? (S.Zharko) break; } } if (!fLegacyEventMode) TsStart = TsStart_new; ///Set new TS strat to earliest discarted track - if (!fLegacyEventMode) cout << "CA Track Finder: " << algo->fCATime << " s/sub-ts" << endl << endl; + if (!fLegacyEventMode) cout << "CA Track Finder: " << fpAlgo->fCATime << " s/sub-ts" << endl << endl; } @@ -1184,11 +1191,11 @@ void CbmL1::Reconstruct(CbmEvent* event) int fHit = 0; bool stop = 0; - ReadEvent(fData, start, end, start, fHit, stop, event); + ReadEvent(fpData, start, end, start, fHit, stop, event); HitMatch(); // calculate the max number of Hits\mcPoints on continuous(consecutive) stations - for (L1Vector<CbmL1MCTrack>::iterator it = vMCTracks.begin(); it != vMCTracks.end(); ++it) + for (L1Vector<CbmL1MCTrack>::iterator it = fvMCTracks.begin(); it != fvMCTracks.end(); ++it) it->Init(); } // @@ -1202,28 +1209,28 @@ void CbmL1::Reconstruct(CbmEvent* event) // ReadSTAPPerfData(); // }; - vRTracks.clear(); - vRTracks.reserve(vRTracksCur.size()); + fvRecoTracks.clear(); + fvRecoTracks.reserve(vRTracksCur.size()); for (unsigned int iTrack = 0; iTrack < vRTracksCur.size(); iTrack++) { for (unsigned int iHit = 0; iHit < vRTracksCur[iTrack].Hits.size(); iHit++) - if (!fLegacyEventMode) vRTracksCur[iTrack].Hits[iHit] = SortedIndex[vRTracksCur[iTrack].Hits[iHit]]; + if (!fLegacyEventMode) { vRTracksCur[iTrack].Hits[iHit] = fvSortedHitsIndexes[vRTracksCur[iTrack].Hits[iHit]]; } - vRTracks.push_back(vRTracksCur[iTrack]); + fvRecoTracks.push_back(vRTracksCur[iTrack]); } if ((fPerformance) && (fSTAPDataMode < 2)) { InputPerformance(); } - for (unsigned int iH = 0; iH < (*algo->vHits).size(); ++iH) { + for (unsigned int iH = 0; iH < (*fpAlgo->vHits).size(); ++iH) { #ifdef USE_EVENT_NUMBER - L1Hit& h = const_cast<L1Hit&>((*algo->vHits)[iH]); + L1Hit& h = const_cast<L1Hit&>((*fpAlgo->vHits)[iH]); h.n = -1; #endif - if (vHits[iH].mcPointIds.size() == 0) continue; + if (fvExternalHits[iH].mcPointIds.size() == 0) continue; #ifdef USE_EVENT_NUMBER - const CbmL1MCPoint& mcp = vMCPoints[vHits[iH].mcPointIds[0]]; + const CbmL1MCPoint& mcp = fvMCPoints[fvExternalHits[iH].mcPointIds[0]]; h.n = mcp.event; #endif } @@ -1302,10 +1309,10 @@ void CbmL1::writedir2current(TObject* obj) void CbmL1::IdealTrackFinder() { - algo->fTracks.clear(); - algo->fRecoHits.clear(); + fpAlgo->fTracks.clear(); + fpAlgo->fRecoHits.clear(); - for (L1Vector<CbmL1MCTrack>::iterator i = vMCTracks.begin(); i != vMCTracks.end(); ++i) { + for (L1Vector<CbmL1MCTrack>::iterator i = fvMCTracks.begin(); i != fvMCTracks.end(); ++i) { CbmL1MCTrack& MC = *i; if (!MC.IsReconstructable()) continue; @@ -1316,33 +1323,33 @@ void CbmL1::IdealTrackFinder() L1Track algoTr; algoTr.NHits = 0; - L1Vector<int> hitIndices("CbmL1::hitIndices", algo->GetNstations(), -1); + L1Vector<int> hitIndices("CbmL1::hitIndices", fpAlgo->GetNstations(), -1); for (unsigned int iH = 0; iH < MC.Hits.size(); iH++) { const int hitI = MC.Hits[iH]; - const CbmL1Hit& hit = vHits[hitI]; + const CbmL1Hit& hit = fvExternalHits[hitI]; - const int iStation = vMCPoints[hit.mcPointIds[0]].iStation; + const int iStation = fvMCPoints[hit.mcPointIds[0]].iStation; if (iStation >= 0) hitIndices[iStation] = hitI; } - for (int iH = 0; iH < algo->GetNstations(); iH++) { + for (int iH = 0; iH < fpAlgo->GetNstations(); iH++) { const int hitI = hitIndices[iH]; if (hitI < 0) continue; - // algo->fRecoHits.push_back(hitI); + // fpAlgo->fRecoHits.push_back(hitI); algoTr.NHits++; } if (algoTr.NHits < 3) continue; - for (int iH = 0; iH < algo->GetNstations(); iH++) { + for (int iH = 0; iH < fpAlgo->GetNstations(); iH++) { const int hitI = hitIndices[iH]; if (hitI < 0) continue; - algo->fRecoHits.push_back(hitI); + fpAlgo->fRecoHits.push_back(hitI); } @@ -1354,7 +1361,7 @@ void CbmL1::IdealTrackFinder() algoTr.TFirst[4] = MC.q / MC.p; algoTr.TFirst[5] = MC.z; - algo->fTracks.push_back(algoTr); + fpAlgo->fTracks.push_back(algoTr); } } // void CbmL1::IdealTrackFinder() @@ -1395,18 +1402,18 @@ void CbmL1::WriteSTAPAlgoData() // must be called after ReadEvent << " "; fadata << vNEvent << endl; // write vStrips - int n = algo->fNstrips; + int n = fpAlgo->fNstrips; fadata << n << endl; if (fVerbose >= 4) { cout << "vStrips[" << n << "]" << " have been written." << endl; } // write fStripFlag - n = (*algo->fStripFlag).size(); + n = (*fpAlgo->fStripFlag).size(); fadata << n << endl; unsigned char element; for (int i = 0; i < n; i++) { - element = (*algo->fStripFlag)[i]; + element = (*fpAlgo->fStripFlag)[i]; fadata << static_cast<int>(element) << endl; }; if (fVerbose >= 4) { @@ -1418,10 +1425,10 @@ void CbmL1::WriteSTAPAlgoData() // must be called after ReadEvent << " have been written." << endl; } // write vHits - n = (*algo->vHits).size(); + n = (*fpAlgo->vHits).size(); fadata << n << endl; for (int i = 0; i < n; i++) { - const L1Hit& h = (*algo->vHits)[i]; + const L1Hit& h = (*fpAlgo->vHits)[i]; fadata << static_cast<int>(h.f) << " "; fadata << static_cast<int>(h.b) << " "; #ifdef USE_EVENT_NUMBER @@ -1430,7 +1437,7 @@ void CbmL1::WriteSTAPAlgoData() // must be called after ReadEvent fadata << h.z << " "; fadata << h.u << " "; fadata << h.v << " "; - // fadata << (*algo->vHits)[i].time << endl; + // fadata << (*fpAlgo->vHits)[i].time << endl; fadata << h.t << endl; }; if (fVerbose >= 4) { @@ -1440,13 +1447,13 @@ void CbmL1::WriteSTAPAlgoData() // must be called after ReadEvent // write HitsStartIndex and HitsStopIndex n = 20; for (int i = 0; i < n; i++) { - if (int(L1Constants::size::kMaxNstations) + 1 > i) { fadata << algo->HitsStartIndex[i] << endl; } + if (int(L1Constants::size::kMaxNstations) + 1 > i) { fadata << fpAlgo->HitsStartIndex[i] << endl; } else { fadata << 0 << endl; } }; for (int i = 0; i < n; i++) { - if (int(L1Constants::size::kMaxNstations) + 1 > i) fadata << algo->HitsStopIndex[i] << endl; + if (int(L1Constants::size::kMaxNstations) + 1 > i) fadata << fpAlgo->HitsStopIndex[i] << endl; else fadata << 0 << endl; }; @@ -1478,128 +1485,128 @@ void CbmL1::WriteSTAPPerfData() // must be called after ReadEvent fpdata << "Event: "; fpdata << vNEvent << endl; - // write vMCPoints - Int_t n = vMCPoints.size(); // number of elements + // write fvMCPoints + Int_t n = fvMCPoints.size(); // number of elements fpdata << n << endl; for (int i = 0; i < n; i++) { - fpdata << vMCPoints[i].xIn << " "; - fpdata << vMCPoints[i].yIn << " "; - fpdata << vMCPoints[i].zIn << " "; - fpdata << vMCPoints[i].pxIn << " "; - fpdata << vMCPoints[i].pyIn << " "; - fpdata << vMCPoints[i].pzIn << " " << endl; - fpdata << vMCPoints[i].xOut << " "; - fpdata << vMCPoints[i].yOut << " "; - fpdata << vMCPoints[i].zOut << " "; - fpdata << vMCPoints[i].pxOut << " "; - fpdata << vMCPoints[i].pyOut << " "; - fpdata << vMCPoints[i].pzOut << " " << endl; - - fpdata << vMCPoints[i].p << " "; - fpdata << vMCPoints[i].q << " "; - fpdata << vMCPoints[i].mass << " "; - fpdata << vMCPoints[i].time << " "; - - fpdata << vMCPoints[i].pdg << " "; - fpdata << vMCPoints[i].ID << " "; - fpdata << vMCPoints[i].mother_ID << " "; - fpdata << vMCPoints[i].iStation << endl; - - const int nhits = vMCPoints[i].hitIds.size(); + fpdata << fvMCPoints[i].xIn << " "; + fpdata << fvMCPoints[i].yIn << " "; + fpdata << fvMCPoints[i].zIn << " "; + fpdata << fvMCPoints[i].pxIn << " "; + fpdata << fvMCPoints[i].pyIn << " "; + fpdata << fvMCPoints[i].pzIn << " " << endl; + fpdata << fvMCPoints[i].xOut << " "; + fpdata << fvMCPoints[i].yOut << " "; + fpdata << fvMCPoints[i].zOut << " "; + fpdata << fvMCPoints[i].pxOut << " "; + fpdata << fvMCPoints[i].pyOut << " "; + fpdata << fvMCPoints[i].pzOut << " " << endl; + + fpdata << fvMCPoints[i].p << " "; + fpdata << fvMCPoints[i].q << " "; + fpdata << fvMCPoints[i].mass << " "; + fpdata << fvMCPoints[i].time << " "; + + fpdata << fvMCPoints[i].pdg << " "; + fpdata << fvMCPoints[i].ID << " "; + fpdata << fvMCPoints[i].mother_ID << " "; + fpdata << fvMCPoints[i].iStation << endl; + + const int nhits = fvMCPoints[i].hitIds.size(); fpdata << nhits << endl << " "; for (int k = 0; k < nhits; k++) { - fpdata << vMCPoints[i].hitIds[k] << " "; + fpdata << fvMCPoints[i].hitIds[k] << " "; }; fpdata << endl; }; if (fVerbose >= 4) { - cout << "vMCPoints[" << n << "]" + cout << "fvMCPoints[" << n << "]" << " have been written." << endl; } - // write vMCTracks . without Points - n = vMCTracks.size(); // number of elements + // write fvMCTracks . without Points + n = fvMCTracks.size(); // number of elements fpdata << n << endl; for (int i = 0; i < n; i++) { - fpdata << vMCTracks[i].x << " "; - fpdata << vMCTracks[i].y << " "; - fpdata << vMCTracks[i].z << " "; - fpdata << vMCTracks[i].px << " "; - fpdata << vMCTracks[i].py << " "; - fpdata << vMCTracks[i].pz << " "; - fpdata << vMCTracks[i].p << " "; - fpdata << vMCTracks[i].q << " "; - fpdata << vMCTracks[i].mass << " "; - fpdata << vMCTracks[i].time << " "; - - fpdata << vMCTracks[i].pdg << " "; - fpdata << vMCTracks[i].ID << " "; - fpdata << vMCTracks[i].mother_ID << endl; - - int nhits = vMCTracks[i].Hits.size(); + fpdata << fvMCTracks[i].x << " "; + fpdata << fvMCTracks[i].y << " "; + fpdata << fvMCTracks[i].z << " "; + fpdata << fvMCTracks[i].px << " "; + fpdata << fvMCTracks[i].py << " "; + fpdata << fvMCTracks[i].pz << " "; + fpdata << fvMCTracks[i].p << " "; + fpdata << fvMCTracks[i].q << " "; + fpdata << fvMCTracks[i].mass << " "; + fpdata << fvMCTracks[i].time << " "; + + fpdata << fvMCTracks[i].pdg << " "; + fpdata << fvMCTracks[i].ID << " "; + fpdata << fvMCTracks[i].mother_ID << endl; + + int nhits = fvMCTracks[i].Hits.size(); fpdata << " " << nhits << endl << " "; for (int k = 0; k < nhits; k++) { - fpdata << vMCTracks[i].Hits[k] << " "; + fpdata << fvMCTracks[i].Hits[k] << " "; }; fpdata << endl; - const int nPoints = vMCTracks[i].Points.size(); + const int nPoints = fvMCTracks[i].Points.size(); fpdata << nPoints << endl << " "; for (int k = 0; k < nPoints; k++) { - fpdata << vMCTracks[i].Points[k] << " "; + fpdata << fvMCTracks[i].Points[k] << " "; }; fpdata << endl; - fpdata << vMCTracks[i].nMCContStations << " "; - fpdata << vMCTracks[i].nHitContStations << " "; - fpdata << vMCTracks[i].maxNStaMC << " "; - fpdata << vMCTracks[i].maxNSensorMC << " "; - fpdata << vMCTracks[i].maxNStaHits << " "; - fpdata << vMCTracks[i].nStations << endl; + fpdata << fvMCTracks[i].nMCContStations << " "; + fpdata << fvMCTracks[i].nHitContStations << " "; + fpdata << fvMCTracks[i].maxNStaMC << " "; + fpdata << fvMCTracks[i].maxNSensorMC << " "; + fpdata << fvMCTracks[i].maxNStaHits << " "; + fpdata << fvMCTracks[i].nStations << endl; }; if (fVerbose >= 4) { - cout << "vMCTracks[" << n << "]" + cout << "fvMCTracks[" << n << "]" << " have been written." << endl; } - // write vHitMCRef - n = vHitMCRef.size(); // number of elements + // write fvHitPointIndexes + n = fvHitPointIndexes.size(); // number of elements fpdata << n << endl; for (int i = 0; i < n; i++) { - fpdata << vHitMCRef[i] << endl; + fpdata << fvHitPointIndexes[i] << endl; }; if (fVerbose >= 4) { - cout << "vHitMCRef[" << n << "]" + cout << "fvHitPointIndexes[" << n << "]" << " have been written." << endl; } - // write vHitStore - n = vHitStore.size(); // number of elements + // write fvHitStore + n = fvHitStore.size(); // number of elements fpdata << n << endl; for (int i = 0; i < n; i++) { - fpdata << vHitStore[i].ExtIndex << " "; - fpdata << vHitStore[i].iStation << " "; + fpdata << fvHitStore[i].ExtIndex << " "; + fpdata << fvHitStore[i].iStation << " "; - fpdata << vHitStore[i].x << " "; - fpdata << vHitStore[i].y << endl; + fpdata << fvHitStore[i].x << " "; + fpdata << fvHitStore[i].y << endl; }; if (fVerbose >= 4) { - cout << "vHitStore[" << n << "]" + cout << "fvHitStore[" << n << "]" << " have been written." << endl; } - // write vHits - n = vHits.size(); // number of elements + // write fvExternalHits + n = fvExternalHits.size(); // number of elements fpdata << n << endl; for (int i = 0; i < n; i++) { - fpdata << vHits[i].hitId << " "; - fpdata << vHits[i].extIndex << endl; + fpdata << fvExternalHits[i].hitId << " "; + fpdata << fvExternalHits[i].extIndex << endl; - const int nPoints = vHits[i].mcPointIds.size(); + const int nPoints = fvExternalHits[i].mcPointIds.size(); fpdata << nPoints << endl << " "; for (int k = 0; k < nPoints; k++) { - fpdata << vHits[i].mcPointIds[k] << " "; + fpdata << fvExternalHits[i].mcPointIds[k] << " "; }; fpdata << endl; }; if (fVerbose >= 4) { - cout << "vHits[" << n << "]" + cout << "fvExternalHits[" << n << "]" << " have been written." << endl; } fpdata.close(); @@ -1649,9 +1656,9 @@ void CbmL1::ReadSTAPAlgoData() if (1) { if (nEvent == 1) fadata.open(fadata_name, std::fstream::in); - if (algo->vHits) algo->vHits->clear(); - algo->fNstrips = 0; - if (algo->fStripFlag) algo->fStripFlag->clear(); + if (fpAlgo->vHits) fpAlgo->vHits->clear(); + fpAlgo->fNstrips = 0; + if (fpAlgo->fStripFlag) fpAlgo->fStripFlag->clear(); // check correct position in file char s[] = "Event: "; @@ -1661,26 +1668,26 @@ void CbmL1::ReadSTAPAlgoData() if (nEv != nEvent) cout << "-E- CbmL1: Can't read event number " << nEvent << " from file " << fadata_name << endl; int n; // number of elements - // read algo->vStrips + // read fpAlgo->vStrips fadata >> n; cout << " n " << n << endl; - algo->fNstrips = n; + fpAlgo->fNstrips = n; if (fVerbose >= 4) { cout << "vStrips[" << n << "]" << " have been read." << endl; } - // read algo->fStripFlag + // read fpAlgo->fStripFlag fadata >> n; for (int i = 0; i < n; i++) { int element; fadata >> element; - algo->fStripFlag->push_back(static_cast<unsigned char>(element)); + fpAlgo->fStripFlag->push_back(static_cast<unsigned char>(element)); } if (fVerbose >= 4) { cout << "fStripFlag[" << n << "]" << " have been read." << endl; } - // read algo->vHits + // read fpAlgo->vHits fadata >> n; int element_f; // for convert int element_b; @@ -1690,7 +1697,7 @@ void CbmL1::ReadSTAPAlgoData() 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); - algo->vHits->push_back(element); + fpAlgo->vHits->push_back(element); } if (fVerbose >= 4) { cout << "vHits[" << n << "]" @@ -1701,12 +1708,12 @@ void CbmL1::ReadSTAPAlgoData() for (int i = 0; i < n; i++) { int tmp; fadata >> tmp; - if (int(L1Constants::size::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->HitsStartIndex[i]) = tmp); + if (int(L1Constants::size::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(fpAlgo->HitsStartIndex[i]) = tmp); } for (int i = 0; i < n; i++) { int tmp; fadata >> tmp; - if (int(L1Constants::size::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->HitsStopIndex[i]) = tmp); + if (int(L1Constants::size::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(fpAlgo->HitsStopIndex[i]) = tmp); } cout << "-I- CbmL1: CATrackFinder data for event " << nEvent << " has been read from file " << fadata_name @@ -1724,11 +1731,11 @@ void CbmL1::ReadSTAPPerfData() if (1) { if (nEvent == 1) { fpdata.open(fpdata_name, std::fstream::in); }; - vMCPoints.clear(); - vMCTracks.clear(); - vHitMCRef.clear(); - vHitStore.clear(); - vHits.clear(); + fvMCPoints.clear(); + fvMCTracks.clear(); + fvHitPointIndexes.clear(); + fvHitStore.clear(); + fvExternalHits.clear(); dFEI2vMCPoints.clear(); dFEI2vMCTracks.clear(); // check if it is right position in file @@ -1740,7 +1747,7 @@ void CbmL1::ReadSTAPPerfData() if (nEv != nEvent) cout << "-E- CbmL1: Performance: can't read event number " << nEvent << " from file " << "data_perfo.txt" << endl; - // vMCPoints + // fvMCPoints int n; // number of elements fpdata >> n; for (int i = 0; i < n; i++) { @@ -1778,13 +1785,13 @@ void CbmL1::ReadSTAPPerfData() element.hitIds.push_back(helement); }; - vMCPoints.push_back(element); + fvMCPoints.push_back(element); }; if (fVerbose >= 4) { - cout << "vMCPoints[" << n << "]" + cout << "fvMCPoints[" << n << "]" << " have been read." << endl; } - // vMCTracks . without Points + // fvMCTracks . without Points fpdata >> n; for (int i = 0; i < n; i++) { CbmL1MCTrack element; @@ -1826,27 +1833,27 @@ void CbmL1::ReadSTAPPerfData() fpdata >> element.nStations; element.CalculateIsReconstructable(); - vMCTracks.push_back(element); + fvMCTracks.push_back(element); }; if (fVerbose >= 4) { - cout << "vMCTracks[" << n << "]" + cout << "fvMCTracks[" << n << "]" << " have been read." << endl; } - // vHitMCRef + // fvHitPointIndexes fpdata >> n; - vHitMCRef.reserve(n); + fvHitPointIndexes.reserve(n); for (int i = 0; i < n; i++) { int element; fpdata >> element; - vHitMCRef.push_back(element); + fvHitPointIndexes.push_back(element); }; if (fVerbose >= 4) { - cout << "vHitMCRef[" << n << "]" + cout << "fvHitPointIndexes[" << n << "]" << " have been read." << endl; } - // vHitStore + // fvHitStore fpdata >> n; - vHitStore.reserve(n); + fvHitStore.reserve(n); for (int i = 0; i < n; i++) { CbmL1HitStore element; fpdata >> element.ExtIndex; @@ -1854,13 +1861,13 @@ void CbmL1::ReadSTAPPerfData() fpdata >> element.x; fpdata >> element.y; - vHitStore.push_back(element); + fvHitStore.push_back(element); }; if (fVerbose >= 4) { - cout << "vHitStore[" << n << "]" + cout << "fvHitStore[" << n << "]" << " have been read." << endl; } - // vHits + // fvExternalHits fpdata >> n; for (int i = 0; i < n; i++) { CbmL1Hit element; @@ -1874,10 +1881,10 @@ void CbmL1::ReadSTAPPerfData() fpdata >> id; element.mcPointIds.push_back(id); }; - vHits.push_back(element); + fvExternalHits.push_back(element); }; if (fVerbose >= 4) { - cout << "vHits[" << n << "]" + cout << "fvExternalHits[" << n << "]" << " have been read." << endl; } @@ -1926,18 +1933,18 @@ void CbmL1::WriteSIMDKFData() rfg[2] = 5.0; dMF->GetFieldValue(rfg, bfg); FileGeo << rfg[2] << " " << bfg[0] << " " << bfg[1] << " " << bfg[2] << " " << endl << endl; - FileGeo << NStation << endl; + FileGeo << fNStations << endl; const int M = 5; // polinom order const int N = (M + 1) * (M + 2) / 2; - for (Int_t ist = 0; ist < NStation; ist++) { + for (Int_t ist = 0; ist < fNStations; ist++) { fscal f_phi, f_sigma, b_phi, b_sigma; double C[3][N]; double z = 0; double Xmax, Ymax; - if (ist < NMvdStations) { + if (ist < fNMvdStations) { CbmKFTube& t = CbmKF::Instance()->vMvdMaterial[ist]; f_phi = 0; f_sigma = 5.e-4; @@ -1947,7 +1954,7 @@ void CbmL1::WriteSIMDKFData() Xmax = Ymax = t.R; } else { - CbmStsStation* station = CbmStsSetup::Instance()->GetStation(ist - NMvdStations); + CbmStsStation* station = CbmStsSetup::Instance()->GetStation(ist - fNMvdStations); f_phi = station->GetSensorRotation(); b_phi = f_phi; double Pi = 3.14159265358; @@ -2029,14 +2036,14 @@ void CbmL1::WriteSIMDKFData() // float delta_x = sqrt(C00); // float delta_y = sqrt(C11); FileGeo << " " << ist << " "; - if (ist < NMvdStations) { + if (ist < fNMvdStations) { CbmKFTube& t = CbmKF::Instance()->vMvdMaterial[ist]; FileGeo << t.z << " "; FileGeo << t.dz << " "; FileGeo << t.RadLength << " "; } - else if (ist < (NStsStations + NMvdStations)) { - CbmStsStation* station = CbmStsSetup::Instance()->GetStation(ist - NMvdStations); + else if (ist < (fNStsStations + fNMvdStations)) { + CbmStsStation* station = CbmStsSetup::Instance()->GetStation(ist - fNMvdStations); FileGeo << station->GetZ() << " "; FileGeo << station->GetSensorD() << " "; FileGeo << station->GetRadLength() << " "; @@ -2080,7 +2087,7 @@ void CbmL1::WriteSIMDKFData() McTracksOut.open("mctracksout.dat", std::fstream::out | std::fstream::app); } - for (L1Vector<CbmL1Track>::iterator RecTrack = vRTracks.begin(); RecTrack != vRTracks.end(); ++RecTrack) { + for (L1Vector<CbmL1Track>::iterator RecTrack = fvRecoTracks.begin(); RecTrack != fvRecoTracks.end(); ++RecTrack) { if (RecTrack->IsGhost()) continue; CbmL1MCTrack* MCTrack = RecTrack->GetMCTrack(); @@ -2091,17 +2098,17 @@ void CbmL1::WriteSIMDKFData() int st[20]; int jHit = 0; for (int iHit = 0; iHit < NHits; iHit++) { - CbmL1HitStore& h = vHitStore[RecTrack->Hits[iHit]]; + CbmL1HitStore& h = fvHitStore[RecTrack->Hits[iHit]]; st[jHit] = h.iStation; if (h.ExtIndex < 0) { - CbmMvdHit* MvdH = (CbmMvdHit*) listMvdHits->At(-h.ExtIndex - 1); + CbmMvdHit* MvdH = (CbmMvdHit*) fpMvdHits->At(-h.ExtIndex - 1); x[jHit] = MvdH->GetX(); y[jHit] = MvdH->GetY(); z[jHit] = MvdH->GetZ(); jHit++; } else { - CbmStsHit* StsH = (CbmStsHit*) listStsHits->At(h.ExtIndex); + CbmStsHit* StsH = (CbmStsHit*) fpStsHits->At(h.ExtIndex); x[jHit] = StsH->GetX(); y[jHit] = StsH->GetY(); z[jHit] = StsH->GetZ(); @@ -2128,7 +2135,7 @@ void CbmL1::WriteSIMDKFData() << " " << MCTrack->py << " " << MCTrack->pz << " " << MCTrack->q << " " << NMCPoints << endl; for (int iPoint = 0; iPoint < NMCPoints; iPoint++) { - CbmL1MCPoint& MCPoint = vMCPoints[MCTrack->Points[iPoint]]; + CbmL1MCPoint& MCPoint = fvMCPoints[MCTrack->Points[iPoint]]; McTracksIn << " " << MCPoint.iStation << " " << MCPoint.xIn << " " << MCPoint.yIn << " " << MCPoint.zIn << " " << MCPoint.pxIn << " " << MCPoint.pyIn << " " << MCPoint.pzIn << endl; McTracksOut << " " << MCPoint.iStation << " " << MCPoint.xOut << " " << MCPoint.yOut << " " << MCPoint.zOut diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index aee4c87c52..226f237258 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -101,12 +101,17 @@ enum class L1DetectorID /// TODO: L1InitManager - main interface of communication between cbmroot/bmnroot and L1Algo (S.Zharko) /// class CbmL1 : public FairTask { -private: - CbmL1(const CbmL1&); - CbmL1 operator=(const CbmL1&); - public: - typedef std::set<std::pair<int, int>> DFSET; + // ********************** + // ** Types definition ** + // ********************** + + using DFSET = std::set<std::pair<int, int>>; // Why std::set<std::pair<>> instead of std::map<>? + using DFEI2I = std::map<Double_t, Int_t>; + + // ************************** + // ** Friends classes list ** + // ************************** friend class L1AlgoDraw; friend class L1AlgoPulls; @@ -117,59 +122,100 @@ public: friend class CbmL1MCTrack; friend class CbmL1PFFitter; - static CbmL1* Instance() { return fInstance; } - void SetParContainers(); - void CheckDetectorPresence(); - virtual InitStatus ReInit(); - virtual InitStatus Init(); - void Exec(Option_t* option); + // ********************************** + // ** Member functions declaration ** + // ********************************** + + // ** Constructors and destructor ** + /// Default constructor CbmL1(); - /** Constructor - * @param _fPerformance - type of Efficiency output: 0 - w\o efficiencies, doesn't use MC data; 1 - L1 standard efficiency definition; 2 - QA efficiency definition - * @param fSTAPDataMode_ - way to work with files for the standalone package: 0 - off , 1 - write, 2 - read data and work only with it, 3 - write and read (debug) - * @param findParticleMode_ : 0 - don't run FindParticles; 1 - run, all MC particle is reco-able; 2 - run, MC particle is reco-able if created from reco-able tracks; 3 - run, MC particle is reco-able if created from reconstructed tracks - */ - CbmL1(const char* name, Int_t iVerbose = 1, Int_t _fPerformance = 0, int fSTAPDataMode_ = 0, - TString fSTAPDataDir_ = "./", int findParticleMode_ = 0); + /// Constructor from parameters + /// \param name Name of the task + /// \param verbose Verbosity level + /// \param performance Performance run flag: + /// 0: run without performance measurement + /// 1: standard efficiency definition + /// 2: QA efficiency definition + /// \param dataMode Option to work with files for the standalone mode + /// 0: standalone mode is not used + /// 1: data for standalone mode is written to configuration file (currently does not work) + /// 2: tracking runs in standalone mode using configuration file (currently does not work) + /// 3: data is written and read (currently does not work) + /// \param dataDir Name of directory for configuration file + /// \param findParticleMode Find particle utility mode + /// 0: FindParticles is not used + /// 1: All MC particles are reconstructable + /// 2: MC particles are reconstructable if created from reconstructable tracks + /// 3: MC particles are reconstructable if created from reconstructed tracks + CbmL1(const char* name, Int_t verbose = 1, Int_t performance = 0, int dataMode = 0, const TString& dataDir = "./", + int findParticleMode = 0); + + /// Copy constructor + CbmL1(const CbmL1&) = delete; + + /// Move constructor + CbmL1(CbmL1&&) = delete; + + /// Copy assignment operator + CbmL1& operator=(const CbmL1&) = delete; + + /// Move assignment operator + CbmL1& operator=(CbmL1&&) = delete; + + /// Destructor + ~CbmL1(); + + /// Pointer to CbmL1 instance + static CbmL1* Instance() { return fpInstance; } + + + // ** Member functions override from FairTask ** + + /// Defines action in the beginning of the run (initialization) + virtual InitStatus Init(); - ~CbmL1(/*if (targetFieldSlice) delete;*/); + /// Reruns the initialization + virtual InitStatus ReInit(); - /// Gets a pointer to L1InitManager (for an access in run_reco.C) - L1InitManager* GetInitManager() { return fpInitManager; } - /// Gets a set of active detectors used in tracking - // TODO: think about return (value, reference or const reference?) (S.Zh.) - std::set<L1DetectorID> GetActiveTrackingDetectorIDs() const { return fActiveTrackingDetectorIDs; } - /// Sets a vector of detectors used in tracking - void SetActiveTrackingDetectorIDs(const std::set<L1DetectorID>& init) { fActiveTrackingDetectorIDs = init; } + /// Defines action in the end of the run (saves results) + void Finish(); + + + // ** Specific member functions ** + + /// Checks, if detector subsystems are present in the setup + /// If a particular subsystem is absent, it is not used in tracking. + void CheckDetectorPresence(); - void SetUseMcHit(int StsUseMcHit = 0, int MuchUseMcHit = 0, int TrdUseMcHit = 0, int TofUseMcHit = 0) - { - fStsUseMcHit = StsUseMcHit; - fMuchUseMcHit = MuchUseMcHit; - fTrdUseMcHit = TrdUseMcHit; - fTofUseMcHit = TofUseMcHit; - } - /* Material budget setters */ + /// Sets material budget file name for MVD void SetMvdMaterialBudgetFileName(const TString& fileName) { if (fileName != "") fMatBudgetFileName[L1DetectorID::kMvd] = fileName; } + + /// Sets material budget file name for STS void SetStsMaterialBudgetFileName(const TString& fileName) { if (fileName != "") fMatBudgetFileName[L1DetectorID::kSts] = fileName; } + + /// Sets material budget file name for MuCh void SetMuchMaterialBudgetFileName(const TString& fileName) { if (fileName != "") fMatBudgetFileName[L1DetectorID::kMuch] = fileName; } + + /// Sets material budget file name for TRD void SetTrdMaterialBudgetFileName(const TString& fileName) { if (fileName != "") fMatBudgetFileName[L1DetectorID::kTrd] = fileName; } + + /// Sets material budget file name for TOF void SetTofMaterialBudgetFileName(const TString& fileName) { if (fileName != "") fMatBudgetFileName[L1DetectorID::kTof] = fileName; @@ -217,14 +263,13 @@ public: void SetExtrapolateToTheEndOfSTS(bool b) { fExtrapolateToTheEndOfSTS = b; } void SetLegacyEventMode(bool b) { fLegacyEventMode = b; } - void SetMuchPar(TString fileName) { fMuchDigiFile = fileName; } + void SetMuchPar(TString fileName) { fsMuchDigiFile = fileName; } // TODO: Remove! (S.Zharko) void SetUseHitErrors(bool value) { fUseHitErrors = value; } void SetMissingHits(bool value) { fMissingHits = value; } void SetStsOnlyMode() { fTrackingMode = L1Algo::TrackingMode::kSts; } void SetMcbmMode() { fTrackingMode = L1Algo::TrackingMode::kMcbm; } void SetGlobalMode() { fTrackingMode = L1Algo::TrackingMode::kGlobal; } - void Finish(); // void SetTrackingLevel( Int_t iLevel ){ fTrackingLevel = iLevel; } // void MomentumCutOff( Double_t cut ){ fMomentumCutOff = cut; } @@ -233,16 +278,20 @@ public: /// Reconstructs an event /// \param event Pointer to current CbmEvent object - void Reconstruct(CbmEvent* event = NULL); + void Reconstruct(CbmEvent* event = nullptr); // bool ReadMCDataFromFile(const char work_dir[100], const int maxNEvent, const int iVerbose); - // vector<CbmL1MCPoint> vMCPoints; + // vector<CbmL1MCPoint> fvMCPoints; // static bool compareZ(const int &a, const int &b ); - inline double Get_Z_vMCPoint(int a) const { return vMCPoints[a].z; } + inline double Get_Z_vMCPoint(int a) const { return fvMCPoints[a].z; } + + const L1Vector<CbmL1MCPoint>& GetMcPoints() const { return fvMCPoints; } + + const L1Vector<int>& GetHitMCRefs() const { return fvHitPointIndexes; } + private: - typedef std::map<Double_t, Int_t> DFEI2I; struct TH1FParameters { TString name, title; @@ -250,15 +299,16 @@ private: float xMin, xMax; }; - void IdealTrackFinder(); // just copy all reconstructable MCTracks into RecoTracks. + /// Runs ideal track finder: copies all MC-tracks into reconstructed tracks + void IdealTrackFinder(); /// 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 timeslice start time - /// \param TsLength Reference to the timeslice length - /// \param TsOverlap Reference to the timeslice overlap length (does not used at the moment) + /// \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 @@ -285,7 +335,7 @@ private: // static bool compareZ(const int &a, const int &b ); // bool compareZ(const int &a, const int &b ); - /// Fills the vMCTracks vector and the dFEI2vMCTracks set + /// Fills the fvMCTracks vector and the dFEI2vMCTracks set void Fill_vMCTracks(); /* @@ -319,59 +369,71 @@ private: /// SIMD KF Banchmark service-functions void WriteSIMDKFData(); + /// Gets a pointer to L1InitManager (for an access in run_reco.C) + L1InitManager* GetInitManager() { return fpInitManager; } + + void SetUseMcHit(int StsUseMcHit = 0, int MuchUseMcHit = 0, int TrdUseMcHit = 0, int TofUseMcHit = 0) + { + fStsUseMcHit = StsUseMcHit; + fMuchUseMcHit = MuchUseMcHit; + fTrdUseMcHit = TrdUseMcHit; + fTofUseMcHit = TofUseMcHit; + } + void WriteHistosCurFile(TObject* obj); static std::istream& eatwhite(std::istream& is); // skip spaces static void writedir2current(TObject* obj); // help procedure - inline Double_t dFEI(int file, int event, int idx) { return (1000 * idx) + file + (0.0001 * event); } + + // *************************** + // ** Member variables list ** + // *************************** + public: - L1Algo* algo {nullptr}; // for access to L1 Algorithm from L1::Instance + // ** Basic data members ** - TString fMuchDigiFile {}; // Much digitization file name - bool fUseHitErrors {true}; - bool fMissingHits {false}; - L1Algo::TrackingMode fTrackingMode {L1Algo::TrackingMode::kSts}; + L1Algo* fpAlgo = nullptr; ///< Pointer to the L1 track finder algorithm + L1InitManager* fpInitManager = nullptr; ///< Pointer to the initialization manager for the L1 algorithm - L1Vector<CbmL1Track> vRTracks {"CbmL1::vRTracks"}; ///> reconstructed tracks - DFSET vFileEvent {}; - L1Vector<CbmL1HitStore> vHitStore {"CbmL1::vHitStore"}; // diff hit information + TString fsMuchDigiFile {}; ///< TODO: REMOVE + bool fUseHitErrors = true; ///< + bool fMissingHits = false; - const L1Vector<CbmL1MCPoint>& GetMcPoints() const { return vMCPoints; } + L1Algo::TrackingMode fTrackingMode = L1Algo::TrackingMode::kSts; ///< Tracking mode: kSts, kMcbm or kGlobal - const L1Vector<int>& GetHitMCRefs() const { return vHitMCRef; } -private: - double LoadMaterialMap(L1Material& mat, const TProfile2D* prof); + DFSET fvFileEvent {}; ///< Map of fileID to eventId - static CbmL1* fInstance; - L1InitManager* fpInitManager {nullptr}; ///< Pointer to L1InitManager object of L1 algorithm core + L1Vector<CbmL1Track> fvRecoTracks = {"CbmL1::fvRecoTracks"}; ///< Reconstructed tracks container - std::set<L1DetectorID> fActiveTrackingDetectorIDs {}; ///< Set of detectors active in tracking +private: + static CbmL1* fpInstance; - L1AlgoInputData* fData {nullptr}; + L1AlgoInputData* fpData {nullptr}; - L1Vector<CbmL1MCPoint> vMCPoints {"CbmL1::vMCPoints"}; int nMvdPoints {0}; - L1Vector<int> vMCPoints_in_Time_Slice {"CbmL1::vMCPoints_in_Time_Slice"}; - - int NStation {0}; ///< number of all detector stations - int NMvdStations {0}; ///< number of mvd stations - int NStsStations {0}; ///< number of sts stations - int NMuchStations {0}; ///< number of much stations - int NTrdStations {0}; ///< number of trd stations - int NTOFStation {0}; ///< number of tof stations - /// - int NMvdStationsGeom; - int NStsStationsGeom; - int NTrdStationsGeom; - int NMuchStationsGeom; - int NTOFStationGeom; - int NStationGeom; + + L1Vector<CbmL1MCPoint> fvMCPoints = {"CbmL1::fvMCPoints"}; ///< Container of MC points + L1Vector<int> fvMCPointIndexesTs {"CbmL1::fvMCPointIndexesTs"}; ///< Indexes of MC points in TS + + int fNStations = 0; ///< number of total active detector stations + int fNMvdStations = 0; ///< number of active MVD stations + int fNStsStations = 0; ///< number of active STS stations + int fNMuchStations = 0; ///< number of active MuCh stations + int fNTrdStations = 0; ///< number of active TRD stations + int fNTofStations = 0; ///< number of active TOF stations + + int fNStationsGeom = 0; ///< number of total detector stations + int fNMvdStationsGeom = 0; ///< number of MVD stations + int fNStsStationsGeom = 0; ///< number of STS stations; + int fNMuchStationsGeom = 0; ///< number of MuCh stations; + int fNTrdStationsGeom = 0; ///< number of TRD stations; + int fNTofStationsGeom = 0; ///< number of TOF stations; Int_t fPerformance {0}; // 0 - w\o perf. 1 - L1-Efficiency definition. 2 - QA-Eff.definition @@ -386,57 +448,93 @@ private: Double_t fMomentumCutOff {0.1}; // currently not used Bool_t fGhostSuppression {true}; // currently not used - Int_t fStsUseMcHit {-1}; // if STS data should be processed - Int_t fMuchUseMcHit {-1}; // if Much data should be processed - Int_t fTrdUseMcHit {-1}; // if Trd data should be processed - Int_t fTofUseMcHit {-1}; // if Tof data should be processed + /// TODO: change to bool + Int_t fStsUseMcHit = -1; ///< if STS data should be processed + Int_t fMuchUseMcHit = -1; ///< if Much data should be processed + Int_t fTrdUseMcHit = -1; ///< if Trd data should be processed + Int_t fTofUseMcHit = -1; ///< if Tof data should be processed - Bool_t fUseMVD {false}; // if Mvd data should be processed - Bool_t fUseSTS {false}; // if Mvd data should be processed - Bool_t fUseMUCH {false}; // if Much data should be processed - Bool_t fUseTRD {false}; // if Trd data should be processed - Bool_t fUseTOF {false}; // if Tof data should be processed + bool fUseMVD = false; ///< if Mvd data should be processed + bool fUseSTS = false; ///< if Mvd data should be processed + bool fUseMUCH = false; ///< if Much data should be processed + bool fUseTRD = false; ///< if Trd data should be processed + bool fUseTOF = false; ///< if Tof data should be processed + + // ** Raw input data ** - /// Input data CbmTimeSlice* fTimeSlice {nullptr}; - CbmMCEventList* fEventList {nullptr}; //! MC event list (all) - CbmMCDataArray* fStsPoints {nullptr}; - CbmMCDataArray* fMvdPoints {nullptr}; - CbmMCDataArray* fMCTracks {nullptr}; - CbmMCDataObject* fMcEventHeader {nullptr}; + // Reconstructed hits input + TClonesArray* fpMvdHits = nullptr; ///< Array of MVD hits ("MvdHit") + TClonesArray* fpStsHits = nullptr; ///< Array of STS hits ("StsHit") + TClonesArray* fpMuchPixelHits = nullptr; ///< Array of MuCh hits ("MuchPixelHit") + TClonesArray* fpTrdHits = nullptr; ///< Array of TRD hits ("TrdHit") + TClonesArray* fpTofHits = nullptr; ///< Array of TOF hits ("TofHit") + + // ** MC input ** + + // General + CbmMCEventList* fpEventList = nullptr; ///< MC event list (all) + CbmMCDataArray* fpMCTracks = nullptr; ///< MC tracks list + CbmMCDataObject* fpMcEventHeader = nullptr; ///< MC event header + + // MC-point arrays + CbmMCDataArray* fpMvdPoints = nullptr; ///< MVD MC-points array + CbmMCDataArray* fpStsPoints = nullptr; ///< STS MC-points array + CbmMCDataArray* fpMuchPoints = nullptr; ///< MuCh MC-points array + CbmMCDataArray* fpTrdPoints = nullptr; ///< TRD MC-points array + CbmMCDataArray* fpTofPoints = nullptr; ///< TOF MC-points array - TClonesArray* listStsDigiMatch {nullptr}; - TClonesArray* listStsClusters {nullptr}; - TClonesArray* listStsHits {nullptr}; - TClonesArray* listStsHitMatch {nullptr}; - TClonesArray* listStsClusterMatch {nullptr}; - TClonesArray* listMvdHits {nullptr}; - TClonesArray* listMvdDigiMatches {nullptr}; - TClonesArray* listMvdHitMatches {nullptr}; + // ** MC-reconstruction matching input ** - //MuCh + // Measured digis + TClonesArray* fpMuchDigis = nullptr; ///< Array of MuCh digis - CbmMCDataArray* fMuchPoints {nullptr}; - TClonesArray* listMuchHitMatches {nullptr}; // Output CbmMatch array - TClonesArray* fDigiMatchesMuch {nullptr}; - TClonesArray* fClustersMuch {nullptr}; - TClonesArray* fMuchPixelHits {nullptr}; // CbmMuchPixelHit array - TClonesArray* fDigisMuch {nullptr}; + // Reconstructed clusters + TClonesArray* fpStsClusters = nullptr; ///< Array of STS clusters + TClonesArray* fpMuchClusters = nullptr; ///< Array of MuCh clusters - //TRD + // Hit matches + TClonesArray* fpStsHitMatches = nullptr; ///< Array of STS hit matches (NOTE: currently not used) + TClonesArray* fpMvdHitMatches = nullptr; ///< Array of MVD hit matches + TClonesArray* fpMuchHitMatches = nullptr; ///< Array of MuCh hit matches + TClonesArray* fpTrdHitMatches = nullptr; ///< Array of TOF hit matches + TClonesArray* fpTofHitMatches = nullptr; ///< Array of TRD hit matches - CbmMCDataArray* fTrdPoints {nullptr}; - TClonesArray* listTrdHits {nullptr}; - TClonesArray* fTrdHitMatches {nullptr}; + // Digi and cluster matches + TClonesArray* fpMvdDigiMatches = nullptr; ///< Array of MVD digi matches (NOTE: currently unused) + TClonesArray* fpStsDigiMatches = nullptr; ///< Array of STS digi matches (NOTE: currently unused) + TClonesArray* fpStsClusterMatches = nullptr; ///< Array of STS cluster matches + TClonesArray* fpMuchDigiMatches = nullptr; ///< Array of MuCh digi matches (NOTE: currently unsused) - //ToF - CbmMCDataArray* fTofPoints {nullptr}; - TClonesArray* fTofHitDigiMatches {nullptr}; // CbmMatches array - TClonesArray* fTofHits {nullptr}; // CbmMatches array - vector<vector<int>> TofPointToTrack; + vector<vector<int>> fTofPointToTrack; ///< + + // ** Repacked input data ** + + L1Vector<CbmL1Hit> fvExternalHits = {"CbmL1::fvExternalHits"}; ///< Array of hits with MC information + + /// Indexes of hits after hits sorting (used only with fLegacyEventMode = true) + L1Vector<int> fvSortedHitsIndexes = {"CbmL1::fvSortedHitsIndexes"}; + + /// Indexes of STS hits in fpStsHits array after hits sorting (used only with fLegacyEventMode = true) + L1Vector<int> fvSortedStsHitsIndexes = {"CbmL1::fvSortedStsHitsIndexes"}; + L1Vector<CbmL1MCTrack> fvMCTracks = {"CbmL1::fvMCTracks"}; ///< Array of MC tracks + L1Vector<int> fvHitPointIndexes = {"CbmL1::fvHitPointIndexes"}; ///< Indexes of MC points vs. hit index + +public: + L1Vector<CbmL1HitStore> fvHitStore = {"CbmL1::fvHitStore"}; ///< Container of hits with extended information + // indices of MCPoints in fvMCPoints, indexed by index of hit in algo->vHits array. According to StsMatch. Used for IdealResponce + // L1Vector<int> vHitMCRef1; + // CbmMatch HitMatch; +private: + DFEI2I dFEI2vMCPoints = {}; + DFEI2I dFEI2vMCTracks = {}; + // ***************************** + // ** Tracking performance QA ** + // ***************************** + // TODO: move to a separate class (S.Zharko) TFile* fPerfFile {nullptr}; TDirectory* fHistoDir {nullptr}; @@ -446,18 +544,6 @@ private: static const int fNGhostHistos = 9; TH1F* fGhostHisto[fNGhostHistos] {nullptr}; - /// Used data = Repacked input data - L1Vector<CbmL1Hit> vHits {"CbmL1::vHits"}; // hits with hit-mcpoint match information - L1Vector<int> SortedIndex {"CbmL1::SortedIndex"}; - L1Vector<int> StsIndex {"CbmL1::StsIndex"}; - L1Vector<CbmL1MCTrack> vMCTracks {"CbmL1::vMCTracks"}; - L1Vector<int> vHitMCRef { - "CbmL1::vHitMCRef"}; // indices of MCPoints in vMCPoints, indexed by index of hit in algo->vHits array. According to StsMatch. Used for IdealResponce - // L1Vector<int> vHitMCRef1; - // CbmMatch HitMatch; - - DFEI2I dFEI2vMCPoints {}; - DFEI2I dFEI2vMCTracks {}; int fFindParticlesMode {0}; // 0 - don't run FindParticles // 1 - run, all MC particle is reco-able diff --git a/reco/L1/CbmL1Hit.h b/reco/L1/CbmL1Hit.h index cf8294588b..92e83bc98c 100644 --- a/reco/L1/CbmL1Hit.h +++ b/reco/L1/CbmL1Hit.h @@ -10,22 +10,22 @@ /// /// hits with hit-mcpoint match information /// -struct CbmL1Hit { - +class CbmL1Hit { +public: CbmL1Hit() = default; CbmL1Hit(int hitId_, int extIndex_, int Det_) : hitId(hitId_), extIndex(extIndex_), Det(Det_) {}; - int hitId = 0; ///> index of L1Hit in algo->vHits array. Should be equal to index of this in L1->vHits - int extIndex = 0; ///> index of hit in the TClonesArray array - int Det = 0; ///> station index - float x = 0.f; ///> measured X coordinate - float y = 0.f; ///> measured Y coordinate - float t = 0.f; ///> measured time - int f = 0; ///> front strip index - int b = 0; ///> back strip index - int ID = 0; ///> TODO: check if this ID is redundant - L1Vector<int> mcPointIds {"CbmL1Hit::mcPointIds"}; // indices of CbmL1MCPoint in L1->vMCPoints array + int hitId = 0; ///< index of L1Hit in algo->vHits array. Should be equal to index of this in L1->vHits + int extIndex = 0; ///< index of hit in the TClonesArray array + int Det = 0; ///< station index + float x = 0.f; ///< measured X coordinate + float y = 0.f; ///< measured Y coordinate + float t = 0.f; ///< measured time + int f = 0; ///< front strip index + int b = 0; ///< back strip index + int ID = 0; ///< TODO: check if this ID is redundant + L1Vector<int> mcPointIds {"CbmL1Hit::mcPointIds"}; ///< indices of CbmL1MCPoint in L1->fvMCPoints array }; #endif diff --git a/reco/L1/CbmL1MCTrack.cxx b/reco/L1/CbmL1MCTrack.cxx index 86dd7e6cf0..e45a6bf590 100644 --- a/reco/L1/CbmL1MCTrack.cxx +++ b/reco/L1/CbmL1MCTrack.cxx @@ -64,7 +64,7 @@ void CbmL1MCTrack::Init() // get Hits Hits.clear(); for (unsigned int iP = 0; iP < Points.size(); iP++) { - CbmL1MCPoint* point = &(L1->vMCPoints[Points[iP]]); + CbmL1MCPoint* point = &(L1->fvMCPoints[Points[iP]]); for (unsigned int iH = 0; iH < point->hitIds.size(); iH++) { const int iih = point->hitIds[iH]; if (std::find(Hits.begin(), Hits.end(), iih) == Hits.end()) Hits.push_back_no_warning(iih); @@ -86,7 +86,7 @@ float CbmL1MCTrack::Fraction_MC() CbmL1* L1 = CbmL1::Instance(); int counter = 0; for (unsigned int iP = 0; iP < Points.size(); iP++) { - if (L1->vMCPoints_in_Time_Slice[Points[iP]] > 0) counter++; + if (L1->fvMCPointIndexesTs[Points[iP]] > 0) counter++; }; return (Points.size() > 0) ? float(counter) / float(Points.size()) : 0; } @@ -100,7 +100,7 @@ void CbmL1MCTrack::CalculateMCCont() nMCContStations = 0; int istaold = -1, ncont = 0; for (int ih = 0; ih < nPoints; ih++) { - CbmL1MCPoint& h = L1->vMCPoints[Points[ih]]; + CbmL1MCPoint& h = L1->fvMCPoints[Points[ih]]; int ista = h.iStation; if (ista - istaold == 1) ncont++; else if (ista - istaold > 1) { @@ -116,7 +116,7 @@ void CbmL1MCTrack::CalculateMCCont() void CbmL1MCTrack::CalculateHitCont() { CbmL1* L1 = CbmL1::Instance(); - L1Algo* algo = L1->algo; + L1Algo* algo = L1->fpAlgo; int nhits = Hits.size(); nHitContStations = 0; @@ -155,7 +155,7 @@ void CbmL1MCTrack::CalculateMaxNStaHits() int lastSta = -1; int cur_maxNStaHits = 0; for (unsigned int iH = 0; iH < Hits.size(); iH++) { - CbmL1HitStore& sh = L1->vHitStore[Hits[iH]]; + CbmL1HitStore& sh = L1->fvHitStore[Hits[iH]]; if (sh.iStation == lastSta) { cur_maxNStaHits++; } else { // new station if (!(sh.iStation > lastSta)) { // tracks going in backward direction are not reconstructable @@ -183,7 +183,7 @@ void CbmL1MCTrack::CalculateMaxNStaMC() float lastz = -1; int cur_maxNStaMC = 0, cur_maxNSensorMC = 0; for (unsigned int iH = 0; iH < Points.size(); iH++) { - CbmL1MCPoint& mcP = L1->vMCPoints[Points[iH]]; + CbmL1MCPoint& mcP = L1->fvMCPoints[Points[iH]]; if (mcP.iStation == lastSta) cur_maxNStaMC++; else { // new station if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC; @@ -230,7 +230,7 @@ void CbmL1MCTrack::CalculateIsReconstructable() if (Points.size() > 0) { isAdditional = f & (nHitContStations == nStations) & (nMCContStations == nStations) & (nMCStations == nStations) - & (nHitContStations >= 3) & (L1->vMCPoints[Points[0]].iStation == 0); + & (nHitContStations >= 3) & (L1->fvMCPoints[Points[0]].iStation == 0); isAdditional &= !isReconstructable; } else diff --git a/reco/L1/CbmL1MCTrack.h b/reco/L1/CbmL1MCTrack.h index 2bb0d1a138..269d5b2ba9 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 L1::vMCPoints - 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 91802a437f..0cb1ac9106 100644 --- a/reco/L1/CbmL1Performance.cxx +++ b/reco/L1/CbmL1Performance.cxx @@ -67,7 +67,7 @@ void CbmL1::TrackMatch() pMCTrackMap.clear(); // fill pMCTrackMap - for (vector<CbmL1MCTrack>::iterator i = vMCTracks.begin(); i != vMCTracks.end(); ++i) { + for (vector<CbmL1MCTrack>::iterator i = fvMCTracks.begin(); i != fvMCTracks.end(); ++i) { CbmL1MCTrack& MC = *i; if (pMCTrackMap.find(MC.ID) == pMCTrackMap.end()) { pMCTrackMap.insert(pair<int, CbmL1MCTrack*>(MC.ID, &MC)); } @@ -76,9 +76,9 @@ void CbmL1::TrackMatch() } } // -- prepare information about reconstructed tracks - const int nRTracks = vRTracks.size(); + const int nRTracks = fvRecoTracks.size(); for (int iR = 0; iR < nRTracks; iR++) { - CbmL1Track* prtra = &(vRTracks[iR]); + CbmL1Track* prtra = &(fvRecoTracks[iR]); // cout<<iR<<" iR"<<endl; @@ -88,13 +88,13 @@ void CbmL1::TrackMatch() map<int, int>& hitmap = prtra->hitMap; // how many hits from each mcTrack belong to current recoTrack for (vector<int>::iterator ih = (prtra->Hits).begin(); ih != (prtra->Hits).end(); ++ih) { - const int nMCPoints = vHits[*ih].mcPointIds.size(); + const int nMCPoints = fvExternalHits[*ih].mcPointIds.size(); for (int iP = 0; iP < nMCPoints; iP++) { - int iMC = vHits[*ih].mcPointIds[iP]; + int iMC = fvExternalHits[*ih].mcPointIds[iP]; // cout<<iMC<<" iMC"<<endl; int ID = -1; - if (iMC >= 0) ID = vMCPoints[iMC].ID; + if (iMC >= 0) ID = fvMCPoints[iMC].ID; if (hitmap.find(ID) == hitmap.end()) hitmap[ID] = 1; else { hitmap[ID] += 1; @@ -309,7 +309,7 @@ void CbmL1::EfficienciesPerformance() ntra.fOutDir = fHistoDir; // Setup a pointer for output directory L1_NTRA.fOutDir = fHistoDir; // Save average efficiencies - for (vector<CbmL1Track>::iterator rtraIt = vRTracks.begin(); rtraIt != vRTracks.end(); ++rtraIt) { + for (vector<CbmL1Track>::iterator rtraIt = fvRecoTracks.begin(); rtraIt != fvRecoTracks.end(); ++rtraIt) { ntra.ghosts += rtraIt->IsGhost(); if (rtraIt->IsGhost()) { // Debug. cout << " L1: ghost track: nhits " << rtraIt->GetNOfHits() << " p " << 1. / rtraIt->T[5] << " purity " @@ -326,14 +326,14 @@ void CbmL1::EfficienciesPerformance() } } - int sta_nhits[algo->GetNstations()], sta_nfakes[algo->GetNstations()]; + int sta_nhits[fpAlgo->GetNstations()], sta_nfakes[fpAlgo->GetNstations()]; - for (int i = 0; i < algo->GetNstations(); i++) { + for (int i = 0; i < fpAlgo->GetNstations(); i++) { sta_nhits[i] = 0; sta_nfakes[i] = 0; } - for (vector<CbmL1MCTrack>::iterator mtraIt = vMCTracks.begin(); mtraIt != vMCTracks.end(); mtraIt++) { + for (vector<CbmL1MCTrack>::iterator mtraIt = fvMCTracks.begin(); mtraIt != fvMCTracks.end(); mtraIt++) { CbmL1MCTrack& mtra = *(mtraIt); @@ -365,7 +365,7 @@ void CbmL1::EfficienciesPerformance() if (reco) nclones = mtra.GetNClones(); // if (nclones){ // Debug. Look at clones // for (int irt = 0; irt < rTracks.size(); irt++){ - // const int ista = vHitStore[rTracks[irt]->Hits[0]].iStation; + // const int ista = fvHitStore[rTracks[irt]->Hits[0]].iStation; // cout << rTracks[irt]->GetNOfHits() << "(" << ista << ") "; // } // cout << mtra.NStations() << endl; @@ -406,7 +406,7 @@ void CbmL1::EfficienciesPerformance() ntra.Inc(reco, killed, ratio_length, ratio_fakes, nclones, mc_length, mc_length_hits, "fast"); if (mtra.IsPrimary()) { // reference primary - if (mtra.NStations() == NStation) { // long reference primary + if (mtra.NStations() == fNStations) { // long reference primary ntra.Inc(reco, killed, ratio_length, ratio_fakes, nclones, mc_length, mc_length_hits, "long_fast_prim"); } ntra.Inc(reco, killed, ratio_length, ratio_fakes, nclones, mc_length, mc_length_hits, "fast_prim"); @@ -465,7 +465,7 @@ void CbmL1::EfficienciesPerformance() if (fVerbose > 1) { ntra.PrintEff(true); cout << "Number of true and fake hits in stations: " << endl; - for (int i = 0; i < algo->GetNstations(); i++) { + for (int i = 0; i < fpAlgo->GetNstations(); i++) { cout << sta_nhits[i] - sta_nfakes[i] << "+" << sta_nfakes[i] << " "; } cout << endl; @@ -760,7 +760,7 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe // //hit density calculation: h_hit_density[10] // - // for (vector<CbmL1HitStore>::iterator hIt = vHitStore.begin(); hIt != vHitStore.end(); ++hIt){ + // for (vector<CbmL1HitStore>::iterator hIt = fvHitStore.begin(); hIt != fvHitStore.end(); ++hIt){ // float x = hIt->x; // float y = hIt->y; // float r = sqrt(x*x+y*y); @@ -768,13 +768,13 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe // } // - for (vector<CbmL1Track>::iterator rtraIt = vRTracks.begin(); rtraIt != vRTracks.end(); ++rtraIt) { + for (vector<CbmL1Track>::iterator rtraIt = fvRecoTracks.begin(); rtraIt != fvRecoTracks.end(); ++rtraIt) { CbmL1Track* prtra = &(*rtraIt); if ((prtra->Hits).size() < 1) continue; { // fill histos if (fabs(prtra->T[4]) > 1.e-10) h_reco_mom->Fill(fabs(1.0 / prtra->T[4])); h_reco_nhits->Fill((prtra->Hits).size()); - CbmL1HitStore& mh = vHitStore[prtra->Hits[0]]; + CbmL1HitStore& mh = fvHitStore[prtra->Hits[0]]; h_reco_station->Fill(mh.iStation); } @@ -806,20 +806,20 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe h_ghost_Rmom->Fill(fabs(1.0 / prtra->T[4])); } h_ghost_nhits->Fill((prtra->Hits).size()); - CbmL1HitStore& h1 = vHitStore[prtra->Hits[0]]; - CbmL1HitStore& h2 = vHitStore[prtra->Hits[1]]; + CbmL1HitStore& h1 = fvHitStore[prtra->Hits[0]]; + CbmL1HitStore& h2 = fvHitStore[prtra->Hits[1]]; h_ghost_fstation->Fill(h1.iStation); h_ghost_r->Fill(sqrt(fabs(h1.x * h1.x + h1.y * h1.y))); - double z1 = algo->GetParameters()->GetStation(h1.iStation).z[0]; - double z2 = algo->GetParameters()->GetStation(h2.iStation).z[0]; + double z1 = fpAlgo->GetParameters()->GetStation(h1.iStation).z[0]; + double z2 = fpAlgo->GetParameters()->GetStation(h2.iStation).z[0]; if (fabs(z2 - z1) > 1.e-4) { h_ghost_tx->Fill((h2.x - h1.x) / (z2 - z1)); h_ghost_ty->Fill((h2.y - h1.y) / (z2 - z1)); } if (fabs(prtra->T[4]) > 1.e-10) h2_ghost_nhits_vs_mom->Fill(fabs(1.0 / prtra->T[4]), (prtra->Hits).size()); - CbmL1HitStore& hf = vHitStore[prtra->Hits[0]]; - CbmL1HitStore& hl = vHitStore[prtra->Hits[(prtra->Hits).size() - 1]]; + CbmL1HitStore& hf = fvHitStore[prtra->Hits[0]]; + CbmL1HitStore& hl = fvHitStore[prtra->Hits[(prtra->Hits).size() - 1]]; if (fabs(prtra->T[4]) > 1.e-10) h2_ghost_fstation_vs_mom->Fill(fabs(1.0 / prtra->T[4]), hf.iStation + 1); if (hl.iStation >= hf.iStation) h2_ghost_lstation_vs_fstation->Fill(hf.iStation + 1, hl.iStation + 1); } @@ -827,7 +827,7 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe } // for reco tracks int mc_total = 0; // total amount of reconstructable mcTracks - for (vector<CbmL1MCTrack>::iterator mtraIt = vMCTracks.begin(); mtraIt != vMCTracks.end(); mtraIt++) { + for (vector<CbmL1MCTrack>::iterator mtraIt = fvMCTracks.begin(); mtraIt != fvMCTracks.end(); mtraIt++) { CbmL1MCTrack& mtra = *(mtraIt); // if( !( mtra.pdg == -11 && mtra.mother_ID == -1 ) ) continue; // electrons only @@ -844,8 +844,8 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe int nSta = mtra.NStations(); - CbmL1HitStore& fh = vHitStore[*(mtra.Hits.begin())]; - CbmL1HitStore& lh = vHitStore[*(mtra.Hits.rbegin())]; + CbmL1HitStore& fh = fvHitStore[*(mtra.Hits.begin())]; + CbmL1HitStore& lh = fvHitStore[*(mtra.Hits.rbegin())]; h_reg_MCmom->Fill(momentum); if (mtra.IsPrimary()) { @@ -907,7 +907,7 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe int iph = mtra.Hits[0]; - CbmL1HitStore& ph = vHitStore[iph]; + CbmL1HitStore& ph = fvHitStore[iph]; h_sec_r->Fill(sqrt(fabs(ph.x * ph.x + ph.y * ph.y))); if (fabs(mtra.pz) > 1.e-8) { @@ -994,16 +994,16 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe h_notfound_r->Fill(sqrt(fabs(ph.x * ph.x + ph.y * ph.y))); if (mtra.Points.size() > 0) { - CbmL1MCPoint& pMC = vMCPoints[mtra.Points[0]]; + CbmL1MCPoint& pMC = fvMCPoints[mtra.Points[0]]; h_notfound_tx->Fill(pMC.px / pMC.pz); h_notfound_ty->Fill(pMC.py / pMC.pz); } - // CbmL1HitStore &ph21 = vHitStore[mtra.Hits[0]]; - // CbmL1HitStore &ph22 = vHitStore[mtra.Hits[1]]; + // CbmL1HitStore &ph21 = fvHitStore[mtra.Hits[0]]; + // CbmL1HitStore &ph22 = fvHitStore[mtra.Hits[1]]; - // double z21 = algo->GetParameters()->GetStation(ph21.iStation).z[0]; - // double z22 = algo->GetParameters()->GetStation(ph22.iStation).z[0]; + // double z21 = fpAlgo->GetParameters()->GetStation(ph21.iStation).z[0]; + // double z22 = fpAlgo->GetParameters()->GetStation(ph22.iStation).z[0]; // if( fabs(z22-z21)>1.e-4 ){ // h_notfound_tx->Fill((ph22.x-ph21.x)/(z22-z21)); // h_notfound_ty->Fill((ph22.y-ph21.y)/(z22-z21)); @@ -1023,17 +1023,17 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitRe } // for mcTracks int NFakes = 0; - for (unsigned int ih = 0; ih < algo->vHits->size(); ih++) { - int iMC = vHitMCRef[ih]; // TODO2: adapt to linking + for (unsigned int ih = 0; ih < fpAlgo->vHits->size(); ih++) { + int iMC = fvHitPointIndexes[ih]; // TODO2: adapt to linking if (iMC < 0) NFakes++; } h_reco_time->Fill(fTrackingTime); h_reco_timeNtr->Fill(mc_total, fTrackingTime); - h_reco_timeNhit->Fill(algo->vHits->size(), fTrackingTime); + h_reco_timeNhit->Fill(fpAlgo->vHits->size(), fTrackingTime); h_reco_fakeNtr->Fill(mc_total, NFakes); - h_reco_fakeNhit->Fill(algo->vHits->size() - NFakes, NFakes); + h_reco_fakeNhit->Fill(fpAlgo->vHits->size() - NFakes, NFakes); h_reg_MCmom->Scale(1.f / NEvents); @@ -1077,7 +1077,7 @@ void CbmL1::TrackFitPerformance() static bool first_call = 1; L1Fit fit; - fit.SetParticleMass(algo->GetDefaultParticleMass()); + fit.SetParticleMass(fpAlgo->GetDefaultParticleMass()); if (first_call) { @@ -1184,7 +1184,7 @@ void CbmL1::TrackFitPerformance() gDirectory = currentDir; } // if first call - for (vector<CbmL1Track>::iterator it = vRTracks.begin(); it != vRTracks.end(); ++it) { + for (vector<CbmL1Track>::iterator it = fvRecoTracks.begin(); it != fvRecoTracks.end(); ++it) { if (it->IsGhost()) continue; @@ -1192,7 +1192,7 @@ void CbmL1::TrackFitPerformance() #define L1FSTPARAMEXTRAPOLATE #ifdef L1FSTPARAMEXTRAPOLATE - const int last_station = vHitStore[it->Hits.back()].iStation; + const int last_station = fvHitStore[it->Hits.back()].iStation; CbmL1MCTrack mc = *(it->GetMCTracks()[0]); L1TrackPar trPar(it->T, it->C); @@ -1202,8 +1202,8 @@ void CbmL1::TrackFitPerformance() int ih = 0; for (unsigned int iMCPoint = 0; iMCPoint < mc.Points.size(); iMCPoint++) { const int iMCP = mc.Points[iMCPoint]; - CbmL1MCPoint& mcP = vMCPoints[iMCP]; - const L1Station& st = algo->GetParameters()->GetStation(mcP.iStation); + CbmL1MCPoint& mcP = fvMCPoints[iMCP]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(mcP.iStation); z[ih] = st.z[0]; if (ih > 0 && (z[ih] - z[ih - 1]) < 0.1) continue; st.fieldSlice.GetFieldValue(mcP.x, mcP.y, B[ih]); @@ -1211,8 +1211,8 @@ void CbmL1::TrackFitPerformance() if (ih == 3) break; } if (ih < 3) continue; - CbmL1MCPoint& mcP = vMCPoints[mc.Points[0]]; - targB = algo->GetParameters()->GetVertexFieldValue(); + CbmL1MCPoint& mcP = fvMCPoints[mc.Points[0]]; + targB = fpAlgo->GetParameters()->GetVertexFieldValue(); fld.Set(B[0], z[0], B[1], z[1], B[2], z[2]); L1Extrapolate(trPar, mcP.zIn, trPar.qp, fld); @@ -1261,14 +1261,14 @@ void CbmL1::TrackFitPerformance() if (finite(trPar.C44[0]) && trPar.C44[0] > 0) h_fit[9]->Fill((trPar.qp[0] - mcP.q / mcP.p) / sqrt(trPar.C44[0])); h_fit[10]->Fill(trPar.qp[0]); h_fit[11]->Fill(mcP.q / mcP.p); - if (last_station > NMvdStations) h_fit[12]->Fill(trPar.t[0] - mcP.time); - if (last_station > NMvdStations) + if (last_station > fNMvdStations) h_fit[12]->Fill(trPar.t[0] - mcP.time); + if (last_station > fNMvdStations) if (finite(trPar.C55[0]) && trPar.C55[0] > 0) h_fit[13]->Fill((trPar.t[0] - mcP.time) / sqrt(trPar.C55[0])); #else - int iMC = vHitMCRef[it->Hits.front()]; // TODO2: adapt to linking + int iMC = fvHitPointIndexes[it->Hits.front()]; // TODO2: adapt to linking if (iMC < 0) continue; - CbmL1MCPoint& mc = vMCPoints[iMC]; + CbmL1MCPoint& mc = fvMCPoints[iMC]; // if( !( mc.pdg == -11 && mc.mother_ID == -1 ) ) continue; // electrons only h_fit[0]->Fill((mc.x - it->T[0]) * 1.e4); h_fit[1]->Fill((mc.y - it->T[1]) * 1.e4); @@ -1296,14 +1296,14 @@ void CbmL1::TrackFitPerformance() } - { // last hit - int iMC = vHitMCRef[it->Hits.back()]; // TODO2: adapt to linking + { // last hit + int iMC = fvHitPointIndexes[it->Hits.back()]; // TODO2: adapt to linking if (iMC < 0) continue; #define L1FSTPARAMEXTRAPOLATE #ifdef L1FSTPARAMEXTRAPOLATE - const int last_station = vHitStore[it->Hits.back()].iStation; + const int last_station = fvHitStore[it->Hits.back()].iStation; CbmL1MCTrack mc = *(it->GetMCTracks()[0]); L1TrackPar trPar(it->TLast, it->CLast); @@ -1313,8 +1313,8 @@ void CbmL1::TrackFitPerformance() int ih = 0; for (unsigned int iMCPoint = 0; iMCPoint < mc.Points.size(); iMCPoint++) { const int iMCP = mc.Points[iMCPoint]; - CbmL1MCPoint& mcP = vMCPoints[iMCP]; - const L1Station& st = algo->GetParameters()->GetStation(mcP.iStation); + CbmL1MCPoint& mcP = fvMCPoints[iMCP]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(mcP.iStation); z[ih] = st.z[0]; if (ih > 0 && (z[ih] - z[ih - 1]) < 0.1) continue; st.fieldSlice.GetFieldValue(mcP.x, mcP.y, B[ih]); @@ -1322,8 +1322,8 @@ void CbmL1::TrackFitPerformance() if (ih == 3) break; } if (ih < 3) continue; - CbmL1MCPoint& mcP = vMCPoints[iMC]; - targB = algo->GetParameters()->GetVertexFieldValue(); + CbmL1MCPoint& mcP = fvMCPoints[iMC]; + targB = fpAlgo->GetParameters()->GetVertexFieldValue(); fld.Set(B[0], z[0], B[1], z[1], B[2], z[2]); L1Extrapolate(trPar, mcP.zOut, trPar.qp, fld); @@ -1332,7 +1332,7 @@ void CbmL1::TrackFitPerformance() h_fitL[2]->Fill((trPar.tx[0] - mcP.pxOut / mcP.pzOut) * 1.e3); h_fitL[3]->Fill((trPar.ty[0] - mcP.pyOut / mcP.pzOut) * 1.e3); h_fitL[4]->Fill(fabs(1. / trPar.qp[0]) / mcP.p - 1); - if (last_station > NMvdStations) h_fitL[12]->Fill(trPar.t[0] - mcP.time); + if (last_station > fNMvdStations) h_fitL[12]->Fill(trPar.t[0] - mcP.time); if (finite(trPar.C00[0]) && trPar.C00[0] > 0) h_fitL[5]->Fill((trPar.x[0] - mcP.xOut) / sqrt(trPar.C00[0])); @@ -1344,10 +1344,10 @@ void CbmL1::TrackFitPerformance() if (finite(trPar.C44[0]) && trPar.C44[0] > 0) h_fitL[9]->Fill((trPar.qp[0] - mcP.q / mcP.p) / sqrt(trPar.C44[0])); h_fitL[10]->Fill(trPar.qp[0]); h_fitL[11]->Fill(mcP.q / mcP.p); - if (last_station > NMvdStations) + if (last_station > fNMvdStations) if (finite(trPar.C55[0]) && trPar.C55[0] > 0) h_fitL[13]->Fill((trPar.t[0] - mcP.time) / sqrt(trPar.C55[0])); #else - CbmL1MCPoint& mc = vMCPoints[iMC]; + CbmL1MCPoint& mc = fvMCPoints[iMC]; h_fitL[0]->Fill((it->TLast[0] - mc.x) * 1.e4); h_fitL[1]->Fill((it->TLast[1] - mc.y) * 1.e4); @@ -1384,8 +1384,8 @@ void CbmL1::TrackFitPerformance() for (unsigned int ih = 0; ih < 3; ih++) { if (ih >= mc.Points.size()) continue; //If nofMCPoints in track < 3 const int iMCP = mc.Points[ih]; - CbmL1MCPoint& mcP = vMCPoints[iMCP]; - const L1Station& st = algo->GetParameters()->GetStation(mcP.iStation); + CbmL1MCPoint& mcP = fvMCPoints[iMCP]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(mcP.iStation); z[ih] = st.z[0]; st.fieldSlice.GetFieldValue(mcP.x, mcP.y, B[ih]); }; @@ -1393,16 +1393,16 @@ void CbmL1::TrackFitPerformance() L1Extrapolate(trPar, mc.z, trPar.qp, fld); // add material - const int fSta = vHitStore[it->Hits[0]].iStation; - const int dir = int((mc.z - algo->GetParameters()->GetStation(fSta).z[0]) - / fabs(mc.z - algo->GetParameters()->GetStation(fSta).z[0])); - // if (abs(mc.z - algo->GetParameters()->GetStation(fSta).z[0]) > 10.) continue; // can't extrapolate on large distance - for (int iSta = fSta /*+dir*/; - (iSta >= 0) && (iSta < NStation) && (dir * (mc.z - algo->GetParameters()->GetStation(iSta).z[0]) > 0); + const int fSta = fvHitStore[it->Hits[0]].iStation; + const int dir = int((mc.z - fpAlgo->GetParameters()->GetStation(fSta).z[0]) + / fabs(mc.z - fpAlgo->GetParameters()->GetStation(fSta).z[0])); + // if (abs(mc.z - fpAlgo->GetParameters()->GetStation(fSta).z[0]) > 10.) continue; // can't extrapolate on large distance + for (int iSta = fSta /*+dir*/; (iSta >= 0) && (iSta < fNStations) + && (dir * (mc.z - fpAlgo->GetParameters()->GetStation(iSta).z[0]) > 0); iSta += dir) { // cout << iSta << " " << dir << endl; - fit.L1AddMaterial(trPar, algo->GetParameters()->GetStation(iSta).materialInfo, trPar.qp, 1); - if (iSta + dir == NMvdStations - 1) fit.L1AddPipeMaterial(trPar, trPar.qp, 1); + fit.L1AddMaterial(trPar, fpAlgo->GetParameters()->GetStation(iSta).materialInfo, trPar.qp, 1); + if (iSta + dir == fNMvdStations - 1) fit.L1AddPipeMaterial(trPar, trPar.qp, 1); } } if (mc.z != trPar.z[0]) continue; @@ -1445,41 +1445,42 @@ void CbmL1::TrackFitPerformance() L1FieldValue B[3], targB _fvecalignment; float z[3]; - targB = algo->GetParameters()->GetVertexFieldValue(); + targB = fpAlgo->GetParameters()->GetVertexFieldValue(); int ih = 1; for (unsigned int iHit = 0; iHit < it->Hits.size(); iHit++) { - const int iStation = vHitStore[it->Hits[iHit]].iStation; - const L1Station& st = algo->GetParameters()->GetStation(iStation); + const int iStation = fvHitStore[it->Hits[iHit]].iStation; + const L1Station& st = fpAlgo->GetParameters()->GetStation(iStation); z[ih] = st.z[0]; - st.fieldSlice.GetFieldValue(vHitStore[it->Hits[iHit]].x, vHitStore[it->Hits[iHit]].y, B[ih]); + st.fieldSlice.GetFieldValue(fvHitStore[it->Hits[iHit]].x, fvHitStore[it->Hits[iHit]].y, B[ih]); ih++; if (ih == 3) break; } if (ih < 3) continue; // add material - const int fSta = vHitStore[it->Hits[0]].iStation; + const int fSta = fvHitStore[it->Hits[0]].iStation; - const int dir = (mc.z - algo->GetParameters()->GetStation(fSta).z[0]) - / abs(mc.z - algo->GetParameters()->GetStation(fSta).z[0]); - // if (abs(mc.z - algo->GetParameters()->GetStation(fSta].z[0]) > 10.) continue; // can't extrapolate on large distance + const int dir = (mc.z - fpAlgo->GetParameters()->GetStation(fSta).z[0]) + / abs(mc.z - fpAlgo->GetParameters()->GetStation(fSta).z[0]); + // if (abs(mc.z - fpAlgo->GetParameters()->GetStation(fSta].z[0]) > 10.) continue; // can't extrapolate on large distance - for (int iSta = fSta + dir; - (iSta >= 0) && (iSta < NStation) && (dir * (mc.z - algo->GetParameters()->GetStation(iSta).z[0]) > 0); + for (int iSta = fSta + dir; (iSta >= 0) && (iSta < fNStations) + && (dir * (mc.z - fpAlgo->GetParameters()->GetStation(iSta).z[0]) > 0); iSta += dir) { - z[0] = algo->GetParameters()->GetStation(iSta).z[0]; + z[0] = fpAlgo->GetParameters()->GetStation(iSta).z[0]; float dz = z[1] - z[0]; - algo->GetParameters()->GetStation(iSta).fieldSlice.GetFieldValue(trPar.x - trPar.tx * dz, - trPar.y - trPar.ty * dz, B[0]); + fpAlgo->GetParameters()->GetStation(iSta).fieldSlice.GetFieldValue(trPar.x - trPar.tx * dz, + trPar.y - trPar.ty * dz, B[0]); fld.Set(B[0], z[0], B[1], z[1], B[2], z[2]); - L1Extrapolate(trPar, algo->GetParameters()->GetStation(iSta).z[0], trPar.qp, fld); - fit.L1AddMaterial(trPar, algo->GetParameters()->GetMaterialThickness(iSta, trPar.x, trPar.y), trPar.qp, 1); - fit.EnergyLossCorrection(trPar, algo->GetParameters()->GetMaterialThickness(iSta, trPar.x, trPar.y), + L1Extrapolate(trPar, fpAlgo->GetParameters()->GetStation(iSta).z[0], trPar.qp, fld); + fit.L1AddMaterial(trPar, fpAlgo->GetParameters()->GetMaterialThickness(iSta, trPar.x, trPar.y), trPar.qp, + 1); + fit.EnergyLossCorrection(trPar, fpAlgo->GetParameters()->GetMaterialThickness(iSta, trPar.x, trPar.y), trPar.qp, fvec(1.f), fvec(1.f)); - if (iSta + dir == NMvdStations - 1) { + if (iSta + dir == fNMvdStations - 1) { fit.L1AddPipeMaterial(trPar, trPar.qp, 1); fit.EnergyLossCorrection(trPar, fit.PipeRadThick, trPar.qp, fvec(1.f), fvec(1.f)); } @@ -1586,16 +1587,16 @@ void CbmL1::FieldApproxCheck() fout->cd(); FairField* MF = CbmKF::Instance()->GetMagneticField(); - for (int ist = 0; ist < NStation; ist++) { + for (int ist = 0; ist < fNStations; ist++) { double z = 0; double Xmax = -100, Ymax = -100; - if (ist < NMvdStations) { + if (ist < fNMvdStations) { CbmKFTube& t = CbmKF::Instance()->vMvdMaterial[ist]; z = t.z; Xmax = Ymax = t.R; } else { - CbmStsStation* station = CbmStsSetup::Instance()->GetStation(ist - NMvdStations); + CbmStsStation* station = CbmStsSetup::Instance()->GetStation(ist - fNMvdStations); z = station->GetZ(); Xmax = station->GetXmax(); @@ -1630,7 +1631,7 @@ void CbmL1::FieldApproxCheck() const int M = 5; // polinom order const int N = (M + 1) * (M + 2) / 2; - const L1Station& st = algo->GetParameters()->GetStation(ist); + const L1Station& st = fpAlgo->GetParameters()->GetStation(ist); for (int i = 0; i < N; i++) { FSl.cx[i] = st.fieldSlice.cx[i][0]; FSl.cy[i] = st.fieldSlice.cy[i][0]; @@ -1929,22 +1930,22 @@ void CbmL1::InputPerformance() map<unsigned int, unsigned int>::iterator it; - if (listStsHits && listStsHitMatch) { - for (unsigned int iH = 0; iH < vHits.size(); iH++) { - const CbmL1Hit& h = vHits[iH]; + if (fpStsHits && fpStsHitMatches) { + for (unsigned int iH = 0; iH < fvExternalHits.size(); iH++) { + const CbmL1Hit& h = fvExternalHits[iH]; if (h.Det != 1) continue; // not sts hit - const CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(h.extIndex)); + const CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(h.extIndex)); // int iMCPoint = -1; CbmLink link; CbmStsPoint* pt = 0; - if (listStsClusterMatch) { + if (fpStsClusterMatches) { const CbmMatch* frontClusterMatch = - static_cast<const CbmMatch*>(listStsClusterMatch->At(sh->GetFrontClusterId())); + static_cast<const CbmMatch*>(fpStsClusterMatches->At(sh->GetFrontClusterId())); const CbmMatch* backClusterMatch = - static_cast<const CbmMatch*>(listStsClusterMatch->At(sh->GetBackClusterId())); + static_cast<const CbmMatch*>(fpStsClusterMatches->At(sh->GetBackClusterId())); CbmMatch stsHitMatch; for (Int_t iFrontLink = 0; iFrontLink < frontClusterMatch->GetNofLinks(); iFrontLink++) { @@ -1967,7 +1968,7 @@ void CbmL1::InputPerformance() bestWeight = link.GetWeight(); Int_t iFile = link.GetFile(); Int_t iEvent = link.GetEntry(); - pt = (CbmStsPoint*) fStsPoints->Get(iFile, iEvent, link.GetIndex()); + pt = (CbmStsPoint*) fpStsPoints->Get(iFile, iEvent, link.GetIndex()); } } } @@ -1976,7 +1977,7 @@ void CbmL1::InputPerformance() double mcTime = pt->GetTime(); - if (!fLegacyEventMode) mcTime += fEventList->GetEventTime(link.GetEntry(), link.GetFile()); + if (!fLegacyEventMode) mcTime += fpEventList->GetEventTime(link.GetEntry(), link.GetFile()); // hit pulls and residuals @@ -2000,9 +2001,9 @@ void CbmL1::InputPerformance() } else { // errors used in TF pullXsts->Fill((hitPos.X() - mcPos.X()) - / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C00[0])); + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C00[0])); pullYsts->Fill((hitPos.Y() - mcPos.Y()) - / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C11[0])); + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C11[0])); } resXsts->Fill((hitPos.X() - mcPos.X()) * 10 * 1000); @@ -2013,12 +2014,12 @@ void CbmL1::InputPerformance() } // sts - if (listMvdHits && listMvdHitMatches) { - Int_t nEnt = listMvdHits->GetEntriesFast(); + if (fpMvdHits && fpMvdHitMatches) { + Int_t nEnt = fpMvdHits->GetEntriesFast(); for (int j = 0; j < nEnt; j++) { - CbmMvdHit* sh = L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(j)); - CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(listMvdHitMatches->At(j)); + CbmMvdHit* sh = L1_DYNAMIC_CAST<CbmMvdHit*>(fpMvdHits->At(j)); + CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(fpMvdHitMatches->At(j)); CbmMvdPoint* pt = nullptr; { @@ -2027,7 +2028,7 @@ void CbmL1::InputPerformance() const CbmLink& link = hm->GetLink(iLink); if (link.GetWeight() < mcWeight) continue; mcWeight = link.GetWeight(); - pt = dynamic_cast<CbmMvdPoint*>(fMvdPoints->Get(&link)); + pt = dynamic_cast<CbmMvdPoint*>(fpMvdPoints->Get(&link)); } } if (!pt) continue; @@ -2048,9 +2049,9 @@ void CbmL1::InputPerformance() // if (hitErr.Y() != 0) pullY->Fill( (hitPos.Y() - mcPos.Y()) / sh->GetDy() ); if (hitErr.X() != 0) pullXmvd->Fill((hitPos.X() - mcPos.X()) - / sqrt(algo->GetParameters()->GetStation(0).XYInfo.C00[0])); // errors used in TF + / sqrt(fpAlgo->GetParameters()->GetStation(0).XYInfo.C00[0])); // errors used in TF if (hitErr.Y() != 0) - pullYmvd->Fill((hitPos.Y() - mcPos.Y()) / sqrt(algo->GetParameters()->GetStation(0).XYInfo.C11[0])); + pullYmvd->Fill((hitPos.Y() - mcPos.Y()) / sqrt(fpAlgo->GetParameters()->GetStation(0).XYInfo.C11[0])); resXmvd->Fill((hitPos.X() - mcPos.X()) * 10 * 1000); resYmvd->Fill((hitPos.Y() - mcPos.Y()) * 10 * 1000); @@ -2058,14 +2059,14 @@ void CbmL1::InputPerformance() } // mvd - if (fMuchPixelHits && listMuchHitMatches) { - for (unsigned int iH = 0; iH < vHits.size(); iH++) { - const CbmL1Hit& h = vHits[iH]; + if (fpMuchPixelHits && fpMuchHitMatches) { + for (unsigned int iH = 0; iH < fvExternalHits.size(); iH++) { + const CbmL1Hit& h = fvExternalHits[iH]; if (h.Det != 2) continue; // mvd hit - const CbmMuchPixelHit* sh = L1_DYNAMIC_CAST<CbmMuchPixelHit*>(fMuchPixelHits->At(h.extIndex)); - CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(listMuchHitMatches->At(h.extIndex)); + const CbmMuchPixelHit* sh = L1_DYNAMIC_CAST<CbmMuchPixelHit*>(fpMuchPixelHits->At(h.extIndex)); + CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(fpMuchHitMatches->At(h.extIndex)); if (hm->GetNofLinks() == 0) continue; @@ -2084,10 +2085,10 @@ void CbmL1::InputPerformance() } if (bestWeight / totalWeight < 0.7 || iMCPoint < 0) continue; - CbmMuchPoint* pt = (CbmMuchPoint*) fMuchPoints->Get(link.GetFile(), link.GetEntry(), link.GetIndex()); + CbmMuchPoint* pt = (CbmMuchPoint*) fpMuchPoints->Get(link.GetFile(), link.GetEntry(), link.GetIndex()); double mcTime = pt->GetTime(); - if (!fLegacyEventMode) mcTime += fEventList->GetEventTime(link.GetEntry(), link.GetFile()); + if (!fLegacyEventMode) mcTime += fpEventList->GetEventTime(link.GetEntry(), link.GetFile()); // mcTime+=20; // hit pulls and residuals @@ -2116,8 +2117,10 @@ void CbmL1::InputPerformance() pullTmuch->Fill((h.t - mcTime) / sh->GetTimeError()); } else { // errors used in TF - pullXmuch->Fill((hitPos.X() - mcPos.X()) / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C00[0])); - pullYmuch->Fill((hitPos.Y() - mcPos.Y()) / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C11[0])); + pullXmuch->Fill((hitPos.X() - mcPos.X()) + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C00[0])); + pullYmuch->Fill((hitPos.Y() - mcPos.Y()) + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C11[0])); } resXmuch->Fill((h.x - mcPos.X()) * 10 * 1000); @@ -2127,13 +2130,13 @@ void CbmL1::InputPerformance() } // much - if (listTrdHits && fTrdHitMatches) { - for (unsigned int iH = 0; iH < vHits.size(); iH++) { - const CbmL1Hit& h = vHits[iH]; + if (fpTrdHits && fpTrdHitMatches) { + for (unsigned int iH = 0; iH < fvExternalHits.size(); iH++) { + const CbmL1Hit& h = fvExternalHits[iH]; if (h.Det != 3) continue; // mvd hit - const CbmTrdHit* sh = L1_DYNAMIC_CAST<CbmTrdHit*>(listTrdHits->At(h.extIndex)); - CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(fTrdHitMatches->At(h.extIndex)); + const CbmTrdHit* sh = L1_DYNAMIC_CAST<CbmTrdHit*>(fpTrdHits->At(h.extIndex)); + CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(fpTrdHitMatches->At(h.extIndex)); if (hm->GetNofLinks() == 0) continue; @@ -2154,10 +2157,10 @@ void CbmL1::InputPerformance() } if (bestWeight / totalWeight < 0.7 || iMCPoint < 0) continue; - CbmTrdPoint* pt = (CbmTrdPoint*) fTrdPoints->Get(link.GetFile(), link.GetEntry(), link.GetIndex()); + CbmTrdPoint* pt = (CbmTrdPoint*) fpTrdPoints->Get(link.GetFile(), link.GetEntry(), link.GetIndex()); double mcTime = pt->GetTime(); - if (!fLegacyEventMode) mcTime += fEventList->GetEventTime(link.GetEntry(), link.GetFile()); + if (!fLegacyEventMode) mcTime += fpEventList->GetEventTime(link.GetEntry(), link.GetFile()); // hit pulls and residuals // if ((sh->GetPlaneId()) == 0) continue; @@ -2183,8 +2186,10 @@ void CbmL1::InputPerformance() pullTtrd->Fill((h.t - mcTime) / sh->GetTimeError()); } else { // errors used in TF - pullXtrd->Fill((hitPos.X() - mcPos.X()) / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C00[0])); - pullYtrd->Fill((hitPos.Y() - mcPos.Y()) / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C11[0])); + pullXtrd->Fill((hitPos.X() - mcPos.X()) + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C00[0])); + pullYtrd->Fill((hitPos.Y() - mcPos.Y()) + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C11[0])); } resXtrd->Fill((h.x - mcPos.X()) * 10 * 1000); @@ -2195,14 +2200,14 @@ void CbmL1::InputPerformance() } // much - if (fTofHits && fTofHitDigiMatches) { - for (unsigned int iH = 0; iH < vHits.size(); iH++) { - const CbmL1Hit& h = vHits[iH]; + if (fpTofHits && fpTofHitMatches) { + for (unsigned int iH = 0; iH < fvExternalHits.size(); iH++) { + const CbmL1Hit& h = fvExternalHits[iH]; if (h.Det != 4) continue; // mvd hit - CbmTofHit* sh = L1_DYNAMIC_CAST<CbmTofHit*>(fTofHits->At(h.extIndex)); - CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(fTofHitDigiMatches->At(h.extIndex)); + CbmTofHit* sh = L1_DYNAMIC_CAST<CbmTofHit*>(fpTofHits->At(h.extIndex)); + CbmMatch* hm = L1_DYNAMIC_CAST<CbmMatch*>(fpTofHitMatches->At(h.extIndex)); if (hm->GetNofLinks() == 0) continue; @@ -2224,10 +2229,10 @@ void CbmL1::InputPerformance() if (iMCPoint < 0) continue; - CbmTofPoint* pt = (CbmTofPoint*) fTofPoints->Get(link.GetFile(), link.GetEntry(), link.GetIndex()); + CbmTofPoint* pt = (CbmTofPoint*) fpTofPoints->Get(link.GetFile(), link.GetEntry(), link.GetIndex()); double mcTime = pt->GetTime(); - if (!fLegacyEventMode) mcTime += fEventList->GetEventTime(link.GetEntry(), link.GetFile()); + if (!fLegacyEventMode) mcTime += fpEventList->GetEventTime(link.GetEntry(), link.GetFile()); // hit pulls and residuals @@ -2251,8 +2256,10 @@ void CbmL1::InputPerformance() pullTtof->Fill((sh->GetTime() - mcTime) / sh->GetTimeError()); } else { // errors used in TF - pullXtof->Fill((hitPos.X() - mcPos.X()) / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C00[0])); - pullYtof->Fill((hitPos.Y() - mcPos.Y()) / sqrt(algo->GetParameters()->GetStation(NMvdStations).XYInfo.C11[0])); + pullXtof->Fill((hitPos.X() - mcPos.X()) + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C00[0])); + pullYtof->Fill((hitPos.Y() - mcPos.Y()) + / sqrt(fpAlgo->GetParameters()->GetStation(fNMvdStations).XYInfo.C11[0])); } resXtof->Fill((h.x - mcPos.X()) * 10 * 1000); diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx index 6c92b96a67..fc6a9c5b83 100644 --- a/reco/L1/CbmL1ReadEvent.cxx +++ b/reco/L1/CbmL1ReadEvent.cxx @@ -62,7 +62,7 @@ using std::find; static bool compareZ(const int& a, const int& b) { - // return (CbmL1::Instance()->vMCPoints[a].z < CbmL1::Instance()->vMCPoints[b].z); + // return (CbmL1::Instance()->fvMCPoints[a].z < CbmL1::Instance()->fvMCPoints[b].z); const CbmL1* l1 = CbmL1::Instance(); return l1->Get_Z_vMCPoint(a) < l1->Get_Z_vMCPoint(b); } @@ -71,21 +71,30 @@ static bool compareZ(const int& a, const int& b) /// The structure is used to sort hits before writing them into L1 input arrays /// struct TmpHit { - int iStripF; ///< index of front strip - int iStripB; ///< index of back strip - int iStation; ///< index of station - int ExtIndex; ///< index of hit in the external TClonesArray array (NOTE: negative for MVD) - double u_front, u_back; ///< positions of strips - double x, y, z; ///< position of hit (Cartesian coordinates) - double xmc, ymc, p; ///< mc position of hit, total momentum - double tx, ty; ///< mc slopes of the mc point - double dx, dy, dxy; ///< hit position errors in Cortesian coordinates - double du, dv; ///< hit position errors in strips coordinates - int iMC; ///< index of MCPoint in the vMCPoints array - double time = 0.; ///< time of the hit - double dt = 1.e10; ///< time error of the hit + int iStripF; ///< index of front strip + int iStripB; ///< index of back strip + int iStation; ///< index of station + int ExtIndex; ///< index of hit in the external TClonesArray array (NOTE: negative for MVD) + double u; ///< position of hit along axis orthogonal to front strips [cm] + double v; ///< position of hit along axis orthogonal to back strips [cm] + double x; ///< position of hit along x axis [cm] + double y; ///< position of hit along y axis [cm] + double z; ///< position of hit along z axis [cm] + double dx; ///< hit position uncertainty along x axis [cm] + double dy; ///< hit position uncertainty along y axis [cm] + double dxy; ///< hit position covariance along x and y axes [cm2] + double du; ///< hit position uncertainty along axis orthogonal to front strips [cm] + double dv; ///< hit position uncertainty along axis orthogonal to back strips [cm] + double xmc; ///< MC position of hit [cm] + double ymc; ///< MC position of hit [cm] + double p; ///< MC total momentum [GeV/c] + double tx; ///< MC slopes of the mc point + double ty; ///< MC slopes of the mc point + int iMC; ///< index of MCPoint in the fvMCPoints array + double time = 0.; ///< time of the hit [ns] + double dt = 1.e10; ///< time error of the hit [ns] int Det; - int id; + int id; ///< index of hit before hits sorting int track; /// Provides comparison of two hits. @@ -129,12 +138,12 @@ struct TmpHit { du = sqrt(st.frontInfo.sigma2[0]); dv = sqrt(st.backInfo.sigma2[0]); - std::tie(u_front, u_back) = st.ConvXYtoUV(point.x, point.y); + std::tie(u, v) = st.ConvXYtoUV<double>(point.x, point.y); - u_front += gRandom->Gaus(0, du); - u_back += gRandom->Gaus(0, dv); + u += gRandom->Gaus(0, du); + v += gRandom->Gaus(0, dv); - std::tie(x, y) = st.ConvUVtoXY(u_front, u_back); + std::tie(x, y) = st.ConvUVtoXY<double>(u, v); z = point.z; xmc = point.x; @@ -153,12 +162,12 @@ struct TmpHit { // TODO: Probably, L1Station& st parameter should be constant. Do we really want to modify a station here? (S.Zharko) void SetHitFromPoint(const CbmL1MCPoint& point, const L1Station& st, bool doSmear = 1) { - x = 0.5 * (point.xIn + point.xOut); - y = 0.5 * (point.yIn + point.yOut); - z = 0.5 * (point.zIn + point.zOut); - time = point.time; - u_front = x * st.frontInfo.cos_phi[0] + y * st.frontInfo.sin_phi[0]; - u_back = x * st.backInfo.cos_phi[0] + y * st.backInfo.sin_phi[0]; + x = 0.5 * (point.xIn + point.xOut); + y = 0.5 * (point.yIn + point.yOut); + z = 0.5 * (point.zIn + point.zOut); + time = point.time; + u = x * st.frontInfo.cos_phi[0] + y * st.frontInfo.sin_phi[0]; + v = x * st.backInfo.cos_phi[0] + y * st.backInfo.sin_phi[0]; if (doSmear) { x += gRandom->Gaus(0, dx); y += gRandom->Gaus(0, dy); @@ -177,41 +186,41 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, fData_->Clear(); // clear arrays for next event - vMCPoints.clear(); /* <CbmL1MCPoint> */ - vMCPoints_in_Time_Slice.clear(); /* <int> */ - vMCTracks.clear(); /* <CbmL1MCTrack> */ - vHits.clear(); /* <CbmL1Hit> */ - vRTracks.clear(); /* <CbmL1Track> */ - vHitMCRef.clear(); /* <int>: indexes of MC-points in vMCPoints (by index of algo->vHits) */ - vHitStore.clear(); /* <CbmL1HitStore> */ + fvMCPoints.clear(); /* <CbmL1MCPoint> */ + fvMCTracks.clear(); /* <CbmL1MCTrack> */ + fvExternalHits.clear(); /* <CbmL1Hit> */ + fvRecoTracks.clear(); /* <CbmL1Track> */ // TODO: Move from this function to more suitable place (S.Zharko) + fvHitPointIndexes.clear(); /* <int>: indexes of MC-points in fvMCPoints (by index of fpAlgo->vHits) */ + fvHitStore.clear(); /* <CbmL1HitStore> */ dFEI2vMCPoints.clear(); /* dFEI vs MC-point index: dFEI = index * 10000 + fileID + eventID * 0.0001 */ dFEI2vMCTracks.clear(); /* dFEI vs MC-track index: dFEI = index * 10000 + fileID + eventID * 0.0001 */ + if (fVerbose >= 10) cout << "ReadEvent: clear is done." << endl; L1Vector<TmpHit> tmpHits("CbmL1ReadEvent::tmpHits"); { // reserve enough space for hits int nHitsTotal = 0; - if (fUseMVD && listMvdHits) nHitsTotal += listMvdHits->GetEntriesFast(); + if (fUseMVD && fpMvdHits) nHitsTotal += fpMvdHits->GetEntriesFast(); Int_t nEntSts = 0; - if (fUseSTS && listStsHits) { + if (fUseSTS && fpStsHits) { if (event) { nEntSts = event->GetNofData(ECbmDataType::kStsHit); } else { - nEntSts = listStsHits->GetEntriesFast(); + nEntSts = fpStsHits->GetEntriesFast(); } if (nEntSts < 0) nEntSts = 0; // GetNofData() can return -1; } nHitsTotal += nEntSts; - if (fUseMUCH && fMuchPixelHits) nHitsTotal += fMuchPixelHits->GetEntriesFast(); - if (fUseTRD && listTrdHits) nHitsTotal += listTrdHits->GetEntriesFast(); - if (fUseTOF && fTofHits) nHitsTotal += fTofHits->GetEntriesFast(); + if (fUseMUCH && fpMuchPixelHits) nHitsTotal += fpMuchPixelHits->GetEntriesFast(); + if (fUseTRD && fpTrdHits) nHitsTotal += fpTrdHits->GetEntriesFast(); + if (fUseTOF && fpTofHits) nHitsTotal += fpTofHits->GetEntriesFast(); tmpHits.reserve(nHitsTotal); } // -- produce Sts hits from space points -- - for (int i = 0; i < NStation; i++) { + for (int i = 0; i < fNStations; i++) { fData_->HitsStartIndex[i] = static_cast<L1HitIndex_t>(-1); fData_->HitsStopIndex[i] = 0; @@ -245,32 +254,32 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, */ if (fPerformance) { - // Fill vMCTracks and dFEI2vMCTracks + // Fill fvMCTracks and dFEI2vMCTracks Fill_vMCTracks(); - // Fill vMCPoints, vMCPoints_in_Time_Slice and dFEI2vMCPoints - vMCPoints.clear(); - vMCPoints.reserve(5 * vMCTracks.size() * NStation); - vMCPoints_in_Time_Slice.clear(); - vMCPoints_in_Time_Slice.reserve(vMCPoints.capacity()); + // Fill fvMCPoints and dFEI2vMCPoints + fvMCPoints.clear(); + fvMCPoints.reserve(5 * fvMCTracks.size() * fNStations); + fvMCPointIndexesTs.clear(); + fvMCPointIndexesTs.reserve(fvMCPoints.capacity()); - for (DFSET::iterator set_it = vFileEvent.begin(); set_it != vFileEvent.end(); ++set_it) { + for (DFSET::iterator set_it = fvFileEvent.begin(); set_it != fvFileEvent.end(); ++set_it) { Int_t iFile = set_it->first; Int_t iEvent = set_it->second; - if (fUseMVD && fMvdPoints) { - Int_t nMvdPointsInEvent = fMvdPoints->Size(iFile, iEvent); + if (fUseMVD && fpMvdPoints) { + Int_t nMvdPointsInEvent = fpMvdPoints->Size(iFile, iEvent); double maxDeviation = 0; for (Int_t iMC = 0; iMC < nMvdPointsInEvent; iMC++) { CbmL1MCPoint MC; if (!ReadMCPoint(&MC, iMC, iFile, iEvent, 1)) { MC.iStation = -1; - const L1Station* sta = algo->GetParameters()->GetStations().begin(); + const L1Station* sta = fpAlgo->GetParameters()->GetStations().begin(); double bestDist = 1.e20; - for (Int_t iSt = 0; iSt < NMvdStationsGeom; iSt++) { + for (Int_t iSt = 0; iSt < fNMvdStationsGeom; iSt++) { // use z_in since z_out is sometimes very wrong // due to a problem in transport - int iStActive = algo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kMvd); + int iStActive = fpAlgo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kMvd); if (iStActive == -1) { continue; } double d = (MC.zIn - sta[iStActive].z[0]); if (fabs(d) < fabs(bestDist)) { @@ -284,30 +293,30 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, DFEI2I::iterator trk_it = dFEI2vMCTracks.find(dtrck); assert(trk_it != dFEI2vMCTracks.end()); MC.ID = trk_it->second; - vMCTracks[MC.ID].Points.push_back_no_warning(vMCPoints.size()); - dFEI2vMCPoints.insert(DFEI2I::value_type(dFEI(iFile, iEvent, iMC), vMCPoints.size())); - vMCPoints.push_back(MC); - vMCPoints_in_Time_Slice.push_back(0); + fvMCTracks[MC.ID].Points.push_back_no_warning(fvMCPoints.size()); + dFEI2vMCPoints.insert(DFEI2I::value_type(dFEI(iFile, iEvent, iMC), fvMCPoints.size())); + fvMCPoints.push_back(MC); + fvMCPointIndexesTs.push_back(0); nMvdPoints++; } } if (fVerbose > 2) { LOG(info) << "CbmL1ReadEvent: max deviation of Mvd points " << maxDeviation; } // ensure that the nominal station positions are not far from the sensors // assert(fabs(maxDeviation) < 1.); - } // fMvdPoints + } // fpMvdPoints - firstStsPoint = vMCPoints.size(); - if (fUseSTS && fStsPoints) { - Int_t nMC = fStsPoints->Size(iFile, iEvent); + firstStsPoint = fvMCPoints.size(); + if (fUseSTS && fpStsPoints) { + Int_t nMC = fpStsPoints->Size(iFile, iEvent); double maxDeviation = 0; for (Int_t iMC = 0; iMC < nMC; iMC++) { CbmL1MCPoint MC; if (!ReadMCPoint(&MC, iMC, iFile, iEvent, 0)) { MC.iStation = -1; - const L1Station* sta = algo->GetParameters()->GetStations().begin(); + const L1Station* sta = fpAlgo->GetParameters()->GetStations().begin(); double bestDist = 1.e20; - for (Int_t iSt = 0; iSt < NStsStationsGeom; iSt++) { - int iStActive = algo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kSts); + for (Int_t iSt = 0; iSt < fNStsStationsGeom; iSt++) { + int iStActive = fpAlgo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kSts); if (iStActive == -1) { continue; } // use z_in since z_out is sometimes very wrong // due to a problem in transport @@ -323,28 +332,28 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, DFEI2I::iterator trk_it = dFEI2vMCTracks.find(dtrck); assert(trk_it != dFEI2vMCTracks.end()); MC.ID = trk_it->second; - vMCTracks[MC.ID].Points.push_back_no_warning(vMCPoints.size()); - dFEI2vMCPoints.insert(DFEI2I::value_type(dFEI(iFile, iEvent, iMC + nMvdPoints), vMCPoints.size())); - vMCPoints.push_back(MC); - vMCPoints_in_Time_Slice.push_back(0); + fvMCTracks[MC.ID].Points.push_back_no_warning(fvMCPoints.size()); + dFEI2vMCPoints.insert(DFEI2I::value_type(dFEI(iFile, iEvent, iMC + nMvdPoints), fvMCPoints.size())); + fvMCPoints.push_back(MC); + fvMCPointIndexesTs.push_back(0); nStsPoints++; } } if (fVerbose > 2) { LOG(info) << "CbmL1ReadEvent: max deviation of Sts points " << maxDeviation; } // ensure that the nominal station positions are not far from the sensors // assert(fabs(maxDeviation) < 1.); - } // fStsPoints + } // fpStsPoints - firstMuchPoint = vMCPoints.size(); - if (fUseMUCH && fMuchPoints) { - Int_t nMC = fMuchPoints->Size(iFile, iEvent); + firstMuchPoint = fvMCPoints.size(); + if (fUseMUCH && fpMuchPoints) { + Int_t nMC = fpMuchPoints->Size(iFile, iEvent); for (Int_t iMC = 0; iMC < nMC; iMC++) { CbmL1MCPoint MC; if (!ReadMCPoint(&MC, iMC, iFile, iEvent, 2)) { MC.iStation = -1; - const L1Station* sta = algo->GetParameters()->GetStations().begin(); - for (Int_t iSt = 0; iSt < NMuchStationsGeom; iSt++) { - int iStActive = algo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kMuch); + const L1Station* sta = fpAlgo->GetParameters()->GetStations().begin(); + for (Int_t iSt = 0; iSt < fNMuchStationsGeom; iSt++) { + int iStActive = fpAlgo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kMuch); if (iStActive == -1) { continue; } if (MC.z > sta[iStActive].z[0] - 2.5) { MC.iStation = iStActive; } } @@ -353,26 +362,26 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, DFEI2I::iterator trk_it = dFEI2vMCTracks.find(dtrck); assert(trk_it != dFEI2vMCTracks.end()); MC.ID = trk_it->second; - vMCTracks[MC.ID].Points.push_back_no_warning(vMCPoints.size()); + fvMCTracks[MC.ID].Points.push_back_no_warning(fvMCPoints.size()); dFEI2vMCPoints.insert( - DFEI2I::value_type(dFEI(iFile, iEvent, iMC + nMvdPoints + nStsPoints), vMCPoints.size())); - vMCPoints.push_back(MC); - vMCPoints_in_Time_Slice.push_back(0); + DFEI2I::value_type(dFEI(iFile, iEvent, iMC + nMvdPoints + nStsPoints), fvMCPoints.size())); + fvMCPoints.push_back(MC); + fvMCPointIndexesTs.push_back(0); nMuchPoints++; } } - } // fMuchPoints + } // fpMuchPoints - firstTrdPoint = vMCPoints.size(); + firstTrdPoint = fvMCPoints.size(); - if (fUseTRD && fTrdPoints) { - for (Int_t iMC = 0; iMC < fTrdPoints->Size(iFile, iEvent); iMC++) { + if (fUseTRD && fpTrdPoints) { + for (Int_t iMC = 0; iMC < fpTrdPoints->Size(iFile, iEvent); iMC++) { CbmL1MCPoint MC; if (!ReadMCPoint(&MC, iMC, iFile, iEvent, 3)) { MC.iStation = -1; - const L1Station* sta = algo->GetParameters()->GetStations().begin(); - for (Int_t iSt = 0; iSt < NTrdStationsGeom; iSt++) { - int iStActive = algo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kTrd); + const L1Station* sta = fpAlgo->GetParameters()->GetStations().begin(); + for (Int_t iSt = 0; iSt < fNTrdStationsGeom; iSt++) { + int iStActive = fpAlgo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kTrd); if (iStActive == -1) { continue; } if (MC.z > sta[iStActive].z[0] - 4.0) { MC.iStation = iStActive; } } @@ -382,125 +391,124 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, DFEI2I::iterator trk_it = dFEI2vMCTracks.find(dtrck); assert(trk_it != dFEI2vMCTracks.end()); MC.ID = trk_it->second; - vMCTracks[MC.ID].Points.push_back_no_warning(vMCPoints.size()); + fvMCTracks[MC.ID].Points.push_back_no_warning(fvMCPoints.size()); dFEI2vMCPoints.insert( - DFEI2I::value_type(dFEI(iFile, iEvent, iMC + nMvdPoints + nStsPoints + nMuchPoints), vMCPoints.size())); - vMCPoints.push_back(MC); - vMCPoints_in_Time_Slice.push_back(0); + DFEI2I::value_type(dFEI(iFile, iEvent, iMC + nMvdPoints + nStsPoints + nMuchPoints), fvMCPoints.size())); + fvMCPoints.push_back(MC); + fvMCPointIndexesTs.push_back(0); nTrdPoints++; } } - } // fTrdPoints + } // fpTrdPoints - firstTofPoint = vMCPoints.size(); - if (fUseTOF && fTofPoints) { + firstTofPoint = fvMCPoints.size(); + if (fUseTOF && fpTofPoints) { - vector<float> TofPointToTrackdZ[NTOFStation]; + vector<float> TofPointToTrackdZ[fNTofStations]; - TofPointToTrack.resize(NTOFStation); + fTofPointToTrack.resize(fNTofStations); - for (Int_t i = 0; i < NTOFStation; i++) { + for (Int_t i = 0; i < fNTofStations; i++) { - TofPointToTrack[i].resize(vMCTracks.size(), 0); - TofPointToTrackdZ[i].resize(vMCTracks.size()); + fTofPointToTrack[i].resize(fvMCTracks.size(), 0); + TofPointToTrackdZ[i].resize(fvMCTracks.size()); } - for (int iSt = 0; iSt < NTOFStation; iSt++) + for (int iSt = 0; iSt < fNTofStations; iSt++) for (unsigned int i = 0; i < TofPointToTrackdZ[iSt].size(); i++) { TofPointToTrackdZ[iSt][i] = 100000; - TofPointToTrack[iSt][i] = -1; + fTofPointToTrack[iSt][i] = -1; } std::vector<char> isTofPointMatched; - isTofPointMatched.resize(fTofPoints->Size(iFile, iEvent), 0); + isTofPointMatched.resize(fpTofPoints->Size(iFile, iEvent), 0); - for (int iHit = 0; iHit < fTofHits->GetEntriesFast(); iHit++) { - CbmMatch* matchHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fTofHitDigiMatches->At(iHit)); - for (int iLink = 0; iLink < matchHitMatch->GetNofLinks(); iLink++) { - Int_t iMC = matchHitMatch->GetLink(iLink).GetIndex(); + for (int iHit = 0; iHit < fpTofHits->GetEntriesFast(); iHit++) { + CbmMatch* pHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fpTofHitMatches->At(iHit)); + for (int iLink = 0; iLink < pHitMatch->GetNofLinks(); iLink++) { + Int_t iMC = pHitMatch->GetLink(iLink).GetIndex(); isTofPointMatched[iMC] = 1; } } - for (Int_t iMC = 0; iMC < fTofPoints->Size(iFile, iEvent); iMC++) { + for (Int_t iMC = 0; iMC < fpTofPoints->Size(iFile, iEvent); iMC++) { if (isTofPointMatched[iMC] == 0) continue; CbmL1MCPoint MC; if (!ReadMCPoint(&MC, iMC, iFile, iEvent, 4)) { - Double_t dtrck = dFEI(iFile, iEvent, MC.ID); - DFEI2I::iterator trk_it = dFEI2vMCTracks.find(dtrck); + Double_t dtrck = dFEI(iFile, iEvent, MC.ID); + auto trk_it = dFEI2vMCTracks.find(dtrck); if (trk_it == dFEI2vMCTracks.end()) continue; Int_t iTrack = trk_it->second; MC.iStation = -1; - const L1Station* sta = algo->GetParameters()->GetStations().begin(); + const L1Station* sta = fpAlgo->GetParameters()->GetStations().begin(); float dist = 1000; int iSta = -1; - for (int iSt = 0; iSt < NTOFStationGeom; iSt++) { - int iStActive = algo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kTof); + for (int iSt = 0; iSt < fNTofStationsGeom; iSt++) { + int iStActive = fpAlgo->GetParameters()->GetStationIndexActive(iSt, L1DetectorID::kTof); if (iStActive == -1) { continue; } if (fabs(MC.z - sta[iStActive].z[0]) < dist) { dist = fabs(MC.z - sta[iStActive].z[0]); iSta = iSt; } } - MC.iStation = algo->GetParameters()->GetStationIndexActive(iSta, L1DetectorID::kTof); + MC.iStation = fpAlgo->GetParameters()->GetStationIndexActive(iSta, L1DetectorID::kTof); if (MC.iStation < 0) continue; assert(MC.iStation >= 0); if (iSta >= 0) { if (fabs(sta[iSta].z[0] - MC.z) < TofPointToTrackdZ[iSta][iTrack]) { - TofPointToTrack[iSta][iTrack] = iMC; + fTofPointToTrack[iSta][iTrack] = iMC; TofPointToTrackdZ[iSta][iTrack] = fabs(sta[iSta].z[0] - MC.z); } } } } - for (int iTofSta = 0; iTofSta < NTOFStation; iTofSta++) - for (unsigned int iTrack = 0; iTrack < TofPointToTrack[iTofSta].size(); iTrack++) { + for (int iTofSta = 0; iTofSta < fNTofStations; iTofSta++) + for (unsigned int iTrack = 0; iTrack < fTofPointToTrack[iTofSta].size(); iTrack++) { - if (TofPointToTrack[iTofSta][iTrack] < 0) continue; + if (fTofPointToTrack[iTofSta][iTrack] < 0) continue; CbmL1MCPoint MC; - if (!ReadMCPoint(&MC, TofPointToTrack[iTofSta][iTrack], iFile, iEvent, 4)) { + if (!ReadMCPoint(&MC, fTofPointToTrack[iTofSta][iTrack], iFile, iEvent, 4)) { - MC.iStation = (NMvdStations + NStsStations + NMuchStations + NTrdStations + iTofSta); - - vMCTracks[iTrack].Points.push_back_no_warning(vMCPoints.size()); + MC.iStation = (fNMvdStations + fNStsStations + fNMuchStations + fNTrdStations + iTofSta); + fvMCTracks[iTrack].Points.push_back_no_warning(fvMCPoints.size()); MC.ID = iTrack; dFEI2vMCPoints.insert(DFEI2I::value_type( dFEI(iFile, iEvent, - TofPointToTrack[iTofSta][iTrack] + nMvdPoints + nStsPoints + nMuchPoints + nTrdPoints), - vMCPoints.size())); + fTofPointToTrack[iTofSta][iTrack] + nMvdPoints + nStsPoints + nMuchPoints + nTrdPoints), + fvMCPoints.size())); - vMCPoints.push_back(MC); + fvMCPoints.push_back(MC); - vMCPoints_in_Time_Slice.push_back(0); + fvMCPointIndexesTs.push_back(0); nTofPoints++; } } } } //time_slice - for (unsigned int iTr = 0; iTr < vMCTracks.size(); iTr++) { + for (unsigned int iTr = 0; iTr < fvMCTracks.size(); iTr++) { - sort(vMCTracks[iTr].Points.begin(), vMCTracks[iTr].Points.end(), compareZ); + sort(fvMCTracks[iTr].Points.begin(), fvMCTracks[iTr].Points.end(), compareZ); - if (vMCTracks[iTr].mother_ID >= 0) { - Double_t dtrck = dFEI(vMCTracks[iTr].iFile, vMCTracks[iTr].iEvent, vMCTracks[iTr].mother_ID); + if (fvMCTracks[iTr].mother_ID >= 0) { + Double_t dtrck = dFEI(fvMCTracks[iTr].iFile, fvMCTracks[iTr].iEvent, fvMCTracks[iTr].mother_ID); DFEI2I::iterator map_it = dFEI2vMCTracks.find(dtrck); - if (map_it == dFEI2vMCTracks.end()) vMCTracks[iTr].mother_ID = -2; + if (map_it == dFEI2vMCTracks.end()) fvMCTracks[iTr].mother_ID = -2; else - vMCTracks[iTr].mother_ID = map_it->second; + fvMCTracks[iTr].mother_ID = map_it->second; } } //iTr - if (fVerbose >= 10) cout << "Points in vMCTracks are sorted." << endl; + if (fVerbose >= 10) cout << "Points in fvMCTracks are sorted." << endl; } //fPerformance @@ -516,24 +524,24 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, * matching with MC points is done */ - int NStrips = 0; + // TODO: Refactor this code: MC information and matches should be collected separately in a separate class (S.Zharko) + int NStrips = 0; // // get MVD hits - - if (fUseMVD && listMvdHits) { + if (fUseMVD && fpMvdHits) { int firstDetStrip = NStrips; - for (int j = 0; j < listMvdHits->GetEntriesFast(); j++) { + for (int j = 0; j < fpMvdHits->GetEntriesFast(); j++) { TmpHit th; { - CbmMvdHit* mh = L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(j)); + CbmMvdHit* mh = L1_DYNAMIC_CAST<CbmMvdHit*>(fpMvdHits->At(j)); th.ExtIndex = -(1 + j); th.id = tmpHits.size(); th.iStation = mh->GetStationNr(); - int stIdx = algo->GetParameters()->GetStationIndexActive(mh->GetStationNr(), L1DetectorID::kMvd); + int stIdx = fpAlgo->GetParameters()->GetStationIndexActive(mh->GetStationNr(), L1DetectorID::kMvd); if (stIdx == -1) continue; th.iStation = stIdx; //mh->GetStationNr() - 1; th.iStripF = firstDetStrip + j; @@ -555,15 +563,15 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.y = pos.Y(); th.z = pos.Z(); - const L1Station& st = algo->GetParameters()->GetStation(th.iStation); - th.u_front = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; - th.u_back = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(th.iStation); + th.u = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; + th.v = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; } th.Det = 0; th.iMC = -1; if (fPerformance) { - if (listMvdHitMatches) { - CbmMatch* mvdHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(listMvdHitMatches->At(j)); + if (fpMvdHitMatches) { + CbmMatch* mvdHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fpMvdHitMatches->At(j)); if (mvdHitMatch->GetNofLinks() > 0) if (mvdHitMatch->GetLink(0).GetIndex() < nMvdPoints) { th.iMC = mvdHitMatch->GetLink(0).GetIndex(); @@ -579,23 +587,23 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, nMvdHits++; } } // for j - } // if listMvdHits - if (fVerbose >= 10) cout << "ReadEvent: mvd hits are gotten." << endl; + } // if fpMvdHits + if (fVerbose >= 10) cout << "ReadEvent: MVD hits collected." << endl; if (fUseSTS && (2 == fStsUseMcHit)) { // create hits from points for (int ip = firstStsPoint; ip < firstStsPoint + nStsPoints; ip++) { - const CbmL1MCPoint& p = vMCPoints[ip]; + const CbmL1MCPoint& p = fvMCPoints[ip]; // int mcTrack = p.ID; // if (mcTrack < 0) continue; - // const CbmL1MCTrack& t = vMCTracks[mcTrack]; + // const CbmL1MCTrack& t = fvMCTracks[mcTrack]; //if (t.p < 1) continue; // if (t.Points.size() > 4) continue; - // cout << "sts mc: station " << p.iStation - NMvdStations << " x " << p.x << " y " << p.y << " z " << p.z << " t " + // cout << "sts mc: station " << p.iStation - fNMvdStations << " x " << p.x << " y " << p.y << " z " << p.z << " t " // << p.time << " mc " << p.ID << " p " << p.p << endl; TmpHit th; int DetId = 1; - th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, algo->GetParameters()->GetStation(p.iStation)); + th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, fpAlgo->GetParameters()->GetStation(p.iStation)); tmpHits.push_back(th); nStsHits++; } @@ -604,9 +612,9 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // // Get STS hits // - if (fUseSTS && listStsHits && (2 != fStsUseMcHit)) { + if (fUseSTS && fpStsHits && (2 != fStsUseMcHit)) { - Int_t nEntSts = (event ? event->GetNofData(ECbmDataType::kStsHit) : listStsHits->GetEntriesFast()); + Int_t nEntSts = (event ? event->GetNofData(ECbmDataType::kStsHit) : fpStsHits->GetEntriesFast()); int firstDetStrip = NStrips; @@ -617,18 +625,24 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, hitIndex = (event ? event->GetIndex(ECbmDataType::kStsHit, j) : j); int hitIndexSort = 0; - if (!fLegacyEventMode) hitIndexSort = StsIndex[hitIndex]; + if (!fLegacyEventMode) hitIndexSort = fvSortedStsHitsIndexes[hitIndex]; else hitIndexSort = j; - CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(hitIndexSort)); + CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(hitIndexSort)); + + // *********************************** + // ** Fill the temporary hit object ** + // *********************************** TmpHit th; + + // Fill reconstructed information { - CbmStsHit* mh = L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(hitIndexSort)); + CbmStsHit* mh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(hitIndexSort)); th.ExtIndex = hitIndexSort; th.Det = 1; - int stIdx = algo->GetParameters()->GetStationIndexActive( + int stIdx = fpAlgo->GetParameters()->GetStationIndexActive( CbmStsSetup::Instance()->GetStationNumber(mh->GetAddress()), L1DetectorID::kSts); if (stIdx == -1) continue; @@ -672,20 +686,21 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.du = mh->GetDu(); th.dv = mh->GetDv(); - const L1Station& st = algo->GetParameters()->GetStation(th.iStation); - th.u_front = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; - th.u_back = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(th.iStation); + th.u = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; + th.v = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; } th.iMC = -1; Int_t iMC = -1; if (fPerformance) { - if (listStsClusterMatch) { + /// TODO: Matching should be done in CbmMatchRecoToMC (S.Zharko) + if (fpStsClusterMatches) { const CbmMatch* frontClusterMatch = - static_cast<const CbmMatch*>(listStsClusterMatch->At(sh->GetFrontClusterId())); + static_cast<const CbmMatch*>(fpStsClusterMatches->At(sh->GetFrontClusterId())); const CbmMatch* backClusterMatch = - static_cast<const CbmMatch*>(listStsClusterMatch->At(sh->GetBackClusterId())); + static_cast<const CbmMatch*>(fpStsClusterMatches->At(sh->GetBackClusterId())); CbmMatch stsHitMatch; for (Int_t iFrontLink = 0; iFrontLink < frontClusterMatch->GetNofLinks(); iFrontLink++) { @@ -737,7 +752,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, nStsHits++; } // for j - } // if listStsHits + } // if fpStsHits // // Get MuCh hits @@ -745,26 +760,26 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, if ((2 == fMuchUseMcHit) && fUseMUCH) { // create hits from points for (int ip = firstMuchPoint; ip < firstMuchPoint + nMuchPoints; ip++) { - const CbmL1MCPoint& p = vMCPoints[ip]; + const CbmL1MCPoint& p = fvMCPoints[ip]; // int mcTrack = p.ID; // if (mcTrack < 0) continue; - // const CbmL1MCTrack& t = vMCTracks[mcTrack]; + // const CbmL1MCTrack& t = fvMCTracks[mcTrack]; //if (t.p < 1) continue; // if (t.Points.size() > 4) continue; TmpHit th; int DetId = 2; - th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, algo->GetParameters()->GetStation(p.iStation)); + th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, fpAlgo->GetParameters()->GetStation(p.iStation)); tmpHits.push_back(th); nMuchHits++; } } - if (fUseMUCH && fMuchPixelHits && (2 != fMuchUseMcHit)) { + if (fUseMUCH && fpMuchPixelHits && (2 != fMuchUseMcHit)) { - Int_t nEnt = fMuchPixelHits->GetEntriesFast(); + Int_t nEnt = fpMuchPixelHits->GetEntriesFast(); int firstDetStrip = NStrips; @@ -772,7 +787,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, TmpHit th; { - CbmMuchPixelHit* mh = static_cast<CbmMuchPixelHit*>(fMuchPixelHits->At(j)); + CbmMuchPixelHit* mh = static_cast<CbmMuchPixelHit*>(fpMuchPixelHits->At(j)); th.ExtIndex = j; th.Det = 2; @@ -784,7 +799,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, int DetId = stationNumber * 3 + layerNumber; - int stIdx = algo->GetParameters()->GetStationIndexActive(DetId, L1DetectorID::kMuch); + int stIdx = fpAlgo->GetParameters()->GetStationIndexActive(DetId, L1DetectorID::kMuch); if (stIdx == -1) continue; th.iStation = stIdx; //mh->GetStationNr() - 1; @@ -810,17 +825,17 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.dv = mh->GetDy(); - const L1Station& st = algo->GetParameters()->GetStation(th.iStation); - th.u_front = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; - th.u_back = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(th.iStation); + th.u = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; + th.v = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; } th.iMC = -1; int iMC = -1; if (fPerformance) { - if (listMuchHitMatches) { - CbmMatch* matchHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(listMuchHitMatches->At(j)); + if (fpMuchHitMatches) { + CbmMatch* matchHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fpMuchHitMatches->At(j)); for (Int_t iLink = 0; iLink < matchHitMatch->GetNofLinks(); iLink++) { @@ -836,7 +851,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, if (trk_it == dFEI2vMCPoints.end()) continue; th.iMC = trk_it->second; if ((1 == fMuchUseMcHit) && (th.iMC > -1)) - th.SetHitFromPoint(vMCPoints[th.iMC], algo->GetParameters()->GetStation(th.iStation)); + th.SetHitFromPoint(fvMCPoints[th.iMC], fpAlgo->GetParameters()->GetStation(th.iStation)); } } } @@ -856,27 +871,27 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, if (2 == fTrdUseMcHit) { // create hits from MC points for (int ip = firstTrdPoint; ip < firstTrdPoint + nTrdPoints; ip++) { - const CbmL1MCPoint& p = vMCPoints[ip]; + const CbmL1MCPoint& p = fvMCPoints[ip]; // int mcTrack = p.ID; // if (mcTrack < 0) continue; - // const CbmL1MCTrack& t = vMCTracks[mcTrack]; + // const CbmL1MCTrack& t = fvMCTracks[mcTrack]; TmpHit th; int DetId = 3; - th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, algo->GetParameters()->GetStation(p.iStation)); + th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, fpAlgo->GetParameters()->GetStation(p.iStation)); tmpHits.push_back(th); nTrdHits++; } } else { // read hits - assert(listTrdHits); + assert(fpTrdHits); vector<bool> mcUsed(nTrdPoints, 0); - for (int iHit = 0; iHit < listTrdHits->GetEntriesFast(); iHit++) { + for (int iHit = 0; iHit < fpTrdHits->GetEntriesFast(); iHit++) { TmpHit th; - CbmTrdHit* mh = L1_DYNAMIC_CAST<CbmTrdHit*>(listTrdHits->At(iHit)); + CbmTrdHit* mh = L1_DYNAMIC_CAST<CbmTrdHit*>(fpTrdHits->At(iHit)); if ((L1Algo::TrackingMode::kGlobal == fTrackingMode) && (int) mh->GetClassType() != 1) { // SGtrd2d!! skip TRD-1D hit @@ -887,7 +902,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.Det = 3; th.id = tmpHits.size(); - int stIdx = algo->GetParameters()->GetStationIndexActive(mh->GetPlaneId(), L1DetectorID::kTrd); + int stIdx = fpAlgo->GetParameters()->GetStationIndexActive(mh->GetPlaneId(), L1DetectorID::kTrd); if (stIdx == -1) continue; th.iStation = stIdx; @@ -920,26 +935,26 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.du = fabs(mh->GetDx()); th.dv = fabs(mh->GetDy()); - const L1Station& st = algo->GetParameters()->GetStation(th.iStation); + const L1Station& st = fpAlgo->GetParameters()->GetStation(th.iStation); - std::tie(th.u_front, th.u_back) = st.ConvXYtoUV(th.x, th.y); + std::tie(th.u, th.v) = st.ConvXYtoUV<double>(th.x, th.y); th.iMC = -1; th.track = -1; int iMcTrd = -1; - if (fPerformance && fTrdHitMatches) { - CbmMatch* trdHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fTrdHitMatches->At(iHit)); + if (fPerformance && fpTrdHitMatches) { + CbmMatch* trdHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fpTrdHitMatches->At(iHit)); if (trdHitMatch->GetNofLinks() > 0) { iMcTrd = trdHitMatch->GetLink(0).GetIndex(); assert(iMcTrd >= 0 && iMcTrd < nTrdPoints); th.iMC = iMcTrd + nMvdPoints + nStsPoints + nMuchPoints; - th.track = vMCPoints[th.iMC].ID; + th.track = fvMCPoints[th.iMC].ID; } } if (1 == fTrdUseMcHit) { // replace hit by MC points - assert(fPerformance && fTrdHitMatches); + assert(fPerformance && fpTrdHitMatches); if (th.iMC < 0) continue; // skip noise hits if (mcUsed[iMcTrd]) continue; // one hit per MC point @@ -950,7 +965,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.dy = .1; th.dv = .1; } - th.SetHitFromPoint(vMCPoints[th.iMC], algo->GetParameters()->GetStation(th.iStation), doSmear); + th.SetHitFromPoint(fvMCPoints[th.iMC], fpAlgo->GetParameters()->GetStation(th.iStation), doSmear); mcUsed[iMcTrd] = 1; } // replace hit by MC points @@ -958,15 +973,15 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, int mcTrack = -1; float mcP = 0; if (th.iMC >= 0) { - mcTrack = vMCPoints[th.iMC].ID; - if (mcTrack >= 0) { mcP = vMCTracks[mcTrack].p; } + mcTrack = fvMCPoints[th.iMC].ID; + if (mcTrack >= 0) { mcP = fvMCTracks[mcTrack].p; } } if (mcP < 1.) continue; } tmpHits.push_back(th); nTrdHits++; - } // for listTrdHits + } // for fpTrdHits } } // read TRD hits @@ -975,31 +990,31 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // if ((2 == fTofUseMcHit) && fUseTOF) { // create hits from points for (int ip = firstTofPoint; ip < firstTofPoint + nTofPoints; ip++) { - const CbmL1MCPoint& p = vMCPoints[ip]; + const CbmL1MCPoint& p = fvMCPoints[ip]; // int mcTrack = p.ID; // if (mcTrack < 0) continue; - //const CbmL1MCTrack& t = vMCTracks[mcTrack]; + //const CbmL1MCTrack& t = fvMCTracks[mcTrack]; //if (t.p < 1) continue; //if (t.Points.size() > 4) continue; TmpHit th; int DetId = 4; - th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, algo->GetParameters()->GetStation(p.iStation)); + th.CreateHitFromPoint(p, ip, DetId, tmpHits.size(), NStrips, fpAlgo->GetParameters()->GetStation(p.iStation)); tmpHits.push_back(th); nTofHits++; } } - if (fUseTOF && fTofHits && (2 != fTofUseMcHit)) { + if (fUseTOF && fpTofHits && (2 != fTofUseMcHit)) { int firstDetStrip = NStrips; - for (int j = 0; j < fTofHits->GetEntriesFast(); j++) { + for (int j = 0; j < fpTofHits->GetEntriesFast(); j++) { TmpHit th; - CbmTofHit* mh = L1_DYNAMIC_CAST<CbmTofHit*>(fTofHits->At(j)); + CbmTofHit* mh = L1_DYNAMIC_CAST<CbmTofHit*>(fpTofHits->At(j)); th.ExtIndex = j; @@ -1038,13 +1053,13 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, if (th.z > 400) continue; // is it still needed here? (S.Zharko) - int stIdx = algo->GetParameters()->GetStationIndexActive(sttof, L1DetectorID::kTof); + int stIdx = fpAlgo->GetParameters()->GetStationIndexActive(sttof, L1DetectorID::kTof); if (stIdx == -1) continue; th.iStation = stIdx; - const L1Station& st = algo->GetParameters()->GetStation(th.iStation); - th.u_front = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; - th.u_back = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; + const L1Station& st = fpAlgo->GetParameters()->GetStation(th.iStation); + th.u = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0]; + th.v = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0]; th.iMC = -1; @@ -1053,7 +1068,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, if (fPerformance) { - CbmMatch* matchHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fTofHitDigiMatches->At(j)); + CbmMatch* matchHitMatch = L1_DYNAMIC_CAST<CbmMatch*>(fpTofHitMatches->At(j)); for (int iLink = 0; iLink < matchHitMatch->GetNofLinks(); iLink++) //matchHitMatch->GetNofLinks(); k++) { @@ -1071,7 +1086,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, th.iMC = trk_it->second; if ((1 == fTofUseMcHit) && (th.iMC > -1)) - th.SetHitFromPoint(vMCPoints[th.iMC], algo->GetParameters()->GetStation(th.iStation)); + th.SetHitFromPoint(fvMCPoints[th.iMC], fpAlgo->GetParameters()->GetStation(th.iStation)); } } @@ -1081,8 +1096,6 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, } // for j } // if listTofHits - if (fVerbose >= 10) cout << "ReadEvent: sts hits are gotten." << endl; - if (fVerbose > 1) { LOG(info) << "L1 ReadEvent: nhits mvd " << nMvdHits << " sts " << nStsHits << " much " << nMuchHits << " trd " << nTrdHits << " tof " << nTofHits << endl; @@ -1095,17 +1108,16 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, * Measured hits gathering: END */ - /* - * Hits sorting - * - * Two hits are compared as follows. If the hits are measured with two different stations, the smallest hit has the smallest - * station ID. If the hits are measured within one station, the smallest hit has the smallest y position coordinate. - */ + + // + // Hits sorting + // + // Two hits are compared as follows. If the hits are measured with two different stations, the smallest hit has the smallest + // station ID. If the hits are measured within one station, the smallest hit has the smallest y position coordinate. + // sort(tmpHits.begin(), tmpHits.end(), TmpHit::Compare); - /* - * Save strips into L1Algo - */ + // ----- Save strips into L1Algo fData_->fNstrips = NStrips; fData_->fStripFlag.reset(NStrips, 0); int maxHitIndex = 0; @@ -1120,20 +1132,20 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, if (fVerbose >= 10) { cout << "ReadEvent: strips are read." << endl; } - /* - * Fill and save vHits, vHitStore and vHitMCRef vectors as well as fData->vHits - */ + + // ----- Fill and save fvExternalHits, fvHitStore and fvHitPointIndexes vectors as well as fpData->vHits int nEffHits = 0; - SortedIndex.reset(maxHitIndex + 1); + fvSortedHitsIndexes.reset(maxHitIndex + 1); - vHits.reserve(nHits); + fvExternalHits.reserve(nHits); fData_->vHits.reserve(nHits); - vHitStore.reserve(nHits); - vHitMCRef.reserve(nHits); + fvHitStore.reserve(nHits); + fvHitPointIndexes.reserve(nHits); + // ----- Fill for (int i = 0; i < nHits; i++) { TmpHit& th = tmpHits[i]; @@ -1148,7 +1160,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, s.dxy = th.dxy; s.time = th.time; - SortedIndex[th.id] = i; + fvSortedHitsIndexes[th.id] = i; assert(th.iStripF >= 0 || th.iStripF < NStrips); assert(th.iStripB >= 0 || th.iStripB < NStrips); @@ -1167,8 +1179,8 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // h.dy = th.dy; h.du = th.du; h.dv = th.dv; - h.u = th.u_front; - h.v = th.u_back; + h.u = th.u; + h.v = th.v; // h.dxy = th.dxy; // h.p = th.p; // h.q = th.q; @@ -1178,16 +1190,16 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // save hit - vHits.push_back(CbmL1Hit(fData->vHits.size(), th.ExtIndex, th.Det)); + fvExternalHits.push_back(CbmL1Hit(fpData->vHits.size(), th.ExtIndex, th.Det)); - vHits[vHits.size() - 1].x = th.x; - vHits[vHits.size() - 1].y = th.y; - vHits[vHits.size() - 1].t = th.time; + fvExternalHits[fvExternalHits.size() - 1].x = th.x; + fvExternalHits[fvExternalHits.size() - 1].y = th.y; + fvExternalHits[fvExternalHits.size() - 1].t = th.time; - vHits[vHits.size() - 1].ID = th.id; + fvExternalHits[fvExternalHits.size() - 1].ID = th.id; - vHits[vHits.size() - 1].f = th.iStripF; - vHits[vHits.size() - 1].b = th.iStripB; + fvExternalHits[fvExternalHits.size() - 1].f = th.iStripF; + fvExternalHits[fvExternalHits.size() - 1].b = th.iStripB; fData_->vHits.push_back(h); @@ -1199,11 +1211,11 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, fData_->HitsStopIndex[iSt] = nEffHits; - vHitStore.push_back(s); - vHitMCRef.push_back(th.iMC); + fvHitStore.push_back(s); + fvHitPointIndexes.push_back(th.iMC); } - for (int i = 0; i < NStation; i++) { + for (int i = 0; i < fNStations; i++) { if (fData_->HitsStartIndex[i] == static_cast<L1HitIndex_t>(-1)) { fData_->HitsStartIndex[i] = fData_->HitsStopIndex[i]; } @@ -1215,8 +1227,8 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, * Translate gathered hits data to the L1Algo object. TODO: raplace it with L1DataManager functionality (S.Zharko) */ - algo->SetData(fData_->GetHits(), fData_->GetNstrips(), fData_->GetSFlag(), fData_->GetHitsStartIndex(), - fData_->GetHitsStopIndex()); + fpAlgo->SetData(fData_->GetHits(), fData_->GetNstrips(), fData_->GetSFlag(), fData_->GetHitsStartIndex(), + fData_->GetHitsStopIndex()); if (fPerformance) { if (fVerbose >= 10) cout << "HitMatch is done." << endl; @@ -1229,32 +1241,32 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength, // void CbmL1::Fill_vMCTracks() { - vMCTracks.clear(); + fvMCTracks.clear(); // Count the total number of tracks in this event and reserve memory { Int_t nMCTracks = 0; - for (DFSET::iterator set_it = vFileEvent.begin(); set_it != vFileEvent.end(); ++set_it) { + for (DFSET::iterator set_it = fvFileEvent.begin(); set_it != fvFileEvent.end(); ++set_it) { Int_t iFile = set_it->first; Int_t iEvent = set_it->second; - nMCTracks += fMCTracks->Size(iFile, iEvent); + nMCTracks += fpMCTracks->Size(iFile, iEvent); } - vMCTracks.reserve(nMCTracks); + fvMCTracks.reserve(nMCTracks); } int fileEvent = 0; /* Loop over MC event */ - for (DFSET::iterator set_it = vFileEvent.begin(); set_it != vFileEvent.end(); ++set_it, ++fileEvent) { + for (DFSET::iterator set_it = fvFileEvent.begin(); set_it != fvFileEvent.end(); ++set_it, ++fileEvent) { Int_t iFile = set_it->first; Int_t iEvent = set_it->second; - auto header = dynamic_cast<FairMCEventHeader*>(fMcEventHeader->Get(iFile, iEvent)); + auto header = dynamic_cast<FairMCEventHeader*>(fpMcEventHeader->Get(iFile, iEvent)); assert(header); - Int_t nMCTrack = fMCTracks->Size(iFile, iEvent); + Int_t nMCTrack = fpMCTracks->Size(iFile, iEvent); /* Loop over MC tracks */ for (Int_t iMCTrack = 0; iMCTrack < nMCTrack; iMCTrack++) { - CbmMCTrack* MCTrack = L1_DYNAMIC_CAST<CbmMCTrack*>(fMCTracks->Get(iFile, iEvent, iMCTrack)); + CbmMCTrack* MCTrack = L1_DYNAMIC_CAST<CbmMCTrack*>(fpMCTracks->Get(iFile, iEvent, iMCTrack)); if (!MCTrack) { continue; } int mother_ID = MCTrack->GetMotherId(); @@ -1270,10 +1282,11 @@ void CbmL1::Fill_vMCTracks() q = TDatabasePDG::Instance()->GetParticle(pdg)->Charge() / 3.0; mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass(); } + // TODO: Add light nuclei (d, t, He3, He4): they are common in tracking but not accounted in TDatabasePDG (S.Zharko) //cout << "mc track " << iMCTrack << " pdg " << pdg << " z " << vr.Z() << endl; - Int_t iTrack = vMCTracks.size(); //or iMCTrack? + Int_t iTrack = fvMCTracks.size(); //or iMCTrack? CbmL1MCTrack T(mass, q, vr, vp, iTrack, mother_ID, pdg); // CbmL1MCTrack T(mass, q, vr, vp, iMCTrack, mother_ID, pdg); T.time = MCTrack->GetStartT(); @@ -1282,9 +1295,9 @@ void CbmL1::Fill_vMCTracks() // signal: primary tracks, displaced from the primary vertex T.isSignal = T.IsPrimary() && (T.z > header->GetZ() + 1.e-10); - vMCTracks.push_back(T); + fvMCTracks.push_back(T); // Double_t dtrck =dFEI(iFile,iEvent,iMCTrack); - dFEI2vMCTracks.insert(DFEI2I::value_type(dFEI(iFile, iEvent, iMCTrack), vMCTracks.size() - 1)); + dFEI2vMCTracks.insert(DFEI2I::value_type(dFEI(iFile, iEvent, iMCTrack), fvMCTracks.size() - 1)); } //iTracks } //Links @@ -1300,7 +1313,7 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M Double_t time = 0.f; if (MVD == 1) { - CbmMvdPoint* pt = L1_DYNAMIC_CAST<CbmMvdPoint*>(fMvdPoints->Get(file, event, iPoint)); // file, event, object + CbmMvdPoint* pt = L1_DYNAMIC_CAST<CbmMvdPoint*>(fpMvdPoints->Get(file, event, iPoint)); // file, event, object //CbmMvdPoint *pt = L1_DYNAMIC_CAST<CbmMvdPoint*> (Point); if (!pt) return 1; @@ -1312,12 +1325,12 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M time = pt->GetTime(); } if (MVD == 0) { - CbmStsPoint* pt = L1_DYNAMIC_CAST<CbmStsPoint*>(fStsPoints->Get(file, event, iPoint)); // file, event, object + CbmStsPoint* pt = L1_DYNAMIC_CAST<CbmStsPoint*>(fpStsPoints->Get(file, event, iPoint)); // file, event, object if (!pt) return 1; if (!fLegacyEventMode) { Double_t StartTime = fTimeSlice->GetStartTime(); Double_t EndTime = fTimeSlice->GetEndTime(); - Double_t Time_MC_point = pt->GetTime() + fEventList->GetEventTime(event, file); + Double_t Time_MC_point = pt->GetTime() + fpEventList->GetEventTime(event, file); if (StartTime > 0) if (Time_MC_point < StartTime) return 1; @@ -1336,12 +1349,12 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M if (MVD == 2) { - CbmMuchPoint* pt = L1_DYNAMIC_CAST<CbmMuchPoint*>(fMuchPoints->Get(file, event, iPoint)); // file, event, object + CbmMuchPoint* pt = L1_DYNAMIC_CAST<CbmMuchPoint*>(fpMuchPoints->Get(file, event, iPoint)); // file, event, object if (!pt) return 1; if (!fLegacyEventMode) { Double_t StartTime = fTimeSlice->GetStartTime(); Double_t EndTime = fTimeSlice->GetEndTime(); - Double_t Time_MC_point = pt->GetTime() + fEventList->GetEventTime(event, file); + Double_t Time_MC_point = pt->GetTime() + fpEventList->GetEventTime(event, file); if (StartTime > 0) if (Time_MC_point < StartTime) return 1; @@ -1360,13 +1373,13 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M if (MVD == 3) { - CbmTrdPoint* pt = L1_DYNAMIC_CAST<CbmTrdPoint*>(fTrdPoints->Get(file, event, iPoint)); // file, event, object + CbmTrdPoint* pt = L1_DYNAMIC_CAST<CbmTrdPoint*>(fpTrdPoints->Get(file, event, iPoint)); // file, event, object if (!pt) return 1; if (!fLegacyEventMode) { Double_t StartTime = fTimeSlice->GetStartTime(); // not used Double_t EndTime = fTimeSlice->GetEndTime(); // not used - Double_t Time_MC_point = pt->GetTime() + fEventList->GetEventTime(event, file); // not used + Double_t Time_MC_point = pt->GetTime() + fpEventList->GetEventTime(event, file); // not used if (StartTime > 0) if (Time_MC_point < StartTime) return 1; @@ -1385,12 +1398,12 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M } if (MVD == 4) { - CbmTofPoint* pt = L1_DYNAMIC_CAST<CbmTofPoint*>(fTofPoints->Get(file, event, iPoint)); // file, event, object + CbmTofPoint* pt = L1_DYNAMIC_CAST<CbmTofPoint*>(fpTofPoints->Get(file, event, iPoint)); // file, event, object if (!pt) return 1; if (!fLegacyEventMode) { Double_t StartTime = fTimeSlice->GetStartTime(); Double_t EndTime = fTimeSlice->GetEndTime(); - Double_t Time_MC_point = pt->GetTime() + fEventList->GetEventTime(event, file); + Double_t Time_MC_point = pt->GetTime() + fpEventList->GetEventTime(event, file); if (StartTime > 0) if (Time_MC_point < StartTime) return 1; @@ -1436,7 +1449,7 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M MC->time = time; if (MC->ID < 0) return 1; - CbmMCTrack* MCTrack = L1_DYNAMIC_CAST<CbmMCTrack*>(fMCTracks->Get(file, event, MC->ID)); + CbmMCTrack* MCTrack = L1_DYNAMIC_CAST<CbmMCTrack*>(fpMCTracks->Get(file, event, MC->ID)); if (!MCTrack) return 1; MC->pdg = MCTrack->GetPdgCode(); MC->mother_ID = MCTrack->GetMotherId(); @@ -1446,6 +1459,7 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* MC, int iPoint, int file, int event, int M MC->q = particlePDG->Charge() / 3.0; MC->mass = particlePDG->Mass(); } + // TODO: Add light nuclei (d, t, He3, He4): they are common in tracking but not accounted in TDatabasePDG (S.Zharko) return 0; } @@ -1456,23 +1470,24 @@ bool CbmL1::ReadMCPoint(CbmL1MCPoint* /*MC*/, int /*iPoint*/, int /*MVD*/) { ret // //-------------------------------------------------------------------------------------------------- // +// TODO: Duplicated code (from CbmL1::ReadEvent) void CbmL1::HitMatch() { - const int NHits = vHits.size(); + const int NHits = fvExternalHits.size(); for (int iH = 0; iH < NHits; iH++) { - CbmL1Hit& hit = vHits[iH]; + CbmL1Hit& hit = fvExternalHits[iH]; if ((hit.Det == 1) && (2 != fStsUseMcHit)) { - CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(vHits[iH].extIndex)); + CbmStsHit* sh = L1_DYNAMIC_CAST<CbmStsHit*>(fpStsHits->At(fvExternalHits[iH].extIndex)); int iP = -1; - if (listStsClusterMatch) { + if (fpStsClusterMatches) { const CbmMatch* frontClusterMatch = - static_cast<const CbmMatch*>(listStsClusterMatch->At(sh->GetFrontClusterId())); + static_cast<const CbmMatch*>(fpStsClusterMatches->At(sh->GetFrontClusterId())); const CbmMatch* backClusterMatch = - static_cast<const CbmMatch*>(listStsClusterMatch->At(sh->GetBackClusterId())); + static_cast<const CbmMatch*>(fpStsClusterMatches->At(sh->GetBackClusterId())); CbmMatch stsHitMatch; Float_t Sum_of_front = 0; // total weight of all front links @@ -1516,8 +1531,8 @@ void CbmL1::HitMatch() if (fLegacyEventMode) { - iFile = vFileEvent.begin()->first; - iEvent = vFileEvent.begin()->second; + iFile = fvFileEvent.begin()->first; + iEvent = fvFileEvent.begin()->second; } Double_t dpnt = dFEI(iFile, iEvent, nMvdPoints + iIndex); @@ -1536,22 +1551,22 @@ void CbmL1::HitMatch() if (iP >= 0) { hit.mcPointIds.push_back_no_warning(iP); - vMCPoints[iP].hitIds.push_back_no_warning(iH); + fvMCPoints[iP].hitIds.push_back_no_warning(iH); } else { - int idPoint = vHitMCRef[iH]; + int idPoint = fvHitPointIndexes[iH]; if (idPoint >= 0) { hit.mcPointIds.push_back_no_warning(idPoint); - vMCPoints[idPoint].hitIds.push_back_no_warning(iH); + fvMCPoints[idPoint].hitIds.push_back_no_warning(iH); } } // if no clusters } if ((hit.Det != 1) || (2 == fStsUseMcHit)) { // the hit is not from STS - int iP = vHitMCRef[iH]; + int iP = fvHitPointIndexes[iH]; if (iP >= 0) { hit.mcPointIds.push_back_no_warning(iP); - vMCPoints[iP].hitIds.push_back_no_warning(iH); + fvMCPoints[iP].hitIds.push_back_no_warning(iH); } } diff --git a/reco/L1/CbmL1TrackFitter.cxx b/reco/L1/CbmL1TrackFitter.cxx deleted file mode 100644 index 375150ebfb..0000000000 --- a/reco/L1/CbmL1TrackFitter.cxx +++ /dev/null @@ -1,182 +0,0 @@ -/* Copyright (C) 2006-2007 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Ivan Kisel, Sergey Gorbunov, Denis Bertini [committer] */ - -/* - *===================================================== - * - * CBM Level 1 Reconstruction - * - * Authors: I.Kisel, S.Gorbunov - * - * e-mail : ikisel@kip.uni-heidelberg.de - * - *===================================================== - * - * Fit reconstructed tracks and find primary vertex - * - */ - -#include "CbmKF.h" -#include "CbmKFMath.h" -#include "CbmKFPrimaryVertexFinder.h" -#include "CbmL1.h" - -#include "TStopwatch.h" - -#include "L1Algo/L1AddMaterial.h" -#include "L1Algo/L1Algo.h" -#include "L1Algo/L1Extrapolation.h" -#include "L1Algo/L1Filtration.h" -#include "L1Algo/L1Hit.h" -#include "L1Algo/L1TrackPar.h" - -void CbmL1::TrackFitter(vector<CbmL1Track>& Tracks, CbmL1Vtx* V) -{ - TStopwatch timer; - timer.Start(); - /* NOTE: algo->vStations is deprecated; one have to change it with algo->GetStations() (see L1Algo.h for documentation) (S.Zharko) - //int nt=0; - for( vector<CbmL1Track>::iterator i = Tracks.begin(); i!=Tracks.end(); ++i) - { - CbmL1Track &T = *i; - - int stmin = 1000, stmax = -1000; - for ( vector<L1Hit*>::iterator j = T.StsHits.begin(); j != T.StsHits.end(); ++j) - { - if ((*j)->iStation < stmin ) stmin = (*j)->iStation; - if ((*j)->iStation > stmax ) stmax = (*j)->iStation; - } - - T.nStations = stmax - stmin + 1; - T.is_long = ( T.StsHits.size() >= 4 ) && ( T.nStations >=4 ); - - //T.is_long = T.is_long &&( vMCPoints[T.MapsHits.back()->MC_Point].mother_ID==-1 ); - //if ( !T.is_long ) continue; - - static L1FieldRegion fld[20]; - { - vector<L1Hit*>::iterator ih2 = T.StsHits.begin(), ih1, ih0; - ih1 = ih2; - ih1++; - ih0 = ih1; - ih0++; - int ist0 = (*ih0)->iStation; - int ist1 = (*ih1)->iStation; - int ist2 = (*ih2)->iStation; - L1Station *st0 = &(algo->vStations[ist0]); - L1Station *st1 = &(algo->vStations[ist1]); - L1Station *st2 = &(algo->vStations[ist2]); - L1FieldValue b0, b1, b2; - fvec z0= st0->z, z1= st1->z, z2= st2->z ; - st0->fieldSlice.GetFieldValue( (*ih0)->x, (*ih0)->y, b0 ); - st1->fieldSlice.GetFieldValue( (*ih1)->x, (*ih1)->y, b1 ); - st2->fieldSlice.GetFieldValue( (*ih2)->x, (*ih2)->y, b2 ); - fld[ist0].Set( b0, z0, b1, z1, b2, z2 ); - fld[ist1] = fld[ist0]; - fld[ist2] = fld[ist0]; - if( ih0!=T.StsHits.end() ){ - while(1){ - ih2 = ih1; b2 = b1; z2 = z1; st2 = st1; - ih1 = ih0; b1 = b0; z1 = z0; st1 = st0; - ih0++; - if( ih0==T.StsHits.end() ) break; - ist0 = (*ih0)->iStation; - st0 = &(algo->vStations[ist0]); - z0 = st0->z; - st0->fieldSlice.GetFieldValue( (*ih0)->x, (*ih0)->y, b0 ); - fld[ist0].Set( b0, z0, b1, z1, b2, z2 ); - } - } - } - fvec vINF = 100.; - L1TrackPar tp; - for( int i=0; i<5; i++ ) *((&tp.x)+i) = T.T[i]; - { - fvec qp0 = tp.qp; - tp.NDF = 2; - tp.chi2 = 0; - vector<L1Hit*>::iterator ih = T.StsHits.begin(); - int ist = (*ih)->iStation; - L1Station *st = &(algo->vStations[ist]); - tp.x = (*ih)->x; - tp.y = (*ih)->y; - tp.z = st->z; - tp.C00 = st->XYInfo.C00; - tp.C10 = st->XYInfo.C10; - tp.C11 = st->XYInfo.C11; - for( int i=3; i<15; i++ ) *((&tp.C00)+i) = 0; - tp.C22 = tp.C33 = tp.C44 = vINF; - for( ; ih!= T.StsHits.end(); ih++ ){ - ist = (*ih)->iStation; - st = &(algo->vStations[ist]); - L1Extrapolate( tp, st->z, qp0, fld[ist] ); - fvec u_f = (*ih)->u_front, u_b = (*ih)->u_back; - L1Filter( tp, st->frontInfo, u_f ); - L1Filter( tp, st->backInfo, u_b ); - L1AddMaterial( tp, st->materialInfo, qp0 ); - } - } - for( int i=0; i<6; i++ ) T.TLast[i] = (*((&tp.x)+i))[0] ; - for( int i=0; i<15; i++ ) T.CLast[i] = (*((&tp.C00)+i))[0]; - - { - fvec qp0 = tp.qp; - tp.NDF = 2; - tp.chi2 = 0; - vector<L1Hit*>::reverse_iterator ih = T.StsHits.rbegin(); - int ist = (*ih)->iStation; - L1Station *st = &(algo->vStations[ist]); - tp.x = (*ih)->x; - tp.y = (*ih)->y; - tp.z = st->z; - tp.C00 = st->XYInfo.C00; - tp.C10 = st->XYInfo.C10; - tp.C11 = st->XYInfo.C11; - for( int i=3; i<15; i++ ) *((&tp.C00)+i) = 0; - tp.C22 = tp.C33 = tp.C44 = vINF; - for( ; ih!= T.StsHits.rend(); ih++ ){ - ist = (*ih)->iStation; - st = &(algo->vStations[ist]); - L1Extrapolate( tp, st->z, qp0, fld[ist] ); - fvec u_f = (*ih)->u_front, u_b = (*ih)->u_back; - L1Filter( tp, st->frontInfo, u_f ); - L1Filter( tp, st->backInfo, u_b ); - L1AddMaterial( tp, st->materialInfo, qp0 ); - } - } - for( int i=0; i<6; i++ ) T.T[i] = (*((&tp.x)+i))[0] ; - for( int i=0; i<15; i++ ) T.C[i] = (*((&tp.C00)+i))[0]; - T.chi2 = tp.chi2[0]; - T.NDF = tp.NDF[0]-5; - } - timer.Stop(); - - stat_vtx_ntracks = 0; - - if(V){ // primary vertex fit - - vector<CbmKFTrackInterface*> vTracks; - - { for( vector<CbmL1Track>::iterator i = Tracks.begin(); i!=Tracks.end(); ++i) - { - if( ( i->StsHits.size() < 5 ) || ( i->nStations <5 ) ) continue; - vTracks.push_back( &*i ); - stat_vtx_ntracks ++; - } - } - cout<<"Fit vertex"<<endl; - if ( vTracks.size()>=3 ) - { - CbmKFPrimaryVertexFinder PVFinder; - PVFinder.SetTracks( vTracks ); - PVFinder.Fit(*V); - } - }// prim. vtx - */ - //c_time.Stop(); - //stat_fit_time += double(c_time.Time()); - //timer.Stop(); - stat_fit_time += timer.CpuTime(); - stat_fit_time_ntracks += Tracks.size(); -} diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index a934089cbc..36b9d066f2 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -100,7 +100,7 @@ void L1Algo::Init(const bool UseHitErrors, const TrackingMode mode, const bool M fMomentumCutOff = fInitManager.GetMomentumCutOff(); } - +/// void L1Algo::SetData(L1Vector<L1Hit>& Hits_, int nStrips_, L1Vector<unsigned char>& SFlag_, const L1HitIndex_t* HitsStartIndex_, const L1HitIndex_t* HitsStopIndex_) { @@ -158,74 +158,23 @@ void L1Algo::SetData(L1Vector<L1Hit>& Hits_, int nStrips_, L1Vector<unsigned cha } } - +/// TODO: Move to L1Hit void L1Algo::GetHitCoor(const L1Hit& _h, fscal& _x, fscal& _y, char iS) { const L1Station& sta = fParameters.GetStation(int(iS)); - std::tie(_x, _y) = sta.ConvUVtoXY(_h.u, _h.v); + std::tie(_x, _y) = sta.ConvUVtoXY<fscal>(_h.u, _h.v); float dz = _h.z - fParameters.GetTargetPositionZ()[0]; _x /= dz; _y /= dz; } +/// TODO: Move to L1Hit void L1Algo::GetHitCoor(const L1Hit& _h, fscal& _x, fscal& _y, fscal& _z, const L1Station& sta) { - fscal u = _h.u; - fscal v = _h.v; - fscal x, y; - StripsToCoor(u, v, x, y, sta); - _x = x; - _y = y; + std::tie(_x, _y) = sta.ConvUVtoXY<fscal>(_h.u, _h.v); _z = _h.z; } -void L1Algo::StripsToCoor( - const fscal& u, const fscal& v, fscal& _x, fscal& _y, - const L1Station& sta) const // TODO: Actually sta.yInfo.sin_phi is same for all stations, so ... -{ - std::tie(_x, _y) = sta.ConvUVtoXY(u, v); -} - - -/// convert strip positions to coordinates -void L1Algo::StripsToCoor( - const fscal& u, const fscal& v, fvec& _x, fvec& _y, - const L1Station& sta) const // TODO: Actually sta.yInfo.sin_phi is same for all stations, so ... -{ - // fvec x,y; - // StripsToCoor(u,v,x,y,sta); - // _x = x[0]; - // _y = y[0]; - _x = sta.xInfo.cos_phi * u + sta.xInfo.sin_phi * v; - _y = sta.yInfo.cos_phi * u + sta.yInfo.sin_phi * v; -} - -void L1Algo::dUdV_to_dY(const fvec& u, const fvec& v, fvec& _y, const L1Station& sta) -{ - _y = sqrt((sta.yInfo.cos_phi * u) * (sta.yInfo.cos_phi * u) + (sta.yInfo.sin_phi * v) * (sta.yInfo.sin_phi * v)); -} - -void L1Algo::dUdV_to_dX(const fvec& u, const fvec& v, fvec& _x, const L1Station& sta) -{ - _x = sqrt((sta.xInfo.cos_phi * u) * (sta.xInfo.cos_phi * u) + (sta.xInfo.sin_phi * v) * (sta.xInfo.sin_phi * v)); -} - -void L1Algo::dUdV_to_dXdY(const fvec& u, const fvec& v, fvec& _xy, const L1Station& sta) -{ - _xy = ((sta.xInfo.cos_phi * u) * (sta.yInfo.cos_phi * u) + (sta.xInfo.sin_phi * v) * (sta.yInfo.sin_phi * v)); -} - -void L1Algo::StripsToCoor( - const fvec& u, const fvec& v, fvec& x, fvec& y, - const L1Station& sta) const // TODO: Actually sta.yInfo.sin_phi is same for all stations, so ... -{ - // only for same-z - // x = u; - // y = (sta.yInfo.cos_phi*u + sta.yInfo.sin_phi*v); - x = sta.xInfo.cos_phi * u + sta.xInfo.sin_phi * v; - y = sta.yInfo.cos_phi * u + sta.yInfo.sin_phi * v; -} - L1HitPoint L1Algo::CreateHitPoint(const L1Hit& hit) { /// full the hit point by hit information: takes hit as input (2 strips) diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index b1f51f0d06..120b17348d 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -1,6 +1,6 @@ -/* Copyright (C) 2007-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2007-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Maksym Zyzak, Valentina Akishina, Igor Kulakov [committer] */ + Authors: Maksym Zyzak, Valentina Akishina, Igor Kulakov [committer], Sergei Zharko */ #ifndef L1Algo_h #define L1Algo_h @@ -22,7 +22,7 @@ class L1AlgoDraw; // =====>dispatched<===== // #define MERGE_CLONES // #define TRACKS_FROM_TRIPLETS_ITERATION kAllPrimIter -//#define HitErrors +// =====>dispatched<===== // #define HitErrors //#define GLOBAL //#define mCBM @@ -67,7 +67,6 @@ class L1AlgoDraw; using std::map; typedef int Tindex; - #ifdef PULLS #define TRIP_PERFORMANCE class L1AlgoPulls; @@ -84,7 +83,7 @@ class L1AlgoEfficiencyPerformance; using L1StationsArray_t = std::array<L1Station, L1Constants::size::kMaxNstations>; using L1MaterialArray_t = std::array<L1Material, L1Constants::size::kMaxNstations>; -/// Central class of L1 tracking +/// Main class of L1 CA track finder algorithm /// class L1Algo { public: @@ -324,18 +323,9 @@ public: void GetHitCoor(const L1Hit& _h, fscal& _x, fscal& _y, fscal& _z, const L1Station& sta); - void dUdV_to_dY(const fvec& u, const fvec& v, fvec& _y, const L1Station& sta); - - void dUdV_to_dX(const fvec& u, const fvec& v, fvec& _x, const L1Station& sta); - - void dUdV_to_dXdY(const fvec& u, const fvec& v, fvec& _xy, const L1Station& sta); void GetHitCoor(const L1Hit& _h, fscal& _x, fscal& _y, char iS); - void StripsToCoor(const fscal& u, const fscal& v, fscal& x, fscal& y, - const L1Station& sta) const; // convert strip positions to coordinates - void StripsToCoor(const fscal& u, const fscal& v, fvec& x, fvec& y, - const L1Station& sta) const; // convert strip positions to coordinates - void StripsToCoor(const fvec& u, const fvec& v, fvec& x, fvec& y, const L1Station& sta) const; + L1HitPoint CreateHitPoint(const L1Hit& hit); // full the hit point by hit information. void CreateHitPoint(const L1Hit& hit, L1HitPoint& point); diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 1efe5236e2..163e293691 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -178,18 +178,11 @@ inline void L1Algo::findSingletsStep1( /// input 1st stage of singlet search // (suppose track is straight line with origin in the target) fvec& u = u_front_l[i1_V]; fvec& v = u_back_l[i1_V]; - fvec xl, yl; // left(1-st) hit coor + auto [xl, yl] = stal.ConvUVtoXY<fvec>(u, v); fvec zl = zPos_l[i1_V]; fvec& time = HitTime_l[i1_V]; fvec& timeEr = HitTimeEr[i1_V]; const fvec dzli = 1.f / (zl - fTargZ); - fvec dx1, dy1, dxy1 = 0; - - dUdV_to_dX(d_u[i1_V], d_v[i1_V], dx1, stal); - dUdV_to_dY(d_u[i1_V], d_v[i1_V], dy1, stal); - dUdV_to_dXdY(d_u[i1_V], d_v[i1_V], dxy1, stal); - - StripsToCoor(u, v, xl, yl, stal); const fvec tx = (xl - fTargX) * dzli; const fvec ty = (yl - fTargY) * dzli; @@ -307,11 +300,7 @@ inline void L1Algo::findSingletsStep1( /// input 1st stage of singlet search T.C10 = stal.XYInfo.C10; T.C11 = stal.XYInfo.C11; - if (fUseHitErrors) { - T.C00 = dx1 * dx1; - T.C10 = dxy1; - T.C11 = dy1 * dy1; - } + if (fUseHitErrors) { std::tie(T.C00, T.C10, T.C11) = stal.FormXYCovarianceMatrix(d_u[i1_V], d_v[i1_V]); } //assert(T.IsConsistent(true, -1)); @@ -484,17 +473,14 @@ inline void L1Algo::findDoubletsStep0( fscal dy_est2 = Pick_m22[i1_4] * fabs(C11[i1_4] + stam.XYInfo.C11[i1_4]); - if (fUseHitErrors) { - fvec dym = 0; - dUdV_to_dY(hitm.dU(), hitm.dV(), dym, stam); - dy_est2 = Pick_m22[i1_4] * fabs(C11[i1_4] + dym[0] * dym[0]); - } + /// Covariation matrix of the hit + auto [dxxScalMhit, dxyScalMhit, dyyScalMhit] = stam.FormXYCovarianceMatrix(hitm.dU(), hitm.dV()); - fvec xm, ym = 0; + if (fUseHitErrors) { dy_est2 = Pick_m22[i1_4] * fabs(C11[i1_4] + dyyScalMhit); } - StripsToCoor(hitm.U(), hitm.V(), xm, ym, stam); + auto [xm, ym] = stam.ConvUVtoXY<fscal>(hitm.U(), hitm.V()); - const fscal dY = ym[i1_4] - y[i1_4]; + const fscal dY = ym - y[i1_4]; if (dY * dY > dy_est2) continue; @@ -504,13 +490,9 @@ inline void L1Algo::findDoubletsStep0( fscal dx_est2 = Pick_m22[i1_4] * fabs(C00[i1_4] + stam.XYInfo.C00[i1_4]); - if (fUseHitErrors) { - fvec dxm = 0; - dUdV_to_dX(hitm.dU(), hitm.dV(), dxm, stam); - dx_est2 = Pick_m22[i1_4] * fabs(C00[i1_4] + dxm[0] * dxm[0]); - } + if (fUseHitErrors) { dx_est2 = Pick_m22[i1_4] * fabs(C00[i1_4] + dxxScalMhit); } - const fscal dX = xm[i1_4] - x[i1_4]; + const fscal dX = xm - x[i1_4]; if (dX * dX > dx_est2) continue; @@ -635,8 +617,6 @@ inline void L1Algo::findTripletsStep0( // input // pack the data fvec u_front_2 = 0.f; fvec u_back_2 = 0.f; - fvec dx2 = 1.f; - fvec dy2 = 1.f; fvec du2 = 1.f; fvec dv2 = 1.f; fvec zPos_2 = 0.f; @@ -678,11 +658,6 @@ inline void L1Algo::findTripletsStep0( // input n2_4++; } // n2_4 - dUdV_to_dX(du2, dv2, dx2, stam); - dUdV_to_dY(du2, dv2, dy2, stam); - - // assert(T2.IsConsistent(true, n2_4)); - fvec dz = zPos_2 - T2.z; L1ExtrapolateTime(T2, dz, stam.timeInfo); @@ -835,9 +810,7 @@ inline void L1Algo::findTripletsStep0( // input const fscal zr = hitr.Z(); // const fscal yr = hitr.Y(); - fvec xr, yr = 0; - - StripsToCoor(hitr.U(), hitr.V(), xr, yr, star); + auto [xr, yr] = star.ConvUVtoXY<fscal>(hitr.U(), hitr.V()); L1TrackPar T_cur = T2; @@ -864,13 +837,12 @@ inline void L1Algo::findTripletsStep0( // input C11[i2_4] + star.XYInfo.C11[i2_4]))); // TODO for FastPrim dx < dy - other sort is optimal. But not for doublets - if (fUseHitErrors) { - fvec dyr = 0; - dUdV_to_dY(hitr.dU(), hitr.dV(), dyr, star); - dy_est2 = (Pick_r22[i2_4] * (fabs(C11[i2_4] + dyr[0] * dyr[0]))); - } + /// Covariation matrix of the hit + auto [dxxScalRhit, dxyScalRhit, dyyScalRhit] = star.FormXYCovarianceMatrix(hitr.dU(), hitr.dV()); + + if (fUseHitErrors) { dy_est2 = (Pick_r22[i2_4] * (fabs(C11[i2_4] + dyyScalRhit))); } - const fscal dY = yr[i2_4] - y[i2_4]; + const fscal dY = yr - y[i2_4]; const fscal dY2 = dY * dY; if (dY2 > dy_est2) continue; // if (yr > y_plus_new [i2_4] ) continue; @@ -883,13 +855,9 @@ inline void L1Algo::findTripletsStep0( // input fscal dx_est2 = (Pick_r22[i2_4] * (fabs(C00[i2_4] + star.XYInfo.C00[i2_4]))); - if (fUseHitErrors) { - fvec dxr = 0; - dUdV_to_dX(hitr.dU(), hitr.dV(), dxr, star); - dx_est2 = (Pick_r22[i2_4] * (fabs(C00[i2_4] + dxr[0] * dxr[0]))); - } + if (fUseHitErrors) { dx_est2 = (Pick_r22[i2_4] * (fabs(C00[i2_4] + dxxScalRhit))); } - const fscal dX = xr[i2_4] - x[i2_4]; + const fscal dX = xr - x[i2_4]; if (dX * dX > dx_est2) continue; // check chi2 // not effective fvec C10; @@ -1090,7 +1058,7 @@ inline void L1Algo::findTripletsStep2( // input // TODO not updated after gaps const L1Hit& hit = (*vHits)[ihit[ih]]; u[ih] = hit.u; v[ih] = hit.v; - StripsToCoor(u[ih], v[ih], x[ih], y[ih], sta[ih]); + std::tie(x[ih], y[ih]) = sta[ih].ConvUVtoXY<fscal>(u[ih], v[ih]); z[ih] = hit.z; }; @@ -2501,9 +2469,8 @@ void L1Algo::CATrackFinder() const L1Hit& hit = (*vHits)[*phIt]; L1HitPoint tempPoint = CreateHitPoint(hit); //TODO take number of station from hit - float xcoor, ycoor = 0; L1Station stah = fParameters.GetStation(0); // TODO: Why is it a copy? - StripsToCoor(tempPoint.U(), tempPoint.V(), xcoor, ycoor, stah); + auto [xcoor, ycoor] = stah.ConvUVtoXY<fscal>(tempPoint.U(), tempPoint.V()); float zcoor = tempPoint.Z() - fParameters.GetTargetPositionZ()[0]; float timeFlight = sqrt(xcoor * xcoor + ycoor * ycoor + zcoor * zcoor) / 30.f; // c = 30[cm/ns] @@ -2520,7 +2487,7 @@ void L1Algo::CATrackFinder() for (unsigned int ih = 0; ih < tr.fHits.size(); ih++) { cout << GetMcTrackIdForHit(tr.fHits[ih]) << " "; } - cout << endl; + cout << '\n'; } } // tracks diff --git a/reco/L1/L1Algo/L1Constants.h b/reco/L1/L1Algo/L1Constants.h index 22ef92fc24..a174a0e8c0 100644 --- a/reco/L1/L1Algo/L1Constants.h +++ b/reco/L1/L1Algo/L1Constants.h @@ -51,23 +51,17 @@ namespace L1Constants namespace control { /// Flag for the radiation length tables usage - /// true - Radiational tables will be used, + /// true - material budget tables will be used, /// false - basic station material info is used constexpr bool kIfUseRadLengthTable {true}; /// Flag for calling the CAMergeClones procedure ... TODO constexpr bool kIfMergeClones {true}; - /// Flag: debug mode for analyzing the doublets performance efficiencies - //constexpr bool kIfDebugDoubletsPerformance {false}; - - /// Flag: debug mode for analyzing the tiplets performance efficiencies - //constexpr bool kIfDebugTripletsPerformance {false}; - - /// Flag: debug mode for creating pools for triplets. - /// NOTE: this feature will work only if the L1Parameters::kIfDebugTipletsPerformace is true! - //constexpr bool kIfCreateTripletPulls {false}; - } // end namespace control + /// Flag: hit errors + /// true - hit errors will be saved in the track extender algorithm + constexpr bool kIfSaveHitErrorsInTrackExtender {false}; + } // namespace control /// Physics constants namespace phys diff --git a/reco/L1/L1Algo/L1Hit.h b/reco/L1/L1Algo/L1Hit.h index 949f86d7a4..5a16305ed7 100644 --- a/reco/L1/L1Algo/L1Hit.h +++ b/reco/L1/L1Algo/L1Hit.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2007-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Valentina Akishina, Igor Kulakov, Sergey Gorbunov [committer], Maksym Zyzak */ @@ -7,7 +7,7 @@ /// @author Igor Kulakov /// @author Valentina Akishina /// @author Maksym Zyzak -/// @date 2007-2021 +/// @date 2007-2022 #ifndef L1Hit_h #define L1Hit_h @@ -15,23 +15,22 @@ using L1HitIndex_t = unsigned /*short*/ int; ///< Index of L1Hit using L1StripIndex_t = unsigned /*short*/ int; ///< Index of the station strip -/// TODO: replace typedef with using (C++11) (S.Zharko) -/// TODO: change naming: THitI -> L1HitIndex_t, TStripI -> L1StripIndex_t (S.Zharko) - - /// /// L1Hit class describes a generic hit for CA tracker +/// Note: U is a transverse coordinate of the hit in the axis perpendicular to the front strip +/// Note: V is a transverse coordinate of the hit in the axis perpendicular to the back strip /// -struct L1Hit { +class L1Hit { +public: L1StripIndex_t f {0}; ///< front strip index L1StripIndex_t b {0}; ///< back strip index - float u {0.f}; ///< measured U coordinate - float v {0.f}; ///< measured V coordinate + float u {0.f}; ///< measured U coordinate [cm] + float v {0.f}; ///< measured V coordinate [cm] float t {0.f}; ///< measured time float z {0.f}; ///< fixed Z coordinate - float du {0.f}; ///< mean squared error of u - float dv {0.f}; ///< mean squared error of v - float dt {0.f}; ///< mean squared error of t + float du {0.f}; ///< measured uncertainty of U coordinate [cm] + float dv {0.f}; ///< measured uncertainty of V coordinate [cm] + float dt {0.f}; ///< measured uncertainty of time [ns] int ID {0}; ///< TODO: check if this ID is redundant }; diff --git a/reco/L1/L1Algo/L1HitsSortHelper.cxx b/reco/L1/L1Algo/L1HitsSortHelper.cxx index 185427d61c..5030ff54c8 100644 --- a/reco/L1/L1Algo/L1HitsSortHelper.cxx +++ b/reco/L1/L1Algo/L1HitsSortHelper.cxx @@ -36,6 +36,7 @@ L1HitsSortHelper::L1HitsSortHelper(vector<L1Hit>& hits, vector<L1HitPoint>& poin fD[i].p = &(points[i]); fD[i].i = indices[i]; // StripsToCoor(fD[i].p->U(),fD[i].p->V(), x, y, vStations[iS]); + // NOTE: Use vStations[iS].ConvUVtoXY() istead // fD[i].bin = fGrid[iS].GetBinBounded(x[0], y[0]); } } diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index 3564b83647..16e80fb3e7 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -64,8 +64,8 @@ using L1DetectorID_t = std::underlying_type_t<L1DetectorID>; /// /// 3. Initialize number of stations for each detector: /// -/// initMan->SetNstationsCrosscheck(L1DetectorID::kMvd, NMvdStations) -/// initMan->SetNstationsCrosscheck(L1DetectorID::kSts, NStsStations); +/// initMan->SetNstationsCrosscheck(L1DetectorID::kMvd, fNMvdStations) +/// initMan->SetNstationsCrosscheck(L1DetectorID::kSts, fNStsStations); /// /// 4. Initialize each station using L1BaseStationInfo: /// diff --git a/reco/L1/L1Algo/L1Station.cxx b/reco/L1/L1Algo/L1Station.cxx index 5aa0c4c544..e6671a1978 100644 --- a/reco/L1/L1Algo/L1Station.cxx +++ b/reco/L1/L1Algo/L1Station.cxx @@ -87,10 +87,8 @@ void L1Station::CheckConsistency() const // Check consistency of coordinate transformations for (float x = -1.f; x < 1.1f; x += 0.2) { for (float y = -1.f; y < 1.1f; y += 0.2) { - float u, v; - std::tie(u, v) = ConvXYtoUV(x, y); - float x1, y1; - std::tie(x1, y1) = ConvUVtoXY(u, v); + auto [u, v] = ConvXYtoUV<float>(x, y); + auto [x1, y1] = ConvUVtoXY<float>(u, v); if (fabs(x1 - x) > 1.e-6 || fabs(y1 - y) > 1.e-6) { std::stringstream msg; @@ -142,7 +140,7 @@ std::string L1Station::ToString(int verbosityLevel, int indentLevel) const aStream << indent << indentChar << "X layer:\n"; aStream << xInfo.ToString(indentLevel + 2) << '\n'; aStream << indent << indentChar << "Y layer:\n"; - aStream << xInfo.ToString(indentLevel + 2) << '\n'; + aStream << yInfo.ToString(indentLevel + 2) << '\n'; } return aStream.str(); } diff --git a/reco/L1/L1Algo/L1Station.h b/reco/L1/L1Algo/L1Station.h index 565d76c4e4..02e879fcae 100644 --- a/reco/L1/L1Algo/L1Station.h +++ b/reco/L1/L1Algo/L1Station.h @@ -6,6 +6,7 @@ #define L1Station_h 1 #include <string> +#include <type_traits> #include "L1Field.h" #include "L1MaterialInfo.h" @@ -50,19 +51,79 @@ public: /// initialization void CheckConsistency() const; - /// convert x,y to u,v - std::pair<float, float> ConvXYtoUV(float x, float y) const - { + /// Converts Cartesian coordinates X and Y into strip coordinates U and V in transverse plane + /// \param x X coordinate [length unit] + /// \param y Y coordinate [length unit] + /// \return Pair of U and V strip coordinates + template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool> = true> + std::pair<T, T> ConvXYtoUV(T x, T y) const; + + /// Converts strip coordinates U and V into Cartesian coordinates X and Y in transverse plane + /// \param x X coordinate [length unit] + /// \param y Y coordinate [length unit] + /// \return Pair of Y and X Cartesian coordinates + template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool> = true> + std::pair<T, T> ConvUVtoXY(T u, T v) const; + + /// Converts variances of strip coordinates U and V into covariance matrix of Cartesian coordinates X and Y + /// \param du U coordinate uncertainty [length unit] + /// \param dv V coordinate uncertainty [length unit] + /// \return Covariance matrix of hit position in Cartesian coordinates: [dxx, dxy, dyy] [length unit squared] + template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool> = true> + std::tuple<T, T, T> FormXYCovarianceMatrix(T du, T dv) const; + +} _fvecalignment; + +// +// Template member functions implementation +// + +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool>> +std::pair<T, T> L1Station::ConvXYtoUV(T x, T y) const +{ + if constexpr (std::is_same<T, fvec>::value) { + return std::make_pair(x * frontInfo.cos_phi + y * frontInfo.sin_phi, x * backInfo.cos_phi + y * backInfo.sin_phi); + } + else { return std::make_pair(x * frontInfo.cos_phi[0] + y * frontInfo.sin_phi[0], x * backInfo.cos_phi[0] + y * backInfo.sin_phi[0]); } +} - /// convert u,v to x,y - std::pair<float, float> ConvUVtoXY(float u, float v) const - { +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool>> +std::pair<T, T> L1Station::ConvUVtoXY(T u, T v) const +{ + if constexpr (std::is_same<T, fvec>::value) { + return std::make_pair(u * xInfo.cos_phi + v * xInfo.sin_phi, u * yInfo.cos_phi + v * yInfo.sin_phi); + } + else { return std::make_pair(u * xInfo.cos_phi[0] + v * xInfo.sin_phi[0], u * yInfo.cos_phi[0] + v * yInfo.sin_phi[0]); } +} -} _fvecalignment; +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool>> +std::tuple<T, T, T> L1Station::FormXYCovarianceMatrix(T du, T dv) const +{ + if constexpr (std::is_same<T, fvec>::value) { + return std::make_tuple( + (xInfo.cos_phi * du) * (xInfo.cos_phi * du) + (xInfo.sin_phi * dv) * (xInfo.sin_phi * dv), // dx2 + (xInfo.cos_phi * du) * (yInfo.cos_phi * du) + (xInfo.sin_phi * dv) * (yInfo.sin_phi * dv), // dxy + (yInfo.cos_phi * du) * (yInfo.cos_phi * du) + (yInfo.sin_phi * dv) * (yInfo.sin_phi * dv) // dy2 + ); + } + else { + return std::make_tuple( + (xInfo.cos_phi[0] * du) * (xInfo.cos_phi[0] * du) + (xInfo.sin_phi[0] * dv) * (xInfo.sin_phi[0] * dv), // dx2 + (xInfo.cos_phi[0] * du) * (yInfo.cos_phi[0] * du) + (xInfo.sin_phi[0] * dv) * (yInfo.sin_phi[0] * dv), // dxy + (yInfo.cos_phi[0] * du) * (yInfo.cos_phi[0] * du) + (yInfo.sin_phi[0] * dv) * (yInfo.sin_phi[0] * dv) // dy2 + ); + } +} #endif // L1Station_h diff --git a/reco/L1/L1Algo/L1Station.h.orig b/reco/L1/L1Algo/L1Station.h.orig new file mode 100644 index 0000000000..bdca0e1426 --- /dev/null +++ b/reco/L1/L1Algo/L1Station.h.orig @@ -0,0 +1,173 @@ +/* Copyright (C) 2007-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov [committer], Igor Kulakov, Sergei Zharko */ + +#ifndef L1Station_h +#define L1Station_h 1 + +#include <string> +#include <type_traits> + +#include "L1Field.h" +#include "L1MaterialInfo.h" +#include "L1NaN.h" +#include "L1UMeasurementInfo.h" +#include "L1Utils.h" +#include "L1XYMeasurementInfo.h" + +/// Structure L1Station +/// Contains a set of geometry parameters for a particular station +/// +class L1Station { +public: + int type {L1NaN::SetNaN<decltype(type)>()}; + int timeInfo {L1NaN::SetNaN<decltype(timeInfo)>()}; ///< flag: if time information can be used + int fieldStatus {L1NaN::SetNaN<decltype( + fieldStatus)>()}; ///< flag: 1 - station is INSIDE the field, 0 - station is OUTSIDE the field (replace with enum) + fvec z {L1NaN::SetNaN<decltype(z)>()}; ///< z position of station [cm] + fvec Rmin {L1NaN::SetNaN<decltype(Rmin)>()}; ///< min radius of the station [cm] + fvec Rmax {L1NaN::SetNaN<decltype(Rmax)>()}; ///< max radius of the station [cm] + fvec dt {L1NaN::SetNaN<decltype(dt)>()}; ///< time resolution [ns] + /// structure containing station thickness(X), rad. length (X0), X/X0 and log(X/X0) values + L1MaterialInfo materialInfo {}; + L1FieldSlice fieldSlice {}; + L1UMeasurementInfo frontInfo {}; + L1UMeasurementInfo backInfo {}; + L1UMeasurementInfo xInfo {}; ///< x axis in front,back coordinates + L1UMeasurementInfo yInfo {}; ///< y axis in front,back coordinates + L1XYMeasurementInfo XYInfo {}; + + /// Prints object fields + /// \param verbosity Verbosity level of the output + void Print(int verbosity = 0) const; + + /// String representation of class contents + /// \param verbosityLevel Verbosity level of the output + /// \param indentLevel Number of indent characters in the output + std::string ToString(int verbosityLevel = 0, int indentLevel = 0) const; + + /// Verifies class invariant consistency + /// \note Object is considered undefined in the creation time, so this function should be called after the object + /// initialization + void CheckConsistency() const; + + /// Converts Cartesian coordinates X and Y into strip coordinates U and V in transverse plane + /// \param x X coordinate [length unit] + /// \param y Y coordinate [length unit] + /// \return Pair of U and V strip coordinates + template <typename T, + typename std::enable_if<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, T>::type* = nullptr> + std::pair<T, T> ConvXYtoUV(T x, T y) const + { + if constexpr (std::is_same<T, fvec>::value) { + return std::make_pair(x * frontInfo.cos_phi + y * frontInfo.sin_phi, + x * backInfo.cos_phi + y * backInfo.sin_phi); + } + else { + return std::make_pair(x * frontInfo.cos_phi[0] + y * frontInfo.sin_phi[0], + x * backInfo.cos_phi[0] + y * backInfo.sin_phi[0]); + } + } + + /// Converts strip coordinates U and V into Cartesian coordinates X and Y in transverse plane + /// \param x X coordinate [length unit] + /// \param y Y coordinate [length unit] + /// \return Pair of Y and X Cartesian coordinates + template <typename T, + typename std::enable_if<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, T>::type* = nullptr> + std::pair<T, T> ConvUVtoXY(T u, T v) const + { + if constexpr (std::is_same<T, fvec>::value) { + return std::make_pair(u * xInfo.cos_phi + v * xInfo.sin_phi, u * yInfo.cos_phi + v * yInfo.sin_phi); + } + else { + return std::make_pair(u * xInfo.cos_phi[0] + v * xInfo.sin_phi[0], u * yInfo.cos_phi[0] + v * yInfo.sin_phi[0]); + } + } + + /// Converts variances of strip coordinates U and V into covariance matrix of Cartesian coordinates X and Y + /// \param du U coordinate uncertainty [length unit] + /// \param dv V coordinate uncertainty [length unit] + /// \return Covariance matrix of hit position in Cartesian coordinates: [dxx, dxy, dyy] [length unit squared] +<<<<<<< Updated upstream + template <typename T, + typename std::enable_if<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, T>::type* = nullptr> + std::tuple<T, T, T> FormXYCovarianceMatrix(T du, T dv) const + { + if constexpr (std::is_same<T, fvec>::value) { + return std::make_tuple( + (xInfo.cos_phi * du) * (xInfo.cos_phi * du) + (xInfo.sin_phi * dv) * (xInfo.sin_phi * dv), // dx2 + (xInfo.cos_phi * du) * (yInfo.cos_phi * du) + (xInfo.sin_phi * dv) * (yInfo.sin_phi * dv), // dxy + (yInfo.cos_phi * du) * (yInfo.cos_phi * du) + (yInfo.sin_phi * dv) * (yInfo.sin_phi * dv) // dy2 + ); + } + else { + return std::make_tuple( + (xInfo.cos_phi[0] * du) * (xInfo.cos_phi[0] * du) + (xInfo.sin_phi[0] * dv) * (xInfo.sin_phi[0] * dv), // dx2 + (xInfo.cos_phi[0] * du) * (yInfo.cos_phi[0] * du) + (xInfo.sin_phi[0] * dv) * (yInfo.sin_phi[0] * dv), // dxy + (yInfo.cos_phi[0] * du) * (yInfo.cos_phi[0] * du) + (yInfo.sin_phi[0] * dv) * (yInfo.sin_phi[0] * dv) // dy2 + ); + } +======= + template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool> = true> + std::tuple<T, T, T> FormXYCovarianceMatrix(T du, T dv) const; + +} _fvecalignment; + +// +// Template member functions implementation +// + +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool>> +std::pair<T, T> L1Station::ConvXYtoUV(T x, T y) const +{ + if constexpr (std::is_same<T, fvec>::value) { + return std::make_pair(x * frontInfo.cos_phi + y * frontInfo.sin_phi, x * backInfo.cos_phi + y * backInfo.sin_phi); + } + else { + return std::make_pair(x * frontInfo.cos_phi[0] + y * frontInfo.sin_phi[0], + x * backInfo.cos_phi[0] + y * backInfo.sin_phi[0]); +>>>>>>> Stashed changes + } + +<<<<<<< Updated upstream +} _fvecalignment; +======= +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool>> +std::pair<T, T> L1Station::ConvUVtoXY(T u, T v) const +{ + if constexpr (std::is_same<T, fvec>::value) { + return std::make_pair(u * xInfo.cos_phi + v * xInfo.sin_phi, u * yInfo.cos_phi + v * yInfo.sin_phi); + } + else { + return std::make_pair(u * xInfo.cos_phi[0] + v * xInfo.sin_phi[0], u * yInfo.cos_phi[0] + v * yInfo.sin_phi[0]); + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// +template<typename T, std::enable_if_t<std::is_floating_point<T>::value || std::is_same<T, fvec>::value, bool>> +std::tuple<T, T, T> L1Station::FormXYCovarianceMatrix(T du, T dv) const +{ + if constexpr (std::is_same<T, fvec>::value) { + return std::make_tuple( + (xInfo.cos_phi * du) * (xInfo.cos_phi * du) + (xInfo.sin_phi * dv) * (xInfo.sin_phi * dv), // dx2 + (xInfo.cos_phi * du) * (yInfo.cos_phi * du) + (xInfo.sin_phi * dv) * (yInfo.sin_phi * dv), // dxy + (yInfo.cos_phi * du) * (yInfo.cos_phi * du) + (yInfo.sin_phi * dv) * (yInfo.sin_phi * dv) // dy2 + ); + } + else { + return std::make_tuple( + (xInfo.cos_phi[0] * du) * (xInfo.cos_phi[0] * du) + (xInfo.sin_phi[0] * dv) * (xInfo.sin_phi[0] * dv), // dx2 + (xInfo.cos_phi[0] * du) * (yInfo.cos_phi[0] * du) + (xInfo.sin_phi[0] * dv) * (yInfo.sin_phi[0] * dv), // dxy + (yInfo.cos_phi[0] * du) * (yInfo.cos_phi[0] * du) + (yInfo.sin_phi[0] * dv) * (yInfo.sin_phi[0] * dv) // dy2 + ); + } +} +>>>>>>> Stashed changes + +#endif // L1Station_h diff --git a/reco/L1/L1Algo/L1Track.h b/reco/L1/L1Algo/L1Track.h index 21c4bc93af..23cbafaf74 100644 --- a/reco/L1/L1Algo/L1Track.h +++ b/reco/L1/L1Algo/L1Track.h @@ -36,9 +36,9 @@ public: float Momentum {kNaN}; ///< TODO: ?? float fTrackTime {kNaN}; ///< Track time fscal TFirst[7] {kNaN}; ///< Track parameters on the first station - fscal CFirst[21] {kNaN}; ///< Track parameter covariation matrix elemenst on the first station + fscal CFirst[21] {kNaN}; ///< Track parameter covariation matrix elements on the first station fscal TLast[7] {kNaN}; ///< Track parameters on the last station - fscal CLast[21] {kNaN}; ///< Track parameter covatiation matrix elements on the second station + fscal CLast[21] {kNaN}; ///< Track parameter covariation matrix elements on the second station fscal Tpv[7] {kNaN}; ///< Track parameters in the primary vertex fscal Cpv[21] {kNaN}; ///< Track parameter covariation matrix elements in the primary vertex fscal chi2 {kNaN}; ///< Track fit chi-square value diff --git a/reco/L1/L1Algo/L1TrackExtender.cxx b/reco/L1/L1Algo/L1TrackExtender.cxx index ece5b290d7..9d38fe5ea5 100644 --- a/reco/L1/L1Algo/L1TrackExtender.cxx +++ b/reco/L1/L1Algo/L1TrackExtender.cxx @@ -54,20 +54,17 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& T, const bool dir, fvec u0 = hit0.u; fvec v0 = hit0.v; - fvec x0, y0; - StripsToCoor(u0, v0, x0, y0, sta0); + auto [x0, y0] = sta0.ConvUVtoXY<fvec>(u0, v0); fvec z0 = hit0.z; fvec u1 = hit1.u; fvec v1 = hit1.v; - fvec x1, y1; - StripsToCoor(u1, v1, x1, y1, sta1); + auto [x1, y1] = sta1.ConvUVtoXY<fvec>(u1, v1); fvec z1 = hit1.z; fvec u2 = hit2.u; fvec v2 = hit2.v; - fvec x2, y2; - StripsToCoor(u2, v2, x2, y2, sta2); + auto [x2, y2] = sta2.ConvUVtoXY<fvec>(u2, v2); // fvec z2 = hit2.z; fvec dzi = 1. / (z1 - z0); @@ -167,8 +164,7 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& T, const bool dir, fldB1 = fldB2; fldZ0 = fldZ1; fldZ1 = fldZ2; - fvec x, y; - StripsToCoor(u, v, x, y, sta); + auto [x, y] = sta.ConvUVtoXY<fvec>(u, v); sta.fieldSlice.GetFieldValue(x, y, fldB2); fldZ2 = sta.z; @@ -219,18 +215,15 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& T, const bool dir, fvec u0 = hit0.u; fvec v0 = hit0.v; - fvec x0, y0; - StripsToCoor(u0, v0, x0, y0, sta0); + auto [x0, y0] = sta0.ConvUVtoXY<fvec>(u0, v0); fvec u1 = hit1.u; fvec v1 = hit1.v; - fvec x1, y1; - StripsToCoor(u1, v1, x1, y1, sta1); + auto [x1, y1] = sta1.ConvUVtoXY<fvec>(u1, v1); fvec u2 = hit2.u; fvec v2 = hit2.v; - fvec x2, y2; - StripsToCoor(u2, v2, x2, y2, sta2); + auto [x2, y2] = sta2.ConvUVtoXY<fvec>(u2, v2); L1FieldValue fldB0, fldB1, fldB2 _fvecalignment; L1FieldRegion fld _fvecalignment; @@ -316,9 +309,8 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& T, const bool dir, const L1Hit& hit = (*vHitsUnused)[iHit_best]; fvec u = hit.u; fvec v = hit.v; - fvec x, y, z; - StripsToCoor(u, v, x, y, sta); - z = hit.z; + fvec z = hit.z; + auto [x, y] = sta.ConvUVtoXY<fvec>(u, v); fvec dz1 = z - T.z; diff --git a/reco/L1/L1Algo/L1TrackFitter.cxx b/reco/L1/L1Algo/L1TrackFitter.cxx index 5d99d26c11..f65c48511d 100644 --- a/reco/L1/L1Algo/L1TrackFitter.cxx +++ b/reco/L1/L1Algo/L1TrackFitter.cxx @@ -67,20 +67,17 @@ void L1Algo::KFTrackFitter_simple() // TODO: Add pipe. fvec u0 = hit0.u; fvec v0 = hit0.v; - fvec x0, y0; - StripsToCoor(u0, v0, x0, y0, sta0); + auto [x0, y0] = sta0.ConvUVtoXY<fvec>(u0, v0); fvec z0 = hit0.z; fvec u1 = hit1.u; fvec v1 = hit1.v; - fvec x1, y1; - StripsToCoor(u1, v1, x1, y1, sta1); + auto [x1, y1] = sta1.ConvUVtoXY<fvec>(u1, v1); fvec z1 = hit1.z; fvec u2 = hit2.u; fvec v2 = hit2.v; - fvec x2, y2; - StripsToCoor(u2, v2, x2, y2, sta2); + auto [x2, y2] = sta1.ConvUVtoXY<fvec>(u2, v2); // fvec z2 = hit2.z; fvec dzi = 1. / (z1 - z0); @@ -146,9 +143,7 @@ void L1Algo::KFTrackFitter_simple() // TODO: Add pipe. fvec u = hit.u; fvec v = hit.v; - fvec x, y; - StripsToCoor(u, v, x, y, sta); - + auto [x, y] = sta.ConvUVtoXY<fvec>(u, v); L1Filter(T, sta.frontInfo, u); L1Filter(T, sta.backInfo, v); fldB0 = fldB1; @@ -208,19 +203,17 @@ void L1Algo::KFTrackFitter_simple() // TODO: Add pipe. fvec u0 = hit0.u; fvec v0 = hit0.v; - fvec x0, y0; - StripsToCoor(u0, v0, x0, y0, sta0); + auto [x0, y0] = sta0.ConvUVtoXY<fvec>(u0, v0); fvec z0 = hit0.z; + fvec u1 = hit1.u; fvec v1 = hit1.v; - fvec x1, y1; - StripsToCoor(u1, v1, x1, y1, sta1); + auto [x1, y1] = sta1.ConvUVtoXY<fvec>(u1, v1); // fvec z1 = hit1.z; fvec u2 = hit2.u; fvec v2 = hit2.v; - fvec x2, y2; - StripsToCoor(u2, v2, x2, y2, sta2); + auto [x2, y2] = sta2.ConvUVtoXY<fvec>(u2, v2); // fvec z2 = hit2.z; // fvec dzi = 1./(z1-z0); @@ -267,8 +260,7 @@ void L1Algo::KFTrackFitter_simple() // TODO: Add pipe. const L1Station& sta = fParameters.GetStation(ista); fvec u = hit.u; fvec v = hit.v; - fvec x, y; - StripsToCoor(u, v, x, y, sta); + auto [x, y] = sta.ConvUVtoXY<fvec>(u, v); // L1Extrapolate( T, hit.z, qp0, fld ); L1ExtrapolateLine(T, hit.z); @@ -353,27 +345,65 @@ void L1Algo::L1KFTrackFitter() L1Track* t[fvecLen]; const L1Station* sta = fParameters.GetStations().begin(); - L1Station staFirst, staLast; - fvec x[L1Constants::size::kMaxNstations], u[L1Constants::size::kMaxNstations], v[L1Constants::size::kMaxNstations], - y[L1Constants::size::kMaxNstations], time[L1Constants::size::kMaxNstations], - timeEr[L1Constants::size::kMaxNstations], z[L1Constants::size::kMaxNstations]; - fvec d_x[L1Constants::size::kMaxNstations], d_y[L1Constants::size::kMaxNstations], - d_xy[L1Constants::size::kMaxNstations], d_u[L1Constants::size::kMaxNstations], - d_v[L1Constants::size::kMaxNstations]; - fvec x_first, y_first, time_first, x_last, y_last, time_last, time_er_first, time_er_last, d_x_fst, d_y_fst, d_xy_fst, - time_er_lst, d_x_lst, d_y_lst, d_xy_lst; - fvec Sy[L1Constants::size::kMaxNstations], w[L1Constants::size::kMaxNstations], - w_time[L1Constants::size::kMaxNstations]; - fvec y_temp, x_temp; - fvec fldZ0, fldZ1, fldZ2, z_start, z_end; + L1Station staFirst, staLast; // FIXME (?): Probably, we should replace these variables with references (S.Zharko) + + // Spatial-time position of a hit vs. station and track in the portion + // NOTE: u- and v-axes are axes, orthogonal to front and back strips of the station, respectively. + fvec u[L1Constants::size::kMaxNstations]; // Hit position along the u-axis [cm] + fvec v[L1Constants::size::kMaxNstations]; // Hit position along the v-axis [cm] + fvec d_u[L1Constants::size::kMaxNstations]; // Hit position uncertainty along the u-axis [cm] + fvec d_v[L1Constants::size::kMaxNstations]; // Hit position uncertainty along the v-axis [cm] + + fvec x[L1Constants::size::kMaxNstations]; // Hit position along the x-axis [cm] + fvec y[L1Constants::size::kMaxNstations]; // Hit position along the y-axis [cm] + fvec d_xx[L1Constants::size::kMaxNstations]; // Variance of the x hit position coordinate [cm2] + fvec d_yy[L1Constants::size::kMaxNstations]; // Variance of the y hit position coordinate [cm2] + fvec d_xy[L1Constants::size::kMaxNstations]; // Covariance between the x and y hit position coordinates [cm2] + + fvec z[L1Constants::size::kMaxNstations]; // Hit position along the z-axis (precised) [cm] + + fvec time[L1Constants::size::kMaxNstations]; // Hit time [ns] + fvec timeEr[L1Constants::size::kMaxNstations]; // Hit time uncertainty [ns] + + fvec x_first; + fvec y_first; + fvec d_xx_fst; + fvec d_yy_fst; + fvec d_xy_fst; + + fvec time_first; + fvec time_er_first; + + fvec x_last; + fvec y_last; + fvec d_xx_lst; + fvec d_yy_lst; + fvec d_xy_lst; + + fvec time_last; + fvec time_er_last; + fvec time_er_lst; /// TODO: Why are there two different variables for the time error on the last station? + + fvec Sy[L1Constants::size::kMaxNstations]; + fvec w[L1Constants::size::kMaxNstations]; + fvec w_time[L1Constants::size::kMaxNstations]; // !!! + fvec y_temp; + fvec x_temp; + fvec fldZ0; + fvec fldZ1; + fvec fldZ2; + fvec z_start; + fvec z_end; + L1FieldValue fB[L1Constants::size::kMaxNstations], fB_temp _fvecalignment; + fvec ZSta[L1Constants::size::kMaxNstations]; for (int iHit = 0; iHit < nHits; iHit++) { ZSta[iHit] = sta[iHit].z; } - unsigned short N_vTracks = fTracks.size(); + unsigned short N_vTracks = fTracks.size(); // number of tracks processed per one SSE register for (unsigned short itrack = 0; itrack < N_vTracks; itrack += fvecLen) { if (N_vTracks - itrack < static_cast<unsigned short>(fvecLen)) nTracks_SIMD = N_vTracks - itrack; @@ -402,16 +432,15 @@ void L1Algo::L1KFTrackFitter() v[ista][iVec] = hit.v; d_u[ista][iVec] = hit.du; d_v[ista][iVec] = hit.dv; - StripsToCoor(u[ista], v[ista], x_temp, y_temp, sta[ista]); + std::tie(x_temp, y_temp) = sta[ista].ConvUVtoXY<fvec>(u[ista], v[ista]); x[ista][iVec] = x_temp[iVec]; y[ista][iVec] = y_temp[iVec]; time[ista][iVec] = hit.t; timeEr[ista][iVec] = hit.dt; z[ista][iVec] = hit.z; sta[ista].fieldSlice.GetFieldValue(x[ista], y[ista], fB_temp); - dUdV_to_dX(d_u[ista], d_v[ista], d_x[ista], sta[ista]); - dUdV_to_dY(d_u[ista], d_v[ista], d_y[ista], sta[ista]); - dUdV_to_dXdY(d_u[ista], d_v[ista], d_xy[ista], sta[ista]); + std::tie(d_xx[ista], d_xy[ista], d_yy[ista]) = sta[ista].FormXYCovarianceMatrix(d_u[ista], d_v[ista]); + fB[ista].x[iVec] = fB_temp.x[iVec]; fB[ista].y[iVec] = fB_temp.y[iVec]; fB[ista].z[iVec] = fB_temp.z[iVec]; @@ -421,8 +450,8 @@ void L1Algo::L1KFTrackFitter() y_first[iVec] = y[ista][iVec]; time_first[iVec] = time[ista][iVec]; time_er_first[iVec] = timeEr[ista][iVec]; - d_x_fst[iVec] = d_x[ista][iVec]; - d_y_fst[iVec] = d_y[ista][iVec]; + d_xx_fst[iVec] = d_xx[ista][iVec]; + d_yy_fst[iVec] = d_yy[ista][iVec]; d_xy_fst[iVec] = d_xy[ista][iVec]; staFirst.XYInfo.C00[iVec] = sta[ista].XYInfo.C00[iVec]; staFirst.XYInfo.C10[iVec] = sta[ista].XYInfo.C10[iVec]; @@ -432,8 +461,8 @@ void L1Algo::L1KFTrackFitter() z_end[iVec] = z[ista][iVec]; x_last[iVec] = x[ista][iVec]; y_last[iVec] = y[ista][iVec]; - d_x_lst[iVec] = d_x[ista][iVec]; - d_y_lst[iVec] = d_y[ista][iVec]; + d_xx_lst[iVec] = d_xx[ista][iVec]; + d_yy_lst[iVec] = d_yy[ista][iVec]; d_xy_lst[iVec] = d_xy[ista][iVec]; time_last[iVec] = time[ista][iVec]; time_er_last[iVec] = timeEr[ista][iVec]; @@ -475,7 +504,7 @@ void L1Algo::L1KFTrackFitter() FilterFirst(T, x_last, y_last, staLast); // FilterFirst( T1, x_last, y_last, time_last, time_er_last, staLast ); - FilterFirst(T1, x_last, y_last, time_last, time_er_last, staLast, d_x_lst, d_y_lst, d_xy_lst); + FilterFirst(T1, x_last, y_last, time_last, time_er_last, staLast, d_xx_lst, d_yy_lst, d_xy_lst); T1.Filter(time[i], timeEr[i], w_time[i], sta[i].timeInfo); @@ -638,7 +667,7 @@ void L1Algo::L1KFTrackFitter() FilterFirst(T, x_first, y_first, staFirst); // FilterFirst( T1, x_first, y_first, time_first, time_er_first, staFirst); - FilterFirst(T1, x_first, y_first, time_first, time_er_first, staFirst, d_x_fst, d_y_fst, d_xy_fst); + FilterFirst(T1, x_first, y_first, time_first, time_er_first, staFirst, d_xx_fst, d_yy_fst, d_xy_fst); T1.Filter(time[i], timeEr[i], w_time[i], sta[i].timeInfo); @@ -782,20 +811,57 @@ void L1Algo::L1KFTrackFitterMuch() const L1Station* sta = fParameters.GetStations().begin(); L1Station staFirst, staLast; - fvec x[L1Constants::size::kMaxNstations], u[L1Constants::size::kMaxNstations], v[L1Constants::size::kMaxNstations], - y[L1Constants::size::kMaxNstations], time[L1Constants::size::kMaxNstations], - timeEr[L1Constants::size::kMaxNstations], z[L1Constants::size::kMaxNstations]; - fvec d_x[L1Constants::size::kMaxNstations], d_y[L1Constants::size::kMaxNstations], - d_xy[L1Constants::size::kMaxNstations], d_u[L1Constants::size::kMaxNstations], - d_v[L1Constants::size::kMaxNstations]; - fvec x_first, y_first, time_first, x_last, y_last, time_last, time_er_fst, d_x_fst, d_y_fst, d_xy_fst, time_er_lst, - d_x_lst, d_y_lst, d_xy_lst, dz; - int iSta[L1Constants::size::kMaxNstations]; - fvec Sy[L1Constants::size::kMaxNstations], w[L1Constants::size::kMaxNstations]; - fvec y_temp, x_temp; - fvec fldZ0, fldZ1, fldZ2, z_start, z_end; + + + fvec u[L1Constants::size::kMaxNstations]; + fvec v[L1Constants::size::kMaxNstations]; + fvec d_u[L1Constants::size::kMaxNstations]; + fvec d_v[L1Constants::size::kMaxNstations]; + + fvec x[L1Constants::size::kMaxNstations]; + fvec y[L1Constants::size::kMaxNstations]; + fvec d_xx[L1Constants::size::kMaxNstations]; + fvec d_yy[L1Constants::size::kMaxNstations]; + fvec d_xy[L1Constants::size::kMaxNstations]; + + fvec z[L1Constants::size::kMaxNstations]; + + fvec time[L1Constants::size::kMaxNstations]; + fvec timeEr[L1Constants::size::kMaxNstations]; + + fvec x_first; + fvec y_first; + fvec d_xx_fst; + fvec d_yy_fst; + fvec d_xy_fst; + + fvec time_first; + fvec time_er_fst; + + fvec x_last; + fvec y_last; + fvec d_xx_lst; + fvec d_yy_lst; + fvec d_xy_lst; + + fvec time_last; + fvec time_er_lst; + fvec dz; /// !!! + + fvec Sy[L1Constants::size::kMaxNstations]; + fvec w[L1Constants::size::kMaxNstations]; + fvec y_temp; + fvec x_temp; + fvec fldZ0; + fvec fldZ1; + fvec fldZ2; + fvec z_start; + fvec z_end; + + L1FieldValue fB[L1Constants::size::kMaxNstations], fB_temp _fvecalignment; + int iSta[L1Constants::size::kMaxNstations]; /// !!! fvec ZSta[L1Constants::size::kMaxNstations]; for (int iHit = 0; iHit < nHits; iHit++) { ZSta[iHit] = sta[iHit].z; @@ -817,8 +883,8 @@ void L1Algo::L1KFTrackFitterMuch() for (iVec = 0; iVec < nTracks_SIMD; iVec++) { for (i = 0; i < fNstations; i++) { - d_x[i][iVec] = 0; - d_y[i][iVec] = 0; + d_xx[i][iVec] = 0; + d_yy[i][iVec] = 0; } } @@ -832,21 +898,20 @@ void L1Algo::L1KFTrackFitterMuch() iSta[i] = ista; w[ista][iVec] = 1.; - d_x[i][iVec] = 0; - d_y[i][iVec] = 0; + d_xx[i][iVec] = 0; + d_yy[i][iVec] = 0; u[ista][iVec] = hit.u; v[ista][iVec] = hit.v; - StripsToCoor(u[ista], v[ista], x_temp, y_temp, sta[ista]); + std::tie(x_temp, y_temp) = sta[ista].ConvUVtoXY<fvec>(u[ista], v[ista]); x[ista][iVec] = x_temp[iVec]; y[ista][iVec] = y_temp[iVec]; time[ista][iVec] = hit.t; timeEr[ista][iVec] = hit.dt; d_u[ista][iVec] = hit.du; d_v[ista][iVec] = hit.dv; - dUdV_to_dX(d_u[ista], d_v[ista], d_x[ista], sta[ista]); - dUdV_to_dY(d_u[ista], d_v[ista], d_y[ista], sta[ista]); - dUdV_to_dXdY(d_u[ista], d_v[ista], d_xy[ista], sta[ista]); + std::tie(d_xx[ista], d_xy[ista], d_yy[ista]) = sta[ista].FormXYCovarianceMatrix(d_u[ista], d_v[ista]); + // mom[ista][iVec] = hit.p; z[ista][iVec] = hit.z; sta[ista].fieldSlice.GetFieldValue(x[ista], y[ista], fB_temp); @@ -859,8 +924,8 @@ void L1Algo::L1KFTrackFitterMuch() y_first[iVec] = y[ista][iVec]; time_first[iVec] = time[ista][iVec]; time_er_fst[iVec] = timeEr[ista][iVec]; - d_x_fst[iVec] = d_x[ista][iVec]; - d_y_fst[iVec] = d_y[ista][iVec]; + d_xx_fst[iVec] = d_xx[ista][iVec]; + d_yy_fst[iVec] = d_yy[ista][iVec]; d_xy_fst[iVec] = d_xy[ista][iVec]; staFirst.XYInfo.C00[iVec] = sta[ista].XYInfo.C00[iVec]; staFirst.XYInfo.C10[iVec] = sta[ista].XYInfo.C10[iVec]; @@ -872,8 +937,8 @@ void L1Algo::L1KFTrackFitterMuch() y_last[iVec] = y[ista][iVec]; time_last[iVec] = time[ista][iVec]; time_er_lst[iVec] = timeEr[ista][iVec]; - d_x_lst[iVec] = d_x[ista][iVec]; - d_y_lst[iVec] = d_y[ista][iVec]; + d_xx_lst[iVec] = d_xx[ista][iVec]; + d_yy_lst[iVec] = d_yy[ista][iVec]; d_xy_lst[iVec] = d_xy[ista][iVec]; staLast.XYInfo.C00[iVec] = sta[ista].XYInfo.C00[iVec]; staLast.XYInfo.C10[iVec] = sta[ista].XYInfo.C10[iVec]; @@ -921,7 +986,7 @@ void L1Algo::L1KFTrackFitterMuch() FilterFirst(T, x_first, y_first, staFirst); - FilterFirst(T1, x_first, y_first, time_first, time_er_fst, staFirst, d_x_fst, d_y_fst, d_xy_fst); + FilterFirst(T1, x_first, y_first, time_first, time_er_fst, staFirst, d_xx_fst, d_yy_fst, d_xy_fst); fldZ1 = z[i]; @@ -979,12 +1044,12 @@ void L1Algo::L1KFTrackFitterMuch() } L1UMeasurementInfo info = sta[i].frontInfo; - info.sigma2 = d_x[i] * d_x[i]; + info.sigma2 = d_xx[i]; L1Filter(T, info, u[i], w1); T1.Filter(info, u[i], w1); info = sta[i].backInfo; - info.sigma2 = d_y[i] * d_y[i]; + info.sigma2 = d_yy[i]; L1Filter(T, info, v[i], w1); T1.Filter(info, v[i], w1); @@ -1068,12 +1133,12 @@ void L1Algo::L1KFTrackFitterMuch() // T1.ExtrapolateLine( z_last, &w1); // L1UMeasurementInfo info = sta[i].frontInfo; - info.sigma2 = d_x[i] * d_x[i]; + info.sigma2 = d_xx[i]; L1Filter(T, info, u[i], w1); T1.Filter(info, u[i], w1); info = sta[i].backInfo; - info.sigma2 = d_y[i] * d_y[i]; + info.sigma2 = d_yy[i]; L1Filter(T, info, v[i], w1); T1.Filter(info, v[i], w1); @@ -1126,7 +1191,7 @@ void L1Algo::L1KFTrackFitterMuch() FilterFirst(T, x_last, y_last, staLast); - FilterFirstL(T1, x_last, y_last, time_last, time_er_lst, staLast, d_x_lst, d_y_lst, d_xy_lst); + FilterFirstL(T1, x_last, y_last, time_last, time_er_lst, staLast, d_xx_lst, d_yy_lst, d_xy_lst); qp0 = T.qp; qp01 = T1.fqp; @@ -1214,13 +1279,13 @@ void L1Algo::L1KFTrackFitterMuch() L1UMeasurementInfo info = sta[i].frontInfo; - info.sigma2 = d_x[i] * d_x[i]; + info.sigma2 = d_xx[i]; L1Filter(T, info, u[i], w1); T1.Filter(info, u[i], w1); info = sta[i].backInfo; - info.sigma2 = d_y[i] * d_y[i]; + info.sigma2 = d_yy[i]; L1Filter(T, info, v[i], w1); T1.Filter(info, v[i], w1); @@ -1564,14 +1629,9 @@ void L1Algo::FilterFirst(L1TrackParFit& track, fvec& x, fvec& y, fvec& t, L1Stat track.NDF = -3.0; track.chi2 = ZERO; } -void L1Algo::FilterFirst(L1TrackParFit& track, fvec& x, fvec& y, fvec& t, fvec& dt, L1Station& st, fvec& /*d_x*/, - fvec& /*d_y*/, fvec& /*d_xy*/) +void L1Algo::FilterFirst(L1TrackParFit& track, fvec& x, fvec& y, fvec& t, fvec& dt, L1Station& st, fvec& /*d_xx*/, + fvec& /*d_yy*/, fvec& /*d_xy*/) { - // initialize covariance matrix - // track.C00= d_x*d_x; - // track.C10= d_xy; track.C11= d_y*d_y; - - track.C00 = st.XYInfo.C00; track.C10 = st.XYInfo.C10; track.C11 = st.XYInfo.C11; @@ -1603,10 +1663,6 @@ void L1Algo::FilterFirst(L1TrackParFit& track, fvec& x, fvec& y, fvec& t, fvec& void L1Algo::FilterFirst(L1TrackParFit& track, fvec& x, fvec& y, fvec& /*t*/, fvec& dt, L1Station& st) { - // initialize covariance matrix - // track.C00= d_x*d_x; - // track.C10= d_xy; track.C11= d_y*d_y; - track.C00 = st.XYInfo.C00; track.C10 = st.XYInfo.C10; track.C11 = st.XYInfo.C11; @@ -1636,15 +1692,16 @@ void L1Algo::FilterFirst(L1TrackParFit& track, fvec& x, fvec& y, fvec& /*t*/, fv } -void L1Algo::FilterFirstL(L1TrackParFit& track, fvec& x, fvec& y, fvec& /*t*/, fvec& dt, L1Station& /*st*/, fvec& d_x, - fvec& d_y, fvec& d_xy) +void L1Algo::FilterFirstL(L1TrackParFit& track, fvec& x, fvec& y, fvec& /*t*/, fvec& dt, L1Station& /*st*/, fvec& d_xx, + fvec& d_yy, fvec& d_xy) { // initialize covariance matrix - track.C00 = d_x * d_x; + track.C00 = d_xx; track.C10 = d_xy; - track.C11 = d_y * d_y; + track.C11 = d_yy; // track.C00= st.XYInfo.C00; - // track.C10= st.XYInfo.C10; track.C11= st.XYInfo.C11; + // track.C10= st.XYInfo.C10; + // track.C11= st.XYInfo.C11; track.C20 = ZERO; track.C21 = ZERO; track.C22 = vINF; @@ -1667,6 +1724,6 @@ void L1Algo::FilterFirstL(L1TrackParFit& track, fvec& x, fvec& y, fvec& /*t*/, f track.fx = x; track.fy = y; // track.ft = t; - track.NDF = -3.0; + track.NDF = -3.0; // TODO: Why -3.0? (S.Zharko) track.chi2 = ZERO; } diff --git a/reco/L1/L1Algo/utils/L1AlgoDraw.cxx b/reco/L1/L1Algo/utils/L1AlgoDraw.cxx index 5d515e6c07..a11086b297 100644 --- a/reco/L1/L1Algo/utils/L1AlgoDraw.cxx +++ b/reco/L1/L1Algo/utils/L1AlgoDraw.cxx @@ -99,7 +99,7 @@ void L1AlgoDraw::DrawMCTracks() cout << "Gray - secondary p < 0.5 - (third\\second iteration)" << endl; }; - for (vector<CbmL1MCTrack>::iterator it = L1.vMCTracks.begin(); it != L1.vMCTracks.end(); ++it) { + for (vector<CbmL1MCTrack>::iterator it = L1.fvMCTracks.begin(); it != L1.fvMCTracks.end(); ++it) { CbmL1MCTrack& T = *it; //draw reconstructable tracks only if (!T.IsReconstructable()) continue; @@ -141,7 +141,7 @@ void L1AlgoDraw::DrawMCTracks() cout << endl; } for (int ip = 0; ip < npoints; ip++) { - CbmL1MCPoint& p = L1.vMCPoints[T.Points[ip]]; + CbmL1MCPoint& p = L1.fvMCPoints[T.Points[ip]]; double par1[6]; //if( fabs(p.pz)<0.05 ) continue; par1[0] = p.x; @@ -557,7 +557,7 @@ void L1AlgoDraw::DrawInputHits() Int_t n_poly_fake = 0; for (int ih = HitsStartIndex[ista]; ih < HitsStopIndex[ista]; ih++) { L1Hit& h = vHits[ih]; - int iMC = CbmL1::Instance()->vHitMCRef[ih]; + int iMC = CbmL1::Instance()->fvHitPointIndexes[ih]; //if( (vSFlag[h.f] | vSFlagB[h.b] )&0x02 ) continue; // if used float x, y, z; @@ -691,7 +691,7 @@ void L1AlgoDraw::DrawRestHits(L1HitIndex_t* StsRestHitsStartIndex, L1HitIndex_t* for (L1HitIndex_t iRestHit = StsRestHitsStartIndex[ista]; iRestHit < StsRestHitsStopIndex[ista]; iRestHit++) { int ih = realIHit[iRestHit]; L1Hit& h = vHits[ih]; - int iMC = CbmL1::Instance()->vHitMCRef[ih]; + int iMC = CbmL1::Instance()->fvHitPointIndexes[ih]; //if( (vSFlag[h.f] | vSFlagB[h.b] )&0x02 ) continue; // if used float x, y, z; diff --git a/reco/L1/L1Algo/utils/L1AlgoEfficiencyPerformance.h b/reco/L1/L1Algo/utils/L1AlgoEfficiencyPerformance.h index 7809e79d4f..5791f20567 100644 --- a/reco/L1/L1Algo/utils/L1AlgoEfficiencyPerformance.h +++ b/reco/L1/L1Algo/utils/L1AlgoEfficiencyPerformance.h @@ -135,7 +135,7 @@ private: void FillMC(); // collect mcTracklets from mcTracks void MatchTracks(); - CbmL1* fL1 {nullptr}; + CbmL1* fL1 {nullptr}; // TODO: remove dependency (S.Zharko) vector<L1RecoTracklet> recoTracklets {}; vector<L1MCTracklet> mcTracklets {}; @@ -166,7 +166,7 @@ void L1AlgoEfficiencyPerformance<NHits>::Init() template<int NHits> void L1AlgoEfficiencyPerformance<NHits>::FillMC() { - for (vector<CbmL1MCTrack>::iterator mtraIt = fL1->vMCTracks.begin(); mtraIt != fL1->vMCTracks.end(); mtraIt++) { + for (vector<CbmL1MCTrack>::iterator mtraIt = fL1->fvMCTracks.begin(); mtraIt != fL1->fvMCTracks.end(); mtraIt++) { CbmL1MCTrack& mtra = *(mtraIt); // if( ! mtra.IsReconstructable() ) continue; @@ -175,7 +175,7 @@ void L1AlgoEfficiencyPerformance<NHits>::FillMC() int lastIterSta = -1; for (int iterOffset = 0; iterOffset < NMCPoints; iterOffset++) { // first mcPoint on the station // const int iterMcId = mtra.Points[iterOffset]; - int iterSta = fL1->vMCPoints[mtra.Points[iterOffset]].iStation; + int iterSta = fL1->fvMCPoints[mtra.Points[iterOffset]].iStation; if (iterSta == lastIterSta) continue; // find offset for next station lastIterSta = iterSta; @@ -185,7 +185,7 @@ void L1AlgoEfficiencyPerformance<NHits>::FillMC() L1MCTracklet trlet; // TODO: don't use hits in mcTracklet for (int is = 0, offset = iterOffset; ((offset < NMCPoints) && (is < NHits)); offset++) { const int mcId = mtra.Points[offset]; - CbmL1MCPoint* mcPs = &(fL1->vMCPoints[mcId]); + CbmL1MCPoint* mcPs = &(fL1->fvMCPoints[mcId]); is = mcPs->iStation - iterSta; if (is < NHits) { @@ -206,7 +206,7 @@ void L1AlgoEfficiencyPerformance<NHits>::FillMC() trlet.mcTrackId = mtra.ID; trlet.mcMotherTrackId = mtra.mother_ID; trlet.p = mtra.p; - if (mtra.p > 1. / fL1->algo->GetMaxInvMom()) trlet.SetAsReconstructable(); + if (mtra.p > 1. / fL1->fpAlgo->GetMaxInvMom()) trlet.SetAsReconstructable(); mcTracklets.push_back(trlet); } // for Iter = stations @@ -224,10 +224,10 @@ bool L1AlgoEfficiencyPerformance<NHits>::AddOne(L1HitIndex_t* iHits) // obtain mc data for (int iih = 0; iih < NHits; iih++) { - int nMC = fL1->vHits[iHits[iih]].mcPointIds.size(); + int nMC = fL1->fvExternalHits[iHits[iih]].mcPointIds.size(); for (int iMC = 0; iMC < nMC; iMC++) { - const int iMCP = fL1->vHits[iHits[iih]].mcPointIds[iMC]; - int mcId = fL1->vMCPoints[iMCP].ID; + const int iMCP = fL1->fvExternalHits[iHits[iih]].mcPointIds[iMC]; + int mcId = fL1->fvMCPoints[iMCP].ID; mcIds[iih].push_back(mcId); } // for mcPoints } // for hits @@ -254,7 +254,7 @@ bool L1AlgoEfficiencyPerformance<NHits>::AddOne(L1HitIndex_t* iHits) for (unsigned int i = 0; i < mcsN.size(); i++) { if (mcsN[i] >= 0) { trlet.mcTrackId = mcsN[i]; - trlet.iStation = fL1->vMCPoints[fL1->vHits[iHits[0]].mcPointIds[0]].iStation; + trlet.iStation = fL1->fvMCPoints[fL1->fvExternalHits[iHits[0]].mcPointIds[0]].iStation; break; } } @@ -341,7 +341,7 @@ void L1AlgoEfficiencyPerformance<NHits>::CalculateEff() // const int NPointHits = mtra.hitIds[iSta2].size(); // for (int iH = 0; iH < NPointHits; iH++){ // cout << mtra.hitIds[iSta2][iH] << ""; - // cout << "(" << fL1->vHitStore[mtra.hitIds[iSta2][iH]].x << "\\" << fL1->vHitStore[mtra.hitIds[iSta2][iH]].y << "= " << fL1->vHitStore[mtra.hitIds[iSta2][iH]].x/fL1->vHitStore[mtra.hitIds[iSta2][iH]].y << " ) "; + // cout << "(" << fL1->fvHitStore[mtra.hitIds[iSta2][iH]].x << "\\" << fL1->fvHitStore[mtra.hitIds[iSta2][iH]].y << "= " << fL1->fvHitStore[mtra.hitIds[iSta2][iH]].x/fL1->fvHitStore[mtra.hitIds[iSta2][iH]].y << " ) "; // } // cout << endl; // } @@ -388,7 +388,7 @@ inline void L1AlgoEfficiencyPerformance<NHits>::Print(TString title, bool statio cout << endl; if (stations) { - for (int iSta = 0; iSta < fL1->NStation - NHits + 1; iSta++) { + for (int iSta = 0; iSta < fL1->fNStations - NHits + 1; iSta++) { TString title_sta = title; title_sta += " station "; title_sta += iSta; diff --git a/reco/L1/L1Algo/utils/L1AlgoPulls.cxx b/reco/L1/L1Algo/utils/L1AlgoPulls.cxx index fe647db43c..1d7704dd3c 100644 --- a/reco/L1/L1Algo/utils/L1AlgoPulls.cxx +++ b/reco/L1/L1Algo/utils/L1AlgoPulls.cxx @@ -125,9 +125,9 @@ void L1AlgoPulls::AddOne(L1TrackPar& T_, int i, L1HitIndex_t ih) err.qp = sqrt(T_.C44[i]); // mc data - int iMCP = fL1->vHitMCRef[ih]; + int iMCP = fL1->fvHitPointIndexes[ih]; if (iMCP < 0) return; - CbmL1MCPoint& mcP = fL1->vMCPoints[iMCP]; + CbmL1MCPoint& mcP = fL1->fvMCPoints[iMCP]; TL1TrackParameters mc(mcP); // fill residuals diff --git a/reco/L1/L1AlgoInputData.h b/reco/L1/L1AlgoInputData.h index 088e95f7c6..38f5ff51de 100644 --- a/reco/L1/L1AlgoInputData.h +++ b/reco/L1/L1AlgoInputData.h @@ -17,10 +17,6 @@ /// L1Hit objects), used for track reconstruction procedure. /// struct L1AlgoInputData { - /* - * Funcitons - */ - 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) @@ -36,14 +32,17 @@ struct L1AlgoInputData { /// 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; } @@ -99,17 +98,11 @@ struct L1AlgoInputData { /* * Data fields (public) */ - /// hits as a combination of front-, backstrips and z-position - L1Vector<L1Hit> vHits {"L1AlgoInputData::vHits"}; - + L1Vector<L1Hit> vHits {"L1AlgoInputData::vHits"}; ///< hits as a combination of front-, backstrips and z-position int fNstrips {0}; ///> Number of strips in the station - /// information of hits station & used hits in tracks; - L1Vector<unsigned char> fStripFlag {"L1AlgoInputData::fStripFlag"}; - - /// Start indeces for a given station - L1HitIndex_t HitsStartIndex[kMaxNStations + 1] {0}; - /// Stop indeces for a given station - L1HitIndex_t HitsStopIndex[kMaxNStations + 1] {0}; + 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; diff --git a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx index 8dc630b687..dae668ac23 100644 --- a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx +++ b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx @@ -81,9 +81,9 @@ Int_t CbmL1GlobalTrackFinder::CopyL1Tracks(CbmEvent* event) Int_t trdTrackIndex = fTrdTracks->GetEntriesFast(); Int_t tofTrackIndex = fTofTracks->GetEntriesFast(); - LOG(debug) << "Copy L1 tracks : " << L1->vRTracks.size() << " tracks in L1"; + LOG(debug) << "Copy L1 tracks : " << L1->fvRecoTracks.size() << " tracks in L1"; - for (vector<CbmL1Track>::iterator it = L1->vRTracks.begin(); it != L1->vRTracks.end(); ++it) { + for (vector<CbmL1Track>::iterator it = L1->fvRecoTracks.begin(); it != L1->fvRecoTracks.end(); ++it) { CbmL1Track& T = *it; //BEGIN add global track new ((*fGlobalTracks)[globalTrackIndex]) CbmGlobalTrack(); @@ -107,7 +107,7 @@ Int_t CbmL1GlobalTrackFinder::CopyL1Tracks(CbmEvent* event) bool hasTrdHits = false; bool hasTofHits = false; for (vector<int>::iterator ih = it->Hits.begin(); ih != it->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; if (h.Det == 1 && hasStsHits == false) { hasStsHits = true; @@ -164,7 +164,7 @@ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTrack(CbmL1Track l1track, CbmTrack* CbmL1* L1 = CbmL1::Instance(); for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; if (h.Det != systemIdT) continue; } ndf -= 5; @@ -190,7 +190,7 @@ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmStsTrack(CbmL1Track l1track, CbmStsT CbmL1* L1 = CbmL1::Instance(); for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; if (h.Det != systemIdT) continue; track->AddHit(h.ExtIndex, kSTSHIT); } @@ -222,7 +222,7 @@ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmMuchTrack(CbmL1Track l1track, CbmMuc CbmL1* L1 = CbmL1::Instance(); for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; if (h.Det != systemIdT) continue; track->AddHit(h.ExtIndex, kMUCHPIXELHIT); } @@ -250,7 +250,7 @@ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTrdTrack(CbmL1Track l1track, CbmTrdT CbmL1* L1 = CbmL1::Instance(); for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; if (h.Det != systemIdT) continue; track->AddHit(h.ExtIndex, kTRDHIT); } @@ -279,7 +279,7 @@ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTofTrack(CbmL1Track l1track, CbmTofT CbmL1* L1 = CbmL1::Instance(); for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; if (h.Det != systemIdT) continue; // track->AddHit(h.ExtIndex, kTOFHIT); } @@ -339,7 +339,7 @@ void CbmL1GlobalTrackFinder::SetDefaultParticlePDG(int pdg) /// set a default particle mass for the track fit /// it is used during reconstruction for the multiple scattering estimation CbmL1* l1 = CbmL1::Instance(); - if (!l1 || !l1->algo) { + if (!l1 || !l1->fpAlgo) { LOG(fatal) << "L1 instance doesn't exist or is not initialised"; return; } @@ -348,5 +348,5 @@ void CbmL1GlobalTrackFinder::SetDefaultParticlePDG(int pdg) LOG(fatal) << "Particle with pdg " << pdg << " doesn't exist"; return; } - l1->algo->SetDefaultParticleMass(p->Mass()); + l1->fpAlgo->SetDefaultParticleMass(p->Mass()); } diff --git a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx index 5f75c29183..4854d17432 100644 --- a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx +++ b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx @@ -68,8 +68,8 @@ Int_t CbmL1StsTrackFinder::CopyL1Tracks(CbmEvent* event) Int_t trackIndex = fTracks->GetEntriesFast(); Int_t nTracks = 0; - LOG(debug) << "Copy L1 tracks : " << L1->vRTracks.size() << " tracks in L1"; - for (vector<CbmL1Track>::iterator it = L1->vRTracks.begin(); it != L1->vRTracks.end(); ++it) { + LOG(debug) << "Copy L1 tracks : " << L1->fvRecoTracks.size() << " tracks in L1"; + for (vector<CbmL1Track>::iterator it = L1->fvRecoTracks.begin(); it != L1->fvRecoTracks.end(); ++it) { CbmL1Track& T = *it; new ((*fTracks)[trackIndex]) CbmStsTrack(); nTracks++; @@ -88,8 +88,8 @@ Int_t CbmL1StsTrackFinder::CopyL1Tracks(CbmEvent* event) t->SetTimeError(T.Cpv[20]); for (vector<int>::iterator ih = it->Hits.begin(); ih != it->Hits.end(); ++ih) { - CbmL1HitStore& h = L1->vHitStore[*ih]; - // double zref = L1->algo->vStations[h.iStation].z[0]; + CbmL1HitStore& h = L1->fvHitStore[*ih]; + // double zref = L1->fpAlgo->vStations[h.iStation].z[0]; if (h.Det > 1) { // not MVD or STS hit continue; } @@ -153,7 +153,7 @@ void SetDefaultParticlePDG(int pdg = 211) /// set a default particle mass for the track fit /// it is used during reconstruction for the multiple scattering estimation CbmL1* l1 = CbmL1::Instance(); - if (!l1 || !l1->algo) { + if (!l1 || !l1->fpAlgo) { LOG(fatal) << "L1 instance doesn't exist or is not initialised"; return; } @@ -162,6 +162,6 @@ void SetDefaultParticlePDG(int pdg = 211) LOG(fatal) << "Particle with pdg " << pdg << " doesn't exist"; return; } - l1->algo->SetDefaultParticleMass(p->Mass()); + l1->fpAlgo->SetDefaultParticleMass(p->Mass()); } // ------------------------------------------------------------------------- diff --git a/reco/L1/ParticleFinder/CbmL1PFFitter.cxx b/reco/L1/ParticleFinder/CbmL1PFFitter.cxx index 0c0d71e7cd..5038852749 100644 --- a/reco/L1/ParticleFinder/CbmL1PFFitter.cxx +++ b/reco/L1/ParticleFinder/CbmL1PFFitter.cxx @@ -92,11 +92,11 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, vector<int>& pidHypo) FairRootManager* fManger = FairRootManager::Instance(); TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject("StsHit"); - int NMvdStations = CbmL1::Instance()->algo->GetNstationsBeforePipe(); + int NMvdStations = CbmL1::Instance()->fpAlgo->GetNstationsBeforePipe(); TClonesArray* listMvdHits = 0; if (NMvdStations > 0.) listMvdHits = (TClonesArray*) fManger->GetObject("MvdHit"); - static int nHits = CbmL1::Instance()->algo->GetNstations(); + static int nHits = CbmL1::Instance()->fpAlgo->GetNstations(); int iVec = 0, i = 0; int nTracks_SIMD = fvecLen; L1TrackPar T; // fitting parametr coresponding to current track @@ -107,7 +107,7 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, vector<int>& pidHypo) CbmStsTrack* t[fvecLen]; int ista; - const L1Station* sta = CbmL1::Instance()->algo->GetParameters()->GetStations().begin(); + const L1Station* sta = CbmL1::Instance()->fpAlgo->GetParameters()->GetStations().begin(); L1Station staFirst, staLast; fvec* x = new fvec[nHits]; fvec* u = new fvec[nHits]; @@ -187,7 +187,7 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, vector<int>& pidHypo) posz = hit->GetZ(); // ista = hit->GetStationNr(); ista = - CbmL1::Instance()->algo->GetParameters()->GetStationIndexActive(hit->GetStationNr(), L1DetectorID::kMvd); + CbmL1::Instance()->fpAlgo->GetParameters()->GetStationIndexActive(hit->GetStationNr(), L1DetectorID::kMvd); if (ista == -1) continue; } else { @@ -200,7 +200,7 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, vector<int>& pidHypo) posz = hit->GetZ(); // ista = CbmStsSetup::Instance()->GetStationNumber(hit->GetAddress()) // + NMvdStations; //hit->GetStationNr() - 1 + NMvdStations; - ista = CbmL1::Instance()->algo->GetParameters()->GetStationIndexActive( + ista = CbmL1::Instance()->fpAlgo->GetParameters()->GetStationIndexActive( CbmStsSetup::Instance()->GetStationNumber(hit->GetAddress()), L1DetectorID::kSts); if (ista == -1) continue; } @@ -262,8 +262,8 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, vector<int>& pidHypo) fit.EnergyLossCorrection(T, fit.PipeRadThick, qp0, fvec(-1.f), wIn); } if constexpr (L1Constants::control::kIfUseRadLengthTable) { - fit.L1AddMaterial(T, CbmL1::Instance()->algo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, wIn); - fit.EnergyLossCorrection(T, CbmL1::Instance()->algo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, + fit.L1AddMaterial(T, CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, wIn); + fit.EnergyLossCorrection(T, CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, -1, wIn); } else { @@ -339,9 +339,9 @@ void CbmL1PFFitter::Fit(vector<CbmStsTrack>& Tracks, vector<int>& pidHypo) fit.EnergyLossCorrection(T, fit.PipeRadThick, qp0, fvec(1.f), wIn); } if constexpr (L1Constants::control::kIfUseRadLengthTable) { - fit.L1AddMaterial(T, CbmL1::Instance()->algo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, wIn); - fit.EnergyLossCorrection(T, CbmL1::Instance()->algo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, 1, - wIn); + fit.L1AddMaterial(T, CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, wIn); + fit.EnergyLossCorrection(T, CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, T.x, T.y), qp0, + 1, wIn); } else { fit.L1AddMaterial(T, sta[i].materialInfo, qp0, wIn); @@ -406,9 +406,9 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<L1FieldRe CbmStsTrack* t[fvecLen]; - int nStations = CbmL1::Instance()->algo->GetNstations(); - int NMvdStations = CbmL1::Instance()->algo->GetNstationsBeforePipe(); - const L1Station* sta = CbmL1::Instance()->algo->GetParameters()->GetStations().begin(); + int nStations = CbmL1::Instance()->fpAlgo->GetNstations(); + int NMvdStations = CbmL1::Instance()->fpAlgo->GetNstationsBeforePipe(); + const L1Station* sta = CbmL1::Instance()->fpAlgo->GetParameters()->GetStations().begin(); fvec* zSta = new fvec[nStations]; for (int iSta = 0; iSta < nStations; iSta++) zSta[iSta] = sta[iSta].z; @@ -490,8 +490,8 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<L1FieldRe } } - fB[0] = CbmL1::Instance()->algo->GetParameters()->GetVertexFieldValue(); - zField[0] = CbmL1::Instance()->algo->GetParameters()->GetTargetPositionZ(); + fB[0] = CbmL1::Instance()->fpAlgo->GetParameters()->GetVertexFieldValue(); + zField[0] = CbmL1::Instance()->fpAlgo->GetParameters()->GetTargetPositionZ(); fld.Set(fB[2], zField[2], fB[1], zField[1], fB[0], zField[0]); field.push_back(fld); @@ -505,8 +505,8 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<L1FieldRe fit.L1AddPipeMaterial(T, T.qp, w); fit.EnergyLossCorrection(T, fit.PipeRadThick, T.qp, fvec(1.f), w); } - fit.L1AddMaterial(T, CbmL1::Instance()->algo->GetParameters()->GetMaterialThickness(iSt, T.x, T.y), T.qp, w); - fit.EnergyLossCorrection(T, CbmL1::Instance()->algo->GetParameters()->GetMaterialThickness(iSt, T.x, T.y), T.qp, + fit.L1AddMaterial(T, CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(iSt, T.x, T.y), T.qp, w); + fit.EnergyLossCorrection(T, CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(iSt, T.x, T.y), T.qp, fvec(1.f), w); } if (NMvdStations <= 0) { @@ -574,7 +574,7 @@ void CbmL1PFFitter::CalculateFieldRegion(vector<CbmStsTrack>& Tracks, vector<L1F FairRootManager* fManger = FairRootManager::Instance(); TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject("StsHit"); TClonesArray* listMvdHits = 0; - int NMvdStations = CbmL1::Instance()->algo->GetNstationsBeforePipe(); + int NMvdStations = CbmL1::Instance()->fpAlgo->GetNstationsBeforePipe(); if (NMvdStations > 0.) listMvdHits = (TClonesArray*) fManger->GetObject("MvdHit"); int nTracks_SIMD = fvecLen; @@ -583,7 +583,7 @@ void CbmL1PFFitter::CalculateFieldRegion(vector<CbmStsTrack>& Tracks, vector<L1F CbmStsTrack* t[fvecLen]; int ista; - const L1Station* sta = CbmL1::Instance()->algo->GetParameters()->GetStations().begin(); + const L1Station* sta = CbmL1::Instance()->fpAlgo->GetParameters()->GetStations().begin(); L1FieldValue fB[3], fB_temp _fvecalignment; fvec zField[3]; @@ -630,8 +630,8 @@ void CbmL1PFFitter::CalculateFieldRegion(vector<CbmStsTrack>& Tracks, vector<L1F } } - fB[0] = CbmL1::Instance()->algo->GetParameters()->GetVertexFieldValue(); - zField[0] = CbmL1::Instance()->algo->GetParameters()->GetTargetPositionZ(); + fB[0] = CbmL1::Instance()->fpAlgo->GetParameters()->GetVertexFieldValue(); + zField[0] = CbmL1::Instance()->fpAlgo->GetParameters()->GetTargetPositionZ(); fld.Set(fB[2], zField[2], fB[1], zField[1], fB[0], zField[0]); field.push_back(fld); } @@ -646,7 +646,7 @@ void CbmL1PFFitter::CalculateFieldRegionAtLastPoint(vector<CbmStsTrack>& Tracks, FairRootManager* fManger = FairRootManager::Instance(); TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject("StsHit"); TClonesArray* listMvdHits = 0; - int NMvdStations = CbmL1::Instance()->algo->GetNstationsBeforePipe(); + int NMvdStations = CbmL1::Instance()->fpAlgo->GetNstationsBeforePipe(); if (NMvdStations > 0.) listMvdHits = (TClonesArray*) fManger->GetObject("MvdHit"); int nTracks_SIMD = fvecLen; @@ -655,7 +655,7 @@ void CbmL1PFFitter::CalculateFieldRegionAtLastPoint(vector<CbmStsTrack>& Tracks, CbmStsTrack* t[fvecLen]; int ista; - const L1Station* sta = CbmL1::Instance()->algo->GetParameters()->GetStations().begin(); + const L1Station* sta = CbmL1::Instance()->fpAlgo->GetParameters()->GetStations().begin(); L1FieldValue fB[3], fB_temp _fvecalignment; fvec zField[3]; -- GitLab