/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 | Static Private Attributes
TargetProtonsSvc Class Reference

#include <TargetProtonsSvc.h>

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

List of all members.

Public Member Functions

 TargetProtonsSvc (const std::string &name, ISvcLocator *svc)
 ~TargetProtonsSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &id, void **interface)
double getBellowsVolume ()
double getBellowsVolumeErr ()
DayaBay::AdMassData getAdMasses ()
DayaBay::AdPConcentrationData getAdPConcentration ()
DayaBay::OFMassData getOFMasses (const ServiceMode &svcMode)
DayaBay::OFHeightData getOFHeights (const ServiceMode &svcMode)
double getGdTemp (const ServiceMode &svcMode)
double getLSTemp (const ServiceMode &svcMode)
DayaBay::ProtonNumber getProtonNumber (const ServiceMode &svcMode)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

int getPhysAdIndex (const Site::Site_t &site, const DetectorId::DetectorId_t &detId)

Private Attributes

IMessageSvc * m_msgSvc
std::string m_adMassFileName
std::string m_adPConcentrationFileName
std::string m_ofHeightMassFileName
IAdMassSvcm_adMassSvc
IOFMassSvcm_ofMassSvc
DayaBay::AdMassDatam_adMasses
DayaBay::AdPConcentrationDatam_adPConcentration
DayaBay::OFMassDatam_ofMasses
DayaBay::OFHeightDatam_ofHeights
DayaBay::ProtonNumber m_protonNumber

Static Private Attributes

static const double m_bellowsV = 0.01008
static const double m_bellowsVErr = 0.00058
static const double m_tiltErr = 1.4

Detailed Description

Definition at line 32 of file TargetProtonsSvc.h.


Constructor & Destructor Documentation

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

Definition at line 48 of file TargetProtonsSvc.cc.

                                                                          : Service(name, svc)
{

  declareProperty("adMassFileName",m_adMassFileName="/u/clewis/nuwa_work/projects/protons/Database/TargetProtonsSvc/data/AdMasses.txt","Name of the file containing mass information");
  declareProperty("adPConcentrationFileName",m_adPConcentrationFileName="/u/clewis/nuwa_work/projects/protons/Database/TargetProtonsSvc/data/AdPConcentration.txt","Name of the file containing H concentration and density information");

}
TargetProtonsSvc::~TargetProtonsSvc ( )

Definition at line 56 of file TargetProtonsSvc.cc.

{
}

Member Function Documentation

StatusCode TargetProtonsSvc::initialize ( ) [virtual]

Definition at line 60 of file TargetProtonsSvc.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,"TargetProtonsSvc");
//  log << MSG::INFO << "Loading AD mass file: " << m_adMassFileName << endreq;
//  log << MSG::INFO << "Loading liquid properties file: " << m_liquidPropsFileName << endreq;
//  log << MSG::INFO << "Loading overflow mass lookup file: " << m_ofHeightMassFileName << endreq;

  st = service("AdMassSvc",m_adMassSvc,true);
  if(st.isFailure()){
    throw GaudiException("Couldn't initialize AdMassSvc",name(), st);
    return st;
  }
  // Set the proton number information based on total AD mass and liquid property info
  //  m_protonNumber.m_protonNumber = m_adMass 
  st = service("OFMassSvc",m_ofMassSvc,true);
  if(st.isFailure()){
    throw GaudiException("Couldn't initialize OFMassSvc",name(), st);
    return st;
  }

  return st;  
}
StatusCode TargetProtonsSvc::finalize ( ) [virtual]

Definition at line 93 of file TargetProtonsSvc.cc.

{
  if(m_adMassSvc!=0){
    m_adMassSvc->finalize();
  }
  if(m_ofMassSvc!=0){
    m_ofMassSvc->finalize();
  }
  StatusCode st=Service::finalize();
  return st;
}
StatusCode TargetProtonsSvc::queryInterface ( const InterfaceID &  id,
void **  interface 
) [virtual]

Definition at line 105 of file TargetProtonsSvc.cc.

{
  StatusCode sc = StatusCode::FAILURE;
  if(interface) {
    *interface=0;
    if(ITargetProtonsSvc::interfaceID().versionMatch(id)){
      *interface = static_cast<ITargetProtonsSvc*>(this);
      sc = StatusCode::SUCCESS;
      addRef();
    }
    else { sc = Service::queryInterface(id,interface); }
  }
  return sc;
}
double TargetProtonsSvc::getBellowsVolume ( ) [virtual]

Implements ITargetProtonsSvc.

Definition at line 140 of file TargetProtonsSvc.cc.

{
  return m_bellowsV;
}
double TargetProtonsSvc::getBellowsVolumeErr ( ) [virtual]

Implements ITargetProtonsSvc.

Definition at line 144 of file TargetProtonsSvc.cc.

{
  return m_bellowsVErr;
}
DayaBay::AdMassData TargetProtonsSvc::getAdMasses ( ) [virtual]

Implements ITargetProtonsSvc.

Definition at line 120 of file TargetProtonsSvc.cc.

