Set properly the limits for projections
authorzconesa <zconesa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 8 Oct 2012 07:28:30 +0000 (07:28 +0000)
committerzconesa <zconesa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 8 Oct 2012 07:28:30 +0000 (07:28 +0000)
PWGHF/vertexingHF/macros/ReadDvsMultiplicity.C

index 0cceea7..503aa06 100644 (file)
@@ -47,7 +47,7 @@ Bool_t fixPeakSigma = kFALSE;
 const Int_t nMultbins=6;\r
 Double_t multlims[nMultbins+1]={1.,9.,14.,20.,31.,49.,100.};\r
 //\r
-Int_t firstUsedBin[nPtBins]={-1,-1,-1}; // -1 uses all bins, >=1 to set the lower bin to be accepted from original histo\r
+Int_t firstUsedBin[nPtBins]={-1,-1,-1,-1,-1}; // -1 uses all bins, >=1 to set the lower bin to be accepted from original histo\r
 //\r
 Bool_t isMC=kFALSE;\r
 Int_t typeb=kExpo;\r
@@ -155,7 +155,7 @@ void ReadDvsMultiplicity(Int_t analysisType=kD0toKpi,
   }\r
   printf(", defined...\n");\r
 \r
-  std::cout << " htemp :"<<hPtMassMult[0]<<std::endl;\r
+  //  std::cout << " htemp :"<<hPtMassMult[0]<<std::endl;\r
   TH1F* hptaxis = (TH1F*)hPtMassMult[0]->ProjectionZ("hptaxis");\r
   TH1F* hmassaxis = (TH1F*)hPtMassMult[0]->ProjectionY("hmassaxis");\r
   TH1F* hmultaxis = (TH1F*)hPtMassMult[0]->ProjectionX("hmultaxis");\r
@@ -217,7 +217,7 @@ void ReadDvsMultiplicity(Int_t analysisType=kD0toKpi,
   for(Int_t j=0; j<nMultbins; j++){\r
     //    printf(" Studying multiplicity bin %d\n",j);\r
     Int_t multbinlow = hmultaxis->FindBin(multlims[j]);\r
-    Int_t multbinhigh = hmultaxis->FindBin(multlims[j+1]);\r
+    Int_t multbinhigh = hmultaxis->FindBin(multlims[j+1])-1;\r
     //\r
     // Loop on pt bins\r
     //\r
@@ -226,10 +226,10 @@ void ReadDvsMultiplicity(Int_t analysisType=kD0toKpi,
       canvas[j]->cd(iPad++);\r
       //      printf(" projecting to the mass histogram\n");\r
       Int_t ptbinlow = hptaxis->FindBin(ptlims[iBin]);\r
-      Int_t ptbinhigh = hptaxis->FindBin(ptlims[iBin+1]);\r
+      Int_t ptbinhigh = hptaxis->FindBin(ptlims[iBin+1])-1;\r
       hmass[massBin] = (TH1F*)hPtMassMult[0]->ProjectionY(Form("hmass_%d_%d",j,iBin),multbinlow,multbinhigh,ptbinlow,ptbinhigh);\r
-      if(  hmass[massBin]->GetEntries() < 60 ) {  \r
-       massBin++; \r
+      if(  hmass[massBin]->GetEntries() < 60 ) {\r
+       massBin++;\r
        continue;\r
       }\r
       Int_t origNbins=hmass[massBin]->GetNbinsX(); \r
@@ -274,6 +274,8 @@ void ReadDvsMultiplicity(Int_t analysisType=kD0toKpi,
       fitter[massBin]->Signal(3,s,errs);\r
       fitter[massBin]->Background(3,b,errb);\r
       fitter[massBin]->Significance(3,sig,errsig);\r
+      Double_t ry=fitter[iBin]->GetRawYield();\r
+      Double_t ery=fitter[iBin]->GetRawYieldError();\r
       myCanvas[massBin] = new TCanvas(Form("myCanvas_%d_%d",j,iBin),Form("Invariant mass mult bin %d, pt bin %d",j,iBin));\r
       fitter[massBin]->DrawHere(gPad);\r
     \r
@@ -295,8 +297,8 @@ void ReadDvsMultiplicity(Int_t analysisType=kD0toKpi,
       hNDiffCntSig2[j]->SetBinContent(iBin+1,(s-cntSig2)/s);\r
       hNDiffCntSig2[j]->SetBinError(iBin+1,TMath::Sqrt(cntErr)/s);\r
       hCntSig2[j]->SetBinError(iBin+1,TMath::Sqrt(cntErr));\r
-      hSignal[j]->SetBinContent(iBin+1,s);\r
-      hSignal[j]->SetBinError(iBin+1,errs);\r
+      hSignal[j]->SetBinContent(iBin+1,ry);\r
+      hSignal[j]->SetBinError(iBin+1,ery);\r
       hRelErrSig[j]->SetBinContent(iBin+1,errs/s);\r
       hInvSignif[j]->SetBinContent(iBin+1,1/sig);\r
       hInvSignif[j]->SetBinError(iBin+1,errsig/(sig*sig));\r
@@ -480,14 +482,15 @@ void ReadDvsMultiplicity(Int_t analysisType=kD0toKpi,
     if(analysisType==kDplusKpipi) partname="Dminus";\r
   }\r
 \r
-  TString outfilename = Form("RawYield%s_%s",partname.Data(),CutsType);\r
+  TString outfilename = Form("RawYield_MultInt_%s_%s",partname.Data(),CutsType);\r
   if(fixPeakSigma) outfilename += "_SigmaFixed";\r
   if(typeb==0) outfilename += "_Expo.root";\r
   else if(typeb==1) outfilename += "_Linear.root";\r
   else if(typeb==2) outfilename += "_Pol2.root";\r
 \r
   TFile* outf=new TFile(outfilename,"update");\r
-  outf->cd();\r
+  outf->cd(); \r
+  for(Int_t j=0; j<massBin; j++) hmass[j]->Write();\r
   for(Int_t j=0; j<nMultbins; j++){\r
     hMass[j]->Write();\r
     hSigma[j]->Write();\r
@@ -790,7 +793,7 @@ Bool_t CheckNtrVsZvtx(TH2F** hNtrackVsVtxZ, TH2F** hNtrackVsVtxZCorr, Int_t nFil
   for(Int_t i=0; i<nFiles; i++){\r
     cZvtx->cd(i+1);\r
     firstbin = hNtrAxis->FindBin( multlims[i] );\r
-    lastbin = hNtrAxis->FindBin( multlims[i+1] );\r
+    lastbin = hNtrAxis->FindBin( multlims[i+1] ) -1;\r
     hZvtx[i] = (TH1F*)hNtrackVsVtxZ[i]->ProjectionX(Form("hZvtx_%d",i),firstbin,lastbin);\r
     hZvtx[i]->Draw();\r
   }\r
@@ -800,7 +803,7 @@ Bool_t CheckNtrVsZvtx(TH2F** hNtrackVsVtxZ, TH2F** hNtrackVsVtxZCorr, Int_t nFil
   for(Int_t i=0; i<nFiles; i++){\r
     cZvtxCorr->cd(i+1);\r
     firstbin = hNtrAxis->FindBin( multlims[i] );\r
-    lastbin = hNtrAxis->FindBin( multlims[i+1] );\r
+    lastbin = hNtrAxis->FindBin( multlims[i+1] ) -1;\r
     hZvtxCorr[i] = (TH1F*)hNtrackVsVtxZCorr[i]->ProjectionX(Form("hZvtxCorr_%d",i),firstbin,lastbin);\r
     hZvtxCorr[i]->Draw();\r
   }\r