11 #include <analysis/modules/CurlTagger/CurlTaggerModule.h>
13 #include <framework/datastore/StoreObjPtr.h>
15 #include <analysis/dataobjects/ParticleList.h>
17 #include <analysis/variables/TrackVariables.h>
18 #include <analysis/variables/Variables.h>
19 #include <analysis/variables/MCTruthVariables.h>
25 #include <analysis/modules/CurlTagger/Bundle.h>
26 #include <analysis/modules/CurlTagger/SelectorCut.h>
27 #include <analysis/modules/CurlTagger/SelectorMVA.h>
45 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");
48 addParam(
"particleLists", m_ParticleLists,
"input particle lists to check for curls or use for training");
49 addParam(
"belle", m_BelleFlag,
"flag to distinuguish Belle (true) from Belle II (false) data",
false);
50 addParam(
"ptCut", m_PtCut,
"preselection pt Cut", 0.6);
51 addParam(
"selectorType", m_SelectorType,
52 "the name of the selector to use when deciding if two reconstructed particles are the same true particle, available : 'cut', 'mva'",
54 addParam(
"mcTruth", m_McStatsFlag,
55 "additionaly bundles the particles using their genParticleIndex and tags them with extraInfo(isTruthCurl) and extraInfo(truthBundleSize).",
57 addParam(
"train", m_TrainFlag,
"flag for training the MVA or other methods if needed",
false);
59 addParam(
"responseCut", m_ResponseCut,
"minimum allowed selector response for a match.", 0.324);
66 if (Variable::particlePt(p) >
m_PtCut) {
return false;}
67 if (!(Variable::trackNCDCHits(p) > 0 || Variable::trackNVXDHits(p) > 0)) {
return false;}
68 if (p -> getCharge() == 0) {
return false;}
79 B2WARNING(
"Curl Tagger 'cut' selector is only calibrated for Belle");
85 B2ERROR(
"Curl Track Tagger - Selector type does not exists.");
103 B2ERROR(
"ParticleList " << iList <<
" not found");
106 unsigned int particleListSize = particleList -> getListSize();
107 if (particleListSize == 0) {
113 std::vector<CurlTagger::Bundle> bundles;
114 std::vector<CurlTagger::Bundle> truthBundles;
116 for (
unsigned int i = 0; i < particleListSize; i++) {
118 Particle* iPart = particleList -> getParticle(i);
119 iPart -> addExtraInfo(
"isCurl", 0);
120 iPart -> addExtraInfo(
"bundleSize", 0);
122 iPart -> addExtraInfo(
"isTruthCurl", 0);
123 iPart -> addExtraInfo(
"truthBundleSize", 0);
127 bool addedParticleToBundle =
false;
128 std::vector<float> bundlesResponse;
131 unsigned int bundleSize = bundle.size();
132 float averageResponse = 0;
134 for (
unsigned int b = 0; b < bundleSize; b++) {
135 Particle* bPart = bundle.getParticle(b);
136 averageResponse +=
m_Selector -> getResponse(iPart, bPart);
139 averageResponse /= bundleSize;
140 bundlesResponse.push_back(averageResponse);
143 if (bundlesResponse.size() > 0) {
144 auto maxElement = std::max_element(bundlesResponse.begin(), bundlesResponse.end());
146 int maxPosition = std::distance(std::begin(bundlesResponse), maxElement);
147 bundles[maxPosition].addParticle(iPart);
148 addedParticleToBundle =
true;
152 if (!addedParticleToBundle) {
155 bundles.push_back(tempBundle);
159 bool addedParticleToTruthBundle =
false;
160 for (
auto& truthBundle : truthBundles) {
161 Particle* bPart = truthBundle.getParticle(0);
162 if (Variable::genParticleIndex(iPart) == Variable::genParticleIndex(bPart)) {
163 truthBundle.addParticle(iPart);
164 addedParticleToTruthBundle =
true;
168 if (!addedParticleToTruthBundle) {
171 truthBundles.push_back(truthTempBundle);
176 bundle.tagCurlInfo();
178 bundle.tagSizeInfo();
183 truthBundle.tagCurlInfo();
184 truthBundle.tagSizeInfo();
188 for (
unsigned int i = 0; i < particleListSize; i++) {
189 Particle* iPart = particleList -> getParticle(i);
192 for (
unsigned int j = 0; j < particleListSize; j++) {
193 Particle* jPart = particleList -> getParticle(j);
194 if (i == j) {
continue;}