LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
util Namespace Reference

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...
 
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...
 
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  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...
 
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  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 > >
 
struct  self_type
 Trait returning the very same type as in the template argument. More...
 
class  SignalShaper
 
class  SignalShaping
 
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  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  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...
 
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_tUBChannelMap_t
 
typedef std::map< UBLArSoftCh_t, UBDaqIDUBChannelReverseMap_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 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 ( $ \pi \rightarrow 180 $) 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<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 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)
 
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)
 Helper to determine the type of a variable at compilation time. 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)
 ADL-aware version of std::to_string. More...
 
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)
 Creates a single one-to-one association with associated data. More...
 
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
 
constexpr double kINVALID_DOUBLE = std::numeric_limits<double>::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
 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
 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
 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).
See also
sim::ISCalculationSeparate::CalculateIonizationAndScintillation()

Recombination factor coefficients come from Nucl.Instrum.Meth.A523:275-286,2004

  • $ dE/dx $ is given by the voxel energy deposition, but have to convert it to MeV/cm from GeV/voxel width
  • electric field: $ E $ in kV/cm
  • $ R = A/(1 + (dE/dx)*k/E) $
  • $ A = 0.800 \pm 0.003 $
  • $ k = 0.0486 $ needs to be scaled with Electric field
constexpr double kRecombA = 0.800
 A constant. More...
 
constexpr double kRecombk = 0.0486
 
Recombination factor coefficients (modified box, ArguNeuT JINST).
See also
sim::ISCalculationSeparate::CalculateIonizationAndScintillation()

Recombination factor coefficients come from Nucl.Instrum.Meth.A523:275-286,2004

  • $ dE/dx $ is given by the voxel energy deposition, but have to convert it to MeV/cm from GeV/voxel width
  • electric field: $ E $ in kV/cm
  • kModBoxB needs to be scaled with the electric field.
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...
 

Detailed Description

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:

  • energy: GeV
  • time: ns
  • space: cm

SumSecondFunction 28-Jul-2009 William Seligman selig.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..edu 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.

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.nosp@m.man@.nosp@m.nevis.nosp@m..col.nosp@m.umbia.nosp@m..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;

  • svm(i) will return the "i-th" value in the map; that is, "i" is a numeric index instead of a key. (Note the use of parenthesis instead of square brackets.) This is a boon to physicists, most of whom couldn't tell an iterator from a hole in the wall.
  • svm.Key(i) will return the "i-th" key in the map.
  • svm.Data(i) will return the same result as svm(i).
  • svm[key_type] will now return the corresponding data_type in both const and non-const contexts. However, if you ask for svm[key] and the key isn't in the map, and you're in a const context, the routine will throw an out-of-range exception.

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:

  • Initialization, where the time doesn't matter (e.g., tracks in a Monte Carlo).
  • Access, where efficient or "simple" access to the map's contents are important. In general, we access a map many, many more times that we create one.
  • After we create/initialize a map, we never change its contents.

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:

  • equal_range in a const context (which causes some weird ROOT dictionary problem); this isn't likely to be used for a map anyway (multimaps or multisets would be a different story).

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.nosp@m.hum@.nosp@m.lanl..nosp@m.gov)

Description: Class that solves system of linear equations via Gaussian Elimination. Intended for use with RFFHitFitter

Typedef Documentation

template<typename DATUM >
using util::GridContainer2D = typedef GridContainerBase2D<DATUM, GridContainer2DIndices>

Container allowing 2D indexing.

Template Parameters
DATUMtype of contained data
See also
GridContainer2DIndices

This is an alias for GridContainerBase2D, with a proper index manager. See the documentation of GridContainerBase2D.

Definition at line 248 of file GridContainers.h.

Index manager for a container of data arranged on a 2D grid.

Definition at line 170 of file GridContainerIndices.h.

template<typename DATUM >
using util::GridContainer3D = typedef GridContainerBase3D<DATUM, GridContainer3DIndices>

Container allowing 3D indexing.

Template Parameters
DATUMtype of contained data
See also
GridContainer3DIndices

This is an alias for GridContainerBase3D, with a proper index manager. See the documentation of GridContainerBase3D.

Definition at line 259 of file GridContainers.h.

Index manager for a container of data arranged on a 3D grid.

Definition at line 173 of file GridContainerIndices.h.

using util::MatrixIndices = typedef TensorIndices<2U>

Type for indexing a 2D-tensor (matrix)

Definition at line 535 of file TensorIndices.h.

Definition at line 46 of file DatabaseUtil.h.

Definition at line 47 of file DatabaseUtil.h.

typedef int util::UBLArSoftCh_t

Definition at line 44 of file DatabaseUtil.h.

Function Documentation

template<typename T >
constexpr auto util::abs ( v)

Returns the absolute value of the argument.

Template Parameters
Ttype of the argument
Parameters
vvalue to be processed
Returns
the absolute value of v

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).

Requirements

  • constexpr construction of a 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.

