ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FPGATrackSimSectorSlice Class Reference

#include <FPGATrackSimSectorSlice.h>

Collaboration diagram for FPGATrackSimSectorSlice:

Public Member Functions

 FPGATrackSimSectorSlice (size_t nSectors, FPGATrackSimTrackParsI const &nBins, FPGATrackSimTrackPars const &min, FPGATrackSimTrackPars const &max)
 
 FPGATrackSimSectorSlice (const std::string &filepath)
 
 FPGATrackSimSectorSlice (const FPGATrackSimSectorSlice &)=delete
 
FPGATrackSimSectorSliceoperator= (const FPGATrackSimSectorSlice &)=delete
 
void addSectorToSlice (sector_t sector, FPGATrackSimTrackParsI const &bins)
 
void saveSlices (const std::string &filepath)
 
std::pair< FPGATrackSimTrackPars, FPGATrackSimTrackParsgetBoundaries () const
 
std::vector< sector_tsearchSectors (FPGATrackSimTrackPars const &pars) const
 

Private Member Functions

void calcDependentVals ()
 
void getBoundary (const TClonesArray *bitmasks, double x_min, double x_max, double &autoMin, double &autoMax, bool wraps, const char *debug) const
 Given a range [x_min, x_max] split in bins corresponding to the size of bitmasks, finds a tighter range of x values for where the bitmasks are non-empty. More...
 
bool checkTrackPars (FPGATrackSimTrackPars const &pars) const
 

Private Attributes

TClonesArray * m_bits_phi = nullptr
 
TClonesArray * m_bits_c = nullptr
 
TClonesArray * m_bits_d0 = nullptr
 
TClonesArray * m_bits_z0 = nullptr
 
TClonesArray * m_bits_eta = nullptr
 
FPGATrackSimTrackParsI m_nBins
 
FPGATrackSimTrackPars m_min
 
FPGATrackSimTrackPars m_max
 
FPGATrackSimTrackPars m_step
 

Detailed Description

Definition at line 31 of file FPGATrackSimSectorSlice.h.

Constructor & Destructor Documentation

◆ FPGATrackSimSectorSlice() [1/3]

FPGATrackSimSectorSlice::FPGATrackSimSectorSlice ( size_t  nSectors,
FPGATrackSimTrackParsI const nBins,
FPGATrackSimTrackPars const min,
FPGATrackSimTrackPars const max 
)

Definition at line 39 of file FPGATrackSimSectorSlice.cxx.

41  :
42  m_nBins(nBins),
43  m_min(min),
44  m_max(max)
45 {
46  m_bits_phi = new TClonesArray("TBits", m_nBins.phi);
47  m_bits_c = new TClonesArray("TBits", m_nBins.qOverPt);
48  m_bits_d0 = new TClonesArray("TBits", m_nBins.d0);
49  m_bits_z0 = new TClonesArray("TBits", m_nBins.z0);
50  m_bits_eta = new TClonesArray("TBits", m_nBins.eta);
51 
52  for (int i = 0; i < m_nBins.phi; i++) new ((*m_bits_phi)[i]) TBits(nSectors);
53  for (int i = 0; i < m_nBins.qOverPt; i++) new ((*m_bits_c)[i]) TBits(nSectors);
54  for (int i = 0; i < m_nBins.d0; i++) new ((*m_bits_d0)[i]) TBits(nSectors);
55  for (int i = 0; i < m_nBins.z0; i++) new ((*m_bits_z0)[i]) TBits(nSectors);
56  for (int i = 0; i < m_nBins.eta; i++) new ((*m_bits_eta)[i]) TBits(nSectors);
57 
59 }

◆ FPGATrackSimSectorSlice() [2/3]

FPGATrackSimSectorSlice::FPGATrackSimSectorSlice ( const std::string &  filepath)

Definition at line 62 of file FPGATrackSimSectorSlice.cxx.

