Belle II Software  release-05-02-19
SpacePoint2TrueHitConnectorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Madlener *
7  * *
8  **************************************************************************/
9 
10 #include <tracking/modules/spacePointCreator/SpacePoint2TrueHitConnectorModule.h>
11 #include <framework/datastore/StoreObjPtr.h>
12 #include <framework/dataobjects/EventMetaData.h>
13 #include <framework/core/Environment.h> // getNumberProcesses
14 
15 #include <pxd/dataobjects/PXDCluster.h>
16 #include <svd/dataobjects/SVDCluster.h>
17 #include <mdst/dataobjects/MCParticle.h>
18 
19 #include <string>
20 #include <vector>
21 #include <cmath>
22 
23 #include <algorithm>
24 #include <unordered_map>
25 #include <tracking/spacePointCreation/MapHelperFunctions.h> // map helper stuff
26 
27 #include <TFile.h>
28 #include <TTree.h>
29 #include <TVector3.h>
30 
31 using namespace Belle2;
32 using namespace std;
33 
34 
35 REG_MODULE(SpacePoint2TrueHitConnector) // register the modules
36 
38  Module()
39 {
40  setDescription("Module that tries to find the appropriate TrueHit to each SpacePoint and to register a relation between them for making MC information for SpacePoints more easily accesible for Modules that need it. Module can also be used to filter out 'fishy' SpacePoints.");
42 
43  addParam("storeSeperate", m_PARAMstoreSeparate,
44  "Set to false if you do not want to create seperate StoreArrays for processed SpacePoints. (i.e. a relation from SpacePoint to TrueHit will be set in the passed StoreArray. NOTE: this StoreArray will contain SpacePoints with a relation to TrueHits and such without after this module). The Names of the output StoreArrays will be the names of the input StoreArrays with 'outputSuffix' (module parameter) appended to them",
45  true);
46 
47  addParam("registerAll", m_PARAMregisterAll,
48  "If set to true, the module simply registers a relation for all TrueHits that are related to a SpacePoint (resp. its Clusters). In this way the module can be used to find all related TrueHits and then the user can decide what to do with these TrueHits (otherwise this module does some decision making). Setting this to true means that all checks (e.g. 'minWeight', 'maxPosSigma', ...) are ommitted! NOTE that some of the information is lost in this way (e.g. how many of the Clusters of a SpacePoint have been related to a TrueHit)!",
49  false);
50 
51  addParam("positionAnalysis", m_PARAMpositionAnalysis,
52  "Analyze the positions of SpacePoints and corresponding TrueHits. NOTE: if enabled a root file gets created!", false);
53 
54  addParam("requirePrimary", m_PARAMrequirePrimary,
55  "Set to true if only relations to TrueHits that are related to a primary particle should get registered.", false);
56 
57  addParam("requireProximity", m_PARAMrequireProximity,
58  "Require that the TrueHit is close to the SpacePoint (in local coordinates). The meaning of 'close' can be defined with the parameters 'maxPosSigma' and 'maxGlobalPosDiff'.",
59  true);
60 
61  std::vector<std::string> defaultInList; // default list for input StoreArrays
62  defaultInList.push_back(std::string(""));
63  addParam("TrueHitNames", m_PARAMtrueHitNames,
64  "Container names of TrueHits. NOTE: need one name per 'DetectorType' (i.e. unique entries in 'DetectorType)!", defaultInList);
65  addParam("SpacePointNames", m_PARAMspacePointNames, "Container names of SpacePoints.", {"SVDSpacePoints", "PXDSpacePoints"});
66  addParam("DetectorTypes", m_PARAMdetectorTypes,
67  "detector types to determine which entries in 'TrueHitNames' and 'SpacePointNames' belong to which detector type. Entries have to be 'SVD' or 'PXD'. NOTE: if more 'SpacePointNames' than 'DetectorTypes' get passed, the last entry in 'DetectorTypes' is assumed to be valid for all remaining 'SpacePointNames'!");
68  addParam("ClusterNames", m_PARAMclusterNames,
69  "Container names of Clusters. NOTE: need one name per 'DetectorType' (i.e. unique entries in 'DetectorType')!", defaultInList);
70 
71  std::vector<std::string> defaultRootFName = { "PositionAnalysis", "RECREATE" };
72  addParam("rootFileName", m_PARAMrootFileName,
73  "Filename and write-mode ('RECREATE' or 'UPDATE'). If given more than 2 strings this module will cause termination",
74  defaultRootFName);
75 
76  addParam("outputSuffix", m_PARAMoutputSuffix,
77  "Suffix that will be appended to the container names if 'storeSeperate' is set to true", std::string("_relTH"));
78 
79  addParam("maxGlobalPosDiff", m_PARAMmaxGlobalDiff,
80  "max difference of global position coordinates between TrueHit and SpacePoint (in each direction) in cm.", 0.05);
81 // addParam("maxLocalPosDiff", m_PARAMmaxLocalDiff, "max difference of local position coordinates between TrueHit and SpacePoint (in U & V direction) in cm. NOTE: the default value is still subject to tuning and finding the appropriate value!", 0.01);
82 
83  addParam("maxPosSigma", m_PARAMmaxPosSigma, "Define the maximum local position difference in units of PitchSize / sqrt(12).", 4.);
84  addParam("minWeight", m_PARAMminWeight,
85  "Define a minimal weight a relation between a Cluster and a TrueHit has to have for the TrueHit to be considered as possible candidate.",
86  0.);
87 
88  // initialize all counters
90  m_rootFilePtr = nullptr;
91  m_treePtr = nullptr;
92 
93  if (m_PARAMpositionAnalysis == true and Environment::Instance().getNumberProcesses() > 0) {
94  B2WARNING(
95  "SpacePoint2TrueHitConnector::initialize: parameter positionAnalysis (and therefore root-output) is enabled and basf2 is running in multi-threaded mode - this can cause nondeterministic behavior! "
96  << "\n"
97  << " you can suppress multi-threading for this module by writing:"
98  << "\n"
99  << "main.add_module('SpacePoint2TrueHitConnector').set_property_flags(0) "
100  << "\n"
101  << "into the steering file!");
102  }
103 }
104 
105 // ================================================================ INITIALIZE ====================================================
107 {
108  B2INFO("SpacePoint2TrueHitConnector -------------------------- initialize --------------------------------");
109 
110  m_nContainers = m_PARAMspacePointNames.size(); // get number of passed arrays
111  unsigned int nTHNames = m_PARAMtrueHitNames.size();
112  unsigned int nDetTypes = m_PARAMdetectorTypes.size();
113  unsigned int nClNames = m_PARAMclusterNames.size();
114  if (m_nContainers < nTHNames || m_nContainers < nDetTypes || m_nContainers < nClNames) {
115  B2FATAL("Passed " << nTHNames << " TrueHitNames and " << nDetTypes << " DetectorTypes but number of passed SpacePointArrays is " <<
116  m_nContainers);
117  }
118  if ((nTHNames != nDetTypes) || (nClNames != nTHNames)) {
119  B2FATAL("Passed " << nTHNames << " TrueHitNames and " << nClNames << "ClusterNames but " << nDetTypes << " DetectorTypes!");
120  }
121 
122  for (unsigned int i = 0; i < m_nContainers; ++i) {
123  if (i < nDetTypes) { // handle the detector types
124  std::string detType = m_PARAMdetectorTypes.at(i);
125  if (detType.compare(std::string("SVD")) != 0 && detType.compare(std::string("PXD")) != 0) {
126  B2FATAL("Found entry " << detType << " in DetectorTypes, but only 'PXD' and 'SVD' are allowed!");
127  }
128  if (detType.compare(std::string("SVD")) == 0) {
129  m_detectorTypes.push_back(c_SVD);
131  m_SVDTrueHits.isRequired();
133  m_SVDClusters.isRequired();
134  } else {
135  m_detectorTypes.push_back(c_PXD);
137  m_PXDTrueHits.isRequired();
139  m_PXDClusters.isRequired();
140  }
141  } else { m_detectorTypes.push_back(m_detectorTypes.at(i - 1)); } // add the last entry again
142 
144  m_inputSpacePoints.at(i).first.isRequired();
145 
146  // add counters
147  m_SpacePointsCtr.push_back(0);
148  m_nRelTrueHitsCtr.push_back(array<unsigned int, 5>());
149  m_noClusterCtr.push_back(0);
150  m_noTrueHitCtr.push_back(0);
151  m_regRelationsCtr.push_back(0);
152  m_ghostHitCtr.push_back(0);
153  m_rejectedRelsCtr.push_back(0);
154  }
155 
156  if (m_PARAMstoreSeparate) {
157  if (m_PARAMoutputSuffix.empty()) {
158  B2WARNING("'outputSuffix' is empty and 'storeSeperate' is set to true. This would lead to StoreArrays with the same name. Resetting to 'outputSuffix' to '_relTH'!");
159  m_PARAMoutputSuffix = "_relTH";
160  }
161 
162  for (unsigned int i = 0; i < m_nContainers; ++i) {
163  std::string name = m_inputSpacePoints.at(i).first.getName() + m_PARAMoutputSuffix;
166 
167  // register relations (detector dependent)
168  if (m_inputSpacePoints.at(i).second == c_SVD) {
171  } else {
174  }
175  }
176  } else {
177  for (unsigned int i = 0; i < m_nContainers; ++i) {
178  if (m_inputSpacePoints.at(i).second == c_SVD) {
180  } else {
182  }
183  }
184  }
185 
186  m_maxGlobalDiff = m_PARAMmaxGlobalDiff * m_PARAMmaxGlobalDiff; // only comparing squared values in module!
187 // m_PARAMmaxLocalDiff *= m_PARAMmaxLocalDiff;
188 
189  if (m_PARAMmaxPosSigma < 0) {
190  B2WARNING("'maxPosSigma' is set to a value below 0: " << m_PARAMmaxPosSigma << "! Resetting to default (4)!");
191  m_PARAMmaxPosSigma = 4.;
192  }
193 
195 }
196 
197 // ========================================================== EVENT ===============================================================
199 {
200  StoreObjPtr<EventMetaData> eventMetaDataPtr("EventMetaData", DataStore::c_Event);
201  const int eventCtr = eventMetaDataPtr->getEvent();
202  B2DEBUG(10, "SpacePoint2TrueHitConnector::event(). Processing event " << eventCtr << " -----------------------");
203 
204  if (m_PARAMpositionAnalysis) m_rootVariables = RootVariables(); // clear the rootVariables for every event
205 
206  // loop over all containers
207  for (m_iCont = 0; m_iCont < m_nContainers; ++m_iCont) {
208  StoreArray<SpacePoint> spacePoints = m_inputSpacePoints.at(m_iCont).first;
209  const int nSpacePoints = spacePoints.getEntries();
210  e_detTypes detType = m_inputSpacePoints.at(m_iCont).second;
211  std::string detTypeStr = detType == c_SVD ? "SVD" : "PXD";
212  B2DEBUG(10, "Found " << nSpacePoints << " SpacePoints in Array " << m_inputSpacePoints.at(m_iCont).first.getName() <<
213  " for this event. detType: " << detTypeStr);
214 
215  m_SpacePointsCtr.at(m_iCont) += nSpacePoints;
216 
217  for (int iSP = 0; iSP < nSpacePoints; ++iSP) {
218  SpacePoint* spacePoint = spacePoints[iSP];
219  B2DEBUG(49, "Processing SpacePoint " << iSP << " from " << nSpacePoints);
220 
221  baseMapT trueHitMap = processSpacePoint<baseMapT>(spacePoint, detType);
222  if (trueHitMap.empty()) continue; // next SpacePoint if something went wrong
223 
224  unsigned int nUniqueTHs = getUniqueSize(trueHitMap);
225  B2DEBUG(50, "Found " << nUniqueTHs << " TrueHits (unique) related to SpacePoint " << spacePoint->getArrayIndex() << " from Array "
226  << spacePoint->getArrayName());
227  unsigned int iRels = nUniqueTHs > 4 ? 4 : nUniqueTHs - 1;
228  m_nRelTrueHitsCtr.at(m_iCont).at(iRels)++;
229 
230  // print the complete map if the debug level is set high enough
231  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 350, PACKAGENAME())) {
232  std::string mapCont = printMap(trueHitMap);
233  B2DEBUG(250, "The TrueHits and their weights for spacePoint " << spacePoint->getArrayIndex() << ": " + mapCont);
234  }
235 
236  int thIndex = -1; // declare negative and only assign a value if ONE relation gets registered! (see doc of positionAnalysis)
237  if (m_PARAMregisterAll) {
238  registerAllRelations(spacePoint, trueHitMap, detType);
239  } else { // find THE ONE TrueHit (to rule them all, one TrueHit to find them all ...)
240  // COULDDO: wrap this up in a function
241  pair<VXDTrueHit*, double> trueHitwWeight;
242 
243  if (detType == c_PXD) trueHitwWeight = getTHwithWeight<baseMapT, PXDTrueHit>(trueHitMap, m_PXDTrueHits, spacePoint, c_PXD);
244  else trueHitwWeight = getTHwithWeight<baseMapT, SVDTrueHit>(trueHitMap, m_SVDTrueHits, spacePoint, c_SVD);
245 
246  if (trueHitwWeight.first != nullptr) {
247  registerOneRelation(spacePoint, trueHitwWeight, detType);
248  thIndex = trueHitwWeight.first->getArrayIndex();
249  } else {
250  B2DEBUG(10, "Could not relate one TrueHit to SpacePoint " << spacePoint->getArrayIndex() << ".");
252  }
253  }
254 
255  if (m_PARAMpositionAnalysis) { positionAnalysis(spacePoint, trueHitMap, thIndex, detType); }
256  } // end loop SpacePoints
257  } // end loop containers
258  if (m_PARAMpositionAnalysis) { m_treePtr->Fill(); }
259 }
260 
261 // ================================================================ TERMINATE ======================================================
263 {
264  unsigned int sumSpacePoints = accumulate(m_SpacePointsCtr.begin(), m_SpacePointsCtr.end(), 0);
265  unsigned int sumRelations = accumulate(m_regRelationsCtr.begin(), m_regRelationsCtr.end(), 0);
266 
267  B2RESULT("SpacePoint2TrueHitConnector: Got " << sumSpacePoints << " SpacePoints in " << m_nContainers <<
268  " containers and registered " << sumRelations << " relations to TrueHits");
269  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 1, PACKAGENAME())) {
270  stringstream contSumm;
271  contSumm << "Container-wise summary: \n";
272 
273  for (unsigned int iCont = 0; iCont < m_nContainers; ++iCont) {
274  contSumm << "In Container " << iCont << " (container name: " << m_inputSpacePoints[iCont].first.getName() << ") " <<
275  m_SpacePointsCtr[iCont] << " SpacePoints were contained. " << m_regRelationsCtr[iCont] <<
276  " relations were registered.\nNumber of related TrueHits to a SpacePoint are:\n";
277  for (unsigned int i = 0; i < m_nRelTrueHitsCtr[iCont].size() - 1; ++i) { contSumm << i + 1 << " related TrueHits to a SpacePoint : " << m_nRelTrueHitsCtr[iCont].at(i) << "\n"; }
278  contSumm << " more than 4 related TrueHits to a SpacePoint: " << m_nRelTrueHitsCtr[iCont].at(4) << "\n"; // WARNING: hardcoded
279  contSumm << m_rejectedRelsCtr.at(iCont) << " SpacePoints did not get a relation, " << m_ghostHitCtr.at(
280  iCont) << " were probably ghost hits in this container!\n";
281  contSumm << m_noTrueHitCtr[iCont] << " SpacePoints had no relation to a TrueHit at all.\n";
282  }
283  B2DEBUG(1, contSumm.str());
284 
285  if (!m_PARAMregisterAll) {
286  // TODO: do this containerwise
287  stringstream furtherSummary;
288  furtherSummary << "Ommited Relations because of weight < " << m_PARAMminWeight << ": " << m_weightTooSmallCtr << "\n";
289  furtherSummary << "Rejected Relations because of non primary particle: " << m_rejectedNoPrimaryCtr;
290 // furtherSummary << "Summary for all containers:\n";
291 // furtherSummary << "possible/accepted relations for cases:\n";
292 // furtherSummary << m_all2WTHCtr << "/" << m_accAll2WTHCtr << " SP with THs (more than one) with all THs having two weights\n";
293 // furtherSummary << m_single2WTHCtr << "/" << m_accSingle2WTHCtr << " SP with THs (more than one) with only one TH having two weights\n";
294 // furtherSummary << m_nonSingle2WTHCtr << "/" << m_accNonSingle2WTHCtr << " SP with THs (more than one) with more than one but not all THs having two weights\n";
295 // furtherSummary << "In " << m_oneCluster2THCtr << " cases there was a SP with only one Cluster but more than one related TrueHits";
296  B2DEBUG(2, furtherSummary.str());
297  }
298  }
299 
301 
302 // B2INFO("total number of weights: " << m_totWeightsCtr << " of which " << m_negWeightCtr << " were negative")
303 // B2INFO("m_moreThan2Weights = " << m_moreThan2Weights);
304 }
305 
306 // ====================================================== PROCESS SPACEPOINT ======================================================
307 template<typename MapType>
309 {
310  B2DEBUG(50, "Processing SpacePoint " << spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName());
311  MapType trueHitMap;
312  try {
313  if (detType == c_PXD) {
314  trueHitMap = getRelatedTrueHits<MapType, PXDCluster, PXDTrueHit>(spacePoint, m_PXDClusters.getName(), m_PXDTrueHits.getName());
315  } else {
316  trueHitMap = getRelatedTrueHits<MapType, SVDCluster, SVDTrueHit>(spacePoint, m_SVDClusters.getName(), m_SVDTrueHits.getName());
317  }
318  } catch (NoClusterToSpacePoint& anE) {
319  B2WARNING("Caught an exception while trying to relate SpacePoints and TrueHits: " << anE.what());
320  m_noClusterCtr.at(m_iCont)++;
321  } catch (...) { // catch the rest
322  B2ERROR("Caught undefined exception while trying to relate SpacePoints and TrueHits");
323  throw; // throw further (maybe it is caught somewhere else)
324  }
325 
326  B2DEBUG(499, "trueHitMap.size() before return in processSpacePoint: " << trueHitMap.size());
327  return trueHitMap;
328 }
329 
331 template<typename MapType, typename ClusterType, typename TrueHitType>
333  std::string trueHitName)
334 {
335  MapType trueHitsMap; // map to be filled with indices (keys) and weights (values)
336 
337  RelationVector<ClusterType> spacePointClusters = spacePoint->getRelationsTo<ClusterType>(clusterName);
338  if (spacePointClusters.size() == 0) {
339  B2DEBUG(1, "Found no related Cluster for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
340  spacePoint->getArrayIndex());
341  throw NoClusterToSpacePoint();
342  }
343  B2DEBUG(75, "Found " << spacePointClusters.size() << " related Clusters to SpacePoint " << spacePoint->getArrayIndex() <<
344  " from Array " << spacePoint->getArrayName());
345 
346  // loop over all Clusters, get all TrueHits from them and add the information to the map
347  short noTrueHits = 0;
348  for (size_t iCl = 0; iCl < spacePointClusters.size(); ++iCl) {
349 
350  const ClusterType* cluster = spacePointClusters[iCl];
351  RelationVector<TrueHitType> clusterTrueHits = cluster->template getRelationsTo<TrueHitType>(trueHitName);
352  if (clusterTrueHits.size() == 0) {
353  B2DEBUG(3, "Found no related TrueHit for Cluster " << cluster->getArrayIndex() << " contained by SpacePoint " <<
354  spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName());
355  noTrueHits++;
356  } else {
357  B2DEBUG(80, "Found " << clusterTrueHits.size() << " related TrueHits to Cluster " << cluster->getArrayIndex() << " from Array " <<
358  cluster->getArrayName());
359 
360  for (unsigned int i = 0; i < clusterTrueHits.size(); ++i) { // 'TrueHit' loop
361  if ((clusterTrueHits.weight(i) < m_PARAMminWeight) && !m_PARAMregisterAll) {
363  continue; // not take into account relations with too little weight
364  }
365  int index = clusterTrueHits[i]->getArrayIndex();
366  if (trueHitsMap.find(index) == trueHitsMap.end()) { // create entry only if it is not already in the map
367  trueHitsMap[index] = TrueHitInfo(index);
368  B2DEBUG(499, "Added new TrueHitInfo to map. Index " << index);
369  }
370  if (spacePointClusters.weight(iCl) > 0) {
371  trueHitsMap[index].setUWeight(clusterTrueHits.weight(i));
372  B2DEBUG(499, "Added UCluster to TrueHitInfo with index " << index);
373  } else {
374  trueHitsMap[index].setVWeight(clusterTrueHits.weight(i));
375  B2DEBUG(499, "Added VCluster to TrueHitInfo with index " << index);
376  }
377  }
378  }
379  }
380  // check if there was no Cluster with a related TrueHit -> then throw
381  if (noTrueHits == spacePoint->getNClustersAssigned()) {
382  m_noTrueHitCtr[m_iCont]++; // increase counter for current container
383  }
384  return trueHitsMap;
385 }
386 
387 // ================================================================= INITIALIZE COUNTERS ==========================================
389 {
390  // NEW
391  for (unsigned int i = 0; i < m_SpacePointsCtr.size(); ++i) {
392  m_SpacePointsCtr.at(i) = 0;
393  m_regRelationsCtr.at(i) = 0;
394  m_noClusterCtr.at(i) = 0;
395  m_ghostHitCtr.at(i) = 0;
396  m_noTrueHitCtr.at(i) = 0;
397  m_rejectedRelsCtr.at(i) = 0;
398 
399  for (unsigned int j = 0; j < m_nRelTrueHitsCtr.at(i).size(); ++j) { m_nRelTrueHitsCtr.at(i).at(j) = 0; }
400  }
401 
404 
405  // initialize the following here because of cppcheck complaining (not initialized in constructor)
406  m_nContainers = 0;
407  m_maxGlobalDiff = 0.;
408  m_iCont = 0;
409 
410 // m_negWeightCtr = 0;
411 // m_totWeightsCtr = 0;
412 // m_moreThan2Weights = 0;
413 //
414 // m_single2WTHCtr = 0;
415 // m_nonSingle2WTHCtr = 0;
416 // m_all2WTHCtr = 0;
417 // m_accSingle2WTHCtr = 0;
418 // m_accNonSingle2WTHCtr = 0;
419 // m_accAll2WTHCtr = 0;
420 //
421 // m_oneCluster2THCtr = 0;
422 //
423 
424 }
425 
426 // ===================================================== REGISTER ALL RELATIONS ===================================================
427 template<typename MapType>
429 {
430  B2DEBUG(50, "Registering all possible relations for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
431  spacePoint->getArrayName() << ". storeSeparate is set to " << m_PARAMstoreSeparate);
432  SpacePoint* newSP = spacePoint; // declaring pointer here, getting new pointer if storeSeparate is true
433 
434  if (m_PARAMstoreSeparate) { // if storing in separate Array, re-register the relations to the Clusters first
435  newSP = m_outputSpacePoints.at(m_iCont).appendNew(*spacePoint);
436  B2DEBUG(50, "Added new SpacePoint to Array " << m_outputSpacePoints[m_iCont].getName() << ".");
437  if (detType == c_PXD) reRegisterClusterRelations<PXDCluster>(spacePoint, newSP, m_PXDClusters.getName());
438  else reRegisterClusterRelations<SVDCluster>(spacePoint, newSP, m_SVDClusters.getName());
439  }
440 
441  std::vector<TrueHitInfo> trueHitInfos = getAllValues(trueHitMap);
442  // sort by the number of related Clusters first and than by weight (descending order)
443  std::sort(trueHitInfos.begin(), trueHitInfos.end());
444 
445  for (const TrueHitInfo& info : trueHitInfos) {
446  if (detType == c_PXD) registerTrueHitRelation<PXDTrueHit>(newSP, info.m_Id, 1, m_PXDTrueHits); // only one Cluster for PXDs!
447  else { // for SVD relation weight is depending on which Cluster is related to TrueHit!
448  double weight = calculateRelationWeight(info, spacePoint);
449  registerTrueHitRelation<SVDTrueHit>(newSP, info.m_Id, weight, m_SVDTrueHits);
450  }
451  }
452 }
453 
454 // =============================================== REGISTER ONE RELATION ==========================================================
455 template<typename TrueHitType>
457  std::pair<TrueHitType*, double> trueHitwWeight, e_detTypes detType)
458 {
459  TrueHitType* trueHit = trueHitwWeight.first;
460  B2DEBUG(50, "Registering relation to TrueHit " << trueHit->getArrayIndex() << " from Array " << trueHit->getArrayName());
461  SpacePoint* newSP = spacePoint; // declaring pointer here, getting new pointer if storeSeparate ist true
462 
463  if (m_PARAMstoreSeparate) { // if storing in separate Array, re-register the relations to the Clusters first
464  newSP = m_outputSpacePoints.at(m_iCont).appendNew(*spacePoint);
465  B2DEBUG(50, "Added new SpacePoint to Array " << m_outputSpacePoints[m_iCont].getName() << ".");
466  if (detType == c_PXD) reRegisterClusterRelations<PXDCluster>(spacePoint, newSP, m_PXDClusters.getName());
467  else reRegisterClusterRelations<SVDCluster>(spacePoint, newSP, m_SVDClusters.getName());
468  }
469 
470  newSP->addRelationTo(trueHit, trueHitwWeight.second);
472  B2DEBUG(50, "Added Relation to TrueHit " << trueHit->getArrayIndex() << " from Array " << trueHit->getArrayName() <<
473  " for SpacePoint " << spacePoint->getArrayIndex() << " (weight = " << trueHitwWeight.second << ")");
474 }
475 
476 // ========================================================= REREGISTER CLUSTER RELATIONS =========================================
477 template<typename ClusterType>
479  Belle2::SpacePoint* newSpacePoint, std::string clusterName)
480 {
481  B2DEBUG(100, "Registering the Relations to Clusters of SpacePoint " << origSpacePoint->getArrayIndex() << " in Array " <<
482  origSpacePoint->getArrayName() << " for SpacePoint " << newSpacePoint->getArrayIndex() << " in Array " <<
483  newSpacePoint->getArrayName());
484 
485  vector<pair<ClusterType*, double> > clustersAndWeights = getRelatedClusters<ClusterType>(origSpacePoint, clusterName);
486  for (auto aCluster : clustersAndWeights) {
487  newSpacePoint->addRelationTo(aCluster.first, aCluster.second);
488  B2DEBUG(100, "Registered Relation to Cluster " << aCluster.first->getArrayIndex() << " with weight " << aCluster.second);
489  }
490 }
491 
492 // =========================================================== GET RELATED CLUSTERS ===============================================
493 template<typename ClusterType>
494 std::vector<std::pair<ClusterType*, double> > SpacePoint2TrueHitConnectorModule::getRelatedClusters(Belle2::SpacePoint* spacePoint,
495  std::string clusterName)
496 {
497  vector<pair<ClusterType*, double> > indsAndWeights;
498  RelationVector<ClusterType> relClusters = spacePoint->getRelationsTo<ClusterType>(clusterName);
499 
500  for (unsigned int iCl = 0; iCl < relClusters.size(); ++iCl) {
501  indsAndWeights.push_back(make_pair(relClusters[iCl], relClusters.weight(iCl)));
502  }
503 
504  // safety measure, should not / cannot happen (checked before)
505  if (indsAndWeights.empty()) { B2ERROR("No Clusters related to SpacePoint " << spacePoint->getArrayIndex() << "!"); }
506 
507  return indsAndWeights;
508 }
509 
510 // ====================================================== REGISTER TRUEHIT RELATIONS ==============================================
511 template<typename TrueHitType>
514 {
515  TrueHitType* trueHit = trueHits[index];
516  spacePoint->addRelationTo(trueHit, weight);
517  m_regRelationsCtr.at(m_iCont)++; // increase counter of registered relations for this container
518  B2DEBUG(50, "Added Relation to TrueHit " << index << " from Array " << trueHits.getName() << " for SpacePoint " <<
519  spacePoint->getArrayIndex() << " (weight = " << weight << ")");
520 }
521 
522 // ====================================================== POSITION ANALYSIS =======================================================
523 // TODO: debug output
524 template<typename MapType>
526  const int& index, e_detTypes detType)
527 {
528  B2DEBUG(250, "Doing position analysis for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
529  spacePoint->getArrayName());
530  simpleBitfield<unsigned short int> relationStatus;
531 
532  // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
533  pair<unsigned short int, unsigned short int> clusterSizes = getClusterSizes(spacePoint, detType);
534  pair<double, double> positionError = getLocalError(spacePoint);
535  // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
536 
537  // do some checks and set the relationStatus
538  pair<bool, bool> setUV = spacePoint->getIfClustersAssigned();
539  if (setUV.first) relationStatus.addStatus(c_SpacePointU);
540  if (setUV.second) relationStatus.addStatus(c_SpacePointV);
541 
542  const vector<TrueHitInfo> trueHitInfos = getAllValues(trueHitMap);
543  unsigned int nRelations = trueHitInfos.size();
544  if (nRelations != 1) relationStatus.addStatus(c_nonUniqueRelation);
545  else relationStatus.addStatus(c_clearHit); // TODO: check if this is according to the definition of cleanHit
546 
547  B2DEBUG(999, "SpacePoint has assigned U: " << setUV.first << ", V: " << setUV.second << ". Possible TrueHits: " << nRelations);
548 
549  pair<double, double> spLocalPos = getLocalPos(spacePoint);
550  unsigned short int vxdId = spacePoint->getVxdID();
551  short nClusters = spacePoint->getNClustersAssigned();
552 
553  // loop over all TrueHitInfos and check if it is a ghostHit, and if a noise hit is contained in the SpacePoint
554  bool onceU = false, onceV = false; // check if both Clusters are at least used once
555  bool twoClusters = false;
556  for (const TrueHitInfo& info : trueHitInfos) {
557  onceU = onceU || info.m_U; // if U is set for one of the possible TrueHits, onceU is true after this loop
558  onceV = onceV || info.m_V;
559  twoClusters = twoClusters || (info.getNClusters() == 2); // if one of the TrueHits has two Clusters in the SpacePoint -> true
560  }
561  bool allSet = onceU && onceV;
562 
563  if (nClusters > 1) { // at this stage noise Clusters and ghostHits can only appear if there are two Clusters in the SpacePoint
564  if (!allSet) relationStatus.addStatus(c_noiseCluster);
565  if (allSet && !twoClusters) relationStatus.addStatus(c_ghostHit);
566  }
567 
568  // get the status that has been set until now as from now on it can differ for every relation
569  unsigned short int overAllStatus = relationStatus.getStatus();
570 
571  for (const TrueHitInfo& info : trueHitInfos) {
572  relationStatus.setStatus(overAllStatus); // reset status
573  VXDTrueHit* trueHit;
574  if (detType == c_SVD) { trueHit = m_SVDTrueHits[info.m_Id]; }
575  else { trueHit = m_PXDTrueHits[info.m_Id]; }
576  pair<TVector3, TVector3> trueHitPos = getTrueHitPositions(trueHit);
577 
578  double weightU = info.m_wU;
579  double weightV = info.m_wV;
580 
581  MCParticle* mcParticle = trueHit->getRelatedFrom<MCParticle>("ALL");
582  if (mcParticle != nullptr) {
583  if (mcParticle->hasStatus(MCParticle::c_PrimaryParticle)) relationStatus.addStatus(c_primaryParticle);
584  }
585 
586  if (info.m_Id == index) relationStatus.addStatus(c_registeredRelation);
587 
588  m_rootVariables.SpacePointULocal.push_back(spLocalPos.first);
589  m_rootVariables.SpacePointVLocal.push_back(spLocalPos.second);
590  m_rootVariables.SpacePointXGlobal.push_back(spacePoint->X());
591  m_rootVariables.SpacePointYGlobal.push_back(spacePoint->Y());
592  m_rootVariables.SpacePointZGlobal.push_back(spacePoint->Z());
593 
594  m_rootVariables.TrueHitULocal.push_back(trueHitPos.first.X());
595  m_rootVariables.TrueHitVLocal.push_back(trueHitPos.first.Y());
596  m_rootVariables.TrueHitXGlobal.push_back(trueHitPos.second.X());
597  m_rootVariables.TrueHitYGlobal.push_back(trueHitPos.second.Y());
598  m_rootVariables.TrueHitZGlobal.push_back(trueHitPos.second.Z());
599 
600  m_rootVariables.NRelations.push_back(nRelations);
601  m_rootVariables.RelationStatus.push_back(relationStatus.getStatus());
602  m_rootVariables.WeightU.push_back(weightU);
603  m_rootVariables.WeightV.push_back(weightV);
604  m_rootVariables.HitVxdID.push_back(vxdId);
605 
606  // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
607  m_rootVariables.ClusterSizeU.push_back(clusterSizes.first);
608  m_rootVariables.ClusterSizeV.push_back(clusterSizes.second);
609  m_rootVariables.SpacePointErrorU.push_back(positionError.first);
610  m_rootVariables.SpacePointErrorV.push_back(positionError.second);
611  m_rootVariables.SpacePointErrorX.push_back(spacePoint->getPositionError().X());
612  m_rootVariables.SpacePointErrorY.push_back(spacePoint->getPositionError().Y());
613  m_rootVariables.SpacePointErrorZ.push_back(spacePoint->getPositionError().Z());
614  // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
615 
616  B2DEBUG(999, "Branch contents of this entry:\nSPLocalU: " << spLocalPos.first << ". SPLocalV: " << spLocalPos.second << "\n" << \
617  "SPGlobalX: " << spacePoint->X() << ", SPGlobalY: " << spacePoint->Y() << ", SPGlobalZ " << spacePoint->Z() << "\n" << \
618  "THLocalU: " << trueHitPos.first.X() << ", THLocalV: " << trueHitPos.first.Y() << "\n" << \
619  "THGlobalX: " << trueHitPos.second.X() << ", THGlobalY: " << trueHitPos.second.Y() << ", THGlobalZ: " << trueHitPos.second.Z() <<
620  "\n" << \
621  "weight1: " << weightU << ", weight2: " << weightV << ", VxdID: " << vxdId << ", nRelations: " << nRelations << ", relStatus: " <<
622  relationStatus.getStatus());
623  }
624 }
625 
626 // ====================================================== GET TH WITH WEIGHT ======================================================
627 template<typename MapType, typename TrueHitType>
628 std::pair<TrueHitType*, double>
630  Belle2::SpacePoint* spacePoint, e_detTypes detType)
631 {
632  vector<TrueHitInfo> trueHitInfos = getAllValues(aMap);
633  std::pair<TrueHitType*, double> THwithWeight(nullptr, 0.0); // default return value
634  // return nullptr pointer and zero weight if there is no TrueHit (safety measure that should not actually be needed!)
635  if (trueHitInfos.empty()) return THwithWeight;
636  std::sort(trueHitInfos.begin(), trueHitInfos.end()); // sort to have best candidates at beginning
637 
638  short nClusters = spacePoint->getNClustersAssigned();
639  size_t nRelations = trueHitInfos.size(); // get the number of possible relations
640 
641  B2DEBUG(50, "Trying to select one TrueHit for SpacePoint " << spacePoint->getArrayIndex() << " from Array " <<
642  spacePoint->getArrayName() << ". SpacePoint has " << nClusters << " Clusters.");
643  B2DEBUG(150, "There are " << nRelations << " possible candidates.");
644 
645  // very verbose output only to have a look on why these TrueHits could be in the same SpacePoint, COULDDO: wrap up in function
646  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 999, PACKAGENAME())) {
647  stringstream output;
648  output << "The candidates are: ";
649  for (auto& info : trueHitInfos) { output << info; }
650  B2DEBUG(999, output.str());
651 
652  std::pair<double, double> spacePointLocal = getLocalPos(spacePoint);
653  std::pair<bool, bool> assignedLocal = spacePoint->getIfClustersAssigned();
654 
655  B2DEBUG(999, "SpacePoint " << spacePoint->getArrayIndex() << " U: " << spacePointLocal.first << " V: " << spacePointLocal.second <<
656  " assigned: " << assignedLocal.first << ", " << assignedLocal.second);
657 
658  std::vector<int> uniqueKeys = getUniqueKeys(aMap);
659  for (int key : uniqueKeys) {
660  TrueHitType* trueHit = trueHits[key];
661  // NOTE: assuming here that there is only one MCParticle to each TrueHit
662  MCParticle* mcParticle = trueHit->template getRelatedFrom<MCParticle>("ALL");
663 
664  int mcPartId = -1, pdgCode = 0;
665  bool primary = false;
666 
667  if (mcParticle != nullptr) {
668  mcPartId = mcParticle->getArrayIndex();
669  primary = mcParticle->hasStatus(MCParticle::c_PrimaryParticle);
670  pdgCode = mcParticle->getPDG();
671  }
672 
673  B2DEBUG(999, "TrueHit " << key << " U: " << trueHit->getU() << ", V: " << trueHit->getV() << " mc Particle Id: " << mcPartId <<
674  ", primary " << primary << ", pdg: " << pdgCode);
675  }
676  }
677 
678  // loop over all TrueHitInfos and check if the number of related Clusters is equal to the number of the number of the assigned
679  // Clusters in the SpacePoint -> if so, check for compatibility and return (the first that is compatible)
680  bool ghostHit = false;
681  for (const TrueHitInfo& info : trueHitInfos) {
682  B2DEBUG(499, "Now checking trueHit: " << info);
683  if (nClusters == info.getNClusters()) {
684  TrueHitType* trueHit = trueHits[info.m_Id];
685  if (compatibleCombination(spacePoint, trueHit)) {
686  double weight = (detType == c_PXD ? 1 : calculateRelationWeight(info, spacePoint)); // if PXD weight is always 1!
687  return make_pair(trueHit, weight);
688  }
689  } else {
690  B2DEBUG(499, "The number of related Clusters ( = " << nClusters << ") and the number of associated weights ( = " <<
691  info.getNClusters() << ") do not match! This indicates a ghost hit");
692  ghostHit = true;
693  }
694  }
695  if (ghostHit) m_ghostHitCtr[m_iCont]++;
696 
697  // B2DEBUG(4999, "just before return in getTHwithWeight")
698  return THwithWeight;
699 }
700 
701 // ============================================== CHECK IF SPACEPOINT AND TRUEHIT ARE COMPATIBLE ==================================
702 template <typename TrueHitType>
704 {
705  B2DEBUG(150, "Checking TrueHit " << trueHit->getArrayIndex() << " from Array " << trueHit->getArrayName() << " and SpacePoint " <<
706  spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName() << " for compatibility");
707 
708  // check primary first
709  MCParticle* mcPart = trueHit->template getRelatedFrom<MCParticle>("ALL");
710  bool primaryPart = false; // assume secondary or background for safety
711  if (mcPart != nullptr) primaryPart = mcPart->hasStatus(MCParticle::c_PrimaryParticle);
712  if (m_PARAMrequirePrimary && !primaryPart) {
713  B2DEBUG(150, "TrueHit is not related to a primary particle but 'requirePrimary' is set to true!");
715  return false;
716  }
717 
718  // CAUTION: if further tests are added, make sure that they do not get 'over-ruled' by this one (i.e. put before this if)
720  B2DEBUG(999, "Not checking positions because 'requireProximity' is set to false");
721  return true;
722  }
723  const VxdID spacePointVxdId = spacePoint->getVxdID();
724  const VxdID trueHitVxdId = trueHit->getSensorID();
725 
726  B2DEBUG(999, "Comparing the VxdIDs, SpacePoint: " << spacePointVxdId << ", TrueHit: " << trueHitVxdId);
727  if (spacePointVxdId != trueHitVxdId) {
728  B2DEBUG(150, "SpacePoint and TrueHit do not have the same VxdID. spacePoint: " << spacePointVxdId << ", trueHit: " << trueHitVxdId);
729  return false;
730  }
731 
733  trueHitVxdId); // only have to get one, since VxdIds are already the same at this point!
734  double maxUres = SensorInfoBase.getUPitch(trueHit->getV()) / sqrt(12.) * m_PARAMmaxPosSigma;
735  double maxVres = SensorInfoBase.getVPitch(trueHit->getV()) / sqrt(12.) * m_PARAMmaxPosSigma;
736 
737  B2DEBUG(999, "maximum residual in U: " << maxUres << ", in V: " << maxVres);
738 
739  const TVector3 trueHitLocalPos = TVector3(trueHit->getU(), trueHit->getV(), 0);
740  const TVector3 trueHitGlobalPos = SensorInfoBase.pointToGlobal(trueHitLocalPos, true); // uses alignment
741 
742  std::pair<double, double> spacePointLocal = getLocalPos(spacePoint);
743  // compare only those values of the local coordinates that have been set
744  std::pair<bool, bool> setCoordinates = spacePoint->getIfClustersAssigned();
745 
746  if (setCoordinates.first) {
747  B2DEBUG(999, "Comparing the U-coordinates, SpacePoint: " << spacePointLocal.first << ", TrueHit: " << trueHitLocalPos.X() <<
748  " -> diff: " << spacePointLocal.first - trueHitLocalPos.X());
749  if (pow(spacePointLocal.first - trueHitLocalPos.X(), 2) > maxUres * maxUres) {
750  B2DEBUG(150, "The local position difference in U direction is " << spacePointLocal.first - trueHitLocalPos.X() <<
751  " but maximum local position difference is set to: " << maxUres);
752  return false;
753  }
754  }
755  if (setCoordinates.second) {
756  B2DEBUG(999, "Comparing the V-coordinates, SpacePoint: " << spacePointLocal.second << ", TrueHit: " << trueHitLocalPos.Y() <<
757  " -> diff: " << spacePointLocal.second - trueHitLocalPos.Y());
758  if (pow(spacePointLocal.second - trueHitLocalPos.Y(), 2) > maxVres * maxVres) {
759  B2DEBUG(150, "The local position difference in V direction is " << spacePointLocal.second - trueHitLocalPos.Y() <<
760  " but maximum local position difference is set to: " << maxVres);
761  return false;
762  }
763  }
764 
765  // only if both local coordinates of a SpacePoint are set, compare also the global positions!
766  if (setCoordinates.first && setCoordinates.second) {
767  B2DEBUG(999, "Comparing the global positions, SpacePoint: (" << spacePoint->X() << "," << spacePoint->Y() << "," << spacePoint->Z()
768  << "), TrueHit: (" << trueHitGlobalPos.X() << "," << trueHitGlobalPos.Y() << "," << trueHitGlobalPos.Z() << ")");
769  if (pow(spacePoint->X() - trueHitGlobalPos.X(), 2) > m_maxGlobalDiff
770  || pow(spacePoint->Y() - trueHitGlobalPos.Y(), 2) > m_maxGlobalDiff ||
771  pow(spacePoint->Z() - trueHitGlobalPos.Z(), 2) > m_maxGlobalDiff) {
772  B2DEBUG(150, "The position differences are for X: " << spacePoint->X() - trueHitGlobalPos.X() << ", Y: " << spacePoint->Y() -
773  trueHitGlobalPos.Y() << " Z: " << spacePoint->Z() - trueHitGlobalPos.Z() << " but the maximum position difference is set to: " <<
774  sqrt(m_PARAMmaxGlobalDiff));
775  return false;
776  }
777  } else {
778  B2DEBUG(5, "For SpacePoint " << spacePoint->getArrayIndex() <<
779  " one of the local coordinates was not assigned. The global positions and the un-assigned local coordinate were not compared!");
780  }
781 
782  return true;
783 }
784 
785 // ===================================================== GET LOCAL SPACEPOINT COORDINATES =========================================
787 {
788  // get the normalized local coordinates from SpacePoint and convert them to local coordinates (have to do so because at the slanted parts the local U-position is dependant on the local V-position)
789  // NOTE: second way is to convert the global position of the SpacePoint to local position via the sensorInfoBase (yields same results)
790  double normU = spacePoint->getNormalizedLocalU();
791  double normV = spacePoint->getNormalizedLocalV();
792  return spacePoint->convertNormalizedToLocalCoordinates(std::make_pair(normU, normV), spacePoint->getVxdID());
793 }
794 
795 // =============================================================== GET TRUEHIT POSITIONS ==========================================
796 template<typename TrueHitType>
797 std::pair<TVector3, TVector3> SpacePoint2TrueHitConnectorModule::getTrueHitPositions(TrueHitType* trueHit)
798 {
799 // TrueHitType* trueHit = trueHits[index];
800  const TVector3 localPos = TVector3(trueHit->getU(), trueHit->getV(), 0);
801 
802  const VxdID trueHitVxdId = trueHit->getSensorID();
803  VXD::SensorInfoBase SensorInfoBase = VXD::GeoCache::getInstance().getSensorInfo(trueHitVxdId);
804  const TVector3 globalPos = SensorInfoBase.pointToGlobal(localPos, true); // uses alignment
805 
806  return make_pair(localPos, globalPos);
807 }
808 
809 // ================================================================= INITIALIZE ROOT FILE =========================================
811 {
812  if (m_PARAMrootFileName.size() != 2 || (m_PARAMrootFileName[1] != "UPDATE" && m_PARAMrootFileName[1] != "RECREATE")) {
813  string output;
814  // cppcheck-suppress useStlAlgorithm
815  for (string entry : m_PARAMrootFileName) { output += "'" + entry + "' "; }
816  B2FATAL("CurlingTrackCandSplitter::initialize() : rootFileName is set wrong: entries are: " << output);
817  }
818 
819  string fileName = m_PARAMrootFileName[0] + ".root";
820  m_rootFilePtr = new TFile(fileName.c_str(), m_PARAMrootFileName[1].c_str());
821  m_treePtr = new TTree("PosAnaTree", "Position Analysis");
822 
823  // link the variables
824  m_treePtr->Branch("SPLocalU", &m_rootVariables.SpacePointULocal);
825  m_treePtr->Branch("SPLocalV", &m_rootVariables.SpacePointVLocal);
826  m_treePtr->Branch("SPGlobalX", &m_rootVariables.SpacePointXGlobal);
827  m_treePtr->Branch("SPGlobalY", &m_rootVariables.SpacePointYGlobal);
828  m_treePtr->Branch("SPGlobalZ", &m_rootVariables.SpacePointZGlobal);
829 
830  m_treePtr->Branch("THLocalU", &m_rootVariables.TrueHitULocal);
831  m_treePtr->Branch("THLocalV", &m_rootVariables.TrueHitVLocal);
832  m_treePtr->Branch("THGlobalX", &m_rootVariables.TrueHitXGlobal);
833  m_treePtr->Branch("THGlobalY", &m_rootVariables.TrueHitYGlobal);
834  m_treePtr->Branch("THGlobalZ", &m_rootVariables.TrueHitZGlobal);
835 
836  m_treePtr->Branch("WeightU", &m_rootVariables.WeightU);
837  m_treePtr->Branch("WeightV", &m_rootVariables.WeightV);
838 
839  m_treePtr->Branch("relStatus", &m_rootVariables.RelationStatus);
840  m_treePtr->Branch("VxdID", &m_rootVariables.HitVxdID);
841  m_treePtr->Branch("nRelations", &m_rootVariables.NRelations);
842 
843  m_treePtr->Branch("clusterSizeU", &m_rootVariables.ClusterSizeU);
844  m_treePtr->Branch("clusterSizeV", &m_rootVariables.ClusterSizeV);
845  m_treePtr->Branch("SPErrorU", &m_rootVariables.SpacePointErrorU);
846  m_treePtr->Branch("SPErrorV", &m_rootVariables.SpacePointErrorV);
847  m_treePtr->Branch("SPErrorX", &m_rootVariables.SpacePointErrorX);
848  m_treePtr->Branch("SPErrorY", &m_rootVariables.SpacePointErrorY);
849  m_treePtr->Branch("SPErrorZ", &m_rootVariables.SpacePointErrorZ);
850 }
851 
852 // ========================================================= CLOSE ROOT FILE ======================================================
854 {
855  if (m_treePtr != nullptr && m_rootFilePtr != nullptr) {
856  m_rootFilePtr->cd(); //important! without this the famework root I/O (SimpleOutput etc) could mix with the root I/O of this module
857 // m_treePtr->Write(); // using TTree::Write() instead, which calls this any way
858  m_rootFilePtr->Write();
859  m_rootFilePtr->Close();
860  }
861 }
862 
863 // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
864 std::pair<unsigned short int, unsigned short int> SpacePoint2TrueHitConnectorModule::getClusterSizes(Belle2::SpacePoint* spacePoint,
865  e_detTypes detType)
866 {
867  std::pair<unsigned short int, unsigned short int> clusterSizes = { 0, 0 };
868  if (detType == c_PXD) {
869  vector<pair<PXDCluster*, double> > relClusters = getRelatedClusters<PXDCluster>(spacePoint, m_PXDClusters.getName());
870  return make_pair(relClusters[0].first->getUSize(), relClusters[0].first->getVSize());
871  } else {
872  vector<pair<SVDCluster*, double> > relClusters = getRelatedClusters<SVDCluster>(spacePoint, m_SVDClusters.getName());
873  for (auto cluster : relClusters) {
874  if (cluster.first->isUCluster()) clusterSizes.first = cluster.first->getSize();
875  else clusterSizes.second = cluster.first->getSize();
876  }
877  }
878  return clusterSizes;
879 }
880 
882 {
883  auto detType = spacePoint->getType();
884  pair<double, double> errors = { -1., -1. };
885  if (detType == VXD::SensorInfoBase::PXD) {
886  vector<pair<PXDCluster*, double> > relClusters = getRelatedClusters<PXDCluster>(spacePoint, m_PXDClusters.getName());
887  errors.first = relClusters[0].first->getUSigma();
888  errors.second = relClusters[0].first->getVSigma();
889  } else if (detType == VXD::SensorInfoBase::SVD) {
890  vector<pair<SVDCluster*, double> > relClusters = getRelatedClusters<SVDCluster>(spacePoint, m_SVDClusters.getName());
891  for (auto cluster : relClusters) {
892  if (cluster.first->isUCluster()) { errors.first = cluster.first->getPositionSigma(); }
893  else { errors.second = cluster.first->getPositionSigma(); }
894  }
895  } else {
896  B2ERROR("Detector type not known in SpacePoint2TrueHitConnector::getLocalError() !");
897  }
898 
899  return errors;
900 }
901 // TODO TODO TODO TODO TODO TODO TODO: remove if not needed, only for tessting at the moment (i.e. do not commit)
902 
903 // ==================================================== CALCULATE RELATION WEIGHT ==================================================
905 {
906  bool isUAssigned = spacePoint->getIfClustersAssigned().first; // get if the Cluster in the SpacePoint is a U-Cluster
907  // get if two Clusters are related to the Truehit (always false for single Cluster SPs
908  bool bothClusters = trueHitInfo.m_U && trueHitInfo.m_V;
909  // calculate the additional weight that identifies which Clusters are related to this TrueHit
910  // 0 -> both Clusters have Relation to TrueHit, 10 -> only U-Cluster, 20 -> only V-Cluster has Relation to TrueHit
911  short addWeight = 20 - (bothClusters ? 20 : isUAssigned ? 10 : 0);
912 
913  return addWeight + (bothClusters ? 2 : 1);
914 }
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::TrueHitZGlobal
std::vector< double > TrueHitZGlobal
TrueHit global Z-position.
Definition: SpacePoint2TrueHitConnectorModule.h:152
Belle2::SpacePoint2TrueHitConnectorModule::SpacePoint2TrueHitConnectorModule
SpacePoint2TrueHitConnectorModule()
Constructor.
Belle2::SpacePoint2TrueHitConnectorModule::m_rejectedNoPrimaryCtr
unsigned int m_rejectedNoPrimaryCtr
Count how many times a relation was rejected because TrueHit was not related to primary.
Definition: SpacePoint2TrueHitConnectorModule.h:284
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::ClusterSizeU
std::vector< unsigned int > ClusterSizeU
size of the u-cluster (resp.
Definition: SpacePoint2TrueHitConnectorModule.h:162
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables
helper struct to access root variables inside the module
Definition: SpacePoint2TrueHitConnectorModule.h:141
Belle2::SpacePoint2TrueHitConnectorModule::getTHwithWeight
std::pair< TrueHitType *, double > getTHwithWeight(const MapType &aMap, Belle2::StoreArray< TrueHitType > trueHits, Belle2::SpacePoint *spacePoint, e_detTypes detType)
get the TrueHit from information that is stored in the map (conditions are checked in the following o...
Definition: SpacePoint2TrueHitConnectorModule.cc:629
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SpacePoint2TrueHitConnectorModule::c_SVD
@ c_SVD
SVD.
Definition: SpacePoint2TrueHitConnectorModule.h:183
Belle2::SpacePoint2TrueHitConnectorModule::m_detectorTypes
std::vector< e_detTypes > m_detectorTypes
storing the detector types for each container in vector, needed in initialize
Definition: SpacePoint2TrueHitConnectorModule.h:237
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::RelationStatus
std::vector< unsigned short int > RelationStatus
different flags of the relation stored in here (see c_relationStatus)
Definition: SpacePoint2TrueHitConnectorModule.h:158
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointErrorU
std::vector< double > SpacePointErrorU
position error of SpacePoint in U direction
Definition: SpacePoint2TrueHitConnectorModule.h:165
Belle2::SpacePoint2TrueHitConnectorModule::registerOneRelation
void registerOneRelation(Belle2::SpacePoint *spacePoint, std::pair< TrueHitType *, double > trueHitwWeight, e_detTypes)
register Relation between SpacePoint and TrueHit (and if neccessary also between SpacePoint and Clust...
Definition: SpacePoint2TrueHitConnectorModule.cc:456
Belle2::getUniqueSize
unsigned int getUniqueSize(const MapType &aMap)
get the number of unique keys inside the map NOTE: for non-multimap this is the same as ....
Definition: MapHelperFunctions.h:61
Belle2::SpacePoint2TrueHitConnectorModule::m_SVDClusters
Belle2::StoreArray< Belle2::SVDCluster > m_SVDClusters
PXDClusters StoreArray used throughout the module.
Definition: SpacePoint2TrueHitConnectorModule.h:245
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMmaxPosSigma
double m_PARAMmaxPosSigma
defining th maximum difference of local coordinates in units of PitchSize / sqrt(12)
Definition: SpacePoint2TrueHitConnectorModule.h:229
Belle2::SpacePoint2TrueHitConnectorModule::m_nContainers
unsigned int m_nContainers
number of passed containers -> storing the size of an input vector for not having to obtain it every ...
Definition: SpacePoint2TrueHitConnectorModule.h:235
Belle2::SpacePoint2TrueHitConnectorModule::m_PXDClusters
Belle2::StoreArray< Belle2::PXDCluster > m_PXDClusters
PXDTClusters StoreArray used throughout the module.
Definition: SpacePoint2TrueHitConnectorModule.h:243
Belle2::SpacePoint2TrueHitConnectorModule::initializeRootFile
void initializeRootFile()
initialize the root file that is used for output
Definition: SpacePoint2TrueHitConnectorModule.cc:810
Belle2::SpacePoint::X
double X() const
return the x-value of the global position of the SpacePoint
Definition: SpacePoint.h:133
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::ClusterSizeV
std::vector< unsigned int > ClusterSizeV
size of the v-cluster (resp.
Definition: SpacePoint2TrueHitConnectorModule.h:163
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ 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:82
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMregisterAll
bool m_PARAMregisterAll
switch for registereing all relations for all TrueHits for all SpacePoints (there can be more than 1 ...
Definition: SpacePoint2TrueHitConnectorModule.h:217
Belle2::SpacePoint::Z
double Z() const
return the z-value of the global position of the SpacePoint
Definition: SpacePoint.h:139
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMmaxGlobalDiff
double m_PARAMmaxGlobalDiff
maximum difference of global position coordinates for each direction between TrueHit and SpacePoint
Definition: SpacePoint2TrueHitConnectorModule.h:225
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMrequirePrimary
bool m_PARAMrequirePrimary
require the TrueHit to be related to a primary particle in order for the relation to get registered!
Definition: SpacePoint2TrueHitConnectorModule.h:221
Belle2::SpacePoint2TrueHitConnectorModule::getLocalPos
std::pair< double, double > getLocalPos(Belle2::SpacePoint *spacePoint)
get the local position of a SpacePoint
Definition: SpacePoint2TrueHitConnectorModule.cc:786
Belle2::SpacePoint::getIfClustersAssigned
std::pair< bool, bool > getIfClustersAssigned() const
Returns, if u(v)-coordinate is based on cluster information.
Definition: SpacePoint.h:172
Belle2::SpacePoint2TrueHitConnectorModule::event
void event() override
event: try to find the appropriate TrueHit to all SpacePoints
Definition: SpacePoint2TrueHitConnectorModule.cc:198
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::TrueHitXGlobal
std::vector< double > TrueHitXGlobal
TrueHit global X-position.
Definition: SpacePoint2TrueHitConnectorModule.h:150
Belle2::SpacePoint2TrueHitConnectorModule::reRegisterClusterRelations
void reRegisterClusterRelations(Belle2::SpacePoint *origSpacePoint, Belle2::SpacePoint *newSpacePoint, std::string clusterName="ALL")
register all the relations to Clusters that origSpacePoint had for newSpacePoint
Definition: SpacePoint2TrueHitConnectorModule.cc:478
Belle2::RelationsInterface::getArrayName
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
Definition: RelationsObject.h:379
Belle2::VXDTrueHit
Class VXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: VXDTrueHit.h:38
Belle2::RelationsInterface::addRelationTo
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Definition: RelationsObject.h:144
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMspacePointNames
std::vector< std::string > m_PARAMspacePointNames
names of containers of SpacePoints
Definition: SpacePoint2TrueHitConnectorModule.h:204
Belle2::SpacePoint2TrueHitConnectorModule::c_PXD
@ c_PXD
PXD.
Definition: SpacePoint2TrueHitConnectorModule.h:182
Belle2::DataStore::c_DontWriteOut
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:73
Belle2::TrueHitInfo
helper struct that holds information that is needed for the registration of the relation between Spac...
Definition: SpacePoint2TrueHitConnectorModule.h:49
Belle2::B2Vector3::Z
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:434
Belle2::MCParticle::getArrayIndex
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
Definition: MCParticle.h:255
Belle2::SpacePoint2TrueHitConnectorModule::getTrueHitPositions
std::pair< TVector3, TVector3 > getTrueHitPositions(TrueHitType *trueHit)
get the local (.first) and global (.second) position of a TrueHit (passed by index)
Definition: SpacePoint2TrueHitConnectorModule.cc:797
Belle2::SpacePoint2TrueHitConnectorModule::m_noTrueHitCtr
std::vector< unsigned int > m_noTrueHitCtr
Number of SpacePoints that contained a Cluster to which no TrueHit could be found (i....
Definition: SpacePoint2TrueHitConnectorModule.h:277
Belle2::SpacePoint2TrueHitConnectorModule::m_iCont
unsigned int m_iCont
'helper variable' needed to not have to pass one integer down to processSpacePoint only to have a han...
Definition: SpacePoint2TrueHitConnectorModule.h:255
Belle2::SpacePoint2TrueHitConnectorModule::m_treePtr
TTree * m_treePtr
pointer to tree in root file
Definition: SpacePoint2TrueHitConnectorModule.h:261
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMrootFileName
std::vector< std::string > m_PARAMrootFileName
name and update status of root file
Definition: SpacePoint2TrueHitConnectorModule.h:211
Belle2::simpleBitfield
helper class for setting up a bitfield that can be used to store several flags in one variable TODO: ...
Definition: SpacePoint2TrueHitConnectorModule.h:435
Belle2::RelationsInterface::getRelationsTo
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
Definition: RelationsObject.h:199
Belle2::SpacePoint2TrueHitConnectorModule::baseMapT
std::unordered_map< int, TrueHitInfo > baseMapT
typedef for shorter notation throughout the module
Definition: SpacePoint2TrueHitConnectorModule.h:176
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SpacePoint2TrueHitConnectorModule::m_weightTooSmallCtr
unsigned int m_weightTooSmallCtr
Count the omitted relations because of a too small weight.
Definition: SpacePoint2TrueHitConnectorModule.h:282
Belle2::SpacePoint2TrueHitConnectorModule::m_PXDTrueHits
Belle2::StoreArray< Belle2::PXDTrueHit > m_PXDTrueHits
PXDTrueHits StoreArray used throughout the module.
Definition: SpacePoint2TrueHitConnectorModule.h:241
Belle2::VXD::SensorInfoBase::getVPitch
double getVPitch(double v=0) const
Return the pitch of the sensor.
Definition: SensorInfoBase.h:150
Belle2::SpacePoint2TrueHitConnectorModule::m_nRelTrueHitsCtr
std::vector< std::array< unsigned int, 5 > > m_nRelTrueHitsCtr
counting different numbers of related TrueHits (to a SpacePoint) with one variable
Definition: SpacePoint2TrueHitConnectorModule.h:267
Belle2::SpacePoint2TrueHitConnectorModule::initializeCounters
void initializeCounters()
initialize all counters to 0 WARNING: only call in constructor of module!
Definition: SpacePoint2TrueHitConnectorModule.cc:388
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SpacePoint::Y
double Y() const
return the y-value of the global position of the SpacePoint
Definition: SpacePoint.h:136
Belle2::SpacePoint2TrueHitConnectorModule::compatibleCombination
bool compatibleCombination(Belle2::SpacePoint *spacePoint, TrueHitType *trueHit)
compares the TrueHit and the SpacePoint positions (global) to decide whether they are compatible NOTE...
Definition: SpacePoint2TrueHitConnectorModule.cc:703
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::SpacePoint2TrueHitConnectorModule::m_rootFilePtr
TFile * m_rootFilePtr
pointer to root file
Definition: SpacePoint2TrueHitConnectorModule.h:259
Belle2::MCParticle::hasStatus
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
Definition: MCParticle.h:140
Belle2::getUniqueKeys
std::vector< typename MapType::key_type > getUniqueKeys(const MapType &aMap)
get the unique keys of a map (i.e.
Definition: MapHelperFunctions.h:42
Belle2::simpleBitfield::addStatus
void addStatus(T __statusBits)
add a status to the bitfield (if it has not already been added)
Definition: SpacePoint2TrueHitConnectorModule.h:450
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2::SpacePoint2TrueHitConnectorModule::e_detTypes
e_detTypes
enum to distinguish the detectortypes
Definition: SpacePoint2TrueHitConnectorModule.h:181
Belle2::SpacePoint2TrueHitConnectorModule::getClusterSizes
std::pair< unsigned short int, unsigned short int > getClusterSizes(Belle2::SpacePoint *spacePoint, e_detTypes detType)
get the sizes of the related Clusters of a SpacePoint
Definition: SpacePoint2TrueHitConnectorModule.cc:864
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointULocal
std::vector< double > SpacePointULocal
SpacePoint local U-position.
Definition: SpacePoint2TrueHitConnectorModule.h:142
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::HitVxdID
std::vector< unsigned short int > HitVxdID
VxdID of the SpacePoint/TrueHit.
Definition: SpacePoint2TrueHitConnectorModule.h:157
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::SpacePoint2TrueHitConnectorModule::initialize
void initialize() override
initialize: initialize counters, check StoreArrays, register StoreArrays, ...
Definition: SpacePoint2TrueHitConnectorModule.cc:106
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMrequireProximity
bool m_PARAMrequireProximity
require the TrueHit to be close to the SpacePoint.
Definition: SpacePoint2TrueHitConnectorModule.h:223
Belle2::SpacePoint2TrueHitConnectorModule::m_regRelationsCtr
std::vector< unsigned int > m_regRelationsCtr
Number of registered relations.
Definition: SpacePoint2TrueHitConnectorModule.h:272
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::NRelations
std::vector< unsigned int > NRelations
Number of related TrueHits to a SpacePoint.
Definition: SpacePoint2TrueHitConnectorModule.h:159
Belle2::SpacePoint2TrueHitConnectorModule::m_outputSpacePoints
std::vector< Belle2::StoreArray< Belle2::SpacePoint > > m_outputSpacePoints
StoreArray of all output SpacePoints.
Definition: SpacePoint2TrueHitConnectorModule.h:250
Belle2::SpacePoint2TrueHitConnectorModule::m_SVDTrueHits
Belle2::StoreArray< Belle2::SVDTrueHit > m_SVDTrueHits
SVDTrueHits StoreArray used throughout the module.
Definition: SpacePoint2TrueHitConnectorModule.h:239
Belle2::MCParticle::getPDG
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:123
Belle2::SpacePoint2TrueHitConnectorModule::getRelatedTrueHits
MapType getRelatedTrueHits(Belle2::SpacePoint *spacePoint, std::string clusterName="ALL", std::string trueHitName="ALL")
get all the related TrueHits to the SpacePoint, including their weights in a map (multimap!...
Definition: SpacePoint2TrueHitConnectorModule.cc:332
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::WeightU
std::vector< double > WeightU
weight of the relation between the U-Cluster of the SpacePoint and the TrueHit
Definition: SpacePoint2TrueHitConnectorModule.h:154
Belle2::SpacePoint2TrueHitConnectorModule::calculateRelationWeight
double calculateRelationWeight(const TrueHitInfo &trueHitInfo, Belle2::SpacePoint *spacePoint)
calculate the Relation weight to be used (for SVD only, although method works with PXD as well!...
Definition: SpacePoint2TrueHitConnectorModule.cc:904
Belle2::SpacePoint2TrueHitConnectorModule::m_noClusterCtr
std::vector< unsigned int > m_noClusterCtr
Number of SpacePoints without relation to a Cluster (i.e.
Definition: SpacePoint2TrueHitConnectorModule.h:270
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMdetectorTypes
std::vector< std::string > m_PARAMdetectorTypes
detector type names as strings to determine which name belongs to which detector type
Definition: SpacePoint2TrueHitConnectorModule.h:207
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMstoreSeparate
bool m_PARAMstoreSeparate
switch for storing the SpacePoints that can be related to a TrueHit into separate StoreArrays,...
Definition: SpacePoint2TrueHitConnectorModule.h:214
Belle2::SpacePoint::getNormalizedLocalV
double getNormalizedLocalV() const
Return normalized local coordinates of the cluster in v (0 <= posV <= 1).
Definition: SpacePoint.h:164
Belle2::SpacePoint2TrueHitConnectorModule::m_ghostHitCtr
std::vector< unsigned int > m_ghostHitCtr
Number of SpacePoints that are considered ghost hits.
Definition: SpacePoint2TrueHitConnectorModule.h:274
Belle2::SpacePoint2TrueHitConnectorModule::positionAnalysis
void positionAnalysis(Belle2::SpacePoint *spacePoint, const MapType &trueHitMap, const int &index, e_detTypes detType)
Analyze the position of SpacePoints and corresponding TrueHits.
Definition: SpacePoint2TrueHitConnectorModule.cc:525
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointXGlobal
std::vector< double > SpacePointXGlobal
SpacePoint global X-position.
Definition: SpacePoint2TrueHitConnectorModule.h:144
Belle2::VXD::SensorInfoBase::SVD
@ SVD
SVD Sensor.
Definition: SensorInfoBase.h:45
Belle2::RelationsInterface::getArrayIndex
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Definition: RelationsObject.h:387
Belle2::VXD::SensorInfoBase::pointToGlobal
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
Definition: SensorInfoBase.h:373
Belle2::SpacePoint2TrueHitConnectorModule::m_rejectedRelsCtr
std::vector< unsigned int > m_rejectedRelsCtr
Number of SpacePoints that were not related to a TrueHit (i.e.
Definition: SpacePoint2TrueHitConnectorModule.h:280
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointErrorY
std::vector< double > SpacePointErrorY
positiion error of SpacePoint in Y direction (global)
Definition: SpacePoint2TrueHitConnectorModule.h:169
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMpositionAnalysis
bool m_PARAMpositionAnalysis
switch for doing the analysis of positions of SpacePoints and TrueHits
Definition: SpacePoint2TrueHitConnectorModule.h:219
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMclusterNames
std::vector< std::string > m_PARAMclusterNames
names of containers of Clusters
Definition: SpacePoint2TrueHitConnectorModule.h:209
Belle2::VXD::SensorInfoBase::getUPitch
double getUPitch(double v=0) const
Return the pitch of the sensor.
Definition: SensorInfoBase.h:143
Belle2::TrueHitInfo::m_U
bool m_U
if true, U-Cluster is used by SpacePoint
Definition: SpacePoint2TrueHitConnectorModule.h:54
Belle2::getAllValues
std::vector< typename MapType::mapped_type > getAllValues(const MapType &aMap)
get all values in the map (i.e.
Definition: MapHelperFunctions.h:143
Belle2::DataStore::c_ErrorIfAlreadyRegistered
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:74
Belle2::LogSystem::Instance
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:33
Belle2::VXD::SensorInfoBase::PXD
@ PXD
PXD Sensor.
Definition: SensorInfoBase.h:44
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointVLocal
std::vector< double > SpacePointVLocal
SpacePoint local V-position.
Definition: SpacePoint2TrueHitConnectorModule.h:143
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMtrueHitNames
std::vector< std::string > m_PARAMtrueHitNames
names of containers of TrueHits
Definition: SpacePoint2TrueHitConnectorModule.h:202
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::TrueHitVLocal
std::vector< double > TrueHitVLocal
TrueHit local V-position.
Definition: SpacePoint2TrueHitConnectorModule.h:149
Belle2::Module::addParam
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:562
Belle2::SpacePoint2TrueHitConnectorModule::processSpacePoint
MapType processSpacePoint(Belle2::SpacePoint *spacePoint, e_detTypes detType)
process a SpacePoint.
Definition: SpacePoint2TrueHitConnectorModule.cc:308
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointYGlobal
std::vector< double > SpacePointYGlobal
SpacePoint global Y-position.
Definition: SpacePoint2TrueHitConnectorModule.h:145
Belle2::SpacePoint2TrueHitConnectorModule::m_rootVariables
RootVariables m_rootVariables
Root variables used for collecting data eventwise.
Definition: SpacePoint2TrueHitConnectorModule.h:257
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::WeightV
std::vector< double > WeightV
weight of the relation between the V-Cluster of the SpacePoint and the TrueHit
Definition: SpacePoint2TrueHitConnectorModule.h:155
Belle2::RelationVector::weight
float weight(int index) const
Get weight with index.
Definition: RelationVector.h:120
Belle2::SpacePoint2TrueHitConnectorModule::registerAllRelations
void registerAllRelations(Belle2::SpacePoint *spacePoint, MapType trueHitMap, e_detTypes detType)
register a Relation to all the TrueHits in the trueHitMap for the passed SpacePoint
Definition: SpacePoint2TrueHitConnectorModule.cc:428
Belle2::LogConfig::c_Debug
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:36
Belle2::SpacePoint2TrueHitConnectorModule::getRelatedClusters
std::vector< std::pair< ClusterType *, double > > getRelatedClusters(Belle2::SpacePoint *spacePoint, std::string clusterName="ALL")
get the pointers to the related Clusters and the weight of the original Relations between the spacePo...
Definition: SpacePoint2TrueHitConnectorModule.cc:494
Belle2::VXD::GeoCache::getSensorInfo
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:68
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointZGlobal
std::vector< double > SpacePointZGlobal
SpacePoint global Z-position.
Definition: SpacePoint2TrueHitConnectorModule.h:146
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMminWeight
double m_PARAMminWeight
define a minimal weight a relation between Cluster and TrueHit.
Definition: SpacePoint2TrueHitConnectorModule.h:231
Belle2::Environment::Instance
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:31
Belle2::SpacePoint2TrueHitConnectorModule::m_inputSpacePoints
std::vector< std::pair< Belle2::StoreArray< Belle2::SpacePoint >, e_detTypes > > m_inputSpacePoints
StoreArray of all input SpacePoints.
Definition: SpacePoint2TrueHitConnectorModule.h:248
Belle2::SpacePoint2TrueHitConnectorModule::m_PARAMoutputSuffix
std::string m_PARAMoutputSuffix
suffix that will be appended to the StoreArray names of the output StoreArrays
Definition: SpacePoint2TrueHitConnectorModule.h:200
Belle2::B2Vector3::X
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:430
Belle2::SpacePoint2TrueHitConnectorModule::registerTrueHitRelation
void registerTrueHitRelation(Belle2::SpacePoint *spacePoint, int index, double weight, Belle2::StoreArray< TrueHitType > trueHits)
register the relation between a SpacePoint and the TrueHit (passed by index in the correspoinding Tru...
Definition: SpacePoint2TrueHitConnectorModule.cc:512
Belle2::SpacePoint2TrueHitConnectorModule::m_SpacePointsCtr
std::vector< unsigned int > m_SpacePointsCtr
Number of SpacePoints presented to the module.
Definition: SpacePoint2TrueHitConnectorModule.h:264
Belle2::SpacePoint2TrueHitConnectorModule::closeRootFile
void closeRootFile()
close root file
Definition: SpacePoint2TrueHitConnectorModule.cc:853
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::TrueHitYGlobal
std::vector< double > TrueHitYGlobal
TrueHit global Y-position.
Definition: SpacePoint2TrueHitConnectorModule.h:151
Belle2::SpacePoint2TrueHitConnectorModule::m_maxGlobalDiff
double m_maxGlobalDiff
storing the squared value of m_PARAMmaxGlobalDiff here to not alter the parameter input
Definition: SpacePoint2TrueHitConnectorModule.h:252
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::TrueHitULocal
std::vector< double > TrueHitULocal
TrueHit local U-position.
Definition: SpacePoint2TrueHitConnectorModule.h:148
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointErrorV
std::vector< double > SpacePointErrorV
position error of SpacePoint in V direction
Definition: SpacePoint2TrueHitConnectorModule.h:166
Belle2::simpleBitfield::getStatus
const T getStatus() const
get the status of the bitfield
Definition: SpacePoint2TrueHitConnectorModule.h:446
Belle2::DataStore::c_Event
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:61
Belle2::SpacePoint::getType
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
Definition: SpacePoint.h:155
Belle2::Module::getName
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:189
Belle2::TrueHitInfo::m_V
bool m_V
if true, V-Cluster is used by SpacePoint
Definition: SpacePoint2TrueHitConnectorModule.h:55
Belle2::SpacePoint::getNClustersAssigned
unsigned short getNClustersAssigned() const
Returns the number of Clusters assigned to this SpacePoint.
Definition: SpacePoint.h:175
Belle2::SpacePoint2TrueHitConnectorModule::getLocalError
std::pair< double, double > getLocalError(Belle2::SpacePoint *spacePoint)
get the position error of SpacePoints in local coordinates @retuns .first is U position error,...
Definition: SpacePoint2TrueHitConnectorModule.cc:881
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointErrorZ
std::vector< double > SpacePointErrorZ
positiion error of SpacePoint in Z direction (global)
Definition: SpacePoint2TrueHitConnectorModule.h:170
Belle2::simpleBitfield::setStatus
void setStatus(T __statusBits)
set the status of the bitfield (CAUTION: overwrites any previously defined status!...
Definition: SpacePoint2TrueHitConnectorModule.h:448
Belle2::SpacePoint2TrueHitConnectorModule::terminate
void terminate() override
terminate: print some summary information
Definition: SpacePoint2TrueHitConnectorModule.cc:262
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::printMap
std::string printMap(const MapType &aMap)
get the contents of the map as string.
Definition: MapHelperFunctions.h:164
Belle2::B2Vector3::Y
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:432
Belle2::MCParticle::c_PrimaryParticle
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:58
Belle2::RelationsInterface::getRelatedFrom
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Definition: RelationsObject.h:265
Belle2::SpacePoint::getPositionError
const B2Vector3< double > & getPositionError() const
return the hitErrors in sigma of the global position
Definition: SpacePoint.h:151
Belle2::SpacePoint::getVxdID
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
Definition: SpacePoint.h:158
Belle2::SpacePoint::convertNormalizedToLocalCoordinates
static std::pair< double, double > convertNormalizedToLocalCoordinates(const std::pair< double, double > &hitNormalized, Belle2::VxdID vxdID, const Belle2::VXD::SensorInfoBase *aSensorInfo=nullptr)
converts a hit in sensor-independent relative coordinates into local coordinate of given sensor.
Definition: SpacePoint.cc:181
Belle2::SpacePoint::getNormalizedLocalU
double getNormalizedLocalU() const
Return normalized local coordinates of the cluster in u (0 <= posU <= 1).
Definition: SpacePoint.h:161
Belle2::RT2SPTCConverterModule::initializeCounters
void initializeCounters()
reset counters to 0 to avoid indeterministic behaviour
Definition: RT2SPTCConverterModuleDev.h:85
Belle2::SpacePoint2TrueHitConnectorModule::RootVariables::SpacePointErrorX
std::vector< double > SpacePointErrorX
positiion error of SpacePoint in X direction (global)
Definition: SpacePoint2TrueHitConnectorModule.h:168