12#include <framework/core/Module.h>
14#include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
15#include <tracking/trackFindingVXD/environment/VXDTFFilters.h>
16#include <tracking/dataobjects/SectorMapConfig.h>
17#include <tracking/trackFindingVXD/filterMap/map/FiltersContainer.h>
19#include <tracking/trackFindingVXD/sectorMapTools/BranchInterface.h>
20#include <tracking/trackFindingVXD/sectorMapTools/SectorGraph.h>
21#include <tracking/trackFindingVXD/sectorMapTools/SubGraph.h>
22#include <tracking/spacePointCreation/SpacePoint.h>
27#include <unordered_map>
71 std::vector<std::string>
getRootFiles(std::string mapName);
81 template<
class ValueType> std::vector<BranchInterface<ValueType>>
getBranches(
82 std::unique_ptr<TChain>& chain,
83 const std::vector<std::string>& branchNames);
90 std::vector<std::string>& secBranchNames,
91 std::vector<std::string>& filterBranchNames);
97 std::vector<unsigned> iDs;
100 iDs.push_back(branch.value);
109 std::unique_ptr<TChain>& chain,
116 std::unique_ptr<TChain>& chain,
123 std::unique_ptr<TChain>& chain,
130 unsigned int nHitCombinations,
bool print2File);
144 int nSecChainLength);
171 unsigned secChainLength)
173 B2INFO(
"processSectorCombinations: training map " << config.secMapName <<
" with secChainLength: " << secChainLength);
176 std::vector<std::string> secBranchNames;
178 std::vector<std::string> filterBranchNames;
183 if (chain->GetEntries() == 0) {
184 B2WARNING(
"raw data for map " << config.secMapName <<
" with " << nHit <<
" is empty! skipping");
189 std::vector<BranchInterface<unsigned>> sectorBranches = getBranches<unsigned>(chain, secBranchNames);
190 std::vector<BranchInterface<double>> filterBranches = getBranches<double>(chain, filterBranchNames);
193 printData(chain, sectorBranches, filterBranches);
199 unsigned nKilled = mainGraph.
pruneGraph(config.rarenessThreshold);
201 B2INFO(
"processSectorCombinations: nKilled after graph-pruning: " << nKilled);
204 for (
auto& subgraph : mainGraph) {
205 subgraph.second.prepareDataCollection(config.quantiles);
214 B2INFO(
"processSectorCombinations: nKilled before the training: " << nKilled);
216 trainGraph(mainGraph, chain, sectorBranches, filterBranches);
234 if (xHitFilters->
size() == 0) {
237 B2FATAL(
"processSectorCombinations: an empty VXDTFFilters was returned, training data did not work!");
251 B2INFO(
"RawSecMapMerger::initialize():");
257 auto config = setup.second->getConfig();
258 B2INFO(
"RawSecMapMerger::initialize(): loading mapName: " << config.secMapName);
262 B2INFO(
"\n\nRawSecMapMerger::initialize(): for mapName " << config.secMapName <<
": process 2-hit-combinations:\n\n");
272 if (xHitFilters->
size() == 0) {
273 B2FATAL(
"This should not happen!");
275 B2INFO(
"\n\nRawSecMapMerger::initialize(): for mapName " << config.secMapName <<
": process 3-hit-combinations:\n\n");
288 bool good(
const std::vector< unsigned>& ids);
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
const setupNameToFilters_t & getAllSetups(void)
returns all the available setups.
The RawSecMapMergerModule.
unsigned updateFilterSubLayerIDs(SectorGraph< FilterType > &mainGraph, VXDTFFilters< SpacePoint > &segFilters)
updates the sublayer ID of the FullSecIDs used in the VXDTFFilters with the one used during the train...
void add3HitFilters(VXDTFFilters< SpacePoint > &filterContainer, SubGraph< FilterType > &subGraph, const SectorMapConfig &config)
WARNING TODO clean up and documentation!
SectorGraph< FilterType > buildGraph(std::unique_ptr< TChain > &chain, std::vector< BranchInterface< unsigned > > §orBranches, std::vector< BranchInterface< double > > &filterBranches)
build graph with secChains found in TChain.
void initialize() override
Initializes the Module.
bool m_PARAMprintFullGraphs
If true, the full trained graphs will be printed to screen.
std::vector< BranchInterface< ValueType > > getBranches(std::unique_ptr< TChain > &chain, const std::vector< std::string > &branchNames)
for given chain and names of branches: this function returns their pointers to the branch and the con...
void printVXDTFFilters(const VXDTFFilters< SpacePoint > &filters, std::string configName, unsigned int nHitCombinations, bool print2File)
for debugging purposes: print VXDTFFilters into a file of name of the sectorMapConfig.
std::unique_ptr< TChain > createTreeChain(const SectorMapConfig &configuration, const std::string &nHitString)
bundle all relevant files to a TChain
std::vector< std::string > m_PARAMrootFileNames
///////////////////////////////////////////////////////////////////////////////// member variables of...
std::vector< std::string > m_PARAMmapNames
contains names of sectorMaps to be loaded.
void printData(std::unique_ptr< TChain > &chain, std::vector< BranchInterface< unsigned > > §orBranches, std::vector< BranchInterface< double > > &filterBranches)
for debugging: print data for crosschecks.
std::vector< std::string > getRootFiles(std::string mapName)
returns all names of root-files fitting given parameter mapName
int m_RelThreshold
Relative threshold for pruning the sector maps (in %).
std::vector< unsigned > getSecIDs(std::vector< BranchInterface< unsigned > > &secBranches, Long64_t entry)
returns secIDs of current entry in the secBranches.
void add4HitFilters(VXDTFFilters< SpacePoint > &filterContainer, SubGraph< FilterType > &subGraph, const SectorMapConfig &config)
WARNING TODO clean up and documentation!
RawSecMapMergerModule()
Constructor of the module.
void add2HitFilters(VXDTFFilters< SpacePoint > &filterContainer, SubGraph< FilterType > &subGraph, const SectorMapConfig &config)
WARNING TODO clean up and documentation!
void getSegmentFilters(const SectorMapConfig &config, SectorGraph< FilterType > &mainGraph, VXDTFFilters< SpacePoint > *xHitFilters, int nSecChainLength)
returns all VxdIDs (sensors) compatible with given configData.
void processSectorCombinations(const SectorMapConfig &config, VXDTFFilters< SpacePoint > *xHitFilters, unsigned secChainLength)
does everything needed for given chainLength of sectors (e.g.: 2 -> twoHitFilters)
void trainGraph(SectorGraph< FilterType > &mainGraph, std::unique_ptr< TChain > &chain, std::vector< BranchInterface< unsigned > > §orBranches, std::vector< BranchInterface< double > > &filterBranches)
fill the graphs with raw data fitting to their filters respectively.
std::string prepareNHitSpecificStuff(unsigned nHits, const SectorMapConfig &config, std::vector< std::string > &secBranchNames, std::vector< std::string > &filterBranchNames)
sets everything which is hit-dependent.
bool good(const std::vector< unsigned > &ids)
check that the vector of FullSecIDs
~RawSecMapMergerModule()
Destructor of the module.
void updateSubLayerIDs()
finds sectors having inner sectors in same layer and update them in the subGraph-ID.
std::string print(bool fullPrint=true) const
returns a string giving an overview of the graph.
unsigned pruneGraphBeforeTraining(int absThreshold)
returns removed occurrences.
int getAbsThreshold(int relThreshold)
Get the absolute threshold (# nfound) given a relative threshold.
unsigned pruneGraph(double rarenessCut)
returns removed occurrences.
contains all relevant stuff needed for dealing with a subGraph.
Class that contains all the static sectors to which the filters are attached.
unsigned size() const
returns number of compact secIDs stored for this filter-container.
Abstract base class for different kinds of events.
simple struct for interfacing the Branch.
simple struct containing all the configuration data needed for the SecMapTrainer.