Example #1
0
ds::Vector ds::Curve::Calculate( ds::Vector Begin, ds::Vector W, ds::Vector End, int Value, int Precision )
{
	float Prec = 1.0f / Precision * Value;

	return ds::Vector( 
		GetDiff( GetDiff( Begin.X , W.X , Prec ), GetDiff( W.X , End.X , Prec ), Prec ),
		GetDiff( GetDiff( Begin.Y , W.Y , Prec ), GetDiff( W.Y , End.Y , Prec ), Prec ) 
	);
}
Example #2
0
void CGppe::Make_Predictions_New_User(const VectorXd & theta_x, const VectorXd& theta_t, double& sigma, const MatrixXd& train_t, const MatrixXd &x, const TypePair & train_pairs,
                                     const VectorXd & idx_global, const VectorXd& idx_global_1, const VectorXd& idx_global_2,
                                     const VectorXd& ind_t, const VectorXd& ind_x, const MatrixXd & test_t, const MatrixXd& idx_pairs, const VectorXd& ftrue, const VectorXd& ytrue)
{
    int N = x.rows();
    int Mtrain = train_t.rows();
    int Npairs = idx_pairs.rows();
    VectorXd fstar;
    MatrixXd pair;
    VectorXd P = VectorXd::Zero(Npairs);
    VectorXd ypred = VectorXd::Zero(Npairs);
    VectorXd sum = VectorXd::Zero(N);
    VectorXd count = VectorXd::Zero(N);

    Approx_CGppe_Laplace( theta_x, theta_t, sigma,
                         train_t, x, train_pairs, idx_global, idx_global_1, idx_global_2, ind_t, ind_x, Mtrain, N);

    for (int i = 0;i < Npairs;i++)
    {
        pair = idx_pairs.row(i);


        Predict_CGppe_Laplace(sigma, train_t, x, idx_global, ind_t, ind_x,
                             test_t, pair);
        P(i) = p;
        sum(pair(0)) += mustar(0);
        count(pair(0)) += 1;
        sum(pair(1)) += mustar(1);
        count(pair(1)) += 1;

    }

    for (int i = 0;i < P.rows();i++)
    {
        if (P(i) > 0.5000001)
            ypred(i) = 1;
        else
        	ypred(i)=0;
    }

    fstar = sum.array() / count.array();
	dsp(fstar,"fstar");
    cout << endl << endl << "error =  " << (GetDiff(ytrue, ypred)).sum() / ytrue.rows()<<endl;
    // need for a plot function here ?
}
Example #3
0
/**
 * Attempt to get patches.
 */
