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

#include <CalibEnergyAlg.h>

Collaboration diagram for CalibEnergyAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CalibEnergyAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~CalibEnergyAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()

Private Attributes

std::string m_readoutLocation
 Property ReadoutLocation - location in TES where the input ReadoutHeader is to be found.
std::vector< std::string > m_energyToolNames
std::string m_calibReadoutLocation
std::string m_sourceName
bool first
IEnergyCalibToolm_GeTool
IEnergyCalibToolm_CoTool
IEnergyCalibToolm_Background
IEnergyCalibToolm_ScinBall
IEnergyCalibToolm_Spallation
TimeStamp m_beginTime
TimeStamp m_endTime
int m_sourcetype
int m_acu
int m_zpo
IDaqDetailsSvcm_daqDetailsSvc
bool m_setACU
int m_calibRun

Detailed Description

Definition at line 20 of file CalibEnergyAlg.h.


Constructor & Destructor Documentation

CalibEnergyAlg::CalibEnergyAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 20 of file CalibEnergyAlg.cc.

    : GaudiAlgorithm(name,pSvcLocator)
{
    declareProperty("ReadoutLocation",
                    m_readoutLocation=DayaBay::ReadoutHeaderLocation::Default,
                    "Location in the TES where the input ReadoutHeader is to be found.");
    declareProperty("CalibReadoutLocation",
                    m_calibReadoutLocation=DayaBay::CalibReadoutHeaderLocation::Default,
                    "Location in the TES where the input CalibReadoutHeader is to be found.");
    declareProperty("CalibSourceName",m_sourceName="Ge",
                    "Source name");
         declareProperty("EnergyTools",m_energyToolNames,
                    "Names of the energy calibration tools");
     declareProperty("setACU",m_setACU= false, "set acu infomation by hand");
     declareProperty("ACU",m_acu= 1, "acu number");
     declareProperty("position",m_zpo= 1, "position z in mm");
}
CalibEnergyAlg::~CalibEnergyAlg ( ) [virtual]

Definition at line 38 of file CalibEnergyAlg.cc.

{
}

Member Function Documentation

StatusCode CalibEnergyAlg::initialize ( ) [virtual]

Definition at line 42 of file CalibEnergyAlg.cc.

{
  StatusCode sc = this->GaudiAlgorithm::initialize();
  if( sc != StatusCode::SUCCESS ) return sc;
  first=true;
  StatusCode sc1 = service("DetailsFromRecordSvc",
                            m_daqDetailsSvc,
                            true);
    if (sc1.isFailure()) {
        error() << "Failed to get DaqDetailsSvc" << endreq;
        return sc1;
    }
    // Get source calibration tool
      std::string toolName = "GeCalib";
      IEnergyCalibTool* calibTool = 0;
       try {
                        calibTool = tool<IEnergyCalibTool>(toolName);
       }
      catch(const GaudiException& exg) {
                        fatal() << "Failed to get energy calib tool: \"" << toolName << "\"" 
                                << endreq;
                        return StatusCode::FAILURE;
      }
      m_GeTool = calibTool;
   
    // Get source calibration tool
      toolName = "CoCalib";
      calibTool = 0;
       try {
                        calibTool = tool<IEnergyCalibTool>(toolName);
       }
      catch(const GaudiException& exg) {
                        fatal() << "Failed to get energy calib tool: \"" << toolName << "\"" 
                                << endreq;
                        return StatusCode::FAILURE;
      }
      m_CoTool = calibTool;
          
      // Get backgrounds Tool
      toolName = "Background";
      calibTool = 0;
       try {
                        calibTool = tool<IEnergyCalibTool>(toolName);
       }
      catch(const GaudiException& exg) {
                        fatal() << "Failed to get energy calib tool: \"" << toolName << "\"" 
                                << endreq;
                        return StatusCode::FAILURE;
      }
      m_Background = calibTool;
          
          // Get ScinBall energy tool for AD3 Dry Run
          toolName = "ScinBall";
      calibTool = 0;
       try {
                        calibTool = tool<IEnergyCalibTool>(toolName);
       }
      catch(const GaudiException& exg) {
                        fatal() << "Failed to get energy calib tool: \"" << toolName << "\"" 
                                << endreq;
                        return StatusCode::FAILURE;
      }
      m_ScinBall = calibTool;
        toolName = "Spallation";
      calibTool = 0;
       try {
                        calibTool = tool<IEnergyCalibTool>(toolName);
       }
      catch(const GaudiException& exg) {
                        fatal() << "Failed to get energy calib tool: \"" << toolName << "\""
                                << endreq;
                        return StatusCode::FAILURE;
      }
      m_Spallation = calibTool;  
  return StatusCode::SUCCESS;
}
StatusCode CalibEnergyAlg::execute ( ) [virtual]

