BOSS 8.0.0
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 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
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_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
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
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 22 of file RootEstTofCalibDataCnv.h.

Constructor & Destructor Documentation

◆ RootEstTofCalibDataCnv()

RootEstTofCalibDataCnv::RootEstTofCalibDataCnv ( ISvcLocator * svc)

Definition at line 39 of file RootEstTofCalibDataCnv.cxx.

RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)

◆ ~RootEstTofCalibDataCnv()

virtual RootEstTofCalibDataCnv::~RootEstTofCalibDataCnv ( )
inlinevirtual

Definition at line 31 of file RootEstTofCalibDataCnv.h.

31{};

Member Function Documentation

◆ classID()

const CLID & RootEstTofCalibDataCnv::classID ( )
static

Definition at line 44 of file RootEstTofCalibDataCnv.cxx.

44{ return CLID_Calib_EstTofCal; }

Referenced by CalibRootCnvSvc::createConverter().

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

263 {
264 MsgStream log( msgSvc(), "RootEstTofCalibDataCnv" );
265
266 // Open the file, create the branch
267 StatusCode sc = openWrite( fname );
268 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
269 // write the Data in the TCDS to RootFile
270 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>( pTDSObj );
271
272 // write btoftree----------------------------------------------------------------
273 double cnvBarPar1[nBarPar];
274 double cnvBarPar2[nBarPar];
275
276 char brname[8], ibrname[8];
277 TTree* btoftree = new TTree( "BarTofPar", "BarTofPar" );
278 for ( unsigned int i = 0; i < nBarPar; i++ )
279 {
280 sprintf( brname, "P%i", i );
281 sprintf( ibrname, "P%i/D", i );
282 btoftree->Branch( brname, &cnvBarPar1[i], ibrname );
283 }
284
285 for ( int i = 0; i < 176; i++ )
286 {
287 for ( int j = 0; j < static_cast<int>( nBarPar ); j++ )
288 {
289 cnvBarPar1[j] = btof->getBTofPleft( i, j );
290 cnvBarPar2[j] = btof->getBTofPright( i, j );
291 }
292 btoftree->Fill();
293 }
294
295 // write etoftree----------------------------------------------------------------
296 double cnvEndPar[nEndPar];
297
298 char ecname[8], iecname[8];
299 TTree* etoftree = new TTree( "EndTofPar", "EndTofPar" );
300 for ( unsigned int i = 0; i < nEndPar; i++ )
301 {
302 sprintf( ecname, "P%i", i );
303 sprintf( iecname, "P%i/D", i );
304 etoftree->Branch( ecname, &cnvEndPar[i], iecname );
305 }
306
307 for ( int i = 0; i < 96; i++ )
308 {
309 for ( int j = 0; j < static_cast<int>( nEndPar ); j++ )
310 { cnvEndPar[j] = btof->getETofP( i, j ); }
311 etoftree->Fill();
312 }
313
314 // write etftree----------------------------------------------------------------
315 double cnvEtfPar[nEtfPar];
316 double cnvEtfPar1[nEtfPar];
317 double cnvEtfPar2[nEtfPar];
318
319 char etfname[8], ietfname[8];
320 TTree* etftree = new TTree( "EtfTofPar", "EtfTofPar" );
321 for ( unsigned int i = 0; i < nEtfPar; i++ )
322 {
323 sprintf( etfname, "P%i", i );
324 sprintf( ietfname, "P%i/D", i );
325 etftree->Branch( etfname, &cnvEtfPar[i], ietfname );
326 }
327 for ( unsigned int i = 0; i < nEtfPar; i++ )
328 {
329 sprintf( etfname, "P%i", i + nEtfPar );
330 sprintf( ietfname, "P%i/D", i + nEtfPar );
331 etftree->Branch( etfname, &cnvEtfPar1[i], ietfname );
332 }
333 for ( unsigned int i = 0; i < nEtfPar; i++ )
334 {
335 sprintf( etfname, "P%i", i + 2 * nEtfPar );
336 sprintf( ietfname, "P%i/D", i + 2 * nEtfPar );
337 etftree->Branch( etfname, &cnvEtfPar2[i], ietfname );
338 }
339
340 for ( int i = 0; i < 72; i++ )
341 {
342 for ( int k = 0; k < 12; k++ )
343 {
344 for ( int j = 0; j < static_cast<int>( nEtfPar ); j++ )
345 {
346 cnvEtfPar[j] = btof->getEtfPcombine( i, k, j );
347 cnvEtfPar1[j] = btof->getEtfPleft( i, k, j );
348 cnvEtfPar2[j] = btof->getEtfPright( i, k, j );
349 }
350 etftree->Fill();
351 }
352 }
353
354 // write all the trees
355 btoftree->Write();
356 etoftree->Write();
357 etftree->Write();
358 delete btoftree;
359 delete etoftree;
360 delete etftree;
361 closeWrite();
362 log << MSG::INFO << "successfully create RootFile" << endmsg;
363
364 return sc;
365}
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
const unsigned int nEndPar
const unsigned int nEtfPar
const unsigned int nBarPar
IMessageSvc * msgSvc()
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 46 of file RootEstTofCalibDataCnv.cxx.

