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

#include <CalibReadoutEventCnv.h>

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

List of all members.

Public Member Functions

 CalibReadoutHeaderCnv (ISvcLocator *svc)
virtual ~CalibReadoutHeaderCnv ()
StatusCode PerToTran (const PerCalibReadoutHeader &perobj, DayaBay::CalibReadoutHeader &tranobj)
 Copy data from TObject based class of type TType to DataObject based class of type DOType.
StatusCode TranToPer (const DayaBay::CalibReadoutHeader &tranobj, PerCalibReadoutHeader &perobj)
 Copy data from DataObject based class of type DOType to TObject based class of type TType.
StatusCode fillRepRefs (IOpaqueAddress *addr, DataObject *dobj)
StatusCode fillObjRefs (IOpaqueAddress *addr, DataObject *dobj)
PerType & getPerInputObject ()
PerType & getPerOutputObject ()
const RootIOBaseObjectgetBaseInputObject ()
const RootIOBaseObjectgetBaseOutputObject ()
virtual StatusCode PerToTran (const PerType &pobj, TranType &tobj)=0
virtual StatusCode TranToPer (const TranType &tobj, PerType &pobj)=0
virtual StatusCode TranObjectToPerObject (DataObject &dat, const RootOutputAddress &)
virtual StatusCode PerObjectToTranObject (DataObject *&dat)
virtual RootInputStreammakeInputStream (const RootInputAddress &ria)
virtual RootOutputStreammakeOutputStream (const RootOutputAddress &ria)
virtual long repSvcType () const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
int commit (const RootOutputAddress &roa)
RootIOBaseCnvotherConverter (int clID)

Static Public Member Functions

static const CLID & classID ()
static unsigned char storageType ()
static const InterfaceID & interfaceID ()

Protected Attributes

std::string m_perclassName
PerType * m_perInObj
PerType * m_perOutObj
IRootIOSvcm_rioSvc
IConversionSvc * m_cnvSvc
RootInputStreamm_ris

Detailed Description

Definition at line 25 of file CalibReadoutEventCnv.h.


Constructor & Destructor Documentation

CalibReadoutHeaderCnv::CalibReadoutHeaderCnv ( ISvcLocator *  svc)

Definition at line 11 of file CalibReadoutEventCnv.cc.

      : RootIOTypedCnv<PerCalibReadoutHeader,CalibReadoutHeader>(
                                                       "PerCalibReadoutHeader",
                                                       classID(),svc)
{
}
CalibReadoutHeaderCnv::~CalibReadoutHeaderCnv ( ) [virtual]

Definition at line 19 of file CalibReadoutEventCnv.cc.

{
}

Member Function Documentation

static const CLID& CalibReadoutHeaderCnv::classID ( ) [inline, static]

Definition at line 29 of file CalibReadoutEventCnv.h.

                               {
    return DayaBay::CLID_CalibReadoutHeader;
  }
StatusCode CalibReadoutHeaderCnv::PerToTran ( const PerCalibReadoutHeader perobj,
DayaBay::CalibReadoutHeader tranobj 
)

Copy data from TObject based class of type TType to DataObject based class of type DOType.

Definition at line 23 of file CalibReadoutEventCnv.cc.

