//------------------------------------------------------------ // It's a simple macro to creat one-dimentional set signal+bkg // 15/01/2013 // A.Karavdina //------------------------------------------------------------ void myTTreePreparation(){ TFile *hfile = new TFile("mySample.root","RECREATE","Test 1D sig+bkg"); TTree *treesig = new TTree("treeSig","sig"); TTree *treebkg = new TTree("treeBkg","bkg"); TTree *treeall = new TTree("treeAll","sig+bkg"); Double_t sig, bkg, theta, mes, phi; // create a branches with theta //and probability for signal and bkg and measur=sig+bkg treesig->Branch("theta",&theta); treebkg->Branch("theta",&theta); treeall->Branch("theta",&theta); treesig->Branch("phi",&phi); treebkg->Branch("phi",&phi); treeall->Branch("phi",&phi); // tree->Branch("signal",&sig); // tree->Branch("measur",&mes); // tree->Branch("bkground",&bkg); Int_t nevent=1000000; //describe signal TF1 *fLand = new TF1("fLand","100*(TMath::Landau(x,[0],[1],0))",2,10); fLand->SetParameters(4.,0.5); // fLand->Draw(); //describe bkg TF1 *fLin = new TF1("fLin","0.01*x+0.5",2,10); // fLin->Draw(); TRandom3 randvar; for (Int_t iev=0;ievEval(theta); bkg = fLin->Eval(theta); mes = sig+bkg; Double_t ranMean = 20*randvar.Rndm(); if(ranMean>sig) continue; if(ranMeanbkg){ phi = 6.3*randvar.Rndm(); treesig->Fill(); treeall->Fill(); } if(ranMeanFill(); treeall->Fill(); } // tree->Fill(); // fill the tree with the current event } treesig->Write(); treebkg->Write(); treeall->Write(); treesig->Print(); treebkg->Print(); treeall->Print(); }