BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
RootEstTofCalibDataCnv Class Reference

#include <RootEstTofCalibDataCnv.h>

+ Inheritance diagram for RootEstTofCalibDataCnv:

Public Member Functions

const CLID & objType () const
 
 RootEstTofCalibDataCnv (ISvcLocator *svc)
 
virtual ~RootEstTofCalibDataCnv ()
 
virtual StatusCode createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj)
 
virtual long repSvcType () const
 
- Public Member Functions inherited from RootCalBaseCnv
virtual ~RootCalBaseCnv ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&refpObject)
 
ICalibRootSvcgetCalibRootSvc ()
 
 RootCalBaseCnv (ISvcLocator *svc, const CLID &clid)
 
virtual StatusCode createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj)
 
virtual StatusCode readRootObj (const std::string &treename, const std::string &branch, TObject *&pCalib, unsigned index=0)
 
virtual StatusCode readRootObj (TTree *tree, const std::string &branch, TObject *&pCalib, unsigned index=0)
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

static const CLID & classID ()
 
- Static Public Member Functions inherited from RootCalBaseCnv
static const unsigned char storageType ()
 

Protected Member Functions

virtual StatusCode i_createObj (const std::string &fname, DataObject *&refpObject)
 
- Protected Member Functions inherited from RootCalBaseCnv
virtual StatusCode internalCreateObj (const std::string &fname, DataObject *&refpObject, IOpaqueAddress *address)
 
virtual StatusCode i_createObj (const std::string &fname, DataObject *&refpObject)
 
virtual StatusCode i_processObj (DataObject *pObject, IOpaqueAddress *address)
 In case there is additional work to do on the created object.
 
virtual StatusCode fillRoot (CalibData::CalibBase *pTDSObj, TObject *pRootObj)
 
virtual StatusCode openWrite (const std::string &fname)
 
StatusCode closeWrite ()
 
StatusCode openRead (const std::string &fname)
 
StatusCode closeRead ()
 
void setBaseInfo (CalibData::CalibBase1 *pObj)
 Another utility for derived classes to use.
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< RootEstTofCalibDataCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RootCalBaseCnv
ICalibRootSvcm_rootSvc
 
ICalibMetaCnvSvcm_metaSvc
 
IInstrumentNamem_instrSvc
 
int m_serNo
 
ITime * m_vstart
 
ITime * m_vend
 
int m_runfrm
 
int m_runto
 
TFile * m_outFile
 
TTree * m_ttree
 
TFile * m_inFile
 
TDirectory * m_saveDir
 

Detailed Description

Definition at line 20 of file RootEstTofCalibDataCnv.h.

Constructor & Destructor Documentation

◆ RootEstTofCalibDataCnv()

RootEstTofCalibDataCnv::RootEstTofCalibDataCnv ( ISvcLocator *  svc)

Definition at line 39 of file RootEstTofCalibDataCnv.cxx.

39 :
41 }
const CLID CLID_Calib_EstTofCal
Definition: CalibModel.h:53

◆ ~RootEstTofCalibDataCnv()

virtual RootEstTofCalibDataCnv::~RootEstTofCalibDataCnv ( )
inlinevirtual

Definition at line 29 of file RootEstTofCalibDataCnv.h.

29{};

Member Function Documentation

◆ classID()

const CLID & RootEstTofCalibDataCnv::classID ( )
static

Definition at line 48 of file RootEstTofCalibDataCnv.cxx.

48 {
50}

◆ createRoot()

StatusCode RootEstTofCalibDataCnv::createRoot ( const std::string &  fname,
CalibData::CalibBase1 pTDSObj 
)
virtual

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

Parameters
fnameFilename for output file
pTDSObjPointer to tds object to be converted

Reimplemented from RootCalBaseCnv.

Definition at line 186 of file RootEstTofCalibDataCnv.cxx.