{
  MsgStream log(msgSvc(), "CalibReadoutHeaderCnv::PerToTran");
  StatusCode sc = HeaderObjectCnv::toTran(perobj,tranobj);
  if (sc.isFailure()) return sc;

  delete tranobj.calibReadout();
  if(perobj.site){
    CalibReadout* readout = 0;
    Detector detector(Site::Site_t(perobj.site),
                      DetectorId::DetectorId_t(perobj.detector));
    if(detector.isAD() || detector.isWaterShield()){ 
      CalibReadoutPmtCrate *out_crate = new CalibReadoutPmtCrate();
      readout = out_crate;
      out_crate->setDetector(detector);
      out_crate->setTriggerType( Trigger::TriggerType_t(perobj.triggerType) );
      out_crate->setTriggerNumber( perobj.triggerNumber );
      timespec value = {perobj.triggerTimeSec,perobj.triggerTimeNanoSec};
      TimeStamp tstamp(value);
      out_crate->setTriggerTime(tstamp);
      
      CalibReadoutPmtCrate::PmtChannelReadouts out_channels;
      
      CalibReadoutPmtChannel* out_channel = 0;
      vector<double> timeArr;
      vector<double> chargeArr;
      if(detector.isAD()){
        // Fill AD hits
        for(unsigned int hitIdx=0; hitIdx<perobj.nHitsAD; hitIdx++){
          AdPmtSensor pmtId(perobj.ring[hitIdx], perobj.column[hitIdx],
                            detector.site(),detector.detectorId());
          if(!out_channel || (pmtId!=out_channel->pmtSensorId())){
            if(out_channel){
              out_channel->setTime(timeArr);
              out_channel->setCharge(chargeArr);
            }
            // create channel
            timeArr.clear();
            chargeArr.clear();
            CalibReadoutPmtChannel cur_channel(pmtId,out_crate);
            out_channels.push_back(cur_channel);
            out_channel=&(out_channels[out_channels.size()-1]);
          }
          timeArr.push_back(perobj.timeAD[hitIdx]);
          chargeArr.push_back(perobj.chargeAD[hitIdx]);
        }
        // Catch 2-inch calibration PMTs
        for(unsigned int hitIdx=0; hitIdx<perobj.nHitsAD_calib; hitIdx++){
          AdPmtSensor pmtId(0/*ring==0 for calib PMTs*/, 
                            perobj.topOrBottom[hitIdx] 
                            + 2*(perobj.acuColumn[hitIdx]-1),
                            detector.site(),detector.detectorId());
          if(!out_channel || (pmtId!=out_channel->pmtSensorId())){
            if(out_channel){
              out_channel->setTime(timeArr);
              out_channel->setCharge(chargeArr);
            }
            // create channel
            timeArr.clear();
            chargeArr.clear();
            CalibReadoutPmtChannel cur_channel(pmtId,out_crate);
            out_channels.push_back(cur_channel);
            out_channel=&(out_channels[out_channels.size()-1]);
          }
          timeArr.push_back(perobj.timeAD_calib[hitIdx]);
          chargeArr.push_back(perobj.chargeAD_calib[hitIdx]);
        }
        // Catch last channel
        if(out_channel){
          out_channel->setTime(timeArr);
          out_channel->setCharge(chargeArr);
        }
      }else if(detector.isWaterShield()){
        // Fill Water Pool hits
        for(unsigned int hitIdx=0; hitIdx<perobj.nHitsPool; hitIdx++){
          PoolPmtSensor pmtId(perobj.wallNumber[hitIdx], 
                              perobj.wallSpot[hitIdx],
                              perobj.inwardFacing[hitIdx],
                              detector.site(),detector.detectorId());
          if(!out_channel || (pmtId!=out_channel->pmtSensorId())){
            if(out_channel){
              out_channel->setTime(timeArr);
              out_channel->setCharge(chargeArr);
            }
            // create channel
            timeArr.clear();
            chargeArr.clear();
            CalibReadoutPmtChannel cur_channel(pmtId,out_crate);
            out_channels.push_back(cur_channel);
            out_channel=&(out_channels[out_channels.size()-1]);
          }
          timeArr.push_back(perobj.timePool[hitIdx]);
          chargeArr.push_back(perobj.chargePool[hitIdx]);
        }
        // Catch last channel
        if(out_channel){
          out_channel->setTime(timeArr);
          out_channel->setCharge(chargeArr);
        }
      } 
      out_crate->setChannelReadout(out_channels);
      out_crate->setHeader( &tranobj );
    }else if(detector.detectorId() == DetectorId::kRPC){
      CalibReadoutRpcCrate *out_crate = new CalibReadoutRpcCrate();
      readout = out_crate;
      out_crate->setDetector(detector);
      out_crate->setTriggerType( Trigger::TriggerType_t(perobj.triggerType) );
      out_crate->setTriggerNumber( perobj.triggerNumber );
      timespec value = {perobj.triggerTimeSec,perobj.triggerTimeNanoSec};
      TimeStamp tstamp(value);
      out_crate->setTriggerTime(tstamp);

      CalibReadoutRpcCrate::RpcChannelReadouts out_channels;
      for(unsigned int hitIdx=0; hitIdx<perobj.nHitsRpc; hitIdx++){
        RpcSensor rpcId(perobj.rpcRow[hitIdx], 
            perobj.rpcColumn[hitIdx],
            perobj.rpcLayer[hitIdx],
            perobj.rpcStrip[hitIdx],
            detector.site(),detector.detectorId());
        CalibReadoutRpcChannel cur_channel(rpcId,out_crate, perobj.rpcFromRot[hitIdx]);
        out_channels.push_back(cur_channel);
      }
      out_crate->setChannelReadout(out_channels);
      out_crate->setHeader( &tranobj );
    }

    tranobj.setCalibReadout( readout );
  }else{
    // Header has no readout
    tranobj.setCalibReadout(0);
  }

  return StatusCode::SUCCESS;
}                                       
StatusCode CalibReadoutHeaderCnv::TranToPer ( const DayaBay::CalibReadoutHeader tranobj,
PerCalibReadoutHeader perobj 
)

