Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TreeEstTofCalibDataCnv Class Reference

#include <TreeEstTofCalibDataCnv.h>

Inheritance diagram for TreeEstTofCalibDataCnv:

TreeCalBaseCnv Converter< Ty1, Ty2 > List of all members.

Public Types

typedef Ty2 destination
typedef Ty2 destination
typedef Ty1 source
typedef Ty1 source

Public Member Functions

virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&refpObject)
virtual StatusCode createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj)
virtual StatusCode finalize ()
ICalibTreeSvcgetCalibTreeSvc ()
virtual StatusCode initialize ()
const CLID & objType () const
destinationoperator (const source &) const
destinationoperator (const source &) const
virtual long repSvcType () const
 TreeEstTofCalibDataCnv (ISvcLocator *svc)
virtual ~TreeEstTofCalibDataCnv ()

Static Public Member Functions

const CLID & classID ()
const unsigned char storageType ()

Protected Member Functions

virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
virtual StatusCode fillRoot (CalibData::CalibBase *pTDSObj, TObject *pRootObj)
virtual StatusCode i_createObj (IOpaqueAddress *address, DataObject *&refpObject)
virtual StatusCode i_processObj (DataObject *pObject, IOpaqueAddress *address)
 In case there is additional work to do on the created object.
virtual StatusCode internalCreateObj (DataObject *&refpObject, IOpaqueAddress *address)
void setBaseInfo (CalibData::CalibBase1 *pObj)
 Another utility for derived classes to use.

Protected Attributes

TFile * m_inFile
IInstrumentNamem_instrSvc
ICalibMetaCnvSvcm_metaSvc
TFile * m_outFile
int m_runfrm
int m_runto
TDirectory * m_saveDir
int m_serNo
ICalibTreeSvcm_treeSvc
TTree * m_ttree

Friends

class CnvFactory<TreeEstTofCalibDataCnv>

Detailed Description

Base class for CAL calibration converters from Ttrees to TCDS. All such converters need to do certain things, which are handled here. Methods common to *all* calibrations are in the base class TreeCalBaseCnv

Author:
huang bin


Member Typedef Documentation

template<class Ty1, class Ty2>
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited]
 

template<class Ty1, class Ty2>
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited]
 

template<class Ty1, class Ty2>
typedef Ty1 Converter< Ty1, Ty2 >::source [inherited]
 

template<class Ty1, class Ty2>
typedef Ty1 Converter< Ty1, Ty2 >::source [inherited]
 


Constructor & Destructor Documentation

TreeEstTofCalibDataCnv::TreeEstTofCalibDataCnv ISvcLocator *  svc  ) 
 

00034                                                                 :
00035   TreeCalBaseCnv(svc, CLID_Calib_EstTofCal) { 
00036       
00037 }

virtual TreeEstTofCalibDataCnv::~TreeEstTofCalibDataCnv  )  [inline, virtual]
 

00029 {};


Member Function Documentation

const CLID & TreeEstTofCalibDataCnv::classID  )  [static]
 

00044                                             {
00045   return CLID_Calib_EstTofCal;
00046 }

template<class Ty1, class Ty2>
virtual destination* Converter< Ty1, Ty2 >::convert const source  )  const [protected, pure virtual, inherited]
 

template<class Ty1, class Ty2>
virtual destination* Converter< Ty1, Ty2 >::convert const source  )  const [protected, pure virtual, inherited]
 

StatusCode TreeCalBaseCnv::createObj IOpaqueAddress *  addr,
DataObject *&  refpObject
[virtual, inherited]
 

Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters.

00108                                                            {
00109   //  StatusCode ret;
00110 
00111   // first do the things we always need:
00112   //   First string parameter of opaque address is file ident
00113   MsgStream log(msgSvc(), "TreeCalBaseCnv");
00114    log << MSG::DEBUG<<"TreeCalBaseCnv::createObj( starting ...."<<endreq;
00115  //  const std::string* par = addr->par();
00116 
00117  // std::string par0 = par[0];
00118    
00119 //  return internalCreateObj(par0, refpObject, addr);
00120   return internalCreateObj(refpObject, addr);
00121 
00122 }

StatusCode TreeCalBaseCnv::createRoot const std::string &  fname,
CalibData::CalibBase1 pTDSObj
[virtual, inherited]
 

Create ROOT file corresponding to TDS object input. Default implementation is to return an error. Must be separately implemented for each calibration type.

