Commit in lcio/src on MAIN
aid/EVENT/SimTrackerHit.aid+3-21.10 -> 1.11
         /TrackerHit.aid+3-21.15 -> 1.16
cpp/CMakeLists.txt+11.28 -> 1.29
cpp/include/IMPL/SimTrackerHitImpl.h+4-21.13 -> 1.14
                /TrackerHitImpl.h+3-21.14 -> 1.15
cpp/src/EXAMPLE/simjob.cc+2-11.58 -> 1.59
cpp/src/IMPL/MCParticleImpl.cc+37-241.29 -> 1.30
            /SimCalorimeterHitImpl.cc+9-61.16 -> 1.17
            /SimTrackerHitImpl.cc+71.13 -> 1.14
            /TrackerHitImpl.cc+71.13 -> 1.14
cpp/src/TESTS/test_trackerhit.cc+4-21.2 -> 1.3
cpp/src/UTIL/LCWarning.cc+167added 1.1
+247-41
1 added + 11 modified, total 12 files
added new utility class for throwing warnings

lcio/src/aid/EVENT
SimTrackerHit.aid 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- SimTrackerHit.aid	2 Jun 2010 10:59:33 -0000	1.10
+++ SimTrackerHit.aid	17 Jun 2010 12:28:59 -0000	1.11
@@ -3,7 +3,7 @@
 /** A generic simulated tracker hit. 
  * 
  * @author gaede
- * @version $Id: SimTrackerHit.aid,v 1.10 2010/06/02 10:59:33 engels Exp $
+ * @version $Id: SimTrackerHit.aid,v 1.11 2010/06/17 12:28:59 engels Exp $
  */
 
 public interface SimTrackerHit extends LCObject {
@@ -25,7 +25,8 @@
     public const double3V getPosition() const ;
 
     /** Returns  the dE/dx of the hit in [GeV].
-     *  DEPRECATED. renamed to getEDep()
+     *  @deprecated
+     *  @see getEDep()
      */
     public float getdEdx() const ;
 

lcio/src/aid/EVENT
TrackerHit.aid 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- TrackerHit.aid	2 Jun 2010 10:59:33 -0000	1.15
+++ TrackerHit.aid	17 Jun 2010 12:28:59 -0000	1.16
@@ -11,7 +11,7 @@
 /** A generic tracker hit to be used by pattern recognition.
  * 
  * @author gaede
- * @version $Id: TrackerHit.aid,v 1.15 2010/06/02 10:59:33 engels Exp $
+ * @version $Id: TrackerHit.aid,v 1.16 2010/06/17 12:28:59 engels Exp $
  */
 
 public interface TrackerHit extends LCObject {
@@ -34,7 +34,8 @@
     public const FloatVec& getCovMatrix() const ;
     
     /** The dE/dx of the hit in [GeV].
-     *  DEPRECATED. renamed to getEDep()
+     *  @deprecated
+     *  @see getEDep()
      */
     public float getdEdx() const ;
     

lcio/src/cpp
CMakeLists.txt 1.28 -> 1.29
diff -u -r1.28 -r1.29
--- CMakeLists.txt	1 Jun 2010 15:02:54 -0000	1.28
+++ CMakeLists.txt	17 Jun 2010 12:29:00 -0000	1.29
@@ -120,6 +120,7 @@
   ./src/UTIL/lStdHep.cc
   ./src/UTIL/lXDR.cc
   ./src/UTIL/LCTOOLS.cc
+  ./src/UTIL/LCWarning.cc
   ./src/UTIL/CellIDEncoder.cc
   ./src/UTIL/CollectionParameterMap.cc
   ./src/UTIL/PIDHandler.cc

lcio/src/cpp/include/IMPL
SimTrackerHitImpl.h 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- SimTrackerHitImpl.h	2 Jun 2010 10:59:33 -0000	1.13
+++ SimTrackerHitImpl.h	17 Jun 2010 12:29:00 -0000	1.14
@@ -40,7 +40,8 @@
     virtual const double * getPosition() const ;
 
     /** Returns  the dE/dx of the hit.
-     *  DEPRECATED. renamed to getEDep()
+     *  @deprecated
+     *  @see getEDep()
      */ 	
     virtual float getdEdx() const ;
 
@@ -80,7 +81,8 @@
     void setPosition( double pos[3])  ;
 
     /** Sets dE/dx.
-     *  DEPRECATED. renamed to setEDep()
+     *  @deprecated
+     *  @see setEDep()
      */
     void setdEdx( float dEdX ) ;
 

lcio/src/cpp/include/IMPL
TrackerHitImpl.h 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- TrackerHitImpl.h	2 Jun 2010 10:59:33 -0000	1.14
+++ TrackerHitImpl.h	17 Jun 2010 12:29:00 -0000	1.15
@@ -15,7 +15,7 @@
 /** Implementation of the  generic tracker hit. 
  * 
  * @author gaede
- * @version $Id: TrackerHitImpl.h,v 1.14 2010/06/02 10:59:33 engels Exp $
+ * @version $Id: TrackerHitImpl.h,v 1.15 2010/06/17 12:29:00 engels Exp $
  */
 
   class TrackerHitImpl : public EVENT::TrackerHit , public AccessChecked {
@@ -39,7 +39,8 @@
     virtual const EVENT::FloatVec & getCovMatrix() const ;
 
     /** The dE/dx of the hit in [GeV/mm].
-     *  DEPRECATED. renamed to getEDep()
+     *  @deprecated
+     *  @see getEDep()
      */ 	
     virtual float getdEdx() const ;
 

lcio/src/cpp/src/EXAMPLE
simjob.cc 1.58 -> 1.59
diff -u -r1.58 -r1.59
--- simjob.cc	9 Nov 2007 21:03:07 -0000	1.58
+++ simjob.cc	17 Jun 2010 12:29:00 -0000	1.59
@@ -323,7 +323,8 @@
 	  LCFloatVec* extF = new LCFloatVec ;
 	  LCIntVec*   extI = new LCIntVec ;
 	  
-	  hit->setdEdx( 30e-9 ) ; 
+	  //hit->setdEdx( 30e-9 ) ; 
+	  hit->setEDep( 30e-9 ) ; 
 
 	  double pos[3] = { 1.1* rand()/RAND_MAX , 2.2* rand()/RAND_MAX , 3.3* rand()/RAND_MAX } ;
 	  

lcio/src/cpp/src/IMPL
MCParticleImpl.cc 1.29 -> 1.30
diff -u -r1.29 -r1.30
--- MCParticleImpl.cc	28 May 2008 14:02:09 -0000	1.29
+++ MCParticleImpl.cc	17 Jun 2010 12:29:00 -0000	1.30
@@ -1,5 +1,6 @@
 
 #include "IMPL/MCParticleImpl.h"
+#include "UTIL/LCWarning.h"
 
 #include "EVENT/LCIO.h"
 #include <iostream>
@@ -83,23 +84,29 @@
   }
 
   int MCParticleImpl::getNumberOfParents() const { 
-    static bool first = true ;
-    if( first ){
-      std::cout << " WARNING >>>>>>>  MCParticleImpl::getNumberOfParents() is deprecated "
-		<< " - please use  MCParticleImpl::getParents().size() ! " << std::endl ;
-      first = false ;
-    }
+    //static bool first = true ;
+    //if( first ){
+    //  std::cout << " WARNING >>>>>>>  MCParticleImpl::getNumberOfParents() is deprecated "
+	//	<< " - please use  MCParticleImpl::getParents().size() ! " << std::endl ;
+    //  first = false ;
+    //}
+    
+    UTIL::LCWarning::getInstance().printWarning( "MCPARTICLE_DEPRECATED_GETNUMBEROFPARENTS" ) ;
+
     return _parents.size() ; 
   }
 
   MCParticle* MCParticleImpl::getParent(int i) const {
     
-    static bool first = true ;
-    if( first ){
-      std::cout << " WARNING >>>>>>>  MCParticleImpl::getParent(i) is deprecated "
-		<< " - please use  MCParticleImpl::getParents()[i] ! " << std::endl ;
-      first = false ;
-    }
+    //static bool first = true ;
+    //if( first ){
+    //  std::cout << " WARNING >>>>>>>  MCParticleImpl::getParent(i) is deprecated "
+	//	<< " - please use  MCParticleImpl::getParents()[i] ! " << std::endl ;
+    //  first = false ;
+    //}
+
+    UTIL::LCWarning::getInstance().printWarning( "MCPARTICLE_DEPRECATED_GETPARENT" ) ;
+
     try{
       //      return _parents.at(i) ;
       //FIXME gcc 2.95 doesn't know at(i) ??
@@ -118,23 +125,29 @@
 
 
   int MCParticleImpl::getNumberOfDaughters() const { 
-    static bool first = true ;
-    if( first ){
-      std::cout << " WARNING >>>>>>>  MCParticleImpl::getNumberOfDaughters() is deprecated "
-		<< " - please use  MCParticleImpl::getDaughters().size() ! " << std::endl ;
-      first = false ;
-    }
+    //static bool first = true ;
+    //if( first ){
+    //  std::cout << " WARNING >>>>>>>  MCParticleImpl::getNumberOfDaughters() is deprecated "
+	//	<< " - please use  MCParticleImpl::getDaughters().size() ! " << std::endl ;
+    //  first = false ;
+    //}
+
+    UTIL::LCWarning::getInstance().printWarning( "MCPARTICLE_DEPRECATED_GETNUMBEROFDAUGHTERS" ) ;
+
     return _daughters.size() ; 
   }
 
   MCParticle* MCParticleImpl::getDaughter(int i) const {
     
-    static bool first = true ;
-    if( first ){
-      std::cout << " WARNING >>>>>>>  MCParticleImpl::getDaughter(i) is deprecated "
-		<< " - please use  MCParticleImpl::getDaughters()[i] ! " << std::endl ;
-      first = false ;
-    }
+    //static bool first = true ;
+    //if( first ){
+    //  std::cout << " WARNING >>>>>>>  MCParticleImpl::getDaughter(i) is deprecated "
+	//	<< " - please use  MCParticleImpl::getDaughters()[i] ! " << std::endl ;
+    //  first = false ;
+    //}
+
+    UTIL::LCWarning::getInstance().printWarning( "MCPARTICLE_DEPRECATED_GETDAUGHTER" ) ;
+
     try{
       //      return _daughters.at(i) ;
       //FIXME gcc 2.95 doesn't know at(i) ??

lcio/src/cpp/src/IMPL
SimCalorimeterHitImpl.cc 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- SimCalorimeterHitImpl.cc	26 Apr 2007 16:39:53 -0000	1.16
+++ SimCalorimeterHitImpl.cc	17 Jun 2010 12:29:00 -0000	1.17
@@ -1,4 +1,5 @@
 #include "IMPL/SimCalorimeterHitImpl.h"
+#include "UTIL/LCWarning.h"
 #include <iostream>
 
 namespace IMPL{
@@ -73,12 +74,14 @@
   }
   
   int SimCalorimeterHitImpl::getNMCParticles() const {
-    static bool first = true ;
-    if( first ){
-      std::cout << " WARNING >>>>>>>  SimCalorimeterHitImpl::getNMCParticles() is deprecated "
-                << " - please use  SimCalorimeterHitImpl::getNMCContributions() ! " << std::endl ;
-      first = false ;
-    }
+    //static bool first = true ;
+    //if( first ){
+    //  std::cout << " WARNING >>>>>>>  SimCalorimeterHitImpl::getNMCParticles() is deprecated "
+    //            << " - please use  SimCalorimeterHitImpl::getNMCContributions() ! " << std::endl ;
+    //  first = false ;
+    //}
+
+    UTIL::LCWarning::getInstance().printWarning( "SIMCALORIMETERHIT_DEPRECATED_GETNMCPARTICLES" ) ;
 
     return getNMCContributions() ;
   }

lcio/src/cpp/src/IMPL
SimTrackerHitImpl.cc 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- SimTrackerHitImpl.cc	2 Jun 2010 10:59:33 -0000	1.13
+++ SimTrackerHitImpl.cc	17 Jun 2010 12:29:00 -0000	1.14
@@ -1,4 +1,5 @@
 #include "IMPL/SimTrackerHitImpl.h"
+#include "UTIL/LCWarning.h"
 
 using namespace EVENT ;
 
@@ -29,6 +30,9 @@
 
   // DEPRECATED. use getEDep()
   float SimTrackerHitImpl::getdEdx() const {
+        
+      UTIL::LCWarning::getInstance().printWarning( "SIMTRACKERHIT_DEPRECATED_GETDEDX" ) ;
+
       //return _dEdx ;
       return getEDep() ;
   }
@@ -57,6 +61,9 @@
 
   // DEPRECATED. use setEDep()
   void SimTrackerHitImpl::setdEdx( float dedx )  {
+
+    UTIL::LCWarning::getInstance().printWarning( "SIMTRACKERHIT_DEPRECATED_SETDEDX" ) ;
+
     //checkAccess("SimTrackerHitImpl::setdEdx") ;
     //_dEdx = dedx ; 
     SimTrackerHitImpl::setEDep( dedx ) ;

lcio/src/cpp/src/IMPL
TrackerHitImpl.cc 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- TrackerHitImpl.cc	2 Jun 2010 10:59:33 -0000	1.13
+++ TrackerHitImpl.cc	17 Jun 2010 12:29:00 -0000	1.14
@@ -1,5 +1,6 @@
 #include "IMPL/TrackerHitImpl.h"
 #include "EVENT/LCIO.h"
+#include "UTIL/LCWarning.h"
 
 using namespace EVENT ;
 
@@ -33,6 +34,9 @@
 
   // DEPRECATED. use getEDep()
   float TrackerHitImpl::getdEdx() const {
+
+      UTIL::LCWarning::getInstance().printWarning( "TRACKERHIT_DEPRECATED_GETDEDX" ) ;
+
       //return _dEdx ;
       return getEDep();
   }
@@ -78,6 +82,9 @@
 
   // DEPRECATED. use setEDep()
   void TrackerHitImpl::setdEdx( float dedx )  {
+
+    UTIL::LCWarning::getInstance().printWarning( "TRACKERHIT_DEPRECATED_SETDEDX" ) ;
+
     //checkAccess("TrackerHitImpl::setdEdx") ;
     //_dEdx = dedx ; 
     setEDep( dedx ) ;

lcio/src/cpp/src/TESTS
test_trackerhit.cc 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- test_trackerhit.cc	2 Jun 2010 10:59:33 -0000	1.2
+++ test_trackerhit.cc	17 Jun 2010 12:29:00 -0000	1.3
@@ -58,7 +58,8 @@
 
             for(int j=0;j<NHITS;j++){
                 TrackerHitImpl* trkHit = new TrackerHitImpl ;
-                trkHit->setEDep( i*j*117. ) ;
+                //trkHit->setEDep( i*j*117. ) ;
+                trkHit->setdEdx( i*j*117. ) ;
                 trkHit->setEDepError( (i+j)*.3 ) ;
                 double pos[3] = { i, j, i*j } ;
                 trkHit->setPosition( pos ) ;
@@ -99,7 +100,8 @@
 
                 TrackerHit* trkHit = dynamic_cast<TrackerHit*>(trkHits->getElementAt(j)) ;
 
-                MYTEST( trkHit->getEDep() ,  i*j*117. , "EDep" ) ;
+                //MYTEST( trkHit->getEDep() ,  i*j*117. , "EDep" ) ;
+                MYTEST( trkHit->getdEdx() ,  i*j*117. , "dEdx" ) ;
                 // remove float converstion and check what happens ;)
                 MYTEST( trkHit->getEDepError() ,  float((i+j)*.3) , "EDepError" ) ;
                 //MYTEST( trkHit->getEDepError() ,  (i+j)*.3 , "EDepError" ) ;

lcio/src/cpp/src/UTIL
LCWarning.cc added at 1.1
diff -N LCWarning.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ LCWarning.cc	17 Jun 2010 12:29:00 -0000	1.1
@@ -0,0 +1,167 @@
+#include "UTIL/LCWarning.h"
+
+#include <iostream>
+#include "Exceptions.h"
+
+using namespace std;
+
+namespace UTIL{
+
+
+///// add new warnings here ===================================================
+LCWarning::LCWarning( ostream& outstream ) : _outstream(outstream) {
+
+
+    // ----- Warnings for SimTrackerHit ---------------------------------------
+    registerWarning(
+        "SIMTRACKERHIT_DEPRECATED_GETDEDX",
+        "used DEPRECATED method SimTrackerHitImpl::getdEdx()\n"
+        "please change your code to use SimTrackerHitImpl::getEDep() instead"
+    );
+
+    registerWarning(
+        "SIMTRACKERHIT_DEPRECATED_SETDEDX",
+        "used DEPRECATED method SimTrackerHitImpl::setdEdx()\n"
+        "please change your code to use SimTrackerHitImpl::setEDep() instead"
+    );
+    // ------------------------------------------------------------------------
+
+
+
+    // ----- Warnings for TrackerHit ------------------------------------------
+    registerWarning(
+        "TRACKERHIT_DEPRECATED_GETDEDX",
+        "used DEPRECATED method TrackerHitImpl::getdEdx()\n"
+        "please change your code to use TrackerHitImpl::getEDep()"
+    );
+
+    registerWarning(
+        "TRACKERHIT_DEPRECATED_SETDEDX",
+        "used DEPRECATED method TrackerHitImpl::setdEdx()\n"
+        "please change your code to use TrackerHitImpl::setEDep() instead."
+    );
+    // ------------------------------------------------------------------------
+
+
+
+    // ----- Warnings for SimCalorimeterHit ---------------------------------------
+    registerWarning(
+        "SIMCALORIMETERHIT_DEPRECATED_GETNMCPARTICLES",
+        "used DEPRECATED method SimCalorimeterHitImpl::getNMCParticles()\n"
+        "please change your code to use SimCalorimeterHitImpl::getNMCContributions() instead"
+    );
+    // ------------------------------------------------------------------------
+
+
+
+    // ----- Warnings for MCParticle ------------------------------------------
+    registerWarning(
+        "MCPARTICLE_DEPRECATED_GETNUMBEROFPARENTS",
+        "used DEPRECATED method MCParticleImpl::getNumberOfParents()\n"
+        "please change your code to use MCParticleImpl::getParents().size() instead."
+    );
+
+    registerWarning(
+        "MCPARTICLE_DEPRECATED_GETPARENT",
+        "used DEPRECATED method MCParticleImpl::getParent(i)\n"
+        "please change your code to use MCParticleImpl::getParents()[i] instead."
+    );
+
+    registerWarning(
+        "MCPARTICLE_DEPRECATED_GETNUMBEROFDAUGHTERS",
+        "used DEPRECATED method MCParticleImpl::getNumberOfDaughters()\n"
+        "please change your code to use MCParticleImpl::getDaughters().size() instead."
+    );
+
+    registerWarning(
+        "MCPARTICLE_DEPRECATED_GETDAUGHTER",
+        "used DEPRECATED method MCParticleImpl::getDaughter(i)\n"
+        "please change your code to use MCParticleImpl::getDaughters()[i] instead."
+    );
+    // ------------------------------------------------------------------------
+
+
+}
+///// =========================================================================
+
+
+
+void LCWarning::registerWarning( const string id, const string txt, int max ) {
+
+    if( _warning_cfg.find( id ) != _warning_cfg.end() ){
+        throw EVENT::Exception( std::string( "Warning [ "+id+" ] was already registered") ); 
+    }
+
+    _warning_cfg[ id ].txt = txt ;
+    _warning_cfg[ id ].max = max ;
+    _warning_cfg[ id ].counter = max ;
+
+    // _outstream << "registered warning " << id << "with max limit: " << max << endl;
+}
+
+
+
+void LCWarning::printWarning( const string id ) {
+
+    // if max limit has been reached for displaying the warning, just return and do nothing.
+    if( _warning_cfg[ id ].counter <= 0 ){ return ; }
+
+    _outstream << endl << endl
+         << endl << "=========== WARNING ========================================================="
+         << endl << _warning_cfg[ id ].txt;
+
+    if(  _warning_cfg[ id ].counter > 1 ){
+        _outstream << endl << "*** this warning will be printed (at most) "
+            << _warning_cfg[ id ].max << " time(s). [ "
+            << _warning_cfg[ id ].counter-1 << " time(s) left ]" ;
+    }
+    // max warnings have been reached.
+    else{
+        _outstream << endl << "*** the maximum amount of times for printing this warning has been reached."
+            << endl << "*** this warning will be printed one last time before the application exits." ;
+
+    }
+
+    _outstream << endl << "============================================================================="
+         << endl << endl ;
+
+    // decrease counter
+    _warning_cfg[ id ].counter-- ;
+}
+
+
+
+// destructor shows warnings one very last time before program ends
+LCWarning::~LCWarning(){
+
+    bool first_warning = true;
+
+    for( _warning_cfg_it = _warning_cfg.begin(); _warning_cfg_it != _warning_cfg.end(); _warning_cfg_it++ ){
+        if( (*_warning_cfg_it).second.max != (*_warning_cfg_it).second.counter ){
+            if( first_warning ){
+                _outstream << endl << endl
+                    << endl << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
+                    << endl << "+++ FOLLOWING WARNINGS WERE FOUND:"
+                    << endl << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
+                ;
+                first_warning = false ;
+            }
+            _outstream << endl << endl << _warning_cfg[ (*_warning_cfg_it).first ].txt ;
+        }
+    }
+    _outstream << endl << endl;
+}
+
+
+
+// singleton
+LCWarning& LCWarning::getInstance()
+{
+  static LCWarning instance;
+  return instance;
+}
+
+
+
+} // namespace UTIL
+
CVSspam 0.2.8