Copy data from DataObject based class of type DOType to TObject based class of type TType.

Definition at line 159 of file CalibReadoutEventCnv.cc.

{
  MsgStream log(msgSvc(), "CalibReadoutHeaderCnv::TranToPer");
  StatusCode sc = HeaderObjectCnv::toPer(tranobj,perobj);
  if (sc.isFailure()) return sc;

  // Clear persistent object
  perobj.clear();

  const CalibReadout* readout = tranobj.calibReadout();
  if(!readout){
    return StatusCode::SUCCESS;
  }
  
  // Convert trigger information
  perobj.site = (unsigned int)(readout->detector().site());
  perobj.detector = (unsigned int)(readout->detector().detectorId());
  perobj.triggerNumber = readout->triggerNumber();
  perobj.triggerType = readout->triggerType();
  perobj.triggerTimeSec =readout->triggerTime().GetSec();
  perobj.triggerTimeNanoSec = readout->triggerTime().GetNanoSec();
  
  // Convert hit information
  if(readout->detector().detectorId() == DetectorId::kUnknown){
    // Unknown detector, skip
    ; 
  }else if( readout->detector().isAD() || readout->detector().isWaterShield() ){
    // PMT data conversion
    const CalibReadoutPmtCrate& pmtCrate = 
      dynamic_cast<const CalibReadoutPmtCrate&>(*readout);
    const CalibReadoutPmtCrate::PmtChannelReadouts& chReadouts 
      = pmtCrate.channelReadout();
    CalibReadoutPmtCrate::PmtChannelReadouts::const_iterator channelIter,
      channelDone=chReadouts.end();
    if(readout->detector().isAD()){
      // Loop over AD hits
      for(channelIter=chReadouts.begin();channelIter!=channelDone;
          ++channelIter){
        const CalibReadoutPmtChannel& channel = *channelIter;
        AdPmtSensor pmtId(channel.pmtSensorId().fullPackedData());
        unsigned int nHits = channel.size();
        if(pmtId.ring()==0){
          // Catch 2inch calibration PMTs, save separately
          for(unsigned int hitIdx=0; hitIdx<nHits; hitIdx++){
            perobj.timeAD_calib.push_back( channel.time(hitIdx) );
            perobj.chargeAD_calib.push_back( channel.charge(hitIdx) );
            perobj.hitCountAD_calib.push_back( hitIdx );
            perobj.topOrBottom.push_back( ((pmtId.column()+1)%2) + 1 );
            perobj.acuColumn.push_back( (pmtId.column()+1)/2 );
            perobj.nHitsAD_calib++;
          }
        }else{
          // 8inch AD PMT
          for(unsigned int hitIdx=0; hitIdx<nHits; hitIdx++){
            perobj.timeAD.push_back( channel.time(hitIdx) );
            perobj.chargeAD.push_back( channel.charge(hitIdx) );
            perobj.hitCountAD.push_back( hitIdx );
            perobj.ring.push_back( pmtId.ring() );
            perobj.column.push_back( pmtId.column() );
            perobj.nHitsAD++;
          }       
        }
      }
    }else if(readout->detector().isWaterShield()){
      // Loop over Water Pool hits
      for(channelIter=chReadouts.begin();channelIter!=channelDone;
          ++channelIter){
        const CalibReadoutPmtChannel& channel = *channelIter;
        PoolPmtSensor pmtId(channel.pmtSensorId().fullPackedData());
        unsigned int nHits = channel.size();
        for(unsigned int hitIdx=0; hitIdx<nHits; hitIdx++){
          perobj.timePool.push_back( channel.time(hitIdx) );
          perobj.chargePool.push_back( channel.charge(hitIdx) );
          perobj.hitCountPool.push_back( hitIdx );
          perobj.wallNumber.push_back( pmtId.wallNumber() );
          perobj.wallSpot.push_back( pmtId.wallSpot() );
          perobj.inwardFacing.push_back( pmtId.inwardFacing() );
          perobj.nHitsPool++;
        }
      }
    }
  }else{
    // RPC data conversion
    const CalibReadoutRpcCrate& rpcCrate = 
      dynamic_cast<const CalibReadoutRpcCrate&>(*readout);
    const CalibReadoutRpcCrate::RpcChannelReadouts& chReadouts 
      = rpcCrate.channelReadout();
    CalibReadoutRpcCrate::RpcChannelReadouts::const_iterator channelIter,
      channelDone=chReadouts.end();
    for(channelIter=chReadouts.begin();channelIter!=channelDone;
        ++channelIter){
      const CalibReadoutRpcChannel& channel = *channelIter;
      RpcSensor rpcId(channel.rpcSensorId().fullPackedData());
      perobj.rpcRow.push_back(rpcId.panelRow());
      perobj.rpcColumn.push_back(rpcId.panelColumn());
      perobj.rpcLayer.push_back(rpcId.layer());
      perobj.rpcStrip.push_back(rpcId.strip());
      perobj.rpcFromRot.push_back(channel.fromRot());
      perobj.nHitsRpc++;
    }
  }

  return StatusCode::SUCCESS;
}
StatusCode CalibReadoutHeaderCnv::fillRepRefs ( IOpaqueAddress *  addr,
DataObject *  dobj 
) [virtual]

