BOSS 7.0.5
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 245 of file RootEstTofCalibDataCnv.cxx.

246 {
247 MsgStream log(msgSvc(), "RootEstTofCalibDataCnv");
248
249 // Open the file, create the branch
250 StatusCode sc = openWrite(fname);
251 if(!sc)
252 { log<<MSG::ERROR<<"unable to open files"<<endreq;
253 }
254 // write the Data in the TCDS to RootFile
255 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
256
257 // write btoftree----------------------------------------------------------------
258 double cnvBarPar1[nBarPar];
259 double cnvBarPar2[nBarPar];
260
261 char brname[8], ibrname[8];
262 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
263 for( unsigned int i=0; i<nBarPar; i++ ) {
264 sprintf( brname, "P%i", i );
265 sprintf( ibrname, "P%i/D", i );
266 btoftree -> Branch( brname, &cnvBarPar1[i], ibrname );
267 }
268
269 for( int i=0; i<176; i++ ) {
270 for( int j=0;j<static_cast<int>(nBarPar);j++){
271 cnvBarPar1[j] = btof->getBTofPleft(i,j);
272 cnvBarPar2[j] = btof->getBTofPright(i,j);
273 }
274 btoftree -> Fill();
275 }
276
277 //write etoftree----------------------------------------------------------------
278 double cnvEndPar[nEndPar];
279
280 char ecname[8], iecname[8];
281 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
282 for( unsigned int i=0; i<nEndPar; i++ ) {
283 sprintf( ecname, "P%i", i );
284 sprintf( iecname, "P%i/D", i );
285 etoftree -> Branch( ecname, &cnvEndPar[i], iecname );
286 }
287
288 for(int i=0; i<96; i++){
289 for(int j=0;j<static_cast<int>(nEndPar);j++){
290 cnvEndPar[j] = btof->getETofP(i,j);
291 }
292 etoftree->Fill();
293 }
294
295 //write etftree----------------------------------------------------------------
296 double cnvEtfPar[nEtfPar];
297 double cnvEtfPar1[nEtfPar];
298 double cnvEtfPar2[nEtfPar];
299
300 char etfname[8], ietfname[8];
301 TTree *etftree = new TTree("EtfTofPar", "EtfTofPar");
302 for( unsigned int i=0; i<nEtfPar; i++ ) {
303 sprintf( etfname, "P%i", i );
304 sprintf( ietfname, "P%i/D", i );
305 etftree -> Branch( etfname, &cnvEtfPar[i], ietfname );
306 }
307 for( unsigned int i=0; i<nEtfPar; i++ ) {
308 sprintf( etfname, "P%i", i+nEtfPar );
309 sprintf( ietfname, "P%i/D", i+nEtfPar );
310 etftree -> Branch( etfname, &cnvEtfPar1[i], ietfname );
311 }
312 for( unsigned int i=0; i<nEtfPar; i++ ) {
313 sprintf( etfname, "P%i", i+2*nEtfPar );
314 sprintf( ietfname, "P%i/D", i+2*nEtfPar );
315 etftree -> Branch( etfname, &cnvEtfPar2[i], ietfname );
316 }
317
318 for( int i=0; i<72; i++ ) {
319 for( int k=0; k<12; k++ ) {
320 for(int j=0;j<static_cast<int>(nEtfPar);j++){
321 cnvEtfPar[j] = btof->getEtfPcombine(i,k,j);
322 cnvEtfPar1[j] = btof->getEtfPleft(i,k,j);
323 cnvEtfPar2[j] = btof->getEtfPright(i,k,j);
324 }
325 etftree -> Fill();
326 }
327 }
328
329 // write all the trees
330 btoftree -> Write();
331 etoftree -> Write();
332 etftree -> Write();
333 delete btoftree;
334 delete etoftree;
335 delete etftree;
336 closeWrite();
337 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
338
339 return sc;
340}
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
curve Fill()
curve Write()
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)
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)

◆ 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< btoftree->GetEntries(); 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<etoftree->GetEntries(); 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<etftree->GetEntries(); 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 int m_runFrom, m_runTo, m_eventFrom, m_eventTo;
212
213 TTree *CalibInfo = (TTree*)m_inFile -> Get("CalibInfo");
214
215 if( CalibInfo->GetBranchStatus("runFrom") ) {
216 CalibInfo->SetBranchAddress("runFrom", &m_runFrom );
217 CalibInfo->SetBranchAddress("runTo", &m_runTo );
218 CalibInfo->SetBranchAddress("eventFrom", &m_eventFrom );
219 CalibInfo->SetBranchAddress("eventTo", &m_eventTo );
220 }
221 else {
222 m_runFrom = -1;
223 m_runTo = -1;
224 m_eventFrom = -1;
225 m_eventTo = -1;
226 }
227
228 entries= CalibInfo->GetEntries();
229 for(cnt=0;cnt<entries;cnt++){
230 CalibInfo->GetEntry(cnt);
231 tofinfo.setRunFrom(m_runFrom);
232 tofinfo.setRunTo(m_runTo);
233 tofinfo.setEventFrom(m_eventFrom);
234 tofinfo.setEventTo(m_eventTo);
235 tofinfoCol.push_back(tofinfo);
236 }
237
238 CalibData::TofCalibData *tmpObject = new CalibData::TofCalibData(&tmpbTof,&tmpbTofCommon,&tmpeTof,&tmpetf,&tofinfoCol);
239
240 refpObject=tmpObject;
241
242 return StatusCode::SUCCESS;
243}
data GetEntry(0)
data SetBranchAddress("time",&time)
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: