ATLAS Offline Software
Classes | Typedefs | Enumerations | Functions
RoiUtil Namespace Reference

Classes

class  range_error
 

Typedefs

typedef uint32_t roitype_t
 
typedef std::vector< std::vector< roitype_t > > roiserial_type
 

Enumerations

enum  ROIENUM {
  PARAM, ETA, ETAMINUS, ETAPLUS,
  PHI, PHIMINUS, PHIPLUS, ZED,
  ZEDMINUS, ZEDPLUS
}
 
enum  MASK { FULLSCAN = 0x1, COMPOSITE = 0x2, ROITYPE = 0x4 }
 

Functions

bool contains (const IRoiDescriptor &roi, double z0, double dzdr)
 see whether a segment is contained within the roi in r-z More...
 
bool contains_zrange (const IRoiDescriptor &roi, double z0, double dzdr, double zmin, double zmax)
 
bool contains (const IRoiDescriptor &roi, double z, double r, double phi)
 see whether a point is contained within the roi (in phi and r-z) More...
 
bool containsPhi (const IRoiDescriptor &roi, double phi)
 test whether a stub is contained within the roi More...
 
bool containsZed (const IRoiDescriptor &roi, double z, double r)
 
double phicheck (double phi)
 basic range checkers More...
 
double etacheck (double eta)
 
double zedcheck (double zed)
 
