Skip to content

Commit

Permalink
Remove virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
dudarboh committed Sep 12, 2022
1 parent eee68fc commit 49c0961
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
30 changes: 15 additions & 15 deletions src/cpp/include/UTIL/LCRelationNavigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,75 +38,75 @@ namespace UTIL {
LCRelationNavigator( const EVENT::LCCollection* col ) ;

/// Destructor.
virtual ~LCRelationNavigator() { /* nop */; }
~LCRelationNavigator() { /* nop */; }

/**The type of the 'from' objects in this relation.
*/
virtual const std::string & getFromType() const ;
const std::string & getFromType() const ;

/**The type of the 'to' objects in this relation.
*/
virtual const std::string & getToType() const ;
const std::string & getToType() const ;

/** All objects that the given from-object is related to.
* LCObjects are of type getToType().
*/
virtual const EVENT::LCObjectVec & getRelatedToObjects(EVENT::LCObject * from) const ;
const EVENT::LCObjectVec & getRelatedToObjects(EVENT::LCObject * from) const ;

/** All from-objects related to the given object ( the inverse relationship).
* LCObjects are of type getFromType().
*/
virtual const EVENT::LCObjectVec & getRelatedFromObjects(EVENT::LCObject * to) const ;
const EVENT::LCObjectVec & getRelatedFromObjects(EVENT::LCObject * to) const ;

/** The weights of the relations returned by a call to getRelatedToObjects(from).
* @see getRelatedToObjects
*/
virtual const EVENT::FloatVec & getRelatedToWeights(EVENT::LCObject * from) const ;
const EVENT::FloatVec & getRelatedToWeights(EVENT::LCObject * from) const ;

/** The weights of the relations returned by a call to getRelatedFromObjects(to).
* @see getRelatedFromObjects
*/
virtual const EVENT::FloatVec & getRelatedFromWeights(EVENT::LCObject * to) const ;
const EVENT::FloatVec & getRelatedFromWeights(EVENT::LCObject * to) const ;

/** Object with a highest weight that the given from-object is related to.
* LCObject is of type getToType().
*/
virtual const EVENT::LCObject* getRelatedToMaxWeightObject(EVENT::LCObject* from, const std::string& weightType) const ;
const EVENT::LCObject* getRelatedToMaxWeightObject(EVENT::LCObject* from, const std::string& weightType) const ;

/** From-object related to the given object with a highest weight (the inverse relationship).
* LCObject is of type getFromType().
*/
virtual const EVENT::LCObject* getRelatedFromMaxWeightObject(EVENT::LCObject* to, const std::string& weightType) const ;
const EVENT::LCObject* getRelatedFromMaxWeightObject(EVENT::LCObject* to, const std::string& weightType) const ;

/** The highest weight of the relations returned by a call to getRelatedToObjects(from).
* @see getRelatedToObjects
*/
virtual float getRelatedToMaxWeight(EVENT::LCObject* from, const std::string& weightType) const ;
float getRelatedToMaxWeight(EVENT::LCObject* from, const std::string& weightType) const ;

/** The highest weight of the relations returned by a call to getRelatedFromObjects(to).
* @see getRelatedFromObjects
*/
virtual float getRelatedFromMaxWeight(EVENT::LCObject* to, const std::string& weightType) const ;
float getRelatedFromMaxWeight(EVENT::LCObject* to, const std::string& weightType) const ;

/** Adds a relation. If there is already an existing relation between the two given objects
* the weight (or default weight 1.0) is added to that relationship's weight.
*/
virtual void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight = 1.0) ;
void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight = 1.0) ;

/** Remove a given relation.
*/
virtual void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to) ;
void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to) ;

/** Remove a given relation. To reduce the weight of the relationship, call
* addRelation( from, to, weight ) with weight<0.
*/
virtual EVENT::LCCollection * createLCCollection() ;
EVENT::LCCollection * createLCCollection() ;

protected:

LCRelationNavigator() ;

virtual void initialize( const EVENT::LCCollection* col ) ;
void initialize( const EVENT::LCCollection* col ) ;

void removeRelation(EVENT::LCObject * from, EVENT::LCObject * to, RelMap& map ) ;
void addRelation(EVENT::LCObject * from, EVENT::LCObject * to, float weight, RelMap& map) ;
Expand Down
16 changes: 6 additions & 10 deletions src/cpp/src/UTIL/LCRelationNavigator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,19 @@ namespace UTIL{
const auto& weights = getRelatedToWeights(from);
if ( objects.empty() ) return 0.;

float maxWeight = 0.;
if (weightType == "track") maxWeight = *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)%10000)/1000. < (int(b)%10000)/1000.;});
else if (weightType == "cluster") maxWeight = *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)/10000)/1000. < (int(b)/10000)/1000. ;});
else maxWeight = *std::max_element(weights.begin(), weights.end(), [](float a, float b){return a < b ;});
return maxWeight;
if (weightType == "track") return *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)%10000)/1000. < (int(b)%10000)/1000.;});
else if (weightType == "cluster") return *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)/10000)/1000. < (int(b)/10000)/1000. ;});
return *std::max_element(weights.begin(), weights.end(), [](float a, float b){return a < b ;});
}

float LCRelationNavigator::getRelatedFromMaxWeight(EVENT::LCObject* to, const std::string& weightType) const {
const auto& objects = getRelatedToObjects(to);
const auto& weights = getRelatedToWeights(to);
if ( objects.empty() ) return 0.;

float maxWeight = 0.;
if (weightType == "track") maxWeight = *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)%10000)/1000. < (int(b)%10000)/1000.;});
else if (weightType == "cluster") maxWeight = *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)/10000)/1000. < (int(b)/10000)/1000. ;});
else maxWeight = *std::max_element(weights.begin(), weights.end(), [](float a, float b){return a < b ;});
return maxWeight;
if (weightType == "track") return *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)%10000)/1000. < (int(b)%10000)/1000.;});
else if (weightType == "cluster") return *std::max_element(weights.begin(), weights.end(), [](float a, float b){return (int(a)/10000)/1000. < (int(b)/10000)/1000. ;});
return *std::max_element(weights.begin(), weights.end(), [](float a, float b){return a < b ;});
}

void LCRelationNavigator::addRelation(EVENT::LCObject * from,
Expand Down

0 comments on commit 49c0961

Please sign in to comment.