Index: /trunk/interface/FuncDef.h
===================================================================
--- /trunk/interface/FuncDef.h	(revision 26)
+++ /trunk/interface/FuncDef.h	(revision 27)
@@ -72,5 +72,5 @@
 }
 
-void GaussValues(TTree * Analyze,string histo,double &rms, double &mean, string min, string max)
+void GaussValues(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
 {
   string temp = histo;
@@ -79,11 +79,14 @@
 
   string nom = histo.erase(0,histo.find(">>")+2);
-  TH1F *h = new TH1F(nom.c_str(),"",100,0,2);
-  Analyze->Draw(temp.c_str(),mintemp.c_str(),maxtemp.c_str());
+  TH1F *h = new TH1F(nom.c_str(),"",200,0,3);
+
+  string all = min + " && " + max;
+  Analyze->Draw(temp.c_str(),all.c_str());
   h->SetMarkerSize(0.6);
+//  double MeanFix = ;
   double MeanFix = h->GetMean();
   double RangMin = h->GetMean()-h->GetRMS();
   double RangMax = h->GetMean()+h->GetRMS();
-  TF1 *Gauss = new TF1("Gauss","gausn",RangMin,RangMax);
+  TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
   Gauss->FixParameter(1,MeanFix);
   h->Fit("Gauss","R");
@@ -95,5 +98,33 @@
   h->Draw("P");
   h->GetXaxis()->SetTitle("E_{T}^{rec}/E_{T}^{MC} [GeV]");
-}
+Gauss->Delete();
+  
+}
+
+void GaussValuesETmis(TTree * Analyze,string histo,double &rms, double &mean, string min,string max)
+{
+  string temp = histo;
+  string mintemp = min;
+  string maxtemp = max;
+
+  string nom = histo.erase(0,histo.find(">>")+2);
+  TH1F *h = new TH1F(nom.c_str(),"",50,-300,300);
+
+  string all = min + " && " + max;
+  Analyze->Draw(temp.c_str(),all.c_str());
+  h->SetMarkerSize(0.6);
+  double RangMin = h->GetMean()-h->GetRMS();
+  double RangMax = h->GetMean()+h->GetRMS();
+  TF1 *Gauss = new TF1("Gauss","gaus",RangMin,RangMax);
+  h->Fit("Gauss","R");
+  h->Fit("Gauss","RI");
+  h->Fit("Gauss","RI");
+  Double_t* params = Gauss->GetParameters();
+  rms=params[2];
+  mean=params[1];
+  h->Draw("P");
+  h->GetXaxis()->SetTitle("E_{T}^{rec}-E_{T}^{MC} [GeV]");
+}
+
 
 TH1F * HiggsMakeNormTH1F(Float_t Scale, Int_t numBin,Float_t minX,Float_t maxX, TTree * Analyze,string histo, Int_t Lcolor, Int_t Fcolor, Int_t Lstyle,Int_t width=2,bool Log=false)
Index: /trunk/routines/resolutions.C
===================================================================
--- /trunk/routines/resolutions.C	(revision 26)
+++ /trunk/routines/resolutions.C	(revision 27)
@@ -9,23 +9,29 @@
 #include "interface/FuncDef.h"
 
