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

#include "CFAlgoTimeProf.h"

Inheritance diagram for cmtool::CFAlgoTimeProf:
cmtool::CFloatAlgoBase cmtool::CMAlgoBase

Public Member Functions

 CFAlgoTimeProf ()
 Default constructor. More...
 
virtual ~CFAlgoTimeProf ()
 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...
 
virtual void SetVerbose (bool doit=true)
 Setter function for verbosity. More...
 

Protected Attributes

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

Private Member Functions

float TProfCompare (std::vector< util::PxHit > hita, std::vector< util::PxHit > hitb)
 

Detailed Description

User implementation for CFloatAlgoBase class doxygen documentation!

Definition at line 25 of file CFAlgoTimeProf.h.

Constructor & Destructor Documentation

cmtool::CFAlgoTimeProf::CFAlgoTimeProf ( )

Default constructor.

Definition at line 20 of file CFAlgoTimeProf.cxx.

20  : CFloatAlgoBase()
21  //-------------------------------------------------------
22  {
23 
24  }
CFloatAlgoBase()
Default constructor.
cmtool::CFAlgoTimeProf::~CFAlgoTimeProf ( )
virtual

Default destructor.

Definition at line 27 of file CFAlgoTimeProf.cxx.

29  {
30  }

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::CFAlgoTimeProf::Float ( const std::vector< const cluster::ClusterParamsAlg * > &  clusters)
virtual

Core function: given the CPAN input, return whether a cluster should be merged or not.

Reimplemented from cmtool::CFloatAlgoBase.

Definition at line 40 of file CFAlgoTimeProf.cxx.

References TProfCompare().

42  {
43  // We now have a vector a clusters.
44 
45  //### need a pointer to the cluster just return -1
46  for(auto const& ptr : clusters) if(!ptr) return -1;
47 
48  std::vector<util::PxHit> hits0;
49  std::vector<util::PxHit> hits1;
50  std::vector<util::PxHit> hits2;
51 
52  // loop over the clusters
53  for(auto const& c : clusters)
54  {
55 // std::cout<<"Size of the xluster vector"<<clusters.size()<<std::endl;
56 // auto Plane = c->Plane();
57 // auto StartPoint = c->GetParams().start_point.t;
58 // auto EndPoint = c->GetParams().end_point.t;
59 // std::cout<<"\t RG Cluster info:\n \t plane: "<<Plane<<std::endl;
60 // std::cout<<"\tStart point: "<<StartPoint<<std::endl;
61 // std::cout<<"\tEnd Point: "<<EndPoint <<std::endl;
62 
63  // Get assosiations for this cluster
64  if(c->Plane() ==0) hits0 = c->GetHitVector();
65  if(c->Plane() ==1) hits1 = c->GetHitVector();
66  if(c->Plane() ==2) hits2 = c->GetHitVector();
67 
68  }// for over the clusters
69 
70 // std::cout<<"Looking for the hits vector size"<<hits0.size()<<","<<hits1.size()<<","<<hits2.size()<<std::endl;
71 // std::cout<<"############# End of loop############# "<<std::endl;
72  // make an integrale over the cluster
73  //bool pl0 = false;
74  //bool pl1 = false;
75  //bool pl2 = false;
76  float tprof01 = -1;
77  float tprof02 = -1;
78  float tprof12 = -1;
79  if(hits0.size()>0)
80  {
81  //pl0 = true;
82  if(hits1.size()>0)
83  {
84  //pl1 = true;
85  //we need to do a profile
86  tprof01 =TProfCompare(hits0,hits1);
87  }// hits1size>0
88  if(hits2.size()>0)
89  {
90  //pl2 = true;
91  //we need to do a profile
92  tprof02 =TProfCompare(hits0,hits2);
93  }// hits2size>0
94  }// hits0size >0
95 
96  if(hits1.size()>0)
97  {
98  //pl1 = true;
99  if(hits2.size()>0)
100  {
101  //pl2 = true;
102  //we need to do a profile
103  tprof12 =TProfCompare(hits1,hits2);
104  }//hits2.size>0
105  }// hits1size>0
106 
107  // This is going to be slow is we are having to re-calutlate this ever time. For now it will have to do
108 
109  // std::cout<< " \t summary of timeprof Planes that are accepted :" <<pl0<<" | " <<pl1<<" | " <<pl2<<" |"<<std::endl;
110  std::vector<float> tprofmatches;
111 // std::cout<< " \t Value of timeprof(01,02,12) :" <<tprof01<<" | " <<tprof02<<" | " <<tprof12<<" |"<<std::endl;
112  tprofmatches.push_back(tprof01);
113  tprofmatches.push_back(tprof02);
114  tprofmatches.push_back(tprof12);
115 
116  float matchscore=0;
117  float avgcounter=0;
118 // std::cout<<"SIZE of trpfmoatch"<< tprofmatches.size()<<std::endl;
119  for( unsigned int a=0;a<tprofmatches.size();a++)
120  {
121  if(tprofmatches[a]==-1) continue;
122  else {
123  matchscore +=tprofmatches[a];
124  avgcounter +=1;
125  }// end of else
126  }//for over the tprofmatchs
127  if(avgcounter!=0){
128 // std::cout << " Match Score pree "<< matchscore<<std::endl;
129 // std::cout<< " Counter "<< avgcounter;
130  matchscore /= avgcounter;
131 // std::cout << " Match Score "<< matchscore<<std::endl;
132  }
133  else{
134 // std::cout << " Match Score "<< -1<<std::endl;
135  return -1;
136  }
137  return matchscore;
138 
139 
140 
141 
142  //if(clusters.size()) return 1.;
143  //else return -1.;
144  }
float TProfCompare(std::vector< util::PxHit > hita, std::vector< util::PxHit > hitb)
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::CFAlgoTimeProf::Report ( )
virtual

