PlexMuxBoxId Class Reference

#include <PlexMuxBoxId.h>

Inheritance diagram for PlexMuxBoxId:
PlexPinDiodeId PlexPixelSpotId

List of all members.

Public Member Functions

 PlexMuxBoxId ()
 PlexMuxBoxId (const Detector::Detector_t detector, const ElecType::Elec_t electronics, Char_t eastwest, Char_t racklevel, UInt_t rackbay, UInt_t inrack)
 PlexMuxBoxId (const PlexMuxBoxId &muxid)
PlexMuxBoxIdoperator= (const PlexMuxBoxId &muxid)
virtual ~PlexMuxBoxId ()
 PlexMuxBoxId (const UInt_t encoded)
UInt_t GetEncoded () const
virtual const char * AsString (Option_t *option="") const
Detector::Detector_t GetDetector () const
ElecType::Elec_t GetElecType () const
Char_t GetEastWest () const
Char_t GetRackLevel () const
UShort_t GetRackBay () const
UShort_t GetInRack () const
UInt_t GetNumericMuxBox () const
Bool_t IsValid () const
void Print (Option_t *option="") const
void SetDetector (Detector::Detector_t detector)
void SetElecType (ElecType::Elec_t elec)
void SetEastWest (Char_t eastwest)
void SetRackLevel (Char_t racklevel)
void SetRackBay (UInt_t rackbay)
void SetInRack (UInt_t inrack)
void ConvertToVersion2 () const

Static Public Member Functions

static UInt_t ConvertEncodedToVersion2 (UInt_t encoded)

Protected Attributes

UInt_t fEncoded

Friends

Bool_t operator< (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
Bool_t operator<= (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
Bool_t operator== (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
Bool_t operator!= (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
Bool_t operator> (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
Bool_t operator>= (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)

Detailed Description

Definition at line 23 of file PlexMuxBoxId.h.


Constructor & Destructor Documentation

PlexMuxBoxId::PlexMuxBoxId (  ) 

Definition at line 60 of file PlexMuxBoxId.cxx.

00061    : fEncoded(defaultMuxBoxId)
00062 {
00063    // Default ctor constructs meaningless value
00064 }

PlexMuxBoxId::PlexMuxBoxId ( const Detector::Detector_t  detector,
const ElecType::Elec_t  electronics,
Char_t  eastwest,
Char_t  racklevel,
UInt_t  rackbay,
UInt_t  inrack 
)

Definition at line 67 of file PlexMuxBoxId.cxx.

References fEncoded, maskPlexMuxVersion, SetDetector(), SetEastWest(), SetElecType(), SetInRack(), SetRackBay(), and SetRackLevel().

00071    : fEncoded(defaultMuxBoxId)
00072 {
00073    // Normal ctor
00074 
00075    fEncoded =  maskPlexMuxVersion;
00076    SetDetector(detector);
00077    SetElecType(elec);
00078    SetEastWest(eastwest);
00079    SetRackLevel(racklevel);
00080    SetRackBay(rackbay);
00081    SetInRack(inrack);
00082 }

PlexMuxBoxId::PlexMuxBoxId ( const PlexMuxBoxId muxid  ) 

Definition at line 94 of file PlexMuxBoxId.cxx.

00095     : fEncoded(muxid.fEncoded)
00096     //ju -bad for derived classes : fEncoded(muxid.fEncoded&zeroPlexMuxUnused)
00097 {
00098     // copy ctor  (trim irrelevant bits)
00099 }

virtual PlexMuxBoxId::~PlexMuxBoxId (  )  [inline, virtual]

Definition at line 37 of file PlexMuxBoxId.h.

00037 { ; } // no owned data members

PlexMuxBoxId::PlexMuxBoxId ( const UInt_t  encoded  )  [explicit]

Definition at line 85 of file PlexMuxBoxId.cxx.

References ConvertToVersion2().

00086    : fEncoded(encoded)
00087 {
00088    // constructor from pre-encoded value
00089    ConvertToVersion2();
00090    //ju -bad for derived classes:  fEncoded &= zeroPlexMuxUnused;
00091 }


Member Function Documentation

const char * PlexMuxBoxId::AsString ( Option_t *  option = ""  )  const [virtual]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Definition at line 111 of file PlexMuxBoxId.cxx.

References GetDetector(), GetEastWest(), GetElecType(), GetInRack(), GetNumericMuxBox(), GetRackBay(), and GetRackLevel().

Referenced by Print().

00112 {
00113    // Return unpacked PlexMuxBoxId as a string
00114    // User should copy result because it points to a 
00115    // statically allocated string.
00116    // Internally uses a circular list of buffers to avoid problems
00117    // using AsString multiple times in a cout-like situation.
00118 
00119    const int nbuffers = 8;  // use a circular list of strings
00120    static char newstring[nbuffers][64];
00121    static int ibuffer = nbuffers;
00122    ibuffer = (ibuffer+1)%nbuffers;  // each time move to next buffer
00123 
00124    string opt = option;
00125    bool numeric_mux  = (opt.find("N") != string::npos);
00126    bool extended     = (opt.find("e") != string::npos);
00127 
00128    const char* efmt =
00129      "MUXB-%c%c-%c%c%2.2d:%2.2d";
00130    if (extended) efmt =
00131      "MUXB-%c%c-%c%c bay %2.2d: inrack %2.2d ";
00132 
00133    const char detc = Detector::AsString(GetDetector())[0];
00134    const char elec = ElecType::AsString(GetElecType())[0];
00135 
00136    if (numeric_mux) {
00137       // numeric mux box location
00138       sprintf(newstring[ibuffer],"SPOT-%c%c%3.3d",
00139               detc,elec,GetNumericMuxBox());
00140    } else {
00141       // unpacked MUX box location
00142       Char_t eastwest  = GetEastWest();
00143       Char_t racklevel = GetRackLevel();
00144       Int_t  rackbay  = GetRackBay();
00145       Int_t  inrack  = GetInRack();
00146       sprintf(newstring[ibuffer],efmt,
00147               detc,elec,
00148               eastwest,racklevel,rackbay,inrack);
00149    }
00150    
00151    return newstring[ibuffer];
00152 }

UInt_t PlexMuxBoxId::ConvertEncodedToVersion2 ( UInt_t  encoded  )  [static]

Definition at line 178 of file PlexMuxBoxId.cxx.

References maskPlexMuxVersion.

Referenced by ConvertToVersion2().

00179 { 
00180   // VERY DANGEROUS!
00181   // conversion for bit layout for rearranged bits
00182   if (encoded & maskPlexMuxVersion) return encoded; // nothing to do
00183 
00184   // this funkiness should work for both old 
00185   // PlexPixelSpotId and PlexPinDiodeId layouts
00186 
00187 //    MSB                          LSB
00188 //     3         2         1         0
00189 //    10987654321098765432109876543210
00190 //    -dddeeWELLBBBBBIII-----iiiiiiiig  old pin diode
00191 //    -dddeeWELLBBBBBIIIttppppppppssss  old pixel spot id
00192 //                        ^- remove this bit
00193 //    77776666555544443333222211110000
00194 //                   v- insert this bit
00195 //    vdddeeWELLBBBBBIIII----iiiiiiiig  new pin diode
00196 //    vdddeeWELLBBBBBIIIIttpppppppssss  new pixel spot id
00197 
00198 //                               76543210
00199   UInt_t unchanged =  encoded & 0x7FFE07FF;
00200   UInt_t newmiddle = ((encoded & 0x0001F000) >> 1 );
00201 
00202   return maskPlexMuxVersion|unchanged|newmiddle;
00203 }

void PlexMuxBoxId::ConvertToVersion2 (  )  const
Detector::Detector_t PlexMuxBoxId::GetDetector (  )  const [inline]

Definition at line 160 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, maskPlexMuxDetector, and shftPlexMuxDetector.

Referenced by AsString(), PlotPmt(), and SimDetector::SortDigiPE().

00161 { 
00162   ConvertToVersion2();
00163   Int_t bitField = ( fEncoded & maskPlexMuxDetector) >> shftPlexMuxDetector;
00164   return (Detector::Detector_t) bitField;   
00165 }

Char_t PlexMuxBoxId::GetEastWest (  )  const [inline]
ElecType::Elec_t PlexMuxBoxId::GetElecType (  )  const [inline]
UInt_t PlexMuxBoxId::GetEncoded (  )  const [inline]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Definition at line 157 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, and zeroPlexMuxUnused.

UShort_t PlexMuxBoxId::GetInRack (  )  const [inline]
UInt_t PlexMuxBoxId::GetNumericMuxBox (  )  const [inline]
UShort_t PlexMuxBoxId::GetRackBay (  )  const [inline]
Char_t PlexMuxBoxId::GetRackLevel (  )  const [inline]
Bool_t PlexMuxBoxId::IsValid (  )  const [inline]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Definition at line 263 of file PlexMuxBoxId.h.

References defaultMuxBoxId, fEncoded, and zeroPlexMuxVersion.

00263                                           {
00264   return ( fEncoded & zeroPlexMuxVersion ) != defaultMuxBoxId;
00265 }

PlexMuxBoxId & PlexMuxBoxId::operator= ( const PlexMuxBoxId muxid  ) 

Definition at line 102 of file PlexMuxBoxId.cxx.

References fEncoded.

00103 {
00104     // assignment   (trim irrelevant bits)
00105     //ju -bad for derived classes: fEncoded = muxid.fEncoded&zeroPlexMuxUnused;
00106     fEncoded = muxid.fEncoded;
00107     return *this;
00108 }

void PlexMuxBoxId::Print ( Option_t *  option = ""  )  const

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Definition at line 155 of file PlexMuxBoxId.cxx.

References AsString().

00156 {
00157    // Print the (decoded) value
00158 
00159    printf("%s\n",AsString(option));
00160 }

void PlexMuxBoxId::SetDetector ( Detector::Detector_t  detector  )  [inline]

Definition at line 213 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, maskPlexMuxDetector, and shftPlexMuxDetector.

Referenced by PlexMuxBoxId().

00214 {
00215   ConvertToVersion2();
00216   fEncoded = ( fEncoded & ~maskPlexMuxDetector ) | 
00217     ( ( detector << shftPlexMuxDetector ) & maskPlexMuxDetector );
00218 }

void PlexMuxBoxId::SetEastWest ( Char_t  eastwest  )  [inline]

Definition at line 227 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, maskPlexMuxEastWest, and shftPlexMuxEastWest.

Referenced by PlexMuxBoxId().

00228 {
00229   ConvertToVersion2();
00230   int iew = 0;
00231   switch (eastwest) {
00232   case 'e':
00233   case 'E':
00234   case '-':
00235     iew = 1;
00236     break;
00237   case 'w':
00238   case 'W':
00239   case '+':
00240     iew = 2;
00241     break;
00242   default:
00243     iew = 0;
00244   }
00245   fEncoded = ( fEncoded & ~maskPlexMuxEastWest ) |
00246     ( ( iew << shftPlexMuxEastWest ) & maskPlexMuxEastWest );
00247 }

void PlexMuxBoxId::SetElecType ( ElecType::Elec_t  elec  )  [inline]

Definition at line 220 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, maskPlexMuxElecType, and shftPlexMuxElecType.

Referenced by PlexMuxBoxId().

00221 {
00222   ConvertToVersion2();
00223   fEncoded = ( fEncoded & ~maskPlexMuxElecType ) | 
00224     ( ( elec << shftPlexMuxElecType ) & maskPlexMuxElecType );
00225 }

void PlexMuxBoxId::SetInRack ( UInt_t  inrack  )  [inline]

Definition at line 256 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, maskPlexMuxInRack, and shftPlexMuxInRack.

Referenced by PlexMuxBoxId().

00257 {
00258   ConvertToVersion2();
00259   fEncoded = ( fEncoded & ~maskPlexMuxInRack ) |
00260     ( ( inrack << shftPlexMuxInRack ) & maskPlexMuxInRack );
00261 }

void PlexMuxBoxId::SetRackBay ( UInt_t  rackbay  )  [inline]

Definition at line 249 of file PlexMuxBoxId.h.

References ConvertToVersion2(), fEncoded, maskPlexMuxBay, and shftPlexMuxBay.

Referenced by PlexMuxBoxId().

00250 {
00251   ConvertToVersion2();
00252   fEncoded = ( fEncoded & ~maskPlexMuxBay ) |
00253     ( ( rackbay << shftPlexMuxBay ) & maskPlexMuxBay );
00254 }

void PlexMuxBoxId::SetRackLevel ( Char_t  racklevel  ) 

Definition at line 31 of file PlexMuxBoxId.cxx.

References ConvertToVersion2(), fEncoded, maskPlexMuxLevel, and shftPlexMuxLevel.

Referenced by PlexMuxBoxId().

00032 {
00033   ConvertToVersion2();
00034   int irl = 0;
00035   switch (racklevel) {
00036   case 'l':
00037   case 'L':
00038   case 'b':
00039   case 'B':
00040     irl = 0;
00041     break;
00042   case 'm':
00043   case 'M':
00044     irl = 1;
00045     break;
00046   case 't':
00047   case 'T':
00048   case 'u':
00049   case 'U':
00050     irl = 2;
00051     break;
00052   default:
00053     irl = 3;
00054   }
00055   fEncoded = ( fEncoded & ~maskPlexMuxLevel ) |
00056     ( ( irl << shftPlexMuxLevel ) & maskPlexMuxLevel );
00057 }


Friends And Related Function Documentation

Bool_t operator!= ( const PlexMuxBoxId lhs,
const PlexMuxBoxId rhs 
) [friend]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Bool_t operator< ( const PlexMuxBoxId lhs,
const PlexMuxBoxId rhs 
) [friend]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Bool_t operator<= ( const PlexMuxBoxId lhs,
const PlexMuxBoxId rhs 
) [friend]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Bool_t operator== ( const PlexMuxBoxId lhs,
const PlexMuxBoxId rhs 
) [friend]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Bool_t operator> ( const PlexMuxBoxId lhs,
const PlexMuxBoxId rhs 
) [friend]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.

Bool_t operator>= ( const PlexMuxBoxId lhs,
const PlexMuxBoxId rhs 
) [friend]

Reimplemented in PlexPinDiodeId, and PlexPixelSpotId.


Member Data Documentation

UInt_t PlexMuxBoxId::fEncoded [protected]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1