00001 #ifndef LogicID_H
00002 #define LogicID_H
00003
00012 #include <vector>
00013 #include <string>
00014 #include <cstring>
00015 #include <stdexcept>
00016
00017 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
00018
00019 class LogicID {
00020
00021 public:
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 static EcalLogicID getEcalLogicID( const char* name,
00032 const int id1 = EcalLogicID::NULLID,
00033 const int id2 = EcalLogicID::NULLID,
00034 const int id3 = EcalLogicID::NULLID ) throw( std::runtime_error ) {
00035
00036
00037
00038 if( strcmp(name, "EB") == 0 ) {
00039 return( EcalLogicID( "EB",
00040 1000000000UL ) );
00041 }
00042 if( strcmp(name, "EB_crystal_number") == 0 ) {
00043 return( EcalLogicID( "EB_crystal_number",
00044 1011000000UL+10000*id1+id2,
00045 id1,
00046 id2 ) );
00047 }
00048 if( strcmp(name, "EB_trigger_tower") == 0 ) {
00049 return( EcalLogicID( "EB_trigger_tower",
00050 1021000000UL+10000*id1+id2,
00051 id1,
00052 id2 ) );
00053 }
00054 if( strcmp(name, "EB_mem_channel") == 0 ) {
00055 return( EcalLogicID( "EB_mem_channel",
00056 1191000000UL+10000*id1+id2,
00057 id1,
00058 id2 ) );
00059 }
00060 if( strcmp(name, "EB_mem_TT") == 0 ) {
00061 return( EcalLogicID( "EB_mem_TT",
00062 1181000000UL+10000*id1+id2,
00063 id1,
00064 id2 ) );
00065 }
00066 if( strcmp(name, "EB_LM_PN") == 0 ) {
00067 return( EcalLogicID( "EB_LM_PN",
00068 1131000000UL+10000*id1+id2,
00069 id1,
00070 id2 ) );
00071 }
00072
00073
00074
00075 if( strcmp(name, "EE") == 0 ) {
00076 return( EcalLogicID( "EE",
00077 2000000000UL ) );
00078 }
00079 if( strcmp(name, "EE_crystal_number") == 0 ) {
00080 return( EcalLogicID( "EE_crystal_number",
00081 2010000000UL+1000000*((id1>=1&&id1<=9)?2:0)+1000*int(id2/1000)+int(id2%1000),
00082 (id1>=1&&id1<=9)?+1:-1,
00083 int(id2/1000),
00084 int(id2%1000) ) );
00085 }
00086 if( strcmp(name, "EE_readout_tower") == 0 ) {
00087 return( EcalLogicID( "EE_readout_tower",
00088 2110000000UL+100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
00089 ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
00090 id2 ) );
00091 }
00092 if( strcmp(name, "EE_mem_channel") == 0 ) {
00093 return( EcalLogicID( "EE_mem_channel",
00094 100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
00095 ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
00096 id2 ) );
00097 }
00098 if( strcmp(name, "EE_mem_TT") == 0 ) {
00099 return( EcalLogicID( "EE_mem_TT",
00100 100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
00101 ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
00102 id2 ) );
00103 }
00104 if( strcmp(name, "EE_LM_PN") == 0 ) {
00105 return( EcalLogicID( "EE_LM_PN",
00106 100*((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10)))+id2,
00107 ((id1>=1&&id1<=9)?(646+(id1-1)):(601+(id1-10))),
00108 id2 ) );
00109 }
00110
00111 throw( std::runtime_error( "Unknown 'name': " + std::string( name ) ) );
00112 return( EcalLogicID( std::string( "" ), EcalLogicID::NULLID ) );
00113
00114 }
00115
00116 private:
00117
00118 LogicID() {};
00119 ~LogicID() {};
00120
00121 };
00122
00123 #endif // LogicID_H