void serialise (const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
 serialise an entire vector of IRoiDescriptors More...
 
void serialise (const TrigRoiDescriptorCollection &rois, roiserial_type &s)
 serialise an entire TrigRoiDescriptor collection More...
 
void deserialise (const roiserial_type &s, std::vector< const IRoiDescriptor * > &rois)
 deserialise uint32_t vector into a full vector of IRoiDescriptors More...
 
void deserialise (const roiserial_type &s, TrigRoiDescriptorCollection &rois)
 deserialise uint32_t vector into a TrigRoiDescriptorCollection More...
 
void serialise (const IRoiDescriptor *roi, std::vector< roitype_t > &s)
 serialise a single IRoiDescriptor More...
 
IRoiDescriptordeserialise (const roitype_t *&s_end, const roitype_t *s_last)
 deserialise to a single IRoiDescriptors (including constituents) More...
 

Typedef Documentation

◆ roiserial_type

typedef std::vector< std::vector<roitype_t> > RoiUtil::roiserial_type

Definition at line 22 of file RoiSerialise.h.

◆ roitype_t

typedef uint32_t RoiUtil::roitype_t

Definition at line 21 of file RoiSerialise.h.

Enumeration Type Documentation

◆ MASK

Enumerator
FULLSCAN 
COMPOSITE 
ROITYPE 

Definition at line 35 of file RoiSerialise.cxx.

35  {
36  FULLSCAN = 0x1,
37  COMPOSITE = 0x2,
38  ROITYPE = 0x4
39  };

◆ ROIENUM

Enumerator
PARAM 
ETA 
ETAMINUS 
ETAPLUS 
PHI 
PHIMINUS 
PHIPLUS 
ZED 
ZEDMINUS 
ZEDPLUS 

Definition at line 28 of file RoiSerialise.cxx.

28  {
29  PARAM,
30  ETA, ETAMINUS, ETAPLUS,
31  PHI, PHIMINUS, PHIPLUS,
33  };

Function Documentation

◆ contains() [1/2]

bool RoiUtil::contains ( const IRoiDescriptor roi,
double  z,
double  r,
double  phi 
)

see whether a point is contained within the roi (in phi and r-z)

Definition at line 110 of file RoiUtil.cxx.

110  {
111  if ( roi.composite() ) {
112  for ( const IRoiDescriptor* rd : roi ) {
113  if ( RoiUtil::contains( *rd, z, r, phi ) ) return true;
114  }
115  return false;
116  }
117  else {
118  return ( RoiUtil::containsZed( roi, z, r ) && RoiUtil::containsPhi( roi, phi ) );
119  }
120 }

◆ contains() [2/2]

bool RoiUtil::contains ( const IRoiDescriptor roi,
double  z0,
double  dzdr 
)

see whether a segment is contained within the roi in r-z

test whether a stub is contained within the roi

Definition at line 42 of file RoiUtil.cxx.

42  {
43  const double zouter = dzdr*MAX_R + z0;
44 
45  auto contains_internal = [zouter, z0]( const IRoiDescriptor& rd ) {
46  return ( z0<=rd.zedPlus() && z0>=rd.zedMinus() &&
47  zouter<=rd.zedOuterPlus() && zouter>=rd.zedOuterMinus() );
48  };
49 
50  if ( roi.composite() ) {
51  for ( const IRoiDescriptor* rd : roi ) {
52  if ( contains_internal( *rd ) ) return true;
53  }
54  return false;
55  }
56  else return contains_internal( roi );
57 }

◆ contains_zrange()

bool RoiUtil::contains_zrange ( const IRoiDescriptor roi,
double  z0,
double  dzdr,
double  zmin,
double  zmax 
)

Definition at line 60 of file RoiUtil.cxx.

60  {
61  const double zouter = dzdr*MAX_R + z0;
62 
63  auto contains_internal = [zouter, z0, zmin, zmax]( const IRoiDescriptor& rd ) {
64  return ( z0<=zmax && z0>=zmin &&
65  zouter<=rd.zedOuterPlus() && zouter>=rd.zedOuterMinus() );
66  };
67 
68  if ( roi.composite() ) {
69  for ( const IRoiDescriptor* rd : roi ) {
70  if ( contains_internal( *rd ) ) return true;
71  }
72  return false;
73  }
74  else return contains_internal( roi );
75 }

◆ containsPhi()

bool RoiUtil::containsPhi ( const IRoiDescriptor roi,
double  phi 
)

test whether a stub is contained within the roi

Definition at line 79 of file RoiUtil.cxx.

79  {
80  if ( roi.composite() ) {
81  for ( const IRoiDescriptor* rd : roi ) {
82  if ( RoiUtil::containsPhi( *rd, phi ) ) return true;
83  }
84  return false;
85  }
86  else {
87  if ( roi.isFullscan() ) return true;
88  if ( roi.phiPlus()>roi.phiMinus() ) return ( phi<roi.phiPlus() && phi>roi.phiMinus() );
89  else return ( phi<roi.phiPlus() || phi>roi.phiMinus() );
90  }
91 }

◆ containsZed()

bool RoiUtil::containsZed ( const IRoiDescriptor roi,
double  z,
double  r 
)

Definition at line 94 of file RoiUtil.cxx.

94  {
95  if ( roi.composite() ) {
96  for ( const IRoiDescriptor* rd : roi ) {
97  if ( RoiUtil::containsZed( *rd, z, r ) ) return true;
98  }
99  return false;
100  }
101  else {
102  if ( roi.isFullscan() ) return true;
103  double zminus = r*roi.dzdrMinus() + roi.zedMinus();
104  double zplus = r*roi.dzdrPlus() + roi.zedPlus();
105  return ( z>=zminus && z<=zplus );
106  }
107 }

◆ deserialise() [1/3]

void RoiUtil::deserialise ( const roiserial_type s,
std::vector< const IRoiDescriptor * > &  rois 
)

deserialise uint32_t vector into a full vector of IRoiDescriptors

deserialise a serialised vector into a full vector of IRoiDescriptors

Definition at line 62 of file RoiSerialise.cxx.

62  {
63  if ( s.empty() ) return;
64  rois.resize(s.size());
65  for ( size_t i=0 ; i<s.size() ; i++ ) {
66  if ( s[i].empty() ) continue;
67  const roitype_t* s_end = &s[i][0];
68  const roitype_t* s_last = &s[i].back();
69  rois[i] = RoiUtil::deserialise( s_end, s_last );
70  }
71  // const roitype_t* s_end = &s[0];
72  // const roitype_t* s_last = &s.back();
73  // while ( s_end<s_last ) rois.push_back( RoiUtil::deserialise( s_end, s_last ) );
74 }

◆ deserialise() [2/3]

void RoiUtil::deserialise ( const roiserial_type s,
TrigRoiDescriptorCollection rois 
)

deserialise uint32_t vector into a TrigRoiDescriptorCollection

deserialise a serialised vector into a full vector of IRoiDescriptors

Oh dear, or dear rois.push_back( RoiUtil::deserialise( s_end, s_last ) );

while ( s_end<s_last )

Definition at line 78 of file RoiSerialise.cxx.

78  {
79  if ( s.empty() ) return;
80  for ( size_t i=0 ; i<s.size() ; i++ ) {
81  if ( s[i].empty() ) continue;
82  const roitype_t* s_end = &s[i][0];
83  const roitype_t* s_last = &s[i].back();
86  rois.push_back( dynamic_cast<TrigRoiDescriptor*>(RoiUtil::deserialise( s_end, s_last )) );
87 
88  }
90  // const roitype_t* s_end = &s[0];
91  // const roitype_t* s_last = &s.back();
92  // while ( s_end<s_last ) rois.push_back( dynamic_cast<TrigRoiDescriptor*>(RoiUtil::deserialise( s_end, s_last )) );
93 }

◆ deserialise() [3/3]

IRoiDescriptor * RoiUtil::deserialise ( const roitype_t *&  s_end,
const roitype_t s_last 
)

deserialise to a single IRoiDescriptors (including constituents)

get the packed version / fullscan / composite word

get the version

at this point we can have some customisation for the version number if required

is it a fullscan roi ?

is it a composite roi

set the expected limit of the serialised roitype_t container

calculate the untimate end of the basic roi roitype_t container

protection against over flowing the vector contents NB: this should really print an error or throw an exception but skipped in the interests of code portability

actually s_end becomes the address of the next word

get the additional (unwanted) roi words if required

create if fullscan

if not full scan, create with the roi parameters ...

this requires the roi words ... NB: if not required, the roi words are all set to 0

created the roi, now set composite if required NB: this is needed in case it is composite, but has no constituents

create constituents if required

Definition at line 162 of file RoiSerialise.cxx.

162  {
163 
164  TrigRoiDescriptor* roi = 0;
165 
166  const roitype_t* s = s_end;
167 
169  uint32_t param = *((uint32_t*)(&s[RoiUtil::PARAM]));
170 
172  int version = (param>>8);
173 
176 
178  bool fullscan = false;
179  if (param&1) fullscan = true;
180 
182  bool composite = false;
183  if (param&2) composite = true;
184 
185  bool roiwords = false;
186  if (param&4) roiwords = true;
187 
189  if ( fullscan ) s_end += RoiUtil::PARAM;
190  else s_end += RoiUtil::ZEDPLUS;
191 
193  unsigned Nextra = ( roiwords ? 3 : 0 );
194  s_end += Nextra;
195 
199  if ( s_end>s_last ) return 0;
200 
202  s_end++;
203 
205  unsigned extra[3] = { 0, 0, 0 };
206  unsigned extra_start = ( fullscan ? RoiUtil::PARAM+1 : RoiUtil::ZEDPLUS+1 );
207 
208  for ( unsigned i=0 ; i<Nextra ; i++ ) extra[i] = unsigned( s[extra_start+i] );
209 
210  unsigned roiWord = extra[0];
211  unsigned l1Id = extra[1];
212  unsigned roiId = extra[2];
213 
215  if ( fullscan ) roi = new TrigRoiDescriptor( true );
216  else {
218 
221  roi = new TrigRoiDescriptor( roiWord, l1Id, roiId,
225 
226  }
227 
228  if ( roi && version>roi->version() ) roi->version( version );
229 
230 
234  if ( roi && composite ) {
235 
236  roi->setComposite(true);
237 
239 
240  unsigned size = *s_end;
241 
242  s_end++;
243 
244  std::cout << "size " << size << std::endl;
245 
246  if ( size>0 ) {
247  for ( unsigned i=0 ; i<size ; i++ ) {
248  roi->push_back( RoiUtil::deserialise( s_end, s_last ) );
249  }
250  }
251  }
252 
253  return roi;
254 
255 }

◆ etacheck()

double RoiUtil::etacheck ( double  eta)

Definition at line 133 of file RoiUtil.cxx.

133  {
134  if ( !(eta>-100 && eta<100) ) { // check also for nan
135  throw range_error( (std::string("eta out of range: ")+std::to_string(eta)).c_str() );
136  }
137  return eta;
138 }

◆ phicheck()

double RoiUtil::phicheck ( double  phi)

basic range checkers

Definition at line 123 of file RoiUtil.cxx.

123  {
124  while ( phi> M_PIF ) phi-=M_2PI;
125  while ( phi<-M_PIF ) phi+=M_2PI;
126  if ( !(phi >= -M_PIF && phi <= M_PIF) ) { // use ! of range rather than range to also catch nan etc
127  throw range_error( (std::string("phi out of range: ")+std::to_string(phi)).c_str() );
128  }
129  return phi;
130 }

◆ serialise() [1/3]

void RoiUtil::serialise ( const IRoiDescriptor roi,
std::vector< roitype_t > &  s 
)

serialise a single IRoiDescriptor

serialise a single IRoiDescriptor (including constituents)

packed version number

pack fullscan flag

pack the composite flag

push back the additional (unwanted?) roi ID variables

now actual roi parameters

number of constituents if a composite roi

now serialise the constituents ...

Definition at line 97 of file RoiSerialise.cxx.

97  {
98 
100  uint32_t param = ( (roi->version()&0xff) << 8);
101 
103  // if ( roi->isFullscan() ) param |= 1;
104  if ( roi->isFullscan() ) param |= RoiUtil::FULLSCAN;
105 
107  // if ( roi->composite() ) param |= 0x2;
108  if ( roi->composite() ) param |= RoiUtil::COMPOSITE;
109 
111  uint32_t extra[3] = { roi->roiWord(), roi->l1Id(), roi->roiId() };
112 
113  // bool plusextra = false;
114  // for ( int i=0 ; i<3 ; i++ ) plusextra |= ( extra[i]!=0 );
115  bool plusextra = ( extra[0]!=0 ) || ( extra[1]!=0 ) || ( extra[2]!=0 );
116 
117  // if ( plusextra ) param |= 0x4;
118  if ( plusextra ) param |= RoiUtil::ROITYPE;
119 
120  // s.push_back( roi->isFullscan() ? 1 : 0 );
121  s.push_back( *((roitype_t*)&param) );
122 
123  int Nextra = 0;
124  if ( plusextra ) Nextra = 3;
125 
126  if ( !roi->isFullscan() ) {
128  s.push_back( uconv(roi->eta()) );
129  s.push_back( uconv(roi->etaMinus()) );
130  s.push_back( uconv(roi->etaPlus()) );
131 
132  s.push_back( uconv(roi->phi()) );
133  s.push_back( uconv(roi->phiMinus()) );
134  s.push_back( uconv(roi->phiPlus()) );
135 
136  s.push_back( uconv(roi->zed()) );
137  s.push_back( uconv(roi->zedMinus()) );
138  s.push_back( uconv(roi->zedPlus()) );
139  }
140 
141  for ( int i=0 ; i<Nextra ; i++ ) s.push_back( extra[i] ); // push back the size of extra information if required
142 
144  if ( roi->composite() ) {
145  s.push_back( roi->size() );
146 
148  // if ( roi->composite() && roi->size()>0 ) {
149  if ( roi->size()>0 ) {
150  IRoiDescriptor::roi_iterator itr = roi->begin();
151  IRoiDescriptor::roi_iterator iend = roi->end();
152  while ( itr!=iend ) RoiUtil::serialise( *itr++, s );
153  }
154  }
155 
156 }

◆ serialise() [2/3]

void RoiUtil::serialise ( const std::vector< const IRoiDescriptor * > &  rois,
RoiUtil::roiserial_type s 
)

serialise an entire vector of IRoiDescriptors

serialise a vector of IRoiDescriptors

Definition at line 45 of file RoiSerialise.cxx.

45  {
46  s.clear();
47  s.resize(rois.size());
48  for ( size_t i=0 ; i<rois.size() ; i++ ) RoiUtil::serialise( rois[i], s[i] );
49 }

◆ serialise() [3/3]

void RoiUtil::serialise ( const TrigRoiDescriptorCollection rois,
RoiUtil::roiserial_type s 
)

serialise an entire TrigRoiDescriptor collection

serialise a vector of IRoiDescriptors

Definition at line 53 of file RoiSerialise.cxx.

53  {
54  s.clear();
55  s.resize(rois.size());
56  for ( size_t i=0 ; i<rois.size() ; i++ ) RoiUtil::serialise( rois[i], s[i] );
57 }

◆ zedcheck()

double RoiUtil::zedcheck ( double  zed)

Definition at line 141 of file RoiUtil.cxx.

141  {
142  if ( !(zed>-100000 && zed<100000 ) ) { // check also for nan
143  throw range_error( (std::string("zed out of range: ")+std::to_string(zed)).c_str() );
144  }
145  return zed;
146 }
IRoiDescriptor::phi
virtual double phi() const =0
Methods to retrieve data members.
beamspotman.r
def r
Definition: beamspotman.py:676
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
IRoiDescriptor::begin
virtual roi_iterator begin() const =0
const limit iterators
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
IRoiDescriptor::roi_iterator
std::vector< const IRoiDescriptor * >::const_iterator roi_iterator
Definition: IRoiDescriptor.h:28
RoiUtil::FULLSCAN
@ FULLSCAN
Definition: RoiSerialise.cxx:36
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
IRoiDescriptor::etaMinus
virtual double etaMinus() const =0
RoiUtil::containsPhi
bool containsPhi(const IRoiDescriptor &roi, double phi)
test whether a stub is contained within the roi
Definition: RoiUtil.cxx:79
RoiUtil::containsZed
bool containsZed(const IRoiDescriptor &roi, double z, double r)
Definition: RoiUtil.cxx:94
IRoiDescriptor::size
virtual unsigned size() const =0
number of constituents
RoiUtil::ROITYPE
@ ROITYPE
Definition: RoiSerialise.cxx:38
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
IRoiDescriptor::end
virtual roi_iterator end() const =0
IRoiDescriptor::etaPlus
virtual double etaPlus() const =0
RoiUtil::PHI
@ PHI
Definition: RoiSerialise.cxx:31
uconv
const uint32_t & uconv(const float &x)
Definition: RoiSerialise.cxx:22
RoiUtil::PHIPLUS
@ PHIPLUS
Definition: RoiSerialise.cxx:31
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
RoiUtil::PARAM
@ PARAM
Definition: RoiSerialise.cxx:29
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
IRoiDescriptor::eta
virtual double eta() const =0
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition: RoiDescriptor.h:157
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
xAOD::roiId
setTeId setLumiBlock roiId
Definition: L2StandAloneMuon_v1.cxx:331
fconv
const float & fconv(const uint32_t &x)
Definition: RoiSerialise.cxx:23
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
RoiUtil::deserialise
void deserialise(const roiserial_type &s, std::vector< const IRoiDescriptor * > &rois)
deserialise uint32_t vector into a full vector of IRoiDescriptors
Definition: RoiSerialise.cxx:62
IRoiDescriptor::phiMinus
virtual double phiMinus() const =0
IRoiDescriptor::roiId
virtual unsigned int roiId() const =0
identifiers
RoiUtil::roitype_t
uint32_t roitype_t
Definition: RoiSerialise.h:21
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
RoiUtil::ETAPLUS
@ ETAPLUS
Definition: RoiSerialise.cxx:30
RoiUtil::COMPOSITE
@ COMPOSITE
Definition: RoiSerialise.cxx:37
RoiUtil::ETAMINUS
@ ETAMINUS
Definition: RoiSerialise.cxx:30
IRoiDescriptor::phiPlus
virtual double phiPlus() const =0
extreme phi values
python.handimod.extra
int extra
Definition: handimod.py:522
RoiUtil::ZEDMINUS
@ ZEDMINUS
Definition: RoiSerialise.cxx:32
IRoiDescriptor::l1Id
virtual unsigned int l1Id() const =0
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
RoiUtil::ETA
@ ETA
Definition: RoiSerialise.cxx:30
get_generator_info.version
version
Definition: get_generator_info.py:33
IRoiDescriptor::zedPlus
virtual double zedPlus() const =0
the zed and eta values at the most forward and most rear ends of the RoI
RoiUtil::ZEDPLUS
@ ZEDPLUS
Definition: RoiSerialise.cxx:32
TriggerTest.rois
rois
Definition: TriggerTest.py:23
IRoiDescriptor::isFullscan
virtual bool isFullscan() const =0
is this a full detector RoI?
IRoiDescriptor::zed
virtual double zed() const =0
IRoiDescriptor::zedMinus
virtual double zedMinus() const =0
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
RoiUtil::ZED
@ ZED
Definition: RoiSerialise.cxx:32
RoiUtil::contains
bool contains(const IRoiDescriptor &roi, double z0, double dzdr)
see whether a segment is contained within the roi in r-z
Definition: RoiUtil.cxx:42
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
RoiDescriptor::version
virtual int version() const override final
versioning
Definition: RoiDescriptor.h:123
M_2PI
#define M_2PI
Definition: CaloGpuGeneral_fnc.cxx:8
RoiUtil::PHIMINUS
@ PHIMINUS
Definition: RoiSerialise.cxx:31
IRoiDescriptor::version
virtual int version() const =0
which roi version?
IRoiDescriptor::roiWord
virtual unsigned int roiWord() const =0
IRoiDescriptor::composite
virtual bool composite() const =0
Super RoI access methods.