larutil::DetectorProperties Class Reference

LArSoft's DetectorProperties service. More...

#include <DetectorProperties.hh>

Inheritance diagram for larutil::DetectorProperties:
larutil::LArUtilBase larlight::larlight_base

List of all members.

Public Member Functions

Double_t SamplingRate () const
Double_t ElectronsToADC () const
UInt_t NumberTimeSamples () const
UInt_t ReadOutWindowSize () const
Int_t TriggerOffset () const
Double_t TimeOffsetU () const
Double_t TimeOffsetV () const
Double_t TimeOffsetZ () const
Double_t ConvertXToTicks (Double_t X, Int_t p)
Double_t ConvertTicksToX (Double_t ticks, Int_t p)
Double_t GetXTicksOffset (Int_t p)
Double_t GetXTicksCoefficient ()
void SetFileName (const std::string filename)
 Method to set data file name.
void SetTreeName (const std::string treename)
 Method to set data TTree name.
virtual bool LoadData (bool force_reload=false)
 Method to load data TTree.
virtual void set_verbosity (MSG::Level level)
 Setter for the verbosity level.
MSG::Level get_verbosity () const
 Getter for the verbosity level.
const std::string class_name () const
 Getter for the class name.
void print (MSG::Level level, std::string where, std::string msg) const
 message print out method
void print (MSG::Level level, std::string msg) const
 message print out method

Static Public Member Functions

static const DetectorPropertiesGetME (bool default_load=true)
 Singleton getter.

Protected Member Functions

virtual bool ReadTree ()
virtual void ClearData ()

Protected Attributes

Double_t fSamplingRate
 in ns
Int_t fTriggerOffset
 in # of clock ticks
Double_t fElectronsToADC
 conversion factor for # of ionization electrons to 1 ADC count
UInt_t fNumberTimeSamples
 number of clock ticks per event
UInt_t fReadOutWindowSize
 number of clock ticks per readout window
Double_t fTimeOffsetU
 time offsets to convert spacepoint
Double_t fTimeOffsetV
 coordinates to hit times on each
Double_t fTimeOffsetZ
 view
bool fInheritTriggerOffset
 Flag saying whether to inherit TriggerOffset.
bool fInheritNumberTimeSamples
 Flag saying whether to inherit NumberTimeSamples.
Double_t fXTicksCoefficient
 Parameters for x<-->ticks.
bool fXTicksParamsLoaded
 calculations
std::vector< Double_t > fXTicksOffsets
std::string _file_name
std::string _tree_name
bool _loaded
char _buf [200]
 char buffer for message manipulation
std::vector< bool > _verbosity
 holder for enabled message levels
MSG::Level _verbosity_level
 holder for specified verbosity level
std::string _name
 class name holder

Private Member Functions

 DetectorProperties (bool default_load=true)
 Singleton constructor.
virtual ~DetectorProperties ()
 Default destructor.

Static Private Attributes

static DetectorProperties_me = 0

Detailed Description

LArSoft's DetectorProperties service.

Database part is currently not implemented. Also we ignore the idea of "inherit properties from history": as that does not seem to be a convincing solution yet adding quite a bit of complexity. Once we have DB, Kazu will implement a simple DBI one can use from command line.

Definition at line 27 of file DetectorProperties.hh.


Constructor & Destructor Documentation

larutil::DetectorProperties::DetectorProperties ( bool  default_load = true  )  [private]

Singleton constructor.

Definition at line 10 of file DetectorProperties.cc.

References larutil::LArUtilBase::_file_name, larlight::larlight_base::_name, larutil::LArUtilBase::_tree_name, larutil::LArUtilConfig::Detector(), larutil::kTREENAME_DETECTORPROPERTIES, larutil::kUTIL_DATA_FILENAME, and larutil::LArUtilBase::LoadData().

Referenced by GetME().