Parameters:
fname Filename for output file
pTDSObj Pointer to tds object to be converted
00086                                                                        {
00087   MsgStream log(msgSvc(), "TreeCalBaseCnv");
00088   log << MSG::ERROR 
00089       << "createRoot method not implemented for this calibration type" 
00090       << endreq;
00091   return StatusCode::FAILURE;
00092 }

StatusCode TreeCalBaseCnv::fillRoot CalibData::CalibBase pTDSObj,
TObject *  pRootObj
[protected, virtual, inherited]
 

Given a pointer to a TDS object which can be cast to "our" type, fill in corresponding information in the corresponding root class

Parameters:
pTDSObj Pointer to tds object to be converted
pRootObj Pointer to destination root object
...maybe don't need pRootObj argument; keep this as the (protected) data member m_rootObj. Or else this routine could set the protected member to this passed-in value
00097                                                           {
00098 
00099   // Get instrument name from InstrumentName service  Now handled by 
00100   // TreeCalBaseCnv
00101   //  TString instr = TString((m_instrSvc->getInstrumentName()).c_str());
00102   //  pRootObj->setInstrument(instr);
00103   return StatusCode::SUCCESS;
00104 }

StatusCode TreeCalBaseCnv::finalize  )  [virtual, inherited]
 

00078                                     {
00079   return Converter::finalize();
00080 }

ICalibTreeSvc* TreeCalBaseCnv::getCalibTreeSvc  )  [inline, inherited]
 

00057                                    {
00058     return m_treeSvc;
00059   }

StatusCode TreeEstTofCalibDataCnv::i_createObj IOpaqueAddress *  address,
DataObject *&  refpObject
[protected, virtual]
 

This creates the transient representation of an object from the corresponding ROOT object. This actually does the "new" operation and deals with the attributes of the node. This base class implementation does nothing; it should not normally be called because it doesn't correspond to any TCDS class. Instead, i_createObj of some derived class will be called.

Parameters:
fname The ROOT file to be read in to be used to builds the object
refpObject the object to be built
Returns:
status depending on the completion of the call

Reimplemented from TreeCalBaseCnv.

