LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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
 

Classes

struct  add_tag
 
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_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...
 
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...
 
class  DetectorPropertiesServiceArgoNeuT
 
class  EventChangeTracker_t
 Detects the presence of a new event. More...
 
struct  extract_to_tuple_type
 Returns type TargetClass<U...> from a SrcTuple<T...>. More...
 
class  FileCatalogMetadataExtras
 
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  KeepByPositionFilterTag
 Tag for filters. More...
 
class  LArFFT
 
class  LArPropertiesServiceArgoNeuT
 Properties related to liquid argon environment in the detector. More...
 
class  LazyVector
 A contiguous data container expanded on write. 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  remove_tag
 Trait holding the type contained in a TaggedType (or the type itself). More...
 
struct  remove_tag< TaggedType< T, Tag > >
 
class  RootGraphicsEnablingService
 Trojan service to inject initialization code. More...
 
struct  self_type
 Trait returning the very same type as in the template argument. More...
 
class  SignalShaping
 
class  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
 

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 T >
using self_t = typename self_type< T >::type
 The very same type as in the template argument. More...
 
template<bool Value>
using bool_constant = std::integral_constant< bool, Value >
 
template<typename BoolTrait >
using negation = bool_constant<!BoolTrait::value >
 
template<typename A , typename B >
using is_not_same = negation< std::is_same< A, B >>
 
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 LArPropertiesArgoNeuT = LArPropertiesServiceArgoNeuT
 type of provider name following LArSoft name convention 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 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 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 PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
 Creates a single one-to-one association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, size_t indx=UINT_MAX)
 Creates a single one-to-one association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, art::Ptr< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn)
 Creates a single one-to-one association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::PtrVector< U > const &b, art::Assns< T, U > &assn, size_t indx=UINT_MAX)
 Creates a single one-to-many association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, art::Ptr< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn)
 Creates a single one-to-many association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< art::Ptr< U >> const &b, art::Assns< T, U > &assn, size_t indx=UINT_MAX)
 Creates a single one-to-many association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX)
 Creates a single one-to-many association. More...
 
template<class PRODUCER , class T , class U >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, std::vector< U > const &b, art::Assns< T, U > &assn, std::vector< size_t > const &indices, size_t indx=UINT_MAX)
 Creates a single one-to-many association. More...
 
template<typename PRODUCER , typename T , typename U , typename Iter >
bool CreateAssn (PRODUCER const &prod, art::Event &evt, art::Assns< T, U > &assn, size_t first_index, Iter from_second_index, Iter to_second_index)
 Creates a single one-to-many association. More...
 
