TofQCorrSvc Class Reference

#include <TofQCorrSvc.h>

Inheritance diagram for TofQCorrSvc:

ITofQCorrSvc List of all members.

Public Member Functions

 TofQCorrSvc (const std::string &name, ISvcLocator *svcloc)
 ~TofQCorrSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void handle (const Incident &)
void getTofQCorrInfo ()
const double getBarEast (int layer, int no)
const double getBarWest (int layer, int no)
const double getEndcap (int layer, int no)
const double BQRaw1 (int id, double q)
const double BQRaw2 (int id, double q)
const double EQRaw (int id, double q)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Attributes

double m_Bar_East [176][3]
double m_Bar_West [176][3]
double m_Endcap [96][3]
MYSQLconn
IDataProviderSvc * m_eventSvc
int m_runNo
IDatabaseSvcm_dbsvc

Detailed Description

Definition at line 16 of file TofQCorrSvc.h.


Constructor & Destructor Documentation

TofQCorrSvc::TofQCorrSvc ( const std::string name,
ISvcLocator *  svcloc 
)

Definition at line 30 of file TofQCorrSvc.cxx.

00030                                                                      : Service(name, svcloc) {
00031 }

TofQCorrSvc::~TofQCorrSvc (  ) 

Definition at line 88 of file TofQCorrSvc.cxx.

00088                          {
00089 }


Member Function Documentation

const double TofQCorrSvc::BQRaw1 ( int  id,
double  q 
) [virtual]

Implements ITofQCorrSvc.

Definition at line 187 of file TofQCorrSvc.cxx.

References m_Bar_East, msgSvc(), and Bes_Common::WARNING.

00187                                                  {
00188   MsgStream log(msgSvc(), name());
00189   double qraw = -999.0;
00190   if( id<0 || id>175 ) {
00191     log << MSG::WARNING << "BQRaw1 :  TofId is out of range, tofid = " << id << endreq;
00192     return qraw;
00193   }
00194   if( fabs(q-10000.0)<1.0e-6 ) { return 10000.0; }
00195   else if( fabs(q+999.0)<1.0e-6 ) { return -999.0; }
00196   double a = m_Bar_East[id][2];
00197   double b = m_Bar_East[id][1];
00198   double c = m_Bar_East[id][0] - q/2.5;
00199   qraw = ( sqrt( b*b - 4.0*a*c ) - b )/( 2.0*a );
00200 
00201   return qraw;
00202 }

const double TofQCorrSvc::BQRaw2 ( int  id,
double  q 
) [virtual]

Implements ITofQCorrSvc.

Definition at line 205 of file TofQCorrSvc.cxx.

References m_Bar_West, msgSvc(), and Bes_Common::WARNING.

00205                                                  {
00206   MsgStream log(msgSvc(), name());
00207   double qraw = -999.0;
00208   if( id<0 || id>175 ) {
00209     log << MSG::WARNING << "BQRaw2 :  TofId is out of range, tofid = " << id << endreq;
00210     return qraw;
00211   }
00212   if( fabs(q-10000.0)<1.0e-6 ) { return 10000.0; }
00213   else if( fabs(q+999.0)<1.0e-6 ) { return -999.0; }
00214   double a = m_Bar_West[id][2];
00215   double b = m_Bar_West[id][1];
00216   double c = m_Bar_West[id][0] - q/2.5;
00217   qraw = ( sqrt( b*b - 4.0*a*c ) - b )/( 2.0*a );
00218   return qraw;
00219 }

const double TofQCorrSvc::EQRaw ( int  id,
double  q 
) [virtual]

Implements ITofQCorrSvc.

Definition at line 222 of file TofQCorrSvc.cxx.

References m_Endcap, msgSvc(), and Bes_Common::WARNING.

00222                                                 {
00223   MsgStream log(msgSvc(), name());
00224   double qraw = -999.0;
00225   if( id<0 || id>95 ) {
00226     log << MSG::WARNING << "EQRaw :  TofId is out of range, tofid = " << id << endreq;
00227     return qraw;
00228   }
00229   if( fabs(q-10000.0)<1.0e-6 ) { return 10000.0; }
00230   else if( fabs(q+999.0)<1.0e-6 ) { return -999.0; }
00231   double a = m_Endcap[id][2];
00232   double b = m_Endcap[id][1];
00233   double c = m_Endcap[id][0] - q/2.5;
00234   qraw = ( sqrt( b*b - 4.0*a*c ) - b )/( 2.0*a );
00235   return qraw;
00236 }

StatusCode TofQCorrSvc::finalize (  )  [virtual]

Definition at line 81 of file TofQCorrSvc.cxx.

References Bes_Common::INFO, and msgSvc().

00081                                    {
00082   MsgStream log(msgSvc(), name());
00083   log << MSG::INFO << name() << ": End of Run" << endreq;
00084   return StatusCode::SUCCESS;
00085 }

const double TofQCorrSvc::getBarEast ( int  layer,
int  no 
) [virtual]

Implements ITofQCorrSvc.

Definition at line 92 of file TofQCorrSvc.cxx.

References m_Bar_East.

00092                                                      {
00093   return  m_Bar_East[layer][no];
00094 }    

const double TofQCorrSvc::getBarWest ( int  layer,
int  no 
) [virtual]

Implements ITofQCorrSvc.

Definition at line 97 of file TofQCorrSvc.cxx.

References m_Bar_West.

00097                                                     {
00098   return  m_Bar_West[layer][no];
00099 } 

const double TofQCorrSvc::getEndcap ( int  layer,
int  no 
) [virtual]

Implements ITofQCorrSvc.

Definition at line 102 of file TofQCorrSvc.cxx.

References m_Endcap.

00102                                                    {
00103   return m_Endcap[layer][no];
00104 }

void TofQCorrSvc::getTofQCorrInfo (  ) 

Definition at line 122 of file TofQCorrSvc.cxx.

References DatabaseRecordVector::clear(), counter, deljobs::end, calibUtil::ERROR, Bes_Common::INFO, m_Bar_East, m_Bar_West, m_dbsvc, m_Endcap, m_eventSvc, IDatabaseSvc::query(), and runNo.

Referenced by handle().

00122                                  {
00123   MsgStream log(messageService(), name());
00124   SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
00125   int  run = eventHeader->runNumber();
00126   if(run<0){
00127     log << MSG::INFO << "This data is the MC sample with the Run Number: " << run << endreq;
00128     run=-run;
00129   }
00130   //  unsigned long *lengths;
00131   char stmt1[200];
00132   sprintf(stmt1,"select TOFCalib "
00133           "from RunParams where run_number = %d", run);
00134 
00135   DatabaseRecordVector res;
00136   int row_no = m_dbsvc->query("run",stmt1,res);
00137   if(!row_no){
00138     log << MSG::ERROR<<"search errror"<<endreq;
00139     exit(1);
00140   }
00141   long int runNo;
00142   DatabaseRecord* records1 = res[0];
00143   sscanf((*records1)["TOFCalib"], "%ld", &runNo);
00144 
00145   char stmt2[200];
00146   sprintf(stmt2,"select be,end,counter,a1,a2,a3 "
00147           "from TOF_Q where run_number = %ld", runNo);
00148 
00149   res.clear();
00150   row_no = m_dbsvc->query("run",stmt2,res);
00151   if(!row_no){
00152     log << MSG::ERROR<<"search errror"<<endreq;
00153     exit(1);
00154   }
00155 
00156  long int be,end,counter;
00157   double sql_result[3];
00158 
00159   for(int jjj=0;jjj<row_no;jjj++){
00160     DatabaseRecord* records2 = res[jjj];
00161     sscanf((*records2)["be"], "%ld", &be);
00162     sscanf((*records2)["end"], "%ld", &end);
00163     sscanf((*records2)["counter"], "%ld", &counter);
00164     sscanf((*records2)["a1"], "%lf", &sql_result[0]);
00165     sscanf((*records2)["a2"], "%lf", &sql_result[1]);
00166     sscanf((*records2)["a3"], "%lf", &sql_result[2]);
00167     if(be==0&&end==0){
00168       m_Endcap[counter][0]=sql_result[0];
00169       m_Endcap[counter][1]=sql_result[1];
00170       m_Endcap[counter][2]=sql_result[2];
00171     }
00172     if(be==1&&end==0){
00173       m_Bar_East[counter][0]=sql_result[0];
00174       m_Bar_East[counter][1]=sql_result[1];
00175       m_Bar_East[counter][2]=sql_result[2];
00176     }
00177     if(be==1&&end==1){
00178       m_Bar_West[counter][0]=sql_result[0];
00179       m_Bar_West[counter][1]=sql_result[1];
00180       m_Bar_West[counter][2]=sql_result[2];
00181       }
00182 }
00183 res.clear();
00184 }

