BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
MucCalibConstSvc.cxx
Go to the documentation of this file.
1//------------------------------------------------------------------------------|
2// [File ]: MucCalibConstSvc.cxx |
3// [Brief ]: Algorithom of MUC calibration constants service |
4// constants read from CalibDataSvc |
5// [Author]: Xie Yuguang, <[email protected]> |
6// [Date ]: Mar 15, 2007 |
7// [Log ]: See ChangLog |
8//------------------------------------------------------------------------------|
9
10#include "GaudiKernel/IInterface.h"
11#include "GaudiKernel/StatusCode.h"
12//#include "GaudiKernel/ISvcFactory.h"
13#include "GaudiKernel/SvcFactory.h"
14#include "GaudiKernel/MsgStream.h"
15
16#include "GaudiKernel/ISvcLocator.h"
17#include "GaudiKernel/Bootstrap.h"
18
19#include "GaudiKernel/IDataProviderSvc.h"
20#include "GaudiKernel/SmartDataPtr.h"
21#include "GaudiKernel/DataSvc.h"
22
27
29
30//static SvcFactory<MucCalibConstSvc> s_factory;
31//const ISvcFactory& MucCalibConstSvcFactory = s_factory;
32
33MucCalibConstSvc::MucCalibConstSvc( const std::string& name, ISvcLocator* svcloc) : Service (name, svcloc),
34 m_pCalibDataSvc(0)
35{
36 declareProperty("ConfigMode", m_fConfigMode=3);
37 declareProperty("UniformEff", m_fUniformEff=0.95);
38 declareProperty("UniformCnt", m_fUniformEff=0.05);
39 declareProperty("UniformNos", m_fUniformEff=0.001);
40 declareProperty("UniformNosRatio",m_fUniformNos=0.05);
41 declareProperty("UniformClst", m_fUniformClst=4);
42}
43
45
46StatusCode MucCalibConstSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)
47{
48 if( IID_IMucCalibConstSvc.versionMatch(riid) ){
49 *ppvInterface = static_cast<IMucCalibConstSvc*> (this);
50 } else {
51 return Service::queryInterface(riid, ppvInterface);
52 }
53 return StatusCode::SUCCESS;
54}
55
57{
58 MsgStream log(messageService(), name());
59 log << MSG::INFO << endreq << "initialize()" << endreq << endreq;
60 log << MSG::INFO << "Config mode:\t" << m_fConfigMode << endreq;
61 StatusCode sc = Service::initialize();
62 if( sc.isFailure() ) return sc;
63
64 sc = service("CalibDataSvc", m_pCalibDataSvc, true);
65 if( sc == StatusCode::SUCCESS ) {
66 log << MSG::INFO << "Retrieve IDataProviderSvc" << endreq;
67 }else{
68 log << MSG::FATAL << "can not get IDataProviderSvc" << endreq;
69 }
70
71 return StatusCode::SUCCESS;
72}
73
75{
76 MsgStream log(messageService(), name());
77 log << MSG::INFO << endreq << "finalize()" << endreq << endreq;
78 return StatusCode::SUCCESS;
79}
80
81//-----------------------------------------------------------------------------------|
82//------------------------------- Access by users -----------------------------------|
83//-----------------------------------------------------------------------------------|
84
85// Get config level
86inline int MucCalibConstSvc::getLevel() const {return m_fConfigMode;}
87
88// Get efficiency(Eff)
89inline double MucCalibConstSvc::getEff(int part, int segment, int layer, int strip ) const
90{
91 double eff = 0.0;
92 MsgStream log(messageService(), name());
93 // log << MSG::INFO << "In MucCalibDataSvc" << endreq;
94 std::string fullPath = "/Calib/MucCal";
95 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
96
97 if( ! pMucCalibConst ){
98 log << MSG::ERROR << "getEff() can not access to MucCalibData via SmartPtr" << endreq;
99 }else
100 {
101 switch( m_fConfigMode )
102 {
103 case 0 :
104 if( m_fUniformEff < 0 )
105 eff = pMucCalibConst->getUniformEff();
106 else
107 eff = m_fUniformEff;
108 break;
109 case 1 :
110 eff = pMucCalibConst->getLayerEff( layer );
111 break;
112 case 2 :
113 eff = pMucCalibConst->getBoxEff( part, segment, layer );
114 break;
115 case 3 :
116 eff = pMucCalibConst->getStripEff( part, segment, layer, strip );
117 break;
118 default: ;
119 }
120 }
121
122 return eff;
123}
124
125// Get counting rate(Cnt)
126inline double MucCalibConstSvc::getCnt(int part, int segment, int layer, int strip ) const
127{
128 double cnt = 0.0;
129 MsgStream log(messageService(), name());
130 std::string fullPath = "/Calib/MucCal";
131 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
132 if( ! pMucCalibConst ){
133 log << MSG::ERROR << "getCnt() can not access to MucCalibData via SmartPtr" << endreq;
134 }else
135 {
136 switch( m_fConfigMode )
137 {
138 case 0 :
139 if( m_fUniformCnt < 0 )
140 cnt = pMucCalibConst->getUniformCnt();
141 else
142 cnt = m_fUniformCnt;
143 break;
144 case 1 :
145 cnt = pMucCalibConst->getLayerCnt( layer );
146 break;
147 case 2 :
148 cnt = pMucCalibConst->getBoxCnt( part, segment, layer );
149 break;
150 case 3 :
151 cnt = pMucCalibConst->getStripCnt( part, segment, layer, strip );
152 break;
153 default: ;
154 }
155 }
156
157 return cnt;
158}
159
160// Get noise(Nos)
161inline double MucCalibConstSvc::getNos(int part, int segment, int layer, int strip ) const
162{
163 double nos = 0.0;
164 MsgStream log(messageService(), name());
165 std::string fullPath = "/Calib/MucCal";
166 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
167 if( ! pMucCalibConst ){
168 log << MSG::ERROR << "getNos() can not access to MucCalibData via SmartPtr" << endreq;
169 }else
170 {
171 switch( m_fConfigMode )
172 {
173 case 0 :
174 if( m_fUniformNos < 0 )
175 nos = pMucCalibConst->getUniformNos();
176 else
177 nos = m_fUniformNos;
178 break;
179 case 1 :
180 nos = pMucCalibConst->getLayerNos( layer );
181 break;
182 case 2 :
183 nos = pMucCalibConst->getBoxNos( part, segment, layer );
184 break;
185 case 3 :
186 nos = pMucCalibConst->getStripNos( part, segment, layer, strip );
187 break;
188 default: ;
189 }
190 }
191
192 return nos;
193}
194
195// Get noise ratio(NosRatio)
196inline double MucCalibConstSvc::getNosRatio(int part, int segment, int layer, int strip ) const
197{
198 double nosRatio = 0.0;
199 MsgStream log(messageService(), name());
200 std::string fullPath = "/Calib/MucCal";
201 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
202 if( ! pMucCalibConst ){
203 log << MSG::ERROR << "getNosRatio() can not access to MucCalibData via SmartPtr" << endreq;
204 }else
205 {
206 switch( m_fConfigMode )
207 {
208 case 0 :
209 if( m_fUniformNosRatio < 0 )
210 nosRatio = pMucCalibConst->getUniformNosRatio();
211 else
212 nosRatio = m_fUniformNosRatio;
213 break;
214 case 1 :
215 nosRatio = pMucCalibConst->getLayerNosRatio( layer );
216 break;
217 case 2 :
218 nosRatio = pMucCalibConst->getBoxNosRatio( part, segment, layer );
219 break;
220 case 3 :
221 nosRatio = pMucCalibConst->getStripNosRatio( part, segment, layer, strip );
222 break;
223 default: ;
224 }
225 }
226
227 return nosRatio;
228}
229
230// Get cluster size(Clst)
231inline double MucCalibConstSvc::getClst(int part, int segment, int layer, double prob ) const
232{
233 double cluster = 0.0;
234 MsgStream log(messageService(), name());
235 std::string fullPath = "/Calib/MucCal";
236 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
237 if( ! pMucCalibConst ){
238 log << MSG::ERROR << "getClst() can not access to MucCalibData via SmartPtr" << endreq;
239 }else
240 {
241 switch( m_fConfigMode )
242 {
243 case 0 :
244 if( m_fUniformClst < 0 )
245 cluster = pMucCalibConst->getUniformClst();
246 else
247 cluster = m_fUniformClst;
248 break;
249 case 1 :
250 cluster = pMucCalibConst->getLayerClst( layer, prob );
251 break;
252 case 2 :
253 cluster = pMucCalibConst->getBoxClst( part, segment, layer, prob );
254 break;
255 case 3 :
256 cluster = 0.0;
257 break;
258 default: ;
259 }
260 }
261
262 return cluster;
263}
264
265
266// Uniform constants
268{
269 double fUniformEff = 0.0;
270 MsgStream log(messageService(), name());
271
272 std::string fullPath = "/Calib/MucCal";
273 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
274 if( ! pMucCalibConst ){
275 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
276 }else {
277 fUniformEff= pMucCalibConst->getUniformEff();
278 }
279
280 return fUniformEff;
281}
282
284{
285 double fUniformCnt = 0.0;
286 MsgStream log(messageService(), name());
287
288 std::string fullPath = "/Calib/MucCal";
289 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
290 if( ! pMucCalibConst ){
291 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
292 }else {
293 fUniformCnt= pMucCalibConst->getUniformCnt();
294 }
295
296 return fUniformCnt;
297}
298
300{
301 double fUniformNosRatio = 0.0;
302 MsgStream log(messageService(), name());
303
304 std::string fullPath = "/Calib/MucCal";
305 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
306 if( ! pMucCalibConst ){
307 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
308 }else {
309 fUniformNosRatio= pMucCalibConst->getUniformNosRatio();
310 }
311
312 return fUniformNosRatio;
313}
314
315
317{
318 double fUniformNos = 0.0;
319 MsgStream log(messageService(), name());
320
321 std::string fullPath = "/Calib/MucCal";
322 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
323 if( ! pMucCalibConst ){
324 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
325 }else {
326 fUniformNos= pMucCalibConst->getUniformNos();
327 }
328
329 return fUniformNos;
330}
331
333{
334 double fUniformClst = 0.0;
335 MsgStream log(messageService(), name());
336
337 std::string fullPath = "/Calib/MucCal";
338 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
339 if( ! pMucCalibConst ){
340 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
341 }else {
342 fUniformClst= pMucCalibConst->getUniformClst();
343 }
344
345 return fUniformClst;
346}
347
348// Level0, layer constants
349inline double MucCalibConstSvc::getLayerEff( int layer ) const
350{
351 double fEff = 0.0;
352 MsgStream log(messageService(), name());
353
354 std::string fullPath = "/Calib/MucCal";
355 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
356 if( ! pMucCalibConst ){
357 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
358 }else {
359 fEff= pMucCalibConst->getLayerEff( layer );
360 }
361
362 // log << MSG::DEBUG << "Layer:\t" << layer << "\t" << fEff << endreq;
363 return fEff;
364}
365
366inline double MucCalibConstSvc::getLayerCnt( int layer ) const
367{
368 double fCnt = 0.0;
369 MsgStream log(messageService(), name());
370
371 std::string fullPath = "/Calib/MucCal";
372 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
373 if( ! pMucCalibConst ){
374 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
375 }else {
376 fCnt= pMucCalibConst->getLayerCnt( layer );
377 }
378
379 return fCnt;
380}
381
382inline double MucCalibConstSvc::getLayerNos( int layer ) const
383{
384 double fNos = 0.0;
385 MsgStream log(messageService(), name());
386
387 std::string fullPath = "/Calib/MucCal";
388 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
389 if( ! pMucCalibConst ){
390 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
391 }else {
392 fNos= pMucCalibConst->getLayerNos( layer );
393 }
394
395 return fNos;
396}
397
398inline double MucCalibConstSvc::getLayerNosRatio( int layer ) const
399{
400 double fNosRatio = 0.0;
401 MsgStream log(messageService(), name());
402
403 std::string fullPath = "/Calib/MucCal";
404 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
405 if( ! pMucCalibConst ){
406 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
407 }else {
408 fNosRatio= pMucCalibConst->getLayerNosRatio( layer );
409 }
410
411 return fNosRatio;
412}
413
414double MucCalibConstSvc::getLayerClst( int layer, double prob ) const
415{
416 double fClst = 0.0;
417 MsgStream log(messageService(), name());
418
419 std::string fullPath = "/Calib/MucCal";
420 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
421 if( ! pMucCalibConst ){
422 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
423 }else {
424 fClst= pMucCalibConst->getLayerClst( layer, prob );
425 }
426
427 return fClst;
428}
429
430// Level1, box constants
431inline double MucCalibConstSvc::getBoxEff( int part, int segment, int layer ) const
432{
433 double fEff = 0.0;
434 MsgStream log(messageService(), name());
435
436 std::string fullPath = "/Calib/MucCal";
437 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
438 if( ! pMucCalibConst ){
439 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
440 }else {
441 fEff= pMucCalibConst->getBoxEff( part, segment, layer );
442 }
443
444 // log << MSG::DEBUG << "Box:\t" << part << "\t" << segment <<"\t" << layer << "\t" << fEff << endreq;
445 return fEff;
446}
447
448inline double MucCalibConstSvc::getBoxCnt( int part, int segment, int layer ) const
449{
450 double fCnt = 0.0;
451 MsgStream log(messageService(), name());
452
453 std::string fullPath = "/Calib/MucCal";
454 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
455 if( ! pMucCalibConst ){
456 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
457 }else {
458 fCnt= pMucCalibConst->getBoxCnt( part, segment, layer );
459 }
460
461 return fCnt;
462}
463
464inline double MucCalibConstSvc::getBoxNos( int part, int segment, int layer ) const
465{
466 double fNos = 0.0;
467 MsgStream log(messageService(), name());
468
469 std::string fullPath = "/Calib/MucCal";
470 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
471 if( ! pMucCalibConst ){
472 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
473 }else {
474 fNos= pMucCalibConst->getBoxNos( part, segment, layer );
475 }
476
477 return fNos;
478}
479
480inline double MucCalibConstSvc::getBoxNosRatio( int part, int segment, int layer ) const
481{
482 double fNosRatio = 0.0;
483 MsgStream log(messageService(), name());
484
485 std::string fullPath = "/Calib/MucCal";
486 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
487 if( ! pMucCalibConst ){
488 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
489 }else {
490 fNosRatio= pMucCalibConst->getBoxNosRatio( part, segment, layer );
491 }
492
493 return fNosRatio;
494}
495
496double MucCalibConstSvc::getBoxClst( int part, int segment, int layer, double prob ) const
497{
498 double fClst = 0.0;
499 MsgStream log(messageService(), name());
500
501 std::string fullPath = "/Calib/MucCal";
502 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
503 if( ! pMucCalibConst ){
504 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
505 }else {
506 fClst= pMucCalibConst->getBoxClst( part, segment, layer, prob );
507 }
508
509 return fClst;
510}
511
512// Level2, strip constants
513inline double MucCalibConstSvc::getStripEff( int part, int segment, int layer, int strip ) const
514{
515 double fEff = 0.0;
516 MsgStream log(messageService(), name());
517
518 log << MSG::INFO << "in MucCalibConstSvc::getStripEff" << endreq;
519
520 std::string fullPath = "/Calib/MucCal";
521 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
522
523 if( ! pMucCalibConst ){
524 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
525 }else {
526 fEff = pMucCalibConst->getStripEff( part, segment, layer, strip );
527 }
528
529 // log << MSG::DEBUG << "Strip:\t" << part << "\t" << segment <<"\t" << layer << "\t" << strip << "\t" << fEff << endreq;
530 return fEff;
531}
532
533inline double MucCalibConstSvc::getStripCnt( int part, int segment, int layer, int strip ) const
534{
535 double fCnt = 0.0;
536 MsgStream log(messageService(), name());
537
538 std::string fullPath = "/Calib/MucCal";
539 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
540 if( ! pMucCalibConst ){
541 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
542 }else {
543 fCnt= pMucCalibConst->getStripCnt( part, segment, layer, strip );
544 }
545
546 return fCnt;
547}
548
549inline double MucCalibConstSvc::getStripNos( int part, int segment, int layer, int strip ) const
550{
551 double fNos = 0.0;
552 MsgStream log(messageService(), name());
553
554 std::string fullPath = "/Calib/MucCal";
555 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
556 if( ! pMucCalibConst ){
557 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
558 }else {
559 fNos= pMucCalibConst->getStripNos( part, segment, layer, strip );
560 }
561
562 return fNos;
563}
564
565inline double MucCalibConstSvc::getStripNosRatio( int part, int segment, int layer, int strip ) const
566{
567 double fNosRatio = 0.0;
568 MsgStream log(messageService(), name());
569
570 std::string fullPath = "/Calib/MucCal";
571 SmartDataPtr<CalibData::MucCalibData> pMucCalibConst(m_pCalibDataSvc, fullPath);
572 if( ! pMucCalibConst ){
573 log << MSG::ERROR << "can not access to MucCalibData via SmartPtr" << endreq;
574 }else {
575 fNosRatio= pMucCalibConst->getStripNosRatio( part, segment, layer, strip );
576 }
577
578 return fNosRatio;
579}
580
581//END
double getBoxNos(int part, int segment, int layer) const
double getStripNosRatio(int part, int segment, int layer, int strip) const
double getClst(int part, int segment, int layer, double prob) const
double getUniformNos() const
double getBoxClst(int part, int segment, int layer, double prob) const
double getLayerNos(int layer) const
double getCnt(int part, int segment, int layer, int strip) const
double getStripCnt(int part, int segment, int layer, int strip) const
double getBoxEff(int part, int segment, int layer) const
double getEff(int part, int segment, int layer, int strip) const
double getUniformEff() const
virtual StatusCode finalize()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
double getLayerEff(int layer) const
MucCalibConstSvc(const std::string &name, ISvcLocator *svcloc)
double getUniformClst() const
double getBoxCnt(int part, int segment, int layer) const
double getBoxNosRatio(int part, int segment, int layer) const
double getUniformCnt() const
double getStripNos(int part, int segment, int layer, int strip) const
double getNosRatio(int part, int segment, int layer, int strip) const
double getLayerNosRatio(int layer) const
double getLayerClst(int layer, double prob) const
double getUniformNosRatio() const
double getLayerCnt(int layer) const
virtual StatusCode initialize()
double getNos(int part, int segment, int layer, int strip) const
double getStripEff(int part, int segment, int layer, int strip) const