/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 | Public Attributes | Private Member Functions | Private Attributes
DybDetCalibSvc Class Reference

#include <DybDetCalibSvc.h>

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

List of all members.

Public Member Functions

 DybDetCalibSvc (const std::string &name, ISvcLocator *svc)
virtual ~DybDetCalibSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
virtual int readEnergyReconTable (const ServiceMode &)
const DayaBay::DetEnergyReconDatadetEnergyReconData (const ServiceMode &svcMode)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Public Attributes

std::map< ServiceMode,
DayaBay::DetEnergyReconData
m_detEnergyReconData
std::map< ServiceMode,
DbiResultKey
m_detEnergyReconKeys

Private Member Functions

ServiceMode CopyWithBOT (const ServiceMode &svcMode)

Private Attributes

ServiceMode energyReconLastSM

Detailed Description

Definition at line 19 of file DybDetCalibSvc.h.


Constructor & Destructor Documentation

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

Definition at line 18 of file DybDetCalibSvc.cc.

    : Service(name,svc)
{

}
DybDetCalibSvc::~DybDetCalibSvc ( ) [virtual]

Definition at line 23 of file DybDetCalibSvc.cc.

{
}

Member Function Documentation

StatusCode DybDetCalibSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

Definition at line 27 of file DybDetCalibSvc.cc.

{
    StatusCode sc = StatusCode::FAILURE;
    if (ppvInterface) {
        *ppvInterface = 0;
    
        if (IDetCalibSvc::interfaceID().versionMatch(riid)) {
            *ppvInterface = static_cast<IDetCalibSvc*>(this);
            sc = StatusCode::SUCCESS;
            addRef();
        }
        else sc = Service::queryInterface( riid, ppvInterface );    
    }
    return sc;
}
int DybDetCalibSvc::readEnergyReconTable ( const ServiceMode serviceMode) [inline, virtual]

Definition at line 60 of file DybDetCalibSvc.cc.

                                                                             {
  
  

  //If same context as previous call don't even sweat it
  if(serviceMode.context() == energyReconLastSM.context() && serviceMode.task() == energyReconLastSM.task()){      
    return 3;    
  }
  energyReconLastSM=serviceMode;
  
  //Check if result is already stored in cache; if not, create it
  ServiceMode mysm = CopyWithBOT(serviceMode);
  DbiResultPtr<GEnergyRecon> pr("EnergyRecon",serviceMode.context(),serviceMode.context().GetDetId(),serviceMode.task());
  DbiResultKey thisResult  = *(pr.GetKey());
  
  if(m_detEnergyReconKeys.find(mysm)!=m_detEnergyReconKeys.end() && thisResult.IsEqualTo(&m_detEnergyReconKeys[mysm])){
    return 2;//<-- nothing to be done; result is already in cache
  } else{
    MsgStream log(msgSvc());
    //Read the DB table
    //-->Results will be stored in this object (don't need vector, as only one set of constants for each detector+task, for each context). 
    DayaBay::DetEnergyReconData enrecdat;
    // --> Check number of entries in result set
    unsigned int numRows = pr.GetNumRows();
    if(numRows!=0) log << MSG::INFO << "Database rows = " << numRows << endreq;
    if(numRows>1){
      log << MSG::WARNING << "Got more than one row for EnergyRecon table when queried with task " << serviceMode.task() << " and context " << serviceMode.context().AsString() << "This service will only return the last one to user." << endreq;
    }
    if(numRows<=0) {
    //  log << MSG::WARNING << "Found no entries in EnergyRecon for task " << serviceMode.task() << " and context " << serviceMode.context().AsString() << endreq;
      return 0;
    }
    const GEnergyRecon* row ;
    // --> Read table
    for (unsigned int idx=0; idx < numRows; idx++) {
      row = pr.GetRowByIndex(idx);   
      enrecdat.m_PeEvis = row->GetPeEvis();
      enrecdat.m_PeEvisUnc = row->GetPeEvisUnc();
          
    }
    m_detEnergyReconData[mysm]=enrecdat;
    m_detEnergyReconKeys[mysm]=thisResult;

  }

  return 1;
  
}//end of readEnergyReconTable
const DayaBay::DetEnergyReconData * DybDetCalibSvc::detEnergyReconData ( const ServiceMode svcMode) [virtual]

Implements IDetCalibSvc.

Definition at line 46 of file DybDetCalibSvc.cc.

                                                                                    {

  int outcome=readEnergyReconTable(svcMode);
  ServiceMode mysm = CopyWithBOT(svcMode);
  std::map<ServiceMode, DayaBay::DetEnergyReconData>::iterator result = 
    m_detEnergyReconData.find(mysm);
  if(result != m_detEnergyReconData.end() && outcome!=0){
    return &(result->second);
  }
  return 0;
}
ServiceMode DybDetCalibSvc::CopyWithBOT ( const ServiceMode svcMode) [private]

Definition at line 112 of file DybDetCalibSvc.cc.

                                                                 {
  
  Context ctx = svcMode.context();
  ctx.SetTimeStamp(TimeStamp::GetBOT());
  ServiceMode mysm(ctx,svcMode.task());
  return mysm;
  
}

Member Data Documentation

Definition at line 36 of file DybDetCalibSvc.h.

Definition at line 37 of file DybDetCalibSvc.h.

Definition at line 46 of file DybDetCalibSvc.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:00:00 for DybMetaDataSvc by doxygen 1.7.4