00010                                                           : LArUtilBase()
00011   {
00012     _name = "DetectorProperties";
00013     if(default_load) {
00014       _file_name = Form("%s/LArUtil/dat/%s",
00015             getenv("LARLIGHT_CORE_DIR"),
00016             kUTIL_DATA_FILENAME[LArUtilConfig::Detector()].c_str());
00017       _tree_name = kTREENAME_DETECTORPROPERTIES;
00018       LoadData();
00019     }
00020   }

virtual larutil::DetectorProperties::~DetectorProperties (  )  [inline, private, virtual]

Default destructor.

Definition at line 35 of file DetectorProperties.hh.

00035 {};


Member Function Documentation

const std::string larlight::larlight_base::class_name (  )  const [inline, inherited]

Getter for the class name.

Definition at line 49 of file larlight_base.hh.

References larlight::larlight_base::_name.

00049 {return _name;};

void larutil::DetectorProperties::ClearData (  )  [protected, virtual]
Double_t larutil::DetectorProperties::ConvertTicksToX ( Double_t  ticks,
Int_t  p 
) [inline]

Definition at line 63 of file DetectorProperties.hh.

References fXTicksCoefficient, and fXTicksOffsets.

00063                                                       {
00064       return (ticks - fXTicksOffsets.at(p) ) * fXTicksCoefficient;
00065     }

Double_t larutil::DetectorProperties::ConvertXToTicks ( Double_t  X,
Int_t  p 
) [inline]

Definition at line 59 of file DetectorProperties.hh.

References fXTicksCoefficient, and fXTicksOffsets.

00059                                                       {
00060       return (X / fXTicksCoefficient +  fXTicksOffsets.at(p));
00061     }

Double_t larutil::DetectorProperties::ElectronsToADC (  )  const [inline]

Definition at line 51 of file DetectorProperties.hh.

References fElectronsToADC.

00051 { return fElectronsToADC; }

MSG::Level larlight::larlight_base::get_verbosity (  )  const [inline, inherited]

Getter for the verbosity level.

Definition at line 46 of file larlight_base.hh.

References larlight::larlight_base::_verbosity_level.

00046 {return _verbosity_level;};

static const DetectorProperties* larutil::DetectorProperties::GetME ( bool  default_load = true  )  [inline, static]

Singleton getter.

Definition at line 42 of file DetectorProperties.hh.

References _me, and DetectorProperties().

Referenced by main(), larutil::GeometryUtilities::Reconfigure(), and larutil::LArUtilManager::ReconfigureUtilities().

00043     {
00044       if(!_me) _me = new DetectorProperties(default_load);
00045       return _me;
00046     }

Double_t larutil::DetectorProperties::GetXTicksCoefficient (  )  [inline]

Definition at line 71 of file DetectorProperties.hh.

References fXTicksCoefficient.

00071                                     {
00072       return fXTicksCoefficient;
00073     }

Double_t larutil::DetectorProperties::GetXTicksOffset ( Int_t  p  )  [inline]

Definition at line 67 of file DetectorProperties.hh.

References fXTicksOffsets.

00067                                       {
00068       return fXTicksOffsets.at(p);
00069     }

bool larutil::LArUtilBase::LoadData ( bool  force_reload = false  )  [virtual, inherited]

Method to load data TTree.

Reimplemented in larutil::Geometry.

Definition at line 20 of file LArUtilBase.cc.

References larutil::LArUtilBase::_file_name, larutil::LArUtilBase::_loaded, larlight::larlight_base::_name, larutil::LArUtilBase::_tree_name, larutil::LArUtilBase::ClearData(), larlight::MSG::ERROR, larlight::MSG::INFO, larlight::MSG::NORMAL, larlight::larlight_base::print(), larutil::LArUtilBase::ReadTree(), and larutil::LArUtilException::what().

Referenced by DetectorProperties(), larutil::LArProperties::LArProperties(), and larutil::LArUtilManager::ReconfigureUtilities().

