/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Emc/EmcCalibConstSvc/EmcCalibConstSvc-00-00-12/src/EmcCalibConstSvc.cxx

Go to the documentation of this file.
00001 #include "EmcCalibConstSvc/EmcCalibConstSvc.h"
00002 #include "GaudiKernel/Kernel.h"
00003 #include "GaudiKernel/IInterface.h"
00004 #include "GaudiKernel/StatusCode.h"
00005 #include "GaudiKernel/SvcFactory.h"
00006 #include "GaudiKernel/MsgStream.h"
00007 
00008 #include "GaudiKernel/ISvcLocator.h"
00009 #include "GaudiKernel/Bootstrap.h"
00010 
00011 #include "GaudiKernel/IDataProviderSvc.h"
00012 #include "GaudiKernel/SmartDataPtr.h"
00013 #include "GaudiKernel/DataSvc.h"
00014 
00015 #include "EmcGeneralClass/EmcStructure.h"
00016 #include "CalibData/CalibModel.h"
00017 #include "CalibData/Emc/EmcCalibData.h"
00018 
00019 #include <vector>
00020 #include <math.h>
00021 #include <fstream>
00022 
00023 
00024 EmcCalibConstSvc::EmcCalibConstSvc( const std::string& name, ISvcLocator* svcloc) :
00025   Service (name, svcloc) {
00026 
00027 
00028   for(int i=0;i<6240;i++){
00029     m_CrystalEmaxData[i]=0;
00030   }
00031  
00032 
00033   string paraPath = getenv("EMCCALIBCONSTSVCROOT");
00034   paraPath += "/share/emax_data.dat";
00035 
00036   ifstream in;
00037   in.open(paraPath.c_str());
00038   assert(in);
00039   int ixtal;
00040   double emaxData;
00041   int Nixt=0;
00042   while (in.peek() != EOF) 
00043     { 
00044       
00045       in >> ixtal>>emaxData;
00046 
00047       m_CrystalEmaxData[ixtal]=emaxData;
00048       Nixt++; 
00049     }
00050 
00051   in.close();
00052  
00053 
00054 }
00055 
00056 EmcCalibConstSvc::~EmcCalibConstSvc(){
00057 
00058 }
00059 
00060 StatusCode EmcCalibConstSvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
00061      if( IID_IEmcCalibConstSvc.versionMatch(riid) ){
00062           *ppvInterface = static_cast<IEmcCalibConstSvc*> (this);
00063      } else{
00064           return Service::queryInterface(riid, ppvInterface);
00065      }
00066      return StatusCode::SUCCESS;
00067 }
00068 
00069 StatusCode EmcCalibConstSvc::initialize(){
00070   MsgStream log(messageService(), name());
00071   log << MSG::INFO << "EmcCalibConstSvc::initialize()" << endreq;
00072   
00073   StatusCode sc = Service::initialize();
00074   if( sc.isFailure() ) return sc;
00075   
00076   sc = service("CalibDataSvc", m_calDataSvc, true);
00077   if( sc == StatusCode::SUCCESS ){
00078     log << MSG::INFO << "Retrieve IDataProviderSvc" << endreq;
00079   }else{
00080     log << MSG::FATAL << "can not get IDataProviderSvc" << endreq;
00081   }
00082 
00083   //     sc = service("EmcRecGeoSvc", m_emcGeomSvc);
00084   //     if( sc != StatusCode::SUCCESS ){
00085   //      log << MSG::ERROR << "can not use EmcRecGeoSvc" << endreq;
00086   // }
00087   
00088   m_theEmcStruc= new EmcStructure() ; 
00089   m_theEmcStruc->setEmcStruc();
00090  
00091   // Dump();
00092 
00093   return StatusCode::SUCCESS;
00094 }
00095 
00096 StatusCode EmcCalibConstSvc::finalize(){
00097  
00098      delete m_theEmcStruc;
00099 
00100      MsgStream log(messageService(), name());
00101      log << MSG::INFO << "EmcCalibConstSvc::finalize()" << endreq;
00102      return StatusCode::SUCCESS;
00103 
00104 }
00105 
00106 double EmcCalibConstSvc::getDigiCalibConst(int No)   const
00107  {
00108      double digiCalibConst = 0.0;
00109      MsgStream log(messageService(), name());
00110      
00111      std::string fullPath = "/Calib/EmcCal";
00112      SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
00113      if( ! calConst ){
00114           log << MSG::ERROR << "can not access to EmcDigi CalibData via SmartPtr" 
00115               << endreq;
00116      }else {
00117          digiCalibConst = calConst->getDigiCalibConst(No);
00118      }
00119      
00120      return digiCalibConst;
00121 }
00122 
00123 int EmcCalibConstSvc::getIxtalNumber(int No)   const
00124  {
00125      int IxtalNumber = 999999;
00126      MsgStream log(messageService(), name());
00127      
00128      std::string fullPath = "/Calib/EmcCal";
00129      SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
00130      if( ! calConst ){
00131           log << MSG::ERROR << "can not access to EmcDigi CalibData via SmartPtr" 
00132               << endreq;
00133      }else {
00134          IxtalNumber = calConst->getIxtalNumber(No);
00135      }
00136      
00137      return IxtalNumber;
00138 }
00139 
00140 int EmcCalibConstSvc::getDigiCalibConstNo( ) const
00141  {
00142      int digiCalibConstNo = 0;
00143      MsgStream log(messageService(), name());
00144      
00145      std::string fullPath = "/Calib/EmcCal";
00146      SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
00147      if( ! calConst ){
00148           log << MSG::ERROR << "can not access to EmcDigiNo CalibData via SmartPtr" 
00149               << endreq;
00150      }else {
00151         digiCalibConstNo = calConst->getDigiCalibConstNo();
00152      }
00153      
00154      return digiCalibConstNo;
00155 }
00156 
00157 int EmcCalibConstSvc::getIxtalNumberNo( ) const
00158  {
00159      int IxtalNumberNo = 0;
00160      MsgStream log(messageService(), name());
00161      
00162      std::string fullPath = "/Calib/EmcCal";
00163      SmartDataPtr<CalibData::EmcCalibData> calConst(m_calDataSvc, fullPath);
00164      if( ! calConst ){
00165           log << MSG::ERROR << "can not access to EmcDigiNo CalibData via SmartPtr" 
00166               << endreq;
00167      }else {
00168         IxtalNumberNo = calConst->getIxtalNumberNo();
00169      }
00170      
00171      return IxtalNumberNo;
00172 }
00173 
00174 
00175 
00176 int EmcCalibConstSvc::getIndex( unsigned int PartId, 
00177                                 unsigned int ThetaIndex, 
00178                                 unsigned int PhiIndex)  const
00179 {
00180   return m_theEmcStruc->getGeomIndex(PartId, ThetaIndex, PhiIndex);
00181 }
00182 
00183 
00184 unsigned int EmcCalibConstSvc::getPartID(int Index) const
00185 {
00186   return m_theEmcStruc->getPartId(Index);
00187 }
00188 
00189 unsigned int EmcCalibConstSvc::getThetaIndex( int Index)  const 
00190 {
00191   return m_theEmcStruc->getTheta(Index);
00192 }
00193 
00194 unsigned int EmcCalibConstSvc::getPhiIndex( int Index)  const  
00195 {
00196   return m_theEmcStruc->getPhi(Index);
00197 }
00198 
00199 
00200 
00201 double EmcCalibConstSvc::getCrystalEmaxData( int Index)  const
00202 {
00203   return m_CrystalEmaxData[Index];
00204 }
00205  
00206 
00207 
00208 void   EmcCalibConstSvc::Dump()
00209 {
00210   /*
00211   for(int iNo=0;iNo<6;iNo++){
00212     cout<<"getDigiCalibConst "<<getDigiCalibConst(iNo)<<endl;
00213   }
00214 
00215   cout<<"getDigiCalibConstNo "<<getDigiCalibConstNo()<<endl;
00216 
00217   
00218    cout<<"ind"<<"  "<<"getThetaIndex(ind)"<<"  "
00219        <<"getPhiIndex(ind)"<<"getPartID"<<endl;
00220 
00221   for(int ind=0; ind<6240;ind++){
00222 
00223     cout<<ind<<"  "<<getThetaIndex(ind)<<"  "
00224         <<getPhiIndex(ind)<<"  "<<getPartID(ind)<<endl;  
00225   
00226   }
00227 
00228   cout<<"getIndex(0,5,95)="<<getIndex(0,5,95)<<endl;
00229   cout<<"getIndex(1,43,119)="<<getIndex(1,43,119)<<endl;
00230   cout<<"getIndex(2,5,95)="<<getIndex(2,5,95)<<endl;
00231   cout<<"getIndex(0,5,96)="<<getIndex(0,5,96)<<endl;
00232   cout<<"getIndex(1,43,120)="<<getIndex(1,43,120)<<endl;
00233   cout<<"getIndex(2,5,96)="<<getIndex(2,5,96)<<endl;
00234 
00235   for(int i=0;i<6240;i++){
00236     cout<<i<<"\t"<<getCrystalEmaxData(i) <<endl;
00237   }
00238   */
00239 
00240 }

Generated on Tue Nov 29 22:58:17 2016 for BOSS_7.0.2 by  doxygen 1.4.7