I have two MC samples with a different luminosity which correspond to two types of background. I would like to get the correlation between two variables, with both background plotted on the scatter plot. I have to use weights. How can I do it?
So far I calculate the correlation this way (it is just a part of the code) but the fact that luminosities are different is not taken into account:
cout <<"--------------Opening files--------------------------" <<endl; TFile *fSK =new TFile ("../signal/cocktailMC/Dstar0CPK_K__pi0_KK7forfitWeight.root"); TTree *treeSK =fSK ->Get("ntp999"); Int_t numbSK =treeSK ->GetEntries(); Double_t CorrelationFactorSK; Int_t entriesSK; TCut cut="m_deltaE_K_fit>-0.2 && m_deltaE_K_fit<0.2"; TCanvas *canSK=new TCanvas("canSK","Scatter plot mes fit:deltaE_K fit for signal"); treeSK->Draw("m_deltaE_K_fit:m_mes_fit",cut); v1SK= treeSK->GetV1(); v2SK= treeSK->GetV2(); Int_t entriesSK = treeSK->GetSelectedRows(); mygraphSK = TGraph(entriesSK,v1SK,v2SK); CorrelationFactorSK=mygraphSK->GetCorrelationFactor(); Double_t errorSK =TMath::sqrt((1-CorrelationFactorSK*CorrelationFactorSK )*(1-CorrelationFactorSK*CorrelationFactorSK )/entriesSK);
Thank you in advance.