Classes | Functions | Variables
util Namespace Reference

Filter events based on their run/event numbers. More...

Classes

class  CopyCellHits
 A module to copy hits from selected clusers into a vector of cell hits. More...
 
class  EventFilterNoSlice
 
class  FakeSpillData
 
class  HashFunctions
 
class  HasStandardRecord
 
class  HoughCalc
 
class  MergeSubruns
 
class  NonEmptyCluster
 A module to copy hits from selected clusers into a vector of cell hits. More...
 
class  NTree
 
class  RemoveBeamSpills
 Reject triggers that are too close to beam spills. More...
 
class  RemoveBeamSpillsPrecise
 
class  RemoveTBSpills
 Reject triggers that are too close to beam spills. More...
 
class  RewriteSpillData
 A module to store a geometry in a file. More...
 
class  RunEventFilter
 
class  StoreGDML
 A module to store a geometry in a file. More...
 
class  TimeFilter
 
class  TruthExpand
 
class  WriteHornCurrentCosmic
 A module to store a geometry in a file. More...
 

Functions

def tot_weight (compos)
 
def tot_fractions (fractions)
 
def elem_frac (compos, elem)
 
def elem_frac_total (elem, compositions, fractions)
 
def zovera (elem)
 
def zoveramaterial (compos)
 
def make_composition (name, fractions, compositions)
 
def print_composition (composition)
 
template<class T >
std::unique_ptr< std::vector< T > > GetHits (const std::vector< rb::Cluster > &clusts)
 
std::string EnvExpansion (const std::string &inString)
 Function to expand environment variables. More...
 
static bool sort_pair_by_first (const std::pair< double, double > &a, const std::pair< double, double > &b)
 
static double find_median (const std::vector< std::pair< double, double > > &a)
 
static bool IsInBeamWindow (const int run, const double time)
 
void SaveObj (const TObject *obj, const std::string &filenameStub, const std::string &dirName="", const std::vector< std::string > exts={".png",".eps",".root"}, bool silent=false)
 
template<typename T >
T GetValAs (const stan::math::var &val)
 explicit specialization for double return value More...
 
template<>
double GetValAs (const stan::math::var &val)
 explicit specialization for double return value More...
 
template<>
stan::math::var GetValAs (const stan::math::var &val)
 explicit specialization for stan::math::var return value More...
 
template<typename T >
std::enable_if< std::is_convertible< T, double >::value, T >::type GetValAs (double val)
 
void SetVal (double &target, const stan::math::var &source)
 Replacement for operator=() making it clear that you're 'casting' across double-stan::math::var boundary. More...
 
void SetVal (stan::math::var &target, const double &source)
 
void SetVal (stan::math::var &target, const stan::math::var &source)
 
void SetVal (double &target, const double &source)
 
double frac (double x)
 Fractional part. More...
 
Create and query associations
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to 1 association between a new product and one already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &filt, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t begin_indx, size_t end_indx, std::string const &instance=std::string())
 Create a 1 to 1 association between each of a series of new products and one already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, art::Ptr< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn)
 Create a 1 to 1 association between two products already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::PtrVector< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to many association between a new product and a PtrVector already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, art::Ptr< T > &a, std::vector< art::Ptr< U > > b, art::Assns< T, U > &assn)
 Create a 1 to many association between products already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, std::vector< art::Ptr< U > > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to many association between a new product and a vector of Ptrs already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, std::vector< U > &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX, std::string const &instancea=std::string(), std::string const &instanceb=std::string())
 Create a 1 to many association between new products. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &filt, art::Event &evt, std::vector< T > &a, std::vector< U > &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX, std::string const &instancea=std::string(), std::string const &instanceb=std::string())
 
template<class T , class U >
static std::vector< const U * > FindUNotAssociatedToT (art::Handle< U > b, art::Event const &evt, std::string const &label)
 Return all objects of type U that are not associated to objects of type T. More...
 
template<class T , class U >
static std::vector< art::Ptr< U > > FindUNotAssociatedToTP (art::Handle< U > b, art::Event const &evt, std::string const &label)
 Return all objects of type U that are not associated to objects of type T. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to 1 association between a new product and one already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t begin_indx, size_t end_indx, std::string const &instance=std::string())
 Create a 1 to 1 association between each of a series of new products and one already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, art::Ptr< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn)
 Create a 1 to 1 association between two products already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::PtrVector< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to many association between a new product and a PtrVector already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, art::Ptr< T > &a, std::vector< art::Ptr< U > > b, art::Assns< T, U > &assn)
 Create a 1 to many association between products already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, std::vector< art::Ptr< U > > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to many association between a new product and a vector of Ptrs already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, std::vector< U > &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX, std::string const &instancea=std::string(), std::string const &instanceb=std::string())
 Create a 1 to many association between new products. More...
 
template<class T , class U >
static bool CreateAssn (art::EDProducer const &prod, art::Event &evt, art::Assns< T, U > &assn, std::vector< T > &a, std::vector< U > &b, size_t indxb=UINT_MAX, size_t indxa=UINT_MAX, std::string const &instancea=std::string(), std::string const &instanceb=std::string())
 Create a 1 to 1 between new products. More...
 
template<class T , class U >
static std::vector< const U * > FindUNotAssociatedToT (art::Handle< U > b, art::Event const &evt, std::string const &label)
 Return all objects of type U that are not associated to objects of type T. More...
 
template<class T , class U >
static std::vector< art::Ptr< U > > FindUNotAssociatedToTP (art::Handle< U > b, art::Event const &evt, std::string const &label)
 Return all objects of type U that are not associated to objects of type T. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to 1 association between a new product and one already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t begin_indx, size_t end_indx, std::string const &instance=std::string())
 Create a 1 to 1 association between each of a series of new products and one already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, art::Ptr< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn)
 Create a 1 to 1 association between two products already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, std::vector< T > &a, art::PtrVector< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to many association between a new product and a PtrVector already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, art::Ptr< T > &a, std::vector< art::Ptr< U > > b, art::Assns< T, U > &assn)
 Create a 1 to many association between products already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, std::vector< T > &a, std::vector< art::Ptr< U > > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
 Create a 1 to many association between a new product and a vector of Ptrs already in the event. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, std::vector< T > &a, std::vector< U > &b, art::Assns< T, U > &assn, size_t startU, size_t endU, size_t indx=UINT_MAX, std::string const &instancea=std::string(), std::string const &instanceb=std::string())
 Create a 1 to many association between new products. More...
 
template<class T , class U >
static bool CreateAssn (art::EDFilter const &prod, art::Event &evt, art::Assns< T, U > &assn, std::vector< T > &a, std::vector< U > &b, size_t indxb=UINT_MAX, size_t indxa=UINT_MAX, std::string const &instancea=std::string(), std::string const &instanceb=std::string())
 Create a 1 to 1 between new products. More...
 
Simple mathematical functions
void LinFitUnweighted (const std::vector< double > &x, const std::vector< double > &y, double &m, double &c)
 Simplified version of LinFit. More...
 
double LinFit (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double &m, double &c)
 Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance from the points to the line. More...
 
template<class T >
T sqr (T x)
 More efficient square function than pow(x,2) More...
 
template<class T >
T cube (T x)
 More efficient cube function than pow(x,3) More...
 
double pythag (double x, double y)
 2D Euclidean distance More...
 
double pythag (double x, double y, double z)
 3D Euclidean distance More...
 
void LinFitTS (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double &m, double &b, int wmode)
 Best fit line to points using Theil-Sens median method. More...
 
template<class T >
T ipow (T x, unsigned int n)
 More efficient exponentiation function than pow(x,n) for small n. More...
 

Variables

list elemlist
 
bool printmore = False
 
const int kBeamWindowPaddingMicroSec = 9
 
const int kBeamWindowMinMicroSec = 217
 
const int kBeamWindowMaxMicroSec = 229
 
const int kMinTimingSidebandBeforeMicroSec = 25
 
const int kMaxTimingSidebandBeforeMicroSec = kBeamWindowMinMicroSec - kBeamWindowPaddingMicroSec
 
const int kMinTimingSidebandAfterMicroSec = kBeamWindowMaxMicroSec + kBeamWindowPaddingMicroSec
 
const int kMaxTimingSidebandAfterMicroSec = 475
 
const int kPeakShiftMicroSec = +64
 
const int kBeamWindowShiftedMinMicroSec = kBeamWindowMinMicroSec + kPeakShiftMicroSec
 
const int kBeamWindowShiftedMaxMicroSec = kBeamWindowMaxMicroSec + kPeakShiftMicroSec
 
const int kMaxTimingSidebandBeforeShiftedWindowMicroSec = kBeamWindowShiftedMinMicroSec - kBeamWindowPaddingMicroSec
 
const int kMinTimingSidebandAfterShiftedWindowMicroSec = kBeamWindowShiftedMaxMicroSec + kBeamWindowPaddingMicroSec
 
const int kLastBadTimingRun = 17945
 
const int kBeamWindowMicroSec = kBeamWindowMaxMicroSec - kBeamWindowMinMicroSec
 How long is the beam window? More...
 
const int kTimingSidebandMicroSec
 
const int kBeamWindowBadPeriodMicroSec
 Two windows to consider here. More...
 
const int kTimingSidebandBadPeriodMicroSec
 Two beam windows to cut out here. More...
 

