diff --git a/Reconstruction/RecGenfitAlg/CMakeLists.txt b/Reconstruction/RecGenfitAlg/CMakeLists.txt index 630086dce7a22cef058903d2859aaed2d469959c..866156036919ed186102e28a6abfbd02938588fa 100644 --- a/Reconstruction/RecGenfitAlg/CMakeLists.txt +++ b/Reconstruction/RecGenfitAlg/CMakeLists.txt @@ -2,13 +2,11 @@ if (GenFit_FOUND) gaudi_add_module(RecGenfitAlg - SOURCES src/RecGenfitAlgSDT.cpp - src/RecGenfitAlgDC.cpp + SOURCES src/RecGenfitAlgDC.cpp src/GenfitTrack.cpp src/GenfitField.cpp src/GenfitFitter.cpp src/GenfitMaterialInterface.cpp - src/GenfitMsg.cpp LINK GearSvc Gaudi::GaudiAlgLib Gaudi::GaudiKernel diff --git a/Reconstruction/RecGenfitAlg/README.md b/Reconstruction/RecGenfitAlg/README.md index c9cddb4c8b0b9285c1a42a72140c953b9f79797a..0870fb5dd8766a3201b19c3af73949907ce0c483 100644 --- a/Reconstruction/RecGenfitAlg/README.md +++ b/Reconstruction/RecGenfitAlg/README.md @@ -7,7 +7,6 @@ It's incudingg the interface to genfit fitter, track and measurement: * GenfitTrack: class for create and access of genfit Track and Measurement * GenfitField: implementation of genfit AbsField * GenfitGeoMaterialInterface: implementation of genfit AbsMaterialInterface -* GenfitMsg: a class to get Gaudi message instance in Genfit classes. * GenfitAlgDC: a class to fit drift chamber * GenfitAlgSDT: a class to fit drift chamber+silicon diff --git a/Reconstruction/RecGenfitAlg/src/GenfitField.cpp b/Reconstruction/RecGenfitAlg/src/GenfitField.cpp index 341e52f3d9c1a0e6539b62bec6225410dbbad7d4..744084254143d4480d2cb096970944aa2b6f0a58 100644 --- a/Reconstruction/RecGenfitAlg/src/GenfitField.cpp +++ b/Reconstruction/RecGenfitAlg/src/GenfitField.cpp @@ -1,5 +1,4 @@ #include "GenfitField.h" -#include "GenfitMsg.h" //External #include "DD4hep/DD4hepUnits.h" diff --git a/Reconstruction/RecGenfitAlg/src/GenfitFitter.cpp b/Reconstruction/RecGenfitAlg/src/GenfitFitter.cpp index 15d40830f9d3fa8deb71e0ca3e306ee7e5ad7c37..4850cf4d360e4ed71c705a32d5a18e4cdc8f319c 100644 --- a/Reconstruction/RecGenfitAlg/src/GenfitFitter.cpp +++ b/Reconstruction/RecGenfitAlg/src/GenfitFitter.cpp @@ -1,6 +1,5 @@ #include "GenfitFitter.h" #include "GenfitTrack.h" -#include "GenfitMsg.h" #include "GenfitField.h" #include "GenfitMaterialInterface.h" @@ -92,8 +91,8 @@ int GenfitFitter::init(bool deleteOldFitter) { if(deleteOldFitter && m_absKalman) delete m_absKalman; - GenfitMsg::get()<<MSG::DEBUG<<"Initialize GenfitFitter with " - <<m_fitterType<<endmsg; + if(m_debug>=2)std::cout<<"Initialize GenfitFitter with " + <<m_fitterType<<std::endl; if (m_fitterType=="DAFRef") { m_absKalman = new genfit::DAF(true,getDeltaPval(), @@ -111,11 +110,11 @@ int GenfitFitter::init(bool deleteOldFitter) } else { m_absKalman = nullptr; - GenfitMsg::get()<< MSG::DEBUG<<"Fitter type is invalid:" - <<m_fitterType<<endmsg; + if(m_debug>=2)std::cout<<"Fitter type is invalid:" + <<m_fitterType<<std::endl; return -1; } - GenfitMsg::get()<<MSG::DEBUG<<"Fitter type is "<<m_fitterType<<endmsg; + if(m_debug>=2)std::cout<<"Fitter type is "<<m_fitterType<<std::endl; m_absKalman->setDebugLvl(m_debug); return 0; @@ -124,11 +123,11 @@ int GenfitFitter::init(bool deleteOldFitter) /// Fit a track from a candidate track int GenfitFitter::processTrackWithRep(GenfitTrack* track,int repID,bool resort) { - GenfitMsg::get()<<MSG::DEBUG<< "In ProcessTrackWithRep rep "<<repID<<endmsg; + if(m_debug>=2)std::cout<< "In ProcessTrackWithRep rep "<<repID<<std::endl; if(getDebug()>2) print(""); if(getDebug()>0){ - GenfitMsg::get()<<MSG::DEBUG<<"Print track seed "<<endmsg; + if(m_debug>=2)std::cout<<"Print track seed "<<std::endl; track->getTrack()->getStateSeed().Print(); } /// Do the fitting @@ -136,29 +135,29 @@ int GenfitFitter::processTrackWithRep(GenfitTrack* track,int repID,bool resort) m_absKalman->processTrackWithRep(track->getTrack(), track->getRep(repID), resort); }catch(genfit::Exception& e){ - GenfitMsg::get()<<MSG::DEBUG<<"Genfit exception caught "<<endmsg; + if(m_debug>=2)std::cout<<"Genfit exception caught "<<std::endl; e.what(); return false; } - GenfitMsg::get()<<MSG::DEBUG<<"End of ProcessTrackWithRep"<<endmsg; + if(m_debug>=2)std::cout<<"End of ProcessTrackWithRep"<<std::endl; return true; } // End of ProcessTrackWithRep /// Fit a track from a candidate track int GenfitFitter::processTrack(GenfitTrack* track, bool resort) { - GenfitMsg::get()<<MSG::DEBUG<<"In ProcessTrack"<<endmsg; + if(m_debug>=2)std::cout<<"In ProcessTrack"<<std::endl; if(getDebug()>2) print(""); /// Do the fitting try{ m_absKalman->processTrack(track->getTrack(),resort); }catch(genfit::Exception& e){ - GenfitMsg::get()<<MSG::DEBUG<<"Genfit exception caught "<<endmsg; + if(m_debug>=2)std::cout<<"Genfit exception caught "<<std::endl; e.what(); return false; } - GenfitMsg::get()<<MSG::DEBUG<<"End of ProcessTrack"<<endmsg; + if(m_debug>=2)std::cout<<"End of ProcessTrack"<<std::endl; return true; } // End of ProcessTrack @@ -167,7 +166,7 @@ void GenfitFitter::setFitterType(const char* val) { std::string oldFitterType=m_fitterType; m_fitterType = val; - GenfitMsg::get()<<MSG::DEBUG<<"Fitter type is "<<m_fitterType<<endmsg; + if(m_debug>=2)std::cout<<"Fitter type is "<<m_fitterType<<std::endl; init(oldFitterType==val); } @@ -210,8 +209,8 @@ GenfitFitter::extrapolateToCylinder(TVector3& pos, TVector3& mom, // get track rep genfit::AbsTrackRep* rep = track->getRep(repID); if(nullptr == rep) { - GenfitMsg::get()<<MSG::DEBUG<<"In ExtrapolateToCylinder rep is null" - <<endmsg; + if(m_debug>=2)std::cout<<"In ExtrapolateToCylinder rep is null" + <<std::endl; return trackLength*dd4hep::cm; } @@ -219,8 +218,8 @@ GenfitFitter::extrapolateToCylinder(TVector3& pos, TVector3& mom, genfit::TrackPoint* tp = track->getTrack()->getPointWithFitterInfo(hitID,rep); if(nullptr == tp) { - GenfitMsg::get()<<MSG::DEBUG<< - "In ExtrapolateToCylinder TrackPoint is null"<<endmsg; + if(m_debug>=2)std::cout<< + "In ExtrapolateToCylinder TrackPoint is null"<<std::endl; return trackLength*dd4hep::cm; } @@ -230,8 +229,8 @@ GenfitFitter::extrapolateToCylinder(TVector3& pos, TVector3& mom, tp->getFitterInfo(rep))->getBackwardUpdate(); if(nullptr == state){ - GenfitMsg::get()<<MSG::DEBUG<<"In ExtrapolateToCylinder " - <<"no KalmanFittedStateOnPlane in backwardUpdate"<<endmsg; + if(m_debug>=2)std::cout<<"In ExtrapolateToCylinder " + <<"no KalmanFittedStateOnPlane in backwardUpdate"<<std::endl; return trackLength*dd4hep::cm; } rep->setPosMom(*state, pos*(1/dd4hep::cm), mom*(1/dd4hep::GeV)); @@ -245,9 +244,9 @@ GenfitFitter::extrapolateToCylinder(TVector3& pos, TVector3& mom, pos = pos*dd4hep::cm; mom = mom*dd4hep::GeV; } catch(genfit::Exception& e){ - GenfitMsg::get() << MSG::ERROR + if(m_debug>=3)std::cout <<"Exception in GenfitFitter::extrapolateToCylinder " - << e.what()<<endmsg; + << e.what()<<std::endl; trackLength = 1e9*dd4hep::cm; } return trackLength*dd4hep::cm; @@ -266,8 +265,8 @@ double GenfitFitter::extrapolateToPoint(TVector3& pos, TVector3& mom, // get track rep genfit::AbsTrackRep* rep = track->getRep(repID); if(nullptr == rep) { - GenfitMsg::get()<<MSG::DEBUG<<"In ExtrapolateToPoint rep " - <<repID<<" not exist!"<<endmsg; + if(m_debug>=2)std::cout<<"In ExtrapolateToPoint rep " + <<repID<<" not exist!"<<std::endl; return trackLength*dd4hep::cm; } @@ -278,8 +277,8 @@ double GenfitFitter::extrapolateToPoint(TVector3& pos, TVector3& mom, genfit::TrackPoint* tp = track->getTrack()->getPointWithFitterInfo(0,rep); if(nullptr == tp) { - GenfitMsg::get()<<MSG::DEBUG<< - "In ExtrapolateToPoint TrackPoint is null"<<endmsg; + if(m_debug>=2)std::cout<< + "In ExtrapolateToPoint TrackPoint is null"<<std::endl; return trackLength*dd4hep::cm; } @@ -289,8 +288,8 @@ double GenfitFitter::extrapolateToPoint(TVector3& pos, TVector3& mom, tp->getFitterInfo(rep))->getBackwardUpdate(); if(nullptr == state) { - GenfitMsg::get()<<MSG::DEBUG<< - "In ExtrapolateToPoint KalmanFittedStateOnPlane is null"<<endmsg; + if(m_debug>=2)std::cout<< + "In ExtrapolateToPoint KalmanFittedStateOnPlane is null"<<std::endl; return trackLength*dd4hep::cm; } trackLength = rep->extrapolateToPoint(*state, @@ -299,9 +298,9 @@ double GenfitFitter::extrapolateToPoint(TVector3& pos, TVector3& mom, pos = pos*dd4hep::cm; mom = mom*dd4hep::GeV; } catch(genfit::Exception& e){ - GenfitMsg::get() << MSG::ERROR + if(m_debug>=3)std::cout <<"Exception in GenfitFitter::extrapolateToPoint" - << e.what()<<endmsg; + << e.what()<<std::endl; trackLength = 1e9*dd4hep::cm; } return trackLength*dd4hep::cm; @@ -343,41 +342,41 @@ void GenfitFitter::print(const char* name) if(0==strlen(name)) name=m_name; //TODO print all fitting parameters - GenfitMsg::get()<<MSG::DEBUG<<name - <<" GenfitFitter Global Parameters:"<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" Fitter type = " << m_fitterType<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" Fitting Parameters:"<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" MinIteration = " << m_minIterations<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" MaxIteration = " << m_maxIterations<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_deltaPval = " << m_deltaPval<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" Material Effect Parameters:"<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_noEffects = " << m_noEffects<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_energyLossBetheBloch= " << m_energyLossBetheBloch<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_noiseBetheBloch = " << m_noiseBetheBloch<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_noiseCoulomb = " << m_noiseCoulomb<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_energyLossBrems = " << m_energyLossBrems<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_noiseBrems = " << m_noiseBrems<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name + if(m_debug>=2)std::cout<<name + <<" GenfitFitter Global Parameters:"<<std::endl; + if(m_debug>=2)std::cout<<name + <<" Fitter type = " << m_fitterType<<std::endl; + if(m_debug>=2)std::cout<<name + <<" Fitting Parameters:"<<std::endl; + if(m_debug>=2)std::cout<<name + <<" MinIteration = " << m_minIterations<<std::endl; + if(m_debug>=2)std::cout<<name + <<" MaxIteration = " << m_maxIterations<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_deltaPval = " << m_deltaPval<<std::endl; + if(m_debug>=2)std::cout<<name + <<" Material Effect Parameters:"<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_noEffects = " << m_noEffects<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_energyLossBetheBloch= " << m_energyLossBetheBloch<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_noiseBetheBloch = " << m_noiseBetheBloch<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_noiseCoulomb = " << m_noiseCoulomb<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_energyLossBrems = " << m_energyLossBrems<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_noiseBrems = " << m_noiseBrems<<std::endl; + if(m_debug>=2)std::cout<<name <<" m_ignoreBoundariesBetweenEqualMaterials= " - << m_ignoreBoundariesBetweenEqualMaterials<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_mscModelName = " << m_mscModelName<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_debug = " << m_debug<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<name - <<" m_hist = " << m_hist<<endmsg; + << m_ignoreBoundariesBetweenEqualMaterials<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_mscModelName = " << m_mscModelName<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_debug = " << m_debug<<std::endl; + if(m_debug>=2)std::cout<<name + <<" m_hist = " << m_hist<<std::endl; if(m_fitterType=="DAF"||m_fitterType=="DAFRef"){ genfit::DAF* daf = getDAF(); @@ -388,27 +387,27 @@ void GenfitFitter::print(const char* name) for (unsigned int i=0; i<betas.size(); ++i) { sBetas<<betas.at(i)<<","; } - GenfitMsg::get()<<MSG::DEBUG<<" print "<<betas.size()<< - " betas: %s "<<sBetas.str()<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<m_name - << " m_deltaWeight = " << m_deltaWeight<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<" DAF maxIterations= " - << daf->getMaxIterations()<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<" DAF minIterations= " - << daf->getMinIterations()<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<" DAF deltaPval= " - << daf->getDeltaPval()<<endmsg; + if(m_debug>=2)std::cout<<" print "<<betas.size()<< + " betas: %s "<<sBetas.str()<<std::endl; + if(m_debug>=2)std::cout<<m_name + << " m_deltaWeight = " << m_deltaWeight<<std::endl; + if(m_debug>=2)std::cout<<" DAF maxIterations= " + << daf->getMaxIterations()<<std::endl; + if(m_debug>=2)std::cout<<" DAF minIterations= " + << daf->getMinIterations()<<std::endl; + if(m_debug>=2)std::cout<<" DAF deltaPval= " + << daf->getDeltaPval()<<std::endl; } } genfit::KalmanFitterRefTrack* ref = getKalRef(); if(nullptr != ref){ std::ostringstream sBetas; - GenfitMsg::get()<<MSG::DEBUG<<" DAF maxIterations= " - << ref->getMaxIterations()<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<" DAF minIterations= " - << ref->getMinIterations()<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<" DAF deltaPval= " - << ref->getDeltaPval()<<endmsg; + if(m_debug>=2)std::cout<<" DAF maxIterations= " + << ref->getMaxIterations()<<std::endl; + if(m_debug>=2)std::cout<<" DAF minIterations= " + << ref->getMinIterations()<<std::endl; + if(m_debug>=2)std::cout<<" DAF deltaPval= " + << ref->getDeltaPval()<<std::endl; } } @@ -422,7 +421,7 @@ void GenfitFitter::setMinIterations(unsigned int val) void GenfitFitter::setMaxIterations(unsigned int val) { if(val<=4) { - GenfitMsg::get()<<MSG::ERROR<<"Could NOT set MaxIteration<=4!"<<endmsg; + if(m_debug>=3)std::cout<<"Could NOT set MaxIteration<=4!"<<std::endl; } m_absKalman->setMaxIterations(val); m_maxIterations = val; @@ -434,10 +433,10 @@ void GenfitFitter::setMaxIterationsBetas(double bStart,double bFinal, m_absKalman->setMaxIterations(val); m_maxIterations = val; if(val<=4) { - GenfitMsg::get()<<MSG::ERROR<<"Could NOT set MaxIteration<=4!"<<endmsg; + if(m_debug>=3)std::cout<<"Could NOT set MaxIteration<=4!"<<std::endl; } - GenfitMsg::get()<<MSG::DEBUG<<"bStart "<<bStart<<" bFinal "<<bFinal - <<" MaxIteration "<<val<<endmsg; + if(m_debug>=2)std::cout<<"bStart "<<bStart<<" bFinal "<<bFinal + <<" MaxIteration "<<val<<std::endl; // genfit version less than 2.2.0 genfit::DAF* daf = dynamic_cast<genfit::DAF*> (m_absKalman); daf->setAnnealingScheme(bStart,bFinal,val); @@ -562,7 +561,7 @@ void GenfitFitter::setMaterialDebugLvl(unsigned int val) ///Set GenfitFitter parameters void GenfitFitter::setDebug(unsigned int val) { - GenfitMsg::get()<<MSG::DEBUG<<"set fitter debugLvl "<<val<<endmsg; + if(m_debug>=2)std::cout<<"set fitter debugLvl "<<val<<std::endl; m_absKalman->setDebugLvl(val); if(nullptr!=getDAF()) getDAF()->setDebugLvl(val); if(val>10) genfit::MaterialEffects::getInstance()->setDebugLvl(val); @@ -577,8 +576,8 @@ genfit::DAF* GenfitFitter::getDAF() try{ daf = dynamic_cast<genfit::DAF*> (m_absKalman); }catch(...){ - GenfitMsg::get()<< MSG::ERROR - << "dynamic_cast m_rom AbsFitter to DAF m_ailed!"<<endmsg; + if(m_debug>=3)std::cout + << "dynamic_cast m_rom AbsFitter to DAF m_ailed!"<<std::endl; return nullptr; } return daf; @@ -590,22 +589,22 @@ genfit::KalmanFitterRefTrack* GenfitFitter::getKalRef() try{ ref = dynamic_cast<genfit::KalmanFitterRefTrack*> (m_absKalman); }catch(...){ - GenfitMsg::get()<< MSG::ERROR + if(m_debug>=3)std::cout << "dynamic_cast m_rom AbsFitter to KalmanFitterRefTrack m_ailed!" - <<endmsg; + <<std::endl; } return ref; } void GenfitFitter::initHist(std::string name) { - GenfitMsg::get()<<MSG::DEBUG<<"GenfitFitter::initHist "<<name<<endmsg; + if(m_debug>=2)std::cout<<"GenfitFitter::initHist "<<name<<std::endl; //getDAF()->initHist(name); } void GenfitFitter::writeHist() { - GenfitMsg::get()<<MSG::DEBUG<<"GenfitFitter::writeHist "<<endmsg; + if(m_debug>=2)std::cout<<"GenfitFitter::writeHist "<<std::endl; //getDAF()->writeHist(); } diff --git a/Reconstruction/RecGenfitAlg/src/GenfitMsg.cpp b/Reconstruction/RecGenfitAlg/src/GenfitMsg.cpp deleted file mode 100644 index 6799d68e0ed8120274c7b5a0d6ac24eb8fb4b078..0000000000000000000000000000000000000000 --- a/Reconstruction/RecGenfitAlg/src/GenfitMsg.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "GenfitMsg.h" -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/IMessageSvc.h" - -MsgStream* GenfitMsg::m_log = nullptr; - -MsgStream GenfitMsg::get(){ - if(nullptr == m_log){ - SmartIF<IMessageSvc> msgSvc( - Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc")); - m_log = new MsgStream(msgSvc, "GenfitMsg"); - (*m_log) << MSG::DEBUG << "initialize GenfitMsg" << endmsg; - } - return (*m_log); -} - -GenfitMsg::~GenfitMsg(){ - delete m_log; -} diff --git a/Reconstruction/RecGenfitAlg/src/GenfitMsg.h b/Reconstruction/RecGenfitAlg/src/GenfitMsg.h deleted file mode 100644 index 43808b42b425ef29245445c2144c8a255facda4b..0000000000000000000000000000000000000000 --- a/Reconstruction/RecGenfitAlg/src/GenfitMsg.h +++ /dev/null @@ -1,26 +0,0 @@ -////////////////////////////////////////////////////////////////////// -/// -/// This is a class for genfit interfaces classes to access Gaudi log -/// system -/// -/// Authors: -/// Yao ZHANG(zhangyao@ihep.ac.cn) -/// -////////////////////////////////////////////////////////////////////// -#ifndef RECGENFITALG_GENFITMSG_H -#define RECGENFITALG_GENFITMSG_H - -#include "GaudiKernel/MsgStream.h" - -class GenfitMsg { - public: - static MsgStream get(); - private: - GenfitMsg(){}; - virtual ~GenfitMsg(); - static MsgStream* m_log; - -}; - -#endif - diff --git a/Reconstruction/RecGenfitAlg/src/GenfitTrack.cpp b/Reconstruction/RecGenfitAlg/src/GenfitTrack.cpp index f210dc9f69c88a0cbc6407b18911c181c700accf..7b361351a17c987464727d72a02cee69859e942b 100644 --- a/Reconstruction/RecGenfitAlg/src/GenfitTrack.cpp +++ b/Reconstruction/RecGenfitAlg/src/GenfitTrack.cpp @@ -1,5 +1,4 @@ #include "GenfitTrack.h" -#include "GenfitMsg.h" #include "GenfitField.h" //CEPCSW @@ -105,11 +104,11 @@ bool GenfitTrack::createGenfitTrack(int pdgType,int charge, int chargeId=0; charge>0 ? chargeId=0 : chargeId=1; - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" CreateGenfitTrack seed pos(" + if(m_debug>=2)std::cout<<m_name<<" CreateGenfitTrack seed pos(" <<seedState[0]<<" "<<seedState[1]<<" "<<seedState[2]<<")cm (" <<seedState[3]<<" "<<seedState[4]<<" "<<seedState[5]<<")GeV charge " - <<charge<<" pdg "<<s_PDG[chargeId][pdgType]<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<"seedCov "<<endmsg; + <<charge<<" pdg "<<s_PDG[chargeId][pdgType]<<std::endl; + if(m_debug>=2)std::cout<<"seedCov "<<std::endl; addTrackRep(s_PDG[chargeId][pdgType]); @@ -124,10 +123,10 @@ bool GenfitTrack::createGenfitTrackFromMCParticle(int pidType, ///get track parameters from McParticle edm4hep::Vector3d mcPocaPos = mcParticle.getVertex();//mm edm4hep::Vector3f mcPocaMom = mcParticle.getMomentum();//GeV - GenfitMsg::get()<<MSG::DEBUG<<"seedPos poca "<< mcPocaPos.x - <<" "<<mcPocaPos.y<<" "<<mcPocaPos.z<<" mm "<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<"seedMom poca "<< mcPocaMom.x - <<" "<<mcPocaMom.y<<" "<<mcPocaMom.z<<" GeV "<<endmsg; + if(m_debug>=2)std::cout<<"seedPos poca "<< mcPocaPos.x + <<" "<<mcPocaPos.y<<" "<<mcPocaPos.z<<" mm "<<std::endl; + if(m_debug>=2)std::cout<<"seedMom poca "<< mcPocaMom.x + <<" "<<mcPocaMom.y<<" "<<mcPocaMom.z<<" GeV "<<std::endl; ///Pivot to first layer to avoid correction of beam pipe edm4hep::Vector3d firstLayerPos(1e9,1e9,1e9); @@ -139,24 +138,24 @@ bool GenfitTrack::createGenfitTrackFromMCParticle(int pidType, TLorentzVector seedPos(firstLayerPos.x,firstLayerPos.y,firstLayerPos.z, eventStartTime); TVector3 seedMom(firstLayerMom.x,firstLayerMom.y,firstLayerMom.z); - GenfitMsg::get()<<MSG::DEBUG<<"seedPos "<< firstLayerPos.x - <<" "<<firstLayerPos.y<<" "<<firstLayerPos.z<<endmsg; - GenfitMsg::get()<<MSG::DEBUG<<"seedMom "<< firstLayerMom.x - <<" "<<firstLayerMom.y<<" "<<firstLayerMom.z<<endmsg; + if(m_debug>=2)std::cout<<"seedPos "<< firstLayerPos.x + <<" "<<firstLayerPos.y<<" "<<firstLayerPos.z<<std::endl; + if(m_debug>=2)std::cout<<"seedMom "<< firstLayerMom.x + <<" "<<firstLayerMom.y<<" "<<firstLayerMom.z<<std::endl; ///Get error matrix of seed track TMatrixDSym covM(5);//FIXME, TODO ///Create a genfit track with seed - GenfitMsg::get()<<MSG::DEBUG<<"createGenfitTrack " ; + if(m_debug>=2)std::cout<<"createGenfitTrack " ; if(!GenfitTrack::createGenfitTrack(pidType,mcParticle.getCharge(), seedPos,seedMom,covM)){ - GenfitMsg::get()<<MSG::ERROR<<"GenfitTrack" - <<" Error in createGenfitTrack" <<endmsg; + if(m_debug>=2)std::cout<<"GenfitTrack" + <<" Error in createGenfitTrack" <<std::endl; return false; }else{ - GenfitMsg::get()<<MSG::DEBUG<<"GenfitTrack " - <<"createGenfitTrackFromMCParticle track created" <<endmsg; + if(m_debug>=2)std::cout<<"GenfitTrack " + <<"createGenfitTrackFromMCParticle track created" <<std::endl; } return true; }//end of createGenfitTrackFromMCParticle @@ -206,13 +205,13 @@ bool GenfitTrack::addSpacePointTrakerHit(edm4hep::ConstTrackerHit& hit, p[1]=pos.y*dd4hep::mm; p[2]=pos.z*dd4hep::mm; - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" addSpacePointTrakerHit"<<hitID - <<"pos "<<p[0]<<" "<<p[1]<<" "<<p[2]<<" cm"<<endmsg; + if(m_debug>=2)std::cout<<m_name<<" addSpacePointTrakerHit"<<hitID + <<"pos "<<p[0]<<" "<<p[1]<<" "<<p[2]<<" cm"<<std::endl; /// New a SpacepointMeasurement double cov[6]; for(int i=0;i<6;i++) { cov[i]=hit.getCovMatrix(i); - GenfitMsg::get()<<MSG::DEBUG<<"cov "<<cov[i]<<endmsg; + if(m_debug>=2)std::cout<<"cov "<<cov[i]<<std::endl; } TMatrixDSym hitCov(3);//FIXME? //in SimpleDigi/src/PlanarDigiAlg.cpp @@ -232,7 +231,7 @@ bool GenfitTrack::addSpacePointTrakerHit(edm4hep::ConstTrackerHit& hit, genfit::TrackPoint* trackPoint = new genfit::TrackPoint(sMeas,m_track); m_track->insertPoint(trackPoint); - GenfitMsg::get()<<MSG::DEBUG<<"end of addSpacePointTrakerHit"<<endmsg; + if(m_debug>=2)std::cout<<"end of addSpacePointTrakerHit"<<std::endl; return true; } @@ -260,10 +259,10 @@ bool GenfitTrack::addSpacePointMeasurement(const TVectorD& pos, hitCov(1,1)=sigma_t*sigma_t; hitCov(2,2)=sigma_t*sigma_t; - GenfitMsg::get()<< MSG::DEBUG<<m_name<<" addSpacePointMeasurement detID " + if(m_debug>=2)std::cout<<m_name<<" addSpacePointMeasurement detID " <<detID<<" hitId "<<hitID<<" " <<pos_t[0]<<" "<<pos_t[1]<<" "<<pos_t[2] <<" cm smeared "<<pos_smeared[0]<<" "<<pos_smeared[1]<<" " - <<pos_smeared[2]<<" sigma_t "<<sigma_t<<" cm"<<endmsg; + <<pos_smeared[2]<<" sigma_t "<<sigma_t<<" cm"<<std::endl; genfit::SpacepointMeasurement* sMeas = new genfit::SpacepointMeasurement(pos_smeared,hitCov,detID,hitID,nullptr); @@ -287,12 +286,12 @@ void GenfitTrack::addWireMeasurement(double driftDistance, wireMeas->setMaxDistance(0.5);//0.5 cm FIXME wireMeas->setLeftRightResolution(lrAmbig); - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" Add wire measurement(cm) "<<hitID + if(m_debug>=2)std::cout<<m_name<<" Add wire measurement(cm) "<<hitID <<" ep1("<<endPoint1[0]<<" "<<endPoint1[1]<<" "<<endPoint1[2] <<") ep2("<<endPoint2[0]<<" "<<endPoint2[1]<<" "<<endPoint2[2] <<") drift "<<driftDistance<<" driftErr "<<driftDistanceError <<" lr "<<lrAmbig<<" detId "<<detID << " hitId "<< hitID - <<endmsg; + <<std::endl; ///New a TrackPoint,create connection between meas. and trackPoint genfit::TrackPoint* trackPoint=new genfit::TrackPoint(wireMeas,m_track); @@ -301,8 +300,8 @@ void GenfitTrack::addWireMeasurement(double driftDistance, m_track->insertPoint(trackPoint); }catch(genfit::Exception& e){ - GenfitMsg::get()<<MSG::DEBUG<<m_name - <<"Add wire measurement exception"<<endmsg; + if(m_debug>=2)std::cout<<m_name + <<"Add wire measurement exception"<<std::endl; e.what(); } }//end of addWireMeasurementOnTrack @@ -320,9 +319,9 @@ bool GenfitTrack::addWireMeasurementOnTrack(edm4hep::Track& track,double sigma) m_gridDriftChamber->cellposition(hit.getCellID(),endPointStart, endPointEnd); int lrAmbig=0; - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" time "<<hit.getTime() + if(m_debug>=2)std::cout<<m_name<<" time "<<hit.getTime() <<" driftVelocity " <<driftVelocity<<std::endl; - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" wire pos " <<endPointStart.X() + if(m_debug>=2)std::cout<<m_name<<" wire pos " <<endPointStart.X() <<" "<<endPointStart.Y()<<" " <<endPointStart.Z()<<" " <<endPointEnd.X()<<" " <<endPointEnd.Y()<<" " <<endPointEnd.Z()<<" " <<std::endl; @@ -363,8 +362,8 @@ genfit::RKTrackRep* GenfitTrack::addTrackRep(int pdg) // genfit::MeasuredStateOnPlane stateInit(rep); // rep->setPosMomCov(stateInit, pos, mom, covM); //}catch(genfit::Exception e){ - // GenfitMsg::get() << MSG::DEBUG<<m_name<<" Exception in set track status" - // <<endmsg ; + // if(m_debug>=2)std::cout<<m_name<<" Exception in set track status" + // <<std::endl ; // std::cout<<e.what()<<std::endl; // return false; //} @@ -414,22 +413,22 @@ bool GenfitTrack::fitSuccess(int repID) const /// Test fitting converged if (!fitStatus->isFitted()||!fitStatus->isFitConverged() ||fitStatus->isFitConvergedFully()) { - GenfitMsg::get() << MSG::DEBUG<<m_name<< "Fitting is failed... isFitted" + if(m_debug>=2)std::cout<<m_name<< "Fitting is failed... isFitted" <<fitStatus->isFitted()<<" , isFitConverged " <<fitStatus->isFitConverged()<<", isFitConvergedFully " - <<fitStatus->isFitConvergedFully()<<endmsg; + <<fitStatus->isFitConvergedFully()<<std::endl; return false; } double chi2 = fitStatus->getChi2(); double ndf = fitStatus->getNdf(); - GenfitMsg::get() << MSG::INFO << "Fit result: chi2 "<<chi2 <<" ndf "<<ndf - << " chi2/ndf = " << chi2/ndf<<endmsg; + if(m_debug>=2)std::cout<< "Fit result: chi2 "<<chi2 <<" ndf "<<ndf + << " chi2/ndf = " << chi2/ndf<<std::endl; /// Test fitting chi2 if (chi2<= 0) { - GenfitMsg::get() << MSG::DEBUG<<m_name<< "Fit chi2<0 (chi2,ndf) = (" << - chi2 << "," << ndf << ")"<<endmsg; + if(m_debug>=2)std::cout<<m_name<< "Fit chi2<0 (chi2,ndf) = (" << + chi2 << "," << ndf << ")"<<std::endl; return false; } return true; @@ -446,7 +445,7 @@ void GenfitTrack::printSeed() const TLorentzVector pos = getSeedStatePos(); TVector3 mom = getSeedStateMom(); print(pos,mom); - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" NumPoints "<<getNumPoints()<<endmsg; + if(m_debug>=2)std::cout<<m_name<<" NumPoints "<<getNumPoints()<<std::endl; } void GenfitTrack::printFitted(int repID) const @@ -455,14 +454,14 @@ void GenfitTrack::printFitted(int repID) const TVector3 fittedMom; TMatrixDSym cov; - GenfitMsg::get()<<MSG::DEBUG<<m_name<< "printFitted nHit=" - <<m_track->getNumPoints()<<endmsg; + if(m_debug>=2)std::cout<<m_name<< "printFitted nHit=" + <<m_track->getNumPoints()<<std::endl; for(unsigned int iHit=0; iHit<m_track->getNumPoints(); iHit++){ if (getPosMomCovMOP((int) iHit, fittedPos, fittedMom, cov, repID)){ //print(fittedPos,fittedMom,to_string(iHit).c_str());//TODO }else{ - GenfitMsg::get()<<MSG::DEBUG<<m_name<<"Hit "<<iHit - <<" have no fitter info"<<endmsg; + if(m_debug>=2)std::cout<<m_name<<"Hit "<<iHit + <<" have no fitter info"<<std::endl; } } } @@ -475,7 +474,7 @@ void GenfitTrack::print( TLorentzVector pos, TVector3 mom, TVector3 mglo = mom; // TODO - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" "<<comment<<endmsg; + if(m_debug>=2)std::cout<<m_name<<" "<<comment<<std::endl; if(m_debug>1){ for(unsigned int i=0;i<m_reps.size();i++){ m_reps[i]->Print(); } @@ -531,8 +530,8 @@ int GenfitTrack::getFittedState(TLorentzVector& pos, TVector3& mom, std::cout<<" getNumPointsWithFittedInfo " <<getNumPointsWithFittedInfo(repID) <<" no TrackPoint with fitted info "<<std::endl; - GenfitMsg::get()<<MSG::DEBUG<<m_name - <<"Exception in getFittedState"<<endmsg; + if(m_debug>=2)std::cout<<m_name + <<"Exception in getFittedState"<<std::endl; std::cout<<e.what()<<std::endl; return 3; } @@ -625,8 +624,8 @@ double GenfitTrack::extrapolateToHit( TVector3& poca, TVector3& pocaDir, extrapoLen = rep->extrapolateToLine(state, end0, end1, poca, pocaDir, pocaOnWire, stopAtBoundary, calcJacobianNoise); }catch(genfit::Exception& e) { - GenfitMsg::get() << MSG::ERROR - <<"Exception in GenfigFitter::ExtrapolateToHit"<<e.what()<<endmsg; + if(m_debug>=3)std::cout<< + "Exception in GenfigFitter::ExtrapolateToHit"<<e.what()<<std::endl; return extrapoLen; } @@ -635,10 +634,10 @@ double GenfitTrack::extrapolateToHit( TVector3& poca, TVector3& pocaDir, pocaOnWire = pocaOnWire; doca = (pocaOnWire-poca).Mag(); //TODO: debug pocaOnWire - GenfitMsg::get() << MSG::DEBUG << " poca "<<poca.x()<<","<<poca.y() - <<" "<<poca.z()<<" doca "<<doca<<endmsg; - GenfitMsg::get() << MSG::DEBUG << " pocaOnWire "<<pocaOnWire.x() - <<","<<pocaOnWire.y()<<" "<<pocaOnWire.z()<<" doca "<<doca<<endmsg; + if(m_debug>=2)std::cout<< " poca "<<poca.x()<<","<<poca.y() + <<" "<<poca.z()<<" doca "<<doca<<std::endl; + if(m_debug>=2)std::cout<< " pocaOnWire "<<pocaOnWire.x() + <<","<<pocaOnWire.y()<<" "<<pocaOnWire.z()<<" doca "<<doca<<std::endl; return extrapoLen*(dd4hep::cm); }//end of ExtrapolateToHit @@ -651,11 +650,11 @@ int GenfitTrack::addSimTrackerHits(const edm4hep::Track& track, //A TrakerHit collection std::vector<edm4hep::ConstSimTrackerHit> sortedDCTrackHitCol; - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" VXD " + if(m_debug>=2)std::cout<<m_name<<" VXD " <<lcio::ILDDetID::VXD<<" SIT " <<lcio::ILDDetID::SIT<<" SET " <<lcio::ILDDetID::SET<<" FTD " - <<lcio::ILDDetID::FTD<<" "<<endmsg; + <<lcio::ILDDetID::FTD<<" "<<std::endl; ///Get TrackerHit on Track int hitID=0; for(unsigned int iHit=0;iHit<track.trackerHits_size();iHit++){ @@ -664,25 +663,25 @@ int GenfitTrack::addSimTrackerHits(const edm4hep::Track& track, UTIL::BitField64 encoder(lcio::ILDCellID0::encoder_string); encoder.setValue(hit.getCellID()); int detID=encoder[lcio::ILDCellID0::subdet]; - GenfitMsg::get()<<MSG::DEBUG<<m_name<<" "<<iHit<<" hit "<<hit - <<" detID "<<detID<<endmsg; + if(m_debug>=2)std::cout<<m_name<<" "<<iHit<<" hit "<<hit + <<" detID "<<detID<<std::endl; if(detID==lcio::ILDDetID::VXD || detID==lcio::ILDDetID::SIT || detID==lcio::ILDDetID::SET || detID==lcio::ILDDetID::FTD){ if(addSpacePointTrakerHit(hit,hitID)){ - GenfitMsg::get()<<MSG::DEBUG<<"add slicon space point"<<endmsg; + if(m_debug>=2)std::cout<<"add slicon space point"<<std::endl; hitID++; }else{ - GenfitMsg::get()<<MSG::ERROR<<"silicon addSpacePointTrakerHit" - <<detID<<" "<<hit.getCellID()<<" faieled"<<endmsg; + if(m_debug>=2)std::cout<<"silicon addSpacePointTrakerHit" + <<detID<<" "<<hit.getCellID()<<" faieled"<<std::endl; } }else if(detID==7){ //if(addSpacePointMeasurement(p,sigma,hit.getCellID(),hitID)){ - // GenfitMsg::get()<<MSG::DEBUG<<"add DC space point"<<endmsg; + // if(m_debug>=2)std::cout<<"add DC space point"<<std::endl; // hitID++; //}else{ - // GenfitMsg::get()<<MSG::ERROR<<"addSpacePointMeasurement" - // <<detID<<" faieled" <<endmsg; + // if(m_debug>=2)std::cout<<"addSpacePointMeasurement" + // <<detID<<" faieled" <<std::endl; //} float minTime=FLT_MAX; edm4hep::ConstSimTrackerHit minTimeSimHit; @@ -697,12 +696,12 @@ int GenfitTrack::addSimTrackerHits(const edm4hep::Track& track, //std::cout<<"minTimeSimHit "<<minTimeSimHit<<std::endl; sortedDCTrackHitCol.push_back(minTimeSimHit); }else{ - GenfitMsg::get()<<MSG::DEBUG<<" Skip add this hit!"<<endmsg; + if(m_debug>=2)std::cout<<" Skip add this hit!"<<std::endl; } }//end loop over hit on track - GenfitMsg::get()<<MSG::DEBUG<<" addSimTrakerHits trackerHits_size=" - <<track.trackerHits_size()<<endmsg; + if(m_debug>=2)std::cout<<" addSimTrakerHits trackerHits_size=" + <<track.trackerHits_size()<<std::endl; ///Add DC hits to track //Sort sim DC hits by time @@ -715,15 +714,15 @@ int GenfitTrack::addSimTrackerHits(const edm4hep::Track& track, p[2]=pos.z; unsigned long long detID = dCTrackerHit.getCellID(); if(addSpacePointMeasurement(p,sigma,detID,hitID,smear)){ - GenfitMsg::get()<<MSG::DEBUG<<"add DC space point"<<endmsg; + if(m_debug>=2)std::cout<<"add DC space point"<<std::endl; hitID++; }else{ - GenfitMsg::get()<<MSG::ERROR<<"addSpacePointMeasurement" - <<detID<<" faieled" <<endmsg; + if(m_debug>=2)std::cout<<"addSpacePointMeasurement" + <<detID<<" faieled" <<std::endl; } } - GenfitMsg::get()<<MSG::DEBUG<<"GenfitTrack nHitAdded "<<hitID<<endmsg; + if(m_debug>=2)std::cout<<"GenfitTrack nHitAdded "<<hitID<<std::endl; return hitID; } @@ -745,13 +744,13 @@ bool GenfitTrack::storeTrack(edm4hep::ReconstructedParticle& recParticle, TLorentzVector fittedPos; TVector3 fittedMom; int fittedState=getFittedState(fittedPos,fittedMom,fittedCov); - GenfitMsg::get()<<MSG::DEBUG<<"fit result: get status OK? pidType " + if(m_debug>=2)std::cout<<"fit result: get status OK? pidType " <<pidType<<" fittedState==0 " <<(0==fittedState)<<" isFitted "<<isFitted - <<" isConverged "<<isConverged<<" ndf "<<ndf<<endmsg; + <<" isConverged "<<isConverged<<" ndf "<<ndf<<std::endl; if((0!=fittedState) || (!isFitted) || !isConvergedFully || (ndf<ndfCut)){ - GenfitMsg::get()<<MSG::DEBUG<<" fitting failed"<<endmsg; + if(m_debug>=2)std::cout<<" fitting failed"<<std::endl; }else{ - GenfitMsg::get()<<MSG::DEBUG<<"fit result: Pos("<< + if(m_debug>=2)std::cout<<"fit result: Pos("<< fittedPos.X()<<" "<< fittedPos.Y()<<" "<< fittedPos.Z()<<") mom("<< @@ -762,7 +761,7 @@ bool GenfitTrack::storeTrack(edm4hep::ReconstructedParticle& recParticle, fittedMom.Perp()<< " chi2 "<<chi2<< " ndf "<<ndf - <<endmsg; + <<std::endl; } float pos[3]={float(fittedPos.X()),float(fittedPos.Y()),float(fittedPos.Z())}; float mom[3]={float(fittedMom.X()),float(fittedMom.Y()),float(fittedMom.Z())};