LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
cmtool::CFAlgoChargeDistrib Class Reference

#include "CFAlgoChargeDistrib.h"

Inheritance diagram for cmtool::CFAlgoChargeDistrib:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgoChargeDistrib ()
 Default constructor. More...
 
virtual ~CFAlgoChargeDistrib ()
 Default destructor. More...
 
virtual float Float (const std::vector< const cluster::ClusterParamsAlg * > &clusters)
 
virtual void Report ()
 
virtual void Reset ()
 Function to reset the algorithm instance, called together with manager's Reset() More...
 
virtual void EventBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void EventEnd ()
 
virtual void IterationBegin (const std::vector< cluster::ClusterParamsAlg > &clusters)
 
virtual void IterationEnd ()
 
void SetAnaFile (TFile *fout)
 Setter function for an output plot TFile pointer. More...
 

Protected Attributes

TFile * _fout
 TFile pointer to an output file. More...
 

Private Member Functions

float TProfConvol (std::vector< util::PxHit > hita, std::vector< util::PxHit > hitb)
 
void SetVerbose (bool on)
 Setter function for verbosity. More...
 
void SetDebug (bool on)
 

Private Attributes

bool _verbose
 
bool _debug
 

Detailed Description

User implementation for CFloatAlgoBase class doxygen documentation!

Definition at line 25 of file CFAlgoChargeDistrib.h.

Constructor & Destructor Documentation

cmtool::CFAlgoChargeDistrib::CFAlgoChargeDistrib ( )

Default constructor.

Definition at line 10 of file CFAlgoChargeDistrib.cxx.

References SetDebug(), and SetVerbose().

10  : CFloatAlgoBase()
11  //-------------------------------------------------------
12  {
13  SetVerbose(false);
14  SetDebug(false);
15  }
CFloatAlgoBase()
Default constructor.
void SetVerbose(bool on)
Setter function for verbosity.
virtual cmtool::CFAlgoChargeDistrib::~CFAlgoChargeDistrib ( )
inlinevirtual

Default destructor.

Definition at line 33 of file CFAlgoChargeDistrib.h.

References Float(), Report(), Reset(), and TProfConvol().

33 {};

Member Function Documentation

virtual void cmtool::CMAlgoBase::EventBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtualinherited

Optional function: called at the beginning of 1st iteration. This is called per event.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, cmtool::CBAlgoArray, and cmtool::CBAlgoPolyShortestDist.

Definition at line 45 of file CMAlgoBase.h.

Referenced by cmtool::CMergeManager::EventBegin().

46  { if(clusters.size()) return; }
virtual void cmtool::CMAlgoBase::EventEnd ( )
inlinevirtualinherited

Optional function: called at the end of event ... after the last merging iteration is over.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 51 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventEnd(), and cmtool::CMergeManager::EventEnd().

52  {return;}
float cmtool::CFAlgoChargeDistrib::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  clusters)
virtual

Core function: given a set of CPANs, return a float which indicates the compatibility the cluster combination.

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 25 of file CFAlgoChargeDistrib.cxx.

References _verbose, c1, c2, and TProfConvol().

Referenced by ~CFAlgoChargeDistrib().

