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