template<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 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 _Key , typename _Tp , typename _Compare >
bool operator== (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
 
template<typename _Key , typename _Tp , typename _Compare >
bool operator< (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
 
template<typename _Key , typename _Tp , typename _Compare >
bool operator!= (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
 Based on operator==. More...
 
template<typename _Key , typename _Tp , typename _Compare >
bool operator> (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
 Based on operator<. More...
 
template<typename _Key , typename _Tp , typename _Compare >
bool operator<= (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
 Based on operator<. More...
 
template<typename _Key , typename _Tp , typename _Compare >
bool operator>= (const VectorMap< _Key, _Tp, _Compare > &__x, const VectorMap< _Key, _Tp, _Compare > &__y)
 Based on operator<. More...
 
template<typename _Key , typename _Tp , typename _Compare >
void swap (VectorMap< _Key, _Tp, _Compare > &__x, VectorMap< _Key, _Tp, _Compare > &__y)
 See VectorMap::swap(). More...
 
std::ostream & operator<< (std::ostream &out, EventChangeTracker_t const &trk)
 
std::ostream & operator<< (std::ostream &out, DataProductChangeTracker_t const &trk)
 
std::ostream & operator<< (std::ostream &out, PlaneDataChangeTracker_t const &trk)
 
template<typename 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...
 
template<typename A , typename B >
constexpr auto absDiff (A const &a, B const &b)
 Returns the absolute value of the difference between two values. More...
 
template<typename PRODUCER , typename T , typename U , typename D >
bool CreateAssnD (PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data)
 Creates a single one-to-one association with associated data. More...
 
template<typename PRODUCER , typename T , typename U , typename D >
bool CreateAssnD (PRODUCER const &prod, art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t const &data)
 Creates a single one-to-one association with associated data. 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...
 
constexpr double kGeVToElectrons = 4.237e7
 23.6eV per ion pair, 1e9 eV/GeV More...
 
constexpr double kc = 29.9792458
 Speed of light in vacuum in LArSoft units [cm/ns]. More...
 
constexpr double kMeterToCentimeter = 1.e2
 1 m = 100 cm More...
 
constexpr double kCentimeterToMeter = 1./kMeterToCentimeter
 
constexpr double kMeterToKilometer = 1.e-3
 1000 m = 1 km More...
 
constexpr double kKilometerToMeter = 1./kMeterToKilometer
 
constexpr double keVToMeV = 1.e-6
 1e6 eV = 1 MeV More...
 
constexpr double kMeVToeV = 1./keVToMeV
 
constexpr double kBogusD = -999.
 obviously bogus double value More...
 
constexpr int kBogusI = -999
 obviously bogus integer value More...
 
constexpr float kBogusF = -999.
 obviously bogus float value More...
 
constexpr double quietCompiler = kBogusD*kBogusI*kBogusF*kRecombA*kRecombk*kGeVToElectrons
 
const double kINVALID_DOUBLE = std::numeric_limits<Double_t>::max()
 
constexpr RangeForWrapperTag range_for
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr std::size_t index_of_extracted_type_v = index_of_extracted_type<Extractor, Target, Tuple>()
 Direct access to the value in index_of_extracted_type. More...
 
template<typename Target , typename Tuple >
constexpr std::size_t index_of_type_v = index_of_type<Target, Tuple>()
 Direct access to the value in index_of_type. More...
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr bool has_extracted_type_v = has_extracted_type<Extractor, Target, Tuple>()
 Direct access to the value in has_extracted_type. More...
 
template<typename Target , typename Tuple >
constexpr bool has_type_v = has_type<Target, Tuple>()
 Direct access to the value in has_type. More...
 
template<template< typename T, typename... > class Extractor, typename Tuple >
constexpr bool has_duplicate_extracted_types_v = has_duplicate_extracted_types<Extractor, Tuple>()
 Direct access to the value in has_duplicate_extracted_types. More...
 
template<typename Tuple >
constexpr bool has_duplicate_types_v = has_duplicate_types<Tuple>()
 Direct access to the value in has_duplicate_types. More...
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr unsigned int count_extracted_types_v = count_extracted_types<Extractor, Target, Tuple>()
 Direct access to the value in count_extracted_types. More...
 
template<typename Target , typename Tuple >
constexpr unsigned int count_types_v = count_types<Target, Tuple>()
 Direct access to the value in count_extracted_types. More...
 
template<typename Tag , typename Tuple >
constexpr std::size_t index_of_tag_v = index_of_tag<Tag, Tuple>()
 Direct access to the value in index_of_tag. More...
 
template<typename Tag , typename Tuple >
constexpr bool has_tag_v = has_tag<Tag, Tuple>()
 Direct access to the value in has_tag. More...
 
template<typename Tag , typename Tuple >
constexpr unsigned int count_tags_v = count_tags<Tag, Tuple>()
 Direct access to the value in count_tags. More...
 
template<typename Tuple >
constexpr bool has_duplicate_tags_v = has_duplicate_tags<Tuple>()
 Direct access to the value in has_duplicate_tags. More...
 
const float SQRT_TWO_PI = 2.506628
 
Recombination factor coefficients (NIM).
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.

Title: PIDA Algorithim Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov), based on ideas/code from Bruce Baller

Description: Algorithm that calculates the PIDA from a calorimetry object Input: anab::Calorimetry Output: PIDA information

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 267 of file GridContainers.h.

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

Definition at line 181 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 279 of file GridContainers.h.

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

Definition at line 184 of file GridContainerIndices.h.

type of provider name following LArSoft name convention

Definition at line 235 of file LArPropertiesServiceArgoNeuT.h.

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

Type for indexing a 2D-tensor (matrix)

Definition at line 550 of file TensorIndices.h.

Definition at line 48 of file DatabaseUtil.h.

Definition at line 49 of file DatabaseUtil.h.

typedef int util::UBLArSoftCh_t

Definition at line 46 of file DatabaseUtil.h.

Function Documentation

template<typename A , typename B >
constexpr auto util::absDiff ( A const &  a,
B const &  b 
)

Returns the absolute value of the difference between two values.

Template Parameters
Atype of the first value
Btype of the second value (must actually be as A)
Parameters
athe first value
bthe second value
Returns
the difference between the largest and the smallest of a and b

The pecularity of this implementation is that it always avoids taking the difference between the smallest and the largest of a and b. An equivalent implementation is:

return std::max(a, b) - std::min(a, b);

It still assumes that the difference is representable in A; for example, this assumption will fail for int types with a a very large number and b a very small (i.e. negative) number.

Requirements:

  • A and B must be the same type

Definition at line 43 of file NumericUtils.h.

Referenced by cluster::ClusterCrawlerAlg::AddHit(), cluster::ClusterCrawlerAlg::ClusterHitsOK(), cluster::DBScan3DAlg::init(), AcceptFindNeighbors::isNear(), calo::Calorimetry::produce(), pma::ProjectionMatchingAlg::selectInitialHits(), and cluster::ClusterCrawlerAlg::Vtx3ClusterMatch().

44  {
45  static_assert(
46  std::is_same<std::decay_t<A>, std::decay_t<B>>(),
47  "Arguments of util::absDiff() have to be of the same type."
48  );
49  return (b > a)? (b - a): (a - b);
50  }
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 94 of file ForEachAssociatedGroup.h.

References a1, a2, and range_for.

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

94  {
95  return assns |
96  ranges::view::all |
97  ranges::view::group_by([](auto a1, auto a2) { return a1.first == a2.first;}) |
98  ranges::view::transform([] (auto pairs) {return pairs | ranges::view::values | util::range_for;}) |
100  ;
101  } // associated_groups()
#define a2
constexpr RangeForWrapperTag range_for
#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 152 of file ForEachAssociatedGroup.h.

References a1, a2, and range_for.

152  {
153  return assns
154  | ranges::view::all
155  | ranges::view::group_by([](auto a1, auto a2) { return a1.first == a2.first;})
156  | ranges::view::transform([] (auto pairs)
157  {
158  return std::make_pair(
159  pairs.front().first, // assuming they're all the same, pick first
160  pairs | ranges::view::values | util::range_for
161  );
162  })
164  ;
165  } // associated_groups_with_left()
#define a2
constexpr RangeForWrapperTag range_for
#define a1
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
std::vector< T > const &  a,
art::Ptr< U > const &  b,
art::Assns< U, T > &  assn,
std::string  a_instance,
size_t  indx = UINT_MAX 
)

Creates a single one-to-one association.

Template Parameters
Ttype of the new object to associate
Utype of the object already in the data product or art::Ptr
Parameters
prodreference to the producer that will write the vector a
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
indxindex 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(*this, evt, *wirecol, digit_ptr, *WireDigitAssn, spill_name)) {
    throw art::Exception(art::errors::ProductRegistrationFailure)
      << "Can't associate wire #" << (wirecol->size() - 1)
      << " with raw digit #" << digit_ptr.key();
  } // if failed to add association

} // for digits

evt.put(std::move(wirecol), spill_name);
evt.put(std::move(WireDigitAssn), spill_name);

Definition at line 591 of file AssociationUtil.h.

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

Referenced by cluster::ClusterMergeHelper::AppendResult(), CreateAssn(), lar_cluster3d::Cluster3D::findTrackSeeds(), lar_cluster3d::Cluster3D::ArtOutputHandler::makeClusterHitAssns(), 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(), wc::MergeWireCell::MakeShowers(), lar_cluster3d::Cluster3D::ArtOutputHandler::makeSpacePointHitAssns(), wc::MergeWireCell::MakeTracks(), vertex::AggregateVertex::MatchV2T(), event::EventMaker::produce(), opdet::FlashClusterMatch::produce(), lar_pandora::LArPandoraTrackCreation::produce(), lar_pandora::LArPandoraShowerCreation::produce(), trk::TrackContainmentTagger::produce(), vertex::VertexCheater::produce(), trkf::TCTrack::produce(), cluster::SimpleClusterMerger::produce(), event::EventCheater::produce(), shwf::ShowerCheater::produce(), opdet::BeamFlashCompatabilityCheck::produce(), trkf::SpacePointCheater::produce(), trkf::SpacePointFinder::produce(), cluster::LineCluster::produce(), sim::MergeSimSources::produce(), tss::TrackShowerHits::produce(), sppt::TTSpacePointFinder::produce(), cluster::SimpleLineCluster::produce(), trkf::BezierTrackerModule::produce(), trkf::TrackCheater::produce(), cluster::ClusterCheater::produce(), calo::BezierCalorimetry::produce(), pid::Chi2ParticleID::produce(), calo::TrackCalorimetry::produce(), cosmic::BeamFlashTrackMatchTagger::produce(), caldata::CalWire::produce(), cluster::DBCluster3D::produce(), wc::MergeWireCell::produce(), opdet::OpFlashFinder::produce(), cluster::TrajCluster::produce(), caldata::CalWireT962::produce(), cluster::DBcluster::produce(), cluster::FuzzyClusterMerger::produce(), cosmic::TrackPFParticleMatch::produce(), ShowerReco3D::produce(), cluster::LineMerger::produce(), cluster::BlurredClustering::produce(), cluster::ClusterCrawler::produce(), cluster::fuzzyCluster::produce(), trkf::SpacePts::produce(), cosmic::CosmicPFParticleTagger::produce(), shower::EMShower::produce(), trkf::Track3Dreco::produce(), cosmic::CosmicTrackTagger::produce(), trkf::TrackKalmanCheater::produce(), vertex::VertexMatch::produce(), shower::TCShower::produce(), shwf::ShowerFinder::produce(), cosmic::CosmicPCAxisTagger::produce(), cosmic::CosmicClusterTagger::produce(), trkf::CCTrackMaker::produce(), vertex::PrimaryVertexFinder::produce(), cluster::SmallClusterFinder::produce(), vertex::HarrisVertexFinder::produce(), cluster::EndPointModule::produce(), trkf::TrackStitcher::produce(), ems::EMShower3D::produce(), cluster::HoughLineFinder::produce(), calo::Calorimetry::produce(), vertex::VertexFinder2D::produce(), shwf::ShowerReco::produce(), trkf::Track3DKalman::produce(), evgen::GENIEGen::produce(), lbne::PhotonCounterT0Matching::produce(), trkf::PMAlgTrajFitter::produce(), trkf::Track3DKalmanSPS::produce(), t0::MCTruthT0Matching::produce(), evd::GraphCluster::produce(), trkf::PMAlgTrackMaker::produce(), trkf::CosmicTracker::produce(), evgen::MarleyTimeGen::produce(), ems::MergeEMShower3D::produce(), mvapid::MVAAlg::RunPID(), opdet::TrackTimeAssoc::StoreFlashMatches(), and lar_pandora::LArPandoraEvent::WriteAssociation().

600 {
601  if (indx == UINT_MAX) indx = a.size()-1;
602 
603  try{
604  art::ProductID aid = prod.template getProductID< std::vector<T>>( a_instance);
605  art::Ptr<T> aptr(aid, indx, evt.productGetter(aid));
606  assn.addSingle(b, aptr);
607  return true;
608  }
609  catch(cet::exception &e){
610  mf::LogWarning("AssociationUtil")
611  << "unable to create requested art:Assns, exception thrown: " << e;
612  return false;
613  }
614 
615 } // util::CreateAssn() [01]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
std::vector< T > const &  a,
art::Ptr< U > const &  b,
art::Assns< U, T > &  assn,
size_t  indx = UINT_MAX 
)
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
prodreference to the producer that will write the vector a
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
indxindex 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(*this, evt, *wirecol, digit_ptr, *WireDigitAssn)) {
    throw art::Exception(art::errors::ProductRegistrationFailure)
      << "Can't associate wire #" << (wirecol->size() - 1)
      << " with raw digit #" << digit_ptr.key();
  } // if failed to add association

} // for digits