Utilities acting on RawDigits

Used by Cana

typedef std::pair< unsigned int, unsigned intRawSlice
 
void TimeSort (std::vector< art::Ptr< rawdata::RawDigit > > &d)
 Arrange the list of raw hits in time order (early to late) More...
 
void CountXY (const std::vector< art::Ptr< rawdata::RawDigit > > &d, unsigned int i1, unsigned int i2, unsigned int *nx, unsigned int *ny)
 Count the number of digits in each detector view. More...
 
void EventBox (const std::vector< art::Ptr< rawdata::RawDigit > > &d, unsigned int i1, unsigned int i2, unsigned int *plane1x, unsigned int *plane2x, unsigned int *cell1x, unsigned int *cell2x, unsigned int *plane1y, unsigned int *plane2y, unsigned int *cell1y, unsigned int *cell2y)
 Find boxes in plane/cell units that contain all the hits. More...
 
void TimeSlice (const std::vector< art::Ptr< rawdata::RawDigit > > &d, unsigned int dt_tdc, unsigned int nhit, unsigned int nhitx, unsigned int nhity, std::vector< RawSlice > &slice)
 Find windows in time that have significant activity in the detector. More...
 
unsigned int FilterFEBFlash (std::vector< art::Ptr< rawdata::RawDigit > > &rd, int adc_sat=3400, int dt_tdc=1280)
 Filter hits that are "FEB flash" candidates; that is, they occur within a specified time of an FEB hit in saturation. More...
 

Detailed Description

Filter events based on their run/event numbers.

Create a dummy spilldata product in cosmic files to set the isRHC field for downstream reco.

Store a geometry in a file.

Rewrite the SpillData object in an MC file to set the isRHC field.

Reject triggers that are too close to beam spills.

This is a simple tree class.

A module to filter events which have a collection of empty clusters.

Hough Calculation service.

utility services

Concatenate subrun files from same run.

Generate unique hashes for reco products.

Fake the SpillData object in an MC file to set the isRHC field.

A module to copy hits from selected clusers into a vector of cell hits.

Remove all events that occur too close to 4.2s Test Beam spill.

Filter events based on their run/subrun and event (trigger) time.

Author
messi.nosp@m.er@i.nosp@m.ndian.nosp@m.a.ed.nosp@m.u
Date
Author
lacke.nosp@m.y32@.nosp@m.fnal..nosp@m.gov
Date
Author
Teresa Lackey - lacke.nosp@m.y32@.nosp@m.fnal..nosp@m.gov
ednin.nosp@m.er@f.nosp@m.nal.g.nosp@m.ov
Date
Author
bckho.nosp@m.use@.nosp@m.fnal..nosp@m.gov
Date
Author
Justin Vasel justi.nosp@m.n.va.nosp@m.sel@g.nosp@m.mail.nosp@m..com
Date
December 2018
Author
nowak.nosp@m.@phy.nosp@m.sics..nosp@m.umn..nosp@m.edu
Date
Author
Alexandre Sousa - asous.nosp@m.a@ph.nosp@m.ysics.nosp@m..har.nosp@m.vard..nosp@m.edu
Date
Author
ahimm.nosp@m.el@f.nosp@m.nal.g.nosp@m.ov
Date
Author
jpale.nosp@m.y@an.nosp@m.l.gov
Date
Author
Christopher Backhouse - bckho.nosp@m.use@.nosp@m.calte.nosp@m.ch.e.nosp@m.du

Typedef Documentation

typedef std::pair<unsigned int, unsigned int> util::RawSlice

A raw slice is just two indices: the index of the first hit in the slice, and the index of the last hit in the slice, inclusive.

Definition at line 23 of file RawUtil.h.

Function Documentation

void util::CountXY ( const std::vector< art::Ptr< rawdata::RawDigit > > &  d,
unsigned int  i1,
unsigned int  i2,
unsigned int nx,
unsigned int ny 
)

Count the number of digits in each detector view.

Parameters
d: The complete list of raw digits to be considered
i1: Index of the first digit to be considered
i2: Index of the last digit to be considered (inclusive)
nx: On output, the number of hits in the x view
ny: On output, the number of hits in the y view

Definition at line 38 of file RawUtil.cxx.

References visualisationForPaperMasterPlot::cmap, d, geom(), cmap::dataprov::CMap::GetPlane(), MECModelEnuComparisons::i, geo::kX, geo::kY, geo::GeometryBase::Plane(), registry_explorer::v, and geo::PlaneGeo::View().

Referenced by comi::Leana::analyze(), comi::Cana::produce(), and TimeSlice().

43 {
46 
47  *nx = 0;
48  *ny = 0;
49  unsigned int i;
50  for (i=i1; i<=i2; ++i) {
51  unsigned int p = cmap->GetPlane(d[i].get());
52  geo::View_t v = geom->Plane(p)->View();
53  if (v==geo::kX) ++(*nx);
54  else if (v==geo::kY) ++(*ny);
55  }
56 }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const char * p
Definition: xmltok.h:285
Vertical planes which measure X.
Definition: PlaneGeo.h:28
const PlaneGeo * Plane(unsigned int i) const
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:53
Float_t d
Definition: plot.C:236
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
void geom(int which=0)
Definition: geom.C:163
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to 1 association between a new product and one already in the event.

Parameters
aThe collection about to be added to the event
bThe product already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to 1 association between a new product and one already in the event.

Parameters
aThe collection about to be added to the event
bThe product already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string

Referenced by skim::NueSkimmer::CopyMichelSlice(), skim::NueSkimmer::CopyMichelTrack(), skim::SkimmingUtils::CopyProductAndSliceAssn(), skim::NueSkimmer::CopyProngCVN(), skim::SkimmingUtils::CopyProngs(), skim::NueSkimmer::CopyShowerLID(), skim::NumuSkimmer::CopyShowerLID(), skim::NueSkimmer::CopyShowerPngAssn(), skim::SkimmingUtils::CopyShowers(), skim::NumuCCpiSkimmer::CopyTrackAssn(), skim::NumuSkimmer::CopyTrackAssn(), skim::SkimmingUtils::CopyTracks(), skim::SkimmingUtils::CopyVertex(), LSTME::FillLSTME::fillEnergies(), SliceLID::FillSliceLID::fillSliceLIDPreds(), novaddt::Clusterer::filter(), calib::RockMuonStopperSelection::filter(), calib::StopperSelection::filter(), novaddt::TriCellTrigger::filter(), novaddt::DDTTrackMerge::filter(), novaddt::UpMuTestTrigger::filter(), novaddt::Merge2DTracks::filter(), trk::TrkAssn::produce(), qeef::QeFinder::produce(), hough::HoughT::produce(), tf::TimingFit::produce(), cheat::ClusterCheater::produce(), cheat::ProngCheater::produce(), cheat::ShowerCheater::produce(), cheat::TrueEnergy::produce(), recodemo::RecoDemo::produce(), hv::HoughVertex::produce(), cheat::TrackCheater::produce(), trk::KalmanTrack::produce(), nuesand::FillNueSandbox::produce(), lem::MergeMatches::produce(), lem::UnTranspose::produce(), beamlinereco::TimeOfFlightReco::produce(), numue::TrackOverlapECalc::produce(), wsnumu::WSNumu::produce(), MergeCollections::MergeCollections::produce(), MergeG4Collections::MergeG4Collections::produce(), presel::RockPresel::produce(), regcvntf::RegCVNTF::produce(), lem::LEMSummarizer::produce(), trk::KalmanTrackMerge::produce(), nussand::FillNusSandbox::produce(), presel::CosmicVeto::produce(), trackinfo::TrackInfo::produce(), slid::Recluster::produce(), novaddt::TrackFit::produce(), numusand::FillSandbox::produce(), presel::NuePresel::produce(), lem::Preselection::produce(), hough::MultiHoughT::produce(), nuonecvntf::NuonECVNTF::produce(), cvn::CVNCosmicMapper::produce(), slid::SliceLIDBuilder::produce(), cvnneutronprongtf::CVNNeutronProngTF::produce(), cvneventtf::CVNEventTF::produce(), calib::FiberCalibration::produce(), cvnprongtf::CVNProngTF::produce(), cosrej::CosRej::produce(), beamlinereco::CkovCounterReco::produce(), MergeGenCollections::MergeGenCollections::produce(), trk::CosmicTrack::produce(), lem::MakeMatches::produce(), g4n::TruthSlim::produce(), numue::NumuEnergy::produce(), muonid::MuonIDProd::produce(), dt::ViewMerger::produce(), earms::ElasticArmsHS::produce(), calib::TimingCalibration::produce(), wcvtx::WCVertex::produce(), beamlinereco::LEHitReco::produce(), dt::DiscreteTracker::produce(), beamlinereco::WCTrackReco::produce(), ndreco::NDReco::produce(), beamlinereco::CFDHitReco::produce(), evgen::GENIERockGen::produce(), calib::PCHitsList::produce(), lem::FindLEMMatches::produce(), vdt::VertexDT::produce(), rwgt::MakeGENIEReweightTable::produce(), cvn::CVNMapper::produce(), ncpi0::MakeNCPi0BkgRej::produce(), lem::MakePID::produce(), murem::MRE::produce(), slid::LIDBuilder::produce(), lem::LEM::produce(), jmshower::NueSel::produce(), evgen::GENIEGen::produce(), dif::DiFShowerFinder::produce(), cvntf::CVNProngEvaluatorTF::produce(), crvtx::CosmicRayVertex::produce(), rvp::RecVarPID::produce(), slid::SPIDBuilder::produce(), xnue::XnuePID::produce(), cvn::RegCVNMapper::produce(), jmshower::NueSelLID::produce(), g4n::G4Gen::produce(), fxwgt::FluxWeightCalculator::produce(), bpfit::BPFEnergyEstimator::produce(), ncid::MakeNCCosRej::produce(), bpfit::BPFPIdMaker::produce(), bpfit::BPFEnergyEstimatorOnly::produce(), remid::RecoMuon::produce(), xsrec::MakeXSecCCPi0Inc::produce(), lem::LEMClient::produce(), cvn::CVNAddTrainingData::produce(), upmuana::UpMuProb::produce(), cosrej::MakeNueCosRej::produce(), ncid::NCNNKeras::produce(), murem::MuonRemove::produce(), murem::FindMREParent::produce(), murem::FindParent::produce(), jmshower::RecoJMShower::produce(), fuzz::FuzzyKVertex::produce(), nerd::NERDProng::produce(), gibuu::GiBUURegen::produce(), caf::CAFMaker::produce(), me::MEFinder::produce(), bpfit::BreakPoint::produce(), jmshower::RecoJMShower::RecoShowers(), and skim::SkimmingUtils::SliceMCTruthAssociation().

