Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MdcCalibAlg Class Reference

#include <MdcCalibAlg.h>

List of all members.

Public Member Functions

StatusCode execute ()
StatusCode execute ()
StatusCode finalize ()
StatusCode finalize ()
StatusCode initialize ()
StatusCode initialize ()
 MdcCalibAlg (const std::string &name, ISvcLocator *pSvcLocator)
 MdcCalibAlg (const std::string &name, ISvcLocator *pSvcLocator)
 ~MdcCalibAlg ()
 ~MdcCalibAlg ()

Private Member Functions

void initParam ()
void initParam ()

Private Attributes

MdcCalibConstm_calconst
MdcCalibConstm_calconst
std::string m_configFile
MdcCalConstMgrm_constmgr
MdcCalConstMgrm_constmgr
bool m_distCalib
int m_evtType
TFile * m_fhist
TFile * m_fhist
int m_flgKalFit
std::string m_histname
TObjArray * m_hlist
TObjArray * m_hlist
bool m_initCalConstFlg
int m_mdcCalFlg
MdcCalibm_mdccalib
MdcCalibm_mdccalib
MdcCalEventm_mdcevt
MdcCalEventm_mdcevt
IMdcCalibFunSvcm_mdcFunSvc
IMdcCalibFunSvcm_mdcFunSvc
IMdcGeomSvcm_mdcGeomSvc
IMdcGeomSvcm_mdcGeomSvc
int m_nEvt
int m_nEvtDisp
MdcCalParams m_param
std::string m_wpcFile


Constructor & Destructor Documentation

MdcCalibAlg::MdcCalibAlg const std::string &  name,
ISvcLocator *  pSvcLocator
 

00020                                                                         :
00021      Algorithm(name, pSvcLocator), m_mdcCalFlg(0), m_flgKalFit(0), m_evtType(0){
00022 
00023      m_histname = "NULL";
00024      m_configFile = "NULL";
00025      m_nEvtDisp = 1000;
00026      m_distCalib = false;
00027      m_nEvt = 0;
00028 
00029      // declare properties
00030      declareProperty("MdcCalFlg", m_mdcCalFlg);
00031      declareProperty("MdcKalmanFlg", m_flgKalFit);
00032      declareProperty("Event", m_evtType);
00033      declareProperty("HistOutput", m_histname);
00034      declareProperty("ConfigFile", m_configFile);
00035      declareProperty("WirePosCorFile", m_wpcFile);
00036      declareProperty("NumEvtDisplay", m_nEvtDisp);
00037      declareProperty("DistCalib", m_distCalib);
00038 
00039      m_initCalConstFlg = false;
00040 }

MdcCalibAlg::~MdcCalibAlg  ) 
 

00042                          {
00043      delete m_constmgr;
00044      std::cout << "m_constmgr deleted" << std::endl;
00045 
00046      delete m_mdccalib;
00047      std::cout << "delete m_mdccalib" << std::endl;
00048 
00049      delete m_mdcevt;
00050      std::cout << "m_mdcevt deleted" << std::endl;
00051 
00052      delete m_hlist;
00053      std::cout << "m_hlist deleted" << std::endl;
00054 
00055      delete m_calconst;
00056      std::cout << "m_calconst deleted" << std::endl;
00057 
00058      if(!m_distCalib){
00059           std::ofstream fend("endcal.out");
00060           fend << "MdcCalib end." << std::endl;
00061           fend.close();
00062      }
00063 
00064      std::cout << "MdcCalibAlg End." << std::endl;
00065 }

MdcCalibAlg::MdcCalibAlg const std::string &  name,
ISvcLocator *  pSvcLocator
 

MdcCalibAlg::~MdcCalibAlg  ) 
 


Member Function Documentation

StatusCode MdcCalibAlg::execute  ) 
 

StatusCode MdcCalibAlg::execute  ) 
 

