BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DedxCurSvc Class Reference

#include <DedxCurSvc.h>

+ Inheritance diagram for DedxCurSvc:

Public Member Functions

 DedxCurSvc (const std::string &name, ISvcLocator *svcloc)
 
 ~DedxCurSvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
void getDedxCurveInfo ()
 
const double getCurve (int i)
 
const double getSigma (int i)
 
const int getCurveSize ()
 
const int getSigmaSize ()
 

Detailed Description

Definition at line 16 of file DedxCurSvc.h.

Constructor & Destructor Documentation

◆ DedxCurSvc()

DedxCurSvc::DedxCurSvc ( const std::string &  name,
ISvcLocator *  svcloc 
)

Definition at line 34 of file DedxCurSvc.cxx.

34 : base_class(name, svcloc) {
35declareProperty("BossRelease",m_bossRelease="default");
36declareProperty("BossVer",m_sftver="default");
37declareProperty("ParVer",m_calParVer="default");
38declareProperty("DbStatus",m_dbStatus="OK");
39declareProperty("Type",m_type="default");
40}

◆ ~DedxCurSvc()

DedxCurSvc::~DedxCurSvc ( )

Definition at line 100 of file DedxCurSvc.cxx.

100 {
101}

Member Function Documentation

◆ finalize()

StatusCode DedxCurSvc::finalize ( )
virtual

Definition at line 93 of file DedxCurSvc.cxx.

93 {
94 MsgStream log(msgSvc(), name());
95 log << MSG::INFO << name() << ": End of Run" << endreq;
96 return StatusCode::SUCCESS;
97}
IMessageSvc * msgSvc()

◆ getCurve()

const double DedxCurSvc::getCurve ( int  i)
inline

Definition at line 31 of file DedxCurSvc.h.

31{return m_curve[i];}

◆ getCurveSize()

const int DedxCurSvc::getCurveSize ( )
inline

Definition at line 33 of file DedxCurSvc.h.

33{return m_curve_size;}

◆ getDedxCurveInfo()

void DedxCurSvc::getDedxCurveInfo ( )

Definition at line 119 of file DedxCurSvc.cxx.

