WireMap Class Reference
[Odbcheck]

C++ Class containing certain ODB keys in a usable form. More...

#include <WireMap.hh>

List of all members.

Public Types

enum  key_t {
  BANK, DETECTOR, ENABLED, PEDESTAL,
  POLARITY, TIMESHIFT, FREQUENCY, UNKNOWN
}

Public Member Functions

 WireMap ()
 This constructs an empty WireMap.
 WireMap (int run, std::string &odb_file)
void UniqueFixes ()
void Clear ()
 Reset this WireMap to a state similar to what it would be if called with the default constructor.
void ResizeToBanks ()
bool AreThereDuplicates ()
void ClearDisabledDuplicateDetectors ()
void Print ()
 Print for debugging.
Setters



void SetRun (unsigned int)
 Set the run number.
void Enable ()
 Enable the last channel added.
bool Enable (unsigned int)
 Enable a channel.
void Disable ()
 Disable last channel added.
bool Disable (unsigned int)
 Disable a channel.
Getters



unsigned int GetRun () const
unsigned int GetNDets () const
std::vector< std::string > & GetBanks ()
std::vector< std::string > & GetDets ()
std::vector< bool > & GetEnableds ()
std::vector< int > & GetPedestals ()
std::vector< int > & GetPolarities ()
std::vector< int > & GetOffsets ()
std::vector< double > & GetFrequencies ()
Adders



void Add (const char bankname[], const char detname[], bool en, int ped, int pol, int off, double freq)
 Add new value to WireMap.
void Add (std::string &bankname, std::string &detname, bool en, int ped, int pol, int off, double freq)
 Add new value to WireMap. See Add(const char[], const char[], bool, int, int, int, double).
void Add (WireMap &wm, int index)
Loaders



void Load (int run, const std::string &odb_file)
void LoadOver (WireMap &)
 Load another WireMap over this one in the same manner ODB Edit loads one ODb over another.

Static Public Member Functions

static WireMap Default ()

Static Private Member Functions

static bool IsODBFile (const std::string &fname)
static int GetArraySize (const char(&tmp)[256])
static key_t GetKey (std::string &key)

Private Attributes

unsigned int fRun
 Run Number.
unsigned int fNDets
 Number of detectors.
std::vector< std::string > fBankName
 Name of each channel.
std::vector< std::string > fDetName
 Detector attached to each channel.
std::vector< bool > fEnabled
 Enabled status for each channel.
std::vector< int > fPedestal
 Pedestals for each channel.
std::vector< int > fPolarity
 Polarity of each channel.
std::vector< int > fOffset
 Timing offset (TimeShift) for each channel.
std::vector< double > fFrequency
 Sampling frequency of each channel.

Static Private Attributes

static WireMapDefaultODB = NULL

Detailed Description

C++ Class containing certain ODB keys in a usable form.

The WireMap contains some information from the ODB wiremap. Specifically the run, banks names, detector names, enabled/disabled status, pedestals, polarities, and offsets. Can be given the path to an ODB file to construct from or built up with the Add method.

Definition at line 20 of file WireMap.hh.


Member Enumeration Documentation

