-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a utility function to return objects index inside a provided LCCo…
…llection
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |