Belle II Software  release-06-02-00
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 
13 //tracking:
14 #include <tracking/modules/VXDTFHelperTools/TrackFinderVXDAnalizerModule.h>
15 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
16 #include <tracking/spacePointCreation/PurityCalculatorTools.h>
17 #include <tracking/trackFindingVXD/analyzingTools/AnalizerTCInfo.h>
18 #include <tracking/trackFindingVXD/analyzingTools/AnalyzingAlgorithmFactory.h>
19 #include <tracking/trackFindingVXD/analyzingTools/AlgoritmType.h>
20 
21 //root-stuff
22 #include <TVector3.h>
23 
24 #include <string>
25 
26 
27 
28 using namespace std;
29 using namespace Belle2;
30 using namespace Belle2::Tracking;
31 
32 
33 
34 //-----------------------------------------------------------------
35 // Register the Module
36 //-----------------------------------------------------------------
37 REG_MODULE(TrackFinderVXDAnalizer)
38 
39 //-----------------------------------------------------------------
40 // Implementation
41 //-----------------------------------------------------------------
42 
44 {
45  B2INFO("TrackFinderVXDAnalizer-initialize");
46 
47  vector<string> rootFileNameVals;
48  rootFileNameVals.push_back("TrackFinderVXDAnalizerResults");
49  rootFileNameVals.push_back("RECREATE");
50 
51 
52  vector< vector< vector< string> > > trackedParametersDouble = {
53  { {"Reference"},
54  {"AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI"}
55  },
56  { {"Lost"},
57  {"AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI"}
58  },
59  { {"Contaminated"},
60  {
61  "AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI",
62  "AnalyzingAlgorithmResidualP", "AnalyzingAlgorithmResidualPT", "AnalyzingAlgorithmResidualPTheta", "AnalyzingAlgorithmResidualPPhi", "AnalyzingAlgorithmResidualPTAngle"
63  }
64  },
65  { {"Clean"},
66  {
67  "AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI",
68  "AnalyzingAlgorithmResidualP", "AnalyzingAlgorithmResidualPT", "AnalyzingAlgorithmResidualPTheta", "AnalyzingAlgorithmResidualPPhi", "AnalyzingAlgorithmResidualPTAngle"
69  }
70  },
71  { {"Perfect"},
72  {
73  "AnalyzingAlgorithmValueP", "AnalyzingAlgorithmValuePT", "AnalyzingAlgorithmValuePTheta", "AnalyzingAlgorithmValuePPhi", "AnalyzingAlgorithmValueDistSeed2IPXY", "AnalyzingAlgorithmValueDistSeed2IPZ", "AnalyzingAlgorithmValueQI",
74  "AnalyzingAlgorithmResidualP", "AnalyzingAlgorithmResidualPT", "AnalyzingAlgorithmResidualPTheta", "AnalyzingAlgorithmResidualPPhi", "AnalyzingAlgorithmResidualPTAngle"
75  }
76  },
77  };
78 
79  vector< vector< vector< string> > > trackedParametersInt = {
80  { {"Reference"},
81  {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters"}
82  },
83  { {"Lost"},
84  {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters"}
85  },
86  { {"Contaminated"},
87  {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters", "AnalyzingAlgorithmLostUClusters", "AnalyzingAlgorithmLostVClusters"}
88  },
89  { {"Clean"},
90  {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters", "AnalyzingAlgorithmLostUClusters", "AnalyzingAlgorithmLostVClusters"}
91  },
92  { {"Perfect"},
93  {"AnalyzingAlgorithmTotalUClusters", "AnalyzingAlgorithmTotalVClusters", "AnalyzingAlgorithmLostUClusters", "AnalyzingAlgorithmLostVClusters"}
94  }
95  };
96 
97 
98  vector< vector< vector< string> > > trackedParametersVecDouble = {
99  { {"Reference"},
100  {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep"}
101  },
102  { {"Lost"},
103  {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep"}
104  },
105  { {"Contaminated"},
106  {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep", "AnalyzingAlgorithmLostUEDep", "AnalyzingAlgorithmLostVEDep"}
107  },
108  { {"Clean"},
109  {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep", "AnalyzingAlgorithmLostUEDep", "AnalyzingAlgorithmLostVEDep"}
110  },
111  { {"Perfect"},
112  {"AnalyzingAlgorithmTotalUEDep", "AnalyzingAlgorithmTotalVEDep", "AnalyzingAlgorithmLostUEDep", "AnalyzingAlgorithmLostVEDep"}
113  }
114  };
115 
116  //Set module properties
117  setDescription("analyzes quality of SpacePointTrackCands delivered by a test-TF compared to a reference TF");
118  setPropertyFlags(c_ParallelProcessingCertified);
119 
120 
121  addParam("referenceTCname", m_PARAMreferenceTCname, "the name of the storeArray container provided by the reference TF",
122  string("mcTracks"));
123  addParam("testTCname", m_PARAMtestTCname, "the name of the storeArray container provided by the TF to be evaluated", string(""));
124  addParam("acceptedTCname", m_PARAMacceptedTCname, "special name for accepted/successfully reconstructed track candidates",
125  string("acceptedVXDTFTracks"));
126  addParam("lostTCname", m_PARAMlostTCname, "special name for lost track candidates", string("lostTracks"));
127  addParam("purityThreshold", m_PARAMpurityThreshold,
128  " chose value to filter TCs found by Test TF. TCs having purities lower than this value won't be marked as reconstructed",
129  double(0.7));
130  addParam("minNDFThreshold", m_PARAMminNDFThreshold,
131  " defines how many measurements (numbers of degrees of freedom) the TC must have to be accepted as reconstructed, standard is 5",
132  unsigned(5));
133 
134  addParam("writeToRoot", m_PARAMwriteToRoot,
135  " if true, analysis data is stored to root file with file name chosen by 'rootFileName'", bool(true));
136  addParam("rootFileName", m_PARAMrootFileName,
137  " 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 ",
138  rootFileNameVals);
139 
140  addParam("trackedParametersDouble", m_PARAMtrackedParametersDouble,
141  "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",
142  trackedParametersDouble);
143 
144  addParam("trackedParametersInt", m_PARAMtrackedParametersInt,
145  "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",
146  trackedParametersInt);
147 
148  addParam("trackedParametersVecDouble", m_PARAMtrackedParametersVecDouble,
149  "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",
150  trackedParametersVecDouble);
151 
152 
153  addParam("origin", m_PARAMorigin, " only allowed size: 3. stores coordinates of the origin used", {0, 0, 0});
154  addParam("useMCDataForValues", m_PARAMuseMCDataForValues,
155  "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."
156  , bool(true));
157 
158  addParam("ignoreDeadTCs", m_PARAMignoreDeadTCs,
159  " if true, test-tc whose activation-state is set to false are skipped for analysis", bool(true));
160 
161  addParam("doEventSummary", m_PARAMdoEventSummary,
162  "if true, for each event a summary will be given (WARNING produces a lot of output!", bool(false));
163 }
164 
165 
166 void TrackFinderVXDAnalizerModule::initialize()
167 {
168  m_referenceTCs.isRequired(m_PARAMreferenceTCname);
169  m_testTCs.isRequired(m_PARAMtestTCname);
170  m_acceptedTCs.registerInDataStore(m_PARAMacceptedTCname, DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered);
171  m_lostTCs.registerInDataStore(m_PARAMlostTCname, DataStore::c_DontWriteOut | DataStore::c_ErrorIfAlreadyRegistered);
172 
173 
174  if (m_PARAMorigin.size() != 3) {
175  B2ERROR("TrackFinderVXDAnalizerModule::initialize() passed parameter 'origin' has wrong number of entries (allowed: 3) of " <<
176  m_PARAMorigin.size() << " reset to standard (0, 0, 0)");
177  m_PARAMorigin = {0, 0, 0};
178  }
179 
180  // deal with root-related stuff
181  if (m_PARAMwriteToRoot == false) { return; }
182 
183  if ((m_PARAMrootFileName.size()) != 2) {
184  string output;
185  for (string& entry : m_PARAMrootFileName) {
186  output += "'" + entry + "' ";
187  }
188  B2FATAL("TrackFinderVXDAnalizer::initialize(), rootFileName is set wrong, although parameter 'writeToRoot' is enabled! Actual entries are: "
189  << output);
190  }
191 
192  // deal with algorithms:
193  m_rootParameterTracker.initialize(m_PARAMrootFileName[0] + ".root", m_PARAMrootFileName[1]);
194  // typedef for increased readability:
197  using AlgorithmVecDouble = AnalyzingAlgorithmBase<vector<double>, AnalizerTCInfo, TVector3>;
198 
199 
200  // prepare all algorithms which store a double per tc:
201  for (auto& parameterPackage : m_PARAMtrackedParametersDouble) {
202  // check if parameterPackage has two entries: first is TCType, second is vector of algorithms
203  if (parameterPackage.size() != 2) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
204 
205  // check if vector for tcType is really only one entry
206  if (parameterPackage.front().size() != 1) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
207 
208  std::string tcTypeName = parameterPackage.front()[0];
209  if (TCType::isValidName(tcTypeName) == false)
210  { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (invalid tcType: " << tcTypeName << ")"); }
211 
212  // for each algorithm, store a branch:
213  for (auto& algorithm : parameterPackage.back()) {
214  if (AlgoritmType::isValidName(algorithm) == false)
215  { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersDouble' was mis-used! Please read the documentation! (invalid algorithmType: " << algorithm << ")"); }
216  m_rootParameterTracker.addParameters4DoubleAlgorithms(tcTypeName, algorithm);
217  }
218  }
219  AlgorithmDouble::setOrigin(TVector3(m_PARAMorigin[0], m_PARAMorigin[1], m_PARAMorigin[2]));
220  AlgorithmDouble::setWillRefTCdataBeUsed4TestTCs(m_PARAMuseMCDataForValues);
221 
222  // prepare all algorithms which store an int per tc:
223  for (auto& parameterPackage : m_PARAMtrackedParametersInt) {
224  // check if parameterPackage has two entries: first is TCType, second is vector of algorithms
225  if (parameterPackage.size() != 2) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
226 
227  // check if vector for tcType is really only one entry
228  if (parameterPackage.front().size() != 1) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
229 
230  std::string tcTypeName = parameterPackage.front()[0];
231  if (TCType::isValidName(tcTypeName) == false)
232  { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (invalid tcType: " << tcTypeName << ")"); }
233 
234  // for each algorithm, store a branch:
235  for (auto& algorithm : parameterPackage.back()) {
236  if (AlgoritmType::isValidName(algorithm) == false)
237  { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersInt' was mis-used! Please read the documentation! (invalid algorithmType: " << algorithm << ")"); }
238  m_rootParameterTracker.addParameters4IntAlgorithms(tcTypeName, algorithm);
239  }
240  }
241  AlgorithmInt::setOrigin(TVector3(m_PARAMorigin[0], m_PARAMorigin[1], m_PARAMorigin[2]));
242  AlgorithmInt::setWillRefTCdataBeUsed4TestTCs(m_PARAMuseMCDataForValues);
243 
244  // prepare all algorithms which store a vector< double> per tc:
245  for (auto& parameterPackage : m_PARAMtrackedParametersVecDouble) {
246  // check if parameterPackage has two entries: first is TCType, second is vector of algorithms
247  if (parameterPackage.size() != 2) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
248 
249  // check if vector for tcType is really only one entry
250  if (parameterPackage.front().size() != 1) { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (wrong number of added parameters)"); }
251 
252  std::string tcTypeName = parameterPackage.front()[0];
253  if (TCType::isValidName(tcTypeName) == false)
254  { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (invalid tcType: " << tcTypeName << ")"); }
255 
256  // for each algorithm, store a branch:
257  for (auto& algorithm : parameterPackage.back()) {
258  if (AlgoritmType::isValidName(algorithm) == false)
259  { B2FATAL("TrackFinderVXDAnalizer::initialize(), parameter 'trackedParametersVecDouble' was mis-used! Please read the documentation! (invalid algorithmType: " << algorithm << ")"); }
260  m_rootParameterTracker.addParameters4VecDoubleAlgorithms(tcTypeName, algorithm);
261  }
262  }
263  AlgorithmVecDouble::setOrigin(TVector3(m_PARAMorigin[0], m_PARAMorigin[1], m_PARAMorigin[2]));
264  AlgorithmVecDouble::setWillRefTCdataBeUsed4TestTCs(m_PARAMuseMCDataForValues);
265 }
266 
267 
268 void TrackFinderVXDAnalizerModule::event()
269 {
270 
271  StoreObjPtr<EventMetaData> eventMetaDataPtr("EventMetaData", DataStore::c_Event);
272  m_eventCounter = eventMetaDataPtr->getEvent();
273  B2DEBUG(10, "################## entering TrackFinderVXDAnalizerModule - event " << m_eventCounter << " ######################");
274 
275  int nReferenceTCs = m_referenceTCs.getEntries();
276  m_mcTrackCounter += nReferenceTCs;
277  m_mcTrackVectorCounter += nReferenceTCs; // WARNING temporal solution!
278  int nTestTCs = m_testTCs.getEntries();
279  m_caTrackCounter += nTestTCs;
280 
281 
283  unsigned nTC = 0;
284  vector<AnalizerTCInfo> referenceTCVector;
285  for (SpacePointTrackCand& aTC : m_referenceTCs) {
286  vector<MCVXDPurityInfo > purities = createPurityInfos(aTC);
287 
288  MCVXDPurityInfo particleInfo = returnDominantParticleID(purities);
289  B2DEBUG(25, "Calculating purities for reference TC " << nTC << ", name. Dominating iD " << particleInfo.getParticleID() <<
290  " with purity " << particleInfo.getPurity().second << " was found among " << purities.size() << " assigned particles");
291 
292  AnalizerTCInfo referenceTC = AnalizerTCInfo::createTC(true, particleInfo, aTC);
293  referenceTCVector.push_back(referenceTC);
294  nTC++;
295 
296  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 1, PACKAGENAME())) { aTC.print(1); }
297  }
298 
299 
301  nTC = 0;
302  vector<AnalizerTCInfo> testTCVector;
303  for (SpacePointTrackCand& aTC : m_testTCs) {
304  if (m_PARAMignoreDeadTCs and aTC.hasRefereeStatus(SpacePointTrackCand::c_isActive) == false) { continue; }
305  vector<MCVXDPurityInfo > purities = createPurityInfos(aTC);
306 
307  MCVXDPurityInfo particleInfo = returnDominantParticleID(purities);
308  B2DEBUG(25, "Calculating purities for test TC " << nTC << ", name. Dominating iD " << particleInfo.getParticleID() <<
309  " with purity" << particleInfo.getPurity().second << " was found among " << purities.size() << " assigned particles");
310 
311  AnalizerTCInfo testTC = AnalizerTCInfo::createTC(false, particleInfo, aTC);
312  testTCVector.push_back(testTC);
313  nTC++;
314 
315  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 1, PACKAGENAME())) { aTC.print(1); }
316  }
317 
318 
326  vector<std::pair<AnalizerTCInfo*, AnalizerTCInfo*> > pairedTCs;
327  for (AnalizerTCInfo& testTC : testTCVector) {
328  int testID = testTC.assignedID.getParticleID();
329 
330  for (AnalizerTCInfo& referenceTC : referenceTCVector) {
331  int refID = referenceTC.assignedID.getParticleID();
332  B2DEBUG(50, "test TC with assigned ID " << testID << " was matched with refID " << refID);
333  if (refID != testID) continue;
334 
335  testTC.tcType = AnalizerTCInfo::classifyTC(referenceTC, testTC, m_PARAMpurityThreshold, m_PARAMminNDFThreshold);
336 
337  B2DEBUG(50, "test TC with assigned ID " << testID <<
338  " was classified for the corresponding with type for testTC/refTC: " << TCType::getTypeName(testTC.tcType) <<
339  "/" << TCType::getTypeName(referenceTC.tcType) << " and will now paired up");
340 
341  referenceTC.pairUp(&testTC);
342 
343  pairedTCs.push_back({ &testTC, &referenceTC});
344  }
345  }
346 
348  AnalizerTCInfo::markUnused(testTCVector, TCType::Ghost);
349 
351  AnalizerTCInfo::markUnused(referenceTCVector, TCType::Lost);
352 
353 
355  // good cases:
356  unsigned int nPerfectTCs = 0, nCleanTCs = 0, nContaminatedTCs = 0, nFound = 0;
357  // not so good cases:
358  unsigned int nClonedTCs = 0, nSmallTCs = 0, nGhostTCs = 0, nLostTestTCs = 0, nLostRefTCs = 0;
359  // bad cases: counts nTimes when the TC could not be identified/classified at all
360  unsigned int nBadCases = 0, nRefClones = 0; // refClones, cases when reference TCs were marked as clones
361  // hitCounters:
362  unsigned int refPXDClusters = 0, refSVDClusters = 0, testPXDClusters = 0, testSVDClusters = 0;
363 
364  for (AnalizerTCInfo& aTC : testTCVector) {
365  testPXDClusters += aTC.assignedID.getNPXDClustersTotal();
366  testSVDClusters += aTC.assignedID.getNSVDUClustersTotal() + aTC.assignedID.getNSVDVClustersTotal();
367 
368  switch (aTC.tcType) {
369  case TCType::Perfect: { nPerfectTCs++; nFound++; break; }
370  case TCType::Clean: { nCleanTCs++; nFound++; break; }
371  case TCType::Contaminated: { nContaminatedTCs++; nFound ++; break; }
372  case TCType::Clone: { nClonedTCs++; break; }
373  case TCType::SmallStump: { nSmallTCs++; break; }
374  case TCType::Ghost: { nGhostTCs++; break; }
375  case TCType::Lost: { nLostTestTCs++; break; }
376  default: {
377  nBadCases++;
378  B2WARNING("TrackFinderVXDAnalizer::event(): test TC got type " << TCType::getTypeName(aTC.tcType) <<
379  " which is not counted for efficiency-calculation");
380  }
381  }
382  }
383 
384  for (AnalizerTCInfo& aTC : referenceTCVector) {
385  refPXDClusters += aTC.assignedID.getNPXDClustersTotal();
386  refSVDClusters += aTC.assignedID.getNSVDUClustersTotal() + aTC.assignedID.getNSVDVClustersTotal();
387 
388  switch (aTC.tcType) {
389  case TCType::Reference: { break; }
390  case TCType::Clone: { nRefClones++; break; }
391  case TCType::Lost: { nLostRefTCs++; break; }
392  default: {
393  nBadCases++;
394  B2WARNING("TrackFinderVXDAnalizer::event(): reference TC got type " << TCType::getTypeName(aTC.tcType) <<
395  " which is not counted for efficiency-calculation");
396  }
397  }
398  }
399 
400 
402  string summary1 = "TrackFinderVXDAnalizer-Event " + to_string(m_eventCounter) +
403  ": the tested TrackFinder found: " +
404  " IDs (total/perfect/clean/contaminated/clone/tooShort/ghost: " + to_string(nFound) +
405  "/" + to_string(nPerfectTCs) +
406  "/" + to_string(nCleanTCs) +
407  "/" + to_string(nContaminatedTCs) +
408  "/" + to_string(nClonedTCs) +
409  "/" + to_string(nSmallTCs) +
410  "/" + to_string(nGhostTCs) +
411  ") within " + to_string(nTestTCs) +
412  " TCs and lost (test/ref) " + to_string(nLostTestTCs) +
413  "/" + to_string(nLostRefTCs) +
414  " TCs. nBadCases: " + to_string(nBadCases) +
415  " refClones: " + to_string(nRefClones) +
416  "\n" +
417  "There are " + to_string(nReferenceTCs) +
418  " referenceTCs, with mean of " + to_string((float(refPXDClusters) / float(nReferenceTCs))) +
419  "/" + to_string((float(refSVDClusters) / float(nReferenceTCs))) + " PXD/SVD clusters"
420  "\n" +
421  "There are " + to_string(nTestTCs) +
422  " testTCs, with mean of " + to_string((float(testPXDClusters) / float(nTestTCs))) +
423  "/" + to_string((float(testSVDClusters) / float(nTestTCs))) + " PXD/SVD clusters";
424 
425  string summary2 = "TrackFinderVXDAnalizer-Event " + to_string(m_eventCounter) +
426  ": the tested TrackFinder had an efficiency : total/perfect/clean/contaminated/clone/tooShort/ghost: " +
427  to_string(double(100 * nFound) / double(nReferenceTCs)) +
428  "%/" + to_string(double(100 * nPerfectTCs) / double(nReferenceTCs)) +
429  "%/" + to_string(double(100 * nCleanTCs) / double(nReferenceTCs)) +
430  "%/" + to_string(double(100 * nContaminatedTCs) / double(nReferenceTCs)) +
431  "%/" + to_string(double(100 * nClonedTCs) / double(nReferenceTCs)) +
432  "%/" + to_string(double(100 * nSmallTCs) / double(nReferenceTCs)) +
433  "%/" + to_string(double(100 * nGhostTCs) / double(nReferenceTCs)) + "%";
434 
435  string summary3 = "TrackFinderVXDAnalizer-Event " + to_string(m_eventCounter) +
436  ": totalCA|totalMC|ratio of pxdHits " + to_string(testPXDClusters) +
437  "|" + to_string(refPXDClusters) +
438  "|" + to_string(float(testPXDClusters) / float(refPXDClusters)) +
439  ", svdHits " + to_string(testSVDClusters) +
440  "|" + to_string(refSVDClusters) +
441  "|" + to_string(float(testSVDClusters) / float(refSVDClusters)) + " found by the two TFs";
442 
443  if (m_PARAMdoEventSummary) {
444  B2INFO(summary1);
445  B2INFO(summary2);
446  B2INFO(summary3);
447  } else {
448  B2DEBUG(10, summary1);
449  B2DEBUG(10, summary2);
450  B2DEBUG(10, summary3);
451  }
452 
453  m_totalRealHits += refPXDClusters + refSVDClusters;
454  m_nCaPXDHits += testPXDClusters;
455  m_nMcPXDHits += refPXDClusters;
456  m_nCaSVDHits += testSVDClusters;
457  m_nMcSVDHits += refSVDClusters;
458  m_countReconstructedTCs += nFound;
459  m_countedPerfectRecoveries += nPerfectTCs;
460  m_countedCleanRecoveries += nCleanTCs;
461  m_countedContaminatedRecoveries += nContaminatedTCs;
462  m_countedDoubleEntries += nClonedTCs;
463  m_countedTCsTooShort += nSmallTCs;
464  m_countedGhosts += nGhostTCs;
465  m_countedLostTest += nLostTestTCs;
466  m_countedLostRef += nLostRefTCs;
467  m_countedReferenceClones += nRefClones;
468 
469 
470  // TODO:
484 // int acceptedTCs = m_acceptedTCs.getEntries();
485 // m_countAcceptedGFTCs += acceptedTCs;
486 // m_lostGFTCs += nLostTCs;
487 // B2DEBUG(1, " of " << nTestTCs << " TCs produced by the tested TrackFinder, " << acceptedTCs <<
488 // " were recognized safely and stored into the container of accepted TCs, " << nLostTCs <<
489 // " were lost and their MCTF-TCs were stored in lostTCs")
490 // for (unsigned int ID : foundIDs) {
491 // B2DEBUG(1, " - ID " << ID << " recovered")
492 // }
493 
494 
495  if (m_PARAMwriteToRoot == false) { return; }
497  // TODO:
498 
499  m_rootParameterTracker.collectData(testTCVector);
500  m_rootParameterTracker.collectData(referenceTCVector);
501 
502  m_rootParameterTracker.fillRoot();
503 
504 }
505 
506 
507 void TrackFinderVXDAnalizerModule::endRun()
508 {
509  B2INFO("------------- >>>TrackFinderVXDAnalizerModule::endRun<<< -------------");
510  B2DEBUG(1, "TrackFinderVXDAnalizerModule-explanation: \n" <<
511  " perfect recovery means: all hits of mc-TC found again and clean TC. \n" <<
512  " clean recovery means: no foreign hits within TC. \n" <<
513  " ghost means: QI was below threshold or mcTC was found more than once (e.g. because of curlers) \n" <<
514  " 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");
515 
516  B2INFO("TrackFinderVXDAnalizerModule: After " << m_eventCounter + 1 << " events there was a total number of " << m_mcTrackCounter <<
517  " mcTrackCandidates and " << m_totalRealHits << " realHits. Of these TCs, " << m_mcTrackVectorCounter <<
518  " mcTrackCandidates where used for analysis because of cutoffs.");
519  B2INFO("TrackFinderVXDAnalizerModule: There were " << m_caTrackCounter << " caTrackCandidates, of those " << m_countAcceptedGFTCs <<
520  " were stored in " << m_PARAMacceptedTCname << " and " << m_lostGFTCs << " lost TCs were stored in " << m_PARAMlostTCname <<
521  " for further use, number of times where charge was guessed wrong: " << m_wrongChargeSignCounter <<
522  ", number of caTCs which produced a double entry: " << m_countedDoubleEntries);
523  B2INFO("TrackFinderVXDAnalizerModule: totalCA|totalMC|ratio of pxdHits " << m_nCaPXDHits << "|" << m_nMcPXDHits << "|" << float(
524  m_nCaPXDHits) / float(m_nMcPXDHits) <<
525  ", svdHits " << m_nCaSVDHits << "|" << m_nMcSVDHits << "|" << float(m_nCaSVDHits) / float(m_nMcSVDHits) <<
526  " found by the two TFs (ghost hits not removed, therefore only useful if ghost-rate is low)");
527 
528  B2INFO("TrackFinderVXDAnalizerModule: the VXDTF found:\n" <<
529  "Absolute numbers: total/perfect/clean/contaminated/clone/tooShort/ghost: " << m_countReconstructedTCs <<
530  "/" << m_countedPerfectRecoveries <<
531  "/" << m_countedCleanRecoveries <<
532  "/" << m_countedContaminatedRecoveries <<
533  "/" << m_countedDoubleEntries <<
534  "/" << m_countedTCsTooShort <<
535  "/" << m_countedGhosts <<
536  " efficiency : total/perfect/clean/contaminated/clone/tooShort/ghost: " << double(100 * m_countReconstructedTCs) / double(
537  m_mcTrackVectorCounter) <<
538  "%/" << double(100 * m_countedPerfectRecoveries) / double(m_mcTrackVectorCounter) <<
539  "%/" << double(100 * m_countedCleanRecoveries) / double(m_mcTrackVectorCounter) <<
540  "%/" << double(100 * m_countedContaminatedRecoveries) / double(m_mcTrackVectorCounter) <<
541  "%/" << double(100 * m_countedDoubleEntries) / double(m_mcTrackVectorCounter) <<
542  "%/" << double(100 * m_countedTCsTooShort) / double(m_mcTrackVectorCounter) <<
543  "%/" << double(100 * m_countedGhosts) / double(m_mcTrackVectorCounter) <<
544  "%");
545 
546  B2INFO("TrackFinderVXDAnalizerModule: additional numbers:\"" <<
547  "nCountedLost (test/ref): " << m_countedLostTest <<
548  "/" << m_countedLostRef <<
549  ", nRefClones: " << m_countedReferenceClones <<
550  ", in percent - nLost (test/ref): " << double(100 * m_countedLostTest) / double(m_mcTrackVectorCounter) <<
551  "/" << double(100 * m_countedLostRef) / double(m_mcTrackVectorCounter) <<
552  "%, nClones: " << double(100 * m_countedReferenceClones) / double(m_mcTrackVectorCounter) <<
553  "%");
555 // B2INFO("TFAnalizerModule: the VXDTF found (total/perfect/clean/ghost)" << m_countReconstructedTCs << "/" <<
556 // m_countedPerfectRecoveries << "/" << m_countedCleanRecoveries << "/" << (m_caTrackCounter - m_countReconstructedTCs) <<
557 // " TCs -> efficiency(total/perfect/clean/ghost): " << double(100 * m_countReconstructedTCs) / double(
558 // m_mcTrackVectorCounter) << "%/" << double(100 * m_countedPerfectRecoveries) / double(m_mcTrackVectorCounter) << "%/" << double(
559 // 100 * m_countedCleanRecoveries) / double(m_mcTrackVectorCounter) << "%/" << double(100 * (m_caTrackCounter -
560 // m_countReconstructedTCs)) / double(m_countReconstructedTCs) << "%")
561 }
562 
563 
564 void TrackFinderVXDAnalizerModule::terminate()
565 {
566 
567  if (m_PARAMwriteToRoot == false) { return; }
568  m_rootParameterTracker.terminate();
569 }
570 
571 
simple class storing infos relevant for a TC for analizing it.
Base class for storing an algorithm determining the data one wants to have.
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
Storage for (VXD) SpacePoint-based track candidates.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
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.