/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AdMassSvc Class Reference

#include <AdMassSvc.h>

Inheritance diagram for AdMassSvc:
Inheritance graph
[legend]
Collaboration diagram for AdMassSvc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AdMassSvc (const std::string &name, ISvcLocator *svc)
 ~AdMassSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &id, void **interface)
virtual StatusCode printAdMass (const int phys_ad)
virtual StatusCode printAdPConcentration (const int phys_ad)
virtual StatusCode adMass (const int phys_ad)
double getGdMass (const int phys_ad)
double getGdMassErr_rel (const int phys_ad)
double getGdMassErr_abs (const int phys_ad)
bool getGdMassBlinded (const int phys_ad)
bool getGdMassRatioBlinded (const int phys_ad)
double getLsMass (const int phys_ad)
double getLsMassErr (const int phys_ad)
double getMoMass (const int phys_ad)
double getMoMassErr (const int phys_ad)
double getGdDensity (const int phys_ad)
double getGdDensityErr_abs (const int phys_ad)
double getGdpPerKg (const int phys_ad)
double getGdpPerKgErr_rel (const int phys_ad)
double getGdpPerKgErr_abs (const int phys_ad)
DayaBay::AdMassData getAdMasses ()
DayaBay::AdPConcentrationData getAdPConcentration ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

StatusCode readAdMassFile (std::string filename)
StatusCode readAdPConcentrationFile (std::string filename)

Private Attributes

IMessageSvc * m_msgSvc
std::string m_adMassFileName
std::string m_adPConcentrationFileName
DayaBay::AdMassData m_adMasses
DayaBay::AdPConcentrationData m_adPConcentration

Detailed Description

Definition at line 27 of file AdMassSvc.h.


Constructor & Destructor Documentation

AdMassSvc::AdMassSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 15 of file AdMassSvc.cc.

                                                            : Service(name, svc)
{
  
  std::string svcrootpath = getenv("TARGETPROTONSSVCROOT");
  declareProperty("adMassFileName",m_adMassFileName=svcrootpath + "/data/AdMasses.txt",
                  "Name of the file containing mass information");
  declareProperty("adPConcentrationFileName",m_adPConcentrationFileName=svcrootpath + "/data/AdPConcentration.txt",
                  "Name of the file containing liquid property information");

}
AdMassSvc::~AdMassSvc ( )

Definition at line 26 of file AdMassSvc.cc.

{
}

Member Function Documentation

StatusCode AdMassSvc::initialize ( ) [virtual]

Definition at line 30 of file AdMassSvc.cc.

{
  StatusCode st = Service::initialize();
  if(st.isFailure()) { 
    throw GaudiException("Couldn't initialize ",name(),st);
    return st;
  }
  m_msgSvc = msgSvc();
  if(!m_msgSvc) {
    return StatusCode::FAILURE;
  }

  MsgStream log(m_msgSvc,"AdMassSvc");
  log << MSG::INFO << "Loading AD mass file: " << m_adMassFileName << endreq;

//  DayaBay::AdMassData m_adMasses;

  st = readAdMassFile(m_adMassFileName);
  if( st == StatusCode::FAILURE ){ return st; }
  st = readAdPConcentrationFile(m_adPConcentrationFileName);
  return st;  
}
StatusCode AdMassSvc::finalize ( ) [virtual]

Implements IAdMassSvc.

Definition at line 53 of file AdMassSvc.cc.

{
  return Service::finalize();
}
StatusCode AdMassSvc::queryInterface ( const InterfaceID &  id,
void **  interface 
) [virtual]

Definition at line 58 of file AdMassSvc.cc.

{
  StatusCode sc = StatusCode::FAILURE;
  if(interface) {
    *interface=0;
    if(IAdMassSvc::interfaceID().versionMatch(id)){
      *interface = static_cast<IAdMassSvc*>(this);
      sc = StatusCode::SUCCESS;
      addRef();
    }
    else { sc = Service::queryInterface(id,interface); }
  }
  return sc;
}
StatusCode AdMassSvc::printAdMass ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 73 of file AdMassSvc.cc.

{
  MsgStream log(m_msgSvc,"AdMassSvc");
  log << "Mass information from detector " << phys_ad << "\n\t"
                << "GdLS: " << m_adMasses.m_gdMass[phys_ad] << endreq;
  return StatusCode::SUCCESS;
}       
StatusCode AdMassSvc::printAdPConcentration ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 81 of file AdMassSvc.cc.

