BOSS 8.0.0
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
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< RootTofSimDataCnv >

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

Constructor & Destructor Documentation

◆ RootTofSimDataCnv()

RootTofSimDataCnv::RootTofSimDataCnv ( ISvcLocator * svc)

Definition at line 36 of file RootTofSimDataCnv.cxx.

RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)

◆ ~RootTofSimDataCnv()

virtual RootTofSimDataCnv::~RootTofSimDataCnv ( )
inlinevirtual

Definition at line 28 of file RootTofSimDataCnv.h.

28{};

Member Function Documentation

◆ classID()

const CLID & RootTofSimDataCnv::classID ( )
static

Definition at line 41 of file RootTofSimDataCnv.cxx.

41{ return CLID_Calib_TofSim; }

Referenced by CalibRootCnvSvc::createConverter().

◆ 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 131 of file RootTofSimDataCnv.cxx.

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

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

◆ objType()

const CLID & RootTofSimDataCnv::objType ( ) const

Definition at line 39 of file RootTofSimDataCnv.cxx.

39{ return CLID_Calib_TofSim; }

◆ repSvcType()

virtual long RootTofSimDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 32 of file RootTofSimDataCnv.h.

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