Index: trunk/routines/resolutions_atlas.C
===================================================================
--- trunk/routines/resolutions_atlas.C	(revision 488)
+++ trunk/routines/resolutions_atlas.C	(revision 489)
@@ -56,19 +56,51 @@
   //TFile *f1 = new TFile("JET2_atlas_midpoint_newCaloRes.root","read");
   //TFile *f1 = new TFile("JET2_atlas_kt_40k.root","read"); // 40k events
-  TFile *f1 = new TFile("JET2_atlas_kt_60k.root","read"); // 60k events
-  //TFile *f1 = new TFile("JET2_atlas_jetclu_new_60k.root","read"); // 60k events
+  //TFile *f1 = new TFile("JET2_atlas_kt_60k.root","read"); // 60k events
+  //TFile *f1 = new TFile("JET2_atlas_jetclu_60k.root","read"); // 60k events
+  //TFile *f1 = new TFile("JET2_atlas.kt_80k.root","read"); // 80k events -- samples jx -- default Delphes
+  //TFile *f1 = new TFile("JET2_atlas.cone_80k.root","read"); // 80k events -- samples jx -- default Delphes + endcaps
+  TFile *f1 = new TFile("JET2_atlas_kt_80k_endcap.root","read"); // 80k events -- samples jx -- default Delphes + endcaps
 
   if(!f1->IsOpen()) { cout << "could not open "<< f1->GetName() << ". Exiting..." << endl; return;}
   if(!f1->FindKey("Analysis")) { cout << "Bad input file, could not find the \"Analysis\" tree. Exiting..." << endl; return;}
   TTree *Analyze = (TTree*)f1->Get("Analysis");
-  
-  //const int numBin=16;
-  //double bins[numBin]={0,10,20,30,40,50,60,70,80,100,120,140,180,220,300,1200};
-  //const int numBin=25;
-  //double bins[numBin]={21,26,32,39,48, 59,72,88,107,130, 158,191,230,278,336, 405,485,581,696,834, 1000,1198,1435,1719,2060};
-  //const int numBin=20;
-  //double bins[numBin]={21,26,32,39,48, 59,72,88,107,130, 158,191,230,278,336, 405,485,581,696,834 };
+ 
+/* 
+  const int numBin=16;
+  double bins[numBin]={0,10,20,30,40,50,60,70,80,100,120,140,180,220,300,1200}; // cms-samples bins
+  string cut = "1==1";
+  TF1 *fitfunATLAS = new TF1("userATLAS","sqrt(pow(0.69*100/sqrt(x),2)+pow(0.03*100,2)+pow(6.3*100/x,2))",10,800);
+  TPaveText *etacut = MakeTPave(0.58,0.51,0.65,0.55,"|#eta|<0.5 ");
+*/
+/*
+  const int numBin=25;
+  double bins[numBin]={21,26,32,39,48, 59,72,88,107,130, 158,191,230,278,336, 405,485,581,696,834, 1000,1198,1435,1719,2060};
+  string cut = "1==1";
+  TF1 *fitfunATLAS = new TF1("userATLAS","sqrt(pow(0.69*100/sqrt(x),2)+pow(0.03*100,2)+pow(6.3*100/x,2))",10,800);
+  TPaveText *etacut = MakeTPave(0.58,0.51,0.65,0.55,"|#eta|<0.5 ");
+*/
+/*
+  const int numBin=20;
+  double bins[numBin]={21,26,32,39,48, 59,72,88,107,130, 158,191,230,278,336, 405,485,581,696,834 };
+  string cut = "1==1";
+  TF1 *fitfunATLAS = new TF1("userATLAS","sqrt(pow(0.69*100/sqrt(x),2)+pow(0.03*100,2)+pow(6.3*100/x,2))",10,800);
+  TPaveText *etacut = MakeTPave(0.58,0.51,0.65,0.55,"|#eta|<0.5 ");
+*/
+
+  // for eta < 0.5, use this
   const int numBin=14;
   double bins[numBin]={21,26,32,39,48, 59,72,88,130, 191,278, 405,581,834 };
+  string cut = "abs(JetPTResol.Eta)<0.5";
+  TF1 *fitfunATLAS = new TF1("userATLAS","sqrt(pow(0.69*100/sqrt(x),2)+pow(0.03*100,2)+pow(6.3*100/x,2))",10,800);
+  TPaveText *etacut = MakeTPave(0.58,0.51,0.65,0.55,"|#eta|<0.5 ");
+
+/*
+  // for forward 1.5 < eta < 2.0, use this
+  const int numBin=10;
+  double bins[numBin]={48, 59,72,88,130, 191,278, 405,581,834 };
+  string cut = "abs(JetPTResol.Eta)<2.0 && abs(JetPTResol.Eta)>1.5";
+  TF1 *fitfunATLAS= new TF1("userATLAS","sqrt(pow(1.19*100/sqrt(x),2)+pow(0.01*100,2)+pow(10*100/x,2))",10,800);
+  TPaveText *etacut = MakeTPave(0.58,0.51,0.65,0.55,"1.5<|#eta|<2.0 ");
+*/
   TProfile *ESoverE = new TProfile("ESoverE","Jet resolution for ATLAS ",numBin-1,bins,-10,10);
   
