CMS 3D CMS Logo

TotemNumberMerger Class Reference

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

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

List of all members.

Public Member Functions

unsigned long Merge (unsigned long value1, unsigned long value2, unsigned long value3, unsigned long value4) const
unsigned long Merge (unsigned long value1, unsigned long value2, unsigned long value3) const
unsigned long Merge (unsigned long value1, unsigned long value2) const
void Split (unsigned long source, unsigned long &value1, unsigned long &value2, unsigned long &value3, unsigned long &value4) 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) 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.

00023                                        {
00024 #ifdef SCRIVI
00025   LogDebug("ForwardSim") << "Creating TotemNumberMerger";
00026 #endif
00027 }

TotemNumberMerger::~TotemNumberMerger (  ) 

Definition at line 29 of file TotemNumberMerger.cc.

References LogDebug.

00029                                         {
00030 #ifdef SCRIVI
00031   LogDebug("ForwardSim") << "Destruction of TotemNumberMerger";
00032 #endif
00033 }


Member Function Documentation

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

00068                                                                      {
00069   return Merge(Merge(value1, value2), Merge(value3, value4));
00070 }

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

Definition at line 59 of file TotemNumberMerger.cc.

References Merge().

00061                                                                      {
00062   return Merge(Merge(value1, value2), value3);
00063 }

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

Definition at line 39 of file TotemNumberMerger.cc.

References c, LogDebug, HLT_VtxMuL3::result, and Split().

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

00040                                                                      {
00041 
00042   unsigned long c(value1+value2);
00043   unsigned long result(((c*(c+1))>>1)+value1);
00044 
00045 #ifdef SCRIVI
00046   LogDebug("ForwardSim") << "Merge(value1=" << value1
00047                          << ", value2=" << value2 << ")=" << result;
00048   
00049   unsigned long invValue1, invValue2;
00050   Split(result, invValue1, invValue2);
00051   
00052   assert(invValue1==value1);
00053   assert(invValue2==value2);                                  
00054 #endif
00055 
00056   return result;
00057 }

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

00096                                                              {
00097   unsigned long mix12, mix34;
00098  
00099   Split(source, mix12, mix34);
00100   Split(mix12, value1, value2);
00101   Split(mix34, value3, value4);
00102 }

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

00087                                                              {
00088   unsigned long mix12;
00089  
00090   Split(source, mix12, value3);
00091   Split(mix12, value1, value2);
00092 }

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

Definition at line 72 of file TotemNumberMerger.cc.

References c, LogDebug, and funct::sqrt().

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

00073                                                              {
00074   unsigned long c(static_cast<unsigned long>(floor(sqrt(1.+8.*static_cast<float>(source))*0.5-0.5)));
00075  
00076   value1 = source-((c*(c+1))>>1);
00077   value2 = c - value1;
00078  
00079 #ifdef SCRIVI
00080   LogDebug("ForwardSim") << "source=" << source << ", c=" << c
00081                          << ", value1=" << value1 << ", value2=" << value2;
00082 #endif
00083 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:50 2009 for CMSSW by  doxygen 1.5.4