SetupRecord Class Reference

#include <SetupRecord.h>

List of all members.

Classes

struct  BankInfo_t
 These are the channel characteristics recored in TSetupData. More...

Public Types

typedef IDs::channel ChannelID

Public Member Functions

virtual ~SetupRecord ()
 Destructor. Default is correct.
Double_t GetTickLength (const ChannelID &cid) const
 The length, in nanoseconds, of each sample clock tick.
Double_t GetTimeFromMuSc (const ChannelID &cid) const
 The timing offset from the muSc.
Short_t GetADCDepth (const ChannelID &cid) const
 The bit depth of the ADC.
Int_t GetOverflowADC (const ChannelID &cid) const
 The overflow value of the ADC, i.e 2^{bit depth} the first impossible value.
Int_t GetMaxADC (const ChannelID &cid) const
 The maximum value recordable by the ADC i.e. 1 less than the overflow.
Short_t GetPedestal (const ChannelID &cid) const
 The pedestal of the channel.
Short_t GetHeadroom (const ChannelID &cid) const
 The headroom, defined as MaxADC - Pedestal Note that negative pulses should typically have |headroom| < |pedestal|, in the same way that positive pulses typically have |pedestal| < |headroom|.
Short_t GetPolarity (const ChannelID &cid) const
 The polarity of the channel.
Bool_t IsEnabled (const ChannelID &cid) const
 Is the enabled bit set for this channel?
std::string GetBankName (const ChannelID &cid) const
 Get the MIDAS bank name for this channelID.
std::string BankFromChannel (const ChannelID &cid) const
 Get the MIDAS bank name for this channelID.
ChannelID ChannelFromBank (const std::string &bankname) const
 Convert a MIDAS bankname to a Channel ID.

Protected Member Functions

const BankInfo_tBankInfo (const std::string &bankname) const
 Get the BankInfo for this bank name.
const BankInfo_tBankInfo (const ChannelID &cid) const
 Get the BankInfo for this Channel ID.
BankInfo_tBankInfo (const std::string &bankname)
 Get the Writable BankInfo for this bank name.
BankInfo_tBankInfo (const ChannelID &cid)
 Get the Writable BankInfo for this Channel ID.
 SetupRecord (const TSetupData *setup_data)
 Normal constructor, used by friends.
 SetupRecord ()
 Default constructor, shouldn't need this.
 SetupRecord (const SetupRecord &src)
 Copy constructor, shouldn't need this.
SetupRecordoperator= (const SetupRecord &rhs)
 Copy assignment, shouldn't need this.
int InitChannels (const TSetupData *setup_data)
 Construction helper.
int InitMetaData (const TSetupData *setup_data)
 Construction helper.

Private Attributes

std::vector< BankInfo_tfInfoLookup
 A lookup for channel Info, with arbitrary ordering;.
std::map< ChannelID, UInt_t > fIDOrderLookup
 A lookup for the record if we know the Channel ID.
std::map< std::string, UInt_t > fNameOrderLookup
 A lookup for the record if we know the MIDAS Bankname.

Friends

class EventNavigator

Detailed Description

This provides access to information stored in TSetupData. Any request for data on a non-existant channel results in an exception (unknown_channel_error) being thrown.

Definition at line 12 of file SetupRecord.h.


Member Typedef Documentation

Definition at line 15 of file SetupRecord.h.


Constructor & Destructor Documentation

SetupRecord::~SetupRecord (  )  [virtual]

Destructor. Default is correct.

Definition at line 37 of file SetupRecord.cpp.

00038 {}

SetupRecord::SetupRecord ( const TSetupData setup_data  )  [protected]

Normal constructor, used by friends.

Definition at line 23 of file SetupRecord.cpp.

References InitChannels(), and InitMetaData().

00024   : fInfoLookup(0)
00025 {
00026   InitChannels(setup_data);
00027   InitMetaData(setup_data);
00028 
00029   //for (int i =0; i < fInfoLookup.size(); ++i) {
00030   //  std::cout << "\n\n";
00031   //  fInfoLookup[i].Print();
00032   //  }
00033 }

