11#include <tracking/spacePointCreation/SpacePointTrackCand.h>
13#include <tracking/trackFindingVXD/sectorMapTools/SecMapTrainerHit.h>
14#include <tracking/trackFindingVXD/sectorMapTools/SecMapTrainerTC.h>
15#include <tracking/dataobjects/SectorMapConfig.h>
16#include <tracking/trackFindingVXD/environment/VXDTFFilters.h>
18#include <tracking/trackFindingVXD/sectorMapTools/FilterMill.h>
19#include <tracking/trackFindingVXD/sectorMapTools/RawSecMapRootInterface.h>
21#include <tracking/trackFindingVXD/filterMap/map/FiltersContainer.h>
22#include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariableNamesToFunctions.h>
23#include <framework/geometry/B2Vector3.h>
25#include <tracking/dataobjects/FullSecID.h>
26#include <vxd/dataobjects/VxdID.h>
42 template <
class FilterFactoryType>
68 std::vector<SecMapTrainerTC>
m_tcs;
90 auto layerID = hit.getVxdID().getLayerNumber();
94 ids += std::to_string(allowedLayer) +
" ";
95 if (allowedLayer == layerID) found =
true;
97 B2DEBUG(20,
"SecMapTrainer::acceptHit: the TC has layerID: " << layerID <<
" and allowed layers: " << ids <<
" and was " <<
98 (found ?
"accepted" :
"rejected"));
108 unsigned nValues = 0;
109 B2DEBUG(20,
"SecMapTrainer::process2HitCombinations: nHits/trackID/pdg: " << aTC.
size() <<
"/" << aTC.
getTrackID() <<
"/" <<
111 if (aTC.
size() < 2) {
return nValues; }
118 std::vector<std::pair<std::string, double> > collectedResults;
119 for (; innerIt != aTC.
innerEnd();) {
120 B2DEBUG(20,
"SecMapTrainer::process2HitCombinations: outerHit-/innerHitSecID: " << outerIt->getSectorIDString() <<
121 "/" << innerIt->getSectorIDString());
128 dataSet.pdg = aTC.
getPDG();
129 dataSet.secIDs.outer = outerIt->getSectorID().getFullSecID();
130 dataSet.secIDs.inner = innerIt->getSectorID().getFullSecID();
134 newHitPair.
outer = &(*outerIt);
135 newHitPair.
inner = &(*innerIt);
136 m_filterMill.grindData2Hit(newHitPair, collectedResults);
139 for (
const auto& entry : collectedResults) {
140 B2DEBUG(25,
"SecMapTrainer::process2HitCombinations: filter/value: " << entry.first <<
"/" << entry.second);
141 dataSet.setValueOfFilter(entry.first, entry.second);
145 collectedResults.clear();
157 unsigned nValues = 0;
158 B2DEBUG(20,
"SecMapTrainer::process3HitCombinations: nHits/trackID/pdg: " << aTC.
size() <<
"/" << aTC.
getTrackID() <<
"/" <<
160 if (aTC.
size() < 3) {
return nValues; }
168 std::vector<std::pair<std::string, double> > collectedResults;
169 for (; innerIt != aTC.
innerEnd();) {
170 B2DEBUG(20,
"SecMapTrainer::process3HitCombinations: outer-/center-/innerHitSecID: " << outerIt->getSectorIDString() <<
171 "/" << centerIt->getSectorIDString() <<
172 "/" << innerIt->getSectorIDString());
179 dataSet.pdg = aTC.
getPDG();
180 dataSet.secIDs.outer = outerIt->getSectorID().getFullSecID();
181 dataSet.secIDs.center = centerIt->getSectorID().getFullSecID();
182 dataSet.secIDs.inner = innerIt->getSectorID().getFullSecID();
186 newHitTriplet.
outer = &(*outerIt);
187 newHitTriplet.
center = &(*centerIt);
188 newHitTriplet.
inner = &(*innerIt);
189 m_filterMill.grindData3Hit(newHitTriplet, collectedResults);
192 for (
const auto& entry : collectedResults) {
193 B2DEBUG(25,
"SecMapTrainer::process3HitCombinations: filter/value: " << entry.first <<
"/" << entry.second);
194 dataSet.setValueOfFilter(entry.first, entry.second);
198 collectedResults.clear();
209 const std::vector<std::pair< FullSecID, const SpacePoint*> >& goodSPs,
210 unsigned tcID,
double pTValue,
int pdgCode)
212 B2DEBUG(20,
"SecMapTrainer::convertSPTC: nGoodHits: " << goodSPs.size());
216 for (
const auto& secIDAndSPpair : goodSPs) {
217 FullSecID fullSecID = secIDAndSPpair.first;
218 B2DEBUG(20,
"SecMapTrainer::convertSPTC: found fullSecID: " << fullSecID.
getFullSecString());
226 newTrack.
addHit(std::move(newVirtualHit));
228 m_tcs.push_back(std::move(newTrack));
235 explicit SecMapTrainer(
const std::string& setupName,
const std::string& appendix =
"",
const std::string& outputdir =
"./") :
246 m_expNo(
std::numeric_limits<unsigned>::max()),
247 m_runNo(
std::numeric_limits<unsigned>::max()),
265 std::vector< std::string> twoHitFilters;
266 for (
const auto& filterNameToFunction : TwoSPfilterNamesToFunctions)
267 twoHitFilters.push_back(filterNameToFunction.first);
270 for (
auto& nameToFunction : TwoSPfilterNamesToFunctions)
278 std::vector< std::string> threeHitFilters;
279 for (
const auto& filterNameToFunction : ThreeSPfilterNamesToFunctions)
280 threeHitFilters.push_back(filterNameToFunction.first);
283 for (
auto& nameToFunction : ThreeSPfilterNamesToFunctions)
285 for (
auto& nameToFunction : ThreeSPfilterNamesToFunctions)
352 B2DEBUG(20,
"SecMapTrainer::storeTC: pT/thresholdmin/-max: " << pT <<
"/" <<
m_config.
pTmin <<
"/" <<
366 std::vector<std::pair<FullSecID, const SpacePoint*> > goodSPs;
371 aSP->getNormalizedLocalU(), aSP->getNormalizedLocalV());
372 if (fSecID.
getFullSecID() == std::numeric_limits<unsigned int>::max())
373 { B2ERROR(
"a secID for spacePoint not found!");
continue; }
375 goodSPs.push_back({fSecID, aSP});
379 B2DEBUG(20,
"SecMapTrainer::storeTC: the TC has now nHits/threshold: " << goodSPs.size() <<
"/" <<
m_config.
nHitsMin);
380 if (goodSPs.size() <
m_config.
nHitsMin || goodSPs.size() == 0)
return false;
383 if (tc.
isOutgoing()) std::reverse(goodSPs.begin(), goodSPs.end());
387 int prevLayerNum = goodSPs.at(0).second->getVxdID().getLayerNumber();
388 for (
auto& spCand : goodSPs) {
389 int thisLayerNum = spCand.second->getVxdID().getLayerNumber();
391 if (thisLayerNum > prevLayerNum) {
392 B2DEBUG(20,
"Rejected TC due to layer ordering of SPs! previous layer: " << prevLayerNum <<
" this layer: " << thisLayerNum);
395 prevLayerNum = thisLayerNum;
428 unsigned n2HitResults = 0;
429 unsigned n3HitResults = 0;
430 unsigned nTracksProcessed =
m_tcs.size();
432 for (
const auto& tc :
m_tcs) {
440 B2DEBUG(25,
"SecMapTrainer::processTracks: nStoredValues for 2-/3-hit: " << n2HitResults <<
"/" << n3HitResults);
442 return nTracksProcessed;
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType Mag() const
The magnitude (rho in spherical coordinate system).
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Small class which stores the filters/selectionVariables to be used for a secMap and has an interface ...
This class contains everything needed by the VXDTF that is not going to change during a RUN,...
static FiltersContainer & getInstance()
one and only way to access the singleton object
Class to identify a sector inside of the VXD.
std::string getFullSecString() const
returns the FullSecID coded as string compatible to secIDs stored in the xml-sectormaps
unsigned int getFullSecID() const
returns the FullSecID coded as integer for further use (can be reconverted to FullSecID by using Full...
To be used as an interface to root-stuff.
void fill3Hit()
fill three-hit-combinations in tree, triggers an Error if values not set yet.
void initialize3Hit(std::vector< std::string > filterNames)
initialize the RawSecMapRootInterface for three-hit-combinations (to be called in Module::initialize(...
FilterValueDataSet< SecIDTriplet > & get3HitDataSet()
returns a reference to the 3-hit-dataset so one can set the relevant values.
void fill2Hit()
fill two-hit-combinations in tree, triggers an Error if values not set yet.
void write()
write all trees to file at end of processing.
void initialize2Hit(std::vector< std::string > filterNames)
initialize the RawSecMapRootInterface for two-hit-combinations (to be called in Module::initialize().
FilterValueDataSet< SecIDPair > & get2HitDataSet()
returns a reference to the 2-hit-dataset so one can set the relevant values.
simple Hit class used for sectorMap-training.
simple Hit class used for sectorMap-training.
unsigned size() const
returns number of hits attached to current track.
ConstIterator innerEnd() const
returns the iterator-position pointing after the innermost hit.
int getTrackID() const
returns indexNumber of current track.
int getPDG() const
returns pdgCode of current track.
void addHit(SecMapTrainerHit hit)
adds hit to Track.
typename std::vector< SecMapTrainerHit >::const_iterator ConstIterator
typedef for more readable iterator-type
ConstIterator outermostHit() const
returns the iterator-position pointing to the outermost hit.
This class contains all relevant tools for training a VXDTFFilters.
SecMapTrainer(const std::string &setupName, const std::string &appendix="", const std::string &outputdir="./")
constructor.
FilterFactoryType m_factory
A factory taking care of having the correct filters prepared for secMapTraining.
const SectorMapConfig & getConfig()
returns configuration.
FilterMill< SecMapTrainerHit > m_filterMill
Stores the prepared filters and applies them on given hit-combinations.
void initialize()
initialize the trainer (to be called in Module::initialize().
void initializeEvent(int expNo, int runNo, int evtNo)
Initialize event.
const std::string getSetupName()
returns the name of the setup used for this trainer
void convertSP2TC(const std::vector< std::pair< FullSecID, const SpacePoint * > > &goodSPs, unsigned tcID, double pTValue, int pdgCode)
converts the SpacePoints into a SecMapTrainerTC and stores it to m_TCs
bool acceptHit(const SpacePoint &hit)
checks if given Hit is acceptable for this trainer.
void terminate()
initialize the trainer (to be called in Module::terminate().
unsigned m_runNo
contains current run number.
RawSecMapRootInterface m_rootInterface
Interface for nice and neat storing in root-ttree.
unsigned process3HitCombinations(const SecMapTrainerTC &aTC)
processes all three-hit-combinations of given TC and stores their results.
FiltersContainer< SpacePoint > & m_filtersContainer
a reference to the singleton FiltersContainer used for this training.
SectorMapConfig m_config
Contains all relevant configurations needed for training a sectorMap.
std::vector< SecMapTrainerTC > m_tcs
contains tcs of event, reset after each event.
unsigned m_expNo
contains current experiment number.
unsigned processTracks()
for given normalized local variables and VxdID a FullSecID is determined.
const std::string m_nameSetup
name of the setting to be used for this training
unsigned m_evtNo
contains current event number.
bool storeTC(const SpacePointTrackCand &tc, unsigned iD)
checks if given TC is acceptable for this trainer and store it if it is accepted.
unsigned process2HitCombinations(const SecMapTrainerTC &aTC)
processes all two-hit-combinations of given TC and stores their results.
Storage for (VXD) SpacePoint-based track candidates.
const ROOT::Math::XYZVector getPosSeed() const
get position seed as ROOT::Math::XYZVector
const ROOT::Math::XYZVector getMomSeed() const
get momentum seed as ROOT::Math::XYZVector
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
int getPdgCode() const
get pdg code
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
bool hasHitsOnSameSensor() const
Check if the SpacePointTrackCand contains consecutive SpacePoints that are on the same sensor WARNING...
bool isOutgoing() const
check if particle is outgoing (simply returns member m_flightDirection)!
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
decltype((0.<=DistanceInTimeUside< point_t >()<=0. &&0.<=DistanceInTimeVside< point_t >()<=0. &&0.<=Distance3DSquared< point_t >()<=0.&&0.<=Distance2DXYSquared< point_t >()<=0.&&0.<=Distance1DZ< point_t >()<=0.&&0.<=SlopeRZ< point_t >()<=0.&&0.<=Distance3DNormed< point_t >()<=0.)) twoHitFilter_t
minimal working 2-hits-example used for redesign of VXDTF.
decltype((0.<=DistanceInTime< point_t >()<=0. &&0.<=Angle3DSimple< point_t >()<=0.&&0.<=CosAngleXY< point_t >()<=0.&&0.<=AngleRZSimple< point_t >()<=0.&&CircleDist2IP< point_t >()<=0.&&0.<=DeltaSlopeRZ< point_t >()<=0.&&0.<=DeltaSlopeZoverS< point_t >()<=0.&&0.<=DeltaSoverZ< point_t >()<=0.&&0.<=HelixParameterFit< point_t >()<=0.&&0.<=Pt< point_t >()<=0.&&0.<=CircleRadius< point_t >()<=0.)) threeHitFilter_t
minimal working example for 3-hits:
std::unordered_map< std::string, typename Variable::functionType > SelectionVariableNamesToFunctions(Belle2::Filter< Variable, Range, Options... >)
Return a map from the SelectionVariable name to the SelectionVariable function of the Variable used i...
Abstract base class for different kinds of events.
small struct containing pointers to two hits.
const PointType * outer
outer hit.
const PointType * inner
inner hit.
small struct containing pointers to three hits.
const PointType * center
center hit.
const PointType * outer
outer hit.
const PointType * inner
inner hit.
simple struct containing all the configuration data needed for the SecMapTrainer.
double pTmin
stores pTCuts for min pT allowed for this .
double pTSmear
allows smearing of the cuts.
std::vector< int > pdgCodesAllowed
Stores all the pdgCodes which are allowed to be used by the SecMap.
double seedMaxDist2IPXY
Stores a cut for maximum distance of the seed in xy of the given virtual IP.
B2Vector3D vIP
Stores the position of the assumed position of the interaction point - The virtual IP.
double seedMaxDist2IPZ
Stores a cut for maximum distance of the seed in z of the given virtual IP.
double pTmax
stores pTCuts for min (.first) and max (.second) ptCut.
unsigned nHitsMin
Stores the minimal number of hits a TC must have to be accepted as TC (vIP-Hits are ignored).
std::vector< int > allowedLayers
stores allowed layers to be used (including virtual IP with layer 0).