CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
RootMdcCalibDataCnv Class Reference

#include <RootMdcCalibDataCnv.h>

+ Inheritance diagram for RootMdcCalibDataCnv:

Public Member Functions

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

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
 

Friends

class CnvFactory< RootMdcCalibDataCnv >
 

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

Base class for CAL calibration converters from ROOT files to TCDS. All such converters need to do certain things, which are handled here. Methods common to all calibrations are in the base class RootCalBaseCnv

Author
J. Bogart

Definition at line 21 of file RootMdcCalibDataCnv.h.

Constructor & Destructor Documentation

◆ RootMdcCalibDataCnv()

RootMdcCalibDataCnv::RootMdcCalibDataCnv ( ISvcLocator * svc)

Definition at line 34 of file RootMdcCalibDataCnv.cxx.

34 :
36
37}
const CLID CLID_Calib_MdcCal
Definition CalibModel.h:41
RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)

◆ ~RootMdcCalibDataCnv()

virtual RootMdcCalibDataCnv::~RootMdcCalibDataCnv ( )
inlinevirtual

Definition at line 30 of file RootMdcCalibDataCnv.h.

30{};

Member Function Documentation

◆ classID()

const CLID & RootMdcCalibDataCnv::classID ( )
static

Definition at line 44 of file RootMdcCalibDataCnv.cxx.

44 {
45 return CLID_Calib_MdcCal;
46}

◆ createRoot()

StatusCode RootMdcCalibDataCnv::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 149 of file RootMdcCalibDataCnv.cxx.

150 {
151
152 MsgStream log(msgSvc(), "RootMdcCalibDataCnv");
153 // Open the file, create the branch
154 StatusCode sc = openWrite(fname);
155 if(!sc)
156 { log<<MSG::ERROR<<"unable to open files"<<endreq;
157 }
158 // write the Data in the TCDS to RootFile
159 CalibData::MdcCalibData* tmpObject = dynamic_cast<CalibData::MdcCalibData*>(pTDSObj);
160 int tmpNo;
161 int key;
162 double xtpar;
163 double t0;
164 double delt0;
165 double qtpar[2];
166 double sdpar;
167 int i;
168
169 //xttree------------------------------------------------------------------
170 TTree *xttree = new TTree("XtTree", "XtTree");
171 xttree -> Branch("xtkey", &key, "key/I");
172 xttree -> Branch("xtpar", &xtpar, "xtpar/D");
173 tmpObject -> setXtBegin();
174 while( tmpObject -> getNextXtpar(key, xtpar) ){
175 xttree -> Fill();
176 }
177 //newxttree------------------------------------------------------------------
178 //FIXME
179 /*
180 TObjArray newxttrees_1;
181 //TBufferFile newxttrees_buf(TBuffer::kWrite);
182 int nTree=0;
183 for(int t_layer=0; t_layer<43; t_layer++){
184 for(int t_bin=0; t_bin<18; t_bin++){
185 for(int t_lr=0; t_lr<2; t_lr++){
186 char newXtTreeName[20];
187 sprintf(newXtTreeName,"trNewXt%02d_%02d_%d",t_layer,t_bin,t_lr);
188 TTree *newXttree = ((TTree*)f->Get(newXtTreeName))->CloneTree();
189 newxttrees_1.Add(newXttree);
190 nTree++;
191 }
192 }
193 }
194 newxttrees_1.Streamer(newxttrees_buf);
195 */
196
197
198 //t0tree-------------------------------------------------------------------
199 TTree *t0tree = new TTree("T0Tree", "T0Tree");
200 t0tree -> Branch("t0", &t0, "t0/D");
201 t0tree -> Branch("delt0", &delt0, "delt0/D");
202 tmpNo = tmpObject -> gett0No();
203 for(i=0; i<tmpNo; i++){
204 t0 = tmpObject -> getT0(i);
205 delt0 = tmpObject -> getDelT0(i);
206 t0tree -> Fill();
207 }
208
209 //qttree--------------------------------------------------------------------
210 TTree *qttree = new TTree("QtTree", "QtTree");
211 qttree -> Branch("qtpar0", &(qtpar[0]), "qtpar0/D");
212 qttree -> Branch("qtpar1", &(qtpar[1]), "qtpar1/D");
213 tmpNo = tmpObject -> getqtparNo();
214 for(i=0; i<tmpNo; i++){
215 qtpar[0] = tmpObject -> getQtpar0(i);
216 qtpar[1] = tmpObject -> getQtpar1(i);
217 qttree -> Fill();
218 }
219
220 //sdtree--------------------------------------------------------------------
221 TTree *sdtree = new TTree("SdTree", "SdTree");
222 sdtree -> Branch("sdkey", &key, "key/I");
223 sdtree -> Branch("sdpar", &sdpar, "sdpar/D");
224 tmpObject -> setSdBegin();
225 while( tmpObject -> getNextSdpar(key, sdpar) ){
226 sdtree -> Fill();
227 }
228
229 xttree -> Write();
230 t0tree -> Write();
231 qttree -> Write();
232 sdtree -> Write();
233
234 delete xttree;
235 delete t0tree;
236 delete qttree;
237 delete sdtree;
238
239 closeWrite();
240 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
241 return sc;
242}
IMessageSvc * msgSvc()
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42
StatusCode closeWrite()
virtual StatusCode openWrite(const std::string &fname)

◆ i_createObj()

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

This creates the transient representation of an object from the corresponding ROOT object. This actually does the "new" operation and deals with the attributes of the node. This base class implementation does nothing; it should not normally be called because it doesn't correspond to any TCDS class. Instead, i_createObj of some derived class will be called.

Parameters
fnameThe ROOT file to be read in to be used to builds the object
refpObjectthe object to be built
Returns
status depending on the completion of the call

Reimplemented from RootCalBaseCnv.

Definition at line 48 of file RootMdcCalibDataCnv.cxx.

49 {
50
51 MsgStream log(msgSvc(), "RootMdcCalibDataCnv");
52 log<<MSG::DEBUG<<"SetProperty"<<endreq;
53
54 StatusCode sc = openRead(fname);
55 if(!sc)
56 { log<<MSG::ERROR<<"unable to open files"<<endreq;
57 }
58
60 // Read in our object
61 int i;
62 int nentries;
63 // read xttree ------------------------------------------------------------
64 double xtpar;
65 int xtkey;
66 TTree *xttree = (TTree*)m_inFile -> Get("XtTree");
67 xttree -> SetBranchAddress("xtpar", &xtpar);
68 xttree -> SetBranchAddress("xtkey", &xtkey);
69 nentries = xttree -> GetEntries();
70 for(i=0; i<nentries; i++){
71 xttree -> GetEntry(i);
72 tmpObject -> setXtpar(xtkey,xtpar);
73 }
74
75 // read newxttree ------------------------------------------------------------
76 TObjArray newXtTrees;
77 if(NULL!=m_inFile->Get("trNewXt00_00_0")){
78 for(int layid=0; layid<43; layid++){
79 for(int entr=0; entr<18; entr++){
80 for(int lr=0; lr<2; lr++){
81 char newXtTreeName[20];
82 sprintf(newXtTreeName,"trNewXt%02d_%02d_%d",layid,entr,lr);
83 TTree* newXtTree = ((TTree*)m_inFile->Get(newXtTreeName));
84 if(!newXtTree) break;
85 newXtTrees.Add(newXtTree->CloneTree());
86 }//end lr
87 }//end entr
88 }//end layid
89 if((43*18*2)==newXtTrees.GetEntries())tmpObject->setNewXtpar(&newXtTrees);
90 }
91
92
93 // read r2ttree ------------------------------------------------------------
94 TObjArray r2tTrees;
95 if(NULL!=m_inFile->Get("r2t00")){
96 for(int layid=0; layid<43; layid++){
97 char r2tTreeName[20];
98 sprintf(r2tTreeName,"r2t%02d",layid);
99 TTree* r2tTree = ((TTree*)m_inFile->Get(r2tTreeName));
100 if(!r2tTree) break;
101 r2tTrees.Add(r2tTree->CloneTree());
102 }
103 if(43==r2tTrees.GetEntries()) tmpObject->setR2tpar(&r2tTrees);
104 }
105
106 // read t0tree ------------------------------------------------------------
107 double t0;
108 double delt0;
109 TTree *t0tree = (TTree*)m_inFile -> Get("T0Tree");
110 t0tree -> SetBranchAddress("t0", &t0);
111 t0tree -> SetBranchAddress("delt0", &delt0);
112 nentries = t0tree -> GetEntries();
113 for(i=0; i<nentries; i++){
114 t0tree -> GetEntry(i);
115 tmpObject -> setT0(t0);
116 tmpObject -> setDelT0(delt0);
117 }
118
119 // read qttree ------------------------------------------------------------
120 double qtpar0;
121 double qtpar1;
122 TTree *qttree = (TTree*)m_inFile -> Get("QtTree");
123 qttree -> SetBranchAddress("qtpar0", &qtpar0);
124 qttree -> SetBranchAddress("qtpar1", &qtpar1);
125 nentries = qttree -> GetEntries();
126 for(i=0; i<nentries; i++){
127 qttree -> GetEntry(i);
128 tmpObject -> setQtpar0(qtpar0);
129 tmpObject -> setQtpar1(qtpar1);
130 }
131
132 // read Sdtree ---------------------------------------------------------
133 double sdpar;
134 int sdkey;
135 TTree *sdtree = (TTree*)m_inFile -> Get("SdTree");
136 sdtree -> SetBranchAddress("sdpar", &sdpar);
137 sdtree -> SetBranchAddress("sdkey", &sdkey);
138 nentries = sdtree -> GetEntries();
139
140 for(i=0; i<nentries; i++){
141 sdtree -> GetEntry(i);
142 tmpObject -> setSdpar(sdkey,sdpar);
143 }
144
145 refpObject=tmpObject;
146 return StatusCode::SUCCESS;
147}
data SetBranchAddress("time",&time)
data GetEntry(0)
Int_t nentries
void setR2tpar(TObjArray *r2tTrees)
void setNewXtpar(TObjArray *newXtTrees)
StatusCode openRead(const std::string &fname)

◆ objType()

const CLID & RootMdcCalibDataCnv::objType ( ) const

Definition at line 40 of file RootMdcCalibDataCnv.cxx.

40 {
41 return CLID_Calib_MdcCal;
42}

◆ repSvcType()

virtual long RootMdcCalibDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 35 of file RootMdcCalibDataCnv.h.

35 {
37 }
unsigned const char CALIBROOT_StorageType

Friends And Related Symbol Documentation

◆ CnvFactory< RootMdcCalibDataCnv >

friend class CnvFactory< RootMdcCalibDataCnv >
friend

Definition at line 1 of file RootMdcCalibDataCnv.h.


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