SetupRecord::SetupRecord (  )  [protected]

Default constructor, shouldn't need this.

SetupRecord::SetupRecord ( const SetupRecord src  )  [protected]

Copy constructor, shouldn't need this.


Member Function Documentation

std::string SetupRecord::BankFromChannel ( const ChannelID cid  )  const [inline]

Get the MIDAS bank name for this channelID.

Definition at line 92 of file SetupRecord.h.

References BankInfo().

Referenced by GetBankName().

00093   { return std::string(BankInfo(cid).Name); }

SetupRecord::BankInfo_t & SetupRecord::BankInfo ( const ChannelID cid  )  [protected]

Get the Writable BankInfo for this Channel ID.

Definition at line 138 of file SetupRecord.cpp.

References BankInfo().

00139 {
00140   const SetupRecord* c_this = this;
00141   return const_cast<BankInfo_t&>(c_this->BankInfo(cid));
00142 }

SetupRecord::BankInfo_t & SetupRecord::BankInfo ( const std::string &  bankname  )  [protected]

Get the Writable BankInfo for this bank name.

Definition at line 129 of file SetupRecord.cpp.

References BankInfo().

00130 {
00131   const SetupRecord* c_this = this;
00132   return const_cast<BankInfo_t&>(c_this->BankInfo(bankname));
00133 }

const SetupRecord::BankInfo_t & SetupRecord::BankInfo ( const ChannelID cid  )  const [protected]

Get the BankInfo for this Channel ID.

Definition at line 118 of file SetupRecord.cpp.

References fIDOrderLookup, and fInfoLookup.

00119 {
00120   std::map<ChannelID, unsigned int>::const_iterator it;
00121   it = fIDOrderLookup.find(cid);
00122   if (it == fIDOrderLookup.end()) throw unknown_channel_error();
00123   return fInfoLookup.at(it->second);
00124 }

const SetupRecord::BankInfo_t & SetupRecord::BankInfo ( const std::string &  bankname  )  const [protected]

Get the BankInfo for this bank name.

Definition at line 107 of file SetupRecord.cpp.

References fInfoLookup, and fNameOrderLookup.

Referenced by BankFromChannel(), BankInfo(), ChannelFromBank(), GetADCDepth(), GetPedestal(), GetPolarity(), GetTickLength(), GetTimeFromMuSc(), InitMetaData(), and IsEnabled().

00108 {
00109   std::map<std::string, UInt_t>::const_iterator it;
00110   it = fNameOrderLookup.find(bankname);
00111   if (it == fNameOrderLookup.end() ) throw unknown_channel_error();
00112   return fInfoLookup.at(it->second);
00113 }

ChannelID SetupRecord::ChannelFromBank ( const std::string &  bankname  )  const [inline]

Convert a MIDAS bankname to a Channel ID.

Definition at line 96 of file SetupRecord.h.

References BankInfo(), and SetupRecord::BankInfo_t::ID.

00097   { return BankInfo(bankname).ID; }

Short_t SetupRecord::GetADCDepth ( const ChannelID cid  )  const [inline]

The bit depth of the ADC.

Definition at line 58 of file SetupRecord.h.

References SetupRecord::BankInfo_t::ADCDepth, and BankInfo().

Referenced by GetOverflowADC().

00059   { return BankInfo(cid).ADCDepth; }

std::string SetupRecord::GetBankName ( const ChannelID cid  )  const [inline]

Get the MIDAS bank name for this channelID.

Definition at line 88 of file SetupRecord.h.

References BankFromChannel().

00089   { return BankFromChannel(cid); }

Short_t SetupRecord::GetHeadroom ( const ChannelID cid  )  const [inline]

The headroom, defined as MaxADC - Pedestal Note that negative pulses should typically have |headroom| < |pedestal|, in the same way that positive pulses typically have |pedestal| < |headroom|.