void TofQCorrSvc::handle ( const Incident &   ) 

Definition at line 107 of file TofQCorrSvc.cxx.

References Bes_Common::DEBUG, getTofQCorrInfo(), and m_eventSvc.

00107                                            {
00108   MsgStream log( messageService(), name() );
00109   log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00110 
00111   SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
00112   int  run = eventHeader->runNumber();
00113   if( run<0 || run>11000 ) return;
00114 
00115   if ( inc.type() == "NewRun" ){
00116     log << MSG::DEBUG << "New Run:" << run << endreq;
00117     getTofQCorrInfo();
00118   }
00119 }

StatusCode TofQCorrSvc::initialize (  )  [virtual]

Definition at line 45 of file TofQCorrSvc.cxx.

References calibUtil::ERROR, Bes_Common::INFO, m_dbsvc, m_eventSvc, m_runNo, and msgSvc().

00045                                      {
00046   
00047   MsgStream log(msgSvc(), name());
00048   log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00049   
00050   StatusCode sc = Service::initialize();
00051   if ( sc.isFailure() ) return sc;
00052 
00053   IIncidentSvc* incsvc;
00054   sc = service("IncidentSvc", incsvc);
00055   int priority = 100;
00056   if( sc.isSuccess() ){
00057     incsvc -> addListener(this, "NewRun", priority);
00058   }
00059 
00060  sc = serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
00061   if (sc .isFailure() ) {
00062     log << MSG::ERROR << "Unable to find DatabaseSvc " << endreq;
00063     return sc;
00064   }
00065 
00066 
00067   sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
00068   if (sc .isFailure() ) {
00069     log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
00070     return sc;
00071   }
00072   
00073   StatusCode scc;
00074   log<<MSG::INFO << "setProperties()" << endreq;
00075   scc = setProperties();
00076    m_runNo=0;
00077   return sc;
00078 }  

static const InterfaceID& ITofQCorrSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 11 of file ITofQCorrSvc.h.

References IID_ITofQCorrSvc().

00011 { return IID_ITofQCorrSvc; }

StatusCode TofQCorrSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
) [virtual]

Definition at line 34 of file TofQCorrSvc.cxx.

References IID_ITofQCorrSvc().

00034                                                                                     {
00035   
00036   if ( IID_ITofQCorrSvc.versionMatch(riid) ) { 
00037     *ppvInterface = static_cast<ITofQCorrSvc*> (this); 
00038   } else { 
00039     return Service::queryInterface(riid, ppvInterface) ; 
00040   }
00041   return StatusCode::SUCCESS;
00042 }


Member Data Documentation

MYSQL* TofQCorrSvc::conn [private]

Definition at line 44 of file TofQCorrSvc.h.

double TofQCorrSvc::m_Bar_East[176][3] [private]

Definition at line 40 of file TofQCorrSvc.h.

Referenced by BQRaw1(), getBarEast(), and getTofQCorrInfo().

double TofQCorrSvc::m_Bar_West[176][3] [private]

Definition at line 41 of file TofQCorrSvc.h.

Referenced by BQRaw2(), getBarWest(), and getTofQCorrInfo().

IDatabaseSvc* TofQCorrSvc::m_dbsvc [private]

Definition at line 47 of file TofQCorrSvc.h.

Referenced by getTofQCorrInfo(), and initialize().

double TofQCorrSvc::m_Endcap[96][3] [private]

Definition at line 42 of file TofQCorrSvc.h.

Referenced by EQRaw(), getEndcap(), and getTofQCorrInfo().

IDataProviderSvc* TofQCorrSvc::m_eventSvc [private]

Definition at line 45 of file TofQCorrSvc.h.

Referenced by getTofQCorrInfo(), handle(), and initialize().

int TofQCorrSvc::m_runNo [private]

Definition at line 46 of file TofQCorrSvc.h.

Referenced by initialize().


Generated on Tue Nov 29 23:36:06 2016 for BOSS_7.0.2 by  doxygen 1.4.7