187 {
188 MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
189
190 // Open the file, create the branch
191 StatusCode sc = openWrite(fname);
192 if(!sc)
193 { log<<MSG::ERROR<<"unable to open files"<<endreq;
194 }
195 // write the Data in the TCDS to RootFile
196 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
197
198 // write btoftree----------------------------------------------------------------
199 double cnvBarPar1[nBarPar];
200 double cnvBarPar2[nBarPar];
201
202 char brname[8], ibrname[8];
203 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
204 for( unsigned int i=0; i<nBarPar; i++ ) {
205 sprintf( brname, "P%i", i );
206 sprintf( ibrname, "P%i/D", i );
207 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
208 }
209
210 for( int i=0; i<176; i++ ) {
211 for( int j=0;j<static_cast<int>(nBarPar);j++){
212 cnvBarPar1[j] = btof->getBTofPleft(i,j);
213 cnvBarPar2[j] = btof->getBTofPright(i,j);
214 }
215 btoftree -> Fill();
216 }
217
218 //write etoftree----------------------------------------------------------------
219 double cnvEndPar[nEndPar];
220
221 char ecname[8], iecname[8];
222 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
223 for( unsigned int i=0; i<nEndPar; i++ ) {
224 sprintf( ecname, "P%i", i );
225 sprintf( iecname, "P%i/D", i );
226 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
227 }
228
229 for(int i=0; i<96; i++){
230 for(int j=0;j<static_cast<int>(nEndPar);j++){
231 cnvEndPar[j] = btof->getETofP(i,j);
232 }
233 etoftree->Fill();
234 }
235
236 // write all the trees
237 btoftree -> Write();
238 etoftree -> Write();
239 delete btoftree;
240 delete etoftree;
241 closeWrite();
242 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
243
244 return sc;
245}
const unsigned int nEndPar
const unsigned int nBarPar
IMessageSvc * msgSvc()
double getETofP(int index, int pardex)
double getBTofPleft(int index, int pardex)
double getBTofPright(int index, int pardex)
StatusCode closeWrite()
virtual StatusCode openWrite(const std::string &fname)

◆ i_createObj()

StatusCode RootEstTofCalibDataCnv::i_createObj ( const std::string &  fname,
DataObject *&  refpObject 
)
protectedvirtual

Create the transient representation of an object, given an opaque address. This and the following update method comprise the core functionality of calibration converters. Convenience routine used by most CAL calibration types, which have a <dimension> element describing how the remainder of the Data is laid out. Read from TDS; store information internally in protected members.
Given a pointer to a TDS object which can be cast to "our" type, fill in corresponding information in the corresponding root class

Parameters
pTDSObjPointer to tds object to be converted
pRootObjPointer to destination root object Read in object from specified branch. Don't need tree name; it's always Calib

Reimplemented from RootCalBaseCnv.

Definition at line 52 of file RootEstTofCalibDataCnv.cxx.

