/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/MdcAlignAlg/MdcAlignAlg-00-01-04/share/distAlign/src/ResiAlign.cpp

Go to the documentation of this file.
00001 #include "include/ResiAlign.h"
00002 #include "include/fun.h"
00003 
00004 #include <cmath>
00005 
00006 #include "TF1.h"
00007 #include "TStyle.h"
00008 #include "TCanvas.h"
00009 
00010 ResiAlign::ResiAlign(){
00011      cout << "Alignment type: ResiAlign" << endl;
00012 }
00013 
00014 ResiAlign::~ResiAlign(){
00015 }
00016 
00017 void ResiAlign::init(TObjArray* hlist, MdcCosGeom* pGeom){
00018      m_pGeom = pGeom;
00019      char hname[200];
00020      m_hnTrk = new TH1F("mHNtrack", "", 10, -0.5, 9.5);
00021      hlist->Add(m_hnTrk);
00022 
00023      m_hnHit = new TH1F("mHNhit", "", 100, -0.5, 99.5);
00024      hlist->Add(m_hnHit);
00025 
00026      m_hlayHitmap = new TH1F("mHitmap", "", 43, -0.5, 42.5);
00027      hlist->Add(m_hnHit);
00028 
00029      m_hresAll = new TH1F("mHResAllInc", "", 200, -1.0, 1.0);
00030      hlist->Add(m_hresAll);
00031 
00032      m_hresInn = new TH1F("mHResInnInc", "", 200, -1.0, 1.0);
00033      hlist->Add(m_hresInn);
00034 
00035      m_hresStp = new TH1F("mHResStpInc", "", 200, -1.0, 1.0);
00036      hlist->Add(m_hresStp);
00037 
00038      m_hresOut = new TH1F("mHResOutInc", "", 200, -1.0, 1.0);
00039      hlist->Add(m_hresOut);
00040 
00041      for(int lay=0; lay<LAYERNMAX; lay++){
00042           sprintf(hname, "mRes_Layer%02d", lay);
00043           m_hresLay[lay] = new TH1F(hname, "", 200, -1.0, 1.0);
00044           hlist->Add(m_hresLay[lay]);
00045      }
00046 
00047      for(int iEP=0; iEP<NEP; iEP++){
00048           m_gr[iEP] = new TGraph();
00049           sprintf(hname, "mgrResi%02d", iEP);
00050           m_gr[iEP]->SetName(hname);
00051           hlist->Add(m_gr[iEP]);
00052 
00053           m_grSinPhi[iEP] = new TGraph();
00054           sprintf(hname, "mgrResi_sinPhi%02d", iEP);
00055           m_grSinPhi[iEP]->SetName(hname);
00056           hlist->Add(m_grSinPhi[iEP]);
00057 
00058           m_grCosPhi[iEP] = new TGraph();
00059           sprintf(hname, "mgrResi_cosPhi%02d", iEP);
00060           m_grCosPhi[iEP]->SetName(hname);
00061           hlist->Add(m_grCosPhi[iEP]);
00062 
00063           m_npoint[iEP] = 0;
00064      }
00065 }
00066 
00067 void ResiAlign::mergeHist(TFile* fhist){
00068      char hname[200];
00069      TH1F* hist;
00070      hist = (TH1F*)fhist->Get("HNtrack");
00071      m_hnTrk->Add(hist);
00072 
00073      hist = (TH1F*)fhist->Get("HNhit");
00074      m_hnHit->Add(hist);
00075 
00076      hist = (TH1F*)fhist->Get("Hitmap");
00077      m_hlayHitmap->Add(hist);
00078 
00079      hist = (TH1F*)fhist->Get("HResAllInc");
00080      m_hresAll->Add(hist);
00081 
00082      hist = (TH1F*)fhist->Get("HResInnInc");
00083      m_hresInn->Add(hist);
00084 
00085      hist = (TH1F*)fhist->Get("HResStpInc");
00086      m_hresStp->Add(hist);
00087 
00088      hist = (TH1F*)fhist->Get("HResOutInc");
00089      m_hresOut->Add(hist);
00090 
00091      for(int lay=0; lay<LAYERNMAX; lay++){
00092           sprintf(hname, "Res_Layer%02d", lay);
00093           hist = (TH1F*)fhist->Get(hname);
00094           m_hresLay[lay]->Add(hist);
00095      }
00096 
00097      for(int iEP=0; iEP<NEP; iEP++){
00098           sprintf(hname, "grResi%02d", iEP);
00099           TGraph* gr = (TGraph*)fhist->Get(hname);
00100           int np = gr->GetN();
00101           double xx;
00102           double yy;
00103           for(int i=0; i<np; i++){
00104                gr->GetPoint(i, xx, yy);
00105                m_gr[iEP]->SetPoint(m_npoint[iEP], xx, yy);
00106                m_grSinPhi[iEP]->SetPoint(m_npoint[iEP], sin(xx), yy);
00107                m_grCosPhi[iEP]->SetPoint(m_npoint[iEP], cos(xx), yy);
00108                m_npoint[iEP]++;
00109           }
00110      }
00111 }
00112 
00113 void ResiAlign::align(MdcAlignPar* alignPar){
00114      int iEP;
00115      double par[3];
00116      double err[3];
00117      double dx;
00118      double dy;
00119      double rz;
00120      double rLayer[] = { 120.225, 205.0, 237.55, 270.175, 302.625, 334.775, 366.65, 500.0,
00121                          120.225, 205.0, 237.55, 270.175, 302.625, 334.775, 366.65, 500.0 };
00122 
00123      TCanvas c1("c1", "c1", 10, 10, 700, 500);
00124      c1.SetFillColor(10);
00125 
00126      TF1* fResPhi = new TF1("fResPhi", funResi, 0, PI2, 3);
00127      fResPhi->SetParameter(0, 0.0);
00128      fResPhi->SetParameter(1, 0.0);
00129      fResPhi->SetParameter(2, 0.0);
00130 
00131      for(iEP=0; iEP<NEP; iEP++){
00132           if((m_gr[iEP]->GetN()) > 500){
00133                // align dx, dy, rz
00134                m_gr[iEP]->Fit("fResPhi", "V");
00135                par[0] = fResPhi->GetParameter(0);
00136                par[1] = fResPhi->GetParameter(1);
00137                par[2] = fResPhi->GetParameter(2);
00138                err[0] = fResPhi->GetParError(0);
00139                err[1] = fResPhi->GetParError(1);
00140                err[2] = fResPhi->GetParError(2);
00141 
00142                // align dx and rz
00143 //             m_grSinPhi[iEP]->Fit("pol1");
00144 //             par[0] = m_grSinPhi[iEP]->GetFunction("pol1")->GetParameter(0);
00145 //             par[1] = m_grSinPhi[iEP]->GetFunction("pol1")->GetParameter(1);
00146 //             par[2] = 0.0;
00147 //             err[0] = m_grSinPhi[iEP]->GetFunction("pol1")->GetParError(0);
00148 //             err[1] = m_grSinPhi[iEP]->GetFunction("pol1")->GetParError(1);
00149 //             err[2] = 0.0;
00150 
00151                // align dy
00152 //             m_grCosPhi[iEP]->Fit("pol1");
00153 //             par[0] = 0.0;
00154 //             par[1] = 0.0;
00155 //             par[2] = m_grCosPhi[iEP]->GetFunction("pol1")->GetParameter(1);
00156 //             err[0] = 0.0;
00157 //             err[1] = 0.0;
00158 //             err[2] = m_grCosPhi[iEP]->GetFunction("pol1")->GetParError(1);
00159 
00160                dx = -1.0 * par[1];
00161                dy = par[2];
00162                rz = par[0] / rLayer[iEP];
00163 
00164                if (7==iEP || 15==iEP) {
00165                     dx = 0.0;
00166                     dy = 0.0;
00167                     rz = 0.0;
00168                     par[0] = 0.0;
00169                     par[1] = 0.0;
00170                     par[2] = 0.0;
00171                }
00172                alignPar->setDelDx(iEP, dx);
00173                alignPar->setDelDy(iEP, dy);
00174                alignPar->setDelRz(iEP, rz);
00175 
00176                alignPar->setErrDx(iEP, err[1]);
00177                alignPar->setErrDy(iEP, err[2]);
00178                alignPar->setErrRz(iEP, err[0]/rLayer[iEP]);
00179           }
00180      }
00181      renameHist();
00182      delete fResPhi;
00183 }
00184 
00185 void ResiAlign::renameHist(){
00186      char hname[200];
00187      m_hnTrk->SetName("HNtrack");
00188      m_hnHit->SetName("HNhit");
00189      m_hlayHitmap->SetName("Hitmap");
00190      m_hresAll->SetName("HResAllInc");
00191      m_hresInn->SetName("HResInnInc");
00192      m_hresStp->SetName("HResStpInc");
00193      m_hresOut->SetName("HResOutInc");
00194      for(int lay=0; lay<LAYERNMAX; lay++){
00195           sprintf(hname, "Res_Layer%02d", lay);
00196           m_hresLay[lay]->SetName(hname);
00197      }
00198      for(int iEP=0; iEP<NEP; iEP++){
00199           sprintf(hname, "grResi%02d", iEP);
00200           m_gr[iEP]->SetName(hname);
00201 
00202           sprintf(hname, "grResi_sinPhi%02d", iEP);
00203           m_grSinPhi[iEP]->SetName(hname);
00204 
00205           sprintf(hname, "grResi_cosPhi%02d", iEP);
00206           m_grCosPhi[iEP]->SetName(hname);
00207      }
00208 }
00209 
00210 Double_t ResiAlign::funResi(Double_t* x, Double_t* par){
00211      Double_t val;
00212      val = par[0] + par[1]*sin(x[0]) + par[2]*cos(x[0]);
00213      return val;
00214 }

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