Namespace for general, non-LArSoft-specific utilities. More...
Namespaces | |
details | |
flags | |
Classes and functions to manage bit masks and flags. | |
manip | |
pre_std | |
quantities | |
Types of variables with a unit. | |
Classes | |
struct | add_tag |
struct | AddressTaker |
Functor returning the address in memory of the operand. More... | |
struct | always_false_type |
A std::false_type with a template argument. More... | |
struct | always_true_type |
A std::true_type with a template argument. More... | |
class | ClusterShapes |
struct | collection_from_reference_type |
Trait with the type of collection referenced by collRef . More... | |
struct | collection_reference_type |
Trait of a type that can be used to reference the collection Coll . More... | |
struct | collection_value_access_type |
Trait of type obtained by access to element of collection Coll . More... | |
struct | collection_value_constant_access_type |
Trait of type obtained by constant access to element of collection Coll . More... | |
struct | collection_value_type |
Trait of value contained in the template collection Coll . More... | |
class | ConvertEdep2Art |
struct | count_extracted_types |
Counts the elements of a tuple-like type containing a Target type. More... | |
class | count_iterator |
An iterator dereferencing to a counter value. More... | |
struct | count_type_in_tuple |
Holds whether the Target type is element of the specified std::tuple . More... | |
struct | count_type_in_tuple< Target, std::tuple< T... > > |
class | CrpGainService |
class | DatabaseUtil |
class | DataProductChangeTracker_t |
Detects the presence of a new event or data product. More... | |
struct | Dereferencer |
Functor dereferencing the operand. More... | |
class | EventChangeTracker_t |
Detects the presence of a new event. More... | |
struct | extract_to_tuple_type |
Returns type TargetClass<U...> from a SrcTuple<T...> . More... | |
class | FileCatalogMetadataDUNE |
class | FileCatalogMetadataMPD |
struct | find_next_type |
Trait: index of the first occurrence of T among the specified Types , starting from the one with index StartFrom . More... | |
class | GaussianEliminationAlg |
class | GeometryUtilities |
class | GridContainerBase1D |
Base class for a container of data arranged on a 1D-grid. More... | |
class | GridContainerBase2D |
Base class for a container of data arranged on a 2D-grid. More... | |
class | GridContainerBase3D |
Base class for a container of data arranged on a 3D-grid. More... | |
class | GridContainerIndicesBase1D |
Index manager for a container of data arranged on a >=1-dim grid. More... | |
class | GridContainerIndicesBase2D |
Index manager for a container of data arranged on a >=2-dim grid. More... | |
class | GridContainerIndicesBase3D |
Index manager for a container of data arranged on a >=3-dim grid. More... | |
struct | has_duplicate_extracted_types |
Traits holding whether elements of Tuple have duplicate types. More... | |
struct | has_extracted_type |
Trait holding whether an element in Tuple type contains Target . More... | |
struct | index_of_extracted_type |
Returns the index of the element in Tuple with the specified type. More... | |
struct | is_any_of |
Trait: whether T is among the specified Types . More... | |
struct | is_basic_string_type |
Trait: whether type T is a STL string type. More... | |
struct | is_basic_string_view_type |
Trait: whether type T is a std::string_view type. More... | |
struct | is_character_type |
Trait: whether type T is a character type. More... | |
struct | is_instance_of |
Trait describing whether T is a template instance of Template . More... | |
struct | is_STLarray |
Identifies whether the specified type is a STL array. More... | |
struct | is_STLarray< std::array< T, N > > |
struct | is_string_type |
Trait: whether type T is a character string type. More... | |
struct | KeepByPositionFilterTag |
Tag for filters. More... | |
class | LArFFT |
class | LArFFTW |
class | LArFFTWPlan |
class | LArPropTest |
class | LazyVector |
A contiguous data container expanded on write. More... | |
struct | lvalue_reference_into_wrapper_type |
Trait with type T into std::reference_wrapper if reference. More... | |
class | MappedContainer |
A meta-container providing transparent mapping on top of another. More... | |
struct | MappedContainerBase |
Non-template base class for MappedContainer . More... | |
class | MultipleChoiceSelection |
Helper to select one among multiple choices via strings. More... | |
class | MultipleChoiceSelectionBase |
Base class of util::MultipleChoiceSelection with basics independent of the option type. More... | |
class | NormalDistribution |
class | PlaneDataChangeTracker_t |
Detects the presence of a new event, data product or wire plane. More... | |
class | PositionInVolumeFilter |
Use to keep particles with at least part of trajectory in a volume. More... | |
class | PxHit |
class | PxHitConverter |
class | PxLine |
class | PxPoint |
class | Range |
represents a "Range" w/ notion of ordering. A range is defined by a pair of "start" and "end" values. This is stored in std::pair attribute util::Range::_window. This attribute is protected so that the start/end cannot be changed w/o a check that start is always less than end. Note the specialization requires a template class T to have less operator implemented. More... | |
struct | RangeForWrapperTag |
Tag marking the use of RangeForWrapperBox. More... | |
struct | reference_addresser |
Functor applying the proper referenced_address() function. More... | |
struct | remove_tag |
Trait holding the type contained in a TaggedType (or the type itself). More... | |
struct | remove_tag< TaggedType< T, Tag > > |
class | RootGraphicsEnablingService |
Trojan service to inject initialization code. More... | |
struct | self_type |
Trait returning the very same type as in the template argument. More... | |
class | SignalShaping |
class | SignalShapingDUNE10ktTest |
class | SignalShapingDUNE35tTest |
class | SignalShapingServiceDUNE |
class | SignalShapingServiceDUNE10kt |
class | SignalShapingServiceDUNE34kt |
class | SignalShapingServiceDUNE35t |
class | SignalShapingServiceDUNEDPhase |
class | SiPMUtils |
struct | span |
Simple class with a begin and an end. More... | |
struct | span_base |
Non-templated base class for span . More... | |
struct | strip_referenceness_type |
Trait with type T stripped of all known reference types. More... | |
struct | StyleSentry |
class | SumSecondFunction |
struct | TagExtractor |
Extracts the tag from a type. More... | |
struct | TaggedType |
A type with a specified tag. More... | |
struct | TagN |
Tag class parametrized by a sequence of numbers. More... | |
class | TensorIndices |
Converts a tensor element specification into a linear index. More... | |
class | TensorIndices< 1U > |
struct | TensorIndicesBasicTypes |
Types for TensorIndices class. More... | |
class | TFileMetadataDUNE |
class | TrackPropagator |
class | UBDaqID |
class | UniqueRangeSet |
std::set of util::Range, which does not allow any overlap in contained element. std::set<Range> w/ modified insert/emplace function. Original std::set does not allow modification of element. I assume what we're interested in is "find if the range already \n exists, and merge if it exists". The insert function does that by recursively looking up overlapping elements w.r.t. input argument of insert function. More... | |
class | UtilException |
class | VectorMap |
struct | with_const_as |
Trait with type Base , plus the constantness as in Key . More... | |
Typedefs | |
template<typename Coll > | |
using | collection_value_t = typename collection_value_type< Coll >::type |
Type contained in the collection Coll . More... | |
template<typename Coll > | |
using | collection_value_access_t = typename collection_value_access_type< Coll >::type |
Type obtained by constant access to element of collection Coll . More... | |
template<typename Coll > | |
using | collection_value_constant_access_t = typename collection_value_constant_access_type< Coll >::type |
Type obtained by constant access to element of collection Coll . More... | |
template<typename Coll > | |
using | collection_reference_t = typename collection_reference_type< Coll >::type |
The type contained in util::collection_reference_type trait. More... | |
template<typename Cont > | |
using | collection_from_reference_t = typename collection_from_reference_type< Cont >::type |
Type contained in util::collection_from_reference_type trait. More... | |
template<typename T > | |
using | self_t = typename self_type< T >::type |
The very same type as in the template argument. More... | |
using | type_traits = std::bool_constant< Value > |
template<typename A , typename B > | |
using | is_not_same = std::negation< std::is_same< A, B >> |
The negation of std::is_same . More... | |
template<typename T , typename... Types> | |
using | find_type = find_next_type< T, 0U, Types... > |
Trait: index of the first occurrence of T among the specified Types . More... | |
template<typename T > | |
using | is_reference_wrapper = is_instance_of< std::reference_wrapper, T > |
Identifies whether the specified type is a std::reference_wrapper . More... | |
template<typename T > | |
using | is_unique_ptr = is_instance_of< std::unique_ptr, T > |
Identifies whether the specified type is a std::unique_ptr . More... | |
template<typename Base , typename Key > | |
using | with_const_as_t = typename with_const_as< Base, Key >::type |
The type Base , plus the constantness as in Key . More... | |
template<typename T > | |
using | strip_referenceness_t = typename strip_referenceness_type< T >::type |
The type T stripped of all known reference types. More... | |
template<typename T > | |
using | lvalue_reference_into_wrapper_t = typename lvalue_reference_into_wrapper_type< T >::type |
The type T stripped of all known reference types. More... | |
typedef int | UBLArSoftCh_t |
typedef std::map< UBDaqID, UBLArSoftCh_t > | UBChannelMap_t |
typedef std::map< UBLArSoftCh_t, UBDaqID > | UBChannelReverseMap_t |
using | GridContainer2DIndices = GridContainerIndicesBase2D<> |
Index manager for a container of data arranged on a 2D grid. More... | |
using | GridContainer3DIndices = GridContainerIndicesBase3D<> |
Index manager for a container of data arranged on a 3D grid. More... | |
template<typename DATUM > | |
using | GridContainer2D = GridContainerBase2D< DATUM, GridContainer2DIndices > |
Container allowing 2D indexing. More... | |
template<typename DATUM > | |
using | GridContainer3D = GridContainerBase3D< DATUM, GridContainer3DIndices > |
Container allowing 3D indexing. More... | |
using | MatrixIndices = TensorIndices< 2U > |
Type for indexing a 2D-tensor (matrix) More... | |
template<typename SrcTuple , template< typename T, typename... > class Extractor, template< typename... > class TargetClass = std::tuple> | |
using | extract_to_tuple_type_t = typename extract_to_tuple_type< SrcTuple, Extractor, TargetClass >::type |
Direct access to the type in extract_to_tuple_type . More... | |
template<typename Tuple , template< typename... > class TargetClass = std::tuple> | |
using | to_tuple = extract_to_tuple_type< Tuple, self_type, TargetClass > |
template<typename Tuple , template< typename... > class TargetClass = std::tuple> | |
using | to_tuple_t = typename to_tuple< Tuple, TargetClass >::type |
Direct access to the type in to_tuple . More... | |
template<typename Target , typename Tuple > | |
using | index_of_type = index_of_extracted_type< self_type, Target, Tuple > |
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple > | |
using | type_with_extracted_type = std::tuple_element< index_of_extracted_type_v< Extractor, Target, Tuple >, Tuple > |
Returns the element type in Tuple with the specified type. More... | |
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple > | |
using | type_with_extracted_type_t = typename type_with_extracted_type< Extractor, Target, Tuple >::type |
Direct access to the value in type_with_extracted_type . More... | |
template<typename Target , typename Tuple > | |
using | has_type = has_extracted_type< self_type, Target, Tuple > |
template<typename Tuple > | |
using | has_duplicate_types = has_duplicate_extracted_types< self_type, Tuple > |
template<typename Target , typename Tuple > | |
using | count_types = count_extracted_types< self_type, Target, Tuple > |
template<typename T , typename Tag > | |
using | add_tag_t = typename add_tag< T, Tag >::type |
template<typename Tagged > | |
using | remove_tag_t = typename remove_tag< Tagged >::type |
Direct access to the type contained in remove_tag . More... | |
template<typename Tagged > | |
using | tag_of = TagExtractor< Tagged > |
Trait holding the tag of Tagged as type . More... | |
template<typename Tagged > | |
using | tag_of_t = typename tag_of< Tagged >::type |
Direct access to the type in tag_of . More... | |
template<typename SrcTuple > | |
using | extract_tags = extract_to_tuple_type< SrcTuple, TagExtractor > |
Returns a tuple with all the tags from SrcTuple . More... | |
template<typename SrcTuple > | |
using | extract_tags_t = typename extract_tags< SrcTuple >::type |
Direct access to the type in extract_tags . More... | |
template<typename Tag , typename Tuple > | |
using | index_of_tag = index_of_extracted_type< TagExtractor, Tag, Tuple > |
Trait holding the index of the element of Tuple with tag Tag . More... | |
template<typename Tag , typename Tuple > | |
using | type_with_tag = type_with_extracted_type< TagExtractor, Tag, Tuple > |
Trait holding the type of the element of Tuple with tag Tag . More... | |
template<typename Tag , typename Tuple > | |
using | type_with_tag_t = typename type_with_tag< Tag, Tuple >::type |
Direct access to the value in type_with_tag . More... | |
template<typename Tag , typename Tuple > | |
using | has_tag = has_extracted_type< TagExtractor, Tag, Tuple > |
Trait informing if there are elements in Tuple with tag Tag . More... | |
template<typename Tag , typename Tuple > | |
using | count_tags = count_extracted_types< TagExtractor, Tag, Tuple > |
Trait counting the elements in Tuple with tag Tag . More... | |
template<typename Tuple > | |
using | has_duplicate_tags = has_duplicate_extracted_types< TagExtractor, Tuple > |
Trait reporting if multiple elements in Tuple have the same tag. More... | |
Functions | |
template<typename Stream > | |
decltype(auto) | operator<< (Stream &&out, EventChangeTracker_t const &trk) |
template<typename Stream > | |
decltype(auto) | operator<< (Stream &&out, DataProductChangeTracker_t const &trk) |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX) |
Creates a single one-to-one association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, size_t indx=UINT_MAX) |
Creates a single one-to-one association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, art::Ptr< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn) |
Creates a single one-to-one association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::PtrVector< U > const &b, art::Assns< T, U > &assn, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, art::Ptr< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class PRODUCER , class T , class U > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, std::vector< size_t > const &indices, size_t indx=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<typename PRODUCER , typename T , typename U , typename Iter > | |
bool | CreateAssn (PRODUCER const &prod, art::Event &evt, art::Assns< T, U > &assn, size_t first_index, Iter from_second_index, Iter to_second_index) |
Creates a single one-to-many association. More... | |
template<typename PRODUCER , typename T , typename U , typename D > | |
bool | CreateAssnD (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, typename art::Assns< U, T, D >::data_t const &data, art::Assns< U, T, D > &assn, size_t indx=UINT_MAX) |
template<class T , class U > | |
std::vector< const U * > | FindUNotAssociatedToT (art::Handle< U > b, art::Event const &evt, std::string const &label) |
template<class T , class U > | |
std::vector< art::Ptr< U > > | FindUNotAssociatedToTP (art::Handle< U > b, art::Event const &evt, std::string const &label) |
template<class T , class U > | |
std::vector< size_t > | GetAssociatedVectorOneI (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<class T , class U > | |
std::vector< const U * > | GetAssociatedVectorOneP (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<class T , class U > | |
std::vector< std::vector< size_t > > | GetAssociatedVectorManyI (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<class T , class U > | |
std::vector< std::vector< const U * > > | GetAssociatedVectorManyP (art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p) |
template<typename Coll > | |
auto | make_collection_reference (Coll &&coll) |
Returns an object referencing to the data contained in coll . More... | |
template<typename CollRef > | |
decltype(auto) | collection_from_reference (CollRef &collRef) |
Returns the object referenced by collRef as a C++ reference. More... | |
template<typename Coll , typename Extractor > | |
decltype(auto) | makeValueIndex (Coll const &coll, Extractor getter) |
Returns a map of value to index. More... | |
template<typename Coll > | |
auto | makeValueIndex (Coll const &coll) |
template<typename Ref > | |
auto | referenced_address (Ref &&ref) |
Returns the address of the referenced object. More... | |
template<typename T > | |
auto | lvalue_reference_into_wrapper (T &&obj) |
Converts a l-value reference object into a std::reference_wrapper . More... | |
decltype(auto) | takeAddress () |
Returns a functor that returns the address of its argument. More... | |
decltype(auto) | dereference () |
Returns a functor that returns *ptr of its argument ptr . More... | |
template<typename Coll > | |
auto | makePointerVector (Coll &coll) |
Creates a STL vector with pointers to data from another collection. More... | |
template<typename Coll , typename PtrColl > | |
void | MoveFromPointers (Coll &dest, PtrColl &src) |
Moves the content from a collection of pointers to one of data. More... | |
template<typename Coll , typename Sorter > | |
void | SortByPointers (Coll &coll, Sorter sorter) |
Applies sorting indirectly, minimizing data copy. More... | |
template<typename Coll , typename Sorter > | |
void | SortUniquePointers (Coll &coll, Sorter &&sorter) |
Sorts a vector of unique pointers using a C pointer sorter. More... | |
template<typename IterB , typename IterE , typename Adaptor > | |
span (IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) > | |
template<typename T = double> | |
constexpr T | pi () |
Returns the constant pi (up to 35 decimal digits of precision) More... | |
template<typename T > | |
constexpr T | DegreesToRadians (T angle) |
Converts the argument angle from degrees into radians. More... | |
template<typename T > | |
constexpr T | RadiansToDegrees (T angle) |
Converts the argument angle from radians into degrees ( ) More... | |
template<typename Stream , typename Left , typename Right , typename Data > | |
void | DumpAssociationsIntro (Stream &&out, art::Assns< Left, Right, Data > const &assns) |
Dumps a short introduction about specified association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX) |
Creates a single one-to-one association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, size_t index=UINT_MAX) |
Creates a single one-to-one association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, art::Ptr< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn) |
Creates a single one-to-one association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, std::vector< T > const &a, art::PtrVector< U > const &b, art::Assns< T, U > &assn, size_t index=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, art::Ptr< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn) |
Creates a single one-to-many association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, std::vector< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn, size_t index=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t index=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<class T , class U > | |
bool | CreateAssn (art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, std::vector< size_t > const &indices, size_t index=UINT_MAX) |
Creates a single one-to-many association. More... | |
template<typename T , typename U , typename Iter > | |
bool | CreateAssn (art::Event &evt, art::Assns< T, U > &assn, size_t first_index, Iter from_second_index, Iter to_second_index) |
Creates a single one-to-many association. More... | |
template<typename Producer , typename... Args> | |
std::enable_if_t< std::is_base_of_v< art::EDProducer, Producer >, bool > | CreateAssn (Producer const &, Args &&...args) |
template<typename Producer , typename... Args> | |
std::enable_if_t< std::is_base_of_v< art::EDProducer, Producer >, bool > | CreateAssnD (Producer const &, Args &&...args) |
template<typename Range , typename Pred > | |
auto | filterRangeFor (Range &&range, Pred &&pred) -> decltype(auto) |
Provides iteration only through elements passing a condition. More... | |
template<class A , class F > | |
void | for_each_associated_group (A const &assns, F &func) |
Helper functions to access associations in order. More... | |
template<class A > | |
auto | associated_groups (A const &assns) |
Helper functions to access associations in order. More... | |
template<class A > | |
auto | associated_groups_with_left (A const &assns) |
Helper functions to access associations in order, also with key. More... | |
template<typename Groups > | |
auto | groupByIndex (Groups &&groups, std::size_t index) -> decltype(auto) |
Returns the group within groups with the specified index. More... | |
template<typename Coll , typename KeyOf > | |
std::vector< size_t > | MakeIndex (Coll const &data, KeyOf key_of=KeyOf()) |
Creates a map of indices from an existing collection. More... | |
template<typename Coll , typename KeyOf > | |
auto | MakeMap (Coll const &data, KeyOf key_of=KeyOf()) -> std::vector< decltype(key_of(*(data.begin()))) const * > |
Creates a map of objects from an existing collection. More... | |
template<typename Range > | |
auto | wrapRangeFor (Range &&range) -> decltype(auto) |
Wraps an object for use in a range-for loop. More... | |
template<typename Range > | |
auto | operator| (Range &&range, RangeForWrapperTag) -> decltype(auto) |
Transforms a range so that it can be used in a range-for loop. More... | |
template<unsigned int RANK1, unsigned int RANK2, typename = std::enable_if_t<(RANK1 != RANK2), bool>> | |
bool | operator== (TensorIndices< RANK1 > const &a, TensorIndices< RANK2 > const &b) |
Comparison operator with tensors of different rank. More... | |
template<unsigned int RANK1, unsigned int RANK2, typename = std::enable_if_t<(RANK1 != RANK2), bool>> | |
bool | operator!= (TensorIndices< RANK1 > const &a, TensorIndices< RANK2 > const &b) |
Comparison operator with tensors of different rank. More... | |
template<typename... DIMS> | |
auto | makeTensorIndices (DIMS...dims) |
Instantiates a TensorIndices class with the specified dimensions. More... | |
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple > | |
auto | getByExtractedType (Tuple const &data) -> decltype(auto) |
Returns the value of the element containing the specified type. More... | |
template<typename Tag , typename T > | |
auto | makeTagged (T &obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tag , typename T > | |
auto | makeTagged (T const &obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tag , typename T > | |
auto | makeTagged (T const &&obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tag , typename T > | |
auto | makeTagged (T &&obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tagged > | |
auto | removeTag (Tagged &tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tagged > | |
auto | removeTag (Tagged const &tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tagged > | |
auto | removeTag (Tagged const &&tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tagged > | |
auto | removeTag (Tagged &&tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tag , typename Tuple > | |
auto | getByTag (Tuple const &data) -> decltype(auto) |
Returns the object with the specified tag. More... | |
template<typename Cont , typename Mapping > | |
auto | mapContainer (Cont cont, Mapping mapping) |
Returns a container-like object mapping the content of cont . More... | |
template<typename Cont , typename Mapping , typename Container , typename Reference > | |
MappedContainer< Cont, Mapping >::template IteratorBase< Container, Reference > | operator+ (typename MappedContainer< Cont, Mapping >::template IteratorBase< Container, Reference >::difference_type n, typename MappedContainer< Cont, Mapping >::template IteratorBase< Container, Reference > const &it) |
template<typename _Key , typename _Tp , typename _Compare > | |
bool | operator== (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y) |
template<typename _Key , typename _Tp , typename _Compare > | |
bool | operator< (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y) |
template<typename _Key , typename _Tp , typename _Compare > | |
bool | operator!= (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y) |
Based on operator==. More... | |
template<typename _Key , typename _Tp , typename _Compare > | |
bool | operator> (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y) |
Based on operator<. More... | |
template<typename _Key , typename _Tp , typename _Compare > | |
bool | operator<= (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y) |
Based on operator<. More... | |
template<typename _Key , typename _Tp , typename _Compare > | |
bool | operator>= (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y) |
Based on operator<. More... | |
template<typename _Key , typename _Tp , typename _Compare > | |
void | swap (VectorMap< _Key, _Tp, _Compare > &__x, VectorMap< _Key, _Tp, _Compare > &__y) |
See VectorMap::swap(). More... | |
std::ostream & | operator<< (std::ostream &out, EventChangeTracker_t const &trk) |
std::ostream & | operator<< (std::ostream &out, DataProductChangeTracker_t const &trk) |
std::ostream & | operator<< (std::ostream &out, PlaneDataChangeTracker_t const &trk) |
template<typename PRODUCER , typename T , typename U , typename D > | |
bool | CreateAssnD (PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data) |
Creates a single one-to-one association with associated data. More... | |
template<typename PRODUCER , typename T , typename U , typename D > | |
bool | CreateAssnD (PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t const &data) |
Counted iterations | |
template<typename T > | |
auto | counter (T begin, T end) |
Returns an object to iterate values from begin to end in a range-for loop. More... | |
template<typename T > | |
auto | counter (T end) |
template<typename T = std::size_t> | |
auto | infinite_counter (T begin=T{}) |
Version of util::counter() starting at begin and never ending. More... | |
Enumerated iterations | |
template<std::size_t Lead, typename... Iterables> | |
auto | enumerate (Iterables &&...iterables) |
Range-for loop helper tracking the number of iteration. More... | |
template<typename... Iterables> | |
auto | enumerate (Iterables &&...iterables) |
This version of enumerate implicitly uses the first iterable as lead. More... | |
Transformed iterations | |
template<std::size_t... Indices, typename Coll > | |
decltype(auto) | get_elements (Coll &&coll) |
Range-for loop helper iterating across some of the element of each value in the specified collection. More... | |
template<std::size_t... Indices, typename Coll > | |
decltype(auto) | get_const_elements (Coll &&coll) |
Range-for loop helper iterating across the constant values of the specified collection. More... | |
template<typename Coll > | |
decltype(auto) | values (Coll &&coll) |
Range-for loop helper iterating across the values of the specified collection. More... | |
template<typename Coll > | |
decltype(auto) | const_values (Coll &&coll) |
Range-for loop helper iterating across the constant values of the specified collection. More... | |
template<typename T > | |
void | staticDumpClassName () |
Helper to determine the type of a variable at compilation time. More... | |
template<typename T > | |
void | staticDumpClassName (T) |
template<typename A , typename B > | |
constexpr auto | absDiff (A const &a, B const &b) |
Returns the absolute value of the difference between two values. More... | |
Span helper functions | |
template<typename BIter , typename EIter > | |
auto | make_span (BIter begin, EIter end) |
Creates a span from specified iterators (can use constructor instead). More... | |
template<typename Cont > | |
auto | make_span (Cont &cont) |
Creates a span from a container type. More... | |
template<typename Cont > | |
auto | make_const_span (Cont &cont) |
Creates a span with constant iterator access from a container type. More... | |
Adapted span helper functions | |
template<typename BIter , typename EIter , typename Adaptor > | |
auto | make_adapted_span (BIter begin, EIter end, Adaptor &&adaptor) |
template<typename Cont , typename Adaptor > | |
auto | make_adapted_span (Cont &cont, Adaptor &&adaptor) |
Creates a span from specified collection via an adaptor. More... | |
template<typename Cont , typename Adaptor > | |
auto | make_adapted_const_span (Cont &cont, Adaptor &&adaptor) |
Creates constant iteration span from specified collection via an adaptor. More... | |
Transformed span helper functions | |
template<typename BIter , typename EIter , typename Op > | |
auto | make_transformed_span (BIter begin, EIter end, Op &&op) |
template<typename Cont , typename Op > | |
auto | make_transformed_span (Cont &cont, Op &&op) |
Creates a span from specified collection via an adaptor. More... | |
template<typename Cont , typename Op > | |
auto | make_transformed_const_span (Cont &cont, Op &&op) |
C++ standard library customization for user-defined classes. | |
template<typename T > | |
decltype(auto) constexpr | to_string (T &&obj) |
ADL-aware version of std::to_string . More... | |
template<typename T > | |
decltype(auto) constexpr | begin (T &&obj) |
ADL-aware version of std::begin . More... | |
template<typename T > | |
decltype(auto) constexpr | end (T &&obj) |
ADL-aware version of std::end . More... | |
template<typename T > | |
decltype(auto) constexpr | cbegin (T &&obj) |
ADL-aware version of std::cbegin . More... | |
template<typename T > | |
decltype(auto) constexpr | cend (T &&obj) |
ADL-aware version of std::cend . More... | |
template<typename T > | |
decltype(auto) constexpr | size (T &&obj) |
ADL-aware version of std::size . More... | |
template<typename T > | |
decltype(auto) constexpr | empty (T &&obj) |
ADL-aware version of std::empty . More... | |
template<std::size_t I, typename T > | |
decltype(auto) | get (T &&obj) |
Parallel iterations | |
template<std::size_t Lead, typename... Iterables> | |
auto | zip (Iterables &&...iterables) |
Range-for loop helper iterating across many collections at the same time. More... | |
template<typename... Iterables> | |
auto | zip (Iterables &&...iterables) |
Version of zip() with first iterator implicitly leading the iteration. More... | |
template<typename T , typename U , typename D > | |
bool | CreateAssnD (art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data) |
Creates a single one-to-one association with associated data. More... | |
template<typename T , typename U , typename D > | |
bool | CreateAssnD (art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t const &data) |
simple mathematical functions | |
template<typename T > | |
constexpr auto | abs (T v) |
Returns the absolute value of the argument. More... | |
Variables | |
template<typename > | |
constexpr bool | always_false_v = false |
A templated constant, always false. More... | |
template<typename > | |
constexpr bool | always_true_v = true |
A template constant always true. More... | |
template<typename T , std::size_t StartFrom, typename... Types> | |
constexpr std::size_t | find_next_type_v = find_next_type<T, StartFrom, Types...>::value |
template<typename T , typename... Types> | |
constexpr std::size_t | find_type_v = find_type<T, Types...>::value |
template<typename T , typename... Types> | |
constexpr bool | is_any_of_v = is_any_of<T, Types...>::value |
Whether T is among the specified Types (see util::is_any_of ). More... | |
template<typename T , typename U > | |
constexpr auto | is_same_decay_v = std::is_same_v<std::decay_t<T>, std::decay_t<U>> |
Whether T and U are the same type, after being applied std::decay . More... | |
template<template< typename... > typename Template, typename T > | |
constexpr bool | is_instance_of_v = is_instance_of<Template, T>::value |
template<typename T > | |
constexpr bool | is_STLarray_v = is_STLarray<T>::value |
A constant describing whether the specified type is a STL array. More... | |
template<typename T > | |
constexpr bool | is_reference_wrapper_v = is_reference_wrapper<T>::value |
A constant describing whether the specified type is a std::reference_wrapper . More... | |
template<typename T > | |
constexpr bool | is_unique_ptr_v = is_unique_ptr<T>::value |
A constant describing whether the specified type is a std::unique_ptr . More... | |
template<typename T > | |
constexpr bool | is_character_type_v = is_character_type<T>::value |
Whether type T is a character type (see util::is_character_type ). More... | |
template<typename T > | |
constexpr bool | is_string_type_v = is_string_type<T>::value |
Whether type T is a character string type (see util::is_string_type ). More... | |
template<typename T > | |
constexpr bool | is_basic_string_type_v = is_basic_string_type<T>::value |
template<typename T > | |
constexpr bool | is_basic_string_view_type_v = is_basic_string_view_type<T>::value |
constexpr double | kGeVToElectrons = 4.237e7 |
23.6eV per ion pair, 1e9 eV/GeV More... | |
constexpr double | kc = 29.9792458 |
Speed of light in vacuum in LArSoft units [cm/ns]. More... | |
constexpr double | kMeterToCentimeter = 1.e2 |
1 m = 100 cm More... | |
constexpr double | kCentimeterToMeter = 1./kMeterToCentimeter |
constexpr double | kMeterToKilometer = 1.e-3 |
1000 m = 1 km More... | |
constexpr double | kKilometerToMeter = 1./kMeterToKilometer |
constexpr double | keVToMeV = 1.e-6 |
1e6 eV = 1 MeV More... | |
constexpr double | kMeVToeV = 1./keVToMeV |
constexpr double | kBogusD = -999. |
obviously bogus double value More... | |
constexpr int | kBogusI = -999 |
obviously bogus integer value More... | |
constexpr float | kBogusF = -999. |
obviously bogus float value More... | |
constexpr double | quietCompiler = kBogusD*kBogusI*kBogusF*kRecombA*kRecombk*kGeVToElectrons |
constexpr double | kINVALID_DOUBLE = std::numeric_limits<Double_t>::max() |
constexpr RangeForWrapperTag | range_for |
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple > | |
constexpr std::size_t | index_of_extracted_type_v = index_of_extracted_type<Extractor, Target, Tuple>() |
Direct access to the value in index_of_extracted_type . More... | |
template<typename Target , typename Tuple > | |
constexpr std::size_t | index_of_type_v = index_of_type<Target, Tuple>() |
Direct access to the value in index_of_type . More... | |
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple > | |
constexpr bool | has_extracted_type_v = has_extracted_type<Extractor, Target, Tuple>() |
Direct access to the value in has_extracted_type . More... | |
template<typename Target , typename Tuple > | |
constexpr bool | has_type_v = has_type<Target, Tuple>() |
Direct access to the value in has_type . More... | |
template<template< typename T, typename... > class Extractor, typename Tuple > | |
constexpr bool | has_duplicate_extracted_types_v = has_duplicate_extracted_types<Extractor, Tuple>() |
Direct access to the value in has_duplicate_extracted_types . More... | |
template<typename Tuple > | |
constexpr bool | has_duplicate_types_v = has_duplicate_types<Tuple>() |
Direct access to the value in has_duplicate_types . More... | |
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple > | |
constexpr unsigned int | count_extracted_types_v = count_extracted_types<Extractor, Target, Tuple>() |
Direct access to the value in count_extracted_types . More... | |
template<typename Target , typename Tuple > | |
constexpr unsigned int | count_types_v = count_types<Target, Tuple>() |
Direct access to the value in count_extracted_types . More... | |
template<typename Tag , typename Tuple > | |
constexpr std::size_t | index_of_tag_v = index_of_tag<Tag, Tuple>() |
Direct access to the value in index_of_tag . More... | |
template<typename Tag , typename Tuple > | |
constexpr bool | has_tag_v = has_tag<Tag, Tuple>() |
Direct access to the value in has_tag . More... | |
template<typename Tag , typename Tuple > | |
constexpr unsigned int | count_tags_v = count_tags<Tag, Tuple>() |
Direct access to the value in count_tags . More... | |
template<typename Tuple > | |
constexpr bool | has_duplicate_tags_v = has_duplicate_tags<Tuple>() |
Direct access to the value in has_duplicate_tags . More... | |
const float | SQRT_TWO_PI = 2.506628 |
Recombination factor coefficients (NIM). | |
Recombination factor coefficients come from Nucl.Instrum.Meth.A523:275-286,2004
| |
constexpr double | kRecombA = 0.800 |
A constant. More... | |
constexpr double | kRecombk = 0.0486 |
Recombination factor coefficients (modified box, ArguNeuT JINST). | |
Recombination factor coefficients come from Nucl.Instrum.Meth.A523:275-286,2004
| |
constexpr double | kModBoxA = 0.930 |
Modified Box Alpha. More... | |
constexpr double | kModBoxB = 0.212 |
Modified Box Beta in g/(MeV cm²)*kV/cm. More... | |
template<typename Target , typename... T> | |
using | count_type_in_list = details::count_type_in_list_impl< Target, T... > |
Returns how many of the types in T exactly match Target . More... | |
template<std::size_t N, typename... T> | |
using | typelist_element_type = std::tuple_element< N, std::tuple< T... >> |
Returns the N type of the type list. More... | |
template<std::size_t N, typename... T> | |
using | typelist_element_t = typename typelist_element_type< N, T... >::type |
Direct access to the value in typelist_element_type . More... | |
template<typename Target , typename... T> | |
using | type_is_in = details::type_is_in_impl< Target, T... > |
Holds whether the Target type is among the ones in the T pack. More... | |
template<typename Target , typename... T> | |
constexpr unsigned int | count_type_in_list_v = count_type_in_list<Target, T...>() |
Direct access to the value in count_type_in_list . More... | |
template<typename Target , typename... T> | |
constexpr bool | type_is_in_v = type_is_in<Target, T...>() |
Direct access to the value in type_is_in . More... | |
Namespace for general, non-LArSoft-specific utilities.
Namespace for general, not LArSoft-specific utilities.
General LArSoft Utilities.
Generic namespace of utility functions generally independent of LArSoft.
Some physical constants are also included here. As a reminder, the "standard" units in LArSoft are:
SumSecondFunction 28-Jul-2009 William Seligman selig When using STL, maps, and the std::accumulate function, there's one function I keep coding over and over again: accumulate the second member of a pair. man@ nevis .col umbia .edu
To save myself time (and others who know and use STL), here's a complete STL-compatible implementation of that function. To use it, assume you have an object:
std::map<K,V> myMap;
To sum all the V's in the map:
V sum = std::accumulate( myMap.begin(),myMap.end(),V(),SumSecondFunction<K,V>() );
(Yes, I know there are other, better ways to do this, if one has access to BOOST. Unfortunately, we're not supposed to use BOOST in LArSoft, since as of Jul-2009 it's not universally installed on FNAL machines.)
VectorMap 17-Apr-2008 William Seligman selig man@ nevis .col umbia .edu
This class is an implementation of a concept discussion in "Effective STL" by Scott Meyers:
STL maps are useful because their contents are always sorted, so they're effective for fast searches. However, in almost every other respect vectors are superior: They take up less space, and they use random-access iterators.
This class implements "sorted vector maps," that is, an STL-style map implemented as a sorted STL vector of pairs. I've done my best to implement all aspects of the std::map interface in this class, with some additions; if you've defined the following:
VectorMap<key_type, data_type> svm;
INCREDIBLY IMPORTANT NOTE: The "key type" of a VectorMap cannot be a "const" type (unlike maps); it won't even compile. When you do an insert, the underlying vector has to move things around within its list, and it uses the assignment operator=() (or "vector{i+1)=vector(i)" if you like). You can't do that if either the key or the data is const.
As with a map, there's no way to insert items at a specific location in a VectorMap. The insertion methods (including operator[]) all operate on a sorted sequence according to the key. Because of this, insertions take a long time.
However, for our processing, this doesn't matter much; for almost all our maps, we typically have:
For this usage, a sorted vector is generally superior to a map.
This class just implements the equivalent of an STL map, not a multimap, set, nor a multiset. If there's a need, I may create additional classes.
Is there any map feature that's not implemented? Yes:
Advanced implementation note: Depending on the application, it might be possible to speed up this class by using "lazy evaluation"; that is, we wouldn't actually sort the vector until the user actually tries to access its contents. I'm not going to do this, because:
A) I don't think my programming skills are up to the task.
B) In the primary application for which I plan to use this class (Monte-Carlo particle tracks), we're performing at least one search after every insert; lazy evaluation wouldn't be much of a speed improvement.
Feb-2011 WGS: VectorMap mostly looks like a map, but there are some memory-management issues that relate to it being a vector. Include the vector-based routines reserve() and capacity().
Title: GaussianEliminationAlg Class Author: Wes Ketchum (wketc) hum@ lanl. gov
Description: Class that solves system of linear equations via Gaussian Elimination. Intended for use with RFFHitFitter
using util::GridContainer2D = typedef GridContainerBase2D<DATUM, GridContainer2DIndices> |
Container allowing 2D indexing.
DATUM | type of contained data |
This is an alias for GridContainerBase2D, with a proper index manager. See the documentation of GridContainerBase2D.
Definition at line 267 of file GridContainers.h.
using util::GridContainer2DIndices = typedef GridContainerIndicesBase2D<> |
Index manager for a container of data arranged on a 2D grid.
Definition at line 181 of file GridContainerIndices.h.
using util::GridContainer3D = typedef GridContainerBase3D<DATUM, GridContainer3DIndices> |
Container allowing 3D indexing.
DATUM | type of contained data |
This is an alias for GridContainerBase3D, with a proper index manager. See the documentation of GridContainerBase3D.
Definition at line 279 of file GridContainers.h.
using util::GridContainer3DIndices = typedef GridContainerIndicesBase3D<> |
Index manager for a container of data arranged on a 3D grid.
Definition at line 184 of file GridContainerIndices.h.
using util::MatrixIndices = typedef TensorIndices<2U> |
Type for indexing a 2D-tensor (matrix)
Definition at line 551 of file TensorIndices.h.
typedef std::map< UBDaqID, UBLArSoftCh_t > util::UBChannelMap_t |
Definition at line 48 of file DatabaseUtil.h.
typedef std::map< UBLArSoftCh_t, UBDaqID > util::UBChannelReverseMap_t |
Definition at line 49 of file DatabaseUtil.h.
typedef int util::UBLArSoftCh_t |
Definition at line 46 of file DatabaseUtil.h.
constexpr auto util::abs | ( | T | v | ) |
Returns the absolute value of the argument.
T | type of the argument |
v | value to be processed |
If the value v
is negative, its opposite is returned. Note that this implementation does not work with data types that are not comparable (like std::complex
).
T
value from the literal 0
operator- (T) constexpr
operator< (T, T) constexpr
convertible to bool
Definition at line 40 of file constexpr_math.h.
Returns the absolute value of the difference between two values.
a | the first value |
b | the second value |
a
and b
The pecularity of this implementation is that it always avoids taking the difference between the smallest and the largest of a
and b
. An equivalent implementation is:
It still assumes that the difference is representable in A
; for example, this assumption will fail for int
types with a
a very large number and b
a very small (i.e. negative) number.
Requirements:
Definition at line 43 of file NumericUtils.h.
auto util::associated_groups | ( | A const & | assns | ) |
Helper functions to access associations in order.
A | type of association being read |
assns | the association being read |
This function provides a functionality equivalent to art::for_each_group()
, but it grants the caller additional control on the external loop and on the function.
Example: assuming that a module with input tag stored in fTrackTag
has created associations of each track to its hits, the total charge for each track can be extracted by:
A number of important points need to be realised about this example:
art::for_each_group()
hits
is an object representing a range of art pointers (art::Ptr<recob::Hit>
) which can be navigated with the begin()
/end()
free functions, or in a range-for loop;util::associated_groups_with_left()
instead. Definition at line 94 of file ForEachAssociatedGroup.h.
auto util::associated_groups_with_left | ( | A const & | assns | ) |
Helper functions to access associations in order, also with key.
A | type of association being read |
assns | the association being read |
This function provides a functionality equivalent to art::for_each_group_with_left()
, but it grants the caller additional control on the external loop and on the function.
Example: assuming that a module with input tag stored in fTrackTag
has created associations of each track to its hits, the total charge for each track can be extracted by:
A number of important points need to be realised about this example:
art::for_each_group_with_left()
hits
is an object representing a range of art pointers (art::Ptr<recob::Hit>
) which can be navigated with the begin()
/end()
free functions, or in a range-for loop. Definition at line 152 of file ForEachAssociatedGroup.h.
decltype(auto) util::const_values | ( | Coll && | coll | ) |
Range-for loop helper iterating across the constant values of the specified collection.
util::values()
This function is equivalent to util::values()
but the values are extracted as if the specified collection were constant.
auto util::counter | ( | T | begin, |
T | end | ||
) |
Returns an object to iterate values from begin
to end
in a range-for loop.
T | type of counter value |
util::count_iterator
An example of usage:
will insert in data
the numbers from 4
to 7
, just like:
would.
Definition at line 285 of file counter.h.
auto util::counter | ( | T | end | ) |
Version of util::counter()
starting at default-constructed T
(usually some form of 0
).
Definition at line 184 of file counter.h.
bool util::CreateAssn | ( | art::Event & | evt, |
std::vector< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
art::Assns< U, T > & | assn, | ||
std::string | a_instance, | ||
size_t | index = UINT_MAX |
||
) |
Creates a single one-to-one association.
T | type of the new object to associate |
U | type of the object already in the data product or art::Ptr |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::Ptr to the (new) object to be associated to the one in a |
assn | reference to association object where the new one will be put |
a_instance | name of the instance that will be used for a in evt |
index | index of the element in a to be associated with b (default: the last element) |
As example of usage: create a wire/raw digit association. This code should live in the art::EDProduce::produce() method. The raw::RawDigit product was created already by a DigitModuleLabel module. The code is supposed to produce one recob::Wire for each existing raw::RawDigit, and contextually associate the new wire to the source digit. We are also assuming that there might be different RawDigit sets produced by the same producer: we identify the one we care of by the string spill_name and we create wires and associations with the same label for convenience.
// this is the original list of digits, thawed from the event art::Handle< std::vector<raw::RawDigit>> digitVecHandle; evt.getByLabel(DigitModuleLabel, spill_name, digitVecHandle); // the collection of wires that will be written as data product std::unique_ptr<std::vector<recob::Wire>> wirecol(new std::vector<recob::Wire>); // ... and an association set std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire>> WireDigitAssn (new art::Assns<raw::RawDigit,recob::Wire>); for(size_t iDigit = 0; iDigit < digitVecHandle->size(); ++iDigit) { // turn the digit into a art::Ptr: art::Ptr<raw::RawDigit> digit_ptr(digitVecHandle, iDigit); // store the wire in its final position in the data product; // the new wire is currently the last of the list wirecol->push_back(std::move(wire)); // add an association between the last object in wirecol // (that we just inserted) and digit_ptr if (!util::CreateAssn(*this, evt, *wirecol, digit_ptr, *WireDigitAssn, spill_name)) { throw art::Exception(art::errors::ProductRegistrationFailure) << "Can't associate wire #" << (wirecol->size() - 1) << " with raw digit #" << digit_ptr.key(); } // if failed to add association } // for digits evt.put(std::move(wirecol), spill_name); evt.put(std::move(WireDigitAssn), spill_name);
Definition at line 581 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
art::Assns< U, T > & | assn, | ||
std::string | a_instance, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-one association.
T | type of the new object to associate |
U | type of the object already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::Ptr to the (new) object to be associated to the one in a |
assn | reference to association object where the new one will be put |
a_instance | name of the instance that will be used for a in evt |
indx | index of the element in a to be associated with b (default: the last element) |
As example of usage: create a wire/raw digit association. This code should live in the art::EDProduce::produce() method. The raw::RawDigit product was created already by a DigitModuleLabel module. The code is supposed to produce one recob::Wire for each existing raw::RawDigit, and contextually associate the new wire to the source digit. We are also assuming that there might be different RawDigit sets produced by the same producer: we identify the one we care of by the string spill_name and we create wires and associations with the same label for convenience.
// this is the original list of digits, thawed from the event art::InputTag itag(DigitModuleLabel, spill_name); auto digitVecHandle = evt.getHandle< std::vector<raw::RawDigit>>(itag); // the collection of wires that will be written as data product std::unique_ptr<std::vector<recob::Wire>> wirecol(new std::vector<recob::Wire>); // ... and an association set std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire>> WireDigitAssn (new art::Assns<raw::RawDigit,recob::Wire>); for(size_t iDigit = 0; iDigit < digitVecHandle->size(); ++iDigit) { // turn the digit into a art::Ptr: art::Ptr<raw::RawDigit> digit_ptr(digitVecHandle, iDigit); // store the wire in its final position in the data product; // the new wire is currently the last of the list wirecol->push_back(std::move(wire)); // add an association between the last object in wirecol // (that we just inserted) and digit_ptr if (!util::CreateAssn(*this, evt, *wirecol, digit_ptr, *WireDigitAssn, spill_name)) { throw art::Exception(art::errors::ProductRegistrationFailure) << "Can't associate wire #" << (wirecol->size() - 1) << " with raw digit #" << digit_ptr.key(); } // if failed to add association } // for digits evt.put(std::move(wirecol), spill_name); evt.put(std::move(WireDigitAssn), spill_name);
Definition at line 601 of file AssociationUtil.h.
|
inline |
Creates a single one-to-one association.
T | type of the new object to associate |
U | type of the object already in the data product or art::Ptr |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::Ptr to the (new) object to be associated to the one in a |
assn | reference to association object where the new one will be put |
index | index of the element in a to be associated with b (default: the last element) |
The instance name of the product a will be in is assumed empty. Example of usage:
// this is the original list of digits, thawed from the event art::Handle< std::vector<raw::RawDigit>> digitVecHandle; evt.getByLabel(DigitModuleLabel, digitVecHandle); // the collection of wires that will be written as data product std::unique_ptr<std::vector<recob::Wire>> wirecol(new std::vector<recob::Wire>); // ... and an association set std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire>> WireDigitAssn (new art::Assns<raw::RawDigit,recob::Wire>); for(size_t iDigit = 0; iDigit < digitVecHandle->size(); ++iDigit) { // turn the digit into a art::Ptr: art::Ptr<raw::RawDigit> digit_ptr(digitVecHandle, iDigit); // store the wire in its final position in the data product; // the new wire is currently the last of the list wirecol->push_back(std::move(wire)); // add an association between the last object in wirecol // (that we just inserted) and digit_ptr if (!util::CreateAssn(*this, evt, *wirecol, digit_ptr, *WireDigitAssn)) { throw art::Exception(art::errors::ProductRegistrationFailure) << "Can't associate wire #" << (wirecol->size() - 1) << " with raw digit #" << digit_ptr.key(); } // if failed to add association } // for digits evt.put(std::move(wirecol)); evt.put(std::move(WireDigitAssn));
Definition at line 209 of file AssociationUtil.h.
|
inline |
Creates a single one-to-one association.
T | type of the new object to associate |
U | type of the object already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::Ptr to the (new) object to be associated to the one in a |
assn | reference to association object where the new one will be put |
indx | index of the element in a to be associated with b (default: the last element) |
The instance name of the product a will be in is assumed empty. Example of usage:
// this is the original list of digits, thawed from the event auto digitVecHandle = evt.getHandle< std::vector<raw::RawDigit>>(DigitModuleLabel); // the collection of wires that will be written as data product std::unique_ptr<std::vector<recob::Wire>> wirecol(new std::vector<recob::Wire>); // ... and an association set std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire>> WireDigitAssn (new art::Assns<raw::RawDigit,recob::Wire>); for(size_t iDigit = 0; iDigit < digitVecHandle->size(); ++iDigit) { // turn the digit into a art::Ptr: art::Ptr<raw::RawDigit> digit_ptr(digitVecHandle, iDigit); // store the wire in its final position in the data product; // the new wire is currently the last of the list wirecol->push_back(std::move(wire)); // add an association between the last object in wirecol // (that we just inserted) and digit_ptr if (!util::CreateAssn(*this, evt, *wirecol, digit_ptr, *WireDigitAssn)) { throw art::Exception(art::errors::ProductRegistrationFailure) << "Can't associate wire #" << (wirecol->size() - 1) << " with raw digit #" << digit_ptr.key(); } // if failed to add association } // for digits evt.put(std::move(wirecol)); evt.put(std::move(WireDigitAssn));
Definition at line 211 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
art::Ptr< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
art::Assns< U, T > & | assn | ||
) |
Creates a single one-to-one association.
T | type of one object to associate |
U | type of the other object to associate |
evt | reference to the current event |
a | art::Ptr to the first object in the association |
b | art::Ptr to the object to be associated to the one in a |
assn | reference to association object where the new one will be put |
This is the simplest way ever. Neither the event not the producer references are used.
Definition at line 608 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Ptr< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
art::Assns< U, T > & | assn | ||
) |
Creates a single one-to-one association.
T | type of one object to associate |
U | type of the other object to associate |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | art::Ptr to the first object in the association |
b | art::Ptr to the object to be associated to the one in a |
assn | reference to association object where the new one will be put |
This is the simplest way ever. Neither the event not the producer references are used.
Definition at line 633 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
std::vector< T > const & | a, | ||
art::PtrVector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | index = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::PtrVector to the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
index | index of the element in a to be associated with all the ones in b (default: the last element) |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 631 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
art::PtrVector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | art::PtrVector to the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 657 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
art::Ptr< T > const & | a, | ||
std::vector< art::Ptr< U >> const & | b, | ||
art::Assns< T, U > & | assn | ||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
evt | reference to the current event |
a | art::Ptr to the item to be associated with many |
b | vector to art::Ptr to the (new) objects to be associated to a |
assn | reference to association object where the new one will be put |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 656 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Ptr< T > const & | a, | ||
std::vector< art::Ptr< U >> const & | b, | ||
art::Assns< T, U > & | assn | ||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | art::Ptr to the item to be associated with many |
b | vector to art::Ptr to the (new) objects to be associated to a |
assn | reference to association object where the new one will be put |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 684 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
std::vector< T > const & | a, | ||
std::vector< art::Ptr< U >> const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | index = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector to art::Ptr to the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
index | index of the element in a to be associated with all the ones in b (default: the last element) |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 678 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
std::vector< art::Ptr< U >> const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector to art::Ptr to the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 707 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
std::vector< T > const & | a, | ||
std::vector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | startU, | ||
size_t | endU, | ||
size_t | index = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector of the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
startU | index in b of the first element to be associated to the one in a |
endU | index in b after the last element to be associated to the one in a |
index | index of the element in a to be associated with all the ones in b (default: the last element) |
Use this when the objects in b are not yet stored in the event and are in a std::vector collection instead.
The method gets the product id for those as well as for the element in a. Also specify the range of entries to use from the std::vector collection of U objects.
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 704 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
std::vector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
size_t | startU, | ||
size_t | endU, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector of the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
startU | index in b of the first element to be associated to the one in a |
endU | index in b after the last element to be associated to the one in a |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
Use this when the objects in b are not yet stored in the event and are in a std::vector collection instead.
The method gets the product id for those as well as for the element in a. Also specify the range of entries to use from the std::vector collection of U objects.
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 735 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
std::vector< T > const & | a, | ||
std::vector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
std::vector< size_t > const & | indices, | ||
size_t | index = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector of the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indices | indices of the elements in b to be associated to the one in a |
index | index of the element in a to be associated with all the ones in b (default: the last element) |
Use this when the objects in b are not yet stored in the event and are in a std::vector collection instead.
The method gets the product id for those as well as for the element in a. Also specify the entries to use from the std::vector collection of U objects.
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 735 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
std::vector< U > const & | b, | ||
art::Assns< T, U > & | assn, | ||
std::vector< size_t > const & | indices, | ||
size_t | indx = UINT_MAX |
||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
a | vector of data products that are in, or will be put into, evt |
b | vector of the (new) objects to be associated to the one in a |
assn | reference to association object where the new one will be put |
indices | indices of the elements in b to be associated to the one in a |
indx | index of the element in a to be associated with all the ones in b (default: the last element) |
Use this when the objects in b are not yet stored in the event and are in a std::vector collection instead.
The method gets the product id for those as well as for the element in a. Also specify the entries to use from the std::vector collection of U objects.
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Definition at line 772 of file AssociationUtil.h.
bool util::CreateAssn | ( | art::Event & | evt, |
art::Assns< T, U > & | assn, | ||
size_t | first_index, | ||
Iter | from_second_index, | ||
Iter | to_second_index | ||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
Iter | iterator to size_t-compatible elements |
evt | reference to the current event |
assn | reference to association object where the new one will be put |
first_index | index of the object of type T to be associated to all the others |
from_second_index | iterator pointing to the first of the indices of U type objects to be associated to the one of the first type |
to_second_index | iterator pointing after the last of the indices of U type objects to be associated to the one of the first type |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Use this if the objects that have to be associated to the one of type T are sparse, spread across a to-be-data-product, but you have a list of the indices in the data product of the elements to associate to the one of type T. In other words, given that you have a data product "a" of type std::vector<T>
and a data product "b" of type std::vector<U>
, this method creates an association between
a[first_index]and
b[*(from_second_index)], another between a[first_index]
and b[*(from_second_index + 1)]
, etc.
The surprising concept here is that you don't need to specify neither of the collections of T or U elements. The data product is uniquely defined by its type, producer, process and product label. Here we assume that the type of the products are std::vector<T>
and std::vector<U>
, and that the products have empty product labels, and that the producer is prod for both of them.
Definition at line 765 of file AssociationUtil.h.
bool util::CreateAssn | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Assns< T, U > & | assn, | ||
size_t | first_index, | ||
Iter | from_second_index, | ||
Iter | to_second_index | ||
) |
Creates a single one-to-many association.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
Iter | iterator to size_t-compatible elements |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
assn | reference to association object where the new one will be put |
first_index | index of the object of type T to be associated to all the others |
from_second_index | iterator pointing to the first of the indices of U type objects to be associated to the one of the first type |
to_second_index | iterator pointing after the last of the indices of U type objects to be associated to the one of the first type |
A "one-to-many" association is actually a number of one-to-one associations. If you want to keep the information of the order of the many, you may have to use an association with a data member (the third template parameter that we pretent not to exist).
Use this if the objects that have to be associated to the one of type T are sparse, spread across a to-be-data-product, but you have a list of the indices in the data product of the elements to associate to the one of type T. In other words, given that you have a data product "a" of type std::vector<T>
and a data product "b" of type std::vector<U>
, this method creates an association between
a[first_index]and
b[*(from_second_index)], another between a[first_index]
and b[*(from_second_index + 1)]
, etc.
The surprising concept here is that you don't need to specify neither of the collections of T or U elements. The data product is uniquely defined by its type, producer, process and product label. Here we assume that the type of the products are std::vector<T>
and std::vector<U>
, and that the products have empty product labels, and that the producer is prod for both of them.
Definition at line 806 of file AssociationUtil.h.
std::enable_if_t<std::is_base_of_v<art::EDProducer, Producer>, bool> util::CreateAssn | ( | Producer const & | , |
Args &&... | args | ||
) |
Definition at line 968 of file AssociationUtil.h.
bool util::CreateAssnD | ( | art::Event & | evt, |
art::Assns< T, U, D > & | assn, | ||
size_t | first_index, | ||
size_t | second_index, | ||
typename art::Assns< T, U, D >::data_t && | data | ||
) |
Creates a single one-to-one association with associated data.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
D | type of the "metadata" coupled to this pair association |
evt | reference to the current event |
assn | reference to association object where the new one will be put |
first_index | index of the object of type T to be associated |
second_index | index of the object of type U to be associated |
data | "metadata" to be store in this association |
Use this if you want some metadata to travel together with the association. An example may be the order of the second element within a list:
size_t a_index = 2; std::vector<size_t> b_indices{ 6, 9, 18, 12 }; for (size_t i = 0; i < b_indices.size(); ++i) CreateAssn(prod, evt, assn, a_index, b_index[i], i);
In this way, the association between the element #2 of "a" (a vector that is not specified – nor needed – in this snippet of code) and the element #18 will be remembered as being the third (metadata value of 2). In this example metadata is of type size_t
the association would be declared as art::Assn<A, B, size_t>
. A FindMany query of that association might look like:
art::Handle<std::vector<A>> a_list; // read this from the event art::FindMany<B, size_t> Query(a_list, event, ModuleLabel); // search for the last of the objects associated to the third element: size_t a_index = 2; // this means third element std::vector<size_t const*> const& metadata = Query.data(a_index); size_t largest_index = 0, last_item = 0; for (size_t iB = 0; iB < metadata.size(); ++iB) { if (largest_index >= *(metadata[iB])) continue; largest_index = *(metadata[iB]); last_item = iB; } // for iB B const& lastB = Query.at(last_item);
In alternative, the elements and their metadata can be fetched simultaneously with:
std::vector<art::Ptr<B>> const& Bs; std::vector<size_t const*> const& metadata; size_t a_index = 2; // this means third element size_t nMatches = Query.get(a_index, Bs, metadata);
Definition at line 799 of file AssociationUtil.h.
bool util::CreateAssnD | ( | art::Event & | evt, |
art::Assns< T, U, D > & | assn, | ||
size_t | first_index, | ||
size_t | second_index, | ||
typename art::Assns< T, U, D >::data_t const & | data | ||
) |
Definition at line 828 of file AssociationUtil.h.
bool util::CreateAssnD | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Assns< T, U, D > & | assn, | ||
size_t | first_index, | ||
size_t | second_index, | ||
typename art::Assns< T, U, D >::data_t && | data | ||
) |
Creates a single one-to-one association with associated data.
T | type of the new object to associate |
U | type of the many objects already in the data product or art::Ptr |
D | type of the "metadata" coupled to this pair association |
prod | reference to the producer that will write the vector a |
evt | reference to the current event |
assn | reference to association object where the new one will be put |
first_index | index of the object of type T to be associated |
second_index | index of the object of type U to be associated |
data | "metadata" to be store in this association |
Use this if you want some metadata to travel together with the association. An example may be the order of the second element within a list:
size_t a_index = 2; std::vector<size_t> b_indices{ 6, 9, 18, 12 }; for (size_t i = 0; i < b_indices.size(); ++i) CreateAssn(prod, evt, assn, a_index, b_index[i], i);
In this way, the association between the element #2 of "a" (a vector that is not specified – nor needed – in this snippet of code) and the element #18 will be remembered as being the third (metadata value of 2). In this example metadata is of type size_t
the association would be declared as art::Assn<A, B, size_t>
. A FindMany query of that association might look like:
art::Handle<std::vector<A>> a_list; // read this from the event art::FindMany<B, size_t> Query(a_list, event, ModuleLabel); // search for the last of the objects associated to the third element: size_t a_index = 2; // this means third element std::vector<size_t const*> const& metadata = Query.data(a_index); size_t largest_index = 0, last_item = 0; for (size_t iB = 0; iB < metadata.size(); ++iB) { if (largest_index >= *(metadata[iB])) continue; largest_index = *(metadata[iB]); last_item = iB; } // for iB B const& lastB = Query.at(last_item);
In alternative, the elements and their metadata can be fetched simultaneously with:
std::vector<art::Ptr<B>> const& Bs; std::vector<size_t const*> const& metadata; size_t a_index = 2; // this means third element size_t nMatches = Query.get(a_index, Bs, metadata);
Definition at line 850 of file AssociationUtil.h.
bool util::CreateAssnD | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
art::Assns< T, U, D > & | assn, | ||
size_t | first_index, | ||
size_t | second_index, | ||
typename art::Assns< T, U, D >::data_t const & | data | ||
) |
Definition at line 887 of file AssociationUtil.h.
bool util::CreateAssnD | ( | PRODUCER const & | prod, |
art::Event & | evt, | ||
std::vector< T > const & | a, | ||
art::Ptr< U > const & | b, | ||
typename art::Assns< U, T, D >::data_t const & | data, | ||
art::Assns< U, T, D > & | assn, | ||
size_t | indx = UINT_MAX |
||
) |
Definition at line 926 of file AssociationUtil.h.
std::enable_if_t<std::is_base_of_v<art::EDProducer, Producer>, bool> util::CreateAssnD | ( | Producer const & | , |
Args &&... | args | ||
) |
Definition at line 974 of file AssociationUtil.h.
|
inline |
Converts the argument angle from degrees into radians.
Definition at line 84 of file PhysicalConstants.h.
decltype(auto) util::dereference | ( | ) |
Returns a functor that returns *ptr
of its argument ptr
.
util::Dereferencer
will fill the vector values
with the values pointed by the elements in ptrs
.
Definition at line 125 of file operations.h.
void util::DumpAssociationsIntro | ( | Stream && | out, |
art::Assns< Left, Right, Data > const & | assns | ||
) |
Dumps a short introduction about specified association.
Stream | type of output stream |
Left | first type in the association |
Right | second type in the association |
Data | metadata type in the association |
out | output stream |
assns | the associations to be dumped |
Definition at line 33 of file DumpAssociations.h.
auto util::enumerate | ( | Iterables &&... | iterables | ) |
Range-for loop helper tracking the number of iteration.
Lead | index of the parameter driving the start and end of the loop |
Iterables | type of objects to be iterated together |
iterables | all iterable objects to be iterated together |
In the range-for loop, at each iteration this object yields a tuple
of values, each of the type returned by dereferencing begin(iterable)
. For example:
In this example, N
iterations will be run because that is the size of the first iterable given to enumerate
. If a different leading iterable is needed, that has to be specified as an argument. The following loop is completely equivalent to the former one:
(the index is zero-based, so 1U
refers to the second argument).
Definition at line 69 of file enumerate.h.
auto util::enumerate | ( | Iterables &&... | iterables | ) |
This version of enumerate
implicitly uses the first iterable as lead.
Definition at line 77 of file enumerate.h.
auto util::filterRangeFor | ( | Range && | range, |
Pred && | pred | ||
) | -> decltype(auto) |
Provides iteration only through elements passing a condition.
Range | the data to be iterated |
Pred | the type of the predicate to be fulfilled |
range | the data to be iterated through |
pred | the predicate to be tested |
This adapter makes the range for loop iterate only through the elements of range
which fulfil the predicate pred
.
This example will print: "0 3 6 9 ":
Note that pred
may be copied (range
will not be).
Range
is an object which can itself go through a range-for:
for (auto&& v: range);
is valid
Pred
is a copiable unary function type, whose single argument can be converted from the value type of Range
, and whose return value can be converted into a bool
vaule Definition at line 137 of file filterRangeFor.h.
|
inline |
Definition at line 953 of file AssociationUtil.h.
|
inline |
Definition at line 978 of file AssociationUtil.h.
void util::for_each_associated_group | ( | A const & | assns, |
F & | func | ||
) |
Helper functions to access associations in order.
A | type of association being read |
F | type of functor to be called on each associated group |
assns | the association being read |
func | functor to be called on each associated group |
art::for_each_group()
. Definition at line 49 of file ForEachAssociatedGroup.h.
decltype(auto) util::get_const_elements | ( | Coll && | coll | ) |
Range-for loop helper iterating across the constant values of the specified collection.
util::values()
This function is equivalent to util::values()
but the values are extracted as if the specified collection were constant.
decltype(auto) util::get_elements | ( | Coll && | coll | ) |
Range-for loop helper iterating across some of the element of each value in the specified collection.
Indices | indices of the elements to extract |
Coll | type of the collection to iterate through |
coll | the collection to iterate through |
util::get_const_elements()
This function enables range-for loops with a selection of elements from a container of tuple
(or anything responding to util::get()
).
The following example fills a map using as key the first element (0U
) of a tuple and as value the third element (2U
):
If only one index is specified, the loop will not use structured binding, but rather a simple variable:
While the examples do not demonstrate changing the values in the data
collection, that is also supported.
std::pair
(std::map
and the likes).
|
inline |
Definition at line 1022 of file AssociationUtil.h.
|
inline |
Definition at line 1031 of file AssociationUtil.h.
|
inline |
Definition at line 1004 of file AssociationUtil.h.
|
inline |
Definition at line 1013 of file AssociationUtil.h.
auto util::groupByIndex | ( | Groups && | groups, |
std::size_t | index | ||
) | -> decltype(auto) |
Returns the group within groups
with the specified index.
Groups | the type of collection of groups |
groups | the collection of all groups |
index | the index of the group to be accessed |
associated_groups()
The groups
argument is expected to be the one returned by associated_groups
.
Definition at line 180 of file ForEachAssociatedGroup.h.
auto util::infinite_counter | ( | T | begin = T{} | ) |
Version of util::counter()
starting at begin
and never ending.
T | type of counter value |
begin | the count to start from (default-constructed, usually some form of 0 , by default) |
An example of usage:
This loop runs through the full range of a character (8 bits, supposedly) twice before being broken.
Definition at line 291 of file counter.h.
auto util::make_adapted_const_span | ( | Cont & | cont, |
Adaptor && | adaptor | ||
) |
Creates constant iteration span from specified collection via an adaptor.
Definition at line 269 of file span.h.
auto util::make_adapted_span | ( | BIter | begin, |
EIter | end, | ||
Adaptor && | adaptor | ||
) |
Creates a span from specified iterators via an adaptor.
Definition at line 223 of file span.h.
auto util::make_adapted_span | ( | Cont & | cont, |
Adaptor && | adaptor | ||
) |
Creates a span from specified collection via an adaptor.
cont | collection to be iterated through |
adapter | iterator transformation to be applied on cont |
util::span
object iterating via an adapter to cont
make_adapted_span(BIter, EIter, Adaptor&&)
, make_adapted_const_span(Cont, Adaptor&&)
This interface is just a little help on using iterator adapters. Note that adapter
transforms the iterators of cont
, not its values. The adapter needs to be written aside and it's in general not trivial. An example of iterating through a collection of objects (actually, just float
for simplicity) stored as unique pointers in a collection:
This example shows the usage of util::make_adapted_span()
. In the specific example, it would have been more explicit to use the constant counterpart, util::make_adapted_const_span()
. The adaptor helper boost::make_indirect_iterator()
is provided in boost/iterator/indirect_iterator.hpp
.
Definition at line 258 of file span.h.
auto util::make_const_span | ( | Cont & | cont | ) |
auto util::make_span | ( | BIter | begin, |
EIter | end | ||
) |
Creates a span from specified iterators (can use constructor instead).
Definition at line 197 of file span.h.
auto util::make_span | ( | Cont & | cont | ) |
auto util::make_transformed_const_span | ( | Cont & | cont, |
Op && | op | ||
) |
Creates constant iteration span from specified collection via a transformation op
.
Definition at line 353 of file span.h.
auto util::make_transformed_span | ( | BIter | begin, |
EIter | end, | ||
Op && | op | ||
) |
Creates a span from specified iterators via an adaptor.
Definition at line 294 of file span.h.
auto util::make_transformed_span | ( | Cont & | cont, |
Op && | op | ||
) |
Creates a span from specified collection via an adaptor.
cont | collection to be iterated through |
adapter | iterator transformation to be applied on cont |
util::span
object iterating via an adapter to cont
make_transformed_span(BIter, EIter, Op&&)
, make_transformed_const_span(Cont, Op&&)
, make_adapted_span()
,This function transforms as directed by the unary operation op
the result of each iteration cycle, so that instead of cont[i]
, a op(cont[i])
is assigned to the iteration control variable. An example of iterating through a collection of objects (actually, just float
for simplicity) stored as unique pointers in a collection:
This example shows the usage of util::make_transformed_span()
. In the specific example, it would have been more explicit to use the constant counterpart, util::make_transformed_const_span()
. Note that in the example the dereference result is copied into v
. For have it by reference, the operation op
must be properly written:
Definition at line 341 of file span.h.
std::vector<size_t> util::MakeIndex | ( | Coll const & | data, |
KeyOf | key_of = KeyOf() |
||
) |
Creates a map of indices from an existing collection.
Coll | type of the collection |
KeyOf | type of the extractor of the key |
data | the data collection |
key_of | instance of a functor extracting a key value from a datum |
This function maps the index of the items in data to an integral key extracted from each item. For example, if the items are wires and the key_of function extracts their channel ID, the resulting vector will contain for each channel ID the index in data of the wire with that channel ID.
The key is converted into a unsigned integer (size_t
). If multiple items have the same key, the outcome for that key is undefined. If no items has a specific key, the index of that key is assigned as
, i.e. an index larger than the size of the original data collection.
The returned vector is big enough to accommodate indices corresponding to the keys of all the items in data. It may contain "holes" (that is, some keys that have no corresponding items have a
value). The memory allocated for the vector may be larger than necessary (if that is a problem, std::vector::shrink_to_fit()
can be used, but it may create more problems than it solves).
Definition at line 43 of file MakeIndex.h.
auto util::MakeMap | ( | Coll const & | data, |
KeyOf | key_of = KeyOf() |
||
) | -> std::vector<decltype(key_of(*(data.begin()))) const*> |
Creates a map of objects from an existing collection.
Coll | type of the collection |
KeyOf | type of the extractor of the key |
data | the data collection |
key_of | instance of a functor extracting a key value from a datum |
This function maps the items in data to an integral key extracted from each of them. For example, if the items are wires and the key_of function extracts their channel ID, the resulting vector will contain for each channel ID the pointer to the wire with that channel ID.
The key is converted into a unsigned integer (size_t
). If multiple items have the same key, the outcome for that key is undefined. If no items has a specific key, the index of that key is assigned a null pointer.
The returned vector is big enough to accommodate pointers corresponding to the keys of all the items in data. It may contain "holes" (that is, some keys that have no corresponding items have a null pointer value). The memory allocated for the vector may be larger than necessary (if that is a problem, std::vector::shrink_to_fit()
can be used, but it may create more problems than it solves).
Definition at line 99 of file MakeIndex.h.
auto util::makePointerVector | ( | Coll & | coll | ) |
Creates a STL vector with pointers to data from another collection.
Coll | type of collection of data |
coll | data collection |
coll
data elements, with same order Definition at line 198 of file SortByPointers.h.
auto util::makeTensorIndices | ( | DIMS... | dims | ) |
Instantiates a TensorIndices class with the specified dimensions.
DIMS | types for each of the arguments |
dims | size of each of the dimensions |
The rank of the tensor is determined by the number of arguments; example:
will initialise a TensorIndices<2>
(that's matrix indices), for a 3 x 4 (3 rows, 4 columns) disposition.
Definition at line 543 of file TensorIndices.h.
decltype(auto) util::makeValueIndex | ( | Coll const & | coll, |
Extractor | getter | ||
) |
Returns a map of value to index.
Coll | type of container |
Extractor | type of value extraction function |
coll | container to get the map of |
getter | function applied to each element to extract the value for map |
std::runtime_error | if multiple elements yield the same value |
The collection coll
is navigated in sequence from begin()
to end()
, and a map is created where to each key, getter(coll[i])
, the index i
is associated. The value returned by getter()
is copied into the key. Therefore that value needs to satisfy all the requirements of the key of the STL associative container std::map
. Duplicate values will trigger an exception.
The collection type Coll
must have:
auto util::makeValueIndex | ( | Coll const & | coll | ) |
Definition at line 61 of file makeValueIndex.h.
auto util::mapContainer | ( | Cont | cont, |
Mapping | mapping | ||
) |
Returns a container-like object mapping the content of cont
.
Cont | type of the original container |
Mapping | type of mapping object |
cont | the container |
mapping | the mapping to be applied |
util::MappedContainer
object transparently applying the mappingSee util::MappedContainer
for the details on the format of the mapping, the ownership of the container and the supported operations.
Definition at line 441 of file MappedContainer.h.
void util::MoveFromPointers | ( | Coll & | dest, |
PtrColl & | src | ||
) |
Moves the content from a collection of pointers to one of data.
Coll | type of collection of data |
PtrColl | type of collection of pointers to data |
dest | collection to be filled |
src | collection with the pointers to data to be moved |
The data pointed from each pointer in src
is moved into dest
. The destination collection is cleared first, and Coll
must support both clear()
and push_back()
Definition at line 61 of file SortByPointers.h.
|
inline |
Based on operator==.
Definition at line 513 of file VectorMap.h.
bool util::operator!= | ( | TensorIndices< RANK1 > const & | a, |
TensorIndices< RANK2 > const & | b | ||
) |
Comparison operator with tensors of different rank.
Definition at line 525 of file TensorIndices.h.
MappedContainer<Cont, Mapping>::template IteratorBase<Container, Reference> util::operator+ | ( | typename MappedContainer< Cont, Mapping >::template IteratorBase< Container, Reference >::difference_type | n, |
typename MappedContainer< Cont, Mapping >::template IteratorBase< Container, Reference > const & | it | ||
) |
Definition at line 703 of file MappedContainer.h.
|
inline |
Definition at line 501 of file VectorMap.h.
decltype(auto) util::operator<< | ( | Stream && | out, |
EventChangeTracker_t const & | trk | ||
) |
Definition at line 102 of file ChangeTrackers.h.
|
inline |
Definition at line 105 of file ChangeTrackers.h.
decltype(auto) util::operator<< | ( | Stream && | out, |
DataProductChangeTracker_t const & | trk | ||
) |
Definition at line 204 of file ChangeTrackers.h.
|
inline |
Definition at line 206 of file ChangeTrackers.h.
|
inline |
Definition at line 319 of file ChangeTrackers.h.
|
inline |
Based on operator<.
Definition at line 529 of file VectorMap.h.
|
inline |
Definition at line 494 of file VectorMap.h.
bool util::operator== | ( | TensorIndices< RANK1 > const & | a, |
TensorIndices< RANK2 > const & | b | ||
) |
Comparison operator with tensors of different rank.
Definition at line 517 of file TensorIndices.h.
|
inline |
Based on operator<.
Definition at line 537 of file VectorMap.h.
auto util::operator| | ( | Range && | range, |
RangeForWrapperTag | |||
) | -> decltype(auto) |
Transforms a range so that it can be used in a range-for loop.
Range | the type of range to be transformed |
range | the range to be transformed |
This is necessary only when the argument provides different types for the begin-of-range and end-of-range iterators. This is also superfluous for compilers adhering to C++ 2017 standard, which accepts iterators of different types by requirement. Example of usage:
where data is supposed to gave begin and end iterators of different types.
Definition at line 458 of file RangeForWrapper.h.
|
inline |
Returns the constant pi (up to 35 decimal digits of precision)
Definition at line 80 of file PhysicalConstants.h.
|
inline |
Converts the argument angle from radians into degrees ( )
Definition at line 88 of file PhysicalConstants.h.
void util::SortByPointers | ( | Coll & | coll, |
Sorter | sorter | ||
) |
Applies sorting indirectly, minimizing data copy.
Coll | type of collection to be sorted |
Sorter | type of sorter |
coll | collection to be sorted |
sorter | functor sorting a vector of pointers (makePointerVector() ) |
The sorter
functor can receive a reference to a vector as the one produced by makePointerVector(coll)
(that is, a C++ STL vector of pointers to the value type of Coll
), and sort it "in place". The container Comp
must implement push_back()
call in a std::vector
fashion.
The algorithm is equivalent to the following:
sorter
)Single elements are moved from the original collection to a new one.
The data elements of Coll
must be moveable, as Coll
itself must be.
Definition at line 204 of file SortByPointers.h.
void util::SortUniquePointers | ( | Coll & | coll, |
Sorter && | sorter | ||
) |
Sorts a vector of unique pointers using a C pointer sorter.
Coll | type of collection to be sorted |
Sorter | type of sorter function |
coll | collection to be sorted |
sorter | sorting procedure |
This adapter moves the unique pointers around to match a sorted version of source. This is an expensive procedure, implying the creation of a temporary vector and of additional supporting data: avoid it if at all possible.
Definition at line 234 of file SortByPointers.h.
util::span | ( | IterB && | b, |
IterE && | e, | ||
Adaptor && | adaptor | ||
) | -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) > |
decltype(auto) util::takeAddress | ( | ) |
Returns a functor that returns the address of its argument.
util::AddressTaker
will fill the vector ptrs
with pointers to the elements of data
.
C++ already provides a tool to effectively take an address, std::addressof
. The reason for takeAddress()
is that std::addressof()
is a function, with many overloads, and to use it in a STL algorithm the overload has to be resolved first. For example:
One important limit is that the type of the argument (in this case int const&
) needs to be known or deduced in a quite precise way, in particular regarding constantness and referenceness. This is unconvenient and convoluted enough that one would rather create a new function, like:
This util::takeAddress()
operates in a very similar way to the lambda in the last example.
Definition at line 86 of file operations.h.
decltype(auto) util::values | ( | Coll && | coll | ) |
Range-for loop helper iterating across the values of the specified collection.
Coll | type of the collection to iterate through |
coll | the collection to iterate through |
util::const_values()
This function is in most of cases a no-operation, returning the collection just as it was specified, to be iterated on directly. In case of mapping types, though, a different object is returned and the iteration will happen to the value type of the mapping instead than on the key-value pair.
will result in values
vector being of size 3
and with values { 4.0F, 8.0F, 12.0F }
(the order is the one of iterating through a std::map
).
auto util::wrapRangeFor | ( | Range && | range | ) | -> decltype(auto) |
Wraps an object for use in a range-for loop.
range | instance of the range object to be wrapped |
This is necessary only when the argument provides different types for the begin-of-range and end-of-range iterators. This is also superfluous for compilers adhering to C++ 2017 standard, which accepts iterators of different types by requirement. Example of usage:
where data is supposed to gave begin and end iterators of different types.
Definition at line 426 of file RangeForWrapper.h.
auto util::zip | ( | Iterables &&... | iterables | ) |
Range-for loop helper iterating across many collections at the same time.
Lead | index of the parameter driving the start and end of the loop |
Iterables | type of objects to be iterated together |
iterables | all iterable objects to be iterated together |
util::enumerate()
In the range-for loop, at each iteration this object yields a tuple
of values, each of the type returned by dereferencing begin(iterable)
. For example:
In this example, N
iterations will be run because that is the size of the first iterable given to enumerate
. If a different leading iterable is needed, that has to be specified as an argument. The following loop is completely equivalent to the former one:
(the index is zero-based, so 1U
refers to the second argument).
Range-for loop helper iterating across many collections at the same time.
Definition at line 295 of file zip.h.
auto util::zip | ( | Iterables &&... | iterables | ) |
constexpr double util::kBogusD = -999. |
obviously bogus double value
Definition at line 71 of file PhysicalConstants.h.
constexpr float util::kBogusF = -999. |
obviously bogus float value
Definition at line 73 of file PhysicalConstants.h.
constexpr int util::kBogusI = -999 |
obviously bogus integer value
Definition at line 72 of file PhysicalConstants.h.
constexpr double util::kc = 29.9792458 |
Speed of light in vacuum in LArSoft units [cm/ns].
Definition at line 59 of file PhysicalConstants.h.
constexpr double util::kCentimeterToMeter = 1./kMeterToCentimeter |
Definition at line 64 of file PhysicalConstants.h.
constexpr double util::keVToMeV = 1.e-6 |
1e6 eV = 1 MeV
Definition at line 68 of file PhysicalConstants.h.
constexpr double util::kGeVToElectrons = 4.237e7 |
23.6eV per ion pair, 1e9 eV/GeV
Definition at line 55 of file PhysicalConstants.h.
constexpr double util::kINVALID_DOUBLE = std::numeric_limits<Double_t>::max() |
Definition at line 33 of file GeometryUtilities.h.
constexpr double util::kKilometerToMeter = 1./kMeterToKilometer |
Definition at line 66 of file PhysicalConstants.h.
constexpr double util::kMeterToCentimeter = 1.e2 |
1 m = 100 cm
Definition at line 63 of file PhysicalConstants.h.
constexpr double util::kMeterToKilometer = 1.e-3 |
1000 m = 1 km
Definition at line 65 of file PhysicalConstants.h.
constexpr double util::kMeVToeV = 1./keVToMeV |
Definition at line 69 of file PhysicalConstants.h.
constexpr double util::kModBoxA = 0.930 |
Modified Box Alpha.
Definition at line 49 of file PhysicalConstants.h.
constexpr double util::kModBoxB = 0.212 |
Modified Box Beta in g/(MeV cm²)*kV/cm.
Definition at line 50 of file PhysicalConstants.h.
constexpr double util::kRecombA = 0.800 |
A constant.
Definition at line 35 of file PhysicalConstants.h.
constexpr double util::kRecombk = 0.0486 |
k constant, in g/(MeV cm²)*kV/cm.
Definition at line 36 of file PhysicalConstants.h.
Definition at line 75 of file PhysicalConstants.h.
constexpr RangeForWrapperTag util::range_for |
Constant to be used with operator|(Range&&, details::RangeForWrapperTag)
.
Definition at line 438 of file RangeForWrapper.h.
const float util::SQRT_TWO_PI = 2.506628 |
Definition at line 18 of file GaussianEliminationAlg.h.