ConfUtilities.h

00001 #ifndef SCTCONF_CONFUTILITIES_H
00002 #define SCTCONF_CONFUTILITIES_H
00003 
00004 #include "ConfigurationException.h"
00005 
00006 namespace SctConfiguration {
00007 
00009 enum EndcapType {ENDCAP_OUTER, ENDCAP_MIDDLE, ENDCAP_SHORT_MIDDLE, ENDCAP_INNER, ENDCAP_UNKNOWN};
00010   
00017 /* Original form replaced by Liverpool by new variant below.
00018 EndcapType getEndcapType(int disk, unsigned number){
00019   char message[1000];
00020   sprintf(message,"Disk out of range:%d", disk);
00021   if (abs(disk)>9) throw ConfigurationException(message);
00022 
00023   if (number<13) {
00024     return ENDCAP_OUTER;
00025   } else if (number<23) {
00026     switch (abs(disk)) {
00027     case 9: {
00028       char message[1000];
00029       sprintf(message,"getEndcapType: out of range: disk %d has no middle modules (number=%d)", disk, number);
00030       throw ConfigurationException(message);
00031     }
00032     case 8: return ENDCAP_SHORT_MIDDLE;
00033     default: return ENDCAP_MIDDLE;
00034     }
00035   } else if (number<33) {
00036     switch (abs(disk)){
00037     case 9: case 8: case 7: case 1: {
00038       char message[1000];
00039       sprintf(message, "getEndcapType: out of range: disk %d has no inner modules (number=%d)", disk, number);
00040       throw ConfigurationException(message);
00041     }
00042     default: return ENDCAP_INNER;
00043     }
00044   } else {
00045     char message[1000];
00046     sprintf(message, "getEndcapType: out of range: number should never take value=%d (disk=%d)", number, disk);
00047     throw ConfigurationException(message);
00048   }
00049 } */
00050 
00052 
00054   EndcapType sillyEndcapDiskAndNumber(const int disk, const unsigned number) {
00055     std::ostringstream os;
00056     os <<"Disk "<<disk<<" and number "<<number
00057        <<" are just plain silly.  Error detected in "
00058        <<__FILE__<<" at line " << __LINE__;
00059     throw ConfigurationException(os.str());
00060     
00061     // what we would return if we ever got here!  At the moment the policy is to throw instead of return MODULE_UNKNOWN, though!
00062     return ENDCAP_UNKNOWN;                  
00063   };
00064 
00065 
00066   EndcapType getEndcapType(const int disk, const unsigned number) {
00067     
00068     if(number < 0) return sillyEndcapDiskAndNumber(disk, number);  
00069     
00070     if(number < 13)  return ENDCAP_OUTER;
00071     
00072     if(number < 23) {
00073       if( disk == 8 || disk == -8) return ENDCAP_SHORT_MIDDLE;
00074       return ENDCAP_MIDDLE;
00075     }
00076     
00077     if(number < 33) return ENDCAP_INNER;
00078     
00079     return sillyEndcapDiskAndNumber(disk, number);                  
00080     
00081   } 
00082   
00083 }
00084 
00085 #endif

Generated on Mon Feb 6 14:01:18 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6