63 {
64  ANA_MSG_INFO("Reading " << filepath);
65  TFile *slice_file = TFile::Open(filepath.c_str());
66 
67  m_bits_phi = dynamic_cast<TClonesArray*>(slice_file->Get("c_bits_phi"));
68  m_bits_c = dynamic_cast<TClonesArray*>(slice_file->Get("c_bits_c"));
69  m_bits_d0 = dynamic_cast<TClonesArray*>(slice_file->Get("c_bits_d"));
70  m_bits_z0 = dynamic_cast<TClonesArray*>(slice_file->Get("c_bits_z0"));
71 
72  // kludge for backward compatability
73  if ((slice_file->Get("c_bits_eta")) != nullptr)
74  m_bits_eta = dynamic_cast<TClonesArray*>(slice_file->Get("c_bits_eta"));
75  else
76  m_bits_eta = dynamic_cast<TClonesArray*>(slice_file->Get("c_bits_ctheta"));
77 
78  if (not m_bits_eta){
79  ANA_MSG_ERROR("m_bits_eta is null in FPGATrackSimSectorSlice constructor");
80  delete slice_file;
81  return;
82  }
83  TTree *slice_tree = dynamic_cast<TTree*>(slice_file->Get("bin_info"));
84  if (not slice_tree){
85  ANA_MSG_ERROR("slice_tree is null in FPGATrackSimSectorSlice constructor");
86  delete slice_file;
87  return;
88  }
89  slice_tree->SetBranchAddress("qOverPt_max", &m_max.qOverPt);
90  slice_tree->SetBranchAddress("d0_max", &m_max.d0);
91  slice_tree->SetBranchAddress("phi_max", &m_max.phi);
92  slice_tree->SetBranchAddress("z0_max", &m_max.z0);
93  slice_tree->SetBranchAddress("eta_max", &m_max.eta);
94 
95  slice_tree->SetBranchAddress("qOverPt_min", &m_min.qOverPt);
96  slice_tree->SetBranchAddress("d0_min", &m_min.d0);
97  slice_tree->SetBranchAddress("phi_min", &m_min.phi);
98  slice_tree->SetBranchAddress("z0_min", &m_min.z0);
99  slice_tree->SetBranchAddress("eta_min", &m_min.eta);
100 
101  slice_tree->SetBranchAddress("qOverPt_bins",&m_nBins.qOverPt);
102  slice_tree->SetBranchAddress("d0_bins", &m_nBins.d0);
103  slice_tree->SetBranchAddress("phi_bins", &m_nBins.phi);
104  slice_tree->SetBranchAddress("z0_bins", &m_nBins.z0);
105  slice_tree->SetBranchAddress("eta_bins", &m_nBins.eta);
106 
107  // For backwards compatability
108  if (slice_tree->GetBranch("qOverPt_max") == nullptr) slice_tree->SetBranchAddress("halfInvPt_max", &m_max.qOverPt);
109  if (slice_tree->GetBranch("qOverPt_min") == nullptr) slice_tree->SetBranchAddress("halfInvPt_min", &m_min.qOverPt);
110  if (slice_tree->GetBranch("qOverPt_bins") == nullptr) slice_tree->SetBranchAddress("halfInvPt_bins", &m_nBins.qOverPt);
111 
112  slice_tree->GetEntry(0);
113 
115 
116  delete slice_file;
117 }

◆ FPGATrackSimSectorSlice() [3/3]

FPGATrackSimSectorSlice::FPGATrackSimSectorSlice ( const FPGATrackSimSectorSlice )
delete

Member Function Documentation

◆ addSectorToSlice()

void FPGATrackSimSectorSlice::addSectorToSlice ( sector_t  sector,
FPGATrackSimTrackParsI const bins 
)

Definition at line 135 of file FPGATrackSimSectorSlice.cxx.

136 {
137  int bin;
138 
139  bin = clamp(bins.phi, 0, m_nBins.phi);
140  static_cast<TBits*>(m_bits_phi->UncheckedAt(bin))->SetBitNumber(sector);
141 
142  bin = clamp(bins.qOverPt, 0, m_nBins.qOverPt);
143  static_cast<TBits*>(m_bits_c->UncheckedAt(bin))->SetBitNumber(sector);
144 
145  bin = clamp(bins.d0, 0, m_nBins.d0);
146  static_cast<TBits*>(m_bits_d0->UncheckedAt(bin))->SetBitNumber(sector);
147 
148  bin = clamp(bins.z0, 0, m_nBins.z0);
149  static_cast<TBits*>(m_bits_z0->UncheckedAt(bin))->SetBitNumber(sector);
150 
151  bin = clamp(bins.eta, 0, m_nBins.eta);
152  static_cast<TBits*>(m_bits_eta->UncheckedAt(bin))->SetBitNumber(sector);
153 }

◆ calcDependentVals()

void FPGATrackSimSectorSlice::calcDependentVals ( )
private

Definition at line 121 of file FPGATrackSimSectorSlice.cxx.

122 {
123 
126  m_step.d0 = (m_max.d0 - m_min.d0) / m_nBins.d0;
127  m_step.z0 = (m_max.z0 - m_min.z0) /m_nBins.z0;
129 }

◆ checkTrackPars()

bool FPGATrackSimSectorSlice::checkTrackPars ( FPGATrackSimTrackPars const pars) const
private

