SimFlag Namespace Reference

Typedefs

typedef enum SimFlag::ESimFlag SimFlag_t

Enumerations

enum  ESimFlag {
  kUnknown = 0x00, kData = 0x01, kDaqFakeData = 0x02, kMC = 0x04,
  kReroot = 0x08
}

Functions

Int_t FullMask ()
const Char_t * AsString (SimFlag_t detector)
const Char_t * MaskToString (Int_t mask)
SimFlag::SimFlag_t StringToEnum (const Char_t *chars, Int_t maxChar=0)
Int_t StringToMask (const Char_t *chars, Int_t maxChar=0)
Int_t Compact (SimFlag_t simFlag)
SimFlag::SimFlag_t Expand (Int_t compactSimFlag)

Typedef Documentation


Enumeration Type Documentation

Enumerator:
kUnknown 
kData 
kDaqFakeData 
kMC 
kReroot 

Definition at line 24 of file SimFlag.h.

00024                          {
00025       kUnknown      = 0x00,
00026       kData         = 0x01,
00027       kDaqFakeData  = 0x02, 
00028       kMC           = 0x04,
00029       kReroot       = 0x08
00030    } SimFlag_t;


Function Documentation

const Char_t * SimFlag::AsString ( SimFlag_t  detector  ) 

Definition at line 17 of file SimFlag.cxx.

References kDaqFakeData, kData, kMC, kReroot, and kUnknown.

Referenced by RawBlockId::AsString(), VldContext::AsString(), DbiValidityRecBuilder::DbiValidityRecBuilder(), DetSim::DefaultConfig(), main(), and MaskToString().

00018 {
00019    // static function to return mapping enum --> string
00020 
00021    switch (simFlag) {
00022    case kUnknown:     return "Unknown";     break;
00023    case kData:        return "Data";        break;
00024    case kDaqFakeData: return "DaqFakeData"; break;
00025    case kMC:          return "MC";          break;
00026    case kReroot:      return "Reroot";      break;
00027    default:           return "?Data?";      break;
00028    }
00029 }

Int_t SimFlag::Compact ( SimFlag_t  simFlag  ) 

Definition at line 104 of file SimFlag.cxx.

References kDaqFakeData, kData, kMC, kReroot, and kUnknown.

Referenced by RotoObjectifier::ExtractEncodedRawBlockId(), and RawBlockId::RawBlockId().

00105 {
00106    // turn mask-like enum value into sequential int
00107 
00108    switch (simFlag) {
00109    case kUnknown:     return -1;  break;
00110    case kData:        return  0;  break;
00111    case kDaqFakeData: return  1;  break;
00112    case kMC:          return  2;  break;
00113    case kReroot:      return  3;  break;
00114    default:           return -1;  break;
00115    }
00116 
00117 }

SimFlag::SimFlag_t SimFlag::Expand ( Int_t  compactSimFlag  ) 

Definition at line 121 of file SimFlag.cxx.

References kDaqFakeData, kData, kMC, kReroot, and kUnknown.

Referenced by RawBlockId::GetSimFlag().

00122 {
00123    // turn sequential int into mask-like enum value
00124 
00125    switch (compactSimFlag) {
00126    case  0:  return kData;        break;
00127    case  1:  return kDaqFakeData; break;
00128    case  2:  return kMC;          break;
00129    case  3:  return kReroot;      break;
00130    default:  return kUnknown;     break;
00131    }
00132 }

Int_t SimFlag::FullMask (  ) 

Definition at line 10 of file SimFlag.cxx.

References kDaqFakeData, kData, kMC, and kReroot.

Referenced by MaskToString(), and DbiLogEntry::Recreate().

00011 {
00012    return kData|kDaqFakeData|kMC|kReroot;
00013 }

const Char_t * SimFlag::MaskToString ( Int_t  mask  ) 

Definition at line 33 of file SimFlag.cxx.

References AsString(), and FullMask().

00034 {
00035    // Return a mask of SimFlags as a string
00036    //
00037    // Result is a pointer to a statically allocated string.
00038    // User should copy this into their own buffer before calling
00039    // this method again.
00040 
00041    static Char_t newstring[255] = "";
00042    
00043    Char_t* ptr = newstring;  // start at the beginning
00044 
00045    *ptr = 0; // start with nothing
00046    Int_t fullmask = SimFlag::FullMask();
00047 
00048    for (Int_t i=0; i<32; i++) {
00049       SimFlag::SimFlag_t flag = (SimFlag::SimFlag_t)(1<<i);
00050       if (mask & flag & fullmask) {
00051          const Char_t* toadd = SimFlag::AsString(flag);
00052          if (ptr != newstring) *ptr++ = ',';
00053          strcpy(ptr,toadd);
00054          ptr += strlen(toadd);
00055       }
00056    }
00057    *ptr++ = 0; // ensure trailing 0
00058 
00059    return newstring;
00060 }

SimFlag::SimFlag_t SimFlag::StringToEnum ( const Char_t *  chars,
Int_t  maxChar = 0 
)

Definition at line 64 of file SimFlag.cxx.

References kDaqFakeData, kData, kMC, kReroot, kUnknown, and StringToMask().

00065 {
00066    // convert a set of chars to a valid enum
00067 
00068    Int_t mask = SimFlag::StringToMask(chars,maxChar);
00069 
00070    switch (mask) {
00071    case kUnknown:     return kUnknown;     break;
00072    case kData:        return kData;        break;
00073    case kDaqFakeData: return kDaqFakeData; break;
00074    case kMC:          return kMC;          break;
00075    case kReroot:      return kReroot;      break;
00076    default:           return kUnknown;     break;
00077    }
00078 
00079 }

Int_t SimFlag::StringToMask ( const Char_t *  chars,
Int_t  maxChar = 0 
)

Definition at line 83 of file SimFlag.cxx.

References kDaqFakeData, kData, kMC, and kReroot.

Referenced by main(), and StringToEnum().

00084 {
00085    // convert a set of chars to a mask of enum's
00086    // simple tests for unique characters: {d,f,m,r}
00087 
00088    Int_t mask  = 0;
00089 
00090    TString thestring(chars);
00091    if (maxChar>0 && maxChar<thestring.Length()) thestring.Resize(maxChar);
00092 
00093    thestring.ToLower();
00094    if (thestring.Contains("d")) mask |= kData;
00095    if (thestring.Contains("f")) mask |= kDaqFakeData;
00096    if (thestring.Contains("m")) mask |= kMC;
00097    if (thestring.Contains("r")) mask |= kReroot;
00098 
00099    return mask;
00100 }


Generated on 14 Dec 2017 for loon by  doxygen 1.6.1