evt.put(std::move(wirecol));
evt.put(std::move(WireDigitAssn));

Definition at line 213 of file AssociationUtil.h.

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

219  { return CreateAssn(prod, evt, a, b, assn, std::string(), indx); }
bool CreateAssn(PRODUCER const &prod, art::Event &evt, art::Assns< T, U > &assn, size_t first_index, Iter from_second_index, Iter to_second_index)
Creates a single one-to-many association.
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
art::Ptr< T > const &  a,
art::Ptr< U > const &  b,
art::Assns< U, T > &  assn 
)

Creates a single one-to-one association.

Template Parameters
Ttype of one object to associate
Utype of the other object to associate
Parameters
prodreference to the producer that will write the vector a
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 621 of file AssociationUtil.h.

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

627  {
628 
629  try{
630  assn.addSingle(b, a);
631  }
632  catch(cet::exception &e){
633  mf::LogWarning("AssociationUtil")
634  << "unable to create requested art:Assns, exception thrown: " << e;
635  return false;
636  }
637 
638  return true;
639 } // util::CreateAssn() [03]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
std::vector< T > const &  a,
art::PtrVector< U > const &  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX 
)

Creates a single one-to-many association.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
prodreference to the producer that will write the vector a
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
indxindex 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 645 of file AssociationUtil.h.

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

