ATLAS Offline Software
Loading...
Searching...
No Matches
RoiUtil Namespace Reference

Classes

class  range_error

Typedefs

typedef std::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
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)
bool containsPhi (const IRoiDescriptor &roi, double phi)
 test whether a stub is contained within the roi
bool containsZed (const IRoiDescriptor &roi, double z, double r)
double phicheck (double phi)
 basic range checkers
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
void serialise (const TrigRoiDescriptorCollection &rois, roiserial_type &s)
 serialise an entire TrigRoiDescriptor collection
void deserialise (const roiserial_type &s, std::vector< const IRoiDescriptor * > &rois)
 deserialise uint32_t vector into a full vector of IRoiDescriptors
void deserialise (const roiserial_type &s, TrigRoiDescriptorCollection &rois)
 deserialise uint32_t vector into a TrigRoiDescriptorCollection
void serialise (const IRoiDescriptor *roi, std::vector< roitype_t > &s)
 serialise a single IRoiDescriptor
IRoiDescriptordeserialise (const roitype_t *&s_end, const roitype_t *s_last)
 deserialise to a single IRoiDescriptors (including constituents)

Typedef Documentation

◆ roiserial_type

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

Definition at line 25 of file RoiSerialise.h.

◆ roitype_t

typedef std::uint32_t RoiUtil::roitype_t

Definition at line 24 of file RoiSerialise.h.

Enumeration Type Documentation

◆ MASK

Enumerator
FULLSCAN 
COMPOSITE 
ROITYPE 

Definition at line 37 of file RoiSerialise.cxx.

37 {
38 FULLSCAN = 0x1,
39 COMPOSITE = 0x2,
40 ROITYPE = 0x4
41 };

◆ ROIENUM

Enumerator
PARAM 
ETA 
ETAMINUS 
ETAPLUS 
PHI 
PHIMINUS 
PHIPLUS 
ZED 
ZEDMINUS 
ZEDPLUS 

Definition at line 30 of file RoiSerialise.cxx.

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}
Scalar phi() const
phi method
#define z
Describes the API of the Region of Ineterest geometry.
virtual bool composite() const =0
Super RoI access methods.
int r
Definition globals.cxx:22
bool containsPhi(const IRoiDescriptor &roi, double phi)
test whether a stub is contained within the roi
Definition RoiUtil.cxx:79
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
bool containsZed(const IRoiDescriptor &roi, double z, double r)
Definition RoiUtil.cxx:94

◆ 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 64 of file RoiSerialise.cxx.

64 {
65 if ( s.empty() ) return;
66 rois.resize(s.size());
67 for ( size_t i=0 ; i<s.size() ; i++ ) {
68 if ( s[i].empty() ) continue;
69 const roitype_t* s_end = &s[i][0];
70 const roitype_t* s_last = &s[i].back();
71 rois[i] = RoiUtil::deserialise( s_end, s_last );
72 }
73 // const roitype_t* s_end = &s[0];
74 // const roitype_t* s_last = &s.back();
75 // while ( s_end<s_last ) rois.push_back( RoiUtil::deserialise( s_end, s_last ) );
76}
static const Attributes_t empty
void deserialise(const roiserial_type &s, std::vector< const IRoiDescriptor * > &rois)
deserialise uint32_t vector into a full vector of IRoiDescriptors
std::uint32_t roitype_t

◆ 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 80 of file RoiSerialise.cxx.

80 {
81 if ( s.empty() ) return;
82 for ( size_t i=0 ; i<s.size() ; i++ ) {
83 if ( s[i].empty() ) continue;
84 const roitype_t* s_end = &s[i][0];
85 const roitype_t* s_last = &s[i].back();
88 rois.push_back( dynamic_cast<TrigRoiDescriptor*>(RoiUtil::deserialise( s_end, s_last )) );
89
90 }
92 // const roitype_t* s_end = &s[0];
93 // const roitype_t* s_last = &s.back();
94 // while ( s_end<s_last ) rois.push_back( dynamic_cast<TrigRoiDescriptor*>(RoiUtil::deserialise( s_end, s_last )) );
95}
value_type push_back(value_type pElem)
Add an element to the end of the collection.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...

◆ 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 164 of file RoiSerialise.cxx.

164 {
165
166 TrigRoiDescriptor* roi = 0;
167
168 const roitype_t* s = s_end;
169
171 uint32_t param = *(reinterpret_cast<const uint32_t*>(&s[RoiUtil::PARAM]));
172
174 int version = (param>>8);
175
178
180 bool fullscan = false;
181 if (param&1) fullscan = true;
182
184 bool composite = false;
185 if (param&2) composite = true;
186
187 bool roiwords = false;
188 if (param&4) roiwords = true;
189
191 if ( fullscan ) s_end += RoiUtil::PARAM;
192 else s_end += RoiUtil::ZEDPLUS;
193
195 unsigned Nextra = ( roiwords ? 3 : 0 );
196 s_end += Nextra;
197
201 if ( s_end>s_last ) return 0;
202
204 s_end++;
205
207 unsigned extra[3] = { 0, 0, 0 };
208 unsigned extra_start = ( fullscan ? RoiUtil::PARAM+1 : RoiUtil::ZEDPLUS+1 );
209
210 for ( unsigned i=0 ; i<Nextra ; i++ ) extra[i] = unsigned( s[extra_start+i] );
211
212 unsigned roiWord = extra[0];
213 unsigned l1Id = extra[1];
214 unsigned roiId = extra[2];
215
217 if ( fullscan ) roi = new TrigRoiDescriptor( true );
218 else {
220
223 roi = new TrigRoiDescriptor( roiWord, l1Id, roiId,
227
228 }
229
230 if ( roi && version>roi->version() ) roi->version( version );
231
232
236 if ( roi && composite ) {
237
238 roi->setComposite(true);
239
241
242 unsigned size = *s_end;
243
244 s_end++;
245
246 std::cout << "size " << size << std::endl;
247
248 if ( size>0 ) {
249 for ( unsigned i=0 ; i<size ; i++ ) {
250 roi->push_back( RoiUtil::deserialise( s_end, s_last ) );
251 }
252 }
253 }
254
255 return roi;
256
257}
const float & fconv(const uint32_t &x)
size_t size() const
Number of registered mappings.
Athena::TPCnvVers::Current TrigRoiDescriptor
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
void setComposite(bool b=true)
virtual int version() const override final
versioning

◆ 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}
Scalar eta() const
pseudorapidity method

◆ 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}
#define M_2PI
static const float M_PIF

◆ 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 99 of file RoiSerialise.cxx.

99 {
100
102 uint32_t param = ( (roi->version()&0xff) << 8);
103
105 // if ( roi->isFullscan() ) param |= 1;
106 if ( roi->isFullscan() ) param |= RoiUtil::FULLSCAN;
107
109 // if ( roi->composite() ) param |= 0x2;
110 if ( roi->composite() ) param |= RoiUtil::COMPOSITE;
111
113 uint32_t extra[3] = { roi->roiWord(), roi->l1Id(), roi->roiId() };
114
115 // bool plusextra = false;
116 // for ( int i=0 ; i<3 ; i++ ) plusextra |= ( extra[i]!=0 );
117 bool plusextra = ( extra[0]!=0 ) || ( extra[1]!=0 ) || ( extra[2]!=0 );
118
119 // if ( plusextra ) param |= 0x4;
120 if ( plusextra ) param |= RoiUtil::ROITYPE;
121
122 // s.push_back( roi->isFullscan() ? 1 : 0 );
123 s.push_back( * static_cast<roitype_t*>(&param) );
124
125 int Nextra = 0;
126 if ( plusextra ) Nextra = 3;
127
128 if ( !roi->isFullscan() ) {
130 s.push_back( uconv(roi->eta()) );
131 s.push_back( uconv(roi->etaMinus()) );
132 s.push_back( uconv(roi->etaPlus()) );
133
134 s.push_back( uconv(roi->phi()) );
135 s.push_back( uconv(roi->phiMinus()) );
136 s.push_back( uconv(roi->phiPlus()) );
137
138 s.push_back( uconv(roi->zed()) );
139 s.push_back( uconv(roi->zedMinus()) );
140 s.push_back( uconv(roi->zedPlus()) );
141 }
142
143 for ( int i=0 ; i<Nextra ; i++ ) s.push_back( extra[i] ); // push back the size of extra information if required
144
146 if ( roi->composite() ) {
147 s.push_back( roi->size() );
148
150 // if ( roi->composite() && roi->size()>0 ) {
151 if ( roi->size()>0 ) {
153 IRoiDescriptor::roi_iterator iend = roi->end();
154 while ( itr!=iend ) RoiUtil::serialise( *itr++, s );
155 }
156 }
157
158}
const uint32_t & uconv(const float &x)
virtual bool isFullscan() const =0
is this a full detector RoI?
virtual double eta() const =0
virtual int version() const =0
which roi version?
virtual roi_iterator end() const =0
virtual double phiPlus() const =0
extreme phi values
virtual double zedPlus() const =0
the zed and eta values at the most forward and most rear ends of the RoI
virtual double phiMinus() const =0
virtual double phi() const =0
Methods to retrieve data members.
virtual double zedMinus() const =0
virtual double zed() const =0
std::vector< constIRoiDescriptor * >::const_iterator roi_iterator
virtual unsigned size() const =0
number of constituents
virtual double etaMinus() const =0
virtual double etaPlus() const =0
virtual roi_iterator begin() const =0
const limit iterators
virtual unsigned int roiWord() const =0
virtual unsigned int roiId() const =0
identifiers
virtual unsigned int l1Id() const =0
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors

◆ 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 47 of file RoiSerialise.cxx.

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

◆ 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 55 of file RoiSerialise.cxx.

55 {
56 s.clear();
57 s.resize(rois.size());
58 for ( size_t i=0 ; i<rois.size() ; i++ ) RoiUtil::serialise( rois[i], s[i] );
59}
size_type size() const noexcept
Returns the number of elements in the collection.

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