Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
lem::DistanceMap Class Reference

Calculate and cache electrostatic potential between cells. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-21/LEM/func/DistanceMap.h"

Public Member Functions

double InvDist (int aplane, int bplane, int acell, int bcell) const
 
double InvDist (const LiteHit &a, const LiteHit &b) const
 
TH2 * MakeHist () const
 

Static Public Member Functions

static const DistanceMapInstance ()
 Singleton. More...
 
static void SetPlaneScale (double ps)
 Must call before first call to Instance() More...
 
static void SetCellScale (double cs)
 
static void SetDecayPower (double dp)
 
static void SetExpMode (bool em=true)
 

Static Protected Member Functions

static double DistFunc (double dp, double dc)
 

Protected Attributes

double fInvDistMap [kNumPlanes][kNumCells]
 

Static Protected Attributes

static double fgPlaneScale = 3.5
 
static double fgCellScale = 10.5
 
static double fgDecayPower = -0.25
 
static bool fgExpMode = false
 

Private Member Functions

 DistanceMap ()
 

Detailed Description

Calculate and cache electrostatic potential between cells.

Definition at line 20 of file DistanceMap.h.

Constructor & Destructor Documentation

lem::DistanceMap::DistanceMap ( )
private

Definition at line 33 of file DistanceMap.cxx.

References plot_validation_datamc::c, confusionMatrixTree::count, DistFunc(), E, fInvDistMap, lem::kNumCells, lem::kNumPlanes, and util::sqr().

34  {
35  for(int p = 0; p < kNumPlanes; ++p){
36  for(int c = 0; c < kNumCells; ++c){
37  // For long enough distances don't bother to do the integral over cells
38  if(p > 5 || c > 5){
39  fInvDistMap[p][c] = DistFunc(p, c);
40  continue;
41  }
42 
43  double E = 0;
44 
45  const int kNumSteps = 10;
46  for(int dp1 = 0; dp1 < kNumSteps; ++dp1){
47  for(int dp2 = 0; dp2 < kNumSteps; ++dp2){
48  const double dp = (dp1-dp2)/double(kNumSteps);
49  for(int dc1 = 0; dc1 < kNumSteps; ++dc1){
50  for(int dc2 = 0; dc2 < kNumSteps; ++dc2){
51  // Avoid division by zero
52  if(p == 0 && c == 0 && dp1 == dp2 && dc1 == dc2) continue;
53 
54  const double dc = (dc1-dc2)/double(kNumSteps);
55 
56  E += DistFunc(p+dp, c+dc);
57  }
58  }
59  }
60  } // end for dp1
61 
62  // Don't count the terms that we continue'd out of
63  int count = util::sqr(util::sqr(kNumSteps));
64  if(p == 0 && c == 0) count -= util::sqr(kNumSteps);
65 
66  fInvDistMap[p][c] = E/count;
67  } // end for c
68  } // end for p
69  }
static double DistFunc(double dp, double dc)
Definition: DistanceMap.cxx:86
const char * p
Definition: xmltok.h:285
double fInvDistMap[kNumPlanes][kNumCells]
Definition: DistanceMap.h:45
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
Float_t E
Definition: plot.C:20
const int kNumCells
Definition: DistanceMap.h:17
const int kNumPlanes
Definition: DistanceMap.h:16

Member Function Documentation

double lem::DistanceMap::DistFunc ( double  dp,
double  dc 
)
staticprotected

Definition at line 86 of file DistanceMap.cxx.

References stan::math::exp(), fgCellScale, fgDecayPower, fgExpMode, fgPlaneScale, cet::pow(), and util::pythag().

Referenced by DistanceMap(), and SetExpMode().

87  {
88  const double dr = util::pythag(fgPlaneScale*dp, fgCellScale*dc);
89 
90  if(fgExpMode){
91  // Can control the coefficient with planeScale and cellScale
92  return exp(-dr);
93  }
94 
95  return pow(dr, fgDecayPower);
96  }
constexpr T pow(T x)
Definition: pow.h:75
static double fgDecayPower
Definition: DistanceMap.h:42
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
static double fgCellScale
Definition: DistanceMap.h:41
static bool fgExpMode
Definition: DistanceMap.h:43
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
static double fgPlaneScale
Definition: DistanceMap.h:40
const DistanceMap & lem::DistanceMap::Instance ( )
static