652  {
653  if(indx == UINT_MAX) indx = a.size() - 1;
654 
655  try{
656  art::ProductID aid = prod.template getProductID< std::vector<T> >();
657  art::Ptr<T> aptr(aid, indx, evt.productGetter(aid));
658  for(art::Ptr<U> const& b_item: b) assn.addSingle(aptr, b_item);
659  }
660  catch(cet::exception &e){
661  mf::LogWarning("AssociationUtil")
662  << "unable to create requested art:Assns, exception thrown: " << e;
663  return false;
664  }
665 
666  return true;
667 } // util::CreateAssn() [04]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
art::Ptr< T > const &  a,
std::vector< art::Ptr< U >> const &  b,
art::Assns< T, U > &  assn 
)

Creates a single one-to-many association.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
prodreference to the producer that will write the vector a
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 672 of file AssociationUtil.h.

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

678  {
679 
680  try{
681  for (art::Ptr<U> const& b_item: b) assn.addSingle(a, b_item);
682  }
683  catch(cet::exception const& e){
684  mf::LogWarning("AssociationUtil")
685  << "unable to create requested art:Assns, exception thrown: " << e;
686  return false;
687  }
688 
689  return true;
690 } // util::CreateAssn() [05]
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
std::vector< T > const &  a,
std::vector< art::Ptr< U >> const &  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX 
)