{
  return m_adMassSvc->getAdMasses();
}
DayaBay::AdPConcentrationData TargetProtonsSvc::getAdPConcentration ( ) [virtual]

Implements ITargetProtonsSvc.

Definition at line 125 of file TargetProtonsSvc.cc.

DayaBay::OFMassData TargetProtonsSvc::getOFMasses ( const ServiceMode svcMode) [virtual]

Implements ITargetProtonsSvc.

Definition at line 130 of file TargetProtonsSvc.cc.

{
  return m_ofMassSvc->getOFMasses(svcMode);
}
DayaBay::OFHeightData TargetProtonsSvc::getOFHeights ( const ServiceMode svcMode) [virtual]

Implements ITargetProtonsSvc.

Definition at line 135 of file TargetProtonsSvc.cc.

{
  return m_ofMassSvc->getOFHeights(svcMode);
}
double TargetProtonsSvc::getGdTemp ( const ServiceMode svcMode) [virtual]

Implements ITargetProtonsSvc.

Definition at line 149 of file TargetProtonsSvc.cc.

{
  return m_ofMassSvc->getGdTemp(svcMode);
}
double TargetProtonsSvc::getLSTemp ( const ServiceMode svcMode) [virtual]

Implements ITargetProtonsSvc.

Definition at line 154 of file TargetProtonsSvc.cc.

{  
  return m_ofMassSvc->getLSTemp(svcMode);
}
DayaBay::ProtonNumber TargetProtonsSvc::getProtonNumber ( const ServiceMode svcMode) [virtual]

Implements ITargetProtonsSvc.

Definition at line 159 of file TargetProtonsSvc.cc.

{
  /*TODO: set  m_protonNumber components in the service initialization 
          so they contain the total number of GdLS protons in the AD
          When running on data, the number calculated based on the OF mass
          will just be subtracted off
  */
  MsgStream log( m_msgSvc,"TargetProtonsSvc");
  log << MSG::INFO << "Getting proton number from Detector: "<< svcMode.context().GetDetId() << ", Site: " << svcMode.context().GetSite() << endreq;
 
  DetectorId::DetectorId_t det = svcMode.context().GetDetId();
  Site::Site_t site = svcMode.context().GetSite();
  int phys_ad = getPhysAdIndex(site,det);
  double adGdMass = m_adMassSvc->getGdMass(phys_ad);
  double adGdMassErr_rel = m_adMassSvc->getGdMassErr_rel(phys_ad);
  double adGdMassErr_abs = m_adMassSvc->getGdMassErr_abs(phys_ad);
  double adGdDensity = m_adMassSvc->getGdDensity(phys_ad);
  double adGdDensityErr_abs = m_adMassSvc->getGdDensityErr_abs(phys_ad);
  double adPperKg = m_adMassSvc->getGdpPerKg(phys_ad);
  double adPperKgErr_abs = m_adMassSvc->getGdpPerKgErr_abs(phys_ad);
  double adPperKgErr_rel = m_adMassSvc->getGdpPerKgErr_rel(phys_ad);

  double bellowsV = m_bellowsV; //0.0043+0.00578; // cubic meters see docDb 7285
  double bellowsVErr = m_bellowsVErr; //sqrt(pow(0.42,2)+pow(0.4,2)); //bellows and stub uncrt.s

  double tiltErr = m_tiltErr; // see docDb 7285

  // Below is stuff for dealing with removed sample liquid from AD1
  TimeStamp ad1SampleTime = TimeStamp(2012, 8, 27, 0, 0, 0, 0, true, 0);
  if(phys_ad == 1 && svcMode.context().GetTimeStamp() >=ad1SampleTime){
    log << MSG::INFO << "AD1 GdLS sample removed" <<endreq;
    adGdMass = adGdMass-5.005; //kg
    adGdMassErr_rel = sqrt(pow(adGdMassErr_rel,2)+pow(0.5,2));
    adGdMassErr_abs = sqrt(pow(adGdMassErr_abs,2)+pow(0.5,2));
  }

  log << MSG::INFO << "From AdMassSvc:\nGdMass: " << adGdMass 
                                          <<"\nGdMassErr_rel: " << adGdMassErr_rel
                                          <<"\nGdMassErr_abs: " << adGdMassErr_abs
                                          <<"\nGdDensity: " << adGdDensity
                                          <<"\nGdDensityErr_abs: " <<adGdDensityErr_abs 
                                          <<"\nGd P per Kg: " << adPperKg 
                                          <<"\nGd P per Kg Err_rel: " << adPperKgErr_rel
                                          <<"\nGd P per Kg Err_abs: " << adPperKgErr_abs
                                          << endreq;

  double adProtonNumber = adGdMass*adPperKg;
  double adProtonNumberErr_rel = sqrt(pow(adGdMassErr_rel*adPperKg,2)+pow(adGdMass*adPperKgErr_rel,2));
  double adProtonNumberErr_abs = sqrt(pow(adGdMassErr_abs*adPperKg,2)+pow(adGdMass*adPperKgErr_abs,2));
  log << MSG::INFO << "Ad Proton Number: " << adProtonNumber <<
                                     "+/-" << adProtonNumberErr_rel << "(rel) +/-"
                                           << adProtonNumberErr_abs << "(abs)" << endreq;
  
  
  double ofGdMass = m_ofMassSvc->getGdMass(svcMode);
  log << MSG::INFO << "From OFMassSvc: \nGdOFMass: " << ofGdMass << endreq;
  double ofGdMassErr_rel = m_ofMassSvc->getGdMassErr_rel(svcMode);
  log << MSG::INFO << "GdOFMass rel error: " << ofGdMassErr_rel << endreq;
  double ofGdMassErr_abs = m_ofMassSvc->getGdMassErr_abs(svcMode);
  log << MSG::INFO << "GdOFMass_abs_error: " << ofGdMassErr_abs << endreq;

  double targetMass = (adGdMass-ofGdMass-bellowsV*adGdDensity);
  double targetMassErr_rel = sqrt( pow(adGdMassErr_rel,2)+pow(ofGdMassErr_rel,2)
                                         +pow(bellowsVErr*adGdDensity,2)+pow(tiltErr,2));
  double targetMassErr_abs = sqrt(pow(adGdMassErr_abs,2)+pow(ofGdMassErr_abs,2)
                                         +pow(bellowsVErr*adGdDensity,2)+pow(bellowsV*adGdDensityErr_abs,2)+pow(tiltErr,2));

  m_protonNumber.targetMass = targetMass;
  m_protonNumber.targetMassErr_rel = targetMassErr_rel;
  m_protonNumber.targetMassErr_abs = targetMassErr_abs;

  m_protonNumber.protonNumber = targetMass*adPperKg;
  m_protonNumber.protonNumberErr_rel = sqrt( pow(targetMass*adPperKgErr_rel,2) 
                                           + pow(targetMassErr_rel*adPperKg,2)
                                           );
  m_protonNumber.protonNumberErr_abs = sqrt( pow(targetMass*adPperKgErr_abs,2)
                                           + pow(targetMassErr_abs*adPperKg,2) 
                                           );

  log << MSG::INFO << "Target Proton Number: " << m_protonNumber.protonNumber <<
                                         "+/-" << m_protonNumber.protonNumberErr_rel << "(rel) +/-"
                                               << m_protonNumber.protonNumberErr_abs << "(abs)" << endreq;

  DayaBay::ProtonNumber currentProtonNumber;
  currentProtonNumber.protonNumber = m_protonNumber.protonNumber;
  currentProtonNumber.protonNumberErr_rel = m_protonNumber.protonNumberErr_rel;
  currentProtonNumber.protonNumberErr_abs = m_protonNumber.protonNumberErr_abs;
  
  currentProtonNumber.targetMass = m_protonNumber.targetMass;
  currentProtonNumber.targetMassErr_rel = m_protonNumber.targetMassErr_rel;
  currentProtonNumber.targetMassErr_abs = m_protonNumber.targetMassErr_abs;

  return currentProtonNumber;

}
int TargetProtonsSvc::getPhysAdIndex ( const Site::Site_t site,
const DetectorId::DetectorId_t detId 
) [private]