Definition at line 197 of file FPGATrackSimSectorSlice.cxx.

198 {
199  if (pars.phi < m_min.phi || pars.phi > m_max.phi) return false;
200  if (pars.qOverPt < m_min.qOverPt || pars.qOverPt > m_max.qOverPt) return false;
201  if (pars.d0 < m_min.d0 || pars.d0 > m_max.d0) return false;
202  if (pars.z0 < m_min.z0 || pars.z0 > m_max.z0) return false;
203  if (pars.eta < m_min.eta || pars.eta > m_max.eta) return false;
204  return true;
205 }

◆ getBoundaries()

std::pair< FPGATrackSimTrackPars, FPGATrackSimTrackPars > FPGATrackSimSectorSlice::getBoundaries ( ) const

Definition at line 252 of file FPGATrackSimSectorSlice.cxx.

253 {
256 
257  getBoundary(m_bits_phi, m_min.phi, m_max.phi, min.phi, max.phi, true, "phi");
258  getBoundary(m_bits_c, m_min.qOverPt, m_max.qOverPt, min.qOverPt, max.qOverPt, false, "c");
259  getBoundary(m_bits_d0, m_min.d0, m_max.d0, min.d0, max.d0, false, "d0");
260  getBoundary(m_bits_z0, m_min.z0, m_max.z0, min.z0, max.z0, false, "z0");
261  getBoundary(m_bits_eta, m_min.eta, m_max.eta, min.eta, max.eta, false, "eta");
262 
263  ANA_MSG_INFO("getBoundaries() returning " << min << "; " << max);
264  return { min, max };
265 }

◆ getBoundary()

void FPGATrackSimSectorSlice::getBoundary ( const TClonesArray *  bitmasks,
double  x_min,
double  x_max,
double &  bound_min,
double &  bound_max,
bool  wraps,
const char *  debug 
) const
private

Given a range [x_min, x_max] split in bins corresponding to the size of bitmasks, finds a tighter range of x values for where the bitmasks are non-empty.

Parameters
bitmasks- A TBits vector with sector bitmasks for each bin.
bound_min- Return value for the boundary min x
bound_max- Return value for the boundary max x

Definition at line 276 of file FPGATrackSimSectorSlice.cxx.

278 {
279  int nbin = bitmasks->GetEntries();
280 
281  // Find the bounds of where there are bits, i_lower and i_upper are inclusive.
282  int i_lower, i_upper;
283  if (!wraps)
284  {
285  for (i_lower = 0; i_lower < nbin-1; i_lower++)
286  if (dynamic_cast<TBits const *>(bitmasks->UncheckedAt(i_lower))->CountBits() > 0) break;
287  for (i_upper = nbin-1; i_upper > 0; i_upper--)
288  if (dynamic_cast<TBits const *>(bitmasks->UncheckedAt(i_upper))->CountBits() > 0) break;
289  }
290  else // special case for cyclic values that wrap around, like phi
291  {
292  // Mark bins with nonzero bits, with a safety margin
293  std::vector<bool> good_bins(nbin);
294  for (int j = 0; j < nbin; j++)
295  {
296  if (dynamic_cast<TBits const *>(bitmasks->UncheckedAt(j))->CountBits() > 0)
297  {
298  // add safety margin: +/- 1 bin
299  // if the good bins are not actually continuous, the region found below will leave out some bins
300  good_bins[(j+nbin-1) % nbin] = true; // mod to handle wrap-around
301  good_bins[j] = true;
302  good_bins[(j+1) % nbin] = true;
303  }
304  }
305 
306  // Locate largest continuous region
307  largest_region_wrap(good_bins, i_lower, i_upper);
308  }
309 
310  if (i_lower >= i_upper) ANA_MSG_WARNING("getBoundary() Completely empty bitmask array");
311  bound_min = x_min + ((x_max-x_min) * i_lower) / nbin;
312  bound_max = x_min + ((x_max-x_min) * (i_upper+1)) / nbin;
313 
314  ANA_MSG_INFO("getBoundary() " << debug << " nbin=" << nbin
315  << " range=[" << x_min << ", " << x_max
316  << "], index=[" << i_lower << ", " << i_upper
317  << "], result=[" << bound_min << ", " << bound_max << "]");
318 }

◆ operator=()

FPGATrackSimSectorSlice& FPGATrackSimSectorSlice::operator= ( const FPGATrackSimSectorSlice )
delete

◆ saveSlices()

void FPGATrackSimSectorSlice::saveSlices ( const std::string &  filepath)

Definition at line 156 of file FPGATrackSimSectorSlice.cxx.

157 {
158  TFile ofile(filepath.c_str(), "recreate");
159 
160  m_bits_phi->Write("c_bits_phi", TObject::kSingleKey);
161  m_bits_c->Write("c_bits_c", TObject::kSingleKey);
162  m_bits_d0->Write("c_bits_d", TObject::kSingleKey);
163  m_bits_z0->Write("c_bits_z0", TObject::kSingleKey);
164  m_bits_eta->Write("c_bits_eta", TObject::kSingleKey);
165 
166  TTree *slice_tree = new TTree("bin_info", "Slice binning information");
167 
168  slice_tree->Branch("qOverPt_max", &m_max.qOverPt);
169  slice_tree->Branch("d0_max", &m_max.d0);
170  slice_tree->Branch("phi_max", &m_max.phi);
171  slice_tree->Branch("z0_max", &m_max.z0);
172  slice_tree->Branch("eta_max", &m_max.eta);
173 
174  slice_tree->Branch("qOverPt_min", &m_min.qOverPt);
175  slice_tree->Branch("d0_min", &m_min.d0);
176  slice_tree->Branch("phi_min", &m_min.phi);
177  slice_tree->Branch("z0_min", &m_min.z0);
178  slice_tree->Branch("eta_min", &m_min.eta);
179 
180  slice_tree->Branch("qOverPt_bins",&m_nBins.qOverPt);
181  slice_tree->Branch("d0_bins", &m_nBins.d0);
182  slice_tree->Branch("phi_bins", &m_nBins.phi);
183  slice_tree->Branch("z0_bins", &m_nBins.z0);
184  slice_tree->Branch("eta_bins", &m_nBins.eta);
185 
186  slice_tree->Fill();
187 
188  ofile.Write();
189  ofile.Close();
190 }

◆ searchSectors()

std::vector< sector_t > FPGATrackSimSectorSlice::searchSectors ( FPGATrackSimTrackPars const pars) const

Definition at line 216 of file FPGATrackSimSectorSlice.cxx.

217 {
218  std::vector<sector_t> sectors;
219  if (!checkTrackPars(pars))
220  {
221  ANA_MSG_ERROR("searchSectors() Bad track parameters: " << pars);
222  return sectors;
223  }
224 
225  // Special case for phi
226  int bin = static_cast<int>((pars.phi - m_min.phi) / m_step.phi);
227  bin = (bin + m_nBins.phi) % m_nBins.phi; // modulo operator: phi wraps around
228  TBits result_bits = *(TBits*)(m_bits_phi->UncheckedAt(bin));
229 
230  result_bits &= *(TBits*)(m_bits_c->UncheckedAt(getBin(pars.qOverPt, m_min.qOverPt, m_step.qOverPt, m_nBins.qOverPt)));
231  result_bits &= *(TBits*)(m_bits_d0->UncheckedAt(getBin(pars.d0, m_min.d0, m_step.d0, m_nBins.d0)));
232  result_bits &= *(TBits*)(m_bits_z0->UncheckedAt(getBin(pars.z0, m_min.z0, m_step.z0, m_nBins.z0)));
233  result_bits &= *(TBits*)(m_bits_eta->UncheckedAt(getBin(pars.eta, m_min.eta, m_step.eta, m_nBins.eta)));
234 
235  unsigned int curPos = result_bits.FirstSetBit(0);
236  while (curPos != result_bits.GetNbits())
237  {
238  sectors.push_back(static_cast<sector_t>(curPos));
239  curPos = result_bits.FirstSetBit(curPos + 1);
240  }
241 
242  return sectors;
243 }

Member Data Documentation

◆ m_bits_c

TClonesArray* FPGATrackSimSectorSlice::m_bits_c = nullptr
private

Definition at line 62 of file FPGATrackSimSectorSlice.h.

◆ m_bits_d0

TClonesArray* FPGATrackSimSectorSlice::m_bits_d0 = nullptr
private

Definition at line 63 of file FPGATrackSimSectorSlice.h.

◆ m_bits_eta

TClonesArray* FPGATrackSimSectorSlice::m_bits_eta = nullptr
private

Definition at line 65 of file FPGATrackSimSectorSlice.h.

◆ m_bits_phi

TClonesArray* FPGATrackSimSectorSlice::m_bits_phi = nullptr
private

Definition at line 61 of file FPGATrackSimSectorSlice.h.

◆ m_bits_z0

TClonesArray* FPGATrackSimSectorSlice::m_bits_z0 = nullptr
private

Definition at line 64 of file FPGATrackSimSectorSlice.h.

◆ m_max

