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 29 of file TotemNumberMerger.h.

Constructor & Destructor Documentation

TotemNumberMerger::TotemNumberMerger ( )

Definition at line 23 of file TotemNumberMerger.cc.

References LogDebug.

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

Definition at line 29 of file TotemNumberMerger.cc.

References LogDebug.

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

Member Function Documentation

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

Definition at line 39 of file TotemNumberMerger.cc.

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

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

40  {
41 
42  unsigned long c(value1+value2);
43  unsigned long result(((c*(c+1))>>1)+value1);
44 
45 #ifdef SCRIVI
46  LogDebug("ForwardSim") << "Merge(value1=" << value1
47  << ", value2=" << value2 << ")=" << result;
48 
49  unsigned long invValue1, invValue2;
50  Split(result, invValue1, invValue2);
51 
52  assert(invValue1==value1);
53  assert(invValue2==value2);
54 #endif
55 
56  return result;
57 }
#define LogDebug(id)
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 59 of file TotemNumberMerger.cc.

References Merge().

61  {
62  return Merge(Merge(value1, value2), value3);
63 }
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 65 of file TotemNumberMerger.cc.

References Merge().

68  {
69  return Merge(Merge(value1, value2), Merge(value3, value4));
70 }
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 72 of file TotemNumberMerger.cc.

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

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

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

Definition at line 85 of file TotemNumberMerger.cc.

References Split().

87  {
88  unsigned long mix12;
89 
90  Split(source, mix12, value3);
91  Split(mix12, value1, value2);
92 }
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
void TotemNumberMerger::Split ( unsigned long  source,
unsigned long &  value1,
unsigned long &  value2,
unsigned long &  value3,
unsigned long &  value4 
) const

Definition at line 94 of file TotemNumberMerger.cc.

References Split().

96  {
97  unsigned long mix12, mix34;
98 
99  Split(source, mix12, mix34);
100  Split(mix12, value1, value2);
101  Split(mix34, value3, value4);
102 }
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const