00022   {
00023     if(!force_reload && _loaded) return true;
00024 
00025     print(larlight::MSG::INFO,__FUNCTION__,
00026       Form("Reading-in data for %s",_name.c_str()));
00027 
00028     if(_file_name.empty() || _tree_name.empty()) {
00029 
00030       throw LArUtilException(Form("Either file or tree name not specified to load data for %s",_name.c_str()));
00031       
00032       return false;
00033     }
00034 
00035     bool status=false;
00036     try {
00037 
00038       print(larlight::MSG::NORMAL, __FUNCTION__,
00039         Form("Loading data for %s...\n     file=%s ", _name.c_str(), _file_name.c_str()));
00040       ClearData();
00041       status = ReadTree();
00042       if(!status)
00043     throw LArUtilException("Failed to load !");
00044     }
00045     catch (LArUtilException &e) {
00046 
00047       print(larlight::MSG::ERROR, __FUNCTION__,
00048         Form("Failed loading data for %s...",_name.c_str()));
00049 
00050       print(larlight::MSG::ERROR, __FUNCTION__,
00051         e.what());
00052       
00053       throw e;
00054       status = false;
00055     }
00056 
00057     return status;
00058   }

UInt_t larutil::DetectorProperties::NumberTimeSamples (  )  const [inline]

Definition at line 52 of file DetectorProperties.hh.

References fNumberTimeSamples.

Referenced by larutil::GeometryUtilities::SelectPolygonHitList().

00052 { return fNumberTimeSamples; }

void larlight::larlight_base::print ( MSG::Level  level,
std::string  msg 
) const [inline, inherited]

message print out method

Definition at line 56 of file larlight_base.hh.

00057     {if(_verbosity.at(level)) Message::send(level,msg);};

void larlight::larlight_base::print ( MSG::Level  level,
std::string  where,
std::string  msg 
) const [inline, inherited]
UInt_t larutil::DetectorProperties::ReadOutWindowSize (  )  const [inline]

Definition at line 53 of file DetectorProperties.hh.

References fReadOutWindowSize.

00053 { return fReadOutWindowSize; }

bool larutil::DetectorProperties::ReadTree (  )  [protected, virtual]

Implements larutil::LArUtilBase.

Definition at line 39 of file DetectorProperties.cc.

References larutil::LArUtilBase::_file_name, larutil::LArUtilBase::_tree_name, ClearData(), fElectronsToADC, fNumberTimeSamples, fReadOutWindowSize, fSamplingRate, fTimeOffsetU, fTimeOffsetV, fTimeOffsetZ, fTriggerOffset, fXTicksCoefficient, and fXTicksOffsets.