27  {
28 
29  // Code-block by Kazu starts
30  // This ensures the algorithm works only if # clusters is > 2 (and not =2)
31  // You may take out this block if you want to allow matching using clusters from only 2 planes.
32  //if(clusters.size()==2) return -1;
33  // Code-block by Kazu ends
34 
35  //This algorithm now works for 3 planes: find 3Dstart point from first 2 planes and find
36  //How well that agrees with 3rd plane's start point location.
37 
38  //So first, make sure clusters vector has more than 1 element.
39  //If not, return -1. Algorithm does not make sense
40  if ( clusters.size() == 1 )
41  return -1;
42 
43  if (_verbose) { std::cout << "Number of clusters taken into account: " << clusters.size() << std::endl; }
44 
45  //MicroBooNE Nomenclature:
46  //Planes: U == 0; V == 1; Y == 2.
47 
48  //Get hits for all 3 clusters
49  std::vector<std::vector<util::PxHit> > Hits;//(clusters.size(), std::vector<util::PxHit>());
50 
51  for (size_t c=0; c < clusters.size(); c++)
52  Hits.push_back( clusters.at(c)->GetHitVector() );
53 
54  // return parameter is the product of
55  // "convolutions" of each pair of clusters
56  // return conv(a,b)*conv(b,c)*conv(c,a)
57  // in the case of 3 planes with clusters
58  // a, b and c.
59  // The functions being convolved are the
60  // charge-distribution in time of each clusters
61  // The "convolution" is the common area of the
62  // two distributions: the larger the charge-
63  // -overlap the better the match
64  // No normalization is performed.
65 
66  float totOverlap = 1;
67  for (size_t c1=0; c1 < (Hits.size()-1); c1++){
68  for (size_t c2=c1+1; c2 < Hits.size(); c2++){
69  if (_verbose) { std::cout << "Considering Clusters: " << c1 << ", " << c2 << std::endl; }
70  totOverlap *= TProfConvol(Hits.at(c1), Hits.at(c2) );
71  }
72  }
73 
74  if (_verbose) { std::cout << "Tot Overlap is: " << totOverlap << std::endl << std::endl; }
75 
76  return totOverlap;
77 
78  }
float TProfConvol(std::vector< util::PxHit > hita, std::vector< util::PxHit > hitb)
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
art::PtrVector< recob::Hit > Hits
virtual void cmtool::CMAlgoBase::IterationBegin ( const std::vector< cluster::ClusterParamsAlg > &  clusters)
inlinevirtualinherited

Optional function: called at the beggining of each iteration over all pairs of clusters. This provides all clusters' information in case the algorithm need them. Note this is called per iteration which may be more than once per event.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 59 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::EventBegin(), cmtool::CMatchManager::IterationBegin(), and cmtool::CMergeManager::IterationBegin().

60  { if(clusters.size()) return;}
virtual void cmtool::CMAlgoBase::IterationEnd ( )
inlinevirtualinherited

Optional function: called at the end of each iteration over all pairs of clusters.

Reimplemented in cmtool::CFAlgoArray, cmtool::CPAlgoArray, and cmtool::CBAlgoArray.

Definition at line 65 of file CMAlgoBase.h.

Referenced by cmtool::CMatchManager::IterationEnd(), and cmtool::CMergeManager::IterationEnd().

66  {return; }
void cmtool::CFAlgoChargeDistrib::Report ( )
virtual

Optional function: called after each iterative approach if a manager class is run with verbosity level <= kPerIteration. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 81 of file CFAlgoChargeDistrib.cxx.

Referenced by ~CFAlgoChargeDistrib().

83  {
84 
85  }
void cmtool::CFAlgoChargeDistrib::Reset ( )
virtual

Function to reset the algorithm instance, called together with manager's Reset()

Reimplemented from cmtool::CMAlgoBase.

Definition at line 18 of file CFAlgoChargeDistrib.cxx.

Referenced by ~CFAlgoChargeDistrib().

20  {
21 
22  }
void cmtool::CMAlgoBase::SetAnaFile ( TFile *  fout)
inlineinherited

Setter function for an output plot TFile pointer.

Definition at line 77 of file CMAlgoBase.h.

References cmtool::CMAlgoBase::_fout.

Referenced by cmtool::CMergeManager::EventBegin().

77 { _fout = fout; }
TFile * _fout
TFile pointer to an output file.
Definition: CMAlgoBase.h:85
void cmtool::CFAlgoChargeDistrib::SetDebug ( bool  on)
inlineprivate

Definition at line 62 of file CFAlgoChargeDistrib.h.

References _debug.

Referenced by CFAlgoChargeDistrib().

void cmtool::CFAlgoChargeDistrib::SetVerbose ( bool  doit)
inlineprivatevirtual

Setter function for verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 60 of file CFAlgoChargeDistrib.h.

References _verbose.

Referenced by CFAlgoChargeDistrib().