Creates a single one-to-many association.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
prodreference to the producer that will write the vector a
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
indxindex 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 695 of file AssociationUtil.h.

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

702  {
703 
704  if (indx == UINT_MAX) indx = a.size() - 1;
705 
706  try{
707  art::ProductID aid = prod.template getProductID< std::vector<T> >();
708  art::Ptr<T> aptr(aid, indx, evt.productGetter(aid));
709  for (art::Ptr<U> const& b_item: b) assn.addSingle(aptr, b_item);
710  }
711  catch(cet::exception &e){
712  mf::LogWarning("AssociationUtil")
713  << "unable to create requested art:Assns, exception thrown: " << e;
714  return false;
715  }
716 
717  return true;
718 } // util::CreateAssn() [06]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
std::vector< T > const &  a,
std::vector< U > const &  b,
art::Assns< T, U > &  assn,
size_t  startU,
size_t  endU,
size_t  indx = UINT_MAX 
)

Creates a single one-to-many association.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
prodreference to the producer that will write the vector a
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
indxindex 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 723 of file AssociationUtil.h.

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

732  {
733 
734  if(indx == UINT_MAX) indx = a.size() - 1;
735 
736  try{
737  art::ProductID aid = prod.template getProductID< std::vector<T> >();
738  art::ProductID bid = prod.template getProductID< std::vector<U> >();
739  art::Ptr<T> aptr(aid, indx, evt.productGetter(aid));
740  auto const* getter = evt.productGetter(bid); // I don't want to know what it is
741  for(size_t i = startU; i < endU; ++i){
742  art::Ptr<U> bptr(bid, i, getter);
743  assn.addSingle(aptr, bptr);
744  }
745  }
746  catch(cet::exception &e){
747  mf::LogWarning("AssociationUtil")
748  << "unable to create requested art:Assns, exception thrown: " << e;
749  return false;
750  }
751 
752  return true;
753 } // util::CreateAssn() [07]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<class PRODUCER , class T , class U >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
std::vector< T > const &  a,
std::vector< U > const &  b,
art::Assns< T, U > &  assn,
std::vector< size_t > const &  indices,
size_t  indx = UINT_MAX 
)

Creates a single one-to-many association.

Template Parameters
Ttype of the new object to associate
Utype of the many objects already in the data product or art::Ptr
Parameters
prodreference to the producer that will write the vector a
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
indxindex 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 758 of file AssociationUtil.h.

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

766  {
767 
768  if(indx == UINT_MAX) indx = a.size() - 1;
769 
770  try{
771  art::ProductID aid = prod.template getProductID< std::vector<T> >();
772  art::ProductID bid = prod.template getProductID< std::vector<U> >();
773  art::Ptr<T> aptr(aid, indx, evt.productGetter(aid));
774  auto const* getter = evt.productGetter(bid); // I don't want to know what it is
775  for(size_t index: indices){
776  art::Ptr<U> bptr(bid, index, getter);
777  assn.addSingle(aptr, bptr);
778  }
779  }
780  catch(cet::exception &e){
781  mf::LogWarning("AssociationUtil")
782  << "unable to create requested art:Assns, exception thrown: " << e;
783  return false;
784  }
785 
786  return true;
787 } // util::CreateAssn() [07a]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename PRODUCER , typename T , typename U , typename Iter >
bool util::CreateAssn ( PRODUCER const &  prod,
art::Event evt,
art::Assns< T, U > &  assn,
size_t  first_index,
Iter  from_second_index,
Iter  to_second_index 
)

Creates a single one-to-many association.

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
prodreference to the producer that will write the vector a
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 792 of file AssociationUtil.h.

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

