#include #include gROOT->Reset(); // Setup file including parameters #include "histMk_3D_setup.h" void histMk_3D_B0B0_LMisID_D0KPi() { // Root macro to produce 3D histogram of B0B0 MC. // B0B0 MC is luminosity nomalized to OnPeak data. //########################################################### // Change these values to meet your condition //########################################################### TString RunNum("RunAll"); if (run == 1) RunNum = "Run1"; if (run == 2) RunNum = "Run2"; if (run == 3) RunNum = "Run3"; if (run == 4) RunNum = "Run4"; TString MCCorr("noCorr"); if (correctTrk) MCCorr ="effCorr"; // Name base of output files TString outFileNameBase("histo_3D_"+RunNum+"_"+MCCorr); // Info of output files TString out3DHistoName(outFileNameBase+"_B0B0_LMisID_D0KPi.root"); TString outInfoFileName(outFileNameBase+"_B0B0_LMisID_D0KPi.txt"); TString histTitle_peak("B0B0 to LMisID (D0Kpi) D mass peak"); TString histTitle_side("B0B0 to LMisID (D0Kpi) D mass sideband"); TString histTitle_sub("B0B0 to LMisID (D0Kpi) sideband subtracted"); // D decay mode selection int DDecMod_3D = DDecMod_D0KPi; // D mass range float DMass1 = DMass_D0KPi1; // lower edge of sideband float DMass2 = DMass_D0KPi2; // lower edge of D mass peak float DMass3 = DMass_D0KPi3; // upper edge of D mass peak float DMass4 = DMass_D0KPi4; // upper edge of sideband // Input files TString inFileName_Run1(baseDir_Run1+"/"+inFile_Run1_B0B0); int nStart_Run1 = nStart_Run1_B0B0; int nStop_Run1 = nStop_Run1_B0B0; TString inFileName_Run2(baseDir_Run2+"/"+inFile_Run2_B0B0); int nStart_Run2 = nStart_Run2_B0B0; int nStop_Run2 = nStop_Run2_B0B0; TString inFileName_Run3(baseDir_Run3+"/"+inFile_Run3_B0B0); int nStart_Run3 = nStart_Run3_B0B0; int nStop_Run3 = nStop_Run3_B0B0; TString inFileName_Run4(baseDir_Run4+"/"+inFile_Run4_B0B0); int nStart_Run4 = nStart_Run4_B0B0; int nStop_Run4 = nStop_Run4_B0B0; // Luminosity normalization factors double c_Run1 = c_Run1_B0B0; double c_Run2 = c_Run2_B0B0; double c_Run3 = c_Run3_B0B0; double c_Run4 = c_Run4_B0B0; double c_All = c_All_B0B0; //####################################################################### // Create D mass peak and sideband arrays, readin data and fill the arrays. cout << "starat B0B0ToLMisID\n"; cout << "start chain\n"; if (run == 1) { TChain * chain_3D = new TChain(ntpName); for (Int_t i=nStart_Run1; i<=nStop_Run1; i++) { chain_3D->Add(inFileName_Run1+"-"+i+".root"); } TTree * tree_3D = chain_3D; double conv = c_Run1; } else if (run == 2) { TChain * chain_3D = new TChain(ntpName); for (Int_t i=nStart_Run2; i<=nStop_Run2; i++) { chain_3D->Add(inFileName_Run2+"-"+i+".root"); } TTree * tree_3D = chain_3D; double conv = c_Run2; } else if (run == 3) { TChain * chain_3D = new TChain(ntpName); for (Int_t i=nStart_Run3; i<=nStop_Run3; i++) { chain_3D->Add(inFileName_Run3+"-"+i+".root"); } TTree * tree_3D = chain_3D; double conv = c_Run3; } else if (run == 4) { TChain * chain_3D = new TChain(ntpName); for (Int_t i=nStart_Run4; i<=nStop_Run4; i++) { chain_3D->Add(inFileName_Run4+"-"+i+".root"); } TTree * tree_3D = chain_3D; double conv = c_Run4; } else { TChain * chain_3D = new TChain(ntpName); for (Int_t i=nStart_Run1; i<=nStop_Run1; i++) { chain_3D->Add(inFileName_Run1+"-"+i+".root"); } for (Int_t i=nStart_Run2; i<=nStop_Run2; i++) { chain_3D->Add(inFileName_Run2+"-"+i+".root"); } for (Int_t i=nStart_Run3; i<=nStop_Run3; i++) { chain_3D->Add(inFileName_Run3+"-"+i+".root"); } for (Int_t i=nStart_Run4; i<=nStop_Run4; i++) { chain_3D->Add(inFileName_Run4+"-"+i+".root"); } TTree * tree_3D = chain_3D; double conv = c_All; } // Define and initialise arrays for 3D histo double num_peak[nbinsx][nbinsy][nbinsz]; double num_side[nbinsx][nbinsy][nbinsz]; for (int i=0; iSetBranchAddress("nDl", &nDl_3D); tree_3D->SetBranchAddress("DDecayMode", &DDecayMode_3D); tree_3D->SetBranchAddress("DMass", &DMass_3D); tree_3D->SetBranchAddress("noExtraKorPi", &noExtraKorPi_3D); tree_3D->SetBranchAddress("mcKaonMissID", &mcKaonMissID_3D); tree_3D->SetBranchAddress("mcPiMissID", &mcPiMissID_3D); tree_3D->SetBranchAddress("mcKPifromSameD", &mcKPifromSameD_3D); tree_3D->SetBranchAddress("mcLepMissID", &mcLepMissID_3D); tree_3D->SetBranchAddress("mcDirectLepFromB", &mcDirectLepFromB_3D); tree_3D->SetBranchAddress("trueBDecMod", &trueBDecMod_3D); tree_3D->SetBranchAddress("trueLepFromSameB", &trueLepFromSameB_3D); tree_3D->SetBranchAddress("trkEffCorr", &trkEffCorr_3D); tree_3D->SetBranchAddress("PIDCorr", &PIDCorr_3D); tree_3D->SetBranchAddress("mcW", &mcW_3D); tree_3D->SetBranchAddress(varx, &varx_3D); tree_3D->SetBranchAddress(vary, &vary_3D); tree_3D->SetBranchAddress(varz, &varz_3D); // Read out root-tuple entries and fill arrays Int_t nevent_3D =(Int_t)tree_3D->GetEntries(); // number of events cout << "number of 3D events = " << nevent_3D << endl; int numCand(0), numSelCand(0); int numCand_DDecMod(0), numCand_Index(0); for (Int_t i=0;iGetEntry(i); //read complete event in memory for (Int_t j=0;j=0 && yIndex>=0 && zIndex>=0) { numSelCand++; // Get FF correction factor double W_D = 1; if (DMass2SetBinContent(i+1,j+1,k+1,num_peak[i][j][k]); side->SetBinContent(i+1,j+1,k+1,num_side[i][j][k]); double peak3D = conv * num_peak[i][j][k]; double side3D = conv * num_side[i][j][k]; double sub3D = peak3D - side3D; double var3D = num_peak[i][j][k] + num_side[i][j][k]; double err3D = conv * sqrt(var3D); sub->SetBinContent(i+1,j+1,k+1,sub3D); sub->SetBinError(i+1,j+1,k+1,err3D); } } } //############################################################# // Open output file and write histograms in it. ###### cout <<"saving histograms to " << out3DHistoName << endl; TFile *f = new TFile(out3DHistoName, "Recreate"); peak->Write(); side->Write(); sub->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 = " << run << endl; if (run == 1) { outFile << " File name base = " << inFileName_Run1 << endl; outFile << " start number = " << nStart_Run1 << endl; outFile << " stop number = " << nStop_Run1 << endl; } else if (run == 2) { outFile << " File name base = " << inFileName_Run2 << endl; outFile << " start number = " << nStart_Run2 << endl; outFile << " stop number = " << nStop_Run2 << endl; } else if (run == 3) { outFile << " File name base = " << inFileName_Run3 << endl; outFile << " start number = " << nStart_Run3 << endl; outFile << " stop number = " << nStop_Run3 << endl; } else if (run == 4) { outFile << " File name base = " << inFileName_Run4 << endl; outFile << " start number = " << nStart_Run4 << endl; outFile << " stop number = " << nStop_Run4 << endl; } else { outFile << " File name base = " << inFileName_Run1 << endl; outFile << " start number = " << nStart_Run1 << endl; outFile << " stop number = " << nStop_Run1 << endl; outFile << " File name base = " << inFileName_Run2 << endl; outFile << " start number = " << nStart_Run2 << endl; outFile << " stop number = " << nStop_Run2 << endl; outFile << " File name base = " << inFileName_Run3 << endl; outFile << " start number = " << nStart_Run3 << endl; outFile << " stop number = " << nStop_Run3 << endl; outFile << " File name base = " << inFileName_Run4 << endl; outFile << " start number = " << nStart_Run4 << endl; outFile << " stop number = " << nStop_Run4 << endl; } outFile << "################" << endl; outFile << "Output files" << endl; outFile << " histograms : " << out3DHistoName << endl; outFile << " information : " << outInfoFileName << 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 before index selection = " << numCand_Index << endl; outFile << " number of candidates selected = " << numSelCand << endl; outFile << "################" << endl; outFile << "Luminosity normalization factor" << endl; outFile << " conv = " << conv << endl; outFile << "D decay mode selection" << endl; outFile << " DDecMod_3D = " << DDecMod_3D << endl; outFile << "D mass cut" << endl; outFile << " DMass1 = " << DMass1 << endl; outFile << " DMass2 = " << DMass2 << endl; outFile << " DMass3 = " << DMass3 << endl; outFile << " DMass4 = " << DMass4 << endl; outFile << "3 variables" << endl; outFile << " Variable1 = " << varx << endl; outFile << " Variable2 = " << vary << endl; outFile << " Variable3 = " << varz << endl; outFile << "################" << endl; outFile << "Do or do not tracking and PID correction" << endl; outFile << " correctTrk = " << correctTrk << endl; outFile << "track and PID correction modificatin factors" << endl; outFile << "modified correction = Corr * Modif" << endl; outFile << " trkCorrModif = " << trkCorrModif << endl; outFile << " PidCorrModif = " << PidCorrModif << endl; outFile.close(); }