diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/InDetBeamSpotFinder/IInDetBeamSpotTool.h b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/InDetBeamSpotFinder/IInDetBeamSpotTool.h index 7c827f51c979a2ff49fefb1c9caf56ffa9311cea..a9915d43347a4feae0ed6e0aa674f56d4adb2f92 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/InDetBeamSpotFinder/IInDetBeamSpotTool.h +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/InDetBeamSpotFinder/IInDetBeamSpotTool.h @@ -12,9 +12,10 @@ //////////////////////////////////////////////////////////// #include "GaudiKernel/IAlgTool.h" -#include "CLHEP/Matrix/SymMatrix.h" -#include "xAODTracking/TrackingPrimitives.h" - +#include "xAODTracking/TrackingPrimitives.h" //for xAOD::VxType +#include <vector> +#include <map> +#include <string> static const InterfaceID IID_IInDetBeamSpotTool("IInDetBeamSpotTool", 1 , 0); namespace BeamSpot { @@ -43,10 +44,8 @@ namespace InDet { from this class. */ class IInDetBeamSpotTool : virtual public IAlgTool { public: - IInDetBeamSpotTool() {} //!< Default Constructor - IInDetBeamSpotTool( const IInDetBeamSpotTool& ){}//Copy constructor - - /** Internaly used enum for fit status. Useful for quick checks.*/ + virtual ~IInDetBeamSpotTool(){} + /** Internally used enum for fit status. Useful for quick checks.*/ enum FitStatus {unsolved=0, problems, failed, successful}; /** Beamspot determination type.*/ enum FitID {trackChi2=1, trackChi2Widths=2, vertexLL=3, vertexChi2=4, RooFitLL = 6, unknown = 99}; diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotID.h b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotID.h index 6d9041ee88f2072551fa9ef31e895e01db464bff..fc415082adaeda9167a3347ae84c1cca266b140d 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotID.h +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/BeamSpotID.h @@ -5,14 +5,11 @@ #ifndef INDET_BEAMSPOTID_H #define INDET_BEAMSPOTID_H -#include <iostream> -#include "InDetBeamSpotFinder/IInDetBeamSpotTool.h" -#include "GaudiKernel/ToolHandle.h" namespace BeamSpot { class ID { public: - ID():m_runNumber(0), m_lumiBlock(0), m_pileup(0), m_bcid(0) {} + ID():m_runNumber(0), m_lumiBlock(0), m_pileup(0), m_bcid(0), m_timeStamp(0) {} unsigned int runNumber() const {return m_runNumber; } unsigned int lumiBlock() const {return m_lumiBlock; } unsigned int pileup() const {return m_pileup; } diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.cxx b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.cxx index 47da56076488f9d40863a028c2c1684a7af25478..3af896ca381b038d7fe0e8ba11f836693dfde398 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.cxx +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.cxx @@ -3,6 +3,7 @@ */ #include "InDetBeamSpotFinder.h" +#include "TrigAnalysisInterfaces/IBunchCrossingTool.h" #include "InDetBeamSpotFinder/IInDetBeamSpotTool.h" #include "InDetBeamSpotVertex.h" #include "InDetBeamSpotRooFit.h" @@ -14,6 +15,20 @@ #include "EventInfo/EventInfo.h" #include "EventInfo/EventID.h" +#include <algorithm> + +namespace{ + //comparison of events for lumiBlock + auto lesserLumiBlock = [](const BeamSpot::Event & e1, const BeamSpot::Event & e2)->bool{ + return (e1.lumiBlock<e2.lumiBlock); + }; + + //comparison of events for run number + auto lesserRunNumber = [](const BeamSpot::Event & e1, const BeamSpot::Event & e2)->bool{ + return (e1.runNumber<e2.runNumber); + }; + +} InDet::InDetBeamSpotFinder::InDetBeamSpotFinder(const std::string& name, ISvcLocator* pSvcLocator): AthAlgorithm(name, pSvcLocator), @@ -44,7 +59,7 @@ InDet::InDetBeamSpotFinder::InDetBeamSpotFinder(const std::string& name, ISvcLoc StatusCode InDet::InDetBeamSpotFinder::initialize() { ATH_MSG_DEBUG( "in initialize()"); - if ( m_beamSpotToolList.size() == 0 ){ + if ( m_beamSpotToolList.empty() ){ ATH_MSG_FATAL("FATAL ERROR: must provide at least one beamspot tool in beamSpotToolList"); return StatusCode::FAILURE; } @@ -59,17 +74,17 @@ StatusCode InDet::InDetBeamSpotFinder::initialize() { } StatusCode InDet::InDetBeamSpotFinder::execute(){ - const xAOD::EventInfo* eventInfo = 0; - const xAOD::VertexContainer* vertexContainer = 0; + const xAOD::EventInfo* eventInfo = nullptr; + const xAOD::VertexContainer* vertexContainer = nullptr; ATH_CHECK(evtStore()->retrieve(eventInfo)); ATH_CHECK(evtStore()->retrieve(vertexContainer, m_vertexContainerName) ); if ( !passEventSelection( *eventInfo ) ) return StatusCode::SUCCESS; BeamSpot::Event currentEvent = readEvent(*eventInfo, *vertexContainer); m_eventList.push_back( currentEvent ); if( m_writeVertexNtuple ){ - for( unsigned int i = 0; i < currentEvent.vertices.size(); i++){ - if( currentEvent.vertices[i].passed || m_writeAllVertices ){ - writeToVertexTree( currentEvent, currentEvent.vertices[i] ); + for( auto & thisVertex: currentEvent.vertices){ + if( thisVertex.passed || m_writeAllVertices ){ + writeToVertexTree( currentEvent, thisVertex ); } } } @@ -105,18 +120,18 @@ BeamSpot::Event InDet::InDetBeamSpotFinder::readEvent(const xAOD::EventInfo & ev event.lumiBlock = BSeventInfo->event_ID()->lumi_block(); } - for(xAOD::VertexContainer::const_iterator vtxItr=vertexContainer.begin(); vtxItr!=vertexContainer.end(); ++vtxItr) { - if ((*vtxItr)->vertexType() == xAOD::VxType::NoVtx) continue; - vertex.x = (*vtxItr)->x(); - vertex.y = (*vtxItr)->y(); - vertex.z = (*vtxItr)->z(); - vertex.vxx = (*vtxItr)->covariancePosition()(0,0); - vertex.vxy = (*vtxItr)->covariancePosition()(0,1); - vertex.vyy = (*vtxItr)->covariancePosition()(1,1); - vertex.vzz = (*vtxItr)->covariancePosition()(2,2); - vertex.vertexType = (*vtxItr)->vertexType(); - vertex.nTracks = (*vtxItr)->nTrackParticles(); - vertex.passed = passVertexSelection( *vtxItr ); + for(const auto & vtx:vertexContainer) { + if (vtx->vertexType() == xAOD::VxType::NoVtx) continue; + vertex.x = vtx->x(); + vertex.y = vtx->y(); + vertex.z = vtx->z(); + vertex.vxx = vtx->covariancePosition()(0,0); + vertex.vxy = vtx->covariancePosition()(0,1); + vertex.vyy = vtx->covariancePosition()(1,1); + vertex.vzz = vtx->covariancePosition()(2,2); + vertex.vertexType = vtx->vertexType(); + vertex.nTracks = vtx->nTrackParticles(); + vertex.passed = passVertexSelection( vtx ); vertex.valid = vertex.passed; event.vertices.push_back( vertex ); } @@ -124,15 +139,15 @@ BeamSpot::Event InDet::InDetBeamSpotFinder::readEvent(const xAOD::EventInfo & ev } void InDet::InDetBeamSpotFinder::sortEvents(){ - for( unsigned int i = 0; i < m_eventList.size(); i++){ + for( const auto & thisEvent: m_eventList){ BeamSpot::ID id; - id.runNumber( (m_maxRunsPerFit > 0) ? m_eventList[i].runNumber : 0 ); - id.lumiBlock( (m_maxLBsPerFit > 0) ? m_eventList[i].lumiBlock : 0 ); - id.pileup ( iequals(m_fitSortingKey,"pileup") ? m_eventList[i].pileup : 0 ); - id.bcid ( iequals(m_fitSortingKey,"bcid" ) ? m_eventList[i].bcid : 0 ); + id.runNumber( (m_maxRunsPerFit > 0) ? thisEvent.runNumber : 0 ); + id.lumiBlock( (m_maxLBsPerFit > 0) ? thisEvent.lumiBlock : 0 ); + id.pileup ( iequals(m_fitSortingKey,"pileup") ? thisEvent.pileup : 0 ); + id.bcid ( iequals(m_fitSortingKey,"bcid" ) ? thisEvent.bcid : 0 ); //std::cout << "time " << iequals(m_fitSortingKey,"time" )<< " " << m_eventList[i].eventTime/m_secondsPerFit << std::endl; - id.timeStamp( iequals(m_fitSortingKey,"time" ) ? m_eventList[i].eventTime/m_secondsPerFit : 0 ); - m_eventMap[id].push_back( m_eventList[i] ); + id.timeStamp( iequals(m_fitSortingKey,"time" ) ? thisEvent.eventTime/m_secondsPerFit : 0 ); + m_eventMap[id].push_back( thisEvent ); } auto iter = m_eventMap.begin(); BeamSpot::ID lastID = iter->first; @@ -167,7 +182,7 @@ void InDet::InDetBeamSpotFinder::sortEvents(){ //Convert the vector of strings to vector of vertex types. void InDet::InDetBeamSpotFinder::convertVtxTypeNames(){ - if ( m_vertexTypeNames.size() ) { + if ( not m_vertexTypeNames.empty() ) { for ( std::vector<std::string>::const_iterator it = m_vertexTypeNames.begin(); it != m_vertexTypeNames.end(); ++it) { if ((*it) == "NoVtx") ; @@ -189,12 +204,7 @@ void InDet::InDetBeamSpotFinder::convertVtxTypeNames(){ bool InDet::InDetBeamSpotFinder::passEventSelection(const xAOD::EventInfo & eventInfo){ int bcid = eventInfo.bcid(); if (m_useFilledBCIDsOnly && !m_bcTool->isFilled(bcid)) { return false; } - if (m_BCIDsToAccept.size() > 0) { - if ( find(m_BCIDsToAccept.begin(), m_BCIDsToAccept.end(), bcid) == m_BCIDsToAccept.end()) { - return false; - } - } - return true; + return ( std::find(m_BCIDsToAccept.begin(), m_BCIDsToAccept.end(), bcid) != m_BCIDsToAccept.end()); } bool InDet::InDetBeamSpotFinder::passVertexSelection(const xAOD::Vertex * vtx ) { @@ -204,8 +214,8 @@ bool InDet::InDetBeamSpotFinder::passVertexSelection(const xAOD::Vertex * vtx ) if(static_cast<int>(vtx->nTrackParticles()) > m_maxTrackNum ){ return false; } if(TMath::Prob(vtx->chiSquared(), vtx->numberDoF()) < m_minVtxProb ) { return false; } if(vtx->covariancePosition()(0,0) <= 0 || vtx->covariancePosition()(1,1) <= 0 || vtx->covariancePosition()(2,2) <= 0 ) { return false; } - if(m_vertexTypes.end() == find( m_vertexTypes.begin(), m_vertexTypes.end(), vtx->vertexType() ) ) { return false; } - if(sqrt(vtx->covariancePosition()(0,0)) > m_maxTransverseError || sqrt(vtx->covariancePosition()(1,1)) > m_maxTransverseError) {return false;} + if(m_vertexTypes.end() == std::find( m_vertexTypes.begin(), m_vertexTypes.end(), vtx->vertexType() ) ) { return false; } + if(std::sqrt(vtx->covariancePosition()(0,0)) > m_maxTransverseError || std::sqrt(vtx->covariancePosition()(1,1)) > m_maxTransverseError) {return false;} return true; } @@ -221,18 +231,18 @@ StatusCode InDet::InDetBeamSpotFinder::performFits(){ IInDetBeamSpotTool::FitStatus bsFitStatus; std::vector<BeamSpot::VrtHolder> verticesToFit; - for( unsigned int i = 0; i < m_sortedEventList.size(); i++){ + for( auto & eventList: m_sortedEventList){ verticesToFit.clear(); - for( unsigned int j = 0; j < m_sortedEventList.at(i).size(); j++){ - for( unsigned int k = 0; k < m_sortedEventList.at(i).at(j).vertices.size(); k++){ - if( m_sortedEventList.at(i).at(j).vertices.at(k).passed ) { verticesToFit.push_back( m_sortedEventList.at(i).at(j).vertices.at(k) ); } + for( const auto & thisEvent: eventList){ + for( const auto & thisVertex: thisEvent.vertices){ + if( thisVertex.passed ) { verticesToFit.push_back( thisVertex ); } } } for( unsigned int j = 0; j < m_beamSpotToolList.size(); j++){ IInDetBeamSpotTool * bs(0); bs = cloneTool(j); if(!bs){ return StatusCode::FAILURE; } - if(verticesToFit.size() > 0) { bsFitStatus = bs->fit(verticesToFit); } + if(not verticesToFit.empty()) { bsFitStatus = bs->fit(verticesToFit); } else { bsFitStatus = IInDetBeamSpotTool::unsolved; } m_BeamStatusCode.clearWord(); @@ -251,8 +261,7 @@ StatusCode InDet::InDetBeamSpotFinder::performFits(){ if (bs->getParamMap()["sigmaX"] == 0 && bs->getParamMap()["sigmaY"] ==0 ) { m_BeamStatusCode.setFitWidth( false); } else { m_BeamStatusCode.setFitWidth(true); } - if(m_sortedEventList[i].size() > 0) - writeToBeamSpotTree( bs, m_sortedEventList[i], verticesToFit ); + if(not eventList.empty()) writeToBeamSpotTree( bs, eventList, verticesToFit ); } } return StatusCode::SUCCESS; @@ -298,7 +307,7 @@ StatusCode InDet::InDetBeamSpotFinder::setupBeamSpotTree(){ } //Loop over the covariance matrix for a given fit tool and create a branch for each element, if it doesn't already exist. for( std::map<std::string,double>::iterator iter = covMap.begin(); iter != covMap.end(); ++iter){ - std::string key = iter->first; + const std::string & key = iter->first; //double val = iter->second; if( !(m_root_bs->GetBranch(key.c_str())) ){ m_beamSpotNtuple.covMap[key] = 0; @@ -354,11 +363,11 @@ void InDet::InDetBeamSpotFinder::writeToBeamSpotTree(const IInDetBeamSpotTool *b m_beamSpotNtuple.nValid = vertexList.size(); unsigned int nVtxAll = 0; unsigned int nVtxPrim = 0; - for( unsigned int i = 0; i < eventList.size(); i++){ - nVtxAll += eventList.at(i).vertices.size(); - for( unsigned int j = 0; j < eventList.at(i).vertices.size(); j++){ - if( eventList.at(i).vertices.at(j).vertexType == xAOD::VxType::PriVtx ){ nVtxPrim++; } - } + auto isPrimaryVertex=[](const BeamSpot::VrtHolder & vertex){ return (vertex.vertexType == xAOD::VxType::PriVtx); }; + for( const auto & thisEvent : eventList){ + const auto & theseVertices=thisEvent.vertices; + nVtxAll += theseVertices.size(); + nVtxPrim+= std::count_if(theseVertices.begin(), theseVertices.end(), isPrimaryVertex); } m_beamSpotNtuple.nVtxAll = nVtxAll; m_beamSpotNtuple.nVtxPrim = nVtxPrim; @@ -368,16 +377,31 @@ void InDet::InDetBeamSpotFinder::writeToBeamSpotTree(const IInDetBeamSpotTool *b m_beamSpotNtuple.timeEnd = iequals(m_fitSortingKey,"time") ? eventList.back().eventTime : 0; m_beamSpotNtuple.timeStart = iequals(m_fitSortingKey,"time") ? eventList.front().eventTime : 0; m_beamSpotNtuple.runEnd = max_run( eventList ); + const auto & bsToolCovMap= bs->getCovMap(); + for (auto & param:m_beamSpotNtuple.paramMap){ + const std::string & key = param.first; + const auto & bsToolEquivalent = bsToolCovMap.find(key); + param.second = ( bsToolEquivalent == bsToolCovMap.end() ) ? 0 : bsToolEquivalent->second; + } + /** leave these here; illustrates coverity defect 29456 for( std::map<std::string,double>::iterator iter = m_beamSpotNtuple.paramMap.begin(); iter != m_beamSpotNtuple.paramMap.end(); ++iter){ std::string key = iter->first; iter->second = ( bs->getParamMap().find(key) == bs->getParamMap().end() ) ? 0 : bs->getParamMap()[key]; } + **/ + for (auto & covariance:m_beamSpotNtuple.covMap){ + const std::string & key = covariance.first; + const auto & bsToolEquivalent = bsToolCovMap.find(key); + covariance.second = ( bsToolEquivalent == bsToolCovMap.end() ) ? 0 : bsToolEquivalent->second; + } + /** leave these here; illustrates coverity defect 29456 for( std::map<std::string,double>::iterator iter = m_beamSpotNtuple.covMap.begin(); iter != m_beamSpotNtuple.covMap.end(); ++iter){ std::string key = iter->first; iter->second = ( bs->getCovMap().find(key) == bs->getCovMap().end() ) ? 0 : bs->getCovMap()[key]; } + **/ m_root_bs->Fill(); } @@ -388,44 +412,22 @@ InDet::IInDetBeamSpotTool* InDet::InDetBeamSpotFinder::cloneTool(int i) { } int InDet::InDetBeamSpotFinder::min_lb( std::vector<BeamSpot::Event> & eventList ){ - unsigned int smallest = eventList.at(0).lumiBlock; - for( unsigned int i = 0; i < eventList.size(); i++){ - if ( eventList.at(i).lumiBlock < smallest){ - smallest = eventList.at(i).lumiBlock; - } - } - return smallest; - + const auto smallestLbEvent=std::min_element(eventList.begin(),eventList.end(), lesserLumiBlock); + return smallestLbEvent->lumiBlock; } int InDet::InDetBeamSpotFinder::max_lb( std::vector<BeamSpot::Event> & eventList ){ - unsigned int largest = eventList.at(0).lumiBlock; - for( unsigned int i = 0; i < eventList.size(); i++){ - if ( eventList.at(i).lumiBlock > largest){ - largest = eventList.at(i).lumiBlock; - } - } - return largest; + const auto largestLbEvent=std::max_element(eventList.begin(),eventList.end(), lesserLumiBlock); + return largestLbEvent->lumiBlock; } int InDet::InDetBeamSpotFinder::min_run( std::vector<BeamSpot::Event> & eventList ){ - unsigned int smallest = eventList.at(0).runNumber; - for( unsigned int i = 0; i < eventList.size(); i++){ - if ( eventList.at(i).runNumber < smallest){ - smallest = eventList.at(i).runNumber; - } - } - return smallest; - + const auto smallestRunEvent=std::min_element(eventList.begin(),eventList.end(), lesserRunNumber); + return smallestRunEvent->runNumber; } int InDet::InDetBeamSpotFinder::max_run( std::vector<BeamSpot::Event> & eventList ){ - unsigned int largest = eventList.at(0).runNumber; - for( unsigned int i = 0; i < eventList.size(); i++){ - if ( eventList.at(i).runNumber > largest){ - largest = eventList.at(i).runNumber; - } - } - return largest; + const auto largestRunEvent=std::max_element(eventList.begin(),eventList.end(), lesserRunNumber); + return largestRunEvent->runNumber; } diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.h b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.h index 0af945fed78cbed472e70e895790bf601893742c..93d61939a3aa06120853db124f5fc5f118863983 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.h +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotFinder.h @@ -9,23 +9,32 @@ // Contact: btamadio@lbl.gov // Main Algorithm: Determine the Beamspot position ////////////////////////////// -#include <string> -#include <vector> -#include <map> + #include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" -#include "TrigAnalysisInterfaces/IBunchCrossingTool.h" -#include "InDetBeamSpotVertex.h" -#include "InDetBeamSpotRooFit.h" +#include "InDetBeamSpotFinder/IInDetBeamSpotTool.h" //for BeamSpot::Event +//#include "InDetBeamSpotVertex.h" +//#include "InDetBeamSpotRooFit.h" #include "InDetBeamSpotFinder/BeamSpotStatusCode.h" -#include "TTree.h" -#include "xAODEventInfo/EventInfo.h" -#include "xAODTracking/VertexContainer.h" -#include "xAODTracking/Vertex.h" +//#include "TTree.h" +#include "xAODEventInfo/EventInfo.h" //typedef, can't fwd declare +#include "xAODTracking/VertexContainer.h" //typedef, can't fwd declare +#include "xAODTracking/TrackingPrimitives.h" //for xAOD::VxType +//#include "xAODTracking/Vertex.h" #include "BeamSpotID.h" +#include <string> +#include <vector> +#include <map> class ITHistSvc; -class ToolSvc; +class IToolSvc; +class IInDetBeamSpotTool; +class TTree; +namespace Trig{ + class IBunchCrossingTool; +} + namespace InDet { class InDetBeamSpotFinder : public AthAlgorithm { @@ -57,19 +66,19 @@ namespace InDet { TTree * m_root_vrt=0; struct beamSpotNtuple_struct{ - int pileup, bcid, defectWord, fill, lbEnd, lbStart; - int nEvents, nValid, nVtxAll, nVtxPrim; - int run, separation, status, timeEnd, timeStart, runEnd; - std::map<std::string,double>paramMap; - std::map<std::string,double>covMap; + int pileup{}, bcid{}, defectWord{}, fill{}, lbEnd{}, lbStart{}; + int nEvents{}, nValid{}, nVtxAll{}, nVtxPrim{}; + int run{}, separation{}, status{}, timeEnd{}, timeStart{}, runEnd{}; + std::map<std::string,double>paramMap{}; + std::map<std::string,double>covMap{}; }; struct vertexNtuple_struct{ - double x,y,z,vxx,vxy,vyy,vzz; - xAOD::VxType::VertexType vType; - unsigned int run, lb, bcid, pileup, nTracks; - unsigned long long eventNumber, eventTime, eventTime_NS; - bool passed, valid; + double x{},y{},z{},vxx{},vxy{},vyy{},vzz{}; + xAOD::VxType::VertexType vType{}; + unsigned int run{}, lb{}, bcid{}, pileup{}, nTracks{}; + unsigned long long eventNumber{}, eventTime{}, eventTime_NS{}; + bool passed{}, valid{}; }; beamSpotNtuple_struct m_beamSpotNtuple; @@ -98,45 +107,45 @@ namespace InDet { void convertVtxTypeNames(); - bool m_sortByPileup; - bool m_sortByBCID; - int m_pileup; + bool m_sortByPileup{}; + bool m_sortByBCID{}; + int m_pileup{}; // Parameters for vertex selection criteria - int m_minTrackNum; //min Tracks in a vertex to be added - int m_maxTrackNum; //max Tracks in a vertex to be added - double m_maxChi2Vertex; //maxChi2 of vertex - double m_maxTransverseError; // max transverse vertex resolution - double m_minVtxProb; // probability cut on chi2/ndf - unsigned int m_minVertexNum; //min vertex count for solution + int m_minTrackNum{}; //min Tracks in a vertex to be added + int m_maxTrackNum{}; //max Tracks in a vertex to be added + double m_maxChi2Vertex{}; //maxChi2 of vertex + double m_maxTransverseError{}; // max transverse vertex resolution + double m_minVtxProb{}; // probability cut on chi2/ndf + unsigned int m_minVertexNum{}; //min vertex count for solution - std::string m_vertexContainerName; + std::string m_vertexContainerName{}; - std::vector<std::string> m_vertexTypeNames; //names of vertexTypes - std::vector<xAOD::VxType::VertexType> m_vertexTypes; + std::vector<std::string> m_vertexTypeNames{}; //names of vertexTypes + std::vector<xAOD::VxType::VertexType> m_vertexTypes{}; IInDetBeamSpotTool * cloneTool( int ); bool passVertexSelection(const xAOD::Vertex * ); //For forcing a specific run number - bool m_useForcedRun; - unsigned int m_forcedRunNumber, m_forcedRunRange; - int m_lbRangeOffset; + bool m_useForcedRun{}; + unsigned int m_forcedRunNumber{}, m_forcedRunRange{}; + int m_lbRangeOffset{}; - bool m_setLBwithViewedEvents; - bool m_setLBwithAcceptedEvents; + bool m_setLBwithViewedEvents{}; + bool m_setLBwithAcceptedEvents{}; // bool m_groupFitsByBCID; // each bcid is fitted separately - bool m_useFilledBCIDsOnly; // Only use filled BCIDs not empty ones (data) - std::string m_fitSortingKey; - bool m_groupFitsByPileup; + bool m_useFilledBCIDsOnly{}; // Only use filled BCIDs not empty ones (data) + std::string m_fitSortingKey{}; + bool m_groupFitsByPileup{}; - bool m_writeAllVertices; + bool m_writeAllVertices{}; //std::map<unsigned int,long> m_nEvents; //std::map<BeamSpot::ID, long> m_nEvents; - unsigned int m_pileupMin; - unsigned int m_pileupMax; + unsigned int m_pileupMin{}; + unsigned int m_pileupMax{}; - unsigned long m_secondsPerFit; + unsigned long m_secondsPerFit{}; }; }//end namespace diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotRooFit.h b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotRooFit.h index 3144188cf7675865c6568bcf2d2e67784427d75e..95a7e3d8a24559fc922c87d1ee756a5e012bbff8 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotRooFit.h +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotRooFit.h @@ -42,6 +42,9 @@ namespace InDet { //Copy Constructor InDetBeamSpotRooFit( const InDetBeamSpotRooFit& rhs ); + + //assignment + InDetBeamSpotRooFit & operator =(const InDetBeamSpotRooFit & other) =default; //These are the member functions to keep: virtual StatusCode initialize(); diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.cxx b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.cxx index 67c1f76b47cb230fc4d95895b72236398cd87350..e694fb0e07863f1548740569918620f38ce11ea3 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.cxx +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.cxx @@ -44,7 +44,7 @@ InDetBeamSpotVertex::InDetBeamSpotVertex( const std::string& type, m_zSolved(0.), m_zErrSolved(0.), m_NPARS(10), m_pLL(m_NPARS,0),m_VLL(m_NPARS,0), m_vertexCount(0),m_getLLres(false), - m_fitStatus(unsolved),m_nUsed(0) + m_fitStatus(unsolved),m_minVtxProb{},m_nUsed(0) { declareInterface<IInDetBeamSpotTool>(this); @@ -839,7 +839,7 @@ bool InDetBeamSpotVertex::applyOutlierRemoval() { + (it->y - (ybar + it->z*ay)) * b(2,2) * (it->y - (ybar + it->z*ay)) + 2*(it->x - (xbar + it->z*ax)) *b(2,1) * (it->y - (ybar + it->z*ay)); - if (ch > m_outlierChi2Tr ) fail += 128; + //if (ch > m_outlierChi2Tr ) fail += 128; fail is never used after this // if vertex fails selection based on [1,2,4] add a large artificial chi2 value to make sure is removed. ch += increaseChi2; diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.h b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.h index 19625b88916c8b3576aa7adbdc69a77eaa870505..f917fdcce60a0941f6ff75c7501bbb9d8840df42 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.h +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/InDetBeamSpotVertex.h @@ -15,11 +15,13 @@ #include "InDetBeamSpotFinder/IInDetBeamSpotTool.h" #include "TrkEventPrimitives/VertexType.h" #include "CLHEP/Matrix/Vector.h" +#include "CLHEP/Matrix/SymMatrix.h" #include "TMinuit.h" #include "TMath.h" #include "TTree.h" #include <string> #include <vector> +#include <map> namespace InDet { /** A concrete implementation of IInDetBeamSpotTool, using primary vertex information to @@ -38,6 +40,9 @@ namespace InDet { //Copy Constructor InDetBeamSpotVertex( const InDetBeamSpotVertex& rhs ); + + //assignment + InDetBeamSpotVertex & operator=(const InDetBeamSpotVertex & other) = default; virtual StatusCode initialize(); virtual StatusCode finalize(); diff --git a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/RefitTracksAndVertex.cxx b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/RefitTracksAndVertex.cxx index 088b0389fc9fff928b5f39f808113a76ed4384ff..e209cfa43bbc36dd80b072fca8ec3611072ef441 100644 --- a/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/RefitTracksAndVertex.cxx +++ b/InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/src/RefitTracksAndVertex.cxx @@ -131,7 +131,8 @@ StatusCode RefitTracksAndVertex::execute() { if ( !evtStore()->retrieve( vertices, m_vertexListInput ).isSuccess() ){ // retrieve arguments: container type, container key ATH_MSG_WARNING("execute() Failed to retrieve Reconstructed vertex container. " << m_vertexListInput ); //ATH_MSG_ERROR(evtStore()->dump()); - return StatusCode::SUCCESS; + delete outputtracks; + return StatusCode::SUCCESS; //?? really } if( evtStore()->record( outputtracks, m_trackListOutput ).isFailure() ) { @@ -146,7 +147,7 @@ StatusCode RefitTracksAndVertex::execute() { CHECK( evtStore()->record(theVertexAuxContainer, m_outputVertexContainerName + "Aux.") ); const xAOD::Vertex* primaryVertex = 0; - for( auto vertex: *vertices ) { + for( const auto & vertex: *vertices ) { if( vertex->vertexType() == xAOD::VxType::PriVtx ) { primaryVertex = vertex; break;