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