Classes | Functions
sn Namespace Reference

Classes

class  SNSlice
 

Functions

double TimeCluster (std::vector< std::pair< double, double >> &pts, double &clustPE)
 
double FindSliceTZero (const std::vector< recob::OpHit > &ophits, double sliceMeanT, double sliceMeanZ, double &flashPhots)
 
double AttenFactor (double dt)
 
double SliceEnergy (const sn::SNSlice &slice, const std::vector< recob::OpHit > &ophits)
 

Function Documentation

double sn::AttenFactor ( double  dt)

Definition at line 104 of file SNUtils.h.

105  {
106  // From an expo fit of totQ/trueE vs dt
107  // return exp(4.83617-0.00037413*dt);
108  return 128.734*exp(-0.000357316*dt);
109  }
double sn::FindSliceTZero ( const std::vector< recob::OpHit > &  ophits,
double  sliceMeanT,
double  sliceMeanZ,
double &  flashPhots 
)

Definition at line 70 of file SNUtils.h.

74  {
75  const geo::GeometryCore& geom(*lar::providerFrom<geo::Geometry>());
76 
77  const double driftLen = geom.Cryostat(0).TPC(0).DriftDistance();
78  const double driftT = driftLen / dp.DriftVelocity();
79 
80  double ophitTotQ = 0;
81 
82  // Times and PE weights, to calculate median
83  std::vector<std::pair<double, double>> ophitTs;
84 
85  for(const recob::OpHit& ophit: ophits){
86  double xyz[3];
87  geom.OpDetGeoFromOpChannel(ophit.OpChannel()).GetCenter(xyz);
88 
89  // Only use hits that are close enough to be consistent
90  if(ophit.PeakTime() < sliceMeanT &&
91  ophit.PeakTime() > sliceMeanT-driftT &&
92  fabs(xyz[2]-sliceMeanZ) < 600){ // 2sigma?*/
93 
94  ophitTotQ += ophit.PE();
95  ophitTs.emplace_back(ophit.PeakTime(), ophit.PE());
96  }
97  } // end for ophit
98 
99  return TimeCluster(ophitTs, flashPhots);
100  }
double TimeCluster(std::vector< std::pair< double, double >> &pts, double &clustPE)
Definition: SNUtils.h:24
Description of geometry of one entire detector.
double sn::SliceEnergy ( const sn::SNSlice slice,
const std::vector< recob::OpHit > &  ophits 
)

Definition at line 112 of file SNUtils.h.

114  {
115  double junk;
116  const double t0 = FindSliceTZero(ophits, slice.meanT, slice.meanZ, junk);
117  const double dt = slice.meanT - t0;
118 
119  return slice.totQ / AttenFactor(dt);
120  }
code to link reconstructed objects back to the MC truth information
float totQ
Definition: SNSlice.h:14
float meanZ
Definition: SNSlice.h:13
float meanT
Definition: SNSlice.h:12
double FindSliceTZero(const std::vector< recob::OpHit > &ophits, double sliceMeanT, double sliceMeanZ, double &flashPhots)
Definition: SNUtils.h:70
double AttenFactor(double dt)
Definition: SNUtils.h:104
double sn::TimeCluster ( std::vector< std::pair< double, double >> &  pts,
double &  clustPE 
)

Definition at line 24 of file SNUtils.h.

26  {
27  // "Clustering by Fast Search and Find of Density Peaks"
28  // Rodriguez and Laio, Science, 2014
29 
30  const double sigma = 5; // characteristic time
31  const double sigsq = mysqr(sigma);
32 
33  // const double norm = 1/(sqrt(2*TMath::Pi())*sigma);
34 
35  std::sort(pts.begin(), pts.end()); // Sort points by time
36 
37  std::vector<double> rhos(pts.size(), 0); // densities
38 
39  for(unsigned int i = 0; i < pts.size(); ++i){
40  double& rho = rhos[i];
41 
42  const double ti = pts[i].first;
43 
44  for(unsigned int j = 0; j < pts.size(); ++j){
45  // if(j == i) continue;
46 
47  const double tj = pts[j].first;
48  const double qj = pts[j].second;
49 
50  rho += qj*exp(-mysqr(ti-tj)/(2*sigsq));
51  } // end for j
52  } // end for i
53 
54  double bestScore = 0;
55  double bestT = 0;
56  for(unsigned int i = 0; i < pts.size(); ++i){
57  if(rhos[i] > bestScore){
58  bestScore = rhos[i];
59  bestT = pts[i].first;
60  clustPE = rhos[i];
61  }
62  }
63  return bestT;
64  }