SimG4CMS
Forward
src
TotemNumberMerger.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: Forward
4
// Class : TotemNumberMerger
5
//
6
// Implementation:
7
// <Notes on implementation>
8
//
9
// Original Author: R. Capra
10
// Created: Tue May 16 10:14:34 CEST 2006
11
//
12
13
// system include files
14
15
// user include files
16
#include "
SimG4CMS/Forward/interface/TotemNumberMerger.h
"
17
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
18
19
//
20
// constructors and destructor
21
//
22
TotemNumberMerger ::TotemNumberMerger
() {
23
#ifdef SCRIVI
24
LogDebug
(
"ForwardSim"
) <<
"Creating TotemNumberMerger"
;
25
#endif
26
}
27
28
TotemNumberMerger ::~TotemNumberMerger
() {
29
#ifdef SCRIVI
30
LogDebug
(
"ForwardSim"
) <<
"Destruction of TotemNumberMerger"
;
31
#endif
32
}
33
34
//
35
// member functions
36
//
37
38
unsigned
long
TotemNumberMerger ::Merge
(
unsigned
long
value1
,
unsigned
long
value2
)
const
{
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
}
54
55
unsigned
long
TotemNumberMerger ::Merge
(
unsigned
long
value1
,
unsigned
long
value2
,
unsigned
long
value3)
const
{
56
return
Merge
(
Merge
(
value1
,
value2
), value3);
57
}
58
59
unsigned
long
TotemNumberMerger ::Merge
(
unsigned
long
value1
,
60
unsigned
long
value2
,
61
unsigned
long
value3,
62
unsigned
long
value4)
const
{
63
return
Merge
(
Merge
(
value1
,
value2
),
Merge
(value3, value4));
64
}
65
66
void
TotemNumberMerger ::Split
(
unsigned
long
source
,
unsigned
long
&
value1
,
unsigned
long
&
value2
)
const
{
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
}
76
77
void
TotemNumberMerger ::Split
(
unsigned
long
source
,
78
unsigned
long
&
value1
,
79
unsigned
long
&
value2
,
80
unsigned
long
&value3)
const
{
81
unsigned
long
mix12;
82
83
Split
(
source
, mix12, value3);
84
Split
(mix12,
value1
,
value2
);
85
}
86
87
void
TotemNumberMerger ::Split
(
unsigned
long
source
,
88
unsigned
long
&
value1
,
89
unsigned
long
&
value2
,
90
unsigned
long
&value3,
91
unsigned
long
&value4)
const
{
92
unsigned
long
mix12, mix34;
93
94
Split
(
source
, mix12, mix34);
95
Split
(mix12,
value1
,
value2
);
96
Split
(mix34, value3, value4);
97
}
MessageLogger.h
cms::cuda::assert
assert(be >=bs)
TotemNumberMerger.h
TotemNumberMerger::~TotemNumberMerger
~TotemNumberMerger()
Definition:
TotemNumberMerger.cc:28
TotemNumberMerger::TotemNumberMerger
TotemNumberMerger()
Definition:
TotemNumberMerger.cc:22
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:223
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:9934
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
HLT_FULL_cff.value1
value1
Definition:
HLT_FULL_cff.py:9935
mps_fire.result
result
Definition:
mps_fire.py:311
Generated for CMSSW Reference Manual by
1.8.16