00040   {
00041 
00042     ClearData();
00043     TChain *ch = new TChain(_tree_name.c_str());
00044     ch->AddFile(_file_name.c_str());
00045 
00046     std::string error_msg("");
00047     if(!(ch->GetBranch("fSamplingRate")))      error_msg += "      fSamplingRate\n";
00048     if(!(ch->GetBranch("fTriggerOffset")))     error_msg += "      fTriggerOffset\n";
00049     if(!(ch->GetBranch("fElectronsToADC")))    error_msg += "      fElectronsToADC\n";
00050     if(!(ch->GetBranch("fNumberTimeSamples"))) error_msg += "      fNumberTimeSamples\n";
00051     if(!(ch->GetBranch("fReadOutWindowSize"))) error_msg += "      fReadOutWindowSize\n";
00052     if(!(ch->GetBranch("fTimeOffsetU")))       error_msg += "      fTimeOffsetU\n";
00053     if(!(ch->GetBranch("fTimeOffsetV")))       error_msg += "      fTimeOffsetV\n";
00054     if(!(ch->GetBranch("fTimeOffsetZ")))       error_msg += "      fTimeOffsetZ\n";
00055     if(!(ch->GetBranch("fXTicksCoefficient"))) error_msg += "      fXTicksCoefficient\n";
00056     if(!(ch->GetBranch("fXTicksOffsets")))     error_msg += "      fXTicksOffsets\n";
00057     if(!error_msg.empty()) {
00058 
00059       throw LArUtilException(Form("Missing following TBranches...\n%s",error_msg.c_str()));
00060 
00061       return false;
00062     }
00063 
00064     ch->SetBranchAddress("fSamplingRate",&fSamplingRate);
00065     ch->SetBranchAddress("fTriggerOffset",&fTriggerOffset);
00066     ch->SetBranchAddress("fElectronsToADC",&fElectronsToADC);
00067     ch->SetBranchAddress("fNumberTimeSamples",&fNumberTimeSamples);
00068     ch->SetBranchAddress("fReadOutWindowSize",&fReadOutWindowSize);
00069     ch->SetBranchAddress("fTimeOffsetU",&fTimeOffsetU);
00070     ch->SetBranchAddress("fTimeOffsetV",&fTimeOffsetV);
00071     ch->SetBranchAddress("fTimeOffsetZ",&fTimeOffsetZ);
00072     ch->SetBranchAddress("fXTicksCoefficient",&fXTicksCoefficient);
00073 
00074     std::vector<Double_t> *pXTicksOffsets=nullptr;
00075     ch->SetBranchAddress("fXTicksOffsets",&pXTicksOffsets);
00076 
00077     ch->GetEntry(0);
00078 
00079     for(size_t i=0; i<pXTicksOffsets->size(); ++i)
00080       fXTicksOffsets.push_back(pXTicksOffsets->at(i));
00081 
00082     delete ch;
00083     return true;
00084   }

Double_t larutil::DetectorProperties::SamplingRate (  )  const [inline]

Definition at line 50 of file DetectorProperties.hh.

References fSamplingRate.

Referenced by larutil::GeometryUtilities::Reconfigure().

00050 { return fSamplingRate;   }

void larlight::larlight_base::set_verbosity ( MSG::Level  level  )  [virtual, inherited]

Setter for the verbosity level.

Reimplemented in larlight::ana_processor.

Definition at line 8 of file larlight_base.cc.

References larlight::larlight_base::_verbosity, larlight::larlight_base::_verbosity_level, larlight::MSG::DEBUG, larlight::MSG::ERROR, larlight::MSG::INFO, larlight::MSG::MSG_TYPE_MAX, larlight::MSG::NORMAL, and larlight::MSG::WARNING.

Referenced by larlight::larlight_base::larlight_base(), main(), and larlight::ana_processor::set_verbosity().

00010   {
00011     
00012     _verbosity_level=level;
00013     
00014     for(size_t i=(size_t)(MSG::DEBUG); i<(size_t)(MSG::MSG_TYPE_MAX); ++i)
00015       _verbosity[i]=false;
00016     
00017     switch(level){
00018     case MSG::DEBUG:
00019       _verbosity[MSG::DEBUG]=true;
00020     case MSG::INFO:
00021       _verbosity[MSG::INFO]=true;
00022     case MSG::NORMAL:
00023       _verbosity[MSG::NORMAL]=true;
00024     case MSG::WARNING:
00025       _verbosity[MSG::WARNING]=true;
00026     case MSG::ERROR:
00027       _verbosity[MSG::ERROR]=true;
00028     case MSG::MSG_TYPE_MAX:
00029       break;
00030     }
00031     
00032   }

void larutil::LArUtilBase::SetFileName ( const std::string  filename  )  [inline, inherited]

Method to set data file name.

Definition at line 44 of file LArUtilBase.hh.

References larutil::LArUtilBase::_file_name.

Referenced by larutil::LArUtilManager::ReconfigureUtilities().

00045     { _file_name = filename; }

void larutil::LArUtilBase::SetTreeName ( const std::string  treename  )  [inline, inherited]

Method to set data TTree name.

