diff --git a/reco/detectors/rich/CbmRichHitProducer.cxx b/reco/detectors/rich/CbmRichHitProducer.cxx index 228d9da9847af3a45144f06fb9c6b04c00c0dd1a..f9b3a2325c9826b4fdae83906dee026260141211 100644 --- a/reco/detectors/rich/CbmRichHitProducer.cxx +++ b/reco/detectors/rich/CbmRichHitProducer.cxx @@ -116,8 +116,8 @@ Int_t CbmRichHitProducer::ProcessData(CbmEvent* event) Int_t nofDigis = static_cast<Int_t>(event->GetNofData(ECbmDataType::kRichDigi)); LOG(debug) << GetName() << ": Event mode. Event # " << event->GetNumber() << ", digis: " << nofDigis; for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) { - Int_t digiIndex = static_cast<Int_t>(event->GetIndex(ECbmDataType::kRichDigi, iDigi)); - ProcessDigi(event, digiIndex); + Int_t iDigiIndex = static_cast<Int_t>(event->GetIndex(ECbmDataType::kRichDigi, iDigi)); + ProcessDigi(event, iDigiIndex); } nDigis = nofDigis; } diff --git a/reco/detectors/rich/CbmRichReconstruction.cxx b/reco/detectors/rich/CbmRichReconstruction.cxx index b5bac0e9ec2fb5e3762e3d29559d25c190082602..fd44f49d550f7ede39f92fd9836692f0ccfaaadc 100644 --- a/reco/detectors/rich/CbmRichReconstruction.cxx +++ b/reco/detectors/rich/CbmRichReconstruction.cxx @@ -317,9 +317,9 @@ void CbmRichReconstruction::RunFitter(CbmEvent* event) { const Int_t nofRings = event ? event->GetNofData(ECbmDataType::kRichRing) : fRichRings->GetEntriesFast(); if (nofRings <= 0) return; - for (Int_t iR0 = 0; iR0 < nofRings; iR0++) { - Int_t iR = event ? event->GetIndex(ECbmDataType::kRichRing, iR0) : iR0; - CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iR)); + for (Int_t iRing = 0; iRing < nofRings; iRing++) { + Int_t iRingIndex = event ? event->GetIndex(ECbmDataType::kRichRing, iRing) : iRing; + CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iRingIndex)); if (nullptr == ring) continue; CbmRichRingLight ringL; diff --git a/reco/detectors/rich/finder/CbmRichRingFinderHough.cxx b/reco/detectors/rich/finder/CbmRichRingFinderHough.cxx index 658ca6daab1f7154d9d93795f5bc2f10361580a3..8cdeb1c7b8258d2dd028889560ea5377975c7e4c 100644 --- a/reco/detectors/rich/finder/CbmRichRingFinderHough.cxx +++ b/reco/detectors/rich/finder/CbmRichRingFinderHough.cxx @@ -78,14 +78,14 @@ Int_t CbmRichRingFinderHough::DoFind(CbmEvent* event, TClonesArray* rHitArray, T // convert CbmRichHit to CbmRichHoughHit and // sort hits according to the photodetector (up or down) - for (Int_t iH0 = 0; iH0 < nofRichHits; iH0++) { - Int_t iH = event ? event->GetIndex(ECbmDataType::kRichHit, iH0) : iH0; - CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(iH)); + for (Int_t iHit = 0; iHit < nofRichHits; iHit++) { + Int_t iHitIndex = event ? event->GetIndex(ECbmDataType::kRichHit, iHit) : iHit; + CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(iHitIndex)); if (hit != nullptr && !hit->GetIsNoiseNN()) { CbmRichHoughHit tempPoint; tempPoint.fHit.fX = hit->GetX(); tempPoint.fHit.fY = hit->GetY(); - tempPoint.fHit.fId = iH; + tempPoint.fHit.fId = iHitIndex; tempPoint.fX2plusY2 = hit->GetX() * hit->GetX() + hit->GetY() * hit->GetY(); tempPoint.fTime = hit->GetTime(); tempPoint.fIsUsed = false; @@ -137,8 +137,8 @@ void CbmRichRingFinderHough::AddRingsToOutputArray(CbmEvent* event, TClonesArray double ringTime = 0.; Int_t ringCounter = 0; - for (Int_t iH = 0; iH < rings[iRing]->GetNofHits(); iH++) { - Int_t hitId = rings[iRing]->GetHitId(iH); + for (Int_t iHit = 0; iHit < rings[iRing]->GetNofHits(); iHit++) { + Int_t hitId = rings[iRing]->GetHitId(iHit); r->AddHit(hitId); CbmRichHit* hit = static_cast<CbmRichHit*>(rHitArray->At(hitId)); if (hit != nullptr) { diff --git a/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseCnn.cxx b/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseCnn.cxx index 96f46b2c1eda5f597785f171bdb4ac21fb36affc..abcb261df3c79f8d7d3fade075e70dab8573da9f 100644 --- a/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseCnn.cxx +++ b/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseCnn.cxx @@ -47,23 +47,23 @@ void CbmRichMCbmDenoiseCnn::Init() void CbmRichMCbmDenoiseCnn::Process(CbmEvent* event, const TClonesArray* richHits) { - int nHits = event ? static_cast<int>(event->GetNofData(ECbmDataType::kRichHit)) : richHits->GetEntriesFast(); + int nHits = event ? event->GetNofData(ECbmDataType::kRichHit) : richHits->GetEntriesFast(); std::vector<int> timeWindowHitIndices; - for (int i = 0; i < nHits; i++) { // Sliding time window loop + for (int iHit = 0; iHit < nHits; iHit++) { // Sliding time window loop timeWindowHitIndices.clear(); - int seedIdx = event ? static_cast<int>(event->GetIndex(ECbmDataType::kRichHit, static_cast<uint32_t>(i))) : i; - CbmRichHit* seedHit = static_cast<CbmRichHit*>(richHits->At(seedIdx)); + int seedIndex = event ? event->GetIndex(ECbmDataType::kRichHit, iHit) : iHit; + CbmRichHit* seedHit = static_cast<CbmRichHit*>(richHits->At(seedIndex)); if (!seedHit) continue; - timeWindowHitIndices.push_back(seedIdx); + timeWindowHitIndices.push_back(seedIndex); int hitsInTimeWindow = 1; - for (int j = i + 1; j < nHits; j++) { // Search for hits in time window - int hitIdx = event ? static_cast<int>(event->GetIndex(ECbmDataType::kRichHit, j)) : j; - CbmRichHit* hit = static_cast<CbmRichHit*>(richHits->At(hitIdx)); + for (int jHit = iHit + 1; jHit < nHits; jHit++) { // Search for hits in time window + int jHitIndex = event ? event->GetIndex(ECbmDataType::kRichHit, jHit) : jHit; + CbmRichHit* hit = static_cast<CbmRichHit*>(richHits->At(jHitIndex)); if (!hit) continue; double dt = hit->GetTime() - seedHit->GetTime(); if (dt < fTimeWindowLength) { hitsInTimeWindow++; - timeWindowHitIndices.push_back(hitIdx); + timeWindowHitIndices.push_back(jHitIndex); } else { break; @@ -72,7 +72,7 @@ void CbmRichMCbmDenoiseCnn::Process(CbmEvent* event, const TClonesArray* richHit if (hitsInTimeWindow >= fMinHitsInTimeWindow) { ProcessTimeWindow(timeWindowHitIndices, seedHit->GetTime(), richHits); - i += hitsInTimeWindow - 1; // Move to last hit inside time window + iHit += hitsInTimeWindow - 1; // Move to last hit inside time window } else { seedHit->SetIsNoiseNN(true); @@ -86,8 +86,8 @@ void CbmRichMCbmDenoiseCnn::ProcessTimeWindow(const std::vector<int>& timeWindow fInput = {}; // Reset all input values to 0.0 std::vector<int> gridIndices; gridIndices.reserve(50); - for (const auto& hitIdx : timeWindowHitIndices) { - CbmRichHit* hit = static_cast<CbmRichHit*>(richHits->At(hitIdx)); + for (const auto& hitIndex : timeWindowHitIndices) { + CbmRichHit* hit = static_cast<CbmRichHit*>(richHits->At(hitIndex)); const auto gridIdx = AddressToGridIndex(hit->GetAddress()); if (gridIdx < 0 || gridIdx >= static_cast<int>(fInput.size())) { LOG(error) << GetName() << "::ProcessTimeWindow: Invalid grid index: " << gridIdx; diff --git a/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseQa.cxx b/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseQa.cxx index fe83df3ec16be42145c81dd50687f093e5f699af..8593459aa27d898f295b6f9485a83416387ec78d 100644 --- a/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseQa.cxx +++ b/reco/detectors/rich/mcbm/CbmRichMCbmDenoiseQa.cxx @@ -101,21 +101,19 @@ void CbmRichMCbmDenoiseQa::Exec(Option_t* /*option*/) void CbmRichMCbmDenoiseQa::Process(CbmEvent* event) { // RICH Hits - Int_t nRichHits = event ? static_cast<Int_t>(event->GetNofData(ECbmDataType::kRichHit)) : fRichHits->GetEntriesFast(); - for (int i = 0; i < nRichHits; i++) { - Int_t hitIndex = event ? static_cast<Int_t>(event->GetIndex(ECbmDataType::kRichHit, static_cast<uint32_t>(i))) : i; - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(hitIndex)); + Int_t nRichHits = event ? event->GetNofData(ECbmDataType::kRichHit) : fRichHits->GetEntriesFast(); + for (int iHit = 0; iHit < nRichHits; iHit++) { + Int_t iHitIndex = event ? event->GetIndex(ECbmDataType::kRichHit, iHit) : iHit; + CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iHitIndex)); if (!hit) continue; fHM->H2("fhRichHitsXY")->Fill(hit->GetX(), hit->GetY()); } // RICH Rings - Int_t nRichRings = - event ? static_cast<Int_t>(event->GetNofData(ECbmDataType::kRichRing)) : fRichRings->GetEntriesFast(); - for (int i = 0; i < nRichRings; i++) { - Int_t ringIndex = - event ? static_cast<Int_t>(event->GetIndex(ECbmDataType::kRichRing, static_cast<uint32_t>(i))) : i; - CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(ringIndex)); + Int_t nRichRings = event ? event->GetNofData(ECbmDataType::kRichRing) : fRichRings->GetEntriesFast(); + for (int iRing = 0; iRing < nRichRings; iRing++) { + Int_t iRingIndex = event ? event->GetIndex(ECbmDataType::kRichRing, iRing) : iRing; + CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iRingIndex)); if (!ring) continue; fHM->H1("fhRingRadius")->Fill(ring->GetRadius()); fHM->H1(std::string("fhRingRadius") + std::string((ring->GetCenterY() > 0) ? "Up" : "Down")) @@ -126,8 +124,9 @@ void CbmRichMCbmDenoiseQa::Process(CbmEvent* event) fHM->H2("fhRingCenterXY")->Fill(ring->GetCenterX(), ring->GetCenterY()); // Ring hits Int_t nRingHits = ring->GetNofHits(); - for (int j = 0; j < nRingHits; j++) { - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(static_cast<Int_t>(ring->GetHit(j)))); + for (int jRingHit = 0; jRingHit < nRingHits; jRingHit++) { + Int_t jRingHitIndex = ring->GetHit(jRingHit); + CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(jRingHitIndex)); if (!hit) continue; fHM->H1("fhRingHitsTimeDiff")->Fill(hit->GetTime() - ring->GetTime()); fHM->H2("fhRingHitsXY")->Fill(hit->GetX(), hit->GetY()); @@ -149,9 +148,9 @@ void CbmRichMCbmDenoiseQa::DrawSED(CbmEvent* event) fHMSed->Add(hName, h); Int_t nHits = static_cast<Int_t>(event->GetNofData(ECbmDataType::kRichHit)); - for (int i = 0; i < nHits; i++) { - Int_t hitIndex = static_cast<Int_t>(event->GetIndex(ECbmDataType::kRichHit, static_cast<uint32_t>(i))); - CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(hitIndex)); + for (int iHit = 0; iHit < nHits; iHit++) { + Int_t iHitIndex = event->GetIndex(ECbmDataType::kRichHit, iHit); + CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iHitIndex)); if (!hit) continue; if (h->GetBinContent(h->FindBin(hit->GetX(), hit->GetY())) > 0) { LOG(info) << GetName() << "::DrawSED channel already filled for this event. Skipping."; @@ -167,9 +166,9 @@ void CbmRichMCbmDenoiseQa::DrawSED(CbmEvent* event) h->Draw("colz"); Int_t nRings = static_cast<Int_t>(event->GetNofData(ECbmDataType::kRichRing)); - for (int i = 0; i < nRings; i++) { - Int_t ringIndex = static_cast<Int_t>(event->GetIndex(ECbmDataType::kRichRing, static_cast<uint32_t>(i))); - CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(ringIndex)); + for (int iRing = 0; iRing < nRings; iRing++) { + Int_t iRingIndex = event->GetIndex(ECbmDataType::kRichRing, iRing); + CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iRingIndex)); if (!ring) continue; TEllipse* circle = new TEllipse(ring->GetCenterX(), ring->GetCenterY(), ring->GetAaxis(), ring->GetBaxis(), 0., 360., ring->GetPhi() * 180. / TMath::Pi()); diff --git a/reco/detectors/rich/mcbm/CbmRichMCbmHitProducer.cxx b/reco/detectors/rich/mcbm/CbmRichMCbmHitProducer.cxx index 5f3cd3ad47cb84757b62384dc11a30e4dc6926d0..aeac7955ae70b78666dd0ee8d90621e81713c6ec 100644 --- a/reco/detectors/rich/mcbm/CbmRichMCbmHitProducer.cxx +++ b/reco/detectors/rich/mcbm/CbmRichMCbmHitProducer.cxx @@ -170,15 +170,16 @@ void CbmRichMCbmHitProducer::ProcessData(CbmEvent* event) fNofHits = 0; for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) { - Int_t digiIndex = event->GetIndex(ECbmDataType::kRichDigi, iDigi); - ProcessDigi(event, digiIndex); + Int_t iDigiIndex = event->GetIndex(ECbmDataType::kRichDigi, iDigi); + ProcessDigi(event, iDigiIndex); } LOG(debug) << "nofDigis: " << nofDigis << "\t\t " << "nofHits : " << fNofHits; fNofHits = 0; } else { - for (Int_t iDigi = 0; iDigi < fDigiMan->GetNofDigis(ECbmModuleId::kRich); iDigi++) { + Int_t nofDigis = fDigiMan->GetNofDigis(ECbmModuleId::kRich); + for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) { ProcessDigi(event, iDigi); } } diff --git a/reco/detectors/rich/tracks/CbmRichProjectionProducerAnalytical.cxx b/reco/detectors/rich/tracks/CbmRichProjectionProducerAnalytical.cxx index 78da7b51880afb952f89e898f054c6b5f53f04bb..1e339e9ddc46ba413f09f0072c267faab33438a9 100644 --- a/reco/detectors/rich/tracks/CbmRichProjectionProducerAnalytical.cxx +++ b/reco/detectors/rich/tracks/CbmRichProjectionProducerAnalytical.cxx @@ -75,11 +75,11 @@ void CbmRichProjectionProducerAnalytical::DoProjection(CbmEvent* event, TClonesA covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) = 1.e-4; Int_t nofTrackParams = event ? event->GetNofData(ECbmDataType::kRichTrackParamZ) : fTrackParams->GetEntriesFast(); - for (Int_t iT0 = 0; iT0 < nofTrackParams; iT0++) { - Int_t iT = event ? event->GetIndex(ECbmDataType::kRichTrackParamZ, iT0) : iT0; - FairTrackParam* trPar = static_cast<FairTrackParam*>(fTrackParams->At(iT)); - new ((*richProj)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); - if (event != nullptr) event->AddData(ECbmDataType::kRichTrackProjection, iT); + for (Int_t iTrack = 0; iTrack < nofTrackParams; iTrack++) { + Int_t iTrackIndex = event ? event->GetIndex(ECbmDataType::kRichTrackParamZ, iTrack) : iTrack; + FairTrackParam* trPar = static_cast<FairTrackParam*>(fTrackParams->At(iTrackIndex)); + new ((*richProj)[iTrackIndex]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); + if (event != nullptr) event->AddData(ECbmDataType::kRichTrackProjection, iTrackIndex); // check if Array was filled if (trPar->GetX() == 0 && trPar->GetY() == 0 && trPar->GetZ() == 0 && trPar->GetTx() == 0 && trPar->GetTy() == 0) @@ -200,7 +200,7 @@ void CbmRichProjectionProducerAnalytical::DoProjection(CbmEvent* event, TClonesA if (isInsidePmt) { FairTrackParam richtrack(outPos.x(), outPos.y(), outPos.z(), 0., 0., 0., covMat); - *(FairTrackParam*) (richProj->At(iT)) = richtrack; + *(FairTrackParam*) (richProj->At(iTrackIndex)) = richtrack; fnSuccessfullProj++; } } diff --git a/reco/detectors/rich/tracks/CbmRichProjectionProducerTGeo.cxx b/reco/detectors/rich/tracks/CbmRichProjectionProducerTGeo.cxx index 29925f8129b775d65c499941f3c6034207479f0a..84ead27185d60cb7ff84bcf82a62a471bbcb1038 100644 --- a/reco/detectors/rich/tracks/CbmRichProjectionProducerTGeo.cxx +++ b/reco/detectors/rich/tracks/CbmRichProjectionProducerTGeo.cxx @@ -75,11 +75,11 @@ void CbmRichProjectionProducerTGeo::DoProjection(CbmEvent* event, TClonesArray* covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) = 1.e-4; Int_t nofTrackParams = event ? event->GetNofData(ECbmDataType::kRichTrackParamZ) : fTrackParams->GetEntriesFast(); - for (Int_t iT0 = 0; iT0 < nofTrackParams; iT0++) { - Int_t iT = event ? event->GetIndex(ECbmDataType::kRichTrackParamZ, iT0) : iT0; - FairTrackParam* trackParam = static_cast<FairTrackParam*>(fTrackParams->At(iT)); - new ((*richProj)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); - if (event != nullptr) event->AddData(ECbmDataType::kRichTrackProjection, iT); + for (Int_t iTrack = 0; iTrack < nofTrackParams; iTrack++) { + Int_t iTrackIndex = event ? event->GetIndex(ECbmDataType::kRichTrackParamZ, iTrack) : iTrack; + FairTrackParam* trackParam = static_cast<FairTrackParam*>(fTrackParams->At(iTrackIndex)); + new ((*richProj)[iTrackIndex]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); + if (event != nullptr) event->AddData(ECbmDataType::kRichTrackProjection, iTrackIndex); if (trackParam->GetX() == 0 && trackParam->GetY() == 0 && trackParam->GetZ() == 0 && trackParam->GetTx() == 0 && trackParam->GetTy() == 0) @@ -137,7 +137,7 @@ void CbmRichProjectionProducerTGeo::DoProjection(CbmEvent* event, TClonesArray* // if( xDet > (-fGP.fPmtXOrig-fGP.fPmtWidthX) && xDet < (fGP.fPmtXOrig+fGP.fPmtWidthX)){ // if(TMath::Abs(yDet) > (fGP.fPmtY-fGP.fPmtWidthY) && TMath::Abs(yDet) < (fGP.fPmtY+fGP.fPmtWidthY)){ FairTrackParam richtrack(xDet, yDet, zDet, 0., 0., 0., covMat); - *(FairTrackParam*) (richProj->At(iT)) = richtrack; + *(FairTrackParam*) (richProj->At(iTrackIndex)) = richtrack; fnSuccessfullProj++; // } // } diff --git a/reco/detectors/rich/tracks/CbmRichRingTrackAssignClosestD.cxx b/reco/detectors/rich/tracks/CbmRichRingTrackAssignClosestD.cxx index cb202f98af23f59cb978b9f678d90ea26f3de82c..5515b519ee2c3656d7015a8c16b010cd8eb2ae5e 100644 --- a/reco/detectors/rich/tracks/CbmRichRingTrackAssignClosestD.cxx +++ b/reco/detectors/rich/tracks/CbmRichRingTrackAssignClosestD.cxx @@ -86,11 +86,11 @@ void CbmRichRingTrackAssignClosestD::DoAssignRingTrack(CbmEvent* event, TClonesA } for (Int_t iIter = 0; iIter < 4; iIter++) { - for (Int_t iR0 = 0; iR0 < nofRings; iR0++) { - Int_t iR = event ? event->GetIndex(ECbmDataType::kRichRing, iR0) : iR0; + for (Int_t iRing = 0; iRing < nofRings; iRing++) { + Int_t iRingIndex = event ? event->GetIndex(ECbmDataType::kRichRing, iRing) : iRing; - if (trackIndex[iR0] != -1) continue; - CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iR)); + if (trackIndex[iRing] != -1) continue; + CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iRingIndex)); if (ring == nullptr) continue; if (ring->GetNofHits() < fMinNofHitsInRing) continue; @@ -99,29 +99,28 @@ void CbmRichRingTrackAssignClosestD::DoAssignRingTrack(CbmEvent* event, TClonesA Double_t rMin = 999.; Int_t iTrackMin = -1; - for (Int_t iT0 = 0; iT0 < nofTracks; iT0++) { - Int_t iT = event ? event->GetIndex(ECbmDataType::kRichTrackProjection, iT0) : iT0; + for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) { + Int_t iTrackIndex = event ? event->GetIndex(ECbmDataType::kRichTrackProjection, iTrack) : iTrack; - vector<Int_t>::iterator it = find(trackIndex.begin(), trackIndex.end(), iT); - if (it != trackIndex.end()) continue; + if (std::find(trackIndex.begin(), trackIndex.end(), iTrackIndex) != trackIndex.end()) continue; - FairTrackParam* track = static_cast<FairTrackParam*>(richProj->At(iT)); + FairTrackParam* track = static_cast<FairTrackParam*>(richProj->At(iTrackIndex)); Double_t xTrack = track->GetX(); Double_t yTrack = track->GetY(); // no projection onto the photodetector plane if (xTrack == 0 && yTrack == 0) continue; - if (fUseTrd && fTrdTracks != nullptr && !IsTrdElectron(iT)) continue; + if (fUseTrd && fTrdTracks != nullptr && !IsTrdElectron(iTrackIndex)) continue; Double_t dist = TMath::Sqrt((xRing - xTrack) * (xRing - xTrack) + (yRing - yTrack) * (yRing - yTrack)); if (dist < rMin) { rMin = dist; - iTrackMin = iT; + iTrackMin = iTrackIndex; } } // loop tracks - trackIndex[iR0] = iTrackMin; - trackDist[iR0] = rMin; + trackIndex[iRing] = iTrackMin; + trackDist[iRing] = rMin; } //loop rings for (UInt_t i1 = 0; i1 < trackIndex.size(); i1++) { @@ -147,8 +146,8 @@ void CbmRichRingTrackAssignClosestD::DoAssignRingTrack(CbmEvent* event, TClonesA // cout << "trackIndex[i]:" << trackIndex[i] << " trackDist[i]:" << trackDist[i] << " r:" << pRing->GetRadius() << " x:" << pRing->GetCenterX() << " y:" << pRing->GetCenterY()<< endl; if (trackIndex[i] == -1) continue; CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(trackIndex[i]); - Int_t ringIndex = event ? event->GetIndex(ECbmDataType::kRichRing, i) : i; - gTrack->SetRichRingIndex(ringIndex); + Int_t iRingIndex = event ? event->GetIndex(ECbmDataType::kRichRing, i) : i; + gTrack->SetRichRingIndex(iRingIndex); } } @@ -157,22 +156,22 @@ void CbmRichRingTrackAssignClosestD::DoAssignTrackRing(CbmEvent* event, TClonesA const Int_t nofTracks = event ? event->GetNofData(ECbmDataType::kRichTrackProjection) : richProj->GetEntriesFast(); const Int_t nofRings = event ? event->GetNofData(ECbmDataType::kRichRing) : rings->GetEntriesFast(); if (nofTracks <= 0 || nofRings <= 0) return; - for (Int_t iT0 = 0; iT0 < nofTracks; iT0++) { - Int_t iT = event ? event->GetIndex(ECbmDataType::kRichTrackProjection, iT0) : iT0; - CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(fGlobalTracks->At(iT)); + for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) { + Int_t iTrackIndex = event ? event->GetIndex(ECbmDataType::kRichTrackProjection, iTrack) : iTrack; + CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(fGlobalTracks->At(iTrackIndex)); // track already has rich segment if (gTrack == nullptr || gTrack->GetRichRingIndex() >= 0) continue; - FairTrackParam* track = static_cast<FairTrackParam*>(richProj->At(iT)); + FairTrackParam* track = static_cast<FairTrackParam*>(richProj->At(iTrackIndex)); Double_t xTrack = track->GetX(); Double_t yTrack = track->GetY(); if (xTrack == 0 && yTrack == 0) continue; - if (fUseTrd && fTrdTracks != nullptr && !IsTrdElectron(iT)) continue; + if (fUseTrd && fTrdTracks != nullptr && !IsTrdElectron(iTrackIndex)) continue; Double_t rMin = 999.; Int_t iRingMin = -1; - for (Int_t iR0 = 0; iR0 < nofRings; iR0++) { - Int_t iR = event ? event->GetIndex(ECbmDataType::kRichRing, iR0) : iR0; - CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iR)); + for (Int_t iRing = 0; iRing < nofRings; iRing++) { + Int_t iRingIndex = event ? event->GetIndex(ECbmDataType::kRichRing, iRing) : iRing; + CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iRingIndex)); if (ring == nullptr) continue; if (ring->GetNofHits() < fMinNofHitsInRing) continue; @@ -181,7 +180,7 @@ void CbmRichRingTrackAssignClosestD::DoAssignTrackRing(CbmEvent* event, TClonesA Double_t dist = TMath::Sqrt((xRing - xTrack) * (xRing - xTrack) + (yRing - yTrack) * (yRing - yTrack)); if (dist < rMin) { rMin = dist; - iRingMin = iR; + iRingMin = iRingIndex; } } // loop rings if (iRingMin < 0) continue; diff --git a/reco/detectors/rich/tracks/CbmRichRingTrackAssignIdeal.cxx b/reco/detectors/rich/tracks/CbmRichRingTrackAssignIdeal.cxx index 78047896c7a09970aa2ad8b93fbbabb28e4108e8..8140c46813d87168302498d3b334a316218afe06 100644 --- a/reco/detectors/rich/tracks/CbmRichRingTrackAssignIdeal.cxx +++ b/reco/detectors/rich/tracks/CbmRichRingTrackAssignIdeal.cxx @@ -44,7 +44,7 @@ void CbmRichRingTrackAssignIdeal::Init() void CbmRichRingTrackAssignIdeal::DoAssign(CbmEvent* event, TClonesArray* rings, TClonesArray* richProj) { - + // TODO: this function needs refactor/update if (event != nullptr) { LOG(fatal) << "CbmRichRingTrackAssignIdeal::DoAssign(): CbmEvent is not nullptr. " "This class does not support time-based mode. Please switch to event-by-event mode."; @@ -53,31 +53,31 @@ void CbmRichRingTrackAssignIdeal::DoAssign(CbmEvent* event, TClonesArray* rings, Int_t nofTracks = richProj->GetEntriesFast(); Int_t nofRings = rings->GetEntriesFast(); - for (Int_t iR = 0; iR < nofRings; iR++) { - CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iR)); + for (Int_t iRing = 0; iRing < nofRings; iRing++) { + CbmRichRing* ring = static_cast<CbmRichRing*>(rings->At(iRing)); if (ring == nullptr) continue; if (ring->GetNofHits() < fMinNofHitsInRing) continue; - CbmTrackMatchNew* ringMatch = static_cast<CbmTrackMatchNew*>(fRingMatches->At(iR)); - if (ringMatch == nullptr) continue; + CbmTrackMatchNew* ringMatch = static_cast<CbmTrackMatchNew*>(fRingMatches->At(iRing)); + if (ringMatch == nullptr) continue; // TODO: Link size check Int_t ringId = ringMatch->GetMatchedLink().GetIndex(); - for (Int_t iT = 0; iT < nofTracks; iT++) { - FairTrackParam* proj = static_cast<FairTrackParam*>(richProj->At(iT)); + for (Int_t iTrack = 0; iTrack < nofTracks; iTrack++) { + FairTrackParam* proj = static_cast<FairTrackParam*>(richProj->At(iTrack)); if (proj == nullptr) continue; // no projection to photodetector plane if (proj->GetX() == 0 && proj->GetY() == 0) continue; - CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(fGlobalTracks->At(iT)); + CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(fGlobalTracks->At(iTrack)); if (gTrack == nullptr) continue; if (gTrack->GetStsTrackIndex() == -1) continue; CbmTrackMatchNew* trackMatch = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(gTrack->GetStsTrackIndex())); - if (trackMatch == nullptr) continue; + if (trackMatch == nullptr) continue; // TODO: Link size check if (trackMatch->GetMatchedLink().GetIndex() == ringId) { - gTrack->SetRichRingIndex(iR); - } + gTrack->SetRichRingIndex(iRing); + } // TODO: replace with Link comparison } } } diff --git a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationIdeal.cxx b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationIdeal.cxx index f5121c625f1dca58ad4a89a85675f3a146e2eec0..8e88e35d1c39d9c4291856bdf78896891832d061 100644 --- a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationIdeal.cxx +++ b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationIdeal.cxx @@ -51,7 +51,7 @@ void CbmRichTrackExtrapolationIdeal::Init() void CbmRichTrackExtrapolationIdeal::DoExtrapolation(CbmEvent* event, TClonesArray* globalTracks, TClonesArray* extrapolatedTrackParams, double /*z*/) { - + // TODO: this function needs refactor/update if (event != nullptr) { LOG(fatal) << "CbmRichTrackExtrapolationIdeal::DoExtrapolation(): CbmEvent is not nullptr. " "This class does not support time-based mode. Please switch to event-by-event mode."; @@ -76,20 +76,20 @@ void CbmRichTrackExtrapolationIdeal::DoExtrapolation(CbmEvent* event, TClonesArr TVector3 pos, mom; Int_t nofGlobalTracks = globalTracks->GetEntriesFast(); - for (Int_t iT = 0; iT < nofGlobalTracks; iT++) { - CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iT)); - new ((*extrapolatedTrackParams)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); + for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) { + CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iTrack)); + new ((*extrapolatedTrackParams)[iTrack]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); Int_t stsInd = gTrack->GetStsTrackIndex(); if (stsInd < 0) continue; CbmStsTrack* stsTrack = static_cast<CbmStsTrack*>(fStsTracks->At(stsInd)); if (stsTrack == nullptr) continue; CbmTrackMatchNew* stsTrackMatch = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(stsInd)); - if (stsTrackMatch == nullptr) continue; + if (stsTrackMatch == nullptr) continue; // TODO: Link size check Int_t stsMcInd = stsTrackMatch->GetMatchedLink().GetIndex(); - for (Int_t iR = 0; iR < fRefPlanePoints->GetEntriesFast(); iR++) { - CbmRichPoint* refPlanePoint = static_cast<CbmRichPoint*>(fRefPlanePoints->At(iR)); + for (Int_t iRefPoint = 0; iRefPoint < fRefPlanePoints->GetEntriesFast(); iRefPoint++) { + CbmRichPoint* refPlanePoint = static_cast<CbmRichPoint*>(fRefPlanePoints->At(iRefPoint)); if (refPlanePoint->GetTrackID() == stsMcInd) { refPlanePoint->Momentum(mom); refPlanePoint->Position(pos); @@ -97,7 +97,7 @@ void CbmRichTrackExtrapolationIdeal::DoExtrapolation(CbmEvent* event, TClonesArr Double_t ty = mom.Py() / mom.Pz(); Double_t qp = charge / mom.Mag(); FairTrackParam richtrack(pos.X(), pos.Y(), pos.Z(), tx, ty, qp, covMat); - *(FairTrackParam*) (extrapolatedTrackParams->At(iT)) = richtrack; + *(FairTrackParam*) (extrapolatedTrackParams->At(iTrack)) = richtrack; } } } diff --git a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationKF.cxx b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationKF.cxx index 0d1199d8a18a83156886757887c9814e140d5c33..22a1ee99a9433d0d26ccdaf85275c822ffcc8a1f 100644 --- a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationKF.cxx +++ b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationKF.cxx @@ -61,11 +61,11 @@ void CbmRichTrackExtrapolationKF::DoExtrapolation(CbmEvent* event, TClonesArray* TVector3 pos, mom; Int_t nofGlobalTracks = event ? event->GetNofData(ECbmDataType::kGlobalTrack) : globalTracks->GetEntriesFast(); - for (Int_t iT0 = 0; iT0 < nofGlobalTracks; iT0++) { - Int_t iT = event ? event->GetIndex(ECbmDataType::kGlobalTrack, iT0) : iT0; - CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iT)); - new ((*extrapolatedTrackParams)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); - if (event != nullptr) event->AddData(ECbmDataType::kRichTrackParamZ, iT); + for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) { + Int_t iTrackIndex = event ? event->GetIndex(ECbmDataType::kGlobalTrack, iTrack) : iTrack; + CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iTrackIndex)); + new ((*extrapolatedTrackParams)[iTrackIndex]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); + if (event != nullptr) event->AddData(ECbmDataType::kRichTrackParamZ, iTrackIndex); Int_t stsInd = gTrack->GetStsTrackIndex(); if (stsInd < 0) continue; @@ -76,6 +76,6 @@ void CbmRichTrackExtrapolationKF::DoExtrapolation(CbmEvent* event, TClonesArray* KF.Extrapolate(stsTrack, z, &ExTrack); - *(FairTrackParam*) (extrapolatedTrackParams->At(iT)) = ExTrack; + *(FairTrackParam*) (extrapolatedTrackParams->At(iTrackIndex)) = ExTrack; } } diff --git a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationLittrack.cxx b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationLittrack.cxx index 64cd94468be73301dfbf24a69434d59889e8b0cd..0fec5ee62ea34d865258fa019a778888cb58f53f 100644 --- a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationLittrack.cxx +++ b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationLittrack.cxx @@ -63,11 +63,11 @@ void CbmRichTrackExtrapolationLittrack::DoExtrapolation(CbmEvent* event, TClones covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) = 1.e-4; Int_t nofGlobalTracks = event ? event->GetNofData(ECbmDataType::kGlobalTrack) : globalTracks->GetEntriesFast(); - for (Int_t iT0 = 0; iT0 < nofGlobalTracks; iT0++) { - Int_t iT = event ? event->GetIndex(ECbmDataType::kGlobalTrack, iT0) : iT0; - CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iT)); - new ((*extrapolatedTrackParams)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); - if (event != nullptr) event->AddData(ECbmDataType::kRichTrackParamZ, iT); + for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) { + Int_t iTrackIndex = event ? event->GetIndex(ECbmDataType::kGlobalTrack, iTrack) : iTrack; + CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iTrackIndex)); + new ((*extrapolatedTrackParams)[iTrackIndex]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); + if (event != nullptr) event->AddData(ECbmDataType::kRichTrackParamZ, iTrackIndex); Int_t stsInd = gTrack->GetStsTrackIndex(); if (stsInd < 0) continue; @@ -84,6 +84,6 @@ void CbmRichTrackExtrapolationLittrack::DoExtrapolation(CbmEvent* event, TClones FairTrackParam outParam(0., 0., 0., 0., 0., 0., covMat); CbmLitConverterFairTrackParam::CbmLitTrackParamToFairTrackParam(&litOutParam, &outParam); - *(FairTrackParam*) (extrapolatedTrackParams->At(iT)) = outParam; + *(FairTrackParam*) (extrapolatedTrackParams->At(iTrackIndex)) = outParam; } } diff --git a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationMirrorIdeal.cxx b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationMirrorIdeal.cxx index 48ad983a3a8554f6bacdc1d8fc7cb1efe59bda04..4de8fc5543e2dbe57fd39a788f6744fc0ed50415 100644 --- a/reco/detectors/rich/tracks/CbmRichTrackExtrapolationMirrorIdeal.cxx +++ b/reco/detectors/rich/tracks/CbmRichTrackExtrapolationMirrorIdeal.cxx @@ -56,7 +56,7 @@ void CbmRichTrackExtrapolationMirrorIdeal::Init() void CbmRichTrackExtrapolationMirrorIdeal::DoExtrapolation(CbmEvent* event, TClonesArray* globalTracks, TClonesArray* extrapolatedTrackParams, double /*z*/) { - + // TODO: this function needs refactor/update if (event != nullptr) { LOG(fatal) << "CbmRichTrackExtrapolationMirrorIdeal::DoExtrapolation(): CbmEvent is not nullptr. " "This class does not support time-based mode. Please switch to event-by-event mode."; @@ -81,19 +81,19 @@ void CbmRichTrackExtrapolationMirrorIdeal::DoExtrapolation(CbmEvent* event, TClo TVector3 pos, mom; Int_t nofGlobalTracks = globalTracks->GetEntriesFast(); - for (Int_t iT = 0; iT < nofGlobalTracks; iT++) { - CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iT)); - new ((*extrapolatedTrackParams)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); + for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) { + CbmGlobalTrack* gTrack = static_cast<CbmGlobalTrack*>(globalTracks->At(iTrack)); + new ((*extrapolatedTrackParams)[iTrack]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat); Int_t stsInd = gTrack->GetStsTrackIndex(); if (stsInd < 0) continue; CbmStsTrack* stsTrack = static_cast<CbmStsTrack*>(fStsTracks->At(stsInd)); if (stsTrack == nullptr) continue; CbmTrackMatchNew* stsTrackMatch = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(stsInd)); - if (stsTrackMatch == nullptr) continue; + if (stsTrackMatch == nullptr) continue; // TODO: Link size check Int_t stsMcInd = stsTrackMatch->GetMatchedLink().GetIndex(); - for (Int_t iM = 0; iM < fRichMirrorPoints->GetEntriesFast(); iM++) { - CbmRichPoint* pMirror = static_cast<CbmRichPoint*>(fRichMirrorPoints->At(iM)); + for (Int_t iMirPoints = 0; iMirPoints < fRichMirrorPoints->GetEntriesFast(); iMirPoints++) { + CbmRichPoint* pMirror = static_cast<CbmRichPoint*>(fRichMirrorPoints->At(iMirPoints)); if (pMirror->GetTrackID() == stsMcInd) { pMirror->Momentum(mom); pMirror->Position(pos); @@ -101,7 +101,7 @@ void CbmRichTrackExtrapolationMirrorIdeal::DoExtrapolation(CbmEvent* event, TClo Double_t ty = mom.Py() / mom.Pz(); Double_t qp = charge / mom.Mag(); FairTrackParam richtrack(pos.X(), pos.Y(), pos.Z(), tx, ty, qp, covMat); - *(FairTrackParam*) (extrapolatedTrackParams->At(iT)) = richtrack; + *(FairTrackParam*) (extrapolatedTrackParams->At(iTrack)) = richtrack; } } } diff --git a/sim/detectors/rich/CbmRich.cxx b/sim/detectors/rich/CbmRich.cxx index b1c785cdc4941546cb433b7d70f547b5b9add841..58512836395510944c8df99787404c0a5d8e195b 100644 --- a/sim/detectors/rich/CbmRich.cxx +++ b/sim/detectors/rich/CbmRich.cxx @@ -234,12 +234,12 @@ TClonesArray* CbmRich::GetCollection(Int_t iColl) const void CbmRich::Print(Option_t*) const { - Int_t nHits = fRichPoints->GetEntriesFast(); - LOG(info) << fName << ": " << nHits << " points registered in this event."; + Int_t nRichPoints = fRichPoints->GetEntriesFast(); + LOG(info) << fName << ": " << nRichPoints << " points registered in this event."; if (fVerboseLevel > 1) - for (Int_t i = 0; i < nHits; i++) - (*fRichPoints)[i]->Print(); + for (Int_t iPoint = 0; iPoint < nRichPoints; iPoint++) + (*fRichPoints)[iPoint]->Print(); } void CbmRich::Reset() diff --git a/sim/detectors/rich/CbmRichDigitizer.cxx b/sim/detectors/rich/CbmRichDigitizer.cxx index d915fa55bac27a453b48b8d95ac31840825eef8d..10ecccab02e7f7e5dcdce00d937c275490886cc3 100644 --- a/sim/detectors/rich/CbmRichDigitizer.cxx +++ b/sim/detectors/rich/CbmRichDigitizer.cxx @@ -146,9 +146,9 @@ Int_t CbmRichDigitizer::ProcessMcEvent() LOG(debug) << fName << ": EventNum:" << fCurrentEvent << " InputNum:" << fCurrentInput << " EventTime:" << fCurrentEventTime << " nofRichPoints:" << nofRichPoints; - for (Int_t j = 0; j < nofRichPoints; j++) { - CbmRichPoint* point = static_cast<CbmRichPoint*>(fRichPoints->At(j)); - ProcessPoint(point, j, fCurrentMCEntry, fCurrentInput); + for (Int_t iPoint = 0; iPoint < nofRichPoints; iPoint++) { + CbmRichPoint* point = static_cast<CbmRichPoint*>(fRichPoints->At(iPoint)); + ProcessPoint(point, iPoint, fCurrentMCEntry, fCurrentInput); } AddEventNoise(fCurrentMCEntry, fCurrentInput); @@ -258,7 +258,7 @@ void CbmRichDigitizer::AddEventNoise(Int_t eventNum, Int_t inputNum) LOG(debug) << "CbmRichDigitizer::AddEventNoise NofAllPixels:" << nofPixels << " nofNoiseDigis:" << nofNoiseDigis; - for (Int_t j = 0; j < nofNoiseDigis; j++) { + for (Int_t i = 0; i < nofNoiseDigis; i++) { Int_t address = CbmRichDigiMapManager::GetInstance().GetRandomPixelAddress(); CbmLink link(1., -1, eventNum, inputNum); Double_t time = fCurrentEventTime + gRandom->Uniform(0, fEventNoiseInterval); @@ -275,7 +275,7 @@ void CbmRichDigitizer::AddDarkRateNoise(Double_t oldEventTime, Double_t newEvent LOG(debug) << "CbmRichDigitizer::AddDarkRateNoise deltaTime:" << dT << " nofPixels:" << nofPixels << " nofNoisePixels:" << nofNoisePixels; - for (Int_t j = 0; j < nofNoisePixels; j++) { + for (Int_t i = 0; i < nofNoisePixels; i++) { Int_t address = CbmRichDigiMapManager::GetInstance().GetRandomPixelAddress(); CbmLink link(1., -1, -1, -1); Double_t time = gRandom->Uniform(oldEventTime, newEventTime);