BOSS 7.0.7
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 queryInterface (const InterfaceID &riid, void **ppvUnknown)
 
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 ()
 
virtual const double getSigma (int i)=0
 
virtual const double getCurve (int i)=0
 
virtual const int getCurveSize ()=0
 
virtual const int getSigmaSize ()=0
 

Additional Inherited Members

- Static Public Member Functions inherited from IDedxCurSvc
static const InterfaceID & interfaceID ()
 

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 32 of file DedxCurSvc.cxx.

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

◆ ~DedxCurSvc()

DedxCurSvc::~DedxCurSvc ( )

Definition at line 98 of file DedxCurSvc.cxx.

98 {
99}

Member Function Documentation

◆ finalize()

StatusCode DedxCurSvc::finalize ( )
virtual

Definition at line 91 of file DedxCurSvc.cxx.

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

◆ getCurve()

const double DedxCurSvc::getCurve ( int  i)
inlinevirtual

Implements IDedxCurSvc.

Definition at line 31 of file DedxCurSvc.h.

31{return m_curve[i];}

◆ getCurveSize()

const int DedxCurSvc::getCurveSize ( )
inlinevirtual

Implements IDedxCurSvc.

Definition at line 33 of file DedxCurSvc.h.

33{return m_curve_size;}

◆ getDedxCurveInfo()

void DedxCurSvc::getDedxCurveInfo ( )

Definition at line 117 of file DedxCurSvc.cxx.

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

Referenced by handle().

◆ getSigma()

const double DedxCurSvc::getSigma ( int  i)
inlinevirtual

Implements IDedxCurSvc.

Definition at line 32 of file DedxCurSvc.h.

32{return m_sigma[i];}

◆ getSigmaSize()

const int DedxCurSvc::getSigmaSize ( )
inlinevirtual

Implements IDedxCurSvc.

Definition at line 34 of file DedxCurSvc.h.

34{return m_sigma_size;}

◆ handle()

void DedxCurSvc::handle ( const Incident &  inc)

Definition at line 103 of file DedxCurSvc.cxx.

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

◆ initialize()

StatusCode DedxCurSvc::initialize ( )
virtual

Definition at line 51 of file DedxCurSvc.cxx.

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

◆ queryInterface()

StatusCode DedxCurSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
)
virtual

Definition at line 41 of file DedxCurSvc.cxx.

41 {
42
43 if ( IID_IDedxCurSvc.versionMatch(riid) ) {
44 *ppvInterface = static_cast<IDedxCurSvc*> (this);
45 }
46 else return Service::queryInterface(riid, ppvInterface) ;
47 return StatusCode::SUCCESS;
48}

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