119 {
120 MsgStream log(messageService(), name());
121 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
122 int run = eventHeader->runNumber();
123 if(run<0){
124 log << MSG::INFO << "This data is the MC sample with the Run Number: " << run << endreq;
125 if(m_type=="Sim"){
126 run=-run;
127 log << MSG::INFO << "Reverse the sign of Run Number" << endreq;
128 }
129 }
130 // unsigned long *lengths;
131 MYSQL_RES *res_set;
132 MYSQL_ROW row;
133 char stmt1[400];
134
135 std::string sftver;
136
137 if(m_sftver == "default" && m_bossRelease == "default")
138 {
139 log << MSG::FATAL << " BossRelease and BossVer for DedxCurve not set!" << endreq;
140 exit(1);
141 }
142
143 if( (run<m_runFromMax || run>m_runToMin) )
144 {
145 if(m_sftver == "default")
146 {
147 sprintf(stmt1,"select RunFrom, RunTo, SftVer, ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType = 'DedxCurve'", m_bossRelease.c_str(), run, run);
148 std::cout<<stmt1<<std::endl;
150 int row_no = m_dbsvc->query("offlinedb",stmt1,rest);
151 if(row_no==0) {
152 log << MSG::FATAL << "can not find result for DedxCur with: " << stmt1 << endreq;
153 exit(1);
154 }
155 if(row_no>1) {
156 log << MSG::FATAL << "find more than 1 results for DedxCur with: " << stmt1 << endreq;
157 exit(1);
158 }
159 DatabaseRecord* recordst = rest[0];
160 sftver = recordst->GetString("SftVer");
161 m_calParVer = recordst->GetString("ParVer");
162 m_runFromMax = atoi((recordst->GetString("RunFrom")).c_str());
163 m_runToMin = atoi((recordst->GetString("RunTo")).c_str());
164 log << MSG::INFO << "get from CalVtxLumVer, m_runFromMax: "<< m_runFromMax << " m_runToMin: "<<m_runToMin<< endreq;
165 }
166 else
167 sftver = m_sftver;
168
169 if(m_calParVer!="default")
170 sprintf(stmt1,"select RunFrom, RunTo, DedxCurvePar,DedxSigmaPar, SftVer, CurveFileName from DedxCurvePar where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and DedxCurveParVer = %s and Status='%s'",sftver.c_str(),run,run,m_calParVer.c_str(), m_dbStatus.c_str());
171 else
172 sprintf(stmt1,"select RunFrom, RunTo, DedxCurvePar,DedxSigmaPar, SftVer, CurveFileName from DedxCurvePar where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and Status='%s' order by DedxCurveParVer desc",sftver.c_str(),run,run, m_dbStatus.c_str());
173 std::cout<<stmt1<<std::endl;
174
176 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
177 if(row_no==0){
178 log << MSG::FATAL << "can not find result for DedxCur with: "<< stmt1 << endreq;
179 exit(1);
180 }
181 if(row_no>1){
182 log << MSG::FATAL << "find more than 1 results for DedxCur with: "<< stmt1 << endreq;
183 exit(1);
184 }
185
186 DatabaseRecord* records = res[0];
187 int runFrom = atoi((records->GetString("RunFrom")).c_str());
188 int runTo = atoi((records->GetString("RunTo")).c_str());
189 std::cout << "before output DedxCurveService version" << endl;
190 std::cout<<" SftVer is " << records->GetString("SftVer")
191 // << " CalVerSft is "<<records->GetString("CalParVer")
192 << " File name is "<<records->GetString("CurveFileName")
193 << std::endl;
194 std::cout << "after output DedxCurveService version" << endl;
195
196 if(m_sftver=="default")
197 {
198 m_runFromMax = runFrom>m_runFromMax? runFrom:m_runFromMax;
199 m_runToMin = runTo<m_runToMin? runTo:m_runToMin;
200 }
201 else
202 {
203 m_runFromMax = runFrom;
204 m_runToMin = runTo;
205 }
206 log << MSG::INFO << "get from DedxCurvePar runFrom: "<< runFrom << " runTo: "<<runTo<< endreq;
207 log << MSG::INFO << "m_runFromMax: "<< m_runFromMax << " m_runToMin: "<<m_runToMin<< endreq;
208
209 TBuffer *buf1 = new TBufferFile(TBuffer::kRead);
210 buf1->SetBuffer((*records)["DedxCurvePar"],327680,kFALSE);
211 TBuffer *buf2 = new TBufferFile(TBuffer::kRead);
212 buf2->SetBuffer((*records)["DedxSigmaPar"],327680,kFALSE);
213
214
215 TTree* curvetree = new TTree();
216 curvetree->Streamer(*buf1);
217
218 TTree* sigmatree = new TTree();
219 sigmatree->Streamer(*buf2);
220
221 double curve[50];
222 double sigma[50];
223 int SigmaSize;
224 int CurveSize;
225 curvetree -> SetBranchAddress("curve", curve);
226 curvetree -> SetBranchAddress("CurveSize", &CurveSize);
227 sigmatree -> SetBranchAddress("sigma", sigma);
228 sigmatree -> SetBranchAddress("SigmaSize", &SigmaSize);
229
230 Int_t nentries_curve = (Int_t)curvetree ->GetEntries();
231 Int_t nentries_sigma = (Int_t)sigmatree ->GetEntries();
232 curvetree -> GetEntry(0);
233 if(CurveSize>50){
234 log << MSG::ERROR<<"CurveSize larger than designed number"<<endreq;
235 exit(1);}
236 for(int i=0; i<CurveSize;i++){
237 m_curve[i]=curve[i];
238 }
239
240 sigmatree-> GetEntry(0);
241 if(SigmaSize>50){
242 log << MSG::ERROR<<"SigmaSize larger than designed number"<<endreq;
243 exit(1);}
244 for(int i=0; i<SigmaSize;i++){
245 m_sigma[i]=sigma[i];}
246 m_curve_size=CurveSize;
247 m_sigma_size=SigmaSize;
248 delete curvetree;
249 delete sigmatree;
250 }
251 return;
252}
TTree * sigma
int SigmaSize
TTree * curve
int CurveSize
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
data GetEntry(0)
data SetBranchAddress("time",&time)
struct st_mysql_res MYSQL_RES
std::string GetString(std::string key)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

Referenced by handle().

◆ getSigma()

const double DedxCurSvc::getSigma ( int  i)
inline

Definition at line 32 of file DedxCurSvc.h.

32{return m_sigma[i];}

◆ getSigmaSize()

const int DedxCurSvc::getSigmaSize ( )
inline

Definition at line 34 of file DedxCurSvc.h.

34{return m_sigma_size;}

◆ handle()

void DedxCurSvc::handle ( const Incident &  inc)

Definition at line 105 of file DedxCurSvc.cxx.

105 {
106 MsgStream log( messageService(), name() );
107 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
108
109 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
110 int run = eventHeader->runNumber();
111
112 if ( inc.type() == "NewRun" ){
113 log << MSG::DEBUG << "New Run:" << run << endreq;
115 }
116}
void getDedxCurveInfo()
Definition: DedxCurSvc.cxx:119

◆ initialize()

StatusCode DedxCurSvc::initialize ( )
virtual

Definition at line 53 of file DedxCurSvc.cxx.

53 {
54
55 MsgStream log(msgSvc(), name());
56 log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
57
58 StatusCode sc = Service::initialize();
59 if ( sc.isFailure() ) return sc;
60
61 IIncidentSvc* incsvc;
62 sc = service("IncidentSvc", incsvc);
63 int priority = 100;
64 if( sc.isSuccess() ){
65 incsvc -> addListener(this, "NewRun", priority);
66 }
67
68
69 sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
70 if (sc .isFailure() ) {
71 log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
72 return sc;
73 }
74
75
76 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
77 if (sc .isFailure() ) {
78 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
79 return sc;
80 }
81
82 StatusCode scc;
83 log<<MSG::INFO << "setProperties()" << endreq;
84 scc = setProperties();
85
86 m_runFromMax=0;
87 m_runToMin=0;
88
89 return sc;
90}

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