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.

References LogDebug.

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

◆ ~TotemNumberMerger()

TotemNumberMerger::~TotemNumberMerger ( )

Definition at line 28 of file TotemNumberMerger.cc.

References LogDebug.

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

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.

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

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

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 }
assert(be >=bs)
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
#define LogDebug(id)

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

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

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

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

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

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

◆ Split() [1/3]

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

Definition at line 66 of file TotemNumberMerger.cc.

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

Referenced by Merge(), and Split().

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 }
T sqrt(T t)
Definition: SSEVec.h:19
static std::string const source
Definition: EdmProvDump.cc:49
#define LogDebug(id)

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

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

80  {
81  unsigned long mix12;
82 
83  Split(source, mix12, value3);
84  Split(mix12, value1, value2);
85 }
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
static std::string const source
Definition: EdmProvDump.cc:49

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

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

91  {
92  unsigned long mix12, mix34;
93 
94  Split(source, mix12, mix34);
95  Split(mix12, value1, value2);
96  Split(mix34, value3, value4);
97 }
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
static std::string const source
Definition: EdmProvDump.cc:49