47 {
48
49 MsgStream log( msgSvc(), "RootEstTofCalibDataCnv" );
50 log << MSG::DEBUG << "SetProperty" << endmsg;
51
52 // open the file
53 StatusCode sc = openRead( fname );
54 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
55
56 CalibData::bTofCalibBase bTof;
57 CalibData::eTofCalibBase eTof;
58 CalibData::etfCalibBase etf;
59 CalibData::bTofCommonCalibBase bTofCommon;
60 CalibData::tofCalibInfoBase tofinfo;
61
62 std::vector<CalibData::bTofCalibBase> tmpbTof;
63 std::vector<CalibData::eTofCalibBase> tmpeTof;
64 std::vector<CalibData::etfCalibBase> tmpetf;
65 std::vector<CalibData::bTofCommonCalibBase> tmpbTofCommon;
66 std::vector<CalibData::tofCalibInfoBase> tofinfoCol;
67
68 // Read in the object
69 int cnt;
70 // read btoftree ------------------------------------------------------------
71 double cnvBarPar1[nBarPar];
72 double cnvBarPar2[nBarPar];
73 double cnvBarParOff1_bunch0[nBarParOff];
74 double cnvBarParOff2_bunch0[nBarParOff];
75 double cnvBarParOff1_bunch1[nBarParOff];
76 double cnvBarParOff2_bunch1[nBarParOff];
77 double cnvBarParOff1_bunch2[nBarParOff];
78 double cnvBarParOff2_bunch2[nBarParOff];
79 double cnvBarParOff1_bunch3[nBarParOff];
80 double cnvBarParOff2_bunch3[nBarParOff];
81
82 TTree* btoftree = (TTree*)m_inFile->Get( "BarTofPar" );
83
84 char brname[10];
85 for ( unsigned int i = 0; i < nBarPar; i++ )
86 {
87 sprintf( brname, "P%i", i );
88 btoftree->SetBranchAddress( brname, &cnvBarPar1[i] );
89 }
90 for ( unsigned int i = 0; i < nBarPar; i++ )
91 {
92 sprintf( brname, "P%i", i + nBarPar );
93 btoftree->SetBranchAddress( brname, &cnvBarPar2[i] );
94 }
95 for ( unsigned int i = 0; i < nBarParOff; i++ )
96 {
97 sprintf( brname, "Bunch0_Poff%i", i );
98 btoftree->SetBranchAddress( brname, &cnvBarParOff1_bunch0[i] );
99 }
100 for ( unsigned int i = 0; i < nBarParOff; i++ )
101 {
102 sprintf( brname, "Bunch0_Poff%i", i + nBarParOff );
103 btoftree->SetBranchAddress( brname, &cnvBarParOff2_bunch0[i] );
104 }
105 for ( unsigned int i = 0; i < nBarParOff; i++ )
106 {
107 sprintf( brname, "Bunch1_Poff%i", i );
108 btoftree->SetBranchAddress( brname, &cnvBarParOff1_bunch1[i] );
109 }
110 for ( unsigned int i = 0; i < nBarParOff; i++ )
111 {
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 {
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 {
122 sprintf( brname, "Bunch2_Poff%i", i + nBarParOff );
123 btoftree->SetBranchAddress( brname, &cnvBarParOff2_bunch2[i] );
124 }
125 for ( unsigned int i = 0; i < nBarParOff; i++ )
126 {
127 sprintf( brname, "Bunch3_Poff%i", i );
128 btoftree->SetBranchAddress( brname, &cnvBarParOff1_bunch3[i] );
129 }
130 for ( unsigned int i = 0; i < nBarParOff; i++ )
131 {
132 sprintf( brname, "Bunch3_Poff%i", i + nBarParOff );
133 btoftree->SetBranchAddress( brname, &cnvBarParOff2_bunch3[i] );
134 }
135
136 for ( cnt = 0; cnt < btoftree->GetEntries(); cnt++ )
137 {
138 btoftree->GetEntry( cnt );
139 bTof.setP1( cnvBarPar1 );
140 bTof.setP2( cnvBarPar2 );
141 bTof.setPoff1_bunch0( cnvBarParOff1_bunch0 );
142 bTof.setPoff2_bunch0( cnvBarParOff2_bunch0 );
143 bTof.setPoff1_bunch1( cnvBarParOff1_bunch1 );
144 bTof.setPoff2_bunch1( cnvBarParOff2_bunch1 );
145 bTof.setPoff1_bunch2( cnvBarParOff1_bunch2 );
146 bTof.setPoff2_bunch2( cnvBarParOff2_bunch2 );
147 bTof.setPoff1_bunch3( cnvBarParOff1_bunch3 );
148 bTof.setPoff2_bunch3( cnvBarParOff2_bunch3 );
149 tmpbTof.push_back( bTof );
150 }
151
152 // read etoftree
153 double cnvEndPar[nEndPar];
154
155 TTree* etoftree = (TTree*)m_inFile->Get( "EndTofPar" );
156
157 char ecname[10];
158 for ( unsigned int i = 0; i < nEndPar; i++ )
159 {
160 sprintf( ecname, "P%i", i );
161 etoftree->SetBranchAddress( ecname, &cnvEndPar[i] );
162 }
163
164 for ( cnt = 0; cnt < etoftree->GetEntries(); cnt++ )
165 {
166 etoftree->GetEntry( cnt );
167 eTof.setP( cnvEndPar );
168 tmpeTof.push_back( eTof );
169 }
170
171 // read etftree
172 double cnvEtfPar[nEtfPar];
173 double cnvEtfPar1[nEtfPar];
174 double cnvEtfPar2[nEtfPar];
175
176 if ( NULL != m_inFile->Get( "EtfTofPar" ) )
177 {
178 TTree* etftree = (TTree*)m_inFile->Get( "EtfTofPar" );
179
180 char etfname[10];
181 for ( unsigned int i = 0; i < nEtfPar; i++ )
182 {
183 sprintf( etfname, "P%i", i );
184 etftree->SetBranchAddress( etfname, &cnvEtfPar[i] );
185 }
186 for ( unsigned int i = 0; i < nEtfPar; i++ )
187 {
188 sprintf( etfname, "P%i", i + nEtfPar );
189 etftree->SetBranchAddress( etfname, &cnvEtfPar1[i] );
190 }
191 for ( unsigned int i = 0; i < nEtfPar; i++ )
192 {
193 sprintf( etfname, "P%i", i + 2 * nEtfPar );
194 etftree->SetBranchAddress( etfname, &cnvEtfPar2[i] );
195 }
196
197 for ( cnt = 0; cnt < etftree->GetEntries(); cnt++ )
198 {
199 etftree->GetEntry( cnt );
200 etf.setP( cnvEtfPar );
201 etf.setP1( cnvEtfPar1 );
202 etf.setP2( cnvEtfPar2 );
203 tmpetf.push_back( etf );
204 }
205 }
206
207 // read bTofCommonCalibBase
208 double cnvBarOffset[nBarOffset];
209 TTree* btofcommontree = (TTree*)m_inFile->Get( "BarTofParCommon" );
210 for ( unsigned int i = 0; i < nBarOffset; i++ )
211 {
212 sprintf( brname, "t0offset%i", i );
213 btofcommontree->SetBranchAddress( brname, &cnvBarOffset[i] );
214 }
215
216 int entries = btofcommontree->GetEntries();
217 for ( cnt = 0; cnt < entries; cnt++ )
218 {
219 btofcommontree->GetEntry( cnt );
220 bTofCommon.setOffset( cnvBarOffset );
221 tmpbTofCommon.push_back( bTofCommon );
222 }
223
224 int m_runFrom, m_runTo, m_eventFrom, m_eventTo;
225
226 TTree* CalibInfo = (TTree*)m_inFile->Get( "CalibInfo" );
227
228 if ( CalibInfo->GetBranchStatus( "runFrom" ) )
229 {
230 CalibInfo->SetBranchAddress( "runFrom", &m_runFrom );
231 CalibInfo->SetBranchAddress( "runTo", &m_runTo );
232 CalibInfo->SetBranchAddress( "eventFrom", &m_eventFrom );
233 CalibInfo->SetBranchAddress( "eventTo", &m_eventTo );
234 }
235 else
236 {
237 m_runFrom = -1;
238 m_runTo = -1;
239 m_eventFrom = -1;
240 m_eventTo = -1;
241 }
242
243 entries = CalibInfo->GetEntries();
244 for ( cnt = 0; cnt < entries; cnt++ )
245 {
246 CalibInfo->GetEntry( cnt );
247 tofinfo.setRunFrom( m_runFrom );
248 tofinfo.setRunTo( m_runTo );
249 tofinfo.setEventFrom( m_eventFrom );
250 tofinfo.setEventTo( m_eventTo );
251 tofinfoCol.push_back( tofinfo );
252 }
253
254 CalibData::TofCalibData* tmpObject =
255 new CalibData::TofCalibData( tmpbTof, tmpbTofCommon, tmpeTof, tmpetf, tofinfoCol );
256
257 refpObject = tmpObject;
258
259 return StatusCode::SUCCESS;
260}
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 42 of file RootEstTofCalibDataCnv.cxx.

42{ return CLID_Calib_EstTofCal; }

◆ repSvcType()

virtual long RootEstTofCalibDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 35 of file RootEstTofCalibDataCnv.h.

◆ 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: