Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide testing functions within appropriate CPP macros #24311

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h
Expand Up @@ -134,7 +134,7 @@ class BaseTrackerRecHit : public TrackingRecHit {

#ifdef VI_DEBUG
void check() const { assert(det());}
#elif EDM_LM_DEBUG
#elif DO_THROW_UNINITIALIZED
void check() const;
#else
static void check(){}
Expand Down
14 changes: 10 additions & 4 deletions DataFormats/TrackerRecHit2D/src/BaseTrackerRecHit.cc
@@ -1,3 +1,4 @@
//#define DO_THROW_UNINITIALIZED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be in .h file?
If define is added only here, then in all cases where the compiler decides to not inline the call of check where it's used, there will be a problem with one definition rule.

#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "DataFormats/TrackingRecHit/interface/KfComponentsHolder.h"
#include "DataFormats/Math/interface/ProjectMatrix.h"
Expand All @@ -6,6 +7,7 @@


namespace {
#ifdef DO_THROW_UNINITIALIZED
inline void
throwExceptionUninitialized(const char *where)
{
Expand All @@ -14,13 +16,13 @@ namespace {
"If you want to get coarse position/error estimation from disk, please set: ComputeCoarseLocalPositionFromDisk = True \n " <<
" to the TransientTrackingRecHitBuilder you are using from RecoTracker/TransientTrackingRecHit/python/TTRHBuilders_cff.py";
}
#endif
void obsolete() {
throw cms::Exception("BaseTrackerRecHit") << "CLHEP is obsolete for Tracker Hits";
}
}

#ifdef EDM_LM_DEBUG
#if !defined(VI_DEBUG) && defined(DO_THROW_UNINITIALIZED)
void BaseTrackerRecHit::check() const {
if (!hasPositionAndError()) throwExceptionUninitialized("localPosition or Error");
}
Expand All @@ -38,7 +40,9 @@ bool BaseTrackerRecHit::hasPositionAndError() const {
void
BaseTrackerRecHit::getKfComponents1D( KfComponentsHolder & holder ) const
{
// if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
#if defined(DO_THROW_UNINITIALIZED)
if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
#endif
AlgebraicVector1 & pars = holder.params<1>();
pars[0] = pos_.x();

Expand All @@ -55,7 +59,9 @@ BaseTrackerRecHit::getKfComponents1D( KfComponentsHolder & holder ) const
void
BaseTrackerRecHit::getKfComponents2D( KfComponentsHolder & holder ) const
{
//if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
#if defined(DO_THROW_UNINITIALIZED)
if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
#endif
AlgebraicVector2 & pars = holder.params<2>();
pars[0] = pos_.x();
pars[1] = pos_.y();
Expand Down
13 changes: 8 additions & 5 deletions DataFormats/TrackerRecHit2D/src/TrackerSingleRecHit.cc
Expand Up @@ -7,6 +7,8 @@
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"

//#define DO_INTERNAL_CHECKS
#if defined(DO_INTERNAL_CHECKS)
namespace {

void verify(OmniClusterRef const ref) {
Expand Down Expand Up @@ -84,7 +86,7 @@ namespace {
verify(thit);

}

bool doingCheck = false;
inline void checkSelf(const TrackingRecHit* one,const TrackingRecHit* two) {
doingCheck=true;
Expand All @@ -94,16 +96,17 @@ namespace {
if (!two->sharesInput(two,TrackingRecHit::some)) problem(two,"some");
doingCheck=false;
}

}
#endif

bool
TrackerSingleRecHit::sharesInput( const TrackingRecHit* other,
SharedInputType what) const
{
// verify(this); verify(other);
// if (!doingCheck && (other!=this)) checkSelf(this,other);

#if defined(DO_INTERNAL_CHECKS)
verify(this); verify(other);
if (!doingCheck && (other!=this)) checkSelf(this,other);
#endif

if (!sameDetModule(*other)) return false;

Expand Down