/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/MdcCalibAlg/MdcCalibAlg-00-09-02/src/T0MdcCalib.cxx

Go to the documentation of this file.
00001 #include "MdcCalibAlg/T0MdcCalib.h"
00002 
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/IMessageSvc.h"
00005 #include "GaudiKernel/StatusCode.h"
00006 #include "GaudiKernel/ISvcLocator.h"
00007 #include "GaudiKernel/Bootstrap.h"
00008 
00009 #include <iostream>
00010 #include <iomanip>
00011 #include <cstring>
00012 
00013 T0MdcCalib::T0MdcCalib(){
00014      for(int lay=0; lay<MdcCalNLayer; lay++){
00015           if(lay < 8){
00016                m_docaMin[lay] = 1.2; // mm
00017                m_docaMax[lay] = 4.8; // mm
00018           } else{
00019                m_docaMin[lay] = 1.6; // mm
00020                m_docaMax[lay] = 6.4; // mm
00021           }
00022      }
00023 }
00024 
00025 T0MdcCalib::~T0MdcCalib(){
00026 }
00027 
00028 void T0MdcCalib::clear(){
00029      for(int i=0; i<MdcCalTotCell; i++){
00030           delete m_hleft[i];
00031           delete m_hright[i];
00032      }
00033      delete m_hLrResiSum;
00034      delete m_hLrResiSub;
00035      delete m_fdT0;
00036      delete m_fdResiWire;
00037 
00038      MdcCalib::clear();
00039 }
00040 
00041 void T0MdcCalib::initialize(TObjArray* hlist, IMdcGeomSvc* mdcGeomSvc,
00042                             IMdcCalibFunSvc* mdcFunSvc, IMdcUtilitySvc* mdcUtilitySvc) {
00043      IMessageSvc* msgSvc;
00044      Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
00045      MsgStream log(msgSvc, "T0MdcCalib");
00046      log << MSG::INFO << "T0MdcCalib::initialize()" << endreq;
00047 
00048      m_hlist = hlist;
00049      m_mdcGeomSvc = mdcGeomSvc;
00050      m_mdcFunSvc = mdcFunSvc;
00051      m_mdcUtilitySvc = mdcUtilitySvc;
00052 
00053      m_vdr = 0.03;
00054 
00055      MdcCalib::initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc);
00056 
00057      int i;
00058      int nwire;
00059      int lay;
00060      int cel;
00061      char hname[200];
00062 
00063      m_fdT0 = new TFolder("fdT0", "fdT0");
00064      m_hlist -> Add(m_fdT0);
00065 
00066      m_fdResiWire = new TFolder("ResiWire", "ResiWire");
00067      m_hlist->Add(m_fdResiWire);
00068 
00069      nwire = m_mdcGeomSvc -> getWireSize();
00070      for(i=0; i<nwire; i++){
00071           lay = m_mdcGeomSvc -> Wire(i) -> Layer();
00072           cel = m_mdcGeomSvc -> Wire(i) -> Cell();
00073 
00074           sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_L", i, lay, cel);
00075           m_hleft[i] = new TH1F(hname, "", 400, -2.0, 2.0);
00076           m_fdT0 -> Add(m_hleft[i]);
00077 
00078           sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_R", i, lay, cel);
00079           m_hright[i] = new TH1F(hname, "", 400, -2.0, 2.0);
00080           m_fdT0 -> Add(m_hright[i]);
00081      }
00082 
00083      m_hLrResiSum = new TH1F("LrResiSum", "", 200, -0.5, 0.5);
00084      m_fdResiWire->Add(m_hLrResiSum);
00085 
00086      m_hLrResiSub = new TH1F("LrResiSub", "", 200, -0.5, 0.5);
00087      m_fdResiWire->Add(m_hLrResiSub);
00088 }
00089 
00090 int T0MdcCalib::fillHist(MdcCalEvent* event){
00091      IMessageSvc* msgSvc;
00092      Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
00093      MsgStream log(msgSvc, "T0MdcCalib");
00094      log << MSG::DEBUG << "T0MdcCalib::fillHist()" << endreq;
00095 
00096      MdcCalib::fillHist(event);
00097 
00098      // get EsTimeCol
00099      bool esCutFg = event->getEsCutFlag();
00100      if( ! esCutFg ) return -1;
00101 
00102      int i;
00103      int k;
00104      int ntrk;
00105      int nhit;
00106      int stat;
00107 
00108      int lay;
00109      int cel;
00110      int wir;
00111      int lr;
00112      double dmeas;
00113      double doca;
00114      double resi;
00115 
00116      bool fgHitLay[MdcCalNLayer];
00117 
00118      MdcCalRecTrk* rectrk;
00119      MdcCalRecHit* rechit;
00120 
00121      ntrk = event -> getNTrk();
00122      if((ntrk < m_param.nTrkCut[0]) || (ntrk > m_param.nTrkCut[1])) return -1;
00123 
00124      for(i=0; i<ntrk; i++){
00125           rectrk = event -> getRecTrk(i);
00126           nhit = rectrk -> getNHits();
00127 
00128           // dr cut
00129           double dr = rectrk->getDr();
00130           if(fabs(dr) > m_param.drCut) continue;
00131 
00132           // dz cut
00133           double dz = rectrk->getDz();
00134           if(fabs(dz) > m_param.dzCut) continue;
00135 
00136           for(lay=0; lay<MdcCalNLayer; lay++) fgHitLay[lay] = false;
00137           for(k=0; k<nhit; k++){
00138                rechit = rectrk -> getRecHit(k);
00139                lay = rechit -> getLayid();
00140                fgHitLay[lay] = true;
00141           }
00142 
00143           int nhitlay = 0;
00144           for(lay=0; lay<MdcCalNLayer; lay++) if(fgHitLay[lay]) nhitlay++;
00145           if(nhitlay < m_param.nHitLayCut) continue;
00146 
00147           bool fgNoise = rectrk->getFgNoiseRatio();
00148           if(m_param.noiseCut && (!fgNoise)) continue;
00149 
00150 //        log << MSG::DEBUG << "nhits: " << nhit << endreq;
00151           for(k=0; k<nhit; k++){
00152                rechit = rectrk -> getRecHit(k);
00153                lay = rechit -> getLayid();
00154                cel = rechit -> getCellid();
00155                wir = m_mdcGeomSvc -> Wire(lay, cel) -> Id();
00156                lr = rechit -> getLR();
00157                doca = rechit -> getDocaExc();
00158                dmeas = rechit -> getDmeas();
00159                resi = rechit -> getResiExc();
00160                stat = rechit -> getStat();
00161 
00162                if(1 != stat) continue;
00163 
00164                if( (fabs(doca) < m_docaMin[lay]) ||
00165                    (fabs(doca) > m_docaMax[lay]) ||
00166                    (fabs(resi) > m_param.resiCut[lay]) ){
00167                     continue;
00168                }
00169 
00170                if(0 == lay){
00171                     if( ! fgHitLay[1] ) continue;
00172                } else if(42 == lay){
00173                     if( ! fgHitLay[41] ) continue;
00174                } else{
00175                     if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
00176                }
00177 
00178                if(wir < (m_mdcGeomSvc->getWireSize()) ){
00179                     if( 0 == lr ){
00180                          m_hleft[wir] -> Fill(resi);
00181                     }else if( 1 == lr ){
00182                          m_hright[wir] -> Fill(resi);
00183                     }
00184                }else{
00185                     std::cout << "wireid: " << wir << std::endl;
00186                }
00187           }
00188      }
00189      return 1;
00190 }
00191 
00192 int T0MdcCalib::updateConst(MdcCalibConst* calconst){
00193      IMessageSvc* msgSvc;
00194      Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
00195      MsgStream log(msgSvc, "T0MdcCalib");
00196      log << MSG::INFO << "T0MdcCalib::updateConst()" << endreq;
00197 
00198      MdcCalib::updateConst(calconst);
00199 
00200      int i;
00201      int lay;
00202      int nwire;
00203      double t0;
00204      double delt0;
00205      double resiLrSum;
00206      double resiLrSub;
00207 
00208      Stat_t entry_l;
00209      double mean_l;
00210 //      double gmean_l;  // mean of fit with the gaussian distribution
00211 //      double sigma_l;
00212 //      double rms_l;
00213 
00214      Stat_t entry_r;
00215      double mean_r;
00216 //      double gmean_r;
00217 //      double sigma_r;
00218 //      double rms_r;
00219 
00220      nwire = m_mdcGeomSvc -> getWireSize();
00221      std::cout << "totwire: " << nwire << std::endl;
00222      for(i=0; i<nwire; i++){
00223           lay = m_mdcGeomSvc -> Wire(i) -> Layer();
00224 
00225           if(1 == m_param.fgCalib[lay]){
00226                entry_l = m_hleft[i] -> GetEntries();
00227                mean_l = m_hleft[i] -> GetMean();
00228 //             m_hleft[i] -> Fit("gaus", "Q");
00229 //             gmean_l = m_hleft[i] -> GetFunction("gaus") -> GetParameter(1);
00230 
00231                entry_r = m_hright[i] -> GetEntries();
00232                mean_r = m_hright[i] -> GetMean();
00233 //             m_hright[i] -> Fit("gaus", "Q");
00234 //             gmean_r = m_hright[i] -> GetFunction("gaus") -> GetParameter(1);
00235 
00236                delt0 = 0.5 * (mean_l + mean_r) / m_vdr;
00237           } else{
00238                delt0 = 0.0;
00239           }
00240 
00241           resiLrSum = 0.5 * (mean_l + mean_r);
00242           resiLrSub = 0.5 * (mean_l - mean_r);
00243           m_hLrResiSum->Fill(resiLrSum);
00244           m_hLrResiSub->Fill(resiLrSub);
00245 
00246           t0 = calconst -> getT0(i);
00247           t0 += delt0;
00248 
00249           calconst -> resetT0(i, t0);
00250           calconst -> resetDelT0(i, delt0);
00251      }
00252      return 1;
00253 }
00254 

Generated on Tue Nov 29 23:12:51 2016 for BOSS_7.0.2 by  doxygen 1.4.7