26 const unsigned int Nb = b.
nhits;
28 for(
unsigned int i = 0;
i <
Nb; ++
i){
38 bool flipEven,
bool flipOdd)
46 float acharge[256*256] = {0,};
48 const unsigned int Na = a.
nhits;
49 const unsigned int Nb = b.
nhits;
50 for(
unsigned int ia = 0; ia <
Na; ++ia){
55 for(
unsigned int ib = 0; ib <
Nb; ++ib){
61 if((v == 0 && flipEven) ||
64 const int bidx = 256*hb.
Plane()+hbc;
77 bool flipEven,
bool flipOdd)
81 const unsigned int N = trial.
nhits;
83 for(
unsigned int i = 0;
i < N; ++
i){
90 if((flipEven && view == 0) || (flipOdd && view == 1))
123 const unsigned int N = trial.
nhits;
129 float overflow[256] = {0,};
131 for(
unsigned int i = 0;
i < N; ++
i){
152 for(
bool flipEven: {
false,
true}){
153 for(
bool flipOdd: {
false,
true}){
154 if(!flipEven && !flipOdd)
continue;
162 if((flipEven && view == 0) || (flipOdd && view == 1))
165 if(fc >= 0 && fc < 256)
176 unsigned int libSize,
180 const std::multiset<float>& alreadyInput,
181 unsigned int numMatches,
191 assert(!heads || headIdx >= 0);
197 std::multiset<float> already;
198 for(
auto a: alreadyInput) already.insert(
a*trial.
selfEnergy);
201 while(already.size() > numMatches){
202 auto itLargest = already.end();
204 already.erase(itLargest);
205 target = *already.rbegin();
220 for(
int flipEven = 0; flipEven <= 1; ++flipEven){
221 for(
int flipOdd = 0; flipOdd <= 1; ++flipOdd){
222 Vs_down.
V[flipEven][flipOdd] = Vs.
V[flipEven][flipOdd].
Downsampled(factor);
228 std::multiset<Match> Elist;
231 for(
unsigned int j = 0;
j < libSize; ++
j){
239 if(lib[i].enrich !=
bool(enrich))
continue;
245 if( useDownsample && downEvt.
weight == 0)
continue;
246 if(!useDownsample && lib[i].
weight == 0)
continue;
248 for(
int flipEven = 0; flipEven <= 1; ++flipEven){
249 if(heads && (heads->
FlipEvenFor(headIdx,
j) ^ flipHeadEven) != flipEven)
continue;
250 for(
int flipOdd = 0; flipOdd <= 1; ++flipOdd){
251 if(heads && (heads->
FlipOddFor(headIdx,
j) ^ flipHeadOdd) != flipOdd)
continue;
256 float E = useDownsample ?
CalcEnergy(Vs_down.
V[flipEven][flipOdd], trial, downEvt) : 0;
260 E =
CalcEnergy(Vs.
V[flipEven][flipOdd], trial, lib[i]);
264 Elist.insert(
Match(E, &lib[i], flipEven, flipOdd,
j));
267 if(Elist.size() > numMatches){
269 auto itLargest = Elist.end();
271 Elist.erase(itLargest);
273 target = Elist.rbegin()->energy;
275 if(already.size() > numMatches){
277 auto itLargest = already.end();
279 already.erase(itLargest);
280 target = *already.rbegin();
290 std::vector<Match>
ret;
291 ret.reserve(numMatches);
292 for(
const auto&
m: Elist){
Simple representation of event for LEM use.
float CalcEnergy(const Potential &Va, const MatchableEvent &a, const MatchableEvent &b)
Attach some information used in matching to an EventSummary.
Map of electrostatic potential at each cell.
int ChildIdxFor(int head, int child) const
bool FlipEvenFor(int head, int child) const
Mapping from a subset of the library to their best matches.
Core of the LEM match-finding algorithm.
std::vector< Match > FindMatches(const MatchableEvent &trial, unsigned int libSize, const MatchableEvent *lib, const MatchableEvent *libDownsample, int factor, const std::multiset< float > &alreadyInput, unsigned int numMatches, int enrich, const Heads *heads, int headIdx, bool flipHeadEven, bool flipHeadOdd, bool useDownsample)
bool FlipOddFor(int head, int child) const
static const DistanceMap & Instance()
Singleton.
double FracChargeMatched(const EventSummary &a, const EventSummary &b, bool flipEven, bool flipOdd)
Mapping from a subset of the library to their best matches.
Information about a LEM match.
Attach some information used in matching to an EventSummary.
void FillPotential(const EventSummary &trial, Potential &V, bool flipEven, bool flipOdd)
assert(nhit_max >=nhit_nbins)
Collection of Potential objects with odd and/or even view flipped.
T min(const caf::Proxy< T > &a, T b)
Potential Downsampled(int factor) const
Compressed hit info, basic component of LEM events.
Calculate and cache electrostatic potential between cells.
double InvDist(int aplane, int bplane, int acell, int bcell) const
Calculate and cache electrostatic potential between cells.