799  {
800 
801  try{
802  // We need the "product ID" of what is going to become a data product.
803  // The data product ID is unique for the combination of process, producer,
804  // data type and product (instance) label.
805  //
806  art::ProductID first_id = prod.template getProductID< std::vector<T> >();
807  art::ProductID second_id = prod.template getProductID< std::vector<U> >();
808 
809  // we declare here that we want to associate the element first_index of the
810  // (only) data product of type std::vector<T> with other objects.
811  // This is the pointer to that element:
812  art::Ptr<T> first_ptr(first_id, first_index, evt.productGetter(first_id));
813 
814  // we are going to associate that element in a with a number of elements
815  // of the only data product of type std::vector<U>
816  auto const* getter = evt.productGetter(second_id); // auto, spare me the details
817  while (from_second_index != to_second_index) {
818  art::Ptr<U> second_ptr(second_id, *from_second_index, getter);
819  assn.addSingle(first_ptr, second_ptr);
820  ++from_second_index;
821  } // while
822  }
823  catch(cet::exception &e){
824  mf::LogWarning("AssociationUtil")
825  << "unable to create requested art:Assns, exception thrown: " << e;
826  return false;
827  }
828 
829  return true;
830 } // util::CreateAssn() [08]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename PRODUCER , typename T , typename U , typename D >
bool util::CreateAssnD ( PRODUCER const &  prod,
art::Event evt,
art::Assns< T, U, D > &  assn,
size_t  first_index,
size_t  second_index,
typename art::Assns< T, U, D >::data_t &&  data 
)

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

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
prodreference to the producer that will write the vector a
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 836 of file AssociationUtil.h.

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

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

843  {
844 
845  try{
846  // We need the "product ID" of what is going to become a data product.
847  // The data product ID is unique for the combination of process, producer,
848  // data type and product (instance) label.
849  //
850  // we declare here that we want to associate the element first_index of the
851  // (only) data product of type std::vector<T> with the other object
852  art::ProductID first_id = prod.template getProductID< std::vector<T> >();
853  art::Ptr<T> first_ptr(first_id, first_index, evt.productGetter(first_id));
854 
855  // the same to associate the element second_index of the (only)
856  // data product of type std::vector<U> with the first object.
857  art::ProductID second_id = prod.template getProductID< std::vector<U> >();
858  art::Ptr<U> second_ptr
859  (second_id, second_index, evt.productGetter(second_id));
860 
861  assn.addSingle(first_ptr, second_ptr, std::move(data));
862  }
863  catch(cet::exception &e){
864  mf::LogWarning("AssociationUtil")
865  << "unable to create requested art:Assns, exception thrown: " << e;
866  return false;
867  }
868 
869  return true;
870 } // util::CreateAssnD() [01a]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename PRODUCER , typename T , typename U , typename D >
bool util::CreateAssnD ( PRODUCER const &  prod,
art::Event evt,
art::Assns< T, U, D > &  assn,
size_t  first_index,
size_t  second_index,
typename art::Assns< T, U, D >::data_t const &  data 
)

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
prodreference to the producer that will write the vector a
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 873 of file AssociationUtil.h.

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

880  {
881 
882  try{
883  // We need the "product ID" of what is going to become a data product.
884  // The data product ID is unique for the combination of process, producer,
885  // data type and product (instance) label.
886  //
887  // we declare here that we want to associate the element first_index of the
888  // (only) data product of type std::vector<T> with the other object
889  art::ProductID first_id = prod.template getProductID< std::vector<T> >();
890  art::Ptr<T> first_ptr(first_id, first_index, evt.productGetter(first_id));
891 
892  // the same to associate the element second_index of the (only)
893  // data product of type std::vector<U> with the first object.
894  art::ProductID second_id = prod.template getProductID< std::vector<U> >();
895  art::Ptr<U> second_ptr
896  (second_id, second_index, evt.productGetter(second_id));
897 
898  assn.addSingle(first_ptr, second_ptr, data);
899  }
900  catch(cet::exception &e){
901  mf::LogWarning("AssociationUtil")
902  << "unable to create requested art:Assns, exception thrown: " << e;
903  return false;
904  }
905 
906  return true;
907 } // util::CreateAssnD() [01b]
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T >
constexpr T util::DegreesToRadians ( angle)
inline

Converts the argument angle from degrees into radians.

Definition at line 84 of file PhysicalConstants.h.

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

84 { return angle / 180 * pi<T>(); }
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 33 of file DumpAssociations.h.

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

34  {
35  out << "Association between '" << cet::demangle_symbol(typeid(Left).name())
36  << "' and '" << cet::demangle_symbol(typeid(Right).name()) << "'";
37  if (std::is_same<Data, void>()) {
38  out << " with '" << cet::demangle_symbol(typeid(Data).name())
39  << "' metadata";
40  }
41  if (assns.size() > 0) {
42  out << " contains " << assns.size() << " relations";
43  }
44  else {
45  out << " is empty";
46  }
47  } // DumpAssociationsIntro<Data>()
size_type size() const
Definition: Assns.h:440
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 137 of file filterRangeFor.h.

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

138  {
139  return details::FilterRangeForStruct<Range, Pred>
140  (std::forward<Range>(range), std::forward<Pred>(pred));
141  }
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 911 of file AssociationUtil.h.

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

