BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
CDFootPrint Class Reference

#include <CDFootPrint.h>

Public Member Functions

 CDFootPrint ()
 CDFootPrint (const CDFootPrint &)
virtual ~CDFootPrint ()
const CDFootPrintoperator= (const CDFootPrint &)
const CDFootPrintoperator+= (const CDFootPrint &aOtherPrint)
CDFootPrintfresh ()
bool operator== (const CDFootPrint &aOtherPrint) const
bool operator!= (const CDFootPrint &aOtherPrint) const
CDFootPrint operator+ (const CDFootPrint &aOtherPrint) const
bool overlap (const CDFootPrint &aOtherPrint) const
bool contains (const CDFootPrint &aOtherPrint) const
uint32_t ToUInt32 () const
 CDFootPrint ()
 CDFootPrint (const CDFootPrint &)
virtual ~CDFootPrint ()
const CDFootPrintoperator= (const CDFootPrint &)
const CDFootPrintoperator+= (const CDFootPrint &aOtherPrint)
CDFootPrintfresh ()
bool operator== (const CDFootPrint &aOtherPrint) const
bool operator!= (const CDFootPrint &aOtherPrint) const
CDFootPrint operator+ (const CDFootPrint &aOtherPrint) const
bool overlap (const CDFootPrint &aOtherPrint) const
bool contains (const CDFootPrint &aOtherPrint) const
uint32_t ToUInt32 () const
 CDFootPrint ()
 CDFootPrint (const CDFootPrint &)
virtual ~CDFootPrint ()
const CDFootPrintoperator= (const CDFootPrint &)
const CDFootPrintoperator+= (const CDFootPrint &aOtherPrint)
CDFootPrintfresh ()
bool operator== (const CDFootPrint &aOtherPrint) const
bool operator!= (const CDFootPrint &aOtherPrint) const
CDFootPrint operator+ (const CDFootPrint &aOtherPrint) const
bool overlap (const CDFootPrint &aOtherPrint) const
bool contains (const CDFootPrint &aOtherPrint) const
uint32_t ToUInt32 () const

Static Public Member Functions

static void reset ()
static void reset ()
static void reset ()

Friends

class FingerPrint
std::ostream & operator<< (std::ostream &os, const CDFootPrint &obj)
std::ostream & operator<< (std::ostream &os, const CDFootPrint &obj)
std::ostream & operator<< (std::ostream &os, const CDFootPrint &obj)

Detailed Description

Constructor & Destructor Documentation

◆ CDFootPrint() [1/6]

CDFootPrint::CDFootPrint ( )

Definition at line 103 of file CDFootPrint.cxx.

103: m_size( 0 ), m_array( 0 ) { ++m_numberFootprints; }

Referenced by CDFootPrint(), contains(), FingerPrint, fresh(), operator!=(), operator+(), operator+=(), operator<<, operator=(), operator==(), and overlap().

◆ CDFootPrint() [2/6]

CDFootPrint::CDFootPrint ( const CDFootPrint & aOtherPrint)

Definition at line 107 of file CDFootPrint.cxx.

107 : m_size( 0 ), m_array( 0 ) {
108 //
109 // book the memory and copy contents of aOtherPrint
110 //
111 resize( aOtherPrint.m_size );
112 for ( uint32_t index = 0; index != m_size; ++index )
113 { m_array[index] = aOtherPrint.m_array[index]; }
114 ++m_numberFootprints;
115}

◆ ~CDFootPrint() [1/3]

CDFootPrint::~CDFootPrint ( )
virtual

Definition at line 119 of file CDFootPrint.cxx.

119 {
120 //
121 // delete memory
122 //
123 delete[] m_array;
124 if ( 0 == --m_numberFootprints ) { reset(); }
125}
static void reset()

◆ CDFootPrint() [3/6]

CDFootPrint::CDFootPrint ( )

◆ CDFootPrint() [4/6]

CDFootPrint::CDFootPrint ( const CDFootPrint & )

◆ ~CDFootPrint() [2/3]

virtual CDFootPrint::~CDFootPrint ( )
virtual

◆ CDFootPrint() [5/6]

CDFootPrint::CDFootPrint ( )

◆ CDFootPrint() [6/6]

CDFootPrint::CDFootPrint ( const CDFootPrint & )

◆ ~CDFootPrint() [3/3]

virtual CDFootPrint::~CDFootPrint ( )
virtual