bool GetPatches(const launcher::Settings &settings) {
  Trace("Getting patch list");
  if (!GetOneFile(settings, "files.pb", 0)) {
    Log(LL::Error) << "Unable to get file listing." << std::endl;
    return false;
  }

  launcher::FileList newFileList;
  if (!appshared::parseProtoFromFile(GetOutputPath("files.pb"), newFileList)) {
    Log(LL::Error) << "Unable to parse file listing from server" << std::endl;
    return false;
  }

  launcher::FileList oldFileList;
  if (!appshared::parseProtoFromFile(GetPatchedPath("files.pb"), oldFileList)) {
    oldFileList = launcher::FileList();
  }

  Trace("Getting patch");
  std::map< std::string, launcher::FileEntry > filesToPatch = GetDiff(oldFileList, newFileList);
  if (settings.get_use_torrent()) {
    // TODO(kulseran): implement torrent mode
  } else {
    if (!DownloadPatch(settings, filesToPatch)) {
      return false;
    }
  }

  Trace("Applying patch");
  if (!CopyPatch(settings, filesToPatch)) {
    return false;
  }
  if (!vfs::util::Copy(GetOutputPath("files.pb"), GetPatchedPath("files.pb"))) {
    return false;
  }

  Trace("Done");
  return true;
}
Example #4
0
void ds::Curve::Create( ds::Vector Begin, ds::Vector W, ds::Vector End, int Precision )
{
	this->Begin = Begin;
	this->W = W;
	this->End = End;

	Points = PointsArray( Precision + 1 );

	float Prec = 1.0f / Precision;
	int Iterator = 0;

	for( float i = 0.0f; i < 1.0f; i += Prec )
//	for( int i = 0; i < Precision; i++ )
	{
		float x = GetDiff( GetDiff( Begin.X , W.X , i ), GetDiff( W.X , End.X , i ), i );
		float y = GetDiff( GetDiff( Begin.Y , W.Y , i ), GetDiff( W.Y , End.Y , i ), i );

		Points[Iterator++] = ds::Vector(x,y);//Calculate( Begin, W, End, i, Precision );
	}
}
Example #5
0
void Plot_McollRatio(TString file, TString fakefile, TString sample, TString SR, bool subtractFakes)
{

	SetAtlasStyle();
	#ifdef __CINT__
	  gROOT->LoadMacro("AtlasUtils.C");
	#endif

  	double xmin = 50;
  	double xmax = 400;


  	TFile* f = new TFile(file);
  	TFile* fakef = new TFile(fakefile);

  	TH1D* hME;
  	TH1D* hEM;

  	//if (isScaled){
//  		hME =(TH1D*)f->Get("ME_scaled");//nom/ME_McollHiggs_Unblind");
//  		hEM =(TH1D*)f->Get("EM");//nom/EM_McollHiggs_Unblind");
//  		hME_orig = (TH1D*)f->Get("ME_original");
//  		hEM_orig = (TH1D*)f->Get("EM_original");
  	//}
  	//else{
  		hME =(TH1D*)f->Get("nom/ME_McollHiggs_Unblind");
  		hEM =(TH1D*)f->Get("nom/EM_McollHiggs_Unblind");
  	//}

  	if (subtractFakes){
  		TH1D* hME_fake = (TH1D*)fakef->Get("nom/ME_McollHiggs_Unblind");
  		TH1D* hEM_fake = (TH1D*)fakef->Get("nom/EM_McollHiggs_Unblind");

  		hME->Add(hME_fake,-1);
  		hEM->Add(hEM_fake,-1);
 	}
  	hEM->SetMarkerStyle(8); hEM->SetMarkerSize(0.7);
  	hEM->SetLineColor(kPink + 8);hEM->SetOption("e1");
  	hEM->SetMarkerColor(kPink + 8);
  	hME->SetMarkerStyle(8); hME->SetMarkerSize(0.7);
  	hME->SetLineColor(kTeal - 6);hME->SetOption("e1");
  	hME->SetMarkerColor(kTeal - 6);
  	hME->GetXaxis()->SetLabelOffset(0); hME->GetXaxis()->SetLabelSize(0);
  	hEM->GetXaxis()->SetLabelOffset(0); hEM->GetXaxis()->SetLabelSize(0);
  	hEM->GetXaxis()->SetRangeUser(xmin,xmax);   hME->GetXaxis()->SetRangeUser(xmin,xmax);
  	hEM->GetYaxis()->SetTitleOffset(1.0);
  	hME->GetYaxis()->SetTitleOffset(1.0);

//  	hEM_orig->SetMarkerStyle(8); hEM_orig->SetMarkerSize(0.7);
//  	hEM_orig->SetLineColor(kPink + 8);hEM_orig->SetOption("e1");
//  	hEM_orig->SetMarkerColor(kPink + 8);
//  	hME_orig->SetMarkerStyle(8); hME_orig->SetMarkerSize(0.7);
//  	hME_orig->SetLineColor(kTeal - 6);hME_orig->SetOption("e1");
//  	hME_orig->SetMarkerColor(kTeal - 6);
//  	hME_orig->GetXaxis()->SetLabelOffset(0); hME_orig->GetXaxis()->SetLabelSize(0);
//  	hEM_orig->GetXaxis()->SetLabelOffset(0); hEM_orig->GetXaxis()->SetLabelSize(0);
//  	hEM_orig->GetXaxis()->SetRangeUser(xmin,xmax);   hME_orig->GetXaxis()->SetRangeUser(xmin,xmax);
//  	hEM_orig->GetYaxis()->SetTitleOffset(1.0);
//  	hME_orig->GetYaxis()->SetTitleOffset(1.0);

  	double numEM = hEM->Integral();
  	double numME = hME->Integral();

  	cout<<"# entries EM = " << numEM << endl;
  	cout<<"# entries ME = " << numME << endl;

//  	TH1D* ratio2 = GetRatio(hEM_orig,hME_orig,xmin,xmax);
//  	TH1D* diff2 = GetDiff(hEM_orig,hME_orig,xmin,xmax);

  	TH1D* ratio = GetRatio(hEM,hME,xmin,xmax);
  	TH1D* diff = GetDiff(hEM,hME,xmin,xmax);

  	TLegend* leg = new TLegend(0.6,0.45,0.75,0.55);
  	leg->SetFillColor(kWhite); leg->SetBorderSize(1); leg->SetLineColor(0); leg->SetTextFont(42);
  	leg->SetTextSize(.05);

  	TLine* line1 = new TLine(xmin,1,xmax,1); line1->SetLineColor(kRed); line1->SetLineStyle(2);
  	TLine* line14 = new TLine(xmin,1.5,xmax,1.5); line14->SetLineStyle(9);
  	line14->SetLineColor(kBlack);
  	TLine* line13 = new TLine(xmin,2./3,xmax,2./3); line13->SetLineStyle(2);
  	line13->SetLineColor(kRed);
  	TLine* line12 = new TLine(xmin,2,xmax,2); line12->SetLineStyle(9);
  	line12->SetLineColor(kBlack);
  	TLine* line15 = new TLine(xmin,0.5,xmax,0.5); line15->SetLineStyle(9);
  	line15->SetLineColor(kBlack);
  	TLine* line2 = new TLine(xmin,0,xmax,0); line2->SetLineColor(kBlack); line2->SetLineStyle(9);

  	TLine* vline1 = new TLine(100,0,100,3000); vline1->SetLineStyle(2);
  	TLine* vline2 = new TLine(150,0,150,3000); vline2->SetLineStyle(2);

  	TCanvas* c0 = new TCanvas("mcoll ","mcoll ",600,600); c0=c0;
  	TPad *pad1 =  new TPad("pad1", "12<L1<15",0.0,0.2,1,1.0,21); pad1->SetMargin(0.1,0.1,0.02,0.2);
  	TPad *pad2 =  new TPad("pad2", "ratio",   0.0,0,1,0.2,21); pad2->SetMargin(0.1,0.1,0.3,0.02);
//  	TPad *pad3 =  new TPad("pad3", "diff",    0.0,0,1,0.2,21); pad3->SetMargin(0.1,0.1,0.3,0.02);

  	pad1->SetFillColor(0);pad2->SetFillColor(0);//pad3->SetFillColor(0);
  	pad1->Draw(); pad2->Draw();//pad3->Draw();


  	pad1->cd();

	#ifdef __CINT__
  		gROOT->LoadMacro("AtlasLabels.C");
	#endif

  	leg->AddEntry(hME,"#mue","le");
  	leg->AddEntry(hEM,"e#mu","le");


  	hEM->Draw("e1"); hME->Draw("e1 sames");
  	vline1->Draw(); vline2->Draw();


  	pad2->cd();
  	ratio->Draw();
  	line14->Draw();line15->Draw();line1->Draw();

//  	pad3->cd();
//  	diff->Draw();
//  	line2->Draw();

  	pad1->cd();
  	myText(0.5,0.65,1,"#int L dt = 20.3 fb^{-1}  #sqrt{s} = 8 TeV");
  	myText(0.6,0.35,1,sample);
  	myText(0.6,0.25,1,SR);

  	ATLASLabel(0.62,0.75,"Internal");

  	leg->Draw();


  	c0->Update();

//  	TCanvas* c1 = new TCanvas("mcoll original","mcoll original",600,600); c0=c0;
//  	TPad *pad1_2 =  new TPad("pad1", "12<L1<15",0.0,0.4,1,1.0,21); pad1_2->SetMargin(0.1,0.1,0.02,0.2);
//  	TPad *pad2_2 =  new TPad("pad2", "ratio",   0.0,0.2,1,0.4,21); pad2_2->SetMargin(0.1,0.1,0.02,0.02);
//  	TPad *pad3_2 =  new TPad("pad3", "diff",    0.0,0,1,0.2,21); pad3_2->SetMargin(0.1,0.1,0.3,0.02);
//
//  	pad1_2->SetFillColor(0);pad2_2->SetFillColor(0);pad3_2->SetFillColor(0);
//  	pad1_2->Draw(); pad2_2->Draw();pad3_2->Draw();
//
//
//  	pad1_2->cd();

//  	hEM_orig->Draw("e1"); hME_orig->Draw("e1 sames");
//  	vline1->Draw(); vline2->Draw();


//  	pad2_2->cd();
//  	ratio2->Draw();
//  	line14->Draw();line15->Draw();line1->Draw();

//  	pad3_2->cd();
//  	diff2->Draw();
//  	line2->Draw();

//  	pad1_2->cd();
//  	myText(0.5,0.65,1,"#int L dt = 20.3 fb^{-1}  #sqrt{s} = 8 TeV");
//  	myText(0.6,0.35,1,sample);
//
//  	ATLASLabel(0.62,0.75,"Internal");
//
//  	leg->Draw();
//
//
//  	c1->Update();



  return;
}