#include #include gROOT->Reset(); void mkHist_D1primeFFCorr_BpBm_test() { // Root macro to produce FF histogram int test = 0; // Name of output files TString outHistoName("hist_D1primeFFCorr_BpBm_test.root"); TString outInfoFileName("hist_D1primeFFCorr_BpBm_test.txt"); // binning enum { nbinsx = 100 }; Float_t xmin = 0.0, xmax = 2.0; // Define histos TH1D *Hw = new TH1D("Hw", "Hw", nbinsx, 1.0, 1.5); TH1D *HoldFF = new TH1D("HoldFF", "HoldFF", nbinsx, xmin, 0.15); TH1D *HnewFF = new TH1D("HnewFF", "HnewFF", nbinsx, xmin, 0.15); TH1D *HcorrFF = new TH1D("HcorrFF", "HcorrFF", nbinsx, xmin, 2.0); // Masses double mB = 5.2790; double mD = 2.4300; // Get normalization factor double RN(1.0); normFactor(RN, mB, mD); cout << " mB = " << mB << endl; cout << " mD = " << mD << endl; cout << " RN = " << RN << endl; //################################### // Chain input data cout << "start chain" << endl; TChain * chain = new TChain("ntp2"); int nStop = 1952; if (test == 1) nStop = 5; for (Int_t i=1; i<=nStop; i++) { TString inFileNameBase("/hep24/khamano/hep03/R16b/Run2/SP-1235-BToDlnu-Run2-R16b"); chain->Add(inFileNameBase+"-"+i+".root"); } TTree * tree = chain; cout << "read tree" << endl; // variables to read out Int_t nDl_3D(0); Int_t isABhabha_3D(0); Int_t DDecayMode_3D[200]; Int_t DlLepType_3D[200]; Int_t tightK_3D[200]; Float_t DMass_3D[200]; double FitDprob_3D[200], FitBprob_3D[200]; Float_t cosDlnonDl_3D[200]; Int_t noExtraKorPi_3D[200], mcKaonMissID_3D[200]; Int_t mcPiMissID_3D[200], mcKPifromSameD_3D[200]; Int_t mcLepMissID_3D[200], mcDirectLepFromB_3D[200]; Int_t trueLepFromSameB_3D[200]; Int_t trueBDecMod_3D[200]; double trkEffCorr_3D[200], PIDCorr_3D[200]; double trkEffCorrErr_3D[200], PIDCorrErr_3D[200]; double PIDKCorr_3D[200], PIDLeptCorr_3D[200]; double PIDKCorrErr_3D[200], PIDLeptCorrErr_3D[200]; double mcW_3D[200]; double MCcosL_3D[200], MCcosV_3D[200], MCcosChi_3D[200]; Float_t varx_3D[200], vary_3D[200], varz_3D[200]; // Set reference between the above variables and root-tuple entries tree->SetBranchAddress("nDl", &nDl_3D); tree->SetBranchAddress("isABhabha", &isABhabha_3D); tree->SetBranchAddress("DDecayMode", &DDecayMode_3D); tree->SetBranchAddress("DlLepType", &DlLepType_3D); tree->SetBranchAddress("tightK", &tightK_3D); tree->SetBranchAddress("DMass", &DMass_3D); tree->SetBranchAddress("FitDprob", &FitDprob_3D); tree->SetBranchAddress("FitBprob", &FitBprob_3D); tree->SetBranchAddress("cosDlnonDl", &cosDlnonDl_3D); tree->SetBranchAddress("noExtraKorPi", &noExtraKorPi_3D); tree->SetBranchAddress("mcKaonMissID", &mcKaonMissID_3D); tree->SetBranchAddress("mcPiMissID", &mcPiMissID_3D); tree->SetBranchAddress("mcKPifromSameD", &mcKPifromSameD_3D); tree->SetBranchAddress("mcLepMissID", &mcLepMissID_3D); tree->SetBranchAddress("mcDirectLepFromB", &mcDirectLepFromB_3D); tree->SetBranchAddress("trueBDecMod", &trueBDecMod_3D); tree->SetBranchAddress("trueLepFromSameB", &trueLepFromSameB_3D); tree->SetBranchAddress("trkEffCorr", &trkEffCorr_3D); tree->SetBranchAddress("trkEffCorrErr", &trkEffCorrErr_3D); tree->SetBranchAddress("PIDCorr", &PIDCorr_3D); tree->SetBranchAddress("PIDCorrErr", &PIDCorrErr_3D); tree->SetBranchAddress("PIDKCorr", &PIDKCorr_3D); tree->SetBranchAddress("PIDKCorrErr", &PIDKCorrErr_3D); tree->SetBranchAddress("PIDLeptCorr", &PIDLeptCorr_3D); tree->SetBranchAddress("PIDLeptCorrErr", &PIDLeptCorrErr_3D); tree->SetBranchAddress("mcW", &mcW_3D); tree->SetBranchAddress("MCcosL", &MCcosL_3D); tree->SetBranchAddress("MCcosV", &MCcosV_3D); tree->SetBranchAddress("MCcosChi", &MCcosChi_3D); tree->SetBranchAddress("DMass", &varx_3D); tree->SetBranchAddress("DMom", &vary_3D); tree->SetBranchAddress("DLcosBY", &varz_3D); // Read out root-tuple entries and fill arrays Int_t nevent_3D =(Int_t)tree->GetEntries(); // number of events cout << "number of events = " << nevent_3D << endl; int numCand(0); //processed candidates int numCand_DDecMod(0); //after D decay mode cut int numCand_EvtSel(0); //after event selection cuts int numCand_selLep(0); //after lepton selection int numCand_Index(0); //before index selection int numSelCand(0); //selcted candidates for (Int_t i=0;iGetEntry(i); //read complete event in memory for (Int_t j=0;j 0.92) continue; numCand_EvtSel++; //if (leptType != 1) continue; numCand_selLep++; if (noExtKorPi == 0) continue; if (kaonMissID == 1) continue; if (piMissID == 1) continue; if (KPiFromSameD == 0) continue; if (lepMissID == 1) continue; if (directLepFromB == 0) continue; if (lepFromSameB == 0) continue; int goodBDecMod(0); if (mcBDecMod == 1640 ) goodBDecMod=1; if (mcBDecMod == 2630 ) goodBDecMod=1; if (mcBDecMod == -1 ) goodBDecMod=1; if (mcBDecMod == -1 ) goodBDecMod=1; if (goodBDecMod != 1) continue; numCand_Index++; numSelCand++; // Get trueW Hw->Fill(trueW); double wx = 1.0; // Get oldFF double oldFF = oldDlnuFF(trueW, mB, mD, cosL, cosV, cosChi); HoldFF->Fill(oldFF); //cout << "oldfF =" << oldFF << endl; // Get newFF double newFF = newDlnuFF(trueW, mB, mD, cosL, cosV, cosChi); HnewFF->Fill(newFF); // Get weight if (oldFF > 0) wx = RN * newFF / oldFF; HcorrFF->Fill(wx); } //end of Dl loop } //end of event loop cout << "number of processed candidates = " << numCand << endl; cout << "number of candidates after D decay mode selection = " << numCand_DDecMod << endl; cout << "number of candidates after event selection = " << numCand_EvtSel << endl; cout << "number of candidates after lepton selection = " << numCand_selLep << endl; cout << "number of candidates before index selection = " << numCand_Index << endl; cout << "number of selected candidates = " << numSelCand << endl; //############################################################# // Open output file and write histograms in it. ###### cout << "saving histograms to " << outHistoName << endl; TFile *f = new TFile(outHistoName, "Recreate"); Hw->Write(); HoldFF->Write(); HnewFF->Write(); HcorrFF->Write(); f->Write(); f->Close(); //####################################################################### // Open output file and save parameters. ##### cout << "dumping parameters to " << outInfoFileName << endl; ofstream outFile(outInfoFileName); //open output file if (!outFile) { cout << "Cannot open file " << outFile << endl; } outFile.setf(ios::fixed); outFile.setf(ios::showpoint); outFile << "Input files" << endl; outFile << " run = 2" << endl; outFile << " base directory = /home1x/OtherMounts/hep03/khamano/R16b" << endl; outFile << " File name base = SP-1235-BToDlnu-Run2-R16b" << endl; outFile << " start number = 1" << endl; outFile << " stop number = " << nStop << endl; outFile << "################" << endl; outFile << "Output files" << endl; outFile << " histograms : " << outHistoName << endl; outFile << " information : " << outInfoFileName << endl; outFile << "################" << endl; outFile << "Signal-background selection" << endl; outFile << " reqRealD = 1" << endl; outFile << " reqRealL = 1" << endl; outFile << " reqDirectL = 1" << endl; outFile << " reqCorr = 1" << endl; outFile << " reqBMod = 1" << endl; outFile << "B decay mode selection" << endl; outFile << " BMod1 = 1140" << endl; outFile << " BMod2 = 2130" << endl; outFile << " BMod3 = -1" << endl; outFile << " BMod4 = -1" << endl; outFile << "################" << endl; outFile << "Event number info" << endl; outFile << " number of events processed = " << nevent_3D << endl; outFile << " number of candidates processed = " << numCand << endl; outFile << " number of candidates after D decay mode selection = " << numCand_DDecMod << endl; outFile << " number of candidates after event selection = " << numCand_EvtSel << endl; outFile << " number of candidates after lepton selection = " << numCand_selLep << endl; outFile << " number of candidates before index selection = " << numCand_Index << endl; outFile << " number of candidates selected = " << numSelCand << endl; outFile << "################" << endl; outFile << "Normalization factor" << endl; outFile << " RN = " << RN << endl; outFile << "################" << endl; outFile << "Binning info" << endl; outFile << " nbinsx = 70" << endl; outFile << " xmin = " << xmin << endl; outFile << " xmax = " << xmax << endl; outFile.close(); //############################################################# //Plot histos if (test == 1) { cout << "plotting\n"; TCanvas * cx = new TCanvas("cx","cx",0,0,600,600); cx->Divide(2,2); gStyle->SetOptStat(000000); cx->cd(1); HoldFF->Draw(); cx->cd(2); HnewFF->Draw(); cx->cd(3); HcorrFF->Draw(); cx->cd(4); Hw->Draw(); } } void normFactor(double &RNM, double mB, double mD) { enum { n = 7 }; double xi[n]; double wi[n]; xi[0] = 0.0; wi[0] = 0.417959183673496; xi[1] = 0.405845151377397; wi[1] = 0.381830050505119; xi[2] = -xi[1]; wi[2] = wi[1]; xi[3] = 0.741531185599394; wi[3] = 0.279705391489277; xi[4] = -xi[3]; wi[4] = wi[3]; xi[5] = 0.949107912342759; wi[5] = 0.129484966168870; xi[6] = -xi[5]; wi[6] = wi[5]; double wMax = (mB*mB + mD*mD)/(2.0*mB*mD); double oldIntBF(0.0); double newIntBF(0.0); for (Int_t i = 0; i