Belle II Software development
TrackFinderVXDAnalizerModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8//fw:
9#include <framework/dataobjects/EventMetaData.h>
10#include <framework/datastore/StoreObjPtr.h>
11#include <framework/core/ModuleParam.templateDetails.h>
12#include <framework/geometry/B2Vector3.h>
13
14//tracking:
15#include <tracking/modules/VXDTFHelperTools/TrackFinderVXDAnalizerModule.h>
16#include <tracking/spacePointCreation/SpacePointTrackCand.h>
17#include <tracking/spacePointCreation/PurityCalculatorTools.h>
18#include <tracking/trackFindingVXD/analyzingTools/AnalizerTCInfo.h>
19#include <tracking/trackFindingVXD/analyzingTools/AnalyzingAlgorithmFactory.h>
20#include <tracking/trackFindingVXD/analyzingTools/AlgoritmType.h>
21
22#include <Math/Vector3D.h>
23
24#include <string>
25
26using namespace Belle2;
27using namespace Belle2::Tracking;
28
29
30//-----------------------------------------------------------------
31// Register the Module
32//-----------------------------------------------------------------
33REG_MODULE(TrackFinderVXDAnalizer);
34
35//-----------------------------------------------------------------
36// Implementation
37//-----------------------------------------------------------------
38
40{
41 B2INFO("TrackFinderVXDAnalizer-initialize");
42
43 std::vector<std::string> rootFileNameVals;
44 rootFileNameVals.push_back("TrackFinderVXDAnalizerResults");
45 rootFileNameVals.push_back("RECREATE");
46
47
48 std::vector< std::vector< std::vector< std::string> > > trackedParametersDouble = {
49 { {"Reference"},
50 {"AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI"}
51 },
52 { {"Lost"},
53 {"AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI"}
54 },
55 { {"Contaminated"},
56 {
57 "AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI",
58 "AnalyzingAlgorithmResidualP", "AnalyzingAlgorithmResidualPT", "AnalyzingAlgorithmResidualPTheta", "AnalyzingAlgorithmResidualPPhi", "AnalyzingAlgorithmResidualPTAngle"
59 }
60 },
61 { {"Clean"},
62 {
63 "AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI",
64 "AnalyzingAlgorithmResidualP", "AnalyzingAlgorithmResidualPT", "AnalyzingAlgorithmResidualPTheta", "AnalyzingAlgorithmResidualPPhi", "AnalyzingAlgorithmResidualPTAngle"
65 }
66 },
67 { {"Perfect"},
68 {
69 "AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI",
70 "AnalyzingAlgorithmResidualP", "AnalyzingAlgorithmResidualPT", "AnalyzingAlgorithmResidualPTheta", "AnalyzingAlgorithmResidualPPhi", "AnalyzingAlgorithmResidualPTAngle"
71 }
72 },
73 };
74
75 std::vector< std::vector< std::vector< std::string> > > trackedParametersInt = {
76 { {"Reference"},
77 {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters"}
78 },
79 { {"Lost"},
80 {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters"}
81 },
82 { {"Contaminated"},
83 {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters", "AnalyzingAlgorithmLostUClusters", "AnalyzingAlgorithmLostVClusters"}
84 },
85 { {"Clean"},
86 {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters", "AnalyzingAlgorithmLostUClusters", "AnalyzingAlgorithmLostVClusters"}
87 },
88 { {"Perfect"},
89 {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters", "AnalyzingAlgorithmLostUClusters", "AnalyzingAlgorithmLostVClusters"}
90 }
91 };
92
93
94 std::vector< std::vector< std::vector< std::string> > > trackedParametersVecDouble = {
95 { {"Reference"},
96 {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep"}
97 },
98 { {"Lost"},
99 {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep"}
100 },
101 { {"Contaminated"},
102 {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep", "AnalyzingAlgorithmLostUEDep", "AnalyzingAlgorithmLostVEDep"}
103 },
104 { {"Clean"},
105 {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep", "AnalyzingAlgorithmLostUEDep", "AnalyzingAlgorithmLostVEDep"}
106 },
107 { {"Perfect"},
108 {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep", "AnalyzingAlgorithmLostUEDep", "AnalyzingAlgorithmLostVEDep"}
109 }
110 };
111
112 //Set module properties
113 setDescription("analyzes quality of SpacePointTrackCands delivered by a test-TF compared to a reference TF");
115
116
117 addParam("referenceTCname", m_PARAMreferenceTCname, "the name of the storeArray container provided by the reference TF",
118 std::string("mcTracks"));
119 addParam("testTCname", m_PARAMtestTCname, "the name of the storeArray container provided by the TF to be evaluated",
120 std::string(""));
121 addParam("acceptedTCname", m_PARAMacceptedTCname, "special name for accepted/successfully reconstructed track candidates",
122 std::string("acceptedVXDTFTracks"));
123 addParam("lostTCname", m_PARAMlostTCname, "special name for lost track candidates", std::string("lostTracks"));
124 addParam("purityThreshold", m_PARAMpurityThreshold,
125 " chose value to filter TCs found by Test TF. TCs having purities lower than this value won't be marked as reconstructed",
126 double(0.7));
127 addParam("minNDFThreshold", m_PARAMminNDFThreshold,
128 " defines how many measurements (numbers of degrees of freedom) the TC must have to be accepted as reconstructed, standard is 5",
129 unsigned(5));
130
131 addParam("writeToRoot", m_PARAMwriteToRoot,
132 " if true, analysis data is stored to root file with file name chosen by 'rootFileName'", bool(true));
133 addParam("rootFileName", m_PARAMrootFileName,
134 " only two entries accepted, first one is the root filename, second one is 'RECREATE' or 'UPDATE' which is the write mode for the root file, parameter is used only if 'writeToRoot'=true ",
135 rootFileNameVals);
136
137 addParam("trackedParametersDouble", m_PARAMtrackedParametersDouble,
138 "set here all parameters to be tracked which use an algorithm storing one double per tc. Accepts a vector of vector of vector of strings of entries. Sample usage in steering file: param('trackedParametersDouble', [ [ ['Perfect'], ['AnalyzingAlgorithmValuePX', 'AnalyzingAlgorithmResidualP'] ] ]) first innermost vector storest the TCType to be tracked, second the algorithms which shall be applied on that tcType",
139 trackedParametersDouble);
140
141 addParam("trackedParametersInt", m_PARAMtrackedParametersInt,
142 "set here all parameters to be tracked which use an algorithm storing one int per tc. Accepts a vector of vector of vector of strings of entries. Sample usage in steering file: param('trackedParametersDouble', [ [ ['Contaminated'], ['AnalyzingAlgorithmLostUClusters', 'AnalyzingAlgorithmLostVClusters'] ] ]) first innermost vector storest the TCType to be tracked, second the algorithms which shall be applied on that tcType",
143 trackedParametersInt);
144
145 addParam("trackedParametersVecDouble", m_PARAMtrackedParametersVecDouble,
146 "set here all parameters to be tracked which use an algorithm storing one vector< double> per tc. Accepts a vector of vector of vector of strings of entries. Sample usage in steering file: param('trackedParametersDouble', [ [ ['Clean'], ['AnalyzingAlgorithmLostUEDep', 'AnalyzingAlgorithmLostVEDep'] ] ]) first innermost vector storest the TCType to be tracked, second the algorithms which shall be applied on that tcType",
147 trackedParametersVecDouble);
148
149
150 addParam("origin", m_PARAMorigin, " only allowed size: 3. stores coordinates of the origin used", {0, 0, 0});
151 addParam("useMCDataForValues", m_PARAMuseMCDataForValues,
152 "if true, for testTC the values of attached refTC will be stored instead of own values. - why are there values of the refTC stored? we want to know the real data, not the guesses of the reconstructed data. Deviations of reference values to guesses of the reconstructed data will be stored in resiudals anyway."
153 , bool(true));
154
155 addParam("ignoreDeadTCs", m_PARAMignoreDeadTCs,
156 " if true, test-tc whose activation-state is set to false are skipped for analysis", bool(true));
157
158 addParam("doEventSummary", m_PARAMdoEventSummary,
159 "if true, for each event a summary will be given (WARNING produces a lot of output!", bool(false));
160}
161
162
164{
169
170
171 if (m_PARAMorigin.size() != 3) {
172 B2ERROR("TrackFinderVXDAnalizerModule::initialize() passed parameter 'origin' has wrong number of entries (allowed: 3) of " <<
173 m_PARAMorigin.size() << " reset to standard (0, 0, 0)");
174 m_PARAMorigin = {0, 0, 0};
175 }
176
177 // deal with root-related stuff
178 if (m_PARAMwriteToRoot == false) { return; }
179
180 if ((m_PARAMrootFileName.size()) != 2) {
181 std::string output;
182 for (std::string& entry : m_PARAMrootFileName) {
183 output += "'" + entry + "' ";
184 }
185 B2FATAL("TrackFinderVXDAnalizer::initialize(), rootFileName is set wrong, although parameter 'writeToRoot' is enabled! Actual entries are: "
186 << output);
187 }
188
189 // deal with algorithms:
191 // typedef for increased readability:
195
196
197 // prepare all algorithms which store a double per tc:
198 for (auto& parameterPackage : m_PARAMtrackedParametersDouble) {
199 // check if parameterPackage has two entries: first is TCType, second is vector of algorithms
200 if (parameterPackage.size() != 2) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
201
202 // check if vector for tcType is really only one entry
203 if (parameterPackage.front().size() != 1) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
204
205 std::string tcTypeName = parameterPackage.front()[0];
206 if (TCType::isValidName(tcTypeName) == false)
207 { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (invalid tcType: " << tcTypeName << ")"); }
208
209 // for each algorithm, store a branch:
210 for (auto& algorithm : parameterPackage.back()) {
211 if (AlgoritmType::isValidName(algorithm) == false)
212 { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (invalid algorithmType: " << algorithm << ")"); }
214 }
215 }
216 AlgorithmDouble::setOrigin(B2Vector3D(m_PARAMorigin[0], m_PARAMorigin[1], m_PARAMorigin[2]));
217 AlgorithmDouble::setWillRefTCdataBeUsed4TestTCs(m_PARAMuseMCDataForValues);
218
219 // prepare all algorithms which store an int per tc:
220 for (auto& parameterPackage : m_PARAMtrackedParametersInt) {
221 // check if parameterPackage has two entries: first is TCType, second is vector of algorithms
222 if (parameterPackage.size() != 2) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
223
224 // check if vector for tcType is really only one entry
225 if (parameterPackage.front().size() != 1) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
226
227 std::string tcTypeName = parameterPackage.front()[0];
228 if (TCType::isValidName(tcTypeName) == false)
229 { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (invalid tcType: " << tcTypeName << ")"); }
230
231 // for each algorithm, store a branch:
232 for (auto& algorithm : parameterPackage.back()) {
233 if (AlgoritmType::isValidName(algorithm) == false)
234 { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (invalid algorithmType: " << algorithm << ")"); }
236 }
237 }
238 AlgorithmInt::setOrigin(B2Vector3D(m_PARAMorigin[0], m_PARAMorigin[1], m_PARAMorigin[2]));
239 AlgorithmInt::setWillRefTCdataBeUsed4TestTCs(m_PARAMuseMCDataForValues);
240
241 // prepare all algorithms which store a vector< double> per tc:
242 for (auto& parameterPackage : m_PARAMtrackedParametersVecDouble) {
243 // check if parameterPackage has two entries: first is TCType, second is vector of algorithms
244 if (parameterPackage.size() != 2) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
245
246 // check if vector for tcType is really only one entry
247 if (parameterPackage.front().size() != 1) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
248
249 std::string tcTypeName = parameterPackage.front()[0];
250 if (TCType::isValidName(tcTypeName) == false)
251 { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (invalid tcType: " << tcTypeName << ")"); }
252
253 // for each algorithm, store a branch:
254 for (auto& algorithm : parameterPackage.back()) {
255 if (AlgoritmType::isValidName(algorithm) == false)
256 { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (invalid algorithmType: " << algorithm << ")"); }
258 }
259 }
260 AlgorithmVecDouble::setOrigin(B2Vector3D(m_PARAMorigin[0], m_PARAMorigin[1], m_PARAMorigin[2]));
261 AlgorithmVecDouble::setWillRefTCdataBeUsed4TestTCs(m_PARAMuseMCDataForValues);
262}
263
264
266{
267
268 StoreObjPtr<EventMetaData> eventMetaDataPtr("EventMetaData", DataStore::c_Event);
269 m_eventCounter = eventMetaDataPtr->getEvent();
270 B2DEBUG(20, "################## entering TrackFinderVXDAnalizerModule - event " << m_eventCounter << " ######################");
271
272 int nReferenceTCs = m_referenceTCs.getEntries();
273 m_mcTrackCounter += nReferenceTCs;
274 m_mcTrackVectorCounter += nReferenceTCs; // WARNING temporal solution!
275 int nTestTCs = m_testTCs.getEntries();
276 m_caTrackCounter += nTestTCs;
277
278
280 unsigned nTC = 0;
281 std::vector<AnalizerTCInfo> referenceTCVector;
283 std::vector<MCVXDPurityInfo > purities = createPurityInfos(aTC);
284
285 MCVXDPurityInfo particleInfo = returnDominantParticleID(purities);
286 B2DEBUG(25, "Calculating purities for reference TC " << nTC << ", name. Dominating iD " << particleInfo.getParticleID() <<
287 " with purity " << particleInfo.getPurity().second << " was found among " << purities.size() << " assigned particles");
288
289 AnalizerTCInfo referenceTC = AnalizerTCInfo::createTC(true, particleInfo, aTC);
290 referenceTCVector.push_back(referenceTC);
291 nTC++;
292
293 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 1, PACKAGENAME())) { aTC.print(1); }
294 }
295
296
298 nTC = 0;
299 std::vector<AnalizerTCInfo> testTCVector;
300 for (SpacePointTrackCand& aTC : m_testTCs) {
301 if (m_PARAMignoreDeadTCs and aTC.hasRefereeStatus(SpacePointTrackCand::c_isActive) == false) { continue; }
302 std::vector<MCVXDPurityInfo > purities = createPurityInfos(aTC);
303
304 MCVXDPurityInfo particleInfo = returnDominantParticleID(purities);
305 B2DEBUG(25, "Calculating purities for test TC " << nTC << ", name. Dominating iD " << particleInfo.getParticleID() <<
306 " with purity" << particleInfo.getPurity().second << " was found among " << purities.size() << " assigned particles");
307
308 AnalizerTCInfo testTC = AnalizerTCInfo::createTC(false, particleInfo, aTC);
309 testTCVector.push_back(testTC);
310 nTC++;
311
312 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 1, PACKAGENAME())) { aTC.print(1); }
313 }
314
315
323 std::vector<std::pair<AnalizerTCInfo*, AnalizerTCInfo*> > pairedTCs;
324 for (AnalizerTCInfo& testTC : testTCVector) {
325 int testID = testTC.assignedID.getParticleID();
326
327 for (AnalizerTCInfo& referenceTC : referenceTCVector) {
328 int refID = referenceTC.assignedID.getParticleID();
329 B2DEBUG(29, "test TC with assigned ID " << testID << " was matched with refID " << refID);
330 if (refID != testID) continue;
331
332 testTC.tcType = AnalizerTCInfo::classifyTC(referenceTC, testTC, m_PARAMpurityThreshold, m_PARAMminNDFThreshold);
333
334 B2DEBUG(29, "test TC with assigned ID " << testID <<
335 " was classified for the corresponding with type for testTC/refTC: " << TCType::getTypeName(testTC.tcType) <<
336 "/" << TCType::getTypeName(referenceTC.tcType) << " and will now paired up");
337
338 referenceTC.pairUp(&testTC);
339
340 pairedTCs.push_back({ &testTC, &referenceTC});
341 }
342 }
343
345 AnalizerTCInfo::markUnused(testTCVector, TCType::Ghost);
346
348 AnalizerTCInfo::markUnused(referenceTCVector, TCType::Lost);
349
350
352 // good cases:
353 unsigned int nPerfectTCs = 0, nCleanTCs = 0, nContaminatedTCs = 0, nFound = 0;
354 // not so good cases:
355 unsigned int nClonedTCs = 0, nSmallTCs = 0, nGhostTCs = 0, nLostTestTCs = 0, nLostRefTCs = 0;
356 // bad cases: counts nTimes when the TC could not be identified/classified at all
357 unsigned int nBadCases = 0, nRefClones = 0; // refClones, cases when reference TCs were marked as clones
358 // hitCounters:
359 unsigned int refPXDClusters = 0, refSVDClusters = 0, testPXDClusters = 0, testSVDClusters = 0;
360
361 for (AnalizerTCInfo& aTC : testTCVector) {
362 testPXDClusters += aTC.assignedID.getNPXDClustersTotal();
363 testSVDClusters += aTC.assignedID.getNSVDUClustersTotal() + aTC.assignedID.getNSVDVClustersTotal();
364
365 switch (aTC.tcType) {
366 case TCType::Perfect: { nPerfectTCs++; nFound++; break; }
367 case TCType::Clean: { nCleanTCs++; nFound++; break; }
368 case TCType::Contaminated: { nContaminatedTCs++; nFound ++; break; }
369 case TCType::Clone: { nClonedTCs++; break; }
370 case TCType::SmallStump: { nSmallTCs++; break; }
371 case TCType::Ghost: { nGhostTCs++; break; }
372 case TCType::Lost: { nLostTestTCs++; break; }
373 default: {
374 nBadCases++;
375 B2WARNING("TrackFinderVXDAnalizer::event(): test TC got type " << TCType::getTypeName(aTC.tcType) <<
376 " which is not counted for efficiency-calculation");
377 }
378 }
379 }
380
381 for (AnalizerTCInfo& aTC : referenceTCVector) {
382 refPXDClusters += aTC.assignedID.getNPXDClustersTotal();
383 refSVDClusters += aTC.assignedID.getNSVDUClustersTotal() + aTC.assignedID.getNSVDVClustersTotal();
384
385 switch (aTC.tcType) {
386 case TCType::Reference: { break; }
387 case TCType::Clone: { nRefClones++; break; }
388 case TCType::Lost: { nLostRefTCs++; break; }
389 default: {
390 nBadCases++;
391 B2WARNING("TrackFinderVXDAnalizer::event(): reference TC got type " << TCType::getTypeName(aTC.tcType) <<
392 " which is not counted for efficiency-calculation");
393 }
394 }
395 }
396
397
399 std::string summary1 = "TrackFinderVXDAnalizer-Event " + std::to_string(m_eventCounter) +
400 ": the tested TrackFinder found: " +
401 " IDs (total/perfect/clean/contaminated/clone/tooShort/ghost: " + std::to_string(nFound) +
402 "/" + std::to_string(nPerfectTCs) +
403 "/" + std::to_string(nCleanTCs) +
404 "/" + std::to_string(nContaminatedTCs) +
405 "/" + std::to_string(nClonedTCs) +
406 "/" + std::to_string(nSmallTCs) +
407 "/" + std::to_string(nGhostTCs) +
408 ") within " + std::to_string(nTestTCs) +
409 " TCs and lost (test/ref) " + std::to_string(nLostTestTCs) +
410 "/" + std::to_string(nLostRefTCs) +
411 " TCs. nBadCases: " + std::to_string(nBadCases) +
412 " refClones: " + std::to_string(nRefClones) +
413 "\n" +
414 "There are " + std::to_string(nReferenceTCs) +
415 " referenceTCs, with mean of " + std::to_string((float(refPXDClusters) / float(nReferenceTCs))) +
416 "/" + std::to_string((float(refSVDClusters) / float(nReferenceTCs))) + " PXD/SVD clusters"
417 "\n" +
418 "There are " + std::to_string(nTestTCs) +
419 " testTCs, with mean of " + std::to_string((float(testPXDClusters) / float(nTestTCs))) +
420 "/" + std::to_string((float(testSVDClusters) / float(nTestTCs))) + " PXD/SVD clusters";
421
422 std::string summary2 = "TrackFinderVXDAnalizer-Event " + std::to_string(m_eventCounter) +
423 ": the tested TrackFinder had an efficiency : total/perfect/clean/contaminated/clone/tooShort/ghost: " +
424 std::to_string(double(100 * nFound) / double(nReferenceTCs)) +
425 "%/" + std::to_string(double(100 * nPerfectTCs) / double(nReferenceTCs)) +
426 "%/" + std::to_string(double(100 * nCleanTCs) / double(nReferenceTCs)) +
427 "%/" + std::to_string(double(100 * nContaminatedTCs) / double(nReferenceTCs)) +
428 "%/" + std::to_string(double(100 * nClonedTCs) / double(nReferenceTCs)) +
429 "%/" + std::to_string(double(100 * nSmallTCs) / double(nReferenceTCs)) +
430 "%/" + std::to_string(double(100 * nGhostTCs) / double(nReferenceTCs)) + "%";
431
432 std::string summary3 = "TrackFinderVXDAnalizer-Event " + std::to_string(m_eventCounter) +
433 ": totalCA|totalMC|ratio of pxdHits " + std::to_string(testPXDClusters) +
434 "|" + std::to_string(refPXDClusters) +
435 "|" + std::to_string(float(testPXDClusters) / float(refPXDClusters)) +
436 ", svdHits " + std::to_string(testSVDClusters) +
437 "|" + std::to_string(refSVDClusters) +
438 "|" + std::to_string(float(testSVDClusters) / float(refSVDClusters)) + " found by the two TFs";
439
441 B2INFO(summary1);
442 B2INFO(summary2);
443 B2INFO(summary3);
444 } else {
445 B2DEBUG(20, summary1);
446 B2DEBUG(20, summary2);
447 B2DEBUG(20, summary3);
448 }
449
450 m_totalRealHits += refPXDClusters + refSVDClusters;
451 m_nCaPXDHits += testPXDClusters;
452 m_nMcPXDHits += refPXDClusters;
453 m_nCaSVDHits += testSVDClusters;
454 m_nMcSVDHits += refSVDClusters;
455 m_countReconstructedTCs += nFound;
456 m_countedPerfectRecoveries += nPerfectTCs;
457 m_countedCleanRecoveries += nCleanTCs;
458 m_countedContaminatedRecoveries += nContaminatedTCs;
459 m_countedDoubleEntries += nClonedTCs;
460 m_countedTCsTooShort += nSmallTCs;
461 m_countedGhosts += nGhostTCs;
462 m_countedLostTest += nLostTestTCs;
463 m_countedLostRef += nLostRefTCs;
464 m_countedReferenceClones += nRefClones;
465
466
467 // TODO:
481// int acceptedTCs = m_acceptedTCs.getEntries();
482// m_countAcceptedGFTCs += acceptedTCs;
483// m_lostGFTCs += nLostTCs;
484// B2DEBUG(1, " of " << nTestTCs << " TCs produced by the tested TrackFinder, " << acceptedTCs <<
485// " were recognized safely and stored into the container of accepted TCs, " << nLostTCs <<
486// " were lost and their MCTF-TCs were stored in lostTCs")
487// for (unsigned int ID : foundIDs) {
488// B2DEBUG(1, " - ID " << ID << " recovered")
489// }
490
491
492 if (m_PARAMwriteToRoot == false) { return; }
494 // TODO:
495
497 m_rootParameterTracker.collectData(referenceTCVector);
498
500
501}
502
503
505{
506 B2INFO("------------- >>>TrackFinderVXDAnalizerModule::endRun<<< -------------");
507 B2DEBUG(20, "TrackFinderVXDAnalizerModule-explanation: \n" <<
508 " perfect recovery means: all hits of mc-TC found again and clean TC. \n" <<
509 " clean recovery means: no foreign hits within TC. \n" <<
510 " ghost means: QI was below threshold or mcTC was found more than once (e.g. because of curlers) \n" <<
511 " found more than once means: that there was more than one TC which was assigned to the same mcTC but each of them were good enough for themselves to be classified as reconstructed");
512
513 B2INFO("TrackFinderVXDAnalizerModule: After " << m_eventCounter + 1 << " events there was a total number of " << m_mcTrackCounter <<
514 " mcTrackCandidates and " << m_totalRealHits << " realHits. Of these TCs, " << m_mcTrackVectorCounter <<
515 " mcTrackCandidates where used for analysis because of cutoffs.");
516 B2INFO("TrackFinderVXDAnalizerModule: There were " << m_caTrackCounter << " caTrackCandidates, of those " << m_countAcceptedGFTCs <<
517 " were stored in " << m_PARAMacceptedTCname << " and " << m_lostGFTCs << " lost TCs were stored in " << m_PARAMlostTCname <<
518 " for further use, number of times where charge was guessed wrong: " << m_wrongChargeSignCounter <<
519 ", number of caTCs which produced a double entry: " << m_countedDoubleEntries);
520 B2INFO("TrackFinderVXDAnalizerModule: totalCA|totalMC|ratio of pxdHits " << m_nCaPXDHits << "|" << m_nMcPXDHits << "|" << float(
521 m_nCaPXDHits) / float(m_nMcPXDHits) <<
522 ", svdHits " << m_nCaSVDHits << "|" << m_nMcSVDHits << "|" << float(m_nCaSVDHits) / float(m_nMcSVDHits) <<
523 " found by the two TFs (ghost hits not removed, therefore only useful if ghost-rate is low)");
524
525 B2INFO("TrackFinderVXDAnalizerModule: the VXDTF found:\n" <<
526 "Absolute numbers: total/perfect/clean/contaminated/clone/tooShort/ghost: " << m_countReconstructedTCs <<
530 "/" << m_countedDoubleEntries <<
531 "/" << m_countedTCsTooShort <<
532 "/" << m_countedGhosts <<
533 " efficiency : total/perfect/clean/contaminated/clone/tooShort/ghost: " << double(100 * m_countReconstructedTCs) / double(
535 "%/" << double(100 * m_countedPerfectRecoveries) / double(m_mcTrackVectorCounter) <<
536 "%/" << double(100 * m_countedCleanRecoveries) / double(m_mcTrackVectorCounter) <<
537 "%/" << double(100 * m_countedContaminatedRecoveries) / double(m_mcTrackVectorCounter) <<
538 "%/" << double(100 * m_countedDoubleEntries) / double(m_mcTrackVectorCounter) <<
539 "%/" << double(100 * m_countedTCsTooShort) / double(m_mcTrackVectorCounter) <<
540 "%/" << double(100 * m_countedGhosts) / double(m_mcTrackVectorCounter) <<
541 "%");
542
543 B2INFO("TrackFinderVXDAnalizerModule: additional numbers:\"" <<
544 "nCountedLost (test/ref): " << m_countedLostTest <<
545 "/" << m_countedLostRef <<
546 ", nRefClones: " << m_countedReferenceClones <<
547 ", in percent - nLost (test/ref): " << double(100 * m_countedLostTest) / double(m_mcTrackVectorCounter) <<
548 "/" << double(100 * m_countedLostRef) / double(m_mcTrackVectorCounter) <<
549 "%, nClones: " << double(100 * m_countedReferenceClones) / double(m_mcTrackVectorCounter) <<
550 "%");
552// B2INFO("TFAnalizerModule: the VXDTF found (total/perfect/clean/ghost)" << m_countReconstructedTCs << "/" <<
553// m_countedPerfectRecoveries << "/" << m_countedCleanRecoveries << "/" << (m_caTrackCounter - m_countReconstructedTCs) <<
554// " TCs -> efficiency(total/perfect/clean/ghost): " << double(100 * m_countReconstructedTCs) / double(
555// m_mcTrackVectorCounter) << "%/" << double(100 * m_countedPerfectRecoveries) / double(m_mcTrackVectorCounter) << "%/" << double(
556// 100 * m_countedCleanRecoveries) / double(m_mcTrackVectorCounter) << "%/" << double(100 * (m_caTrackCounter -
557// m_countReconstructedTCs)) / double(m_countReconstructedTCs) << "%")
558}
559
560
562{
563
564 if (m_PARAMwriteToRoot == false) { return; }
566}
567
568
static bool isValidName(std::string type)
checks if the name given is a valid name for an AlgoritmType
Definition: AlgoritmType.h:79
simple class storing infos relevant for a TC for analizing it.
static TCType::Type classifyTC(AnalizerTCInfo &referenceTC, AnalizerTCInfo &testTC, double purityThreshold, unsigned int ndfThreshold)
for given pair of TCs their compatibility will be checked and the testTC classified,...
static void markUnused(std::vector< AnalizerTCInfo > &tcs, TCType::Type newType)
find unpaired tcs and mark them with given type
static AnalizerTCInfo createTC(bool isReference, const MCVXDPurityInfo &iD, SpacePointTrackCand &aTC)
static function for correctly creating TrackCandidates
Base class for storing an algorithm determining the data one wants to have.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
The MC VXD Purity info container class.
std::pair< int, float > getPurity() const
getter - returns overal purity (.second) for this particleID (.first).
int getParticleID() const
getter - returns the ID of the particle, if value is -1 no particle has been able to be found for it
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void addParameters4DoubleAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one double per TC:
void addParameters4VecDoubleAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one vector of double per TC:
void terminate()
final cleanup and closing rootFile
void fillRoot()
fills tree/branches with their stuff, clear intermediate results afterwards
void initialize(std::string fileName, std::string fileTreatment)
creates rootFile, first parameter is fileName, second one specifies how the file shall be treated.
void addParameters4IntAlgorithms(std::string tcTypeName, std::string algorithmName)
relevant for all algorithms storing one int per TC:
void collectData(const std::vector< AnalizerTCInfo > &tcVector)
take vector and fill for each tcType stored in rootParameterTracker
Storage for (VXD) SpacePoint-based track candidates.
@ c_isActive
bit 11: SPTC is active (i.e.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
static std::string getTypeName(TCType::Type type)
for given TCType the corresponding string-name will be returned.
Definition: TCType.h:62
static bool isValidName(std::string type)
checks if the name given is a valid name for a TCType
Definition: TCType.h:55
std::string m_PARAMlostTCname
the name of the trackCandidateCollection of lost track candidates determined by the TFAnalizer
unsigned int m_eventCounter
knows current event number.
unsigned int m_nMcPXDHits
counts total number of pxdHits added by mcTF.
unsigned int m_nCaSVDHits
counts total number of svdHits added by caTF.
unsigned int m_lostGFTCs
counts number of TCs found by MCTF but lost by VXDTF, they are stored for external tests in storaArra...
std::string m_PARAMreferenceTCname
the name of the storeArray container provided by the reference TF (has to be set manually there and h...
unsigned int m_PARAMminNDFThreshold
defines how many measurements (numbers of degrees of freedom) the TC must have to be accepted as reco...
unsigned int m_nCaPXDHits
counts total number of pxdHits added by caTF.
unsigned int m_mcTrackVectorCounter
another counter of mcTCs, consideres size of datastores containing mcTCs.
unsigned int m_countAcceptedGFTCs
counts number of accepted TCs which are stored in separate container for external tests (e....
unsigned int m_countedCleanRecoveries
counts number of tracks, where no foreign hits were attached ('clean'), does NOT mean that all recons...
unsigned int m_countedReferenceClones
counts number reference TCs which were marked as clones.
StoreArray< SpacePointTrackCand > m_referenceTCs
StoreArray for the reference TCs provided by a reference TF (like trackFinderMCTruth).
unsigned int m_totalRealHits
total number of hits (clusters/2) attached to mcTCs (therefore total number of real hits).
double m_PARAMpurityThreshold
choose value to filter TCs found by VXDTF.
StoreArray< SpacePointTrackCand > m_lostTCs
StoreArray for lost track candidates.
unsigned int m_wrongChargeSignCounter
counts number of times, where assigned caTC guessed wrong sign of charge.
unsigned int m_countedLostTest
counts number of Lost test tcs.
bool m_PARAMignoreDeadTCs
if true, test-tc whose activation-state is set to false are skipped for analysis.
unsigned int m_countedTCsTooShort
counts number of tracks, which did not have enough hits at all.
bool m_PARAMwriteToRoot
if true, analysis data is stored to root file with file name chosen by 'rootFileName'
std::vector< std::string > m_PARAMrootFileName
only two entries accepted, first one is the root filename, second one is 'RECREATE' or 'UPDATE' which...
bool m_PARAMdoEventSummary
if true, for each event a summary will be given (WARNING produces a lot of output!
unsigned int m_caTrackCounter
counts number of tracks reconstructed by the CATF.
RootParameterTracker m_rootParameterTracker
takes care of collecting data and storing it to root branches
std::string m_PARAMacceptedTCname
the name of the trackCandidateCollection of successfully reconstructed track candidates determined by...
unsigned int m_countedContaminatedRecoveries
counts number of tracks, where foreign hits werew attached but its purity was above the threshold.
unsigned int m_nMcSVDHits
counts total number of svdHits added by mcTF.
unsigned int m_countedDoubleEntries
if a TC was found more than once with good (contaminated or clean ones) caTCs, it will be counted to ...
std::vector< std::vector< std::vector< std::string > > > m_PARAMtrackedParametersInt
set here all parameters to be tracked which use an algorithm storing one int per tc.
StoreArray< SpacePointTrackCand > m_testTCs
StoreArray for the TCs provided by a TF to be tested (like VXDTF).
std::string m_PARAMtestTCname
the name of the storeArray container provided by the TF to be evaluated (has to be set manually there...
unsigned int m_mcTrackCounter
counts number of tracks reconstructed by the mcTrackFinder.
StoreArray< SpacePointTrackCand > m_acceptedTCs
StoreArray for accepted/successfully reconstructed track candidates.
std::vector< std::vector< std::vector< std::string > > > m_PARAMtrackedParametersVecDouble
set here all parameters to be tracked which use an algorithm storing one vector< double> per tc.
bool m_PARAMuseMCDataForValues
if true, for testTC the values of attached refTC will be stored instead of own values.
std::vector< std::vector< std::vector< std::string > > > m_PARAMtrackedParametersDouble
set here all parameters to be tracked which use an algorithm storing one double per tc.
PurityType returnDominantParticleID(const std::vector< PurityType > &purities)
of a vector of given particleIDs with their purities it returns the one which had the highest purity
unsigned int m_countedGhosts
counts number of tracks, where a dominating TC was found, but the purity did not reach the threshold.
std::vector< double > m_PARAMorigin
only allowed size: 3.
unsigned int m_countReconstructedTCs
counts number of reconstructed TCs.
unsigned int m_countedPerfectRecoveries
counts number of tracks, where no foreign hits were attached ('clean') AND all hits of the mcTC were ...
unsigned int m_countedLostRef
counts number of Lost reference tcs.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
static std::vector< Belle2::MCVXDPurityInfo > createPurityInfos(const SPContainer *container)
create a vector of MCVXDPurityInfos objects for any given container holding SpacePoints and providing...
Abstract base class for different kinds of events.