Definition at line 120 of file CalibEnergyAlg.cc.

{
  debug() << "calling execute()" << endreq; 
  // Get input header
  DayaBay::CalibReadoutHeader* calibReadoutHeader = get<DayaBay::CalibReadoutHeader>(m_calibReadoutLocation);
  if(!m_setACU){ 
         int task = 0;
         ServiceMode serviceMode(calibReadoutHeader->context(), task);
         if (first&&(0 != m_daqDetailsSvc->calibDetailsCount(serviceMode))) {
               const DaqCalibDetails& calibDetails = m_daqDetailsSvc->calibDetails(1,serviceMode);
             int aType =calibDetails.sourceIdA();
             int zPositionA = calibDetails.zPositionA();
             int bType =calibDetails.sourceIdB();
             int zPositionB = calibDetails.zPositionB();
                 int cType =calibDetails.sourceIdC();
             int zPositionC = calibDetails.zPositionC();
             if(zPositionB>3000&&zPositionC>3000) { m_sourcetype = aType; m_acu = 1; m_zpo = zPositionA;}
              else if(zPositionA>3000&&zPositionC>3000) { m_sourcetype = bType; m_acu = 2; m_zpo = zPositionB;}
          else if(zPositionB>3000&&zPositionA>3000) { m_sourcetype = cType; m_acu = 3; m_zpo = zPositionC;}
           else {m_acu = 1; m_zpo = 0;m_sourcetype=0;}
           
           if(m_sourcetype==2) m_sourceName="CoAmC";
           else if(m_sourcetype==3) m_sourceName="Ge";
           else m_sourceName="Background";
        cout<<"From daq info: "<<' '<<aType<<' '<<zPositionA<<' '<<bType<<' '<<zPositionB<<' '<<cType<<' '<<zPositionC<<' '<<m_acu<<endl;
                 }
    }
     
   if(exist<HeaderObject>("/Event/Readout/ReadoutHeader")) {
    ReadoutHeader* roh = get<ReadoutHeader>("/Event/Readout/ReadoutHeader");
    const DaqCrate* daqCrate = roh->daqCrate();
    //const DaqPmtCrate* pmtCrate = daqCrate->asPmtCrate();
    m_calibRun = daqCrate->runNumber();
  }

   TimeStamp trigTime = calibReadoutHeader->timeStamp();
  
  if(first) {
    m_beginTime = trigTime;
    first = false;
  }
  m_endTime = trigTime; 
    
  DayaBay::Detector det(calibReadoutHeader->context().GetSite(),
                        calibReadoutHeader->context().GetDetId());
  debug() << "Got calibReadout from " << det.detName() <<" id= "
         << det.siteDetPackedData() <<endreq;
  
  if(m_sourceName == "Ge"){
    // Loop over each PMT calibration tool
     StatusCode sc = m_GeTool->process(*calibReadoutHeader ,m_sourcetype , m_acu, m_zpo);
      if( sc != StatusCode::SUCCESS ) return sc;
  }else if(m_sourceName == "CoAmC"){
     StatusCode sc = m_CoTool->process(*calibReadoutHeader ,m_sourcetype , m_acu, m_zpo);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
    else if(m_sourceName == "Background"){
     StatusCode sc = m_Background->process(*calibReadoutHeader ,m_sourcetype , m_acu, m_zpo);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
        else if(m_sourceName == "ScinBall"){
     StatusCode sc = m_ScinBall->process(*calibReadoutHeader ,m_sourcetype , m_acu, m_zpo);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
         else if(m_sourceName == "Spallation"){
     StatusCode sc = m_Spallation->process(*calibReadoutHeader ,m_sourcetype , m_acu, m_zpo);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
  else{
    error() << "Unknown source name " << m_sourceName << endreq; 
    info() << "I am ignoring for now! " << endreq;//tmp
    return StatusCode::SUCCESS;//tmp
  }
  
  return StatusCode::SUCCESS;
}
StatusCode CalibEnergyAlg::finalize ( ) [virtual]

Definition at line 201 of file CalibEnergyAlg.cc.

{
  // Run calibration calculations for each tool
  float TimeInterval = m_endTime.GetSec() - m_beginTime.GetSec() + (m_endTime.GetNanoSec() - m_beginTime.GetNanoSec())/1.0e9;
    if(m_sourceName == "Ge"){
     StatusCode sc = m_GeTool->calibrate(TimeInterval ,m_sourcetype , m_acu, m_zpo,m_calibRun);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
    
  else if(m_sourceName == "CoAmC"){
 
     StatusCode sc = m_CoTool->calibrate(TimeInterval ,m_sourcetype , m_acu, m_zpo,m_calibRun);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
    else if(m_sourceName == "Background"){
     StatusCode sc = m_Background->calibrate(TimeInterval ,m_sourcetype , m_acu, m_zpo,m_calibRun);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
        else if(m_sourceName == "ScinBall"){
     StatusCode sc = m_ScinBall->calibrate(TimeInterval ,m_sourcetype , m_acu, m_zpo,m_calibRun);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
else if(m_sourceName == "Spallation"){
     StatusCode sc = m_Spallation->calibrate(TimeInterval ,m_sourcetype , m_acu, m_zpo,m_calibRun);
      if( sc != StatusCode::SUCCESS ) return sc;
    }
        else{
    error() << "Unknown source name " << m_sourceName << endreq; 
    info() << "I am ignoring for now! " << endreq;//tmp
    //return StatusCode::FAILURE;//tmp !! quick fix by jpochoa, temporary! See track ticket #737
    return StatusCode::SUCCESS;//tmp
  }

  info()<<"First trigger time: "<<m_beginTime.GetSec()<<" sec "<<m_beginTime.GetNanoSec()<<" nanoSec"<<endreq;
  info()<<"Last trigger time:  "<<m_endTime.GetSec()<<" sec "<<m_endTime.GetNanoSec()<<" nanoSec"<<endreq;

  return this->GaudiAlgorithm::finalize();
}

Member Data Documentation

std::string CalibEnergyAlg::m_readoutLocation [private]

Property ReadoutLocation - location in TES where the input ReadoutHeader is to be found.

Default is DayaBay::ReadoutHeader::Default

Definition at line 38 of file CalibEnergyAlg.h.

std::vector<std::string> CalibEnergyAlg::m_energyToolNames [private]

Definition at line 40 of file CalibEnergyAlg.h.

Definition at line 42 of file CalibEnergyAlg.h.

std::string CalibEnergyAlg::m_sourceName [private]

Definition at line 44 of file CalibEnergyAlg.h.

bool CalibEnergyAlg::first [private]

Definition at line 45 of file CalibEnergyAlg.h.

Definition at line 46 of file CalibEnergyAlg.h.

Definition at line 47 of file CalibEnergyAlg.h.

Definition at line 48 of file CalibEnergyAlg.h.

Definition at line 49 of file CalibEnergyAlg.h.

Definition at line 50 of file CalibEnergyAlg.h.

Definition at line 52 of file CalibEnergyAlg.h.

Definition at line 53 of file CalibEnergyAlg.h.

Definition at line 54 of file CalibEnergyAlg.h.

int CalibEnergyAlg::m_acu [private]

Definition at line 54 of file CalibEnergyAlg.h.

int CalibEnergyAlg::m_zpo [private]

Definition at line 54 of file CalibEnergyAlg.h.

Definition at line 55 of file CalibEnergyAlg.h.

bool CalibEnergyAlg::m_setACU [private]

Definition at line 56 of file CalibEnergyAlg.h.

Definition at line 57 of file CalibEnergyAlg.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 10:03:20 for CalibEnergy by doxygen 1.7.4