00249                                 {
00250      MsgStream log(msgSvc(), name());
00251      log << MSG::DEBUG << "MdcCalibAlg execute()" << endreq;
00252 
00253      // display event number for debug
00254      SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00255      if (!eventHeader) {
00256           log << MSG::FATAL << "Could not find Event Header" << endreq;
00257           return( StatusCode::FAILURE);
00258      }
00259      int iRun = eventHeader->runNumber();
00260      int iEvt = eventHeader->eventNumber();
00261      if(0 == (m_nEvt % m_nEvtDisp))
00262           std::cout << "Run " << iRun << ", Event " << iEvt << ",   Total Event number " << m_nEvt << endl;
00263 
00264      m_mdcevt->setEvtNoOnline(iEvt);
00265      m_mdcevt->setEvtNoOffline(m_nEvt);
00266 
00267      if( ! m_initCalConstFlg ){
00268 //        if((0 == m_mdcCalFlg) && (0 == m_param.fgIniCalConst)){
00269 //             m_calconst->initCalibConst();
00270 //        } else{
00271 //             m_constmgr -> rdConstTcds(m_calconst);
00272 //        }
00273           m_constmgr -> rdConstTcds(m_calconst);
00274           m_initCalConstFlg = true;
00275      }
00276 
00277      if(m_mdcCalFlg > 1){
00278           if(m_flgKalFit)  m_mdcevt -> setKalEvent();
00279           else             m_mdcevt -> setRecEvent();
00280      }
00281 
00282      // fill histograms
00283      m_mdccalib -> fillHist(m_mdcevt);
00284      m_mdcevt   -> clear();
00285      m_nEvt++;
00286 
00287      return StatusCode::SUCCESS;
00288 }

StatusCode MdcCalibAlg::finalize  ) 
 

StatusCode MdcCalibAlg::finalize  ) 
 

00291                                  {
00292      MsgStream log(msgSvc(), name());
00293      log << MSG::INFO << "MdcCalibAlg finalize()" << endreq;
00294 
00295      gStyle -> SetCanvasBorderMode(0);
00296      gStyle -> SetCanvasColor(10);
00297      gStyle -> SetOptFit(0011);
00298      gStyle -> SetStatColor(10);
00299      gStyle -> SetStatBorderSize(1);
00300      gStyle -> SetStatFont(42);
00301      gStyle -> SetStatFontSize(0.04);
00302      gStyle -> SetStatX(0.9);
00303      gStyle -> SetStatY(0.9);
00304      gStyle -> SetPadColor(10);
00305      gStyle -> SetFuncColor(2);
00306 
00307      // execute calibration and write new calibration data file
00308      if(!m_distCalib){
00309           m_mdccalib -> updateConst(m_calconst);
00310           m_constmgr -> wrtConst( m_calconst );
00311      }
00312 
00313      // write histogram file
00314      TFile fhist(m_histname.c_str(), "recreate");
00315      m_hlist -> Write();
00316      fhist.Close();
00317      std::cout << m_histname << " was written" << std::endl;
00318 
00319      m_mdccalib->clear();
00320 
00321      return StatusCode::SUCCESS;
00322 }

StatusCode MdcCalibAlg::initialize  ) 
 

StatusCode MdcCalibAlg::initialize  ) 
 

