CMS 3D CMS Logo

List of all members | Public Member Functions
TotemNumberMerger Class Reference

#include <SimG4CMS/Forward/interface/TotemNumberMerger.h>

Public Member Functions

unsigned long Merge (unsigned long value1, unsigned long value2) const
 
unsigned long Merge (unsigned long value1, unsigned long value2, unsigned long value3) const
 
unsigned long Merge (unsigned long value1, unsigned long value2, unsigned long value3, unsigned long value4) const
 
void Split (unsigned long source, unsigned long &value1, unsigned long &value2) const
 
void Split (unsigned long source, unsigned long &value1, unsigned long &value2, unsigned long &value3) const
 
void Split (unsigned long source, unsigned long &value1, unsigned long &value2, unsigned long &value3, unsigned long &value4) const
 
 TotemNumberMerger ()
 
 ~TotemNumberMerger ()
 

Detailed Description

Description: Takes two integers and merges them together in only an integer! It's also possible the opposite operation.

Usage: Used in TotemOrganizations to get unique ID of sensitive detector element

Definition at line 28 of file TotemNumberMerger.h.

Constructor & Destructor Documentation

◆ TotemNumberMerger()

TotemNumberMerger::TotemNumberMerger ( )

Definition at line 22 of file TotemNumberMerger.cc.

22  {
23 #ifdef SCRIVI
24  LogDebug("ForwardSim") << "Creating TotemNumberMerger";
25 #endif
26 }

References LogDebug.

◆ ~TotemNumberMerger()

TotemNumberMerger::~TotemNumberMerger ( )

Definition at line 28 of file TotemNumberMerger.cc.

28  {
29 #ifdef SCRIVI
30  LogDebug("ForwardSim") << "Destruction of TotemNumberMerger";
31 #endif
32 }

References LogDebug.

Member Function Documentation

◆ Merge() [1/3]

unsigned long TotemNumberMerger::Merge ( unsigned long  value1,
unsigned long  value2 
) const

Definition at line 38 of file TotemNumberMerger.cc.

38  {
39  unsigned long c(value1 + value2);
40  unsigned long result(((c * (c + 1)) >> 1) + value1);
41 
42 #ifdef SCRIVI
43  LogDebug("ForwardSim") << "Merge(value1=" << value1 << ", value2=" << value2 << ")=" << result;
44 
45  unsigned long invValue1, invValue2;
46  Split(result, invValue1, invValue2);
47 
48  assert(invValue1 == value1);
49  assert(invValue2 == value2);
50 #endif
51 
52  return result;
53 }

References cms::cuda::assert(), c, LogDebug, mps_fire::result, Split(), HLT_FULL_cff::value1, and HLT_FULL_cff::value2.

Referenced by TotemT1Organization::_FromDataToUnitID(), and Merge().

◆ Merge() [2/3]

unsigned long TotemNumberMerger::Merge ( unsigned long  value1,
unsigned long  value2,
unsigned long  value3 
) const

Definition at line 55 of file TotemNumberMerger.cc.

55  {
56  return Merge(Merge(value1, value2), value3);
57 }

References Merge(), HLT_FULL_cff::value1, and HLT_FULL_cff::value2.

◆ Merge() [3/3]

unsigned long TotemNumberMerger::Merge ( unsigned long  value1,
unsigned long  value2,
unsigned long  value3,
unsigned long  value4 
) const

Definition at line 59 of file TotemNumberMerger.cc.

62  {
63  return Merge(Merge(value1, value2), Merge(value3, value4));
64 }

References Merge(), HLT_FULL_cff::value1, and HLT_FULL_cff::value2.

◆ Split() [1/3]

void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2 
) const

Definition at line 66 of file TotemNumberMerger.cc.

66  {
67  unsigned long c(static_cast<unsigned long>(floor(sqrt(1. + 8. * static_cast<float>(source)) * 0.5 - 0.5)));
68 
69  value1 = source - ((c * (c + 1)) >> 1);
70  value2 = c - value1;
71 
72 #ifdef SCRIVI
73  LogDebug("ForwardSim") << "source=" << source << ", c=" << c << ", value1=" << value1 << ", value2=" << value2;
74 #endif
75 }

References c, LogDebug, source, mathSSE::sqrt(), HLT_FULL_cff::value1, and HLT_FULL_cff::value2.

Referenced by Merge(), and Split().

◆ Split() [2/3]

void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2,
unsigned long &  value3 
) const

Definition at line 77 of file TotemNumberMerger.cc.

80  {
81  unsigned long mix12;
82 
83  Split(source, mix12, value3);
84  Split(mix12, value1, value2);
85 }

References source, Split(), HLT_FULL_cff::value1, and HLT_FULL_cff::value2.

◆ Split() [3/3]

void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2,
unsigned long &  value3,
unsigned long &  value4 
) const

Definition at line 87 of file TotemNumberMerger.cc.

91  {
92  unsigned long mix12, mix34;
93 
94  Split(source, mix12, mix34);
95  Split(mix12, value1, value2);
96  Split(mix34, value3, value4);
97 }

References source, Split(), HLT_FULL_cff::value1, and HLT_FULL_cff::value2.

cms::cuda::assert
assert(be >=bs)
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
source
static const std::string source
Definition: EdmProvDump.cc:47
TotemNumberMerger::Split
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
Definition: TotemNumberMerger.cc:66
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
TotemNumberMerger::Merge
unsigned long Merge(unsigned long value1, unsigned long value2) const
Definition: TotemNumberMerger.cc:38
HLT_FULL_cff.value2
value2
Definition: HLT_FULL_cff.py:9868
HLT_FULL_cff.value1
value1
Definition: HLT_FULL_cff.py:9869
mps_fire.result
result
Definition: mps_fire.py:311
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46