Referenced by CreateAssn().

914 {
915 
916  // Do a FindOne for type T for each object of type U
917  // If the FindOne returns an invalid maybe ref, add the pointer
918  // of object type U to the return vector
919 
920  std::vector<const U*> notAssociated;
921 
922  art::FindOne<T> fa(b, evt, label);
923 
924  for(size_t u = 0; u < b->size(); ++u){
925  cet::maybe_ref<T const> t(fa.at(u));
926  if( !t.isValid() ){
927  art::Ptr<U> ptr(b, u);
928  notAssociated.push_back(ptr.get());
929  }
930  }
931 //
932  return notAssociated;
933 }
TFile fa("Li7.root")
TCEvent evt
Definition: DataStructs.cxx:5
Definition: fwd.h:25
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 936 of file AssociationUtil.h.

References fa().

Referenced by CreateAssn().

939 {
940 
941  // Do a FindOneP for type T for each object of type U
942  // If the FindOne returns an invalid maybe ref, add the pointer
943  // of object type U to the return vector
944 
945  std::vector< art::Ptr<U> > notAssociated;
946 
947  art::FindOneP<T> fa(b, evt, label);
948 
949  for(size_t u = 0; u < b->size(); ++u){
950  cet::maybe_ref<T const> t(fa.at(u));
951  if( !t.isValid() ){
952  art::Ptr<U> ptr(b, u);
953  notAssociated.push_back(ptr);
954  }
955  }
956 
957  return notAssociated;
958 }
TFile fa("Li7.root")
TCEvent evt
Definition: DataStructs.cxx:5
Definition: fwd.h:25
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 49 of file ForEachAssociatedGroup.h.

References art::for_each_group().

50  { art::for_each_group(assns, func); }
void for_each_group(art::Assns< A, B, D > const &assns, F func)
Helper functions to access associations in order.
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 980 of file AssociationUtil.h.

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

982 {
983  std::vector< std::vector<size_t> > associated_indices(index_p->size());
984  for(auto const& pair : *h)
985  associated_indices.at(pair.first.key()).push_back(pair.second.key());
986  return associated_indices;
987 }
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 989 of file AssociationUtil.h.

Referenced by CreateAssn().

991 {
992  std::vector< std::vector<const U*> > associated_pointers(index_p->size());
993  for(auto const& pair : *h)
994  associated_pointers.at(pair.first.key()).push_back( &(*(pair.second)) );
995  return associated_pointers;
996 }
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 962 of file AssociationUtil.h.

Referenced by CreateAssn().

964 {
965  std::vector<size_t> associated_index(index_p->size());
966  for(auto const& pair : *h)
967  associated_index.at(pair.first.key()) = pair.second.key();
968  return associated_index;
969 }
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 971 of file AssociationUtil.h.

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

973 {
974  std::vector<const U*> associated_pointer(index_p->size());
975  for(auto const& pair : *h)
976  associated_pointer.at(pair.first.key()) = &(*(pair.second));
977  return associated_pointer;
978 }
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 180 of file ForEachAssociatedGroup.h.

Referenced by TrackProducerFromPFParticle::produce().

181  { return *(std::next(groups.begin(), index)); }
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

, i.e. an index larger than the size of the original data collection.

The returned vector is big enough to accommodate indices corresponding to the keys of all the items in data. It may contain "holes" (that is, some keys that have no corresponding items have a

value). The memory allocated for the vector may be larger than necessary (if that is a problem, std::vector::shrink_to_fit() can be used, but it may create more problems than it solves).

Definition at line 43 of file MakeIndex.h.

References max.

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

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

References max.

101  {
102  using Mapped_t = decltype(key_of(*(data.begin())));
103  using Ptr_t = Mapped_t const*;
104  using Map_t = std::vector<Ptr_t>;
105 
106  // we start the index with the best guess that all the items will have
107  // a unique key and they are contiguous:
108  // the index would have the same size as the data
109  Map_t Index(data.size(), nullptr);
110 
111  size_t min_size = 0; // minimum size needed to hold all keys
112 
113  for (auto const& datum: data) {
114  size_t key = size_t(key_of(datum));
115  if (key >= min_size) min_size = key + 1;
116  if (Index.size() <= key) {
117  // make room for the entry: double the size
118  Index.resize(std::max(key + 1, Index.size() * 2), nullptr);
119  } // if expand index
120  Index[key] = &datum;
121  } // for datum
122  Index.resize(min_size);
123  return Index;
124  } // MakeMap()
Int_t max
Definition: plot.C:27
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 103 of file SortByPointers.h.

References n.

Referenced by SortByPointers().