00068                                    {
00069      MsgStream log( msgSvc(), name() );
00070      log << MSG::INFO << "MdcCalibAlg initialze() ..." << endreq;
00071      log << MSG::INFO << "MdcCalFlg = " << m_mdcCalFlg << endreq;
00072 
00073      if("NULL"==m_histname){
00074           log << MSG::ERROR << "not defined histogram file." << endreq;
00075           return StatusCode::FAILURE;
00076      }
00077      if("NULL"==m_configFile){
00078           log << MSG::ERROR << "not defined MdcCalibConfig file." << endreq;
00079           return StatusCode::FAILURE;
00080      }
00081 
00082      StatusCode sc = service("MdcGeomSvc", m_mdcGeomSvc);
00083      if(sc != StatusCode::SUCCESS){
00084           log << MSG::ERROR << "can not use MdcGeomSvc" << endreq;
00085      }
00086 
00087      sc = service("MdcCalibFunSvc", m_mdcFunSvc);
00088      if( sc != StatusCode::SUCCESS ){
00089           log << MSG::FATAL << "can not use MdcCalibFunSvc" << endreq;
00090      }
00091 
00092      // initialize m_param
00093      initParam();
00094 
00095      // read mdc config parameters
00096      int i;
00097      int lay;
00098      std::string strconfig;
00099      std::string strcomment;
00100      std::string strtmp;
00101      std::string strTes;
00102      int fgTes[50];
00103      for(i=0; i<50; i++) fgTes[i] = -999;
00104      ifstream fconfig( m_configFile.c_str() );
00105      if( ! fconfig.is_open() ){
00106           log << MSG::ERROR << "can not open config file " << m_configFile
00107               << ". Use defalt config parameters" << endreq;
00108           return StatusCode::FAILURE;
00109      } else {
00110           log << MSG::INFO << "Open config file " << m_configFile << endreq;
00111           while( fconfig >> strconfig ){
00112                if('#' == strconfig[0]){
00113                     getline(fconfig, strcomment);
00114                } else if("FillNtuple" == strconfig){
00115                     fconfig >> m_param.fillNtuple;
00116                } else if("nEvtNtuple" == strconfig){
00117                     fconfig >> m_param.nEvtNtuple;
00118                }else if("FlagCalDetEffi" == strconfig){
00119                     fconfig >> m_param.fgCalDetEffi;
00120                } else if("Magnet" == strconfig){
00121                     fconfig >> m_param.mag;
00122                     if(fabs(m_param.mag) > 0.01) m_param.flagMag = true;
00123                     else m_param.flagMag = false;
00124                }else if("Ecm" == strconfig){
00125                     fconfig >> m_param.ecm;
00126                }else if("PFitRange" == strconfig){
00127                     fconfig >> m_param.pFitMin >> m_param.pFitMax;
00128                }else if("BoostPar" == strconfig){
00129                     fconfig >> m_param.boostPar[0] >> m_param.boostPar[1] >> m_param.boostPar[2];
00130                } else if("EsTimeFlag" == strconfig){
00131                     getline(fconfig, strTes);
00132                     int n = sscanf(strTes.c_str(), "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d",
00133                                    fgTes+0, fgTes+1, fgTes+2, fgTes+3, fgTes+4,
00134                                    fgTes+5, fgTes+6, fgTes+7, fgTes+8, fgTes+9,
00135                                    fgTes+10, fgTes+11, fgTes+12, fgTes+13, fgTes+14,
00136                                    fgTes+15, fgTes+16, fgTes+17, fgTes+18, fgTes+19);
00137                     for(i=0; i<n; i++) m_param.esFlag[i] = fgTes[i];
00138                     m_param.nEsFlag = n;
00139                } else if("TimeShift" == strconfig){
00140                     fconfig >> m_param.timeShift;
00141                } else if("TesMin" == strconfig){
00142                     fconfig >> m_param.tesMin;
00143                } else if("TesMax" == strconfig){
00144                     fconfig >> m_param.tesMax;
00145                } else if("FlagIniCalConst" == strconfig){
00146                     fconfig >> m_param.fgIniCalConst;
00147                } else if("FlagUpdateTmInPreT0" == strconfig){
00148                     fconfig >> m_param.preT0SetTm;
00149                } else if("InitT0" == strconfig){
00150                     fconfig >> m_param.initT0;
00151                } else if("T0Shift" == strconfig){
00152                     fconfig >> m_param.t0Shift;
00153                } else if("TminFitChindf" == strconfig){
00154                     fconfig >> m_param.tminFitChindf;
00155                } else if("TmaxFitChindf" == strconfig){
00156                     fconfig >> m_param.tmaxFitChindf;
00157                } else if("InitSigma" == strconfig){
00158                     fconfig >> m_param.initSigma;
00159                } else if("ResidualType" == strconfig){
00160                     fconfig >> m_param.resiType;
00161                } else if("FixXtC0" == strconfig){
00162                     fconfig >> m_param.fixXtC0;
00163                } else if("FlagAdjacLayerCut" == strconfig){
00164                     fconfig >> m_param.fgAdjacLayerCut;
00165                } else if("FlagBoundLayerCut" == strconfig){
00166                     fconfig >> m_param.fgBoundLayerCut;
00167                } else if("hitStatCut" == strconfig){
00168                     fconfig >> m_param.hitStatCut;
00169                } else if("nTrkCut" == strconfig){
00170                     fconfig >> m_param.nTrkCut[0] >> m_param.nTrkCut[1];
00171                } else if("nHitLayCut" == strconfig){
00172                     fconfig >> m_param.nHitLayCut;
00173                } else if("nHitCut" == strconfig){
00174                     fconfig >> m_param.nHitCut;
00175                } else if("cosThetaCut" == strconfig){
00176                     fconfig >> m_param.costheCut[0] >> m_param.costheCut[1];
00177                } else if("DrCut" == strconfig){
00178                     fconfig >> m_param.drCut;
00179                } else if("DzCut" == strconfig){
00180                     fconfig >> m_param.dzCut;
00181                }else if("MaximalDocaInner" == strconfig){
00182                     fconfig >> m_param.maxDocaInner;
00183                }else if("MaximalDocaOuter" == strconfig){
00184                     fconfig >> m_param.maxDocaOuter;
00185                }else if("MaximalResidual" == strconfig){
00186                     fconfig >> m_param.maxResi;
00187                } else if("RawTimeFitRange" == strconfig){
00188                     for(lay=0; lay<MdcCalNLayer; lay++){
00189                          fconfig >> strtmp
00190                                  >> m_param.fgCalib[lay]
00191                                  >> m_param.tminFitRange[lay][0]
00192                                  >> m_param.tminFitRange[lay][1]
00193                                  >> m_param.tmaxFitRange[lay][0]
00194                                  >> m_param.tmaxFitRange[lay][1]
00195                                  >> m_param.initTm[lay];
00196                     }
00197                }
00198           }
00199           fconfig.close();
00200      }
00201      // set single wire position calibration file
00202      m_param.wpcFile = m_wpcFile;
00203 
00204      // set event type
00205      m_param.particle = m_evtType;
00206 
00207      cout << "EsFlag for Mdc Calibration: ";
00208      for(int iEs=0; iEs<m_param.nEsFlag; iEs++) cout << setw(6) << m_param.esFlag[iEs];
00209      cout << endl;
00210 
00211      m_hlist    = new TObjArray(0);
00212      m_constmgr = new MdcCalConstMgr();
00213      m_calconst = new MdcCalibConst();
00214 
00215      m_mdcevt   = new MdcCalEvent();
00216      m_mdcevt -> setParam(m_param);
00217 
00218      if( 0 == m_mdcCalFlg ){
00219           m_mdccalib  = new IniMdcCalib();
00220      }else if( 1 == m_mdcCalFlg ){
00221           m_mdccalib  = new PreXtMdcCalib();
00222      }else if( 2 == m_mdcCalFlg ){
00223           m_mdccalib  = new PreT0MdcCalib();
00224      }else if( 3 == m_mdcCalFlg ){
00225           m_mdccalib  = new XtMdcCalib();
00226      }else if( 4 == m_mdcCalFlg ){
00227           m_mdccalib  = new GrXtMdcCalib();
00228      }else if( 5 == m_mdcCalFlg ){
00229           m_mdccalib  = new T0MdcCalib();
00230      }else if( 6 == m_mdcCalFlg ){
00231           m_mdccalib  = new WrMdcCalib();
00232      }else if( 7 == m_mdcCalFlg ){
00233           m_mdccalib  = new Wr2dMdcCalib();
00234      }else if( 8 == m_mdcCalFlg ){
00235           m_mdccalib  = new QtMdcCalib();
00236      }
00237      // initialize and read the calibraion data from TCDS
00238      m_constmgr -> init(m_mdcGeomSvc, m_mdcFunSvc);
00239 
00240      m_mdccalib -> setParam(m_param);
00241      m_mdccalib -> initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc);
00242 
00243 //      if(0 == m_mdcCalFlg) m_calconst->initCalibConst();
00244 
00245      return StatusCode::SUCCESS;
00246 }

