9 #include <analysis/modules/CurlTagger/CurlTaggerModule.h>
11 #include <framework/datastore/StoreObjPtr.h>
13 #include <analysis/dataobjects/ParticleList.h>
15 #include <analysis/variables/TrackVariables.h>
16 #include <analysis/variables/Variables.h>
17 #include <analysis/variables/MCTruthVariables.h>
23 #include <analysis/modules/CurlTagger/Bundle.h>
24 #include <analysis/modules/CurlTagger/SelectorCut.h>
25 #include <analysis/modules/CurlTagger/SelectorMVA.h>
43 R
"DOC("Curl Tagger is a tool designed to identify and tag extra tracks caused by low pt particles curling around the detector. For further documentation please see 'tagCurlTracks' in modularAnalysis.")DOC");
46 addParam(
"particleLists", m_ParticleLists,
"input particle lists to check for curls or use for training");
47 addParam(
"belle", m_BelleFlag,
"flag to distinuguish Belle (true) from Belle II (false) data",
false);
48 addParam(
"ptCut", m_PtCut,
"preselection pt Cut", 0.6);
49 addParam(
"selectorType", m_SelectorType,
50 "the name of the selector to use when deciding if two reconstructed particles are the same true particle, available : 'cut', 'mva'",
52 addParam(
"mcTruth", m_McStatsFlag,
53 "additionally bundles the particles using their genParticleIndex and tags them with extraInfo(isTruthCurl) and extraInfo(truthBundleSize).",
55 addParam(
"train", m_TrainFlag,
"flag for training the MVA or other methods if needed",
false);
57 addParam(
"responseCut", m_ResponseCut,
"minimum allowed selector response for a match.", 0.324);
64 if (Variable::particlePt(p) >
m_PtCut) {
return false;}
65 if (!(Variable::trackNCDCHits(p) > 0 || Variable::trackNVXDHits(p) > 0)) {
return false;}
66 if (p -> getCharge() == 0) {
return false;}
77 B2WARNING(
"Curl Tagger 'cut' selector is only calibrated for Belle");
83 B2ERROR(
"Curl Track Tagger - Selector type does not exists.");
101 B2ERROR(
"ParticleList " << iList <<
" not found");
104 unsigned int particleListSize = particleList -> getListSize();
105 if (particleListSize == 0) {
111 std::vector<CurlTagger::Bundle> bundles;
112 std::vector<CurlTagger::Bundle> truthBundles;
114 for (
unsigned int i = 0; i < particleListSize; i++) {
116 Particle* iPart = particleList -> getParticle(i);
117 iPart -> addExtraInfo(
"isCurl", 0);
118 iPart -> addExtraInfo(
"bundleSize", 0);
120 iPart -> addExtraInfo(
"isTruthCurl", 0);
121 iPart -> addExtraInfo(
"truthBundleSize", 0);
125 bool addedParticleToBundle =
false;
126 std::vector<float> bundlesResponse;
129 unsigned int bundleSize = bundle.size();
130 float averageResponse = 0;
132 for (
unsigned int b = 0; b < bundleSize; b++) {
133 Particle* bPart = bundle.getParticle(b);
134 averageResponse +=
m_Selector -> getResponse(iPart, bPart);
137 averageResponse /= bundleSize;
138 bundlesResponse.push_back(averageResponse);
141 if (bundlesResponse.size() > 0) {
142 auto maxElement = std::max_element(bundlesResponse.begin(), bundlesResponse.end());
144 int maxPosition = std::distance(std::begin(bundlesResponse), maxElement);
145 bundles[maxPosition].addParticle(iPart);
146 addedParticleToBundle =
true;
150 if (!addedParticleToBundle) {
153 bundles.push_back(tempBundle);
157 bool addedParticleToTruthBundle =
false;
158 for (
auto& truthBundle : truthBundles) {
159 Particle* bPart = truthBundle.getParticle(0);
160 if (Variable::genParticleIndex(iPart) == Variable::genParticleIndex(bPart)) {
161 truthBundle.addParticle(iPart);
162 addedParticleToTruthBundle =
true;
166 if (!addedParticleToTruthBundle) {
169 truthBundles.push_back(truthTempBundle);
174 bundle.tagCurlInfo();
176 bundle.tagSizeInfo();
181 truthBundle.tagCurlInfo();
182 truthBundle.tagSizeInfo();
186 for (
unsigned int i = 0; i < particleListSize; i++) {
187 Particle* iPart = particleList -> getParticle(i);
190 for (
unsigned int j = 0; j < particleListSize; j++) {
191 Particle* jPart = particleList -> getParticle(j);
192 if (i == j) {
continue;}
This module is designed to tag curl tracks.
std::vector< std::string > m_ParticleLists
input particle lists
bool passesPreSelection(Particle *particle)
preselects particles that may be curl tracks
virtual void initialize() override
initialise
virtual void event() override
event code - all curl track selection done here
virtual void endRun() override
end run - unused
virtual void terminate() override
termination
virtual ~CurlTaggerModule() override
destructor
bool m_TrainFlag
switch between training and classifying
virtual void beginRun() override
begin run - unused
std::string m_SelectorType
name of selector function to use
bool m_McStatsFlag
if true also does some truth based matching and tags the particles with truthCurl info
double m_PtCut
preselection pt cut
bool m_BelleFlag
flags if data/mc comes from belle or belle II
CurlTagger::Selector * m_Selector
contains the selector used
double m_ResponseCut
min classifier response to consider a match
class to contain particles identified to come from the same actual/mc particle
void addParticle(Particle *particle)
adds Particle to Bundle
Simple cut based selector for curl tracks taken from Belle note 1079.
MVA based selector for tagging curl tracks in Belle and Belle II.
virtual void finalize()
finalise selector if needed
virtual void initialize()
initialise selector if needed
virtual void collectTrainingInfo(Particle *, Particle *)
collect information for training for mva or other selectors
Class to store reconstructed particles.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.