Public Member Functions | Private Member Functions | Private Attributes | List of all members
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...
 
- Public Member Functions inherited from cmtool::CFloatAlgoBase
 CFloatAlgoBase ()
 Default constructor. More...
 
virtual ~CFloatAlgoBase ()
 Default destructor. More...
 
- Public Member Functions inherited from cmtool::CMAlgoBase
 CMAlgoBase ()
 Default constructor. More...
 
virtual ~CMAlgoBase ()
 Default destructor. 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...
 

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
 

Additional Inherited Members

- Protected Attributes inherited from cmtool::CMAlgoBase
TFile * _fout
 TFile pointer to an output file. More...
 
bool _verbose
 Boolean to choose verbose mode. Turned on if CMergeManager/CMatchManager's verbosity level is >= kPerMerging. More...
 

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 8 of file CFAlgoChargeDistrib.cxx.

9  //-------------------------------------------------------
10  {
11  SetVerbose(false);
12  SetDebug(false);
13  }
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.

33 {};

Member Function Documentation

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 23 of file CFAlgoChargeDistrib.cxx.

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

81  {
82 
83  }
void cmtool::CFAlgoChargeDistrib::Reset ( void  )
virtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 16 of file CFAlgoChargeDistrib.cxx.

18  {
19 
20  }
void cmtool::CFAlgoChargeDistrib::SetDebug ( bool  on)
inlineprivate

Definition at line 62 of file CFAlgoChargeDistrib.h.

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

Setter function for verbosity.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 60 of file CFAlgoChargeDistrib.h.

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

Definition at line 87 of file CFAlgoChargeDistrib.cxx.

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

Member Data Documentation

bool cmtool::CFAlgoChargeDistrib::_debug
private

Definition at line 65 of file CFAlgoChargeDistrib.h.

bool cmtool::CFAlgoChargeDistrib::_verbose
private

Definition at line 64 of file CFAlgoChargeDistrib.h.


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