NearbyVertexFinder Class Reference

#include <NearbyEvents.h>

List of all members.

Public Member Functions

 NearbyVertexFinder ()
 NearbyVertexFinder (int nevent)
void LoadVertex (float x, float y, float z, float t, float ph=1.0, int mcevt=1)
void ProcessVertices ()
void ClosestSpatial (int this_idx, int &idx, float &dist, float &time, float &ph, int &mcevt)
void ClosestTemporal (int this_idx, int &idx, float &dist, float &time, float &ph, int &mcevt)
void ProcessEntry (MadBase *)

Private Member Functions

void ResizeMatrices (int n)

Private Attributes

std::vector< float > _x
std::vector< float > _y
std::vector< float > _z
std::vector< float > _t
std::vector< float > _ph
std::vector< int > _idx
std::vector< int > _mcevt
std::vector< int > idx_vtx_closest
std::vector< float > dist_vtx_closest
std::vector< int > idx_vtx_closest_time
std::vector< float > dist_vtx_closest_time
std::vector< std::vector< float > > vtx_dsep
std::vector< std::vector< float > > vtx_tsep

Detailed Description

Definition at line 26 of file NearbyEvents.h.


Constructor & Destructor Documentation

NearbyVertexFinder::NearbyVertexFinder (  ) 

Definition at line 49 of file NearbyEvents.cxx.

00051   :
00052  _x(10,0), _y(10,0), _z(10,0), _t(10,0), 
00053     _ph(10,0), _idx(10,-1), _mcevt(10,-1),
00054     idx_vtx_closest(10,-1), dist_vtx_closest(10,999999),
00055     idx_vtx_closest_time(10,-1), dist_vtx_closest_time(10,999999) 
00056   */
00057 {}

NearbyVertexFinder::NearbyVertexFinder ( int  nevent  ) 

Definition at line 28 of file NearbyEvents.cxx.

00030   : 
00031 _x(nevent,0), _y(nevent,0), _z(nevent,0), _t(nevent,0), 
00032     _ph(nevent,0), _idx(nevent,-1), _mcevt(nevent,-1),
00033     idx_vtx_closest(nevent,-1), dist_vtx_closest(nevent,0),
00034     idx_vtx_closest_time(nevent,-1), dist_vtx_closest_time(nevent,0)
00035   */
00036 {
00037   /*
00038   std::cout<<"*** "<<nevent
00039            <<"   "<<_idx.size()
00040            <<"   "<<idx_vtx_closest.size()
00041            <<"   "<<dist_vtx_closest.size()
00042            <<"   "<<idx_vtx_closest_time.size()
00043            <<"   "<<dist_vtx_closest_time.size()
00044            <<std::endl;
00045   */
00046 }


Member Function Documentation

void NearbyVertexFinder::ClosestSpatial ( int  this_idx,
int &  idx,
float &  dist,
float &  time,
float &  ph,
int &  mcevt 
)

Definition at line 150 of file NearbyEvents.cxx.

References _idx, _mcevt, _ph, dist_vtx_closest, idx_vtx_closest, and vtx_tsep.

Referenced by MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00151                                                                      {
00152   // for the event with 'this_idx', get the index, distance, time, etc..
00153   // of the event which is closest to it in space.
00154 
00155   idx=-1;
00156   if(this_idx<0 || this_idx> int(_idx.size()-1)) return;
00157 
00158   idx=idx_vtx_closest[this_idx];
00159   if(idx>-1){
00160     dist = dist_vtx_closest[this_idx];
00161     time = vtx_tsep[this_idx][idx];
00162     ph = _ph[idx];
00163     mcevt = _mcevt[idx];
00164   }
00165 }

void NearbyVertexFinder::ClosestTemporal ( int  this_idx,
int &  idx,
float &  dist,
float &  time,
float &  ph,
int &  mcevt 
)

Definition at line 167 of file NearbyEvents.cxx.

References _idx, _mcevt, _ph, dist_vtx_closest_time, idx_vtx_closest_time, and vtx_dsep.

Referenced by MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00168                                                                       {
00169   // for the event with 'this_idx', get the index, distance, time, etc..
00170   // of the event which is closest to it in time.
00171 
00172   idx=-1;
00173   if(this_idx<0 || this_idx> int(_idx.size()-1)) return;
00174 
00175   idx=idx_vtx_closest_time[this_idx];
00176   if(idx>-1){
00177     time = dist_vtx_closest_time[this_idx];
00178     dist = vtx_dsep[this_idx][idx];
00179     ph = _ph[idx];
00180     mcevt = _mcevt[idx];
00181   }
00182 
00183 }

