28 , fNoiseCluster(false)
29 , fPrecalcTotalGeV(-1)
40 for(
unsigned int i = 0;
i < cells.
size(); ++
i)
Add(cells[
i]);
59 for(
unsigned int i = 0;
i < cells.
size(); ++
i)
Add(cells[
i]);
72 for(
unsigned int i = 0;
i < cells.size(); ++
i)
Add(cells[
i]);
88 assert(weight >= 0 && weight <= 1);
97 if(!optWeights)
fXWeights.push_back(weight);
102 if(!optWeights)
fYWeights.push_back(weight);
108 const std::vector<double>&
weights)
110 const unsigned int N = cells.
size();
112 assert(weights.empty() || weights.size() == N);
114 for(
unsigned int n = 0;
n < N; ++
n){
115 assert(weights.empty() || (weights[
n] >= 0 && weights[
n] <= 1));
116 Add(cells[
n], weights.
empty() ? 1 : weights[
n]);
130 return MeanV(otherView);
140 default:
assert(0 &&
"Unknown view");
146 unsigned int viewIdx)
const 152 default:
assert(0 &&
"Unknown view");
192 std::vector<geo::OfflineChan>
ret;
193 ret.reserve(
NCell());
194 for(
unsigned int i = 0;
i <
NCell(); ++
i)
202 std::vector<rb::WeightedHit> all;
203 for(
unsigned int cellIdx = 0; cellIdx <
NCell(); ++cellIdx)
238 const unsigned int I =
NCell();
239 const unsigned int J = excl->
NCell();
240 for(
unsigned int i = 0;
i < I; ++
i){
243 for(
unsigned int j = 0;
j <
J; ++
j){
244 if(excl->
Cell(
j) == chit){
343 assert(weight >= 0 && weight <= 1);
363 for(
unsigned int i = 0;
i <
NCell(); ++
i)
372 for(
unsigned int i = 0;
i <
NCell(); ++
i)
383 mf::LogWarning(
"rb::Cluster::TotalGeV()") <<
"Passed kUsePrecalcEnergy but no energy was cached in the Cluster. Falling back to recomputing." <<
std::endl;
392 for(
unsigned int i = 0;
i <
NCell(); ++
i){
417 for(
unsigned int i = 0;
i <
NXCell(); ++
i){
421 for(
unsigned int i = 0;
i <
NYCell(); ++
i){
433 for(
unsigned int cellIdx = 0; cellIdx <
NCell(); ++cellIdx)
465 unsigned int ret = UINT_MAX;
466 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
475 unsigned int ret = UINT_MAX;
476 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
485 double ret = DBL_MAX;
486 for(
unsigned int i = 0;
i <
NCell(); ++
i)
511 unsigned int ret = 0;
512 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
521 unsigned int ret = 0;
522 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
531 double ret = -DBL_MAX;
532 for(
unsigned int i = 0;
i <
NCell(); ++
i)
559 for(
unsigned int i = 0;
i <
NCell(); ++
i){
595 for(
int n = 0;
n < 3; ++
n){
601 for(
unsigned int i = 0;
i <
NCell(); ++
i){
605 const double x = xyz[0];
606 const double y = xyz[1];
607 const double z = xyz[2];
613 if(x < lo.X()) lo.SetX(x);
614 if(x > hi.X()) hi.SetX(x);
615 mean.SetX(mean.X()+x*
weight);
619 if(y < lo.Y()) lo.SetY(y);
620 if(y > hi.Y()) hi.SetY(y);
621 mean.SetY(mean.Y()+y*
weight);
624 if(z < lo.Z()) lo.SetZ(z);
625 if(z > hi.Z()) hi.SetZ(z);
626 mean.SetZ(mean.Z()+z*
weight);
629 if(Wx) mean.SetX(mean.X()/Wx);
630 if(Wy) mean.SetY(mean.Y()/Wy);
631 if(Wx || Wy) mean.SetZ(mean.Z()/(Wx+Wy));
637 std::set<int> planes;
639 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
640 planes.insert(
Cell(view,
i)->Plane());
642 if(planes.empty())
return 0;
648 const int expGap = (view ==
geo::kXorY) ? 1 : 2;
650 int prevPlane = -999;
653 for(
auto plane: planes){
654 if(
plane - prevPlane == expGap){
656 longestRun =
std::max(longestRun, curRun);
670 std::set<int> planes;
672 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
673 planes.insert(
Cell(view,
i)->Plane());
675 if(planes.empty())
return 0;
678 int prevPlane = *planes.begin();
679 for(
int plane: planes){
689 return (maxDiff-2)/2;
699 std::set<int> planes;
701 for(
unsigned int i = 0;
i <
NCell(view); ++
i)
702 planes.insert(
Cell(view,
i)->Plane());
704 if(planes.empty())
return 0;
706 return (*planes.rbegin() - *planes.begin())/stride - (
int)planes.size() + 1;
726 if (a->
ID() !=b->
ID())
return a->
ID() <b->
ID();
745 <<
" Sort for weighted hits not implemented" 760 <<
". If you intended to reset the stored value, you must pass kResetTotalGeV. Aborting." <<
std::endl;
764 mf::LogWarning(
"rb::Cluster") <<
"Called SaveTotalGeV() twice for the same cluster, which is inefficient." <<
std::endl;
772 o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
double MinV(geo::View_t view) const
virtual geo::View_t View() const
kXorY for 3D clusters.
T max(const caf::Proxy< T > &a, T b)
double TotalPE() const
Sum of the PE value of all the contained hits.
std::vector< geo::OfflineChan > OfflineChans() const
Positions of all the CellHits.
TSpline3 lo("lo", xlo, ylo, 12,"0")
virtual double W(const rb::CellHit *chit) const
Estimate the unmeasured coordinate of chit.
void StandardSort()
Put the cells in the cluster into a standard order.
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
double fPrecalcTotalGeV
-1 = uninitialized
double J(double q0, double q3, double Enu, double ml)
art::Ptr< rb::CellHit > XCell(unsigned int xIdx) const
Get the ith cell in the x-view.
fvar< T > fabs(const fvar< T > &x)
void SetNoise(bool noise)
Declare the cluster to consist of noise hits or not.
void SavePrecalcTotalGeV(ESaveGeVMode savemode)
Store the current result of TotalGeV / CalorimetricEnergy.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
unsigned short Plane() const
Vertical planes which measure X.
double MaxV(geo::View_t view) const
iterator erase(iterator position)
rb::RecoHit MakeRecoHit(rb::CellHit const &cellhit, double w)
double GetGeVToCalorimetricScale() const
For use by RecoBase classes.
A collection of associated CellHits.
double MeanZ(rb::AveragingScheme scheme=kDefaultScheme) const
double TotalGeVFastClusterOnly() const
Optimized form of TotalGeV, only valid for actual Clusters.
unsigned int MaxCell(geo::View_t view) const
void RemoveHit(const art::Ptr< rb::CellHit > hit)
Remove hit from current cluster.
double MeanV(geo::View_t view, rb::AveragingScheme scheme=kDefaultScheme) const
const PlaneGeo * Plane(unsigned int i) const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void SetWeight(unsigned int globalIdx, double weight)
Set weight of the cell at this index.
TVector3 MeanXYZ(rb::AveragingScheme=kDefaultScheme) const
rb::Cluster Exclude(const rb::Cluster *excl) const
Create a cluster from this one, but with the hits of excl removed.
art::PtrVector< rb::CellHit > fYCell
collection of y-view cells in cluster
bool standard_compare(const art::Ptr< rb::CellHit > &a, const art::Ptr< rb::CellHit > &b)
Horizontal planes which measure Y.
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
unsigned int ExtentCell(geo::View_t view) const
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
unsigned short Cell() const
Use a value computed by a previous call to SavePrecalcTotalGeV.
art::PtrVector< rb::CellHit > fXCell
collection of x-view cells in cluster
Altering the already-set value is not an error.
int MostMissingPlanes(geo::View_t view) const
Longest run of adjacent planes with no hits.
double TotalADC() const
Sum of the ADC of all the contained hits.
TSpline3 hi("hi", xhi, yhi, 18,"0")
bool operator<(const Cluster &other) const
double CalorimetricEnergy(EEnergyCalcScheme escheme=kRecomputeEnergy) const
Simple estimate of neutrino energy.
void push_back(Ptr< U > const &p)
unsigned int NCell() const
Number of cells in either view.
art::Ptr< rb::CellHit > YCell(unsigned int yIdx) const
Get the ith cell in the y-view.
std::vector< rb::WeightedHit > WeightedHits() const
Get all hits from both views, with weights attached.
geo::View_t fView
view this cluster is in
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
rb::RecoHit RecoHit(const art::Ptr< rb::CellHit > &chit) const
Return calibrated hit based on assumed W coordinate.
bool fNoiseCluster
flag for whether this is a noise cluster
bool IsCalibrated() const
You MUST check here before accessing PECorr, MIP or GeV.
std::vector< int32_t > fTDC
TDC(-like) time value. Event time is subtracted. Vector structure is a historical artifact...
Perform a "2 point" Hough transform on a collection of hits.
unsigned int NYCell() const
Number of cells in the y-view.
unsigned int MinPlane(geo::View_t view=geo::kXorY) const
int NMissingPlanes(geo::View_t view) const
Total number of missing planes in cluster.
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
std::vector< int16_t > fADC
list of ADC(-like) charge values
virtual bool Is3D() const
A rawdata::RawDigit with channel information decoded.
std::vector< double > fXWeights
Weights, matching cell indexing.
int16_t ADC(uint32_t i) const
unsigned int NXCell() const
Number of cells in the x-view.
unsigned int MinCell(geo::View_t view) const
int MostContiguousPlanes(geo::View_t view) const
Longest run of adjacent planes with hits.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
double TotalWeight() const
Sum of all the weights. The effective number of hits.
Simple hit+weight pair, returned from rb::Cluster::WeightedHits.
assert(nhit_max >=nhit_nbins)
double TotalGeV(EEnergyCalcScheme escheme=kRecomputeEnergy) const
Simple sum of the estimated GeV of all the hits.
unsigned int MaxPlane(geo::View_t view=geo::kXorY) const
void MinMaxMeanXYZ(TVector3 &lo, TVector3 &hi, TVector3 &mean, rb::AveragingScheme scheme=kDefaultScheme) const
Gets the min/max/mean all at once, called by the functions above.
void EnsureWeightAlloc()
Helper. Resizes weights vectors to match cell vectors.
virtual void Clear()
Forget about all owned cell hits.
In addition to the intrinsic weights.
std::vector< double > fYWeights
May be empty, means all weights are 1.
double Weight(unsigned int globalIdx) const
Weight assigned to the cell.
Encapsulate the geometry of one entire detector (near, far, ndos)
Default. Ask Calibrator about each hit, and sum.
friend std::ostream & operator<<(std::ostream &o, const Cluster &c)