Examples for Pluto as a quick converter

All examples can be combined and adapted.

Output of a reaction to ASCII

This can be done by the echo-command:

PReaction my_reaction("_T1=2.2","p","p","p p eta [dilepton [e+ e-] g]");
my_reaction.Output("eta_dalitz.lst",
                   "px=[eta]->Px(); py=[eta]->Py(); pz=[eta]->Pz(); echo $px,$py,$pz");
my_reaction.Print();
my_reaction.Loop(100);

Reading of an ASCII file and conversion to a TNtuple

Text files can be read with the readline-command. The pattern in the curly brackets is similar to scanf. The target variables are defined with the @-prefix.
Keep in mind that the variables in the ntuple are filled automatically if the branches match the defined variables by name.

TFile *f = new TFile("ntuple.root", "RECREATE");
TNtuple *ntuple = new TNtuple("ntuple", "data", "px:py:pz");

PReaction my_reaction;
    
my_reaction.Input("eta_dalitz.lst", "readline{@px,@py,@pz};");
my_reaction.Output(ntuple);

cout << my_reaction.Loop() << " events converted" << endl;
ntuple->Write();

f->Close();

Reading of an ASCII file and projection of the content to a histogram

The text file can be read, new variables can be calculated and projected to histograms:

TH1F *pt = new TH1F("pt","",20,0,1);

PReaction my_reaction;
    
my_reaction.Input("eta_dalitz.lst", "readline{@px,@py,@pz};");
my_reaction.Do(pt,"_x = sqrt(px*px + py*py)");

cout << my_reaction.Loop() << " events projected" << endl;
pt->Draw();

Reading of an ASCII file and conversion to PParticles

PReaction my_reaction("eta_file");
    
my_reaction.Input("eta_dalitz.lst", "readline{@px,@py,@pz};");
my_reaction.Do("myeta = P3M(px,py,pz,eta.mass); myeta->SetID(eta.pid); push(myeta)");

cout << my_reaction.Loop() << " events converted" << endl;

Conversion of a TNtuple to ASCII

This is quite simple, as the branches in the input ntuple are used as variables.

TFile *f = new TFile("ntuple.root");

PReaction my_reaction;
    
my_reaction.Input(ntuple);
my_reaction.Output("eta.lst","echo $px,$py,$pz");

cout << my_reaction.Loop() << " events converted" << endl;

Conversion of an UniGen file to a TNtuple

This is a more complex example, how Pluto can be used to read UniGen files. UniGen has a lot of converters for (e.g.) UrQMD and HSD, therefore these files can be feed into Pluto by the UniGen input.

TFile *f = new TFile("dileptons.root", "RECREATE");

TNtuple *ntuple = new TNtuple("dileptons", "data", "ee_mass");

PReaction my_reaction;
    
my_reaction.AddBulk(new PUniGenInput("eta_dalitz_unigen.root"));

my_reaction.Do("ee_mass = ([e+] + [e-] )->M();");
my_reaction.Output(ntuple);

cout << my_reaction.Loop() << " events converted" << endl;

f->cd();
ntuple->Write();
f->Close();

*Version 5.37.4 (dev),