void PhaseSpace() { if (!gROOT->GetClass("TGenPhaseSpace")) gSystem->Load("libPhysics"); TLorentzVector target(0.0, 0.0, 0.0, 0.938); TLorentzVector beam(0.0, 0.0, .65, .65); TLorentzVector W = beam + target; //(Momentum, Energy units are Gev/C, GeV) Double_t masses[3] = { 0.938, 0.139, 0.139} ; TGenPhaseSpace event; event.SetDecay(W, 3, masses); TH2F *h2 = new TH2F("h2","h2", 50,1.1,1.8, 50,1.1,1.8); for (Int_t n=0;n<100000;n++) { Double_t weight = event.Generate(); TLorentzVector *pProton = event.GetDecay(0); TLorentzVector *pPip = event.GetDecay(1); TLorentzVector *pPim = event.GetDecay(2); TLorentzVector pPPip = *pProton + *pPip; TLorentzVector pPPim = *pProton + *pPim; h2->Fill(pPPip.M2() ,pPPim.M2() ,weight); } h2->Draw(); }
Int_t Program::Code() { /* Note that TFGenPhaseSpace, as per LHCb standard, is in GeV. Hence all the * calculations and graphs hereonin are in GeV. */ if (!gROOT->GetClass("TGenPhaseSpace")) gSystem->Load("libPhysics"); // get and load TGenPhaseSpace class psiInvMass = new TH1F("#psi(3770) Decay", "#psi(3770) Meson Decay;m(D^{0}#bar{D^{0}}) [GeV/c^{2}];", 50, 3, 4); // Initialise histogram for plot later TLorentzVector Psi_3770(0.0, 0.0, 0.0, PSIMASS); // Parent Psi 4-momentum in rest frame Double_t masses[2] = { DMASS, DMASS }; // Product particle mass array TGenPhaseSpace event; // Declare event of type class TGenPhaseSpace event.SetDecay(Psi_3770, 2, masses); // Set up decay parents and products for (Int_t n = 0; n < 1000000; n++) // Loop 100,000 times { Double_t weight = event.Generate(); // Produce weighting for each event TLorentzVector *D_0 = event.GetDecay(0); TLorentzVector *D_0bar = event.GetDecay(1); // Get product 4-vectors from GteDecay() TLorentzVector D_0D_0bar = *D_0 + *D_0bar; // Add 4-vectors together, for purpose of calculating invariant mass psiInvMass->Fill(D_0D_0bar.M(), weight); // Fill histogram with invariant mass } TCanvas* PsiInvMassCanv = new TCanvas("PsiInvMassCanv", "PsiInvMassCanv", 500, 500); psiInvMass->GetXaxis()->CenterTitle(); psiInvMass->GetXaxis()->SetTitleOffset(1.25); psiInvMass->Draw(); PsiInvMassCanv->Print("../graphs/TwoBodyDecay.eps"); delete PsiInvMassCanv; delete psiInvMass; return 0; }
void drawing_pion_decay(){ double Pi_lifetime = 0.26033e-6; //s double c = 3e8;//m/s TCanvas *c1 = new TCanvas("test", "test"); TRandom *r = new TRandom(); TView *view = TView::CreateView(1, 0, 0); view->ShowAxis(); view->SetRange(-5, -5, 0, 5, 5, 10); for (int i = 0; i < 100; ++i) { double px = 0.3; double py = 0.3; double pz = -1; // GeV double energy = sqrt(px*px+py*py+pz*pz+M_pion*M_pion); //life time double t = r->Exp(Pi_lifetime); //decay length double gamma = energy/M_pion; double length = c*t*gamma/1e3; // decay position double vx = 0; double vy = 0; double vz = 10 - length; TLorentzVector pion(px, py, pz, energy); double decay_particle_mass[2] = {M_muon, M_neu}; TGenPhaseSpace event; event.SetDecay(pion, 2, decay_particle_mass); event.Generate(); TLorentzVector Muon = *(event.GetDecay(0)); TLorentzVector Neu = *(event.GetDecay(1)); plot_particle(Muon, vx, vy, vz, 2); plot_particle(Neu, vx, vy, vz, 4); } }
void recursive_inter_with_air(){ TFile *f1 = new TFile("muon.root", "recreate"); TCanvas *c1 = new TCanvas("test", "test", 600, 700); TH1F * mu_c_1 = new TH1F("mu_c_1", "mu_c_1", 100, 0, 500); TH1F * mu_c_2 = new TH1F("mu_c_2", "mu_c_2", 100, 0, 500); TH1F * mu_c_3 = new TH1F("mu_c_3", "mu_c_3", 100, 0, 500); fn_muon_dxde = new TF1("f1", dxde_muon, M_mu, 1000, 1); TNtuple * ntuple = new TNtuple("ntuple", "ntuple", "nobs:detz:theta:press"); // TNtuple *ntuple = new TNtuple("ntuple", "ntuple", "id:flag:e:px:py:pz:x:y:z"); r = new TRandom(); // r ->SetSeed(12232); for (int ievertex_nt = 0; ievertex_nt < 500; ievertex_nt++) { n_particle = 0; // init muon conunter int mu_counter1 = 0; int mu_counter2 = 0; int mu_counter3 = 0; double E = 1000; // GeV double theta = 0; // double theta = acos(r->Rndm()); double phi = r->Rndm()*pi*2; double x = 0, y = 0, z = 1.0e10; //infinity double vertex_z, vertex_x, vertex_y; //km Get_Int_Posi(pdg_proton_p, theta, phi, x, y, z, vertex_x, vertex_y, vertex_z); Hillas_Split(pdg_proton_p, E, theta, phi, vertex_x, vertex_y, vertex_z); double proton_threshold = 10; double pion_threshold = 10; int i_particle = 0; while(i_particle < n_particle){ int id = Ptcl_bank[i_particle].id; int flag = Ptcl_bank[i_particle].flag; double e = Ptcl_bank[i_particle].e; double x = Ptcl_bank[i_particle].vertex_x; double y = Ptcl_bank[i_particle].vertex_y; double z = Ptcl_bank[i_particle].vertex_z; if (id == pdg_proton_p && flag == 1 && e > proton_threshold) { Get_Int_Posi(id, theta, phi, x, y, z, vertex_x, vertex_y, vertex_z); if (vertex_z > 0) { Hillas_Split(id, e, theta, phi, vertex_x, vertex_y, vertex_z); Ptcl_bank[i_particle].flag = 0; } } if (id == pdg_pion_p &&flag == 1){ Get_Int_Posi(id, theta, phi, x, y, z, vertex_x, vertex_y, vertex_z) ; double l_to_interaction = sqrt((vertex_x-x)*(vertex_x-x)+(vertex_y-y)*(vertex_y-y)+(vertex_z-z)*(vertex_z-z)); double l_to_decay = get_decay_length(pdg_pion_p, tau_pion, e); if (l_to_decay>l_to_interaction){ if (vertex_z > 0){ Hillas_Split(id, e, theta, phi, vertex_x, vertex_y, vertex_z); Ptcl_bank[i_particle].flag = 0; } }else{ // pion decay Ptcl_bank[i_particle].flag = 0; double px = Ptcl_bank[i_particle].px; double py = Ptcl_bank[i_particle].py; double pz = Ptcl_bank[i_particle].pz; // GeV TLorentzVector pion(px, py, pz, e); double decay_particle_mass[2] = {M_mu, M_neu}; TGenPhaseSpace event; event.SetDecay(pion, 2, decay_particle_mass); event.Generate(); TLorentzVector Muon = *(event.GetDecay(0)); TLorentzVector Neu = *(event.GetDecay(1)); double mu_theta = Muon.Theta(); double mu_phi = Muon.Phi(); if (mu_theta>pi/2.) { double mu_E = Muon.E(); double muon_decay_time = r ->Exp(tau_muon); double muon_decay_length = get_decay_length(pdg_muon_n, tau_muon, mu_E); float det_x = 0; float det_y = 0; float det_z = 0; mu_counter1++; double l_mu_vtx_to_det = sqrt(pow(vertex_x-det_x,2)+pow(vertex_y-det_y,2)+pow(vertex_z-det_z,2)); // cout << "MuE" << mu_E << " Mass" <<M_mu<< " dl" << muon_decay_length << " lvd" << l_mu_vtx_to_det << endl; if (muon_decay_length > l_mu_vtx_to_det) { mu_counter2++; double mu_stop_x; double mu_stop_y; double mu_stop_z; get_muon_stop_position(mu_E, mu_theta, mu_phi, vertex_x, vertex_y, vertex_z, mu_stop_x, mu_stop_y, mu_stop_z); double l_muon_stop = sqrt(pow(vertex_x-mu_stop_x,2)+pow(vertex_y-mu_stop_y,2)+pow(vertex_z-mu_stop_z,2)); // cout << l_muon_stop << " " << l_mu_vtx_to_det <<endl; if (l_muon_stop > l_mu_vtx_to_det) { mu_counter3++; } } } } } i_particle++; } mu_c_1 ->Fill(mu_counter1); mu_c_2 ->Fill(mu_counter2); mu_c_3 ->Fill(mu_counter3); // for (int i_particle = 0; i_particle < n_particle; ++i_particle){ // int id = Ptcl_bank[i_particle].id; // int flag = Ptcl_bank[i_particle].flag; // double e = Ptcl_bank[i_particle].e; // double px = Ptcl_bank[i_particle].px; // double py = Ptcl_bank[i_particle].py; // double pz = Ptcl_bank[i_particle].pz; // double x = Ptcl_bank[i_particle].vertex_x; // double y = Ptcl_bank[i_particle].vertex_y; // double z = Ptcl_bank[i_particle].vertex_z; // ntuple->Fill(id, flag, e, px, py, pz, x, y, z); // } } mu_c_3 ->Draw(); mu_c_2 ->SetLineColor(2); mu_c_2 ->Draw("same"); mu_c_1 ->SetLineColor(4); mu_c_1 ->Draw("same"); // ntuple->Draw("z"); }
/** * The main function. */ int main(int argc, char **argv) { int seed = 1234; string output_filename("JakeFitResult.root"); string output_directory("./executables/DalitzFit/"); string input_filename("JPSIPSMC.ACC.root"); string input_directory("./executables/DalitzFit/"); string output_file_suffix(""); if (argc > 1) output_directory = argv[1]; if (argc > 2) output_filename = argv[2]; if (argc > 3) input_directory = argv[3]; if (argc > 4) input_filename = argv[4]; if (argc > 5) seed = atoi(argv[5]); if (argc > 6) output_file_suffix = argv[6]; // create correct output file name boost::filesystem::path input_file(input_filename); string input_file_path = input_directory + "/" + input_filename; if (output_file_suffix != "") input_file_path = input_directory + "/" + input_file.stem().string() + "_" + output_file_suffix + input_file.extension().string(); Logging log("log", boost::log::trivial::debug); //initialize logging BOOST_LOG_TRIVIAL(info)<< " ComPWA Copyright (C) 2013 Mathias Michel "; BOOST_LOG_TRIVIAL(info)<< " This program comes with ABSOLUTELY NO WARRANTY; for details see license.txt"; BOOST_LOG_TRIVIAL(info)<< std::endl; DalitzKinematics* kin = dynamic_cast<DalitzKinematics*>(DalitzKinematics::createInstance( "jpsi", "gamma", "pi0", "pi0")); //DPKinematics kin("J/psi","gamma","pi0","pi0"); //DPKinematics kin("D0","gamma","K-","K+"); //static dataPoint* point = dataPoint::instance(kin); bool useFctTree = false, resultGen = true; const char* pPath = getenv("COMPWA_DIR"); std::string path = ""; try { path = std::string(pPath); } catch (std::logic_error& ex) { BOOST_LOG_TRIVIAL(error)<<"Environment Variable COMPWA_DIR not set?"<<std::endl; } std::string resoFile = path + "/executables/DalitzFit/Jake_ypipi.xml"; boost::property_tree::ptree pt; read_xml(resoFile, pt, boost::property_tree::xml_parser::trim_whitespace); auto fitAmpPtr = new AmpSumIntensity("amp",normStyle::none, std::shared_ptr<Efficiency>(new UnitEfficiency()), nFitEvents); fitAmpPtr->Configure(pt); std::shared_ptr<Amplitude> amps( fitAmpPtr ); BOOST_LOG_TRIVIAL(info)<< "Load Modules"; std::string file = "executables/DalitzFit/JPSIDATA.ACC.root"; std::shared_ptr<JakeReader> myReader( new JakeReader(file, "kin")); //std::shared_ptr<RootReader> myReader( //new RootReader(input_file_path, "data")); myReader->resetWeights(); //setting weights to 1 std::shared_ptr<JakeReader> myPHSPReader( new JakeReader(input_file_path, "kin")); myPHSPReader->setEfficiency(shared_ptr<Efficiency>(new UnitEfficiency())); //setting efficiency to 1 //std::shared_ptr<Amplitude> amps(new AmpSumIntensity(M, Br, m1, m2, m3,"J/psi","gamma","pi0","pi0", ini)); // Initiate parameters ParameterList par; std::shared_ptr<Optimizer::ControlParameter> esti; amps->FillParameterList(par); //perfect startvalues esti = MinLogLH::createInstance(amps, myReader, myPHSPReader, nStartEvent, nFitEvents); MinLogLH* contrPar = dynamic_cast<MinLogLH*>(&*(esti->Instance())); std::shared_ptr<FunctionTree> tree; if (useFctTree) { contrPar->setUseFunctionTree(1); tree = contrPar->getTree(); } // if(useFctTree){//using tree? // esti = MinLogLH::createInstance(amps, myReader, myPHSPReader, nStartEvent, nFitEvents); // }else{ // BOOST_LOG_TRIVIAL(debug)<<"allMasses: try to get MassContainer..."; // allMasses myEvtMasses(myReader->getMasses(nStartEvent,nFitEvents)); // allMasses myPhspMasses(myPHSPReader->getMasses(nStartEvent,nFitEvents)); // BOOST_LOG_TRIVIAL(debug)<<"EvtMasses: "<< myEvtMasses.nEvents <<" events and "<< myEvtMasses.nInvMasses <<" inv masses"; // BOOST_LOG_TRIVIAL(debug)<<"PHSPMasses: "<< myPhspMasses.nEvents <<" events and "<< myPhspMasses.nInvMasses <<" inv masses"; //// physicsTree = amps->functionTree(myPhspMasses,myEvtMasses); // allMasses emptyMasses; //// amps->iniFunctionTree(myEvtMasses,myPhspMasses,emptyMasses); //// physicsTree = amps->getPhysicsTree(); // if(!physicsTree){ // BOOST_LOG_TRIVIAL(error)<<"Physics Trees not setup correctly, quitting"; // return 0; // } //// phspTree = amps->getPhspTree(); // if(!phspTree){ // BOOST_LOG_TRIVIAL(error)<<"Phsp Trees not setup correctly, quitting"; // return 0; // } // // BOOST_LOG_TRIVIAL(debug)<<"Check Trees: "; // if(!physicsTree->sanityCheck()) return 0; // if(!phspTree->sanityCheck()) return 0; // //BOOST_LOG_TRIVIAL(info)<<physicsTree<<std::endl; // //BOOST_LOG_TRIVIAL(info)<<phspTree<<std::endl; // physicsTree->recalculate(); // phspTree->recalculate(); // BOOST_LOG_TRIVIAL(debug)<<physicsTree<<std::endl; // BOOST_LOG_TRIVIAL(debug)<<phspTree<<std::endl; // BOOST_LOG_TRIVIAL(debug)<<"Evt Tree: "<<(std::dynamic_pointer_cast<DoubleParameter>(physicsTree->head()->getValue()))->GetValue(); // BOOST_LOG_TRIVIAL(debug)<<"Phsp Tree: "<<(std::dynamic_pointer_cast<DoubleParameter>(phspTree->head()->getValue()))->GetValue(); // BOOST_LOG_TRIVIAL(info)<<"Trees are set up"<<std::endl; // // esti = MinLogLH::createInstance(physicsTree, phspTree, myEvtMasses.nEvents); // dataPoint myPoint(myReader->getEvent(0)); // std::shared_ptr<TreeNode> LogNode = (physicsTree->head()->getChildren())[0]; // std::shared_ptr<TreeNode> IntNode = (LogNode->getChildren())[0]; // std::shared_ptr<TreeNode> AmpNodeEff = (IntNode->getChildren())[0]; // std::shared_ptr<TreeNode> AmpNode = (AmpNodeEff->getChildren())[1]; // std::shared_ptr<TreeNode> ResNode = (AmpNode->getChildren())[0]; // std::shared_ptr<TreeNode> BWNode = (ResNode->getChildren())[0]; // std::shared_ptr<TreeNode> ADNode = (ResNode->getChildren())[2]; // // std::shared_ptr<MultiComplex> resoChild = std::dynamic_pointer_cast<MultiComplex>( ResNode->getValue() ); // std::shared_ptr<MultiDouble> intensChild = std::dynamic_pointer_cast<MultiDouble>( IntNode->getValue() ); // std::shared_ptr<MultiComplex> bwChild = std::dynamic_pointer_cast<MultiComplex>( BWNode->getValue() ); // std::shared_ptr<MultiDouble> adChild = std::dynamic_pointer_cast<MultiDouble>( ADNode->getValue() ); // std::shared_ptr<MultiComplex> ampChild = std::dynamic_pointer_cast<MultiComplex>( AmpNode->getValue() ); // // BOOST_LOG_TRIVIAL(debug) << "InvMasses first Evt from dataPoint: \t" << myPoint.getVal("m23sq") << " \t " << myPoint.getVal("m13sq"); // BOOST_LOG_TRIVIAL(debug) << "InvMasses first Evt from allMasses: \t" << (myEvtMasses.masses_sq[std::make_pair(2,3)])[0] << " \t " << (myEvtMasses.masses_sq[std::make_pair(1,3)])[0]; // // BOOST_LOG_TRIVIAL(debug) << "First BW first Evt classical: \t" << (amps->getFirstBW(myPoint,par)); // BOOST_LOG_TRIVIAL(debug) << "First BW first Evt from tree: \t" << (bwChild->GetValue()*adChild->GetValue()); // // BOOST_LOG_TRIVIAL(debug) << "FirstReso first Evt classical: \t" << amps->getFirstReso(myPoint,par); // BOOST_LOG_TRIVIAL(debug) << "FirstReso first Evt from tree: \t" << resoChild->GetValue(); // // BOOST_LOG_TRIVIAL(debug) << "First Amp first Evt classical: \t" << amps->getFirstAmp(myPoint,par); // BOOST_LOG_TRIVIAL(debug) << "First Amp first Evt from tree: \t" << ampChild->GetValue(); // // BOOST_LOG_TRIVIAL(debug) << "Intensity of first data event classical: \t" << amps->intensity(myPoint,par).GetParameterValue(0); // BOOST_LOG_TRIVIAL(debug) << "Intensity of first data event from tree: \t" << intensChild->GetValue(); // BOOST_LOG_TRIVIAL(debug)<<"Finish consistency checks"<<std::endl; // } //std::shared_ptr<ControlParameter> esti = MinLogLH::createInstance(amps, myReader, myPHSPReader); //std::shared_ptr<Estimator> esti(new MinLogLH(amps, myReader, myPHSPReader)); std::shared_ptr<Optimizer::Optimizer> opti(new Optimizer::Minuit2::MinuitIF(esti, par)); ParameterList test; /*if(useFctTree) if(!amps->functionTree(test)) return 1;*/ //return 0; BOOST_LOG_TRIVIAL(info)<< "LH with optimal parameters: " << esti->controlParameter(par); if (useFctTree) BOOST_LOG_TRIVIAL(info)<<tree; //exit(1); double startInt[par.GetNDouble()], optiInt[par.GetNDouble()]; for (unsigned int i = 0; i < par.GetNDouble(); i++) { std::shared_ptr<DoubleParameter> tmp = par.GetDoubleParameter(i); optiInt[i] = tmp->GetValue(); //if (/*i < 2 ||*/ i > 10 /*|| i%4==2 || i%4==3 */) { //omega's and f0 fixed //if(i<2 || i>3 || i%2==1){ //omega's and f0 fixed // tmp->FixParameter(true); //} else { // tmp->FixParameter(true); if(i==5) tmp->FixParameter(false); // BOOST_LOG_TRIVIAL(debug)<< *tmp; //tmp->SetValue(tmp->GetValue()+0.5); ///((i+1))); // tmp->SetError(tmp->GetValue()); // if (!tmp->GetValue()) // tmp->SetError(1.); //} startInt[i] = tmp->GetValue(); } BOOST_LOG_TRIVIAL(info)<< "LH with following parameters: " << esti->controlParameter(par); for (unsigned int i = 0; i < par.GetNDouble(); i++) { BOOST_LOG_TRIVIAL(info)<< par.GetDoubleParameter(i)->GetName() << " = " << par.GetDoubleParameter(i)->GetValue(); } // std::cout << "Fixing 5 of 7 parameters " << std::endl; //for(unsigned int i=2; i<par.GetNDouble(); i++){ // par.GetDoubleParameter(i).FixParameter(true); // } BOOST_LOG_TRIVIAL(info)<< "Start Fit"; std::shared_ptr<FitResult> genResult = opti->exec(par); BOOST_LOG_TRIVIAL(info)<< "Final LH = " << genResult->getResult(); BOOST_LOG_TRIVIAL(info)<< "Optimierte intensitäten: " << esti->controlParameter(par); for (unsigned int i = 0; i < par.GetNDouble(); i++) { BOOST_LOG_TRIVIAL(info)<< par.GetDoubleParameter(i)->GetName() << " = " << par.GetDoubleParameter(i)->GetValue() << " [ start: " << startInt[i] << " ," << " optimal: " << optiInt[i] << " ]"; } /*AmplitudeSetup iniTrue(resoFile); //put start parameters here std::shared_ptr<Amplitude> trueAmp( new AmpSumIntensity(iniTrue, AmpSumIntensity::normStyle::none, std::shared_ptr<Efficiency>(new UnitEfficiency()), myReader->getNEvents())); ParameterList truePar; trueAmp->fillStartParVec(truePar); //true values genResult->setTrueParameters(truePar); genResult->print(); amps->printFractions();*/ string output_file_path = output_directory + "/fitresult.txt"; if (output_file_suffix != "") output_file_path = output_directory + "/fitresult_" + output_file_suffix + ".txt"; //genResult->writeText(output_file_path); output_file_path = output_directory + "/simplefitresult.txt"; if (output_file_suffix != "") output_file_path = output_directory + "/simplefitresult_" + output_file_suffix + ".txt"; //genResult->writeSimpleText(output_file_path); // if(useFctTree){ // BOOST_LOG_TRIVIAL(debug)<<physicsTree<<std::endl; // BOOST_LOG_TRIVIAL(debug)<<phspTree<<std::endl; // } if (!resultGen) return 0; //Plot result TH2D* bw12 = new TH2D("bw12", "inv. mass-sq of particles 1&2 Generated", 1000, 0., 10., 1000, 0., 10.); bw12->GetXaxis()->SetTitle("m_{12}^{2} / GeV^{2}"); bw12->GetXaxis()->CenterTitle(); bw12->GetYaxis()->SetTitle("#"); bw12->GetYaxis()->CenterTitle(); TH2D* bw13 = new TH2D("bw13", "inv. mass-sq of particles 1&3 Generated", 1000, 0., 10., 1000, 0., 10.); bw13->GetXaxis()->SetTitle("m_{13}^{2} / GeV^{2}"); bw13->GetXaxis()->CenterTitle(); bw13->GetYaxis()->SetTitle("#"); bw13->GetYaxis()->CenterTitle(); TH2D* bw23 = new TH2D("bw23", "inv. mass-sq of particles 2&3 Generated", 1000, 0., 10., 1000, 0., 10.); bw23->GetXaxis()->SetTitle("m_{23}^{2} / GeV^{2}"); bw23->GetXaxis()->CenterTitle(); bw23->GetYaxis()->SetTitle("#"); bw23->GetYaxis()->CenterTitle(); JakeReader myReaderPHSP(input_file_path, "kin"); unsigned int maxEventsPHSP = myReaderPHSP.getNEvents(); //double masssq12PHSP, masssq13PHSP, masssq23PHSP; TH2D* bw12PHSP = new TH2D("bw12PHSP", "inv. mass-sq of particles 1&2 PHSP", 1000, 0., 10., 1000, 0., 10.); bw12PHSP->GetXaxis()->SetTitle("m_{12}^{2} / GeV^{2}"); bw12PHSP->GetXaxis()->CenterTitle(); bw12PHSP->GetYaxis()->SetTitle("#"); bw12PHSP->GetYaxis()->CenterTitle(); TH2D* bw13PHSP = new TH2D("bw13PHSP", "inv. mass-sq of particles 1&3 PHSP", 1000, 0., 10., 1000, 0., 10.); bw13PHSP->GetXaxis()->SetTitle("m_{13}^{2} / GeV^{2}"); bw13PHSP->GetXaxis()->CenterTitle(); bw13PHSP->GetYaxis()->SetTitle("#"); bw13PHSP->GetYaxis()->CenterTitle(); TH2D* bw23PHSP = new TH2D("bw23PHSP", "inv. mass-sq of particles 2&3 PHSP", 1000, 0., 10., 1000, 0., 10.); bw23PHSP->GetXaxis()->SetTitle("m_{23}^{2} / GeV^{2}"); bw23PHSP->GetXaxis()->CenterTitle(); bw23PHSP->GetYaxis()->SetTitle("#"); bw23PHSP->GetYaxis()->CenterTitle(); TH2D* bw12FIT = new TH2D("bw12FIT", "inv. mass-sq of particles 1&2 FitResult", 1000, 0., 10., 1000, 0., 10.); bw12FIT->GetXaxis()->SetTitle("m_{12}^{2} / GeV^{2}"); bw12FIT->GetXaxis()->CenterTitle(); bw12FIT->GetYaxis()->SetTitle("#"); bw12FIT->GetYaxis()->CenterTitle(); TH2D* bw13FIT = new TH2D("bw13FIT", "inv. mass-sq of particles 1&3 FitResult", 1000, 0., 10., 1000, 0., 10.); bw13FIT->GetXaxis()->SetTitle("m_{13}^{2} / GeV^{2}"); bw13FIT->GetXaxis()->CenterTitle(); bw13FIT->GetYaxis()->SetTitle("#"); bw13PHSP->GetYaxis()->CenterTitle(); TH2D* bw23FIT = new TH2D("bw23FIT", "inv. mass-sq of particles 2&3 FitResult", 1000, 0., 10., 1000, 0., 10.); bw23FIT->GetXaxis()->SetTitle("m_{23}^{2} / GeV^{2}"); bw23FIT->GetXaxis()->CenterTitle(); bw23FIT->GetYaxis()->SetTitle("#"); bw23FIT->GetYaxis()->CenterTitle(); TH2D* bw12DIFF = new TH2D("bw12DIFF", "inv. mass-sq of particles 1&2 FitResult", 1000, 0., 10., 1000, 0., 10.); bw12DIFF->GetXaxis()->SetTitle("m_{12}^{2} / GeV^{2}"); bw12DIFF->GetXaxis()->CenterTitle(); bw12DIFF->GetYaxis()->SetTitle("#"); bw12DIFF->GetYaxis()->CenterTitle(); TH2D* bw13DIFF = new TH2D("bw13DIFF", "inv. mass-sq of particles 1&3 FitResult", 1000, 0., 10., 1000, 0., 10.); bw13DIFF->GetXaxis()->SetTitle("m_{13}^{2} / GeV^{2}"); bw13DIFF->GetXaxis()->CenterTitle(); bw13DIFF->GetYaxis()->SetTitle("#"); bw13PHSP->GetYaxis()->CenterTitle(); TH2D* bw23DIFF = new TH2D("bw23DIFF", "inv. mass-sq of particles 2&3 FitResult", 1000, 0., 10., 1000, 0., 10.); bw23DIFF->GetXaxis()->SetTitle("m_{23}^{2} / GeV^{2}"); bw23DIFF->GetXaxis()->CenterTitle(); bw23DIFF->GetYaxis()->SetTitle("#"); bw23DIFF->GetYaxis()->CenterTitle(); double masssq12, masssq13, masssq23; for (unsigned int i = 0; i < myReader->getNEvents(); i++) { Event event(myReader->getEvent(i)); //myReader.getEvent(-1, a, b, masssq); //if(!myReader.getEvent(i, event)) continue; TODO: try exception if (!event.getNParticles() == 3) continue; //if(!event) continue; //cout << "Event: \t" << i << "\t NParticles: \t" << event.getNParticles() << endl; const Particle &a(event.getParticle(0)); const Particle &b(event.getParticle(1)); const Particle &c(event.getParticle(2)); masssq12 = pow(a.E + b.E, 2) - pow(a.px + b.px, 2) - pow(a.py + b.py, 2) - pow(a.pz + b.pz, 2); masssq13 = pow(a.E + c.E, 2) - pow(a.px + c.px, 2) - pow(a.py + c.py, 2) - pow(a.pz + c.pz, 2); masssq23 = pow(b.E + c.E, 2) - pow(b.px + c.px, 2) - pow(b.py + c.py, 2) - pow(b.pz + c.pz, 2); bw12->Fill(masssq12, masssq13); bw13->Fill(masssq13, masssq12); bw23->Fill(masssq23, masssq12); } // TH2D* bw12DIFF = (TH2D*)bw12->Clone("bw12DIFF"); // TH2D* bw13DIFF = (TH2D*)bw13->Clone("bw13DIFF"); // TH2D* bw23DIFF = (TH2D*)bw23->Clone("bw23DIFF"); for (unsigned int i = 0; i < maxEventsPHSP; i++) { Event event(myReaderPHSP.getEvent(i)); //myReader.getEvent(-1, a, b, masssq); //if(!myReader.getEvent(i, event)) continue; TODO: try exception if (!event.getNParticles() == 3) continue; //if(!event) continue; //cout << "Event: \t" << i << "\t NParticles: \t" << event.getNParticles() << endl; const Particle &a(event.getParticle(0)); const Particle &b(event.getParticle(1)); const Particle &c(event.getParticle(2)); masssq12 = pow(a.E + b.E, 2) - pow(a.px + b.px, 2) - pow(a.py + b.py, 2) - pow(a.pz + b.pz, 2); masssq13 = pow(a.E + c.E, 2) - pow(a.px + c.px, 2) - pow(a.py + c.py, 2) - pow(a.pz + c.pz, 2); masssq23 = pow(b.E + c.E, 2) - pow(b.px + c.px, 2) - pow(b.py + c.py, 2) - pow(b.pz + c.pz, 2); bw12PHSP->Fill(masssq12, masssq13); bw13PHSP->Fill(masssq13, masssq12); bw23PHSP->Fill(masssq23, masssq12); vector<double> x; x.push_back(sqrt(masssq23)); x.push_back(sqrt(masssq13)); x.push_back(sqrt(masssq12)); //bw12FIT->Fill(masssq12,masssq13,1000*amps->intensity(x,par)); // bw13FIT->Fill(masssq13,masssq12,1000*amps->intensity(x,par)); // bw23FIT->Fill(masssq23,masssq12,1000*amps->intensity(x,par)); } //Generation TRandom3 rando; TLorentzVector W(0.0, 0.0, 0.0, M); //= beam + target; //(Momentum, Energy units are Gev/C, GeV) Double_t masses[3] = { m1, m2, m2 }; TGenPhaseSpace event; event.SetDecay(W, 3, masses); TLorentzVector *pGamma, *pPip, *pPim, pPm23, pPm13, pPm12; double weight, m23sq, m13sq, m12sq, maxTest = 0; ParameterList paras(par); if (useFctTree) { paras.RemoveDouble("ma"); paras.RemoveDouble("mb"); paras.RemoveDouble("mc"); } BOOST_LOG_TRIVIAL(info)<< "Einschwingen"; unsigned int schwingFactor = 10; if (myReader->getNEvents() < 1000) schwingFactor = 1000; for (unsigned int schwing = 0; schwing < schwingFactor * myReader->getNEvents(); schwing++) { weight = event.Generate(); pGamma = event.GetDecay(0); pPip = event.GetDecay(1); pPim = event.GetDecay(2); pPm23 = *pPim + *pPip; pPm13 = *pGamma + *pPim; pPm12 = *pGamma + *pPip; m23sq = pPm23.M2(); m13sq = pPm13.M2(); m12sq = pPm12.M2(); dataPoint point; try{ Kinematics::instance()->FillDataPoint(0,1,m23sq,m13sq,point); } catch (BeyondPhsp& ex){ continue; } // m12sq = kin.getThirdVariableSq(m23sq,m13sq); //point->setMsq(3,m12sq); point->setMsq(4,m13sq); point->setMsq(5,m23sq); // m12sq=M*M+m1*m1+m2*m2+m3*m3-m13sq-m23sq; if (std::fabs(m12sq - kin->getThirdVariableSq(m23sq, m13sq)) > 0.01) { std::cout << m12sq << " " << kin->getThirdVariableSq(m23sq, m13sq) << std::endl; std::cout << " " << m23sq << " " << m13sq << " " << m12sq << std::endl; } //call physics module vector<double> x; x.push_back(sqrt(m23sq)); x.push_back(sqrt(m13sq)); x.push_back(sqrt(m12sq)); //ParameterList intensL = amps->intensity(x, paras); double AMPpdf = amps->intensity(point).GetDoubleParameterValue(0); //double AMPpdf = intensL.GetDoubleParameter(0)->GetValue(); //double AMPpdf = testBW.intensity(x, minPar); //mb.setVal(m13); //double m13pdf = totAmp13.getVal();//fun_combi2->Eval(m13); if (maxTest < (weight * AMPpdf)) maxTest = (weight * AMPpdf); } maxTest *= 1.1; BOOST_LOG_TRIVIAL(info)<< "Start generation of y pi0 pi0 Dalitz Result"; unsigned int i = 0; do { weight = event.Generate(); pGamma = event.GetDecay(0); pPip = event.GetDecay(1); pPim = event.GetDecay(2); pPm23 = *pPim + *pPip; pPm13 = *pGamma + *pPim; pPm12 = *pGamma + *pPip; m23sq = pPm23.M2(); m13sq = pPm13.M2(); m12sq = pPm12.M2(); dataPoint dataP; dataP.setVal(0, m23sq); dataP.setVal(1, m13sq); // m12sq=M*M-m13sq-m23sq; //if(m12sq<0){ //cout << tmpm12_sq << "\t" << M*M << "\t" << m13_sq << "\t" << m23_sq << endl; //continue; // m12sq=0.0001; // } TParticle fparticleGam(22, 1, 0, 0, 0, 0, *pGamma, W); TParticle fparticlePip(211, 1, 0, 0, 0, 0, *pPip, W); TParticle fparticlePim(-211, 1, 0, 0, 0, 0, *pPim, W); //call physics module //dataPoint dataP; dataP.setVal("m23sq",m23sq); dataP.setVal("m13sq",m13sq); // vector<double> x; // x.push_back(sqrt(m23sq)); // x.push_back(sqrt(m13sq)); // x.push_back(sqrt(m12sq)); double AMPpdf = amps->intensity(dataP).GetDoubleParameterValue(0); //double AMPpdf = amps->intensity(x, par); double test = rando.Uniform(0, maxTest); //mb.setVal(m13); //double m13pdf = totAmp13.getVal();//fun_combi2->Eval(m13); if (maxTest < (weight * AMPpdf)) cout << "Einschwingen zu kurz!" << endl; if (test < (weight * AMPpdf)) { i++; bw12FIT->Fill(m12sq, m13sq); bw13FIT->Fill(m13sq, m12sq); bw23FIT->Fill(m23sq, m12sq); if(i%1000 == 0) BOOST_LOG_TRIVIAL(debug)<< "Event " << i; } } while (i < (myReader->getNEvents()/10.)); bw12DIFF->Add(bw12, 1.0); bw23DIFF->Add(bw23, 1.0); bw13DIFF->Add(bw13, 1.0); bw12DIFF->Divide(bw12FIT); bw23DIFF->Divide(bw23FIT); bw13DIFF->Divide(bw13FIT); // bw12DIFF = new TH2D(*bw12 - *bw12FIT); // bw23DIFF = new TH2D(*bw23 - *bw23FIT); // bw13DIFF = new TH2D(*bw13 - *bw13FIT); boost::filesystem::path output_file(output_filename); output_file_path = output_directory + "/" + output_filename; if (output_file_suffix != "") output_file_path = output_directory + "/" + output_file.stem().string() + "_" + output_file_suffix + output_file.extension().string(); TFile output(output_file_path.c_str(), "RECREATE", "ROOT_Tree"); bw12->Write(); bw13->Write(); bw23->Write(); bw12PHSP->Write(); bw13PHSP->Write(); bw23PHSP->Write(); bw12FIT->Write(); bw13FIT->Write(); bw23FIT->Write(); bw12DIFF->Write(); bw13DIFF->Write(); bw23DIFF->Write(); output.Write(); output.Close(); BOOST_LOG_TRIVIAL(info)<< "Done"; return 0; }
Int_t Program::Code() { /* Note that TFGenPhaseSpace, as per LHCb standard, is in GeV. Hence all the * calculations and graphs hereonin are in GeV. */ gStyle->SetOptStat(0); // Get rid of annoying statistics const Int_t NRGBs = 5; const Int_t NCont = 35; Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle -> SetNumberContours(NCont); if (!gROOT->GetClass("TGenPhaseSpace")) // Get "TGenPhaseSpace" class gSystem->Load("libPhysics"); // Load it if successful DK_DKHist = new TH2F("DK-DK", "DK-DK; m^{2}(D^{0}K^{+}) [(GeV/c^{2})^{2}];m^{2}(#bar{D^{0}}K^{+}) [(GeV/c^{2})^{2}]", 50, 5, 12, 50, 5, 12); DK_DDHist = new TH2F("DK-DD", "DK-DD;m^{2}(D^{0}#bar{D^{0}}) [(GeV/c^{2})^{2}];m^{2}(D^{0}K^{+}) [(GeV/c^{2})^{2}]", 50, 12, 25, 50, 5, 12); D_DHist = new TH1F("D-D", "B^{+} Meson Decay;m(D^{0}#bar{D^{0}}) [GeV/c^{2}]", 50, 3.5, 5); // Declare the histograms to be ploted later TLorentzVector B_plus(0.0, 0.0, 0.0, BPLUSMASS); // Lorentz Vector for the parent B+ (in rest frame) Double_t masses[3] = { DMASS, DMASS, KPLUSMASS }; // Array of masses for the product particles TGenPhaseSpace event; // Declare event of type class TGenPhaseSpace event.SetDecay(B_plus, 3, masses); // Set the decay up for (Int_t n = 0; n < 1000000; n++) { Double_t weight = event.Generate(); // Generate weightings for each decay TLorentzVector *D_0 = event.GetDecay(0); TLorentzVector *D_0bar = event.GetDecay(1); TLorentzVector *K_plus = event.GetDecay(2); /* Set decay products equal to result from GetDecay(). * Note that the order of particles must correspond to the order * of the particles in the masses array, and that pointers to * TLorentzVectors are returned. */ TLorentzVector D_0K_plus = *K_plus + *D_0; TLorentzVector D_0barK_plus = *K_plus + *D_0bar; TLorentzVector D_0D_0bar = *D_0 + *D_0bar; /* Add together all possible combinations of the three decay products. * Note the TLorentzVectors are pointers, so need to be dereferenced. * For use in calculating the invariant mass of the combinations*/ DK_DKHist->Fill(D_0K_plus.M2(), D_0barK_plus.M2(), weight); DK_DDHist->Fill(D_0D_0bar.M2(), D_0K_plus.M2(), weight); // Fill the histograms with weighted invariant mass squared D_DHist->Fill(D_0D_0bar.M(), weight); // Fill the histograms with weighted invariant mass } TCanvas *ThreeDCanv = new TCanvas("ThreeDCanv", "ThreeDCanvas", 1000, 500); ThreeDCanv->Divide(2,1); ThreeDCanv->cd(1); DK_DKHist->GetXaxis()->CenterTitle(); DK_DKHist->GetXaxis()->SetTitleOffset(1.75); DK_DKHist->GetYaxis()->CenterTitle(); DK_DKHist->GetYaxis()->SetTitleOffset(1.75); DK_DKHist->Draw("Lego2"); ThreeDCanv->cd(2); DK_DDHist->GetXaxis()->CenterTitle(); DK_DDHist->GetXaxis()->SetTitleOffset(1.75); DK_DDHist->GetYaxis()->CenterTitle(); DK_DDHist->GetYaxis()->SetTitleOffset(1.75); DK_DDHist->Draw("Lego2"); ThreeDCanv->Print("../graphs/ThreeBodyDecay3D.eps"); TCanvas *ThreeDCanvDK_DK = new TCanvas("ThreeDCanvDK_DK", "ThreeDCanvasDK_DK", 500, 500); DK_DKHist->Draw("Lego2"); ThreeDCanvDK_DK->Print("../graphs/ThreeBodyDecayDK_DK.eps"); TCanvas *ThreeDCanvDK_DD = new TCanvas("ThreeDCanvDK_DD", "ThreeDCanvasDK_DD", 500, 500); DK_DDHist->Draw("Lego2"); ThreeDCanvDK_DD->Print("../graphs/ThreeBodyDecayDK_DD.eps"); TCanvas *TwoDCanv = new TCanvas("TwoDCanv", "TwoDCanvas", 500, 500); D_DHist->GetXaxis()->CenterTitle(); D_DHist->GetXaxis()->SetTitleOffset(1.25); D_DHist->Draw(); TwoDCanv->Print("../graphs/ThreeBodyDecay2D.eps"); delete TwoDCanv; delete ThreeDCanv; delete DK_DKHist; delete DK_DDHist; delete D_DHist; return 0; }
void PhaseSpace( int d ) { int decay(d); gROOT->ProcessLine(".x ~/lhcb/lhcbStyle.C"); if (!gROOT->GetClass("TGenPhaseSpace")) gSystem->Load("libPhysics"); const double mBs(5.36677); const double mBd(5.2794); const double mLb(5.6195); const double mpi(0.13957); const double mK(0.493677); const double mp(0.938272); const double mJpsi(3.096916); const double mPsi(3.686093); TLorentzVector Lb; Double_t masses[3]; double min(5.2); double max(5.5); string title1; string title2; switch (decay) { case 1: cout << "Simluated decay: Bs -> psi(2S) K K" << endl; Lb = TLorentzVector(0.0, 0.0, 0.0, mBs); masses[0] = mPsi; masses[1] = mK; masses[2] = mK; min = 5.2; max = 5.35; cout << "Reconstructed final state: psi(2S) K pi" << endl; cout << "Reconstructed final state: psi(2S) pi K" << endl; title1 = "m(#psi(2S)K(K#rightarrow#pi)) [GeV]"; title2 = "m(#psi(2S)(K#rightarrow#pi)K) [GeV]"; break; case 2: cout << "Simluated decay: Bd -> psi(2S) pi pi" << endl; Lb = TLorentzVector(0.0, 0.0, 0.0, mBd); masses[0] = mPsi; masses[1] = mpi; masses[2] = mpi; min = 5.2; max = 5.5; cout << "Reconstructed final state: psi(2S) pi K" << endl; cout << "Reconstructed final state: psi(2S) K pi" << endl; title1 = "m(#psi(2S)#pi(#pi#rightarrowK)) [GeV]"; title2 = "m(#psi(2S)(#pi#rightarrowK)#pi) [GeV]"; break; case 3: cout << "Simluated decay: Bs -> psi(2S) pi pi" << endl; Lb = TLorentzVector(0.0, 0.0, 0.0, mBs); masses[0] = mPsi; masses[1] = mpi; masses[2] = mpi; min = 5.4; max = 5.7; cout << "Reconstructed final state: psi(2S) pi K" << endl; cout << "Reconstructed final state: psi(2S) K pi" << endl; title1 = "m(#psi(2S)#pi(#pi#rightarrowK)) [GeV]"; title2 = "m(#psi(2S)(#pi#rightarrowK)#pi) [GeV]"; break; case 4: cout << "Simluated decay: Lb -> psi(2S) K p" << endl; Lb = TLorentzVector(0.0, 0.0, 0.0, mLb); masses[0] = mPsi; masses[1] = mK; masses[2] = mp; min = 4.9; max = 5.4; cout << "Reconstructed final state: psi(2S) K pi" << endl; cout << "Reconstructed final state: psi(2S) pi K" << endl; title1 = "m(#psi(2S)K(p#rightarrow#pi)) [GeV]"; title2 = "m(#psi(2S)(K#rightarrow#pi)(p#rightarrowK) [GeV]"; break; case 5: cout << "Simluated decay: Lb -> psi(2S) pi p" << endl; Lb = TLorentzVector(0.0, 0.0, 0.0, mLb); masses[0] = mPsi; masses[1] = mpi; masses[2] = mp; min = 5.2; max = 5.5; cout << "Reconstructed final state: psi(2S) pi K" << endl; cout << "Reconstructed final state: psi(2S) K pi" << endl; title1 = "m(#psi(2S)#pi(p#rightarrowK)) [GeV]"; title2 = "m(#psi(2S)(#pi#rightarrowK)(p#rightarrow#pi) [GeV]"; break; case 6: cout << "Simluated decay: Bs -> psi(2S) K pi" << endl; Lb = TLorentzVector(0.0, 0.0, 0.0, mBs); masses[0] = mPsi; masses[1] = mK; masses[2] = mpi; min = 5.5; max = 5.8; cout << "Reconstructed final state: psi(2S) K p" << endl; cout << "Reconstructed final state: psi(2S) p pi" << endl; title1 = "m(#psi(2S)K(#pi#rightarrowp)) [GeV]"; title2 = "m(#psi(2S)(K#rightarrowp)#pi) [GeV]"; break; } TGenPhaseSpace event; event.SetDecay(Lb, 3, masses); TH1F *h1 = new TH1F("h1","h1", 50, 5.2, 5.8); TH1F *h2 = new TH1F("h2","h2", 50, min, max); TH1F *h3 = new TH1F("h3","h3", 50, min, max); TH2F *h4 = new TH2F("h4","h4", 50, 4.5*4.5, 5.5*5.5, 50, 3.6*3.6, 5.7*5.7); h1->Sumw2(); h2->Sumw2(); h3->Sumw2(); h4->Sumw2(); for (Int_t n=0;n<10000;n++) { Double_t weight = event.Generate(); TLorentzVector *pPsi = event.GetDecay(0); TLorentzVector *pHadron1 = event.GetDecay(1); TLorentzVector *pHadron2 = event.GetDecay(2); TLorentzVector pHadron1_as_kaon (pHadron1->Px(), pHadron1->Py(), pHadron1->Pz(), sqrt(pHadron1->P()*pHadron1->P() + mK *mK)); TLorentzVector pHadron1_as_pion (pHadron1->Px(), pHadron1->Py(), pHadron1->Pz(), sqrt(pHadron1->P()*pHadron1->P() + mpi*mpi)); TLorentzVector pHadron1_as_proton(pHadron1->Px(), pHadron1->Py(), pHadron1->Pz(), sqrt(pHadron1->P()*pHadron1->P() + mp *mp)); TLorentzVector pHadron2_as_kaon (pHadron2->Px(), pHadron2->Py(), pHadron2->Pz(), sqrt(pHadron2->P()*pHadron2->P() + mK *mK)); TLorentzVector pHadron2_as_pion (pHadron2->Px(), pHadron2->Py(), pHadron2->Pz(), sqrt(pHadron2->P()*pHadron2->P() + mpi*mpi)); TLorentzVector pHadron2_as_proton(pHadron2->Px(), pHadron2->Py(), pHadron2->Pz(), sqrt(pHadron2->P()*pHadron2->P() + mp *mp)); TLorentzVector pB = *pPsi + *pHadron1 + *pHadron2; TLorentzVector pB_wrong1; TLorentzVector pB_wrong2; switch (decay) { case 1: pB_wrong1 = *pPsi + *pHadron1 + pHadron2_as_pion; pB_wrong2 = *pPsi + pHadron1_as_pion + *pHadron2; break; case 2: pB_wrong1 = *pPsi + *pHadron1 + pHadron2_as_kaon; pB_wrong2 = *pPsi + pHadron1_as_kaon + *pHadron2; break; case 3: pB_wrong1 = *pPsi + *pHadron1 + pHadron2_as_kaon; pB_wrong2 = *pPsi + pHadron1_as_kaon + *pHadron2; break; case 4: pB_wrong1 = *pPsi + *pHadron1 + pHadron2_as_pion; pB_wrong2 = *pPsi + pHadron1_as_pion + pHadron2_as_kaon; break; case 5: pB_wrong1 = *pPsi + *pHadron1 + pHadron2_as_kaon; pB_wrong2 = *pPsi + pHadron1_as_kaon + pHadron2_as_pion; break; case 6: pB_wrong1 = *pPsi + *pHadron1 + pHadron2_as_proton; pB_wrong2 = *pPsi + pHadron1_as_proton + *pHadron2; break; } TLorentzVector pPsiHadron1 = *pPsi + *pHadron1; TLorentzVector pPsiHadron2 = *pPsi + *pHadron2; h1->Fill(pB.M() ,weight); h2->Fill(pB_wrong1.M() ,weight); h3->Fill(pB_wrong2.M() ,weight); h4->Fill(pPsiHadron1.M2() ,pPsiHadron2.M2() ,weight); } TCanvas * c = new TCanvas(); c->Divide(2,1); //c->cd(1); //h1->Draw(); //h1->GetXaxis()->SetTitle("m(#psi(2S)p#pi) [GeV]"); //h1->GetXaxis()->SetTitle("m(#psi(2S)pK) [GeV]"); c->cd(1); h2->Draw(); h2->GetXaxis()->SetTitle(title1.c_str()); c->cd(2); h3->Draw(); h3->GetXaxis()->SetTitle(title2.c_str()); //c->cd(4); //h4->Draw(); char buf[20]; sprintf(buf, "plot%d.pdf", decay); c->SaveAs(buf); }
int main( int argc, const char *argv[] ) { //////////////////////// // // // -- Initializing -- // // // //////////////////////// int nEvents = 3; // Event parameters int nParticles = 2; // Auxiliary vector(s) TLorentzVector k0 (1.0, 0.0, 0.0, 1.0); // Fortran COMMON blocks masses_.rmtau = m_tau; couplings_.wcl = 1.0; couplings_.gh_tautau = 1.0; amplitudes_.rh_6f_tautau = 0.0; amplitudes_.rh_6f_taum = 0.0; amplitudes_.rh_6f_taup = 0.0; amplitudes_.rh_6f_res = 0.0; amplitudes_.rh_6f_res_nwa = 0.0; // Ampltiudes //cval cdec_taum[2][2]; CMatrix_2_2 cdec_taum; CMatrix_2_2 cdec_taup; CMatrix_2_2 ch_tautau; TauMatrix h_tautau; TauMatrix taum; TauMatrix taup; TauMatrix c7_568; h_tautau.SetName("H->tau- tau+"); taum.SetName("taum"); taup.SetName("taup"); c7_568.SetName("c7_568"); //////////////////////////////////////////////////// // -- Generate HiggsDecays with TGenPhaseSpace -- // //////////////////////////////////////////////////// TGenPhaseSpace HiggsDecay; TLorentzVector Higgs(0.0, 0.0, 0.0, m_higgs); double TauMasses[2] = {m_tau, m_tau}; TGenPhaseSpace p568Decay; TGenPhaseSpace p734Decay; double LeptonMasses1[3] = {m_nu_tau, m_ele, m_nu_ele}; double LeptonMasses2[3] = {m_nu_tau, m_muo, m_nu_muo}; HiggsDecay.SetDecay(Higgs, 2, TauMasses); TH2F *h2 = new TH2F("h2","h2", 50,1.1,1.8, 50,1.1,1.8); double p1_[4]; double p2_[4]; double p3_[4]; double p4_[4]; double p5_[4]; double p6_[4]; double p7_[4]; double p8_[4]; std::cout << "\n\n#########################" << std::endl; std::cout << "### Consistency check ###" << std::endl; std::cout << "#########################\n" << std::endl; std::cout << "Process:" << std::endl; std::cout << "H --> (tau+) (tau-) --> (3 leptons) (3 leptons)\n" << std::endl; std::cout << Form("m_higgs (used in phase space gen): %8.4f [GeV]", m_higgs) << std::endl; std::cout << Form("masses_.rmtau (used in rh_6f): %8.4f [GeV]", masses_.rmtau) << std::endl; std::cout << Form("m_tau (used in phase space gen): %8.4f [GeV]", m_tau) << std::endl; std::cout << Form("m_ele (used in phase space gen): %8.4f [GeV]", m_ele) << std::endl; std::cout << Form("m_muo (used in phase space gen): %8.4f [GeV]", m_muo) << std::endl; std::cout << Form("and all neutrinos are massless") << std::endl; for (int iEv = 0; iEv < nEvents; iEv++) { std::cout << Form("\n################\n### iEv: %3d ###\n################", iEv) << std::endl; // Higgs Decay Double_t weight = HiggsDecay.Generate(); std::cout << "weight: " << weight << std::endl; // Get tau+ and tau- TLorentzVector *p734 = HiggsDecay.GetDecay(1); TLorentzVector *p568 = HiggsDecay.GetDecay(0); TVector3 p734_BoostVector = p734->BoostVector(); TVector3 p568_BoostVector = p568->BoostVector(); // Make taus decay p734Decay.SetDecay( (*p734), 3, LeptonMasses1 ); p568Decay.SetDecay( (*p568), 3, LeptonMasses2 ); Double_t weight1 = p568Decay.Generate(); Double_t weight2 = p734Decay.Generate(); std::cout << "weight1: " << weight1 << std::endl; std::cout << "weight2: " << weight2 << std::endl; TLorentzVector *p7 = p734Decay.GetDecay(0); // v_tau TLorentzVector *p3 = p734Decay.GetDecay(1); // ele- TLorentzVector *p4 = p734Decay.GetDecay(2); // v_ele_bar TLorentzVector *p8 = p568Decay.GetDecay(0); // v_tau_bar TLorentzVector *p6 = p568Decay.GetDecay(1); // mu+ TLorentzVector *p5 = p568Decay.GetDecay(2); // v_muo double p568k0 = k0 * (*p568); double p734k0 = k0 * (*p734); double p3k0 = k0 * (*p3); double p4k0 = k0 * (*p4); double p5k0 = k0 * (*p5); double p6k0 = k0 * (*p6); double p7k0 = k0 * (*p7); double p8k0 = k0 * (*p8); TLorentzVector *sum = new TLorentzVector; (*sum) = (*p8) + (*p6) + (*p5) + (*p7) + (*p3) + (*p4); std::cout << "\n# --- Generated momenta --- #\n"; std::cout << "- sum: "; displayTLorentzVector(sum); std::cout << "- p734 "; displayTLorentzVector(p734); std::cout << "- p568 "; displayTLorentzVector(p568); std::cout << "- p7 (v_tau )"; displayTLorentzVector(p7); std::cout << "- p3 (e-)"; displayTLorentzVector(p3); std::cout << "- p4 (v_ebar)"; displayTLorentzVector(p4); std::cout << "- p8 (v_taubar)"; displayTLorentzVector(p8); std::cout << "- p6 (muon+)"; displayTLorentzVector(p6); std::cout << "- p5 (v_mu)"; displayTLorentzVector(p5); // -- Unpolarized term -- // double taum_amp = p734->Dot((*p4)) * p3->Dot((*p7)); double taup_amp = p568->Dot((*p5)) * p6->Dot((*p8)); // -- Polarized term -- // // polarization vectors TLorentzVector polvec_taum; TLorentzVector polvec_taup; // standard polarization vector with p and k0 for(int nu = 0; nu<4; nu++) { polvec_taum[nu] = ( (*p734)[nu]/m_tau) - (m_tau/p734k0)*k0[nu]; polvec_taup[nu] = ( (*p568)[nu]/m_tau) - (m_tau/p568k0)*k0[nu]; } double taum_pol_amp = m_tau*( polvec_taum * (*p4) ) * ( (*p3) * (*p7) ); // (ek')(qk) double taup_pol_amp = m_tau*( polvec_taup * (*p5) ) * ( (*p6) * (*p8) ); // (ek')(qk) std::cout << Form("\n# --- Standard calculation --- #") << std::endl; std::cout << Form("Unpolarized case:") << std::endl; std::cout << Form("- tau- (pk')(qk) (unpolarized): %.4f", taum_amp ) << std::endl; std::cout << Form("- tau+ (pk')(qk) (unpolarized): %.4f", taup_amp ) << std::endl; std::cout << Form("- tau-/tau+ (unpolarized): %.4f", taum_amp/taup_amp ) << std::endl; std::cout << Form("Polarized case:") << std::endl; std::cout << Form("- tau- m_tau*(ek')(qk) (polarized term): %.4f", taum_pol_amp ) << std::endl; std::cout << Form("- tau+ m_tau*(ek')(qk) (polarized term): %.4f", taup_pol_amp ) << std::endl; double taum_standard_pol_1 = taum_amp - taum_pol_amp; double taum_standard_pol_2 = taum_amp + taum_pol_amp; double taup_standard_pol_1 = taup_amp - taup_pol_amp; double taup_standard_pol_2 = taup_amp + taup_pol_amp; std::cout << Form("- taum_standard_pol_1 ((pk')(qk)-m_tau*(ek')(qk)): %.4f", taum_standard_pol_1) << std::endl; std::cout << Form("- taum_standard_pol_2 ((pk')(qk)+m_tau*(ek')(qk)): %.4f", taum_standard_pol_2) << std::endl; std::cout << Form("- taup_standard_pol_1 ((pk')(qk)-m_tau*(ek')(qk)): %.4f", taup_standard_pol_1) << std::endl; std::cout << Form("- taup_standard_pol_2 ((pk')(qk)+m_tau*(ek')(qk)): %.4f", taup_standard_pol_2) << std::endl; for (int i = 0; i < 4; i++) { p1_[e2m[i]] = (*p568)[i]; p2_[e2m[i]] = (*p734)[i]; p3_[e2m[i]] = (*p3)[i]; p4_[e2m[i]] = (*p4)[i]; p5_[e2m[i]] = (*p5)[i]; p6_[e2m[i]] = (*p6)[i]; p7_[e2m[i]] = (*p7)[i]; p8_[e2m[i]] = (*p8)[i]; } // double rh_tautau_val = rh_tautau_(p1_,p2_); // std::cout << Form("rh_tautau: %.2f\n", rh_tautau_val) << std::endl; std::cout << Form("\n# --- Helicity amplitude calculation --- #") << std::endl; double rh_6f_val = rh_6f_(p3_,p4_,p5_,p6_,p7_,p8_); h_tautau.ReadInCMatrix_2_2( taumatrices_.ch_tautau ); taum.ReadInCMatrix_2_2( taumatrices_.cdec_taum ); taup.ReadInCMatrix_2_2( taumatrices_.cdec_taup ); c7_568.ReadInCMatrix_2_2( taumatrices_.c7_568 ); h_tautau.Show(); taum.Show(); taup.Show(); double taum_rh_6f_pol_1 = std::abs(taum.m[1][0])*std::abs(taum.m[1][0]); double taum_rh_6f_pol_2 = std::abs(taum.m[1][1])*std::abs(taum.m[1][1]); double taup_rh_6f_pol_1 = std::abs(taup.m[0][1])*std::abs(taup.m[0][1]); double taup_rh_6f_pol_2 = std::abs(taup.m[1][1])*std::abs(taup.m[1][1]); taum_rh_6f_pol_1 = taum_rh_6f_pol_1/p3k0/p4k0/p7k0/p734k0; taum_rh_6f_pol_2 = taum_rh_6f_pol_2/p3k0/p4k0/p7k0/p734k0; taup_rh_6f_pol_1 = taup_rh_6f_pol_1/p5k0/p6k0/p8k0/p568k0; taup_rh_6f_pol_2 = taup_rh_6f_pol_2/p5k0/p6k0/p8k0/p568k0; taum.ShowSumOfSquares(); taup.ShowSumOfSquares(); // for (int i=0; i<2; i++) // for (int j=0; j<2; j++) // { // std::cout << Form("rh_6f_tau-[%d][%d].r: %.4f \n",i,j,cdec_taum[i][j].r); // std::cout << Form("rh_6f_tau-[%d][%d].i: %.4f \n",i,j,cdec_taum[i][j].i); // } // // for (int i=0; i<2; i++) // for (int j=0; j<2; j++) // { // std::cout << Form("rh_6f_tau+[%d][%d].r: %.4f \n",i,j,cdec_taup[i][j].r); // std::cout << Form("rh_6f_tau+[%d][%d].i: %.4f \n",i,j,cdec_taup[i][j].i); // } double taum_unpol = taum.CalcSumOfSquares(); double taup_unpol = taup.CalcSumOfSquares(); taum_unpol = taum_unpol/p3k0/p4k0/p7k0/p734k0; taup_unpol = taup_unpol/p5k0/p6k0/p8k0/p568k0; std::cout << Form("- taum_unpolarized (calc via sum of square of tau elements): %.4f", taum_unpol) << std::endl; std::cout << Form("- taup_unpolarized (calc via sum of square of tau elements): %.4f", taup_unpol) << std::endl; std::cout << Form("- taum_rh_6f_pol_1 (calc via square): %.4f", taum_rh_6f_pol_1) << std::endl; std::cout << Form("- taum_rh_6f_pol_2 (calc via square): %.4f", taum_rh_6f_pol_2) << std::endl; std::cout << Form("- taup_rh_6f_pol_1 (calc via square): %.4f", taup_rh_6f_pol_1) << std::endl; std::cout << Form("- taup_rh_6f_pol_2 (calc via square): %.4f", taup_rh_6f_pol_2) << std::endl; std::cout << Form("- (taum_rh_6f_pol_1-taum_rh_6f_pol_2) (calc via square): %.4f", taum_rh_6f_pol_1-taum_rh_6f_pol_2) << std::endl; std::cout << Form("- (taup_rh_6f_pol_1-taup_rh_6f_pol_2) (calc via square): %.4f", taup_rh_6f_pol_1-taup_rh_6f_pol_2) << std::endl; std::cout << Form("- rh_6f_taum (passed through FORTRAN common): %.4f", amplitudes_.rh_6f_taum) << std::endl; std::cout << Form("- rh_6f_taup (passed through FORTRAN common): %.4f", amplitudes_.rh_6f_taup ) << std::endl; std::cout << Form("- rh_6f tau-/tau+ (passed through FORTRAN common): %.4f", amplitudes_.rh_6f_taum/amplitudes_.rh_6f_taup ) << std::endl; std::cout << Form("- rh_6f_res (passed through FORTRAN common): %.4f", amplitudes_.rh_6f_res ) << std::endl; std::cout << Form("- rh_6f_res_nwa (passed through FORTRAN common): %.4f", amplitudes_.rh_6f_res_nwa ) << std::endl; std::cout << Form("\n# --- Comparison --- #") << std::endl; std::cout << Form("- rh_6f_taum/taum ratio (unpolarized): %.4f", amplitudes_.rh_6f_taum/taum_amp ) << std::endl; std::cout << Form("- rh_6f_taup/taup ratio (unpolarized): %.4f", amplitudes_.rh_6f_taup/taup_amp ) << std::endl; std::cout << Form("- taum_pol_1 (rh_6f/standard ratio) (polarized): %.4f", taum_rh_6f_pol_1/taum_standard_pol_1 ) << std::endl; std::cout << Form("- taum_pol_2 (rh_6f/standard ratio) (polarized): %.4f", taum_rh_6f_pol_2/taum_standard_pol_2 ) << std::endl; std::cout << Form("- taup_pol_1 (rh_6f/standard ratio) (polarized): %.4f", taup_rh_6f_pol_1/taup_standard_pol_1 ) << std::endl; std::cout << Form("- taup_pol_2 (rh_6f/standard ratio) (polarized): %.4f", taup_rh_6f_pol_2/taup_standard_pol_2 ) << std::endl; //std::cout << Form("rh_6f: %.2f", rh_6f_val) << std::endl; // double LeptonMasses1[3] = {m_nu_tau, m_ele, m_nu_ele}; // double LeptonMasses2[3] = {m_nu_tau, m_muo, m_nu_muo}; // H(p) -> e-(p3) vebar(p4) vmu(p5) mu+(p6) vtau(p7) vtaubar(p8) } }
{ gSystem.Load("libPhysics"); TLorentzVector target(0.0,0.0,0.0,0.938); TLorentzVector beam(0.0,0.0,10.4,10.4); TLorentzVector W = beam+target; Double_t masses[3]={0.938,0.135,0.135}; TGenPhaseSpace event; event.SetDecay(W,3,masses); event.Generate(); TLorentzVector *pProton = event.GetDecay(0); TLorentzVector *pPi0 = event.GetDecay(1); TLorentzVector *pPi02 = event.GetDecay(2); TH1D *h = new TH1D("his","theta",100,0,180); h->Fill(pProton->Theta()*57.3); /* for(Int_t n=0;n<100000;n++) { event.Generate(); TLorentzVector *pProton = event.GetDecay(0); TLorentzVector *pPi0 = event.GetDecay(1); TLorentzVector *pPi02 = event.GetDecay(2); h->Fill(pProton->Theta()*57.3); } */ h->Draw(); }
void PhaseDplusKKpi( std::string filename = "bsdspi.root", int nToGen = 1e7) { // gROOT->ProcessLine(".x ~/lhcb/lhcbStyle.C"); if (!gROOT->GetClass("TGenPhaseSpace")) gSystem->Load("libPhysics"); // loaf the fonll stuff TFile* fonll = new TFile("fonll.root"); TH1F* ptHisto = (TH1F*) fonll->Get("pthisto"); TH1F* etaHisto = (TH1F*) fonll->Get("etahisto"); // get the graph to smear with TFile* smearfile = new TFile("smear12.root"); TGraphErrors* sgraph = (TGraphErrors*)smearfile->Get("data;1"); Double_t masses[2] = {mDplus,mpi}; Double_t masses2[3] = {mK,mpi,mpi}; double min(5.2); double max(5.5); TH1F *h1 = new TH1F("h1","h1", 100, 4850, 5550); h1->Sumw2(); TH1F *dh1 = new TH1F("dh1","dh1", 100, 0., 5000.); dh1->Sumw2(); TH1F *dh2 = new TH1F("dh2","dh2", 100, 1000., 2000.); dh2->Sumw2(); TH1F *dh3 = new TH1F("pi","pi", 100, 2000., 4000.); dh3->Sumw2(); TH1F *dh4 = new TH1F("phi","phi", 100, 750, 1250); dh4->Sumw2(); TRandom ran; for (Int_t n=0;n<nToGen; n++) { // Double_t weight = event.Generate(); TLorentzVector Bs = genB(ran,ptHisto,etaHisto, mBd); TGenPhaseSpace event; if (!generateEvent(Bs,event,masses,ran,1000)) continue; TLorentzVector dplus = *event.GetDecay(0); // ds TLorentzVector pi1 = *event.GetDecay(1); //pi // generate the Ds TGenPhaseSpace subevent; if (!generateEvent(dplus,subevent,masses2,ran,1000)) continue; TLorentzVector k1 = *subevent.GetDecay(0); TLorentzVector pi2 = *subevent.GetDecay(1); TLorentzVector pi3 = *subevent.GetDecay(2); // smear the vectors TLorentzVector spi1 = smearedVec(pi1,sgraph,ran); TLorentzVector spi2 = smearedVec(pi2,sgraph,ran); TLorentzVector spi3 = smearedVec(pi3,sgraph,ran); TLorentzVector sk1 = smearedVec(k1,sgraph,ran); TLorentzVector fk2; TLorentzVector fpi2; if (ran.Uniform() > 0.5){ fk2 = reassignMass(spi2,mK); fpi2 = spi3; } else{ fk2 = reassignMass(spi3,mK); fpi2 = spi2; } TLorentzVector sum = spi1 + spi2 + sk1 +fk2; TLorentzVector pipi = spi1 + fpi2 ; TLorentzVector phi = sk1+fk2 ; TLorentzVector dsum = spi1 + sk1 + fk2 ; TLorentzVector dsum2 = spi2 + sk1 + fk2 ; if ( select(spi1,fpi2,sk1,fk2,ran)) { h1->Fill(1000*sum.M()); dh1->Fill(1000*dsum.M()); dh2->Fill(1000*dsum2.M()); dh3->Fill(1000*pipi.M()); dh4->Fill(1000*phi.M()); } // std::cout << pipi.P() << std::endl; } TCanvas* can = new TCanvas("can","can", 800,600); h1->Draw("HISTO"); TCanvas* can2 = new TCanvas("can2","can2", 800,600); dh1->Draw("HISTO"); TCanvas* can3 = new TCanvas("can3","can3", 800,600); dh2->Draw("HISTO"); TCanvas* can4 = new TCanvas("can4","can4", 800,600); dh3->Draw("HISTO"); TCanvas* can5 = new TCanvas("can5","can5", 800,600); dh4->Draw("HISTO"); TFile* output = new TFile(filename.c_str(),"RECREATE","output ROOT file"); dh1->Write(); dh2->Write(); dh3->Write(); dh4->Write(); h1->Write(); output->Close(); }
void PhaseSignal(int mode =2, int nEvtToGen = 1000000) { // mode == which chic // gROOT->ProcessLine(".x ~/lhcb/lhcbStyle.C"); if (!gROOT->GetClass("TGenPhaseSpace")) gSystem->Load("libPhysics"); // loaf the fonll stuff TFile* fonll = new TFile("fonll.root"); TH1F* ptHisto = (TH1F*) fonll->Get("pthisto"); TH1F* etaHisto = (TH1F*) fonll->Get("etahisto"); // get the graph to smear with TFile* smearfile = new TFile("smear12.root"); TGraphErrors* sgraph = (TGraphErrors*)smearfile->Get("data;1"); //make pdfs for phi and chi mass shape RooRealVar m1("m1","m1",0.6, 1.5); RooRealVar m2("m2","m2",3.2, 3.6); RooRealVar m3("m3","m3",3.6, 3.8); RooRelBreitWigner* bw = createPhiMassPdf(m1); RooRelBreitWigner* chibw= 0; if (mode ==0) { chibw = createChi0MassPdf(m2); } else if (mode == 2){ chibw = createChi2MassPdf(m2); } else { chibw = createChi1MassPdf(m2); } // generate phi datasets RooDataSet *phidata = bw->generate(RooArgSet(m1),100000) ; RooDataSet *chicdata = chibw->generate(RooArgSet(m2),100000) ; // RooDataSet *psi2sdata = psi2bw->generate(RooArgSet(m3),100000) ; Double_t masses[2] = {mchic2,mphi}; Double_t masses3[2] = {mpi,mpi}; Double_t masses4[2] = {mK,mK}; double min(5.2); double max(5.5); TH1F *h1 = new TH1F("h1","h1", 100, 5150, 5550); h1->Sumw2(); TH1F *dh1 = new TH1F("dh1","dh1", 100, 0., 5000.); dh1->Sumw2(); TH1F *dh2 = new TH1F("dh2","dh2", 100, 1000., 2000.); dh2->Sumw2(); TH1F *dh3 = new TH1F("pi","pi", 100, 2000., 4000.); dh3->Sumw2(); TH1F *dh4 = new TH1F("phi","phi", 100, 750, 1250); dh4->Sumw2(); TRandom ran; int ngenerated = 0; int nselected = 0; for (Int_t n=0;n<nEvtToGen;n++) { // Double_t weight = event.Generate(); TLorentzVector Bs = genB(ran,ptHisto,etaHisto, mBs); TGenPhaseSpace event; // Generate the Bs int ntoGen = 0; masses[1] = pick(phidata,ran,std::string("m1")); masses[0] = pick(chicdata ,ran,std::string("m2")); if (!generateEvent(Bs,event,masses,ran,1000)) continue; TLorentzVector chic = *event.GetDecay(0); // psi TLorentzVector phi = *event.GetDecay(1); //phi // chic decay to pipi TGenPhaseSpace subevent1; if (!generateEvent(chic,subevent1,masses3,ran,1000)) continue; TLorentzVector pi1 = *subevent1.GetDecay(0); TLorentzVector pi2 = *subevent1.GetDecay(1); // phi decays to kk TGenPhaseSpace subevent2; if (!generateEvent(phi,subevent2,masses4,ran,1000)) continue; TLorentzVector k1 = *subevent2.GetDecay(0); TLorentzVector k2 = *subevent2.GetDecay(1); // smear the vectors TLorentzVector spi1 = smearedVec(pi1,sgraph,ran); TLorentzVector spi2 = smearedVec(pi2,sgraph,ran); TLorentzVector sk1 = smearedVec(k1,sgraph,ran); TLorentzVector sk2 = smearedVec(k2,sgraph,ran); // TLorentzVector sk2 = reassignMass(spi,mK); TLorentzVector sum = spi1 + spi2 + sk1 + sk2; TLorentzVector pipi = spi1 + spi2 ; TLorentzVector sphi = sk1+sk2 ; TLorentzVector dsum = spi1 + sk1 + sk2 ; TLorentzVector dsum2 = spi2 + sk1 + sk2 ; ++ngenerated; if (select(spi1,spi2,sk1,sk2,ran)) { h1->Fill(sum.M()*1000); dh1->Fill(dsum.M()*1000); dh2->Fill(dsum2.M()*1000); dh3->Fill(pipi.M()*1000); dh4->Fill(sphi.M()*1000); ++nselected; } // std::cout << pipi.P() << std::endl; } //event loop TCanvas* can1 = new TCanvas("can","can", 800,600); h1->Fit("gaus"); h1->Draw("HISTO"); TCanvas* can2 = new TCanvas("can2","can2", 800,600); dh1->Draw("HISTO"); TCanvas* can3 = new TCanvas("can3","can3", 800,600); dh2->Draw("HISTO"); TCanvas* can4 = new TCanvas("can4","can4", 800,600); dh3->Draw("HISTO"); TCanvas* can5 = new TCanvas("can5","can5", 800,600); dh4->Draw("HISTO"); std::cout << "Generated " << ngenerated << std::endl; std::cout << "Selected " << nselected << std::endl; std::stringstream outputname; outputname << "radiative_signal_" << mode <<".root"; TFile* output = new TFile(outputname.str().c_str(),"RECREATE","output ROOT file"); dh1->Write(); dh2->Write(); dh3->Write(); dh4->Write(); h1->Write(); output->Close(); }