-
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
3 changed files
with
26 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
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,15 @@ | ||
#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. If object is not found, return -1. | ||
* @author Bohdan Dudar | ||
* @version August 2022 | ||
*/ | ||
int getElementIndex(const EVENT::LCObject* item, EVENT::LCCollection* collection); | ||
} | ||
|
||
#endif |
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,10 @@ | ||
#include "UTIL/LCCollectionTools.h" | ||
|
||
namespace UTIL{ | ||
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; | ||
} | ||
} |