{
  MsgStream log(m_msgSvc,"AdMassSvc");
  log << "P concentration from detector " << phys_ad << "\n\t" << m_adPConcentration.m_pPerKg[phys_ad] 
                << "p/kg +/- " << m_adPConcentration.m_pPerKgErr_rel[phys_ad] << "(relative uncertainty)\n\t"
                << "      +/- " << m_adPConcentration.m_pPerKgErr_abs[phys_ad] << "(absolute uncertainty)" << endreq;
  log << "Gd density " << phys_ad <<"\n\t" << m_adPConcentration.m_gdDensity[phys_ad]
                << "      +/- " << m_adPConcentration.m_gdDensityErr_abs[phys_ad] << "(absolute uncertainty)" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode AdMassSvc::adMass ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 93 of file AdMassSvc.cc.

{
  return StatusCode::SUCCESS;
}
double AdMassSvc::getGdMass ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 98 of file AdMassSvc.cc.

{
  return m_adMasses.m_gdMass[phys_ad];
}
double AdMassSvc::getGdMassErr_rel ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 102 of file AdMassSvc.cc.

{
  return m_adMasses.m_gdMassErr_rel[phys_ad];
}
double AdMassSvc::getGdMassErr_abs ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 106 of file AdMassSvc.cc.

{
  return m_adMasses.m_gdMassErr_abs[phys_ad];
}
bool AdMassSvc::getGdMassBlinded ( const int  phys_ad)

Definition at line 110 of file AdMassSvc.cc.

{
  return m_adMasses.m_gdMassBlinded[phys_ad];
}
bool AdMassSvc::getGdMassRatioBlinded ( const int  phys_ad)

Definition at line 114 of file AdMassSvc.cc.

{
  return m_adMasses.m_gdMassRatioBlinded[phys_ad];
}
double AdMassSvc::getLsMass ( const int  phys_ad)

Definition at line 119 of file AdMassSvc.cc.

{
  return m_adMasses.m_lsMass[phys_ad];
}
double AdMassSvc::getLsMassErr ( const int  phys_ad)

Definition at line 123 of file AdMassSvc.cc.

{
  return m_adMasses.m_lsMassErr[phys_ad];
}  
double AdMassSvc::getMoMass ( const int  phys_ad)

Definition at line 127 of file AdMassSvc.cc.

{
  return m_adMasses.m_moMass[phys_ad];
}
double AdMassSvc::getMoMassErr ( const int  phys_ad)

Definition at line 131 of file AdMassSvc.cc.

{
  return m_adMasses.m_moMassErr[phys_ad];
}
double AdMassSvc::getGdDensity ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 141 of file AdMassSvc.cc.

{
  return m_adPConcentration.m_gdDensity[phys_ad];
}
double AdMassSvc::getGdDensityErr_abs ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 146 of file AdMassSvc.cc.

double AdMassSvc::getGdpPerKg ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 151 of file AdMassSvc.cc.

{
  return m_adPConcentration.m_pPerKg[phys_ad];
}
double AdMassSvc::getGdpPerKgErr_rel ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 161 of file AdMassSvc.cc.

{
  return m_adPConcentration.m_pPerKgErr_rel[phys_ad];
}
double AdMassSvc::getGdpPerKgErr_abs ( const int  phys_ad) [virtual]

Implements IAdMassSvc.

Definition at line 156 of file AdMassSvc.cc.

{
  return m_adPConcentration.m_pPerKgErr_abs[phys_ad];
}
DayaBay::AdMassData AdMassSvc::getAdMasses ( ) [virtual]

Implements IAdMassSvc.

Definition at line 136 of file AdMassSvc.cc.

{
  return m_adMasses;
}
DayaBay::AdPConcentrationData AdMassSvc::getAdPConcentration ( ) [virtual]

Implements IAdMassSvc.

Definition at line 166 of file AdMassSvc.cc.

{
  return m_adPConcentration;
}
StatusCode AdMassSvc::readAdMassFile ( std::string  filename) [private]

Definition at line 219 of file AdMassSvc.cc.

                                                            {
  StatusCode st=StatusCode::FAILURE;
  
  IMessageSvc* msg = m_msgSvc;
  MsgStream log(msg, "AdMassSvc");
  std::ifstream input( adMassFileName.c_str() );
  std::ostringstream prtStr;

  if( !input.is_open()){
    std::ostringstream msgStr;
    msgStr << "Couldn't open file: " << adMassFileName;
    msg->reportMessage("AdMassSvc",MSG::ERROR,msgStr.str());
    return st;
  }

  int detNo; 
  double gdMass, gdMassErr_rel, gdMassErr_abs, lsMass, lsMassErr, moMass, moMassErr;
  int gdMassBlinded, gdMassRatioBlinded;
  std::string line;

  while( std::getline(input,line) ){
    std::ostringstream msgStr;
    msgStr << "Read line: " << line;
    msg->reportMessage("AdMassSvc",MSG::INFO,msgStr.str());
    msgStr.str("");
    std::stringstream streamLine(line);
    if( streamLine.peek() == '#' ){
      continue;
    }
    streamLine >> detNo >> gdMass >> gdMassErr_rel >> gdMassErr_abs
               >> gdMassBlinded >> gdMassRatioBlinded >> lsMass
               >> lsMassErr >> moMass >> moMassErr;
    
    m_adMasses.m_gdMass[detNo] = gdMass;
    m_adMasses.m_gdMassErr_rel[detNo] = gdMassErr_rel;
    m_adMasses.m_gdMassErr_abs[detNo] = gdMassErr_abs;
    m_adMasses.m_gdMassBlinded[detNo] = (gdMassBlinded==1) ? true : false;
    m_adMasses.m_gdMassRatioBlinded[detNo] = (gdMassRatioBlinded==1) ? true : false;
    m_adMasses.m_lsMass[detNo] = lsMass;
    m_adMasses.m_lsMassErr[detNo] = lsMassErr;
    m_adMasses.m_moMass[detNo] = moMass;
    m_adMasses.m_moMassErr[detNo] = moMassErr;

  }
  return StatusCode::SUCCESS;
}
StatusCode AdMassSvc::readAdPConcentrationFile ( std::string  filename) [private]

Definition at line 174 of file AdMassSvc.cc.

                                                                                {
  StatusCode st=StatusCode::FAILURE;

  IMessageSvc* msg = msgSvc();
  if (!msg ){
    return st;
  }
  MsgStream log(msg,"AdMassSvc");

  std::ifstream input( adPConcentrationFileName.c_str());
  std::ostringstream prtStr;

  if( !input.is_open()){
    std::ostringstream msgStr;
    msgStr << "Couldn't open file: " << adPConcentrationFileName;
    msg->reportMessage("AdMassSvc",MSG::ERROR,msgStr.str());
    return st;
  }

  int detNo;
  double hPercent;
  double hFraction, hFractionErr_rel, hFractionErr_abs;
  double gdDensity, gdDensityErr_abs;
  std::string line;

  while( std::getline(input,line) ){
    std::ostringstream msgStr;
    msgStr << "Read line: " << line;
    msg->reportMessage("AdMassSvc",MSG::INFO,msgStr.str());
    msgStr.str("");
    std::stringstream streamLine(line);
    if( streamLine.peek() == '#' ){
      continue;
    }
    streamLine >> detNo >> hPercent >> hFractionErr_rel >> hFractionErr_abs >> gdDensity >> gdDensityErr_abs;
    hFraction = hPercent/100.;
    m_adPConcentration.m_pPerKg[detNo] = hFraction/(1.00794/6.0221415e26);
    m_adPConcentration.m_pPerKgErr_rel[detNo] = hFractionErr_rel/100.*hFraction/(1.00794/6.0221415e26);
    m_adPConcentration.m_pPerKgErr_abs[detNo] = hFractionErr_abs/100.*hFraction/(1.00794/6.0221415e26);
    m_adPConcentration.m_gdDensity[detNo] = gdDensity;
    m_adPConcentration.m_gdDensityErr_abs[detNo] = gdDensityErr_abs;
  }
  return StatusCode::SUCCESS;
}

Member Data Documentation

IMessageSvc* AdMassSvc::m_msgSvc [private]

Definition at line 65 of file AdMassSvc.h.

std::string AdMassSvc::m_adMassFileName [private]

Definition at line 66 of file AdMassSvc.h.

Definition at line 67 of file AdMassSvc.h.

Definition at line 69 of file AdMassSvc.h.

Definition at line 70 of file AdMassSvc.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:58:04 for TargetProtonsSvc by doxygen 1.7.4