template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  filt,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  begin_indx,
size_t  end_indx,
std::string const &  instance = std::string() 
)
static

Create a 1 to 1 association between each of a series of new products and one already in the event.

Parameters
aThe collection about to be added to the event
bThe product already in the event
begin_indxWhich element of a to associate first.
end_indxOne more than the index of the last element to associate
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  begin_indx,
size_t  end_indx,
std::string const &  instance = std::string() 
)
static

Create a 1 to 1 association between each of a series of new products and one already in the event.

Parameters
aThe collection about to be added to the event
bThe product already in the event
begin_indxWhich element of a to associate first.
end_indxOne more than the index of the last element to associate
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
art::Ptr< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn 
)
static

Create a 1 to 1 association between two products already in the event.

Parameters
aA product already in the event
bAnother product already in the event
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
art::Ptr< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn 
)
static

Create a 1 to 1 association between two products already in the event.

Parameters
aA product already in the event
bAnother product already in the event
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
art::PtrVector< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to many association between a new product and a PtrVector already in the event.

Parameters
aThe collection about to be added to the event
bThe products already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
art::PtrVector< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to many association between a new product and a PtrVector already in the event.

Parameters
aThe collection about to be added to the event
bThe products already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
art::Ptr< T > &  a,
std::vector< art::Ptr< U > >  b,
art::Assns< T, U > &  assn 
)
static

Create a 1 to many association between products already in the event.

Parameters
aA product already in the event
bA vector of products already in the event (the many)
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
art::Ptr< T > &  a,
std::vector< art::Ptr< U > >  b,
art::Assns< T, U > &  assn 
)
static

Create a 1 to many association between products already in the event.

Parameters
aA product already in the event
bA vector of products already in the event (the many)
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
std::vector< art::Ptr< U > >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to many association between a new product and a vector of Ptrs already in the event.

Parameters
aThe collection about to be added to the event
bThe products already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
std::vector< art::Ptr< U > >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to many association between a new product and a vector of Ptrs already in the event.

Parameters
aThe collection about to be added to the event
bThe products already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
std::vector< U > &  b,
art::Assns< T, U > &  assn,
size_t  startU,
size_t  endU,
size_t  indx = UINT_MAX,
std::string const &  instancea = std::string(),
std::string const &  instanceb = std::string() 
)
static

Create a 1 to many association between new products.

Parameters
aA collection about to be added to the event
bAnother collection about to be added to the event
startUThe first element of b to associate
endUThe last element of b to associate +1 (like STL begin() and end())
indxWhich element of a to associate. By default the last one.
instanceainstance label for product a, defaulted to be an empty string
instancebinstance label for product b, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
std::vector< T > &  a,
std::vector< U > &  b,
art::Assns< T, U > &  assn,
size_t  startU,
size_t  endU,
size_t  indx = UINT_MAX,
std::string const &  instancea = std::string(),
std::string const &  instanceb = std::string() 
)
static

Create a 1 to many association between new products.

Parameters
aA collection about to be added to the event
bAnother collection about to be added to the event
startUThe first element of b to associate
endUThe last element of b to associate +1 (like STL begin() and end())
indxWhich element of a to associate. By default the last one.
instanceainstance label for product a, defaulted to be an empty string
instancebinstance label for product b, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDProducer const &  prod,
art::Event evt,
art::Assns< T, U > &  assn,
std::vector< T > &  a,
std::vector< U > &  b,
size_t  indxb = UINT_MAX,
size_t  indxa = UINT_MAX,
std::string const &  instancea = std::string(),
std::string const &  instanceb = std::string() 
)
static

Create a 1 to 1 between new products.

Parameters
aA collection about to be added to the event
bAnother collection about to be added to the event
indxbWhich element of b to associate. By default the last one.
indxaWhich element of a to associate. By default the last one.
instanceainstance label for product a, defaulted to be an empty string
instancebinstance label for product b, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  filt,
art::Event evt,
std::vector< T > &  a,
std::vector< U > &  b,
art::Assns< T, U > &  assn,
size_t  startU,
size_t  endU,
size_t  indx = UINT_MAX,
std::string const &  instancea = std::string(),
std::string const &  instanceb = std::string() 
)
static
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to 1 association between a new product and one already in the event.

Parameters
aThe collection about to be added to the event
bThe product already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
std::vector< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn,
size_t  begin_indx,
size_t  end_indx,
std::string const &  instance = std::string() 
)
static

Create a 1 to 1 association between each of a series of new products and one already in the event.

Parameters
aThe collection about to be added to the event
bThe product already in the event
begin_indxWhich element of a to associate first.
end_indxOne more than the index of the last element to associate
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
art::Ptr< T > &  a,
art::Ptr< U >  b,
art::Assns< T, U > &  assn 
)
static

Create a 1 to 1 association between two products already in the event.

Parameters
aA product already in the event
bAnother product already in the event
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
std::vector< T > &  a,
art::PtrVector< U >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to many association between a new product and a PtrVector already in the event.

Parameters
aThe collection about to be added to the event
bThe products already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
art::Ptr< T > &  a,
std::vector< art::Ptr< U > >  b,
art::Assns< T, U > &  assn 
)
static

Create a 1 to many association between products already in the event.

Parameters
aA product already in the event
bA vector of products already in the event (the many)
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
std::vector< T > &  a,
std::vector< art::Ptr< U > >  b,
art::Assns< T, U > &  assn,
size_t  indx = UINT_MAX,
std::string const &  instance = std::string() 
)
static

Create a 1 to many association between a new product and a vector of Ptrs already in the event.

Parameters
aThe collection about to be added to the event
bThe products already in the event
indxWhich element of a to associate. By default the last one.
instanceinstance label for product, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
std::vector< T > &  a,
std::vector< U > &  b,
art::Assns< T, U > &  assn,
size_t  startU,
size_t  endU,
size_t  indx = UINT_MAX,
std::string const &  instancea = std::string(),
std::string const &  instanceb = std::string() 
)
static

Create a 1 to many association between new products.

Parameters
aA collection about to be added to the event
bAnother collection about to be added to the event
startUThe first element of b to associate
endUThe last element of b to associate +1 (like STL begin() and end())
indxWhich element of a to associate. By default the last one.
instanceainstance label for product a, defaulted to be an empty string
instancebinstance label for product b, defaulted to be an empty string
template<class T , class U >
static bool util::CreateAssn ( art::EDFilter const &  prod,
art::Event evt,
art::Assns< T, U > &  assn,
std::vector< T > &  a,
std::vector< U > &  b,
size_t  indxb = UINT_MAX,
size_t  indxa = UINT_MAX,
std::string const &  instancea = std::string(),
std::string const &  instanceb = std::string() 
)
static

Create a 1 to 1 between new products.

Parameters
aA collection about to be added to the event
bAnother collection about to be added to the event
indxbWhich element of b to associate. By default the last one.
indxaWhich element of a to associate. By default the last one.
instanceainstance label for product a, defaulted to be an empty string
instancebinstance label for product b, defaulted to be an empty string
template<class T >
T util::cube ( T  x)
inline
def util.elem_frac (   compos,
  elem 
)

Definition at line 20 of file util.py.

References tot_weight().

Referenced by elem_frac_total().

20 def elem_frac(compos, elem):
21  if elem in compos:
22  return compos[elem] * atomic_weight[elem] / tot_weight(compos)
23  else:
24  return 0
25 
def elem_frac(compos, elem)
Definition: util.py:20
def tot_weight(compos)
Definition: util.py:8
def util.elem_frac_total (   elem,
  compositions,
  fractions 
)

Definition at line 26 of file util.py.

References elem_frac(), and tot_fractions().

Referenced by make_composition(), and print_composition().

