BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
checkTof.cxx
Go to the documentation of this file.
1//$Header: /bes/bes/BossCvs/Calibration/CalibSvc/CalibTreeCnv/src/test/checkTof.cxx,v 1.2 2010/10/14 05:33:40 huangb Exp $
2/*#include <stdio.h>
3#include "GaudiKernel/Algorithm.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/Service.h"
7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "CalibData/Tof/TofCalibData.h"
10#include "CalibData/Tof/bTofCalibBase.h"
11#include "CalibData/CalibModel.h"
12#include "GaudiKernel/DataSvc.h"
13#include "CalibDataSvc/ICalibTreeSvc.h"
14using namespace std;
15/// Simple algorithm to test functioning of "the other" TDS
16class checkTof : public Algorithm {
17
18public:
19 checkTof(const std::string& name, ISvcLocator* pSvcLocator);
20
21 StatusCode initialize();
22
23 StatusCode execute();
24
25 StatusCode finalize();
26
27private:
28 IDataProviderSvc* m_pCalibDataSvc;
29 ICalibTreeSvc* m_pTreeSvc;
30 // Maybe something to say which kind of data to look up?
31
32};
33
34/// Instantiation of a static factory to create instances of this algorithm
35//static const AlgFactory<checkTof> Factory;
36//const IAlgFactory& UseCalibFactory = Factory;
37//const IAlgFactory& checkTofFactory = Factory;
38*/
39#include "checkTof.h"
40checkTof::checkTof( const std::string& name,
41 ISvcLocator* pSvcLocator )
42 : Algorithm ( name, pSvcLocator ), m_pCalibDataSvc(0)
43{
44 // Declare properties here.
45
46}
47
48
50 StatusCode sc;
51 MsgStream log(msgSvc(), name());
52 log << MSG::INFO << "Initialize()" << endreq;
53
54 // So far don't have any properties, but in case we do some day..
55// setProperties();
56
57 log<<MSG::INFO << "setProperties()" << endreq;
58
59 sc = service("CalibDataSvc", m_pCalibDataSvc, true);
60
61 if ( !sc.isSuccess() ) {
62 log << MSG::ERROR
63 << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc"
64 << endreq;
65 return sc;
66 } else {
67 log << MSG::DEBUG
68 << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc"
69 << endreq;
70 }
71
72 sc = service("CalibTreeCnvSvc", m_pTreeSvc, true);
73 if ( !sc.isSuccess() ) {
74 log << MSG::ERROR
75 << "Could not get ICalibTreeSvc interface of CalibTreeCnvSvc"
76 << endreq;
77 return sc;
78 }
79 // Get properties from the JobOptionsSvc
80
81 sc = setProperties();
82
83 return StatusCode::SUCCESS;
84
85}
86
87
88StatusCode checkTof::execute( ) {
89
90 MsgStream log(msgSvc(), name());
91
92 // Cheat for now since Windows is having trouble finding definition
93 // of Calibdata::Test_t
94 std::string fullPath = "/Calib/TofCal";
95 log << MSG::INFO<<"execute() fullPath = "<<fullPath<< endreq;
96
97 SmartDataPtr<CalibData::TofCalibData> btof(m_pCalibDataSvc, fullPath);
98
99 for(int i =0;i<176;i++)
100 {
101 double bAtten0 = btof->getBTofAtten(i,0);
102 double bAtten1 = btof->getBTofAtten(i,1);
103 double bP0 = btof->getBTofPleft(i,0);
104 double bP1 = btof->getBTofPleft(i,1);
105 double bP2 = btof->getBTofPleft(i,2);
106 double bP3 = btof->getBTofPleft(i,3);
107 double bP4 = btof->getBTofPleft(i,4);
108 double bP5 = btof->getBTofPleft(i,5);
109 double bP10 = btof->getBTofPright(i,0);
110
111
112 // double bQ = btof->getBTofQ(i);
113 double bSpeed0 = btof->getBTofSpeed(i,0);
114 double bSpeed1 = btof->getBTofSpeed(i,1);
115 // double bW1 = btof->getBTofW(i,0);
116 // double bW2 = btof->getBTofW(i,1);
117 // double bW3 = btof->getBTofW(i,2);
118 // double bW4 = btof->getBTofW(i,3);
119 std::cout<<"=========================================="<<"\n";
120 std::cout<<"cnt ="<<i<<"\n";
121 std::cout<<"Atten0="<<bAtten0<<"Atten1="<<bAtten1<<"Q="<<"bQ"<<"Speed0="<<bSpeed0<<"Speed1="<<bSpeed1<<"P0="<<bP0<<"P1="<<bP1<<"P2="<<bP2<<"P3="<<bP3<<"P4="<<bP4<<"P10="<<bP10;
122 std::cout<<"\n";
123 std::cout<<"P5="<<bP5<<"Q="<<"bQ";
124 // std::cout<<"W1="<<bW1<<"W2="<<bW2<<"W3="<<bW3<<"W4="<<bW4;
125 std::cout<<"\n";
126
127 /*
128 std::cout<<"Atten[1]="<<*(bAtten+1)<<"P0[1]="<<*(bP0+1)<<"P1[1]="<<*(bP1+1)<<"P2[1]="<<*(bP2+1)<<"P3[1]="<<*(bP3+1)<<"P4[1]="<<*(bP4+1);
129 std::cout<<"\n";
130 std::cout<<"P5[1]="<<*(bP5+1)<<"S[1]="<<*(bS+1)<<"SS[1]="<<*(bSS+1)<<"Veff[1]="<<*(bVeff+1);
131 */
132 }
133 for(int i =0;i<96;i++)
134 {
135 double eAtten0 = btof->getETofAtten(i,0);
136 double eAtten1 = btof->getETofAtten(i,1);
137 double eP0 = btof->getETofP(i,0);
138 double eP1 = btof->getETofP(i,1);
139 double eP2 = btof->getETofP(i,2);
140 double eP3 = btof->getETofP(i,3);
141 double eP4 = btof->getETofP(i,4);
142 double eP5 = btof->getETofP(i,5);
143 double eP6 = btof->getETofP(i,6);
144
145 double eSpeed0 = btof->getETofSpeed(i,0);
146 double eSpeed1 = btof->getETofSpeed(i,1);
147
148 std::cout<<"=========================================="<<"\n";
149 std::cout<<"cnt ="<<i<<"\n";
150
151 std::cout<<"Atten0="<<eAtten0<<"Atten1="<<eAtten1<<"Speed0="<<eSpeed0<<"Speed1="<<eSpeed1<<"P0="<<eP0<<"P1="<<eP1<<"P2="<<eP2<<"P3="<<eP3<<"P4="<<eP4<<"P6="<<eP6;
152 std::cout<<"\n";
153 std::cout<<"P5="<<eP5;
154 std::cout<<"\n";
155
156 }
157 //maqm comment because cann't write
158 // m_pTreeSvc->writeToTree("./Tof_test.root", fullPath);
159
160 return StatusCode::SUCCESS;
161}
162/*
163DataSvc::retrieveObject(fullPath,CalibData::CalibTest1);
164*/
165StatusCode checkTof::finalize( ) {
166
167 MsgStream log(msgSvc(), name());
168 log << MSG::INFO
169 << " checkTof FINALIZE!! "
170 << endreq;
171
172 return StatusCode::SUCCESS;
173}
174
175
IMessageSvc * msgSvc()
StatusCode initialize()
Definition: checkTof.cxx:49
StatusCode finalize()
Definition: checkTof.cxx:165
checkTof(const std::string &name, ISvcLocator *pSvcLocator)
Definition: checkTof.cxx:40
StatusCode execute()
Definition: checkTof.cxx:88