Member Function Documentation

◆ contains() [1/3]

bool CDFootPrint::contains ( const CDFootPrint & aOtherPrint) const

Definition at line 373 of file CDFootPrint.cxx.

373 {
374 if ( this == &aOtherPrint )
375 {
376 //
377 // if being tested with itself return `true'
378 //
379 return ( !false );
380 }
381 //
382 // find the shortest length to compare the two memoery sections
383 //
384 uint32_t shorterSize;
385 if ( m_size > aOtherPrint.m_size ) { shorterSize = aOtherPrint.m_size; }
386 else { shorterSize = m_size; }
387
388 //
389 // for shorter CDFootPrint check aOtherPrint is within this one
390 //
391 uint32_t index = 0;
392 while ( ( index != shorterSize ) &&
393 ( m_array[index] == ( m_array[index] | aOtherPrint.m_array[index] ) ) )
394 { ++index; }
395 //
396 // if check finished before the shorter CDFootPrint was covered,
397 // then aOtherPrint has at least one bit outside this CDFootPrint
398 //
399 if ( index != shorterSize ) { return ( false ); }
400 //
401 // if this CDFootPrint is the longer then aOtherPrint is totally contained
402 //
403 if ( m_size > aOtherPrint.m_size ) { return ( !false ); }
404 //
405 // as aOtherPrint is longer need to check rest of it is zero
406 //
407 while ( ( index != aOtherPrint.m_size ) && ( aOtherPrint.m_array[index] == uint32_t( 0 ) ) )
408 { ++index; }
409 //
410 // if check finished before aOtherPrint was finished
411 // then aOtherPrint has at least one bit in the rest of it
412 //
413 return ( aOtherPrint.m_size == index );
414}

◆ contains() [2/3]

bool CDFootPrint::contains ( const CDFootPrint & aOtherPrint) const

◆ contains() [3/3]

bool CDFootPrint::contains ( const CDFootPrint & aOtherPrint) const

◆ fresh() [1/3]

CDFootPrint & CDFootPrint::fresh ( void )

Definition at line 208 of file CDFootPrint.cxx.

208 {
209 if ( m_size != 0 )
210 {
211 //
212 // if already assigned a value do nothing
213 //
214 return ( *this );
215 }
216
217 const uint32_t kBitsInByte = 8;
218 //
219 // Take a number and increase the number of CDFootPrints issued
220 //
221 uint32_t freshNumber = m_numberIssued++;
222 //
223 // calculate which bit, and which element to set
224 //
225 uint32_t element = freshNumber / ( kBitsInByte * sizeof( uint32_t ) );
226 uint32_t offsetInElement = freshNumber % ( kBitsInByte * sizeof( uint32_t ) );
227 //
228 // book enough memory
229 //
230 resize( element + 1 );
231 //
232 // fill all but the last part of the memory with zeros
233 //
234 for ( uint32_t index = 0; index < element; ++index ) { m_array[index] = uint32_t( 0 ); }
235 //
236 // fill in last part of memory with correct bit set
237 //
238 m_array[element] = uint32_t( 1 ) << offsetInElement;
239 return ( *this );
240}

◆ fresh() [2/3]

CDFootPrint & CDFootPrint::fresh ( )

◆ fresh() [3/3]

CDFootPrint & CDFootPrint::fresh ( )

◆ operator!=() [1/3]

bool CDFootPrint::operator!= ( const CDFootPrint & aOtherPrint) const

Definition at line 326 of file CDFootPrint.cxx.

326 {
327 return ( !operator==( aOtherPrint ) );
328}

◆ operator!=() [2/3]

bool CDFootPrint::operator!= ( const CDFootPrint & aOtherPrint) const

◆ operator!=() [3/3]

bool CDFootPrint::operator!= ( const CDFootPrint & aOtherPrint) const

◆ operator+() [1/3]

CDFootPrint CDFootPrint::operator+ ( const CDFootPrint & aOtherPrint) const

Definition at line 333 of file CDFootPrint.cxx.

333 {
334 CDFootPrint result( *this );
335 result += aOtherPrint;
336 return ( result );
337}

◆ operator+() [2/3]

CDFootPrint CDFootPrint::operator+ ( const CDFootPrint & aOtherPrint) const

◆ operator+() [3/3]

CDFootPrint CDFootPrint::operator+ ( const CDFootPrint & aOtherPrint) const