Reimplemented from RootIOTypedCnv< PerCalibReadoutHeader, DayaBay::CalibReadoutHeader >.

Definition at line 266 of file CalibReadoutEventCnv.cc.

{
    MsgStream log(msgSvc(), "CalibReadoutHeaderCnv::fillRepRefs");
    CalibReadoutHeader* rh = dynamic_cast<CalibReadoutHeader*>(dobj);

    log << MSG::DEBUG
        << "Saving links to " << rh->inputHeaders().size() 
        << " input headers" << endreq;

    StatusCode sc = HeaderObjectCnv::fillPer(m_rioSvc,*rh,*m_perOutObj);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Failed to fill HeaderObject part" << endreq;
        return sc;
    }

    // ... fill CalibReadoutHeader part...
    return sc;
}
StatusCode CalibReadoutHeaderCnv::fillObjRefs ( IOpaqueAddress *  addr,
DataObject *  dobj 
) [virtual]

Reimplemented from RootIOTypedCnv< PerCalibReadoutHeader, DayaBay::CalibReadoutHeader >.

Definition at line 285 of file CalibReadoutEventCnv.cc.

{
    MsgStream log(msgSvc(), "CalibReadoutHeaderCnv::fillObjRefs");
    HeaderObject* hobj = dynamic_cast<HeaderObject*>(dobj);
    StatusCode sc = HeaderObjectCnv::fillTran(m_rioSvc,*m_perInObj,*hobj);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Failed to fill HeaderObject part" << endreq;
        return sc;
    }

    log << MSG::DEBUG
        << "Restored links to " << hobj->inputHeaders().size() 
        << " input headers" << endreq;

    // ... fill CalibReadoutHeader part...
    return sc;
}
PerType & RootIOTypedCnv< class, class >::getPerInputObject ( ) [inherited]
PerType & RootIOTypedCnv< class, class >::getPerOutputObject ( ) [inherited]
const RootIOBaseObject * RootIOTypedCnv< class, class >::getBaseInputObject ( ) [virtual, inherited]

