BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
RootDedxCalibDataCnv Class Reference

#include <RootDedxCalibDataCnv.h>

+ Inheritance diagram for RootDedxCalibDataCnv:

Public Member Functions

const CLID & objType () const
 
 RootDedxCalibDataCnv (ISvcLocator *svc)
 
virtual ~RootDedxCalibDataCnv ()
 
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< RootDedxCalibDataCnv >
 

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 RootDedxCalibDataCnv.h.

Constructor & Destructor Documentation

◆ RootDedxCalibDataCnv()

RootDedxCalibDataCnv::RootDedxCalibDataCnv ( ISvcLocator *  svc)

Definition at line 35 of file RootDedxCalibDataCnv.cxx.

35 :
37}
const CLID CLID_Calib_DedxCal
Definition: CalibModel.h:45

◆ ~RootDedxCalibDataCnv()

virtual RootDedxCalibDataCnv::~RootDedxCalibDataCnv ( )
inlinevirtual

Definition at line 29 of file RootDedxCalibDataCnv.h.

29{};

Member Function Documentation

◆ classID()

const CLID & RootDedxCalibDataCnv::classID ( )
static

Definition at line 44 of file RootDedxCalibDataCnv.cxx.

44 {
45 return CLID_Calib_DedxCal;
46}

◆ createRoot()

StatusCode RootDedxCalibDataCnv::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 293 of file RootDedxCalibDataCnv.cxx.