float cmtool::CFAlgoChargeDistrib::TProfConvol ( std::vector< util::PxHit hita,
std::vector< util::PxHit hitb 
)
private

Definition at line 89 of file CFAlgoChargeDistrib.cxx.

References _debug, _verbose, detinfo::DetectorProperties::NumberTimeSamples(), and util::GeometryUtilities::TimeToCm().

Referenced by Float(), and ~CFAlgoChargeDistrib().

90  {
92  const detinfo::DetectorProperties* detp = lar::providerFrom<detinfo::DetectorPropertiesService>();
93  int NumTimeSamples = detp->NumberTimeSamples() * geou.TimeToCm();
94 
95  double Tmin = NumTimeSamples;
96  double Tmax = 0;
97 
98  // Make two vectors to hold the Time-Profile of the Q-distribution
99  // of the two clusters
100  std::vector<float> QprofA(100,0.);
101  std::vector<float> QprofB(100,0.);
102  float QB = 0;
103  float QA = 0;
104 
105  //First find min and max times
106  for(auto const& hitA : hA) {
107  if(hitA.t > Tmax) Tmax = hitA.t;
108  if(hitA.t < Tmin) Tmin = hitA.t;
109  }
110  for(auto const& hitB : hB) {
111  if(hitB.t > Tmax) Tmax = hitB.t;
112  if(hitB.t < Tmin) Tmin = hitB.t;
113  }
114 
115  //Now Fill Q-profile vectors
116  for(auto const& hitA : hA){
117  QprofA.at( int(99*(hitA.t-Tmin)/(Tmax-Tmin)) ) += hitA.charge;
118  QA += hitA.charge;
119  }
120  for(auto const& hitB : hB){
121  QprofB.at( int(99*(hitB.t-Tmin)/(Tmax-Tmin)) ) += hitB.charge;
122  QB += hitB.charge;
123  }
124 
125  /*//Normalize distributions
126  for (size_t b=0; b < QprofA.size(); b++)
127  QprofA.at(b) /= QA;
128  for (size_t b=0; b < QprofB.size(); b++)
129  QprofB.at(b) /= QB;
130  */
131 
132  //print out distribution if verbose
133  if (_debug){
134  std::cout << "Q distribution for Cluster A:" << std::endl;
135  for (size_t b=0; b < QprofA.size(); b++)
136  if ( QprofA.at(b) != 0 ) { std::cout << b << "\t" << QprofA.at(b) << std::endl; }
137  std::cout << "Q distribution for Cluster B:" << std::endl;
138  for (size_t b=0; b < QprofB.size(); b++)
139  if ( QprofB.at(b) != 0 ) { std::cout << b << "\t" << QprofB.at(b) << std::endl; }
140  }
141 
142  // Now find convolution between the two distributions
143  // Scan two vectors and always take smallest quantity
144  // Add this smallest quantity as vector is scanned to
145  // obtain the common Q-distribution for the clusters
146  float conv= 0;
147  for (size_t b=0; b < QprofA.size(); b++){
148  if ( QprofA.at(b) < QprofB.at(b) ) { conv += QprofA.at(b); }
149  else { conv += QprofB.at(b); }
150  }
151  if (_verbose) { std::cout << "Convolution is: " << conv << std::endl; }
152 
153  return conv;
154  }
Double_t TimeToCm() const
virtual unsigned int NumberTimeSamples() const =0

Member Data Documentation

bool cmtool::CFAlgoChargeDistrib::_debug
private

Definition at line 65 of file CFAlgoChargeDistrib.h.

Referenced by SetDebug(), and TProfConvol().

TFile* cmtool::CMAlgoBase::_fout
protectedinherited

TFile pointer to an output file.

Definition at line 85 of file CMAlgoBase.h.

Referenced by cmtool::CMAlgoBase::CMAlgoBase(), and cmtool::CMAlgoBase::SetAnaFile().

bool cmtool::CFAlgoChargeDistrib::_verbose
private

Definition at line 64 of file CFAlgoChargeDistrib.h.

Referenced by Float(), SetVerbose(), and TProfConvol().


The documentation for this class was generated from the following files: