ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimSectorSlice.cxx File Reference
#include "FPGATrackSimBanks/FPGATrackSimSectorSlice.h"
#include <TFile.h>
#include <TTree.h>
#include <TBits.h>
#include <TClonesArray.h>
#include <AsgMessaging/MessageCheck.h>
Include dependency graph for FPGATrackSimSectorSlice.cxx:

Go to the source code of this file.

Functions

void largest_region_wrap (std::vector< bool > const &good_bin, int &i_lower, int &i_upper)
int getBin (double x, double min, double step, int clamp_max)

Function Documentation

◆ getBin()

int getBin ( double x,
double min,
double step,
int clamp_max )

Definition at line 209 of file FPGATrackSimSectorSlice.cxx.

210{
211 int bin = static_cast<int>((x - min) / step);
212 return clamp(bin, 0, clamp_max);
213}
#define x
#define min(a, b)
Definition cfImp.cxx:40

◆ largest_region_wrap()

void largest_region_wrap ( std::vector< bool > const & good_bin,
int & i_lower,
int & i_upper )

Definition at line 321 of file FPGATrackSimSectorSlice.cxx.

322{
323 int start = -1; // start of current region
324 int best_start = -1; // start of best region
325 int best_size = 0; // size of best region
326 for (int j = 0; j < 2*(int)good_bins.size(); j++) // j < 2*size to get regions across j=0
327 {
328 if (good_bins[j % good_bins.size()])
329 {
330 if (start < 0) start = j; // start region
331 int size = j + 1 - start;
332 if (size > best_size)
333 {
334 best_start = start;
335 best_size = size;
336 if (best_size == (int)good_bins.size()) break; // All bins are filled
337 }
338 }
339 else // end region
340 {
341 start = -1;
342 }
343 }
344 i_lower = best_start;
345 i_upper = best_start + best_size - 1; // inclusive
346 // May be larger than nbin, which causes max phi to be larger than 2pi, e.g.
347}