103  {
104 
105  using coll_t = Coll;
106  using value_type = typename coll_t::value_type;
107  using pointer_type = std::add_pointer_t<value_type>;
108  using ptr_coll_t = std::vector<pointer_type>;
109 
110  auto const n = coll.size();
111 
112  //
113  // create the collection of pointers to data
114  //
115  ptr_coll_t ptrs;
116  ptrs.reserve(n);
117  std::transform(coll.begin(), coll.end(), std::back_inserter(ptrs),
118  [](auto& obj){ return &obj; });
119 
120  return ptrs;
121 
122 } // util::makePointerVector()
Char_t n[5]
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 542 of file TensorIndices.h.

543  {
544  return TensorIndices<sizeof...(DIMS)>
545  { TensorIndicesBasicTypes::DimSize_t(dims)... };
546  }
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 57 of file SortByPointers.h.

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

Referenced by SortByPointers().

58  { details::MoveFromPointersImpl<Coll, PtrColl>::move(dest, src); }
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 513 of file VectorMap.h.

515  {
516  return !(__x == __y);
517  }
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 524 of file TensorIndices.h.

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

525  { return true; }
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 501 of file VectorMap.h.

503  {
504  return std::lexicographical_compare(__x.sortedVectorMap.begin(),
505  __x.sortedVectorMap.end(),
506  __y.sortedVectorMap.begin(),
507  __y.sortedVectorMap.end(),
508  __x.valueCompare);
509  }
std::ostream& util::operator<< ( std::ostream &  out,
EventChangeTracker_t const &  trk 
)
inline

Definition at line 105 of file ChangeTrackers.h.

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

Definition at line 206 of file ChangeTrackers.h.

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

Definition at line 319 of file ChangeTrackers.h.

320  { out << std::string(trk); return out; }
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 529 of file VectorMap.h.

531  {
532  return !(__y < __x);
533  }
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 494 of file VectorMap.h.

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

496  {
497  return __x.sortedVectorMap == __y.sortedVectorMap;
498  }
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 516 of file TensorIndices.h.

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

517  { return false; }
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 521 of file VectorMap.h.

523  {
524  return __y < __x;
525  }
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 537 of file VectorMap.h.

539  {
540  return !(__x < __y);
541  }
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 460 of file RangeForWrapper.h.

References wrapRangeFor().

461  { return wrapRangeFor(std::forward<Range>(range)); }
auto wrapRangeFor(Range &&range) -> decltype(auto)
Wraps an object for use in a range-for loop.
template<typename T = double>
constexpr T util::pi ( )
inline

Returns the constant pi (up to 35 decimal digits of precision)

Definition at line 80 of file PhysicalConstants.h.

Referenced by NuShowerEff::analyze(), util::GeometryUtilities::CalculatePitch(), apa::DisambigAlg::FindChanTimeEndPts(), art::FileDumperOutput::printPrincipal(), geo::OpDetGeo::ThetaZ(), and geo::WireGeo::WireGeo().

80 { return 3.14159265358979323846264338327950288L; }
template<typename T >
constexpr T util::RadiansToDegrees ( angle)
inline

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

Definition at line 88 of file PhysicalConstants.h.

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

88 { return angle / pi<T>() * 180; }
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 127 of file SortByPointers.h.

References makePointerVector(), and MoveFromPointers().

Referenced by geo::CryostatGeo::CryostatGeo(), MoveFromPointers(), geo::GeometryCore::SortGeometry(), geo::CryostatGeo::SortSubVolumes(), and geo::PlaneGeo::SortWires().

127  {
128 
129  using coll_t = Coll;
130 
131  //
132  // create the collection of pointers to data
133  //
134  auto ptrs = makePointerVector(coll);
135 
136  //
137  // delegate the sorting by pointers
138  //
139  sorter(ptrs);
140 
141  //
142  // create a sorted collection moving the content from the original one
143  //
144  coll_t sorted;
145  MoveFromPointers(sorted, ptrs);
146 
147  //
148  // replace the old container with the new one
149  //
150  coll = std::move(sorted);
151 
152 } // 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 _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 545 of file VectorMap.h.

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

547  {
548  __x.swap(__y);
549  }
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 428 of file RangeForWrapper.h.

Referenced by operator|().

429  {
430  return details::WrapRangeForDispatcher<Range>::wrap
431  (std::forward<Range>(range));
432  }

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.

const double util::kINVALID_DOUBLE = std::numeric_limits<Double_t>::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
constexpr double util::kModBoxB = 0.212
constexpr double util::kRecombk = 0.0486
constexpr double util::quietCompiler = kBogusD*kBogusI*kBogusF*kRecombA*kRecombk*kGeVToElectrons

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