Definition at line 76 of file SetupRecord.h.

References GetMaxADC(), and GetPedestal().

00077   { return GetMaxADC(cid) - GetPedestal(cid); }

Int_t SetupRecord::GetMaxADC ( const ChannelID cid  )  const [inline]

The maximum value recordable by the ADC i.e. 1 less than the overflow.

Definition at line 66 of file SetupRecord.h.

References GetOverflowADC().

Referenced by GetHeadroom(), and TemplateMultiFitter::TemplateMultiFitter().

00067   { return GetOverflowADC(cid) -1; }

Int_t SetupRecord::GetOverflowADC ( const ChannelID cid  )  const [inline]

The overflow value of the ADC, i.e 2^{bit depth} the first impossible value.

Definition at line 62 of file SetupRecord.h.

References GetADCDepth().

Referenced by GetMaxADC().

00063   { return (1 << GetADCDepth(cid)); }

Short_t SetupRecord::GetPedestal ( const ChannelID cid  )  const [inline]

The pedestal of the channel.

Definition at line 70 of file SetupRecord.h.

References BankInfo(), and SetupRecord::BankInfo_t::Pedestal.

Referenced by GetHeadroom().

00071   { return BankInfo(cid).Pedestal; }

Short_t SetupRecord::GetPolarity ( const ChannelID cid  )  const [inline]
Double_t SetupRecord::GetTickLength ( const ChannelID cid  )  const [inline]

The length, in nanoseconds, of each sample clock tick.

Definition at line 50 of file SetupRecord.h.

References BankInfo(), and SetupRecord::BankInfo_t::TickLength.

00051   { return BankInfo(cid).TickLength; }

Double_t SetupRecord::GetTimeFromMuSc ( const ChannelID cid  )  const [inline]

The timing offset from the muSc.

Definition at line 54 of file SetupRecord.h.

References BankInfo(), and SetupRecord::BankInfo_t::TimeFromMuSc.

00055   { return BankInfo(cid).TimeFromMuSc; }

int SetupRecord::InitChannels ( const TSetupData setup_data  )  [protected]

Construction helper.

Definition at line 42 of file SetupRecord.cpp.

References TSetupData::fBankToDetectorMap, fIDOrderLookup, fInfoLookup, fNameOrderLookup, SetupRecord::BankInfo_t::ID, and SetupRecord::BankInfo_t::Name.

Referenced by SetupRecord().

00043 {
00044   typedef const std::map<std::string, std::string> StrStrMap;
00045   typedef StrStrMap::const_iterator StrStrIt;
00046 
00047 
00048   UInt_t lut_size = fInfoLookup.size();
00049   StrStrMap& b2d = setup_data->fBankToDetectorMap;
00050   fInfoLookup.resize(b2d.size());
00051   for (StrStrIt it = b2d.begin() ; it != b2d.end(); ++it){
00052     const std::string& name = it->first;
00053     if (name.size() > 4) throw std::out_of_range("Bank name too long!");
00054     ChannelID cid(it->second);
00055     fNameOrderLookup.insert(std::make_pair(name,lut_size));
00056     fIDOrderLookup.insert(std::make_pair(cid,lut_size));
00057 
00058     BankInfo_t& info = fInfoLookup.at(lut_size);
00059     name.copy(info.Name, 4);     info.Name[4] = '\0';
00060     info.ID = cid;
00061     ++lut_size;
00062   }
00063   return lut_size;
00064 }

int SetupRecord::InitMetaData ( const TSetupData setup_data  )  [protected]

Construction helper.

Definition at line 67 of file SetupRecord.cpp.