◆ operator+=() [1/3]

const CDFootPrint & CDFootPrint::operator+= ( const CDFootPrint & aOtherPrint)

Definition at line 148 of file CDFootPrint.cxx.

148 {
149 if ( this == &aOtherPrint )
150 {
151 //
152 // if Footprint is added and assigned to itself do nothing.
153 //
154 return ( *this );
155 }
156 if ( m_size >= aOtherPrint.m_size )
157 {
158 //
159 // if this Footprint is larger or equal than to aOtherPrint,
160 // only `or' with the contents of aOtherPoint
161 //
162 for ( uint32_t index = 0; index != aOtherPrint.m_size; ++index )
163 { m_array[index] |= aOtherPrint.m_array[index]; }
164 }
165 else
166 {
167 //
168 // if this Footprint is smaller than to aOtherPrint book new memory
169 // Note: can not use resize, as this thorws away old memory
170 //
171 uint32_t* tmp_ptr = new uint32_t[aOtherPrint.m_size];
172 if ( 0 == tmp_ptr )
173 {
174 std::cerr << "No memory to allocate another kinematicData" << std::endl;
175 exit( 1 );
176 }
177 //
178 // for the length of the old memory, fill the new memory with
179 // `or' of old and aOtherPrint
180 //
181 for ( uint32_t index_1 = 0; index_1 != m_size; ++index_1 )
182 { tmp_ptr[index_1] = m_array[index_1] | aOtherPrint.m_array[index_1]; }
183 //
184 // for the rest of length of the new memory, fill with aOtherPrint
185 //
186 for ( uint32_t index_2 = m_size; index_2 != aOtherPrint.m_size; ++index_2 )
187 { tmp_ptr[index_2] = aOtherPrint.m_array[index_2]; }
188 //
189 // delete old memory
190 //
191 delete[] m_array;
192 //
193 // update member data elements
194 //
195 m_size = aOtherPrint.m_size;
196 m_array = tmp_ptr;
197 }
198 return ( *this );
199}

◆ operator+=() [2/3]

const CDFootPrint & CDFootPrint::operator+= ( const CDFootPrint & aOtherPrint)

◆ operator+=() [3/3]

const CDFootPrint & CDFootPrint::operator+= ( const CDFootPrint & aOtherPrint)

◆ operator=() [1/3]

const CDFootPrint & CDFootPrint::operator= ( const CDFootPrint & aOtherPrint)

Definition at line 131 of file CDFootPrint.cxx.

131 {
132 if ( this == &aOtherPrint )
133 {
134 //
135 // if Footprint is assigned to itself do nothing.
136 //
137 return ( *this );
138 }
139 //
140 // book the memory and copy contents of aOtherPrint
141 //
142 resize( aOtherPrint.m_size );
143 for ( uint32_t index = 0; index != m_size; ++index )
144 { m_array[index] = aOtherPrint.m_array[index]; }
145 return ( *this );
146}

◆ operator=() [2/3]

const CDFootPrint & CDFootPrint::operator= ( const CDFootPrint & )

◆ operator=() [3/3]

const CDFootPrint & CDFootPrint::operator= ( const CDFootPrint & )

◆ operator==() [1/3]

bool CDFootPrint::operator== ( const CDFootPrint & aOtherPrint) const

Definition at line 281 of file CDFootPrint.cxx.

281 {
282 if ( this == &aOtherPrint )
283 {
284 //
285 // if being compare with itself return `true'
286 //
287 return ( !false );
288 }
289 //
290 // find the shortest length to compare the two memory sections
291 //
292 uint32_t shorterSize;
293 if ( m_size > aOtherPrint.m_size ) { shorterSize = aOtherPrint.m_size; }
294 else { shorterSize = m_size; }
295 //
296 // check shorter CDFootPrint matches the section longer CDFootPrint
297 //
298 uint32_t index = 0;
299 while ( ( index != shorterSize ) && ( m_array[index] == aOtherPrint.m_array[index] ) )
300 { ++index; }
301 //
302 // if check finished before the shorter CDFootPrint was covered,
303 // then two CDFootPrints are unequal
304 //
305 if ( index != shorterSize ) { return ( false ); }
306 //
307 // check that the rest of the longer footprint is zero
308 //
309 if ( m_size >= aOtherPrint.m_size )
310 {
311 while ( ( index != m_size ) && ( m_array[index] == uint32_t( 0 ) ) ) { ++index; }
312 return ( m_size == index );
313 }
314 else
315 {
316 while ( ( index != aOtherPrint.m_size ) &&
317 ( aOtherPrint.m_array[index] == uint32_t( 0 ) ) )
318 { ++index; }
319 return ( aOtherPrint.m_size == index );
320 }
321}

