Belle II Software  release-05-01-25
SPTCRefereeModule.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/SPTCRefereeModule.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/dataobjects/EventMetaData.h>
16 
17 #include <tracking/spacePointCreation/SpacePoint.h>
18 #include <pxd/dataobjects/PXDTrueHit.h>
19 #include <svd/dataobjects/SVDTrueHit.h>
20 #include <vxd/dataobjects/VxdID.h>
21 
22 #include <framework/geometry/B2Vector3.h> // use TVector3 instead?
23 #include <boost/range/adaptor/reversed.hpp> // for ranged based loops in reversed order
24 
25 using namespace Belle2;
26 using namespace std;
27 
28 REG_MODULE(SPTCReferee) // register the module
29 
31 {
32  setDescription("Module that does some sanity checks on SpacePointTrackCands to prevent some problematic cases to be "
33  "forwarded to other modules that rely on 'unproblematic' cases (e.g. FilterCalculator). "
34  "Different checks can be enabled by setting the according flags. Using MC information for "
35  "the tests can also be switched on/off for tests where MC information can be helpful.");
37 
38  // names
39  addParam("sptcName", m_PARAMsptcName,
40  "Container name of the SpacePointTrackCands to be checked (input)",
41  m_PARAMsptcName);
42  addParam("newArrayName", m_PARAMnewArrayName,
43  "Container name of SpacePointTrackCands if 'storeNewArray' is set to true",
44  m_PARAMnewArrayName);
45  addParam("curlingSuffix", m_PARAMcurlingSuffix,
46  "Suffix that will be used to get a name for the StoreArray in which the trackStubs that are obtained by "
47  "splitting a curling SPTC get stored. NOTE: If 'storeNewArray' is set to true, "
48  "this will not be used and all output SPTCs will be in the same Array!",
49  m_PARAMcurlingSuffix);
50 
51  // flags
52  addParam("checkSameSensor", m_PARAMcheckSameSensor,
53  "Check if two subsequent SpacePoints are on the same sensor",
54  m_PARAMcheckSameSensor);
55  addParam("checkMinDistance", m_PARAMcheckMinDistance,
56  "Check if two subsequent SpacePoints are seperated by more than 'minDistance'",
57  m_PARAMcheckMinDistance);
58  addParam("checkCurling", m_PARAMcheckCurling,
59  "Check the SpacePointTrackCand for curling behaviour and mark it as curling if it does",
60  m_PARAMcheckCurling);
61  addParam("splitCurlers", m_PARAMsplitCurlers,
62  "Split curling SpacePointTrackCands and save the TrackStubs in seperate StoreArrays",
63  m_PARAMsplitCurlers);
64  addParam("keepOnlyFirstPart", m_PARAMkeepOnlyFirstPart,
65  "Keep only the first part of a curling SpacePointTrackCand (e.g. when only this is needed)",
66  m_PARAMkeepOnlyFirstPart);
67  addParam("useMCInfo", m_PARAMuseMCInfo,
68  "Set to true if the use of MC information (e.g. from underlying TrueHits) for the checks is wanted, "
69  "and to false if the checks should all be done with information that can be obtained from "
70  "SpacePoints directly. NOTE: the tests without MC information have to be developed first!",
71  m_PARAMuseMCInfo);
72  addParam("kickSpacePoint", m_PARAMkickSpacePoint,
73  "Set to true if only the 'problematic' SpacePoint shall be kicked and not the whole SpacePointTrackCand",
74  m_PARAMkickSpacePoint);
75  addParam("storeNewArray", m_PARAMstoreNewArray,
76  "Set to true if the checked SpacePointTrackCands should be stored in a new StoreArray."
77  "WARNING: all previously registered relations get lost in this way!",
78  m_PARAMstoreNewArray);
79 
80  // other
81  addParam("minDistance", m_PARAMminDistance,
82  "Minimal Distance [cm] that two subsequent SpacePoints have to be seperated if 'checkMinDistance' is enabled",
83  m_PARAMminDistance);
84  addParam("setOrigin", m_PARAMsetOrigin, "WARNING: still need to find out the units that are used internally! "
85  "Reset origin to given point. Used for determining the direction of flight of a particle for a "
86  "given hit. Needs to be reset for e.g. testbeam, where origin is not at (0,0,0)",
87  m_PARAMsetOrigin);
88 
89  addParam("minNumSpacePoints", m_PARAMminNumSpacePoints,
90  "minimum number of space points that a track candidate has to "
91  "contain (added later, set to 0 to reproduce old behavior",
92  m_PARAMminNumSpacePoints);
93 
94  addParam("checkIfFitted", m_PARAMcheckIfFitted,
95  "If true a flag is set in the SpacePointTrackCandidate if any related RecoTrack "
96  "with successful track fit is found",
97  m_PARAMcheckIfFitted);
98 
99  // initialize counters (cppcheck)
100  initializeCounters();
101 }
102 
103 // ======================================================================= INITIALIZE =============================================
105 {
106  B2INFO("SPTCReferee::initialize(): ------------------------------------------------ ");
107  // check if StoreArray of SpacePointTrackCands is her
109  inputSpacePoints.isRequired(m_PARAMsptcName);
110 
111  // register new StoreArray
112  if (m_PARAMstoreNewArray) {
115  newStoreArray.registerRelationTo(inputSpacePoints, DataStore::c_Event, DataStore::c_DontWriteOut);
116  } else {
118  B2DEBUG(20, "StoreArray name of the curling parts: " << m_curlingArrayName);
121  newStoreArray.registerRelationTo(inputSpacePoints, DataStore::c_Event, DataStore::c_DontWriteOut);
122  }
123 
124  // sanity checks on the other parameters
126  if (m_PARAMminDistance < 0) {
127  B2WARNING("minDistance set to value below 0: " << m_PARAMminDistance <<
128  ", Taking the absolute value and resetting 'minDistance' to that!");
130  }
131  }
132 
133  B2DEBUG(20, "Provided Parameters: checkSameSensor - " << m_PARAMcheckSameSensor << ", checkMinDistance - " <<
135  << ", checkCurling - " << m_PARAMcheckCurling << ", splitCurlers - " << m_PARAMsplitCurlers << ", keepOnlyFirstPart - " <<
136  m_PARAMkeepOnlyFirstPart << ", useMCInfo - " << m_PARAMuseMCInfo << ", kickSpacePoint - " << m_PARAMkickSpacePoint);
137  if (m_PARAMsetOrigin.size() != 3) {
138  B2WARNING("CurlingTrackCandSplitter::initialize: Provided origin is not a 3D point! Please provide 3 values (x,y,z). "
139  "Rejecting user input and setting origin to (0,0,0) for now!");
140  m_PARAMsetOrigin.clear();
141  m_PARAMsetOrigin.assign(3, 0);
142  }
144  B2DEBUG(20, "Set origin to (x,y,z): (" << m_origin.X() << "," << m_origin.Y() << "," << m_origin.Z() << ")");
145 
147 }
148 
149 // ======================================================================== EVENT =================================================
151 {
152  StoreObjPtr<EventMetaData> eventMetaDataPtr("EventMetaData", DataStore::c_Event);
153  const int eventCtr = eventMetaDataPtr->getEvent();
154  B2DEBUG(20, "Processing event " << eventCtr << " -----------------------");
155 
157  const int nTCs = trackCands.getEntries();
158 
159  m_totalTrackCandCtr += nTCs;
160 
161  B2DEBUG(20, "Found " << nTCs << " SpacePointTrackCands in Array " << trackCands.getName() << " for this event");
162 
163  for (int iTC = 0; iTC < nTCs; ++iTC) { // loop over all TrackCands
164  SpacePointTrackCand* trackCand = trackCands[iTC];
165  B2DEBUG(20, "Processing SpacePointTrackCand " << iTC << ": It has " << trackCand->getNHits() << " SpacePoints in it");
166 
167  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 200, PACKAGENAME())) { trackCand->print(); }
168  B2DEBUG(20, "refereeStatus of TrackCand before tests: " << trackCand->getRefereeStatus() << " -> " <<
169  trackCand->getRefereeStatusString());
170 
171  // if all tests will be performed -> add checkedByReferee status to the SPTC,
172  // CAUTION: if there are new tests this has to be updated!!!, WARNING: if curling check fails,
173  // checkedForCurling will return false but hasRefereeStatus(c_checkedByReferee) will return true after this module!
176  }
177  bool allChecksClean = true; // assume that all tests will be passed, change to false if one of them fails
178  CheckInfo prevChecksInfo;
179 
180 
181  // added check for the number of space points in the track candidate
182  if ((int)(trackCand->getNHits()) < m_PARAMminNumSpacePoints) {
183  allChecksClean = false;
184  }
185 
186 
187  // set a flag if a fitted recotrack is found for that trackcand
188  if (m_PARAMcheckIfFitted) {
189  // take any related recotrack
190  RelationVector<RecoTrack> relatedRecoTracks = trackCand->getRelationsTo<RecoTrack>("ALL");
191  if (relatedRecoTracks.size() >= 1) {
192  // assume that there is only one!
193  if (relatedRecoTracks[0]->wasFitSuccessful()) {
195  } else {
196  allChecksClean = false;
197  B2DEBUG(20, "Found RecoTrack was not fitted! Will not use this track candidate for training.");
198  }
199  } else {
200  allChecksClean = false;
201  B2DEBUG(20, "No related RecoTrack found. Will not use that track candidate for training");
202  }
203  }
204 
205 
206  // check same sensors if desired
208  const std::vector<int> sameSensorInds = checkSameSensor(trackCand);
209  std::get<0>(prevChecksInfo) = sameSensorInds;
210  if (!sameSensorInds.empty()) {
211  m_SameSensorCtr++;
212  allChecksClean = false;
213  // assign the actually removed indices to the prevChecksInfo
214  if (m_PARAMkickSpacePoint) {
215  std::get<0>(prevChecksInfo) = removeSpacePoints(trackCand, sameSensorInds);
216  } else {
217  // only add status if the SpacePoints on the same sensors have not been removed!
219  }
220  } else {
221  B2DEBUG(20, "Found no two subsequent SpacePoints on the same sensor for this SpacePointTrackCand ("
222  << iTC << " in Array " << trackCands.getName() << ")");
223  }
225  B2DEBUG(20, "refereeStatus of TrackCand after checkSameSensor " << trackCand->getRefereeStatus() << " -> " <<
226  trackCand->getRefereeStatusString());
227  }
228 
229 
230  // check min distance if desired
232  const std::vector<int> lowDistanceInds = checkMinDistance(trackCand, m_PARAMminDistance);
233  std::get<1>(prevChecksInfo) = lowDistanceInds;
234  if (!lowDistanceInds.empty()) {
236  allChecksClean = false;
237  // assign the actually removed indices to the prevChecksInfo
238  if (m_PARAMkickSpacePoint) {
239  std::get<1>(prevChecksInfo) = removeSpacePoints(trackCand, lowDistanceInds);
240  } else {
241  // only add status if the SpacePoints not far enough apart have not been removed!
243  }
244  } else {
245  B2DEBUG(20, "Found no two subsequent SpacePoints that were closer than " << m_PARAMminDistance <<
246  " cm together for this SpacePointTrackCand (" << iTC << " in Array " << trackCands.getName() << ")");
247  }
249  B2DEBUG(20, "refereeStatus of TrackCand after checkMinDistance " << trackCand->getRefereeStatus() << " -> " <<
250  trackCand->getRefereeStatusString());
251  }
252 
253  // vector of TrackStubs that shall be saved to another StoreArray
254  std::vector<SpacePointTrackCand> curlingTrackStubs;
255  // check curling if desired
256  if (m_PARAMcheckCurling) {
257  // setting the TrackStubIndex to 0 implies that this trackCand has been checked for curling.
258  // (If there is something wrong in the curling check this value is reset to -1!)
259  trackCand->setTrackStubIndex(0);
260  const std::vector<int> curlingSplitInds = checkCurling(trackCand, m_PARAMuseMCInfo);
261  if (!curlingSplitInds.empty()) {
262  if (!(curlingSplitInds.at(0) == 0 && curlingSplitInds.size() == 1)) {
263  // this means essentially that the direction of flight for this SPTC is inwards for all SpacePoints!
265  allChecksClean = false;
266  if (m_PARAMsplitCurlers) {
267  curlingTrackStubs = splitTrackCand(trackCand, curlingSplitInds, m_PARAMkeepOnlyFirstPart, prevChecksInfo, m_PARAMkickSpacePoint);
268  if (curlingTrackStubs.empty()) {
269  B2ERROR("The vector returned by splitTrackCand is empty!");
270  } // safety measure
271  }
272  // set this to the original SPTC only after splitting to avoid having this status in the trackStubs
274  } else {
275  B2DEBUG(20, "The only entry in the return vector of checkCurling is 0! The direction of flight is inwards for the whole SPTC!");
276  trackCand->setFlightDirection(false);
277  m_allInwardsCtr++;
278  }
279  } else {
280  B2DEBUG(20, "SpacePointTrackCand " << trackCand->getArrayIndex() << " is not curling!");
281  }
282  B2DEBUG(20, "refereeStatus of TrackCand after checkCurling " << trackCand->getRefereeStatus() << " -> " <<
283  trackCand->getRefereeStatusString());
284  }
285 
286  // PROCESSING AFTER CHECKS
287  if (allChecksClean) trackCand->addRefereeStatus(SpacePointTrackCand::c_checkedClean);
288 
289  B2DEBUG(20, "referee Status of SPTC after referee module: " << trackCand->getRefereeStatus() << " -> " <<
290  trackCand->getRefereeStatusString());
291  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 200, PACKAGENAME())) { trackCand->print();}
292 
293  // store in appropriate StoreArray
294  if (m_PARAMstoreNewArray) {
296  if (!trackCand->isCurling()) { copyToNewStoreArray(trackCand, newArray); }
297  else {
298  for (const SpacePointTrackCand& trackStub : curlingTrackStubs) { addToStoreArray(trackStub, newArray, trackCand); }
299  }
300  } else {
302  if (trackCand->isCurling()) {
303  for (const SpacePointTrackCand& trackStub : curlingTrackStubs) { addToStoreArray(trackStub, curlingArray, trackCand); }
304  }
305  }
306  }
307 }
308 
309 // ============================================================================= TERMINATE ========================================
311 {
312  // TODO: info output more sophisticated
313  stringstream summary;
315  summary << "Checked for consecutive SpacePoints on same sensor and found "
316  << m_SameSensorCtr << " TrackCands showing this behavior.\n";
317  }
319  summary << "Checked for minimal distance between two consecutive SpacePoints and found "
320  << m_minDistanceCtr << " TrackCands with SpacePoints not far enough apart.\n";
321  }
322  if (m_PARAMkickSpacePoint) {
323  summary << m_kickedSpacePointsCtr << " SpacePoints have been removed from SpacePointTrackCands\n";
324  }
325  if (m_PARAMcheckCurling) {
326  summary << m_curlingTracksCtr << " SPTCs were curling. Registered "
327  << m_regTrackStubsCtr << " track stubs. 'splitCurlers' was set to "
328  << m_PARAMsplitCurlers << ", 'keepOnlyFirstPart' was set to "
329  << m_PARAMkeepOnlyFirstPart << ". There were "
330  << m_allInwardsCtr << " SPTCs that had flight direction 'inward' for all SpacePoints in them";
331  }
332 
333  B2INFO("SPTCRefere::terminate(): Module got " << m_totalTrackCandCtr << " SpacePointTrackCands. \n" << summary.str());
334 
336  B2WARNING("The curling checking without MC Information is at the moment at a very crude and unsophisticated state. "
337  "If you have MC information available you should use it to do this check!");
338  }
339 }
340 
341 // ====================================================================== CHECK SAME SENSORS ======================================
343 {
344  B2DEBUG(20, "Checking SpacePointTrackCand " << trackCand->getArrayIndex() << " from Array " << trackCand->getArrayName() <<
345  " for consecutive SpacePoints on the same sensor");
346  std::vector<int> sameSensorInds; // return vector
347 
348  std::vector<const SpacePoint*> spacePoints = trackCand->getHits();
349 
350  // catch cases where the TC has no space points! (Yes that happens!)
351  if (spacePoints.size() == 0) return sameSensorInds;
352 
353  VxdID lastSensorId = spacePoints.at(0)->getVxdID();
354 
355  for (unsigned int iSp = 1; iSp < spacePoints.size(); ++iSp) {
356  VxdID sensorId = spacePoints.at(iSp)->getVxdID();
357  B2DEBUG(20, "Checking SpacePoint " << iSp << ". (ArrayIndex " << spacePoints.at(iSp)->getArrayIndex() <<
358  ") SensorId of this SpacePoint: " << sensorId << ", SensorId of last SpacePoint: " << lastSensorId);
359  if (sensorId == lastSensorId) {
360  // push back the index of the first SpacePoint (50:50 chance of getting the right one without further testing) -> retrieving the other index is no big science from this index!!
361  sameSensorInds.push_back(iSp - 1);
362  B2DEBUG(20, "SpacePoint " << iSp << " and " << iSp - 1 << " are on the same sensor: " << sensorId);
363  }
364  lastSensorId = sensorId;
365  }
366 
367  return sameSensorInds;
368 }
369 
370 // ========================================================================= CHECK MIN DISTANCE ===================================
371 const std::vector<int> SPTCRefereeModule::checkMinDistance(Belle2::SpacePointTrackCand* trackCand, double minDistance)
372 {
373  B2DEBUG(20, "Checking the distances between consecutive SpacePoints for SpacePointTrackCand " << trackCand->getArrayIndex() <<
374  " from Array " << trackCand->getArrayIndex());
375  std::vector<int> lowDistanceInds; // return vector
376 
377  std::vector<const SpacePoint*> spacePoints = trackCand->getHits();
378 
379  // catch case where the track candidate has no spacepoints
380  if (spacePoints.size() == 0) return lowDistanceInds;
381 
382  B2Vector3F oldPosition = spacePoints.at(0)->getPosition();
383 
384  for (unsigned int iSp = 1; iSp < spacePoints.size(); ++iSp) {
385  B2Vector3F position = spacePoints.at(iSp)->getPosition();
386  B2Vector3F diffPos = oldPosition - position;
387  B2DEBUG(20, "Position of SpacePoint " << iSp << " (ArrayIndex " << spacePoints.at(iSp)->getArrayIndex() << "): (" << position.X() <<
388  "," << position.Y() << "," << position.Z() << "), Position of SpacePoint " << iSp - 1 << ": (" << oldPosition.X() << "," <<
389  oldPosition.Y() << "," << oldPosition.Z() << ") --> old - new = (" << diffPos.X() << "," << diffPos.Y() << "," << diffPos.Z() <<
390  ")");
391 
392  if (diffPos.Mag() <= minDistance) {
393  B2DEBUG(20, "Position difference is " << diffPos.Mag() << " but minDistance is set to " << minDistance << ". SpacePoints: " << iSp
394  << " and " << iSp - 1);
395  // push back the index of the first SpacePoint (50:50 chance of getting the right one without further testing)
396  lowDistanceInds.push_back(iSp);
397  }
398  oldPosition = position;
399  }
400 
401  return lowDistanceInds;
402 }
403 
404 // ============================================================= REMOVE SPACEPOINTS ===============================================
405 const std::vector<int>
406 SPTCRefereeModule::removeSpacePoints(Belle2::SpacePointTrackCand* trackCand, const std::vector<int>& indsToRemove)
407 {
408  std::vector<int> removedInds; // return vector
409  try {
410  unsigned int nInds = indsToRemove.size();
411  B2DEBUG(20, "Got " << nInds << " indices to remove from SPTC " << trackCand->getArrayIndex());
412 
413  int nRemoved = 0;
414  for (int index : boost::adaptors::reverse(indsToRemove)) { // reverse iteration as trackCand gets 'resized' with every remove
415  B2DEBUG(20, "Removing " << nRemoved + 1 << " from " << nInds << ". index = " << index); // +1 only for better readability
416  trackCand->removeSpacePoint(index);
417  nRemoved++;
419  B2DEBUG(20, "Removed SpacePoint " << index << " from SPTC " << trackCand->getArrayIndex());
420  // NOTE: this way if a removed SpacePoint is "at the edge" between two trackStubs the status will be assigned to the second of those!
421  removedInds.push_back(index - (nInds - nRemoved));
422  }
424  } catch (SpacePointTrackCand::SPTCIndexOutOfBounds& anE) {
425  B2WARNING("Caught an Exception while trying to remove a SpacePoint from a SpacePointTrackCand: " << anE.what());
426  }
427 
428  return removedInds;
429 }
430 // =========================================================== CHECK CURLING ======================================================
431 const std::vector<int> SPTCRefereeModule::checkCurling(Belle2::SpacePointTrackCand* trackCand, bool useMCInfo)
432 {
433  std::vector<int> splitInds; // return vector
434 
435  //catch cases where there are no space points in the trackCand!
436  if (trackCand->getHits().size() == 0) return splitInds;
437 
438  // Only do curling checking if useMCInfo is false, OR if useMCInfo is true if the SPTCs SpacePoints have been checked for a relation to TrueHits!
440 
441  std::string mcInfoStr = useMCInfo ? std::string("with") : std::string("without");
442  B2DEBUG(20, "Checking SpacePointTrackCand " << trackCand->getArrayIndex() << " from Array " << trackCand->getArrayName() <<
443  " for curling behavior " << mcInfoStr << " MC Information");
444 
445  // get the SpacePoints of the TrackCand
446  const std::vector<const SpacePoint*>& tcSpacePoints = trackCand->getHits();
447  B2DEBUG(20, "SPTC has " << tcSpacePoints.size() << " SpacePoints");
448 
449  // get the directions of flight for every SpacePoint
450  const std::vector<bool> dirsOfFlight = getDirectionsOfFlight(tcSpacePoints, useMCInfo);
451 
452  // if(trackCand->getNHits() != dirsOfFlight.size()) B2FATAL("did not get a direction of flight for every SpacePoint"); // should not /cannot happen
453 
454  // loop over all entries of dirsOfFlight and compare them pair-wise. If they change -> add Index to splitInds.
455  if (!dirsOfFlight.at(0)) {
456  // if the direction of flight is inwards for the first hit, push_back 0 -> make information accessible from outside this function
457  splitInds.push_back(0);
458  B2DEBUG(20, "Direction of flight was inwards for first SpacePoint of this SPTC");
459  }
460  // DEBUG output
461  B2DEBUG(20, "Direction of flight is " << dirsOfFlight.at(0) << " for SpacePoint " << 0 << " of this SPTC");
462  for (unsigned int i = 1; i < dirsOfFlight.size(); ++i) {
463  B2DEBUG(20, "Direction of flight is " << dirsOfFlight.at(i) << " for SpacePoint " << i << " of this SPTC");
464  if (dirsOfFlight.at(i) ^ dirsOfFlight.at(i - 1)) {
465  splitInds.push_back(i); // NOTE: using the bitoperator for XOR here to determine if the bools differ!
466  B2DEBUG(20, "Direction of flight has changed from SpacePoint " << i - 1 << " to " << i << ".");
467  }
468  } // END DEBUG output
469  } else {
470  B2ERROR("'useMCInfo' is set to true, but SpacePoints of SPTC have not been checked for relations to TrueHits! Not Checking this SPTC for curling!");
471  trackCand->setTrackStubIndex(-1); // reset to not being checked for curling
472  }
473  return splitInds;
474 }
475 
476 // ============================================================ SPLIT CURLING TRACK CAND ==========================================
477 std::vector<Belle2::SpacePointTrackCand>
478 SPTCRefereeModule::splitTrackCand(const Belle2::SpacePointTrackCand* trackCand, const std::vector<int>& splitIndices,
479  bool onlyFirstPart, const CheckInfo& prevChecksInfo, bool removedHits)
480 {
481  std::vector<SpacePointTrackCand> trackStubs; // return vector
482 
483  B2DEBUG(20, "Splitting SpacePointTrackCand " << trackCand->getArrayIndex() << " from Array " << trackCand->getArrayName() <<
484  ": number of entries in splitIndices " << splitIndices.size());
485  // int trackStub = 0;
486  bool dirOfFlight = splitIndices.at(0) != 0; // if first entry is zero the direction of flight is false (= ingoing)
487 
488  B2DEBUG(20, "first entry of passed vector<int> is " << splitIndices.at(0) << " --> direction of flight is " << dirOfFlight);
489  // if the first entry of splitIndices is zero the first TrackStub is from 0 to second entry instead of from 0 to first entry
490  int firstLast = dirOfFlight ? splitIndices.at(0) : splitIndices.at(1);
491  std::vector<std::pair<int, int> >
492  rangeIndices; // .first is starting, .second is final index for each TrackStub. Store them in vector to be able to easily loop over them
493  rangeIndices.push_back(std::make_pair(0, firstLast));
494 
495  if (!onlyFirstPart) { // if more than the first part is desired push_back the other ranges too
496  unsigned int iStart = dirOfFlight ? 1 : 2;
497  for (unsigned int i = iStart; i < splitIndices.size(); ++i) {
498  rangeIndices.push_back(std::make_pair(splitIndices.at(i - 1), splitIndices.at(i)));
499  }
500  // last TrackStub is from last split index to end of TrackCand
501  rangeIndices.push_back(std::make_pair(splitIndices.at(splitIndices.size() - 1), trackCand->getNHits()));
502  }
503  B2DEBUG(20, "There will be " << rangeIndices.size() << " TrackStubs created for this TrackCand. (size of the passed splitIndices: "
504  << splitIndices.size() << ", onlyFirstPart " << onlyFirstPart);
505 
506  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 999, PACKAGENAME())) {
507  stringstream dbOutput;
508  dbOutput << "The indices that will be used for splitting the SPTC: ";
509  for (auto entry : rangeIndices) { dbOutput << "[" << entry.first << "," << entry.second << ") "; }
510  B2DEBUG(20, dbOutput.str());
511  }
512 
513  // loop over all entries in range indices and create a SpacePointTrackCand from it
514  for (unsigned int iTs = 0; iTs < rangeIndices.size(); ++iTs) {
515  int firstInd = rangeIndices.at(iTs).first;
516  int lastInd = rangeIndices.at(iTs).second;
517 
518  unsigned short int refStatus = getCheckStatus(trackCand);
519 
520  B2DEBUG(20, "Trying to create TrackStub from SPTC " << trackCand->getArrayIndex() << " with indices [" << firstInd << "," <<
521  lastInd << ")");
522  // encapsulate in try block to catch indices out of range
523  try {
524  const std::vector<const SpacePoint*> spacePoints = trackCand->getHitsInRange(firstInd, lastInd);
525  const std::vector<double> sortingParams = trackCand->getSortingParametersInRange(firstInd, lastInd);
526 
527  // create new TrackCand
528  SpacePointTrackCand trackStub(spacePoints, trackCand->getPdgCode(), trackCand->getChargeSeed(), trackCand->getMcTrackID());
529  trackStub.setSortingParameters(sortingParams);
530 
531  // set the state seed and the cov seed only for the first trackStub of the TrackCand
532  if (iTs < 1) {
533  trackStub.set6DSeed(trackCand->getStateSeed());
534  trackStub.setCovSeed(trackCand->getCovSeed());
535  }
536 
537  // set the direction of flight and flip it afterwards, because next trackCand hs changed direction of flight
538  trackStub.setFlightDirection(dirOfFlight);
539  dirOfFlight = !dirOfFlight;
540 
541  // trackStub index starts at 1 for curling SPTCs. NOTE: this might be subject to chagnes with the new bitfield in SpacePointTrackCand
542  trackStub.setTrackStubIndex(iTs + 1);
543 
544  // determine and set the referee status of this trackStub based upon the information from the previous tests
545  const std::vector<int>& sameSensInds = std::get<0>(prevChecksInfo);
546  const std::vector<int>& lowDistInds = std::get<0>(prevChecksInfo);
547  bool hasSameSens = vectorHasValueBetween(sameSensInds, rangeIndices.at(iTs));
548  bool hasLowDist = vectorHasValueBetween(lowDistInds, rangeIndices.at(iTs));
549  if ((hasSameSens || hasLowDist) && removedHits) refStatus += SpacePointTrackCand::c_removedHits;
550  if (hasSameSens && !removedHits) refStatus += SpacePointTrackCand::c_hitsOnSameSensor;
551  if (hasLowDist && !removedHits) refStatus += SpacePointTrackCand::c_hitsLowDistance;
552 
553  trackStub.setRefereeStatus(refStatus);
554  B2DEBUG(20, "Set TrackStubIndex " << iTs + 1 << " and refereeStatus " << trackStub.getRefereeStatus() <<
555  " for this trackStub (refStatus string: " << trackStub.getRefereeStatusString());
556 
557  trackStubs.push_back(trackStub);
558  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, 499, PACKAGENAME())) { trackStub.print(); }
559  } catch (SpacePointTrackCand::SPTCIndexOutOfBounds& anE) {
560  B2WARNING("Caught an exception while trying to split a curling SpacePointTrackCand: " << anE.what() <<
561  " This trackStub will not be created!");
562  }
563  }
564 
565  return trackStubs;
566 }
567 
568 // ========================================================= GET DIRECTIONS OF FLIGHT =============================================
569 const std::vector<bool>
570 SPTCRefereeModule::getDirectionsOfFlight(const std::vector<const Belle2::SpacePoint*>& spacePoints, bool useMCInfo)
571 {
572  std::vector<bool> dirsOfFlight; // return vector
573 
574  if (useMCInfo) {
575  try {
576  for (const SpacePoint* spacePoint : spacePoints) { // loop over all SpacePoints
577  if (spacePoint->getType() == VXD::SensorInfoBase::PXD) {
578  dirsOfFlight.push_back(getDirOfFlightTrueHit<PXDTrueHit>(spacePoint, m_origin));
579  } else if (spacePoint->getType() == VXD::SensorInfoBase::SVD) {
580  dirsOfFlight.push_back(getDirOfFlightTrueHit<SVDTrueHit>(spacePoint, m_origin));
581  } else throw
582  SpacePointTrackCand::UnsupportedDetType(); // NOTE: should never happen, because SpacePointTrackCand can only handle PXD and SVD at the moment!
583  }
584  } catch (SpacePointTrackCand::UnsupportedDetType& anE) {
585  B2FATAL("Caught a fatal exception while checking if a SpacePointTrackCand curls: " <<
586  anE.what()); // FATAL because if this happens this needs some time to implement and it affects more than only this module!
587  }
588  } else {
589  dirsOfFlight = getDirsOfFlightSpacePoints(spacePoints, m_origin);
590  }
591 
592  return dirsOfFlight;
593 }
594 
595 // ================================================ GET DIRECTION OF FLIGHT FROM TRUEHIT ==========================================
596 template <typename TrueHitType>
598 {
599  TrueHitType* trueHit = spacePoint->template getRelatedTo<TrueHitType>("ALL"); // COULDDO: search only certain arrays
600 
601  if (trueHit == NULL) { B2ERROR("Found no TrueHit to SpacePoint " << spacePoint->getArrayIndex() << " from Array " << spacePoint->getArrayName()); }
602 
603  // get SensorId - needed for transforming local to global coordinates
604  VxdID vxdID = trueHit->getSensorID();
605 
606  const VXD::SensorInfoBase& sensorInfoBase = VXD::GeoCache::getInstance().getSensorInfo(vxdID);
607  B2Vector3F position = sensorInfoBase.pointToGlobal(B2Vector3F(trueHit->getU(), trueHit->getV(), 0), true); // global position
608  B2Vector3F momentum = sensorInfoBase.vectorToGlobal(trueHit->getMomentum(), true); // global momentum
609 
610  B2DEBUG(20, "Getting the direction of flight for SpacePoint " << spacePoint->getArrayIndex() << ", related to TrueHit " <<
611  trueHit->getArrayIndex() << ". Both are on Sensor " << vxdID << ". (TrueHit) Position: (" << position.x() << "," << position.y() <<
612  "," << position.z() << "), (TrueHit) Momentum: (" << momentum.x() << "," << momentum.y() << "," << momentum.z() << ")");
613 
614  return getDirOfFlightPosMom(position, momentum, origin);
615 }
616 
617 // ==================================================== GET DIRECTION OF FLIGHT FROM SPACEPOINT ===================================
618 std::vector<bool>
619 SPTCRefereeModule::getDirsOfFlightSpacePoints(const std::vector<const Belle2::SpacePoint*>& spacePoints, B2Vector3F origin)
620 {
621  std::vector<bool> dirsOfFlight; // return vector
622 
623  B2Vector3F oldPosition = origin; // assumption: first position is origin
624  for (unsigned int iSP = 0; iSP < spacePoints.size(); ++iSP) {
625  B2Vector3F position = spacePoints.at(iSP)->getPosition();
626  // estimate momentum by linearizing between old position and new position -> WARNING: not a very good estimate!!!
627  B2Vector3F momentumEst = position - oldPosition;
628  B2DEBUG(20, "Getting the direction of flight for SpacePoint " << spacePoints.at(iSP)->getArrayIndex() << ". Position: (" <<
629  position.x() << "," << position.y() << "," << position.z() << "), estimated momentum: (" << momentumEst.x() << "," <<
630  momentumEst.y() << "," << momentumEst.z() << ")");
631  dirsOfFlight.push_back(getDirOfFlightPosMom(position, momentumEst, origin));
632  oldPosition = position; // reassign for next round
633  }
634 
635  return dirsOfFlight;
636 }
637 
638 // =============================================== GET DIRECTION OF FLIGHT FROM POSITION AND MOMENTUM =============================
640 {
641  // calculate the positon relative to the set origin, and add the momentum to the position to get the direction of flight
642  B2Vector3F originToHit = position - origin;
643 
644  B2DEBUG(20, "Position relative to origin: (" << originToHit.x() << "," << originToHit.y() << "," << originToHit.z() <<
645  "). Momentum : (" << momentum.x() << "," << momentum.y() << "," <<
646  momentum.z() << ").");
647 
648  // get dot product of momentum and hit position for the perpendicular component only!
649  float dot_xy = originToHit.x() * momentum.x() + originToHit.y() * momentum.y();
650 
651  B2DEBUG(20, "result dot product xy component between postion and momentum: " << dot_xy);
652 
653  if (dot_xy < 0) {
654  B2DEBUG(20, "Direction of flight is inwards for this hit");
655  return false;
656  } else {
657  B2DEBUG(20, "Direction of flight is outwards for this hit");
658  return true;
659  }
660 }
661 
662 // ============================================ COPY TO NEW STORE ARRAY ===========================================================
665 {
666  SpacePointTrackCand* newTC = newStoreArray.appendNew(*trackCand);
667  newTC->addRelationTo(trackCand);
668  B2DEBUG(20, "Added new SPTC to StoreArray " << newStoreArray.getName() << " and registered relation to SPTC " <<
669  trackCand->getArrayIndex() << " from Array " << trackCand->getArrayName());
670 }
671 
672 // =================================================== ADD TO STORE ARRAY =========================================================
675  const Belle2::SpacePointTrackCand* origTrackCand)
676 {
677  SpacePointTrackCand* newTC = storeArray.appendNew(trackCand);
678  newTC->addRelationTo(origTrackCand);
679  B2DEBUG(20, "Added new SPTC to StoreArray " << storeArray.getName() << " and registered relation to SPTC " <<
680  origTrackCand->getArrayIndex() << " from Array " << origTrackCand->getArrayName());
682 }
683 
684 // ======================================================== GET CHECK STATUS ======================================================
686 {
687  unsigned short int status = trackCand->getRefereeStatus();
691  return status;
692 }
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::SPTCRefereeModule::splitTrackCand
std::vector< Belle2::SpacePointTrackCand > splitTrackCand(const Belle2::SpacePointTrackCand *trackCand, const std::vector< int > &splitIndices, bool onlyFirstPart, const CheckInfo &prevChecksInfo, bool removedHits)
split a curling SpacePointTrackCand into TrackStubs.
Definition: SPTCRefereeModule.cc:478
Belle2::SPTCRefereeModule::m_PARAMcheckIfFitted
bool m_PARAMcheckIfFitted
if true it is looked for any related RecoTrack and if that RecoTrack has a valid fit.
Definition: SPTCRefereeModule.h:81
Belle2::SPTCRefereeModule::m_kickedSpacePointsCtr
unsigned int m_kickedSpacePointsCtr
counter of kicked SpacePoints
Definition: SPTCRefereeModule.h:134
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SpacePointTrackCand::isCurling
bool isCurling() const
get if the TrackCand is curling.
Definition: SpacePointTrackCand.h:261
Belle2::StoreArray::registerRelationTo
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:150
Belle2::SpacePointTrackCand::getHitsInRange
const std::vector< const Belle2::SpacePoint * > getHitsInRange(int firstInd, int lastInd) const
get hits (SpacePoints) in range (indices of SpacePoint inside SpacePointTrackCand) including first in...
Definition: SpacePointTrackCand.cc:69
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::SPTCRefereeModule::m_PARAMkeepOnlyFirstPart
bool m_PARAMkeepOnlyFirstPart
parameter for keeping only the first part of a curling SpacePointTrackCand
Definition: SPTCRefereeModule.h:93
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::SpacePointTrackCand::setRefereeStatus
void setRefereeStatus(unsigned short int bitmask)
set referee status (resets the complete to the passed status!)
Definition: SpacePointTrackCand.h:341
Belle2::B2Vector3::x
DataType x() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:424
Belle2::SPTCRefereeModule::initialize
void initialize() override
initialize: check StoreArrays, initialize counters, ...
Definition: SPTCRefereeModule.cc:104
Belle2::SpacePointTrackCand::addRefereeStatus
void addRefereeStatus(unsigned short int bitmask)
add a referee status
Definition: SpacePointTrackCand.h:344
Belle2::SpacePointTrackCand::setSortingParameters
void setSortingParameters(const std::vector< double > &sortParams)
set the sorting parameters
Definition: SpacePointTrackCand.cc:136
Belle2::SPTCRefereeModule::m_origin
B2Vector3F m_origin
origin used internally.
Definition: SPTCRefereeModule.h:117
Belle2::SPTCRefereeModule::initializeCounters
void initializeCounters()
initialize all counters to 0
Definition: SPTCRefereeModule.h:148
Belle2::VXD::SensorInfoBase::vectorToGlobal
TVector3 vectorToGlobal(const TVector3 &local, bool reco=false) const
Convert a vector from local to global coordinates.
Definition: SensorInfoBase.h:383
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::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::SPTCRefereeModule::getDirOfFlightTrueHit
bool getDirOfFlightTrueHit(const Belle2::SpacePoint *spacePoint, B2Vector3F origin)
get the direction of flight for a SpacePoint by using information from the underlying TrueHit NOTE: t...
Definition: SPTCRefereeModule.cc:597
Belle2::SpacePointTrackCand::c_checkedSameSensors
@ c_checkedSameSensors
bit 6: It has been checked, if two consecutive SpacePoints are on the same sensor for this SPTC.
Definition: SpacePointTrackCand.h:89
Belle2::SPTCRefereeModule::checkMinDistance
const std::vector< int > checkMinDistance(Belle2::SpacePointTrackCand *trackCand, double minDistance)
Check if two subsequent SpacePoints are seperated by at least the provided minDistance.
Definition: SPTCRefereeModule.cc:371
Belle2::DataStore::c_DontWriteOut
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:73
Belle2::SPTCRefereeModule::m_allInwardsCtr
unsigned int m_allInwardsCtr
counter for the number of SPTCs which have direction of flight inward for all SpacePoints in them
Definition: SPTCRefereeModule.h:143
Belle2::SpacePointTrackCand::setCovSeed
void setCovSeed(const TMatrixDSym &cov)
set the covariance matrix seed
Definition: SpacePointTrackCand.h:313
Belle2::SPTCRefereeModule::event
void event() override
event: check SpacePointTrackCands
Definition: SPTCRefereeModule.cc:150
Belle2::SPTCRefereeModule::m_PARAMcurlingSuffix
std::string m_PARAMcurlingSuffix
Suffix that will be used to get a name for the StoreArray that holds the trackStubs that were obtaine...
Definition: SPTCRefereeModule.h:75
Belle2::B2Vector3::Z
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:434
Belle2::SpacePointTrackCand::print
void print(int debuglevel=150, const Option_t *="") const
print the Track Candidate in its "full beauty".
Definition: SpacePointTrackCand.cc:160
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::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SPTCRefereeModule::removeSpacePoints
const std::vector< int > removeSpacePoints(Belle2::SpacePointTrackCand *trackCand, const std::vector< int > &indsToRemove)
remove the SpacePoint passed to this function from the SpacePointTrackCand
Definition: SPTCRefereeModule.cc:406
Belle2::SpacePointTrackCand::setTrackStubIndex
void setTrackStubIndex(int trackStubInd)
set TrackStub index
Definition: SpacePointTrackCand.h:338
Belle2::B2Vector3< float >
Belle2::SPTCRefereeModule::getDirectionsOfFlight
const std::vector< bool > getDirectionsOfFlight(const std::vector< const Belle2::SpacePoint * > &spacePoints, bool useMCInfo)
get the directions of Flight for every SpacePoint in the passed vector.
Definition: SPTCRefereeModule.cc:570
Belle2::SpacePointTrackCand::c_checkedTrueHits
@ c_checkedTrueHits
bit 5: All SpacePoints of the SPTC have a relation to at least one TrueHit.
Definition: SpacePointTrackCand.h:86
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SpacePointTrackCand::getNHits
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
Definition: SpacePointTrackCand.h:154
Belle2::SpacePointTrackCand::c_curlingTrack
@ c_curlingTrack
bit 8: SPTC is curling (resp.
Definition: SpacePointTrackCand.h:91
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::SpacePointTrackCand::getSortingParametersInRange
const std::vector< double > getSortingParametersInRange(int firstIndex, int lastIndex) const
get the sorting parameters in range (indices of SpacePoints inside SpacePointTrackCand) including fir...
Definition: SpacePointTrackCand.cc:86
Belle2::SPTCRefereeModule::m_PARAMstoreNewArray
bool m_PARAMstoreNewArray
parameter for indicating if all checked SpacePointTrackCands should be stored in a new StoreArray NOT...
Definition: SPTCRefereeModule.h:106
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::SpacePointTrackCand::getRefereeStatusString
std::string getRefereeStatusString(std::string delimiter=" ") const
get the refereeStatus as a string (easier to read than an unsigned short int)
Definition: SpacePointTrackCand.cc:211
Belle2::SpacePointTrackCand::set6DSeed
void set6DSeed(const TVectorD &state6D)
set the 6D state seed
Definition: SpacePointTrackCand.h:308
Belle2::SPTCRefereeModule::terminate
void terminate() override
terminate: print some summary information
Definition: SPTCRefereeModule.cc:310
Belle2::SPTCRefereeModule::m_curlingTracksCtr
unsigned int m_curlingTracksCtr
counter for tracks that curl
Definition: SPTCRefereeModule.h:137
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2::SpacePointTrackCand::removeSpacePoint
void removeSpacePoint(int indexInTrackCand)
remove a SpacePoint (and its sorting parameter) from the SpacePointTrackCand
Definition: SpacePointTrackCand.cc:146
Belle2::SPTCRefereeModule::m_PARAMsetOrigin
std::vector< double > m_PARAMsetOrigin
assumed interaction point from which the SpacePointTrackCands emerge.
Definition: SPTCRefereeModule.h:112
Belle2::SPTCRefereeModule::getDirOfFlightPosMom
bool getDirOfFlightPosMom(B2Vector3F position, B2Vector3F momentum, B2Vector3F origin)
get the direction of flight provided the global position and momentum of a SpacePoint/TrueHit for the...
Definition: SPTCRefereeModule.cc:639
Belle2::SpacePointTrackCand::getPdgCode
int getPdgCode() const
get pdg code
Definition: SpacePointTrackCand.h:164
Belle2::SpacePointTrackCand::getHits
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
Definition: SpacePointTrackCand.h:131
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::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::SPTCRefereeModule::copyToNewStoreArray
void copyToNewStoreArray(const Belle2::SpacePointTrackCand *trackCand, Belle2::StoreArray< Belle2::SpacePointTrackCand > newStoreArray)
copy the SpacePointTrackCand to a new StoreArray and register a relation to the original trackCand
Definition: SPTCRefereeModule.cc:663
Belle2::SPTCRefereeModule::m_SameSensorCtr
unsigned int m_SameSensorCtr
counter for TrackCands with SpacePoints on the same sensor
Definition: SPTCRefereeModule.h:125
Belle2::SpacePointTrackCand::setFlightDirection
void setFlightDirection(bool direction)
set the direction of flight (true is outgoing, false is ingoing).
Definition: SpacePointTrackCand.h:335
Belle2::SpacePointTrackCand::c_hitsOnSameSensor
@ c_hitsOnSameSensor
bit 2: SPTC has two (or more) SpacePoints on same sensor.
Definition: SpacePointTrackCand.h:81
Belle2::SPTCRefereeModule::m_PARAMcheckMinDistance
bool m_PARAMcheckMinDistance
parameter for indicating if the check for the minimal distance between two subsequent SpacePoints sho...
Definition: SPTCRefereeModule.h:84
Belle2::SPTCRefereeModule::m_PARAMuseMCInfo
bool m_PARAMuseMCInfo
parameter for indicating if MC information should be used or not
Definition: SPTCRefereeModule.h:96
Belle2::SPTCRefereeModule::m_PARAMnewArrayName
std::string m_PARAMnewArrayName
Name of the output container of SpacePointTrackCands if 'storeNewArray' is set to true.
Definition: SPTCRefereeModule.h:71
Belle2::SPTCRefereeModule::m_curlingArrayName
std::string m_curlingArrayName
name of the StoreArray in which the trackStubs from a curling SPTC are stored
Definition: SPTCRefereeModule.h:120
Belle2::SPTCRefereeModule::m_PARAMkickSpacePoint
bool m_PARAMkickSpacePoint
parameter for indicating if only the 'problematic' SpacePoint shall be removed from the SPTC or if th...
Definition: SPTCRefereeModule.h:99
Belle2::SPTCRefereeModule::CheckInfo
std::tuple< std::vector< int >, std::vector< int > > CheckInfo
typedef for storing the outcome of previously done checks to have them available later.
Definition: SPTCRefereeModule.h:63
Belle2::SPTCRefereeModule::addToStoreArray
void addToStoreArray(const Belle2::SpacePointTrackCand &trackCand, Belle2::StoreArray< Belle2::SpacePointTrackCand > storeArray, const Belle2::SpacePointTrackCand *origTrackCand)
register the SpacePointTrackCand (i.e.
Definition: SPTCRefereeModule.cc:673
Belle2::SpacePointTrackCand::hasRefereeStatus
bool hasRefereeStatus(unsigned int short bitmask) const
Check if the SpacePointTrackCand has the status characterized by the bitmask.
Definition: SpacePointTrackCand.h:217
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::SPTCRefereeModule::m_PARAMminDistance
double m_PARAMminDistance
minimal distance two subsequent SpacePoints have to be seperated
Definition: SPTCRefereeModule.h:109
Belle2::SpacePointTrackCand::c_removedHits
@ c_removedHits
bit 4: SpacePoints were removed from this SPTC.
Definition: SpacePointTrackCand.h:85
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::SpacePointTrackCand::getChargeSeed
double getChargeSeed() const
get charge
Definition: SpacePointTrackCand.h:169
Belle2::SPTCRefereeModule::SPTCRefereeModule
SPTCRefereeModule()
Constructor.
Belle2::B2Vector3::y
DataType y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:426
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::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::SPTCRefereeModule::checkSameSensor
const std::vector< int > checkSameSensor(Belle2::SpacePointTrackCand *trackCand)
Check if two subsequent SpacePoints are on the same sensor.
Definition: SPTCRefereeModule.cc:342
Belle2::SPTCRefereeModule::m_regTrackStubsCtr
unsigned int m_regTrackStubsCtr
counter for the number of track stubs that were registered by this module
Definition: SPTCRefereeModule.h:140
Belle2::SPTCRefereeModule::vectorHasValueBetween
bool vectorHasValueBetween(std::vector< T > V, std::pair< T, T > P)
function to determine if any of the values in vector V are between the values of P (i....
Definition: SPTCRefereeModule.h:240
Belle2::SPTCRefereeModule::m_PARAMsplitCurlers
bool m_PARAMsplitCurlers
parameter for switching on/off the splitting of curling SpacePointTrackCands
Definition: SPTCRefereeModule.h:90
Belle2::SpacePointTrackCand::getRefereeStatus
unsigned short int getRefereeStatus(unsigned short int bitmask=USHRT_MAX) const
Return the refere status code of the SpacePointTrackCand.
Definition: SpacePointTrackCand.h:212
Belle2::SPTCRefereeModule::m_PARAMsptcName
std::string m_PARAMsptcName
Name of input container of SpacePointTrackCands.
Definition: SPTCRefereeModule.h:68
Belle2::SpacePointTrackCand::c_checkedMinDistance
@ c_checkedMinDistance
bit 7: It has been checked if two consecutive SpacePoints are far enough apart.
Definition: SpacePointTrackCand.h:90
Belle2::LogConfig::c_Debug
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:36
Belle2::B2Vector3::z
DataType z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:428
Belle2::SPTCRefereeModule::checkCurling
const std::vector< int > checkCurling(Belle2::SpacePointTrackCand *trackCand, bool useMCInfo)
Check if the SpacePointTrackCand shows curling behavior.
Definition: SPTCRefereeModule.cc:431
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::SPTCRefereeModule::m_totalTrackCandCtr
unsigned int m_totalTrackCandCtr
counter for the total number of TrackCands
Definition: SPTCRefereeModule.h:131
Belle2::StoreArray< SpacePointTrackCand >
Belle2::SpacePointTrackCand::getStateSeed
const TVectorD & getStateSeed() const
get state seed as 6D vector
Definition: SpacePointTrackCand.h:175
Belle2::SpacePointTrackCand::getCovSeed
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
Definition: SpacePointTrackCand.h:172
Belle2::B2Vector3::X
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:430
Belle2::SpacePointTrackCand::c_checkedClean
@ c_checkedClean
bit 1: SPTC shows no 'problematic' behaviour.
Definition: SpacePointTrackCand.h:80
Belle2::SPTCRefereeModule::m_PARAMcheckSameSensor
bool m_PARAMcheckSameSensor
parameter for indicating if the check for subsequent SpacePoints being on the same sensor should be d...
Definition: SPTCRefereeModule.h:78
Belle2::B2Vector3F
B2Vector3< float > B2Vector3F
typedef for common usage with float
Definition: B2Vector3.h:510
Belle2::SpacePointTrackCand::c_hasFittedRecoTrack
@ c_hasFittedRecoTrack
bit 13: SPTC is related to a RecoTrack which has a successful fit.
Definition: SpacePointTrackCand.h:96
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::SpacePointTrackCand::getMcTrackID
int getMcTrackID() const
get the MC Track ID
Definition: SpacePointTrackCand.h:201
Belle2::B2Vector3::SetXYZ
void SetXYZ(DataType x, DataType y, DataType z)
set all coordinates using data type
Definition: B2Vector3.h:459
Belle2::SPTCRefereeModule::m_PARAMminNumSpacePoints
int m_PARAMminNumSpacePoints
only keep track candidates which have at least m_PARAMminNumSpacePoints space points
Definition: SPTCRefereeModule.h:102
Belle2::SpacePointTrackCand::c_hitsLowDistance
@ c_hitsLowDistance
bit 3: SPTC has two (or more) SpacePoints that are not far enough apart.
Definition: SpacePointTrackCand.h:84
Belle2::B2Vector3::Mag
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition: B2Vector3.h:158
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::B2Vector3::Y
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:432
Belle2::SpacePointTrackCand::c_checkedByReferee
@ c_checkedByReferee
bit 0: SPTC has been checked by a Referee (all possible tests).
Definition: SpacePointTrackCand.h:79
Belle2::SpacePointTrackCand
Storage for (VXD) SpacePoint-based track candidates.
Definition: SpacePointTrackCand.h:51
Belle2::SPTCRefereeModule::m_minDistanceCtr
unsigned int m_minDistanceCtr
counter for TrackCands with SpacePoints not far enough apart
Definition: SPTCRefereeModule.h:128
Belle2::SPTCRefereeModule::getCheckStatus
unsigned short int getCheckStatus(const Belle2::SpacePointTrackCand *trackCand)
get the checked referee status of a SPTC (i.e.
Definition: SPTCRefereeModule.cc:685
Belle2::SPTCRefereeModule::getDirsOfFlightSpacePoints
std::vector< bool > getDirsOfFlightSpacePoints(const std::vector< const Belle2::SpacePoint * > &spacePoints, B2Vector3F origin)
get the directions of flight for a vector of SpacePoints using only information from SpacePoints (i....
Definition: SPTCRefereeModule.cc:619
Belle2::SPTCRefereeModule::m_PARAMcheckCurling
bool m_PARAMcheckCurling
parameter for indicating if the SpacePointTrackCand should be checked for curling
Definition: SPTCRefereeModule.h:87