diff --git a/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.cpp b/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.cpp index dca085ab96fc4108e8c6db035baad0916cde06a1..cb878b3644386e5c89d0919da23921f5a768aa25 100755 --- a/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.cpp +++ b/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.cpp @@ -18,33 +18,19 @@ #include "Event/RecVertex.h" #include "TrackKernel/TrackStateVertex.h" #include "TrackInterfaces/ITrackVertexer.h" -//#include <boost/lambda/bind.hpp> -//#include <boost/lambda/lambda.hpp> #include <boost/foreach.hpp> -//from TrackInterfaces #include "TrackInterfaces/IVeloExpectation.h" #include "TrackInterfaces/IMeasurementProvider.h" #include "TrackInterfaces/ITrackSelector.h" -// Det - -// gsl -//#include "gsl/gsl_math.h" - #include "GaudiKernel/PhysicalConstants.h" #include "GaudiKernel/ToStream.h" - -// Boost -#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L #include <functional> using std::bind; using namespace std::placeholders; -#else -#include <boost/lambda/bind.hpp> -using namespace boost::lambda; -#endif + #include <boost/lambda/lambda.hpp> #include "VeloTrackMonitorNT.h" @@ -76,17 +62,7 @@ DECLARE_NAMESPACE_ALGORITHM_FACTORY(Velo, VeloTrackMonitorNT) //============================================================================= Velo::VeloTrackMonitorNT::VeloTrackMonitorNT(const std::string& name, ISvcLocator* pSvcLocator ) : - GaudiTupleAlg( name , pSvcLocator ), - m_allString("ALL"), - m_clusterLoc ( VeloClusterLocation::Default ), - m_asctLocation ( m_clusterLoc+"2MCHits" ), - m_rawClusters(0), - m_veloDet(0), - m_expectTool(0), - m_clusterTool(0), - m_asctTable ( 0 ), - m_vertexer(NULL), - m_tracksFitter(0) + GaudiTupleAlg( name , pSvcLocator ) { declareProperty( "TracksInContainer", m_tracksInContainer = LHCb::TrackLocation::Default ); declareProperty( "PVContainer", m_pvContainerName = LHCb::RecVertexLocation::Primary ) ; @@ -105,11 +81,6 @@ Velo::VeloTrackMonitorNT::VeloTrackMonitorNT(const std::string& name, } -//============================================================================= -// Destructor -//============================================================================= -Velo::VeloTrackMonitorNT::~VeloTrackMonitorNT() {} - //============================================================================= // Initialization. Check parameters //============================================================================= @@ -132,12 +103,6 @@ StatusCode Velo::VeloTrackMonitorNT::initialize() return StatusCode::SUCCESS; } - //============================================================================= -StatusCode Velo::VeloTrackMonitorNT::finalize() -{ - return GaudiTupleAlg::finalize(); -} - namespace { @@ -196,10 +161,8 @@ namespace { //============================================================================= StatusCode Velo::VeloTrackMonitorNT::execute() { - - LHCb::ODIN* odin = getIfExists<LHCb::ODIN> ( LHCb::ODINLocation::Default ); - if ( NULL != odin ){ + if ( nullptr != odin ){ if( msgLevel(MSG::DEBUG) ) debug()<< "Run " << odin->runNumber() << ", Event " << odin->eventNumber() << endmsg; @@ -226,8 +189,8 @@ StatusCode Velo::VeloTrackMonitorNT::execute() int pvntr=0; // get the input data LHCb::Tracks* tracks = getIfExists<LHCb::Tracks>(m_tracksInContainer); - if ( NULL == tracks ) { - debug() << "No VeloTracks container found for this event !" << endmsg; + if ( nullptr == tracks ) { + if( msgLevel(MSG::DEBUG) ) debug() << "No VeloTracks container found for this event !" << endmsg; return StatusCode::SUCCESS; } @@ -245,7 +208,7 @@ StatusCode Velo::VeloTrackMonitorNT::execute() // histograms per track m_rawClusters = getIfExists<LHCb::VeloClusters>(m_clusterCont); - if( NULL == m_rawClusters ){ + if( nullptr == m_rawClusters ){ return Error( " ==> There is no VeloClusters in TES " ); } else{ @@ -256,8 +219,8 @@ StatusCode Velo::VeloTrackMonitorNT::execute() const LHCb::RecVertices* pvcontainer = getIfExists<LHCb::RecVertices>( m_pvContainerName ) ; - if ( NULL == pvcontainer ) { - debug() << "No Vertex container found for this event !" << endmsg; + if ( nullptr == pvcontainer ) { + if( msgLevel(MSG::DEBUG) ) debug() << "No Vertex container found for this event !" << endmsg; //return StatusCode::SUCCESS; } else{ @@ -285,25 +248,22 @@ StatusCode Velo::VeloTrackMonitorNT::execute() if(m_runWithMC){ - debug()<< "Run with MC truth " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "Run with MC truth " << endmsg; // create the ass table if run over MC data - AsctTool associator(evtSvc(), m_asctLocation); - debug()<< "associator " << endmsg; + AsctTool associator(evtSvc(), m_clusterLoc+"2MCHits"); + if( msgLevel(MSG::DEBUG) ) debug()<< "associator " << endmsg; m_asctTable=associator.direct(); - debug()<< "associator,direct" << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "associator,direct" << endmsg; if(!m_asctTable){ return ( Error("Empty table with associations", StatusCode::FAILURE) ); } - debug()<< "asct table exist " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "asct table exist " << endmsg; } for (LHCb::Tracks::const_iterator iterT = tracks->begin(); iterT != tracks->end(); ++iterT){ - StatusCode cluNTStatus; - if(m_clntuple) cluNTStatus=FillVeloClNtuple(**iterT,n_pv, n_back, pvx,pvy,pvz,pvchi2,pvndof,pvntr); - if(cluNTStatus.isSuccess()){ - cluNTStatus.ignore(); - }else{ - return ( cluNTStatus ); + if(m_clntuple) { + StatusCode cluNTStatus = FillVeloClNtuple(**iterT,n_pv, n_back, pvx,pvy,pvz,pvchi2,pvndof,pvntr); + if( cluNTStatus.isFailure() ) return ( cluNTStatus ); } if (m_trntuple) FillVeloTrNtuple(**iterT,n_pv, n_back, pvx,pvy,pvz,pvchi2,pvndof,pvntr); @@ -324,24 +284,23 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, Tuple tuple=nTuple("VeloClNtuple", "Clusters on track",CLID_ColumnWiseTuple ); long long int tzero= 1270064494071424ll; //there is an ll at the end, so that C++ knows this has to be a long long float eventTimeMicroSecGps = (float) (((m_evTimeGps - tzero)/1000000.)); - debug()<< "Cluster information ntuple " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "Cluster information ntuple " << endmsg; if(m_runWithMC){ - debug()<< "Run with MC truth " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "Run with MC truth " << endmsg; // create the ass table if run over MC data - AsctTool associator(evtSvc(), m_asctLocation); + AsctTool associator(evtSvc(), m_clusterLoc+"2MCHits"); m_asctTable=associator.direct(); eventTimeMicroSecGps=0; if(!m_asctTable){ return ( Error("Empty table with associations", StatusCode::FAILURE) ); } - debug()<< "asct table exist " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "asct table exists" << endmsg; } - if( msgLevel(MSG::DEBUG) ) - debug()<< "Cluster information ntuple " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "Cluster information ntuple " << endmsg; const LHCb::State& firststate = track.firstState() ; const LHCb::State& laststate = track.closestState(760) ; @@ -354,13 +313,11 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, double z0=firststate.position().z()+20; double z1=laststate.position().z()-20; - if( msgLevel(MSG::DEBUG) ) + if( msgLevel(MSG::DEBUG) ) { debug() << " z0="<<z0<<" z1="<<z1 <<endmsg; - - if( msgLevel(MSG::DEBUG) ) debug() << "Track node size="<< track.nodes().size()<<endmsg; - if( msgLevel(MSG::DEBUG) ) debug() << "Track lhcbids size="<< track.lhcbIDs().size()<<endmsg; + } if( nVeloHits>0 ) { std::string names[] = { "VeloR","VeloPhi" } ; @@ -404,11 +361,11 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, for( LHCb::Track::ConstNodeRange::const_iterator inode = nodes.begin() ; inode != nodes.end(); ++inode) { - if( msgLevel(MSG::DEBUG) ) + if( msgLevel(MSG::DEBUG) ) { debug() << " node type="<< (*inode)->type() <<endmsg; - if( msgLevel(MSG::DEBUG) ) debug() << " errResidual2=" << (*inode)->errResidual2() << " tolerance="<<TrackParameters::lowTolerance<<endmsg; + } if( (*inode)->type() == LHCb::Node::HitOnTrack // discard extremely small fraction of hits with zero error @@ -469,7 +426,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, StatusCode sc = m_tracksFitter -> fit( *tr_clone ); if ( !sc.isSuccess() ) { - debug() << "Track fit failed. Continuing with next track." << endmsg; + if( msgLevel(MSG::DEBUG) ) debug() << "Track fit failed. Continuing with next track." << endmsg; continue; } @@ -549,9 +506,8 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, pntphi_mc=localMidPoint.Phi(); pntr_mc=localMidPoint.Rho(); double offset=0.; - StatusCode channelStat; VeloChannelID entryChann; - channelStat=phiDet->pointToChannel(midPoint, entryChann, offset, pitch_mc); + phiDet->pointToChannel(midPoint, entryChann, offset, pitch_mc).ignore(); LHCb::VeloChannelID cluCentChann=clus->channelID(); IVeloClusterPosition::Direction globalDir_mc; slx_mc=aHit->dxdz(); @@ -617,7 +573,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, // this part is used when MC info is available - reso study, R clusters if(m_runWithMC){ const MCHit* aHit=getAssocMCHit(clus); - if(0==aHit) continue; + if(nullptr==aHit) continue; Gaudi::XYZPoint midPoint=aHit->midPoint(); Gaudi::XYZPoint localMidPoint=rDet->globalToLocal(midPoint); pntx_mc=localMidPoint.x(); @@ -626,9 +582,8 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, pntphi_mc=localMidPoint.Phi(); pntr_mc=localMidPoint.Rho(); double offset=0.; - StatusCode channelStat; VeloChannelID entryChann; - channelStat=rDet->pointToChannel(midPoint, entryChann, offset, pitch_mc); + rDet->pointToChannel(midPoint, entryChann, offset, pitch_mc).ignore(); LHCb::VeloChannelID cluCentChann=clus->channelID(); IVeloClusterPosition::Direction globalDir_mc; slx_mc=aHit->dxdz(); @@ -754,7 +709,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, tuple->column("r_clu", r_clu); tuple->column("pntphi_mc", pntphi_mc); } - tuple->write(); + tuple->write().ignore(); //} @@ -812,7 +767,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, } tuple->farray( "stripadc",stripADC,"stripN",4); tuple->farray( "stripNum",stripNum,"stripN",4); - tuple->write(); + tuple->write().ignore(); } } @@ -823,8 +778,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloClNtuple(const LHCb::Track& track, //low tolerance }//end of loop on the node } //track.nodes.size>0 - if( msgLevel(MSG::DEBUG) ) - debug() << "Filled cluster information ntuple " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug() << "Filled cluster information ntuple " << endmsg; return ( StatusCode::SUCCESS ); } @@ -843,8 +797,7 @@ void Velo::VeloTrackMonitorNT::FillVeloTrNtuple(const LHCb::Track& track, eventTimeMicroSecGps=0; - if( msgLevel(MSG::DEBUG) ) - debug() << "Track information ntuple " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug() << "Track information ntuple " << endmsg; // found hits of each type @@ -910,13 +863,11 @@ void Velo::VeloTrackMonitorNT::FillVeloTrNtuple(const LHCb::Track& track, unsigned int sensnmin=105, sensnmax=0; sensnmax= ((sensnpmax-64)>sensnrmax) ? (sensnpmax-64) : sensnrmax ; sensnmin= ((sensnpmin-64)<sensnrmin) ? (sensnpmin-64) : sensnrmin ; - if( msgLevel(MSG::DEBUG) ) + if( msgLevel(MSG::DEBUG) ) { debug()<<" zmin=" <<zmin <<" zmax="<<zmax<<" sensnmin=" <<sensnmin<<" sensnmax="<<sensnmax<<endmsg; - if( msgLevel(MSG::DEBUG) ) debug()<<" sensnrmin="<<sensnrmin<<" sensnrmax="<<sensnrmax<<endmsg; - if( msgLevel(MSG::DEBUG) ) - debug()<<" sensnpmin="<<sensnpmin<<" sensnpmax="<<sensnpmax<<endmsg; + } for(unsigned int j=(sensnmin); j<=sensnmax; j++){ if ((j<=41) || ((j>=64)&&(j<=105))){ @@ -1025,7 +976,7 @@ void Velo::VeloTrackMonitorNT::FillVeloTrNtuple(const LHCb::Track& track, tuple->column( "Trside", m_side); tuple->column( "Eff", pseudoEff); tuple->column( "EffInterp", pseudoEfficiencyInterp); - tuple->write(); + tuple->write().ignore(); } } @@ -1043,7 +994,7 @@ void Velo::VeloTrackMonitorNT::FillVeloEvNtuple(LHCb::Tracks* tracks,int n_pv, long long int tzero= 1270064494071424ll; //there is an ll at the end, so that C++ knows this has to be a long long float eventTimeMicroSecGps = (float) (((m_evTimeGps - tzero)/1000000.)); - debug()<< "Cluster information ntuple " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "Cluster information ntuple " << endmsg; if(m_runWithMC) @@ -1331,7 +1282,7 @@ for(TrackVector::const_iterator itTrg= righttracks.begin();itTrg!= righttracks.e tuple->column( "pvry", pvry); tuple->column( "pvrz", pvrz); tuple->column( "pvrntr", pvrntr); - tuple->write(); + tuple->write().ignore(); if( msgLevel(MSG::DEBUG) ) debug() << "Filled Event information ntuple " << endmsg; @@ -1350,7 +1301,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloAllClNtuple(LHCb::Tracks* tracks) long long int tzero= 1270064494071424ll; //there is an ll at the end, so that C++ knows this has to be a long long float eventTimeMicroSecGps = (float) (((m_evTimeGps - tzero)/1000000.)); - debug()<< "All Cluster information ntuple " << endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< "All Cluster information ntuple " << endmsg; LHCb::VeloClusters::const_iterator itVC; @@ -1404,7 +1355,7 @@ StatusCode Velo::VeloTrackMonitorNT::FillVeloAllClNtuple(LHCb::Tracks* tracks) tuple->column( "link", activeLink ); tuple->column( "clr",clr); tuple->column( "clphi",clphi); - tuple->write(); + tuple->write().ignore(); } @@ -1517,7 +1468,7 @@ const LHCb::MCHit* Velo::VeloTrackMonitorNT::getAssocMCHit(const LHCb::VeloClust if(range.begin()==range.end()){ if( msgLevel(MSG::DEBUG) ) debug()<< " No MCHits associated " <<endmsg; - return ( 0 ); + return ( nullptr ); } const MCHit* aHit=(range.begin())->to(); @@ -1527,9 +1478,8 @@ const LHCb::MCHit* Velo::VeloTrackMonitorNT::getAssocMCHit(const LHCb::VeloClust //============================================================================ VeloChannelID Velo::VeloTrackMonitorNT::weightedMean(const VeloCluster* cluster, double& isp) { - debug()<< " ==> weightedMean() " <<endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< " ==> weightedMean() " <<endmsg; // - StatusCode sc; int strips=cluster->size(); int intDistance=0; double centre=0., totalCharge=0.; @@ -1537,10 +1487,9 @@ VeloChannelID Velo::VeloTrackMonitorNT::weightedMean(const VeloCluster* cluster, unsigned int sensorNumber=cluster->channelID().sensor(); const DeVeloSensor* sensor=m_veloDet->sensor(sensorNumber); for(int strip=0; strip<strips; ++strip){ - sc=sensor->channelDistance(cluster->channels()[0], - cluster->channels()[strip], intDistance); - sc.ignore(); - debug()<< " int distance: " << intDistance <<endmsg; + sensor->channelDistance(cluster->channels()[0], + cluster->channels()[strip], intDistance).ignore(); + if( msgLevel(MSG::DEBUG) ) debug()<< " int distance: " << intDistance <<endmsg; centre+=(static_cast<float>(intDistance+100))* cluster->stripValues()[strip].second; totalCharge+=cluster->stripValues()[strip].second; @@ -1548,10 +1497,10 @@ VeloChannelID Velo::VeloTrackMonitorNT::weightedMean(const VeloCluster* cluster, centre/=totalCharge; centre-=100; intDistance=static_cast<int>(LHCb::Math::round(centre)); - debug()<< " centre: " << centre <<endmsg; + if( msgLevel(MSG::DEBUG) ) debug()<< " centre: " << centre <<endmsg; isp=centre-intDistance; VeloChannelID intDistanceID; - sc=sensor->neighbour(cluster->channels()[0], intDistance, intDistanceID); + StatusCode sc=sensor->neighbour(cluster->channels()[0], intDistance, intDistanceID); // if(sc.isSuccess()){ return ( intDistanceID ); diff --git a/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.h b/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.h index ab94df733f95731c96282890ca742b4541de1e39..fd064a97cb8864184c06de78e43adda44360b61c 100644 --- a/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.h +++ b/Velo/VeloRecMonitors/src/VeloTrackMonitorNT.h @@ -39,16 +39,11 @@ namespace Velo /** Standard construtor */ VeloTrackMonitorNT( const std::string& name, ISvcLocator* pSvcLocator ); - /** Destructor */ - virtual ~VeloTrackMonitorNT(); - /** Algorithm execute */ StatusCode execute() override; /** Algorithm initialize */ StatusCode initialize() override; - /** Algorithm initialize */ - StatusCode finalize() override; // associators typedef LinkerTool<LHCb::VeloCluster, LHCb::MCHit> AsctTool; @@ -84,19 +79,20 @@ namespace Velo bool m_runWithMC; bool m_etastudy; - std::string m_allString; - std::string m_clusterLoc; - std::string m_asctLocation; - LHCb::VeloClusters* m_rawClusters; - const DeVelo* m_veloDet ; - unsigned int m_runodin; - ulonglong m_eventodin; - unsigned int m_bunchid; - ulonglong m_evTimeGps; - IVeloExpectation* m_expectTool; - IVeloClusterPosition* m_clusterTool; - const Table* m_asctTable; - ITrackVertexer* m_vertexer ; + std::string m_allString = "ALL"; + std::string m_clusterLoc = LHCb::VeloClusterLocation::Default; + LHCb::VeloClusters* m_rawClusters = nullptr; + const DeVelo* m_veloDet = nullptr; + unsigned int m_runodin = 0; + ulonglong m_eventodin = 0; + unsigned int m_bunchid = 0; + ulonglong m_evTimeGps = 0; + IVeloExpectation* m_expectTool = nullptr; + IVeloClusterPosition* m_clusterTool = nullptr; + const Table* m_asctTable = nullptr; + ITrackVertexer* m_vertexer = nullptr; + /// interface to tracks fitter tool + ITrackFitter* m_tracksFitter = nullptr; protected: @@ -111,11 +107,9 @@ namespace Velo const LHCb::MCHit* getAssocMCHit(const LHCb::VeloCluster* clus) const; LHCb::VeloChannelID weightedMean(const LHCb::VeloCluster* cluster, double& isp); - /// interface to tracks fitter tool - ITrackFitter* m_tracksFitter; }; } -#endif // VELOTRACKMONITORNT_H +#endif // VELOTRACKMONITORNT_H \ No newline at end of file