26 def elem_frac_total(elem, compositions, fractions):
27  frac = 0
28  for material, compos in compositions.items():
29  if material in fractions:
30  frac += elem_frac(compos, elem) * fractions[material]
31  return frac / tot_fractions(fractions)
32 
def elem_frac(compos, elem)
Definition: util.py:20
def tot_fractions(fractions)
Definition: util.py:14
def elem_frac_total(elem, compositions, fractions)
Definition: util.py:26
std::string util::EnvExpansion ( const std::string &  inString)

Function to expand environment variables.

Definition at line 8 of file EnvExpand.cxx.

References compare_h5_caf::idx, confusionMatrixTree::out, fabricate::status, and tmp.

Referenced by wsnumu::WSNumu::beginRun(), ncpi0::MakeNCPi0BkgRej::beginRun(), ncid::MakeNCCosRej::beginRun(), bpfit::BPFEnergyEstimator::beginRun(), bpfit::BPFPIdMaker::beginRun(), bpfit::BPFEnergyEstimatorOnly::beginRun(), cosrej::MakeNueCosRej::beginRun(), ncid::NCNNKeras::beginRun(), ncid::NCNNKerasVal::beginRun(), cvntf::CVNCosmicTF::CVNCosmicTF(), cvneventtf::CVNEventTF::CVNEventTF(), cvnneutronprongtf::CVNNeutronProngTF::CVNNeutronProngTF(), cvntf::CVNProngEvaluatorTF::CVNProngEvaluatorTF(), cvnprongtf::CVNProngTF::CVNProngTF(), qeef::QeFinder::Init(), cosrej::CosRej::Init(), muonid::MuonIDProd::Init(), remid::RecoMuon::Init(), slid::DedxDistribution::Initialize(), ana::GetBDTCosRej_BPF_FHCPer1::InitTMVA(), ana::GetBDTCosRej_BPF_FHCPer2::InitTMVA(), ana::GetBDTCosRej_BPF_FHCHigh::InitTMVA(), ana::GetBDTCosRej_BPF_RHCHigh::InitTMVA(), ana::GetBDTCosRej_Kal_FHCPer1::InitTMVA(), ana::GetBDTCosRej_Kal_FHCPer2::InitTMVA(), ana::GetBDTCosRej_Kal_FHCHigh::InitTMVA(), ana::GetBDTCosRej_Kal_RHCHigh::InitTMVA(), slid::LIDAlg::LIDAlg(), slid::ParticleIDAlg::LoadDedxHistogramFiles(), jmshower::RecoJMShower::LoadDedxHistograms(), jmshower::RecoJMShower::LoadTreeWeights(), lem::MakePID::MakePID(), nuonecvntf::NuonECVNTF::NuonECVNTF(), lem::LEMLibrary::reconfigure(), lem::FindMatchesTranspose::reconfigure(), lem::FindLEMMatches::reconfigure(), lem::LEM::reconfigure(), slid::LIDBuilder::reconfigure(), slid::SPIDBuilder::reconfigure(), rvp::RecVarPID::RecVarPID(), regcvntf::RegCVNTF::RegCVNTF(), slid::SPIDAlg::SPIDAlg(), and xnue::XnuePID::XnuePID().

9  {
10  std::string outString = inString;
11 
12  wordexp_t out;
13  int status = wordexp(inString.c_str(), &out, WRDE_SHOWERR);
14  if(status == 0){
15  outString = "";
16  for (unsigned int idx = 0; idx < out.we_wordc; ++idx){
17  std::string tmp(out.we_wordv[idx]);
18  outString.append(tmp);
19  }
20  }
21  wordfree(&out);
22  return outString;
23  }
int status
Definition: fabricate.py:1613
Float_t tmp
Definition: plot.C:36
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void util::EventBox ( const std::vector< art::Ptr< rawdata::RawDigit > > &  d,
unsigned int  i1,
unsigned int  i2,
unsigned int plane1x,
unsigned int plane2x,
unsigned int cell1x,
unsigned int cell2x,
unsigned int plane1y,
unsigned int plane2y,
unsigned int cell1y,
unsigned int cell2y 
)

Find boxes in plane/cell units that contain all the hits.

Parameters
d: The complete list of raw digits to be considered
i1: Index of the first hit to be considered
i2: Index of the last hit to be considered (inclusive)
plane1x: On output, the lowest plane number in the x view
plane2x: On output, the highest plane number in the x view
cell1x: On output, the lowest cell number in the x view
cellx: On output, the highest cell number in the x view
plane1y: On output, the lowest plane number in the y view
plane2y: On output, the highest plane number in the y view
cell1y: On output, the lowest cell number in the y view
celly: On output, the highest cell number in the y view

Definition at line 60 of file RawUtil.cxx.

References plot_validation_datamc::c, visualisationForPaperMasterPlot::cmap, d, geom(), cmap::dataprov::CMap::GetCell(), cmap::dataprov::CMap::GetPlane(), MECModelEnuComparisons::i, geo::kX, geo::kY, geo::GeometryBase::Plane(), registry_explorer::v, and geo::PlaneGeo::View().

71 {
74 
75  *plane1x = 999999;
76  *plane1y = 999999;
77  *cell1x = 999999;
78  *cell1y = 999999;
79  *plane2x = 0;
80  *cell2x = 0;
81  *plane2y = 0;
82  *cell2y = 0;
83 
84  unsigned int i;
85  unsigned int p, c;
86  geo::View_t v;
87  for (i=i1; i<=i2; ++i) {
88  p = cmap->GetPlane(d[i].get());
89  v = geom->Plane(p)->View();
90  c = cmap->GetCell(d[i].get());
91  if (v==geo::kX) {
92  if (p<(*plane1x)) (*plane1x) = p;
93  if (p>(*plane2x)) (*plane2x) = p;
94  if (c<(*cell1x)) (*cell1x) = c;
95  if (c>(*cell2x)) (*cell2x) = c;
96  }
97  else if (v==geo::kY) {
98  if (p<(*plane1y)) (*plane1y) = p;
99  if (p>(*plane2y)) (*plane2y) = p;
100  if (c<(*cell1y)) (*cell1y) = c;
101  if (c>(*cell2y)) (*cell2y) = c;
102  }
103  }
104 }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const char * p
Definition: xmltok.h:285
Vertical planes which measure X.
Definition: PlaneGeo.h:28
const PlaneGeo * Plane(unsigned int i) const
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:53
Float_t d
Definition: plot.C:236
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
void geom(int which=0)
Definition: geom.C:163
unsigned short GetCell(const rawdata::RawDigit *dig)
Definition: CMap.cxx:327
unsigned int util::FilterFEBFlash ( std::vector< art::Ptr< rawdata::RawDigit > > &  rd,
int  adc_sat = 3400,
int  dt_tdc = 1280 
)

Filter hits that are "FEB flash" candidates; that is, they occur within a specified time of an FEB hit in saturation.

Parameters
rd- Input list of raw digits. On output it will be time sorted and have had FEB flash hits removed.
adc_sat- ADC value to flag a raw hit as being in saturation, recommended value is 3400 counts
dt_tdc- time difference between time of saturation and time of candidate "flash" hit in units of TDC counts. Recommended value is 1280 (20 usec) Note: 1920 (30 usec) is also a useful optional value.
Returns
the new size of the rd raw hit list

Note that the vector rd will be returned time sorted and equal or shorter than its original length

Definition at line 194 of file RawUtil.cxx.

References update_sam_good_runs_metadata::good, MECModelEnuComparisons::i, calib::j, and TimeSort().

197 {
198  unsigned int i, j;
199 
200  //
201  // For efficiency, time sort the hits in advance
202  //
203  util::TimeSort(rd);
204 
205  //
206  // Flag all hits as good, look for ones that might be bad
207  //
208  std::vector<bool> isgood(rd.size());
209  for (i=0; i<rd.size(); ++i) isgood[i] = true;
210  for (i=0; (i+1)<rd.size(); ++i) {
211  //
212  // If the hit i is not in saturation, we can skip to the next
213  // hit
214  //
215  if (rd[i]->ADC()<adc_sat) continue;
216  //
217  // Get ID number for the FEB ID that has the hit in saturation
218  //
219  unsigned int chi = rd[i]->DaqChannel();
220  unsigned int diblocki = (chi&0x0FC00000)>>22;
221  unsigned int dcmi = (chi&0x003F0000)>>16;
222  unsigned int febi = (chi&0x0000FF00)>>8;
223  for (j=i+1; j<rd.size(); ++j) {
224  //
225  // Don't need to look beyond the time limit
226  //
227  if ((rd[j]->TDC()-rd[i]->TDC())>dt_tdc) break;
228  //
229  // Hit j is in time range of another hit which is in
230  // saturation. Check if hit j comes from the same FEB as hit
231  // i
232  //
233  unsigned int chj = rd[j]->DaqChannel();
234  unsigned int diblockj = (chj&0x0FC00000)>>22;
235  unsigned int dcmj = (chj&0x003F0000)>>16;
236  unsigned int febj = (chj&0x0000FF00)>>8;
237  bool sameFEB =
238  (diblocki==diblockj) && (dcmi==dcmj) && (febi==febj);
239  if (sameFEB) isgood[j] = false;
240  }
241  }
242  //
243  // Push all the good hits into the final list
244  //
245  std::vector< art::Ptr<rawdata::RawDigit> > good;
246  good.reserve(rd.size());
247  for (i=0; i<rd.size(); ++i) {
248  if (isgood[i]) good.push_back(rd[i]);
249  }
250  rd.swap(good);
251  return rd.size();
252 }
const double j
Definition: BetheBloch.cxx:29
void TimeSort(std::vector< art::Ptr< rawdata::RawDigit > > &d)
Arrange the list of raw hits in time order (early to late)
Definition: RawUtil.cxx:31
static double util::find_median ( const std::vector< std::pair< double, double > > &  a)
static

