diff --git a/Pr/PrAlgorithms/src/IPrForwardTool.h b/Pr/PrAlgorithms/src/IPrForwardTool.h index 70b2a3cab8f20ba0d374259ec37ff17e99f8a4db..f1fcbaf7ca9e0868babbf1e3e6ea8dc7bfa76004 100644 --- a/Pr/PrAlgorithms/src/IPrForwardTool.h +++ b/Pr/PrAlgorithms/src/IPrForwardTool.h @@ -19,7 +19,7 @@ struct IPrForwardTool : public extend_interfaces<IAlgTool> { DeclareInterfaceID( IPrForwardTool, 2, 0); - virtual void extendTrack( const LHCb::Tracks& velo, std::vector<LHCb::Track>& result , const PrFTHitHandler<PrHit>& hitHandler) const = 0; + virtual void extendTrack( const std::vector<LHCb::Track>& velo, std::vector<LHCb::Track>& result , const PrFTHitHandler<PrHit>& hitHandler) const = 0; // -- Debugging stuff diff --git a/Pr/PrAlgorithms/src/PrForwardTool.cpp b/Pr/PrAlgorithms/src/PrForwardTool.cpp index d93e355173d934e7325044cd3445b37143a77840..a16f3fcdf82041a8ec3812b46f67b71308cbc205 100644 --- a/Pr/PrAlgorithms/src/PrForwardTool.cpp +++ b/Pr/PrAlgorithms/src/PrForwardTool.cpp @@ -174,15 +174,15 @@ StatusCode PrForwardTool::initialize ( ) { //========================================================================= // Main method: Process a track //========================================================================= -void PrForwardTool::extendTrack (const LHCb::Tracks& velo, std::vector<LHCb::Track>& result, const PrFTHitHandler<PrHit>& FTHitHandler) const { +void PrForwardTool::extendTrack (const std::vector<LHCb::Track>& velo, std::vector<LHCb::Track>& result, const PrFTHitHandler<PrHit>& FTHitHandler) const { std::vector<PrForwardTrack> tracks; tracks.reserve(velo.size()); //in the worst(!) case preslection <<< HERE! for(const auto& track: velo) { - if( not ( track->checkFlag( LHCb::Track::Invalid) ) && not (track->checkFlag( LHCb::Track::Backward) ) // accept track - && not ( m_preselection && track->pt() < m_preselectionPT ) // preselect the VeloUT tracks - && not ( std::fabs(track->closestState(StateParameters::ZEndVelo).qOverP()) > 0.001 ) //very low momentum tracks P < 1GeV of no interest + if( not ( track.checkFlag( LHCb::Track::Invalid) ) && not (track.checkFlag( LHCb::Track::Backward) ) // accept track + && not ( m_preselection && track.pt() < m_preselectionPT ) // preselect the VeloUT tracks + && not ( std::fabs(track.closestState(StateParameters::ZEndVelo).qOverP()) > 0.001 ) //very low momentum tracks P < 1GeV of no interest ) { tracks.emplace_back(track); } @@ -252,7 +252,7 @@ void PrForwardTool::extendTrack (const LHCb::Tracks& velo, std::vector<LHCb::Tra // -- > Debug -------- if ( msgLevel(MSG::DEBUG) ) { auto velot = std::next(velo.begin(), i); - info() << "********** final list of 1st loop candidates, Velo = " << (*velot)->key() << " ********" << endmsg; + info() << "********** final list of 1st loop candidates, Velo = " << (*velot).key() << " ********" << endmsg; for ( const auto& trackcand : trackCandidates ){ printTrack( trackcand ); } @@ -1427,7 +1427,8 @@ void PrForwardTool::makeLHCbTracks ( PrForwardTracks& trackCandidates, std::vect auto validEnd = std::remove_if(trackCandidates.begin(), trackCandidates.end(), [](const auto& track) { return not track.valid(); }); const range_of_const_<PrForwardTrack> validTracks{ trackCandidates.begin(), validEnd }; - + + std::vector<LHCb::LHCbID> ids; for (const auto& cand : validTracks ){ LHCb::Track tmp{*(cand.track())}; tmp.setType( LHCb::Track::Types::Long ); diff --git a/Pr/PrAlgorithms/src/PrForwardTracking.cpp b/Pr/PrAlgorithms/src/PrForwardTracking.cpp index b19875b65a73a169ae86bdd9a79cc6c0117324fe..d87b3e3cafc9f075f2d39ac57afdcf152db2f7bb 100644 --- a/Pr/PrAlgorithms/src/PrForwardTracking.cpp +++ b/Pr/PrAlgorithms/src/PrForwardTracking.cpp @@ -113,7 +113,7 @@ std::vector<LHCb::Track> PrForwardTracking::operator()(const PrFTHitHandler<PrHi // -- Loop over all Velo input tracks and try to find extension in the T-stations // -- This is the main 'work' of the forward tracking. - m_forwardTool->extendTrack(velo, result , prFTHitHandler); + m_forwardTool->extendTrack(veloUT, result , prFTHitHandler); //============================================================ //== Final processing: filtering of duplicates,... @@ -132,6 +132,8 @@ std::vector<LHCb::Track> PrForwardTracking::operator()(const PrFTHitHandler<PrHi auto notFT = [](const LHCb::LHCbID& id) { return !id.isFT(); }; + for ( auto itT1 = result.begin(); result.end() != itT1; ++itT1 ) { + LHCb::State* state1 = itT1->stateAt( LHCb::State::AtT ); for ( auto itT2 = itT1+1; result.end() != itT2; ++itT2 ) { LHCb::State* state2 = itT2->stateAt( LHCb::State::AtT ); @@ -141,8 +143,8 @@ std::vector<LHCb::Track> PrForwardTracking::operator()(const PrFTHitHandler<PrHi if ( std::fabs(dy) > 100. ) continue; // -- Find the beginning of the FT LHCbIDs - const auto& id1 = (*itT1)->lhcbIDs(); - const auto& id2 = (*itT2)->lhcbIDs(); + const auto& id1 = (*itT1).lhcbIDs(); + const auto& id2 = (*itT2).lhcbIDs(); // -- Velo track has at least three hits, so advance by three // checking whether we have the correct minimal number of velo hits diff --git a/Pr/PrPixel/src/PrPixelTracking.cpp b/Pr/PrPixel/src/PrPixelTracking.cpp index 28458bf80a3f24e87dc7cfd0d9982533a4680a8b..365066171d129be50a3fcd3bb65e7864a3caf6ae 100644 --- a/Pr/PrPixel/src/PrPixelTracking.cpp +++ b/Pr/PrPixel/src/PrPixelTracking.cpp @@ -62,26 +62,14 @@ std::tuple<std::vector<LHCb::Track>, LHCb::VPLightClusters> PrPixelTracking::ope throw GaudiException("Failure in getting hits!", "PrPixelTracking" , sc); } - - //info() << "printing hits of " << modulehits.size() << " modules" << endmsg; - //for (auto& m : modulehits){ - //info() << "printing next module with: " << m.size() << " hits" << endmsg; - //for (size_t hit = 0; hit < m.size(); ++hit) info() << m.getX(hit) << " " << m.getY(hit) << " " << m.getZ(hit) << " " << m.getID(hit) << endmsg; - //} - // Search for tracks by finding a pair of hits, then extrapolating. - std::vector<LHCb::Track> outputTracks; outputTracks.reserve(tracks.size()); + std::vector<LHCb::Track> outputTracks; searchByPair(modulehits, outputTracks); #ifdef DEBUG_HISTO - monitor(modulehits, outputTracks, clusters); + monitor(modulehits, outputTracks, clusters); #endif - //int i = 0; - //for ( auto tr : outputTracks ){ - //info() << "Track: " << ++i << endmsg; - //for ( auto& id : tr->lhcbIDs() ) info() << id.lhcbID() << endmsg; - //} - return std::make_tuple( std::move( outputTracks ), std::move( clusters ) ); + return std::make_tuple( std::move( outputTracks ), std::move( clusters ) ); } //============================================================================= @@ -146,7 +134,7 @@ void PrPixelTracking::extendTrack( std::vector<PrPixelModuleHits>& modulehits, s // Search starting with a pair of consecutive modules. //========================================================================= void PrPixelTracking::searchByPair( std::vector<PrPixelModuleHits>& modulehits, - LHCb::Tracks& outputTracks ) const + std::vector<LHCb::Track>& outputTracks ) const { // Get the range of modules to start search on, @@ -262,30 +250,12 @@ void PrPixelTracking::searchByPair( std::vector<PrPixelModuleHits>& modulehits, void PrPixelTracking::makeLHCbTracks( PrPixelTrack& track, const std::array<size_t, 71>& hitbuffer, std::vector<PrPixelModuleHits>& modulehits, std::vector<LHCb::Track>& outputTracks ) const { - - // Create a new LHCb track. - LHCb::Track newTrack{outputTracks.size()}; + LHCb::Track newTrack{outputTracks.size()}; newTrack.setType(LHCb::Track::Velo); newTrack.setHistory(LHCb::Track::PatFastVelo); newTrack.setPatRecStatus(LHCb::Track::PatRecIDs); - // Sort the hits back by decreasing z. - // FIXME there used to be a sort here but it seems to be redundant? - //auto& x = track.hitsX(); - //auto& y = track.hitsY(); - //auto& z = track.hitsZ(); - //auto& i = track.hitsID(); - //auto zipped = view::zip( x,y,z,i); - //auto comp = []( const std::tuple<float, float, float, LHCb::LHCbID>& h1, - //const std::tuple<float, float, float, LHCb::LHCbID>& h2 ) { - //return std::get<2>( h2 ) < std::get<2>( h1 ); - //}; - //sort(zipped, comp); - - //std::sort(track.hits().begZin(), track.hits().end(), - //[](SOA::PrPixelHit::pointer a, SOA::PrPixelHit::pointer b) - //{return b->z() < a->z();}); std::vector<LHCb::LHCbID> ids; ids.reserve(hitbuffer[0]/2); // Loop over the hits and add their LHCbIDs to the LHCb track. @@ -365,7 +335,6 @@ void PrPixelTracking::makeLHCbTracks( PrPixelTrack& track, const std::array<size newTrack.setChi2PerDoF(track.chi2()); // Add the LHCb track to the list. outputTracks.push_back(std::move(newTrack)); - } } //========================================================================= diff --git a/Pr/PrPixel/src/PrPixelTracking.h b/Pr/PrPixel/src/PrPixelTracking.h index 6b8c17c621df119f55b738937ab95c2efc86edbd..041aa4b51486dc0c861e25661a5241ed4f83ace5 100644 --- a/Pr/PrPixel/src/PrPixelTracking.h +++ b/Pr/PrPixel/src/PrPixelTracking.h @@ -47,7 +47,7 @@ void extendTrack( std::vector<PrPixelModuleHits>& modulehits, std::array<size_t, 71>& hitbuffer) const; /// Search for tracks starting from pair of hits on adjacent sensors - void searchByPair( std::vector<PrPixelModuleHits>& modulehits, LHCb::Tracks& outputTracks ) const; + void searchByPair( std::vector<PrPixelModuleHits>& modulehits, std::vector<LHCb::Track>& outputTracks ) const; /// Produce LHCb::Track list understandable to other LHCb applications. void makeLHCbTracks( PrPixelTrack& track, const std::array<size_t, 71>& hitbuffer, diff --git a/Pr/PrVeloUT/src/PrVeloUT.cpp b/Pr/PrVeloUT/src/PrVeloUT.cpp index 40f74c53cd5f41a9b2598803b3f2adbb9dce3f5f..b40c6c651aa21336f9c3badac0456390cf11fc3f 100755 --- a/Pr/PrVeloUT/src/PrVeloUT.cpp +++ b/Pr/PrVeloUT/src/PrVeloUT.cpp @@ -43,7 +43,7 @@ StatusCode PrVeloUT::initialize() { //============================================================================= // Main execution //============================================================================= -LHCb::Tracks PrVeloUT::operator()(const std::vector<LHCb::Track>& inputTracks) const { +std::vector<LHCb::Track> PrVeloUT::operator()(const std::vector<LHCb::Track>& inputTracks) const { if ( m_doTiming ) m_timerTool->start( m_veloUTTime ); std::vector<LHCb::Track> outputTracks; outputTracks.reserve(inputTracks.size()); diff --git a/Tr/TrackFitter/src/TrackEventFitter.cpp b/Tr/TrackFitter/src/TrackEventFitter.cpp index 17103a003893a26a7f2c872d5adef7ee1e7975e5..e4ad70dd9307be693646b3621fc537d8d7fdf1f9 100644 --- a/Tr/TrackFitter/src/TrackEventFitter.cpp +++ b/Tr/TrackFitter/src/TrackEventFitter.cpp @@ -55,29 +55,28 @@ StatusCode TrackEventFitter::initialize() { //============================================================================= LHCb::Tracks TrackEventFitter::operator()(const std::vector<LHCb::Track>& tracksCont) const { if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - + LHCb::Tracks tracks; // Loop over the tracks and fit them // --------------------------------- unsigned int nFitFail = 0; unsigned int nBadInput = 0; - for (auto& t : tracksCont) { std::vector<std::reference_wrapper<LHCb::Track>> trackReferences; std::vector<std::reference_wrapper<LHCb::Track>> fittingTracks; std::vector<double> qopBeforeVector; for (const auto& itrack : tracksCont) { - LHCb::Track& track = *((itrack)->cloneWithKey()); + LHCb::Track& track = *((itrack).cloneWithKey()); trackReferences.push_back(track); } - + std::for_each(trackReferences.begin(), trackReferences.end(), [&] (LHCb::Track& track) { if ( msgLevel( MSG::DEBUG ) ) { - debug() << "#### Fitting Track # " << track->key() << " ####" << endmsg - << " # of states before fit:" << track->nStates() << endmsg ; - if( track->nStates()>0 ) { + debug() << "#### Fitting Track # " << track.key() << " ####" << endmsg + << " # of states before fit:" << track.nStates() << endmsg ; + if( track.nStates()>0 ) { if( msgLevel( MSG::VERBOSE ) ) { verbose() << " States are: " << endmsg; const std::vector<LHCb::State*>& allstates = track.states(); @@ -90,12 +89,12 @@ LHCb::Tracks TrackEventFitter::operator()(const std::vector<LHCb::Track>& tracks } } else { if ( msgLevel( MSG::DEBUG ) ) - debug() << " First state vector = " << track->firstState().stateVector() - << " at z = " << track->firstState().z() << endmsg ; + debug() << " First state vector = " << track.firstState().stateVector() + << " at z = " << track.firstState().z() << endmsg ; } } } - + if( track.nStates()==0 || track.checkFlag( LHCb::Track::Flags::Invalid ) || (m_skipFailedFitAtInput.value() && track.fitStatus() == LHCb::Track::FitStatus::FitFailed)) { @@ -107,50 +106,48 @@ LHCb::Tracks TrackEventFitter::operator()(const std::vector<LHCb::Track>& tracks qopBeforeVector.push_back(track.firstState().qOverP()); } }); - + // Fit in batch RANGES_FOR(auto tracksChunk, ranges::v3::view::chunk(fittingTracks, m_batchSize.value())) { std::vector<std::reference_wrapper<LHCb::Track>> t = tracksChunk; m_tracksFitter->operator()(t).ignore(); } - + for (auto zipped : ranges::view::zip(fittingTracks, qopBeforeVector)) { LHCb::Track& track = zipped.first; double& qopBefore = zipped.second; if (track.fitStatus() == LHCb::Track::FitStatus::Fitted) { - std::string prefix = Gaudi::Utils::toString(track->type()) ; - if( msgLevel( MSG::INFO ) ) { - if ( msgLevel( MSG::DEBUG ) ) { - debug() << "Fitted successfully track # " << track->key() << endmsg; - } - // Update counters + std::string prefix = Gaudi::Utils::toString(track.type()) ; + if( msgLevel( MSG::INFO ) ) { + if ( msgLevel( MSG::DEBUG ) ) { + debug() << "Fitted successfully track # " << track.key() << endmsg; + } + // Update counters if( track.checkFlag( LHCb::Track::Flags::Backward ) ) prefix += "Backward" ; - prefix += '.' ; - if( track->nDoF()>0) { - double chisqprob = track->probChi2() ; - counter(prefix + "chisqprobSum") += chisqprob ; - counter(prefix + "badChisq") += bool(chisqprob<0.01) ; + prefix += '.' ; + if( track.nDoF()>0) { + double chisqprob = track.probChi2() ; + counter(prefix + "chisqprobSum") += chisqprob ; + counter(prefix + "badChisq") += bool(chisqprob<0.01) ; + } + counter(prefix + "flipCharge") += bool( qopBefore * track.firstState().qOverP() <0) ; + counter(prefix + "numOutliers") += track.nMeasurementsRemoved() ; } - counter(prefix + "flipCharge") += bool( qopBefore * track->firstState().qOverP() <0) ; - counter(prefix + "numOutliers") += track->nMeasurementsRemoved() ; - } - // Add the track to the new Tracks container if it passes the chi2-cut - // ----------------------------------------- + // Add the track to the new Tracks container if it passes the chi2-cut + // ----------------------------------------- if ( m_maxChi2DoF > track.chi2PerDoF() ) tracks.add( &track ); - else{ - delete track; - counter(prefix + "RejectedChisqCut") += 1 ; - } - } - else { + else{ + counter(prefix + "RejectedChisqCut") += 1 ; + } + } else { track.setFlag( LHCb::Track::Flags::Invalid, true ); - ++nFitFail; - if ( msgLevel( MSG::DEBUG ) ) - debug() << "Unable to fit the track # " << track->key() << endmsg; + ++nFitFail; + if ( msgLevel( MSG::DEBUG ) ) + debug() << "Unable to fit the track # " << track.key() << endmsg; + } } - } - + // Update counters // --------------- if( msgLevel( MSG::INFO ) ) {