void histMk_1D_DMass_uds() { #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_uds"); 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-998-BToDlnu-Run3-R16b"); int nStart = 1; int nStop = 282; //282 // 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 *Cont_D0 = new TH1D("Cont_D0","D mass (D0)",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 // Project trees treeMC->Project("Cont_D0","DMass",*cut_D0); treeMC->Project("Cont_Dch","DMass",*cut_Dch); // Open output file and write histograms in it. ###### TFile *f = new TFile(outHistoFileName, "Recreate"); Cont_D0->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(); }