コード例 #1
0
void DRateQuasiFree()
{
  cout<<"============= Quasi Free =================== "<<endl;
  

  Double_t TMax=0.450;
  Double_t TMin=0.180;
  
  Double_t TStep=0.001;
  Int_t NNT = (TMax-TMin)/TStep;
  cout<<NNT<<endl; 
  Double_t TT[1000];
  
  Double_t SigmaQuasiT[1000];

  Double_t SigmaGluonDissVacT[1000];

  Double_t SigmaQuasiFreeGluonT[1000];
 
  Double_t aMuT[1000];
  
  Double_t EDJPsi[1000];
  Double_t EDUpsilon[1000];
 
  Double_t Temp=0;
  cout<<" T:  "<<"  Mu  "<<"  EDiss J "<<"  EDiss Y "<<endl;

  //NNT =1;
  for(int i=0;i<NNT;i++)
    {
      Temp=TMin+(TStep*i);
      TT[i]=Temp;
      
      aMuT[i]= MuT(Temp);
      EDJPsi[i]=EDiss(1,Temp);
      EDUpsilon[i]=EDiss(2,Temp);

      SigmaQuasiT[i]=SigmaQuasiQuark(0.0,Temp);
      
      SigmaGluonDissVacT[i]= SigmaQuasiGluon(1,0.0, Temp);
      SigmaQuasiFreeGluonT[i]= SigmaQuasiGluon(2,0.0, Temp);

      

      cout<<TT[i]<<"  "<<aMuT[i]<<"  "<<EDJPsi[i]<<"  "<<EDUpsilon[i]<<endl;


    } 
  TGraph *GrfSigmaQ = new TGraph(NNT,TT,SigmaQuasiT);
  GrfSigmaQ->SetLineWidth(2);
  GrfSigmaQ->SetLineColor(2);
 
  GrfSigmaQ->GetXaxis()->SetTitle("T(MeV/c)");
  GrfSigmaQ->GetYaxis()->SetTitle("#Gamma (MeV)");

  new TCanvas;
  gPad->SetTicks(1);
  GrfSigmaQ->Draw("APL");

  
  TGraph *GrfSigmaGluonT = new TGraph(NNT,TT,SigmaGluonDissVacT);
  GrfSigmaGluonT->SetLineWidth(2);
  GrfSigmaGluonT->SetLineColor(2);
 
  GrfSigmaGluonT->GetXaxis()->SetTitle("T(MeV/c)");
  GrfSigmaGluonT->GetYaxis()->SetTitle("#Gamma_{J/#psig} (MeV)");

  GrfSigmaGluonT->GetXaxis()->SetRangeUser(0.15,0.45);
  GrfSigmaGluonT->GetYaxis()->SetRangeUser(1.0,1000.0);


  TGraph *GrfSigmaQuasiFreeGluonT = new TGraph(NNT,TT,SigmaQuasiFreeGluonT);
  GrfSigmaQuasiFreeGluonT->SetLineWidth(2);
  GrfSigmaQuasiFreeGluonT->SetLineColor(4);

  new TCanvas;
  gPad->SetTicks(1);
  gPad->SetLogy(1);

  GrfSigmaGluonT->Draw("APL");
  GrfSigmaQuasiFreeGluonT->Draw("PLsame");

  return;









  TGraph *GrfMuT = new TGraph(NNT,TT,aMuT);
  GrfMuT->SetLineWidth(2);
  GrfMuT->SetLineColor(4);

  GrfMuT->GetXaxis()->SetTitle("T(MeV/c)");
  GrfMuT->GetYaxis()->SetTitle("#mu_{D}(GeV)");

  new TCanvas;
  gPad->SetTicks(1);
  GrfMuT->Draw("APL");


  TGraph *GrfEDUpsilon = new TGraph(NNT,TT,EDUpsilon);
  GrfEDUpsilon->SetLineWidth(2);
  GrfEDUpsilon->SetLineColor(2);

  GrfEDUpsilon->GetXaxis()->SetTitle("T(MeV/c)");
  GrfEDUpsilon->GetYaxis()->SetTitle("E_{dis}(GeV)");
  GrfEDUpsilon->GetYaxis()->SetRangeUser(0.0,1.2);

  TGraph *GrfEDJPsi = new TGraph(NNT,TT,EDJPsi);
  GrfEDJPsi->SetLineWidth(2);
  GrfEDJPsi->SetLineColor(4);

  GrfEDJPsi->GetXaxis()->SetTitle("T(MeV/c)");
  GrfEDJPsi->GetYaxis()->SetTitle("E_{dis}(GeV)");

  new TCanvas;
  gPad->SetTicks(1);
  GrfEDUpsilon->Draw("APL");
  GrfEDJPsi->Draw("PLsame");



  cout<<" ========================= pT dependance ============================== "<<endl;

  Double_t PMax=10.0;
  Double_t PMin=0.1;
  Double_t PStep=0.1;
  Int_t NNP= (PMax-PMin)/PStep;
  cout<<NNP<<endl; 
  Double_t PP[1000];
  
  Double_t SigmaQuasiQuarkP1[1000];
  Double_t SigmaQuasiQuarkP2[1000];
  Double_t SigmaQuasiQuarkP3[1000];
  
  Double_t SigmaQuasiGluonP1[1000];
  Double_t SigmaQuasiGluonP2[1000];
  Double_t SigmaQuasiGluonP3[1000];
  

  Double_t P=0;

  //NNP=1;

  for(int i=0;i<NNP;i++)
    {
      P=PMin+(PStep*i);
      PP[i]=P;
      SigmaQuasiQuarkP1[i]=SigmaQuasiQuark(P,0.180);
      SigmaQuasiQuarkP2[i]=SigmaQuasiQuark(P,0.250);
      SigmaQuasiQuarkP3[i]=SigmaQuasiQuark(P,0.375);

      
      SigmaQuasiGluonP1[i]=SigmaQuasiGluon(2,P,0.180);
      SigmaQuasiGluonP2[i]=SigmaQuasiGluon(2,P,0.250);
      SigmaQuasiGluonP3[i]=SigmaQuasiGluon(2,P,0.375);

      cout<<PP[i]<<"  "<<SigmaQuasiQuarkP1[i]<<"   "<<SigmaQuasiGluonP1[i]<<endl;
   


    } 

  TGraph *GrfSigmaQP1 = new TGraph(NNP,PP,SigmaQuasiQuarkP1);
  GrfSigmaQP1->SetLineWidth(2);
  GrfSigmaQP1->SetLineColor(1);
 
  GrfSigmaQP1->GetXaxis()->SetTitle("p_{J/#psi}(GeV)");
  GrfSigmaQP1->GetYaxis()->SetTitle("#Gamma_{J/#psi q} (MeV)");

  GrfSigmaQP1->GetYaxis()->SetRangeUser(0.0,400.0);

  TGraph *GrfSigmaQP2 = new TGraph(NNP,PP,SigmaQuasiQuarkP2);
  GrfSigmaQP2->SetLineWidth(2);
  GrfSigmaQP2->SetLineColor(2);


  TGraph *GrfSigmaQP3 = new TGraph(NNP,PP,SigmaQuasiQuarkP3);
  GrfSigmaQP3->SetLineWidth(2);
  GrfSigmaQP3->SetLineColor(3);


  new TCanvas;
  gPad->SetTicks(1);
  GrfSigmaQP1->Draw("AL");
  GrfSigmaQP2->Draw("Lsame");
  GrfSigmaQP3->Draw("Lsame");



  TGraph *GrfSigmaGP1 = new TGraph(NNP,PP,SigmaQuasiGluonP1);
  GrfSigmaGP1->SetLineWidth(2);
  GrfSigmaGP1->SetLineColor(1);
 
  GrfSigmaGP1->GetXaxis()->SetTitle("p_{J/#psi}(GeV)");
  GrfSigmaGP1->GetYaxis()->SetTitle("#Gamma_{J/#psi g} (MeV)");

  GrfSigmaGP1->GetYaxis()->SetRangeUser(0.0,400.0);


  TGraph *GrfSigmaGP2 = new TGraph(NNP,PP,SigmaQuasiGluonP2);
  GrfSigmaGP2->SetLineWidth(2);
  GrfSigmaGP2->SetLineColor(2);

  TGraph *GrfSigmaGP3 = new TGraph(NNP,PP,SigmaQuasiGluonP3);
  GrfSigmaGP3->SetLineWidth(2);
  GrfSigmaGP3->SetLineColor(3);



  new TCanvas;
  gPad->SetTicks(1);
  GrfSigmaGP1->Draw("AL");
  GrfSigmaGP2->Draw("Lsame");
  GrfSigmaGP3->Draw("Lsame");




}
コード例 #2
0
ファイル: compareBestFit.C プロジェクト: aashaqshah/cmssw-1
void compareBestFit(const char* filename="test.root", const char* channelstr="boost,vbf,vhtt,cmb+", const char* type="sm", double mass=125, double minimum=-1., double maximum=4.5, const char* label="Preliminary, #sqrt{s}=7-8 TeV, L = 24.3 fb^{-1}, H #rightarrow #tau #tau")
{
  SetStyle();

  std::map<std::string, unsigned int> colors;
  colors["0jet"       ] = kBlue;
  colors["2jet"       ] = kMagenta;
  colors["vbf"        ] = kRed;
  colors["boost"      ] = kGreen;
  colors["btag"       ] = kRed;
  colors["nobtag"     ] = kBlue;
  colors["em"         ] = kBlue;
  colors["et"         ] = kRed;
  colors["mt"         ] = kGreen;
  colors["mm"         ] = kMagenta;
  colors["tt"         ] = kOrange;
  colors["vhtt"       ] = kMagenta+2;
  colors["cmb"        ] = kBlack;
  colors["cmb+"       ] = kGray+2;
  colors["htt"        ] = kBlack;
  colors["ggH"        ] = kRed;
  colors["bbH"        ] = kBlue;
  colors["mvis"       ] = kBlue+2;
  colors["test-0"     ] = kRed+2;
  colors["test-1"     ] = kGreen+2;
  colors["test-2"     ] = kGreen;
  colors["test-3"     ] = kRed+2;
  colors["test-4"     ] = kBlue;
  colors["test-5"     ] = kViolet-6;
  colors["HIG-11-020" ] = kBlue+2;
  colors["HIG-11-029" ] = kRed+2;
  colors["HIG-12-018" ] = kBlue;
  colors["HIG-12-032" ] = kRed+2;
  colors["HIG-12-043" ] = kBlack;
  colors["HIG-12-050" ] = kBlack;

  std::cout << " *******************************************************************************************************\n"
	    << " * Usage     : root -l                                                                                  \n"
	    << " *             .x macros/compareBestFit.C+(file, chn, type)                                             \n"
	    << " *                                                                                                      \n"
	    << " * Arguments :  + file     const char*      full path to the input file                                 \n"
	    << " *              + chn      const char*      list of channels; choose between: 'cmb', 'htt', 'em',       \n"
	    << " *                                          'et', 'mt', 'mm', 'vhtt', 'hgg', 'hww', 'ggH',              \n"
	    << " *                                          'bbH', 'nomix[-200, +200]', 'mhmax[-400, -200, +200]'       \n"
	    << " *                                          'mhmax[+400, +600, +800]', 'test-0...5', 'saeff', 'gluph'   \n"
	    << " *                                          The list should be comma separated and may contain          \n"
	    << " *                                          whitespaces                                                 \n"
	    << " *              + type      const char*     type of plot; choose between 'sm' and 'mssm'                \n"
	    << " *                                                                                                      \n"
	    << " *              + mass      double          Higgs mass for which the plot should be performed           \n"
	    << " *                                                                                                      \n"
	    << " *              + minimum   double          Minimum value for the x-Axis (best fit value)               \n"
	    << " *                                                                                                      \n"
	    << " *              + maximum   double          Maximum value for the x-Axis (best fit value)               \n"
	    << " *                                                                                                      \n"
	    << " *******************************************************************************************************\n";

  /// open input file  
  TFile* inputFile = new TFile(filename); if(inputFile->IsZombie()){ std::cout << "ERROR:: file: " << filename << " does not exist.\n"; }

  /// prepare input parameters
  std::vector<std::string> channels;
  string2Vector(cleanupWhitespaces(channelstr), channels);

  /// prepare histograms
  std::vector<TGraph*> hexp;
  std::vector<TGraph*> hband;
  for(unsigned i=0; i<channels.size(); ++i){
    hexp.push_back(get<TGraph>(inputFile, std::string(channels[i]).append("/expected").c_str()));
    hband.push_back(get<TGraph>(inputFile, std::string(channels[i]).append("/innerBand").c_str()));
  }
  int massid = 0; 
  for(int i0  = 0; i0 < hexp[hexp.size()-1]->GetN(); i0++) {   
    double lX = 0; double lY = 0; 
    hexp[hexp.size()-1]->GetPoint(i0, lX, lY);
    if(lX==mass) {massid = i0; break;}
  }
    
  /// do the drawing
  TCanvas* canv1 = new TCanvas("canv1", "Best Fit Comparison", 600, 600);
  canv1->cd();
  canv1->SetGridx(0);
  canv1->SetGridy(0);

  TLine* SM   = new TLine(1, 0, 1, hexp.size());
  TLine* ZERO = new TLine(0, 0, 0, hexp.size());
  
  double *lBestFitX = new double[4];
  double *lBestFitY = new double[4]; 
  lBestFitX[0] = hexp[hexp.size()-1]->Eval(mass) - hband[hband.size()-1]->GetErrorYlow(massid);
  lBestFitX[1] = hexp[hexp.size()-1]->Eval(mass) + hband[hband.size()-1]->GetErrorYhigh(massid);
  lBestFitX[3] = hexp[hexp.size()-1]->Eval(mass) - hband[hband.size()-1]->GetErrorYlow(massid);
  lBestFitX[2] = hexp[hexp.size()-1]->Eval(mass) + hband[hband.size()-1]->GetErrorYhigh(massid);
  lBestFitY[0] = hexp.size();
  lBestFitY[1] = hexp.size();
  lBestFitY[2] = 0;
  lBestFitY[3] = 0;
  TGraph* BAND = new TGraph(4,lBestFitX,lBestFitY); BAND->SetFillColor(kYellow);
  TLine * BEST = new TLine (hexp[hexp.size()-1]->Eval(mass),0,hexp[hexp.size()-1]->Eval(mass),hexp.size()); BEST->SetLineStyle(kDashed); BEST->SetLineColor(kRed);
  bool firstPlot=true;
  for(unsigned int i=0; i<hexp.size(); ++i){
    double value[1] = {hexp[i]->Eval(mass)};
    double position[1] = {hexp.size()-i-0.5}; 

    double x;
    double y;
    double el=0;
    double eh=0;
    int k = hexp[i]->GetN();
    for(int l=0; l<k; l++){
      hexp[i]->GetPoint(l, x, y);
      if(x==mass){
	el=hband[i]->GetErrorYlow(l);
	eh=hband[i]->GetErrorYhigh(l);
	break;
      }
    }

    double elow[1] = {el};
    double ehigh[1] = {eh};
    double help1[1] = {0.0};
    double help2[1] = {0.0};
    TGraphAsymmErrors *gr = new TGraphAsymmErrors(1, value, position, elow, ehigh, help1, help2);
    if(firstPlot){
      if(std::string(type) == std::string("mssm")){
	gr->SetMaximum(hexp.size());
	gr->SetMinimum(0);
      }
      else{
	gr->SetMaximum(hexp.size());
	gr->SetMinimum(0);
      }
      // gr->GetYaxis()->Set(hexp.size(), 0, hexp.size());
      // gr = new TGraphAsymmErrors(1, value, position, elow, ehigh, help1, help2);
      // std::cout << gr->GetYaxis()->GetNbins() << std::endl;
      // format x-axis
      std::string x_title;
      if(std::string(type).find("mssm")!=std::string::npos){
	x_title = std::string("best fit for #sigma(#phi#rightarrow#tau#tau)");
      }
      else{
	x_title = std::string("best fit for #sigma/#sigma_{SM}");
      }
      
      gr->GetXaxis()->SetTitle(x_title.c_str());
      gr->GetXaxis()->SetLabelFont(62);
      gr->GetXaxis()->SetTitleFont(62);
      gr->GetXaxis()->SetTitleColor(1);
      gr->GetXaxis()->SetTitleOffset(1.05);
      gr->GetXaxis()->SetLimits(minimum, maximum);

      BAND->GetXaxis()->SetTitle(x_title.c_str());
      BAND->GetXaxis()->SetLabelFont(62);
      BAND->GetXaxis()->SetTitleFont(62);
      BAND->GetXaxis()->SetTitleColor(1);
      BAND->GetXaxis()->SetTitleOffset(1.05);
      BAND->GetXaxis()->SetLimits(minimum, maximum);

      // format y-axis
      //BAND->GetYaxis()->Set(hexp.size(), 0, hexp.size());
      gr  ->GetYaxis()->Set(hexp.size(), 0, hexp.size());
      //std::cout<<gr->GetYaxis()->GetBinCenter(hexp.size()-i)<<std::endl;
      //BAND->GetYaxis()->SetBinLabel(hexp.size()-1, legendEntry(channels[hexp.size()-1]).c_str());
      for(unsigned int j=0; j<hexp.size(); ++j){
	gr  ->GetYaxis()->SetBinLabel(hexp.size()-j, legendEntry(channels[j]).c_str());
      }
      gr->GetYaxis()->SetTickLength(0);
      gr->GetYaxis()->SetLabelFont(62);
      gr->GetYaxis()->SetTitleFont(62);
      gr->GetYaxis()->SetLabelSize(0.07);
      gr->GetYaxis()->SetTitle("");
      gr->GetYaxis()->SetLabelFont(62);
      gr->GetYaxis()->SetTitleOffset(1.05);
      gr->GetYaxis()->SetLabelSize(0.03);           
      gr->GetYaxis()->SetLabelOffset(-0.32);           

      BAND->GetYaxis()->SetLabelFont(62);
      BAND->GetYaxis()->SetTitleFont(62);
      BAND->GetYaxis()->SetLabelSize(0.07);
      BAND->GetYaxis()->SetTitle("");
      BAND->GetYaxis()->SetLabelFont(62);
      BAND->GetYaxis()->SetTitleOffset(1.05);
      BAND->GetYaxis()->SetLabelSize(0.03);           
      BAND->GetYaxis()->SetLabelOffset(-0.32);           
    }
    BAND->GetYaxis()->SetLabelSize(0.07);
    BAND->SetTitle("");
    gr  ->GetYaxis()->SetLabelSize(0.07);
    gr->SetTitle("");
    gr->SetLineStyle( 1.);
    gr->SetLineWidth( 2.); 
    //gr->SetLineColor(colorzxs.find(channels[i])->second);
    gr->SetLineColor(kBlack);
    gr->SetMarkerStyle(kFullCircle);
    gr->SetMarkerSize(MARKER_SIZE);
    //gr->SetMarkerColor(colors.find(channels[i])->second);
    gr->SetMarkerColor(kBlack);
    cout << "===> " << gr->GetErrorYhigh(0) << endl;
    
    //cout << "==> "<< BAND->GetYaxis()->GetMaximum() << endl;
    if(firstPlot) gr->Draw("AP");  
    if(firstPlot) {
      BAND->Draw("Fsame");  
      BEST->Draw("l");
      TLine *lLine = new TLine(minimum,1.0,maximum,1.0); lLine->SetLineWidth(3); lLine->SetLineColor(kBlue+2);
      lLine->Draw();
      SM->SetLineWidth(3);
      SM->SetLineColor(kGreen+3);
      if(std::string(type).find("mssm")==std::string::npos) SM->Draw("same");
    }
    gr->Draw(firstPlot ? "Psame" : "Psame");
    //gr->Draw(firstPlot ? "AL" : "Lsame");
    firstPlot=false;
  }
  ZERO->SetLineWidth(3);
  ZERO->SetLineColor(kBlue);
  ZERO->SetLineStyle(11);
  //ZERO->Draw("same");
  

  //TPaveText *pt = new TPaveText(2*(maximum+minimum)/3,hexp.size()-0.3,maximum,hexp.size()-0.02);
  TPaveText *pt = new TPaveText(0.76, 0.88, 1.0, 1.0, "NDC");
  if(std::string(type).find("mssm")!=std::string::npos) pt->AddText(TString::Format("m_{A} = %0.0f GeV" , mass));
  else pt->AddText(TString::Format("m_{H} = %0.0f GeV" , mass));
  pt->SetBorderSize(   0 );
  pt->SetFillStyle(    0 );
  pt->SetTextAlign(   12 );
  pt->SetTextSize ( 0.03 );
  pt->SetTextColor(    1 );
  pt->SetTextFont (   62 );
  pt->Draw("same");
  canv1->RedrawAxis();
  CMSPrelim(label, "", 0.15, 0.835);
  
  canv1->Print(std::string("BestFit").append(std::string(type).find("mssm")!=std::string::npos ? "_mssm.png" : "_sm.png").c_str());
  canv1->Print(std::string("BestFit").append(std::string(type).find("mssm")!=std::string::npos ? "_mssm.pdf" : "_sm.pdf").c_str());
  canv1->Print(std::string("BestFit").append(std::string(type).find("mssm")!=std::string::npos ? "_mssm.pdf" : "_sm.eps").c_str());
  return;
}
int SPICE_step3_offset_gain_final_calfile() {
  
  // Declaring arrays for the TGraphs
  vector <double> Bi207 = {481.6935,553.8372,565.8473,975.651,1047.795,1059.805};
  vector<float> experimental_Bi207;
   vector <float> c; 
  vector<float> d;
//double energy_152eu[7] = {121.782, 244.697, 344.279, 443.965, 778.904, 964.079, 1408.006}; //energies of the gamma-rays associated with Eu-152, retrieved from the Idaho National Laboratory Catalogue
//double charge_152eu[448];
vector <double> channel_centroids;

// Declaring fit parameter variables
double a, b;

ifstream fin("energycalonly_centroids.txt");
ofstream outfile("offset_gain_energycalonly.txt");
/* file contains calculated charges from the centroids and energy coefficients. After every six lines is a new core number. Also note that all of the DIV/0 errors were replaced with zeros in this file */
cout << fin <<endl;

int fSize = Bi207.size();
double inValue;
while (true) {
  channel_centroids.clear();
  for (int i=0; i<fSize; i++) {
      fin >> inValue;
      channel_centroids.push_back(inValue);      
  }
  
  if (fin.eof()) break;
  // Here will be plotting
    
  
  TGraph *gr = new TGraph(fSize, &channel_centroids[0], &Bi207[0]);
  gr->SetMarkerStyle(8); // makes points bigger
  gr->Draw("ap");
  
  TF1 *f1 = new TF1("f1", "pol1", 1000, 3000 );
  gr->Fit(f1, "RQ");
  
  a = f1->GetParameter(0);
  b = f1->GetParameter(1);
  c.push_back(a);
  d.push_back(b);
  //Writing parameters to text file
  outfile  << a << " " << b << endl;
   
}
//string datafile="spice_check.root";
string calfile="SPICE_blank_calfile.txt";
//string path="singles/SPICE_energy_";



//Check if cal exists
ifstream calin(calfile.c_str());
if(!calin.is_open())return 0;

//Check if data file exists
ofstream calout("SPICE_energycalonly.cal");
unsigned int fSegment=0;
string line;
//for (int i=0; i<fSegment; i++) {
while(getline(calin,line)){
  
	if(line.find("EngCoeff")<=1 && line.size()>1 && fSegment<120){
		stringstream parsestream;
		parsestream<<line;
		string first;
		parsestream>>first;
		string buf;
		buf.assign(first,7,2);
			
		calout<<"	EngCoeff: "<< " "<< c[fSegment]<< " "<< d[fSegment] <<endl;//fOffset[fSegment]<<" "<<fGain[fSegment]<<endl;
			
	}else{
		if(line.find("SPI00XN")<=1&&line.size()>1){
コード例 #4
0
void Riemann(){
  
  double xg = 0, yg = 0, zg = 0, p2g = 0;

  double N = 0;

  TMatrix M(1,3);
  TMatrix Mg(1,3);
  TMatrix A(3,3);

  double u0 = 800, v0 = 500;
  double rho0 = 1000;

  for (int j = 1; j< 100; j++){

    double xP = cos(j*1.0)*rho0+u0;
    double yP = sin(j*1.0)*rho0+v0;

    double R2 = xP*xP+yP*yP;

    double R = sqrt(R2);
    double p = (1+R2);

    double x = xP/p;
    double y = yP/p;

//    double x = xP/p;
//    double y = yP/p;
    double z = R2/p;

    cout << "x = " << x << " y = " << y << " z = " << z << endl;
      
    //   p = sqrt(p);
    p = 1;

    Mg[0][0] += p*p*x;
    Mg[0][1] += p*p*y;
    Mg[0][2] += p*p*z;
    p2g += p*p;
    N ++;

  }

  Mg *= 1./p2g;
  /*

  for(int i = 0; i < 3; i++){
      cout << " " << Mg[0][i];
    cout << " is Mg "<<endl;
  }


  for(int i = 0; i < 3; i++){
      cout << " " << M[0][i];
    cout << " is M "<<endl;
  }

  */

  TGraph* g = new TGraph(100);

  for (int j = 1; j< 100; j++){
   
    double xP = cos(j*1.0)*rho0+u0;
    double yP = sin(j*1.0)*rho0+v0;

    g->SetPoint(j-1, xP, yP);

    cout << "xP = " << xP << " yP = " << yP << endl;

    double R2 = xP*xP+yP*yP;

    double R = sqrt(R2);
    double p = (1+R2);
 
 
    double x = xP/p;
    double y = yP/p;

    //   double x = xP/p;
    //  double y = yP/p;
    double z = R2/p;

    cout << "x = " << x << " y = " << y << " z = " << z << " mG = " << Mg[0][2] << endl;
    
    TMatrix K(1,3);

    K[0][0] = (x-Mg[0][0]);
    K[0][1] = (y-Mg[0][1]);
    K[0][2] = (z-Mg[0][2]);
    
    
    TMatrix ntR = K;
    TMatrix tR = K.Transpose(K);

    TMatrix F = tR*ntR;
  

    for(int m = 0; m < 3; m++){
      for(int l = 0; l < 3; l++)
	cout << " " << F[m][l];
      cout << " is F"<<endl;
    }
    //    p = sqrt(p);
    p = 1;
    A += p*p*F;
    
  }

  TH1D* PLOTTER = new TH1D("", "", 1, -3, 3);
  PLOTTER->SetMaximum(3);
  PLOTTER->SetMinimum(-3);
  PLOTTER->Draw();
  //  g->SetMarkerSize(1);
  g->SetMarkerStyle(20);
  g->Draw();

  

  /*

  for (int i = 1; i< hFIT->GetXaxis()->GetNbins()+1; i++){
    double xbin = hFIT->GetXaxis()->GetBinCenter(i);

    for (int j = 1; j< hFIT->GetYaxis()->GetNbins()+1; j++){
      double ybin = hFIT->GetYaxis()->GetBinCenter(j);
      double R2 = ybin*ybin + xbin*xbin;
      double R = sqrt(R2);
      double p = (1+R2);

      if (R < 2.5 || R > 3.3 ) continue;

      double cosPhi = xbin/R;
      double sinPhi = ybin/R;
      double x = R*R*cosPhi*cosPhi/p;
      double y = R*R*sinPhi*sinPhi/p;
      double z = R2/p;

      M[0][0] += p*x*hFIT->GetBinContent(i, j);
      M[0][1] += p*y*hFIT->GetBinContent(i, j);
      M[0][2] += p*z*hFIT->GetBinContent(i, j);
      
      Mg[0][0] += p*p*x*hFIT->GetBinContent(i, j);
      Mg[0][1] += p*p*y*hFIT->GetBinContent(i, j);
      Mg[0][2] += p*p*z*hFIT->GetBinContent(i, j);
      p2g += p*p*hFIT->GetBinContent(i, j);
      N += hFIT->GetBinContent(i, j);

    }

  }

  Mg *= 1./p2g;

  for (int i = 1; i< hFIT->GetXaxis()->GetNbins()+1; i++){
    double xbin = hFIT->GetXaxis()->GetBinCenter(i);

    for (int j = 1; j< hFIT->GetYaxis()->GetNbins()+1; j++){
         double ybin = hFIT->GetYaxis()->GetBinCenter(j);
      double R2 = ybin*ybin + xbin*xbin;
      double R = sqrt(R2);
      double p = (1+R2);

      if (R < 2.5 || R > 3.3 ) continue;

      M -= p*Mg;
      
    }

  }
  */

  
  cout << "N = " << N << endl;
  
  for(int i = 0; i < 3; i++){
      cout << " " << M[0][i];
    cout << ""<<endl;
  }

  
  A *= (1.0/N);

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++)
      cout << " " << A[i][j];
    cout << ""<<endl;
  }

  TVectorF eigVal;

  TMatrix Egenv = A.EigenVectors(eigVal);

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++)
      cout << " " << Egenv[i][j];
    cout << " is Eigenv"<<endl;
  }




  for(int i = 0; i < 3; i++){
      cout << " " << eigVal[i];
  }

  cout << "" << endl;

  TMatrix n(3,1);
  n[0][0] = Egenv[0][2];
  n[1][0] = Egenv[1][2]; 
  n[2][0] = Egenv[2][2];

  TMatrix zero = A*n - eigVal[2]*n;

  
  for(int i = 0; i < 3; i++){
      cout << " " << n[i][0];
    cout << " is n "<<endl;
  }

  for(int i = 0; i < 3; i++){
      cout << " " << zero[i][0];
    cout << " is An - lbda*n "<<endl;
  }

  cout << "Norm = " << n[0][0]*n[0][0] + n[1][0]*n[1][0] + n[2][0]*n[2][0] << endl;

  for(int i = 0; i < 3; i++){
      cout << " " << Mg[0][i];
  }
  cout << " is Mg" << endl; 

  double xg = Mg[0][0], yg = Mg[0][1], zg = Mg[0][2];
  double n0 = n[0][0], n1 = n[1][0], n2 = n[2][0];

  double c = -1*( xg*n0 + yg*n1 + zg*n2);

  cout << "c = " << c << endl;



  double x0 = -1.0/2 * n0/(c+n2);
  double y0 = -1* n[1][0]/(2*(c+n[2][0]));
  double R02 = ( n[0][0]*n[0][0] + n[1][0]*n[1][0] - 4*c*(c+n[2][0]) )/(4*(c+n[2][0]) * (c+n[2][0]));
  cout << "x0 = " << x0 << " y0 = " << y0 << " r0 = " << sqrt(R02) << endl;
  /*
 for (int j = 1; j< 100; j++){
   
    double xP = cos(j*1.0)*rho0+u0;
    double yP = sin(j*1.0)*rho0+v0;

    g->SetPoint(j-1, xP, yP);

    cout << "xP = " << xP << " yP = " << yP << endl;

    cout << "rho0 = " << sqrt((xP-u0)*(xP-u0) + (yP-v0)*(yP-v0)) << endl;

    double R2 = xP*xP+yP*yP;

    double R = sqrt(R2);
    double p = (1+R2);
 
 
    double x = xP/p;
    double y = yP/p;

    //   double x = xP/p;
    //  double y = yP/p;
    double z = R2/p;

    cout << "x = " << x << " y = " << y << " z = " << z << " mG = " << Mg[0][2] << endl;
  
    cout << " 0 = " << n0*x + n1*y + n2*z + c << endl;
  
    
  }
*/

}
コード例 #5
0
ファイル: PlotHARPAnalysis.C プロジェクト: gpestana/thesis
void PlotHARPHisto( std::string beam, std::string target, std::string energy,
                    std::string secondary,
		    std::string region,
		    int ibin )
{
   
   // ReadHARPData( beam, target, energy, secondary, region );
   
   double ymin = 10000.; // something big... don't know if I can use FLT_MAX
   double ymax = -1. ;
   
   for ( int i=0; i<NPoints[ibin]; i++ )
   {
      if ( (Y[ibin][i]+EY[ibin][i]) > ymax ) ymax = Y[ibin][i]+EY[ibin][i];
      if ( (Y[ibin][i]-EY[ibin][i]) < ymin && (Y[ibin][i]-EY[ibin][i]) > 0. ) ymin = (Y[ibin][i]-EY[ibin][i]);
   }
   
   TH1F* hi[NModels];
   std::string YTitle;

   for ( int m=0; m<NModels; m++ )
   {

      std::string histofile = "";
      
      // histofile = "./harp-histo/";
      histofile = "./harp-histo-no-res-decays/";
      // histofile = "../t23-bld/harp-histo/";
      
      // std::string histofile = "./harp-histo/" + beam + target + energy + "GeV" + ModelName[m] + ".root"; 
      histofile += ( beam + target + energy + "GeV" + ModelName[m] + ".root" ); 
      
      // std::cout << " histofile = " << histofile << std::endl;
      
      TFile* f = new TFile( histofile.c_str() );
      
      char buf[5];
      sprintf( buf, "%i", ibin );      
      std::string histoname = secondary + "_" + region + "_";
      histoname.append( buf );
      
      hi[m] = (TH1F*)f->Get( histoname.c_str() );
      
      hi[m]->SetStats(0);
      hi[m]->SetLineColor(ColorModel[m]);
      hi[m]->SetLineWidth(2);
      
      int nx = hi[m]->GetNbinsX();
      for (int k=1; k <= nx; k++) 
      {
	double yy = hi[m]->GetBinContent(k);
	if ( yy > ymax ) ymax = yy;
	if ( yy < ymin && yy > 0. ) ymin = yy;
      }
      if ( m == 0 ) 
      {
         hi[m]->Draw();
	 hi[m]->GetXaxis()->SetTitle("momentum (GeV/c)");
	 //hi[m]->GetYaxis()->SetTitle( YTitle.c_str() );
	 // hi[m]->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dpd#Theta} [mb/(GeV/c/rad)]");
	 hi[m]->GetYaxis()->SetTitle("d^{2}#sigma / dpd#Theta [mb/(GeV/c/rad)]");
	 hi[m]->GetYaxis()->SetTitleOffset(1.5);
      }
      else hi[m]->Draw("same"); 
            
   }
   
   TLegend* leg = new TLegend(0.6, 0.70, 0.9, 0.9);
   
   for ( int m=0; m<NModels; m++ )
   {
      hi[m]->GetYaxis()->SetRangeUser(ymin,ymax*1.1); // hi[m]->SetTitle("");
      leg->AddEntry( hi[m], ModelName[m].c_str(), "L" );
   }
      
   float* X = new float[NPoints[ibin]];
   for ( int i=0; i<NPoints[ibin]; i++ )
   {
      X[i] = 0.5 * (XMin[ibin][i]+XMax[ibin][i]);
      //std::cout << "X[" << i << "] = " << X[i] << std::endl;
      //std::cout << "Y[" << i << "] = " << Y[0][i] << std::endl;
   }
   
   TGraph* gr = new TGraphErrors( NPoints[ibin], X, Y[ibin], 0, EY[ibin] );
   gr->SetMarkerColor(kBlue);
   gr->SetMarkerStyle(22);
   gr->SetMarkerSize(1.5);
    
   gr->Draw("p");
      
   leg->AddEntry( gr, "exp.data", "p");

   leg->Draw();
   leg->SetFillColor(kWhite);   


   return;

}
コード例 #6
0
ファイル: drawGraphEnv.C プロジェクト: ferriff/usercode
//Draw an error envelop from a TGraphAsymmErrors
void drawGraphEnv(TGraphAsymmErrors* g, float scale = 1, bool doAxis = false,
                  int linestyle = 1, int linewidth = 2, int linecolor = 4,
                  bool fill = false,
                  TH1** ppGl = 0, TH1** ppGh = 0){
  //                  const char* opth = "", const char* optl = ""){
  char buffer[256];
  int n = g->GetN();
  double* x = new double[n+2];
  double* yh = new double[n+2];
  double* yl = new double[n+2];

  for(int i = 0; i < n; ++i){
    x[i+1]  = g->GetX()[i];
    yh[i+1] = g->GetY()[i] + g->GetEYhigh()[i] * scale;
    yl[i+1] = g->GetY()[i] - g->GetEYlow()[i] * scale;
  }

  x[0] = g->GetX()[0] - g->GetEXlow()[0];
  yl[0] = yl[1] - (yl[2]-yl[1])/(x[2]-x[1])*g->GetEXlow()[0];
  yh[0] = yh[1] - (yh[2]-yh[1])/(x[2]-x[1])*g->GetEXlow()[0];

  x[n+1] = g->GetX()[n-1] + g->GetEXhigh()[n-1];
  yl[n+1] = yl[n] + (yl[n]-yl[n-1])/(x[n]-x[n-1])*g->GetEXhigh()[n-1];
  yh[n+1] = yh[n] + (yh[n]-yh[n-1])/(x[n]-x[n-1])*g->GetEXhigh()[n-1];

  TGraph* gl = new TGraph(n+2, x, yl);
  gl->SetTitle(g->GetTitle());
  TGraph* gh = new TGraph(n+2, x, yh);
  gh->SetTitle(g->GetTitle());
  const char* opt = "l,same";
  
  sprintf(buffer, "%s_eh", g->GetName());
  gh->SetName(buffer);
  
  sprintf(buffer, "%s_el", g->GetName());
  gl->SetName(buffer);

  if(doAxis){
    g->Draw("AP");
    TH1* h = g->GetHistogram();
    gPad->Clear();
    h->Draw();
  }

  if(fill){
    gl->SetFillStyle(linestyle);
    gl->SetFillColor(linecolor);
    gl->SetLineColor(linecolor);
  
    gh->SetFillStyle(linestyle);
    gh->SetFillColor(linecolor);
    gh->SetLineColor(linecolor);
  } else{
    gl->SetLineStyle(linestyle);
    gl->SetLineWidth(linewidth);
    gl->SetLineColor(linecolor);
    
    gh->SetLineStyle(linestyle);
    gh->SetLineWidth(linewidth);
    gh->SetLineColor(linecolor);
  }
  
  gh->Draw(opt);
  gl->Draw(opt);

  if(ppGh) *ppGh = gh;
  if(ppGl) *ppGl = gl;
}
コード例 #7
0
ファイル: kirk_dune.C プロジェクト: DUNE/lblpwgtools
void kirk_dune()
{
  //  this binning is a primary determinant of the time this macro takes to run

  //  very coarse binning, just to test macro, will worsen results: ~ 45 min
  //  int binsnumuE = 4;
  //  int binsnumuPID = 4;
  //  int binsnueE = 4;
  //  int binsnuePID = 4;

  // full binning: 2-3 hours
  int binsnumuE = 15;
  int binsnumuPID = 15;
  int binsnueE = 15;
  int binsnuePID = 20;

  int binsnumu2d = binsnumuE*binsnumuPID;
  int binsnue2d = binsnumuE*binsnumuPID;

  rootlogon(); // style

  // POT/yr * 3.5yrs * mass correction
  const double pot = 3.5 * 1.47e21 * 40/1.13;

  SpectrumLoader loaderNumu("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/numutest.root");
  SpectrumLoader loaderNue("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/nuetest.root");

  SpectrumLoader loaderNumuRHC("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/anumutest.root");
  SpectrumLoader loaderNueRHC("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/anuetest.root");

  osc::IOscCalculatorAdjustable* calc = DefaultOscCalc();
  calc->SetL(1300);
  calc->SetdCP(TMath::Pi()*1.5);

  // Standard DUNE numbers from Matt Bass
  calc->SetTh12(0.5857);
  calc->SetTh13(0.148);
  calc->SetTh23(0.7854);
  calc->SetDmsq21(0.000075);
  calc->SetDmsq32(0.002524-0.000075); // quoted value is 31

  osc::IOscCalculatorAdjustable* calci = DefaultOscCalc();
  calci->SetL(1300);
  calci->SetdCP(TMath::Pi()*1.5);

  // Standard DUNE numbers from Matt Bass
  calci->SetTh12(0.5857);
  calci->SetTh13(0.148);
  calci->SetTh23(0.7854);
  calci->SetDmsq21(0.000075);
  calci->SetDmsq32(-(0.002524+0.000075)); // quoted value is 31

  // One sigma errors
  // (t12,t13,t23,dm21,dm32)=(0.023,0.018,0.058,0.0,0.024,0.016)

  auto* loaderNumuBeam  = loaderNumu.LoaderForRunPOT(20000001);
  auto* loaderNumuNue   = loaderNumu.LoaderForRunPOT(20000002);
  auto* loaderNumuNuTau = loaderNumu.LoaderForRunPOT(20000003);
  auto* loaderNumuNC    = loaderNumu.LoaderForRunPOT(0);

  auto* loaderNueBeam  = loaderNue.LoaderForRunPOT(20000001);
  auto* loaderNueNue   = loaderNue.LoaderForRunPOT(20000002);
  auto* loaderNueNuTau = loaderNue.LoaderForRunPOT(20000003);
  auto* loaderNueNC    = loaderNue.LoaderForRunPOT(0);

  auto* loaderNumuBeamRHC  = loaderNumuRHC.LoaderForRunPOT(20000004);
  auto* loaderNumuNueRHC   = loaderNumuRHC.LoaderForRunPOT(20000005);
  auto* loaderNumuNuTauRHC = loaderNumuRHC.LoaderForRunPOT(20000006);
  auto* loaderNumuNCRHC    = loaderNumuRHC.LoaderForRunPOT(0);

  auto* loaderNueBeamRHC  = loaderNueRHC.LoaderForRunPOT(20000004);
  auto* loaderNueNueRHC   = loaderNueRHC.LoaderForRunPOT(20000005);
  auto* loaderNueNuTauRHC = loaderNueRHC.LoaderForRunPOT(20000006);
  auto* loaderNueNCRHC    = loaderNueRHC.LoaderForRunPOT(0);

  Loaders loadersdunenue;
  loadersdunenue.AddLoader(loaderNueBeam,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenue.AddLoader(loaderNueNue,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenue.AddLoader(loaderNueNuTau, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenue.AddLoader(loaderNueNC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  Loaders loadersdunenuerhc;
  loadersdunenuerhc.AddLoader(loaderNueBeamRHC,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenuerhc.AddLoader(loaderNueNueRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenuerhc.AddLoader(loaderNueNuTauRHC, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenuerhc.AddLoader(loaderNueNCRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  Loaders loadersdunenumu;
  loadersdunenumu.AddLoader(loaderNumuBeam,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenumu.AddLoader(loaderNumuNue,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenumu.AddLoader(loaderNumuNuTau, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenumu.AddLoader(loaderNumuNC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  Loaders loadersdunenumurhc;
  loadersdunenumurhc.AddLoader(loaderNumuBeamRHC,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenumurhc.AddLoader(loaderNumuNueRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenumurhc.AddLoader(loaderNumuNuTauRHC, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenumurhc.AddLoader(loaderNumuNCRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  const Var Enu_reco = SIMPLEVAR(dune.Ev_reco);
  const Var pid_reco = SIMPLEVAR(dune.mvaresult);

  float kNumuMVACutFHC = 0.25;
  float kNumuMVACutRHC = 0.5;
  float kNueMVACut = 0.8;

  const Cut kSelNumu = SIMPLEVAR(dune.mvaresult) > kNumuMVACutFHC;
  const Cut kSelNumuRHC = SIMPLEVAR(dune.mvaresult) > kNumuMVACutRHC;
  const Cut kSelNue = SIMPLEVAR(dune.mvaresult) > kNueMVACut;
  const Cut kSelNueRHC = SIMPLEVAR(dune.mvaresult) > kNueMVACut;


  std::vector<const ISyst*> systsE = {&kEnergyScaleSyst, &kEnergyResSyst};
  std::vector<const ISyst*> systsnorm = {&kNCSyst, &kNutauSyst,  &kNueBeamSyst};
  std::vector<const ISyst*> systsall = {&kEnergyScaleSyst, &kEnergyResSyst, &kNCSyst, &kNutauSyst, &kNueBeamSyst};
  std::vector<const ISyst*> systsall2 = {&kEnergyScaleSyst, &kEnergyResSyst, &kNCSyst2, &kNutauSyst, &kNueBeamSyst};


  const Var kEnuPidNumu = Var2D(Enu_reco, Binning::Simple(binsnumuE, 0, 10), pid_reco, Binning::Simple(binsnumuPID, -1, +1));
  const Var kEnuPidNue = Var2D(Enu_reco, Binning::Simple(binsnueE, 0, 6), pid_reco, Binning::Simple(binsnuePID, -1, +1));

  // 2D w/ Loaders
  NoExtrapGenerator gendunenumu(HistAxis("PID/E2d", Binning::Simple(binsnumu2d,0,binsnumu2d), kEnuPidNumu), kNoCut);
  NoExtrapGenerator gendunenue (HistAxis("PID/E2d", Binning::Simple(binsnue2d,0,binsnue2d), kEnuPidNue),  kNoCut);
  PredictionInterp preddunenumu(systsall, calc, gendunenumu, loadersdunenumu);
  PredictionInterp preddunenue (systsall, calc, gendunenue,  loadersdunenue);

  NoExtrapGenerator gendunenumurhc(HistAxis("PID/E2d", Binning::Simple(binsnumu2d,0,binsnumu2d), kEnuPidNumu), kNoCut);
  NoExtrapGenerator gendunenuerhc (HistAxis("PID/E2d", Binning::Simple(binsnue2d,0,binsnue2d), kEnuPidNue),  kNoCut);
  PredictionInterp preddunenumurhc(systsall, calc, gendunenumurhc, loadersdunenumurhc);
  PredictionInterp preddunenuerhc (systsall, calc, gendunenuerhc,  loadersdunenuerhc);


  // 1D w/ Loaders
  NoExtrapGenerator gendunenumu1d(HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNumu);
  NoExtrapGenerator gendunenue1d (HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNue);
  PredictionInterp preddunenumu1d(systsall, calc, gendunenumu1d, loadersdunenumu);
  PredictionInterp preddunenue1d (systsall, calc, gendunenue1d,  loadersdunenue);

  NoExtrapGenerator gendunenumu1drhc(HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNumuRHC);
  NoExtrapGenerator gendunenue1drhc (HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNueRHC);
  PredictionInterp preddunenumu1drhc(systsall, calc, gendunenumu1drhc, loadersdunenumurhc);
  PredictionInterp preddunenue1drhc (systsall, calc, gendunenue1drhc,  loadersdunenuerhc);


  // SpectrumLoader instead of Loaders
  PredictionNoExtrap predNumuPID(*loaderNumuBeam, *loaderNumuNue, *loaderNumuNuTau, *loaderNumuNC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap predNumuPIDRHC(*loaderNumuBeamRHC, *loaderNumuNueRHC, *loaderNumuNuTauRHC, *loaderNumuNCRHC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap predNuePID(*loaderNueBeam, *loaderNueNue, *loaderNueNuTau, *loaderNueNC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap predNuePIDRHC(*loaderNueBeamRHC, *loaderNueNueRHC, *loaderNueNuTauRHC, *loaderNueNCRHC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap pred(*loaderNumuBeam, *loaderNumuNue, *loaderNumuNuTau, *loaderNumuNC, "Reconstructed E (GeV)", Binning::Simple(80, 0, 10), Enu_reco, kSelNumu);

  PredictionNoExtrap pred2d(*loaderNumuBeam, *loaderNumuNue, *loaderNumuNuTau, *loaderNumuNC, "Reconstructed E (GeV)", Binning::Simple(binsnumu2d, 0, binsnumu2d), kEnuPidNumu, kNoCut);

  PredictionNoExtrap predRHC(*loaderNumuBeamRHC, *loaderNumuNueRHC, *loaderNumuNuTauRHC, *loaderNumuNCRHC, "Reconstructed E (GeV)", Binning::Simple(80, 0, 10), Enu_reco, kSelNumuRHC);

  PredictionNoExtrap predNue(*loaderNueBeam, *loaderNueNue, *loaderNueNuTau, *loaderNueNC, "Reconstructed E (GeV)", Binning::Simple(24, 0, 6), Enu_reco, kSelNue);

  PredictionNoExtrap predNue2d(*loaderNueBeam, *loaderNueNue, *loaderNueNuTau, *loaderNueNC, "Reconstructed E (GeV)", Binning::Simple(binsnue2d, 0, binsnue2d), kEnuPidNue, kNoCut);

  PredictionNoExtrap predNueRHC(*loaderNueBeamRHC, *loaderNueNueRHC, *loaderNueNuTauRHC, *loaderNueNCRHC, "Reconstructed E (GeV)", Binning::Simple(24, 0, 6), Enu_reco, kSelNueRHC);


  // test systematics are really shifting
  SystShifts scaleshift, resshift;
  scaleshift.SetShift(&kEnergyScaleSyst, +3);
  resshift.SetShift(&kEnergyResSyst, +3);

  Spectrum nom2(*loaderNumuBeam, HistAxis("blah", Binning::Simple(binsnumuE,0,binsnumuE), Enu_reco), kNoCut);
  Spectrum scale2(*loaderNumuBeam, HistAxis("blah", Binning::Simple(binsnumuE,0,binsnumuE), Enu_reco), kNoCut, scaleshift);
  Spectrum res2(*loaderNumuBeam, HistAxis("blah", Binning::Simple(binsnumuE,0,binsnumuE), Enu_reco), kNoCut, resshift);


  loaderNumu.Go();
  loaderNue.Go();
  loaderNumuRHC.Go();
  loaderNueRHC.Go();

  // have to have this for each prediction from a Loaders or it doesn't work; TODO fix this in source code
  preddunenue.LoadedCallback();
  preddunenumu.LoadedCallback();
  preddunenuerhc.LoadedCallback();
  preddunenumurhc.LoadedCallback();

  preddunenue1d.LoadedCallback();
  preddunenumu1d.LoadedCallback();
  preddunenue1drhc.LoadedCallback();
  preddunenumu1drhc.LoadedCallback();


  SaveToFile(preddunenue, "pred_nue_fhc.root", "pred");
  SaveToFile(preddunenuerhc, "pred_nue_rhc.root", "pred");
  SaveToFile(preddunenumu, "pred_numu_fhc.root", "pred");
  SaveToFile(preddunenumurhc, "pred_numu_rhc.root", "pred");


  Spectrum mock = pred.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt(&pred, mock);

  Spectrum mock2d = pred2d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt2d(&pred2d, mock2d);

  Spectrum mock2dsysts = preddunenumu.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt2dsysts(&preddunenumu, mock2dsysts);

  Spectrum mock2dsystsrhc = preddunenumurhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt2dsystsrhc(&preddunenumurhc, mock2dsystsrhc);

  Spectrum mock2di = pred2d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expt2di(&pred2d, mock2di);

  Spectrum mock2disysts = preddunenumu.Predict(calci).FakeData(pot);
  SingleSampleExperiment expt2disysts(&preddunenumu, mock2disysts);

  Spectrum mock2disystsrhc = preddunenumurhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expt2disystsrhc(&preddunenumurhc, mock2disystsrhc);

  Spectrum mockRHC = predRHC.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptRHC(&predRHC, mockRHC);

  Spectrum mockNue = predNue.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue(&predNue, mockNue);

  Spectrum mockNue2d = predNue2d.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue2d(&predNue2d, mockNue2d);

  Spectrum mockNue2dsysts = preddunenue.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue2dsysts(&preddunenue, mockNue2dsysts);

  Spectrum mockNue2dsystsrhc = preddunenuerhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue2dsystsrhc(&preddunenuerhc, mockNue2dsystsrhc);

  Spectrum mockNue2di = predNue2d.Predict(calci).FakeData(pot);
  SingleSampleExperiment exptNue2di(&predNue2d, mockNue2di);

  Spectrum mockNue2disysts = preddunenue.Predict(calci).FakeData(pot);
  SingleSampleExperiment exptNue2disysts(&preddunenue, mockNue2disysts);

  Spectrum mockNue2disystsrhc = preddunenuerhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment exptNue2disystsrhc(&preddunenuerhc, mockNue2disystsrhc);

  Spectrum mockNueRHC = predNueRHC.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNueRHC(&predNueRHC, mockNueRHC);

  Spectrum mockNuePID = predNuePID.Predict(calc).FakeData(pot);
  Spectrum mockNuePIDRHC = predNuePIDRHC.Predict(calc).FakeData(pot);
  Spectrum mockNumuPID = predNumuPID.Predict(calc).FakeData(pot);
  Spectrum mockNumuPIDRHC = predNumuPIDRHC.Predict(calc).FakeData(pot);


  Surface surf(&expt, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55);
  Surface surf2d(&expt2d, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55);
  Surface surf2dcheck(&expt2dsysts, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55); //should be same as previous line, let's check
  Surface surf2dsysts(&expt2dsysts, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55, {}, systsnorm);
  Surface surf2dsystsall(&expt2dsysts, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55, {}, systsall);
  Surface surfRHC(&exptRHC, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55);

  MultiExperiment numuall({&expt2dsysts, &expt2dsystsrhc});

  Surface surfAll(&numuall, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55, {}, systsall);

  MultiExperiment me({&expt, &exptNue, new SolarConstraints()});
  MultiExperiment me2d({&expt2d, &exptNue2d, new SolarConstraints()});
  MultiExperiment me2dsysts({&expt2dsysts, &exptNue2dsysts, new SolarConstraints()});
  MultiExperiment me2di({&expt2di, &exptNue2di, new SolarConstraints()});
  MultiExperiment me2disysts({&expt2disysts, &exptNue2disysts, new SolarConstraints()});
  MultiExperiment meRHC({&exptRHC, &exptNueRHC, new SolarConstraints()});
  MultiExperiment meAll({&exptNue2dsysts, &exptNue2dsystsrhc, &expt2dsysts, &expt2dsystsrhc, new SolarConstraints()});

  Surface surfNue(&me, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6);
  Surface surfNue2d(&me2d, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6);
  Surface surfNue2dsysts(&me2dsysts, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsnorm);
  Surface surfNue2dsystsall(&me2dsysts, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsall);
  Surface surfNue2dsystsall2(&me2dsysts, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsall2);
  Surface surfNueRHC(&meRHC, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6);
  Surface surfNueAll(&meAll, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsall);

  new TCanvas;
  TH1* h3 = DataMCComparisonComponents(mock, &pred, calc);
  h3->SetTitle("#nu_{#mu} FHC selection (MVA>0.25) 3.5yrs #times 40kt");
  CenterTitles(h3);
  Legend();
  gPad->Print("components.pdf");
  gPad->Print("components.C");

  new TCanvas;
  TH1* h3r = DataMCComparisonComponents(mockRHC, &predRHC, calc);
  h3r->SetTitle("#nu_{#mu} RHC selection (MVA>0.5) 3.5yrs #times 40kt");
  CenterTitles(h3);
  Legend();
  gPad->Print("components_rhc.pdf");
  gPad->Print("components_rhc.C");

  new TCanvas;
  TH1* h4 = DataMCComparisonComponents(mockNue, &predNue, calc);
  h4->SetTitle("#nu_{e} FHC selection (MVA>0.8) 3.5yrs #times 40kt");
  CenterTitles(h4);
  Legend();
  gPad->Print("components_nue.pdf");
  gPad->Print("components_nue.C");

  new TCanvas;
  TH1* h4r = DataMCComparisonComponents(mockNueRHC, &predNueRHC, calc);
  h4r->SetTitle("#nu_{e} RHC selection (MVA>0.8) 3.5yrs #times 40kt");
  CenterTitles(h4);
  Legend();
  gPad->Print("components_nue_rhc.pdf");
  gPad->Print("components_nue_rhc.C");

  new TCanvas;
  TH1* h2 = DataMCComparisonComponents(mockNumuPID, &predNumuPID, calc);
  h2->SetTitle("#nu_{#mu} FHC 3.5yrs #times 40kt");
  CenterTitles(h2);
  Legend();
  h2->GetYaxis()->SetRangeUser(1, 1e4);
  gPad->SetLogy();
  gPad->Print("components_pid.pdf");
  gPad->Print("components_pid.C");

  new TCanvas;
  TH1* h2d = DataMCComparisonComponents(mock2d, &pred2d, calc);
  h2d->SetTitle("#nu_{#mu} FHC 3.5yrs #times 40kt");
  CenterTitles(h2);
  Legend();
  h2->GetYaxis()->SetRangeUser(1, 1e4);
  gPad->SetLogy();
  gPad->Print("components_pid_2d.pdf");
  gPad->Print("components_pid_2d.C");

  new TCanvas;
  TH1* h2r = DataMCComparisonComponents(mockNumuPIDRHC, &predNumuPIDRHC, calc);
  h2r->SetTitle("#nu_{#mu} RHC 3.5yrs #times 40kt");
  CenterTitles(h2);
  Legend();
  h2->GetYaxis()->SetRangeUser(1, 1e4);
  gPad->SetLogy();
  gPad->Print("components_pid_rhc.pdf");
  gPad->Print("components_pid_rhc.C");

  new TCanvas;
  TH1* h = DataMCComparisonComponents(mockNuePID, &predNuePID, calc);
  h->SetTitle("#nu_{e} FHC 3.5yrs #times 40kt");
  CenterTitles(h);
  Legend();
  h->GetYaxis()->SetRangeUser(0, 600);
  gPad->Print("components_nue_pid.pdf");
  gPad->Print("components_nue_pid.C");

  new TCanvas;
  TH1* hd = DataMCComparisonComponents(mockNue2d, &predNue2d, calc);
  hd->SetTitle("#nu_{e} FHC 3.5yrs #times 40kt");
  CenterTitles(h);
  Legend();
  h->GetYaxis()->SetRangeUser(0, 600);
  gPad->Print("components_nue_pid_2d.pdf");
  gPad->Print("components_nue_pid_2d.C");

  new TCanvas;
  TH1* hr = DataMCComparisonComponents(mockNuePIDRHC, &predNuePIDRHC, calc);
  h->SetTitle("#nu_{e} RHC 3.5yrs #times 40kt");
  CenterTitles(h);
  Legend();
  h->GetYaxis()->SetRangeUser(0, 600);
  gPad->Print("components_nue_pid_rhc.pdf");
  gPad->Print("components_nue_pid_rhc.C");

  new TCanvas;
  surf.DrawContour(Gaussian90Percent2D(surf), kSolid, 4);
  //  surfRHC.DrawContour(Gaussian90Percent2D(surfRHC), kSolid, kGreen+2);
  surf2d.DrawContour(Gaussian90Percent2D(surf2d), kSolid, 1);
  surf2dcheck.DrawContour(Gaussian90Percent2D(surf2d), kSolid, 1); // if there are 2 solid black lines there is a problem
  surf2dsysts.DrawContour(Gaussian90Percent2D(surf2dsysts), kSolid, kGreen+2);
  surf2dsystsall.DrawContour(Gaussian90Percent2D(surf2dsystsall), kSolid, 2);
  surf.DrawBestFit(kRed);
  surfAll.DrawContour(Gaussian90Percent2D(surfAll), 1, kMagenta);
  gPad->Print("cont.pdf");

  new TCanvas;
  surfNue.DrawContour(Gaussian90Percent2D(surfNue), kSolid, 4);
  surfNue2d.DrawContour(Gaussian90Percent2D(surfNue2d), kSolid, 1);
  surfNue2dsysts.DrawContour(Gaussian90Percent2D(surfNue2dsysts), kSolid, kGreen+2);
  surfNue2dsystsall.DrawContour(Gaussian90Percent2D(surfNue2dsystsall), kSolid, 2);
  //  surfNue2dsystsall2.DrawContour(Gaussian90Percent2D(surfNue2dsystsall2), kSolid, kMagenta); // just a check that a 50% NC syst is same as a 5%
  surfNueAll.DrawContour(Gaussian90Percent2D(surfNueAll), kSolid, kMagenta);
  surfNue.DrawBestFit(kRed);
  gPad->Print("cont_nue.pdf");

  Spectrum testnom = preddunenumu.Predict(calc);
  Spectrum scaleshifted = preddunenumu.PredictSyst(calc,scaleshift);
  Spectrum resshifted = preddunenumu.PredictSyst(calc,resshift);

  new TCanvas;

  TH1* htestnom = testnom.ToTH1(pot);
  TH1* hscaleshifted = scaleshifted.ToTH1(pot);
  TH1* hresshifted = resshifted.ToTH1(pot);

  htestnom->SetLineWidth(2);
  hscaleshifted->SetLineWidth(2);
  hresshifted->SetLineWidth(2);

  hscaleshifted->SetLineColor(2);
  hresshifted->SetLineColor(4);

  htestnom->Draw();
  hscaleshifted->Draw("same");
  hresshifted->Draw("same");

  gPad->Print("testsysts.pdf"); // yes things are really shifting, here we can see it happen

  new TCanvas;

  TH1* hnom2 = nom2.ToTH1(pot);
  TH1* hscale2 = scale2.ToTH1(pot);
  TH1* hres2 = res2.ToTH1(pot);

  hnom2->SetLineWidth(2);
  hscale2->SetLineWidth(2);
  hres2->SetLineWidth(2);

  hscale2->SetLineColor(2);
  hres2->SetLineColor(4);

  hnom2->Draw();
  hscale2->Draw("same");
  hres2->Draw("same");

  gPad->Print("testsysts2.pdf"); // check shifts are happening in 2D variable also

  new TCanvas;

  // This is a very cheesy way to make the McD plot - would have to be very
  // different if we were varying any other parameters; leave in for now but don't trust this
  calc->SetdCP(0);
  Spectrum zeroNumu = pred.Predict(calc).FakeData(pot);
  Spectrum zeroNue = predNue.Predict(calc).FakeData(pot);
  Spectrum zeroNumu2d = pred2d.Predict(calc).FakeData(pot);
  Spectrum zeroNue2d = predNue2d.Predict(calc).FakeData(pot);
  Spectrum zeroNumuRHC = predRHC.Predict(calc).FakeData(pot);
  Spectrum zeroNueRHC = predNueRHC.Predict(calc).FakeData(pot);
  calc->SetdCP(TMath::Pi());
  Spectrum oneNumu = pred.Predict(calc).FakeData(pot);
  Spectrum oneNue = predNue.Predict(calc).FakeData(pot);
  Spectrum oneNumu2d = pred2d.Predict(calc).FakeData(pot);
  Spectrum oneNue2d = predNue2d.Predict(calc).FakeData(pot);
  Spectrum oneNumuRHC = predRHC.Predict(calc).FakeData(pot);
  Spectrum oneNueRHC = predNueRHC.Predict(calc).FakeData(pot);

  TGraph* g = new TGraph;
  TGraph* g2d = new TGraph;
  TGraph* grhc = new TGraph;
  TGraph* gold = new TGraph;
  TGraph* gold2 = new TGraph;

  for(int i = -100; i <= 100; ++i){
    calc->SetdCP(i/100.*TMath::Pi());

    Spectrum mockNumu = pred.Predict(calc).FakeData(pot);
    Spectrum mockNue = predNue.Predict(calc).FakeData(pot);
    Spectrum mockNumu2d = pred2d.Predict(calc).FakeData(pot);
    Spectrum mockNue2d = predNue2d.Predict(calc).FakeData(pot);
    Spectrum mockNumuRHC = predRHC.Predict(calc).FakeData(pot);
    Spectrum mockNueRHC = predNueRHC.Predict(calc).FakeData(pot);

    const double llZero = LogLikelihood(zeroNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(zeroNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double llOne = LogLikelihood(oneNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(oneNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double llZero2d = LogLikelihood(zeroNumu2d.ToTH1(pot), mockNumu2d.ToTH1(pot))+
      LogLikelihood(zeroNue2d.ToTH1(pot), mockNue2d.ToTH1(pot));

    const double llOne2d = LogLikelihood(oneNumu2d.ToTH1(pot), mockNumu2d.ToTH1(pot))+
      LogLikelihood(oneNue2d.ToTH1(pot), mockNue2d.ToTH1(pot));

    const double llZeroRHC = LogLikelihood(zeroNumuRHC.ToTH1(pot), mockNumuRHC.ToTH1(pot))+LogLikelihood(zeroNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(zeroNueRHC.ToTH1(pot), mockNueRHC.ToTH1(pot))+LogLikelihood(zeroNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double llOneRHC = LogLikelihood(oneNumuRHC.ToTH1(pot), mockNumuRHC.ToTH1(pot))+LogLikelihood(oneNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(oneNueRHC.ToTH1(pot), mockNueRHC.ToTH1(pot))+LogLikelihood(oneNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double ll = std::min(llZero, llOne);
    const double ll2d = std::min(llZero2d, llOne2d);
    const double llrhc = std::min(llZeroRHC, llOneRHC);

    if(ll>0) g->SetPoint(g->GetN(), i/100., sqrt(ll));
    if(ll2d>0) g2d->SetPoint(g2d->GetN(), i/100., sqrt(ll2d));
    if(llrhc>0) grhc->SetPoint(grhc->GetN(), i/100., sqrt(llrhc));
  }

  TH2* axes = new TH2F("", "3.5yrs #times 40kt, stats only;#delta / #pi;#sqrt{#chi^{2}}", 200, -1, +1, 50, 0, 8);

  CenterTitles(axes);
  axes->Draw();

  g2d->SetLineWidth(2);
  g2d->SetLineColor(1);
  g2d->Draw("l same");

  g->SetLineWidth(2);
  g->SetLineColor(4);
  g->Draw("l same");

  grhc->SetLineWidth(2);
  grhc->SetLineColor(kMagenta);
  grhc->Draw("l same");

  gPad->SetGridx();
  gPad->SetGridy();

  gPad->Print("mcd_hacky.pdf");
  gPad->Print("mcd_hacky.C");



  new TCanvas; // now try to make the plot right

  TH2* axes2 = new TH2F("", "3.5yrs #times 40kt, stats only;#delta / #pi;#sqrt{#chi^{2}}", 100, -1, +1, 50, 0, 8);

  TGraph* gr1d = new TGraph;    // IH+NH, all systs, 1D (E only)
  TGraph* grfull = new TGraph;  // IH+NH, all systs, 2D (ExPID)
  TGraph* gr2 = new TGraph;     // IH+NH, norm systs only, 2D
  TGraph* gr3 = new TGraph;     // FHC only, all systs, 2D, IH+NH
  TGraph* grstat = new TGraph;  // FHC only, no  systs, 2D, IH+NH
  TGraph* grnh = new TGraph;    // NH only part of previous
  TGraph* grih = new TGraph;    // IH only part


  // lots of possible combinations here: 2 hierarchies x 2 (FHC, RHC) x 2 expts (numu, nue) 2 x variables (1D, 2D) = 16, at 2 values of dCP = 32

  // do dCP = 0 case

  calc->SetdCP(0);
  calci->SetdCP(0);

  Spectrum tempnumu = preddunenumu.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu(&preddunenumu, tempnumu);
  Spectrum tempnue = preddunenue.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue(&preddunenue, tempnue);

  Spectrum tempnumui = preddunenumu.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui(&preddunenumu, tempnumu);
  Spectrum tempnuei = preddunenue.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei(&preddunenue, tempnue);

  Spectrum tempnumurhc = preddunenumurhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc(&preddunenumurhc, tempnumurhc);
  Spectrum tempnuerhc = preddunenuerhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc(&preddunenuerhc, tempnuerhc);

  Spectrum tempnumuirhc = preddunenumurhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc(&preddunenumurhc, tempnumurhc);
  Spectrum tempnueirhc = preddunenuerhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc(&preddunenuerhc, tempnuerhc);

  Spectrum tempnumu1d = preddunenumu1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu1d(&preddunenumu1d, tempnumu1d);
  Spectrum tempnue1d = preddunenue1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue1d(&preddunenue1d, tempnue1d);

  Spectrum tempnumui1d = preddunenumu1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui1d(&preddunenumu1d, tempnumu1d);
  Spectrum tempnuei1d = preddunenue1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei1d(&preddunenue1d, tempnue1d);

  Spectrum tempnumurhc1d = preddunenumu1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc1d(&preddunenumu1drhc, tempnumurhc1d);
  Spectrum tempnuerhc1d = preddunenue1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc1d(&preddunenue1drhc, tempnuerhc1d);

  Spectrum tempnumuirhc1d = preddunenumu1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc1d(&preddunenumu1drhc, tempnumurhc1d);
  Spectrum tempnueirhc1d = preddunenue1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc1d(&preddunenue1drhc, tempnuerhc1d);

  MultiExperiment tempme({&expttempnumu, &expttempnue, new SolarConstraints()}); // FHC only NH numu+nue
  MultiExperiment tempmei({&expttempnumui, &expttempnuei, new SolarConstraints()}); // FHC only IH numu+nue

  MultiExperiment tempmefull({&expttempnumu, &expttempnue, &expttempnumurhc, &expttempnuerhc, new SolarConstraints()}); // nue+numu FHC+RHC NH 2D
  MultiExperiment tempmeifull({&expttempnumui, &expttempnuei, &expttempnumuirhc, &expttempnueirhc, new SolarConstraints()}); // nue+numu FHC+RHC IH 2D

  MultiExperiment tempmefull1d({&expttempnumu1d, &expttempnue1d, &expttempnumurhc1d, &expttempnuerhc1d, new SolarConstraints()}); // nue+numu FHC+RHC NH 1D
  MultiExperiment tempmeifull1d({&expttempnumui1d, &expttempnuei1d, &expttempnumuirhc1d, &expttempnueirhc1d, new SolarConstraints()}); // nue+numu FHC+RHC IH 1D

  // now dCP = PI case

  calc->SetdCP(TMath::Pi());
  calci->SetdCP(TMath::Pi());

  Spectrum tempnumu2 = preddunenumu.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu2(&preddunenumu, tempnumu2);
  Spectrum tempnue2 = preddunenue.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue2(&preddunenue, tempnue2);

  Spectrum tempnumui2 = preddunenumu.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui2(&preddunenumu, tempnumu2);
  Spectrum tempnuei2 = preddunenue.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei2(&preddunenue, tempnue2);

  Spectrum tempnumurhc2 = preddunenumurhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc2(&preddunenumurhc, tempnumurhc2);
  Spectrum tempnuerhc2 = preddunenuerhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc2(&preddunenuerhc, tempnuerhc2);

  Spectrum tempnumuirhc2 = preddunenumurhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc2(&preddunenumurhc, tempnumurhc2);
  Spectrum tempnueirhc2 = preddunenuerhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc2(&preddunenuerhc, tempnuerhc2);

  Spectrum tempnumu1d2 = preddunenumu1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu1d2(&preddunenumu1d, tempnumu1d2);
  Spectrum tempnue1d2 = preddunenue1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue1d2(&preddunenue1d, tempnue1d2);

  Spectrum tempnumui1d2 = preddunenumu1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui1d2(&preddunenumu1d, tempnumu1d2);
  Spectrum tempnuei1d2 = preddunenue1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei1d2(&preddunenue1d, tempnue1d2);

  Spectrum tempnumurhc1d2 = preddunenumu1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc1d2(&preddunenumu1drhc, tempnumurhc1d2);
  Spectrum tempnuerhc1d2 = preddunenue1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc1d2(&preddunenue1drhc, tempnuerhc1d2);

  Spectrum tempnumuirhc1d2 = preddunenumu1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc1d2(&preddunenumu1drhc, tempnumurhc1d2);
  Spectrum tempnueirhc1d2 = preddunenue1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc1d2(&preddunenue1drhc, tempnuerhc1d2);

  MultiExperiment tempme2({&expttempnumu2, &expttempnue2, new SolarConstraints()});
  MultiExperiment tempmei2({&expttempnumui2, &expttempnuei2, new SolarConstraints()});

  MultiExperiment tempmefull2({&expttempnumu2, &expttempnue2, &expttempnumurhc2, &expttempnuerhc2, new SolarConstraints()});
  MultiExperiment tempmeifull2({&expttempnumui2, &expttempnuei2, &expttempnumuirhc2, &expttempnueirhc2, new SolarConstraints()});

  MultiExperiment tempmefull1d2({&expttempnumu1d2, &expttempnue1d2, &expttempnumurhc1d2, &expttempnuerhc1d2, new SolarConstraints()});
  MultiExperiment tempmeifull1d2({&expttempnumui1d2, &expttempnuei1d2, &expttempnumuirhc1d2, &expttempnueirhc1d2, new SolarConstraints()});

  // now make fitters that will do actual fits // TODO make variable names intelligible
  // these allow Dmsq32, sinsqth23, sinsq2th13 to float, constrained only by the data itself
  // they also allow Dmsq21 and sinsq2th12 to float, constrained be external solar data (see CAFAna/Experiments/SolarConstraints.*)

  // dCP = 0 fits
  Fitter fit(&tempme, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);            // FHC only, NH, norm systs only
  Fitter fit2(&tempme, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});                      // FHC only, NH, no systs
  Fitter fit3(&tempme, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);            // FHC only, NH, all systs
  Fitter fitfull(&tempmefull, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);     // FHC+ RHC, NH, all systs
  Fitter fitfull1d(&tempmefull1d, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall); // FHC+ RHC, NH, all systs, 1D
  SystShifts systsout = SystShifts::Nominal();
  Fitter fiti(&tempmei, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);          // same but IH now
  Fitter fit2i(&tempmei, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});
  Fitter fit3i(&tempmei, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter fitfulli(&tempmeifull, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter fitfull1di(&tempmeifull1d, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  SystShifts systsouti = SystShifts::Nominal();


  // dCP = PI fits
  Fitter xfit(&tempme2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);
  Fitter xfit2(&tempme2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});
  Fitter xfit3(&tempme2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfull(&tempmefull2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfull1d(&tempmefull1d2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  SystShifts xsystsout = SystShifts::Nominal();
  Fitter xfiti(&tempmei2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);
  Fitter xfit2i(&tempmei2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});
  Fitter xfit3i(&tempmei2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfulli(&tempmeifull2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfull1di(&tempmeifull1d2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  SystShifts xsystsouti = SystShifts::Nominal();

  for(int i = -50; i <= 50; ++i){    // scan over dCP, create fake data at each dCP value, compare to dCP = 0 or PI cases, for each hierarchy
    calc->SetdCP(i/50.*TMath::Pi());
    calci->SetdCP(i/50.*TMath::Pi());

    std::cout << "Doing fits for dCP significance: " << i+50 << "%" << std::endl;

    // do the actual fits here, returns are chisq value of fits
    double throwaway = fit.Fit(calc, systsout, Fitter::kQuiet);  // debugging some odd behavior
    double chisqout = fit.Fit(calc, systsout, Fitter::kQuiet);
    double chisqouti = fiti.Fit(calci, systsouti, Fitter::kQuiet);
    double chisqout2 = fit2.Fit(calc, systsout, Fitter::kQuiet);
    double chisqout2i = fit2i.Fit(calci, systsout, Fitter::kQuiet);
    double chisqout3 = fit3.Fit(calc, systsout, Fitter::kQuiet);
    double chisqout3i = fit3i.Fit(calci, systsouti, Fitter::kQuiet);
    double chisqoutfull = fitfull.Fit(calc, systsout, Fitter::kQuiet);
    double chisqoutfulli = fitfulli.Fit(calci, systsout, Fitter::kQuiet);
    double chisqoutfull1d = fitfull1d.Fit(calc, systsout, Fitter::kQuiet);
    double chisqoutfull1di = fitfull1di.Fit(calci, systsout, Fitter::kQuiet);

    double xthrowaway = xfit.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqout = xfit.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqouti = xfiti.Fit(calci, systsouti, Fitter::kQuiet);
    double xchisqout2 = xfit2.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqout2i = xfit2i.Fit(calci, systsout, Fitter::kQuiet);
    double xchisqout3 = xfit3.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqout3i = xfit3i.Fit(calci, systsouti, Fitter::kQuiet);
    double xchisqoutfull = xfitfull.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqoutfulli = xfitfulli.Fit(calci, systsout, Fitter::kQuiet);
    double xchisqoutfull1d = xfitfull1d.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqoutfull1di = xfitfull1di.Fit(calci, systsout, Fitter::kQuiet);
    //    std::cout << " for dcp = " << i/50.*TMath::Pi() << " chisqs are: " << chisqout << " " << chisqouti << " " << sqrt(std::min(chisqout,chisqouti)) << std::endl; // debug

    // prevent possible errors
    if(chisqout < 0) chisqout = 0;
    if(chisqouti < 0) chisqouti = 0;
    if(chisqout2 < 0) chisqout = 0;
    if(chisqout2i < 0) chisqouti = 0;
    if(chisqout3 < 0) chisqout = 0;
    if(chisqout3i < 0) chisqouti = 0;
    if(chisqoutfull < 0) chisqoutfull = 0;
    if(chisqoutfulli < 0) chisqoutfulli = 0;
    if(chisqoutfull1d < 0) chisqoutfull1d = 0;
    if(chisqoutfull1di < 0) chisqoutfull1di = 0;

    if(xchisqout < 0) xchisqout = 0;
    if(xchisqouti < 0) xchisqouti = 0;
    if(xchisqout2 < 0) xchisqout = 0;
    if(xchisqout2i < 0) xchisqouti = 0;
    if(xchisqout3 < 0) xchisqout = 0;
    if(xchisqout3i < 0) xchisqouti = 0;
    if(xchisqoutfull < 0) xchisqoutfull = 0;
    if(xchisqoutfulli < 0) xchisqoutfulli = 0;
    if(xchisqoutfull1d < 0) xchisqoutfull1d = 0;
    if(xchisqoutfull1di < 0) xchisqoutfull1di = 0;

    //chisq for each point is minimum chisq of fit comparing to dCP = 0, PI, for either hierarchy

    gr2->SetPoint(gr2->GetN(), i/50., sqrt(std::min( std::min(chisqout,chisqouti), std::min(xchisqout,xchisqouti) )));
    gr3->SetPoint(gr3->GetN(), i/50., sqrt(std::min(std::min(chisqout3,chisqout3i),std::min(xchisqout3,xchisqout3i))));
    grnh->SetPoint(grnh->GetN(), i/50., sqrt(std::min(chisqout2,xchisqout2)));
    grih->SetPoint(grih->GetN(), i/50., sqrt(std::min(chisqout2i,xchisqout2i)));
    grstat->SetPoint(grstat->GetN(), i/50., sqrt(std::min(std::min(chisqout2i,chisqout2),std::min(xchisqout2i,xchisqout2))));
    grfull->SetPoint(grfull->GetN(), i/50., sqrt(std::min(std::min(chisqoutfulli,chisqoutfull),std::min(xchisqoutfulli,xchisqoutfull))));
    gr1d->SetPoint(gr1d->GetN(), i/50., sqrt(std::min(std::min(chisqoutfull1di,chisqoutfull1d),std::min(xchisqoutfull1di,xchisqoutfull1d))));
  }

  axes2->Draw();

  grfull->SetLineWidth(2);
  grfull->SetLineColor(2);
  grfull->Draw("l same");

  gr1d->SetLineWidth(2);
  gr1d->SetLineColor(4);
  gr1d->Draw("l same");

  gr2->SetLineWidth(2);
  gr2->SetLineColor(4);
  //  gr2->Draw("l same");

  gr3->SetLineWidth(2);
  gr3->SetLineColor(kGreen+2);
  gr3->Draw("l same");

  grnh->SetLineWidth(2);
  grnh->SetLineColor(1);
  //  grnh->Draw("l same");

  grih->SetLineWidth(2);
  grih->SetLineColor(2);
  //  grih->Draw("l same");

  grstat->SetLineWidth(2);
  grstat->SetLineColor(1);
  grstat->Draw("l same");

  gPad->SetGridx();
  gPad->SetGridy();

  gPad->Print("mcd.pdf");
  gPad->Print("mcd.C");
}
コード例 #8
0
ファイル: proj_npe_7.C プロジェクト: nikihowe/flash
void proj_npe_7()
{
//=========Macro generated from canvas: c/
//=========  (Wed Jul 15 10:08:15 2015) by ROOT version6.04/00
   TCanvas *c = new TCanvas("c", "",0,45,600,500);
   c->SetHighLightColor(2);
   c->Range(-2716.773,-19.2575,4381.788,173.3175);
   c->SetFillColor(0);
   c->SetBorderMode(0);
   c->SetBorderSize(2);
   c->SetFrameBorderMode(0);
   c->SetFrameBorderMode(0);
   
   Double_t _fx8[40] = {
   -1533.68,
   -1080.366,
   -985.4475,
   -967.7257,
   -676.2766,
   -543.2768,
   0.5077484,
   1.609375,
   4,
   230.4228,
   298.6529,
   327.7793,
   383.4035,
   536.5637,
   668.7969,
   863.9145,
   907.8805,
   964.7188,
   971.6563,
   1075.914,
   1097.936,
   1215.826,
   1275.258,
   1308.524,
   1328.116,
   1732.736,
   2102.711,
   2197.457,
   2255.99,
   2286.444,
   2371.061,
   2594.067,
   2630.891,
   2704.654,
   2727.792,
   2773.388,
   2784.73,
   2845.592,
   2924.958,
   3198.695};
   Double_t _fy8[40] = {
   2.75,
   2.65,
   2.65,
   2.7,
   2.35,
   2.45,
   140.25,
   2.65,
   2.15,
   2.55,
   2.35,
   2.45,
   2.3,
   2.5,
   2.65,
   4.05,
   2.55,
   2.5,
   2.35,
   2.25,
   2.6,
   2.7,
   2.7,
   2.6,
   2.4,
   2.35,
   2.8,
   2.55,
   2.35,
   2.8,
   2.4,
   2.35,
   2.6,
   2.6,
   2.45,
   2.45,
   2.65,
   2.55,
   2.55,
   2.65};
   TGraph *graph = new TGraph(40,_fx8,_fy8);
   graph->SetName("");
   graph->SetTitle("npe values of flashes in event: 7");
   graph->SetFillColor(1);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#0000ff");
   graph->SetMarkerColor(ci);
   graph->SetMarkerStyle(20);
   
   TH1F *Graph_Graph8 = new TH1F("Graph_Graph8","npe values of flashes in event: 7",100,-2006.917,3671.932);
   Graph_Graph8->SetMinimum(0);
   Graph_Graph8->SetMaximum(154.06);
   Graph_Graph8->SetDirectory(0);
   Graph_Graph8->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph8->SetLineColor(ci);
   Graph_Graph8->GetXaxis()->SetTitle("flash_t");
   Graph_Graph8->GetXaxis()->SetLabelFont(42);
   Graph_Graph8->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph8->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph8->GetXaxis()->SetTitleFont(42);
   Graph_Graph8->GetYaxis()->SetTitle("flash_npe");
   Graph_Graph8->GetYaxis()->SetLabelFont(42);
   Graph_Graph8->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph8->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph8->GetYaxis()->SetTitleFont(42);
   Graph_Graph8->GetZaxis()->SetLabelFont(42);
   Graph_Graph8->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph8->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph8->GetZaxis()->SetTitleFont(42);
   graph->SetHistogram(Graph_Graph8);
   
   graph->Draw("ap");
   
   TPaveText *pt = new TPaveText(0.1823077,0.9368947,0.8176923,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("npe values of flashes in event: 7");
   pt->Draw();
   c->Modified();
   c->cd();
   c->SetSelected(c);
}
コード例 #9
0
void Neutrals (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
{
  cout << "TEST VII" << endl; 
  char infile[100];
  int pz[9] = {1,2,4,8,12,16,32,40,50};
  double x[9];
  double means[9] = {0};
  double y[9];
  double mval = 0;
  int lastbincont = 0;
  bool lastbin = false;
  int var = 11;
  double intnum[1000]  = {0};
  double varnum[1000] = {0};
  char *part[] = {"gamma","neutron","anti_neutron"};
  int i = 0;
  int w =4;
  //TCanvas *c3 = new TCanvas("TresGraphitos","stupid graph",1);
  // TH1F *h4 = new TH1F("histo","histo",1000,0,.5);
  //TH2F *h3 = new TH2F("HistoGraph","HistoGraph",1000,0,.55,1000,0,1.2);
  // TMarker *grmark = new TMarker();
  //	  TCanvas *c19 = new TCanvas();
  // h3->Draw();
  for (int q=0; q<3; q++) 
  {
    for (int w=0; w<9;w++)
    {
      cout << "TEST VI" << endl;
      char ffile[100];
      sprintf(ffile,"/phenix/u/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/HistoBaseFiles/%s_ThinBins.root", part[q]);
      TFile *f = TFile::Open(ffile);
      char hname[100];
      sprintf(hname,"%s%dd",part[q],pz[w]);
      TH1F *h1 = (TH1F *)f->Get(hname);
      var = 11;
      i = 0;
      while (var <= 8001)
      {

	if (i<1000)
	{
	  varnum[i] = .005*(i);
	  intnum[i] = (h1->Integral(var-10,var))/10000.;//(h1->Integral());
	  i++;
	}
	var+=10;
      }
      // varnum[0] = 0;
      // intnum[0] = 0;
      char fname [100];
      sprintf(fname, "Gamma_Neutron_Hijing_Energy_Graphs.root");
      TFile *fout = TFile::Open(fname,"UPDATE");
      // h1->Write();
      //fout->Write();
      f->Close();
      //char hname[100];
      //sprintf(hname,"%s%dGeV",part[q],pz[w]);
      // cout << h1->Integral() << " "  <<  hname << " " << pz[i] << endl;
      //TH2 *h2 = new TH2F("hname","hname",1,0,5,1,0,1.2);
      gStyle->SetOptStat(0);

	  
      TMarker *mean = new TMarker();
      mean->SetMarkerStyle(20);
      mean->SetMarkerColor(3);
      char canvname[100];
      sprintf(canvname,"%s%d",part[q],pz[w]);
      //TCanvas *c3 = new TCanvas(canvname,"stupid graph",1);
      //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; 
      cout << "TEST V" << endl;
      TGraph *gr = new TGraph((i-2),varnum,intnum);
      char gtitle[100];
      sprintf(gtitle,"%s%dGeV;ConeSize;Percentage of Energy Deposited",part[q],pz[w]);
      char gname[100];
      sprintf(gname,"%s%dGeV",part[q],pz[w]);
      cout << intnum[50] << " " << varnum[50] << endl;
      gr->SetTitle(gtitle);
      gr->SetName(gname);
      gr->SetMarkerStyle(20);
      if (part[q] == "anti_neutron")
      {
	gr->SetMarkerColor(4);
      }
      else if (part[q] == "neutron")
      {
	gr->SetMarkerColor(2);
      }
      else if (part[q] == "gamma")
      {
	gr->SetMarkerColor(3);
      }
      else 
      {
	cout << "idiot" << endl;
      }
//	  gr->SetMaximum(1.2);
      //h2->Draw();
      //gr->Draw("A*");
      gr->Draw("ALP");
      //c3->DrawFrame(0,0,0.5,1.2);
      // gr->PaintGrapHist((i-1),varnum,intnum,"chopt");
      //	  gr->SetHistogram(h4);
      //h4->Write();
      gr->Write();
      cout << "TEST 1" << endl;
      //  TH2F *h3 = (TH2F *) "HistoGraph";
      cout << "TEST II" << endl;

      cout << "TEST III" << endl;
      //h3->Write();
      cout << "TEST IV" << endl;
      //double x;
      //double y;
      //gr()->GetPoint(

      fout->Write();
      fout->Close();
      //	  gr->Close();
      for (int a=0;a<1000;a++)
      {
	intnum[a] = 0;
	varnum[a] = 0;
      }
	  
    }
  }
}