00001 #include "include/T0Calib.h" 00002 #include "include/fun.h" 00003 00004 T0Calib::T0Calib(){ 00005 cout << "Calibration type: T0Calib" << endl; 00006 } 00007 00008 T0Calib::~T0Calib(){ 00009 } 00010 00011 void T0Calib::init(TObjArray* hlist, MdcCosGeom* pGeom){ 00012 CalibBase::init(hlist, pGeom); 00013 00014 m_pGeom = pGeom; 00015 00016 m_fdT0 = new TFolder("fdt0","fdt0"); 00017 hlist->Add(m_fdT0); 00018 00019 m_fdResiWire = new TFolder("resiWire", "resiWire"); 00020 hlist->Add(m_fdResiWire); 00021 00022 char hname[200]; 00023 for(int i=0; i<NWIRE; i++){ 00024 int lay = pGeom -> getWire(i) -> getLayerId(); 00025 int cel = pGeom -> getWire(i) -> getCellId(); 00026 00027 sprintf(hname, "mResi%04d_Lay%02d_Cell%03d_L", i, lay, cel); 00028 m_hleft[i] = new TH1F(hname, "", 400, -2.0, 2.0); 00029 m_fdT0 -> Add(m_hleft[i]); 00030 00031 sprintf(hname, "mResi%04d_Lay%02d_Cell%03d_R", i, lay, cel); 00032 m_hright[i] = new TH1F(hname, "", 400, -2.0, 2.0); 00033 m_fdT0 -> Add(m_hright[i]); 00034 } 00035 m_hLrResiSum = new TH1F("mLrResiSum", "", 200, -0.5, 0.5); 00036 m_fdResiWire->Add(m_hLrResiSum); 00037 00038 m_hLrResiSub = new TH1F("mLrResiSub", "", 200, -0.5, 0.5); 00039 m_fdResiWire->Add(m_hLrResiSub); 00040 } 00041 00042 void T0Calib::mergeHist(TFile* fhist){ 00043 CalibBase::mergeHist(fhist); 00044 00045 char hname[200]; 00046 TFolder* fd = (TFolder*)fhist->Get("fdT0"); 00047 for(int i=0; i<NWIRE; i++){ 00048 int lay = m_pGeom -> getWire(i) -> getLayerId(); 00049 int cel = m_pGeom -> getWire(i) -> getCellId(); 00050 00051 sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_L", i, lay, cel); 00052 TH1F* hl = (TH1F*)fd->FindObjectAny(hname); 00053 m_hleft[i]->Add(hl); 00054 00055 sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_R", i, lay, cel); 00056 TH1F* hr = (TH1F*)fd->FindObjectAny(hname); 00057 m_hright[i]->Add(hr); 00058 } 00059 } 00060 00061 void T0Calib::calib(MdcCalibConst* calconst, TObjArray* newXtList, TObjArray* r2tList){ 00062 CalibBase::calib(calconst, newXtList, r2tList); 00063 00064 double vdr = 0.03; 00065 for(int i=0; i<NWIRE; i++){ 00066 Stat_t entry_l = m_hleft[i] -> GetEntries(); 00067 double mean_l = m_hleft[i] -> GetMean(); 00068 if(entry_l < 50) mean_l = 0.0; 00069 00070 Stat_t entry_r = m_hright[i] -> GetEntries(); 00071 double mean_r = m_hright[i] -> GetMean(); 00072 if(entry_r < 50) mean_r = 0.0; 00073 00074 double delt0 = 0.5 * (mean_l + mean_r) / vdr; 00075 double resiLrSum = 0.5 * (mean_l + mean_r); 00076 double resiLrSub = 0.5 * (mean_l - mean_r); 00077 m_hLrResiSum->Fill(resiLrSum); 00078 m_hLrResiSub->Fill(resiLrSub); 00079 00080 double t0 = calconst->getT0(i); 00081 t0 += delt0; 00082 calconst->resetT0(i, t0); 00083 calconst->resetDelT0(i, delt0); 00084 } 00085 renameHist(); 00086 } 00087 00088 void T0Calib::renameHist(){ 00089 char hname[200]; 00090 m_fdT0->SetName("fdT0"); 00091 for(int i=0; i<NWIRE; i++){ 00092 int lay = m_pGeom -> getWire(i) -> getLayerId(); 00093 int cel = m_pGeom -> getWire(i) -> getCellId(); 00094 sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_L", i, lay, cel); 00095 m_hleft[i]->SetName(hname); 00096 sprintf(hname, "Resi%04d_Lay%02d_Cell%03d_R", i, lay, cel); 00097 m_hright[i]->SetName(hname); 00098 } 00099 00100 m_fdResiWire->SetName("ResiWire"); 00101 m_hLrResiSum->SetName("LrResiSum"); 00102 m_hLrResiSub->SetName("LrResiSub"); 00103 }