BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
RootTofSimDataCnv Class Reference

#include <RootTofSimDataCnv.h>

+ Inheritance diagram for RootTofSimDataCnv:

Public Member Functions

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

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 17 of file RootTofSimDataCnv.h.

Constructor & Destructor Documentation

◆ RootTofSimDataCnv()

RootTofSimDataCnv::RootTofSimDataCnv ( ISvcLocator * svc)

Definition at line 37 of file RootTofSimDataCnv.cxx.

37 :
39 }
const CLID CLID_Calib_TofSim
Definition CalibModel.h:59
RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)

◆ ~RootTofSimDataCnv()

virtual RootTofSimDataCnv::~RootTofSimDataCnv ( )
inlinevirtual

Definition at line 26 of file RootTofSimDataCnv.h.

26{};

Member Function Documentation

◆ classID()

const CLID & RootTofSimDataCnv::classID ( )
static

Definition at line 46 of file RootTofSimDataCnv.cxx.

46 {
47 return CLID_Calib_TofSim;
48}

◆ createRoot()

StatusCode RootTofSimDataCnv::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 136 of file RootTofSimDataCnv.cxx.

137 {
138 MsgStream log(msgSvc(), "RootTofSimDataCnv");
139
140 // Open the file, create the branch
141 StatusCode sc = openWrite(fname);
142 if(!sc)
143 { log<<MSG::ERROR<<"unable to open files"<<endreq;
144 }
145 // write the Data in the TCDS to RootFile
146 /* int i;
147 int j;
148 CalibData::TofCalibData* btof = dynamic_cast<CalibData::TofCalibData*>(pTDSObj);
149
150 // write btoftree----------------------------------------------------------------
151 double cnvP1[10];
152 double cnvP2[10];
153 double cnvW[4];
154 double cnvAtten[8];
155 double cnvQ;
156 double cnvSpeed[2];
157 TTree *btoftree = new TTree("BarTofPar", "BarTofPar");
158 btoftree -> Branch("Atten0",&cnvAtten[0], "Atten0/D");
159 btoftree -> Branch("Atten1",&cnvAtten[1], "Atten1/D");
160 btoftree -> Branch("Atten2",&cnvAtten[2], "Atten2/D");
161 btoftree -> Branch("Atten3",&cnvAtten[3], "Atten3/D");
162 btoftree -> Branch("Atten4",&cnvAtten[4], "Atten4/D");
163 btoftree -> Branch("Atten5",&cnvAtten[5], "Atten5/D");
164 btoftree -> Branch("Atten6",&cnvAtten[6], "Atten6/D");
165 btoftree -> Branch("Atten7",&cnvAtten[7], "Atten7/D");
166 btoftree -> Branch("Q0",&cnvQ, "Q0/D");
167 btoftree -> Branch("Speed0",&cnvSpeed[0], "Speed0/D");
168 btoftree -> Branch("Speed1",&cnvSpeed[1], "Speed1/D");
169 btoftree -> Branch("P0",&cnvP1[0], "P0/D");
170 btoftree -> Branch("P1",&cnvP1[1], "P1/D");
171 btoftree -> Branch("P2",&cnvP1[2], "P2/D");
172 btoftree -> Branch("P3",&cnvP1[3], "P3/D");
173 btoftree -> Branch("P4",&cnvP1[4], "P4/D");
174 btoftree -> Branch("P5",&cnvP1[5], "P5/D");
175 btoftree -> Branch("P6",&cnvP1[6], "P6/D");
176 btoftree -> Branch("P7",&cnvP1[7], "P7/D");
177 btoftree -> Branch("P8",&cnvP1[8], "P8/D");
178 btoftree -> Branch("P9",&cnvP1[9], "P9/D");
179 btoftree -> Branch("P10",&cnvP2[0], "P10/D");
180 btoftree -> Branch("P11",&cnvP2[1], "P11/D");
181 btoftree -> Branch("P12",&cnvP2[2], "P12/D");
182 btoftree -> Branch("P13",&cnvP2[3], "P13/D");
183 btoftree -> Branch("P14",&cnvP2[4], "P14/D");
184 btoftree -> Branch("P15",&cnvP2[5], "P15/D");
185 btoftree -> Branch("P16",&cnvP2[6], "P16/D");
186 btoftree -> Branch("P17",&cnvP2[7], "P17/D");
187 btoftree -> Branch("P18",&cnvP2[8], "P17/D");
188 btoftree -> Branch("P19",&cnvP2[9], "P17/D");
189 btoftree -> Branch("W0",&cnvW[0], "W0/D");
190 btoftree -> Branch("W1",&cnvW[1], "W1/D");
191 btoftree -> Branch("W2",&cnvW[2], "W2/D");
192 btoftree -> Branch("W3",&cnvW[3], "W3/D");
193
194 for(i=0; i<176; i++){
195 cnvAtten[0] = btof->getBTofAtten(i,0);
196 cnvAtten[1] = btof->getBTofAtten(i,1);
197 cnvAtten[2] = btof->getBTofAtten(i,2);
198 cnvQ = btof->getBTofQ(i);
199 cnvSpeed[0] = btof->getBTofSpeed(i,0);
200 cnvSpeed[1] = btof->getBTofSpeed(i,1);
201 for(j=0;j<10;j++){
202 cnvP1[j] = btof->getBTofPleft(i,j);
203 cnvP2[j] = btof->getBTofPright(i,j);
204 }
205 for(j=0;j<4;j++){
206 cnvW[j]=btof->getBTofW(i,j);
207 }
208 btoftree -> Fill();
209 }
210
211 //write etoftree----------------------------------------------------------------
212 double ecnvP[8];
213 double ecnvAtten[5];
214 double ecnvSpeed[3];
215 TTree *etoftree = new TTree("EndTofPar", "EndTofPar");
216 etoftree -> Branch("Atten0",&ecnvAtten[0], "Atten0/D");
217 etoftree -> Branch("Atten1",&ecnvAtten[1], "Atten1/D");
218 etoftree -> Branch("Atten2",&ecnvAtten[2], "Atten2/D");
219 etoftree -> Branch("Atten3",&ecnvAtten[3], "Atten3/D");
220 etoftree -> Branch("Atten4",&ecnvAtten[4], "Atten4/D");
221 etoftree -> Branch("Speed0",&ecnvSpeed[0], "Speed0/D");
222 etoftree -> Branch("Speed1",&ecnvSpeed[1], "Speed1/D");
223 etoftree -> Branch("P0",&ecnvP[0], "P0/D");
224 etoftree -> Branch("P1",&ecnvP[1], "P1/D");
225 etoftree -> Branch("P2",&ecnvP[2], "P2/D");
226 etoftree -> Branch("P3",&ecnvP[3], "P3/D");
227 etoftree -> Branch("P4",&ecnvP[4], "P4/D");
228 etoftree -> Branch("P5",&ecnvP[5], "P5/D");
229 etoftree -> Branch("P6",&ecnvP[6], "P6/D");
230 etoftree -> Branch("P7",&ecnvP[7], "P7/D");
231
232 for(i=0; i<96; i++){
233 ecnvAtten[0] = btof->getETofAtten(i,0);
234 ecnvAtten[1] = btof->getETofAtten(i,1);
235 ecnvAtten[2] = btof->getETofAtten(i,2);
236 ecnvSpeed[0] = btof->getETofSpeed(i,0);
237 ecnvSpeed[1] = btof->getETofSpeed(i,1);
238 for(j=0;j<8;j++){
239 ecnvP[j] = btof->getETofP(i,j);
240 }
241 etoftree -> Fill();
242 }
243// write all the trees
244 btoftree -> Write();
245 etoftree -> Write();
246 delete btoftree;
247 delete etoftree;
248 closeWrite();
249 log<<MSG::INFO<<"successfully create RootFile"<<endreq;
250*/
251 return sc;
252
253}
IMessageSvc * msgSvc()
virtual StatusCode openWrite(const std::string &fname)

◆ i_createObj()

StatusCode RootTofSimDataCnv::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 50 of file RootTofSimDataCnv.cxx.

51 {
52
53 MsgStream log(msgSvc(), "RootTofSimDataCnv");
54 log<<MSG::DEBUG<<"SetProperty"<<endreq;
55
56 // open the file
57 StatusCode sc = openRead(fname);
58 if(!sc)
59 { log<<MSG::ERROR<<"unable to open files"<<endreq;
60 }
61
65 std::vector<CalibData::BTofSimBase> tmpbTof;//; = new vector<CalibData::bTofCalibBase>;
66 std::vector<CalibData::ETofSimBase> tmpeTof;
67 std::vector<CalibData::TofSimConstBase> tofbaseCol;
68 // Read in the object
69 int cnt;
70 // read btoftree ------------------------------------------------------------
71 double AttenLength;
72 double Gain;
73 double Ratio;
74 double NoiseSmear;
75 TTree *btoftree = (TTree*)m_inFile -> Get("BTofSim");
76 btoftree -> SetBranchAddress("AttenLength", &AttenLength);
77 btoftree -> SetBranchAddress("Gain", &Gain);
78 btoftree -> SetBranchAddress("Ratio", &Ratio);
79 int entries=btoftree->GetEntries();
80 for(cnt=0; cnt<entries; cnt++){
81 btoftree -> GetEntry(cnt);
82 bTof.setGain(Gain);
83 bTof.setRatio(Ratio);
84 bTof.setAttenLength(AttenLength);
85 tmpbTof.push_back(bTof);
86 }
87 //read etoftree
88 TTree *etoftree = (TTree*)m_inFile -> Get("ETofSim");
89 etoftree -> SetBranchAddress("Gain", &Gain);
90 etoftree -> SetBranchAddress("AttenLength", &AttenLength);
91 etoftree -> SetBranchAddress("NoiseSmear", &NoiseSmear );
92 entries=etoftree->GetEntries();
93 for(cnt=0; cnt<entries; cnt++){
94 etoftree->GetEntry(cnt);
95 eTof.setGain(Gain);
96 eTof.setAttenLength(AttenLength);
97 eTof.setNoiseSmear(NoiseSmear);
98 tmpeTof.push_back(eTof);
99 }
100
101 //read SimConstants
102 double BarConstant,BarPMTGain,BarHighThres,BarLowThres,EndConstant,EndPMTGain,EndHighThres,EndLowThres,EndNoiseSwitch;
103 TTree *btofcommontree = (TTree*)m_inFile -> Get("SimConstants");
104 btofcommontree-> SetBranchAddress("BarConstant", &BarConstant);
105 btofcommontree-> SetBranchAddress("BarPMTGain", &BarPMTGain);
106 btofcommontree-> SetBranchAddress("BarHighThres", &BarHighThres);
107 btofcommontree-> SetBranchAddress("BarLowThres", &BarLowThres);
108 btofcommontree-> SetBranchAddress("EndConstant", &EndConstant);
109 btofcommontree-> SetBranchAddress("EndPMTGain", &EndPMTGain);
110 btofcommontree-> SetBranchAddress("EndHighThres", &EndHighThres);
111 btofcommontree-> SetBranchAddress("EndLowThres", &EndLowThres);
112 btofcommontree-> SetBranchAddress("EndNoiseSwitch", &EndNoiseSwitch);
113 entries = btofcommontree->GetEntries();
114 for(cnt=0;cnt<entries;cnt++){
115 btofcommontree->GetEntry(cnt);
116 tofbase.setBarLowThres(BarLowThres);
117 tofbase.setBarHighThres(BarHighThres);
118 tofbase.setEndLowThres(EndLowThres);
119 tofbase.setEndHighThres(EndHighThres);
120 tofbase.setBarPMTGain(BarPMTGain);
121 tofbase.setEndPMTGain(EndPMTGain);
122 tofbase.setBarConstant(BarConstant);
123 tofbase.setEndConstant(EndConstant);
124 tofbase.setEndNoiseSwitch(EndNoiseSwitch);
125 tofbaseCol.push_back(tofbase);
126 }
127
128 CalibData::TofSimData *tmpObject = new CalibData::TofSimData(&tofbaseCol,&tmpbTof,&tmpeTof);
129
130
131 refpObject=tmpObject;
132
133 return StatusCode::SUCCESS;
134}
data GetEntry(0)
data SetBranchAddress("time",&time)
void setRatio(double ratio)
Definition BTofSimBase.h:16
void setGain(double gain)
Definition BTofSimBase.h:15
void setAttenLength(double length)
Definition BTofSimBase.h:17
void setGain(double gain)
Definition ETofSimBase.h:14
void setAttenLength(double length)
Definition ETofSimBase.h:15
void setNoiseSmear(double noisesmear)
Definition ETofSimBase.h:16
void setBarConstant(const double bc)
void setBarHighThres(const double bhth)
void setEndNoiseSwitch(const double eswitch)
void setEndHighThres(const double ehth)
void setEndConstant(const double ec)
void setBarPMTGain(const double bg)
void setEndPMTGain(const double eg)
void setEndLowThres(const double elth)
void setBarLowThres(const double blth)
StatusCode openRead(const std::string &fname)

◆ objType()

const CLID & RootTofSimDataCnv::objType ( ) const

Definition at line 42 of file RootTofSimDataCnv.cxx.

42 {
43 return CLID_Calib_TofSim;
44}

◆ repSvcType()

virtual long RootTofSimDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 31 of file RootTofSimDataCnv.h.

31 {
33 }
unsigned const char CALIBROOT_StorageType

Friends And Related Symbol Documentation

◆ CnvFactory< RootTofSimDataCnv >

friend class CnvFactory< RootTofSimDataCnv >
friend

Definition at line 1 of file RootTofSimDataCnv.h.


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