-void JetResol(TTree *Analyze)
+void JetResol()
 {
-   TCanvas *c1 = new TCanvas("c1","JET resol",100,100,600,450);
-   c1->cd(); 
+
+   setTDRStyle();
+   gROOT->Reset();
+
+   TFile *f1 = new TFile("JETResol.root","read");
+   TTree *Analyze = (TTree*)f1->Get("Analysis");
   
    const Int_t numBin=7;
-   double bins[numBin]={0,20,60,100,220,420,860};
+   double bins[numBin]={0,20,40,60,80,100,220};
    TProfile *ETSoverET = new TProfile("ETSoverET","Jet resolution: E_{T}^{rec}/E_{T}^{mc}",(numBin-1),bins,-10,10);
-   Analyze->Draw("JetPTResol.SmearePT:JetPTResol.NonSmearePT>>ETSoverET","JetPTResol.NonSmearePT>1");
 
    double rms[numBin];
    double mean[numBin];
 
-   TCanvas *c2 = new TCanvas("c2","JET resol",0,0,1000,650);
-   c2->cd(); int frame=0;
-   c2->Divide(6,2);
+   TCanvas *c1 = new TCanvas("c1","JET resol",0,0,1000,650);
+   c1->cd(); int frame=0;
+   c1->Divide(6,2);
 
    float x[numBin-1];
    float y[numBin-1];
+   float ex[numBin-1];
+   float ey[numBin-1];
+
    float finval=0;//valeur a remplir puis a fitter
 
@@ -38,59 +44,67 @@
         cout<<"binMin "<<binMin<<" binMax "<<binMax<<" bin center "<<binCenter<<endl;
         char tempMin[500];
-        sprintf(tempMin,"JetPTResol.NonSmearePT>%d",binMin);
+        if(i==0)binMin=5;
+        sprintf(tempMin,"JetPTResol.NonSmearePT > %d",binMin);
         string mystringMin(tempMin);
         char tempMax[500];
-        sprintf(tempMax,"JetPTResol.NonSmearePT<%d",binMax);
+        sprintf(tempMax,"JetPTResol.NonSmearePT < %d",binMax);
         string mystringMax(tempMax);
         char tempName[500];
-        sprintf(tempName,"JetPTResol.SmearePT>>hETSoverET%d",i);
+        sprintf(tempName,"(JetPTResol.SmearePT)>>hETSoverET%d",i);
         string mystringName(tempName);
 
-        c2->cd(++frame);
+        c1->cd(++frame);
         GaussValues(Analyze,tempName,rms[i],mean[i],mystringMin,mystringMax);
         x[i]=binCenter;
         finval=rms[i]/mean[i];
-        y[i]=(finval*2);
+        y[i]=(finval*100);
+        ex[i]=0;
+        ey[i]=0;
         cout<<"finval "<<finval<<" mean val "<<mean[i]<<" rms value "<<rms[i]<<endl;
-
       }
 
-   TCanvas *c3 = new TCanvas("c3","JET resol",100,100,600,450);
-   c3->cd();
+   TCanvas *c2 = new TCanvas("c2","JET resol",100,100,600,450);
+   c2->cd();
 
-   TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",1,3000);
+   TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",1,170);
 
-   TGraph *gr11 = new TGraph((numBin-1),x,y);
+   TGraphErrors *gr11 = new TGraphErrors((numBin-1),x,y,ex,ey);
    gr11->Draw("AP");
+   gr11->SetTitle("");
    gr11->GetXaxis()->SetTitle("E_{T}^{MC} [GeV]");
-   gr11->GetYaxis()->SetTitle("#sigma(E_{T}^{rec}/E_{T}^{MC})/<E_{T}^{rec}/E_{T}^{MC}>");
+   gr11->GetYaxis()->SetRangeUser(0,50);
+   gr11->GetYaxis()->SetTitle("#sigma(E_{T}^{rec}/E_{T}^{MC})_{fit}/<E_{T}^{rec}/E_{T}^{MC}>_{fit}");
 
-   //fitfun->FixParameter(0,0.0541930);
-   //fitfun->FixParameter(1,0.634908);
-   gr11->Fit("user","RQ");
-   gr11->Fit("user","RQ");
-   gr11->Fit("user","RQ");
+   Double_t* params = fitfun->GetParameters();
+
    gr11->Fit("user","R");
+   gr11->Fit("user","RI");
+   gr11->Fit("user","RI");
+   gr11->Fit("user","RI");
+   char tempResol[500];
+   sprintf(tempResol,"#frac{#sigma(E_{T}^{rec}/E_{T}^{MC})}{<E_{T}^{rec}/E_{T}^{MC}>} = #frac{%f}{#sqrt{E_{T}^{MC}}} #oplus #frac{%f}{E_{T}^{MC}} #oplus %f",params[1]/100,params[2]/100,params[0]/100);
 
+   TPaveText *leg1 = MakeTPave(0.4,0.6,0.8,0.65,tempResol);
+   leg1->Draw();
 
-
- delete fitfun;
-// delete Gauss;
+   delete fitfun;
 }
 
 
