ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimMatrixIO.h File Reference

Classes to read/write matrix files event by event. More...

#include "FPGATrackSimMatrixAccumulator.h"
#include "FPGATrackSimObjects/FPGATrackSimTypes.h"
#include <vector>
#include "TTree.h"
Include dependency graph for FPGATrackSimMatrixIO.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FPGATrackSimMatrixReader
class  FPGATrackSimMatrixWriter

Functions

void readTree (AccumulateMap &map, TTree *tree, size_t nLayers, size_t nCoords)
 Reads a matrix tree, accumulating its entries into a map.
std::vector< std::pair< std::vector< module_t >, FPGATrackSimMatrixAccumulator > > readTree (TTree *tree, size_t nLayers, size_t nCoords)
 Reads a matrix tree, accumulating its entries into a vector, in the order they are read.
template<typename Iter>
void fillTree (Iter begin, Iter end, TTree *tree, int nLayers, int nCoords)
 Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).
void fillTree (AccumulateMap &map, TTree *tree, int nLayers, int nCoords)
 Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).

Detailed Description

Classes to read/write matrix files event by event.

Author
Riley Xu - riley.nosp@m..xu@.nosp@m.cern..nosp@m.ch
Date
May 29th, 2020

See below for batch read and write functions.

Definition in file FPGATrackSimMatrixIO.h.

Function Documentation

◆ fillTree() [1/2]

void fillTree ( AccumulateMap & map,
TTree * tree,
int nLayers,
int nCoords )

Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).

Parameters
map- map to be written
tree- tree to be written to; this function will create the branches
nLayers- number of logical layers
nCoords- number of hit coordinates in a full (13/13) track

Definition at line 226 of file FPGATrackSimMatrixIO.cxx.

227{
228 fillTree(map.begin(), map.end(), tree, nLayers, nCoords);
229}
void fillTree(AccumulateMap &map, TTree *tree, int nLayers, int nCoords)
Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).
STL class.
TChain * tree

◆ fillTree() [2/2]

template<typename Iter>
void fillTree ( Iter begin,
Iter end,
TTree * tree,
int nLayers,
int nCoords )

Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).

Parameters
begin- iterator to a std::pair<std::vector<module_t>, FPGATrackSimMatrixAccumulator>> to begin filling
end- end iterator to stop filling
tree- tree to be written to; this function will create the branches
nLayers- number of logical layers
nCoords- number of hit coordinates in a full (13/13) track

Definition at line 157 of file FPGATrackSimMatrixIO.h.

158{
159 // Sort sectors by decreasing coverage
160 std::vector<Iter> sorted_sectors;
161 sorted_sectors.reserve(std::distance(begin, end));
162 for (Iter i = begin; i != end; i++) sorted_sectors.push_back(i);
163
164 std::sort(sorted_sectors.begin(), sorted_sectors.end(), [](Iter const & a, Iter const & b)
165 { return a->second.track_bins.size() > b->second.track_bins.size(); }
166 );
167
168 // Create the writer
169 FPGATrackSimMatrixWriter writer(tree, nLayers, nCoords);
170
171 // Fill the tree
172 for (Iter & sector_info : sorted_sectors)
173 writer.fill(sector_info->first, sector_info->second);
174}
static Double_t a
writer
show summary of content
Definition example.py:36
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ readTree() [1/2]

void readTree ( AccumulateMap & map,
TTree * tree,
size_t nLayers,
size_t nCoords )

Reads a matrix tree, accumulating its entries into a map.

Note this functions sets and resets branch addresses.

Parameters
map- map to be added to
tree- tree to be read
nLayers- number of logical layers
nCoords- number of hit coordinates in a full (13/13) track

Definition at line 92 of file FPGATrackSimMatrixIO.cxx.

93{
94 FPGATrackSimMatrixReader reader(tree, nLayers, nCoords);
95 while (reader.nextEntry())
96 accumulate(map, reader.getModules(), reader.getAccumulator());
97}
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
reader
read the goodrunslist xml file(s)
Definition collisions.py:22

◆ readTree() [2/2]

std::vector< std::pair< std::vector< module_t >, FPGATrackSimMatrixAccumulator > > readTree ( TTree * tree,
size_t nLayers,
size_t nCoords )

Reads a matrix tree, accumulating its entries into a vector, in the order they are read.

Note this functions sets and resets branch addresses.

Parameters
tree- tree to be read
nLayers- number of logical layers
nCoords- number of hit coordinates in a full (13/13) track

Definition at line 108 of file FPGATrackSimMatrixIO.cxx.

109{
110 std::vector<std::pair<std::vector<module_t>, FPGATrackSimMatrixAccumulator>> matrices;
111
112 FPGATrackSimMatrixReader reader(tree, nLayers, nCoords);
113 while (reader.nextEntry())
114 matrices.push_back({ reader.getModules(), reader.getAccumulator() });
115
116 return matrices;
117}