9#include <tracking/modules/trackFinderMCTruth/TrackFinderMCTruthRecoTracksModule.h>
11#include <framework/datastore/RelationArray.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/dataobjects/EventMetaData.h>
14#include <framework/gearbox/Const.h>
15#include <cdc/geometry/CDCGeometryPar.h>
16#include <top/dataobjects/TOPBarHit.h>
17#include <simulation/monopoles/MonopoleConstants.h>
19#include <framework/geometry/BFieldManager.h>
20#include <framework/geometry/B2Vector3.h>
21#include <framework/dataobjects/Helix.h>
45 setDescription(
"Uses the MC information to create genfit::TrackCandidates for primary MCParticles and Relations between them. "
46 "Fills the created genfit::TrackCandidates with all information (start values, hit indices) needed for the fitting.");
52 "Set true if PXDHits or PXDClusters should be used",
56 "Set true if SVDHits or SVDClusters should be used",
60 "Set true if CDCHits should be used",
64 "Set true if only the axial CDCHits should be used",
68 "Set the number of loops whose hits will be marked as priority hits. All other hits "
69 "will be marked as auxiliary and therefore not considered for efficiency computations "
70 "By default, all hits will be priority hits.",
74 "Mark hits as auxiliary after the track left the CDC and touched the TOP detector.",
78 "Include hits reassigned from discarded secondary daughters in the tracks.",
82 "Also includes the CDC 2nd hit information in the MC tracks.",
86 "Minimum number of PXD hits needed to allow the created of a track candidate",
90 "Minimum number of SVD hits needed to allow the created of a track candidate",
94 "Minimum number of CDC hits form an axial wire needed to allow the created of a track candidate",
98 "Minimum number of CDC hits form a stereo wire needed to allow the created of a track candidate",
100 addParam(
"AllowFirstCDCSuperLayerOnly",
102 "Allow tracks to pass the stereo hit requirement if they touched only the first (axial) CDC layer",
107 "Minimum number of total hits needed to allow the creation of a track candidate. "
108 "It is called NDF (number of degrees of freedom) because it counts the dimensionality. "
109 "2D hits are counted as 2",
116 "List of keywords to mark what properties particles must have to get a track candidate. "
117 "If several properties are given all of them must be true: "
118 "\"primary\" particle must come from the generator, "
119 "\"PXD\", \"SVD\", \"CDC\", \"TOP\", \"ARICH\", \"ECL\" or \"KLM\" particle must have hits in the subdetector with that name. "
120 "\"is:X\" where X is a PDG code: particle must have this code. "
121 "\"from:X\" any of the particles's ancestors must have this (X) code",
122 std::vector<std::string>(1,
"primary"));
123 addParam(
"onlyCheckDirectParentPdgCode",
125 "To be used together with WhichParticles to select the ancestor and daughters. "
126 "If true, only check the direct parent to be contained in the list of possible ancestors. "
127 "If false, check all ancestors in in the list of possible ancestors. "
128 "This could be used to e.g. only create MCRecoTracks for slow pions from D* decays instead of creating an MCRecoTrack "
129 "for every pion as long as the D* is one of its ancestors.",
134 "Track candidates are only created for MCParticles with energy larger than this cut ",
139 "Set true if track candidates should be created also for neutral particles",
144 "Merge decay in flights that produce a single charged particle to the parent particle",
149 "Set true to forward the production time as time seed of the particles to the RecoTrack",
155 "Smearing of MCMomentum/MCVertex prior to storing it in genfit::TrackCandidate (in %). "
156 "A negative value will switch off smearing. This is also the default.",
161 "Covariance matrix used to smear the true pos and mom before passed to track candidate. "
162 "This matrix will also passed to Genfit as the initial covarance matrix. "
163 "If any diagonal value is negative this feature will not be used. "
164 "OFF DIAGONAL ELEMENTS DO NOT HAVE AN EFFECT AT THE MOMENT",
165 std::vector<double>(36, -1.0));
169 "Minimal time delay between two sim hits (in ns) after which MC reco track will be "
170 "split into separate tracks. If < 0, don't do splitting."
171 "This feature was designed to be used in MC cosmics reconstruction to get two MCRecoTracks"
172 "when track pass through empty SVD region, so that number of MCRecoTracks can be compared with"
173 "number of non merged reco tracks. ",
177 addParam(
"RecoTracksStoreArrayName",
179 "Name of store array holding the RecoTracks (output)",
184 "If set true only cluster hits that have a relation to a TrueHit will be included in the track candidate",
189 "If set true hits marked as auxiliary (e.g. hits in higher loops) will not be included in the track candidate.",
194 "List of CDC super layers to be used.",
199 "List of layers to be used. "
200 "If a layer number is given in 'ignoreLayers', too, this will result on a B2FATAL. "
201 "Either use 'useLayers' and provide a set of layers to be used, "
202 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
207 "List of layers to be ignored. "
208 "If a layer number is given in 'useLayers', too, this will result on a B2FATAL. "
209 "Either use 'useLayers' and provide a set of layers to be used, "
210 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
233 for (
int i = 0; i not_eq nProperties; ++i) {
252 std::stringstream(pdgCodeString) >> aPdgCode;
253 B2DEBUG(20,
"PDG code added to m_particlePdgCodes " << aPdgCode <<
" *******");
257 std::stringstream(pdgCodeString) >> aPdgCode;
258 B2DEBUG(20,
"PDG code added to m_fromPdgCodes " << aPdgCode <<
" *******");
261 B2FATAL(
"Invalid values were given to the MCTrackFinder parameter WhichParticles");
270 B2FATAL(
"SmearingCov does not have exactly 36 elements. So 6x6 covariance matrix can be formed from it");
274 for (
int i = 0; i != 6; ++i) {
281 B2FATAL(
"Both relative smearing (Smearing) and using a smearing cov (SmearingCov) is activated but only one of both can be used");
296 if (useLayer == ingoreLayer) {
297 B2FATAL(
"You chose to use and ignore CDC layer " << useLayer <<
" at the same time. "
298 "Please decide to either use or to ignore the layer.");
332 B2DEBUG(20,
"Skipping MC Track Finder as there are no MC Particles registered in the DataStore.");
337 const int eventCounter = eventMetaDataPtr->getEvent();
338 B2DEBUG(20,
"******* MCTrackFinderModule processing event number: " << eventCounter <<
" *******");
342 B2DEBUG(20,
"MCTrackFinder: total Number of MCParticles: " << nMcParticles);
346 B2DEBUG(20,
"MCTrackFinder: Number of PXDTrueHits: " << nPXDHits);
349 const int nMcPartToPXDHits = mcPartToPXDTrueHits.
getEntries();
350 B2DEBUG(20,
"MCTrackFinder: Number of relations between MCParticles and PXDHits: " << nMcPartToPXDHits);
354 B2DEBUG(20,
"MCTrackFinder: Number of PXDClusters: " << nPXDClusters);
357 const int nPxdClusterToMCPart = pxdClusterToMCParticle.
getEntries();
358 B2DEBUG(20,
"MCTrackFinder: Number of relations between PXDCluster and MCParticles: " << nPxdClusterToMCPart);
362 B2DEBUG(20,
"MCTrackFinder: Number of SVDDHits: " << nSVDHits);
365 const int nMcPartToSVDHits = mcPartToSVDTrueHits.
getEntries();
366 B2DEBUG(20,
"MCTrackFinder: Number of relations between MCParticles and SVDHits: " << nMcPartToSVDHits);
370 B2DEBUG(20,
"MCTrackFinder: Number of SVDClusters: " << nSVDClusters);
373 const int nSvdClusterToMCPart = svdClusterToMCParticle.
getEntries();
374 B2DEBUG(20,
"MCTrackFinder: Number of relations between SVDCluster and MCParticles: " << nSvdClusterToMCPart);
377 const int nCDCHits =
m_CDCHits.getEntries();
378 B2DEBUG(20,
"MCTrackFinder: Number of CDCHits: " << nCDCHits);
381 const int nMcPartToCDCHits = mcPartToCDCHits.
getEntries();
382 B2DEBUG(20,
"MCTrackFinder: Number of relations between MCParticles and CDCHits: " << nMcPartToCDCHits);
385 B2DEBUG(20,
"MCTrackFinder: Number of CDCSimHits: " << nCDCSimHits);
388 const int nCdcSimHitToHitRel = cdcSimHitToHitRel.
getEntries();
389 B2DEBUG(20,
"MCTrackFinder: Number of relations between CDCSimHit and CDCHits: " << nCdcSimHitToHitRel);
395 std::set<int> alreadyConsumedMCParticles;
396 for (
int iPart = 0; iPart < nMcParticles; ++iPart) {
397 if (alreadyConsumedMCParticles.count(iPart))
continue;
398 alreadyConsumedMCParticles.insert(iPart);
403 B2DEBUG(20,
"Particle that did not propagate significantly cannot make track.");
408 int mcParticleProperties = 0;
410 mcParticleProperties += 1;
413 mcParticleProperties += 2;
416 mcParticleProperties += 4;
419 mcParticleProperties += 8;
422 mcParticleProperties += 16;
425 mcParticleProperties += 32;
428 mcParticleProperties += 64;
431 mcParticleProperties += 128;
435 B2DEBUG(20,
"PDG: " << aMcParticlePtr->
getPDG() <<
" | property mask of particle " << mcParticleProperties <<
441 B2DEBUG(20,
"particle energy too low. MC particle will be skipped");
448 if (nPdgCodes not_eq 0) {
449 const int currentPdgCode = aMcParticlePtr->
getPDG();
450 int nFalsePdgCodes = 0;
451 for (
int i = 0; i not_eq nPdgCodes; ++i) {
456 if (nFalsePdgCodes == nPdgCodes) {
457 B2DEBUG(20,
"particle does not have one of the user provided pdg codes and will therefore be skipped");
465 if (nFromPdgCodes not_eq 0) {
467 int nFalsePdgCodes = 0;
469 bool foundParent =
false;
470 while (currentParent not_eq
nullptr) {
471 int currentParentPdgCode = currentParent->
getPDG();
472 for (
int i = 0; i not_eq nFromPdgCodes; ++i) {
484 currentParent =
nullptr;
486 currentParent = currentParent->
getMother();
491 B2DEBUG(20,
"particle does not have and ancestor with one of the user provided pdg codes and will therefore be skipped");
498 if (abs(aMcParticlePtr->
getPDG()) > 1000000000
500 B2DEBUG(20,
"Skipped Baryon.");
506 if (!
m_neutrals && (aMcParticlePtr->
getCharge() == 0 && abs(aMcParticlePtr->
getPDG()) != Monopoles::c_monopolePDGCode)) {
507 B2DEBUG(20,
"particle does not have the right charge. MC particle will be skipped");
512 B2DEBUG(20,
"Build a track for the MCParticle with index: " << iPart <<
" (PDG: " << aMcParticlePtr->
getPDG() <<
")");
514 std::vector<const MCParticle*> trackMCParticles;
515 trackMCParticles.push_back(aMcParticlePtr);
518 std::vector<MCParticle*> daughters = aMcParticlePtr->
getDaughters();
519 std::vector<MCParticle*> decayInFlightParticles;
521 if (daughter->getSecondaryPhysicsProcess() > 200 and daughter->getCharge() != 0) {
522 decayInFlightParticles.push_back(daughter);
525 if (decayInFlightParticles.size() == 1) {
526 trackMCParticles.push_back(decayInFlightParticles.front());
527 alreadyConsumedMCParticles.insert(trackMCParticles.back()->getArrayIndex());
536 typedef std::tuple<double, int, RecoHitInformation::OriginTrackFinder, Const::EDetector> TimeHitIDDetector;
537 std::vector<TimeHitIDDetector> hitsWithTimeAndDetectorInformation;
544 for (
const MCParticle* trackMCParticle : trackMCParticles) {
547 for (
size_t i = 0; i < relatedClusters.
size(); ++i) {
548 bool isReassigned = relatedClusters.
weight(i) < 0;
552 auto mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderPriorityHit;
556 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
561 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
566 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
570 if (
m_discardAuxiliaryHits and mcFinder == RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit)
continue;
582 for (
const PXDTrueHit& pxdTrueHit : relatedTrueHits) {
586 if (std::find_if(relatedMCParticles.
begin(),
587 relatedMCParticles.
end(),
588 [trackMCParticle](
const MCParticle & mcParticle) {
589 return &mcParticle == trackMCParticle;
590 }) != relatedMCParticles.
end()) {
591 time = pxdTrueHit.getGlobalTime();
595 if (not std::isnan(time)) {
596 hitsWithTimeAndDetectorInformation.emplace_back(time, pxdCluster->
getArrayIndex(), mcFinder, Const::PXD);
602 B2DEBUG(20,
" add " << hitCounter <<
" PXDClusters. " << relatedClusters.
size() - hitCounter <<
603 " PXDClusters were not added because they do not have a corresponding PXDTrueHit");
615 for (
const MCParticle* trackMCParticle : trackMCParticles) {
618 for (
size_t i = 0; i < relatedClusters.
size(); ++i) {
619 bool isReassigned = relatedClusters.
weight(i) < 0;
622 auto mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderPriorityHit;
626 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
631 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
636 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
640 if (
m_discardAuxiliaryHits and mcFinder == RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit)
continue;
652 for (
const SVDTrueHit& svdTrueHit : relatedTrueHits) {
656 if (std::find_if(relatedMCParticles.
begin(),
657 relatedMCParticles.
end(),
658 [trackMCParticle](
const MCParticle & mcParticle) {
659 return &mcParticle == trackMCParticle;
660 }) != relatedMCParticles.
end()) {
661 time = svdTrueHit.getGlobalTime();
665 if (not std::isnan(time)) {
666 hitsWithTimeAndDetectorInformation.emplace_back(time, svdCluster->
getArrayIndex(), mcFinder, Const::SVD);
672 B2DEBUG(20,
" add " << hitCounter <<
" SVDClusters. " << relatedClusters.
size() - hitCounter <<
673 " SVDClusters were not added because they do not have a corresponding SVDTrueHit");
686 std::array<int, 9> nHitsBySuperLayerId{};
688 for (
const MCParticle* trackMCParticle : trackMCParticles) {
691 for (
size_t i = 0; i < relatedHits.
size(); ++i) {
692 bool isReassigned = relatedHits.
weight(i) < 0;
699 unsigned short layerID = cdcHit->
getICLayer();
707 auto mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderPriorityHit;
711 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
716 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
721 mcFinder = RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit;
725 if (
m_discardAuxiliaryHits and mcFinder == RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit)
continue;
729 if (not aCDCSimHitPtr) {
730 B2DEBUG(20,
" Skipping CDCHit without related CDCSimHit.");
737 if (superLayerId % 2 == 0) {
738 hitsWithTimeAndDetectorInformation.emplace_back(time, cdcHit->
getArrayIndex(), mcFinder, Const::CDC);
741 ++nHitsBySuperLayerId[superLayerId];
744 hitsWithTimeAndDetectorInformation.emplace_back(time, cdcHit->
getArrayIndex(), mcFinder, Const::CDC);
747 ++nHitsBySuperLayerId[superLayerId];
752 B2DEBUG(20,
" added " << nAxialHits <<
" axial and " << nStereoHits <<
" stereo CDCHits");
761 nHitsBySuperLayerId[0] == nAxialHits and
781 std::sort(hitsWithTimeAndDetectorInformation.begin(), hitsWithTimeAndDetectorInformation.end(),
782 [](
const TimeHitIDDetector & rhs,
const TimeHitIDDetector & lhs) {
783 return std::get<0>(rhs) < std::get<0>(lhs);
789 std::vector< std::vector<TimeHitIDDetector> > hitsWithTimeAndDetectorInformationVectors;
792 hitsWithTimeAndDetectorInformationVectors.push_back(hitsWithTimeAndDetectorInformation);
795 std::vector<TimeHitIDDetector>::size_type splitFromIdx = 0;
796 for (std::vector<TimeHitIDDetector>::size_type i = 1; i != hitsWithTimeAndDetectorInformation.size(); i++) {
798 double delta_t = (std::get<0>(hitsWithTimeAndDetectorInformation[i])
799 - std::get<0>(hitsWithTimeAndDetectorInformation[i - 1]));
803 hitsWithTimeAndDetectorInformationVectors
804 .emplace_back(hitsWithTimeAndDetectorInformation.begin() + splitFromIdx,
805 hitsWithTimeAndDetectorInformation.begin() + i);
810 hitsWithTimeAndDetectorInformationVectors
811 .emplace_back(hitsWithTimeAndDetectorInformation.begin() + splitFromIdx,
812 hitsWithTimeAndDetectorInformation.end());
817 B2DEBUG(20,
"We came pass all filter of the MCPartile and hit properties. TrackCandidate " << counter <<
818 " will be created from the MCParticle with index: " << iPart <<
" (PDG: " << aMcParticlePtr->
getPDG() <<
")");
824 ROOT::Math::XYZVector momentumTrue = aMcParticlePtr->
getMomentum();
828 ROOT::Math::XYZVector momentum = momentumTrue;
829 ROOT::Math::XYZVector position = positionTrue;
830 double time = timeTrue;
831 TVectorD stateSeed(6);
832 TMatrixDSym covSeed(6);
834 covSeed(0, 0) = 1; covSeed(1, 1) = 1; covSeed(2, 2) = 2 * 2;
835 covSeed(3, 3) = 0.1 * 0.1; covSeed(4, 4) = 0.1 * 0.1; covSeed(5, 5) = 0.2 * 0.2;
843 double smearedX = gRandom->Gaus(positionTrue.x(), smearing * positionTrue.x());
844 double smearedY = gRandom->Gaus(positionTrue.y(), smearing * positionTrue.y());
845 double smearedZ = gRandom->Gaus(positionTrue.z(), smearing * positionTrue.z());
846 position.SetXYZ(smearedX, smearedY, smearedZ);
847 double smearedPX = gRandom->Gaus(momentumTrue.x(), smearing * momentumTrue.x());
848 double smearedPY = gRandom->Gaus(momentumTrue.y(), smearing * momentumTrue.y());
849 double smearedPZ = gRandom->Gaus(momentumTrue.z(), smearing * momentumTrue.z());
850 momentum.SetXYZ(smearedPX, smearedPY, smearedPZ);
857 double smearedX = gRandom->Gaus(positionTrue.x(),
sqrt(
m_initialCov(0, 0)));
858 double smearedY = gRandom->Gaus(positionTrue.y(),
sqrt(
m_initialCov(1, 1)));
859 double smearedZ = gRandom->Gaus(positionTrue.z(),
sqrt(
m_initialCov(2, 2)));
860 position.SetXYZ(smearedX, smearedY, smearedZ);
861 double smearedPX = gRandom->Gaus(momentumTrue.x(),
sqrt(
m_initialCov(3, 3)));
862 double smearedPY = gRandom->Gaus(momentumTrue.y(),
sqrt(
m_initialCov(4, 4)));
863 double smearedPZ = gRandom->Gaus(momentumTrue.z(),
sqrt(
m_initialCov(5, 5)));
864 momentum.SetXYZ(smearedPX, smearedPY, smearedPZ);
870 for (
const auto& hitInformationVector : hitsWithTimeAndDetectorInformationVectors) {
873 short int charge =
static_cast<short int>(aMcParticlePtr->
getCharge());
876 if (hitInformationVector.size() != 0) {
878 time = std::get<0>(hitInformationVector.at(0));
881 const double beta_xy = momentum.Rho() / energy;
887 momentum = helix.getMomentumAtArcLength2D(arclength2D, Bz);
888 position = helix.getPositionAtArcLength2D(arclength2D);
900 B2DEBUG(20,
" --- Create relation between genfit::TrackCand " << counter <<
" and MCParticle " << iPart);
903 for (
const TimeHitIDDetector& hitInformation : hitInformationVector) {
906 const int hitID = std::get<1>(hitInformation);
907 const auto hitOriginMCFinderType = std::get<2>(hitInformation);
910 if (detectorInformation == Const::CDC) {
915 ROOT::Math::XYZVector simHitPos = aCDCSimHitPtr->
getPosTrack();
916 ROOT::Math::XYZVector simMom = aCDCSimHitPtr->
getMomentum();
917 ROOT::Math::XYZVector simHitPosOnWire = aCDCSimHitPtr->
getPosWire();
920 const unsigned short isRightHit = cdcGeometry.
getNewLeftRightRaw(simHitPosOnWire, simHitPos, simMom);
923 newRecoTrack->
addCDCHit(cdcHit, hitCounter, RecoHitInformation::RightLeftInformation::c_right, hitOriginMCFinderType);
925 newRecoTrack->
addCDCHit(cdcHit, hitCounter, RecoHitInformation::RightLeftInformation::c_left, hitOriginMCFinderType);
927 B2DEBUG(20,
"CDC hit " << hitID <<
" has reft/right sign " << isRightHit);
928 }
else if (detectorInformation == Const::PXD) {
930 newRecoTrack->
addPXDHit(pxdCluster, hitCounter, hitOriginMCFinderType);
931 }
else if (detectorInformation == Const::SVD) {
933 newRecoTrack->
addSVDHit(svdCluster, hitCounter, hitOriginMCFinderType);
938 B2DEBUG(20,
"New RecoTrack: #PXDHits: " << newRecoTrack->
getPXDHitList().size() <<
948template<
class THit,
class TSimHit>
956 const TSimHit* aSimHit =
nullptr;
957 for (
const auto& thisSimHit : relatedSimHits) {
958 mcParticle = thisSimHit.template getRelated<MCParticle>();
959 aSimHit = &thisSimHit;
960 if (mcParticle)
break;
962 if (not mcParticle or not aSimHit) {
970 const float absMom3D = mcParticle->
getMomentum().R();
972 const double loopLength = 2 * M_PI * absMom3D / (Bz * 0.00299792458);
973 const double loopTOF = loopLength / speed;
974 if (tof > loopTOF * nLoops) {
981template<
class THit,
class TSimHit>
984 const TSimHit* simHit = ahit->template getRelated<TSimHit>();
985 if (not simHit)
return false;
987 const MCParticle* mcParticle = simHit->template getRelated<MCParticle>();
988 if (not mcParticle)
return false;
992 if (topHits.
size() == 0)
return false;
996 return lhs.
getTime() < rhs.getTime();
998 auto itFirstTopHit = std::min_element(topHits.
begin(), topHits.
end(), lessTime);
1000 return simHit->getGlobalTime() > itFirstTopHit->getTime();
1009 " number of degrees of freedom (NDF). No Track Candidates were created from them so they will not be passed to the track fitter");
1013 " cluster hits did not have a relation to a true hit and were therefore not included in a track candidate");
1015 B2INFO(
"The MCTrackFinder created a total of " <<
m_nRecoTracks <<
" track candidates");
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
bool is2ndHit() const
Getter for 2nd hit flag.
unsigned short getICLayer() const
Getter for iCLayer (0-55).
unsigned short getISuperLayer() const
Getter for iSuperLayer.
double getFlightTime() const
The method to get flight time.
B2Vector3D getPosWire() const
The method to get position on wire.
B2Vector3D getPosTrack() const
The method to get position on the track.
B2Vector3D getMomentum() const
The method to get momentum.
The Class for CDC Geometry Parameters.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
unsigned short getNewLeftRightRaw(const B2Vector3D &posOnWire, const B2Vector3D &posOnTrack, const B2Vector3D &momentum) const
Returns new left/right_raw.
int getPDGCode() const
PDG code.
EDetector
Enum for identifying the detector components (detector and subdetector).
static const double speedOfLight
[cm/ns]
static const ChargedStable deuteron
deuteron particle
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
A Class to store the Monte Carlo particle information.
float getEnergy() const
Return particle energy in GeV.
@ c_PrimaryParticle
bit 0: Particle is primary particle.
ROOT::Math::XYZVector getDecayVertex() const
Return decay vertex.
bool hasSeenInDetector(Const::DetectorSet set) const
Return if the seen-in flag for a specific subdetector is set or not.
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
bool hasStatus(unsigned short int bitmask) const
Return if specific status bit is set.
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
float getCharge() const
Return the particle charge defined in TDatabasePDG.
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
int getPDG() const
Return PDG code of particle.
float getProductionTime() const
Return production time in ns.
ROOT::Math::XYZVector getMomentum() const
Return momentum.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
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.
This is the Reconstruction Event-Data Model Track.
bool addCDCHit(const UsedCDCHit *cdcHit, const unsigned int sortingParameter, RightLeftInformation rightLeftInformation=RightLeftInformation::c_undefinedRightLeftInformation, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a cdc hit with the given information to the reco track.
std::vector< Belle2::RecoTrack::UsedPXDHit * > getPXDHitList() const
Return an unsorted list of pxd hits.
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSVDHitList() const
Return an unsorted list of svd hits.
bool addPXDHit(const UsedPXDHit *pxdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a pxd hit with the given information to the reco track.
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
void setTimeSeed(const double timeSeed)
Set the time seed. ATTENTION: This is not the fitted time.
static void registerRequiredRelations(StoreArray< RecoTrack > &recoTracks, std::string const &pxdHitsStoreArrayName="", std::string const &svdHitsStoreArrayName="", std::string const &cdcHitsStoreArrayName="", std::string const &bklmHitsStoreArrayName="", std::string const &eklmHitsStoreArrayName="", std::string const &recoHitInformationStoreArrayName="")
Convenience method which registers all relations required to fully use a RecoTrack.
bool addSVDHit(const UsedSVDHit *svdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a svd hit with the given information to the reco track.
Low-level class to create/modify relations between StoreArrays.
int getEntries() const
Get the number of elements.
Class for type safe access to objects that are referred to in relations.
T * object(int index) const
Get object with index.
size_t size() const
Get number of relations.
iterator end()
Return iterator to last entry +1.
iterator begin()
Return iterator to first entry.
float weight(int index) const
Get weight with index.
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).
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
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.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
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 store track parameters of incoming MC particles relation to MCParticle filled in top/simulat...
double getTime() const
Returns time of impact.
bool m_useCDCHits
Boolean to select if CDCHits should be used.
bool didParticleExitCDC(const THit *aHit)
helper function which returns true if the current hit has a creation time after the MCParticle left t...
bool m_enforceTrueHit
If set true only cluster hits that have a relation to a TrueHit will be included in the track candida...
std::vector< int > m_fromPdgCodes
if size() is not 0, only for particles having an ancestor (parent or parent of parent etc) with PDG c...
std::vector< int > m_particlePdgCodes
if size() is not 0, only for particles with PDG codes same as in this vector a track candidate will b...
StoreArray< SVDCluster > m_SVDClusters
SVDTrueHits StoreArray.
double m_energyCut
Create track candidates only for MCParticles with energy above this cut.
void initialize() override
Initialize the Module.
TrackFinderMCTruthRecoTracksModule()
Constructor of the module.
std::vector< std::string > m_whichParticles
List of keywords to mark what properties particles must have to get a track candidate .
bool m_discardAuxiliaryHits
if true hits marked as auxiliary will not be included in the RecoTrack
void event() override
This method is the core of the module.
int m_minimalNdf
Minimum number of total hits per track to allow track candidate creation.
StoreArray< PXDTrueHit > m_PXDTrueHits
PXDTrueHits StoreArray.
void endRun() override
This method is called if the current run ends.
int m_particleProperties
Internal encoding of m_whichParticles to avoid string comparisons.
bool m_useReassignedHits
Boolean to select the inclusion of hits form discarded secondary daughters.
std::vector< double > m_smearingCov
Covariance matrix used to smear the true pos and mom before passed to track candidate.
bool m_mcParticlesPresent
This flag is set to false if there are no MC Particles in the data store (probably data run?...
bool m_allowFirstCDCSuperLayerOnly
Boolean to allow tracks to pass the stereo hit requirement if they touched only the first (axial) CDC...
bool m_onlyCheckDirectParentPdgCode
To be used together with WhichParticles to select the ancestor and daughters.
bool m_mergeDecayInFlight
Boolean to merge decay in flight chains that involve a single charged particle.
bool m_setTimeSeed
Boolean to forward the production time as seed time.
float m_useNLoops
Number of loops to include in the MC tracks.
double m_splitAfterDeltaT
Minimal time delay between two sim hits (in ns) after which MC reco track will be split into separate...
bool m_useSecondCDCHits
Also includes the CDC 2nd hit information in the mc tracks.
StoreArray< CDCSimHit > m_CDCSimHits
CDCSimHits StoreArray.
int m_minCDCStereoHits
Minimum number of CDC hits from stereo wires per track to allow track candidate creation.
StoreArray< PXDCluster > m_PXDClusters
PXDClusters StoreArray.
bool m_usePXDHits
Boolean to select if PXDHits should be used.
void beginRun() override
Called when entering a new run.
std::vector< uint > m_param_useCDCLayers
List of layers to be used.
bool m_useOnlyBeforeTOP
Boolean to select if hits after TOP detector are discarded.
std::vector< uint > m_param_ignoreCDCLayers
List of layers to be ignored in tracking.
std::vector< uint > m_param_useCDCSuperLayers
List of super layers to be used.
int m_minCDCAxialHits
Minimum number of CDC hits from axial wires per track to allow track candidate creation.
int m_noTrueHitCounter
will hold number of cluster hits that do not have a corresponding true hit
int m_minSVDHits
Minimum number of SVD hits per track to allow track candidate creation.
int m_notEnoughtHitsCounter
will hold number of tracks that do not have enough hits to form a track candidate (total NDF less tha...
bool m_useOnlyAxialCDCHits
Boolean to select if only axial CDCHits should be used.
StoreArray< RecoTrack > m_RecoTracks
RecoTracks StoreArray.
std::array< bool, 56 > m_useCDCLayers
Bits for the used layers ATTENTION: hardcoded value for number of layers.
double m_smearing
Smearing of MCMomentum and MCVertex in %.
std::array< bool, 9 > m_useCDCSuperLayers
Bits for the used super layers ATTENTION: hardcoded value for number of super layers.
std::string m_recoTracksStoreArrayName
RecoTracks StoreArray name.
int m_minPXDHits
Minimum number of PXD hits per track to allow track candidate creation.
bool m_neutrals
Boolean to mark if track candidates should also be created for neutral particles.
TMatrixDSym m_initialCov
The std::vector m_smearingCov will be translated into this TMatrixD.
StoreArray< SVDTrueHit > m_SVDTrueHits
SVDTrueHits StoreArray.
StoreArray< MCParticle > m_MCParticles
MCParticles StoreArray.
int m_nRecoTracks
will hold the total number of created track candidates
bool isWithinNLoops(double Bz, const THit *aHit, double nLoops)
helper function which returns true if the current hit is within n loops the template give the hit typ...
StoreArray< CDCHit > m_CDCHits
CDCHits StoreArray.
bool m_useSVDHits
Boolean to select if SVDHits should be used.
static const double cm
Standard units with the value = 1.
static const double T
[tesla]
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
B2Vector3< double > B2Vector3D
typedef for common usage with double
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
double sqrt(double a)
sqrt for double
MCParticle * getMother() const
Returns a pointer to the mother particle.
Abstract base class for different kinds of events.