8 #include "EVENT/LCIO.h"
10 #define RELATIONFROMTYPESTR "FromType"
11 #define RELATIONTOTYPESTR "ToType"
13 using namespace EVENT ;
14 using namespace IMPL ;
36 for(
int i=0; i < n; i++){
52 return _map[ from ].first ;
58 return _rMap[ to ].first ;
63 return _map[ from ].second ;
68 return _rMap[ to ].second ;
84 FloatVec & vWgt = map[ from ].second ;
86 bool isNewObject = true ;
88 for(
int i=0; i<n ; i++){
112 RelMap::iterator iter = map.
find( from ) ;
113 if( iter != map.
end() ) {
117 FloatVec & vWgt = iter->second.second ;
122 LCObjectVec::iterator iTo = find( vTo.
begin(), vTo.
end() , to ) ;
124 if( iTo != vTo.
end() ){
126 FloatVec::iterator iWgt = vWgt.
begin() ;
128 advance( iWgt , distance( vTo.
begin() , iTo ) ) ;
134 assert( vWgt.
empty() ) ;
151 bool storeWeights = false ;
152 for(RelMap::iterator iter =
_map.
begin() ;
153 iter !=
_map.
end() ; iter++ ) {
157 FloatVec & vWgt = iter->second.second ;
159 unsigned int n = vTo.
size() ;
160 assert( n == vWgt.
size() ) ;
162 for(
unsigned int i=0 ; i<n ; i++ ){
165 if( vWgt[i] != 1.0f ) storeWeights = true ;
170 flag.
setBit( LCIO::LCREL_WEIGHTED ) ;
The generic object that is held in an LCCollection.
Implementation of the LCRelation.
virtual const EVENT::FloatVec & getRelatedToWeights(EVENT::LCObject *from) const
The weights of the relations returned by a call to getRelatedToObjects(from).
virtual EVENT::LCParameters & parameters()
Parameters defined for this run.
virtual const EVENT::LCObjectVec & getRelatedFromObjects(EVENT::LCObject *to) const
All from-objects related to the given object ( the inverse relationship).
Implementation of the LCCollection using (inheriting from) an STL vector of LCObjects.
virtual LCObject * getTo() const =0
The 'to' object of the given relation.
virtual void removeRelation(EVENT::LCObject *from, EVENT::LCObject *to)
Remove a given relation.
void setFlag(int flag)
Sets the flag word for this collection.
virtual LCObject * getElementAt(int index) const =0
Returns pointer to element at index - no range check, use getNumberOfEntries().
virtual float getWeight() const =0
The weight of the given relation - only if collection flag bit LCIO::LCREL_WEIGHTED is set...
virtual int getFlag() const
Returns the flag word.
virtual const EVENT::LCObjectVec & getRelatedToObjects(EVENT::LCObject *from) const
All objects that the given from-object is related to.
virtual EVENT::LCCollection * createLCCollection()
Remove a given relation.
Implementation of helper class to create and interpret the 32-bit flag word in LCCollections.
virtual const std::string & getTypeName() const =0
Returns the type name of the collection - valid names are defined in LCIO.
virtual void addElement(EVENT::LCObject *obj)
Adds the given element to (end of) the collection.
virtual void setValue(const std::string &key, int value)=0
Set integer value for the given key.
virtual const std::string & getFromType() const
The type of the 'from' objects in this relation.
#define RELATIONTOTYPESTR
virtual const std::string & getToType() const
The type of the 'to' objects in this relation.
virtual int getNumberOfElements() const =0
Returns the number of elements in the collection.
A single weighted relationship between two LCObjects.
virtual void initialize(const EVENT::LCCollection *col)
The generic collection used in LCIO.
#define RELATIONFROMTYPESTR
virtual LCObject * getFrom() const =0
The 'from' object of the given relation.
virtual void addRelation(EVENT::LCObject *from, EVENT::LCObject *to, float weight=1.0)
Adds a relation.
virtual void setBit(int bit)
Sets bit to 1.
virtual const EVENT::FloatVec & getRelatedFromWeights(EVENT::LCObject *to) const
The weights of the relations returned by a call to getRelatedFromObjects(to).