Definition at line 48 of file LArUtilBase.hh.

References larutil::LArUtilBase::_tree_name.

Referenced by larutil::LArUtilManager::ReconfigureUtilities().

00049     { _tree_name = treename; }

Double_t larutil::DetectorProperties::TimeOffsetU (  )  const [inline]

Definition at line 55 of file DetectorProperties.hh.

References fTimeOffsetU.

00055 { return fTimeOffsetU; }

Double_t larutil::DetectorProperties::TimeOffsetV (  )  const [inline]

Definition at line 56 of file DetectorProperties.hh.

References fTimeOffsetV.

00056 { return fTimeOffsetV; }

Double_t larutil::DetectorProperties::TimeOffsetZ (  )  const [inline]

Definition at line 57 of file DetectorProperties.hh.

References fTimeOffsetZ.

00057 { return fTimeOffsetZ; }

Int_t larutil::DetectorProperties::TriggerOffset (  )  const [inline]

Member Data Documentation

char larlight::larlight_base::_buf[200] [protected, inherited]

char buffer for message manipulation

Definition at line 57 of file larlight_base.hh.

Referenced by larlight::storage_manager::open(), larlight::storage_manager::prepare_tree(), and larlight::ana_processor::run().

std::string larutil::LArUtilBase::_file_name [protected, inherited]
bool larutil::LArUtilBase::_loaded [protected, inherited]

Definition at line 35 of file DetectorProperties.hh.

Referenced by GetME().

std::string larlight::larlight_base::_name [protected, inherited]
std::string larutil::LArUtilBase::_tree_name [protected, inherited]
std::vector<bool> larlight::larlight_base::_verbosity [protected, inherited]
MSG::Level larlight::larlight_base::_verbosity_level [protected, inherited]

holder for specified verbosity level

Definition at line 63 of file larlight_base.hh.

Referenced by larlight::larlight_base::get_verbosity(), larlight::ana_processor::initialize(), and larlight::larlight_base::set_verbosity().

conversion factor for # of ionization electrons to 1 ADC count

Definition at line 92 of file DetectorProperties.hh.

Referenced by ClearData(), ElectronsToADC(), and ReadTree().

Flag saying whether to inherit NumberTimeSamples.

Definition at line 100 of file DetectorProperties.hh.

Flag saying whether to inherit TriggerOffset.

Definition at line 99 of file DetectorProperties.hh.

number of clock ticks per event

Definition at line 93 of file DetectorProperties.hh.

Referenced by ClearData(), NumberTimeSamples(), and ReadTree().

number of clock ticks per readout window

Definition at line 94 of file DetectorProperties.hh.

Referenced by ClearData(), ReadOutWindowSize(), and ReadTree().

in ns

Definition at line 90 of file DetectorProperties.hh.

Referenced by ClearData(), ReadTree(), and SamplingRate().

time offsets to convert spacepoint

Definition at line 95 of file DetectorProperties.hh.

Referenced by ClearData(), ReadTree(), and TimeOffsetU().

coordinates to hit times on each

Definition at line 96 of file DetectorProperties.hh.

Referenced by ClearData(), ReadTree(), and TimeOffsetV().

view

Definition at line 97 of file DetectorProperties.hh.

Referenced by ClearData(), ReadTree(), and TimeOffsetZ().

in # of clock ticks

Definition at line 91 of file DetectorProperties.hh.

Referenced by ClearData(), ReadTree(), and TriggerOffset().

Parameters for x<-->ticks.

Definition at line 102 of file DetectorProperties.hh.

Referenced by ClearData(), ConvertTicksToX(), ConvertXToTicks(), GetXTicksCoefficient(), and ReadTree().

std::vector<Double_t> larutil::DetectorProperties::fXTicksOffsets [protected]

calculations

Definition at line 103 of file DetectorProperties.hh.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator

Generated on 3 Jun 2014 for MyProject by  doxygen 1.6.1