void NearbyVertexFinder::LoadVertex ( float  x,
float  y,
float  z,
float  t,
float  ph = 1.0,
int  mcevt = 1 
)

Definition at line 59 of file NearbyEvents.cxx.

References _idx, _mcevt, _ph, _t, _x, _y, and _z.

Referenced by ProcessEntry().

00060                                                             {
00061   _x.push_back(x);
00062   _y.push_back(y);
00063   _z.push_back(z);
00064   _t.push_back(t);
00065   _ph.push_back(p);
00066   _mcevt.push_back(m);
00067   _idx.push_back(_idx.size());
00068 
00069 }

void NearbyVertexFinder::ProcessEntry ( MadBase mb  ) 

Definition at line 185 of file NearbyEvents.cxx.

References NtpStRecord::evt, MadBase::GetEvent(), MadBase::GetEventSummary(), MadBase::GetTruthForRecoTH(), NtpSRStripPulseHeight::gev, LoadVertex(), NtpSREventSummary::nevent, NtpSREvent::ph, ProcessVertices(), NtpSRVertex::t, NtpSREvent::vtx, NtpSRVertex::x, NtpSRVertex::y, and NtpSRVertex::z.

Referenced by MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00185                                                 {
00186   if(!mb) return;
00187   // store vertices
00188   const NtpSREventSummary* eventSummary = mb->GetEventSummary();
00189   for(int i=0;i<eventSummary->nevent;i++){ 
00190     const NtpSREvent* evt = mb->GetEvent(i);
00191     if(!evt) continue; //no event found
00192     int mcidx=-1;
00193     int mcevent=-1;
00194     if(mb->GetTruthForRecoTH(i,mcevent)) {
00195       mcidx = mcevent;
00196     }
00197 
00198 
00199     LoadVertex(evt->vtx.x,
00200                evt->vtx.y,
00201                evt->vtx.z,
00202                evt->vtx.t,
00203                evt->ph.gev,
00204                mcidx);
00205   }
00206   
00207   ProcessVertices();
00208   
00209 }

void NearbyVertexFinder::ProcessVertices (  ) 

Definition at line 97 of file NearbyEvents.cxx.

References _idx, _t, _x, _y, _z, dist_vtx_closest, dist_vtx_closest_time, idx_vtx_closest, idx_vtx_closest_time, ResizeMatrices(), vtx_dsep, and vtx_tsep.

Referenced by ProcessEntry().

00097                                         {
00098   // go through all vertices stored with LoadVertex
00099   // for each vertex, loop over the others and find the one
00100   // that is closest in space or time
00101   // save results in idx_vtx_* and dist_vtx_* arrays
00102   // and vtx_?sep matrices
00103 
00104   const int nevent=_idx.size();
00105   ResizeMatrices(nevent);
00106 
00107   // find closest vertex in space
00108   //  vector< vector<float> > vtx_dsep(nevent, vector<float>(nevent,0));  
00109   for(int i=0; i<nevent; i++){
00110     for(int j=0; j<nevent; j++){
00111       if(i==j) {vtx_dsep[i][j]=0.0; continue;}
00112       // really big distance should only apply if LoadEvent()
00113       // failed for event i or j
00114       float dist = 9999999; // default is a really big distance 
00115       if((_idx[j] != -1)&&(_idx[i] != -1) ) {
00116         dist=std::pow(_x[i]-_x[j],2)+std::pow(_y[i]-_y[j],2)+std::pow(_z[i]-_z[j],2);
00117         dist=sqrt(dist);
00118       } 
00119       vtx_dsep[i][j]=dist;
00120       // find index and distance of closest vertex in space
00121       if((i!=j) && (vtx_dsep[i][j]<dist_vtx_closest[i])){
00122         idx_vtx_closest[i]=j;
00123         dist_vtx_closest[i]=vtx_dsep[i][j];
00124       } 
00125     }
00126   }
00127 
00128   // find closest vertex in time
00129   //  vector< vector<float> > vtx_tsep(nevent, vector<float>(nevent,0));
00130   for(int i=0; i<nevent; i++){
00131     for(int j=0; j<nevent; j++){
00132       if(i==j) {vtx_tsep[i][j]=0.0; continue;}
00133       // really big distance should only apply if LoadEvent()
00134       // failed for event i or j
00135       float dist = 9999999; // default is a really big distance 
00136       if((_idx[j] != -1)&&(_idx[i] != -1) ) {
00137         dist=fabs(_t[i]-_t[j]);
00138       } 
00139       vtx_tsep[i][j]=dist;
00140       // find index and distance of closest vertex in time
00141       if((i!=j) && (vtx_tsep[i][j]<dist_vtx_closest_time[i])){
00142         idx_vtx_closest_time[i]=j;
00143         dist_vtx_closest_time[i]=vtx_tsep[i][j];
00144       } 
00145     }
00146   }
00147 
00148 }

