Skip to content

Commit

Permalink
Add a utility function to return objects index inside a provided LCCo…
Browse files Browse the repository at this point in the history
…llection
  • Loading branch information
dudarboh committed Aug 31, 2022
1 parent 635db54 commit 4668a95
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/cpp/include/UTIL/LCCollectionTools.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef UTIL_LCCollectionTools_H
#define UTIL_LCCollectionTools_H 1

#include "EVENT/LCObject.h"
#include "EVENT/LCCollection.h"

namespace UTIL{
/** Extract object index inside a given LCCollection.
* @author Bohdan Dudar
* @version August 2022
*/
int getElementIndex(const EVENT::LCObject* item, EVENT::LCCollection* collection){
for(int i=0; i < collection->getNumberOfElements(); ++i){
if ( item == collection->getElementAt(i) ) return i;
}
return -1;
}
}

#endif

0 comments on commit 4668a95

Please sign in to comment.