FPGATrackSimTrackPars FPGATrackSimSectorSlice::m_max
private

Definition at line 72 of file FPGATrackSimSectorSlice.h.

◆ m_min

FPGATrackSimTrackPars FPGATrackSimSectorSlice::m_min
private

Definition at line 71 of file FPGATrackSimSectorSlice.h.

◆ m_nBins

FPGATrackSimTrackParsI FPGATrackSimSectorSlice::m_nBins
private

Definition at line 68 of file FPGATrackSimSectorSlice.h.

◆ m_step

FPGATrackSimTrackPars FPGATrackSimSectorSlice::m_step
private

Definition at line 75 of file FPGATrackSimSectorSlice.h.


The documentation for this class was generated from the following files:
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
FPGATrackSimTrackPars::phi
double phi
Definition: FPGATrackSimTrackPars.h:24
max
#define max(a, b)
Definition: cfImp.cxx:41
FPGATrackSimTrackParsI::eta
int eta
Definition: FPGATrackSimTrackPars.h:62
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
FPGATrackSimTrackPars::qOverPt
double qOverPt
Definition: FPGATrackSimTrackPars.h:25
FPGATrackSimSectorSlice::getBoundary
void getBoundary(const TClonesArray *bitmasks, double x_min, double x_max, double &autoMin, double &autoMax, bool wraps, const char *debug) const
Given a range [x_min, x_max] split in bins corresponding to the size of bitmasks, finds a tighter ran...
Definition: FPGATrackSimSectorSlice.cxx:276
FPGATrackSimSectorSlice::calcDependentVals
void calcDependentVals()
Definition: FPGATrackSimSectorSlice.cxx:121
FPGATrackSimSectorSlice::m_bits_d0
TClonesArray * m_bits_d0
Definition: FPGATrackSimSectorSlice.h:63
FPGATrackSimSectorSlice::m_bits_c
TClonesArray * m_bits_c
Definition: FPGATrackSimSectorSlice.h:62
validation.ofile
ofile
Definition: validation.py:96
FPGATrackSimTrackPars::d0
double d0
Definition: FPGATrackSimTrackPars.h:26
FPGATrackSimSectorSlice::m_step
FPGATrackSimTrackPars m_step
Definition: FPGATrackSimSectorSlice.h:75
bin
Definition: BinsDiffFromStripMedian.h:43
FPGATrackSimSectorSlice::m_nBins
FPGATrackSimTrackParsI m_nBins
Definition: FPGATrackSimSectorSlice.h:68
getBin
int getBin(double x, double min, double step, int clamp_max)
Definition: FPGATrackSimSectorSlice.cxx:209
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
FPGATrackSimTrackParsI::d0
int d0
Definition: FPGATrackSimTrackPars.h:60
FPGATrackSimSectorSlice::m_min
FPGATrackSimTrackPars m_min
Definition: FPGATrackSimSectorSlice.h:71
FPGATrackSimTrackPars::eta
double eta
Definition: FPGATrackSimTrackPars.h:28
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimSectorSlice::checkTrackPars
bool checkTrackPars(FPGATrackSimTrackPars const &pars) const
Definition: FPGATrackSimSectorSlice.cxx:197
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
FPGATrackSimSectorSlice::m_max
FPGATrackSimTrackPars m_max
Definition: FPGATrackSimSectorSlice.h:72
min
#define min(a, b)
Definition: cfImp.cxx:40
sector_t
int32_t sector_t
Definition: FPGATrackSimTypes.h:21
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
FPGATrackSimSectorSlice::m_bits_eta
TClonesArray * m_bits_eta
Definition: FPGATrackSimSectorSlice.h:65
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
FPGATrackSimSectorSlice::m_bits_phi
TClonesArray * m_bits_phi
Definition: FPGATrackSimSectorSlice.h:61
FPGATrackSimTrackParsI::phi
int phi
Definition: FPGATrackSimTrackPars.h:58
FPGATrackSimTrackPars::z0
double z0
Definition: FPGATrackSimTrackPars.h:27
FPGATrackSimTrackParsI::z0
int z0
Definition: FPGATrackSimTrackPars.h:61
largest_region_wrap
void largest_region_wrap(std::vector< bool > const &good_bin, int &i_lower, int &i_upper)
Definition: FPGATrackSimSectorSlice.cxx:321
FPGATrackSimSectorSlice::m_bits_z0
TClonesArray * m_bits_z0
Definition: FPGATrackSimSectorSlice.h:64
FPGATrackSimTrackParsI::qOverPt
int qOverPt
Definition: FPGATrackSimTrackPars.h:59