CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemCalibFunSvc Class Reference

#include <CgemCalibFunSvc.h>

+ Inheritance diagram for CgemCalibFunSvc:

Public Member Functions

 CgemCalibFunSvc (const std::string &name, ISvcLocator *svcloc)
 
 ~CgemCalibFunSvc ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
double getSigma (int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const
 
double getTimeRising (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const
 
double getTimeFalling (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const
 
double getTimeWalk (int layer, int xvFlag, int sheet, int stripID, double Q) const
 
double getTimeWalk (double Q, double threshold) const
 
 CgemCalibFunSvc (const std::string &name, ISvcLocator *svcloc)
 
 ~CgemCalibFunSvc ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
void handle (const Incident &)
 
double getSigma (int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const
 
double getTimeRising (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const
 
double getTimeFalling (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const
 
double getTimeWalk (int layer, int xvFlag, int sheet, int stripID, double Q) const
 
double getTimeWalk (double Q, double threshold) const
 
virtual double getSigma (int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const =0
 
virtual double getTimeRising (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
 
virtual double getTimeFalling (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
 
virtual double getTimeWalk (int layer, int xvFlag, int sheet, int stripID, double Q) const =0
 
virtual double getTimeWalk (double Q, double threshold) const =0
 
virtual double getSigma (int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const =0
 
virtual double getTimeRising (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
 
virtual double getTimeFalling (int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
 
virtual double getTimeWalk (int layer, int xvFlag, int sheet, int stripID, double Q) const =0
 
virtual double getTimeWalk (double Q, double threshold) const =0
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ CgemCalibFunSvc() [1/2]

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

◆ ~CgemCalibFunSvc() [1/2]

CgemCalibFunSvc::~CgemCalibFunSvc ( )

Definition at line 45 of file CgemCalibFunSvc.cxx.

45 {
46}

◆ CgemCalibFunSvc() [2/2]

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

◆ ~CgemCalibFunSvc() [2/2]

CgemCalibFunSvc::~CgemCalibFunSvc ( )

Member Function Documentation

◆ finalize() [1/2]

StatusCode CgemCalibFunSvc::finalize ( )
virtual

Definition at line 118 of file CgemCalibFunSvc.cxx.

118 {
119 MsgStream log(messageService(), name());
120 log << MSG::INFO << "CgemCalibFunSvc::finalize()" << endreq;
121
122 return StatusCode::SUCCESS;
123}

◆ finalize() [2/2]

virtual StatusCode CgemCalibFunSvc::finalize ( )
virtual

◆ getSigma() [1/2]

double CgemCalibFunSvc::getSigma ( int  layer,
int  xvFlag,
int  readoutMode,
double  angle,
double  Q,
double  T 
) const
virtual

Implements ICgemCalibFunSvc.

Definition at line 271 of file CgemCalibFunSvc.cxx.

271 {
272 double sigma = 0.13; // unit: mm
273 return sigma;
274}

Referenced by CgemHitOnTrack::getFitStuff().

◆ getSigma() [2/2]

double CgemCalibFunSvc::getSigma ( int  layer,
int  xvFlag,
int  readoutMode,
double  angle,
double  Q,
double  T 
) const
virtual

Implements ICgemCalibFunSvc.

◆ getTimeFalling() [1/2]

double CgemCalibFunSvc::getTimeFalling ( int  layer,
int  xvFlag,
int  sheet,
int  stripID,
double  Q = 100.,
double  z = 0. 
) const
virtual

Implements ICgemCalibFunSvc.

Definition at line 280 of file CgemCalibFunSvc.cxx.

280 {
281 return m_tFalling[layer][xvFlag][sheet];
282}

◆ getTimeFalling() [2/2]

double CgemCalibFunSvc::getTimeFalling ( int  layer,
int  xvFlag,
int  sheet,
int  stripID,
double  Q = 100.,
double  z = 0. 
) const
virtual

Implements ICgemCalibFunSvc.

◆ getTimeRising() [1/2]

double CgemCalibFunSvc::getTimeRising ( int  layer,
int  xvFlag,
int  sheet,
int  stripID,
double  Q = 100.,
double  z = 0. 
) const
virtual

Implements ICgemCalibFunSvc.

Definition at line 276 of file CgemCalibFunSvc.cxx.

276 {
277 return m_tRising[layer][xvFlag][sheet];
278}

◆ getTimeRising() [2/2]

double CgemCalibFunSvc::getTimeRising ( int  layer,
int  xvFlag,
int  sheet,
int  stripID,
double  Q = 100.,
double  z = 0. 
) const
virtual

Implements ICgemCalibFunSvc.

◆ getTimeWalk() [1/4]

double CgemCalibFunSvc::getTimeWalk ( double  Q,
double  threshold 
) const
virtual

Implements ICgemCalibFunSvc.

Definition at line 300 of file CgemCalibFunSvc.cxx.

300 {
301 MsgStream log(messageService(), name());
302
303 double tw = 0.0;
304 int thresholdId = -1;
305 double minval = 1000.;
306 for(int i=0; i<m_valThreshold.size(); i++){
307 double val = fabs(threshold-m_valThreshold[i]);
308 if(val<minval){
309 minval = val;
310 thresholdId = i;
311 }
312 }
313
314 int binMin = m_thIdFrom[thresholdId];
315 int binMax = m_thIdEnd[thresholdId];
316 double qMin = m_charge[binMin];
317 double qMax = m_charge[binMax];
318
319 if(minval>1.0){
320 log << MSG::WARNING << "can not find time walk calibration constants for threshold="
321 << threshold << " , use the parameters with threshold=" << m_valThreshold[thresholdId] << endreq;
322 if(m_printInfo){
323 cout << "threshold_binId = " << thresholdId << " qMin = " << qMin
324 << " qMax = " << qMax << endl;
325 }
326 }
327
328 if(Q < 0.0){
329 log << MSG::WARNING << "charge<0, calculate time walk with charge=0" << endreq;
330 tw = (0.0-m_charge[binMin])*(m_tw[binMin]-m_tw[binMin+1])/(m_charge[binMin]-m_charge[binMin+1]) + m_tw[binMin];
331 } else if(Q < qMin){
332 log << MSG::WARNING << "charge < minimumCharge in time walk calibration function " << qMin << endreq;
333 tw = (Q-m_charge[binMin])*(m_tw[binMin]-m_tw[binMin+1])/(m_charge[binMin]-m_charge[binMin+1]) + m_tw[binMin];
334 } else if(Q > qMax){
335 log << MSG::WARNING << "charge > maximumCharge in time walk calibration function " << qMax << endreq;
336 if(m_printInfo) cout << "binMin = " << binMin << " binMax = " << binMax << endl;
337 tw = (Q-m_charge[binMax])*(m_tw[binMax]-m_tw[binMax-1])/(m_charge[binMax]-m_charge[binMax-1]) + m_tw[binMax];
338 } else{
339 for(int i=binMin; i<binMax; i++){
340 if((Q>=m_charge[i]) && (Q<m_charge[i+1])){
341 tw = (m_tw[i+1]-m_tw[i])*(Q-m_charge[i])/(m_charge[i+1]-m_charge[i]) + m_tw[i];
342 }
343 }
344 }
345
346 return tw;
347}

◆ getTimeWalk() [2/4]

double CgemCalibFunSvc::getTimeWalk ( double  Q,
double  threshold 
) const
virtual

Implements ICgemCalibFunSvc.

◆ getTimeWalk() [3/4]

double CgemCalibFunSvc::getTimeWalk ( int  layer,
int  xvFlag,
int  sheet,
int  stripID,
double  Q 
) const
virtual

Implements ICgemCalibFunSvc.

Definition at line 284 of file CgemCalibFunSvc.cxx.

284 {
285 double tw = 0.0;
286 if(!m_readLUT){
287 cout << "ERROR: can not calculate time walk with LUT, return tw=0." << endl;
288 return tw;
289 }
290 double threshold = m_cgemLUTReader->Get_thr_T_fC(layer, sheet, xvFlag, stripID);
291 if(m_printInfo){
292 cout << setw(8)<<layer <<setw(8)<<sheet<<setw(8)<<xvFlag<<setw(8)<<stripID
293 <<setw(15)<<threshold<<endl;
294 }
295
296 tw = getTimeWalk(Q, threshold);
297 return tw;
298}
double getTimeWalk(int layer, int xvFlag, int sheet, int stripID, double Q) const
float Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip)

Referenced by getTimeWalk().

◆ getTimeWalk() [4/4]

double CgemCalibFunSvc::getTimeWalk ( int  layer,
int  xvFlag,
int  sheet,
int  stripID,
double  Q 
) const
virtual

Implements ICgemCalibFunSvc.

◆ handle() [1/2]

void CgemCalibFunSvc::handle ( const Incident &  inc)

Definition at line 125 of file CgemCalibFunSvc.cxx.

125 {
126 MsgStream log( messageService(), name() );
127 log << MSG::DEBUG << "handle: " << inc.type() << endreq;
128
129 if ( inc.type() == "NewRun" ){
130 log << MSG::DEBUG << "NewRun" << endreq;
131
132 if( ! initCalibConst() ){
133 log << MSG::ERROR
134 << "can not initilize Cgem Calib Constants" << endl
135 << " Please insert the following statement "
136 << "in your \"jobOption.txt\" "
137 << "before the include file of Cgem Reconstruction: "
138 << endl << " "
139 << "#include \"$CALIBSVCROOT/share/job-CalibData.txt\""
140 << endreq;
141 }
142 }
143}

◆ handle() [2/2]

void CgemCalibFunSvc::handle ( const Incident &  )

◆ initialize() [1/2]

StatusCode CgemCalibFunSvc::initialize ( )
virtual

Definition at line 57 of file CgemCalibFunSvc.cxx.

57 {
58 MsgStream log(messageService(), name());
59 log << MSG::INFO << "CgemCalibFunSvc::initialize()" << endreq;
60
61 StatusCode sc = Service::initialize();
62 if( sc.isFailure() ) return sc;
63
64 // IIncidentSvc* incsvc;
65 // sc = service("IncidentSvc", incsvc);
66 // int priority = 100;
67 // if( sc.isSuccess() ){
68 // incsvc -> addListener(this, "NewRun", priority);
69 // }
70
71 m_getRunNo = false;
72 static IJobOptionsSvc* jobSvc = 0;
73 if ( jobSvc == 0 ) {
74 sc = service("JobOptionsSvc", jobSvc);
75 if ( sc.isFailure() ) {
76 std::cout << "Can't get the JobOptionsSvc @ DistBoss::GetPropertyValue()" << std::endl;
77 return sc;
78 }
79 }
80 const vector<const Property*>* properties = jobSvc->getProperties("ReadCosmicRayData");
81 if ( properties == NULL ) {
82 log << MSG::WARNING << "can not get runNo from ReadCosmicRayData" << endreq;
83 } else{
84 for ( unsigned int i = 0; i < properties->size(); ++i ) {
85 if ( properties->at(i)->name() == "runNo" ) {
86 cout << "name of property: " << properties->at(i)->name() << endl;
87 string strRnd = properties->at(i)->toString();
88 sscanf(strRnd.c_str(), "%d", &m_run);
89 // cout << "runNo: " << m_run << endl;
90 break;
91 }
92 }
93 m_getRunNo = true;
94 }
95 if( !initCalibConst() ){
96 log << MSG::ERROR << "can not initialize CGEM calibration constants" << endreq;
97 return StatusCode::FAILURE;
98 }
99
100 sc = service("CalibDataSvc", m_pCalDataSvc, true);
101 if( sc == StatusCode::SUCCESS ){
102 log << MSG::INFO << "Retrieve IDataProviderSvc" << endreq;
103 }else{
104 log << MSG::FATAL << "can not get IDataProviderSvc" << endreq;
105 }
106
107 m_readLUT = true;
108 m_cgemLUTReader = new CgemLUTReader(m_fileLUT.c_str());
109 cout << "LUT file: " << m_fileLUT << endl;
110 if(!m_cgemLUTReader->ReadLUT()){
111 m_readLUT = false;
112 log << MSG::FATAL << "can not read LUT " << m_fileLUT << endl;
113 }
114
115 return StatusCode::SUCCESS;
116}

◆ initialize() [2/2]

virtual StatusCode CgemCalibFunSvc::initialize ( )
virtual

◆ queryInterface() [1/2]

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

Definition at line 48 of file CgemCalibFunSvc.cxx.

48 {
49 if( IID_ICgemCalibFunSvc.versionMatch(riid) ){
50 *ppvInterface = static_cast<ICgemCalibFunSvc*> (this);
51 } else{
52 return Service::queryInterface(riid, ppvInterface);
53 }
54 return StatusCode::SUCCESS;
55}

◆ queryInterface() [2/2]

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

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