BOSS 7.0.1
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
 
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
 
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
 
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)

◆ ~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 47 of file RootEstTofCalibDataCnv.cxx.

47 {
49}

◆ 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 218 of file RootEstTofCalibDataCnv.cxx.

219 {
220 MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
221
222 // Open the file, create the branch
223 StatusCode sc = openWrite(fname);
224 if(!sc)
225 { log<<MSG::ERROR<<"unable to open files"<<endreq;
226 }
227 // write the Data in the TCDS to RootFile
228 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
229
230 // write btoftree----------------------------------------------------------------
231 double cnvBarPar1[nBarPar];
232 double cnvBarPar2[nBarPar];
233
234 char brname[8], ibrname[8];
235 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
236 for( unsigned int i=0; i<nBarPar; i++ ) {
237 sprintf( brname, "P%i", i );
238 sprintf( ibrname, "P%i/D", i );
239 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
240 }
241
242 for( int i=0; i<176; i++ ) {
243 for( int j=0;j<static_cast<int>(nBarPar);j++){
244 cnvBarPar1[j] = btof->getBTofPleft(i,j);
245 cnvBarPar2[j] = btof->getBTofPright(i,j);
246 }
247 btoftree -> Fill();
248 }
249
250 //write etoftree----------------------------------------------------------------
251 double cnvEndPar[nEndPar];
252
253 char ecname[8], iecname[8];
254 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
255 for( unsigned int i=0; i<nEndPar; i++ ) {
256 sprintf( ecname, "P%i", i );
257 sprintf( iecname, "P%i/D", i );
258 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
259 }
260
261 for(int i=0; i<96; i++){
262 for(int j=0;j<static_cast<int>(nEndPar);j++){
263 cnvEndPar[j] = btof->getETofP(i,j);
264 }
265 etoftree->Fill();
266 }
267
268 //write etftree----------------------------------------------------------------
269 double cnvEtfPar[nEtfPar];
270 double cnvEtfPar1[nEtfPar];
271 double cnvEtfPar2[nEtfPar];
272
273 char etfname[8], ietfname[8];
274 TTree *etftree = new TTree("EtfTofPar", "EtfTofPar");
275 for( unsigned int i=0; i<nEtfPar; i++ ) {
276 sprintf( etfname, "P%i", i );
277 sprintf( ietfname, "P%i/D", i );
278 etftree -> Branch( etfname, &cnvEtfPar[i], ietfname );
279 }
280 for( unsigned int i=0; i<nEtfPar; i++ ) {
281 sprintf( etfname, "P%i", i+nEtfPar );
282 sprintf( ietfname, "P%i/D", i+nEtfPar );
283 etftree -> Branch( etfname, &cnvEtfPar1[i], ietfname );
284 }
285 for( unsigned int i=0; i<nEtfPar; i++ ) {
286 sprintf( etfname, "P%i", i+2*nEtfPar );
287 sprintf( ietfname, "P%i/D", i+2*nEtfPar );
288 etftree -> Branch( etfname, &cnvEtfPar2[i], ietfname );
289 }
290
291 for( int i=0; i<72; i++ ) {
292 for( int k=0; k<12; k++ ) {
293 for(int j=0;j<static_cast<int>(nEtfPar);j++){
294 cnvEtfPar[j] = btof->getEtfPcombine(i,k,j);
295 cnvEtfPar1[j] = btof->getEtfPleft(i,k,j);
296 cnvEtfPar2[j] = btof->getEtfPright(i,k,j);
297 }
298 etftree -> Fill();
299 }
300 }
301
302 // write all the trees
303 btoftree -> Write();
304 etoftree -> Write();
305 etftree -> Write();
306 delete btoftree;
307 delete etoftree;
308 delete etftree;
309 closeWrite();
310 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
311
312 return sc;
313}
const unsigned int nEndPar
const unsigned int nEtfPar
const unsigned int nBarPar
double getETofP(int index, int pardex)
double getEtfPleft(int index, int strip, int pardex)
double getEtfPcombine(int index, int strip, int pardex)
double getEtfPright(int index, int strip, 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 51 of file RootEstTofCalibDataCnv.cxx.

52 {
53
54 MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
55 log<<MSG::DEBUG<<"SetProperty"<<endreq;
56
57 // open the file
58 StatusCode sc = openRead(fname);
59 if(!sc)
60 { log<<MSG::ERROR<<"unable to open files"<<endreq;
61 }
62
68
69 std::vector<CalibData::bTofCalibBase> tmpbTof;
70 std::vector<CalibData::eTofCalibBase> tmpeTof;
71 std::vector<CalibData::etfCalibBase> tmpetf;
72 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
73 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
74
75 // Read in the object
76 int cnt;
77 // read btoftree ------------------------------------------------------------
78 double cnvBarPar1[nBarPar];
79 double cnvBarPar2[nBarPar];
80 double cnvBarParOff1_bunch0[nBarParOff];
81 double cnvBarParOff2_bunch0[nBarParOff];
82 double cnvBarParOff1_bunch1[nBarParOff];
83 double cnvBarParOff2_bunch1[nBarParOff];
84 double cnvBarParOff1_bunch2[nBarParOff];
85 double cnvBarParOff2_bunch2[nBarParOff];
86 double cnvBarParOff1_bunch3[nBarParOff];
87 double cnvBarParOff2_bunch3[nBarParOff];
88
89 TTree *btoftree = (TTree*)m_inFile -> Get("BarTofPar");
90
91 char brname[10];
92 for( unsigned int i=0; i<nBarPar; i++ ) {
93 sprintf( brname, "P%i", i );
94 btoftree -> SetBranchAddress( brname, &cnvBarPar1[i] );
95 }
96 for( unsigned int i=0; i<nBarPar; i++ ) {
97 sprintf( brname, "P%i", i+nBarPar );
98 btoftree -> SetBranchAddress( brname, &cnvBarPar2[i] );
99 }
100 for( unsigned int i=0; i<nBarParOff; i++ ) {
101 sprintf( brname, "Bunch0_Poff%i", i );
102 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch0[i] );
103 }
104 for( unsigned int i=0; i<nBarParOff; i++ ) {
105 sprintf( brname, "Bunch0_Poff%i", i+nBarParOff );
106 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch0[i] );
107 }
108 for( unsigned int i=0; i<nBarParOff; i++ ) {
109 sprintf( brname, "Bunch1_Poff%i", i );
110 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch1[i] );
111 }
112 for( unsigned int i=0; i<nBarParOff; i++ ) {
113 sprintf( brname, "Bunch1_Poff%i", i+nBarParOff );
114 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch1[i] );
115 }
116 for( unsigned int i=0; i<nBarParOff; i++ ) {
117 sprintf( brname, "Bunch2_Poff%i", i );
118 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch2[i] );
119 }
120 for( unsigned int i=0; i<nBarParOff; i++ ) {
121 sprintf( brname, "Bunch2_Poff%i", i+nBarParOff );
122 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch2[i] );
123 }
124 for( unsigned int i=0; i<nBarParOff; i++ ) {
125 sprintf( brname, "Bunch3_Poff%i", i );
126 btoftree -> SetBranchAddress( brname, &cnvBarParOff1_bunch3[i] );
127 }
128 for( unsigned int i=0; i<nBarParOff; i++ ) {
129 sprintf( brname, "Bunch3_Poff%i", i+nBarParOff );
130 btoftree -> SetBranchAddress( brname, &cnvBarParOff2_bunch3[i] );
131 }
132
133 for(cnt=0; cnt<176; cnt++){
134 btoftree -> GetEntry(cnt);
135 bTof.setP1( cnvBarPar1 );
136 bTof.setP2( cnvBarPar2 );
137 bTof.setPoff1_bunch0( cnvBarParOff1_bunch0 );
138 bTof.setPoff2_bunch0( cnvBarParOff2_bunch0 );
139 bTof.setPoff1_bunch1( cnvBarParOff1_bunch1 );
140 bTof.setPoff2_bunch1( cnvBarParOff2_bunch1 );
141 bTof.setPoff1_bunch2( cnvBarParOff1_bunch2 );
142 bTof.setPoff2_bunch2( cnvBarParOff2_bunch2 );
143 bTof.setPoff1_bunch3( cnvBarParOff1_bunch3 );
144 bTof.setPoff2_bunch3( cnvBarParOff2_bunch3 );
145 tmpbTof.push_back( bTof );
146 }
147
148 //read etoftree
149 double cnvEndPar[nEndPar];
150
151 TTree *etoftree = (TTree*)m_inFile -> Get("EndTofPar");
152
153 char ecname[10];
154 for( unsigned int i=0; i<nEndPar; i++ ) {
155 sprintf( ecname, "P%i", i );
156 etoftree -> SetBranchAddress( ecname, &cnvEndPar[i] );
157 }
158
159 for(cnt=0; cnt<96; cnt++){
160 etoftree->GetEntry(cnt);
161 eTof.setP( cnvEndPar );
162 tmpeTof.push_back(eTof);
163 }
164
165 //read etftree
166 double cnvEtfPar[nEtfPar];
167 double cnvEtfPar1[nEtfPar];
168 double cnvEtfPar2[nEtfPar];
169
170 if( NULL!=m_inFile->Get("EtfTofPar") ) {
171 TTree *etftree = (TTree*)m_inFile -> Get("EtfTofPar");
172
173 char etfname[10];
174 for( unsigned int i=0; i<nEtfPar; i++ ) {
175 sprintf( etfname, "P%i", i );
176 etftree -> SetBranchAddress( etfname, &cnvEtfPar[i] );
177 }
178 for( unsigned int i=0; i<nEtfPar; i++ ) {
179 sprintf( etfname, "P%i", i+nEtfPar );
180 etftree -> SetBranchAddress( etfname, &cnvEtfPar1[i] );
181 }
182 for( unsigned int i=0; i<nEtfPar; i++ ) {
183 sprintf( etfname, "P%i", i+2*nEtfPar );
184 etftree -> SetBranchAddress( etfname, &cnvEtfPar2[i] );
185 }
186
187 for(cnt=0; cnt<(72*12); cnt++){
188 etftree -> GetEntry(cnt);
189 etf.setP( cnvEtfPar );
190 etf.setP1( cnvEtfPar1 );
191 etf.setP2( cnvEtfPar2 );
192 tmpetf.push_back(etf);
193 }
194 }
195
196 //read bTofCommonCalibBase
197 double cnvBarOffset[nBarOffset];
198 TTree *btofcommontree = (TTree*)m_inFile -> Get("BarTofParCommon");
199 for( unsigned int i=0; i<nBarOffset; i++ ) {
200 sprintf( brname, "t0offset%i", i );
201 btofcommontree-> SetBranchAddress( brname, &cnvBarOffset[i]);
202 }
203
204 int entries = btofcommontree->GetEntries();
205 for(cnt=0;cnt<entries;cnt++){
206 btofcommontree->GetEntry(cnt);
207 bTofCommon.setOffset( cnvBarOffset );
208 tmpbTofCommon.push_back(bTofCommon);
209 }
210
211 CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tmpetf,&tofinfoCol);
212
213 refpObject=tmpObject;
214
215 return StatusCode::SUCCESS;
216}
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)
void setP(const double *etfP)
void setP1(const double *etfP1)
void setP2(const double *etfP2)
StatusCode openRead(const std::string &fname)

◆ objType()

const CLID & RootEstTofCalibDataCnv::objType ( ) const

Definition at line 43 of file RootEstTofCalibDataCnv.cxx.

43 {
45}

◆ repSvcType()

virtual long RootEstTofCalibDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 34 of file RootEstTofCalibDataCnv.h.

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: