void nnTest2(int trainMe, double w1, double w2){
  gROOT->Reset();
  gStyle->SetPalette(1);
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(0);
  char *s = new char[1];


  //myTrueLine->SetLineColor(1);

  auto c1 = new TCanvas("c1","c1");

  //GET RANDOM
  UInt_t mySeed = 3; 
  TRandom3 *myRandGen = new TRandom3(mySeed);
  Double_t myRandVal;
  
  int nToPlot = 100;
  int nToPlot1 = 0;
  int nToPlot2 = 0;

  double vecX[100];
  double vecY[100];
  double vecEX[100];
  double vecEY[100];

  double vecX1[100];
  double vecY1[100];
  double vecEX1[100];
  double vecEY1[100];

  double vecX2[100];
  double vecY2[100];
  double vecEX2[100];
  double vecEY2[100];

  int vecT[100];

  for (int myInt = 0; myInt < nToPlot; myInt++){
    double myXVal = myRandGen->Uniform(0.0,1.0);
    double myYVal = myRandGen->Uniform(0.0,1.0);
    int tVal = 0;
    vecX[myInt] = myXVal;       
    vecY[myInt] = myYVal;       
    vecEX[myInt] = 0.0; 
    vecEY[myInt] = 0.0; 

    if (myYVal > -myXVal + 1.0) {
      vecX1[nToPlot1] = myXVal; 
      vecY1[nToPlot1] = myYVal; 
      vecEX1[nToPlot1] = 0.0;   
      vecEY1[nToPlot1] = 0.0;   
      tVal = 1;
      nToPlot1++;
    } else {
      vecX2[nToPlot2] = myXVal; 
      vecY2[nToPlot2] = myYVal; 
      vecEX2[nToPlot2] = 0.0;   
      vecEY2[nToPlot2] = 0.0;   
      nToPlot2++;
    }
    vecT[myInt] = tVal; 
  }
  if (trainMe == 1) {
    w1 = 1.0;
    w2 = 0.3;
  }
  double theta = 0.7;
  double alpha = .1;
  bool runMe = true;

  TGraphErrors *myGraph = new TGraphErrors(nToPlot,vecX,vecY,vecEX,vecEY);
  TGraphErrors *myGraph1 = new TGraphErrors(nToPlot1,vecX1,vecY1,vecEX1,vecEY1);
  TGraphErrors *myGraph2 = new TGraphErrors(nToPlot2,vecX2,vecY2,vecEX2,vecEY2);

  myGraph->Draw();

  myGraph->SetMarkerStyle(27);
  myGraph->SetMarkerColor(3);
  myGraph1->SetMarkerStyle(20);
  myGraph1->SetMarkerColor(2);
  myGraph2->SetMarkerStyle(21);
  myGraph2->SetMarkerColor(4);

  TLine *myTrueLine = new TLine(0,1,1,0);
  myTrueLine->SetLineWidth(2);
  myTrueLine->SetLineColor(1);

  double x1 = 0.0;
  double x2 = 1.0;
  double y1 = theta/w2 - x1*w1/w2;
  double y2 = theta/w2 - x2*w1/w2;
  TLine *myTrainedLine = new TLine(x1,y1,x2,y2);
  

  //training our line
  while(runMe == true){
    int mismatchedCounter = 0;
    for(int i = 0; i < nToPlot1; ++i)
      {
	if(vecY1[i] < theta/w2 - vecX1[i]*w1/w2)
	      w1 = w1 + alpha*vecX1[i];
	      w2 = w2 + alpha*vecY1[i];
	    //cout<<"mismatched: vec = "<<vecX1[i]<<" , "<<vecY1[i]<<" while yLine = "<<theta/w2 - vecX1[i]*w1/w2<<endl;
	      mismatchedCounter++;
	  }
	else
	  {
	    //cout<<"everything is cool: vec = "<<vecX1[i]<<" , "<<vecY1[i]<<" while yLine = "<<theta/w2 - vecX1[i]*w1/w2<<endl;
	  }
      }

    for(int i = 0; i < nToPlot2; ++i)
      {
	if(vecY2[i] > theta/w2 - vecX2[i]*w1/w2)
	  {
	    w1 = w1 - alpha*vecX2[i];
	    w2 = w2 - alpha*vecY2[i];
	    //cout<<"mismatched: vec = "<<vecX2[i]<<" , "<<vecY2[i]<<" while yLine = "<<theta/w2 - vecX2[i]*w1/w2<<endl;
	    mismatchedCounter++;
	  }
	else
	  {
	    //cout<<"everything is cool: vec = "<<vecX2[i]<<" , "<<vecY2[i]<<" while yLine = "<<theta/w2 - vecX2[i]*w1/w2<<endl;
	  }
      }

    y1 = theta/w2 - x1*w1/w2;
    y2 = theta/w2 - x2*w1/w2;
    if(mismatchedCounter == 0){runMe = false;}
    cout<<"theta,w1,w2 = "<<theta<<" , "<<w1<<" , "<<w2<<endl;

  }

  TLine *betterLine = new TLine(x1,y1,x2,y2);
  betterLine->SetLineWidth(2);
  betterLine->SetLineColor(4);
  //if you just want the fixed line and not the initial:
 //cout<<"y1,y2 = "<<y1<<", "<<y2<<endl;
  //TLine *myTrainedLine = new TLine(x1,y1,x2,y2);
  myTrainedLine->SetLineWidth(2);
  myTrainedLine->SetLineColor(3);

  c1->Clear();
  c1->Divide(2,2);
  c1->cd(1); 
  myGraph->Draw("ap");
  c1->cd(2); 
  myGraph1->Draw("ap");
  c1->cd(3); 
  myGraph2->Draw("ap");
  c1->cd(4); 
  myGraph->Draw("ap");
  myGraph1->Draw("psame");  
  myGraph2->Draw("psame"); 
  myTrueLine->Draw();
  myTrainedLine->Draw();
  betterLine->Draw();


}


void nnTrained(){
  gROOT->Reset();
  gStyle->SetPalette(1);
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(0);
  char *s = new char[1];

  auto c2 = new TCanvas("c2","c2");

  //GET RANDOM
  UInt_t mySeed = 3; 
  TRandom3 *myRandGen = new TRandom3(mySeed);
  Double_t myRandVal;
  
  double theta = 0.7;
  double w1 = 0.707281;
  double w2 = 0.687651;

  int nToPlot = 100;
  int nToPlot1 = 0;
  int nToPlot2 = 0;

  double vecX[100];
  double vecY[100];
  double vecEX[100];
  double vecEY[100];

  double vecX1[100];
  double vecY1[100];
  double vecEX1[100];
  double vecEY1[100];

  double vecX2[100];
  double vecY2[100];
  double vecEX2[100];
  double vecEY2[100];


  for (int myInt = 0; myInt < nToPlot; myInt++){
    double myXVal = myRandGen->Uniform(0.0,1.0);
    double myYVal = myRandGen->Uniform(0.0,1.0);
    int tVal = 0;
    vecX[myInt] = myXVal;
    vecY[myInt] = myYVal;
    vecEX[myInt] = 0.0;
    vecEY[myInt] = 0.0;

    if (myYVal > -myXVal + 1.0) {
      vecX1[nToPlot1] = myXVal;
      vecY1[nToPlot1] = myYVal;
      vecEX1[nToPlot1] = 0.0;
      vecEY1[nToPlot1] = 0.0;
      tVal = 1;
      nToPlot1++;
    } else {
      vecX2[nToPlot2] = myXVal;
      vecY2[nToPlot2] = myYVal;
      vecEX2[nToPlot2] = 0.0;
      vecEY2[nToPlot2] = 0.0;
      nToPlot2++;
    }
  }
  
  TLine *myTrueLine = new TLine(0,1,1,0);
  myTrueLine->SetLineWidth(2);
  myTrueLine->SetLineColor(1);

  TGraphErrors *myGraph = new TGraphErrors(nToPlot,vecX,vecY,vecEX,vecEY);
  TGraphErrors *myGraph1 = new TGraphErrors(nToPlot1,vecX1,vecY1,vecEX1,vecEY1);
  TGraphErrors *myGraph2 = new TGraphErrors(nToPlot2,vecX2,vecY2,vecEX2,vecEY2);

  myGraph->Draw();

  myGraph->SetMarkerStyle(27);
  myGraph->SetMarkerColor(3);
  myGraph1->SetMarkerStyle(20);
  myGraph1->SetMarkerColor(2);
  myGraph2->SetMarkerStyle(21);
  myGraph2->SetMarkerColor(4);

  
  c2->Clear();
  c2->Divide(2,2);
  c2->cd(1); 
  myGraph->Draw("ap");
  c2->cd(2); 
  myGraph1->Draw("ap");
  c2->cd(3); 
  myGraph2->Draw("ap");
  c2->cd(4); 
  myGraph->Draw("ap");
  myGraph1->Draw("psame");  
  myGraph2->Draw("psame"); 
  myTrueLine->Draw();


  

}
