21 std::multiset<Match>::emplace(E,
args...);
25 auto itLargest =
end();
70 std::vector<Match>
ret;
71 ret.reserve(matches.size());
72 for(
const Match&
m: matches){
84 unsigned int numMatches,
88 return FindMatchesHeads (trial, numMatches, enrich);
90 return FindMatchesNoHeads(trial, numMatches, enrich);
96 unsigned int numMatches,
106 const unsigned int I = fLib->NEvents();
107 for(
unsigned int i = 0;
i < I; ++
i){
111 if(libEvt.
enrich !=
bool(enrich))
continue;
115 if(libEvt.
weight == 0)
continue;
117 for(
int flipEven: {0, 1}){
118 for(
int flipOdd: {0, 1}){
120 const float E =
CalcEnergy(trialVs.
V[flipEven][flipOdd], trial, libEvt);
121 Elist.
emplace(E, &libEvt, flipEven, flipOdd,
i);
126 return PackageMatches(Elist, trial);
132 bool& bestFlipEven,
bool& bestFlipOdd,
133 double& bestEnergy)
const 136 bestEnergy = FLT_MAX;
138 const int nHeads = fHeads->NHeads();
139 for(
int iHead = 0; iHead < nHeads; ++iHead){
140 const MatchableEvent& headEvt = fLib->Event(fHeads->HeadIdx(iHead));
142 for(
int flipEven: {0, 1}){
143 for(
int flipOdd: {0, 1}){
144 const float E =
CalcEnergy(trialVs.
V[flipEven][flipOdd], trial,
149 bestFlipEven = flipEven;
150 bestFlipOdd = flipOdd;
163 unsigned int numMatches,
169 bool headFlipEven, headFlipOdd;
171 const int headIdx = BestHeadFor(trialVs, trial,
172 headFlipEven, headFlipOdd, headE);
179 const unsigned int J = fHeads->HeadSeqsLen();
180 for(
unsigned int j = 0;
j <
J; ++
j){
181 const int i = fHeads->ChildIdxFor(headIdx,
j);
186 if(libEvt.
enrich !=
bool(enrich))
continue;
190 if(libEvt.
weight == 0)
continue;
192 const bool flipEven = (fHeads->FlipEvenFor(headIdx,
j) ^ headFlipEven);
193 const bool flipOdd = (fHeads->FlipOddFor (headIdx,
j) ^ headFlipOdd );
195 const float E =
CalcEnergy(trialVs.
V[flipEven][flipOdd], trial, libEvt);
196 Elist.
emplace(E, &libEvt, flipEven, flipOdd,
j);
199 return PackageMatches(Elist, trial);
bool enrich
Was this event generated in a filtered-for-pi0 job?
float CalcEnergy(const Potential &Va, const MatchableEvent &a, const MatchableEvent &b)
Attach some information used in matching to an EventSummary.
double J(double q0, double q3, double Enu, double ml)
std::vector< Match > FindMatches(const MatchableEvent &trial, unsigned int numMatches, int enrich) const
FindMatchesAlg(const std::string &libDir, bool preload, bool useHeads)
std::vector< Match > PackageMatches(const std::multiset< Match > &matches, const MatchableEvent &trial) const
Core of the LEM match-finding algorithm.
void emplace(double E, T...args)
double FracChargeMatched(const EventSummary &a, const EventSummary &b, bool flipEven, bool flipOdd)
SortedMatchList(unsigned int numMatches)
Information about a LEM match.
void FillPotential(const EventSummary &trial, Potential &V, bool flipEven, bool flipOdd)
int BestHeadFor(const FlippedPotentials &trialVs, const MatchableEvent &trial, bool &bestFlipEven, bool &bestFlipOdd, double &bestEnergy) const
assert(nhit_max >=nhit_nbins)
Collection of Potential objects with odd and/or even view flipped.
static Heads * FromMMap(const std::string &libPath, bool touchAll)
std::vector< Match > FindMatchesHeads(const MatchableEvent &trial, unsigned int numMatches, int enrich) const
static Library * FromMMap(const std::string &libPath, bool touchAll)
std::vector< Match > FindMatchesNoHeads(const MatchableEvent &trial, unsigned int numMatches, int enrich) const