-void ETmisResol(TTree *Analyze)
+void ETmisResol()
 {
 
-   TCanvas *c4 = new TCanvas("c4","ETmis resol",100,100,600,450);
-   c4->cd(); 
-  
-   const Int_t numBin=10;
-   double bins[numBin]={0,10,20,40,80,160,320,640,1080,2160};
-   TProfile *ETSoverET = new TProfile("ETSoverET","ETmis resol",(numBin-1),bins,-10,10);
-   Analyze->Draw("(ETmisResol.EtSmeare-ETmisResol.Et):(ETmisResol.Et)>>ETSoverET","(ETmisResol.Et)>1");
+   setTDRStyle();
+   gROOT->Reset();
 
-   double rms[numBin];
-   double mean[numBin];
+   TFile *f1 = new TFile("PTMIS.root","read");
+   TTree *Analyze = (TTree*)f1->Get("Analysis");
+
+   const Int_t numBin=6;
+   double bins[numBin]={10,20,30,50,80,100};
+   TProfile *ETSoverET = new TProfile("ETSoverET","ETmis resol",(numBin-1),bins,-1000,1000);
+
+   double rms[numBin-1];
+   double mean[numBin-1];
 
    TCanvas *c5 = new TCanvas("c5","gerrors2",0,0,1000,650);
@@ -98,6 +112,6 @@
    c5->Divide(6,2);
 
-   float x[numBin-1];
-   float y[numBin-1];
+   double x[numBin-1];
+   double y[numBin-1];
 
    for ( int i=0; i<(numBin-1); i++)  // premiÃšre bin : i ==1 et pas i == 0
@@ -109,17 +123,17 @@
         cout<<"binMin "<<binMin<<" binMax "<<binMax<<" bin center "<<binCenter<<endl;
         char tempMin[500];
-        sprintf(tempMin,"(ETmisResol.Et)>%d",binMin);
+        sprintf(tempMin,"ETmisResol.Et>%d",binMin);
         string mystringMin(tempMin);
         char tempMax[500];
-        sprintf(tempMax,"(ETmisResol.Et)<%d",binMax);
+        sprintf(tempMax,"ETmisResol.Et<%d",binMax);
         string mystringMax(tempMax);
+
         char tempName[500];
-        sprintf(tempName,"(ETmisResol.EtSmeare-ETmisResol.Et)>>hETSoverET%d",i);
+        sprintf(tempName,"ETmisResol.EtSmeare>>hETSoverET%d",i);
         string mystringName(tempName);
 
         c5->cd(++frame);
-        GaussValues(Analyze,tempName,rms[i],mean[i],mystringMin,mystringMax);
+        GaussValuesETmis(Analyze,tempName,rms[i],mean[i],mystringMin,mystringMax);
         x[i]=binCenter;
-        mean[i]=ETSoverET->GetBinContent(i+1);
         y[i]=rms[i];
         cout<<" mean val "<<mean[i]<<" rms value "<<rms[i]<<endl;
@@ -130,13 +144,10 @@
    c6->cd();
 
-   TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",1,3000);
+   TF1 *fitfun = new TF1("user","sqrt(pow([0],2)+pow([1]/sqrt(x),2)+pow([2]/x,2))",0,200);
 
-   TGraph *gr11 = new TGraph((numBin-1),x,y);
+   TGraph *gr11 = new TGraph((numBin-1),x,rms);
    gr11->Draw("AP");
-   gr11->GetXaxis()->SetTitle("E_{T}^{MC} [GeV]");
-   gr11->GetYaxis()->SetTitle("#sigma(E_{T}^{rec}>");
-
-   //fitfun->FixParameter(0,0.0541930);
-   //fitfun->FixParameter(1,0.634908);
+   gr11->GetXaxis()->SetTitle("MC^{MET} [GeV]");
+   gr11->GetYaxis()->SetTitle("#sigma(REC^{MET}-MC^{MET})");
    gr11->Fit("user","RQ");
    gr11->Fit("user","RQ");
@@ -144,18 +155,21 @@
    gr11->Fit("user","R");
 
+   TCanvas *c7 = new TCanvas("c7","ETmis resolution",100,100,600,450);
+   c7->cd();
+
+   TGraph *gr12 = new TGraph((numBin-1),x,mean);
+   gr12->Draw("AP");
+   gr12->GetXaxis()->SetTitle("MC^{MET} [GeV]");
+   gr12->GetYaxis()->SetTitle("<(REC^{MET}-MC^{MET})>");
 
 
  delete fitfun;
-// delete Gauss;
 }
 
 void General()
 {
-  setTDRStyle();
-  gROOT->Reset();
+  JetResol();
+  ETmisResol();
+}
 
-  TFile *f1 = new TFile("Smearing.root","read");
-  TTree *Analyze = (TTree*)f1->Get("Analysis");
-  JetResol(Analyze);
 
-}
