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