294 {
295
296 MsgStream log(msgSvc(), "RootDedxCalibDataCnv");
297
298 // Open the file, create the branch
299 StatusCode sc = openWrite(fname);
300 if(!sc)
301 { log<<MSG::ERROR<<"unable to open files"<<endreq;
302 }
303 // write the Data in the TCDS to RootFile
304 int i;
305 CalibData::DedxCalibData* tmpObject = dynamic_cast<CalibData::DedxCalibData*>(pTDSObj);
306 // write rungcalib ------------------------------------------------------------
307 double rungain;
308 double runmean;
309 double runno;
310 double runresol;
311 TTree *rungcalibtree = new TTree("rungcalib", "rungCalib");
312 rungcalibtree -> Branch("rungain", &rungain, "S/D");
313 rungcalibtree -> Branch("runmean", &runmean, "S/D");
314 rungcalibtree -> Branch("runno", &runno, "S/D");
315 rungcalibtree -> Branch("runresol", &runresol, "S/D");
316 int N = tmpObject->getrunNO();
317 for(i=0; i<N; i++){
318 rungain = tmpObject->getrung(0,i);
319 runmean = tmpObject->getrung(1,i);
320 runno = tmpObject->getrung(2,i);
321 runresol = tmpObject->getrung(3,i);
322 rungcalibtree -> Fill();
323 }
324
325
326
327 // write ddgcalib----------------------------------------------------------------
328 double ddg0;
329 double ddg1;
330 double ddg2;
331 double ddg3;
332 TTree *ddgcalibtree = new TTree("ddgcalib", "ddgCalib");
333 ddgcalibtree -> Branch("ddg0", &ddg0, "S/D");
334 ddgcalibtree -> Branch("ddg1", &ddg1, "S/D");
335 ddgcalibtree -> Branch("ddg2", &ddg2, "S/D");
336 ddgcalibtree -> Branch("ddg3", &ddg3, "S/D");
337 for(i=0; i<43; i++){
338 ddg0 = tmpObject->getddg(0,i);
339 ddg1 = tmpObject->getddg(1,i);
340 ddg2 = tmpObject->getddg(2,i);
341 ddg3 = tmpObject->getddg(3,i);
342 ddgcalibtree -> Fill();
343 }
344
345 // write ggscalib----------------------------------------------------------------
346 double ggs0;
347 double ggs1;
348 double ggs2;
349 double ggs3;
350 TTree *ggscalibtree = new TTree("ggscalib", "ggsCalib");
351 ggscalibtree -> Branch("ggs0", &ggs0, "S/D");
352 ggscalibtree -> Branch("ggs1", &ggs1, "S/D");
353 ggscalibtree -> Branch("ggs2", &ggs2, "S/D");
354 ggscalibtree -> Branch("ggs3", &ggs3, "S/D");
355 for(i=0; i<43; i++){
356 ggs0 = tmpObject->getggs(0,i);
357 ggs1 = tmpObject->getggs(1,i);
358 ggs2 = tmpObject->getggs(2,i);
359 ggs3 = tmpObject->getggs(3,i);
360 ggscalibtree -> Fill();
361 }
362
363// write zdepcalib----------------------------------------------------------------
364 double zdep0;
365 double zdep1;
366 double zdep2;
367 double zdep3;
368 TTree *zdepcalibtree = new TTree("zdepcalib", "zdepCalib");
369 zdepcalibtree -> Branch("zdep0", &zdep0, "S/D");
370 zdepcalibtree -> Branch("zdep1", &zdep1, "S/D");
371 zdepcalibtree -> Branch("zdep2", &zdep2, "S/D");
372 zdepcalibtree -> Branch("zdep3", &zdep3, "S/D");
373 for(i=0; i<43; i++){
374 zdep0 = tmpObject->getzdep(0,i);
375 zdep1 = tmpObject->getzdep(1,i);
376 zdep2 = tmpObject->getzdep(2,i);
377 zdep3 = tmpObject->getzdep(3,i);
378 zdepcalibtree -> Fill();
379 }
380
381// write entacalib----------------------------------------------------------------
382 double enta0;
383 double enta1;
384 double enta2;
385 double enta3;
386 TTree *entacalibtree = new TTree("entacalib", "entaCalib");
387 entacalibtree -> Branch("enta0", &enta0, "S/D");
388 entacalibtree -> Branch("enta1", &enta1, "S/D");
389 entacalibtree -> Branch("enta2", &enta2, "S/D");
390 entacalibtree -> Branch("enta3", &enta3, "S/D");
391 for(i=0; i<43; i++){
392 enta0 = tmpObject->getenta(0,i);
393 enta1 = tmpObject->getenta(1,i);
394 enta2 = tmpObject->getenta(2,i);
395 enta3 = tmpObject->getenta(3,i);
396 entacalibtree -> Fill();
397 }
398
399
400
401// write gain---------------------------------------------------------------------
402 double gain;
403 TTree *gaintree = new TTree("gaincalib", "gainCalib");
404 gaintree -> Branch("gain", &gain, "S/D");
405 gain = tmpObject->getgain();
406 gaintree -> Fill();
407
408// write resol---------------------------------------------------------------------
409 double resol;
410 TTree *resoltree = new TTree("resolcalib", "resolCalib");
411 resoltree -> Branch("resol", &resol, "S/D");
412 resol = tmpObject->getresol();
413 resoltree -> Fill();
414
415
416// write wiregcalib----------------------------------------------------------------
417 double wireg;
418 TTree *wiregcalibtree = new TTree("wiregcalib", "wiregCalib");
419 wiregcalibtree -> Branch("wireg", &wireg, "S/D");
420 for(i=0; i<6796; i++){
421 wireg = tmpObject->getwireg(i);
422 wiregcalibtree -> Fill();
423 }
424
425// write layergcalib----------------------------------------------------------------
426 double layerg;
427 TTree *layergcalibtree = new TTree("layergcalib", "layergCalib");
428 layergcalibtree -> Branch("layerg", &layerg, "S/D");
429 for(i=0; i<43; i++){
430 layerg = tmpObject->getlayerg(i);
431 layergcalibtree -> Fill();
432 }
433
434// write all the trees
435 rungcalibtree -> Write();
436 ddgcalibtree -> Write();
437 ggscalibtree -> Write();
438 zdepcalibtree -> Write();
439 entacalibtree -> Write();
440 gaintree -> Write();
441 resoltree -> Write();
442 wiregcalibtree -> Write();
443 layergcalibtree -> Write();
444
445 delete rungcalibtree;
446 delete ddgcalibtree;
447 delete ggscalibtree;
448 delete zdepcalibtree;
449 delete entacalibtree;
450 delete gaintree;
451 delete resoltree;
452 delete wiregcalibtree;
453 delete layergcalibtree;
454 closeWrite();
455 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
456 return sc;
457
458}
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
curve Fill()
curve Write()
IMessageSvc * msgSvc()
double getenta(int i, int j) const
Definition: DedxCalibData.h:70
double getzdep(int i, int j) const
Definition: DedxCalibData.h:64
double getrung(int i, int j) const
Definition: DedxCalibData.h:73
double getresol() const
Definition: DedxCalibData.h:66
double getlayerg(int i) const
Definition: DedxCalibData.h:68
double getwireg(int i) const
Definition: DedxCalibData.h:60
double getddg(int i, int j) const
Definition: DedxCalibData.h:56
double getggs(int i, int j) const
Definition: DedxCalibData.h:58
double getgain() const
Definition: DedxCalibData.h:62
StatusCode closeWrite()
virtual StatusCode openWrite(const std::string &fname)

