daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Double_t FBSigma(TH2D* hist=0){
  2.     Double_t MEANF=hist->GetMean(1);
  3.     Double_t MEANB=hist->GetMean(2);
  4.     Double_t RMSF=hist->GetRMS(1);
  5.     Double_t RMSB=hist->GetRMS(2);
  6.     Double_t COR=hist->GetCorrelationFactor();
  7.     Double_t SigmaFB = (MEANB*RMSF*RMSF/MEANF+MEANF*RMSB*RMSB/MEANB-2*COR*RMSF*RMSB)/(MEANF+MEANB);
  8. //cout<<"$$$"<<SigmaFB<<endl;
  9.     if (SigmaFB==SigmaFB) return SigmaFB; else return -100500;
  10.  
  11. }
  12.  
  13. Double_t FBDelta(TH2D* hist=0){
  14.     Double_t MEANF=hist->GetMean(1);
  15.     Double_t MEANB=hist->GetMean(2);
  16.     Double_t RMSF=hist->GetRMS(1);
  17.     Double_t RMSB=hist->GetRMS(2);
  18.     Double_t COR=hist->GetCorrelationFactor();
  19.     Double_t DeltaFB = (MEANB*RMSF*RMSF/MEANF-MEANF*RMSB*RMSB/MEANB)/(MEANB-MEANF);
  20.     if (DeltaFB==DeltaFB) return DeltaFB; else return -100500;
  21. }
  22.  
  23. void banderr (TH2D* h, Double_t& bcorr, Double_t& berr){
  24.     //h
  25.     const Int_t NHists=20;
  26.     TH2D** HIS=new TH2D*[NHists];
  27.     TH2D* cloned=h->Clone("cloned");
  28.     cloned->Reset();
  29.     for (Int_t i=0; i<NHists; i++){
  30.         HIS[i]=cloned->Clone(Form("cloned_%i",i));
  31.        
  32.     }
  33.     ULong_t NC=0;
  34.     for (Int_t iy=0; iy<h->GetYaxis()->GetNbins(); iy++){
  35.         for (Int_t ix=0; ix<h->GetXaxis()->GetNbins(); ix++){
  36.             Int_t c=0;
  37.             c=h->GetBinContent(ix,iy);
  38.             while (c>0) {
  39.                 Int_t seed=gRandom->Integer(NHists);
  40.                 HIS[seed]->Fill(h->GetXaxis()->GetBinCenter(ix),h->GetYaxis()->GetBinCenter(iy));
  41.                 NC++;
  42.                 c--;
  43.             }
  44.         }
  45.     }
  46.  
  47.     Double_t BA=0,B2A=0;
  48.     for (Int_t i=0; i<NHists; i++){
  49.         double brel=HIS[i]->GetCorrelationFactor();
  50.         BA+=brel;
  51.         B2A+=brel*brel;
  52.         delete HIS[i];
  53.     }  
  54.     bcorr=BA/NHists;
  55.     berr=sqrt( (B2A/NHists)-(BA/NHists)*(BA/NHists)  )/sqrt(NHists);
  56.     delete[] HIS;
  57. }
  58.  
  59.  
  60.  
  61. void sigmaanderr (TH2D* h, Double_t& sigma, Double_t& sigmaerr){
  62.     //h
  63.     const Int_t NHists=20;
  64.     TH2D** HIS=new TH2D*[NHists];
  65.     TH2D* cloned=h->Clone("cloned");
  66.     cloned->Reset();
  67.     for (Int_t i=0; i<NHists; i++){
  68.         HIS[i]=cloned->Clone(Form("cloned_%i",i));
  69.        
  70.     }
  71.     ULong_t NC=0;
  72.     for (Int_t iy=0; iy<h->GetYaxis()->GetNbins(); iy++){
  73.         for (Int_t ix=0; ix<h->GetXaxis()->GetNbins(); ix++){
  74.             Int_t c=0;
  75.             c=h->GetBinContent(ix,iy);
  76.             while (c>0) {
  77.                 Int_t seed=gRandom->Integer(NHists);
  78.                 HIS[seed]->Fill(h->GetXaxis()->GetBinCenter(ix),h->GetYaxis()->GetBinCenter(iy));
  79.                 NC++;
  80.                 c--;
  81.             }
  82.         }
  83.     }
  84.  
  85.     Double_t BA=0,B2A=0;
  86.     for (Int_t i=0; i<NHists; i++){
  87.         double sigma=FBSigma(HIS[i]);
  88.         BA+=sigma;
  89.         B2A+=sigma*sigma;
  90.         delete HIS[i];
  91.     }  
  92.     sigma=BA/NHists;
  93.     sigmaerr=sqrt( (B2A/NHists)-(BA/NHists)*(BA/NHists)  )/sqrt(NHists);
  94.     delete[] HIS;
  95. }
  96.  
  97.  
  98. double MeanX(TH2D* h){
  99.     TH1D* pX=h->ProjectionX();
  100.     double mX=pX->GetMean();
  101.     delete pX;
  102.     return mX;
  103. }
  104.  
  105. double MeanY(TH2D* h){
  106.     TH1D* pY=h->ProjectionY();
  107.     double mY=pY->GetMean();
  108.     delete pY;
  109.     return mY;
  110. }
  111.  
  112. double GetnF2(TH2D* h){
  113.     TH1D* pX=h->ProjectionX();
  114.     double mX=pX->GetMean();
  115.     double rX=pX->GetRMS();
  116.     delete pX;
  117.     return rX*rX+mX*mX;
  118. }
  119.  
  120. double GetCov(TH2D* h){
  121.     double r=h->GetCorrelationFactor();
  122.     TH1D* pX=h->ProjectionX();
  123.     double rX=pX->GetRMS();
  124.     delete pX;
  125.     TH1D* pY=h->ProjectionY();
  126.     double rY=pY->GetRMS();
  127.     delete pY;
  128.     return r*rX*rY;
  129. }
  130.  
  131. double GetCorr(TH2D* h){
  132.     double r=h->GetCorrelationFactor();
  133.     return r;
  134. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top