Definition at line 25 of file TargetProtonsSvc.cc.

                                                                                             {
  int index = 0; // Not an AD that has been installed
  switch (site){
    case Site::kDayaBay:
      if(det==DetectorId::kAD1){index = 1;}
      else if(det==DetectorId::kAD2){index = 2;}
      break;
    case Site::kLingAo:
      if(det==DetectorId::kAD1){index = 3;}
      if(det==DetectorId::kAD2){index = 8;}
      break;
    case Site::kFar:
      if(det==DetectorId::kAD1){index = 4;}
      else if(det==DetectorId::kAD2){index = 5;}
      else if(det==DetectorId::kAD3){index = 6;}
      else if(det==DetectorId::kAD4){index = 7;}
      break;
    default:
      index=0;  
  }
  return index;         
}

Member Data Documentation

IMessageSvc* TargetProtonsSvc::m_msgSvc [private]

Definition at line 64 of file TargetProtonsSvc.h.

std::string TargetProtonsSvc::m_adMassFileName [private]

Definition at line 65 of file TargetProtonsSvc.h.

Definition at line 66 of file TargetProtonsSvc.h.

Definition at line 67 of file TargetProtonsSvc.h.

Definition at line 69 of file TargetProtonsSvc.h.

Definition at line 70 of file TargetProtonsSvc.h.

Definition at line 72 of file TargetProtonsSvc.h.

Definition at line 73 of file TargetProtonsSvc.h.

Definition at line 74 of file TargetProtonsSvc.h.

Definition at line 75 of file TargetProtonsSvc.h.

Definition at line 76 of file TargetProtonsSvc.h.

const double TargetProtonsSvc::m_bellowsV = 0.01008 [static, private]

Definition at line 78 of file TargetProtonsSvc.h.

const double TargetProtonsSvc::m_bellowsVErr = 0.00058 [static, private]

Definition at line 79 of file TargetProtonsSvc.h.

const double TargetProtonsSvc::m_tiltErr = 1.4 [static, private]

Definition at line 80 of file TargetProtonsSvc.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