void calc_SBRatio_D0Kpi2() { #include #include gROOT->Reset(); // Root macro to calculate uncertainty of signal //####################################################### // Change these values to meet your condition //####################################################### // Info of input data/MC root files TString baseDir("/home1x/OtherMounts/hep03/khamano/R16b/Run3"); //TString baseDir("/home1x/OtherMounts/hep03/khamano/R16b/kCut1"); TString nameBase_BpBm("SP-1235-BToDlnu-Run3-R16b"); int nStart_BpBm = 1; int nStop_BpBm = 1193; //218 //87 TString nameBase_B0B0bar("SP-1237-BToDlnu-Run3-R16b"); int nStart_B0B0bar = 10000; int nStop_B0B0bar = 855; //220 //88 TString nameBase_ccbar("SP-1005-BToDlnu-Run3-R16b"); int nStart_ccbar = 1000; int nStop_ccbar = 208; //208 //83 TString nameBase_uds("SP-998-BToDlnu-Run3-R16b"); int nStart_uds = 1000; int nStop_uds = 143; //143 //58 TString nameBase_tautau("SP-3429-BToDlnu-Run3-R16b"); int nStart_tautau = 100; int nStop_tautau = 11; //11 //5 // Name of the root tree in the input root files TString ntpName("ntp2"); // Info of output files TString outFileName("SBRatio2_D0Kpi_Run3_test.txt"); TString outHistoFileName("histo2_nDl_D0Kpi_Run3_test.root"); // D mass peak region float DMassMin = 1.840; //1.855; //1.845; //for D0 float DMassMax = 1.888; //1.875; //1.885; // D mass off peak (side band)region float DSideMin1 = 1.816; //for Dch float DSideMax1 = 1.840; float DSideMin2 = 1.888; //for Dch float DSideMax2 = 1.912; // Select D decay mode int setDDecMod = 1; // D0Kpi //int setDDecMod = 2; // D0K3pi //int setDDecMod = 3; // D0Kpipi0 //int setDDecMod = 4; // D0Kspipi // Vertex cut float DprobMin = 0.01; //0.001 float BprobMin = 0.01; //0.001 // Thrust cut float cosThrMax = 0.80; // Select a bin float DMomMin = 0.2; float DMomMax = 2.8; float LMomMin = 0.8; float LMomMax = 2.8; float cosBYMin = -10; float cosBYMax = 5; // uncertainty on background float rho = 0; //####################################################################### // Define output historgams int nbin = 5; float xmin = 0; float xmax = 5; TH1D *TH1nDl_total = new TH1D("TH1nDl_total","nDl_total",nbin, xmin,xmax); TH1D *TH1nDl_sig = new TH1D("TH1nDl_sig","nDl_sig",nbin, xmin,xmax); TH1D *TH1nDl_bkg = new TH1D("TH1nDl_bkg","nDl_bkg",nbin, xmin,xmax); // Chain input root files and define trees. cout << "start chain\n"; TChain * chain_MC = new TChain(ntpName); for (Int_t i=nStart_BpBm; i<=nStop_BpBm; i++) { chain_MC->Add(baseDir+"/"+nameBase_BpBm+"-"+i+".root"); } for (Int_t i=nStart_B0B0bar; i<=nStop_B0B0bar; i++) { chain_MC->Add(baseDir+"/"+nameBase_B0B0bar+"-"+i+".root"); } for (Int_t i=nStart_ccbar; i<=nStop_ccbar; i++) { chain_MC->Add(baseDir+"/"+nameBase_ccbar+"-"+i+".root"); } for (Int_t i=nStart_uds; i<=nStop_uds; i++) { chain_MC->Add(baseDir+"/"+nameBase_uds+"-"+i+".root"); } for (Int_t i=nStart_tautau; i<=nStop_tautau; i++) { chain_MC->Add(baseDir+"/"+nameBase_tautau+"-"+i+".root"); } TTree * tree_MC = chain_MC; int numDl(0); int DDecMod[200], DType[200]; double fitDprob[200], fitBprob[200]; float cosThr[200]; int isABEvent[200], isDirectFromB[200], isFromSameB[200]; int BDecMod[200], mcDDecMod[200]; int noExtKPi[200], KMissID[200], PiMissID[200], KPiSameD[200]; float Dmass[200]; float pD[200], pLep[200], cosBY[200]; float pAddLep[200]; tree_MC->SetBranchAddress("nDl", &numDl); tree_MC->SetBranchAddress("DDecayMode", &DDecMod); tree_MC->SetBranchAddress("DhadType", &DType); tree_MC->SetBranchAddress("FitDprob", &fitDprob); tree_MC->SetBranchAddress("FitBprob", &fitBprob); tree_MC->SetBranchAddress("cosDlnonDl", &cosThr); tree_MC->SetBranchAddress("trueLepFromB", &isABEvent); tree_MC->SetBranchAddress("mcDirectLepFromB", &isDirectFromB); tree_MC->SetBranchAddress("trueLepFromSameB", &isFromSameB); tree_MC->SetBranchAddress("trueBDecMod", &BDecMod); tree_MC->SetBranchAddress("trueDDecMod", &mcDDecMod); tree_MC->SetBranchAddress("noExtraKorPi", &noExtKPi); tree_MC->SetBranchAddress("mcKaonMissID", &KMissID); tree_MC->SetBranchAddress("mcPiMissID", &PiMissID); tree_MC->SetBranchAddress("mcKPifromSameD", &KPiSameD); tree_MC->SetBranchAddress("DMass", &Dmass); tree_MC->SetBranchAddress("DMom", &pD); tree_MC->SetBranchAddress("DlLeptMom", &pLep); tree_MC->SetBranchAddress("DLcosBY", &cosBY); tree_MC->SetBranchAddress("AddLepMom", &pAddLep); int nSig_Peak(0), nBkg_Peak(0); int nBchD_Peak(0), nBchDstar_Peak(0), nBchD2star_Peak(0), nBchD0star_Peak(0); int nBchD1_Peak(0), nBchD1H_Peak(0), nBchDpi_Peak(0), nBchDstarpi_Peak(0); int nB0D_Peak(0), nB0Dstar_Peak(0), nB0D2star_Peak(0), nB0D0star_Peak(0); int nB0D1_Peak(0), nB0D1H_Peak(0), nB0Dpi_Peak(0), nB0Dstarpi_Peak(0); int nNonB_Peak(0), nNonB_realD_Peak(0), nLepMissID_Peak(0); int nNotDirectB_Peak(0), nNotFrmSameB_Peak(0); int nKMissID_Peak(0), nPiMissID_Peak(0), nKPiNotSameD_Peak(0); int nExtraKPi_Peak(0), nOther_Peak(0); int nSig_Side(0), nBkg_Side(0); int nBchD_Side(0), nBchDstar_Side(0), nBchD2star_Side(0), nBchD0star_Side(0); int nBchD1_Side(0), nBchD1H_Side(0), nBchDpi_Side(0), nBchDstarpi_Side(0); int nB0D_Side(0), nB0Dstar_Side(0), nB0D2star_Side(0), nB0D0star_Side(0); int nB0D1_Side(0), nB0D1H_Side(0), nB0Dpi_Side(0), nB0Dstarpi_Side(0); int nNonB_Side(0), nNonB_realD_Side(0), nLepMissID_Side(0); int nNotDirectB_Side(0), nNotFrmSameB_Side(0); int nKMissID_Side(0), nPiMissID_Side(0), nKPiNotSameD_Side(0); int nExtraKPi_Side(0), nOther_Side(0); Int_t nEvent =(Int_t)tree_MC->GetEntries(); // get number of events cout << "nEvent = " << nEvent << endl; int nSelEvent(0); for (Int_t i=0;iGetEntry(i); //read complete event in memory int nDl_total(0), nDl_sig(0), nDl_bkg(0); int nDl_side(0); for (Int_t j=0;jDlnu = " << nBchD_Peak << endl; outFile << "number of Bp->D*lnu = " << nBchDstar_Peak << endl; outFile << "number of Bp->D0**lnu = " << nBchD0star_Peak << endl; outFile << "number of Bp->D1**lnu = " << nBchD1_Peak << endl; outFile << "number of Bp->D1H**lnu = " << nBchD1H_Peak << endl; outFile << "number of Bp->D2**lnu = " << nBchD2star_Peak << endl; outFile << "number of Bp->DPilnu = " << nBchDpi_Peak << endl; outFile << "number of Bp->D*Pilnu = " << nBchDstarpi_Peak << endl; outFile << "number of B0->Dlnu = " << nB0D_Peak << endl; outFile << "number of B0->D*lnu = " << nB0Dstar_Peak << endl; outFile << "number of B0->D0**lnu = " << nB0D0star_Peak << endl; outFile << "number of B0->D1**lnu = " << nB0D1_Peak << endl; outFile << "number of B0->D1H**lnu = " << nB0D1H_Peak << endl; outFile << "number of B0->D2**lnu = " << nB0D2star_Peak << endl; outFile << "number of B0->DPilnu = " << nB0Dpi_Peak << endl; outFile << "number of B0->D*Pilnu = " << nB0Dstarpi_Peak << endl; outFile << "number of signal = " << nSig_Peak << endl; outFile << "number of non-B without real D = " << nNonB_Peak << endl; outFile << "number of non-B with real D = " << nNonB_realD_Peak << endl; outFile << "number of kaon miss ID = " << nKMissID_Peak << endl; outFile << "number of pi miss ID = " << nPiMissID_Peak << endl; outFile << "number of K and Pi not from same D = " << nKPiNotSameD_Peak << endl; outFile << "number of extra K or Pi from same D = " << nExtraKPi_Peak << endl; outFile << "number of lepton miss ID = " << nLepMissID_Peak << endl; outFile << "number of lepton not direct from B = " << nNotDirectB_Peak << endl; outFile << "number of lepton and D not from same B = " << nNotFrmSameB_Peak << endl; outFile << "number of other background = " << nOther_Peak << endl; outFile << "number of background = " << nBkg_Peak << endl; outFile << "Delta_S / S = " << SBRatio << endl; outFile << "Delta_S / S (sideband subtracted) = " << SBRatio_sub << endl; outFile << "-----------------------------------" << endl; outFile << "D mass side band" << endl; outFile << "number of Bp->Dlnu = " << nBchD_Side << endl; outFile << "number of Bp->D*lnu = " << nBchDstar_Side << endl; outFile << "number of Bp->D0**lnu = " << nBchD0star_Side << endl; outFile << "number of Bp->D1**lnu = " << nBchD1_Side << endl; outFile << "number of Bp->D1H**lnu = " << nBchD1H_Side << endl; outFile << "number of Bp->D2**lnu = " << nBchD2star_Side << endl; outFile << "number of Bp->DPilnu = " << nBchDpi_Side << endl; outFile << "number of Bp->D*Pilnu = " << nBchDstarpi_Side << endl; outFile << "number of B0->Dlnu = " << nB0D_Side << endl; outFile << "number of B0->D*lnu = " << nB0Dstar_Side << endl; outFile << "number of B0->D0**lnu = " << nB0D0star_Side << endl; outFile << "number of B0->D1**lnu = " << nB0D1_Side << endl; outFile << "number of B0->D1H**lnu = " << nB0D1H_Side << endl; outFile << "number of B0->D2**lnu = " << nB0D2star_Side << endl; outFile << "number of B0->DPilnu = " << nB0Dpi_Side << endl; outFile << "number of B0->D*Pilnu = " << nB0Dstarpi_Side << endl; outFile << "number of signal = " << nSig_Side << endl; outFile << "number of non-B without real D = " << nNonB_Side << endl; outFile << "number of non-B with real D = " << nNonB_realD_Side << endl; outFile << "number of kaon miss ID = " << nKMissID_Side << endl; outFile << "number of pi miss ID = " << nPiMissID_Side << endl; outFile << "number of K and Pi not from same D = " << nKPiNotSameD_Side << endl; outFile << "number of extra K or Pi from same D = " << nExtraKPi_Side << endl; outFile << "number of lepton miss ID = " << nLepMissID_Side << endl; outFile << "number of lepton not direct from B = " << nNotDirectB_Side << endl; outFile << "number of lepton and D not from same B = " << nNotFrmSameB_Side << endl; outFile << "number of other background = " << nOther_Side << endl; outFile << "number of background = " << nBkg_Side << endl; outFile.close(); // Open output file and write histograms in it. ###### TFile *f = new TFile(outHistoFileName, "Recreate"); TH1nDl_total->Write(); TH1nDl_sig->Write(); TH1nDl_bkg->Write(); f->Write(); f->Close(); }