Excluding lowest pt point for K and p, ratios fit/data are now shown in 3 canvases
authormfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 8 Dec 2010 14:55:00 +0000 (14:55 +0000)
committermfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 8 Dec 2010 14:55:00 +0000 (14:55 +0000)
PWG2/SPECTRA/Fit/AliLatexTable.cxx
PWG2/SPECTRA/Fit/CombineSpectra.C

index 71216c3..4e6a8aa 100644 (file)
@@ -354,8 +354,9 @@ void AliLatexTable::PrintTable(Option_t * opt){
   // "ASCII" -> plain ASCII
   // "HTML"  -> HTML, to be improved
   // "CSV"   -> skips hline, usefult for importing in excell 
+  // "TWIKI" -> skips hline, usefult for importing in TWIKI
 
-  if(TString(opt) == "ASCII" || TString(opt)=="HTML" ||  TString(opt)=="CSV") {
+  if(TString(opt) == "ASCII" || TString(opt)=="HTML" ||  TString(opt)=="CSV" ||  TString(opt)=="TWIKI") {
     
     Int_t nrow = fRows->GetEntriesFast();
 
@@ -368,7 +369,7 @@ void AliLatexTable::PrintTable(Option_t * opt){
     for(Int_t irow = 0; irow < nrow; irow++){
       TString row = ((TObjString*) fRows->At(irow))->String();
       if (row.Contains("\\hline")){    
-       if (TString(opt)!="CSV") {
+       if (TString(opt)!="CSV" && TString(opt)!="TWIKI") {
          for(Int_t il = 0; il < total_lenght; il++) printf("-");
          printf("\n");   
        }
@@ -376,8 +377,13 @@ void AliLatexTable::PrintTable(Option_t * opt){
       }
       StripLatex(row, opt);
       TObjArray * cols = row.Tokenize("&");
+      if (TString(opt)=="TWIKI") printf(" | ");
       for(Int_t icol = 0; icol < fNcol; icol++){
-       const char * colstr = ((TObjString *) cols->At(icol))->String().Data();
+       TString strTmp = ((TObjString *) cols->At(icol))->String();
+       if(TString(opt)=="TWIKI" || TString(opt)=="HTML"){
+         strTmp.ReplaceAll("AMPER","&");
+       }
+       const char * colstr = strTmp.Data();
        char format [200];
        if (TString(opt)!="CSV") {
          sprintf(format, "%%%ds", col_widths[icol] + 2);       
@@ -386,6 +392,7 @@ void AliLatexTable::PrintTable(Option_t * opt){
        }
        printf(format, colstr);
        if (TString(opt)=="CSV") printf(", ");
+       if (TString(opt)=="TWIKI") printf(" | ");
 
       }
       printf ("\n");
@@ -450,18 +457,20 @@ void AliLatexTable::StripLatex(TString &text, TString format) {
   // command with corresponding text/tags
 
   text.ReplaceAll("\\cdot", "x");
-  text.ReplaceAll("\\pm", "+-");
   text.ReplaceAll("$", "");
   if (format == "ASCII") {
     text.ReplaceAll("\\right>", ">");
     text.ReplaceAll("\\left<", "<");
     text.ReplaceAll("\\rangle", ">");
     text.ReplaceAll("\\langle", "<");
-  } else if (format == "HTML") {
-    text.ReplaceAll("\\right>", "&rang;");
-    text.ReplaceAll("\\left<",  "&lang;");
-    text.ReplaceAll("\\rangle", "&rang;");
-    text.ReplaceAll("\\langle", "&lang;");
+    text.ReplaceAll("\\pm", "+-");
+  } else if (format == "HTML" || format == "TWIKI") {
+    // the & is used to tokenize... Have to cheat here
+    text.ReplaceAll("\\right>", "AMPERrang;");
+    text.ReplaceAll("\\left<",  "AMPERlang;");
+    text.ReplaceAll("\\rangle", "AMPERrang;");
+    text.ReplaceAll("\\langle", "AMPERlang;");
+    text.ReplaceAll("\\pm",     "AMPERplusmn;");
   } 
   if(text.Contains("multicolumn")) {
     //    cout << "col " << text.Data() << endl;
index 590ce45..3880ed7 100644 (file)
@@ -255,13 +255,16 @@ void FitCombined() {
   TH1F* hRatiosToFitSyst[kNPart][kNCharge]; // Ratio data/fit, stat + syst
   //  Fit all 
   Int_t chargeLoop = sumCharge ? 1 : 2; 
+  Bool_t divideRatiosCanvas=kTRUE;
   for(Int_t icharge = 0; icharge < chargeLoop; icharge++){
 
     TCanvas * c2 = new TCanvas(TString("cCombined")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombined")+chargeFlag[icharge],700,700);
     c2->SetTickx();
     c2->SetTicky();
     c2->SetLeftMargin(0.14);
-    TCanvas * c2r = new TCanvas(TString("cCombinedRatio")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombinedRatio")+chargeFlag[icharge],700,700);
+    TCanvas * c2r = 0;
+    if(divideRatiosCanvas) c2r = new TCanvas(TString("cCombinedRatio")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombinedRatio")+chargeFlag[icharge],1200,500);
+    else                   c2r = new TCanvas(TString("cCombinedRatio")+chargeFlag[icharge]+"_"+funcName[fitFuncID], TString("cCombinedRatio")+chargeFlag[icharge],700,700);
     c2->cd();
     gPad->SetLogy();
     TH2F * hempty = new TH2F(TString("hempty")+long(icharge),"hempty",100,0.,2.9, 100, 0.0005,5);
@@ -271,14 +274,18 @@ void FitCombined() {
     hempty->GetXaxis()->SetTitleOffset(1.1);
     hempty->Draw();
     c2r->cd();
+    if(divideRatiosCanvas) {
+      c2r->Divide(3,1);
+      c2r->cd(1);
+    }
     gPad->SetGridy();
     TH2F * hemptyR = new TH2F(TString("hemptyR")+long(icharge),"hemptyR",100,0.,2.9, 100, 0.5,1.5);
     hemptyR->SetXTitle("p_{t} (GeV/c)");
     hemptyR->SetYTitle("Data/Fit");
     hemptyR->Draw();
-
     
-    TLegend * l = new TLegend(0.176724, 0.153274, 0.475575, 0.434524,chargeLabel[icharge]);
+
+    TLegend * l = new TLegend(0.176724, 0.181548, 0.477011, 0.462798,chargeLabel[icharge]);
     l->SetFillColor(kWhite);
     l->SetTextSize(0.035);
     
@@ -291,6 +298,7 @@ void FitCombined() {
       tf->SetTextFont(12);
       tf->SetTextSize(0.032);
     }
+
     for(Int_t ipart = 0; ipart < kNPart; ipart++){
       printf(" ----- Fit %s %s ------\n",partFlag[ipart],chargeFlag[icharge]);
       Float_t fitmin = 0;
@@ -370,6 +378,11 @@ void FitCombined() {
       if(drawStar)    DrawStar(icharge);
       hRatiosToFit[ipart][icharge]=(TH1F*)hToFit->Clone(Form("hRatio%s%s",chargeFlag[icharge],partFlag[icharge])); // Ratio data/fit
       hRatiosToFitSyst[ipart][icharge]=(TH1F*)hsyststat->Clone(Form("hRatioSyst%s%s",chargeFlag[icharge],partFlag[icharge])); // Ratio data/fit
+      // Syst error on ratio with no fill
+      hRatiosToFitSyst[ipart][icharge]->SetLineColor(hToFit->GetLineColor());
+      hRatiosToFitSyst[ipart][icharge]->SetFillStyle(0);
+      
+
       // Compute ratio data/function integrating the function in the bin width
       for(Int_t iBin=1; iBin<hToFit->GetNbinsX(); iBin++){
        Double_t lowLim=hToFit->GetBinLowEdge(iBin);
@@ -439,6 +452,12 @@ void FitCombined() {
       //      tempTable.SetNextCol(yieldAbove/yield,-2);
       tempTable.InsertRow();
       c2r->cd();
+      if(divideRatiosCanvas) {
+       c2r->cd(ipart+1);
+       gPad->SetGridy();
+       TH2F * heloc = new TH2F(*hemptyR);
+       heloc->Draw();
+      }
       hRatiosToFitSyst[ipart][icharge]->Draw("e2same");
       hRatiosToFit[ipart][icharge]->Draw("esame");
 
@@ -457,7 +476,8 @@ void FitCombined() {
   }
 
   
-  table.PrintTable("ASCII");
+  //  table.PrintTable("ASCII");
+  table.PrintTable("TWIKI");
   
   cout << "" << endl;
   tempTable.PrintTable("ASCII");
@@ -604,11 +624,17 @@ void LoadSpectra() {
          hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
          hSpectra[kITS][ipart][icharge]->SetBinError  (ibin,0);
        }
-       if(ipart == kProton && ibin==9){
+       if(ipart == kProton && (ibin==9 || ibin==10)){
          printf("Kill bin %d (%f - %f GeV/c)for ITS protons\n",ibin,hSpectra[kITS][ipart][icharge]->GetBinLowEdge(ibin),hSpectra[kITS][ipart][icharge]->GetBinLowEdge(ibin)+hSpectra[kITS][ipart][icharge]->GetBinWidth(ibin));
          hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
          hSpectra[kITS][ipart][icharge]->SetBinError  (ibin,0);
        }
+       if(ipart == kKaon && ibin==7){
+         printf("Kill bin %d (%f - %f GeV/c)for ITS kaons\n",ibin,hSpectra[kITS][ipart][icharge]->GetBinLowEdge(ibin),hSpectra[kITS][ipart][icharge]->GetBinLowEdge(ibin)+hSpectra[kITS][ipart][icharge]->GetBinWidth(ibin));
+         hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
+         hSpectra[kITS][ipart][icharge]->SetBinError  (ibin,0);
+       }
+       
 //     if ((ipart == kKaon && ibin >= 12) || (ipart == kProton && ibin >= 20)) {
 //       hSpectra[kITS][ipart][icharge]->SetBinContent(ibin,0);
 //       hSpectra[kITS][ipart][icharge]->SetBinError  (ibin,0);
@@ -664,16 +690,16 @@ void LoadSpectra() {
   nbin =  hSpectra[kTPC][kKaon][kPos]->GetNbinsX();
   for(Int_t ibin = 0; ibin < nbin; ibin++){
     Float_t pt =  hSpectra[kTPC][kKaon][kPos]->GetBinCenter(ibin);
-    if (pt > 0.45){  // || pt<0.25) {
+    if (pt > 0.45 || pt<0.25) {
       for(Int_t icharge = 0; icharge < kNCharge; icharge++){
-       hSpectra[kTPC][kKaon][icharge]->SetBinContent(ibin,0);
-       hSpectra[kTPC][kKaon][icharge]->SetBinError  (ibin,0);  
+       hSpectra[kTPC][kKaon][icharge]->SetBinContent(ibin,0);
+       hSpectra[kTPC][kKaon][icharge]->SetBinError  (ibin,0);  
       }      
     }
-    if (pt < 0.25) {
-      hSpectra[kTPC][kKaon][kNeg]->SetBinContent(ibin,0);
-      hSpectra[kTPC][kKaon][kNeg]->SetBinError  (ibin,0);      
-    }
+    // if (pt < 0.25) {
+    //   hSpectra[kTPC][kKaon][kNeg]->SetBinContent(ibin,0);
+    //   hSpectra[kTPC][kKaon][kNeg]->SetBinError  (ibin,0);   
+    // }
     if (pt < 0.45) {
       for(Int_t icharge = 0; icharge < kNCharge; icharge++){
        hSpectra[kTPC][kProton][icharge]->SetBinContent(ibin,0);