00001
00002
00003
00004
00005
00006
00007
00009
00010 #include "Plex/PlexPinDiodeId.h"
00011 #include "Plex/PlexPixelSpotId.h"
00012
00013 #include "TBuffer.h"
00014 #include "TClass.h"
00015
00016 #include <iostream>
00017 #include <iomanip>
00018 #include <string>
00019
00020 #include <cassert>
00021
00022 #include "MessageService/MsgService.h"
00023
00024
00025 ClassImp(PlexPinDiodeId)
00026
00027
00028 ostream& operator<<(ostream& os, const PlexPinDiodeId& p)
00029 {
00030 os << p.AsString();
00031
00032 return os;
00033 }
00034
00035
00036 PlexPinDiodeId::PlexPinDiodeId()
00037 : PlexMuxBoxId()
00038 {
00039
00040 }
00041
00042
00043 PlexPinDiodeId::PlexPinDiodeId(Detector::Detector_t detector,
00044 ElecType::Elec_t elec,
00045 Char_t eastwest, Char_t racklevel,
00046 UInt_t rackbay, UInt_t inrack,
00047 UInt_t inbox, UInt_t gain)
00048 : PlexMuxBoxId(detector,elec,eastwest,racklevel,rackbay,inrack)
00049 {
00050
00051
00052 SetInBox(inbox);
00053 SetGain(gain);
00054 }
00055
00056
00057 PlexPinDiodeId::PlexPinDiodeId(PlexMuxBoxId muxbox,
00058 UInt_t inbox, UInt_t gain)
00059 : PlexMuxBoxId(muxbox)
00060 {
00061
00062
00063 SetInBox(inbox);
00064 SetGain(gain);
00065 }
00066
00067
00068 PlexPinDiodeId::PlexPinDiodeId(const UInt_t encoded)
00069 : PlexMuxBoxId(encoded)
00070 {
00071
00072 }
00073
00074
00075 PlexPinDiodeId::~PlexPinDiodeId()
00076 {
00077
00078 }
00079
00080
00081 const char * PlexPinDiodeId::AsString(Option_t *option) const
00082 {
00083
00084
00085
00086
00087
00088
00089 const int nbuffers = 8;
00090 static char newstring[nbuffers][64];
00091 static int ibuffer = nbuffers;
00092 ibuffer = (ibuffer+1)%nbuffers;
00093
00094 string opt = option;
00095 bool extended = (opt.find("e") != string::npos);
00096
00097 const char* efmt = "%s-PIN-%3.3d%c";
00098 if (extended) efmt = "%s-PIN-diode %3.3d gain %c";
00099
00100 const char* muxAsString = PlexMuxBoxId::AsString(option);
00101 sprintf(newstring[ibuffer],efmt,muxAsString,GetInBox(),(IsLowGain()?'L':'H'));
00102
00103 return newstring[ibuffer];
00104 }
00105
00106
00107 void PlexPinDiodeId::Print(Option_t *option) const
00108 {
00109
00110
00111 printf("%s\n",AsString(option));
00112 }
00113
00114
00115 void PlexPinDiodeId::Streamer(TBuffer &R__b)
00116 {
00117
00118 if (R__b.IsReading()) {
00119 UInt_t R__s, R__c;
00120 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00121 if ( R__v > 2 ) {
00122 PlexPinDiodeId::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
00123 return;
00124 }
00125
00126 R__b >> fEncoded;
00127 if (R__v == 1) ConvertToVersion2();
00128
00129
00130
00131 }
00132 else {
00133
00134 PlexPinDiodeId::Class()->WriteBuffer(R__b, this);
00135 }
00136 }
00137
00138 #ifdef ENABLE_PINDIODEID_ISNULL
00139
00140 Bool_t PlexPinDiodeId::IsNull() const
00141 {
00142 MSG("Plex",Msg::kWarning)
00143 << "PlexPinDiodeId::IsNull() is obsolete -- use !IsValid()" << endl;
00144 return !IsValid();
00145 }
00146 #endif
00147
00148 #ifdef ENABLE_PINDIODEID_ENCODEMUXBOX
00149
00150 Int_t PlexPinDiodeId::EncodeMuxBox(Char_t eastwest, Char_t racklevel,
00151 Int_t rackbay, Int_t inrack)
00152 {
00153
00154
00155
00156
00157
00158 return PlexPixelSpotId::EncodeMuxBox(eastwest,racklevel,rackbay,inrack);
00159 }
00160
00161
00162 void PlexPinDiodeId::DecodeMuxBox(Int_t muxbox, Char_t& eastwest,
00163 Char_t& racklevel, Int_t& rackbay,
00164 Int_t& inrack)
00165 {
00166
00167
00168
00169
00170
00171 PlexPixelSpotId::DecodeMuxBox(muxbox,eastwest,racklevel,rackbay,inrack);
00172 }
00173 #endif
00174
00175