Each member corresponds to an ODB key used in WireMap. The method GetKey takes a string and if it matches an ODB key used by WireMap, returns the corresponding one (or UNKNOWN if not found.

Enumerator:
BANK 
DETECTOR 
ENABLED 
PEDESTAL 
POLARITY 
TIMESHIFT 
FREQUENCY 
UNKNOWN 

Definition at line 53 of file WireMap.hh.


Constructor & Destructor Documentation

WireMap::WireMap (  ) 

This constructs an empty WireMap.

Definition at line 10 of file WireMap.cc.

Referenced by Default().

00010                  {
00011 }

WireMap::WireMap ( int  run,
std::string &  odb_file 
)

Construct a WireMap from an ODB file.

Parameters:
[in] run The run number needs to be specified since, as of yet, it isn't got from the ODB file.
[in] odb_file Path to the ODB files to use to construct a WireMap.

Definition at line 13 of file WireMap.cc.

References Load().

00013                                              {
00014   Load(run, odb_file);
00015 }


Member Function Documentation

void WireMap::Add ( WireMap wm,
int  index 
)

Add new value to WireMap from another WireMap

Parameters:
[in] wm WireMap that has element we wish to copy to this WireMap.
[in] index Which element of this WireMap to copy.

Definition at line 63 of file WireMap.cc.

References fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, fPolarity, GetBanks(), GetDets(), GetEnableds(), GetFrequencies(), GetOffsets(), GetPedestals(), and GetPolarities().

00063                                     {
00064   ++fNDets;
00065   fBankName.push_back(wm.GetBanks()[i]);
00066   fDetName.push_back(wm.GetDets()[i]);
00067   fEnabled.push_back(wm.GetEnableds()[i]);
00068   fPedestal.push_back(wm.GetPedestals()[i]);
00069   fPolarity.push_back(wm.GetPolarities()[i]);
00070   fOffset.push_back(wm.GetOffsets()[i]);
00071   fFrequency.push_back(wm.GetFrequencies()[i]);
00072 }

void WireMap::Add ( std::string &  bankname,
std::string &  detname,
bool  en,
int  ped,
int  pol,
int  off,
double  freq 
)

Add new value to WireMap. See Add(const char[], const char[], bool, int, int, int, double).

Definition at line 52 of file WireMap.cc.

References fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, and fPolarity.

00052                                                                                                           {
00053   ++fNDets;
00054   fBankName.push_back(bankname);
00055   fDetName.push_back(detname);
00056   fEnabled.push_back(en);
00057   fPedestal.push_back(ped);
00058   fPolarity.push_back(pol);
00059   fOffset.push_back(off);
00060   fFrequency.push_back(freq);
00061 }

void WireMap::Add ( const char  bankname[],
const char  detname[],
bool  en,
int  ped,
int  pol,
int  off,
double  freq 
)

Add new value to WireMap.

Parameters:
[in] bankname Channel name
[in] detname Detector name
[in] en Enabled status
[in] ped Pedestal
[in] pol Polarity
[in] off Timing offset (TimeShift)
[in] freq Sampling frequency

Definition at line 46 of file WireMap.cc.

Referenced by ODBCheck::Check(), and Default().

00046                                                                                                               {
00047   std::string bn(bankname);
00048   std::string dn(detname);
00049   Add(bn, dn, en, ped, pol, off, freq);
00050 }

bool WireMap::AreThereDuplicates (  ) 

Check for duplicate detectors that are both enabled.

Returns:
True if there exist two detectors with the same name that are both enabled.

Definition at line 281 of file WireMap.cc.

References fDetName, and fEnabled.

00281                                  {
00282   unsigned int n = 0;
00283   if (fEnabled.size() < fDetName.size()) {
00284     std::cout << "WireMap WARNING: Array of enabled information is smaller than " <<
00285       "                 array of detector name information." << std::endl;
00286     n = fEnabled.size();
00287   } else if (fEnabled.size() > fDetName.size()) {
00288     std::cout << "WireMap WARNING: Array of enabled information is larger than " <<
00289       "array of detector name information." << std::endl;
00290     n = fDetName.size();
00291   }
00292 
00293   // If two channels are both the same detector and
00294   // both enabled, return true because there is a problem.
00295   for (unsigned int i = 0; i < n; ++i)
00296     for (unsigned int j = i + 1; j < n; ++j)
00297       if (fDetName[i] == fDetName[j] &&
00298           fEnabled[i] == fEnabled[j])
00299         return true;
00300 
00301   return false;
00302 }

void WireMap::Clear (  ) 

Reset this WireMap to a state similar to what it would be if called with the default constructor.

Definition at line 232 of file WireMap.cc.

References fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, fPolarity, and fRun.

Referenced by ODBCheck::Check(), and Load().

00232                     {
00233   fRun = 0;
00234   fNDets = 0;
00235   fBankName.clear();
00236   fDetName.clear();
00237   fEnabled.clear();
00238   fPedestal.clear();
00239   fPolarity.clear();
00240   fOffset.clear();
00241   fFrequency.clear();
00242 }

void WireMap::ClearDisabledDuplicateDetectors (  ) 

Removes duplicate detectors as long as only one is enabled.

If there are multiple detectors with the same name, this sets the name of all of them to "blank" as long as only a single one of the duplicates is enabled.

Definition at line 304 of file WireMap.cc.

References fBankName, fDetName, fEnabled, and fRun.

Referenced by ODBCheck::Check().

00304                                               {
00305   static const std::string default_det("blank");
00306   for (unsigned int i = 0; i < fDetName.size(); ++i) {
00307     if (fDetName[i] == default_det) continue;
00308     for (unsigned int j = i + 1; j < fDetName.size(); ++j) {
00309       if (fDetName[j] == default_det) continue;
00310       if (fDetName[i] == fDetName[j]) {
00311         if (j < fEnabled.size() && !fEnabled[j]) {
00312           std::cout <<
00313             "Removing duplicate detector " << fDetName[j] << " from channel" <<
00314             fBankName[j] << " as it is disabled..." << std::endl;
00315           fDetName[j] = default_det;
00316         } else if (i < fEnabled.size() && !fEnabled[i]) {
00317           std::cout <<
00318             "Removing duplicate detector " << fDetName[i] << " from channel" <<
00319             fBankName[i] << " as it is disabled..." << std::endl;
00320           fDetName[i] = default_det;
00321         } else {
00322           std::cout <<
00323             "WireMap ERROR: Couldn't determine which detector " << fDetName[i] <<
00324             " to remove in run " << fRun << "!" <<
00325             "(" << fBankName[i] << " and " << fBankName[j] << ")!" << std::endl;
00326         }
00327       }
00328     }
00329   }
00330 }

WireMap WireMap::Default (  )  [static]

Return default WireMap

The batch scripts cause a number of ODB files to be loaded in analyzer/odb/ that can confuse issues. The WireMap that would result from loading all of these defaults has been hardcoded here.

Returns:
The default WireMap.

Definition at line 420 of file WireMap.cc.

References Add(), fOffset, and WireMap().

Referenced by ODBCheck::Check().

00420                          {
00421   // Construct the default WireMap if it doesn't exist yet
00422   if (!WireMap::DefaultODB) {
00423     WireMap::DefaultODB = new WireMap();
00424 
00425     WireMap::DefaultODB->Add("Na80", "SiL2-S", true, 2745, -1, 4000, 1.7e+07);
00426     WireMap::DefaultODB->Add("Nb80", "SiR2-S", true, 2730, -1, 4000, 1.7e+07);
00427     WireMap::DefaultODB->Add("Nc80", "blank", true, 1000, -1, 0, 8.5e+06);
00428     WireMap::DefaultODB->Add("Nd80", "blank", false, 1, -1, 0, 1.7e+07);
00429     WireMap::DefaultODB->Add("Ne80", "blank", false, 1, -1, 0, 1.7e+08);
00430     WireMap::DefaultODB->Add("Nf80", "blank", false, 1, -1, 0, 1.7e+08);
00431     WireMap::DefaultODB->Add("Ng80", "blank", false, 1, -1, 0, 1.7e+08);
00432     WireMap::DefaultODB->Add("Nh80", "blank", false, 1, -1, 0, 1.7e+08);
00433     
00434     WireMap::DefaultODB->Add("Na81", "SiL2-F", true, 1415, 1, 407, 1.7e+08);
00435     WireMap::DefaultODB->Add("Nb81", "SiR2-F", true, 1210, 1, 444, 1.7e+08);
00436     WireMap::DefaultODB->Add("Nc81", "SiL1-1-F", true, 1292, 1, 146.7, 1.7e+08);
00437     WireMap::DefaultODB->Add("Nd81", "SiL1-2-F", true, 1300, 1, 150, 1.7e+08);
00438     WireMap::DefaultODB->Add("Ne81", "SiL1-3-F", true, 1280, 1, 149, 1.7e+08);
00439     WireMap::DefaultODB->Add("Nf81", "SiL1-4-F", true, 1290, 1, 149.4, 1.7e+08);
00440     WireMap::DefaultODB->Add("Ng81", "SiR1-sum-F", true, 1, 1, 0, 1.7e+08);
00441     WireMap::DefaultODB->Add("Nh81", "Ge-F", true, 1390, 1, 81.1, 1.7e+08);
00442     
00443     WireMap::DefaultODB->Add("Na82", "SiL1-1-S", true, 2760, -1, 2431, 1.7e+07);
00444     WireMap::DefaultODB->Add("Nb82", "SiL1-2-S", true, 2820, -1, 2427, 1.7e+07);
00445     WireMap::DefaultODB->Add("Nc82", "SiL1-3-S", true, 2740, -1, 2431, 1.7e+07);
00446     WireMap::DefaultODB->Add("Nd82", "SiL1-4-S", true, 2740, -1, 2429, 1.7e+07);
00447     WireMap::DefaultODB->Add("Ne82", "SiR1-1-S", true, 2750, -1, 2600, 1.7e+07);
00448     WireMap::DefaultODB->Add("Nf82", "SiR1-2-S", true, 2750, -1, 2600, 1.7e+07);
00449     WireMap::DefaultODB->Add("Ng82", "SiR1-3-S", true, 2740, -1, 2600, 1.7e+07);
00450     WireMap::DefaultODB->Add("Nh82", "SiR1-4-S", true, 2740, -1, 2600, 1.7e+07);
00451     
00452     WireMap::DefaultODB->Add("Na83", "ScL", true, 1, 1, 69.7, 1.7e+07);
00453     WireMap::DefaultODB->Add("Nb83", "ScR", false, 1, 1, 69.2, 3.4e+07);
00454     WireMap::DefaultODB->Add("Nc83", "ScGe", true, 1185, -1, 81.1, 1.7e+08);
00455     WireMap::DefaultODB->Add("Nd83", "ScVe", false, 1, 1, 71.9, 3.4e+07);
00456     WireMap::DefaultODB->Add("Ne83", "blank", false, 1, 1, 146.7, 3.4e+07);
00457     WireMap::DefaultODB->Add("Nf83", "blank", false, 1, 1, 150, 3.4e+07);
00458     WireMap::DefaultODB->Add("Ng83", "LiquidSc", false, 1, 1, 149, 3.4e+07);
00459     WireMap::DefaultODB->Add("Nh83", "blank", false, 1, 1, 149, 3.4e+07);
00460 
00461     WireMap::DefaultODB->Add("CaUH","Ge-S", true, 1140,-1, 42000, 1e+08);
00462     WireMap::DefaultODB->Add("CbUH","blank", false, 1, -1, 37000, 1e+08);
00463     WireMap::DefaultODB->Add("CcUH","blank", false, 1, -1, 0, 1e+08);
00464     WireMap::DefaultODB->Add("CdUH","blank", false, 1, -1, 0, 1e+08);
00465     WireMap::DefaultODB->Add("CeUH","blank", false, 1, -1, 0, 1e+08);
00466     WireMap::DefaultODB->Add("CfUH","blank", false, 1, -1, 0, 1e+08);
00467     WireMap::DefaultODB->Add("CgUH","blank", false, 1, -1, 0, 1e+08);
00468     WireMap::DefaultODB->Add("ChUH","blank", false, 1, -1, 0, 1e+08);
00469 
00470     WireMap::DefaultODB->Add("CaBU","muSc", false, 2071, 1, 0, 2.5e+08);
00471     WireMap::DefaultODB->Add("CbBU","muScA", false, 2122, 1, 12.7, 2.5e+08);
00472     WireMap::DefaultODB->Add("CcBU","muScA", false, 1, 1, 0, 2.5e+08);
00473     WireMap::DefaultODB->Add("CdBU","blank", false, 1, 1, 0, 2.5e+08);
00474 
00475     WireMap::DefaultODB->Add("ZZZZ","blank", false, 1, -1, 0, 0.);
00476     WireMap::DefaultODB->Add("ZZZZ","blank", false, 1, -1, 0, 0.);
00477     WireMap::DefaultODB->Add("ZZZZ","blank", false, 1, -1, 0, 0.);
00478     WireMap::DefaultODB->Add("ZZZZ","blank", false, 1, -1, 0, 0.);
00479 
00480     // The default ODB has 4 extra offset entries in the
00481     // offset key
00482     for (unsigned int i = 0; i < 4; ++i)
00483       WireMap::DefaultODB->fOffset.push_back(0);
00484   }
00485 
00486   return *WireMap::DefaultODB;
00487 }

bool WireMap::Disable ( unsigned int  i  ) 

Disable a channel.

Returns:
True if succesful.

Definition at line 40 of file WireMap.cc.

References fEnabled.

00040                                     {
00041   if (i < fEnabled.size())
00042     return !(fEnabled[i] = false);
00043   return false;
00044 }

void WireMap::Disable (  ) 

Disable last channel added.

Definition at line 36 of file WireMap.cc.

References fEnabled.

Referenced by ODBCheck::Check().

00036                       {
00037   fEnabled.back() = false;
00038 }

bool WireMap::Enable ( unsigned int  i  ) 

Enable a channel.

Returns:
True if succesful.

Definition at line 30 of file WireMap.cc.

References fEnabled.

00030                                    {
00031   if (i < fEnabled.size())
00032     return (fEnabled[i] = true);
00033   return false;
00034 }

void WireMap::Enable (  ) 

Enable the last channel added.

Definition at line 26 of file WireMap.cc.

References fEnabled.

00026                      {
00027   fEnabled.back() = true;
00028 }

int WireMap::GetArraySize ( const char(&)  tmp[256]  )  [static, private]

Determines the number of elements in an ODB key's array

The ODB records how many elements are in an key that is an array. The key declaration in the ODB file is of the form

VARIABLE = TYPE [##] :

Parameters:
tmp The part of the key declaration of the form " = TYPE [##] :"
Returns:
The number of elemented in the array.

Definition at line 336 of file WireMap.cc.

Referenced by Load().

00336                                                 {
00337   // Get # of detectors from line in ODB of the form
00338   // VARIBALE = TYPE[#] :
00339   std::string str(tmp);
00340   std::stringstream ss;
00341   int n;
00342   int pos[2];
00343 
00344   pos[0] = str.find('[') + 1;
00345   pos[1] = str.find(']');
00346   str = str.substr(pos[0], pos[1] - pos[0]);
00347   ss << str;
00348   ss >> n;
00349 
00350   return n;
00351 }

std::vector< std::string > & WireMap::GetBanks (  ) 
Returns:
Reference to vector of bank names.

Definition at line 361 of file WireMap.cc.

References fBankName.

Referenced by Add(), ODBCheck::Check(), and LoadOver().

00361                                         {
00362   return fBankName;
00363 }

std::vector< std::string > & WireMap::GetDets (  ) 
Returns:
Reference to vector of detector names.

Definition at line 365 of file WireMap.cc.

References fDetName.

Referenced by Add(), ODBCheck::Check(), LoadOver(), and ODBCheck::OutputCorrections().

00365                                        {
00366   return fDetName;
00367 }

std::vector< bool > & WireMap::GetEnableds (  ) 
Returns:
Reference to vector of channel's enabled status.

Definition at line 369 of file WireMap.cc.

References fEnabled.

Referenced by Add(), LoadOver(), and ODBCheck::OutputCorrections().

00369                                       {
00370   return fEnabled;
00371 }

std::vector< double > & WireMap::GetFrequencies (  ) 
Returns:
Reference to vector of sampling frequencies.

Definition at line 385 of file WireMap.cc.

References fFrequency.

Referenced by Add(), ODBCheck::Check(), LoadOver(), and ODBCheck::OutputCorrections().

00385                                            {
00386   return fFrequency;
00387 }

WireMap::key_t WireMap::GetKey ( std::string &  key  )  [static, private]

Get the ODB key from its declaration in the ODB file.

Keys in an ODB file are declared akin to

KEYNAME = KEYTYPE

Parameters:
[in] key The string in the ODB file that declares the key. Just the stirng KEYNAME
Returns:
The key type.

Definition at line 389 of file WireMap.cc.

References BANK, DETECTOR, ENABLED, FREQUENCY, PEDESTAL, POLARITY, TIMESHIFT, and UNKNOWN.

Referenced by Load().

00389                                            {
00390   static const std::string bankname_key("BankName");
00391   static const std::string detname_key("DetectorName");
00392   static const std::string enabled_key("Enabled");
00393   static const std::string polarity_key("TriggerPolarity");
00394   static const std::string pedestal_key("Pedestal");
00395   static const std::string offset_key("TimeShift");
00396   static const std::string frequency_key("SamplingFrequency");
00397 
00398   if (key == bankname_key)
00399     return BANK;
00400   else if (key == detname_key)
00401     return DETECTOR;
00402   else if (key == enabled_key)
00403     return ENABLED;
00404   else if (key == polarity_key)
00405     return POLARITY;
00406   else if (key == pedestal_key)
00407     return PEDESTAL;
00408   else if (key == offset_key)
00409     return TIMESHIFT;
00410   else if (key == frequency_key)
00411     return FREQUENCY;
00412   return UNKNOWN;
00413 }

unsigned int WireMap::GetNDets (  )  const
Returns:
Number of detectors.

Definition at line 357 of file WireMap.cc.

References fNDets.

Referenced by ODBCheck::Check(), LoadOver(), and ODBCheck::OutputCorrections().

00357                                      {
00358   return fNDets;
00359 }

std::vector< int > & WireMap::GetOffsets (  ) 
Returns:
Reference to vector of timing offsets (TimeShift).

Definition at line 381 of file WireMap.cc.

References fOffset.

Referenced by Add(), LoadOver(), and ODBCheck::OutputCorrections().

00381                                     {
00382   return fOffset;
00383 }

std::vector< int > & WireMap::GetPedestals (  ) 
Returns:
Reference to vector of pedestals.

Definition at line 373 of file WireMap.cc.

References fPedestal.

Referenced by Add(), LoadOver(), and ODBCheck::OutputCorrections().

00373                                       {
00374   return fPedestal;
00375 }

std::vector< int > & WireMap::GetPolarities (  ) 
Returns:
Reference to vector of polarities (+/- 1).

Definition at line 377 of file WireMap.cc.

References fPolarity.

Referenced by Add(), LoadOver(), and ODBCheck::OutputCorrections().

00377                                        {
00378   return fPolarity;
00379 }

unsigned int WireMap::GetRun (  )  const
Returns:
Run number.

Definition at line 353 of file WireMap.cc.

References fRun.

Referenced by LoadOver(), and ODBCheck::OutputCorrections().

00353                                    {
00354   return fRun;
00355 }

bool WireMap::IsODBFile ( const std::string &  fname  )  [static, private]

Checks extension for 'odb'

This is called internally before trying to load an ODB file.

Parameters:
[in] fname Path to ODB file.
Returns:
True if the extension indicates the path points to an ODB file..

Definition at line 332 of file WireMap.cc.

Referenced by Load().

00332                                               {
00333   return ".odb" == fname.substr(fname.size() - 4);
00334 }

void WireMap::Load ( int  run,
const std::string &  odb_file 
)

Load ODB values into WireMap from an ODB file.

Parses an ODB file, finds keys indicating what the WireMap can hold, and loads those.

Parameters:
[in] run Run number. Needs to be included here because it's not parsed from the ODB file yet.
[in] odb_file Path to ODB file to load.

Definition at line 91 of file WireMap.cc.

References BANK, Clear(), DETECTOR, ENABLED, fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, fPolarity, FREQUENCY, fRun, GetArraySize(), GetKey(), IsODBFile(), PEDESTAL, POLARITY, and TIMESHIFT.

Referenced by WireMap().

00091                                                             {
00092   static const std::string header("[/Analyzer/WireMap]");
00093   static char tmp[256];
00094 
00095   if (!IsODBFile(odb_file)) {
00096     std::cout <<
00097       "WireMap ERROR: Not recognized as ODB file input! Must be ODB file." <<
00098       std::endl;
00099     return;
00100   }
00101 
00102   Clear();
00103   fRun = run_number;
00104   
00105   // Look through ODB file for appropriate banks
00106   std::ifstream f(odb_file.c_str());
00107   std::string str;
00108   key_t key;
00109   int x;
00110   char c;
00111   double d;
00112   while (f.good()) {
00113     f >> str;
00114     if (str == header) {
00115       while (f.good()) {
00116         f >> str;
00117         // Quit out if a new key has started,
00118         // indicated in the ODB by a [
00119         if (str[0] == '[')
00120           break;
00121         key = GetKey(str);
00122         f.getline(tmp, 256);
00123         unsigned int n = 0; // Array size in ODB
00124         if (key == BANK) {
00125           n = GetArraySize(tmp);
00126           fBankName.reserve(n);
00127           fNDets = n; // Set number of detectors equal to number of banks
00128           for (unsigned int i = 0; i < n; ++i) {
00129             f >> str;
00130             if (f.read(tmp, 1).peek() == '\n') // Strings can be null, cause streaming problems
00131               str = "";
00132             else
00133               f >> str;
00134             fBankName.push_back(str);
00135           }
00136         } else if (key == DETECTOR) {
00137           n = GetArraySize(tmp);
00138           fDetName.reserve(n);
00139           for (unsigned int i = 0; i < n; ++i) {
00140             f >> str;
00141             if (f.read(tmp, 1).peek() == '\n') // Strings can be null, cause streaming problems
00142               str = "";
00143             else
00144               f >> str;
00145             fDetName.push_back(str);
00146           }
00147         } else if (key == ENABLED) {
00148           n = GetArraySize(tmp);
00149           fEnabled.reserve(n);
00150           for (unsigned int i =0; i < n; ++i) {
00151             f >> str >> c;
00152             if (c == 'y') fEnabled.push_back(true);
00153             else if (c == 'n') fEnabled.push_back(false);
00154             else std::cout << "WireMap ERROR: '" << c <<
00155                    "' is not an ODB boolean!" << std::endl;
00156           }
00157         } else if (key == PEDESTAL) {
00158           n = GetArraySize(tmp);
00159           fPedestal.reserve(n);
00160           for (unsigned int i = 0; i < n; ++i) {
00161             f >> str >> x;
00162             fPedestal.push_back(x);
00163           }
00164         } else if (key == POLARITY) {
00165           n = GetArraySize(tmp);
00166           fPolarity.reserve(n);
00167           for (unsigned int i = 0; i < n; ++i) {
00168             f >> str >> x;
00169             fPolarity.push_back(x);
00170           }
00171         } else if (key == TIMESHIFT) {
00172           n = GetArraySize(tmp);
00173           fOffset.reserve(n);
00174           for (unsigned int i = 0; i < n; ++i) {
00175             f >> str >> x;
00176             fOffset.push_back(x);
00177           }
00178         } else if (key == FREQUENCY) {
00179           n = GetArraySize(tmp);
00180           fFrequency.reserve(n);
00181           for (unsigned int i = 0; i < n; ++i) {
00182             f >> str >> d;
00183             fFrequency.push_back(d);
00184           }
00185         }
00186         // If for some reason haven't got the number of detectors
00187         // from number of banks, then grab the first non-zero
00188         // array sized key from ODB
00189         if (fNDets == 0)
00190           fNDets = n;
00191         // If everything is the right size
00192         // That means everything is finished
00193         if (fNDets != 0 &&
00194             fBankName.size() == fNDets &&
00195             fDetName.size() == fNDets &&
00196             fPedestal.size() == fNDets &&
00197             fPolarity.size() == fNDets &&
00198             fOffset.size() == fNDets &&
00199             fFrequency.size() == fNDets)
00200           return;
00201       }
00202     }
00203   }
00204   // If we get to this point, vectors are not all equal in size
00205   std::cout <<
00206     "WireMap WARNING: Didn't find everything in the ODB! (" <<
00207     odb_file << ")" << std::endl;
00208 
00209 }

void WireMap::LoadOver ( WireMap wm  ) 

Load another WireMap over this one in the same manner ODB Edit loads one ODb over another.

Definition at line 211 of file WireMap.cc.

References fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, fPolarity, fRun, GetBanks(), GetDets(), GetEnableds(), GetFrequencies(), GetNDets(), GetOffsets(), GetPedestals(), GetPolarities(), and GetRun().

Referenced by ODBCheck::Check().

00211                                   {
00212   // Load the new WireMap variables if they exist
00213   // This seems to be how the ODB operates
00214   fRun = wm.GetRun();
00215   fNDets = wm.GetNDets();
00216   if (wm.GetBanks().size() > 0)
00217     fBankName = wm.GetBanks();
00218   if (wm.GetDets().size() > 0)
00219     fDetName = wm.GetDets();
00220   if (wm.GetEnableds().size() > 0)
00221     fEnabled = wm.GetEnableds();
00222   if (wm.GetPedestals().size() > 0)
00223     fPedestal = wm.GetPedestals();
00224   if (wm.GetPolarities().size() > 0)
00225     fPolarity = wm.GetPolarities();
00226   if (wm.GetOffsets().size() > 0)
00227     fOffset = wm.GetOffsets();
00228   if (wm.GetFrequencies().size() > 0)
00229     fFrequency = wm.GetFrequencies();
00230 }

void WireMap::Print (  ) 

Print for debugging.

Definition at line 489 of file WireMap.cc.

References fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, fPolarity, and fRun.

00489                     {
00490   using namespace std;
00491   stringstream ss;
00492 
00493   // Determine which field is biggest for looping
00494   std::vector<unsigned int> sizes;
00495   sizes.push_back(fBankName.size());
00496   sizes.push_back(fDetName.size());
00497   sizes.push_back(fEnabled.size());
00498   sizes.push_back(fPedestal.size());
00499   sizes.push_back(fPolarity.size());
00500   sizes.push_back(fOffset.size());
00501   sizes.push_back(fFrequency.size());
00502   unsigned int n = sizes[0];
00503   for (unsigned int i = 1; i < sizes.size(); ++i)
00504     if (sizes[i] > n)
00505       n = sizes[i];
00506 
00507   // General
00508   cout << left;
00509   cout << setw(24) << "Run Number:" << fRun << endl;
00510   cout << setw(24) << "Number of detectors:" << fNDets << endl;
00511   
00512   // Header
00513   ss << "Bank (" << fBankName.size() << ")";
00514   cout << setw(11) << ss.str(); ss.str(string());
00515   ss << "Detector (" << fDetName.size() << ")";
00516   cout << setw(15) << ss.str(); ss.str(string());
00517   ss << "Enabled (" << fEnabled.size() << ")";
00518   cout << setw(14) << ss.str(); ss.str(string());
00519   ss << "Pedestal (" << fPedestal.size() << ")";
00520   cout << setw(15) << ss.str(); ss.str(string());
00521   ss << "Polarity (" << fPolarity.size() << ")";
00522   cout << setw(15) << ss.str(); ss.str(string());
00523   ss << "TimeShift (" << fOffset.size() << ")";
00524   cout << setw(16) << ss.str(); ss.str(string());
00525   ss << "Frequency (" << fFrequency.size() << ")";
00526   cout << setw(16) << ss.str(); ss.str(string());
00527 
00528   // Separator
00529   cout << endl;
00530   cout << setfill('-') << setw(98) << '-' << setfill(' ') << endl;
00531   cout << setfill(' ') << right;
00532 
00533   // The WireMap
00534   for (unsigned int i = 0; i < n; ++i) {
00535     cout << setw(11);
00536     if (i < fBankName.size()) cout << fBankName[i];
00537     else cout << ' ';
00538     cout << setw(15);
00539     if (i < fDetName.size()) cout << fDetName[i];
00540     else cout << ' ';
00541     cout << setw(14);
00542     if (i < fEnabled.size()) cout << (fEnabled[i] ? 'y' : 'n');
00543     else cout << ' ';
00544     cout << setw(15);
00545     if (i < fPedestal.size()) cout << fPedestal[i];
00546     else cout << ' ';
00547     cout << setw(15);
00548     if (i < fPolarity.size()) cout << (fPolarity[i] == -1 ? '-' : '+');
00549     else cout << ' ';
00550     cout << setw(16);
00551     if (i < fOffset.size()) cout << -fOffset[i];
00552     else cout << ' ';
00553     cout << setw(16);
00554     if (i < fFrequency.size()) cout << fFrequency[i];
00555     else cout << ' ';
00556     cout << endl;
00557   }
00558 }

void WireMap::ResizeToBanks (  ) 

Resize all vectors to size of banks.

It's possible that upond loading an ODB file not all of the data vectors (bank name, detector names, enabled status, ...) are equal in size. This poses a problem because the index of these vectors are what correspond the data to one another.

This resizes all vectors to the same size as the bank name vector by trimming them down or bloating them up. The trimming is done by removing the last element of the data vectors until they're short enough, or by appending default values until long enough. Ideally, this would never be necessary; however it was needed during development of odb_check.cc and is being kept in case it is needed again.

Definition at line 244 of file WireMap.cc.

References fBankName, fDetName, fEnabled, fFrequency, fNDets, fOffset, fPedestal, and fPolarity.

00244                             {
00245   static const std::string default_det("blank");
00246   static const bool default_en = false;
00247   static const int default_ped = 0;
00248   static const int default_pol = 1;
00249   static const int default_off = 0;
00250   static const double default_freq = 0.;
00251 
00252   fNDets = fBankName.size();
00253   // Trim down
00254   while (fDetName.size() > fNDets)
00255     fDetName.pop_back();
00256   while (fEnabled.size() > fNDets)
00257     fEnabled.pop_back();
00258   while (fPedestal.size() > fNDets)
00259     fPedestal.pop_back();
00260   while (fPolarity.size() > fNDets)
00261     fPedestal.pop_back();;
00262   while (fOffset.size() > fNDets)
00263     fOffset.pop_back();
00264   while (fFrequency.size() > fNDets)
00265     fFrequency.pop_back();
00266   // Bulk up
00267   while (fDetName.size() < fNDets)
00268     fDetName.push_back(default_det);
00269   while (fEnabled.size() < fNDets)
00270     fEnabled.push_back(default_en);
00271   while (fPedestal.size() < fNDets)
00272     fPedestal.push_back(default_ped);
00273   while (fPolarity.size() < fNDets)
00274     fPolarity.push_back(default_pol);
00275   while (fOffset.size() < fNDets)
00276     fOffset.push_back(default_off);
00277   while (fFrequency.size() < fNDets)
00278     fFrequency.push_back(default_freq);
00279 }

void WireMap::SetRun ( unsigned int  run  ) 

Set the run number.

Definition at line 17 of file WireMap.cc.

References fRun.

Referenced by ODBCheck::Check().

00017                                      {
00018   if (run > 0 && run < 100000)
00019     fRun = run;
00020   else
00021     std::cout <<
00022       "WireMap WARNING: Run outside range! (" << run << ")" <<
00023       std::endl;
00024 }

void WireMap::UniqueFixes (  ) 

Unique fixes for certain runs

1. For runs 2091-2103, correct the sampling frequency

Definition at line 74 of file WireMap.cc.

References fBankName, fFrequency, and fRun.

Referenced by ODBCheck::Check().

00074                           {
00075   // The UH CAEN had the incorrect sampling
00076   // for runs 2091-2103
00077   double default_freq = 0.;
00078   double freq_fix = 1.6129e7;
00079   if (fRun >= 2091 && fRun <= 2103) {
00080     for (unsigned int i = 0; i < fBankName.size(); ++i) {
00081       if (fBankName[i].substr(0,1) == "C" && fBankName[i].substr(fBankName[i].size() - 2) == "UH") {
00082         while (fFrequency.size() <= i) {
00083           fFrequency.push_back(default_freq);
00084         }
00085         fFrequency[i] = freq_fix;
00086       }
00087     }
00088   }
00089 }


Member Data Documentation

WireMap * WireMap::DefaultODB = NULL [static, private]

WireMap corresponding to default ODB.

Constructed if needed.

Definition at line 25 of file WireMap.hh.

std::vector<std::string> WireMap::fBankName [private]

Name of each channel.

Definition at line 32 of file WireMap.hh.

Referenced by Add(), Clear(), ClearDisabledDuplicateDetectors(), GetBanks(), Load(), LoadOver(), Print(), ResizeToBanks(), and UniqueFixes().

std::vector<std::string> WireMap::fDetName [private]

Detector attached to each channel.

Definition at line 34 of file WireMap.hh.

Referenced by Add(), AreThereDuplicates(), Clear(), ClearDisabledDuplicateDetectors(), GetDets(), Load(), LoadOver(), Print(), and ResizeToBanks().

std::vector<bool> WireMap::fEnabled [private]

Enabled status for each channel.

Definition at line 36 of file WireMap.hh.

Referenced by Add(), AreThereDuplicates(), Clear(), ClearDisabledDuplicateDetectors(), Disable(), Enable(), GetEnableds(), Load(), LoadOver(), Print(), and ResizeToBanks().

std::vector<double> WireMap::fFrequency [private]

Sampling frequency of each channel.

Definition at line 44 of file WireMap.hh.

Referenced by Add(), Clear(), GetFrequencies(), Load(), LoadOver(), Print(), ResizeToBanks(), and UniqueFixes().

unsigned int WireMap::fNDets [private]

Number of detectors.

Definition at line 30 of file WireMap.hh.

Referenced by Add(), Clear(), GetNDets(), Load(), LoadOver(), Print(), and ResizeToBanks().

std::vector<int> WireMap::fOffset [private]

Timing offset (TimeShift) for each channel.

Definition at line 42 of file WireMap.hh.

Referenced by Add(), Clear(), Default(), GetOffsets(), Load(), LoadOver(), Print(), and ResizeToBanks().

std::vector<int> WireMap::fPedestal [private]

Pedestals for each channel.

Definition at line 38 of file WireMap.hh.

Referenced by Add(), Clear(), GetPedestals(), Load(), LoadOver(), Print(), and ResizeToBanks().

std::vector<int> WireMap::fPolarity [private]

Polarity of each channel.

Definition at line 40 of file WireMap.hh.

Referenced by Add(), Clear(), GetPolarities(), Load(), LoadOver(), Print(), and ResizeToBanks().

unsigned int WireMap::fRun [private]

Run Number.

Run number

Definition at line 28 of file WireMap.hh.

Referenced by Clear(), ClearDisabledDuplicateDetectors(), GetRun(), Load(), LoadOver(), Print(), SetRun(), and UniqueFixes().


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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1