Optional function: called after Bool() function is called for all possible cluster pairs by CMergeManager/CMatchManager IFF run with verbosity level kPerIteration. Maybe useful for debugging.

Reimplemented from cmtool::CMAlgoBase.

Definition at line 221 of file CFAlgoTimeProf.cxx.

223  {
224 
225  }
void cmtool::CFAlgoTimeProf::Reset ( )
virtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 33 of file CFAlgoTimeProf.cxx.

35  {
36 
37  }
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
virtual void cmtool::CMAlgoBase::SetVerbose ( bool  doit = true)
inlinevirtualinherited
float cmtool::CFAlgoTimeProf::TProfCompare ( std::vector< util::PxHit hita,
std::vector< util::PxHit hitb 
)
private

Optional function: called at the beginning of 1st iteration. This is called per event. Optional function: called at the end of event ... after the last merging iteration is over. Optional function: called at the beggining of each iterative loop. 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. Optional function: called at the end of each iterative loop.

Definition at line 147 of file CFAlgoTimeProf.cxx.

References bin, detinfo::DetectorProperties::GetXTicksOffset(), detinfo::DetectorProperties::NumberTimeSamples(), and util::GeometryUtilities::TimeToCm().

Referenced by Float().

148  {
150  const detinfo::DetectorProperties* detp = lar::providerFrom<detinfo::DetectorPropertiesService>();
151 // int nts = larutil::DetectorProperties::GetME()->NumberTimeSamples()*larutil::GeometryUtilities::GetME()->TimeToCm();
152  // Where is this?
153  //int nplanes = geom->Nplanes();
154  int nplanes = 3;
155  double ks = 0.0;
156  std::vector< std::vector<TH1D*> > signals(nplanes);
157  std::vector< std::vector<TH1D*> > pulses(nplanes);
158 
159  double time_diff = ( detp->GetXTicksOffset((int)(hita.at(0).plane),0,0) -
160  detp->GetXTicksOffset((int)(hitb.at(0).plane),0,0) ) * geou.TimeToCm();
161 
162  // First go look for the min & max of hits
163  double min_time = detp->NumberTimeSamples() * geou.TimeToCm();
164  double max_time = 0;
165  for(auto const& h : hita) {
166  if(h.t > max_time) max_time = h.t;
167  if(h.t < min_time) min_time = h.t;
168  }
169  for(auto const& h : hitb) {
170  if( (h.t + time_diff) > max_time ) max_time = h.t + time_diff;
171  if( (h.t + time_diff) < min_time ) min_time = h.t + time_diff;
172  }
173 
174  TH1D histo_a("ha", "", 200, min_time-1, max_time+1);
175  TH1D histo_b("hb", "", 200, min_time-1, max_time+1);
176  TH1D histo_inta("hinta", "", 200, min_time-1, max_time+1);
177  TH1D histo_intb("hintb", "", 200, min_time-1, max_time+1);
178 
179  // First loop over hits in A and make the hist
180  // in this case let's just use plane 0,1
181  for( auto const& ha : hita){
182  double time = ha.t;
183  //time -= larutil::DetectorProperties::GetME()->GetXTicksOffset(ha.plane)*larutil::GeometryUtilities::GetME()->TimeToCm();
184  double charge = ha.charge;
185 
186  int bin = histo_a.FindBin(time);
187  histo_a.SetBinContent(bin,histo_a.GetBinContent(bin)+charge);
188  for (int j = bin; j<=histo_a.GetNbinsX(); ++j){
189  histo_inta.SetBinContent(j,histo_inta.GetBinContent(j)+charge);
190  }
191  }
192  if (histo_inta.Integral()) histo_inta.Scale(1./histo_inta.GetBinContent(histo_inta.GetNbinsX()));
193  for( auto const& hb : hitb){
194  double time = hb.t + time_diff;
195  //time -= larutil::DetectorProperties::GetME()->GetXTicksOffset(hb.plane)*larutil::GeometryUtilities::GetME()->TimeToCm();
196  double charge = hb.charge;
197  int bin = histo_b.FindBin(time);
198  histo_b.SetBinContent(bin,histo_b.GetBinContent(bin)+charge);
199  for (int j = bin; j<=histo_b.GetNbinsX(); ++j){
200  histo_intb.SetBinContent(j,histo_intb.GetBinContent(j)+charge);
201  }
202  }
203 
204 /*
205  std::cout
206  << "siga: "<< histo_a.GetEntries() << std::endl
207  << "sigb: "<< histo_b.GetEntries() << std::endl
208  << "siginta: "<<histo_inta.GetEntries() << std::endl
209  << "sigintb: "<<histo_intb.GetEntries() << std::endl
210  << std::endl;
211 */
212 
213  if (histo_intb.Integral()) histo_intb.Scale(1./histo_intb.GetBinContent(histo_intb.GetNbinsX()));
214  ks = histo_inta.KolmogorovTest(&histo_intb);
215 
216  std::cout<<ks<<std::endl;
217  return ks;
218  }
Double_t TimeToCm() const
virtual unsigned int NumberTimeSamples() const =0
float bin[41]
Definition: plottest35.C:14
virtual double GetXTicksOffset(int p, int t, int c) const =0

Member Data Documentation

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().


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