53 {
54
55 MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
56 log<<MSG::DEBUG<<"SetProperty"<<endreq;
57
58 // open the file
59 StatusCode sc = openRead(fname);
60 if(!sc)
61 { log<<MSG::ERROR<<"unable to open files"<<endreq;
62 }
63
68
69 std::vector<CalibData::bTofCalibBase> tmpbTof;
70 std::vector<CalibData::eTofCalibBase> tmpeTof;
71 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
72 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
73
74 // Read in the object
75 int cnt;
76 // read btoftree ------------------------------------------------------------
77 double cnvBarPar1[nBarPar];
78 double cnvBarPar2[nBarPar];
79 double cnvBarParOff1_bunch0[nBarParOff];
80 double cnvBarParOff2_bunch0[nBarParOff];
81 double cnvBarParOff1_bunch1[nBarParOff];
82 double cnvBarParOff2_bunch1[nBarParOff];
83 double cnvBarParOff1_bunch2[nBarParOff];
84 double cnvBarParOff2_bunch2[nBarParOff];
85 double cnvBarParOff1_bunch3[nBarParOff];
86 double cnvBarParOff2_bunch3[nBarParOff];
87
88 TTree *btoftree = (TTree*)m_inFile -> Get("BarTofPar");
89
90 char brname[10];
91 for( unsigned int i=0; i<nBarPar; i++ ) {
92 sprintf( brname, "P%i", i );
93 btoftree -> SetBranchAddress( brname, &cnvBarPar1[i] );
94 }
95 for( unsigned int i=0; i<nBarPar; i++ ) {
96 sprintf( brname, "P%i", i+nBarPar );
97 btoftree -> SetBranchAddress( brname, &cnvBarPar2[i] );
98 }
99 for( unsigned int i=0; i<nBarParOff; i++ ) {
100 sprintf( brname, "Bunch0_Poff%i", i );
101 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch0[i] );
102 }
103 for( unsigned int i=0; i<nBarParOff; i++ ) {
104 sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
105 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch0[i] );
106 }
107 for( unsigned int i=0; i<nBarParOff; i++ ) {
108 sprintf( brname, "Bunch1_Poff%i", i );
109 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch1[i] );
110 }
111 for( unsigned int i=0; i<nBarParOff; i++ ) {
112 sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
113 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch1[i] );
114 }
115 for( unsigned int i=0; i<nBarParOff; i++ ) {
116 sprintf( brname, "Bunch2_Poff%i", i );
117 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch2[i] );
118 }
119 for( unsigned int i=0; i<nBarParOff; i++ ) {
120 sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
121 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch2[i] );
122 }
123 for( unsigned int i=0; i<nBarParOff; i++ ) {
124 sprintf( brname, "Bunch3_Poff%i", i );
125 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch3[i] );
126 }
127 for( unsigned int i=0; i<nBarParOff; i++ ) {
128 sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
129 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch3[i] );
130 }
131
132 for(cnt=0; cnt<176; cnt++){
133 btoftree -> GetEntry(cnt);
134 bTof.setP1( cnvBarPar1 );
135 bTof.setP2( cnvBarPar2 );
136 bTof.setPoff1_bunch0( cnvBarParOff1_bunch0 );
137 bTof.setPoff2_bunch0( cnvBarParOff2_bunch0 );
138 bTof.setPoff1_bunch1( cnvBarParOff1_bunch1 );
139 bTof.setPoff2_bunch1( cnvBarParOff2_bunch1 );
140 bTof.setPoff1_bunch2( cnvBarParOff1_bunch2 );
141 bTof.setPoff2_bunch2( cnvBarParOff2_bunch2 );
142 bTof.setPoff1_bunch3( cnvBarParOff1_bunch3 );
143 bTof.setPoff2_bunch3( cnvBarParOff2_bunch3 );
144 tmpbTof.push_back( bTof );
145 }
146
147 //read etoftree
148 double cnvEndPar[nEndPar];
149
150 TTree *etoftree = (TTree*)m_inFile -> Get("EndTofPar");
151
152 char ecname[10];
153 for( unsigned int i=0; i<nEndPar; i++ ) {
154 sprintf( ecname, "P%i", i );
155 etoftree -> SetBranchAddress( ecname, &cnvEndPar[i] );
156 }
157
158 for(cnt=0; cnt<96; cnt++){
159 etoftree->GetEntry(cnt);
160 eTof.setP( cnvEndPar );
161 tmpeTof.push_back(eTof);
162 }
163
164 //read bTofCommonCalibBase
165 double cnvBarOffset[nBarOffset];
166 TTree *btofcommontree = (TTree*)m_inFile -> Get("BarTofParCommon");
167 for( unsigned int i=0; i<nBarOffset; i++ ) {
168 sprintf( brname, "t0offset%i", i );
169 btofcommontree-> SetBranchAddress( brname, &cnvBarOffset[i]);
170 }
171
172 int entries = btofcommontree->GetEntries();
173 for(cnt=0;cnt<entries;cnt++){
174 btofcommontree->GetEntry(cnt);
175 bTofCommon.setOffset( cnvBarOffset );
176 tmpbTofCommon.push_back(bTofCommon);
177 }
178
179 CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tofinfoCol);
180
181 refpObject=tmpObject;
182
183 return StatusCode::SUCCESS;
184}
data SetBranchAddress("time",&time)
data GetEntry(0)
const unsigned int nBarOffset
const unsigned int nBarParOff
void setP2(const double *TofP2)
void setPoff1_bunch3(const double *TofPoff1_bunch3)
void setPoff2_bunch1(const double *TofPoff2_bunch1)
void setPoff1_bunch0(const double *TofPoff1_bunch0)
void setPoff2_bunch2(const double *TofPoff2_bunch2)
void setPoff1_bunch1(const double *TofPoff1_bunch1)
void setPoff1_bunch2(const double *TofPoff1_bunch2)
void setPoff2_bunch3(const double *TofPoff2_bunch3)
void setPoff2_bunch0(const double *TofPoff2_bunch0)
void setP1(const double *TofP1)
void setOffset(const double *offset)
void setP(const double *TofP)
StatusCode openRead(const std::string &fname)

◆ objType()

const CLID & RootEstTofCalibDataCnv::objType ( ) const

Definition at line 44 of file RootEstTofCalibDataCnv.cxx.

44 {
46}

◆ repSvcType()

virtual long RootEstTofCalibDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 34 of file RootEstTofCalibDataCnv.h.

34 {
36 }
unsigned const char CALIBROOT_StorageType
Definition: ICalibRootSvc.h:20

Friends And Related Function Documentation

◆ CnvFactory< RootEstTofCalibDataCnv >

friend class CnvFactory< RootEstTofCalibDataCnv >
friend

Definition at line 1 of file RootEstTofCalibDataCnv.h.


The documentation for this class was generated from the following files: