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>
74 std::vector<std::string>
getRootFiles(std::string mapName);
84 template<
class ValueType> std::vector<BranchInterface<ValueType>>
getBranches(
85 std::unique_ptr<TChain>& chain,
86 const std::vector<std::string>& branchNames);
93 std::vector<std::string>& secBranchNames,
94 std::vector<std::string>& filterBranchNames);
100 std::vector<unsigned> iDs;
102 branch.update(entry);
103 iDs.push_back(branch.value);
112 std::unique_ptr<TChain>& chain,
119 std::unique_ptr<TChain>& chain,
126 std::unique_ptr<TChain>& chain,
133 unsigned int nHitCombinations,
bool print2File);
147 int nSecChainLength);
174 unsigned secChainLength)
176 B2INFO(
"processSectorCombinations: training map " << config.secMapName <<
" with secChainLength: " << secChainLength);
179 std::vector<std::string> secBranchNames;
181 std::vector<std::string> filterBranchNames;
186 if (chain->GetEntries() == 0) {
187 B2WARNING(
"raw data for map " << config.secMapName <<
" with " << nHit <<
" is empty! skipping");
192 std::vector<BranchInterface<unsigned>> sectorBranches = getBranches<unsigned>(chain, secBranchNames);
193 std::vector<BranchInterface<double>> filterBranches = getBranches<double>(chain, filterBranchNames);
196 printData(chain, sectorBranches, filterBranches);
202 unsigned nKilled = mainGraph.
pruneGraph(config.rarenessThreshold);
204 B2INFO(
"processSectorCombinations: nKilled after graph-pruning: " << nKilled);
207 for (
auto& subgraph : mainGraph) {
208 subgraph.second.prepareDataCollection(config.quantiles);
217 B2INFO(
"processSectorCombinations: nKilled before the training: " << nKilled);
219 trainGraph(mainGraph, chain, sectorBranches, filterBranches);
237 if (xHitFilters->
size() == 0) {
240 B2FATAL(
"processSectorCombinations: an empty VXDTFFilters was returned, training data did not work!");
254 B2INFO(
"RawSecMapMerger::initialize():");
260 auto config = setup.second->getConfig();
261 B2INFO(
"RawSecMapMerger::initialize(): loading mapName: " << config.secMapName);
265 B2INFO(
"\n\nRawSecMapMerger::initialize(): for mapName " << config.secMapName <<
": process 2-hit-combinations:\n\n");
275 if (xHitFilters->
size() == 0) {
276 B2FATAL(
"This should not happen!");
278 B2INFO(
"\n\nRawSecMapMerger::initialize(): for mapName " << config.secMapName <<
": process 3-hit-combinations:\n\n");
291 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!
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 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.
void printData(std::unique_ptr< TChain > &chain, std::vector< BranchInterface< unsigned >> §orBranches, std::vector< BranchInterface< double >> &filterBranches)
for debugging: print data for crosschecks.
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.
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 %).
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.
std::vector< unsigned > getSecIDs(std::vector< BranchInterface< unsigned >> &secBranches, Long64_t entry)
returns secIDs of current entry in the secBranches.
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.
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 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 occurances.
int getAbsThreshold(int relThreshold)
Get the absolute treshold (# nfound) given a relative threshold.
unsigned pruneGraph(double rarenessCut)
returns removed occurances.
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.