Skip to content

Commit

Permalink
Work in progress. Not functional.
Browse files Browse the repository at this point in the history
  • Loading branch information
bamesserly committed Mar 25, 2022
1 parent 730d544 commit 66b2b6b
Showing 1 changed file with 177 additions and 2 deletions.
179 changes: 177 additions & 2 deletions includes/Cuts.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,57 @@
// * bool PassesCut(cut)
// * PassedCuts <-- just an event counter
//==============================================================================
// Passes All Cuts v4 (experimental)
// return tuple {passes_all_cuts, is_w_sideband, pion_candidate_idxs}
std::tuple<bool, bool, std::vector<int>> PassesCuts(
CVUniverse& universe, const bool is_mc,
const SignalDefinition signal_definition, std::vector<ECuts> cuts) {
//============================================================================
// passes all cuts but w cut
//============================================================================
endpoint::MichelMap endpoint_michels;
endpoint::MichelMap vertex_michels;
bool passes_all_but_w_cut = true;
for (auto c : GetWSidebandCuts()) {
// Set the pion candidates to the universe. The values set in early cuts
// are used for later cuts, which is why we assign them to the CVU.
universe.SetPionCandidates(GetHadIdxsFromMichels(endpoint_michels));

passes_all_but_w_cut =
passes_all_but_w_cut && PassesCut(universe, c, is_mc, signal_definition,
endpoint_michels, vertex_michels);
}

//============================================================================
// The cuts function returns a container of endpoint michels which are
// matched to hadron tracks that have passed the pion candidate cuts. From
// here on out, use the pion candidates to calculate pion quantities for this
// event-universe.
//============================================================================
std::vector<int> pion_candidate_idxs =
GetHadIdxsFromMichels(endpoint_michels);

//============================================================================
// is in the w sideband
//============================================================================
bool is_w_sideband = passes_all_but_w_cut &&
(universe.GetWexp() >= sidebands::kSidebandCutVal);

//============================================================================
// finally: check the w cut
//============================================================================
// is the W cut in the cuts vector provided?
bool do_w_cut = std::find(cuts.begin(), cuts.end(), kWexp) != cuts.end();

bool passes_all_cuts = passes_all_but_w_cut;
if (do_w_cut)
passes_all_cuts =
passes_all_but_w_cut && WexpCut(universe, signal_definition);

return {passes_all_cuts, is_w_sideband, pion_candidate_idxs};
}