void NearbyVertexFinder::ResizeMatrices ( int  n  )  [private]

Definition at line 71 of file NearbyEvents.cxx.

References dist_vtx_closest, dist_vtx_closest_time, idx_vtx_closest, idx_vtx_closest_time, vtx_dsep, and vtx_tsep.

Referenced by ProcessVertices().

00071                                             {
00072   // resize vtx_?sep matrices for to hold results for n events
00073 
00074   if(n<=0) return;
00075 
00076   idx_vtx_closest.resize(n,-1);
00077   idx_vtx_closest_time.resize(n,-1);
00078 
00079   dist_vtx_closest.resize(n,9999999);
00080   dist_vtx_closest_time.resize(n,9999999);
00081   
00082   vtx_dsep.resize(n,std::vector<float>(n));
00083   for (unsigned int i=0; i<vtx_dsep.size(); i++){
00084     std::vector<float>& v = vtx_dsep[i];
00085     v.resize(n,9999999);
00086   }
00087   
00088   vtx_tsep.resize(n,std::vector<float>(n));
00089   for (unsigned int i=0; i<vtx_tsep.size(); i++){
00090     std::vector<float>& v = vtx_tsep[i];
00091     v.resize(n,9999999);
00092   }
00093   
00094 
00095 }


Member Data Documentation

std::vector<int> NearbyVertexFinder::_idx [private]

Definition at line 57 of file NearbyEvents.h.

Referenced by ClosestSpatial(), ClosestTemporal(), LoadVertex(), and ProcessVertices().

std::vector<int> NearbyVertexFinder::_mcevt [private]

Definition at line 58 of file NearbyEvents.h.

Referenced by ClosestSpatial(), ClosestTemporal(), and LoadVertex().

std::vector<float> NearbyVertexFinder::_ph [private]

Definition at line 56 of file NearbyEvents.h.

Referenced by ClosestSpatial(), ClosestTemporal(), and LoadVertex().

std::vector<float> NearbyVertexFinder::_t [private]

Definition at line 55 of file NearbyEvents.h.

Referenced by LoadVertex(), and ProcessVertices().

std::vector<float> NearbyVertexFinder::_x [private]

Definition at line 52 of file NearbyEvents.h.

Referenced by LoadVertex(), and ProcessVertices().

std::vector<float> NearbyVertexFinder::_y [private]

Definition at line 53 of file NearbyEvents.h.

Referenced by LoadVertex(), and ProcessVertices().

std::vector<float> NearbyVertexFinder::_z [private]

Definition at line 54 of file NearbyEvents.h.

Referenced by LoadVertex(), and ProcessVertices().

std::vector<float> NearbyVertexFinder::dist_vtx_closest [private]

Definition at line 61 of file NearbyEvents.h.

Referenced by ClosestSpatial(), ProcessVertices(), and ResizeMatrices().

std::vector<float> NearbyVertexFinder::dist_vtx_closest_time [private]

Definition at line 64 of file NearbyEvents.h.

Referenced by ClosestTemporal(), ProcessVertices(), and ResizeMatrices().

std::vector<int> NearbyVertexFinder::idx_vtx_closest [private]

Definition at line 60 of file NearbyEvents.h.

Referenced by ClosestSpatial(), ProcessVertices(), and ResizeMatrices().

std::vector<int> NearbyVertexFinder::idx_vtx_closest_time [private]

Definition at line 63 of file NearbyEvents.h.

Referenced by ClosestTemporal(), ProcessVertices(), and ResizeMatrices().

std::vector< std::vector<float> > NearbyVertexFinder::vtx_dsep [private]

Definition at line 66 of file NearbyEvents.h.

Referenced by ClosestTemporal(), ProcessVertices(), and ResizeMatrices().

std::vector< std::vector<float> > NearbyVertexFinder::vtx_tsep [private]

Definition at line 67 of file NearbyEvents.h.

Referenced by ClosestSpatial(), ProcessVertices(), and ResizeMatrices().


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

Generated on 3 Oct 2018 for loon by  doxygen 1.6.1