00049                                                                 {
00050 
00051   MsgStream log(msgSvc(), "TreeEstTofCalibDataCnv");
00052   log<<MSG::DEBUG<<"SetProperty"<<endreq;
00053   
00054   TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
00055   DatabaseRecord *records=add->pp();
00056 
00057   TBuffer *buf1 = new TBuffer(TBuffer::kRead);
00058   TBuffer *buf2 = new TBuffer(TBuffer::kRead);
00059   TBuffer *buf3 = new TBuffer(TBuffer::kRead);
00060   TBuffer *buf4 = new TBuffer(TBuffer::kRead);
00061       
00062   buf1->SetBuffer((*records)["BarTofPar"],512000,kFALSE);
00063   buf2->SetBuffer((*records)["EndTofPar"],512000,kFALSE);
00064   buf3->SetBuffer((*records)["TofConPar"],512000,kFALSE);
00065   buf4->SetBuffer((*records)["BarTof"],512000,kFALSE);
00066 
00067   std::cout<<" CalVerSft is "<<(*records)["CalParVer"];
00068   std::cout<<"  File name  is "<<(*records)["FileName"]<<std::endl;
00069 
00070   TTree *btoftree= new TTree();
00071   TTree *etoftree= new TTree();
00072   TTree *btofcommontree = new TTree();
00073   TTree *CalibInfo = new TTree();
00074 
00075   btoftree->Streamer(*buf1);
00076   etoftree->Streamer(*buf2);
00077   btofcommontree->Streamer(*buf3);
00078   CalibInfo->Streamer(*buf4);
00079 
00080   CalibData::bTofCalibBase bTof;
00081   CalibData::eTofCalibBase eTof;
00082   CalibData::bTofCommonCalibBase bTofCommon;
00083   CalibData::tofCalibInfoBase tofinfo;
00084 
00085   std::vector<CalibData::bTofCalibBase> tmpbTof;
00086   std::vector<CalibData::eTofCalibBase> tmpeTof;
00087   std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
00088   std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
00089 
00090   // Read in the object
00091   int cnt;
00092   // read btoftree ------------------------------------------------------------
00093   double cnvBarPar1[nBarPar];
00094   double cnvBarPar2[nBarPar];
00095   double cnvBarParOff1[nBarParOff];
00096   double cnvBarParOff2[nBarParOff];
00097 
00098   char brname[10];
00099   for( unsigned int i=0; i<nBarPar; i++ ) {
00100     sprintf( brname, "P%i", i );
00101     btoftree -> SetBranchAddress( brname, &cnvBarPar1[i] );    
00102   }
00103   for( unsigned int i=0; i<nBarPar; i++ ) {
00104     sprintf( brname, "P%i", i+nBarPar );
00105     btoftree -> SetBranchAddress( brname, &cnvBarPar2[i] );    
00106   }
00107   for( unsigned int i=0; i<nBarParOff; i++ ) {
00108     sprintf( brname, "Poff%i", i );
00109     btoftree -> SetBranchAddress( brname, &cnvBarParOff1[i] );    
00110   }
00111   for( unsigned int i=0; i<nBarParOff; i++ ) {
00112     sprintf( brname, "Poff%i", i+nBarParOff );
00113     btoftree -> SetBranchAddress( brname, &cnvBarParOff2[i] );    
00114   }
00115 
00116   for(cnt=0; cnt<176; cnt++){
00117     btoftree -> GetEntry( cnt );
00118     bTof.setP1( cnvBarPar1 );
00119     bTof.setP2( cnvBarPar2 );
00120     bTof.setPoff1( cnvBarParOff1 );
00121     bTof.setPoff2( cnvBarParOff2 );
00122     tmpbTof.push_back(bTof);
00123   }
00124 
00125   //read etoftree
00126   double cnvEndPar[nEndPar];
00127 
00128   char ecname[10];
00129   for( unsigned int i=0; i<nEndPar; i++ ) {
00130     sprintf( ecname, "P%i", i );
00131     etoftree -> SetBranchAddress( ecname, &cnvEndPar[i] );
00132   }
00133 
00134   for( cnt=0; cnt<96; cnt++ ) {
00135     etoftree -> GetEntry( cnt );
00136     eTof.setP( cnvEndPar );
00137     tmpeTof.push_back( eTof );
00138   }
00139 
00140   //read bTofCommonCalibBase
00141   double cnvBarOffset[nBarOffset];
00142   for( unsigned int i=0; i<nBarOffset; i++ ) {
00143     sprintf( brname, "t0offset%i", i );
00144     btofcommontree-> SetBranchAddress( brname, &cnvBarOffset[i]);
00145   }
00146 
00147   int entries = btofcommontree->GetEntries();
00148   for(cnt=0;cnt<entries;cnt++){
00149     btofcommontree->GetEntry(cnt);
00150     bTofCommon.setOffset( cnvBarOffset );
00151     tmpbTofCommon.push_back(bTofCommon);
00152   }
00153 
00154   CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tofinfoCol);
00155   
00156   refpObject=tmpObject;
00157   delete btoftree;
00158   delete etoftree;
00159   delete btofcommontree;
00160   delete CalibInfo;
00161 
00162   return StatusCode::SUCCESS;
00163 }

StatusCode TreeCalBaseCnv::i_processObj DataObject *  pObject,
IOpaqueAddress *  address
[protected, virtual, inherited]
 

In case there is additional work to do on the created object.

00184                                                                       {
00185   return StatusCode::SUCCESS;
00186 }

StatusCode TreeCalBaseCnv::initialize  )  [virtual, inherited]
 

00045                                       {
00046   StatusCode status = Converter::initialize();
00047 
00048   IDataProviderSvc* dp;
00049 
00050   // I guess the service names are assigned in jobOptions?
00051 
00052   serviceLocator()->getService ("CalibDataSvc",
00053                                 IID_IDataProviderSvc,
00054                                 (IInterface*&)dp);
00055   setDataProvider(dp);
00056   
00057   // Locate the Root Conversion Service
00058   serviceLocator()->getService ("CalibTreeCnvSvc",
00059                                 IID_ICalibTreeSvc,
00060                                 (IInterface*&) m_treeSvc);
00061 
00062   // Locate meta conversion service
00063   // Will anything need to be changed here to accommodate possibility
00064   // of two concrete implementations of ICalibMetaCnvSvc?  Would
00065   // have different storage types.  Could specify type desired
00066   // as job option.  Ditto for name of class?
00067   serviceLocator()->getService("CalibMySQLCnvSvc", 
00068                                IID_ICalibMetaCnvSvc,
00069                                 (IInterface*&)m_metaSvc);
00070 
00071   serviceLocator()->getService ("CalibDataSvc",
00072                                 IID_IInstrumentName,
00073                                 (IInterface*&)m_instrSvc);
00074 
00075   return status;
00076 }

StatusCode TreeCalBaseCnv::internalCreateObj DataObject *&  refpObject,
IOpaqueAddress *  address
[protected, virtual, inherited]
 

