void histMk_1D_DMass_cc() { #include #include gROOT->Reset(); // Root macro to produce D mass plots //####################################################### // Change these values to meet your condition //####################################################### // Output histogram name TString outFileNameBase("histo_1D_DMass_cc"); TString outHistoFileName(outFileNameBase+".root"); TString outTxtFileName(outFileNameBase+".txt"); // Info of input data/MC root files TString baseDir("/home1x/OtherMounts/hep03/khamano/R16b/Run3"); TString nameBase("SP-1005-BToDlnu-Run3-R16b"); int nStart = 1; int nStop = 307; //307 // Name of the root tree in the input root files TString ntpName("ntp2"); //################################################################### // Chain input root files. cout << "start chain\n"; TChain * chainMC = new TChain(ntpName); for (Int_t i=nStart; i<=nStop; i++) { chainMC->Add(baseDir+"/"+nameBase+"-"+i+".root"); } TTree * treeMC = chainMC; // Define histograms int nbin = 70; double xmin = 1.8; double xmax = 1.94; TH1D *RealD_D0 = new TH1D("RealD_D0","D mass (D0)",nbin, xmin,xmax); TH1D *Cont_D0 = new TH1D("Cont_D0","D mass (D0)",nbin, xmin,xmax); TH1D *RealD_Dch = new TH1D("RealD_Dch","D mass (Dch)",nbin, xmin,xmax); TH1D *Cont_Dch = new TH1D("Cont_Dch","D mass (Dch)",nbin, xmin,xmax); // Define cuts #################### // Cuts on D decay modes: TCut * cut_D0 = new TCut("DDecayMode==1"); //D0 -> Kpi TCut * cut_Dch = new TCut("DDecayMode==5"); //Dch -> Kpipi // Cotinuum background TCut * cut_Cont = new TCut("noExtraKorPi==0 || mcKaonMissID==1 || mcPiMissID==1 || mcKPifromSameD==0"); // RealD background TCut * cut_RealD = new TCut("noExtraKorPi==1 && mcKaonMissID==0 && mcPiMissID==0 && mcKPifromSameD==1"); // Project trees treeMC->Project("RealD_D0","DMass",*cut_D0&&*cut_RealD); treeMC->Project("Cont_D0","DMass",*cut_D0&&*cut_Cont); treeMC->Project("RealD_Dch","DMass",*cut_Dch&&*cut_RealD); treeMC->Project("Cont_Dch","DMass",*cut_Dch&&*cut_Cont); // Open output file and write histograms in it. ###### TFile *f = new TFile(outHistoFileName, "Recreate"); RealD_D0->Write(); Cont_D0->Write(); RealD_Dch->Write(); Cont_Dch->Write(); f->Write(); f->Close(); //####################################################################### // Open output txt file and save parameters. ##### ofstream outFile(outTxtFileName); //open output file if (!outFile) { cout << "Cannot open file " << outFile << endl; } outFile.setf(ios::fixed); outFile.setf(ios::showpoint); outFile << "outFileNameBase = " << outFileNameBase << endl; outFile.close(); }