◆ i_createObj()

StatusCode RootDedxCalibDataCnv::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 48 of file RootDedxCalibDataCnv.cxx.

49 {
50
51 MsgStream log(msgSvc(), "RootDedxCalibDataCnv");
52 log<<MSG::DEBUG<<"SetProperty"<<endreq;
53 StatusCode sc = openRead(fname);
54 if(!sc)
55 { log<<MSG::ERROR<<"unable to open files"<<endreq;
56 }
57
59 // Read in our object
60 int i;
61 // read rungcalib ------------------------------------------------------------
62 double rungain;
63 double runmean;
64 int runno, evtfrom, evtto;
65 double runresol;
66 TTree *rungtree = (TTree*)m_inFile -> Get("runcalib");
67 rungtree -> SetBranchAddress("rungain", &rungain);
68 rungtree -> SetBranchAddress("runmean", &runmean);
69 rungtree -> SetBranchAddress("runno", &runno);
70 rungtree -> SetBranchAddress("runresol", &runresol);
71 if(rungtree->GetBranchStatus("evtfrom")){ rungtree -> SetBranchAddress("evtfrom", &evtfrom); rungtree -> SetBranchAddress("evtto", &evtto); } else{ evtfrom = 0; evtto = 1000000000; }
72 int N = rungtree -> GetEntries();
73 tmpObject -> setrunNO(N);
74 //std::cout<<"N = "<<N<<std::endl;
75 for(i=0; i<N; i++){
76 rungtree -> GetEntry(i);
77 //std::cout<<rungain<<" "<<runmean<<" "<<runno<<" "<<runresol<<std::endl;
78 tmpObject -> setrung(rungain,0);
79 tmpObject -> setrung(runmean,1);
80 tmpObject -> setrung(runno,2);
81 tmpObject -> setrung(runresol,3);
82 tmpObject -> setrung(evtfrom,4);
83 tmpObject -> setrung(evtto,5);
84 }
85
86
87
88 // read ddgcalib ------------------------------------------------------------
89 double ddg0[43];
90 double ddg1[43];
91 double ddg2[43];
92 double ddg3[43];
93 double id_doca[1600];
94 double iner_chi[1600];
95 double iner_gain[1600];
96 double iner_hits[1600];
97 double ip_eangle[1600];
98 double out_chi[1600];
99 double out_gain[1600];
100 double out_hits[1600];
101
102 TTree *ddgtree = (TTree*)m_inFile -> Get("ddgcalib");
103 ddgtree -> SetBranchAddress("ddg0", ddg0);
104 ddgtree -> SetBranchAddress("ddg1", ddg1);
105 ddgtree -> SetBranchAddress("ddg2", ddg2);
106 ddgtree -> SetBranchAddress("ddg3", ddg3);
107 TBranch *bbb = ddgtree->FindBranch("Id_doca");
108 if(bbb){
109 ddgtree -> SetBranchAddress("Id_doca", id_doca);
110 ddgtree -> SetBranchAddress("Iner_chi", iner_chi);
111 ddgtree -> SetBranchAddress("Iner_gain", iner_gain);
112 ddgtree -> SetBranchAddress("Iner_hits", iner_hits);
113 ddgtree -> SetBranchAddress("Ip_eangle", ip_eangle);
114 ddgtree -> SetBranchAddress("Out_chi", out_chi);
115 ddgtree -> SetBranchAddress("Out_gain", out_gain);
116 ddgtree -> SetBranchAddress("Out_hits", out_hits);
117 }
118 ddgtree -> GetEntry(0);
119 for(i=0; i<43; i++){
120 tmpObject -> setddg(ddg0[i],0,i);
121 tmpObject -> setddg(ddg1[i],1,i);
122 tmpObject -> setddg(ddg2[i],2,i);
123 tmpObject -> setddg(ddg3[i],3,i);
124 }
125
126 for(i=0; i<1600; i++){
127 if(!bbb){
128 id_doca[i]=0;
129 iner_chi[i]=0;
130 iner_gain[i]=0;
131 iner_hits[i]=0;
132 ip_eangle[i]=0;
133 out_chi[i]=0;
134 out_gain[i]=0;
135 out_hits[i]=0;
136 }
137 tmpObject -> set_id_doca(id_doca[i],i);
138 tmpObject -> set_iner_chi(iner_chi[i],i);
139 tmpObject -> set_iner_gain(iner_gain[i],i);
140 tmpObject -> set_iner_hits(iner_hits[i],i);
141 tmpObject -> set_ip_eangle(ip_eangle[i],i);
142 tmpObject -> set_out_chi(out_chi[i],i);
143 tmpObject -> set_out_gain(out_gain[i],i);
144 tmpObject -> set_out_hits(out_hits[i],i);
145 }
146
147// read entratree---------------------------------------------
148 double entra0[43];
149 double entra1[43];
150 double entra2[43];
151 double entra3[43];
152 double engle[100];
153 int engle_no;
154 TTree *entratree = (TTree*)m_inFile -> Get("entracalib");
155 entratree -> SetBranchAddress("entra0", entra0);
156 entratree -> SetBranchAddress("entra1", entra1);
157 entratree -> SetBranchAddress("entra2", entra2);
158 entratree -> SetBranchAddress("entra3", entra3);
159 entratree -> SetBranchAddress("1denangle", engle);
160 entratree -> SetBranchAddress("1denangle_entry", &engle_no);
161 entratree -> GetEntry(0);
162 for(i=0; i<43; i++){
163 tmpObject -> setenta(entra0[i],0,i);
164 tmpObject -> setenta(entra1[i],1,i);
165 tmpObject -> setenta(entra2[i],2,i);
166 tmpObject -> setenta(entra3[i],3,i);
167 }
168 tmpObject -> set_enanglesize(engle_no);
169 for(i=0; i<engle_no; i++){
170 tmpObject -> set_enangle(engle[i],i);
171 }
172
173
174
175// read ggscalib ------------------------------------------------------------
176 double ggs0[43];
177 double ggs1[43];
178 double ggs2[43];
179 double ggs3[43];
180 double gcostheta[80];
181 int hadron_entry;
182 double hadron[20];
183 TTree *ggstree = (TTree*)m_inFile -> Get("ggscalib");
184 ggstree -> SetBranchAddress("ggs0", ggs0);
185 ggstree -> SetBranchAddress("ggs1", ggs1);
186 ggstree -> SetBranchAddress("ggs2", ggs2);
187 ggstree -> SetBranchAddress("ggs3", ggs3);
188 ggstree -> SetBranchAddress("hadron", hadron);
189 ggstree -> SetBranchAddress("hadronNo", &hadron_entry);
190 if(bbb){
191 ggstree -> SetBranchAddress("costheta", gcostheta);
192 }
193 ggstree -> GetEntry(0);
194 for(i=0; i<43;i++){
195 tmpObject -> setggs(ggs0[i],0,i);
196 tmpObject -> setggs(ggs1[i],1,i);
197 tmpObject -> setggs(ggs2[i],2,i);
198 tmpObject -> setggs(ggs3[i],3,i);
199 }
200
201 for(i=0; i<80;i++){
202 if(!bbb) gcostheta[i]=0;
203 tmpObject ->set_costheta(gcostheta[i],i);
204 }
205
206 if(hadron_entry>20){
207 log<<MSG::FATAL<<"hadron entry is larger than 20, larger than designed"<<endreq;
208 return StatusCode::FAILURE;
209 }
210
211 tmpObject->set_hadronNo(hadron_entry);
212
213 for(i=0;i<hadron_entry;i++){
214 tmpObject->set_hadron(hadron[i],i);
215 }
216
217
218// read zdepcalib ------------------------------------------------------------
219 double zdep0[43];
220 double zdep1[43];
221 double zdep2[43];
222 double zdep3[43];
223 TTree *zdeptree = (TTree*)m_inFile -> Get("zdepcalib");
224 zdeptree -> SetBranchAddress("zdep0", zdep0);
225 zdeptree -> SetBranchAddress("zdep1", zdep1);
226 zdeptree -> SetBranchAddress("zdep2", zdep2);
227 zdeptree -> SetBranchAddress("zdep3", zdep3);
228 zdeptree -> GetEntry(0);
229
230 for(i=0; i<43;i++){
231 tmpObject -> setzdep(zdep0[i],0,i);
232 tmpObject -> setzdep(zdep1[i],1,i);
233 tmpObject -> setzdep(zdep2[i],2,i);
234 tmpObject -> setzdep(zdep3[i],3,i);
235 }
236
237// read gain ------------------------------------------------------------
238 double gain;
239 double gt0[35],gdedx[35];
240 TTree *gaintree = (TTree*)m_inFile -> Get("gaincalib");
241 gaintree -> SetBranchAddress("gain", &gain);
242 if(bbb){
243 gaintree -> SetBranchAddress("t0", gt0);
244 gaintree -> SetBranchAddress("dedx", gdedx);
245 }
246 gaintree -> GetEntry(0);
247 tmpObject -> setgain(gain);
248 for(i=0; i<35;i++){
249 if(!bbb){
250 gt0[i]=0;
251 gdedx[i]=0;
252 }
253 tmpObject->set_t0(gt0[i],i);
254 tmpObject->set_dedx(gdedx[i],i);
255 }
256
257// read resol----------------------------------------------------------------
258 double resol;
259 TTree *resoltree = (TTree*)m_inFile -> Get("resolcalib");
260 resoltree -> SetBranchAddress("resol", &resol);
261 resoltree -> GetEntry(0);
262 tmpObject -> setresol(resol);
263
264// read wireg----------------------------------------------------------------
265 double wireg[6796];
266 TTree *wiregtree = (TTree*)m_inFile -> Get("wiregcalib");
267 wiregtree -> SetBranchAddress("wireg",wireg);
268 wiregtree -> GetEntry(0);
269 for(i=0;i<6796;i++){
270 tmpObject -> setwireg(wireg[i],i);
271 }
272
273// read layerg----------------------------------------------------------------
274 double layerg[43];
275 TTree *layergtree = (TTree*)m_inFile -> Get("layergcalib");
276 layergtree -> SetBranchAddress("layerg",layerg);
277 layergtree -> GetEntry(0);
278
279 for(i=0;i<43;i++){
280 tmpObject -> setlayerg(layerg[i],i);
281 }
282
283 refpObject=tmpObject;
284 // delete pObj;
285 // std::cout<<"pObj.m_t0[Cell]="<<*(pObj->gett0()+Cell-1);
286 // dynamic_cast<CalibData::Mdct0& >(refpObject);
287 //refpObject = pObj;
288 // std::cout<<"refObject.m_t0[Cell]="<<*(refpObject->gett0()+Cell-1);
289 // refpObject = new Mdct0(&t0_tmp[0]);
290 return StatusCode::SUCCESS;
291}
data GetEntry(0)
data SetBranchAddress("time",&time)
void set_costheta(const double aa, int i)
void set_hadron(const double aa, int i)
void set_t0(const double aa, int i)
void set_dedx(const double aa, int i)
StatusCode openRead(const std::string &fname)

◆ objType()

const CLID & RootDedxCalibDataCnv::objType ( ) const

Definition at line 40 of file RootDedxCalibDataCnv.cxx.

40 {
41 return CLID_Calib_DedxCal;
42}

◆ repSvcType()

virtual long RootDedxCalibDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 34 of file RootDedxCalibDataCnv.h.

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

Friends And Related Function Documentation

◆ CnvFactory< RootDedxCalibDataCnv >

friend class CnvFactory< RootDedxCalibDataCnv >
friend

Definition at line 1 of file RootDedxCalibDataCnv.h.


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