13 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
15 #include <tracking/trackFindingVXD/sectorMapTools/SecMapTrainerHit.h>
16 #include <tracking/trackFindingVXD/sectorMapTools/SecMapTrainerTC.h>
17 #include <tracking/dataobjects/SectorMapConfig.h>
18 #include <tracking/trackFindingVXD/environment/VXDTFFilters.h>
20 #include <tracking/trackFindingVXD/sectorMapTools/FilterMill.h>
21 #include <tracking/trackFindingVXD/sectorMapTools/RawSecMapRootInterface.h>
23 #include <tracking/trackFindingVXD/filterMap/map/FiltersContainer.h>
24 #include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariableNamesToFunctions.h>
25 #include <framework/geometry/B2Vector3.h>
27 #include <tracking/dataobjects/FullSecID.h>
28 #include <vxd/dataobjects/VxdID.h>
44 template <
class FilterFactoryType>
70 std::vector<SecMapTrainerTC>
m_tcs;
92 auto layerID = hit.getVxdID().getLayerNumber();
96 ids += std::to_string(allowedLayer) +
" ";
97 if (allowedLayer == layerID) found =
true;
99 B2DEBUG(10,
"SecMapTrainer::acceptHit: the TC has layerID: " << layerID <<
" and allowd layers: " << ids <<
" and was " <<
100 (found ?
"accepted" :
"rejected"));
110 unsigned nValues = 0;
111 B2DEBUG(10,
"SecMapTrainer::process2HitCombinations: nHits/trackID/pdg: " << aTC.size() <<
"/" << aTC.getTrackID() <<
"/" <<
113 if (aTC.size() < 2) {
return nValues; }
120 std::vector<std::pair<std::string, double> > collectedResults;
121 for (; innerIt != aTC.innerEnd();) {
122 B2DEBUG(10,
"SecMapTrainer::process2HitCombinations: outerHit-/innerHitSecID: " << outerIt->getSectorIDString() <<
123 "/" << innerIt->getSectorIDString());
129 dataSet.trackNo = aTC.getTrackID();
130 dataSet.pdg = aTC.getPDG();
131 dataSet.secIDs.outer = outerIt->getSectorID().getFullSecID();
132 dataSet.secIDs.inner = innerIt->getSectorID().getFullSecID();
136 newHitPair.
outer = &(*outerIt);
137 newHitPair.
inner = &(*innerIt);
138 m_filterMill.grindData2Hit(newHitPair, collectedResults);
141 for (
const auto& entry : collectedResults) {
142 B2DEBUG(50,
"SecMapTrainer::process2HitCombinations: filter/value: " << entry.first <<
"/" << entry.second);
143 dataSet.setValueOfFilter(entry.first, entry.second);
147 collectedResults.clear();
159 unsigned nValues = 0;
160 B2DEBUG(10,
"SecMapTrainer::process3HitCombinations: nHits/trackID/pdg: " << aTC.size() <<
"/" << aTC.getTrackID() <<
"/" <<
162 if (aTC.size() < 3) {
return nValues; }
170 std::vector<std::pair<std::string, double> > collectedResults;
171 for (; innerIt != aTC.innerEnd();) {
172 B2DEBUG(10,
"SecMapTrainer::process3HitCombinations: outer-/center-/innerHitSecID: " << outerIt->getSectorIDString() <<
173 "/" << centerIt->getSectorIDString() <<
174 "/" << innerIt->getSectorIDString());
180 dataSet.trackNo = aTC.getTrackID();
181 dataSet.pdg = aTC.getPDG();
182 dataSet.secIDs.outer = outerIt->getSectorID().getFullSecID();
183 dataSet.secIDs.center = centerIt->getSectorID().getFullSecID();
184 dataSet.secIDs.inner = innerIt->getSectorID().getFullSecID();
188 newHitTriplet.
outer = &(*outerIt);
189 newHitTriplet.
center = &(*centerIt);
190 newHitTriplet.
inner = &(*innerIt);
191 m_filterMill.grindData3Hit(newHitTriplet, collectedResults);
194 for (
const auto& entry : collectedResults) {
195 B2DEBUG(50,
"SecMapTrainer::process3HitCombinations: filter/value: " << entry.first <<
"/" << entry.second);
196 dataSet.setValueOfFilter(entry.first, entry.second);
200 collectedResults.clear();
211 std::vector<std::pair< FullSecID, const SpacePoint*> >& goodSPs,
212 unsigned tcID,
double pTValue,
int pdgCode)
214 B2DEBUG(10,
"SecMapTrainer::convertSPTC: nGoodHits: " << goodSPs.size());
216 SecMapTrainerTC newTrack(tcID, pTValue, pdgCode);
218 for (
const auto& secIDAndSPpair : goodSPs) {
219 FullSecID fullSecID = secIDAndSPpair.first;
220 B2DEBUG(20,
"SecMapTrainer::convertSPTC: found fullSecID: " << fullSecID.
getFullSecString());
228 newTrack.addHit(std::move(newVirtualHit));
230 m_tcs.push_back(std::move(newTrack));
237 explicit SecMapTrainer(
const std::string& setupName ,
const std::string& appendix =
"") :
248 m_expNo(std::numeric_limits<unsigned>::max()),
249 m_runNo(std::numeric_limits<unsigned>::max()),
250 m_evtNo(std::numeric_limits<unsigned>::max())
267 std::vector< std::string> twoHitFilters;
268 for (
const auto& filterNameToFunction : TwoSPfilterNamesToFunctions)
269 twoHitFilters.push_back(filterNameToFunction.first);
272 for (
auto& nameToFunction : TwoSPfilterNamesToFunctions)
280 std::vector< std::string> threeHitFilters;
281 for (
const auto& filterNameToFunction : ThreeSPfilterNamesToFunctions)
282 threeHitFilters.push_back(filterNameToFunction.first);
285 for (
auto& nameToFunction : ThreeSPfilterNamesToFunctions)
287 for (
auto& nameToFunction : ThreeSPfilterNamesToFunctions)
335 bool storeTC(
const SpacePointTrackCand& tc,
unsigned iD)
337 B2DEBUG(10,
"SecMapTrainer::storeTC: nHits/threshold: " << tc.getNHits() <<
"/" <<
m_config.
nHitsMin);
341 B2DEBUG(10,
"SecMapTrainer::storeTC: hasHitsOnSameSensor: " << tc.hasHitsOnSameSensor());
343 if (tc.hasHitsOnSameSensor())
return false;
348 if (tc.getPdgCode() == pdg) found =
true;
353 auto pT = tc.getMomSeed().Perp();
354 B2DEBUG(10,
"SecMapTrainer::storeTC: pT/thresholdmin/-max: " << pT <<
"/" <<
m_config.
pTmin <<
"/" <<
368 std::vector<std::pair<FullSecID, const SpacePoint*> > goodSPs;
373 aSP->getNormalizedLocalU(), aSP->getNormalizedLocalV());
374 if (fSecID.
getFullSecID() == std::numeric_limits<unsigned int>::max())
375 { B2ERROR(
"a secID for spacePoint not found!");
continue; }
377 goodSPs.push_back({fSecID, aSP});
381 B2DEBUG(10,
"SecMapTrainer::storeTC: the TC has now nHits/threshold: " << goodSPs.size() <<
"/" <<
m_config.
nHitsMin);
382 if (goodSPs.size() <
m_config.
nHitsMin || goodSPs.size() == 0)
return false;
385 if (tc.isOutgoing()) std::reverse(goodSPs.begin(), goodSPs.end());
389 int prevLayerNum = goodSPs.at(0).second->getVxdID().getLayerNumber();
390 for (
auto& spCand : goodSPs) {
391 int thisLayerNum = spCand.second->getVxdID().getLayerNumber();
393 if (thisLayerNum > prevLayerNum) {
394 B2DEBUG(20,
"Rejected TC due to layer ordering of SPs! previous layer: " << prevLayerNum <<
" this layer: " << thisLayerNum);
397 prevLayerNum = thisLayerNum;
401 convertSP2TC(goodSPs, iD, tc.getMomSeed().Perp(), tc.getPdgCode());
430 unsigned n2HitResults = 0;
431 unsigned n3HitResults = 0;
432 unsigned nTracksProcessed =
m_tcs.size();
434 for (
const auto& tc :
m_tcs) {
442 B2DEBUG(25,
"SecMapTrainer::processTracks: nStoredValues for 2-/3-hit: " << n2HitResults <<
"/" << n3HitResults);
444 return nTracksProcessed;