@@ -77,8 +109,9 @@
   TCanvas *c1 = new TCanvas("c1","JET resol: (E_reco - E_gen)/E_gen",0,0,1000,650);
   c1->cd(); int frame=0;
-  c1->Divide(10,2);
+  int nc = numBin/2 + numBin%2;
+  c1->Divide(nc,2);
   TCanvas *c1b = new TCanvas("c1b","JET resol: [(E_reco - E_gen)/E_gen]^2 ",0,0,1000,650);
   c1b->cd(); int frame2=0;
-  c1b->Divide(10,2);
+  c1b->Divide(nc,2);
   
   float x[numBin-1];
@@ -116,7 +149,4 @@
       string mystringName(tempName);
       c1->cd(++frame);
-      //string cut = "abs(JetPTResol.Eta)<2.0 && abs(JetPTResol.Eta)>1.5";
-      string cut = "abs(JetPTResol.Eta)<0.5";
-      //string cut = "1==1";
       GaussValuesAsymmetry(Analyze,tempName,mean[i],mystringMin,mystringMax,cut);
 
@@ -127,5 +157,4 @@
       c1b->cd(++frame2);
       GaussValuesAsymmetry2(Analyze,tempName,mean2[i],mystringMin,mystringMax,cut);
-
 
       x[i]=binCenter;
@@ -183,13 +212,8 @@
   fitfunDelphes->Draw("same");
 
-  TF1 *fitfunATLAS = new TF1("userATLAS","sqrt(pow(0.69*100/sqrt(x),2)+pow(0.03*100,2)+pow(6.3*100/x,2))",10,800);
   fitfunATLAS->SetLineColor(kBlue);
   fitfunATLAS->Draw("same");
 
-  TF1 *fitfunATLAS2= new TF1("userATLAS2","sqrt(pow(1.19*100/sqrt(x),2)+pow(0.01*100,2)+pow(10*100/x,2))",10,800);
-  fitfunATLAS2->SetLineColor(kBlue);
-  //fitfunATLAS2->Draw("same");
-
-  TPaveText *etacut = MakeTPave(0.58,0.51,0.65,0.55,"|#eta|<0.5 ");
+
   etacut->Draw();
 
@@ -358,14 +382,18 @@
   //TFile *f1 = new TFile("JET2_ATLAS.root","read");
   //TFile *f1 = new TFile("JET2_atlas_midpoint.root","read");
-  TFile *f1 = new TFile("JET2_atlas_kt_60k.root","read"); // 60k events
+  //TFile *f1 = new TFile("JET2_atlas_kt_60k.root","read"); // 60k events
+  //TFile *f1 = new TFile("JET2_atlas_kt_80k_endcap.root","read"); // 80k events + endcap
+  TFile *f1 = new TFile("JET2_atlas.cone_80k.root","read"); // 80k events + endcap
   if(!f1->IsOpen()) { cout << "could not open "<< f1->GetName() << ". Exiting..." << endl; return;}
   if(!f1->FindKey("Analysis")) { cout << "Bad input file, could not find the \"Analysis\" tree. Exiting..." << endl; return;}
   TTree *Analyze = (TTree*)f1->Get("Analysis");
   
-  TF1 *fitfun = new TF1("user","[0]*sqrt(x)",0,600);
+  //const Int_t numBin=6;   double bins[numBin]={180,260,340,420,500,580};
+  double max = 900;
+  const Int_t numBin=6;   double bins[numBin]={100,250,400,550,700,max};
+  //const Int_t numBin=6;   double bins[numBin]={180,260,340,420,500,max};
+  TProfile *ETSoverET = new TProfile("ETSoverET","ETmis resol",numBin-1,bins,-1000,1000);
+  TF1 *fitfun = new TF1("user","[0]*sqrt(x)",0,max);
   fitfun->SetLineColor(kBlue);
-  const Int_t numBin=6;
-  double bins[numBin]={180,260,340,420,500,580};
-  TProfile *ETSoverET = new TProfile("ETSoverET","ETmis resol",(numBin-1),bins,-1000,1000);
  
  
@@ -374,5 +402,6 @@
   TCanvas *c5 = new TCanvas("c5","PTmis resol",0,0,1000,650);
   c5->cd(); int frame=0;
-  c5->Divide(6,2);
+  int nb = numBin/2 + numBin%2;
+  c5->Divide(nb,2);
   
   double x[numBin];
@@ -420,5 +449,5 @@
   gr11->Fit("user","RQ");
   gr11->GetYaxis()->SetRangeUser(0,60);
-  gr11->GetXaxis()->SetRangeUser(1,600);
+  gr11->GetXaxis()->SetRangeUser(1,max);
   gr11->SetMaximum(16);
 
