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

#include <QsumLinearityEnergyTool.h>

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

List of all members.

Public Member Functions

 QsumLinearityEnergyTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~QsumLinearityEnergyTool ()
virtual StatusCode reconstruct (const DayaBay::CalibReadout &readout, DayaBay::RecTrigger &recTrigger)
virtual StatusCode initialize ()
virtual StatusCode finalize ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Attributes

std::string m_cableSvcName
ICableSvcm_cableSvc
std::string m_calibDataSvcName
ICalibDataSvcm_calibDataSvc
std::string m_recDataSvcName
IDetCalibSvcm_recDataSvc

Detailed Description

Definition at line 27 of file QsumLinearityEnergyTool.h.


Constructor & Destructor Documentation

QsumLinearityEnergyTool::QsumLinearityEnergyTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 16 of file QsumLinearityEnergyTool.cc.

  : GaudiTool(type,name,parent)
  , m_cableSvc(0)
  , m_calibDataSvc(0)
{
    declareInterface< IReconTool >(this) ;   
    declareProperty("CableSvcName",m_cableSvcName="CableSvc",
                    "Name of service to map between detector, hardware, and electronic IDs");
    declareProperty("CalibDataSvcName", m_calibDataSvcName="CalibDataSvc",
                    "Name of calibration data service");
    declareProperty("RecDataSvcName", m_recDataSvcName="DybDetCalibSvc",
                    "Name of calibration data service");
}
QsumLinearityEnergyTool::~QsumLinearityEnergyTool ( ) [virtual]

Definition at line 32 of file QsumLinearityEnergyTool.cc.

{}

Member Function Documentation

StatusCode QsumLinearityEnergyTool::reconstruct ( const DayaBay::CalibReadout readout,
DayaBay::RecTrigger recTrigger 
) [virtual]

Implements IReconTool.

Definition at line 49 of file QsumLinearityEnergyTool.cc.

{
  if( !readout.detector().isAD() ){
    debug() << "Not an AD readout; ignoring detector " 
            << readout.detector().detName() << endreq;
    recTrigger.setEnergyStatus( ReconStatus::kNotProcessed );
    return StatusCode::SUCCESS;
  }

  const CalibReadoutPmtCrate* pmtReadout 
    = dynamic_cast<const CalibReadoutPmtCrate*>(&readout);
  if(!pmtReadout){
    error() << "Incorrect type of readout crate for detector "
            << readout.detector().detName() << endreq;
    recTrigger.setEnergyStatus( ReconStatus::kBadReadout );
    return StatusCode::FAILURE;
  }

  // Context for this data
  int task = 0;
  ServiceMode svcMode(readout.header()->context(), task);
  const DayaBay::DetEnergyReconData* srcEn = m_recDataSvc->detEnergyReconData(svcMode);

  // Loop over hits and add up charge
  double qSum = 0;
  double qSquareSum = 0;
  int nHits = 0;
  CalibReadoutPmtCrate::PmtChannelReadouts::const_iterator chanIter, 
    chanEnd = pmtReadout->channelReadout().end();
  for(chanIter=pmtReadout->channelReadout().begin(); chanIter != chanEnd; 
      chanIter++){
    const CalibReadoutPmtChannel& channel = *chanIter;
    AdPmtSensor pmtId(channel.pmtSensorId().fullPackedData());
    //AdPmtSensor pmtId = m_cableSvc->adPmtSensor(channel.channelId(), svcMode);
    if( pmtId.ring()<1 ){ continue; }  // Ignore calibration pmts
    const PmtCalibData* pmtCalib = m_calibDataSvc->pmtCalibData(pmtId, svcMode);
    if( !pmtCalib ){ 
      error() << "No calibration data for pmt ID: " << pmtId << endreq;
      recTrigger.setEnergyStatus( ReconStatus::kBadReadout );
      return StatusCode::FAILURE;
    }
    if( pmtCalib->m_status != PmtCalibData::kGood ) { continue; }
    double peakAdc = channel.maxCharge();
    qSum += peakAdc;
    qSquareSum += peakAdc*peakAdc;
    nHits++;
  }

  if(nHits<1){
    recTrigger.setEnergyStatus( ReconStatus::kNoHits );
    return StatusCode::SUCCESS;
  }

        //the next constant value is based on the results of DYB-doc-4061
  //PE=133.1*Energy-10.7
  double indexPEtoEnergy = srcEn->m_PeEvis;
  double interceptOfLinearity=10.7; // the intercept of the linearity fitting;
                                                                                                                                                //FIXME: add to calibration data service
  double energy = (qSum +interceptOfLinearity)/ indexPEtoEnergy;

  
  recTrigger.setEnergy( energy );
  // Set quality to standard deviation of hits
  recTrigger.setEnergyQuality(sqrt((qSquareSum - qSum*qSum/nHits)/(nHits-1)));
  recTrigger.setEnergyStatus( ReconStatus::kGood );

  return StatusCode::SUCCESS;
}
StatusCode QsumLinearityEnergyTool::initialize ( ) [virtual]

Definition at line 34 of file QsumLinearityEnergyTool.cc.

{
  // Get Cable Service
  m_cableSvc = svc<ICableSvc>(m_cableSvcName,true);
  m_calibDataSvc = svc<ICalibDataSvc>(m_calibDataSvcName,true);
  m_recDataSvc = svc<IDetCalibSvc>(m_recDataSvcName,true);

  return StatusCode::SUCCESS;
}
StatusCode QsumLinearityEnergyTool::finalize ( ) [virtual]

Definition at line 44 of file QsumLinearityEnergyTool.cc.

{
  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 45 of file QsumLinearityEnergyTool.h.

Definition at line 48 of file QsumLinearityEnergyTool.h.

Definition at line 51 of file QsumLinearityEnergyTool.h.

Definition at line 54 of file QsumLinearityEnergyTool.h.

Definition at line 56 of file QsumLinearityEnergyTool.h.

Definition at line 59 of file QsumLinearityEnergyTool.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:13:10 for QsumLinearityEnergy by doxygen 1.7.4