//[ basic_bytearray_cpp_main int main() { BByteArray ar1 ( "abcdef" ); unsigned char * tmp = 0; // Creating another bytearray that shares the internal data with ar1 BByteArray ar2 = ar1; printf("ar1 internal buffer address: %p\n", (void*)ar1.constData()); printf("ar2 internal buffer address: %p\n\n", (void*)ar2.constData()); // performing a non read-only operation on ar2, using the non-const version // of BByteArray::data() tmp = ar2.data(); printf("ar1 internal buffer address: %p\n", (void*)ar1.constData()); printf("ar2 internal buffer address: %p\n\n", (void*)ar2.constData()); // performing another non read-only operation on ar2, but this time, ar2 is // not shared, thus it doesn't need to copy its internal data tmp = ar2.data(); printf("ar1 internal buffer address: %p\n", (void*)ar1.constData()); printf("ar2 internal buffer address: %p\n\n", (void*)ar2.constData()); return 0; }
bool Object::equal(const Object& v2) const { if (m_px == v2.get()) { return true; } if (!m_px || !v2.get()) { return false; } if (m_px->isCollection()) { return collectionEquals(m_px, v2.get()); } if (UNLIKELY(m_px->instanceof(SystemLib::s_DateTimeInterfaceClass))) { return c_DateTime::GetTimestamp(*this) == c_DateTime::GetTimestamp(v2); } if (v2.get()->getVMClass() != m_px->getVMClass()) { return false; } if (UNLIKELY(m_px->instanceof(SystemLib::s_ArrayObjectClass))) { // Compare the whole object, not just the array representation Array ar1(ArrayData::Create()); Array ar2(ArrayData::Create()); m_px->o_getArray(ar1, false); v2->o_getArray(ar2, false); return ar1->equal(ar2.get(), false); } return toArray().equal(v2.toArray()); }
void CControlView::OnTvnItemChangedPlotdataTree(NMHDR *pNMHDR, LRESULT *pResult) { NMTVITEMCHANGE *pNMTVItemChange = reinterpret_cast<NMTVITEMCHANGE*>(pNMHDR); // TODO: 在此添加控件通知处理程序代码 //UpdateData(TRUE); if (Initial_flag && clicked_flag)//防止bug { CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd; CPlotView* pPlotView_tempt=(CPlotView*)pMain->pPlotView; CSmartCarDoc * pDoc_temp=(CSmartCarDoc*)m_pDocument; for (int i=0; i<3; i++) pPlotView_tempt->Window[i].SetShowFlag(m_PlotTree.GetCheck(hWindow[i])); for (int i=0;i<9;i++) pDoc_temp->plot[i].SetShowFlag(m_PlotTree.GetCheck(hPlot[i])); //序列化保存配置信息 CFile file (_T ("abc.txt"), CFile::modeCreate | CFile::modeWrite); CArchive ar (&file, CArchive::store); for (int i=0;i<9;i++) { pDoc_temp->plot[i].Serialize(ar); } ar.Flush(); //读完毕,关闭文件流 ar.Close(); file.Close(); //保存窗口坐标轴信息 CFile file1 (_T ("Axis.txt"), CFile::modeCreate | CFile::modeWrite); CArchive ar1 (&file1, CArchive::store); for (int i=0;i<3;i++) { pPlotView_tempt->Window[i].Serialization(ar1); } ar1.Flush(); //读完毕,关闭文件流 ar1.Close(); file1.Close(); clicked_flag = FALSE; //更新视图 pPlotView_tempt->Invalidate(FALSE); } *pResult = 0; }
void plotHitResSim(){ setTDRStyle(); gROOT->SetStyle("tdrStyle"); // load the code before executing the macro: gROOT->LoadMacro("TrackingAnalysis/Cosmics/test/OverlapHistos.C+"); //make sure OverlapHistos.h is pointing to a root file from MC ol = new OverlapHistos(); ol->Loop(); //summary histos written out to main file, histos/detid pair in root->ROOT Memory //new TBrowser() width->SetLineColor(2); width->SetMarkerStyle(24); //20 width->SetMarkerColor(2); width->GetYaxis()->SetTitle("Uncertainty [#mum]"); width->SetMinimum(0); width->GetXaxis()->SetTitle(""); width->GetXaxis()->SetLabelSize(0); width->GetXaxis()->SetTickLength(0); simRec->SetLineColor(4); simRec->SetMarkerStyle(25); //21 simRec->SetMarkerColor(4); simTrk->SetMarkerStyle(26); //22 width->Draw(); simTrk->Draw("same"); simRec->Draw("same"); leg_hist = new TLegend(0.12,0.7,0.39,0.89); leg_hist->AddEntry(width,"Fitted width #Deltax_{hit}-#Deltax_{pred} [#mum]","p"); leg_hist->AddEntry(simTrk,"Fitted width #Deltax_{pred}-#Deltax_{sim}","p"); leg_hist->AddEntry(simRec,"Fitted width #Deltax_{hit}-#Deltax_{sim}","p"); leg_hist->SetTextSize(0.055); leg_hist->SetFillColor(0); leg_hist->Draw("same"); TArrow ar1(0.0,0.0,5.5,0.0,0.05,"<|>"); ar1.SetArrowSize(0.02); ar1.SetAngle(40); ar1.SetLineWidth(2); ar1.Draw(); TArrow ar3(6,0.0,15.5,0.0,0.05,"<|>"); ar3.SetArrowSize(0.02); ar3.SetAngle(40); ar3.SetLineWidth(2); ar3.Draw(); TArrow ar4(16,0.0,33.5,0.0,0.05,"<|>"); ar4.SetArrowSize(0.02); ar4.SetAngle(40); ar4.SetLineWidth(2); ar4.Draw(); TArrow ar5(34,0.0,60.5,0.0,0.05,"<|>"); ar5.SetArrowSize(0.02); ar5.SetAngle(40); ar5.SetLineWidth(2); ar5.Draw(); TArrow ar2(61,0.0,86,0.0,0.05,"<|>"); ar2.SetArrowSize(0.02); ar2.SetAngle(40); ar2.SetLineWidth(2); ar2.Draw(); TLatex* taga = new TLatex(.115, .085, "TIB1"); taga->SetNDC(kTRUE); taga->SetTextSize(0.04); taga->Draw(); TLatex* taga = new TLatex(.19, .085, "TIB2"); taga->SetNDC(kTRUE); taga->SetTextSize(0.04); taga->Draw(); TLatex* taga = new TLatex(.33, .085, "TIB3"); taga->SetNDC(kTRUE); taga->SetTextSize(0.04); taga->Draw(); TLatex* taga = new TLatex(.55, .085, "TIB4"); taga->SetNDC(kTRUE); taga->SetTextSize(0.04); taga->Draw(); TLatex* tagg = new TLatex(.83, .085, "TOB"); tagg->SetNDC(kTRUE); tagg->SetTextSize(0.04); tagg->Draw(); c1->SaveAs("ResolutionSim.eps"); // c1->Print("ResolutionSim.pdf","pdf"); // do epstopdf instead }
int main(int argc, char *argv[]) { // Initialize POOMA and output stream, using Tester class Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); tester.out() << argv[0] << ": Tests of expressions with multipatch." << std::endl; tester.out() << "------------------------------------------------" << std::endl; int size = 30; int from = 0; int to = size-1; int fromInterior = 0; int toInterior = size-1; int loc1 = 4; int loc2 = 14; int loc3 = 22; Interval<1> dom(from,to); Interval<1> I(fromInterior,toInterior); Interval<1> domain(size); UniformGridPartition<1> partition(Loc<1>(10),GuardLayers<1>(1)); UniformGridLayout<1> layout(domain,partition,ReplicatedTag()); Array<1,double,MultiPatch<UniformTag,Brick> > a1(layout), a2(layout), a3(layout), a4(layout), initial(layout); initial = 0.0; Pooma::blockAndEvaluate(); initial(loc1) = 2.0; initial(loc2) = 3.0; initial(loc3) = 4.0; test1(tester, 1, a1, a2, a3, a4, initial, I); test2(tester, 2, a1, a2, a3, a4, initial, I); test3(tester, 3, a1, a2, a3, a4, initial, I); test4(tester, 4, a1, a2, a3, a4, initial, I); Array<1,Vector<2,double>,MultiPatch<UniformTag,Brick> > av1(layout),av2(layout),av3(layout),av4(layout), initialv(layout); initialv = Vector<2,double>(0.0,0.0); Pooma::blockAndEvaluate(); initialv(loc1) = Vector<2,double>(2.0,3.0); initialv(loc2) = Vector<2,double>(3.0,-1.0); initialv(loc3) = Vector<2,double>(4.0,-5.0); test5(tester, 5, av1, av2, av3, av4, initialv, I); test1(tester, 6, av1, av2, av3, av4, initialv, I); test4(tester, 7, av1, av2, av3, av4, initialv, I); UniformGridLayout<1> layoutr(domain, partition, DistributedTag()); Array<1, double, MultiPatch<UniformTag, Remote<Brick> > > ar1(layoutr), ar2(layoutr), ar3(layoutr), ar4(layoutr); test1(tester, 8, ar1, ar2, ar3, ar4, initial, I); test2(tester, 9, ar1, ar2, ar3, ar4, initial, I); test3(tester, 10, ar1, ar2, ar3, ar4, initial, I); test4(tester, 11, ar1, ar2, ar3, ar4, initial, I); tester.out() << "------------------------------------------------" << std::endl; int retval = tester.results("array_test18"); Pooma::finalize(); return retval; }
LRESULT CWorkThread::Proc_CMD_PTR_PRINT_FORM(WPARAM wParam) { CServiceBasic *pServiceBasic = (CServiceBasic *)wParam; WFSPTRPRINTFORM *pwfsPrintForm = (WFSPTRPRINTFORM*)pServiceBasic->m_lpCmdData; if(pwfsPrintForm == 0 ) return WFS_ERR_PTR_FORMINVALID; //wfsPrintForm = *(WFSPTRPRINTFORM*)pServiceBasic->m_lpCmdData; //PrinterBase printerBase; const LPSTR lpszFormName = pwfsPrintForm->lpszFormName; const LPSTR lpszMediaName = pwfsPrintForm->lpszMediaName; CString strFileName = pServiceBasic->GetFormFilePath( m_strLogicalName,lpszFormName); if(strFileName == "") { return WFS_ERR_PTR_FORMNOTFOUND; } // Form preprocessing // replace * with form name { strFileName.Replace("*",lpszFormName); } BOOL bRemote = FALSE; { CString strFileSource = ""; CString strFile = strFileName; long n = strFile.Find(":"); if(n == 1) { bRemote = FALSE; strFile.TrimRight(); strFileSource = strFile; char *p = strFileSource.GetBuffer(0); for(long i=0; i<strFileSource.GetLength(); i++) { if(p[i] == '/') p[i] = '\\'; } strFileSource.ReleaseBuffer(); } else { bRemote = TRUE; strFile.TrimRight(); strFileSource = strFile; char *p = strFileSource.GetBuffer(0); for(long i=0; i<strFileSource.GetLength(); i++) { if(p[i] == '\\') p[i] = '/'; } strFileSource.ReleaseBuffer(); } CString strTarget = strFileSource; char bufTempPath[2048]={0}; DWORD nn = ::GetTempPath( 2048, // size, in characters, of the buffer bufTempPath // pointer to buffer for temp. path ); char buf[2048]={0}; UINT nRet = ::GetTempFileName( bufTempPath, //LPCTSTR lpPathName, // pointer to directory name for temporary // file "NI", //LPCTSTR lpPrefixString, // pointer to filename prefix 0, //UINT uUnique, // number used to create temporary filename buf // pointer to buffer that receives the new // filename ); if(nRet == 0) { CString m_strTempDir = ""; char *pUser = getenv( "ProgramFiles"); if(pUser != 0) { m_strTempDir = CString(pUser); } CString strRandom; srand(::GetTickCount()); long n = rand(); strRandom.Format("%d",n); CString strTempFile = m_strTempDir + "\\Temp\\NI" + strRandom; strcpy(buf,strTempFile); } NI_MakePath(buf); BOOL bRet = FALSE; if(!bRemote) { bRet = ::CopyFile(strTarget,buf,FALSE); } else // tang 20050728 { bstr_t url(strTarget.GetBuffer(0)); bstr_t filepath (buf); HRESULT hr = URLDownloadToFile( NULL, //LPUNKNOWN pCaller, // Caller's controlling IUnknown url, //LPCWSTR szURL, // Pointer to URL to be downloaded filepath, //LPCTSTR szFileName, // Pointer to file name 0, //DWORD dwResv, // Reserved for future use 0 //LPBINDSTATUSCALLBACK lpfnCB // Caller's IBindStatusCallback ); if(hr == 0) bRet = TRUE; else { ::DeleteFile(buf); bRet = FALSE; } } if(!bRet) return -1; strFileName = buf; } //char strFileName[2000]; //memset(strFileName,0,sizeof(strFileName)); //int nLen; //nLen = sizeof(strFileName); //GetFormName(lpszFormName,strFileName,nLen); //if(strlen(strFileName) < 0 ) // return -1;//can't find the form; ///test ... //CFile cfile; //cfile.Open(strFileName,CFile::modeReadWrite | CFile::shareExclusive,NULL); //CXFSForm xfsform; //CArchive ar(&cfile,CArchive::load); //xfsform.Serialize(ar); /// //process form CXFSForm *pform = 0; pform = new CXFSForm; CFile cfile; BOOL bRet; bRet = cfile.Open(strFileName,CFile::modeRead | CFile::shareExclusive); if(!bRet) return WFS_ERR_PTR_FORMNOTFOUND; CArchive ar(&cfile,CArchive::load); try { while(1) { pform->Serialize(ar); if(pform->m_strFormName == lpszFormName) break; delete pform; pform = new CXFSForm; } } catch(CFileException *e) { e->Delete(); delete pform; pform = 0; } ar.Close(); cfile.Close(); if(pform == 0) return WFS_ERR_PTR_FORMNOTFOUND; // if(pwfsPrintForm->wAlignment == WFS_PTR_ALNUSEFORMDEFN){} else if(pwfsPrintForm->wAlignment == WFS_PTR_ALNTOPLEFT){ pform->alignment.m_strAlignment = "TOPLEFT"; } else if(pwfsPrintForm->wAlignment == WFS_PTR_ALNTOPRIGHT){ pform->alignment.m_strAlignment = "TOPRIGHT"; } else if(pwfsPrintForm->wAlignment == WFS_PTR_ALNBOTTOMLEFT){ pform->alignment.m_strAlignment = "BOTTOMLEFT"; } else if(pwfsPrintForm->wAlignment == WFS_PTR_ALNBOTTOMRIGHT){ pform->alignment.m_strAlignment = "BOTTOMRIGHT"; } if(pwfsPrintForm->wOffsetX == WFS_PTR_OFFSETUSEFORMDEFN){} else{ pform->alignment.m_wXoffset = pwfsPrintForm->wOffsetX; } if(pwfsPrintForm->wOffsetY == WFS_PTR_OFFSETUSEFORMDEFN){} else{ pform->alignment.m_wYoffset = pwfsPrintForm->wOffsetY; } CXFSMedia *pMedia = 0; if(lpszMediaName != 0 && lpszMediaName[0] != 0) { pMedia = new CXFSMedia; bRet = cfile.Open(strFileName,CFile::modeRead | CFile::shareExclusive); if(!bRet) return WFS_ERR_PTR_FORMNOTFOUND; CArchive ar1(&cfile,CArchive::load); pMedia->Serialize(ar1); try { while(1) { pMedia->Serialize(ar); if(pMedia->m_strMediaName == lpszMediaName) break; delete pform; pMedia = new CXFSMedia; } } catch(CFileException *e) { e->Delete(); delete pMedia; pMedia = 0; } ar1.Close(); cfile.Close(); } //if(bRemote) ::DeleteFile(strFileName); if(bRemote) ::DeleteFile(strFileName); if(pMedia && pMedia->size.m_wWidth == 0 || pMedia->size.m_wHeight == 0) { //delete pMedia; //pMedia = 0; } pform->ExtractFieldValue(pwfsPrintForm->lpszFields); HRESULT hr = 0; if(pMedia) hr = pform->CheckAgainstMedia(pMedia); //m_PrinterBase. DOCINFO MyDocInfo; MyDocInfo.cbSize = sizeof(DOCINFO); MyDocInfo.lpszDocName=(LPSTR)"SPI"; MyDocInfo.lpszOutput=NULL; if(m_pDC->StartDoc((DOCINFO far *)&MyDocInfo)>=0) { m_pDC->StartPage(); pform->Draw(m_pDC); m_pDC->EndPage(); if(m_pDC->EndDoc()<0) { m_pDC->AbortDoc(); PostEventWnd(pServiceBasic->m_hService,EXECUTE_EVENTS, WFS_EXEE_PTR_NOMEDIA,(DWORD)"Abort Printing", 0); } } delete pform; /* WFSPTRFORM *pwfsptrform; int nLength ; nLength = sizeof(WFSPTRFORM); pwfsptrform = new WFSPTRFORM; GetData_FormBuffer(pFile,nLen,(char*)pwfsptrform,nLength); ///get the struct of WFSPTRFORM now we deal with with this struct if(wfsPrintForm.wAlignment != WFS_PTR_ALNUSEFORMDEFN) { if(wfsPrintForm.wAlignment == WFS_PTR_ALNTOPLEFT) { //sprintf(pwfsptrform->alignment_form.alignment,"TOPLEFT"); } else if(wfsPrintForm.wAlignment == WFS_PTR_ALNTOPRIGHT) { //sprintf(pwfsptrform->alignment_form.alignment,"TOPRIGHT"); } else if(wfsPrintForm.wAlignment == WFS_PTR_ALNBOTTOMLEFT) { sprintf(pwfsptrform->alignment_form.alignment,"BOTTOMLEFT"); } else if(wfsPrintForm.wAlignment == WFS_PTR_ALNBOTTOMRIGHT) { sprintf(pwfsptrform->alignment_form.alignment,"BOTTOMRIGHT"); } pwfsptrform->alignment_form.xoffset = wfsPrintForm.wOffsetX; pwfsptrform->alignment_form.yoffset = wfsPrintForm.wOffsetY; } ////SET printer resolution if(wfsPrintForm.wResolution == WFS_PTR_RESLOW) { printerBase.SetPrinterResolution(120); } else if(wfsPrintForm.wResolution == WFS_PTR_RESMED) { printerBase.SetPrinterResolution(180); } else if(wfsPrintForm.wResolution == WFS_PTR_RESHIGH) { printerBase.SetPrinterResolution(180); } ///// ////print field here,and each field terminate with two null characters ,every string ////is null terminate //// char *pFields; pFields = wfsPrintForm.lpszFields; ///this string is null terminate each field and two null terminate // CXfsPrinter xfsprinter; // xfsprinter.printField((char*)pwfsptrform,pFields); {///结束处理 if(pwfsptrform) delete pwfsptrform; } //when after print ,how to control media ?, to deal this process if(wfsPrintForm.dwMediaControl != 0) { } */ return hr; }
static void testrotations() { ap::real_2d_array al1; ap::real_2d_array al2; ap::real_2d_array ar1; ap::real_2d_array ar2; ap::real_1d_array cl; ap::real_1d_array sl; ap::real_1d_array cr; ap::real_1d_array sr; ap::real_1d_array w; int m; int n; int maxmn; double t; int pass; int passcount; int i; int j; double err; double maxerr; bool isforward; passcount = 1000; maxerr = 0; for(pass = 1; pass <= passcount; pass++) { // // settings // m = 2+ap::randominteger(50); n = 2+ap::randominteger(50); isforward = ap::randomreal()>0.5; maxmn = ap::maxint(m, n); al1.setbounds(1, m, 1, n); al2.setbounds(1, m, 1, n); ar1.setbounds(1, m, 1, n); ar2.setbounds(1, m, 1, n); cl.setbounds(1, m-1); sl.setbounds(1, m-1); cr.setbounds(1, n-1); sr.setbounds(1, n-1); w.setbounds(1, maxmn); // // matrices and rotaions // for(i = 1; i <= m; i++) { for(j = 1; j <= n; j++) { al1(i,j) = 2*ap::randomreal()-1; al2(i,j) = al1(i,j); ar1(i,j) = al1(i,j); ar2(i,j) = al1(i,j); } } for(i = 1; i <= m-1; i++) { t = 2*ap::pi()*ap::randomreal(); cl(i) = cos(t); sl(i) = sin(t); } for(j = 1; j <= n-1; j++) { t = 2*ap::pi()*ap::randomreal(); cr(j) = cos(t); sr(j) = sin(t); } // // Test left // applyrotationsfromtheleft(isforward, 1, m, 1, n, cl, sl, al1, w); for(j = 1; j <= n; j++) { applyrotationsfromtheleft(isforward, 1, m, j, j, cl, sl, al2, w); } err = 0; for(i = 1; i <= m; i++) { for(j = 1; j <= n; j++) { err = ap::maxreal(err, fabs(al1(i,j)-al2(i,j))); } } maxerr = ap::maxreal(err, maxerr); // // Test right // applyrotationsfromtheright(isforward, 1, m, 1, n, cr, sr, ar1, w); for(i = 1; i <= m; i++) { applyrotationsfromtheright(isforward, i, i, 1, n, cr, sr, ar2, w); } err = 0; for(i = 1; i <= m; i++) { for(j = 1; j <= n; j++) { err = ap::maxreal(err, fabs(ar1(i,j)-ar2(i,j))); } } maxerr = ap::maxreal(err, maxerr); } printf("TESTING ROTATIONS\n"); printf("Pass count %0ld\n", long(passcount)); printf("Error is %5.3le\n", double(maxerr)); }
void CV_SolvePolyTest::run( int ) { CvRNG rng = cvRNG(); int fig = 100; double range = 50; double err_eps = 1e-4; for (int idx = 0, max_idx = 1000, progress = 0; idx < max_idx; ++idx) { progress = update_progress(progress, idx-1, max_idx, 0); int n = cvRandInt(&rng) % 13 + 1; std::vector<complex_type> r(n), ar(n), c(n + 1, 0); std::vector<double> a(n + 1), u(n * 2), ar1(n), ar2(n); int rr_odds = 3; // odds that we get a real root for (int j = 0; j < n;) { if (cvRandInt(&rng) % rr_odds == 0 || j == n - 1) r[j++] = cvRandReal(&rng) * range; else { r[j] = complex_type(cvRandReal(&rng) * range, cvRandReal(&rng) * range + 1); r[j + 1] = std::conj(r[j]); j += 2; } } for (int j = 0, k = 1 << n, jj, kk; j < k; ++j) { int p = 0; complex_type v(1); for (jj = 0, kk = 1; jj < n && !(j & kk); ++jj, ++p, kk <<= 1) ; for (; jj < n; ++jj, kk <<= 1) { if (j & kk) v *= -r[jj]; else ++p; } c[p] += v; } bool pass = false; double div = 0, s = 0; int cubic_case = idx & 1; for (int maxiter = 100; !pass && maxiter < 10000; maxiter *= 2, cubic_case = (cubic_case + 1) % 2) { for (int j = 0; j < n + 1; ++j) a[j] = c[j].real(); CvMat amat, umat; cvInitMatHeader(&amat, n + 1, 1, CV_64FC1, &a[0]); cvInitMatHeader(&umat, n, 1, CV_64FC2, &u[0]); cvSolvePoly(&amat, &umat, maxiter, fig); for (int j = 0; j < n; ++j) ar[j] = complex_type(u[j * 2], u[j * 2 + 1]); sort(r.begin(), r.end(), pred_complex()); sort(ar.begin(), ar.end(), pred_complex()); pass = true; if( n == 3 ) { ar2.resize(n); cv::Mat _umat2(3, 1, CV_64F, &ar2[0]), umat2 = _umat2; cvFlip(&amat, &amat, 0); int nr2; if( cubic_case == 0 ) nr2 = cv::solveCubic(cv::Mat(&amat),umat2); else nr2 = cv::solveCubic(cv::Mat_<float>(cv::Mat(&amat)), umat2); cvFlip(&amat, &amat, 0); if(nr2 > 0) sort(ar2.begin(), ar2.begin()+nr2, pred_double()); ar2.resize(nr2); int nr1 = 0; for(int j = 0; j < n; j++) if( fabs(r[j].imag()) < DBL_EPSILON ) ar1[nr1++] = r[j].real(); pass = pass && nr1 == nr2; if( nr2 > 0 ) { div = s = 0; for(int j = 0; j < nr1; j++) { s += fabs(ar1[j]); div += fabs(ar1[j] - ar2[j]); } div /= s; pass = pass && div < err_eps; } } div = s = 0; for (int j = 0; j < n; ++j) { s += fabs(r[j].real()) + fabs(r[j].imag()); div += sqrt(pow(r[j].real() - ar[j].real(), 2) + pow(r[j].imag() - ar[j].imag(), 2)); } div /= s; pass = pass && div < err_eps; } if (!pass) { ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT); ts->printf( CvTS::LOG, "too big diff = %g\n", div ); for (size_t j=0;j<ar2.size();++j) ts->printf( CvTS::LOG, "ar2[%d]=%g\n", j, ar2[j]); ts->printf(CvTS::LOG, "\n"); for (size_t j=0;j<r.size();++j) ts->printf( CvTS::LOG, "r[%d]=(%g, %g)\n", j, r[j].real(), r[j].imag()); ts->printf( CvTS::LOG, "\n" ); for (size_t j=0;j<ar.size();++j) ts->printf( CvTS::LOG, "ar[%d]=(%g, %g)\n", j, ar[j].real(), ar[j].imag()); break; } } }
void tqgammaVStqz(){ TCanvas *c1 = new TCanvas("c1","upper limit results ",200,10,700,500); c1->SetLogy(1); c1->SetLogx(1); c1->Range(0,0,1,1); const int N=3; double cdfx[4]={0,0.032,0.032,1}; double cdfy[4]={0.037,0.037,0,0}; double dzerox[4]={0.000001,0.02,0.06,1}; double dzeroy[4]={0.032,0.032,0.032,0.032}; //double cdfx[7]={0,0,1,1,0.45,0.45,0}; //double cdfy[7]={0.032,0.1,0.1,0,0,0.032,0.032}; double lepx[4]={0,0.0468,0.04681,0.0468}; double lepy[4]={0.08,0.08,0,0}; double herax[4]={0,0.0060,0.0060,0.0060}; double heray[4]={0.3,0.3,0,0}; double h1x[4]={0.0064,0.0064,0.0064,0.0064}; double h1y[4]={0.000001,0.02,0.06,1}; double cmsx[4]={0.000001,0.02,0.06,1}; double cmsy[4]={0.0005,0.0005,0.0005,0.0005}; double atlasx[4]={0.000001,0.02,0.06,1}; double atlasy[4]={0.0073,0.0073,0.0073,0.0073}; double mycmsx[4]={0.000161,0.000161,0.000161,0.000161}; double mycmsy[4]={0.000001,0.02,0.06,1}; double mycmscx[4]={0.00182,0.00182,0.00182,0.00182}; double mycmscy[4]={0.000001,0.02,0.06,1}; double cmsphux[4]={0.00001,0.000161,0.000161001,1}; double cmsphuy[4]={0,0,0,0}; double cmsphcx[4]={0.00182,0.00182,0.00182,0.00182}; double cmsphcy[4]={0,0.02,0.06,1}; TGraph *cdf= new TGraph(4,cdfx,cdfy); cdf->SetLineColor(12); cdf->SetLineWidth(3); cdf->SetMarkerColor(1); cdf->SetMarkerStyle(20); // Observed->SetLineStyle(2); cdf->GetYaxis()->SetTitle("Cross Section [pb]"); cdf->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); cdf->SetTitle("with "); cdf->SetFillColor(45); cdf->GetXaxis()->SetLabelOffset(0.0001); TGraph *dzero= new TGraph(4,dzerox,dzeroy); dzero->SetLineColor(3); dzero->SetLineWidth(3); dzero->SetMarkerColor(1); dzero->SetMarkerStyle(20); // Observed->SetLineStyle(2); dzero->GetYaxis()->SetTitle("Cross Section [pb]"); dzero->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); dzero->SetTitle("with "); dzero->SetFillColor(45); dzero->GetXaxis()->SetLabelOffset(0.0001); TGraph *cms= new TGraph(4,mycmsx,mycmsy); cms->SetLineColor(2); cms->SetLineWidth(3); cms->SetMarkerColor(1); cms->SetMarkerStyle(20); // Observed->SetLineStyle(2); cms->GetYaxis()->SetTitle("Cross Section [pb]"); cms->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); cms->SetTitle("with "); cms->SetFillColor(45); TGraph *cmsc= new TGraph(4,mycmscx,mycmscy); cmsc->SetLineColor(2); cmsc->SetLineWidth(3); cmsc->SetMarkerColor(1); cmsc->SetMarkerStyle(20); // Observed->SetLineStyle(2); cmsc->GetYaxis()->SetTitle("Cross Section [pb]"); cmsc->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); cmsc->SetTitle("with "); cmsc->SetFillColor(45); TGraph *cmsz= new TGraph(4,cmsx,cmsy); cmsz->SetLineColor(1); cmsz->SetLineWidth(3); cmsz->SetMarkerColor(1); cmsz->SetMarkerStyle(20); // Observed->SetLineStyle(2); cmsz->GetYaxis()->SetTitle("Cross Section [pb]"); cmsz->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); cmsz->SetTitle("with "); cmsz->SetFillColor(45); TGraph *hera= new TGraph(4,herax,heray); hera->SetLineColor(6); hera->SetLineWidth(3); hera->SetMarkerColor(1); hera->SetMarkerStyle(20); // hera->SetLineStyle(2); // hera->SetLineStyle(2); hera->GetYaxis()->SetTitle("Cross Section [pb]"); hera->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); hera->SetTitle("with "); hera->SetFillColor(45); TGraph *h1= new TGraph(4,h1x,h1y); h1->SetLineColor(28); h1->SetLineWidth(3); h1->SetMarkerColor(1); // h1->SetMarkerStyle(20); // hera->SetLineStyle(2); h1->GetYaxis()->SetTitle("Cross Section [pb]"); h1->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); // h1->SetLineStyle(2); h1->SetTitle("with "); h1->SetFillColor(45); TGraph *lep= new TGraph(4,lepx,lepy); lep->SetLineColor(4); lep->SetLineWidth(3); lep->SetMarkerColor(1); lep->SetMarkerStyle(20); // lep->SetLineStyle(2); lep->GetYaxis()->SetTitle("Cross Section [pb]"); lep->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); lep->SetTitle("with "); lep->SetFillColor(39); TGraph *atlas= new TGraph(4,atlasx,atlasy); atlas->SetLineColor(46); atlas->SetLineWidth(3); atlas->SetMarkerColor(1); atlas->SetMarkerStyle(20); // lep->SetLineStyle(2); atlas->GetYaxis()->SetTitle("Cross Section [pb]"); atlas->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); atlas->SetTitle("with "); atlas->SetFillColor(39); TGraphAsymmErrors *grafphotoncms=new TGraphAsymmErrors(4); grafphotoncms->SetPoint(0,cmsphux[0],cmsphuy[0]); grafphotoncms->SetPointError(0,0,0,0,0); grafphotoncms->SetPoint(1,cmsphux[1],cmsphuy[1]); grafphotoncms->SetPointError(1,0,0,0,0); grafphotoncms->SetPoint(2,cmsphux[2],cmsphuy[2]); grafphotoncms->SetPointError(2,0,0,0,1); grafphotoncms->SetPoint(3,cmsphux[3],cmsphuy[3]); grafphotoncms->SetPointError(3,0,0,0,1); //grafhera->SetFillColor(kYellow+3); grafphotoncms->SetFillColor(kOrange-3); //grafphotoncms->SetFillColor(kTeal-9); grafphotoncms->SetFillStyle(3004); grafphotoncms->GetXaxis()->SetRangeUser(0.00005, 1); grafphotoncms->GetYaxis()->SetRangeUser(0.00001, 1); grafphotoncms->GetYaxis()->SetTitle("BR(t #rightarrow qZ)"); grafphotoncms->GetXaxis()->SetTitle("BR(t #rightarrow q#gamma)"); grafphotoncms->GetXaxis()->SetLabelSize(0.03); grafphotoncms->GetYaxis()->SetLabelSize(0.03); grafphotoncms->GetXaxis()->SetTitleFont(62); grafphotoncms->GetYaxis()->SetTitleFont(62); grafphotoncms->GetXaxis()->SetTitleSize(0.050); grafphotoncms->GetYaxis()->SetTitleSize(0.050); grafphotoncms->GetXaxis()->SetTitleOffset(0.8); grafphotoncms->GetYaxis()->SetTitleOffset(0.8); TGraphAsymmErrors *grafphotoncms2=new TGraphAsymmErrors(4); grafphotoncms2->SetPoint(0,cmsx[0],cmsy[0]); grafphotoncms2->SetPointError(0,0,0,0,1-cmsy[0]); grafphotoncms2->SetPoint(1,cmsphux[2],cmsy[1]); grafphotoncms2->SetPointError(1,0,0,0,1-cmsy[1]); grafphotoncms2->SetPoint(2,cmsphux[2],cmsphuy[2]); grafphotoncms2->SetPointError(2,0,0,0,1); grafphotoncms2->SetPoint(3,cmsphux[3],cmsphuy[3]); grafphotoncms2->SetPointError(3,0,0,0,1); //grafhera->SetFillColor(kYellow+3); //grafhera->SetFillColor(kRed-8); grafphotoncms2->SetFillColor(kYellow-9); // grafphotoncms2->SetFillStyle(3005); grafphotoncms2->GetXaxis()->SetRangeUser(0.00005, 1); grafphotoncms2->GetYaxis()->SetRangeUser(0.00001, 1); grafphotoncms2->GetYaxis()->SetTitle("BR(t #rightarrow qZ)"); grafphotoncms2->GetXaxis()->SetTitle("BR(t #rightarrow q#gamma)"); grafphotoncms2->GetXaxis()->SetLabelSize(0.03); grafphotoncms2->GetYaxis()->SetLabelSize(0.03); grafphotoncms2->GetXaxis()->SetTitleFont(62); grafphotoncms2->GetYaxis()->SetTitleFont(62); grafphotoncms2->GetXaxis()->SetTitleSize(0.065); grafphotoncms2->GetYaxis()->SetTitleSize(0.045); grafphotoncms2->GetXaxis()->SetLabelOffset(0.0001); grafphotoncms2->GetXaxis()->SetTitleOffset(0.60); TGraphAsymmErrors *grafcms=new TGraphAsymmErrors(4); grafcms->SetPoint(0,cmsx[0],cmsy[0]); grafcms->SetPointError(0,0,0,0,1-cmsy[0]); grafcms->SetPoint(1,cmsx[1],cmsy[1]); grafcms->SetPointError(1,0,0,0,1-cmsy[1]); grafcms->SetPoint(2,cmsx[2],cmsy[2]); grafcms->SetPointError(2,0,0,0,1-cmsy[2]); grafcms->SetPoint(3,cmsx[3],cmsy[3]); grafcms->SetPointError(3,0,0,0,1-cmsy[3]); grafcms->SetFillColor(kGray+1); // grafcms->SetFillColor(kCyan-10); // grafcms->SetFillColor(kCyan-8); // grafcms->SetFillColor(kMagenta-10); grafcms->SetFillStyle(3005); grafcms->SetLineColor(1); grafcms->GetXaxis()->SetRangeUser(0.00005, 1); grafcms->GetYaxis()->SetRangeUser(0.00001, 1); grafcms->GetYaxis()->SetTitle("BR(t #rightarrow #gamma u)"); grafcms->GetXaxis()->SetTitle("#kappa_{tu#gamma}"); grafcms->GetXaxis()->SetLabelSize(0.03); grafcms->GetYaxis()->SetLabelSize(0.03); grafcms->GetXaxis()->SetTitleFont(62); grafcms->GetYaxis()->SetTitleFont(62); grafcms->GetXaxis()->SetTitleSize(0.065); grafcms->GetYaxis()->SetTitleSize(0.045); grafcms->GetXaxis()->SetLabelOffset(0.0001); grafcms->GetXaxis()->SetTitleOffset(0.60); grafphotoncms->Draw("AL3"); grafphotoncms2->Draw("L3SAME"); grafcms->Draw("L3SAME"); // grafphotoncms2->Draw("L3SAME"); grafphotoncms->Draw("L3SAME"); // grafphotoncms->Draw("L3SAME"); cdf->Draw("same"); dzero->Draw("same"); cms->Draw("same"); cmsc->Draw("same"); cmsz->Draw("same"); hera->Draw("same"); h1->Draw("same"); lep->Draw("same"); atlas->Draw("same"); TPaveText *pt = new TPaveText(0.1,0.95,0.4,0.95, "NDC"); // NDC sets coords pt->SetLineColor(10); // relative to pad dimensions pt->SetFillColor(10); // text is black on white pt->SetTextSize(0.045); pt->SetTextAlign(12); pt->AddText("CMS Preliminary, 19.1 fb^{-1}, #sqrt{s} = 8 TeV"); pt->SetShadowColor(10); // pt->Draw("same"); cdf->GetHistogram()->Draw("AXISSAMEY+"); cdf->GetHistogram()->Draw("AXISSAMEX+"); cdf->GetHistogram()->Draw("AXISSAME"); TLatex latex; latex.SetTextSize(0.035); latex.SetTextAlign(13); //align at top latex.DrawLatex(0.000014,cdfy[0]+cdfy[0]/1.5,"#color[12]{CDF}"); latex.DrawLatex(0.000014,dzeroy[0]-dzeroy[0]/10,"#color[3]{D0}"); latex.DrawLatex(0.000014,lepy[0]+lepy[0]/1.5,"#color[4]{DELPHI}"); // latex.DrawLatex(0.000014,heray[0]+heray[0]/1.5,"#color[6]{ZEUS}"); latex.DrawLatex(0.000014,atlasy[0]+atlasy[0]/1.5,"#color[46]{ATLAS}"); latex.DrawLatex(0.000014,cmsy[0]+cmsy[0]/1.5,"#color[1]{CMS}"); latex.DrawLatex(mycmsx[0]+mycmsx[0]/8,0.000035,"#splitline{#color[2]{}}{#color[2]{(q=u)}}"); latex.DrawLatex(mycmscx[0]-mycmscx[0]/1.85,0.000035,"#splitline{#color[2]{}}{#color[2]{(q=c)}}"); latex.DrawLatex(mycmsx[0]+mycmsx[0]/2,0.0001,"#splitline{#color[2]{ CMS}}{#color[2]{Preliminary}}"); latex.DrawLatex(0.000014,heray[0]+heray[0]/1.5,"#color[6]{ZEUS (q=u)}"); latex.DrawLatex(h1x[0]+h1x[0]/8,0.00005,"#splitline{#color[28]{H1}}{#color[28]{(q=u)}}"); // latex.DrawLatex(0.03,cmsy[0]+cmsy[0]/1.5,"#color[46]{ #scale[10.2]{#rightarrow}CMS}"); latex.DrawLatex(0.03,0.55,"#splitline{#color[1]{ 95% C.L} }{#color[1]{EXCLUDED REGION}}"); TArrow ar1(0.1,0.1,1,0.1); ar1.Draw("same"); // TText *th1 = new TText(0.005,cdfy[0]+0.005,"#color[2]{Left adjusted}" ); // th1->SetTextAlign(5); // th1->SetTextSize(0.05); // th1->Draw(); // grafexp1sigma->Draw("L3same"); // cdf->Draw("AL"); // Observed->Draw("L"); // TGaxis *axis1 = new TGaxis(-8,-0.5,8,-0.5,0.0001,0.5,510,"-"); // axis1->SetName("axis1"); // axis1->Draw("same"); // c1->Update(); /* TLegend *leg1 = new TLegend(0.2, 0.6, 0.35, 0.8); leg1->SetTextSize(0.03); leg1->SetBorderSize(0); leg1->SetLineColor(0); leg1->SetLineWidth(0); leg1->SetFillColor(kWhite); leg1->AddEntry(cdf, "Predicted", "L"); // leg1->AddEntry(Observed, "95% CL Observed Limit", "L"); // leg1->AddEntry(Expected, "95% CL Expected Limit", "L"); // leg1->AddEntry(grafexp1sigma, "#pm1#sigma Exp.Limit", "F"); // leg1->AddEntry(grafexp2sigma, "#pm2#sigma Exp.Limit", "F"); leg1->Draw(); TLine *line1 = new TLine(5, 1, 40, 1); line1->SetLineColor(2); line1->SetLineWidth(2); // line1->Draw("same"); TPaveText *pt = new TPaveText(0.15,0.80,0.4,0.87, "NDC"); // NDC sets coords pt->SetLineColor(10); // relative to pad dimensions pt->SetFillColor(10); // text is black on white pt->SetTextSize(0.03); pt->SetTextAlign(12); pt->AddText("CMS Preliminary #sqrt{s} = 8 TeV, #int L dt= 19.145 fb^{-1}"); pt->SetShadowColor(10); pt->Draw("same"); */ }