◆ operator==() [2/3]

bool CDFootPrint::operator== ( const CDFootPrint & aOtherPrint) const

◆ operator==() [3/3]

bool CDFootPrint::operator== ( const CDFootPrint & aOtherPrint) const

◆ overlap() [1/3]

bool CDFootPrint::overlap ( const CDFootPrint & aOtherPrint) const

Definition at line 342 of file CDFootPrint.cxx.

342 {
343 if ( this == &aOtherPrint )
344 {
345 //
346 // if being tested with itself return `true'
347 //
348 return ( !false );
349 }
350 //
351 // find the shortest length to compare the two memoery sections
352 //
353 uint32_t shorterSize;
354 if ( m_size > aOtherPrint.m_size ) { shorterSize = aOtherPrint.m_size; }
355 else { shorterSize = m_size; }
356 //
357 // check shorter CDFootPrint matches the section longer CDFootPrint
358 //
359 uint32_t index = 0;
360 while ( ( index != shorterSize ) &&
361 ( 0 == ( m_array[index] & aOtherPrint.m_array[index] ) ) )
362 { ++index; }
363 //
364 // if check finished before the shorter CDFootPrint was covered,
365 // then two CDFootPrints have at least one bit in common
366 //
367 return ( index != shorterSize );
368}

◆ overlap() [2/3]

bool CDFootPrint::overlap ( const CDFootPrint & aOtherPrint) const

◆ overlap() [3/3]

bool CDFootPrint::overlap ( const CDFootPrint & aOtherPrint) const

◆ reset() [1/3]

void CDFootPrint::reset ( )
static

Definition at line 423 of file CDFootPrint.cxx.

423{ m_numberIssued = 0; }

Referenced by ~CDFootPrint().

◆ reset() [2/3]

void CDFootPrint::reset ( )
static

◆ reset() [3/3]

void CDFootPrint::reset ( )
static

◆ ToUInt32() [1/3]

uint32_t CDFootPrint::ToUInt32 ( ) const
inline

Definition at line 108 of file Event/BesDChain/include/BesDChain/CDFootPrint.h.

108{ return m_array[0]; }

◆ ToUInt32() [2/3]

uint32_t CDFootPrint::ToUInt32 ( ) const
inline

Definition at line 108 of file InstallArea/x86_64-el9-gcc13-dbg/include/BesDChain/CDFootPrint.h.

108{ return m_array[0]; }

◆ ToUInt32() [3/3]

uint32_t CDFootPrint::ToUInt32 ( ) const
inline

Definition at line 108 of file InstallArea/x86_64-el9-gcc13-opt/include/BesDChain/CDFootPrint.h.

108{ return m_array[0]; }

◆ FingerPrint

FingerPrint
friend

Definition at line 83 of file Event/BesDChain/include/BesDChain/CDFootPrint.h.

Referenced by FingerPrint.

◆ operator<< [1/3]

std::ostream & operator<< ( std::ostream & os,
const CDFootPrint & obj )
friend

Definition at line 88 of file CDFootPrint.cxx.

88 {
89 os << "0x" << std::hex;
90 for ( int i = obj.m_size - 1; i >= 0; i-- ) { os << obj.m_array[i]; }
91 os << std::dec;
92
93 return os;
94}

◆ operator<< [2/3]

std::ostream & operator<< ( std::ostream & os,
const CDFootPrint & obj )
friend

Definition at line 88 of file CDFootPrint.cxx.

88 {
89 os << "0x" << std::hex;
90 for ( int i = obj.m_size - 1; i >= 0; i-- ) { os << obj.m_array[i]; }
91 os << std::dec;
92
93 return os;
94}

◆ operator<< [3/3]

std::ostream & operator<< ( std::ostream & os,
const CDFootPrint & obj )
friend

Definition at line 88 of file CDFootPrint.cxx.

88 {
89 os << "0x" << std::hex;
90 for ( int i = obj.m_size - 1; i >= 0; i-- ) { os << obj.m_array[i]; }
91 os << std::dec;
92
93 return os;
94}

The documentation for this class was generated from the following files: