BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RootTofQElecDataCnv.cxx
Go to the documentation of this file.
2#include "CalibData/Tof/TofElecData.h"
3#include "CalibDataSvc/IInstrumentName.h"
4#include "GaudiKernel/MsgStream.h"
5#include "TBuffer.h"
6#include "TDirectory.h"
7#include "TFile.h"
8#include "TObject.h"
9#include "TTree.h"
10
11#include "GaudiKernel/DataObject.h"
12#include "GaudiKernel/GenericAddress.h"
13#include "GaudiKernel/IAddressCreator.h"
14#include "GaudiKernel/IConversionSvc.h"
15#include "GaudiKernel/IDataProviderSvc.h"
16#include "GaudiKernel/IOpaqueAddress.h"
17
18#include "CalibDataSvc/ICalibMetaCnvSvc.h"
19#include "CalibDataSvc/ICalibTreeSvc.h" //maybe
20
21// Temporary. Hope to find a better way to do this
22#include "CalibData/CalibModel.h"
23using namespace CalibData;
24// static CnvFactory<RootTofElecDataCnv> TofCal_factory;
25// const ICnvFactory& RootTofElecDataCnvFactory = TofCal_factory;
26
29
30const CLID& RootTofElecDataCnv::objType() const { return CLID_TofQ_Elec; }
31
33
34StatusCode RootTofElecDataCnv::i_createObj( const std::string& fname,
35 DataObject*& refpObject ) {
36
37 MsgStream log( msgSvc(), "RootTofElecDataCnv" );
38 log << MSG::DEBUG << "SetProperty" << endmsg;
39 StatusCode sc = openRead( fname );
40 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
41
42 TTree* BarBoardNum = (TTree*)m_inFile->Get( "BarBoardNum" );
43 TTree* EndBoardNum = (TTree*)m_inFile->Get( "EndBoardNum" );
44 TTree* QElecBarParEast = (TTree*)m_inFile->Get( "QElecBarParEast" );
45 TTree* QElecBarParWest = (TTree*)m_inFile->Get( "QElecBarParWest" );
46 TTree* QElecEndPar = (TTree*)m_inFile->Get( "QElecEndPar" );
47 TTree* SimQElecBarParEast = (TTree*)m_inFile->Get( "SimQElecBarParEast" );
48 TTree* SimQElecBarParWest = (TTree*)m_inFile->Get( "SimQElecBarParWest" );
49 TTree* SimQElecEndPar = (TTree*)m_inFile->Get( "SimQElecEndPar" );
50
53
54 std::vector<CalibData::BarrelElec> tmpbTof; //; = new vector<CalibData::bTofCalibBase>;
55 std::vector<CalibData::EndcapElec> tmpeTof;
56
57 // Read in the object
58 int cnt;
59 // read btoftree ------------------------------------------------------------
60 unsigned int num[4];
61 double num1[4];
62 BarBoardNum->SetBranchAddress( "Board", &num1[0] );
63 BarBoardNum->SetBranchAddress( "Channel", &num1[1] );
64 BarBoardNum->SetBranchAddress( "Crate", &num1[2] );
65 BarBoardNum->SetBranchAddress( "Fee", &num1[3] );
66 double p[11];
67 QElecBarParEast->SetBranchAddress( "P0", &p[0] );
68 QElecBarParEast->SetBranchAddress( "P1", &p[1] );
69 QElecBarParEast->SetBranchAddress( "P2", &p[2] );
70 QElecBarParEast->SetBranchAddress( "P3", &p[3] );
71 QElecBarParEast->SetBranchAddress( "P4", &p[4] );
72 QElecBarParEast->SetBranchAddress( "P5", &p[5] );
73 QElecBarParEast->SetBranchAddress( "P6", &p[6] );
74 QElecBarParEast->SetBranchAddress( "P7", &p[7] );
75 QElecBarParEast->SetBranchAddress( "P8", &p[8] );
76 QElecBarParEast->SetBranchAddress( "P9", &p[9] );
77 QElecBarParEast->SetBranchAddress( "P10", &p[10] );
78 double p_w[11];
79 QElecBarParWest->SetBranchAddress( "P0", &p_w[0] );
80 QElecBarParWest->SetBranchAddress( "P1", &p_w[1] );
81 QElecBarParWest->SetBranchAddress( "P2", &p_w[2] );
82 QElecBarParWest->SetBranchAddress( "P3", &p_w[3] );
83 QElecBarParWest->SetBranchAddress( "P4", &p_w[4] );
84 QElecBarParWest->SetBranchAddress( "P5", &p_w[5] );
85 QElecBarParWest->SetBranchAddress( "P6", &p_w[6] );
86 QElecBarParWest->SetBranchAddress( "P7", &p_w[7] );
87 QElecBarParWest->SetBranchAddress( "P8", &p_w[8] );
88 QElecBarParWest->SetBranchAddress( "P9", &p_w[9] );
89 QElecBarParWest->SetBranchAddress( "P10", &p_w[10] );
90 double p_se[11];
91 SimQElecBarParEast->SetBranchAddress( "P0", &p_se[0] );
92 SimQElecBarParEast->SetBranchAddress( "P1", &p_se[1] );
93 SimQElecBarParEast->SetBranchAddress( "P2", &p_se[2] );
94 SimQElecBarParEast->SetBranchAddress( "P3", &p_se[3] );
95 SimQElecBarParEast->SetBranchAddress( "P4", &p_se[4] );
96 SimQElecBarParEast->SetBranchAddress( "P5", &p_se[5] );
97 SimQElecBarParEast->SetBranchAddress( "P6", &p_se[6] );
98 SimQElecBarParEast->SetBranchAddress( "P7", &p_se[7] );
99 SimQElecBarParEast->SetBranchAddress( "P8", &p_se[8] );
100 SimQElecBarParEast->SetBranchAddress( "P9", &p_se[9] );
101 SimQElecBarParEast->SetBranchAddress( "P10", &p_se[10] );
102 double p_sw[11];
103 SimQElecBarParWest->SetBranchAddress( "P0", &p_sw[0] );
104 SimQElecBarParWest->SetBranchAddress( "P1", &p_sw[1] );
105 SimQElecBarParWest->SetBranchAddress( "P2", &p_sw[2] );
106 SimQElecBarParWest->SetBranchAddress( "P3", &p_sw[3] );
107 SimQElecBarParWest->SetBranchAddress( "P4", &p_sw[4] );
108 SimQElecBarParWest->SetBranchAddress( "P5", &p_sw[5] );
109 SimQElecBarParWest->SetBranchAddress( "P6", &p_sw[6] );
110 SimQElecBarParWest->SetBranchAddress( "P7", &p_sw[7] );
111 SimQElecBarParWest->SetBranchAddress( "P8", &p_sw[8] );
112 SimQElecBarParWest->SetBranchAddress( "P9", &p_sw[9] );
113 SimQElecBarParWest->SetBranchAddress( "P10", &p_sw[10] );
114
115 for ( cnt = 0; cnt < 352; cnt++ )
116 {
117 BarBoardNum->GetEntry( cnt );
118 num[0] = num1[0];
119 num[1] = num1[1];
120 num[2] = num1[2];
121 num[3] = num1[3];
122 if ( cnt % 2 != 0 ) { bTof.setNumWest( num ); }
123 if ( cnt % 2 == 0 )
124 {
125 bTof.setNumEast( num );
126 int kkk = cnt / 2;
127 QElecBarParEast->GetEntry( kkk );
128 QElecBarParWest->GetEntry( kkk );
129 SimQElecBarParEast->GetEntry( kkk );
130 SimQElecBarParWest->GetEntry( kkk );
131 bTof.setP1( p );
132 bTof.setP2( p_w );
133 bTof.setSimP1( p_se );
134 bTof.setSimP2( p_sw );
135 }
136 if ( cnt % 2 != 0 ) tmpbTof.push_back( bTof );
137 }
138
139 // read etoftree
140 EndBoardNum->SetBranchAddress( "Board", &num1[0] );
141 EndBoardNum->SetBranchAddress( "Channel", &num1[1] );
142 EndBoardNum->SetBranchAddress( "Crate", &num1[2] );
143 EndBoardNum->SetBranchAddress( "Fee", &num1[3] );
144 QElecEndPar->SetBranchAddress( "P0", &p[0] );
145 QElecEndPar->SetBranchAddress( "P1", &p[1] );
146 QElecEndPar->SetBranchAddress( "P2", &p[2] );
147 QElecEndPar->SetBranchAddress( "P3", &p[3] );
148 QElecEndPar->SetBranchAddress( "P4", &p[4] );
149 QElecEndPar->SetBranchAddress( "P5", &p[5] );
150 QElecEndPar->SetBranchAddress( "P6", &p[6] );
151 QElecEndPar->SetBranchAddress( "P7", &p[7] );
152 QElecEndPar->SetBranchAddress( "P8", &p[8] );
153 QElecEndPar->SetBranchAddress( "P9", &p[9] );
154 QElecEndPar->SetBranchAddress( "P10", &p[10] );
155 SimQElecEndPar->SetBranchAddress( "P0", &p_w[0] );
156 SimQElecEndPar->SetBranchAddress( "P1", &p_w[1] );
157 SimQElecEndPar->SetBranchAddress( "P2", &p_w[2] );
158 SimQElecEndPar->SetBranchAddress( "P3", &p_w[3] );
159 SimQElecEndPar->SetBranchAddress( "P4", &p_w[4] );
160 SimQElecEndPar->SetBranchAddress( "P5", &p_w[5] );
161 SimQElecEndPar->SetBranchAddress( "P6", &p_w[6] );
162 SimQElecEndPar->SetBranchAddress( "P7", &p_w[7] );
163 SimQElecEndPar->SetBranchAddress( "P8", &p_w[8] );
164 SimQElecEndPar->SetBranchAddress( "P9", &p_w[9] );
165 SimQElecEndPar->SetBranchAddress( "P10", &p_w[10] );
166 for ( cnt = 0; cnt < 96; cnt++ )
167 {
168 EndBoardNum->GetEntry( cnt );
169 QElecEndPar->GetEntry( cnt );
170 SimQElecEndPar->GetEntry( cnt );
171 num[0] = num1[0];
172 num[1] = num1[1];
173 num[2] = num1[2];
174 num[3] = num1[3];
175 eTof.setNum( num );
176 eTof.setP( p );
177 eTof.setSimP( p_w );
178 tmpeTof.push_back( eTof );
179 }
180
181 CalibData::TofElecData* tmpObject = new CalibData::TofElecData( &tmpbTof, &tmpeTof );
182
183 refpObject = tmpObject;
184 delete BarBoardNum;
185 delete EndBoardNum;
186 delete QElecBarParEast;
187 delete QElecBarParWest;
188 delete QElecEndPar;
189 delete SimQElecBarParEast;
190 delete SimQElecBarParWest;
191 delete SimQElecEndPar;
192
193 return StatusCode::SUCCESS;
194}
IMessageSvc * msgSvc()
void setNumEast(unsigned int idx, unsigned int num)
void setNumWest(unsigned int idx, unsigned int num)
StatusCode openRead(const std::string &fname)
RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)
const CLID & objType() const
virtual StatusCode i_createObj(const std::string &fname, DataObject *&refpObject)
RootTofElecDataCnv(ISvcLocator *svc)
static const CLID & classID()