Implements RootIOBaseCnv.

const RootIOBaseObject * RootIOTypedCnv< class, class >::getBaseOutputObject ( ) [virtual, inherited]

Implements RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< class, class >::PerToTran ( const PerType &  pobj,
TranType &  tobj 
) [pure virtual, inherited]
virtual StatusCode RootIOTypedCnv< class, class >::TranToPer ( const TranType &  tobj,
PerType &  pobj 
) [pure virtual, inherited]
virtual StatusCode RootIOTypedCnv< class, class >::TranObjectToPerObject ( DataObject &  dat,
const RootOutputAddress  
) [virtual, inherited]

Implements RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< class, class >::PerObjectToTranObject ( DataObject *&  dat) [virtual, inherited]

Implements RootIOBaseCnv.

virtual RootInputStream * RootIOTypedCnv< class, class >::makeInputStream ( const RootInputAddress ria) [virtual, inherited]

Implements RootIOBaseCnv.

virtual RootOutputStream * RootIOTypedCnv< class, class >::makeOutputStream ( const RootOutputAddress ria) [virtual, inherited]

Implements RootIOBaseCnv.

virtual long RootIOTypedCnv< class, class >::repSvcType ( ) const [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< class, class >::initialize ( ) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< class, class >::finalize ( ) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< class, class >::createObj ( IOpaqueAddress *  addr,
DataObject *&  dat 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

virtual StatusCode RootIOTypedCnv< class, class >::createRep ( DataObject *  pObject,
IOpaqueAddress *&  refpAddress 
) [virtual, inherited]

Reimplemented from RootIOBaseCnv.

int RootIOTypedCnv< class, class >::commit ( const RootOutputAddress roa) [inherited]

Reimplemented from RootIOBaseCnv.

RootIOBaseCnv * RootIOTypedCnv< class, class >::otherConverter ( int  clID) [inherited]

Reimplemented from RootIOBaseCnv.

static unsigned char RootIOTypedCnv< class, class >::storageType ( ) [static, inherited]

Reimplemented from RootIOBaseCnv.

static const InterfaceID & RootIOTypedCnv< class, class >::interfaceID ( ) [static, inherited]

Reimplemented from RootIOBaseCnv.


Member Data Documentation

std::string RootIOTypedCnv< class, class >::m_perclassName [protected, inherited]
PerType * RootIOTypedCnv< class, class >::m_perInObj [protected, inherited]
PerType * RootIOTypedCnv< class, class >::m_perOutObj [protected, inherited]
IRootIOSvc * RootIOTypedCnv< class, class >::m_rioSvc [protected, inherited]

Reimplemented from RootIOBaseCnv.

IConversionSvc * RootIOTypedCnv< class, class >::m_cnvSvc [protected, inherited]

Reimplemented from RootIOBaseCnv.

RootInputStream * RootIOTypedCnv< class, class >::m_ris [protected, inherited]

Reimplemented from RootIOBaseCnv.


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:48 for PerCalibReadoutEvent by doxygen 1.7.4