/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 | Protected Member Functions | Protected Attributes | Private Attributes
ADSingleData Class Reference

#include <ADSingleData.h>

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

List of all members.

Public Member Functions

 ADSingleData (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~ADSingleData ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
DayaBay::UserDataHeaderGetCurrentHeaderObject () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysExecute ()
virtual StatusCode preExecute ()
virtual StatusCode postExecute ()
virtual StatusCode sysFinalize ()
IDataProviderSvc * arcSvc () const
void putTES (DataObject *obj, std::string location) const
TYPE * getTES (std::string location) const
TYPE * getAES (std::string location, int index) const
std::vector< DataObject * > getAEScollection (std::string location) const
int getExecNum ()
std::string Location () const

Protected Member Functions

DayaBay::UserDataHeaderMakeHeaderObject ()
void InitializeHeader (DayaBay::HeaderObject *header)
TYPE * MakeHeader ()
TYPE * MakeHeader (std::vector< const DayaBay::IHeader * > &inputHeaders)
TYPE * MakeHeader (const DayaBay::IHeader *referenceHeader)
void AppendInputHeader (const DayaBay::HeaderObject *header) const

Protected Attributes

DayaBay::HeaderObjectm_headerObject
bool m_pullMode
std::string m_location

Private Attributes

IJobInfoSvcm_jobInfoSvc
IDataProviderSvc * m_archiveSvc
string m_AdsingleTagLoc
int m_count
bool m_applyMLRec
std::vector< std::string > m_reconToolNames
std::vector< IReconTool * > m_reconTools

Detailed Description

Definition at line 24 of file ADSingleData.h.


Constructor & Destructor Documentation

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

Definition at line 27 of file ADSingleData.cc.

: DybAlgorithm<DayaBay::UserDataHeader>(name,pSvcLocator)
{
  declareProperty("ADSingleTag_location", m_AdsingleTagLoc, 
      "Path for ADSingle tag");
  declareProperty("ApplyMLRec", m_applyMLRec = false);
  declareProperty("ReconTools", m_reconToolNames,
      "List of Reconstruction tools");

}
ADSingleData::~ADSingleData ( ) [virtual]

Definition at line 38 of file ADSingleData.cc.

{
}

Member Function Documentation

StatusCode ADSingleData::initialize ( ) [virtual]

Definition at line 42 of file ADSingleData.cc.

{
  debug() << "initialize()" << endreq;

  m_jobInfoSvc = svc<IJobInfoSvc>("JobInfoSvc",true);
  if(!m_jobInfoSvc) {
    error() << "Failed to initialize JobInfoSvc" << endreq;
    return StatusCode::FAILURE;
  }

  //Get Archive Svc
  StatusCode status = service("EventDataArchiveSvc", m_archiveSvc);
  if (status.isFailure()) {
    Error("Service [EventDataArchiveSvc] not found", status);
    return status;
  }

  // Setup reconstruction styles and get tools
  for(unsigned int toolIdx = 0; toolIdx < m_reconToolNames.size(); toolIdx++){
    std::string toolName = m_reconToolNames[toolIdx];
    IReconTool* currentTool = 0;
    try {
      currentTool = tool<IReconTool>(toolName);
    }
    catch(const GaudiException& exg) {
      fatal() << "Failed to get Recon tool: \"" << toolName << "\"" << endreq;
      return StatusCode::FAILURE;
    }
    m_reconTools.push_back(currentTool);
    info() << "Added recon tool " << toolName << endreq;
  }

  m_count=0;

  return StatusCode::SUCCESS;
}
StatusCode ADSingleData::execute ( ) [virtual]

Definition at line 79 of file ADSingleData.cc.

{
  debug() << "execute() ______________________________ start" << endreq;

  // Get tagged single recHeader
  if(!exist<HeaderObject>(m_AdsingleTagLoc)) {
    return StatusCode::SUCCESS;
  }

  HeaderObject *ADSingleTag = get<HeaderObject>(m_AdsingleTagLoc);
  if(!ADSingleTag) {
    error() << "Get no ADSingleTag from TES." << endreq;
    return StatusCode::FAILURE;
  }

  const std::vector<const DayaBay::IHeader*>& recHeaderList = ADSingleTag->inputHeaders();

  // For singleTag, only one recHeader in each inputHeaders.
  const RecHeader* recHeader = dynamic_cast<const RecHeader*> (recHeaderList[0]);
  if(!recHeader) {
    error() << "Get no recHeader from NeutronSpTag!!" << endreq;
    return StatusCode::FAILURE;
  }
float singlenPESum=0, singlenPMax=0,singleRMS=0;
 
  // Create output user data header
  UserDataHeader* ADsingleData = MakeHeaderObject();

  // Copy from the recHeader
  ADsingleData->setExecNumber(recHeader->execNumber());
  ADsingleData->setContext(recHeader->context());
  ADsingleData->setEarliest(recHeader->earliest());
  ADsingleData->setLatest(recHeader->latest());


  // Get job id
  const DayaBay::JobId &m_currentJobId = m_jobInfoSvc->currentJobInfo()->jobId();
  ADsingleData->setJobId(m_currentJobId);

  float energy=recHeader->recTrigger().energy();
  float triggerType=recHeader->recTrigger().triggerType();
  float x=recHeader->recTrigger().position().x();
  float y=recHeader->recTrigger().position().y();
  float z=recHeader->recTrigger().position().z();
  TimeStamp trigTime(recHeader->timeStamp());
  int trigTimeSec=trigTime.GetSec();
  int trigTimeNanoSec=trigTime.GetNanoSec();
  int detectorId = recHeader->context().GetDetId();

  //  int muonTimeSec=0;
  //  int muonTimeNanoSec=0;
  float deltaT = 0;
  /*
  //Get muon list         
  SmartDataPtr<DybArchiveList>  muonlist(m_archiveSvc, m_muonloc);
  if(muonlist)
  {
  debug() << "Number of muon in the ArchiveList: " << muonlist->size() << endreq;
  }
  else
  {
  error() << "No MuonList for NeutronSpTag event?!" << endreq;
  return StatusCode::FAILURE;
  }
  DybArchiveList::const_iterator iter = muonlist->begin();
  for(; iter!=muonlist->end(); iter++)
  {
  HeaderObject* muonTag = dynamic_cast<HeaderObject*>(*iter);
  int muonDetId = muonTag->context().GetDetId();
  if(muonDetId==detectorId)
  {
  TimeStamp muonTime(muonTag->timeStamp());
  muonTimeSec=muonTime.GetSec();
  muonTimeNanoSec=muonTime.GetNanoSec();
  TimeStamp currentTime(recHeader->timeStamp());
  currentTime.Subtract(muonTime);
  deltaT = currentTime.GetSeconds();
  debug() << "DeltaT: " << deltaT << endreq;
  break;
  }
  }
  */
const std::vector<const IHeader*> &calibstats = ADSingleTag->findHeaders(UserDataHeader::classID());
      UserDataHeader* singleClbStsHdr = 0;

      for(unsigned int i = 0; i < calibstats.size(); i++) {
        IHeader* iHeader = const_cast<IHeader*>(calibstats[i]);
        UserDataHeader* header = dynamic_cast<UserDataHeader*>(iHeader);
        debug() << header->name() << ", " << header->context() << endreq;
        if(header->name()!="/CalibStats") continue;
        if(header->context().GetDetId() == detectorId) {
          singleClbStsHdr = header;
          break;
        }
      }
if(singleClbStsHdr) {
        singlenPESum = singleClbStsHdr->getFloat("nPESum");
         singlenPMax = singleClbStsHdr->getFloat("nPEMax");
        singleRMS = singleClbStsHdr->getFloat("tRMS");
        debug() << "nPESum: " << singlenPESum <<"PEMax "<<singlenPMax<< endreq;
      }

  debug()<<"energy:"<<energy<<";x:"<<x<<";y:"<<y<<";z:"<<z<<";timeToMuon:"<<deltaT<<";detectorId:"<<detectorId<<endreq;

  // Fill user data
  ADsingleData->set("energy", energy);
  ADsingleData->set("triggerType", triggerType);
  ADsingleData->set("x", x);
  ADsingleData->set("y", y);
  ADsingleData->set("z", z);
  ADsingleData->set("trigTimeSec", trigTimeSec);
  ADsingleData->set("trigTimeNanoSec", trigTimeNanoSec);
  ADsingleData->set("singlenPESum", singlenPESum);
  ADsingleData->set("detectorId", detectorId);
  ADsingleData->set("singlenPMax", singlenPMax);
  ADsingleData->set("singleRMS", singleRMS);
  //  ADsingleData->set("muonTimeNanoSec", muonTimeNanoSec);


  // Apply Maximum Likelyhood reconstruction to AD singles
  if(m_applyMLRec) {
    const std::vector<const IHeader*> &ihs = ADSingleTag->findHeaders(CalibReadoutHeader::classID());
    if(ihs.size() != 1) {
      error() << "Find no or more than one CalibReadoutHeader for AD singles." << endreq;
      return StatusCode::FAILURE;
    } 

    IHeader* iHeader = const_cast<IHeader*>(ihs[0]);
    CalibReadoutHeader *crh = dynamic_cast<CalibReadoutHeader*>(iHeader);
    const DayaBay::CalibReadout* calibReadout = crh->calibReadout();
    if(!calibReadout) {
      info() << "Can't find CalibReadout." << endreq;
      return StatusCode::FAILURE;
    }

    // Run the recon tools
    RecTrigger mlrec;
    for(unsigned int toolIdx = 0; toolIdx < m_reconTools.size(); toolIdx++){
      StatusCode sc = m_reconTools[toolIdx]->reconstruct(*calibReadout, mlrec);
      if(sc != StatusCode::SUCCESS) return sc;
    }

    // Fill ML results to user data
    ADsingleData->set("mlenergy", (float)mlrec.energy());
    ADsingleData->set("mlx", (float)mlrec.position().x());
    ADsingleData->set("mly", (float)mlrec.position().y());
    ADsingleData->set("mlz", (float)mlrec.position().z());
  }

  m_count++;
  debug() << "execute() ______________________________ end" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode ADSingleData::finalize ( ) [virtual]

Definition at line 233 of file ADSingleData.cc.

{
  debug() << "finalize()" << endreq;
  info() << "Summary: UserData ADSingleData : "<< m_count <<" events data filled."<< endreq;
  return StatusCode::SUCCESS;
}
DayaBay::UserDataHeader * DybAlgorithm< DayaBay::UserDataHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::preExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::postExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysFinalize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

IDataProviderSvc * DybAlgorithm< DayaBay::UserDataHeader >::arcSvc ( ) const [inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::UserDataHeader >::putTES ( DataObject *  obj,
std::string  location 
) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::getTES ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::getAES ( std::string  location,
int  index 
) const [inherited]

Reimplemented from DybBaseAlg.

std::vector< DataObject * > DybAlgorithm< DayaBay::UserDataHeader >::getAEScollection ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

int DybAlgorithm< DayaBay::UserDataHeader >::getExecNum ( ) [inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::UserDataHeader >::Location ( ) const [inherited]

Reimplemented from DybBaseAlg.

DayaBay::UserDataHeader * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeaderObject ( ) [protected, inherited]
void DybAlgorithm< DayaBay::UserDataHeader >::InitializeHeader ( DayaBay::HeaderObject header) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( ) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( std::vector< const DayaBay::IHeader * > &  inputHeaders) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( const DayaBay::IHeader referenceHeader) [protected, inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::UserDataHeader >::AppendInputHeader ( const DayaBay::HeaderObject header) const [protected, inherited]

Reimplemented from DybBaseAlg.


Member Data Documentation

Reimplemented from DybBaseAlg.

Definition at line 35 of file ADSingleData.h.

IDataProviderSvc* ADSingleData::m_archiveSvc [private]

Definition at line 36 of file ADSingleData.h.

Definition at line 37 of file ADSingleData.h.

int ADSingleData::m_count [private]

Definition at line 38 of file ADSingleData.h.

Definition at line 40 of file ADSingleData.h.

std::vector<std::string> ADSingleData::m_reconToolNames [private]

Definition at line 43 of file ADSingleData.h.

std::vector<IReconTool*> ADSingleData::m_reconTools [private]

Definition at line 45 of file ADSingleData.h.

Reimplemented from DybBaseAlg.

bool DybAlgorithm< DayaBay::UserDataHeader >::m_pullMode [protected, inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::UserDataHeader >::m_location [protected, inherited]

Reimplemented from DybBaseAlg.


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:11:36 for ADSinglesTagging by doxygen 1.7.4