void MdcCalibAlg::initParam  )  [private]
 

void MdcCalibAlg::initParam  )  [private]
 

00324                            {
00325      m_param.fillNtuple = 0;
00326      m_param.nEvtNtuple = 10000;
00327      m_param.fgCalDetEffi = 0;
00328      m_param.flagMag = true;
00329      m_param.mag = 1.0;
00330      m_param.ecm = 3.68632;
00331      m_param.pFitMin = 1.81;
00332      m_param.pFitMax = 1.95;
00333      m_param.boostPar[0] = 0.011;
00334      m_param.boostPar[1] = 0.0;
00335      m_param.boostPar[2] = 0.004;
00336      m_param.particle = 0;
00337      m_param.nEsFlag = 0;
00338      for(int i=0; i<50; i++) m_param.esFlag[i] = -999;
00339      m_param.timeShift = 0.0;
00340      m_param.tesMin = 0.0;
00341      m_param.tesMax = 9999.0;
00342      m_param.fgIniCalConst = 2;
00343      m_param.preT0SetTm = true;
00344      m_param.initT0 = 50.0;
00345      m_param.timeShift = 0.0;
00346      m_param.t0Shift = 0.0;
00347      m_param.tminFitChindf = 20.0;
00348      m_param.tmaxFitChindf = 20.0;
00349      m_param.initSigma = 0.16;  // mm
00350      m_param.resiType = 0;
00351      m_param.fixXtC0 = 0;
00352      m_param.fgAdjacLayerCut = 0;
00353      m_param.fgBoundLayerCut = 0;
00354      m_param.hitStatCut = 0;
00355      m_param.nTrkCut[0] = 2;
00356      m_param.nTrkCut[1] = 2;
00357      m_param.nHitLayCut = 35;
00358      m_param.nHitCut = 0;
00359      m_param.costheCut[0] = -1.0;
00360      m_param.costheCut[1] = 1.0;
00361      m_param.drCut = 50.0;      // mm
00362      m_param.dzCut = 300.0;     // mm
00363      m_param.maxDocaInner = 8.0;        // mm
00364      m_param.maxDocaOuter = 12.0;       // mm
00365      m_param.maxResi = 1.0;     // mm
00366 
00367      for(int lay=0; lay<MdcCalNLayer; lay++){
00368           m_param.fgCalib[lay] = 1;
00369           m_param.tminFitRange[lay][0] = 0.0;
00370           m_param.tminFitRange[lay][1] = 100.0;
00371           m_param.tmaxFitRange[lay][0] = 120.0;
00372           m_param.tmaxFitRange[lay][1] = 400.0;
00373           m_param.initTm[lay] = 300.0;
00374      }
00375 }