Definition at line 83 of file MathUtil.cxx.

References a, MECModelEnuComparisons::i, moon_position_table_new3::second, x1, submit_syst::x2, y1, and submit_syst::y2.

Referenced by LinFitTS().

84  {
85  unsigned int i;
86  for (i=0; i<a.size(); ++i) {
87  if (a[i].second>0.5) break;
88  }
89  if (i>1) {
90  //
91  // Linearly interpolate along weights to find 0.5
92  //
93  double x1 = a[i-1].second;
94  double x2 = a[i]. second;
95  double y1 = a[i-1].first;
96  double y2 = a[i]. first;
97  return y1 + (0.5-x1)*(y2-y1)/(x2-x1);
98  }
99  return a[i].first;
100  }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
const double a
template<class T , class U >
static std::vector<const U*> util::FindUNotAssociatedToT ( art::Handle< U >  b,
art::Event const &  evt,
std::string const &  label 
)
static

Return all objects of type U that are not associated to objects of type T.

Label is the module label that would have produced the associations and likely the objects of type T this method assumes there is a one to many relationship between T and U for example if you want to get all rb::CellHits that are not associated to rb::Clusters std::vector<const rb::CellHit*> hits = FindUNotAssociatedToU<rb::Cluster>(art::Handle<rb::CellHit>, ...);

template<class T , class U >
static std::vector<const U*> util::FindUNotAssociatedToT ( art::Handle< U >  b,
art::Event const &  evt,
std::string const &  label 
)
static

Return all objects of type U that are not associated to objects of type T.

Label is the module label that would have produced the associations and likely the objects of type T this method assumes there is a one to many relationship between T and U for example if you want to get all rb::CellHits that are not associated to rb::Clusters std::vector<const rb::CellHit*> hits = FindUNotAssociatedToU<rb::Cluster>(art::Handle<rb::CellHit>, ...);

template<class T , class U >
static std::vector< art::Ptr<U> > util::FindUNotAssociatedToTP ( art::Handle< U >  b,
art::Event const &  evt,
std::string const &  label 
)
static

Return all objects of type U that are not associated to objects of type T.

Label is the module label that would have produced the associations and likely the objects of type T this method assumes there is a one to many relationship between T and U for example if you want to get all rb::CellHits that are not associated to rb::Clusters std::vector<art::Ptr<rb::CellHit> > hits = FindUNotAssociatedToTP<rb::Cluster>(art::Handle<rb::CellHit>, ...);

template<class T , class U >
static std::vector< art::Ptr<U> > util::FindUNotAssociatedToTP ( art::Handle< U >  b,
art::Event const &  evt,
std::string const &  label 
)
static

Return all objects of type U that are not associated to objects of type T.

Label is the module label that would have produced the associations and likely the objects of type T this method assumes there is a one to many relationship between T and U for example if you want to get all rb::CellHits that are not associated to rb::Clusters std::vector<art::Ptr<rb::CellHit> > hits = FindUNotAssociatedToTP<rb::Cluster>(art::Handle<rb::CellHit>, ...);

double util::frac ( double  x)
template<class T >
std::unique_ptr<std::vector<T> > util::GetHits ( const std::vector< rb::Cluster > &  clusts)

Definition at line 54 of file CopyCellHits_module.cc.

55  {
56  auto hitcol = std::make_unique<std::vector<T>>();
57 
58  for(const rb::Cluster& clust: clusts)
59  for(unsigned int iCell = 0; iCell < clust.NCell(); ++iCell)
60  hitcol->push_back(*clust.Cell(iCell));
61 
62  return hitcol;
63  }
A collection of associated CellHits.
Definition: Cluster.h:47
template<typename T >
T util::GetValAs ( const stan::math::var val)
inline

explicit specialization for double return value

Either no-op or convert stan::math::var to double. Exists so GetVal<T>(var) can be used with one signature inside a function templated over both stan::math::var & double. (see, e.g., CAFAna/Fit/StanFitter.cxx.)

explicit specialization for double return value

Definition at line 25 of file StanUtils.h.

References febshutoff_auto::val, and stan::math::var::val().

25 {return val.val();}
double val() const
Definition: var.hpp:294
template<>
double util::GetValAs ( const stan::math::var val)
inline

explicit specialization for double return value

Either no-op or convert stan::math::var to double. Exists so GetVal<T>(var) can be used with one signature inside a function templated over both stan::math::var & double. (see, e.g., CAFAna/Fit/StanFitter.cxx.)

Definition at line 25 of file StanUtils.h.

References stan::math::var::val().

25 {return val.val();}
double val() const
Definition: var.hpp:294
template<>
stan::math::var util::GetValAs ( const stan::math::var val)
inline

explicit specialization for stan::math::var return value

explicit specialization for double return value

Definition at line 29 of file StanUtils.h.

References febshutoff_auto::val.

29 { return val; }
template<typename T >
std::enable_if<std::is_convertible<T, double>::value, T>::type util::GetValAs ( double  val)
inline

Companion to GetValAs<>(stan::math::var) to provide ability to use GetValAs<double>(double) without implicitly converting to a stan::math::var.

Definition at line 36 of file StanUtils.h.

References febshutoff_auto::val.

36 { return val; }
template<class T >
T util::ipow ( T  x,
unsigned int  n 
)
inline

More efficient exponentiation function than pow(x,n) for small n.

Definition at line 29 of file MathUtil.h.

References b, plot_validation_datamc::c, MECModelEnuComparisons::i, LinFit(), LinFitTS(), LinFitUnweighted(), m, getGoodRuns4SAM::n, pythag(), runNovaSAM::ret, sqr(), std::sqrt(), T, w, submit_syst::x, submit_syst::y, and test::z.

Referenced by ana::AtmConstraint::BiCubicInterp(), rsim::LegacyPulseShaper::CreateTrace(), and calib::ThresholdCorrMap::~ThresholdCorrMap().

30  {
31  T ret = 1;
32  if (n == 0) return ret;
33  for(unsigned int i = 1; i <= n; ++i) ret *= x;
34  return ret;
35  }
double T
Definition: Xdiff_gwt.C:5
static bool util::IsInBeamWindow ( const int  run,
const double  time 
)
inlinestatic

Definition at line 100 of file NuMITimeParams.h.

Referenced by Exposure(), presel::CosmicVeto::produce(), and presel::CosmicCVNVeto::produce().

102  {
103  // In the bad period and in the shifted window
104  if(run <= kLastBadTimingRun &&
107  return true;
108 
109  // Or in any period and in the main window
110  return (time > 1000*kBeamWindowMinMicroSec &&
112  }
const int kBeamWindowMinMicroSec
const int kLastBadTimingRun
const int kBeamWindowShiftedMinMicroSec
const int kBeamWindowMaxMicroSec
const int kBeamWindowShiftedMaxMicroSec
Definition: run.py:1
double util::LinFit ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  w,
double &  m,
double &  c 
)

Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance from the points to the line.

Parameters
x- input vector of x coordinates
y- input vector of y coordinates
w- input vector of weights for the points
m- output gradient of the fit line
c- output y-intercept of the fit line
Returns
The chi^2 value defined by chi^2 = sum_i[w_i d^2_i]

In the common case of unweighted data with Gaussian errors, you should set the points weights to 1/sigma^2 for each point.

Parameters
x- input vector of x coordinates
y- input vector of y coordinates
w- input vector of weights for the points
m- output gradient of the fit line
c- output y-intercept of the fit line
Returns
The chi^2 value defined by chi^2 = sum_i[w_i d^2_i]

Definition at line 36 of file MathUtil.cxx.

References ana::assert(), chi2(), d, and MECModelEnuComparisons::i.

Referenced by upmuana::UpMuAnalysis::analyze(), lem::MakePID::AvgAndFit(), caldp::TCTrack::CalculateFiberVelocity(), caldp::TCTrack::CalculateMuonVelocity(), ipow(), geo::LinFit(), upmuana::LlrUpmu::LLR(), upmuana::UpMuAnalysis::LLR(), upmuana::UpMuRecoAna::LLR(), calib::AttenFit::lowessFit(), calib::AttenuationFit::lowessFit(), and pythag().

40  {
41  // Before going ahead, make sure we have sensible arrays
42  assert(x.size() == y.size());
43  assert(x.size() == w.size());
44  assert(x.size() >= 2);
45 
46  // Accumulate the sums for the fit
47  double Sw = 0;
48  double Swx = 0;
49  double Swy = 0;
50  double Swxy = 0;
51  double Swy2 = 0;
52  double Swx2 = 0;
53  for(unsigned int i = 0; i < w.size(); ++i) {
54  Sw += w[i];
55  Swx += w[i]*x[i];
56  Swy += w[i]*y[i];
57  Swx2 += w[i]*x[i]*x[i];
58  Swxy += w[i]*x[i]*y[i];
59  Swy2 += w[i]*y[i]*y[i];
60  }
61  const double d = Sw*Swx2 - Swx*Swx;
62  m = (Sw*Swxy - Swx*Swy)/d;
63  c = (Swy*Swx2 - Swx*Swxy)/d;
64 
65  const double chi2 =
66  Swy2 - 2.0*m*Swxy - 2.0*c*Swy + 2.0*m*c*Swx +
67  c*c*Sw + m*m*Swx2;
68 
69  return chi2;
70  }
double chi2()
Float_t d
Definition: plot.C:236
assert(nhit_max >=nhit_nbins)
Float_t w
Definition: plot.C:20
void util::LinFitTS ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  w,
double &  m,
double &  b,
int  wmode 
)

