Potential.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file Potential.cxx
3 /// \brief Map of electrostatic potential at each cell
4 /// \author Christopher Backhouse - bckhouse@caltech.edu
5 ////////////////////////////////////////////////////////////////////////
6
7 #include "LEM/func/Potential.h"
8
9 #include <algorithm>
10 #include <cassert>
11
12 namespace lem
13 {
14  //......................................................................
16  {
17  // That "V()" should have taken care of this, check.
18  assert(V[0] == 0);
19  assert(V[256*256-1] == 0);
20  }
21
22  //......................................................................
24  {
25  Potential ret;
26
27  for(int p = 0; p < 256; ++p){
28  for(int c = 0; c < 256; ++c){
29  const int idx = p*256+c;
30
31  const int newp = ((p>>(factor+1))<<1)+p%2;
32  const int newc = c>>factor;
33
34  // Matches indexing in MatchableEvent::Downsampled()
35  const int newidx = (newp<<(8-factor))+newc;
36
37  // Keeping the largest value ensures that the energy calculated from
38  // this potential is a lower bound, as required.
39  ret.V[newidx] = std::max(ret.V[newidx], V[idx]);
40  }
41  }
42
43  return ret;
44  }
45 }
T max(const caf::Proxy< T > &a, T b)
Map of electrostatic potential at each cell.
Map of electrostatic potential at each cell.
Definition: Potential.h:13
const char * p
Definition: xmltok.h:285
PID
Definition: FillPIDs.h:14
assert(nhit_max >=nhit_nbins)
Potential Downsampled(int factor) const
Definition: Potential.cxx:23
float V[256 *256]
Definition: Potential.h:18