Member Data Documentation

MdcCalibConst* MdcCalibAlg::m_calconst [private]
 

MdcCalibConst* MdcCalibAlg::m_calconst [private]
 

std::string MdcCalibAlg::m_configFile [private]
 

MdcCalConstMgr* MdcCalibAlg::m_constmgr [private]
 

MdcCalConstMgr* MdcCalibAlg::m_constmgr [private]
 

bool MdcCalibAlg::m_distCalib [private]
 

int MdcCalibAlg::m_evtType [private]
 

TFile* MdcCalibAlg::m_fhist [private]
 

TFile* MdcCalibAlg::m_fhist [private]
 

int MdcCalibAlg::m_flgKalFit [private]
 

std::string MdcCalibAlg::m_histname [private]
 

TObjArray* MdcCalibAlg::m_hlist [private]
 

TObjArray* MdcCalibAlg::m_hlist [private]
 

bool MdcCalibAlg::m_initCalConstFlg [private]
 

int MdcCalibAlg::m_mdcCalFlg [private]
 

MdcCalib* MdcCalibAlg::m_mdccalib [private]
 

MdcCalib* MdcCalibAlg::m_mdccalib [private]
 

MdcCalEvent* MdcCalibAlg::m_mdcevt [private]
 

MdcCalEvent* MdcCalibAlg::m_mdcevt [private]
 

IMdcCalibFunSvc* MdcCalibAlg::m_mdcFunSvc [private]
 

IMdcCalibFunSvc* MdcCalibAlg::m_mdcFunSvc [private]
 

IMdcGeomSvc* MdcCalibAlg::m_mdcGeomSvc [private]
 

IMdcGeomSvc* MdcCalibAlg::m_mdcGeomSvc [private]
 

int MdcCalibAlg::m_nEvt [private]
 

int MdcCalibAlg::m_nEvtDisp [private]
 

MdcCalParams MdcCalibAlg::m_param [private]
 

std::string MdcCalibAlg::m_wpcFile [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:23:45 2011 for BOSS6.5.5 by  doxygen 1.3.9.1