ATLAS Offline Software
Classes | Functions
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. More...
 
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. More...
 
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). More...
 
void fillTree (AccumulateMap &map, TTree *tree, int nLayers, int nCoords)
 Writes the contents of an AccumulateMap into the supplied tree (one entry per sector). More...
 

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 225 of file FPGATrackSimMatrixIO.cxx.

226 {
227  fillTree(map.begin(), map.end(), tree, nLayers, nCoords);
228 }

◆ 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 }

◆ 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 }

◆ 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 }
FPGATrackSimMatrixWriter
Definition: FPGATrackSimMatrixIO.h:87
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
tree
TChain * tree
Definition: tile_monitor.h:30
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
fillTree
void fillTree(AccumulateMap &map, TTree *tree, int nLayers, int nCoords)
Writes the contents of an AccumulateMap into the supplied tree (one entry per sector).
Definition: FPGATrackSimMatrixIO.cxx:225
lumiFormat.i
int i
Definition: lumiFormat.py:92
FPGATrackSimMatrixAccumulator
Definition: FPGATrackSimMatrixAccumulator.h:36
FPGATrackSimMatrixReader
Definition: FPGATrackSimMatrixIO.h:41
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
collisions.reader
reader
read the goodrunslist xml file(s)
Definition: collisions.py:22
example.writer
writer
show summary of content
Definition: example.py:36
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54