10 #include <tracking/modules/spacePointCreator/CurlingTrackCandSplitterModule.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/dataobjects/EventMetaData.h>
15 #include <framework/datastore/StoreObjPtr.h>
18 #include <pxd/dataobjects/PXDCluster.h>
19 #include <pxd/dataobjects/PXDTrueHit.h>
20 #include <svd/dataobjects/SVDCluster.h>
21 #include <svd/dataobjects/SVDTrueHit.h>
24 #include <tracking/spacePointCreation/SpacePoint.h>
25 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
27 #include <boost/format.hpp>
40 setDescription(
"Module for checking SpacePointTrackCands for curling behaviour and (if wanted) splitting them into SpacePointTrackCands that no longer show curling behaviour. WARNING: MODULE IS DEPRECATED use SPTCReferee instead!");
42 addParam(
"splitCurlers", m_PARAMsplitCurlers,
43 "Split curling SpacePointTrackCands into non-curling SpacePointTrackCands and store them",
true);
44 addParam(
"nTrackStubs", m_PARAMnTrackStubs,
45 "Maximum number of SpacePointTrackCand Stubs to be created from a curling SpacePointTrackCand. Set to 0 if you want all possible TrackCand Stubs",
48 addParam(
"SpacePointTCName", m_PARAMsptcName,
"Collection name of the SpacePointTrackCands to be analyzed for curling behaviour",
50 addParam(
"curlingFirstOutName", m_PARAMcurlingOutFirstName,
51 "Collection name under which the first outgoing part of a curling TrackCand will be stored in the StoreArray. The first part of a curling Track has its origin at the interaction point.",
53 addParam(
"curlingAllInName", m_PARAMcurlingAllInName,
54 "Collection name under which all ingoing parts of a curling TrackCand will be stored in the StoreArray", std::string(
""));
55 addParam(
"curlingRestOutName", m_PARAMcurlingOutRestName,
56 "Collection name under which all but the first outgoing parts of a curling TrackCand will be stored in the StoreArray",
58 addParam(
"completeCurlerName", m_PARAMcompleteCurlerName,
59 "Collection name under which all parts of a curling TrackCand will be stored in the StoreArray together. NOTE: only if this parameter is set to a non-empty string a complete (but splitted) curling TrackCand will be stored!",
63 std::vector<double> defaultOrigin = { 0., 0., 0. };
64 addParam(
"setOrigin", m_PARAMsetOrigin,
65 "WARNING: still need to find out the units that are used internally! Reset origin to given point. Used for determining the direction of flight of a particle for a given hit. Needs to be reset for e.g. testbeam, where origin is not at (0,0,0)",
68 addParam(
"positionAnalysis", m_PARAMpositionAnalysis,
69 "Set to true to investigate the positions of SpacePoints and TrueHits and write them to a ROOT file",
false);
71 std::vector<std::string> defaultRootFName;
72 defaultRootFName.push_back(
"PositionResiduals");
73 defaultRootFName.push_back(
"RECREATE");
75 addParam(
"rootFileName", m_PARAMrootFileName,
76 "Filename and write-mode ('RECREATE' or 'UPDATE'). If given more than 2 strings this module will cause termination",
80 addParam(
"useNonSingleTHinPA", m_PARAMuseNonSingleTHinPA,
81 "Switch for using SpacePoints in position Analysis that are related to more than one TrueHit",
false);
86 m_saveCompleteCurler =
false;
92 void CurlingTrackCandSplitterModule::initialize()
95 B2INFO(
"CurlingTrackCandSplitter ----------------------------- initialize() -------------------------------------");
96 B2WARNING(
"CurlingTrackCandSplitter is deprecated and will be removed from framework in the near future! use SPTCReferee instead!");
99 spacePointTCs.isRequired(m_PARAMsptcName);
103 if (m_PARAMcurlingOutFirstName.empty()) { emptyCtr++; }
104 if (m_PARAMcurlingAllInName.empty()) { emptyCtr++; }
105 if (m_PARAMcurlingOutRestName.empty()) { emptyCtr++; }
108 B2WARNING(
"CurlingTrackCandSplitter::initialize: More than one of your input strings for the collection names is empty. This can lead to undeterministic behaviour since two or more collections will be stored under the same name!");
113 curlingFirstOuts.registerInDataStore(m_PARAMcurlingOutFirstName, DataStore::c_ErrorIfAlreadyRegistered);
117 curlingAllIns.registerInDataStore(m_PARAMcurlingAllInName, DataStore::c_ErrorIfAlreadyRegistered);
121 curlingRestOuts.registerInDataStore(m_PARAMcurlingOutRestName, DataStore::c_ErrorIfAlreadyRegistered);
126 curlingCompletes.registerInDataStore(m_PARAMcompleteCurlerName, DataStore::c_ErrorIfAlreadyRegistered);
129 if (!m_PARAMcompleteCurlerName.empty()) {
130 m_saveCompleteCurler =
true;
131 B2DEBUG(1,
"You put in " << m_PARAMcompleteCurlerName <<
132 " as collection name for complete curling TrackCands. Complete curling TrackCands will hence be stored.");
135 "You did not put in any under which complete curling TrackCands should be stored, hence curling TrackCands will only be stored in parts.");
136 m_saveCompleteCurler =
false;
140 if (m_PARAMnTrackStubs < 0) {
141 B2WARNING(
"CurlingTrackCandSplitter::initialize> Value of nTrackStubs is below 0: nTrackStubs = " << m_PARAMnTrackStubs <<
142 ". Resetting this value to 0 now! This means that all parts of curling TrackCands will be stored.");
143 m_PARAMnTrackStubs = 0;
144 }
else { B2DEBUG(1,
"Entered value for nTrackStubs = " << m_PARAMnTrackStubs); }
146 B2DEBUG(1,
"Entered Value for splitCurlers: " << m_PARAMsplitCurlers);
148 if (m_PARAMsetOrigin.size() != 3) {
149 B2WARNING(
"CurlingTrackCandSplitter::initialize: Provided origin is not a 3D point! Please provide 3 values (x,y,z). Rejecting user input and setting origin to (0,0,0) for now!");
150 m_PARAMsetOrigin.clear();
151 m_PARAMsetOrigin.assign(3, 0);
153 m_origin.SetXYZ(m_PARAMsetOrigin.at(0), m_PARAMsetOrigin.at(1), m_PARAMsetOrigin.at(2));
154 B2DEBUG(10,
"Set origin to (x,y,z): (" << m_origin.X() <<
"," << m_origin.Y() <<
"," << m_origin.Z() <<
")");
156 if (m_PARAMpositionAnalysis) {
158 if (m_PARAMrootFileName.size() != 2 || (m_PARAMrootFileName[1] !=
"UPDATE" && m_PARAMrootFileName[1] !=
"RECREATE")) {
161 for (
string entry : m_PARAMrootFileName) { output +=
"'" + entry +
"' "; }
162 B2FATAL(
"CurlingTrackCandSplitter::initialize() : rootFileName is set wrong: entries are: " << output);
165 m_PARAMrootFileName[0] +=
".root";
166 m_rootFilePtr =
new TFile(m_PARAMrootFileName[0].c_str(), m_PARAMrootFileName[1].c_str());
167 m_treePtr =
new TTree(
"m_treePtr",
"aTree");
170 for (
int layer = 0; layer < c_nPlanes; ++layer) {
171 string layerString = (boost::format(
"%1%") % (layer +
174 string name =
"SpacePointXGlobal_" + layerString;
175 m_treePtr->Branch(name.c_str(), &m_rootSpacePointXGlobals.at(layer));
176 name =
"SpacePointYGlobal_" + layerString;
177 m_treePtr->Branch(name.c_str(), &m_rootSpacePointYGlobals.at(layer));
178 name =
"SpacePointZGlobal_" + layerString;
179 m_treePtr->Branch(name.c_str(), &m_rootSpacePointZGlobals.at(layer));
181 name =
"SpacePointULocal_" + layerString;
182 m_treePtr->Branch(name.c_str(), &m_rootSpacePointULocals.at(layer));
183 name =
"SpacePointVlocal_" + layerString;
184 m_treePtr->Branch(name.c_str(), &m_rootSpacePointVLocals.at(layer));
186 name =
"TrueHitXGlobal_" + layerString;
187 m_treePtr->Branch(name.c_str(), &m_rootTrueHitXGlobals.at(layer));
188 name =
"TrueHitYGlobal_" + layerString;
189 m_treePtr->Branch(name.c_str(), &m_rootTrueHitYGlobals.at(layer));
190 name =
"TrueHitZGlobal_" + layerString;
191 m_treePtr->Branch(name.c_str(), &m_rootTrueHitZGlobals.at(layer));
193 name =
"TrueHitULocal_" + layerString;
194 m_treePtr->Branch(name.c_str(), &m_rootTrueHitULocals.at(layer));
195 name =
"TrueHitVLocal_" + layerString;
196 m_treePtr->Branch(name.c_str(), &m_rootTrueHitVLocals.at(layer));
198 name =
"PosResidualsXGlobal_" + layerString;
199 m_treePtr->Branch(name.c_str(), &m_rootPosResidueXGlobal.at(layer));
200 name =
"PosResidualsYGlobal_" + layerString;
201 m_treePtr->Branch(name.c_str(), &m_rootPosResidueYGlobal.at(layer));
202 name =
"PosResidualsZGlobal_" + layerString;
203 m_treePtr->Branch(name.c_str(), &m_rootPosResidueZGlobal.at(layer));
205 name =
"PosResidualsULocal_" + layerString;
206 m_treePtr->Branch(name.c_str(), &m_rootPosResidueULocal.at(layer));
207 name =
"PosResidualsVLocal_" + layerString;
208 m_treePtr->Branch(name.c_str(), &m_rootPosResidueVLocal.at(layer));
211 name =
"LocalPositionResiduals_" + layerString;
212 m_treePtr->Branch(name.c_str(), &m_rootLocalPosResiduals.at(layer));
213 name =
"GlobalPositionResiduals_" + layerString;
214 m_treePtr->Branch(name.c_str(), &m_rootGlobalPosResiduals.at(layer));
216 name =
"MisMatchPosDistance_" + layerString;
217 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosDistance.at(layer));
218 name =
"MisMatchPosX_" + layerString;
219 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosX.at(layer));
220 name =
"MisMatchPosY_" + layerString;
221 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosY.at(layer));
222 name =
"MisMatchPosZ_" + layerString;
223 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosZ.at(layer));
225 name =
"MisMatchPosU_" + layerString;
226 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosU.at(layer));
227 name =
"MisMatchPosV_" + layerString;
228 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosV.at(layer));
230 name =
"MisMatchMomX_" + layerString;
231 m_treePtr->Branch(name.c_str(), &m_rootMisMatchMomX.at(layer));
232 name =
"MisMatchMomY_" + layerString;
233 m_treePtr->Branch(name.c_str(), &m_rootMisMatchMomY.at(layer));
234 name =
"MisMatchMomZ_" + layerString;
235 m_treePtr->Branch(name.c_str(), &m_rootMisMatchMomZ.at(layer));
238 m_rootFilePtr = NULL;
244 void CurlingTrackCandSplitterModule::event()
247 const int eventCounter = eventMetaDataPtr->getEvent();
248 B2DEBUG(10,
"CurlingTrackCandSplitter::event(). -------------- Processing event " << eventCounter <<
" ----------------");
260 B2DEBUG(15,
"Found " << nTCs <<
" SpacePointTrackCands in StoreArray " << spacePointTCs.getName() <<
" for this event");
264 for (
int iTC = 0; iTC < nTCs; ++iTC) {
268 B2DEBUG(15,
"=========================== Processing SpacePointTrackCand " << iTC <<
" ===============================");
270 const std::vector<int> splittingIndices = checkTrackCandForCurling(*spacePointTC, rootVariables);
272 if (splittingIndices.empty()) {
273 B2DEBUG(15,
"This SpacePointTrackCand shows no curling behaviour and will be added to collection: " << m_PARAMcurlingOutFirstName);
280 B2DEBUG(15,
"This SpacePointTrackCand shows curling behaviour");
281 if (!m_PARAMsplitCurlers) {
282 B2DEBUG(15,
"This SpacePointTrackCand could be split into " << splittingIndices.size() + 1 <<
283 " but will not, because splitCurlers is set to false");
288 std::vector<SpacePointTrackCand> trackStubs = splitCurlingTrackCand(*spacePointTC, m_PARAMnTrackStubs, splittingIndices);
292 m_createdTrackStubsCtr++;
293 if (m_saveCompleteCurler) {
298 if (!trackStub.isOutgoing()) {
303 if (trackStub.getTrackStubIndex() > 1) {
315 }
catch (FoundNoTrueHit& anE) {
316 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
317 " This TrackCandidate cannot be checked for curling behaviour");
318 m_noDecisionPossibleCtr++;
319 }
catch (FoundNoCluster& anE) {
320 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
321 " This TrackCandidate cannot be checked for curling behaviour");
322 m_noDecisionPossibleCtr++;
323 }
catch (TrueHitsNotMatching& anE) {
324 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
325 " This TrackCandidate cannot be checked for curling behaviour");
326 m_noDecisionPossibleCtr++;
327 }
catch (SpacePointTrackCand::UnsupportedDetType& anE) {
328 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
329 " This TrackCandidate cannot be checked for curling behaviour");
330 m_noDecisionPossibleCtr++;
334 if (m_PARAMpositionAnalysis) { writeToRoot(rootVariables); }
338 void CurlingTrackCandSplitterModule::terminate()
340 B2INFO(
"CurlingTrackCandSplitter::terminate(): checked " << m_spacePointTCCtr <<
" SpacePointTrackCands for curling behaviour. " <<
341 m_curlingTCCtr <<
" of them were curling and " << m_createdTrackStubsCtr <<
" TrackStubs were created. " << m_NoCurlingTCsCtr <<
342 " SPTCs were not curling and were merely copied into StoreArray " << m_PARAMcurlingOutFirstName <<
". In " <<
343 m_noDecisionPossibleCtr <<
" cases no decision could be made. There were " << m_NoSingleTrueHitCtr <<
344 " SpacePoints that were related to more than one TrueHit");
346 if (m_treePtr != NULL) {
349 m_rootFilePtr->Close();
357 const std::vector<const Belle2::SpacePoint*>& tcSpacePoints = SPTrackCand.
getHits();
358 unsigned int nHits = SPTrackCand.
getNHits();
360 B2DEBUG(70,
"SpacePointTrackCand contains " << nHits <<
" SpacePoints");
362 std::vector<int> returnVector;
364 std::pair<bool, bool>
369 for (
unsigned int iHit = 0; iHit < nHits; ++iHit) {
370 const SpacePoint* spacePoint = tcSpacePoints[iHit];
371 auto detType = spacePoint->
getType();
373 B2DEBUG(100,
"Now checking SpacePoint " << iHit <<
" in SPTC. This SpacePoint has Index " << spacePoint->
getArrayIndex() <<
379 if (detType == VXD::SensorInfoBase::PXD) {
387 if (pxdTrueHit == NULL) {
388 B2DEBUG(1,
"Found no PXDTrueHit for PXDCluster " << pxdCluster->
getArrayIndex() <<
" from Array " << pxdCluster->
getArrayName() <<
389 ". This PXDCluster is related with SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " << spacePoint->
getArrayName());
390 throw FoundNoTrueHit();
393 B2DEBUG(100,
"Found PXDCluster " << pxdCluster->
getArrayIndex() <<
" and " <<
" PXDTrueHit " << pxdTrueHit->getArrayIndex() <<
394 " from StoreArray " << pxdTrueHit->getArrayName() <<
" related to this SpacePoint");
396 B2DEBUG(100,
"Now getting global position and momentum for PXDCluster " << pxdCluster->
getArrayIndex() <<
" from Array " <<
398 hitGlobalPosMom = getGlobalPositionAndMomentum(pxdTrueHit);
401 if (m_PARAMpositionAnalysis) { getValuesForRoot(spacePoint, pxdTrueHit, rootVariables); }
403 }
else if (detType == VXD::SensorInfoBase::SVD) {
407 if (svdClusters.
size() == 0) {
408 B2WARNING(
"Found no related clusters for SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " << spacePoint->
getArrayName()
409 <<
". With no Cluster no information if a track is curling or not can be obtained");
410 throw FoundNoCluster();
415 std::vector<const SVDTrueHit*> svdTrueHits;
416 for (
const SVDCluster& aCluster : svdClusters) {
420 if (relTrueHits.
size() == 0) {
421 B2DEBUG(1,
"Found no SVDTrueHit for SVDCluster " << aCluster.getArrayIndex() <<
" from Array " << aCluster.getArrayName() <<
422 ". This SVDCluster is related with SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " << spacePoint->
getArrayName());
423 throw FoundNoTrueHit();
426 B2DEBUG(100,
"Found " << relTrueHits.
size() <<
" TrueHits for SVDCluster " << aCluster.getArrayIndex() <<
" from Array " <<
427 aCluster.getArrayName());
428 for (
unsigned int i = 0; i < relTrueHits.
size(); ++i) { svdTrueHits.push_back(relTrueHits[i]); }
443 if (svdTrueHits.size() >= 1) {
444 B2DEBUG(150,
"Found " << svdTrueHits.size() <<
" SVDTrueHits related to Clusters related to SpacePoint " <<
448 std::sort(svdTrueHits.begin(), svdTrueHits.end());
449 unsigned int oldSize = svdTrueHits.size();
450 auto newEnd = std::unique(svdTrueHits.begin(), svdTrueHits.end());
451 svdTrueHits.resize(std::distance(svdTrueHits.begin(), newEnd));
454 if (svdTrueHits.size() == oldSize) {
455 stringstream trueHitInds;
456 for (
const SVDTrueHit* trueHit : svdTrueHits) { trueHitInds << trueHit->getArrayIndex() <<
", "; }
457 B2DEBUG(1,
"There is no overlapping TrueHit for SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " <<
458 spacePoint->
getArrayName() <<
". The Indices of the TrueHits are: " << trueHitInds.str());
461 if (m_PARAMpositionAnalysis) {
462 std::vector<B2Vector3<double> > globalPositions;
463 std::vector<B2Vector3<double> > globalMomenta;
465 for (
unsigned int i = 0; i < svdTrueHits.size(); ++i) {
466 auto posMom = getGlobalPositionAndMomentum(svdTrueHits[i]);
467 globalPositions.push_back(posMom.first);
468 globalMomenta.push_back(posMom.second);
471 int layer = svdTrueHits[0]->getSensorID().getLayerNumber() - 1;
473 for (
unsigned int i = 1; i < globalPositions.size(); ++i) {
474 rootVariables.
MisMatchPosResiduals.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).Mag());
476 rootVariables.
MisMatchPosX.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).X());
477 rootVariables.
MisMatchPosY.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).Y());
478 rootVariables.
MisMatchPosZ.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).Z());
480 rootVariables.
MisMatchPosU.at(layer).push_back((svdTrueHits[i]->getU() - svdTrueHits[i - 1]->getU()));
481 rootVariables.
MisMatchPosV.at(layer).push_back((svdTrueHits[i]->getV() - svdTrueHits[i - 1]->getV()));
490 if (svdClusters.size() > 1) { TrueHitsNotMatching(); }
495 if (svdTrueHits.size() > 1) {
496 m_NoSingleTrueHitCtr++;
500 B2DEBUG(100,
"Now getting global position and momentum for SVDCluster " << svdClusters[0]->getArrayIndex() <<
" from Array " <<
501 svdClusters[0]->getArrayName() <<
" via SVDTrueHit " << svdTrueHits[0]->getArrayIndex() <<
" from StoreArray " <<
502 svdTrueHits[0]->getArrayName());
503 hitGlobalPosMom = getGlobalPositionAndMomentum(svdTrueHits[0]);
508 if (m_PARAMpositionAnalysis && (svdTrueHits.size() == 1 || m_PARAMuseNonSingleTHinPA)) { getValuesForRoot(spacePoint, svdTrueHits[0], rootVariables); }
511 throw SpacePointTrackCand::UnsupportedDetType();
515 directions.second = getDirectionOfFlight(hitGlobalPosMom, m_origin);
518 if (directions.first != directions.second) {
519 B2DEBUG(75,
"The direction of flight has changed for SpacePoint " << iHit <<
520 " in SpacePointTrackCand. The StoreArray index of this SpacePoint is " << spacePoint->
getArrayIndex() <<
" in " <<
522 returnVector.push_back(iHit);
525 directions.first = directions.second;
533 template<
class TrueHit>
535 CurlingTrackCandSplitterModule::getGlobalPositionAndMomentum(TrueHit* aTrueHit)
538 VxdID aVxdId = aTrueHit->getSensorID();
540 B2DEBUG(100,
"Getting global position and momentum vectors for TrueHit " << aTrueHit->getArrayIndex() <<
" from Array " <<
541 aTrueHit->getArrayName() <<
". This hit has VxdID " << aVxdId);
543 const VXD::GeoCache& geometry = VXD::GeoCache::getInstance();
550 B2DEBUG(100,
"Local position of hit is (" << hitLocal.
X() <<
"," << hitLocal.
Y() <<
"," << hitLocal.
Z() <<
551 "), Global position of hit is (" << hitGlobal.
X() <<
"," << hitGlobal.
Y() <<
"," << hitGlobal.
Z() <<
")");
555 B2DEBUG(100,
"Global momentum of hit is (" << pGlobal.
X() <<
"," << pGlobal.
Y() <<
"," << pGlobal.
Z() <<
")");
557 return std::make_pair(hitGlobal, pGlobal);
561 bool CurlingTrackCandSplitterModule::getDirectionOfFlight(
const
569 B2DEBUG(100,
"Position of hit relative to origin is (" << originToHit.
X() <<
"," << originToHit.
Y() <<
"," << originToHit.
Z() <<
570 "). Momentum relative to hit (relative to origin) (" << momentumAtHit.
X() <<
"," << momentumAtHit.
Y() <<
"," << momentumAtHit.
Z() <<
575 double hitRadComp = originToHit.
Perp();
576 double hitMomRadComp =
577 momentumAtHit.
Perp();
579 B2DEBUG(250,
" radial component of hit coordinates: " << hitRadComp <<
580 ", radial component of tip of momentum vector with its origin set to hit position: " << hitMomRadComp);
582 if (hitMomRadComp < hitRadComp) {
583 B2DEBUG(100,
"Direction of flight is inwards for this hit");
586 B2DEBUG(100,
"Direction of flight is outwards for this hit");
592 const std::vector<Belle2::SpacePointTrackCand>
594 const std::vector<int>& splitIndices)
596 std::vector<SpacePointTrackCand> spacePointTCs;
598 std::vector<std::pair<int, int> >
602 for (
int index : splitIndices) {
603 rangeIndices.push_back({firstIndex, index});
604 firstIndex = index + 1;
606 rangeIndices.push_back({firstIndex, SPTrackCand.
getNHits() - 1});
610 bool outgoing = splitIndices[0] != 0;
614 if (NTracklets < 1) { NTracklets = rangeIndices.size(); }
615 for (
unsigned iTr = 0; iTr < rangeIndices.size() && iTr < uint(NTracklets); ++iTr) {
617 int lastInd = rangeIndices[iTr].second;
618 int firstInd = rangeIndices[iTr].first;
620 B2DEBUG(75,
"Creating Track Stub " << iTr <<
" of " << splitIndices.size() <<
621 " possible Track Stub for this SpacePointTrackCand. The indices for this Tracklet are (first,last): (" << firstInd <<
"," << lastInd
622 <<
"). This SpacePointTrackCand contains " << SPTrackCand.
getNHits() <<
" SpacePoints in total.");
626 const std::vector<const SpacePoint*> trackletSpacePoints = SPTrackCand.
getHitsInRange(firstInd, lastInd);
641 outgoing = !outgoing;
646 spacePointTCs.push_back(newSPTrackCand);
647 }
catch (SpacePointTrackCand::SPTCIndexOutOfBounds& anE) {
648 B2WARNING(
"Caught an exception while trying to split SpacePointTrackCands: " << anE.what() <<
649 " This SPTC will be skipped from splitting!");
653 return spacePointTCs;
657 template <
class TrueHit>
658 void CurlingTrackCandSplitterModule::getValuesForRoot(
const Belle2::SpacePoint* spacePoint,
const TrueHit* trueHit,
661 B2DEBUG(100,
"Getting positions (for ROOT output) of SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " <<
662 spacePoint->
getArrayName() <<
" and TrueHit " << trueHit->getArrayIndex() <<
" from Array " << trueHit->getArrayName());
666 VxdID trueHitVxdId = trueHit->getSensorID();
679 const VXD::GeoCache& geometry = VXD::GeoCache::getInstance();
689 if (spLayer != thLayer) {
690 B2FATAL(
"Layer numbers of TrueHit and SpacePoint do not match!");
694 bool singleCluster =
true;
695 if (spacePointUV.
m_setU) {
697 rootVariables.
TrueHitULocal.at(thLayer).push_back(trueHit->getU());
698 rootVariables.
PosResidueULocal.at(spLayer).push_back((spacePointUV.
m_U - trueHit->getU()));
700 if (spacePointUV.
m_setV) {
702 rootVariables.
TrueHitVLocal.at(thLayer).push_back(trueHit->getV());
703 rootVariables.
PosResidueVLocal.at(spLayer).push_back((spacePointUV.
m_V - trueHit->getV()));
714 rootVariables.
PosResidueXGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).X());
715 rootVariables.
PosResidueYGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).Y());
716 rootVariables.
PosResidueZGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).Z());
718 rootVariables.
PosResiduesGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).Mag());
719 rootVariables.
PosResiduesLocal.at(spLayer).push_back((spacePointLocal - trueHitLocal).Mag());
721 singleCluster =
false;
724 B2DEBUG(200,
"Global (x,y,z)/Local (U,V) positions of SpacePoint: (" << spacePointGlobal.
X() <<
"," << spacePointGlobal.
Y() <<
","
725 << spacePointGlobal.
Z() <<
")/(" << spacePointLocal.
X() <<
"," << spacePointLocal.
Y() <<
"). This was a singleCluster SpacePoint: "
728 B2DEBUG(200,
"Global (x,y,z)/Local (U,V) positions of TrueHit: (" << trueHitGlobal.
X() <<
"," << trueHitGlobal.
Y() <<
"," <<
729 trueHitGlobal.
Z() <<
")/(" << trueHitLocal.
X() <<
"," << trueHitLocal.
Y() <<
")");
731 B2DEBUG(200,
"This leads to position differences global/local: " << (spacePointGlobal - trueHitGlobal).Mag() <<
"/" <<
732 (spacePointLocal - trueHitLocal).Mag());
737 void CurlingTrackCandSplitterModule::writeToRoot(
RootVariables& rootVariables)
786 std::pair<double, double> localUV = SpacePoint::convertNormalizedToLocalCoordinates(std::make_pair(normU, normV),
793 returnVals.
m_setU = setCoords.first;
794 returnVals.
m_setV = setCoords.second;
795 returnVals.
m_U = localUV.first;
796 returnVals.
m_V = localUV.second;
802 void CurlingTrackCandSplitterModule::initializeCounters()
804 m_createdTrackStubsCtr = 0;
806 m_noDecisionPossibleCtr = 0;
807 m_spacePointTCCtr = 0;
808 m_NoSingleTrueHitCtr = 0;
809 m_NoCurlingTCsCtr = 0;