Public Member Functions | Private Member Functions | List of all members
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...
 
- 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...
 
virtual void SetVerbose (bool doit=true)
 Setter function for verbosity. More...
 

Private Member Functions

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

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

Constructor & Destructor Documentation

cmtool::CFAlgoTimeProf::CFAlgoTimeProf ( )

Default constructor.

Definition at line 10 of file CFAlgoTimeProf.cxx.

10  : CFloatAlgoBase()
11  //-------------------------------------------------------
12  {
13 
14  }
CFloatAlgoBase()
Default constructor.
cmtool::CFAlgoTimeProf::~CFAlgoTimeProf ( )
virtual

Default destructor.

Definition at line 17 of file CFAlgoTimeProf.cxx.

19  {
20  }

Member Function Documentation

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 30 of file CFAlgoTimeProf.cxx.

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

213  {
214 
215  }
void cmtool::CFAlgoTimeProf::Reset ( void  )
virtual

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

Reimplemented from cmtool::CMAlgoBase.

Definition at line 23 of file CFAlgoTimeProf.cxx.

25  {
26 
27  }
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 137 of file CFAlgoTimeProf.cxx.

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

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