Singleton.

Definition at line 26 of file DistanceMap.cxx.

Referenced by lem::FillPotential(), and lem::MatchableEvent::MatchableEvent().

27  {
28  static DistanceMap instance;
29  return instance;
30  }
double lem::DistanceMap::InvDist ( int  aplane,
int  bplane,
int  acell,
int  bcell 
) const

Definition at line 99 of file DistanceMap.cxx.

References abs(), ana::assert(), fInvDistMap, lem::kNumCells, and lem::kNumPlanes.

Referenced by lem::FillPotential(), InvDist(), and lem::MatchableEvent::MatchableEvent().

100  {
101  const int dp = abs(aplane-bplane);
102  const int dc = abs(acell-bcell);
103 
104  // Very far away
105  if(dp < 0) return 0;
106  if(dp >= kNumPlanes) return 0;
107  if(dc < 0) return 0;
108  if(dc >= kNumCells) return 0;
109 
110  // Comparison between different views shouldn't happen
111  assert(dp%2 == 0);
112 
113  return fInvDistMap[dp][dc];
114  }
void abs(TH1 *hist)
double fInvDistMap[kNumPlanes][kNumCells]
Definition: DistanceMap.h:45
assert(nhit_max >=nhit_nbins)
const int kNumCells
Definition: DistanceMap.h:17
const int kNumPlanes
Definition: DistanceMap.h:16
double lem::DistanceMap::InvDist ( const LiteHit a,
const LiteHit b 
) const

Definition at line 117 of file DistanceMap.cxx.

References lem::LiteHit::Cell(), InvDist(), and lem::LiteHit::Plane().

118  {
119  return InvDist(a.Plane(), b.Plane(), a.Cell(), b.Cell());
120  }
const double a
const hit & b
Definition: hits.cxx:21
double InvDist(int aplane, int bplane, int acell, int bcell) const
Definition: DistanceMap.cxx:99
TH2 * lem::DistanceMap::MakeHist ( ) const

Definition at line 72 of file DistanceMap.cxx.

References plot_validation_datamc::c, fInvDistMap, lem::kNumCells, and lem::kNumPlanes.

73  {
74  TH2* hDistMap = new TH2F("", ";#Deltaplanes;#Deltacells", 5, 0, 5, 5, 0, 5);
75 
76  for(int p = 0; p < kNumPlanes; ++p){
77  for(int c = 0; c < kNumCells; ++c){
78  hDistMap->Fill(p, c, 1/fInvDistMap[p][c]);
79  } // end for c
80  } // end for p
81 
82  return hDistMap;
83  }
const char * p
Definition: xmltok.h:285
double fInvDistMap[kNumPlanes][kNumCells]
Definition: DistanceMap.h:45
const int kNumCells
Definition: DistanceMap.h:17
const int kNumPlanes
Definition: DistanceMap.h:16
static void lem::DistanceMap::SetCellScale ( double  cs)
inlinestatic
static void lem::DistanceMap::SetDecayPower ( double  dp)
inlinestatic
static void lem::DistanceMap::SetExpMode ( bool  em = true)
inlinestatic
static void lem::DistanceMap::SetPlaneScale ( double  ps)
inlinestatic

Member Data Documentation

double lem::DistanceMap::fgCellScale = 10.5
staticprotected

Definition at line 41 of file DistanceMap.h.

Referenced by DistFunc(), and SetCellScale().

double lem::DistanceMap::fgDecayPower = -0.25
staticprotected

Definition at line 42 of file DistanceMap.h.

Referenced by DistFunc(), and SetDecayPower().

bool lem::DistanceMap::fgExpMode = false
staticprotected

Definition at line 43 of file DistanceMap.h.

Referenced by DistFunc(), and SetExpMode().

double lem::DistanceMap::fgPlaneScale = 3.5
staticprotected

Definition at line 40 of file DistanceMap.h.

Referenced by DistFunc(), and SetPlaneScale().

double lem::DistanceMap::fInvDistMap[kNumPlanes][kNumCells]
protected

Definition at line 45 of file DistanceMap.h.

Referenced by DistanceMap(), InvDist(), and MakeHist().


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