CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ( )

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 ( )

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

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

Definition at line 38 of file TotemNumberMerger.cc.

References assert(), EnergyCorrector::c, LogDebug, query::result, and Split().

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

39  {
40 
41  unsigned long c(value1+value2);
42  unsigned long result(((c*(c+1))>>1)+value1);
43 
44 #ifdef SCRIVI
45  LogDebug("ForwardSim") << "Merge(value1=" << value1
46  << ", value2=" << value2 << ")=" << result;
47 
48  unsigned long invValue1, invValue2;
49  Split(result, invValue1, invValue2);
50 
51  assert(invValue1==value1);
52  assert(invValue2==value2);
53 #endif
54 
55  return result;
56 }
#define LogDebug(id)
assert(m_qm.get())
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
tuple result
Definition: query.py:137
unsigned long TotemNumberMerger::Merge ( unsigned long  value1,
unsigned long  value2,
unsigned long  value3 
) const

Definition at line 58 of file TotemNumberMerger.cc.

References Merge().

60  {
61  return Merge(Merge(value1, value2), value3);
62 }
unsigned long Merge(unsigned long value1, unsigned long value2) const
unsigned long TotemNumberMerger::Merge ( unsigned long  value1,
unsigned long  value2,
unsigned long  value3,
unsigned long  value4 
) const

Definition at line 64 of file TotemNumberMerger.cc.

References Merge().

67  {
68  return Merge(Merge(value1, value2), Merge(value3, value4));
69 }
unsigned long Merge(unsigned long value1, unsigned long value2) const
void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2 
) const

Definition at line 71 of file TotemNumberMerger.cc.

References EnergyCorrector::c, LogDebug, and mathSSE::sqrt().

Referenced by TotemT1Organization::_FromUnitIDToData(), Merge(), and Split().

72  {
73  unsigned long c(static_cast<unsigned long>(floor(sqrt(1.+8.*static_cast<float>(source))*0.5-0.5)));
74 
75  value1 = source-((c*(c+1))>>1);
76  value2 = c - value1;
77 
78 #ifdef SCRIVI
79  LogDebug("ForwardSim") << "source=" << source << ", c=" << c
80  << ", value1=" << value1 << ", value2=" << value2;
81 #endif
82 }
#define LogDebug(id)
T sqrt(T t)
Definition: SSEVec.h:48
static std::string const source
Definition: EdmProvDump.cc:42
void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2,
unsigned long &  value3 
) const

Definition at line 84 of file TotemNumberMerger.cc.

References Split().

86  {
87  unsigned long mix12;
88 
89  Split(source, mix12, value3);
90  Split(mix12, value1, value2);
91 }
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
static std::string const source
Definition: EdmProvDump.cc:42
void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2,
unsigned long &  value3,
unsigned long &  value4 
) const

Definition at line 93 of file TotemNumberMerger.cc.

References Split().

95  {
96  unsigned long mix12, mix34;
97 
98  Split(source, mix12, mix34);
99  Split(mix12, value1, value2);
100  Split(mix34, value3, value4);
101 }
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
static std::string const source
Definition: EdmProvDump.cc:42