Best fit line to points using Theil-Sens median method.

An implementation of the Theil-Sens straight line estimator (http://en.wikipedia.org/wiki/Theil-Sen_estimator)

Theil-Sens sets the slope to be the median slope of data-point pairs and the intercept to the median value for data points computed using the median slope. Theil-Sens is more robust against the presence of noise.

The weighting method is controlled by "wmode":

  • wmode=0 : pairs of points will be assigned the same weights (that is, unweighted)
  • wmode=1 : pairs of points will be assigned weights equal to sqrt(w[i]*w[j])
  • wmode=2 : pairs of points will be assigned weights sqrt(w1*w1*d^2) where d is the distance between the points.
Parameters
x- input vector of x coordinates
y- input vector of y coordinates
w- input vector of weights
m- on return, the slope value
b- on return, the intercept value
wmode- weight mode

Definition at line 104 of file MathUtil.cxx.

References ana::assert(), dx, dy, find_median(), MECModelEnuComparisons::i, calib::j, getGoodRuns4SAM::n, sort_pair_by_first(), std::sqrt(), and w.

Referenced by bpfit::TrackBasis::FindAxis(), and ipow().

110  {
111  unsigned int i, j;
112 
113  //
114  // Check that we have at least two points and that the x and y
115  // vectors sizes match
116  //
117  unsigned int n = x.size();
118  assert(n>1);
119  assert(n==y.size());
120 
121  //
122  // Reserve a vector of slope,weight pairs. Reserve the space we need
123  // up front to improve efficiency
124  //
125  std::vector<std::pair<double,double> > mw;
126  mw.reserve(n*(n-1)-1);
127 
128  //
129  // Find the slopes of all pairs of points x,y. Depending on calling
130  // options, weight the pairs by their separation distance.
131  //
132  double dx, dy, w;
133  double wnorm = 0.0;
134  for (i=0; (i+1)<n; ++i) {
135  for (j=i+1; j<n; ++j) {
136  dx = x[j]-x[i];
137  dy = y[j]-y[i];
138  if (dx!=0.0) {
139  m = dy/dx;
140  switch (wmode) {
141  case 1: w = sqrt(wt[i]*wt[j]); break;
142  case 2: w = sqrt(wt[i]*wt[j]*(dx*dx+dy*dy)); break;
143  default: w = 1.0; break;
144  }
145  if (w>0.0) {
146  mw.push_back( std::pair<double,double>(m,w) );
147  wnorm += w;
148  }
149  }
150  }
151  }
152  std::sort(mw.begin(), mw.end(), sort_pair_by_first);
153 
154  //
155  // Normalize weights to accumulate along the interval between 0 and 1
156  //
157  double sumw = 0.0;
158  wnorm = 1.0/wnorm;
159  for (i=0; i<mw.size(); ++i) {
160  mw[i].second = wnorm*mw[i].second + sumw;
161  sumw = mw[i].second;
162  }
163 
164  m = find_median(mw);
165 
166  //
167  // Build a vector or intercept, weight pairs
168  //
169  std::vector<std::pair<double,double> > bw;
170  bw.reserve(n);
171 
172  //
173  // Now compute the intercepts
174  //
175  wnorm = 0.0;
176  w = 1.0;
177  for (i=0; i<n; ++i) {
178  b = y[i] - m*x[i];
179  bw.push_back( std::pair<double,double>(b,w) );
180  wnorm += w;
181  }
182  std::sort(bw.begin(), bw.end(), sort_pair_by_first);
183 
184  //
185  // Normalize the weights to accumulate along a range between 0 and
186  // 1
187  //
188  sumw = 0.0;
189  wnorm = 1.0/wnorm;
190  for (i=0; i<bw.size(); ++i) {
191  bw[i].second = wnorm*bw[i].second + sumw;
192  sumw = bw[i].second;
193  }
194 
195  b = find_median(bw);
196  }
static bool sort_pair_by_first(const std::pair< double, double > &a, const std::pair< double, double > &b)
Definition: MathUtil.cxx:75
T sqrt(T number)
Definition: d0nt_math.hpp:156
double dy[NP][NC]
double dx[NP][NC]
const double j
Definition: BetheBloch.cxx:29
static double find_median(const std::vector< std::pair< double, double > > &a)
Definition: MathUtil.cxx:83
const hit & b
Definition: hits.cxx:21
assert(nhit_max >=nhit_nbins)
Float_t w
Definition: plot.C:20
void util::LinFitUnweighted ( const std::vector< double > &  x,
const std::vector< double > &  y,
double &  m,
double &  c 
)

Simplified version of LinFit.

All weights are assumed 1. In the absence of ability to weight, the returned chi-square doesn't mean much and is omitted.

Definition at line 8 of file MathUtil.cxx.

References ana::assert(), d, and MECModelEnuComparisons::i.

Referenced by novaddt::ClusterAna::analyze(), lem::MakePID::AvgAndFit(), novaddt::NuESelect::filter(), ipow(), and pythag().

11  {
12  // Before going ahead, make sure we have sensible arrays
13  assert(x.size() == y.size());
14  assert(x.size() >= 2);
15 
16  // Accumulate the sums for the fit
17  double Sx = 0;
18  double Sy = 0;
19  double Sxy = 0;
20  double Sy2 = 0;
21  double Sx2 = 0;
22  const unsigned int I = x.size();
23  for(unsigned int i = 0; i < I; ++i) {
24  Sx += x[i];
25  Sy += y[i];
26  Sx2 += x[i]*x[i];
27  Sxy += x[i]*y[i];
28  Sy2 += y[i]*y[i];
29  }
30  const double d = I*Sx2 - Sx*Sx;
31  m = (I*Sxy - Sx*Sy)/d;
32  c = (Sy*Sx2 - Sx*Sxy)/d;
33  }
Float_t d
Definition: plot.C:236
assert(nhit_max >=nhit_nbins)
def util.make_composition (   name,
  fractions,
  compositions 
)

Definition at line 46 of file util.py.

References elem_frac_total().

Referenced by air.air_composition(), barite.barite_composition(), fdbedrock.fdbedrock_composition(), fdbermrock.fdbermrock_composition(), glue.glue_composition(), pvc.pvc_composition(), snow.snow_composition(), and soil.soil_composition().

46 def make_composition(name, fractions, compositions):
47  the_composition = { }
48 
49  for elem in elemlist:
50  the_composition[elem] = elem_frac_total(elem, compositions, fractions)
51 
52  return the_composition
53 
54 
def elem_frac_total(elem, compositions, fractions)
Definition: util.py:26
def make_composition(name, fractions, compositions)
Definition: util.py:46
def util.print_composition (   composition)

Definition at line 55 of file util.py.

References elem_frac_total(), novadaq::HexUtils.format(), and print.

Referenced by printscintfd.scintfd_composition().

55 def print_composition(composition):
56  for elem in elemlist:
57  if elem in composition and composition[elem] > 0:
58  print(" <fraction n=\"{0:.7f}\" ref={1:<10s}/>"
59  .format(composition[elem],
60  "\"{0:s}\"".format(atomic_names[elem]))),
61  if elem == 'Cl':
62  print("<!-- Cl-35: {0:.4f}, Cl-37: {1:.4f} -->".
63  format(composition[elem]*cl35massfrac,
64  composition[elem]*cl37massfrac))
65  else:
66  print("")
67  if printmore:
68  for elem in elemlist:
69  if elem in composition and composition[elem] > 0:
70  print("const double {0:s}_{1:<2s} = {2:f};"
71  .format(name, elem, elem_frac_total(elem, compositions, fractions)))
72 
def print_composition(composition)
Definition: util.py:55
def elem_frac_total(elem, compositions, fractions)
Definition: util.py:26
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
double util::pythag ( double  x,
double  y 
)
inline

2D Euclidean distance

Definition at line 29 of file MathUtil.h.

References sqr(), and std::sqrt().

Referenced by ana::KrigeKernel::AddPoint(), comi::CosmicMetrics::analyze(), mcchk::CosmicAna::analyze(), align::Alignment::analyze(), mcchk::LeptonAna::analyze(), earms::ElasticArmsValidate::analyze(), comi::NearlineAna::analyze(), mono::Monopole::analyze(), fuzz::FuzzyKValidate::analyze(), geo::AverageCellPathLength(), numue::NumuEAna::beginRun(), hough::Hough2P::BuildMap(), hough::MultiHough2P::BuildMap(), slid::ParticleIDAlg::CalcTrkHitPath(), geo::GeometryBase::CountCellsOnLine(), geo::GeometryBase::DEdge(), lem::DistanceMap::DistFunc(), me::TrkME::DistToTrk(), comi::Leana::DumpMuon(), lem::EventSummary::EventSummary(), sn::SupernovaAna::FillPlaneSeperations(), filter::Filter::FillTrackVariables(), comi::Leana::FindClosestMuon(), dt::DiscreteTracker::FindVertex(), dt::ViewMerger::FindVertex(), xsrec::MakeXSecCCPi0Inc::GetBPI(), evd::RecoBaseDrawer::GetClusterOutlinesConvexHull(), tdslicer::TDSlicer::GetDist(), nerd::NERDProng::HitToHitDistance(), me::MEFinder::HitToHitDistance(), geo::InitializePathTable(), ipow(), calib::PCHitsList::IsGoodTrack(), osc::EarthModel::LineProfile(), fuzz::FuzzyKMeanAlg::MakeAngles(), geo::GeometryBase::MassBetweenPoints(), fuzz::ViewMatchAlg::Matching(), nerd::ViewMatchAlg::Matching(), geo::GeometryBase::MaterialsBetweenPoints(), numue::NumuEAlg::NumuEAlg(), ana::KrigeKernel::operator()(), mcchk::ShowerAnaCheck::PointLineDistance(), nussand::FillNusSandbox::produce(), jmshower::JMTrackMerge::produce(), comi::Cana::produce(), photrans::PhotonTransport::produce(), jmshower::JMClusterMerge::produce(), hough::MultiHough2P::RefinePeak(), hough::Hough2P::RhoTheta(), hough::MultiHough2P::RhoTheta(), hough::MultiHoughT::Scrub(), earms::ElasticArmsHS::Scrub(), vdt::VertexDT::Scrub(), fuzz::FuzzyKVertex::Scrub(), trk::RLFit::SeedWeights(), photrans::ImprovedTransport::StepAlongHit(), dt::ViewMerger::TotalChargePerView(), htk::Track3D::Track3D(), mono::Track3D::Track3D(), and me::MEFinder::TrkMEDist().

30  {
31  return sqrt(sqr(x)+sqr(y));
32  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
double util::pythag ( double  x,
double  y,
double  z 
)
inline

3D Euclidean distance

Definition at line 35 of file MathUtil.h.

References plot_validation_datamc::c, LinFit(), LinFitUnweighted(), m, sqr(), std::sqrt(), w, submit_syst::x, and submit_syst::y.

36  {
37  return sqrt(sqr(x)+sqr(y)+sqr(z));
38  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
z
Definition: test.py:28
void util::SaveObj ( const TObject *  obj,
const std::string &  filenameStub,
const std::string &  dirName = "",
const std::vector< std::string >  exts = {".png", ".eps", ".root"},
bool  silent = false 
)
inline

Definition at line 21 of file ROOTHelpers.h.

References dirName, galleryMaker::ext, and runNovaSAM::gErrorIgnoreLevel.

Referenced by drawSystsShiftingNDdata(), and EHadVisMECpairs().

24  {".png", ".eps", ".root"},
25  bool silent=false)
26  {
27  std::string fullFname = (dirName.size() ? (dirName + "/") : "") + filenameStub;
28  auto prevOutputFlag = gErrorIgnoreLevel;
29  if (silent)
30  gErrorIgnoreLevel = kWarning;
31  for (const auto & ext : exts)
32  obj->SaveAs( (fullFname + ext).c_str() );
33  if (silent)
34  gErrorIgnoreLevel = prevOutputFlag;
35  }
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string dirName
Definition: PlotSpectra.h:47
void util::SetVal ( double &  target,
const stan::math::var source 
)
inline

Replacement for operator=() making it clear that you're 'casting' across double-stan::math::var boundary.

Definition at line 40 of file StanUtils.h.

References stan::math::var::val().

40 {target = source.val();}
const XML_Char * target
Definition: expat.h:268
double val() const
Definition: var.hpp:294
void util::SetVal ( stan::math::var target,
const double &  source 
)
inline

Definition at line 41 of file StanUtils.h.

41 {target = source;}
const char * source
Definition: lz4.h:436
void util::SetVal ( stan::math::var target,
const stan::math::var source 
)
inline

Definition at line 42 of file StanUtils.h.

42 {target = source;}
const char * source
Definition: lz4.h:436
void util::SetVal ( double &  target,
const double &  source 
)
inline

Definition at line 45 of file StanUtils.h.

45 {target = source;}
const XML_Char * target
Definition: expat.h:268
const char * source
Definition: lz4.h:436
static bool util::sort_pair_by_first ( const std::pair< double, double > &  a,
const std::pair< double, double > &  b 
)
static

Definition at line 75 of file MathUtil.cxx.

Referenced by LinFitTS().

77  {
78  return (a.first<b.first);
79  }
const double a
const hit & b
Definition: hits.cxx:21
template<class T >
T util::sqr ( T  x)
inline

More efficient square function than pow(x,2)

Definition at line 23 of file MathUtil.h.

References submit_syst::x.

Referenced by ana::KrigeKernel::AddPoint(), novaddt::ClusterAna::analyze(), align::Alignment::analyze(), ana::AutoPlaceLegend(), ana::CalcChi2(), fnex::ShifterAndWeighter::CalcInterpolatedWgt(), cc(), ana::Dmsq32Constraint::ChiSq(), ana::ReactorExperiment::ChiSq(), ana::GaussianConstraint::ChiSq(), ana::SolarConstraints::ChiSq(), ana::AtmConstraint::ChiSq(), ana::Ssth23Constraint::ChiSq(), ana::ComparisonTableNbins(), ana::TwoSampleDecomp::Decomp(), calib::BetheBlochAnalytic::dEdx(), lem::DistanceMap::DistanceMap(), ana::Hist::Divide(), geo::DsqrToLine(), ana::ErrorBarChart(), tf::HoughScore::Eval(), FCCorrectSlice(), tdslicer::TDSlicer::FillDists(), hv::HoughVertexAlg::FillMaps(), novaddt::NuESelect::filter(), calib::AttenFit::FitQuality(), calib::AttenuationFit::FitQuality(), ana::PredictionInterp::FitRatios(), trk::CosmicTrackAlg::FitView(), trk::WindowTrackingAlg::FitWindow(), lem::dec::Cut::FOM(), ana::Hist::FromDirectory(), ana::FitSinSq2Theta13::GetValue(), ana::FitSinSqTheta23::GetValue(), FitSinSqTheta23UO::GetValue(), ana::FitSinSqTheta23UpperOctant::GetValue(), FitSinSqTheta23LO::GetValue(), ana::FitSinSqTheta23LowerOctant::GetValue(), ana::FitSinSqTheta13Sterile::GetValue(), ana::FitSinSq2Theta23CPT::GetValue(), ana::FitSinSq2Theta23::GetValue(), ana::FitSinSq2Theta13Sterile::GetValue(), ana::FitSinSqTheta23CPT::GetValue(), ana::FitSinSqTheta23Sterile::GetValue(), ana::FitSinSq2Theta13CPT::GetValue(), ana::FitSinSqTheta14Sterile::GetValue(), ana::FitSinSq2Theta12CPT::GetValue(), FitSinSqTheta23MaxMix::GetValue(), ana::FitSinSqTheta24Sterile::GetValue(), ana::FitTanSqTheta12::GetValue(), ana::FitSinSq2Theta12::GetValue(), ana::FitSinSqTheta34Sterile::GetValue(), FitSinSqTheta23LowerOctant::GetValue(), FitSinSqTheta23UpperOctant::GetValue(), ana::MINERvA_MEC_Wgt_Var::GetWeight(), ana::Spectrum::Integral(), ipow(), osc::EarthModel::LineProfile(), geo::LinFitMinDperp(), test::LogGauss(), ana::T2KToyExperiment::LogL(), test::GaussQuadExperiment::LogLikelihood(), MakeStackNME(), hough::Hough2P::Map(), hough::MultiHough2P::Map(), monoprob(), calib::BetheBlochAnalytic::MPV(), ana::Hist::Multiply(), ana::NeutronMass(), ana::IConstrainedFitVar::Penalty(), plot_3flavor_withsysts(), ana::PointDistanceToBox(), mcchk::ShowerAnaCheck::PointLineDistance(), ana::PrintOscilationParameters(), numusand::FillSandbox::produce(), jmshower::JMTrackMerge::produce(), lem::MakePID::produce(), cosrej::MakeNueCosRej::produce(), pythag(), ana::RefineSeeds(), ana::MCMCSamples::RunDiagnostics(), ana::SummedSyst::Shift(), ana::PredictionInterp::ShiftBins(), ana::SimpleFOM(), ncs::NCAna::SimpleOscProb(), lem::Library::SimpleSurvivalProb(), lem::SimpleSurvivalProb(), test_ana(), test_stanfit_statsonly(), test_stanfit_withsysts(), lem::dec::Forest::Train(), lem::dec::Forest::TrainSingleTransformed(), calib::AttenFit::TruncatedMeanProfile(), calib::AttenuationFit::TruncatedMeanProfile(), and demo::DemoSyst1::TruthShift().

23 {return x*x;}
void util::TimeSlice ( const std::vector< art::Ptr< rawdata::RawDigit > > &  d,
unsigned int  tdcwindow,
unsigned int  nhit,
unsigned int  nhitx,
unsigned int  nhity,
std::vector< RawSlice > &  slice 
)

Find windows in time that have significant activity in the detector.

Parameters
d- The full raw digit list to consider
dt_tdc- Sliding window size in NOvA clock ticks (64 MHz)
nhit- Total number of hits to look for in window
nhitx- Number of hits required in x view
nhity- Number of hits required in y view
slice- On output, the start and end indicies of the time windows

Note: d must be time sorted on input. See "TimeSort" above.

Find time windows with significant hit activity

Definition at line 111 of file RawUtil.cxx.

References CountXY(), d, MECModelEnuComparisons::i, calib::j, demo1::nhit, and moon_position_table_new3::second.

Referenced by comi::Leana::analyze(), comi::FEBFlash::FEBTimeSlice(), and comi::Cana::produce().

117 {
118  //
119  // If the list can't meet our minimum hit requirements, we're done
120  // before we start. These checks also guarantee that the assumptions
121  // we make later regarding unsigned int arithmetic is correct
122  //
123  if (nhit<1 || nhit<(nhitx+nhity) || d.size()<nhit) return;
124 
125  unsigned int i, j;
126  std::vector<RawSlice> tmpslice;
127  for (i=0; i<d.size(); ++i) {
128  //
129  // Slide forward through the hits until we pass the limit of the
130  // time window
131  //
132  unsigned int dt = 0;
133  for (j=i+1; j<d.size(); ++j) {
134  dt = d[j]->TDC() - d[i]->TDC();
135  if (dt>=tdcwindow) {
136  //
137  // The last hit will have exceeded the time window so back up by
138  // one so that j is the index of the last hit to be included
139  //
140  --j;
141  //
142  // Do we have enough total hits?
143  //
144  if (j>=i && (j-i+1)>=nhit) {
145  //
146  // Do we have enough in the x and y views?
147  //
148  unsigned int nx=0, ny=0;
149  util::CountXY(d, i, j, &nx, &ny);
150  //
151  // Slice meets requirements. Put it in the list.
152  //
153  if (nx>=nhitx && ny>=nhity) {
154  RawSlice rs;
155  rs.first = i;
156  rs.second = j;
157  tmpslice.push_back(rs);
158  }
159  }
160  break; // Jump out of loop on j
161  } // if (dt>=tdcwindow)
162  } // for (j=...
163  //
164  // If we've bumped into the end of the digit list, we're done
165  //
166  if (j==d.size()) break;
167  }
168  //
169  // Merge overlaping slices
170  //
171  for (i=0; i<tmpslice.size(); ++i) {
172  if (tmpslice[i].first==0 && tmpslice[i].second==0) continue;
173  for (j=i+1; j<tmpslice.size(); ++j) {
174  if (tmpslice[j].first <= tmpslice[i].second) {
175  tmpslice[i].second = tmpslice[j].second;
176  tmpslice[j].first = 0;
177  tmpslice[j].second= 0;
178  }
179  }
180  }
181  //
182  // Push which ever slices survived to the output
183  //
184  for (unsigned int i=0; i<tmpslice.size(); ++i) {
185  if (!(tmpslice[i].first==0 && tmpslice[i].second==0)) {
186  slice.push_back(tmpslice[i]);
187  }
188  }
189 }
nhit
Definition: demo1.py:25
std::pair< unsigned int, unsigned int > RawSlice
Definition: RawUtil.h:23
void CountXY(const std::vector< art::Ptr< rawdata::RawDigit > > &d, unsigned int i1, unsigned int i2, unsigned int *nx, unsigned int *ny)
Count the number of digits in each detector view.
Definition: RawUtil.cxx:38
Definition: Cand.cxx:23
Float_t d
Definition: plot.C:236
const double j
Definition: BetheBloch.cxx:29
void util::TimeSort ( std::vector< art::Ptr< rawdata::RawDigit > > &  d)

Arrange the list of raw hits in time order (early to late)

Parameters
d: The list of digits to be sorted. Sorted on output.

Sort the list of digits to be in increasing time order, earliest to lattest

Definition at line 31 of file RawUtil.cxx.

References d, and digi_sort().

Referenced by comi::Leana::analyze(), comi::FEBFlash::FEBTimeSlice(), comi::FEBFlash::FilterFEBFlash(), FilterFEBFlash(), and comi::Cana::produce().

32 {
33  sort(d.begin(), d.end(), digi_sort);
34 }
static bool digi_sort(const art::Ptr< rawdata::RawDigit > d1, const art::Ptr< rawdata::RawDigit > d2)
Collection of basic utilities for working with raw digits.
Definition: RawUtil.cxx:19
Float_t d
Definition: plot.C:236
def util.tot_fractions (   fractions)

Definition at line 14 of file util.py.

Referenced by elem_frac_total().

14 def tot_fractions(fractions):
15  tions = 0
16  for material, fraction in fractions.items():
17  tions += fraction
18  return tions
19 
def tot_fractions(fractions)
Definition: util.py:14
def util.tot_weight (   compos)

Definition at line 8 of file util.py.

Referenced by elem_frac().

8 def tot_weight(compos):
9  weight = 0
10  for element, number in compos.items():
11  weight += number * atomic_weight[element]
12  return weight
13 
def tot_weight(compos)
Definition: util.py:8
def util.zovera (   elem)

Definition at line 33 of file util.py.

Referenced by zoveramaterial().

33 def zovera(elem):
34  # Not quite correct since atomic_weight in amu is only protons +
35  # neutrons up to the mass defect
36  return atomic_number[elem]/atomic_weight[elem]
37 
38 # takes a weight-fraction composition
def zovera(elem)
Definition: util.py:33
def util.zoveramaterial (   compos)

Definition at line 39 of file util.py.

References zovera().

39 def zoveramaterial(compos):
40  zoverasum = 0
41  for elem in elemlist:
42  if elem in compos:
43  zoverasum += zovera(elem)*compos[elem]
44  return zoverasum
45 
def zovera(elem)
Definition: util.py:33
def zoveramaterial(compos)
Definition: util.py:39

Variable Documentation

list util.elemlist
Initial value:
1 = [ 'H', 'C', 'O', 'N', 'S', 'Cl', 'Ti', 'Sn', 'Ca', 'Na',
2  'Al', 'Fe', 'Si', 'K', 'Mn', 'P', 'Ba' ]

Definition at line 3 of file util.py.

const int util::kBeamWindowBadPeriodMicroSec
Initial value:
=
const int kBeamWindowMinMicroSec
const int kBeamWindowShiftedMinMicroSec
const int kBeamWindowMaxMicroSec
const int kBeamWindowShiftedMaxMicroSec

Two windows to consider here.

Definition at line 89 of file NuMITimeParams.h.

const int util::kBeamWindowMaxMicroSec = 229

Definition at line 50 of file NuMITimeParams.h.

Referenced by generate_fd_fake_events().

const int util::kBeamWindowMicroSec = kBeamWindowMaxMicroSec - kBeamWindowMinMicroSec

How long is the beam window?

Definition at line 81 of file NuMITimeParams.h.

const int util::kBeamWindowMinMicroSec = 217

Definition at line 49 of file NuMITimeParams.h.

Referenced by generate_fd_fake_events().

const int util::kBeamWindowPaddingMicroSec = 9

Definition at line 47 of file NuMITimeParams.h.

const int util::kBeamWindowShiftedMaxMicroSec = kBeamWindowMaxMicroSec + kPeakShiftMicroSec

Definition at line 67 of file NuMITimeParams.h.

const int util::kBeamWindowShiftedMinMicroSec = kBeamWindowMinMicroSec + kPeakShiftMicroSec

Definition at line 66 of file NuMITimeParams.h.

const int util::kLastBadTimingRun = 17945

Definition at line 77 of file NuMITimeParams.h.

Referenced by Exposure().

const int util::kMaxTimingSidebandAfterMicroSec = 475

Definition at line 60 of file NuMITimeParams.h.

Referenced by generate_fd_fake_events().

const int util::kMaxTimingSidebandBeforeMicroSec = kBeamWindowMinMicroSec - kBeamWindowPaddingMicroSec

Definition at line 55 of file NuMITimeParams.h.

const int util::kMaxTimingSidebandBeforeShiftedWindowMicroSec = kBeamWindowShiftedMinMicroSec - kBeamWindowPaddingMicroSec

Definition at line 71 of file NuMITimeParams.h.

const int util::kMinTimingSidebandAfterMicroSec = kBeamWindowMaxMicroSec + kBeamWindowPaddingMicroSec

Definition at line 59 of file NuMITimeParams.h.

Referenced by generate_fd_fake_events().

const int util::kMinTimingSidebandAfterShiftedWindowMicroSec = kBeamWindowShiftedMaxMicroSec + kBeamWindowPaddingMicroSec

Definition at line 72 of file NuMITimeParams.h.

const int util::kMinTimingSidebandBeforeMicroSec = 25

Definition at line 54 of file NuMITimeParams.h.

const int util::kPeakShiftMicroSec = +64

Definition at line 63 of file NuMITimeParams.h.

const int util::kTimingSidebandBadPeriodMicroSec
Initial value:

Two beam windows to cut out here.

Definition at line 94 of file NuMITimeParams.h.

const int util::kTimingSidebandMicroSec
Initial value:

How long is the part of the spill far from the start and end, and also not in the beam window?

Definition at line 84 of file NuMITimeParams.h.

bool util.printmore = False

Definition at line 6 of file util.py.