References SetupRecord::BankInfo_t::ADCDepth, BankInfo(), SetupRecord::BankInfo_t::Enabled, TSetupData::fBankToBitMap, fInfoLookup, fNameOrderLookup, TSetupData::GetADCOffsetCalib(), TSetupData::GetADCSlopeCalib(), TSetupData::GetClockTick(), TSetupData::GetEnableBit(), TSetupData::GetNBits(), TSetupData::GetPedestal(), TSetupData::GetTimeShift(), TSetupData::GetTriggerPolarity(), SetupRecord::BankInfo_t::ID, IDs::kErrorDetector, IDs::kErrorSlowFast, SetupRecord::BankInfo_t::LinearWidthLSB, SetupRecord::BankInfo_t::LinearZeroPoint, SetupRecord::BankInfo_t::Name, SetupRecord::BankInfo_t::Pedestal, SetupRecord::BankInfo_t::Polarity, SetupRecord::BankInfo_t::TickLength, and SetupRecord::BankInfo_t::TimeFromMuSc.

Referenced by SetupRecord().

00068 {
00069   typedef const std::map<std::string, int> StrIntMap;
00070   typedef StrIntMap::const_iterator StrIntIt;
00071 
00072   UInt_t lut_size = fInfoLookup.size();
00073   const StrIntMap& bit_map = setup_data->fBankToBitMap;
00074   if (bit_map.size() > lut_size){
00075     BankInfo_t blank;
00076     blank.ID = ChannelID(IDs::kErrorDetector, 
00077                          IDs::kErrorSlowFast);
00078     fInfoLookup.resize(bit_map.size(), blank);
00079   }
00080   
00081   //Assume all of these maps have the same length.  If not they wil
00082   //record default values, and it probably does not matter
00083   for (StrIntIt it = bit_map.begin(); it != bit_map.end(); ++it){
00084     std::string name = it->first;
00085     if (fNameOrderLookup.count(name) == 0){
00086       fNameOrderLookup.insert(make_pair(name, lut_size));
00087       ++lut_size;
00088     }  
00089     
00090     BankInfo_t& info = BankInfo(name);
00091     name.copy(info.Name, 4);    info.Name[4] = '\0';
00092     info.TickLength = setup_data->GetClockTick(name);
00093     info.LinearWidthLSB = setup_data->GetADCSlopeCalib(name);
00094     info.LinearZeroPoint = setup_data->GetADCOffsetCalib(name);
00095     info.TimeFromMuSc = setup_data->GetTimeShift(name);
00096     info.ADCDepth = setup_data->GetNBits(name);
00097     info.Pedestal = setup_data->GetPedestal(name);
00098     info.Polarity = setup_data->GetTriggerPolarity(name);
00099     info.Enabled = setup_data->GetEnableBit(name);
00100   }
00101   return lut_size;
00102 }

Bool_t SetupRecord::IsEnabled ( const ChannelID cid  )  const [inline]

Is the enabled bit set for this channel?

Definition at line 84 of file SetupRecord.h.

References BankInfo(), and SetupRecord::BankInfo_t::Enabled.

00085   { return static_cast<Bool_t>(BankInfo(cid).Enabled); }

SetupRecord& SetupRecord::operator= ( const SetupRecord rhs  )  [protected]

Copy assignment, shouldn't need this.


Friends And Related Function Documentation

friend class EventNavigator [friend]

Definition at line 14 of file SetupRecord.h.


Member Data Documentation

std::map<ChannelID, UInt_t> SetupRecord::fIDOrderLookup [private]

A lookup for the record if we know the Channel ID.

Definition at line 135 of file SetupRecord.h.

Referenced by BankInfo(), and InitChannels().

std::vector<BankInfo_t> SetupRecord::fInfoLookup [private]

A lookup for channel Info, with arbitrary ordering;.

Definition at line 132 of file SetupRecord.h.

Referenced by BankInfo(), InitChannels(), and InitMetaData().

std::map<std::string, UInt_t> SetupRecord::fNameOrderLookup [private]

A lookup for the record if we know the MIDAS Bankname.

Definition at line 138 of file SetupRecord.h.

Referenced by BankInfo(), InitChannels(), and InitMetaData().


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

Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1