Writing TNtuple(s) and ASCII files


{

    TFile *f = new TFile("ntuple.root", "RECREATE");
    TNtuple *ntuple = new TNtuple("ntuple", "data from Pluto events", "eta_px:eta_py:eta_pz:eta_m");
    
    TFile *f2 = new TFile("ntuple2.root", "RECREATE");
    TNtuple *ntuple2 = new TNtuple("ntuple2", "data from Pluto events", "cos_theta_eta");

    //Define the reaction
    PReaction my_reaction("3.5", "p", "p", "p p eta [pi+ pi- pi0]");
   
    //Writing to the ntuple is done by defining the variables of the branches:
    my_reaction.Output(ntuple,"eta_px = [eta]->Px() ; eta_py = [eta]->Py() ; eta_pz = [eta]->Pz(); eta_m = [eta]->M()");
    my_reaction.Output(ntuple2,"myeta = [eta]; myeta->Boost([p + p]); cos_theta_eta = myeta->CosTheta()");

    //Writing to ASCII output files works with the same syntax as the "echo" command:
    my_reaction.Output("eta_sample.txt", "echo $eta_px $eta_py $eta_pz $eta_m");

    my_reaction.Print();

    cout << my_reaction.Loop(100000) << " events recorded" << endl;

    f->Write();
    f2->Write();

}
 batch_write_ntuple.C:1
 batch_write_ntuple.C:2
 batch_write_ntuple.C:3
 batch_write_ntuple.C:4
 batch_write_ntuple.C:5
 batch_write_ntuple.C:6
 batch_write_ntuple.C:7
 batch_write_ntuple.C:8
 batch_write_ntuple.C:9
 batch_write_ntuple.C:10
 batch_write_ntuple.C:11
 batch_write_ntuple.C:12
 batch_write_ntuple.C:13
 batch_write_ntuple.C:14
 batch_write_ntuple.C:15
 batch_write_ntuple.C:16
 batch_write_ntuple.C:17
 batch_write_ntuple.C:18
 batch_write_ntuple.C:19
 batch_write_ntuple.C:20
 batch_write_ntuple.C:21
 batch_write_ntuple.C:22
 batch_write_ntuple.C:23
 batch_write_ntuple.C:24
 batch_write_ntuple.C:25
 batch_write_ntuple.C:26
 batch_write_ntuple.C:27
 batch_write_ntuple.C:28