// Passes All Cuts v3 (latest and greatest)
// return tuple {passes_all_cuts, is_w_sideband, pion_candidate_idxs}
std::tuple<bool, bool, std::vector<int>> PassesCuts(
Expand Down Expand Up @@ -143,7 +194,130 @@ EventCount PassedCuts(const CVUniverse& univ,
return Pass;
}

// Pass Single, Given Cut
// v2 Pass Single, Given Cut
std::tuple<bool, endpoint::MichelMap, vertex::MichelEvent> PassesCut(
const CVUniverse& univ, const ECuts cut, const bool is_mc,
const SignalDefinition signal_definition) {
endpoint::MichelMap endpoint_michels;
vertex::MichelEvent vtx_michels;
const bool useOVMichels = false;
if (IsPrecut(cut) && !is_mc) return true;

switch (cut) {
case kNoCuts:
return true;

case kGoodObjects:
return univ.IsTruth() ? GoodObjectsCut(univ) : true;

case kGoodVertex:
return univ.IsTruth() ? GoodVertexCut(univ) : true;

case kFiducialVolume:
return univ.IsTruth() ? FiducialVolumeCut(univ) : true;

case kMinosActivity:
return univ.IsTruth() ? MinosActivityCut(univ) : true;

case kPrecuts:
return univ.IsTruth() ? GoodObjectsCut(univ) && GoodVertexCut(univ) &&
FiducialVolumeCut(univ)
: true;
// MinosActivityCut(univ) : true;

case kVtx:
return vtxCut(univ);

case kMinosMatch:
return MinosMatchCut(univ);

case kMinosCharge:
return MinosChargeCut(univ);

case kMinosMuon:
return MinosMatchCut(univ) && MinosChargeCut(univ);

case kWexp:
return WexpCut(univ, signal_definition);

case kIsoProngs:
return IsoProngCut(univ);

case kPmu:
return PmuCut(univ);

// ==== At Least One Michel ====
// For now, we need at least one ENDPOINT michel (any # of vtx michels).
// This cut fills our michel containers, which we use to ID pion tracks
// and subsequently make track cuts (LLR, node).
case kAtLeastOneMichel: {
endpoint::MichelMap all_michels = endpoint::GetQualityMichels(univ);
for (auto m : all_michels) {
if (m.second.had_idx == -1)
vertex_michels.insert(m);
else
endpoint_michels.insert(m);
}
vertex::MichelEvent mehreen_michels = vertex::GetQualityMichels(univ);
return endpoint_michels.size() > 0 /*|| mehreen_michels.size() = 0*/;
}

// ==== At Least One Michel (NEW) ====
// Going to try allowing at least one michel of either endpoint or vtx
// type.
//
// This cut fills our michel containers.
//
// Endpoint michels will be (already have been?) subject to subsequent cuts
// (LLR and Node) on their matched tracks.
//
// Vtx michels already have been subjected to Mehreen's quality cuts
case kAtLeastOneMichelv2: {
endpoint::MichelMap endpoint_michels;
vertex::MichelEvent vtx_michels;
std::tie(endpoint_michels, vtx_michels) = GetQualityMichelsv2(univ);
return
}

case kAtLeastOnePionCandidateTrack:
return GetQualityPionCandidateIndices(univ).size() > 0;

// If a michel's pion fails the LLR cut, remove it from the michels
case kLLR: {
ContainerEraser::erase_if(endpoint_michels,
[&univ](std::pair<int, endpoint::Michel> mm) {
return !LLRCut(univ, mm.second.had_idx);
});
return endpoint_michels.size() > 0;
}

// If a michel's pion fails the node cut, remove it from the michels
case kNode: {
ContainerEraser::erase_if(endpoint_michels,
[&univ](std::pair<int, endpoint::Michel> mm) {
return !NodeCut(univ, mm.second.had_idx);
});
return endpoint_michels.size() > 0;
}

case kPionMult: {
if (signal_definition == kOnePi || signal_definition == kOnePiNoW)
return endpoint_michels.size() == 1 && vertex_michels.size() == 0;
else
return endpoint_michels.size() >= 1;
}

case kAllCuts:
return true;

default:
std::cout << "PassesCut Error Unknown Cut!" << cut << " " << GetCutName(cut) << "\n";
return false;
};
}

/*
// v1 Pass Single, Given Cut
bool PassesCut(const CVUniverse& univ, const ECuts cut, const bool is_mc,
const SignalDefinition signal_definition,
endpoint::MichelMap& endpoint_michels, endpoint::MichelMap& vertex_michels) {
Expand Down Expand Up @@ -206,7 +380,7 @@ bool PassesCut(const CVUniverse& univ, const ECuts cut, const bool is_mc,
endpoint_michels.insert(m);
}
vertex::MichelEvent mehreen_michels = vertex::GetQualityMichels(univ);
return endpoint_michels.size() > 0 /*|| mehreen_michels.size() = 0*/;
return endpoint_michels.size() > 0; // || mehreen_michels.size() = 0;
}
case kAtLeastOnePionCandidateTrack:
Expand Down Expand Up @@ -245,6 +419,7 @@ bool PassesCut(const CVUniverse& univ, const ECuts cut, const bool is_mc,
return false;
};
}
*/

//==============================================================================
// Cut Definitions
Expand Down

0 comments on commit 66b2b6b

Please sign in to comment.