CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LogicID.h
Go to the documentation of this file.
1 #ifndef LogicID_H
2 #define LogicID_H
3 
12 #include <vector>
13 #include <string>
14 #include <cstring>
15 #include <stdexcept>
16 
18 
19 class LogicID {
20 
21 public:
22 
23 //-------------------------------------------------------------------------
24 
25 // WARNING:
26 // this file depends on the content of
27 // OnlineDB/EcalCondDB/perl/lib/CondDB/channelView.pm
28 
29 //-------------------------------------------------------------------------
30 
31 static EcalLogicID getEcalLogicID( const char* name,
32  const int id1 = EcalLogicID::NULLID,
33  const int id2 = EcalLogicID::NULLID,
34  const int id3 = EcalLogicID::NULLID ) throw( std::runtime_error ) {
35 
36  // EcalBarrel
37 
38  if( strcmp(name, "EB") == 0 ) {
39  return( EcalLogicID( "EB",
40  1000000000UL ) );
41  }
42  if( strcmp(name, "EB_crystal_number") == 0 ) {
43  return( EcalLogicID( "EB_crystal_number",
44  1011000000UL+10000*id1+id2,
45  id1,
46  id2 ) );
47  }
48  if( strcmp(name, "EB_trigger_tower") == 0 ) {
49  return( EcalLogicID( "EB_trigger_tower",
50  1021000000UL+10000*id1+id2,
51  id1,
52  id2 ) );
53  }
54  if( strcmp(name, "EB_mem_channel") == 0 ) {
55  return( EcalLogicID( "EB_mem_channel",
56  1191000000UL+10000*id1+id2,
57  id1,
58  id2 ) );
59  }
60  if( strcmp(name, "EB_mem_TT") == 0 ) {
61  return( EcalLogicID( "EB_mem_TT",
62  1181000000UL+10000*id1+id2,
63  id1,
64  id2 ) );
65  }
66  if( strcmp(name, "EB_LM_PN") == 0 ) {
67  return( EcalLogicID( "EB_LM_PN",
68  1131000000UL+10000*id1+id2,
69  id1,
70  id2 ) );
71  }
72 
73  // EcalEndcap
74 
75  if( strcmp(name, "EE") == 0 ) {
76  return( EcalLogicID( "EE",
77  2000000000UL ) );
78  }
79  if( strcmp(name, "EE_crystal_number") == 0 ) {
80  return( EcalLogicID( "EE_crystal_number",
81  2010000000UL+1000000*((id1>=1&&id1<=9)?2:0)+1000*int(id2/1000)+int(id2%1000),
82  (id1>=1&&id1<=9)?+1:-1,
83  int(id2/1000),
84  int(id2%1000) ) );
85  }
86  if( strcmp(name, "EE_readout_tower") == 0 ) {
87  return( EcalLogicID( "EE_readout_tower",
88  2110000000UL+100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
89  ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
90  id2 ) );
91  }
92  if( strcmp(name, "EE_mem_channel") == 0 ) {
93  return( EcalLogicID( "EE_mem_channel",
94  100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
95  ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
96  id2 ) );
97  }
98  if( strcmp(name, "EE_mem_TT") == 0 ) {
99  return( EcalLogicID( "EE_mem_TT",
100  100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
101  ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
102  id2 ) );
103  }
104  if( strcmp(name, "EE_LM_PN") == 0 ) {
105  return( EcalLogicID( "EE_LM_PN",
106  100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
107  ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
108  id2 ) );
109  }
110 
111  throw( std::runtime_error( "Unknown 'name': " + std::string( name ) ) );
112  return( EcalLogicID( std::string( "" ), EcalLogicID::NULLID ) );
113 
114 }
115 
116 private:
117 
118  LogicID() {}; // Hidden to force static use
119  ~LogicID() {}; // Hidden to force static use
120 
121 };
122 
123 #endif // LogicID_H
~LogicID()
Definition: LogicID.h:119
LogicID()
Definition: LogicID.h:118
static const int NULLID
Definition: EcalLogicID.h:43
static EcalLogicID getEcalLogicID(const char *name, const int id1=EcalLogicID::NULLID, const int id2=EcalLogicID::NULLID, const int id3=EcalLogicID::NULLID)
Definition: LogicID.h:31