00001 #include "GenericThingId.h" 00002 #include <TString.h> 00004 // 00005 // GenericThingId 00006 // 00007 // n.tagg1@physics.ox.ac.uk 00008 // 00009 // This class is a generic wrapper for a bunch of other 00010 // ID classes. It is used by the Calibrator to abstract things 00011 // to a sort of 'generic channel id' which can be made into a string. 00012 // It is used to count error statistics in a nice, general way. 00013 // It may have other uses. 00014 // 00016 00017 GenericThingId::GenericThingId() 00018 : fType(kUnknown), 00019 fEncoded(0) 00020 {} 00021 00022 GenericThingId::GenericThingId(Int_t encoded) 00023 : fType(kUnknown), 00024 fEncoded(encoded) 00025 {} 00026 00027 GenericThingId::GenericThingId(const RawChannelId& c) 00028 : fType(kRawChannelId), 00029 fEncoded(c.GetEncoded()) 00030 {} 00031 00032 GenericThingId::GenericThingId(const PlexPixelSpotId& c) 00033 : fType(kPlexPixelSpotId), 00034 fEncoded(c.GetEncoded()) 00035 {} 00036 00037 GenericThingId::GenericThingId(const PlexStripEndId& c) 00038 : fType(kPlexStripEndId), 00039 fEncoded(c.GetEncoded()) 00040 {} 00041 00042 GenericThingId::GenericThingId(const PlexLedId& c) 00043 : fType(kPlexLedId), 00044 fEncoded(c.GetEncoded()) 00045 {} 00046 00047 const char* GenericThingId::AsString(const char* opt) const 00048 { 00049 switch(fType) { 00050 case kRawChannelId: 00051 return RawChannelId(fEncoded).AsString(opt); 00052 00053 case kPlexPixelSpotId: 00054 return PlexPixelSpotId(fEncoded).AsString(opt); 00055 00056 case kPlexLedId: 00057 return PlexLedId(fEncoded).AsString(opt); 00058 00059 case kPlexStripEndId: 00060 return PlexStripEndId(fEncoded).AsString(opt); 00061 00062 case kUnknown: 00063 return Form("GenericThingId: %d",fEncoded); 00064 00065 default: 00066 return Form("GenericThingId: (%d)%d",fType,fEncoded); 00067 } 00068 } 00069 00070 bool GenericThingId::operator<(const GenericThingId& other) const 00071 { 00072 // Used for std::map 00073 if(fType<other.fType) return true; 00074 if(fEncoded<other.fEncoded) return true; 00075 return false; 00076 }
1.3.9.1