Referenced by util::quantities::concepts::Quantity< Unit, T >::abs(), raw::ADCStickyCodeCheck(), cluster::ClusterCrawlerAlg::AddHit(), tca::AddHits(), opdet::AddHitToFlash(), cluster::ClusterCrawlerAlg::AddLAHit(), sim::OpDetBacktrackerRecord::AddScintillationPhotons(), tca::AddTjsInsideEnvelope(), larg4::CheckSimEnergyDeposit::analyze(), shower::TCShowerElectronLikelihood::analyze(), shower::TCShowerTemplateMaker::analyze(), calo::CaloChecker::analyze(), pfpf::PFPAna::analyze(), cluster::ClusterAna::analyze(), cluster::DBclusterAna::analyze(), cluster::ClusterTrackAna::analyze(), nnet::EvaluateROIEff::analyze(), NuShowerEff::analyze(), nnet::RawWaveformClnSigDump::analyze(), nnet::PointIdTrainingData::analyze(), trkf::SeedAna::analyze(), trkf::TrackAna::analyze(), tca::AnalyzeRotPos(), trkf::TrackAna::anaStitch(), cluster::ClusterCrawlerAlg::AngleFactor(), larg4::ISCalcCorrelated::AngleToEFieldAtStep(), trkf::TrackStatePropagator::apply_mcs(), sce::SCECorrection::applyT0Shift(), sim::ParticleList::at(), tca::AttachToAnyVertex(), cmtool::CBAlgoAngleAlign::Bool(), cmtool::CBAlgoAngleCompat::Bool(), cmtool::CBAlgoAngleIncompat::Bool(), cmtool::CBAlgoAngleSeparate::Bool(), cmtool::CBAlgoOutOfConeSeparate::Bool(), cmtool::CBAlgoCenterOfMass::Bool(), dbsPoint::bounds(), tca::BraggSplit(), lar_cluster3d::ConvexHullPathFinder::breakClusterAtBigGap(), lar_cluster3d::VoronoiPathFinder::breakIntoTinyBits(), lar_cluster3d::ClusterPathFinder::buildConvexHull(), lar_cluster3d::VoronoiPathFinder::buildConvexHull(), lar_cluster3d::ConvexHullPathFinder::buildConvexHull(), lar_cluster3d::MSTPathFinder::buildConvexHull(), lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps(), trkf::KalmanFilterAlg::buildTrack(), lar_cluster3d::ClusterPathFinder::buildVoronoiDiagram(), lar_cluster3d::VoronoiPathFinder::buildVoronoiDiagram(), larg4::ISCalcNESTLAr::CalcIonAndScint(), util::SignalShaper::CalculateDeconvKernel(), util::SignalShaping::CalculateDeconvKernel(), ShowerRecoTools::ShowerTrackDirection::CalculateElement(), ShowerRecoTools::ShowerTrackSpacePointDirection::CalculateElement(), ShowerRecoTools::ShowerStartPositionCheater::CalculateElement(), ShowerRecoTools::ShowerTrackHitDirection::CalculateElement(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement(), NestAlg::CalculateIonizationAndScintillation(), larg4::ISCalculationCorrelated::CalculateIonizationAndScintillation(), util::GeometryUtilities::CalculatePitch(), util::GeometryUtilities::CalculatePitchPolar(), geo::GeometryCore::ChannelsIntersect(), shower::LArPandoraShowerCheatingAlg::CheatDebugEVD(), DUNE::NeutrinoShowerEff::checkCNNtrkshw(), opdet::FlashHypothesisCollection::CheckFrac(), shower::EMShowerAlg::CheckShowerHits_(), tca::ChgFracBetween(), tca::ChkBegin(), tca::ChkChgAsymmetry(), cluster::ClusterCrawlerAlg::ChkClusterDS(), cluster::ClusterCrawlerAlg::ChkClusterNearbyHits(), cluster::ClusterCrawlerAlg::ChkMerge(), cluster::ClusterCrawlerAlg::ChkMerge12(), cluster::ClusterCrawlerAlg::ChkSignal(), tca::ChkStop(), tca::ChkStopEndPts(), cluster::ClusterCrawlerAlg::ChkVertex(), lar_cluster3d::ClusterMergeAlg::closestApproach(), evd::RecoBaseDrawer::Cluster2D(), cluster::ClusterCrawlerAlg::ClusterLoop(), cluster::ClusterCrawlerAlg::ClusterVertex(), nnet::TrainingDataAlg::collectVtxFlags(), opdet::FlashUtilities::CompareByError(), opdet::FlashUtilities::CompareByFraction(), trkf::SpacePointAlg::compatible(), tca::CompatibleMerge(), tca::CompleteIncomplete3DVerticesInGaps(), pma::Track3D::CompleteMissingWires(), trkf::TrackMomentumCalculator::compute_max_fluctuation_vector(), voronoi2d::EventUtilities::computeArcVal(), voronoi2d::EventUtilities::computeBreak(), voronoi2d::VoronoiDiagram::computeCircleCenter2(), voronoi2d::VoronoiDiagram::computeCircleCenter3(), geo::TPCGeo::ComputeDriftDistance(), geo::GeometryCore::ComputeThirdPlaneSlope(), evgb::GENIEHelper::ConfigGeomScan(), lar_cluster3d::kdTree::consistentPairs(), opdet::ConstructFlash(), Py8CharmDecayerPhysics::ConstructProcess(), Py8TauDecayerPhysics::ConstructProcess(), cluster::ClusterCrawlerAlg::CrawlUS(), cluster::ClusterCrawlerAlg::CrawlVtxChk(), cluster::ClusterCrawlerAlg::CrawlVtxChk2(), t0::DirectHitParticleAssns::CreateHitParticleAssociations(), hit::RFFHitFitter::CreateMergeVector(), lar_pandora::LArPandoraInput::CreatePandoraMCLinks2D(), sppt::SpacePointAlg_TimeSort::createSpacePoints(), RunAction::CriticalEnergy(), shower::LArPandoraShowerAlg::DebugEVD(), tca::dEdx(), trkf::Propagator::dedx_prop(), lcvn::PixelMapProducer< T, U >::DefineBoundary(), tca::DefineHitPos(), tca::DeltaAngle(), recob::MCSFitResult::deltaLogLikelihood(), geo::TPCGeo::DetectDriftDirection(), larg4::OpFastScintillation::detectedReflecHits(), phot::SemiAnalyticalModel::detectedReflectedVisibilities(), geo::PlaneGeo::DetectGeometryDirections(), detectGlobalDriftDir(), phot::PhotonMappingXMirrorTransformations::detectorToLibrary(), lar_cluster3d::SnippetHit3DBuilder::DistanceFromPointToHitWire(), trkf::TrackKalmanFitter::doFitWork(), evdb_tool::SpacePoint3DDrawerHitAsymmetry::Draw(), evd::Ortho3DPad::Draw(), evd::RecoBaseDrawer::Draw2DSlopeEndPoints(), evd_tool::ProtoDUNEDrawer::DrawAxes(), evd_tool::StandardDrawer::DrawAxes(), evd_tool::ProtoDUNEDrawer::DrawGrids(), evd_tool::StandardDrawer::DrawGrids(), larg4::LArVoxelReadout::DriftIonizationElectrons(), tca::ElectronLikelihood(), fhicl::detail::encode(), lar::util::GaussianFit< T >::EncodeValue(), cluster::ClusterCrawlerAlg::EndKinkAngle(), tca::EndMerge(), cluster::EndPointAlg::EndPoint(), geo::details::ActiveAreaCalculator::equal(), sim::ParticleList::erase(), tca::ExpectedHitsRMS(), trkf::KalmanFilterAlg::extendTrack(), phot::fast_acos(), larg4::fast_acos(), cluster::HoughBaseAlg::FastTransform(), trkf::VertexFitAlg::fcnVtxPos(), lar_content::ElectronInitialRegionRefinementAlgorithm::FillElectronHitMap(), trkf::CCTrackMaker::FillEndMatch(), TruthMatchUtils::FillG4IDToEnergyDepositMap(), lar_content::LArHierarchyHelper::MCHierarchy::Node::FillHierarchy(), lar_content::LArHierarchyHelper::MCHierarchy::FillHierarchy(), lar_content::LArHierarchyHelper::RecoHierarchy::Node::FillHierarchy(), lar_content::LArHierarchyHelper::RecoHierarchy::FillHierarchy(), evgen::NDKGen::FillHistograms(), evgen::GENIEGen::FillHistograms(), microboone::CosmicRemovalAna::FillMCInfo(), cheat::RecoCheckAna::FillResults(), simfilter::FilterCryostatNus::filter(), simfilter::FilterGenInTime::filter(), sim::ParticleList::find(), vertex::FeatureVertexFinder::Find2dClusterVertexCandidates(), tca::Find2DVertices(), tca::Find3DVertices(), vertex::FeatureVertexFinder::Find3dVtxFrom2dClusterVtxCand(), trkf::TrackMomentumCalculator::find_angle(), lar_cluster3d::MinSpanTreeAlg::FindBestPathInCluster(), lar_cluster3d::MSTPathFinder::FindBestPathInCluster(), cluster::BlurredClusteringAlg::FindBlurringParameters(), evd::TWQProjectionView::FindEndPoint(), tca::FindHammerVertices(), trkf::StitchAlg::FindHeadsAndTails(), reco_tool::CandHitMorphological::findHitCandidates(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::FindInitialTrackHits(), shower::EMShowerAlg::FindInitialTrackHits(), evd::TWQProjectionView::FindLineLength(), tca::FindParent(), reco_tool::PeakFitterMrqdt::findPeakParameters(), reco_tool::PeakFitterGaussian::FindRefitCand(), reco_tool::PeakFitterGaussian::FindShiftedGaussian(), shower::EMShowerAlg::FindShowerStart_(), cluster::ClusterCrawlerAlg::FindStarVertices(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::FindTrackSpacePoints(), tca::FindUseHits(), cluster::ClusterCrawlerAlg::FindVertices(), trkf::TrajectoryMCSFitter::fitMcs(), trkf::KalmanFilterAlg::fitMomentumMS(), hit::CCHitFinderAlg::FitNG(), tca::FitPar(), tca::FitTraj(), tca::FixBegin(), tca::Forecast(), MedicalBeam::GenerateBeamDirection(), util::GeometryUtilities::Get2Dangle(), util::GeometryUtilities::Get2DPitchDistance(), util::GeometryUtilities::Get2DPitchDistanceWSlope(), util::GeometryUtilities::Get3DSpecialCaseTheta(), vertex::FeatureVertexFinder::Get3dVertexCandidates(), opreco::OpticalRecoAna::get_MC_particle_list(), lar_content::LArMCParticleHelper::GetAllDescendentMCParticles(), lar_content::LArPfoHelper::GetAllDownstreamPfos(), lar_content::ShowerGrowingAlgorithm::GetAllVertexSeedCandidates(), larg4::SimpleWireplaneAction::GetAttenuationFraction(), larg4::OverlaidWireplanesAction::GetAttenuationFraction(), lar_content::ShowerStartFinderTool::GetBoundaryExtremalPoints(), voronoi2d::VoronoiDiagram::getConvexHull(), trkf::TrackMomentumCalculator::getDeltaThetaij_(), util::GaussianEliminationAlg::GetDistance(), lar_pandora::ConsolidatedPFParticleAnalysisTemplate::GetFinalStatePFParticleVectors(), tca::GetHitMultiplet(), cluster::ClusterCrawlerAlg::GetHitRange(), lcvn::AssignLabels::GetInteractionType(), lcvn::AssignLabels::GetInteractionTypeFromSlice(), trkf::SurfYZPlane::getMomentum(), trkf::SurfYZLine::getMomentum(), trkf::SurfXYZPlane::getMomentum(), sim::PhotonVoxelDef::GetNeighboringVoxelIDsImpl(), lar_content::ShowerGrowingAlgorithm::GetNextSeedCandidate(), calo::GnocchiCalorimetry::GetPitch(), shower::EMShowerAlg::GetPlanePermutations_(), lcvn::AssignLabels::GetProtoDUNEBeamInteractionType(), lar_content::ShowerGrowingAlgorithm::GetSeedAssociationList(), shower::TCShowerElectronLikelihood::getShowerProfile(), cluster::DBScanAlg::getSimilarity(), cluster::DBScanAlg::getSimilarity2(), sce::SCECorrection::getSliceBestT0(), lcvn::AssignLabels::GetTopology(), lcvn::AssignLabels::GetTopologyType(), lcvn::AssignLabels::GetTopologyTypeAlt(), trkf::TrackMomentumCalculator::GetTrackMomentum(), shower::LArPandoraShowerCheatingAlg::GetTrueChain(), util::NormalDistribution::getValue(), phot::PropagationTimeModel::getVISTimes(), larg4::OpFastScintillation::getVISTimes(), quad::GetVtxByAssns(), shower::TCShowerAlg::goodHit(), tca::GottaKink(), lar_cluster3d::SpacePointHit3DBuilder::Hit3DBuilder(), cluster::HoughBaseAlg::HoughBaseAlg(), cosmic::BeamFlashTrackMatchTaggerAlg::InDetector(), ArParticleHPCaptureFS::Init(), hit::DisambigCheater::InitHitToWids(), tca::InShowerProb(), tca::InShowerProbTrans(), geo::PlaneGeo::InterWireDistance(), lar::sparse_vector< float >::is_equal(), lar::sparse_vector< float >::is_zero(), lar_content::CheatingClusterCharacterisationAlgorithm::IsClearTrack(), lar_content::CheatingPfoCharacterisationAlgorithm::IsClearTrack(), lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), tca::IsCloseToVertex(), lar_content::LArMCParticleHelper::IsDescendentOf(), nnet::TrainingDataAlg::isElectronEnd(), trkf::SurfYZPlane::isEqual(), trkf::SurfYZLine::isEqual(), trkf::SurfXYZPlane::isEqual(), nnet::PointIdEffTest::isMuonDecaying(), nnet::TrainingDataAlg::isMuonDecaying(), AcceptFindNeighbors::isNear(), lar_content::LArMCParticleHelper::IsNeutrino(), lar_content::LArPfoHelper::IsNeutrino(), lar_pandora::LArPandoraHelper::IsNeutrino(), phot::SemiAnalyticalModel::isOpDetInSameTPC(), phot::PDFastSimPAR::isOpDetInSameTPC(), larg4::OpFastScintillation::isOpDetInSameTPC(), trkf::SurfYZPlane::isParallel(), trkf::SurfYZLine::isParallel(), trkf::SurfXYZPlane::isParallel(), lar_content::CheatingPfoCreationAlgorithm::IsShower(), lar_content::LArPfoHelper::IsShower(), lar_pandora::LArPandoraHelper::IsShower(), lar_content::CheatingPfoCreationAlgorithm::IsTrack(), lar_content::LArPfoHelper::IsTrack(), lar_pandora::LArPandoraHelper::IsTrack(), trkf::SurfYZLine::isTrackValid(), lar_content::LArMCParticleHelper::IsVisible(), lar_pandora::LArPandoraHelper::IsVisible(), simfilter::FilterGenInTime::KeepParticle(), trkf::KHitWireLine::KHitWireLine(), trkf::KHitWireX::KHitWireX(), cluster::ClusterCrawlerAlg::KillGarbageClusters(), tca::KinkSignificance(), cluster::ClusterCrawlerAlg::LACrawlUS(), corner::CornerFinderAlg::line_integral(), lar_cluster3d::ClusterMergeAlg::linearClusters(), tca::LineLineIntersect(), sim::ParticleList::lower_bound(), lar_cluster3d::ConvexHullPathFinder::makeCandidateCluster(), lar_cluster3d::VoronoiPathFinder::makeCandidateCluster(), trkf::CCTrackMaker::MakeClusterChains(), tca::MakeHaloTj(), lar_cluster3d::StandardHit3DBuilder::makeHitTriplet(), lar_cluster3d::SnippetHit3DBuilder::makeHitTriplet(), shower::EMShowerAlg::MakeShower(), shower::TCShowerAlg::makeShowers(), trkf::SpacePointAlg::makeSpacePoints(), tca::MakeTP3D(), tca::MakeTP3Ds(), trkf::KTrack::Mass(), trkf::TrackState::mass(), trkf::TrajectoryMCSFitter::mass(), tca::Match3DFOM(), tca::Match3Planes(), opreco::OpticalRecoAna::match_flashes_to_particles(), tca::MaxChargeAsymmetry(), vertex::FeatureVertexFinder::MergeAndSort3dVtxCandidate(), sim::AuxDetSimChannel::MergeAuxDetSimChannel(), sim::MergeSimSourcesUtility::MergeAuxDetSimChannels(), cluster::ClusterCrawlerAlg::MergeHits(), sim::MergeSimSourcesUtility::MergeMCParticles(), cluster::ClusterCrawlerAlg::MergeOverlap(), sim::SimChannel::MergeSimChannel(), sim::MergeSimSourcesUtility::MergeSimChannels(), tca::MoveTPToWire(), lar_content::MvaPfoCharacterisationAlgorithm< T >::MvaPfoCharacterisationAlgorithm(), trkf::TrackMomentumCalculator::my_mcs_llhd(), apa::APAGeometryAlg::NearestWireIDOnChan(), trkf::InteractPlane::noise(), cheat::PhotonBackTracker::OpDetToTrackSDPs(), evd::RawDataDrawer::BoxDrawer::Operate(), evd::RawDataDrawer::RoIextractorClass::Operate(), compare_to_value::operator()(), compare_to_range::operator()(), geo::WireIDIntersection::operator<(), larg4::OpFastScintillation::OpFastScintillation(), shower::LArPandoraShowerAlg::OrderShowerHits(), larsim::Utils::SCE::out_of_bounds(), pma::PMAlgCosmicTagger::outOfDriftWindow(), tca::ParentFOM(), cluster::BlurredClusteringAlg::PassesTimeCut(), lar_content::LArMCParticleHelper::PassMCParticleChecks(), lar_content::EventWritingAlgorithm::PassMCParticleFilter(), tca::PDGCodeIndex(), lar_content::RecursivePfoMopUpAlgorithm::PfoMergeStatsComp(), util::GeometryUtilities::PitchInView(), geo::TPCGeo::PlanePitch(), trkf::CCTrackMaker::PlnMatch(), tca::PointInsideEnvelope(), tca::PointPull(), larg4::MuNuclearSplittingProcess::PostStepDoIt(), larg4::MuNuclearSplittingProcessXSecBias::PostStepDoIt(), trkf::KETrack::Print(), trkf::KHit< N >::Print(), cluster::ClusterCrawlerAlg::PrintClusters(), DUNE::NeutrinoShowerEff::processEff(), evgen::NueAr40CCGenerator::ProcessOneNeutrino(), shwf::ShowerCheater::produce(), evgen::CosmicsGen::produce(), trkf::TrackCheater::produce(), caldata::CalWire::produce(), caldata::CalWireT962::produce(), cluster::DBCluster3D::produce(), calo::ShowerCalorimetry::produce(), trkf::SpacePts::produce(), trkf::Track3Dreco::produce(), cluster::TrajCluster::produce(), trkf::TrackKalmanCheater::produce(), vertex::VertexFinder2D::produce(), detsim::DriftElectronstoPlane::produce(), calo::Calorimetry::produce(), trkf::Track3DKalmanSPS::produce(), detsim::SimDriftElectrons::produce(), trkf::PMAlgTrackMaker::produce(), calo::GnocchiCalorimetry::produce(), evgen::Decay0Gen::produce_radio(), trkf::TrackStatePropagator::propagateToPlane(), phot::PropagationTimeModel::propagationTime(), larg4::OpFastScintillation::propagationTime(), trkf::Track3DKalmanHitAlg::qualityCutsOnSeedTrack(), evd::RawDataDrawer::QueueDrawingBoxes(), tca::Reconcile2Vs(), larg4::LArVoxelReadout::RecoverOffPlaneDeposit(), phot::SemiAnalyticalModel::Rectangle_SolidAngle(), simb::MCFlux::ReDecay(), cluster::ClusterCrawlerAlg::RefineVertexClusters(), shower::EMShowerAlg::RelativeWireWidth_(), pmtana::RiseTimeGaussFit::RiseTime(), shower::LArPandoraShowerAlg::RMSShowerGradient(), geo::vect::extra::roundValue0(), geo::vect::extra::roundValue01(), lar_content::ShowerTensorVisualizationTool::Run(), lar_dl_content::DlHitValidationAlgorithm::Run(), lar_content::VisualParticleMonitoringAlgorithm::Run(), lar_content::HierarchyMonitoringAlgorithm::Run(), lar_content::HierarchyValidationAlgorithm::Run(), tca::SaveCRInfo(), dnn::SavePiMu::saveImage(), phot::SemiAnalyticalModel::SemiAnalyticalModel(), nnet::TrainingDataAlg::setEventData(), evd::TWQProjectionView::SetMouseZoomRegion(), simb::MCTruth::SetNeutrino(), lar_content::NeutrinoPropertiesAlgorithm::SetNeutrinoId(), tca::SetSection(), shower::TCShowerTemplateMaker::showerProfile(), shower::TCShowerTemplateMaker::showerProfileTrue(), tca::SignalAtTp(), tca::SignalAtTpInSlc(), evd::RecoBaseDrawer::Slice2D(), evd::RecoBaseDrawer::Slice3D(), cluster::LineMerger::SlopeCompatibility(), geo::sortPlaneStandard(), geo::sortWireStandard(), tca::StartChgVec(), tca::StepAway(), larg4::G4BadIdeaAction::SteppingAction(), tca::StitchPFPs(), trkf::CCTrackMaker::StoreTrack(), hit::CCHitFinderAlg::StudyHits(), geo::WireGeo::TanThetaZ(), nnet::PointIdEffTest::testCNN(), trkf::Track3DKalmanHitAlg::testSeedSlope(), geo::OpDetGeo::ThetaZ(), apa::APAGeometryAlg::ThreeChanPos(), geo::TPCGeo::TPCGeo(), tca::TPNearVertex(), trkf::CosmicTrackerAlg::Track3D(), cheat::PhotonBackTracker::TrackIDToMCTruth(), cheat::ParticleInventory::TrackIdToMCTruth_P(), cheat::PhotonBackTracker::TrackIDToMotherParticle(), cheat::ParticleInventory::TrackIdToMotherParticle_P(), cheat::BackTracker::TrackIdToSimIDEs_Ps(), cheat::PhotonBackTracker::TrackIDToSimSDP(), cheat::PhotonBackTracker::TrackIdToSimSDPs_Ps(), lar::util::TrackPitchInView(), lar::util::TrackProjectedLength(), trkf::CosmicTrackerAlg::TrackTrajectory(), lar_dl_content::DlHitTrackShowerIdAlgorithm::Train(), tca::TrajClosestApproach(), tca::TrajHitsOK(), tca::TrajTrajDOCA(), tca::TrimEndPts(), shower::LArPandoraShowerCheatingAlg::TrueParticleIDFromTrueChain(), shower::TCShowerAnalysis::truthMatcher(), DUNE::NeutrinoShowerEff::truthMatcher(), trkf::KalmanFilterAlg::updateMomentum(), geo::PlaneGeo::UpdateOrientation(), geo::TPCGeo::UpdatePlaneCache(), tca::UpdateShower(), tca::UpdateTjChgProperties(), geo::PlaneGeo::UpdateView(), tca::UpdateVxEnvironment(), sim::ParticleList::upper_bound(), lar::util::ValueInRange(), trkf::Propagator::vec_prop(), larg4::OpFastScintillation::VISHits(), phot::SemiAnalyticalModel::VISVisibility(), geo::GeometryCore::VolumeName(), cluster::ClusterCrawlerAlg::Vtx3ClusterSplit(), cluster::ClusterCrawlerAlg::VtxConstraint(), larg4::OpFastScintillation::VUVHits(), phot::SemiAnalyticalModel::VUVVisibility(), lar_pandora::ICARUS::WireAngleW(), geo::GeometryCore::WireEndPoints(), lar_cluster3d::SnippetHit3DBuilder::WireIDsIntersect(), geo::WireGeo::WirePitch(), shower::EMShowerAlg::WorstPlane_(), lar::util::RealComparisons< RealType >::zero(), and raw::ZeroSuppression().

41  {
42  return (-T(0) < v) ? v : -v;
43  }
template<class A >
auto util::associated_groups ( A const &  assns)

Helper functions to access associations in order.

Template Parameters
Atype of association being read
Parameters
assnsthe association being read
See also
for_each_associated_group()

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:

auto assns = art::getValidHandle<art::Assns<recob::Track, recob::Hit>>
(fTrackTag);
std::vector<double> totalCharge;
for (auto const& hits: util::associated_groups(*assns)) {
double total = 0.;
total += hit->Integral();
totalCharge.push_back(total);
} // for

A number of important points need to be realised about this example:

  • the requirements of this function on its input association are the same as for art::for_each_group()
  • we can code the action on each group of hits directly in a loop, if like in this case the code is succinct
  • again, there is one outer loop iteration for every track;
  • the value of 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;
  • on each iteration, the information of which track the hits are associated to is not available; if that is also needed, use util::associated_groups_with_left() instead.

Definition at line 93 of file ForEachAssociatedGroup.h.

References a1, a2, range_for, and values().

Referenced by TrackProducerFromTrack::produce(), TrackProducerFromTrackTrajectory::produce(), and TrackProducerFromPFParticle::produce().

94  {
95  return assns | ranges::views::all |
96  ranges::views::chunk_by([](auto a1, auto a2) { return a1.first == a2.first; }) |
97  ranges::views::transform(
98  [](auto pairs) { return pairs | ranges::views::values | util::range_for; }) |
100  } // associated_groups()
#define a2
constexpr RangeForWrapperTag range_for
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
#define a1
template<class A >
auto util::associated_groups_with_left ( A const &  assns)

Helper functions to access associations in order, also with key.

Template Parameters
Atype of association being read
Parameters
assnsthe association being read
See also
for_each_associated_group()

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:

auto assns = art::getValidHandle<art::Assns<recob::Track, recob::Hit>>
(fTrackTag);
std::map<int, double> totalCharge;
for (auto const& trackWithHits: util::associated_groups_with_left(*assns))
{
art::Ptr<recob::Track> const& track = trackWithHits.first;
auto const& hits = trackWithHits.second;
if (totalCharge.count(track->ID()) > 0) {
<< "Multiple tracks have ID " << track->ID() << "!\n";
}
double& total = totalCharge[track->ID()];
total = 0.0;
total += hit->Integral();
} // for

A number of important points need to be realised about this example:

  • the requirements of this function on its input association are the same as for art::for_each_group_with_left()
  • we can code the action on each group of hits directly in a loop, if like in this case the code is succinct
  • again, there is one outer loop iteration for every track;
  • the value of 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 150 of file ForEachAssociatedGroup.h.

References a1, a2, range_for, and values().

151  {
152  return assns | ranges::views::all |
153  ranges::views::chunk_by([](auto a1, auto a2) { return a1.first == a2.first; }) |
154  ranges::views::transform([](auto pairs) {
155  return std::make_pair(pairs.front().first, // assuming they're all the same, pick first
157  }) |
159  } // associated_groups_with_left()
#define a2
constexpr RangeForWrapperTag range_for
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
#define a1
template<typename Coll >
decltype(auto) util::const_values ( Coll &&  coll)

Range-for loop helper iterating across the constant values of the specified collection.

See also
util::values()

This function is equivalent to util::values() but the values are extracted as if the specified collection were constant.

template<typename T >
auto util::counter ( begin,
end 
)

Returns an object to iterate values from begin to end in a range-for loop.

Template Parameters
Ttype of counter value
Returns
a control object for range-for loop
See also
util::count_iterator

An example of usage:

std::vector<std::size_t> data;
for (auto i: util::counter(4, 8)) {
data.push_back(i);
}

will insert in data the numbers from 4 to 7, just like:

for (std::size_t i = 4; i < 8; ++i) {
data.push_back(i);
}

would.

Definition at line 295 of file counter.h.

References util::count_iterator< T >::count_iterator(), and span().

Referenced by opdet::SimPhotonCounterAlg::AddSimPhotonCollection(), opdet::SimPhotonCounterAlg::AddSimPhotonsVector(), lar::details::bulk_allocator::ReferenceCounter::AddUser(), NestAlg::CalculateIonizationAndScintillation(), opdet::SimPhotonCounterAlg::ClearCounters(), lar::details::bulk_allocator::ReferenceCounter::Count(), counter(), larg4::OpFastScintillation::detectedDirectHits(), phot::SemiAnalyticalModel::detectedDirectVisibilities(), larg4::OpFastScintillation::detectedReflecHits(), phot::SemiAnalyticalModel::detectedReflectedVisibilities(), larg4::AuxDetSD::EndOfEvent(), trkf::KGTrack::fillHits(), trkf::SeedFinderAlgorithm::FindSeedAtEnd(), phot::PropagationTimeModel::getVISTimes(), larg4::OpFastScintillation::getVISTimes(), lar::details::bulk_allocator::ReferenceCounter::hasUsers(), calo::TrackCalorimetryAlg::IsInvertedTrack(), lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterKey_t::Key(), ClusteringValidation::ClusterAnalyser::MakeHistograms(), phot::PropagationTimeModel::opDetCenters(), phot::PDFastSimPAR::opDetCenters(), phot::PropagationTimeModel::opDetOrientations(), art::detail::IPRHelper< ProdA, ProdB, Data, DATACOLL, EVENT >::operator()(), larg4::OpFastScintillation::OpFastScintillation(), phot::SemiAnalyticalModel::opticalDetectors(), sim::MergeSimSources::produce(), evgen::RadioGen::RadioGen(), pmtana::AlgoSiPM::RecoPulse(), pmtana::AlgoThreshold::RecoPulse(), larg4::OpFastScintillation::RecordPhotonsProduced(), lar::details::bulk_allocator::ReferenceCounter::RemoveUser(), shower::LArPandoraShowerAlg::RMSShowerGradient(), hit::HitAnaAlg::ROIInfo(), lar_content::TransverseMatrixVisualizationTool::Run(), lar_content::ShowerTensorVisualizationTool::Run(), and lar_content::TransverseTensorVisualizationTool::Run().

296 {
297  return util::span(count_iterator(begin), count_iterator(end));
298 }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
template<typename T >
auto util::counter ( end)

Version of util::counter() starting at default-constructed T (usually some form of 0).

Definition at line 194 of file counter.h.

References counter(), end(), and infinite_counter().

195  {
196  return counter(T{}, end);
197  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
auto counter(T end)
Definition: counter.h:194
template<class T , class U >
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.

Template Parameters
Ttype of the new object to associate
Utype of the object already in the data product or art::Ptr
Parameters
evtreference to the current event
avector of data products that are in, or will be put into, evt
bart::Ptr to the (new) object to be associated to the one in a
assnreference to association object where the new one will be put
a_instancename of the instance that will be used for a in evt
indexindex of the element in a to be associated with b (default: the last element)
Returns
whether the operation was successful (can it ever fail??)

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(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 558 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), e, and tca::evt.

Referenced by cluster::ClusterMergeHelper::AppendResult(), CreateAssn(), lar_cluster3d::Cluster3D::findTrackSeeds(), nnet::EmTrack< N >::make_clusters(), lar_cluster3d::Cluster3D::ArtOutputHandler::makeClusterHitAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makeEdgeSpacePointAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makePFPartClusterAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makePFPartEdgeAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makePFPartPCAAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makePFPartSeedAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makePFPartSpacePointAssns(), lar_cluster3d::Cluster3D::ArtOutputHandler::makeSpacePointHitAssns(), pid::Chi2ParticleID::produce(), cosmic::TrackPFParticleMatch::produce(), lar_pandora::LArPandoraShowerCreation::produce(), lar_pandora::LArPandoraTrackCreation::produce(), vertex::VertexCheater::produce(), event::EventCheater::produce(), shwf::ShowerCheater::produce(), cosmic::CosmicClusterTagger::produce(), trk::TrackContainmentTagger::produce(), trkf::TCTrack::produce(), cosmic::CosmicTrackTagger::produce(), trkf::SpacePointCheater::produce(), trkf::SpacePointFinder::produce(), tss::TrackShowerHits::produce(), trkf::TrackCheater::produce(), cluster::LineCluster::produce(), cosmic::CosmicPFParticleTagger::produce(), sppt::TTSpacePointFinder::produce(), opdet::OpFlashFinder::produce(), cluster::ClusterCheater::produce(), cluster::ClusterCrawler::produce(), shwf::ShowerFinder::produce(), trkf::TrackStitcher::produce(), vertex::PrimaryVertexFinder::produce(), cluster::DBcluster::produce(), caldata::CalWire::produce(), cosmic::BeamFlashTrackMatchTagger::produce(), cluster::EndPointModule::produce(), caldata::CalWireT962::produce(), cluster::DBCluster3D::produce(), cluster::HoughLineFinder::produce(), cluster::LineMerger::produce(), calo::ShowerCalorimetry::produce(), calo::TrackCalorimetry::produce(), shower::TCShower::produce(), cosmic::CosmicPCAxisTagger::produce(), trkf::SpacePts::produce(), ShowerReco3D::produce(), trkf::Track3Dreco::produce(), cluster::BlurredClustering::produce(), cluster::TrajCluster::produce(), ems::EMShower3D::produce(), trkf::CCTrackMaker::produce(), trkf::Track3DKalman::produce(), shwf::ShowerReco::produce(), cluster::SmallClusterFinder::produce(), trkf::TrackKalmanCheater::produce(), vertex::VertexFinder2D::produce(), evd::GraphCluster::produce(), lbne::PhotonCounterT0Matching::produce(), trkf::PMAlgTrajFitter::produce(), t0::MCTruthT0Matching::produce(), calo::Calorimetry::produce(), evgen::GENIEGen::produce(), trkf::Track3DKalmanSPS::produce(), nnet::EmTrackClusterId2out::produce(), nnet::EmTrackClusterId::produce(), nnet::EmTrackMichelId::produce(), trkf::PMAlgTrackMaker::produce(), calo::GnocchiCalorimetry::produce(), trkf::CosmicTracker::produce(), and mvapid::MVAAlg::RunPID().

565 {
566  if (index == UINT_MAX) index = a.size() - 1;
567 
568  try {
569  assn.addSingle(b, art::PtrMaker<T>{evt, a_instance}(index));
570  return true;
571  }
572  catch (cet::exception& e) {
573  mf::LogWarning("AssociationUtil")
574  << "unable to create requested art:Assns, exception thrown: " << e;
575  return false;
576  }
577 
578 } // util::CreateAssn() [01]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TCEvent evt
Definition: DataStructs.cxx:8
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class U >
bool util::CreateAssn ( art::Event evt,
std::vector< T > const &  a,
art::Ptr< U > const &  b,
art::Assns< U, T > &  assn,
size_t  index = UINT_MAX 
)
inline

Creates a single one-to-one association.

Template Parameters
Ttype of the new object to associate
Utype of the object already in the data product or art::Ptr
Parameters
evtreference to the current event
avector of data products that are in, or will be put into, evt
bart::Ptr to the (new) object to be associated to the one in a
assnreference to association object where the new one will be put
indexindex of the element in a to be associated with b (default: the last element)
Returns
whether the operation was successful (can it ever fail??)

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(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.

References CreateAssn(), CreateAssnD(), tca::evt, FindUNotAssociatedToT(), FindUNotAssociatedToTP(), GetAssociatedVectorManyI(), GetAssociatedVectorManyP(), GetAssociatedVectorOneI(), GetAssociatedVectorOneP(), geo::vect::indices(), and lar::dump::vector().

216  {
217  return CreateAssn(evt, a, b, assn, std::string(), index);
218  }
std::enable_if_t< std::is_base_of_v< art::EDProducer, Producer >, bool > CreateAssn(Producer const &, Args &&...args)
template<class T , class U >
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.

Template Parameters
Ttype of one object to associate
Utype of the other object to associate
Parameters
evtreference to the current event
aart::Ptr to the first object in the association
bart::Ptr to the object to be associated to the one in a
assnreference to association object where the new one will be put
Returns
whether the operation was successful (can it ever fail??)

This is the simplest way ever. Neither the event not the producer references are used.

Definition at line 583 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

587 {
588 
589  try {
590  assn.addSingle(b, a);
591  }
592  catch (cet::exception& e) {
593  mf::LogWarning("AssociationUtil")
594  << "unable to create requested art:Assns, exception thrown: " << e;
595  return false;
596  }
597 
598  return true;
599 } // util::CreateAssn() [03]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class U >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
evtreference to the current event
avector of data products that are in, or will be put into, evt
bart::PtrVector to the (new) objects to be associated to the one in a
assnreference to association object where the new one will be put
indexindex of the element in a to be associated with all the ones in b (default: the last element)
Returns
whether the operation was successful (can it ever fail??)

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 604 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

610 {
611  if (index == UINT_MAX) index = a.size() - 1;
612 
613  try {
614  auto const aptr = art::PtrMaker<T>{evt}(index);
615  for (art::Ptr<U> const& b_item : b)
616  assn.addSingle(aptr, b_item);
617  }
618  catch (cet::exception& e) {
619  mf::LogWarning("AssociationUtil")
620  << "unable to create requested art:Assns, exception thrown: " << e;
621  return false;
622  }
623 
624  return true;
625 } // util::CreateAssn() [04]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
Definition: fwd.h:26
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class U >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
evtreference to the current event
aart::Ptr to the item to be associated with many
bvector to art::Ptr to the (new) objects to be associated to a
assnreference to association object where the new one will be put
Returns
whether the operation was successful (can it ever fail??)

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 630 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

634 {
635 
636  try {
637  for (art::Ptr<U> const& b_item : b)
638  assn.addSingle(a, b_item);
639  }
640  catch (cet::exception const& e) {
641  mf::LogWarning("AssociationUtil")
642  << "unable to create requested art:Assns, exception thrown: " << e;
643  return false;
644  }
645 
646  return true;
647 } // util::CreateAssn() [05]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
Definition: fwd.h:26
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class U >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
evtreference to the current event
avector of data products that are in, or will be put into, evt
bvector to art::Ptr to the (new) objects to be associated to the one in a
assnreference to association object where the new one will be put
indexindex of the element in a to be associated with all the ones in b (default: the last element)
Returns
whether the operation was successful (can it ever fail??)

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 652 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

658 {
659 
660  if (index == UINT_MAX) index = a.size() - 1;
661 
662  try {
663  auto const aptr = art::PtrMaker<T>{evt}(index);
664  for (art::Ptr<U> const& b_item : b)
665  assn.addSingle(aptr, b_item);
666  }
667  catch (cet::exception& e) {
668  mf::LogWarning("AssociationUtil")
669  << "unable to create requested art:Assns, exception thrown: " << e;
670  return false;
671  }
672 
673  return true;
674 } // util::CreateAssn() [06]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
Definition: fwd.h:26
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class U >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
evtreference to the current event
avector of data products that are in, or will be put into, evt
bvector of the (new) objects to be associated to the one in a
assnreference to association object where the new one will be put
startUindex in b of the first element to be associated to the one in a
endUindex in b after the last element to be associated to the one in a
indexindex of the element in a to be associated with all the ones in b (default: the last element)
Returns
whether the operation was successful (can it ever fail??)

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 679 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

687 {
688 
689  if (index == UINT_MAX) index = a.size() - 1;
690 
691  try {
692  auto const aptr = art::PtrMaker<T>{evt}(index);
693  art::PtrMaker<U> const make_bptr{evt};
694  for (size_t i = startU; i < endU; ++i) {
695  assn.addSingle(aptr, make_bptr(i));
696  }
697  }
698  catch (cet::exception& e) {
699  mf::LogWarning("AssociationUtil")
700  << "unable to create requested art:Assns, exception thrown: " << e;
701  return false;
702  }
703 
704  return true;
705 } // util::CreateAssn() [07]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class T , class U >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
evtreference to the current event
avector of data products that are in, or will be put into, evt
bvector of the (new) objects to be associated to the one in a
assnreference to association object where the new one will be put
indicesindices of the elements in b to be associated to the one in a
indexindex of the element in a to be associated with all the ones in b (default: the last element)
Returns
whether the operation was successful (can it ever fail??)

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 710 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

717 {
718 
719  if (index == UINT_MAX) index = a.size() - 1;
720 
721  try {
722  auto const aptr = art::PtrMaker<T>{evt}(index);
723  art::PtrMaker<U> const make_bptr{evt};
724  for (size_t index : indices) {
725  assn.addSingle(aptr, make_bptr(index));
726  }
727  }
728  catch (cet::exception& e) {
729  mf::LogWarning("AssociationUtil")
730  << "unable to create requested art:Assns, exception thrown: " << e;
731  return false;
732  }
733 
734  return true;
735 } // util::CreateAssn() [07a]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T , typename U , typename Iter >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Iteriterator to size_t-compatible elements
Parameters
evtreference to the current event
assnreference to association object where the new one will be put
first_indexindex of the object of type T to be associated to all the others
from_second_indexiterator pointing to the first of the indices of U type objects to be associated to the one of the first type
to_second_indexiterator pointing after the last of the indices of U type objects to be associated to the one of the first type
Returns
whether the operation was successful (can it ever fail??)

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 betweena[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 740 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

745 {
746 
747  try {
748  // we declare here that we want to associate the element first_index of the
749  // (only) data product of type std::vector<T> with other objects.
750  // This is the pointer to that element:
751  auto const first_ptr = art::PtrMaker<T>{evt}(first_index);
752 
753  // we are going to associate that element in a with a number of elements
754  // of the only data product of type std::vector<U>
755  art::PtrMaker<U> const make_second_ptr{evt};
756  for (; from_second_index != to_second_index; ++from_second_index) {
757  assn.addSingle(first_ptr, make_second_ptr(*from_second_index));
758  } // while
759  }
760  catch (cet::exception& e) {
761  mf::LogWarning("AssociationUtil")
762  << "unable to create requested art:Assns, exception thrown: " << e;
763  return false;
764  }
765 
766  return true;
767 } // util::CreateAssn() [08]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename Producer , typename... Args>
std::enable_if_t<std::is_base_of_v<art::EDProducer, Producer>, bool> util::CreateAssn ( Producer const &  ,
Args &&...  args 
)

Definition at line 930 of file AssociationUtil.h.

References CreateAssn().

932  {
933  return CreateAssn(std::forward<Args>(args)...);
934  }
std::enable_if_t< std::is_base_of_v< art::EDProducer, Producer >, bool > CreateAssn(Producer const &, Args &&...args)
template<typename T , typename U , typename D >
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.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Dtype of the "metadata" coupled to this pair association
Parameters
evtreference to the current event
assnreference to association object where the new one will be put
first_indexindex of the object of type T to be associated
second_indexindex of the object of type U to be associated
data"metadata" to be store in this association
Returns
whether the operation was successful (can it ever fail??)

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 772 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

Referenced by CreateAssn(), CreateAssnD(), cluster::LineCluster::produce(), cluster::ClusterCrawler::produce(), and cluster::TrajCluster::produce().

777 {
778 
779  try {
780  // we declare here that we want to associate the element first_index of the
781  // (only) data product of type std::vector<T> with the other object
782  auto const first_ptr = art::PtrMaker<T>{evt}(first_index);
783 
784  // the same to associate the element second_index of the (only)
785  // data product of type std::vector<U> with the first object.
786  auto const second_ptr = art::PtrMaker<U>{evt}(second_index);
787 
788  assn.addSingle(first_ptr, second_ptr, std::move(data));
789  }
790  catch (cet::exception& e) {
791  mf::LogWarning("AssociationUtil")
792  << "unable to create requested art:Assns, exception thrown: " << e;
793  return false;
794  }
795 
796  return true;
797 } // util::CreateAssnD() [01a]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T , typename U , typename D >
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 
)

Creates a single one-to-one association with associated data.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Dtype of the "metadata" coupled to this pair association
Parameters
evtreference to the current event
assnreference to association object where the new one will be put
first_indexindex of the object of type T to be associated
second_indexindex of the object of type U to be associated
data"metadata" to be store in this association
Returns
whether the operation was successful (can it ever fail??)

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 800 of file AssociationUtil.h.

References art::Assns< L, R, D >::addSingle(), and e.

805 {
806 
807  try {
808  // we declare here that we want to associate the element first_index of the
809  // (only) data product of type std::vector<T> with the other object
810  auto const first_ptr = art::PtrMaker<T>{evt}(first_index);
811 
812  // the same to associate the element second_index of the (only)
813  // data product of type std::vector<U> with the first object.
814  auto const second_ptr = art::PtrMaker<U>{evt}(second_index);
815 
816  assn.addSingle(first_ptr, second_ptr, data);
817  }
818  catch (cet::exception& e) {
819  mf::LogWarning("AssociationUtil")
820  << "unable to create requested art:Assns, exception thrown: " << e;
821  return false;
822  }
823 
824  return true;
825 } // util::CreateAssnD() [01b]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename Producer , typename... Args>
std::enable_if_t<std::is_base_of_v<art::EDProducer, Producer>, bool> util::CreateAssnD ( Producer const &  ,
Args &&...  args 
)

Definition at line 937 of file AssociationUtil.h.

References CreateAssnD().

939  {
940  return CreateAssnD(std::forward<Args>(args)...);
941  }
std::enable_if_t< std::is_base_of_v< art::EDProducer, Producer >, bool > CreateAssnD(Producer const &, Args &&...args)
template<typename T >
constexpr T util::DegreesToRadians ( angle)
inline

Converts the argument angle from degrees into radians.

Definition at line 87 of file PhysicalConstants.h.

Referenced by cluster::LazyClusterParamsAlg::StartAngle(), and cluster::StandardClusterParamsAlg::StartAngle().

88  {
89  return angle / 180 * pi<T>();
90  }
decltype(auto) util::dereference ( )

Returns a functor that returns *ptr of its argument ptr.

See also
util::Dereferencer

Example:

std::vector<int> values(ptrs.size());
std::transform
(ptrs.cbegin(), ptrs.cend(), values.begin(), util::dereference());

will fill the vector values with the values pointed by the elements in ptrs.

Definition at line 128 of file operations.h.

129  {
130  return Dereferencer();
131  }
template<typename Stream , typename Left , typename Right , typename Data >
void util::DumpAssociationsIntro ( Stream &&  out,
art::Assns< Left, Right, Data > const &  assns 
)

Dumps a short introduction about specified association.

Template Parameters
Streamtype of output stream
Leftfirst type in the association
Rightsecond type in the association
Datametadata type in the association
Parameters
outoutput stream
assnsthe associations to be dumped

Definition at line 31 of file DumpAssociations.h.

References art::Assns< L, R, D >::size().

32  {
33  out << "Association between '" << cet::demangle_symbol(typeid(Left).name()) << "' and '"
34  << cet::demangle_symbol(typeid(Right).name()) << "'";
35  if (std::is_same<Data, void>()) {
36  out << " with '" << cet::demangle_symbol(typeid(Data).name()) << "' metadata";
37  }
38  if (assns.size() > 0) { out << " contains " << assns.size() << " relations"; }
39  else {
40  out << " is empty";
41  }
42  } // DumpAssociationsIntro<Data>()
size_type size() const
Definition: Assns.h:500
template<std::size_t Lead, typename... Iterables>
auto util::enumerate ( Iterables &&...  iterables)

Range-for loop helper tracking the number of iteration.

Template Parameters
Leadindex of the parameter driving the start and end of the loop
Iterablestype of objects to be iterated together
Parameters
iterablesall iterable objects to be iterated together
Returns
an object suitable for range-for loop

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:

constexpr std::size_t N = 4;
std::array<int, N> twice;
std::vector<double> thrice(N + 1);
for (auto&& [i, a, b]: util::enumerate(twice, thrice)) {
a = 2 * i;
b = 3.0 * i;
} // for

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:

for (auto&& [i, b, a]: util::enumerate<1U>(thrice, twice)) {
a = 2 * i;
b = 3.0 * i;
} // for

(the index is zero-based, so 1U refers to the second argument).

Definition at line 65 of file enumerate.h.

References infinite_counter().

Referenced by ophit::DumpOpHits::analyze(), sim::DumpSimEnergyDeposits::analyze(), ophit::DumpOpFlashes::analyze(), sim::MergeSimSources::dumpConfiguration(), larg4::ISTPC::ISTPC(), makeValueIndex(), larg4::OpFastScintillation::OpFastScintillation(), phot::PDFastSimPAR::PDFastSimPAR(), sim::MergeSimSources::produce(), and evgen::RadioGen::RadioGen().

66  {
67  return zip<Lead + 1>(infinite_counter(), std::forward<Iterables>(iterables)...);
68  }
auto infinite_counter(T begin=T{})
Version of util::counter() starting at begin and never ending.
Definition: counter.h:302
template<typename... Iterables>
auto util::enumerate ( Iterables &&...  iterables)

This version of enumerate implicitly uses the first iterable as lead.

Definition at line 72 of file enumerate.h.

73  {
74  return enumerate<0U>(std::forward<Iterables>(iterables)...);
75  }
template<typename Range , typename Pred >
auto util::filterRangeFor ( Range &&  range,
Pred &&  pred 
) -> decltype(auto)

Provides iteration only through elements passing a condition.

Template Parameters
Rangethe data to be iterated
Predthe type of the predicate to be fulfilled
Parameters
rangethe data to be iterated through
predthe predicate to be tested
Returns
an object suitable to be used in a range-for loop

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 ":

std::vector<int> data = { 0, 1, 2, 3, 4, 5, 6 ,7, 8, 9 };
for (int v: util::filterRangeFor(data, [](int v){ return v % 3 == 0; })) {
std::cout << v << " ";
} // for
std::cout << std::endl;

Note that pred may be copied (range will not be).

Requirements

  • 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 128 of file filterRangeFor.h.

Referenced by proxy::TrackCollectionProxyElement< CollProxy >::selectPoints().

129  {
130  return details::FilterRangeForStruct<Range, Pred>(std::forward<Range>(range),
131  std::forward<Pred>(pred));
132  }
template<class T , class U >
std::vector< const U * > util::FindUNotAssociatedToT ( art::Handle< U >  b,
art::Event const &  evt,
std::string const &  label 
)
inline

Definition at line 829 of file AssociationUtil.h.

References fa(), and art::Ptr< T >::get().

Referenced by CreateAssn().

832 {
833  // Do a FindOne for type T for each object of type U
834  // If the FindOne returns an invalid maybe ref, add the pointer
835  // of object type U to the return vector
836 
837  std::vector<const U*> notAssociated;
838 
839  art::FindOne<T> const fa(b, evt, label);
840 
841  for (size_t u = 0; u < b->size(); ++u) {
842  cet::maybe_ref<T const> t(fa.at(u));
843  if (!t.isValid()) {
844  art::Ptr<U> ptr(b, u);
845  notAssociated.push_back(ptr.get());
846  }
847  }
848 
849  return notAssociated;
850 }
TCEvent evt
Definition: DataStructs.cxx:8
Definition: fwd.h:26
TFile fa("Li7.root")
template<class T , class U >
std::vector< art::Ptr< U > > util::FindUNotAssociatedToTP ( art::Handle< U >  b,
art::Event const &  evt,
std::string const &  label 
)
inline

Definition at line 854 of file AssociationUtil.h.

References fa().

Referenced by CreateAssn().

857 {
858  // Do a FindOneP for type T for each object of type U
859  // If the FindOne returns an invalid maybe ref, add the pointer
860  // of object type U to the return vector
861 
862  std::vector<art::Ptr<U>> notAssociated;
863 
864  art::FindOneP<T> const fa(b, evt, label);
865 
866  for (size_t u = 0; u < b->size(); ++u) {
867  cet::maybe_ref<T const> t(fa.at(u));
868  if (!t.isValid()) { notAssociated.emplace_back(b, u); }
869  }
870 
871  return notAssociated;
872 }
TCEvent evt
Definition: DataStructs.cxx:8
TFile fa("Li7.root")
template<class A , class F >
void util::for_each_associated_group ( A const &  assns,
F &  func 
)

Helper functions to access associations in order.

Template Parameters
Atype of association being read
Ftype of functor to be called on each associated group
Parameters
assnsthe association being read
funcfunctor to be called on each associated group
See also
associated_groups() art::for_each_group()
Deprecated:
Moved into canvas: art::for_each_group().

Definition at line 46 of file ForEachAssociatedGroup.h.

References art::for_each_group().

48  {
49  art::for_each_group(assns, func);
50  }
void for_each_group(art::Assns< A, B, D > const &assns, F func)
Helper functions to access associations in order.
template<std::size_t... Indices, typename Coll >
decltype(auto) util::get_const_elements ( Coll &&  coll)

Range-for loop helper iterating across the constant values of the specified collection.

See also
util::values()

This function is equivalent to util::values() but the values are extracted as if the specified collection were constant.

Referenced by util::details::get_elements_impl< Coll, First, Others >::iterate().

template<std::size_t... Indices, typename Coll >
decltype(auto) util::get_elements ( Coll &&  coll)

Range-for loop helper iterating across some of the element of each value in the specified collection.

Template Parameters
Indicesindices of the elements to extract
Colltype of the collection to iterate through
Parameters
collthe collection to iterate through
Returns
an object suitable for range-for loop
See also
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):

std::vector<std::tuple<char, int, float>> data
{ { 'z', 0, 1.0F }, { 'o', 1, 3.0F }, { 't', 2, 9.0F } };
std::map<char, double> factors;
for (auto const& [ letter, factor ]: util::get_elements<0U, 2U>(data)) {
factors.emplace(letter, factor);
}

If only one index is specified, the loop will not use structured binding, but rather a simple variable:

std::vector<int> exponents;
for (int exponent: util::get_elements<1U>(data)) {
exponents.push_back(exponent);
}

While the examples do not demonstrate changing the values in the data collection, that is also supported.

Note
This function also works with associative containers based on std::pair (std::map and the likes).

Referenced by util::details::get_elements_impl< Coll, First, Others >::iterate().

template<class T , class U >
std::vector< std::vector< size_t > > util::GetAssociatedVectorManyI ( art::Handle< art::Assns< T, U >>  h,
art::Handle< std::vector< T >>  index_p 
)
inline

Definition at line 895 of file AssociationUtil.h.

Referenced by microboone::CosmicRemovalAna::analyze(), CreateAssn(), cosmic::BeamFlashTrackMatchTagger::produce(), and calo::TrackCalorimetry::produce().

898 {
899  std::vector<std::vector<size_t>> associated_indices(index_p->size());
900  for (auto const& pair : *h)
901  associated_indices.at(pair.first.key()).push_back(pair.second.key());
902  return associated_indices;
903 }
template<class T , class U >
std::vector< std::vector< const U * > > util::GetAssociatedVectorManyP ( art::Handle< art::Assns< T, U >>  h,
art::Handle< std::vector< T >>  index_p 
)
inline

Definition at line 906 of file AssociationUtil.h.

Referenced by CreateAssn().

909 {
910  std::vector<std::vector<const U*>> associated_pointers(index_p->size());
911  for (auto const& pair : *h)
912  associated_pointers.at(pair.first.key()).push_back(&(*(pair.second)));
913  return associated_pointers;
914 }
template<class T , class U >
std::vector< size_t > util::GetAssociatedVectorOneI ( art::Handle< art::Assns< T, U >>  h,
art::Handle< std::vector< T >>  index_p 
)
inline

Definition at line 875 of file AssociationUtil.h.

Referenced by CreateAssn().

877 {
878  std::vector<size_t> associated_index(index_p->size());
879  for (auto const& pair : *h)
880  associated_index.at(pair.first.key()) = pair.second.key();
881  return associated_index;
882 }
template<class T , class U >
std::vector< const U * > util::GetAssociatedVectorOneP ( art::Handle< art::Assns< T, U >>  h,
art::Handle< std::vector< T >>  index_p 
)
inline

Definition at line 885 of file AssociationUtil.h.

Referenced by microboone::CosmicRemovalAna::analyze(), and CreateAssn().

887 {
888  std::vector<const U*> associated_pointer(index_p->size());
889  for (auto const& pair : *h)
890  associated_pointer.at(pair.first.key()) = &(*(pair.second));
891  return associated_pointer;
892 }
template<typename Groups >
auto util::groupByIndex ( Groups &&  groups,
std::size_t  index 
) -> decltype(auto)

Returns the group within groups with the specified index.

Template Parameters
Groupsthe type of collection of groups
Parameters
groupsthe collection of all groups
indexthe index of the group to be accessed
Returns
the group with specified index (may be a reference)
See also
associated_groups()

The groups argument is expected to be the one returned by associated_groups.

Definition at line 173 of file ForEachAssociatedGroup.h.

Referenced by TrackProducerFromPFParticle::produce().

174  {
175  return *(std::next(groups.begin(), index));
176  }
template<typename T = std::size_t>
auto util::infinite_counter ( begin = T{})

Version of util::counter() starting at begin and never ending.

Template Parameters
Ttype of counter value
Parameters
beginthe count to start from (default-constructed, usually some form of 0, by default)
Returns
a control object for range-for loop

An example of usage:

std::vector<unsigned char> data;
for (auto ch: util::infinite_counter<unsigned char>()) {
if (data.size() >= 512U) break;
data.push_back(ch);
}

This loop runs through the full range of a character (8 bits, supposedly) twice before being broken.

Definition at line 302 of file counter.h.

References util::count_iterator< T >::count_iterator(), and span().

Referenced by counter(), and enumerate().

303 {
304  return util::span(count_iterator(begin), details::infinite_endcount_iterator<T>());
305 } // util::infinite_counter()
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
template<typename Cont , typename Adaptor >
auto util::make_adapted_const_span ( Cont &  cont,
Adaptor &&  adaptor 
)

Creates constant iteration span from specified collection via an adaptor.

Definition at line 273 of file span.h.

References util::span_base::get_cbegin(), util::span_base::get_cend(), and make_adapted_span().

274  {
275  return make_adapted_span(
276  span_base::get_cbegin(cont), span_base::get_cend(cont), std::forward<Adaptor>(adaptor));
277  }
auto make_adapted_span(Cont &cont, Adaptor &&adaptor)
Creates a span from specified collection via an adaptor.
Definition: span.h:264
template<typename BIter , typename EIter , typename Adaptor >
auto util::make_adapted_span ( BIter  begin,
EIter  end,
Adaptor &&  adaptor 
)

Creates a span from specified iterators via an adaptor.

See also
make_adapted_span(Cont&, Adaptor&&)

Definition at line 227 of file span.h.

References span().

Referenced by make_adapted_const_span(), make_adapted_span(), and make_transformed_span().

228  {
229  return util::span(adaptor(begin), adaptor(end));
230  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
template<typename Cont , typename Adaptor >
auto util::make_adapted_span ( Cont &  cont,
Adaptor &&  adaptor 
)

Creates a span from specified collection via an adaptor.

Parameters
contcollection to be iterated through
adapteriterator transformation to be applied on cont
Returns
a util::span object iterating via an adapter to cont
See also
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:

float accumulate(std::vector<std::unique_ptr<float>> const& v) {
using src_iterator = std::vector<std::unique_ptr<float>>::const_iterator;
float sum = 0.0F;
for (float v: util::make_adapted_span(v, boost::make_indirect_iterator<src_iterator>))
sum += v;
return sum;
} // accumulate()

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 264 of file span.h.

References util::span_base::get_begin(), util::span_base::get_end(), and make_adapted_span().

265  {
266  return make_adapted_span(
267  span_base::get_begin(cont), span_base::get_end(cont), std::forward<Adaptor>(adaptor));
268  }
auto make_adapted_span(Cont &cont, Adaptor &&adaptor)
Creates a span from specified collection via an adaptor.
Definition: span.h:264
template<typename Cont >
auto util::make_const_span ( Cont &  cont)

Creates a span with constant iterator access from a container type.

Definition at line 212 of file span.h.

References util::span_base::get_cbegin(), and util::span_base::get_cend().

213  {
214  return span{span_base::get_cbegin(cont), span_base::get_cend(cont)};
215  }
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
template<typename BIter , typename EIter >
auto util::make_span ( BIter  begin,
EIter  end 
)

Creates a span from specified iterators (can use constructor instead).

Definition at line 198 of file span.h.

References span().

199  {
200  return util::span(begin, end);
201  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
template<typename Cont >
auto util::make_span ( Cont &  cont)

Creates a span from a container type.

Definition at line 205 of file span.h.

References util::span_base::get_begin(), and util::span_base::get_end().

206  {
207  return span{span_base::get_begin(cont), span_base::get_end(cont)};
208  }
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
template<typename Cont , typename Op >
auto util::make_transformed_const_span ( Cont &  cont,
Op &&  op 
)

Creates constant iteration span from specified collection via a transformation op.

Definition at line 349 of file span.h.

References make_transformed_span().

350  {
351  return make_transformed_span(std::as_const(cont), std::forward<Op>(op));
352  }
auto make_transformed_span(Cont &cont, Op &&op)
Creates a span from specified collection via an adaptor.
Definition: span.h:339
template<typename BIter , typename EIter , typename Op >
auto util::make_transformed_span ( BIter  begin,
EIter  end,
Op &&  op 
)

Creates a span from specified iterators via an adaptor.

See also
make_transformed_span(Cont&, Op&&)

Definition at line 294 of file span.h.

References make_adapted_span().

Referenced by util::details::get_elements_impl< Coll, First, Others >::iterate(), make_transformed_const_span(), and make_transformed_span().

295  {
296  auto adaptor = [&op](auto iter) { return boost::make_transform_iterator(iter, op); };
297  return util::make_adapted_span(begin, end, adaptor);
298  }
auto make_adapted_span(BIter begin, EIter end, Adaptor &&adaptor)
Definition: span.h:227
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
template<typename Cont , typename Op >
auto util::make_transformed_span ( Cont &  cont,
Op &&  op 
)

Creates a span from specified collection via an adaptor.

Parameters
contcollection to be iterated through
adapteriterator transformation to be applied on cont
Returns
a util::span object iterating via an adapter to cont
See also
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:

float accumulate(std::vector<std::unique_ptr<float>> const& v) {
float sum = 0.0F;
for (float v: util::make_transformed_span(v, [](auto& ptr){ return *ptr; }))
sum += v;
return sum;
} // accumulate()

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:

void scale(std::vector<std::unique_ptr<float>>& v, float factor) {
for (float& v: util::make_transformed_span(v, [](auto& ptr) -> float& { return *ptr; }))
v *= factor;
} // scale()

Definition at line 339 of file span.h.

References util::span_base::get_begin(), util::span_base::get_end(), and make_transformed_span().

340  {
341  return make_transformed_span(
342  span_base::get_begin(cont), span_base::get_end(cont), std::forward<Op>(op));
343  }
auto make_transformed_span(Cont &cont, Op &&op)
Creates a span from specified collection via an adaptor.
Definition: span.h:339
template<typename Coll , typename KeyOf >
std::vector<size_t> util::MakeIndex ( Coll const &  data,
KeyOf  key_of = KeyOf() 
)

Creates a map of indices from an existing collection.

Template Parameters
Colltype of the collection
KeyOftype of the extractor of the key
Parameters
datathe data collection
key_ofinstance of a functor extracting a key value from a datum
Returns
a vector with indices corresponding to the data keys

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

std::numeric_limits<size_t>::max()

, 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

std::numeric_limits<size_t>::max()

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.

Referenced by recob::HitCollectionAssociator::prepare_associations().

44  {
45 
46  // we start the index with the best guess that all the items will have
47  // a unique key and they are contiguous:
48  // the index would have the same size as the data
49  std::vector<size_t> Index(data.size(), std::numeric_limits<size_t>::max());
50 
51  size_t min_size = 0; // minimum size needed to hold all keys
52 
53  size_t iDatum = 0;
54  for (auto const& datum : data) {
55  size_t key = size_t(key_of(datum));
56  if (key >= min_size) min_size = key + 1;
57  if (Index.size() <= key) {
58  // make room for the entry: double the size
59  Index.resize(std::max(key + 1, Index.size() * 2), std::numeric_limits<size_t>::max());
60  } // if expand index
61  Index[key] = iDatum;
62  ++iDatum;
63  } // for datum
64  Index.resize(min_size);
65  return Index;
66  } // MakeIndex()
template<typename Coll , typename KeyOf >
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.

Template Parameters
Colltype of the collection
KeyOftype of the extractor of the key
Parameters
datathe data collection
key_ofinstance of a functor extracting a key value from a datum
Returns
a vector with pointers to data corresponding to their keys

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 96 of file MakeIndex.h.

98  {
99  using Mapped_t = decltype(key_of(*(data.begin())));
100  using Ptr_t = Mapped_t const*;
101  using Map_t = std::vector<Ptr_t>;
102 
103  // we start the index with the best guess that all the items will have
104  // a unique key and they are contiguous:
105  // the index would have the same size as the data
106  Map_t Index(data.size(), nullptr);
107 
108  size_t min_size = 0; // minimum size needed to hold all keys
109 
110  for (auto const& datum : data) {
111  size_t key = size_t(key_of(datum));
112  if (key >= min_size) min_size = key + 1;
113  if (Index.size() <= key) {
114  // make room for the entry: double the size
115  Index.resize(std::max(key + 1, Index.size() * 2), nullptr);
116  } // if expand index
117  Index[key] = &datum;
118  } // for datum
119  Index.resize(min_size);
120  return Index;
121  } // MakeMap()
template<typename Coll >
auto util::makePointerVector ( Coll &  coll)

Creates a STL vector with pointers to data from another collection.

Template Parameters
Colltype of collection of data
Parameters
colldata collection
Returns
a STL vector with pointers to coll data elements, with same order

Definition at line 186 of file SortByPointers.h.

References util::details::PointerVectorMaker< Coll, typename >::make().

Referenced by sim::DumpSimPhotons::DumpElement(), SortByPointers(), and SortUniquePointers().

187 {
189 }
std::unique_ptr< InputSource > make(fhicl::ParameterSet const &conf, InputSourceDescription &desc)
template<typename... DIMS>
auto util::makeTensorIndices ( DIMS...  dims)

Instantiates a TensorIndices class with the specified dimensions.

Template Parameters
DIMStypes for each of the arguments
Parameters
dimssize of each of the dimensions
Returns
a TensorIndices object with properly initialised 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 529 of file TensorIndices.h.

530  {
531  return TensorIndices<sizeof...(DIMS)>{TensorIndicesBasicTypes::DimSize_t(dims)...};
532  }
template<typename Coll , typename Extractor >
decltype(auto) util::makeValueIndex ( Coll const &  coll,
Extractor  getter 
)

Returns a map of value to index.

Template Parameters
Colltype of container
Extractortype of value extraction function
Parameters
collcontainer to get the map of
getterfunction applied to each element to extract the value for map
Returns
a value-to-index associative container
Exceptions
std::runtime_errorif 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.

Requirements

The collection type Coll must have:

  • value_type type defining the content of the container
  • support begin() and end() free functions returning input iterators, that is support a ranged-for loop

Referenced by makeValueIndex(), and SortUniquePointers().

template<typename Coll >
auto util::makeValueIndex ( Coll const &  coll)

Definition at line 59 of file makeValueIndex.h.

References enumerate(), makeValueIndex(), and to_string().

60  {
62  }
auto makeValueIndex(Coll const &coll)
Transparent functor that returns its argument just as passed.
template<typename Cont , typename Mapping >
auto util::mapContainer ( Cont  cont,
Mapping  mapping 
)

Returns a container-like object mapping the content of cont.

Template Parameters
Conttype of the original container
Mappingtype of mapping object
Parameters
contthe container
mappingthe mapping to be applied
Returns
a util::MappedContainer object transparently applying the mapping

See util::MappedContainer for the details on the format of the mapping, the ownership of the container and the supported operations.

Definition at line 415 of file MappedContainer.h.

416  {
417  return MappedContainer<Cont, Mapping>(cont, mapping);
418  }
template<typename Coll , typename PtrColl >
void util::MoveFromPointers ( Coll &  dest,
PtrColl &  src 
)

Moves the content from a collection of pointers to one of data.

Template Parameters
Colltype of collection of data
PtrColltype of collection of pointers to data
Parameters
destcollection to be filled
srccollection 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 58 of file SortByPointers.h.

References util::details::MoveFromPointersImpl< Coll, PtrColl >::move(), SortByPointers(), and SortUniquePointers().

Referenced by SortByPointers().

59  {
60  details::MoveFromPointersImpl<Coll, PtrColl>::move(dest, src);
61  }
template<typename _Key , typename _Tp , typename _Compare >
bool util::operator!= ( const VectorMap< _Key, _Tp, _Compare > &  __x,
const VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

Based on operator==.

Definition at line 437 of file VectorMap.h.

439  {
440  return !(__x == __y);
441  }
template<unsigned int RANK1, unsigned int RANK2, typename = std::enable_if_t<(RANK1 != RANK2), bool>>
bool util::operator!= ( TensorIndices< RANK1 > const &  a,
TensorIndices< RANK2 > const &  b 
)

Comparison operator with tensors of different rank.

Definition at line 510 of file TensorIndices.h.

Referenced by util::TensorIndices< DIMS >::operator!=().

511  {
512  return true;
513  }
template<typename Cont , typename Mapping , typename Container , typename Reference >
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.

References n.

707  {
708  return it + n;
709  }
Char_t n[5]
template<typename _Key , typename _Tp , typename _Compare >
bool util::operator< ( const VectorMap< _Key, _Tp, _Compare > &  __x,
const VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

Definition at line 425 of file VectorMap.h.

427  {
428  return std::lexicographical_compare(__x.sortedVectorMap.begin(),
429  __x.sortedVectorMap.end(),
430  __y.sortedVectorMap.begin(),
431  __y.sortedVectorMap.end(),
432  __x.valueCompare);
433  }
std::ostream& util::operator<< ( std::ostream &  out,
EventChangeTracker_t const &  trk 
)
inline

Definition at line 97 of file ChangeTrackers.h.

98  {
99  out << std::string(trk);
100  return out;
101  }
std::ostream& util::operator<< ( std::ostream &  out,
DataProductChangeTracker_t const &  trk 
)
inline

Definition at line 197 of file ChangeTrackers.h.

198  {
199  out << std::string(trk);
200  return out;
201  }
std::ostream& util::operator<< ( std::ostream &  out,
PlaneDataChangeTracker_t const &  trk 
)
inline

Definition at line 308 of file ChangeTrackers.h.

309  {
310  out << std::string(trk);
311  return out;
312  }
template<typename _Key , typename _Tp , typename _Compare >
bool util::operator<= ( const VectorMap< _Key, _Tp, _Compare > &  __x,
const VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

Based on operator<.

Definition at line 453 of file VectorMap.h.

455  {
456  return !(__y < __x);
457  }
template<typename _Key , typename _Tp , typename _Compare >
bool util::operator== ( const VectorMap< _Key, _Tp, _Compare > &  __x,
const VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

Definition at line 418 of file VectorMap.h.

References util::VectorMap< _Key, _Tp, _Compare >::sortedVectorMap.

420  {
421  return __x.sortedVectorMap == __y.sortedVectorMap;
422  }
template<unsigned int RANK1, unsigned int RANK2, typename = std::enable_if_t<(RANK1 != RANK2), bool>>
bool util::operator== ( TensorIndices< RANK1 > const &  a,
TensorIndices< RANK2 > const &  b 
)

Comparison operator with tensors of different rank.

Definition at line 501 of file TensorIndices.h.

Referenced by util::TensorIndices< DIMS >::operator==().

502  {
503  return false;
504  }
template<typename _Key , typename _Tp , typename _Compare >
bool util::operator> ( const VectorMap< _Key, _Tp, _Compare > &  __x,
const VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

Based on operator<.

Definition at line 445 of file VectorMap.h.

447  {
448  return __y < __x;
449  }
template<typename _Key , typename _Tp , typename _Compare >
bool util::operator>= ( const VectorMap< _Key, _Tp, _Compare > &  __x,
const VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

Based on operator<.

Definition at line 461 of file VectorMap.h.

463  {
464  return !(__x < __y);
465  }
template<typename Range >
auto util::operator| ( Range &&  range,
RangeForWrapperTag   
) -> decltype(auto)

Transforms a range so that it can be used in a range-for loop.

Template Parameters
Rangethe type of range to be transformed
Parameters
rangethe range to be transformed
Returns
an equivalent range object to be used in a range-for loop

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:

Range data; // initialization
for (auto&& value: data | util::range_for) // ...

where data is supposed to gave begin and end iterators of different types.

Definition at line 470 of file RangeForWrapper.h.

References wrapRangeFor().

471  {
472  return wrapRangeFor(std::forward<Range>(range));
473  }
auto wrapRangeFor(Range &&range) -> decltype(auto)
Wraps an object for use in a range-for loop.
template<typename T >
constexpr T util::RadiansToDegrees ( angle)
inline

Converts the argument angle from radians into degrees ( $ \pi \rightarrow 180 $)

Definition at line 94 of file PhysicalConstants.h.

Referenced by geo::OpDetGeo::ThetaZ(), and geo::WireGeo::ThetaZ().

95  {
96  return angle / pi<T>() * 180;
97  }
template<typename Coll , typename Sorter >
void util::SortByPointers ( Coll &  coll,
Sorter  sorter 
)

Applies sorting indirectly, minimizing data copy.

Template Parameters
Colltype of collection to be sorted
Sortertype of sorter
Parameters
collcollection to be sorted
sorterfunctor 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:

  1. create a parallel vector of pointers to the data
  2. sort the data pointers (delegating to sorter)
  3. move the data, sorted, from the original collection to a new one
  4. replace the content of cont with the one from the sorted collection

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.

Note
Use this algorithm only as a last resort, as there are usually better ways to sort collections than this one, which is not even particularly optimized.

Definition at line 193 of file SortByPointers.h.

References makePointerVector(), and MoveFromPointers().

Referenced by MoveFromPointers().

194 {
195 
196  using coll_t = Coll;
197 
198  //
199  // create the collection of pointers to data
200  //
201  auto ptrs = makePointerVector(coll);
202 
203  //
204  // delegate the sorting by pointers
205  //
206  sorter(ptrs);
207 
208  //
209  // create a sorted collection moving the content from the original one
210  //
211  coll_t sorted;
212  MoveFromPointers(sorted, ptrs);
213 
214  //
215  // replace the old container with the new one
216  //
217  coll = std::move(sorted);
218 
219 } // util::SortByPointers()
auto makePointerVector(Coll &coll)
Creates a STL vector with pointers to data from another collection.
void MoveFromPointers(Coll &dest, PtrColl &src)
Moves the content from a collection of pointers to one of data.
template<typename Coll , typename Sorter >
void util::SortUniquePointers ( Coll &  coll,
Sorter &&  sorter 
)

Sorts a vector of unique pointers using a C pointer sorter.

Template Parameters
Colltype of collection to be sorted
Sortertype of sorter function
Parameters
collcollection to be sorted
sortersorting 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 223 of file SortByPointers.h.

References makePointerVector(), and makeValueIndex().

Referenced by MoveFromPointers().

224 {
225 
226  using Collection_t = Coll;
227  using UPtr_t = typename Collection_t::value_type;
228 
229  static_assert(util::is_unique_ptr_v<UPtr_t>);
230 
231  //
232  // create the collection of pointers to data
233  //
234  auto ptrs = makePointerVector(coll);
235 
236  // data pointer -> index
237  auto const ptrIndex = util::makeValueIndex(ptrs);
238 
239  //
240  // delegate the sorting by pointers
241  //
242  sorter(ptrs);
243 
244  //
245  // create a sorted collection moving the content from the original one
246  //
247  Collection_t sorted;
248  for (auto const& dataPtr : ptrs) {
249  std::size_t const originalIndex = ptrIndex.at(dataPtr);
250  sorted.emplace_back(std::move(coll[originalIndex]));
251  }
252 
253  //
254  // replace the old container with the new one
255  //
256  coll = std::move(sorted);
257 
258 } // util::SortUniquePointers()
auto makePointerVector(Coll &coll)
Creates a STL vector with pointers to data from another collection.
decltype(auto) makeValueIndex(Coll const &coll, Extractor getter)
Returns a map of value to index.
template<typename IterB , typename IterE , typename Adaptor >
util::span ( IterB &&  b,
IterE &&  e,
Adaptor &&  adaptor 
) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
template<typename _Key , typename _Tp , typename _Compare >
void util::swap ( VectorMap< _Key, _Tp, _Compare > &  __x,
VectorMap< _Key, _Tp, _Compare > &  __y 
)
inline

See VectorMap::swap().

Definition at line 469 of file VectorMap.h.

References util::VectorMap< _Key, _Tp, _Compare >::swap().

470  {
471  __x.swap(__y);
472  }
decltype(auto) util::takeAddress ( )

Returns a functor that returns the address of its argument.

See also
util::AddressTaker

Example:

std::vector<int*> ptrs(data.size());
std::transform
(data.begin(), data.end(), ptrs.begin(), util::takeAddress());

will fill the vector ptrs with pointers to the elements of data.

Why bother?

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:

using addressof_t = int const*(*)(int const&);
std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtr),
((addressof_t) &std::addressof));

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:

auto takeAddress = [](auto&& ref){ return std::addressof(ref); };
std::vector<int const*> dataPtr;
std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtr),

This util::takeAddress() operates in a very similar way to the lambda in the last example.

Definition at line 85 of file operations.h.

86  {
87  return AddressTaker();
88  }
template<typename Coll >
decltype(auto) util::values ( Coll &&  coll)

Range-for loop helper iterating across the values of the specified collection.

Template Parameters
Colltype of the collection to iterate through
Parameters
collthe collection to iterate through
Returns
an object suitable for range-for loop
See also
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.

std::map<int, float> data { { 1, 4.0F }, { 3, 12.0F }, { 2, 8.0F } };
std::vector<float> values;
for (float value: util::values(data))
values.push_back(value);

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).

Referenced by ophit::DumpOpFlashes::analyze(), associated_groups(), associated_groups_with_left(), lar::sparse_vector< T >::datarange_t::begin(), artg4tk::ActionHolderService::beginOfEventAction(), artg4tk::ActionHolderService::callArtProduces(), lar::sparse_vector< T >::datarange_t::cbegin(), lar::sparse_vector< T >::datarange_t::cend(), shower::EMShowerAlg::CheckIsolatedHits_(), util::flags::BitMask< Storage >::clear(), art::ProductInserter::commitProducts(), keras::LayerMaxPooling::compute_output(), art::Principal::createGroupsForProducedProducts(), art::detail::SharedResources::createQueues(), art::Principal::ctor_create_groups(), lar::sparse_vector< T >::datarange_t::datarange_t(), art::OutputModule::doSelectProducts(), lar::sparse_vector< T >::datarange_t::dump(), evdb::ParameterSetEdit::Edit(), lar::sparse_vector< T >::datarange_t::end(), sim::POTaccumulator::endJob(), larg4::ParticleListActionService::endOfEventAction(), artg4tk::ActionHolderService::endOfEventAction(), art::EndPathExecutor::EndPathExecutor(), lar::sparse_vector< T >::datarange_t::extend(), anab::FeatureVector< N >::FeatureVector(), cluster::BlurredClusteringAlg::FindClusters(), shower::EMShowerAlg::FindShowers(), art::for_each_group(), art::for_each_group_with_left(), art::detail::SharedResources::freeze(), artg4tk::ActionHolderService::generatePrimaries(), lar::sparse_vector< T >::datarange_t::get_const_iterator(), lar_content::LArConnectionPathwayHelper::GetMinMiddleMax(), art::ServicesManager::getParameterSets(), shower::EMShowerAlg::GetPlanePermutations_(), lariov::DBFolder::GetSQLiteData(), art::GroupSelector::GroupSelector(), artg4tk::ActionHolderService::initialize(), artg4tk::ActionHolderService::killNewTrack(), art::make_product_descriptions(), lar::util::MinMaxCollector< float >::MinMaxCollector(), lar::sparse_vector< T >::datarange_t::move_head(), util::flags::BitMask< Storage >::operator!=(), anab::FeatureVector< N >::operator=(), util::flags::BitMask< Storage >::operator==(), lar::sparse_vector< T >::datarange_t::operator[](), art::detail::orderedProcessNamesCollection(), cluster::OverriddenClusterParamsAlg< AlgoBase >::OverrideParameter(), evdb::ParameterSetEditRow::ParameterSetEditRow(), artg4tk::ActionHolderService::postUserTrackingAction(), artg4tk::ActionHolderService::preUserTrackingAction(), art::FileDumperOutput::printPrincipal(), evgen::larg4SingleGen::printVecs(), evgen::SingleGen::printVecs(), art::detail::prune_config_if_enabled(), art::Principal::readImmediate(), geo::fhicl::readOptionalIDsequence(), lar_content::SupportVectorMachine::ReadSupportVector(), art::ProductRegistryHelper::registerProducts(), art::ServicesManager::registerProducts(), art::PathsInfo::reset(), lar::sparse_vector< T >::datarange_t::resize(), anab::FeatureVector< N >::set(), anab::FVectorWriter< 4 >::setVector(), geo::vect::transformCoords(), and artg4tk::ActionHolderService::userSteppingAction().

template<typename Range >
auto util::wrapRangeFor ( Range &&  range) -> decltype(auto)

Wraps an object for use in a range-for loop.

Template Parameters
Rangetype of range object (anything with begin() and end())
Parameters
rangeinstance 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:

Range data; // initialization
for (auto&& value: util::wrapRangeFor(data)) // ...

where data is supposed to gave begin and end iterators of different types.

Definition at line 440 of file RangeForWrapper.h.

Referenced by operator|().

441  {
442  return details::WrapRangeForDispatcher<Range>::wrap(std::forward<Range>(range));
443  }
template<std::size_t Lead, typename... Iterables>
auto util::zip ( Iterables &&...  iterables)

Range-for loop helper iterating across many collections at the same time.

Template Parameters
Leadindex of the parameter driving the start and end of the loop
Iterablestype of objects to be iterated together
Parameters
iterablesall iterable objects to be iterated together
Returns
an object suitable for range-for loop
See also
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:

constexpr std::size_t N = 4;
std::array<int, N> twice;
std::vector<double> thrice(N + 1);
unsigned int i = 0;
for (auto&& [ a, b]: util::zip(twice, thrice)) {
a = 2 * i;
b = 3.0 * i;
++i;
} // for

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:

unsigned int i = 0;
for (auto&& [ b, a]: util::zip<1U>(thrice, twice)) {
a = 2 * i;
b = 3.0 * i;
++i;
} // for

(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 293 of file zip.h.

References span().

Referenced by detinfo::DetectorClocksStandard::debugReport(), and sim::MergeSimSources::produce().

294 {
295 
296  return util::span(details::make_zip_begin_iterator<Lead>(iterables...),
297  details::make_zip_end_iterator<Lead>(iterables...));
298 
299 } // util::zip()
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
template<typename... Iterables>
auto util::zip ( Iterables &&...  iterables)

Version of zip() with first iterator implicitly leading the iteration.

Range-for loop helper iterating across many collections at the same time.

Definition at line 78 of file zip.h.

References span().

Referenced by detinfo::DetectorClocksStandard::debugReport(), and sim::MergeSimSources::produce().

79  {
80  return zip<0U>(std::forward<Iterables>(iterables)...);
81  }

Variable Documentation

constexpr double util::kc = 29.9792458

Speed of light in vacuum in LArSoft units [cm/ns].

Definition at line 59 of file PhysicalConstants.h.

Referenced by genf::GFEnergyLossBrems::energyLoss(), and genf::GFMaterialEffects::energyLossBrems().

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::kINVALID_DOUBLE = std::numeric_limits<double>::max()

Definition at line 35 of file GeometryUtilities.h.

Referenced by util::GeometryUtilities::Get3DaxisN().

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.

Referenced by sim::LArG4Parameters::LArG4Parameters().

constexpr double util::kModBoxB = 0.212

Modified Box Beta in g/(MeV cm²)*kV/cm.

Definition at line 50 of file PhysicalConstants.h.

Referenced by calo::CalorimetryAlg::CalorimetryAlg(), and sim::LArG4Parameters::LArG4Parameters().

constexpr double util::kRecombA = 0.800
constexpr double util::kRecombk = 0.0486
constexpr double util::quietCompiler
Initial value:
=
constexpr int kBogusI
obviously bogus integer value
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
constexpr float kBogusF
obviously bogus float value
constexpr double kRecombk
constexpr double kBogusD
obviously bogus double value
constexpr double kRecombA
A constant.

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 450 of file RangeForWrapper.h.

Referenced by associated_groups(), and associated_groups_with_left().

const float util::SQRT_TWO_PI = 2.506628

Definition at line 18 of file GaussianEliminationAlg.h.