This creates the transient representation of an object from the corresponding ROOT object it, then fills it and process it. This implementation actually only calls the i_* methods of the "right" converter to do the job; so the very first thing it does is get a pointer to the appropriate derived converter. Converters typically don't need to override this method but only to override/implement some of the i_* methods.

Parameters:
pRootObj pointer to the ROOT object
refpObject the object to be built
address the opaque address for this object
Returns:
status depending on the completion of the call
00128                                                                    {
00129 
00130   MsgStream log(msgSvc(), "TreeCalBaseCnv");
00131    log << MSG::DEBUG<<"TreeCalBaseCnv::internalCreateObj( starting ..... "<<endreq;
00132    TreeCalBaseCnv* converter = this;
00133   CLID classId = address->clID();
00134 
00135   IConverter* conv = this->conversionSvc()->converter(classId);
00136   if (0 == conv) {
00137     log << MSG::WARNING
00138         << "No proper converter found for classID " << classId
00139             << ", the default converter"
00140             << " will be used. " << endreq;
00141   } else {
00142     converter = dynamic_cast <TreeCalBaseCnv*> (conv);
00143     if (0 == converter) {
00144       log << MSG::ERROR
00145           << "The converter found for classID " << classId
00146               << " was not a descendent of TreeCalBaseCnv as it should be "
00147               << "( was of type " << typeid (*converter).name() << "). "
00148               << "The default converter will be used" << endreq;
00149       converter = this;
00150     }
00151   }
00152 
00153     m_runfrm =*( address->ipar());
00154     m_runto =*( address->ipar()+1);
00155  //   m_runfrm = 100;
00156  //   m_runto =1000;
00157    // creates an object for the node found
00158    StatusCode sc = converter->i_createObj(address, refpObject);
00159      if (sc.isFailure()) {
00160     return sc;
00161   } 
00162      CalibData::CalibBase1* tmpObject =  dynamic_cast <CalibData::CalibBase1*> (refpObject);
00163      setBaseInfo(tmpObject);
00164   // ends up the object construction
00165   sc = converter->i_processObj(refpObject, address);
00166   if (sc.isSuccess()) {
00167     log << MSG::DEBUG << "Successfully created calib. object " << endreq;
00168   }
00169  // closeRead();
00170   return sc;
00171 }

const CLID & TreeEstTofCalibDataCnv::objType  )  const
 

00040                                                   {
00041   return CLID_Calib_EstTofCal;
00042 }

template<class Ty1, class Ty2>
destination* Converter< Ty1, Ty2 >::operator const source  )  const [inline, inherited]
 

template<class Ty1, class Ty2>
destination* Converter< Ty1, Ty2 >::operator const source  )  const [inline, inherited]
 

virtual long TreeEstTofCalibDataCnv::repSvcType  )  const [inline, virtual]
 

00034                                   { 
00035           return CALIBTREE_StorageType; 
00036       } 

void TreeCalBaseCnv::setBaseInfo CalibData::CalibBase1 pObj  )  [protected, inherited]
 

Another utility for derived classes to use.

Another convenience for derived classes: sets information belonging to the calibration base class, namely validity interval and serial number.

00189                                                           {
00190    MsgStream log(msgSvc(), "TreeCalBaseCnv");
00191    log << MSG::DEBUG<<"set the runfrm and runto Numbers in the converter"<<endreq;
00192   pObj->setrunfrm(m_runfrm);
00193   pObj->setrunto(m_runto);
00194 }

const unsigned char TreeCalBaseCnv::storageType  )  [inline, static, inherited]
 

00061 {return CALIBTREE_StorageType;}


Friends And Related Function Documentation

friend class CnvFactory<TreeEstTofCalibDataCnv> [friend]
 


Member Data Documentation

TFile* TreeCalBaseCnv::m_inFile [protected, inherited]
 

IInstrumentName* TreeCalBaseCnv::m_instrSvc [protected, inherited]
 

ICalibMetaCnvSvc* TreeCalBaseCnv::m_metaSvc [protected, inherited]
 

TFile* TreeCalBaseCnv::m_outFile [protected, inherited]
 

int TreeCalBaseCnv::m_runfrm [protected, inherited]
 

int TreeCalBaseCnv::m_runto [protected, inherited]
 

TDirectory* TreeCalBaseCnv::m_saveDir [protected, inherited]
 

int TreeCalBaseCnv::m_serNo [protected, inherited]
 

ICalibTreeSvc* TreeCalBaseCnv::m_treeSvc [protected, inherited]
 

TTree* TreeCalBaseCnv::m_ttree [protected, inherited]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:04:27 2011 for BOSS6.5.5 by  doxygen 1.3.9.1