9 #include <tracking/modules/spacePointCreator/CurlingTrackCandSplitterModule.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/dataobjects/EventMetaData.h>
14 #include <framework/datastore/StoreObjPtr.h>
17 #include <pxd/dataobjects/PXDCluster.h>
18 #include <pxd/dataobjects/PXDTrueHit.h>
19 #include <svd/dataobjects/SVDCluster.h>
20 #include <svd/dataobjects/SVDTrueHit.h>
23 #include <tracking/spacePointCreation/SpacePoint.h>
24 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
26 #include <boost/format.hpp>
39 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!");
41 addParam(
"splitCurlers", m_PARAMsplitCurlers,
42 "Split curling SpacePointTrackCands into non-curling SpacePointTrackCands and store them",
true);
43 addParam(
"nTrackStubs", m_PARAMnTrackStubs,
44 "Maximum number of SpacePointTrackCand Stubs to be created from a curling SpacePointTrackCand. Set to 0 if you want all possible TrackCand Stubs",
47 addParam(
"SpacePointTCName", m_PARAMsptcName,
"Collection name of the SpacePointTrackCands to be analyzed for curling behaviour",
49 addParam(
"curlingFirstOutName", m_PARAMcurlingOutFirstName,
50 "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.",
52 addParam(
"curlingAllInName", m_PARAMcurlingAllInName,
53 "Collection name under which all ingoing parts of a curling TrackCand will be stored in the StoreArray", std::string(
""));
54 addParam(
"curlingRestOutName", m_PARAMcurlingOutRestName,
55 "Collection name under which all but the first outgoing parts of a curling TrackCand will be stored in the StoreArray",
57 addParam(
"completeCurlerName", m_PARAMcompleteCurlerName,
58 "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!",
62 std::vector<double> defaultOrigin = { 0., 0., 0. };
63 addParam(
"setOrigin", m_PARAMsetOrigin,
64 "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)",
67 addParam(
"positionAnalysis", m_PARAMpositionAnalysis,
68 "Set to true to investigate the positions of SpacePoints and TrueHits and write them to a ROOT file",
false);
70 std::vector<std::string> defaultRootFName;
71 defaultRootFName.push_back(
"PositionResiduals");
72 defaultRootFName.push_back(
"RECREATE");
74 addParam(
"rootFileName", m_PARAMrootFileName,
75 "Filename and write-mode ('RECREATE' or 'UPDATE'). If given more than 2 strings this module will cause termination",
79 addParam(
"useNonSingleTHinPA", m_PARAMuseNonSingleTHinPA,
80 "Switch for using SpacePoints in position Analysis that are related to more than one TrueHit",
false);
85 m_saveCompleteCurler =
false;
87 m_rootFilePtr =
nullptr;
91 void CurlingTrackCandSplitterModule::initialize()
94 B2INFO(
"CurlingTrackCandSplitter ----------------------------- initialize() -------------------------------------");
95 B2WARNING(
"CurlingTrackCandSplitter is deprecated and will be removed from framework in the near future! use SPTCReferee instead!");
102 if (m_PARAMcurlingOutFirstName.empty()) { emptyCtr++; }
103 if (m_PARAMcurlingAllInName.empty()) { emptyCtr++; }
104 if (m_PARAMcurlingOutRestName.empty()) { emptyCtr++; }
107 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!");
112 curlingFirstOuts.
registerInDataStore(m_PARAMcurlingOutFirstName, DataStore::c_ErrorIfAlreadyRegistered);
116 curlingAllIns.
registerInDataStore(m_PARAMcurlingAllInName, DataStore::c_ErrorIfAlreadyRegistered);
120 curlingRestOuts.
registerInDataStore(m_PARAMcurlingOutRestName, DataStore::c_ErrorIfAlreadyRegistered);
125 curlingCompletes.
registerInDataStore(m_PARAMcompleteCurlerName, DataStore::c_ErrorIfAlreadyRegistered);
128 if (!m_PARAMcompleteCurlerName.empty()) {
129 m_saveCompleteCurler =
true;
130 B2DEBUG(1,
"You put in " << m_PARAMcompleteCurlerName <<
131 " as collection name for complete curling TrackCands. Complete curling TrackCands will hence be stored.");
134 "You did not put in any under which complete curling TrackCands should be stored, hence curling TrackCands will only be stored in parts.");
135 m_saveCompleteCurler =
false;
139 if (m_PARAMnTrackStubs < 0) {
140 B2WARNING(
"CurlingTrackCandSplitter::initialize> Value of nTrackStubs is below 0: nTrackStubs = " << m_PARAMnTrackStubs <<
141 ". Resetting this value to 0 now! This means that all parts of curling TrackCands will be stored.");
142 m_PARAMnTrackStubs = 0;
143 }
else { B2DEBUG(1,
"Entered value for nTrackStubs = " << m_PARAMnTrackStubs); }
145 B2DEBUG(1,
"Entered Value for splitCurlers: " << m_PARAMsplitCurlers);
147 if (m_PARAMsetOrigin.size() != 3) {
148 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!");
149 m_PARAMsetOrigin.clear();
150 m_PARAMsetOrigin.assign(3, 0);
152 m_origin.SetXYZ(m_PARAMsetOrigin.at(0), m_PARAMsetOrigin.at(1), m_PARAMsetOrigin.at(2));
153 B2DEBUG(10,
"Set origin to (x,y,z): (" << m_origin.X() <<
"," << m_origin.Y() <<
"," << m_origin.Z() <<
")");
155 if (m_PARAMpositionAnalysis) {
157 if (m_PARAMrootFileName.size() != 2 || (m_PARAMrootFileName[1] !=
"UPDATE" && m_PARAMrootFileName[1] !=
"RECREATE")) {
159 for (
string entry : m_PARAMrootFileName) { output +=
"'" + entry +
"' "; }
160 B2FATAL(
"CurlingTrackCandSplitter::initialize() : rootFileName is set wrong: entries are: " << output);
163 m_PARAMrootFileName[0] +=
".root";
164 m_rootFilePtr =
new TFile(m_PARAMrootFileName[0].c_str(), m_PARAMrootFileName[1].c_str());
165 m_treePtr =
new TTree(
"m_treePtr",
"aTree");
168 for (
int layer = 0; layer < c_nPlanes; ++layer) {
169 string layerString = (boost::format(
"%1%") % (layer +
172 string name =
"SpacePointXGlobal_" + layerString;
173 m_treePtr->Branch(name.c_str(), &m_rootSpacePointXGlobals.at(layer));
174 name =
"SpacePointYGlobal_" + layerString;
175 m_treePtr->Branch(name.c_str(), &m_rootSpacePointYGlobals.at(layer));
176 name =
"SpacePointZGlobal_" + layerString;
177 m_treePtr->Branch(name.c_str(), &m_rootSpacePointZGlobals.at(layer));
179 name =
"SpacePointULocal_" + layerString;
180 m_treePtr->Branch(name.c_str(), &m_rootSpacePointULocals.at(layer));
181 name =
"SpacePointVlocal_" + layerString;
182 m_treePtr->Branch(name.c_str(), &m_rootSpacePointVLocals.at(layer));
184 name =
"TrueHitXGlobal_" + layerString;
185 m_treePtr->Branch(name.c_str(), &m_rootTrueHitXGlobals.at(layer));
186 name =
"TrueHitYGlobal_" + layerString;
187 m_treePtr->Branch(name.c_str(), &m_rootTrueHitYGlobals.at(layer));
188 name =
"TrueHitZGlobal_" + layerString;
189 m_treePtr->Branch(name.c_str(), &m_rootTrueHitZGlobals.at(layer));
191 name =
"TrueHitULocal_" + layerString;
192 m_treePtr->Branch(name.c_str(), &m_rootTrueHitULocals.at(layer));
193 name =
"TrueHitVLocal_" + layerString;
194 m_treePtr->Branch(name.c_str(), &m_rootTrueHitVLocals.at(layer));
196 name =
"PosResidualsXGlobal_" + layerString;
197 m_treePtr->Branch(name.c_str(), &m_rootPosResidueXGlobal.at(layer));
198 name =
"PosResidualsYGlobal_" + layerString;
199 m_treePtr->Branch(name.c_str(), &m_rootPosResidueYGlobal.at(layer));
200 name =
"PosResidualsZGlobal_" + layerString;
201 m_treePtr->Branch(name.c_str(), &m_rootPosResidueZGlobal.at(layer));
203 name =
"PosResidualsULocal_" + layerString;
204 m_treePtr->Branch(name.c_str(), &m_rootPosResidueULocal.at(layer));
205 name =
"PosResidualsVLocal_" + layerString;
206 m_treePtr->Branch(name.c_str(), &m_rootPosResidueVLocal.at(layer));
209 name =
"LocalPositionResiduals_" + layerString;
210 m_treePtr->Branch(name.c_str(), &m_rootLocalPosResiduals.at(layer));
211 name =
"GlobalPositionResiduals_" + layerString;
212 m_treePtr->Branch(name.c_str(), &m_rootGlobalPosResiduals.at(layer));
214 name =
"MisMatchPosDistance_" + layerString;
215 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosDistance.at(layer));
216 name =
"MisMatchPosX_" + layerString;
217 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosX.at(layer));
218 name =
"MisMatchPosY_" + layerString;
219 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosY.at(layer));
220 name =
"MisMatchPosZ_" + layerString;
221 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosZ.at(layer));
223 name =
"MisMatchPosU_" + layerString;
224 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosU.at(layer));
225 name =
"MisMatchPosV_" + layerString;
226 m_treePtr->Branch(name.c_str(), &m_rootMisMatchPosV.at(layer));
228 name =
"MisMatchMomX_" + layerString;
229 m_treePtr->Branch(name.c_str(), &m_rootMisMatchMomX.at(layer));
230 name =
"MisMatchMomY_" + layerString;
231 m_treePtr->Branch(name.c_str(), &m_rootMisMatchMomY.at(layer));
232 name =
"MisMatchMomZ_" + layerString;
233 m_treePtr->Branch(name.c_str(), &m_rootMisMatchMomZ.at(layer));
236 m_rootFilePtr =
nullptr;
242 void CurlingTrackCandSplitterModule::event()
245 const int eventCounter = eventMetaDataPtr->getEvent();
246 B2DEBUG(10,
"CurlingTrackCandSplitter::event(). -------------- Processing event " << eventCounter <<
" ----------------");
258 B2DEBUG(15,
"Found " << nTCs <<
" SpacePointTrackCands in StoreArray " << spacePointTCs.
getName() <<
" for this event");
262 for (
int iTC = 0; iTC < nTCs; ++iTC) {
266 B2DEBUG(15,
"=========================== Processing SpacePointTrackCand " << iTC <<
" ===============================");
268 const std::vector<int> splittingIndices = checkTrackCandForCurling(*spacePointTC, rootVariables);
270 if (splittingIndices.empty()) {
271 B2DEBUG(15,
"This SpacePointTrackCand shows no curling behaviour and will be added to collection: " << m_PARAMcurlingOutFirstName);
278 B2DEBUG(15,
"This SpacePointTrackCand shows curling behaviour");
279 if (!m_PARAMsplitCurlers) {
280 B2DEBUG(15,
"This SpacePointTrackCand could be split into " << splittingIndices.size() + 1 <<
281 " but will not, because splitCurlers is set to false");
286 std::vector<SpacePointTrackCand> trackStubs = splitCurlingTrackCand(*spacePointTC, m_PARAMnTrackStubs, splittingIndices);
290 m_createdTrackStubsCtr++;
291 if (m_saveCompleteCurler) {
296 if (!trackStub.isOutgoing()) {
301 if (trackStub.getTrackStubIndex() > 1) {
313 }
catch (FoundNoTrueHit& anE) {
314 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
315 " This TrackCandidate cannot be checked for curling behaviour");
316 m_noDecisionPossibleCtr++;
317 }
catch (FoundNoCluster& anE) {
318 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
319 " This TrackCandidate cannot be checked for curling behaviour");
320 m_noDecisionPossibleCtr++;
321 }
catch (TrueHitsNotMatching& anE) {
322 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
323 " This TrackCandidate cannot be checked for curling behaviour");
324 m_noDecisionPossibleCtr++;
325 }
catch (SpacePointTrackCand::UnsupportedDetType& anE) {
326 B2WARNING(
"Caught an exception during checking for curling behaviour: " << anE.what() <<
327 " This TrackCandidate cannot be checked for curling behaviour");
328 m_noDecisionPossibleCtr++;
332 if (m_PARAMpositionAnalysis) { writeToRoot(rootVariables); }
336 void CurlingTrackCandSplitterModule::terminate()
338 B2INFO(
"CurlingTrackCandSplitter::terminate(): checked " << m_spacePointTCCtr <<
" SpacePointTrackCands for curling behaviour. " <<
339 m_curlingTCCtr <<
" of them were curling and " << m_createdTrackStubsCtr <<
" TrackStubs were created. " << m_NoCurlingTCsCtr <<
340 " SPTCs were not curling and were merely copied into StoreArray " << m_PARAMcurlingOutFirstName <<
". In " <<
341 m_noDecisionPossibleCtr <<
" cases no decision could be made. There were " << m_NoSingleTrueHitCtr <<
342 " SpacePoints that were related to more than one TrueHit");
344 if (m_treePtr !=
nullptr) {
347 m_rootFilePtr->Close();
355 const std::vector<const Belle2::SpacePoint*>& tcSpacePoints = SPTrackCand.
getHits();
356 unsigned int nHits = SPTrackCand.
getNHits();
358 B2DEBUG(70,
"SpacePointTrackCand contains " << nHits <<
" SpacePoints");
360 std::vector<int> returnVector;
362 std::pair<bool, bool>
367 for (
unsigned int iHit = 0; iHit < nHits; ++iHit) {
368 const SpacePoint* spacePoint = tcSpacePoints[iHit];
369 auto detType = spacePoint->
getType();
371 B2DEBUG(100,
"Now checking SpacePoint " << iHit <<
" in SPTC. This SpacePoint has Index " << spacePoint->
getArrayIndex() <<
377 if (detType == VXD::SensorInfoBase::PXD) {
385 if (pxdTrueHit ==
nullptr) {
386 B2DEBUG(1,
"Found no PXDTrueHit for PXDCluster " << pxdCluster->
getArrayIndex() <<
" from Array " << pxdCluster->
getArrayName() <<
387 ". This PXDCluster is related with SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " << spacePoint->
getArrayName());
388 throw FoundNoTrueHit();
391 B2DEBUG(100,
"Found PXDCluster " << pxdCluster->
getArrayIndex() <<
" and " <<
" PXDTrueHit " << pxdTrueHit->getArrayIndex() <<
392 " from StoreArray " << pxdTrueHit->getArrayName() <<
" related to this SpacePoint");
394 B2DEBUG(100,
"Now getting global position and momentum for PXDCluster " << pxdCluster->
getArrayIndex() <<
" from Array " <<
396 hitGlobalPosMom = getGlobalPositionAndMomentum(pxdTrueHit);
399 if (m_PARAMpositionAnalysis) { getValuesForRoot(spacePoint, pxdTrueHit, rootVariables); }
401 }
else if (detType == VXD::SensorInfoBase::SVD) {
405 if (svdClusters.
size() == 0) {
406 B2WARNING(
"Found no related clusters for SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " << spacePoint->
getArrayName()
407 <<
". With no Cluster no information if a track is curling or not can be obtained");
408 throw FoundNoCluster();
413 std::vector<const SVDTrueHit*> svdTrueHits;
414 for (
const SVDCluster& aCluster : svdClusters) {
418 if (relTrueHits.
size() == 0) {
419 B2DEBUG(1,
"Found no SVDTrueHit for SVDCluster " << aCluster.getArrayIndex() <<
" from Array " << aCluster.getArrayName() <<
420 ". This SVDCluster is related with SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " << spacePoint->
getArrayName());
421 throw FoundNoTrueHit();
424 B2DEBUG(100,
"Found " << relTrueHits.
size() <<
" TrueHits for SVDCluster " << aCluster.getArrayIndex() <<
" from Array " <<
425 aCluster.getArrayName());
426 for (
unsigned int i = 0; i < relTrueHits.
size(); ++i) { svdTrueHits.push_back(relTrueHits[i]); }
441 if (svdTrueHits.size() >= 1) {
442 B2DEBUG(150,
"Found " << svdTrueHits.size() <<
" SVDTrueHits related to Clusters related to SpacePoint " <<
446 std::sort(svdTrueHits.begin(), svdTrueHits.end());
447 unsigned int oldSize = svdTrueHits.size();
448 auto newEnd = std::unique(svdTrueHits.begin(), svdTrueHits.end());
449 svdTrueHits.resize(std::distance(svdTrueHits.begin(), newEnd));
452 if (svdTrueHits.size() == oldSize) {
453 stringstream trueHitInds;
454 for (
const SVDTrueHit* trueHit : svdTrueHits) { trueHitInds << trueHit->getArrayIndex() <<
", "; }
455 B2DEBUG(1,
"There is no overlapping TrueHit for SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " <<
456 spacePoint->
getArrayName() <<
". The Indices of the TrueHits are: " << trueHitInds.str());
459 if (m_PARAMpositionAnalysis) {
460 std::vector<B2Vector3<double> > globalPositions;
461 std::vector<B2Vector3<double> > globalMomenta;
463 for (
unsigned int i = 0; i < svdTrueHits.size(); ++i) {
464 auto posMom = getGlobalPositionAndMomentum(svdTrueHits[i]);
465 globalPositions.push_back(posMom.first);
466 globalMomenta.push_back(posMom.second);
469 int layer = svdTrueHits[0]->getSensorID().getLayerNumber() - 1;
471 for (
unsigned int i = 1; i < globalPositions.size(); ++i) {
472 rootVariables.
MisMatchPosResiduals.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).Mag());
474 rootVariables.
MisMatchPosX.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).X());
475 rootVariables.
MisMatchPosY.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).Y());
476 rootVariables.
MisMatchPosZ.at(layer).push_back((globalPositions[i] - globalPositions[i - 1]).Z());
478 rootVariables.
MisMatchPosU.at(layer).push_back((svdTrueHits[i]->getU() - svdTrueHits[i - 1]->getU()));
479 rootVariables.
MisMatchPosV.at(layer).push_back((svdTrueHits[i]->getV() - svdTrueHits[i - 1]->getV()));
488 if (svdClusters.size() > 1) { TrueHitsNotMatching(); }
493 if (svdTrueHits.size() > 1) {
494 m_NoSingleTrueHitCtr++;
498 B2DEBUG(100,
"Now getting global position and momentum for SVDCluster " << svdClusters[0]->getArrayIndex() <<
" from Array " <<
499 svdClusters[0]->getArrayName() <<
" via SVDTrueHit " << svdTrueHits[0]->getArrayIndex() <<
" from StoreArray " <<
500 svdTrueHits[0]->getArrayName());
501 hitGlobalPosMom = getGlobalPositionAndMomentum(svdTrueHits[0]);
506 if (m_PARAMpositionAnalysis && (svdTrueHits.size() == 1 || m_PARAMuseNonSingleTHinPA)) { getValuesForRoot(spacePoint, svdTrueHits[0], rootVariables); }
509 throw SpacePointTrackCand::UnsupportedDetType();
513 directions.second = getDirectionOfFlight(hitGlobalPosMom, m_origin);
516 if (directions.first != directions.second) {
517 B2DEBUG(75,
"The direction of flight has changed for SpacePoint " << iHit <<
518 " in SpacePointTrackCand. The StoreArray index of this SpacePoint is " << spacePoint->
getArrayIndex() <<
" in " <<
520 returnVector.push_back(iHit);
523 directions.first = directions.second;
531 template<
class TrueHit>
533 CurlingTrackCandSplitterModule::getGlobalPositionAndMomentum(TrueHit* aTrueHit)
536 VxdID aVxdId = aTrueHit->getSensorID();
538 B2DEBUG(100,
"Getting global position and momentum vectors for TrueHit " << aTrueHit->getArrayIndex() <<
" from Array " <<
539 aTrueHit->getArrayName() <<
". This hit has VxdID " << aVxdId);
541 const VXD::GeoCache& geometry = VXD::GeoCache::getInstance();
548 B2DEBUG(100,
"Local position of hit is (" << hitLocal.
X() <<
"," << hitLocal.
Y() <<
"," << hitLocal.
Z() <<
549 "), Global position of hit is (" << hitGlobal.
X() <<
"," << hitGlobal.
Y() <<
"," << hitGlobal.
Z() <<
")");
553 B2DEBUG(100,
"Global momentum of hit is (" << pGlobal.
X() <<
"," << pGlobal.
Y() <<
"," << pGlobal.
Z() <<
")");
555 return std::make_pair(hitGlobal, pGlobal);
559 bool CurlingTrackCandSplitterModule::getDirectionOfFlight(
const
567 B2DEBUG(100,
"Position of hit relative to origin is (" << originToHit.
X() <<
"," << originToHit.
Y() <<
"," << originToHit.
Z() <<
568 "). Momentum relative to hit (relative to origin) (" << momentumAtHit.
X() <<
"," << momentumAtHit.
Y() <<
"," << momentumAtHit.
Z() <<
573 double hitRadComp = originToHit.
Perp();
574 double hitMomRadComp =
575 momentumAtHit.
Perp();
577 B2DEBUG(250,
" radial component of hit coordinates: " << hitRadComp <<
578 ", radial component of tip of momentum vector with its origin set to hit position: " << hitMomRadComp);
580 if (hitMomRadComp < hitRadComp) {
581 B2DEBUG(100,
"Direction of flight is inwards for this hit");
584 B2DEBUG(100,
"Direction of flight is outwards for this hit");
590 const std::vector<Belle2::SpacePointTrackCand>
592 const std::vector<int>& splitIndices)
594 std::vector<SpacePointTrackCand> spacePointTCs;
596 std::vector<std::pair<int, int> >
600 for (
int index : splitIndices) {
601 rangeIndices.push_back({firstIndex, index});
602 firstIndex = index + 1;
604 rangeIndices.push_back({firstIndex, SPTrackCand.
getNHits() - 1});
608 bool outgoing = splitIndices[0] != 0;
612 if (NTracklets < 1) { NTracklets = rangeIndices.size(); }
613 for (
unsigned iTr = 0; iTr < rangeIndices.size() && iTr < uint(NTracklets); ++iTr) {
615 int lastInd = rangeIndices[iTr].second;
616 int firstInd = rangeIndices[iTr].first;
618 B2DEBUG(75,
"Creating Track Stub " << iTr <<
" of " << splitIndices.size() <<
619 " possible Track Stub for this SpacePointTrackCand. The indices for this Tracklet are (first,last): (" << firstInd <<
"," << lastInd
620 <<
"). This SpacePointTrackCand contains " << SPTrackCand.
getNHits() <<
" SpacePoints in total.");
624 const std::vector<const SpacePoint*> trackletSpacePoints = SPTrackCand.
getHitsInRange(firstInd, lastInd);
639 outgoing = !outgoing;
644 spacePointTCs.push_back(newSPTrackCand);
645 }
catch (SpacePointTrackCand::SPTCIndexOutOfBounds& anE) {
646 B2WARNING(
"Caught an exception while trying to split SpacePointTrackCands: " << anE.what() <<
647 " This SPTC will be skipped from splitting!");
651 return spacePointTCs;
655 template <
class TrueHit>
656 void CurlingTrackCandSplitterModule::getValuesForRoot(
const Belle2::SpacePoint* spacePoint,
const TrueHit* trueHit,
659 B2DEBUG(100,
"Getting positions (for ROOT output) of SpacePoint " << spacePoint->
getArrayIndex() <<
" from Array " <<
660 spacePoint->
getArrayName() <<
" and TrueHit " << trueHit->getArrayIndex() <<
" from Array " << trueHit->getArrayName());
664 VxdID trueHitVxdId = trueHit->getSensorID();
677 const VXD::GeoCache& geometry = VXD::GeoCache::getInstance();
687 if (spLayer != thLayer) {
688 B2FATAL(
"Layer numbers of TrueHit and SpacePoint do not match!");
692 bool singleCluster =
true;
693 if (spacePointUV.
m_setU) {
695 rootVariables.
TrueHitULocal.at(thLayer).push_back(trueHit->getU());
696 rootVariables.
PosResidueULocal.at(spLayer).push_back((spacePointUV.
m_U - trueHit->getU()));
698 if (spacePointUV.
m_setV) {
700 rootVariables.
TrueHitVLocal.at(thLayer).push_back(trueHit->getV());
701 rootVariables.
PosResidueVLocal.at(spLayer).push_back((spacePointUV.
m_V - trueHit->getV()));
712 rootVariables.
PosResidueXGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).X());
713 rootVariables.
PosResidueYGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).Y());
714 rootVariables.
PosResidueZGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).Z());
716 rootVariables.
PosResiduesGlobal.at(spLayer).push_back((spacePointGlobal - trueHitGlobal).Mag());
717 rootVariables.
PosResiduesLocal.at(spLayer).push_back((spacePointLocal - trueHitLocal).Mag());
719 singleCluster =
false;
722 B2DEBUG(200,
"Global (x,y,z)/Local (U,V) positions of SpacePoint: (" << spacePointGlobal.
X() <<
"," << spacePointGlobal.
Y() <<
","
723 << spacePointGlobal.
Z() <<
")/(" << spacePointLocal.
X() <<
"," << spacePointLocal.
Y() <<
"). This was a singleCluster SpacePoint: "
726 B2DEBUG(200,
"Global (x,y,z)/Local (U,V) positions of TrueHit: (" << trueHitGlobal.
X() <<
"," << trueHitGlobal.
Y() <<
"," <<
727 trueHitGlobal.
Z() <<
")/(" << trueHitLocal.
X() <<
"," << trueHitLocal.
Y() <<
")");
729 B2DEBUG(200,
"This leads to position differences global/local: " << (spacePointGlobal - trueHitGlobal).Mag() <<
"/" <<
730 (spacePointLocal - trueHitLocal).Mag());
735 void CurlingTrackCandSplitterModule::writeToRoot(
const RootVariables& rootVariables)
784 std::pair<double, double> localUV = SpacePoint::convertNormalizedToLocalCoordinates(std::make_pair(normU, normV),
791 returnVals.
m_setU = setCoords.first;
792 returnVals.
m_setV = setCoords.second;
793 returnVals.
m_U = localUV.first;
794 returnVals.
m_V = localUV.second;
800 void CurlingTrackCandSplitterModule::initializeCounters()
802 m_createdTrackStubsCtr = 0;
804 m_noDecisionPossibleCtr = 0;
805 m_spacePointTCCtr = 0;
806 m_NoSingleTrueHitCtr = 0;
807 m_NoCurlingTCsCtr = 0;
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType X() const
access variable X (= .at(0) without boundary check)
DataType Y() const
access variable Y (= .at(1) without boundary check)
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Module for checking SpacePointTrackCandidates for curling behaviour and splitting them into Track Can...
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
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).
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Storage for (VXD) SpacePoint-based track candidates.
void setSortingParameters(const std::vector< double > &sortParams)
set the sorting parameters
void set6DSeed(const TVectorD &state6D)
set the 6D state seed
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
int getPdgCode() const
get pdg code
void setCovSeed(const TMatrixDSym &cov)
set the covariance matrix seed
int getMcTrackID() const
get the MC Track ID
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
void setTrackStubIndex(int trackStubInd)
set TrackStub index
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
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...
const std::vector< double > getSortingParametersInRange(int firstIndex, int lastIndex) const
get the sorting parameters in range (indices of SpacePoints inside SpacePointTrackCand) including fir...
const TVectorD & getStateSeed() const
get state seed as 6D vector
double getChargeSeed() const
get charge
void setFlightDirection(bool direction)
set the direction of flight (true is outgoing, false is ingoing).
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
const B2Vector3< double > & getPosition() const
return the position vector in global coordinates
double getNormalizedLocalV() const
Return normalized local coordinates of the cluster in v (0 <= posV <= 1).
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
std::pair< bool, bool > getIfClustersAssigned() const
Returns, if u(v)-coordinate is based on cluster information.
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
double Z() const
return the z-value of the global position of the SpacePoint
double X() const
return the x-value of the global position of the SpacePoint
double getNormalizedLocalU() const
Return normalized local coordinates of the cluster in u (0 <= posU <= 1).
double Y() const
return the y-value of the global position of the SpacePoint
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
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.
Type-safe access to single objects in the data store.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Base class to provide Sensor Information for PXD and SVD.
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
TVector3 vectorToGlobal(const TVector3 &local, bool reco=false) const
Convert a vector from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getLayerNumber() const
Get the layer id.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Internal DataStore for ROOT output variables.
std::array< std::vector< double >, c_nPlanes > PosResidueVLocal
V-position (local) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchMomZ
Difference of Momentum in Z-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > MisMatchPosZ
Difference of Z-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosU
Difference of U-positions (local) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResidueZGlobal
Z-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchMomX
Difference of Momentum in X-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > MisMatchPosV
Difference of V-positions (local) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosResiduals
Distance between TrueHits that do not match but are related from one SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosY
Difference of Y-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointYGlobal
global y-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchPosX
Difference of X-positions (global) for mismatched TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointVLocal
local v-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitULocal
local u-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointZGlobal
global z-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResidueULocal
U-position (local) differnece between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitXGlobal
global x-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResiduesGlobal
position differences in global coordinates (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointULocal
local u-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitVLocal
local v-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > MisMatchMomY
Difference of Momentum in Y-Direction for TrueHits that do not match but are related from one SpacePo...
std::array< std::vector< double >, c_nPlanes > PosResidueYGlobal
Y-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > SpacePointXGlobal
global x-positions of SpacePoints (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResiduesLocal
position differences in local coordinates (layerwise)
std::array< std::vector< double >, c_nPlanes > PosResidueXGlobal
X-position (global) difference between TrueHit and SpacePoint (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitZGlobal
global z-positions of TrueHits (layerwise)
std::array< std::vector< double >, c_nPlanes > TrueHitYGlobal
global y-positions of TrueHits (layerwise)
struct for easier handling of getting U- & V-position of SpacePoints and some difficulties that arise...
bool m_setV
indicator if V is set
bool m_setU
indicator if U is set