Browse Source

Initial commit.

Nikita Ermakov 3 years ago
commit
f354fa1b51
26 changed files with 2776 additions and 0 deletions
  1. 5 0
      .gitignore
  2. 37 0
      Makefile
  3. 26 0
      UArrays.cxx
  4. 28 0
      UArrays.h
  5. 62 0
      UDst.cxx
  6. 53 0
      UDst.h
  7. 144 0
      UEvent.cxx
  8. 126 0
      UEvent.h
  9. 282 0
      UManager.cxx
  10. 79 0
      UManager.h
  11. 110 0
      UPIDConverter.cxx
  12. 40 0
      UPIDConverter.h
  13. 252 0
      UParticle.cxx
  14. 233 0
      UParticle.h
  15. 149 0
      URun.cxx
  16. 142 0
      URun.h
  17. 41 0
      UTask.cxx
  18. 32 0
      UTask.h
  19. 17 0
      UniGenLinkDef.h
  20. 13 0
      input/Makefile
  21. 69 0
      input/pluto_pdg.dat
  22. 316 0
      input/urqmd_pdg.dat
  23. 200 0
      input/urqmd_pdg.dat_old
  24. 85 0
      input/werner_pdg.dat
  25. 16 0
      unigenlogin.bash
  26. 219 0
      urqmd2u.cpp

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+*.so
+*.o
+urqmd2u
+UniGen_Dict.C
+UniGen_Dict_rdict.pcm

+ 37 - 0
Makefile

@@ -0,0 +1,37 @@
+# Define compiler
+CXX = g++
+
+# Define flags
+CFLAGS = $(shell root-config --cflags) -O2 -fPIC -Wall -pipe -std=c++11 -I.
+LIBS = $(shell root-config --glibs) -lEG
+INCS = $(shell root-config --incdir)
+
+# Define output library
+UNIGEN = libUniGen.so
+
+# Compile all *.cxx classes in the directory
+SRC = $(shell find . -name "*.cxx")
+
+all: $(UNIGEN)
+
+# $(SRC:.cc=.o)
+$(UNIGEN): $(SRC:.cxx=.o) UniGen_Dict.C
+	$(CXX) $(CFLAGS) -shared $^ -o $(UNIGEN) $(LIBS)
+
+%.o: %.cxx
+	$(CXX) -fPIC $(CFLAGS) -c -o $@ $<
+
+# Dictionary deneration: -DROOT_CINT -D__ROOT__
+UniGen_Dict.C: $(shell find . -name "*.h" ! -name "*LinkDef*")
+	rootcint -f $@ -c -I. -I$(INCS) $^ UniGenLinkDef.h
+
+.PHONY: clean distclean converters
+
+clean:
+	rm -vf *.o UniGen_Dict*
+
+distclean:
+	rm -vf *.o UniGen_Dict* $(UNIGEN) urqmd2u
+
+converters: urqmd2u.cpp
+	$(CXX) $(CFLAGS) -I$(INCS) $^ -o $(patsubst %.cpp,%,$<) -L. -l$(patsubst lib%.so,%,$(UNIGEN)) $(LIBS)

+ 26 - 0
UArrays.cxx

@@ -0,0 +1,26 @@
+#include "UArrays.h"
+
+//________________
+UArrays::UArrays() {
+  /* emtpy */
+}
+
+//________________
+UArrays::~UArrays() {
+  /* emtpy */
+}
+
+// Array names
+//________________
+const char* UArrays::uArrayNames[NAllUArrays] = { "Run", "Event", "Particle" };
+
+// Array types
+//________________
+const char* UArrays::uArrayTypes[NAllUArrays] = { "URun", "UEvent", "UParticle" };
+
+// Array sizes
+// These are intial sizes. Automatically resized if too small.
+// Choosing too large initial values gives a performance penalty when reading
+// only selected femtoDst branches
+//_________________
+int UArrays::uArraySizes[NAllUArrays] = { 1, 1, 1500 };

+ 28 - 0
UArrays.h

@@ -0,0 +1,28 @@
+#ifndef UArrays_h
+#define UArrays_h
+
+//________________
+class UArrays {
+ public:
+  /// Default constructor
+  UArrays();
+  /// Destructor
+  ~UArrays();
+
+  /// Number of used arrays
+  enum { NAllUArrays = 3 };
+
+  /// Names of the TBranches in the TTree/TFile
+  static const char* uArrayNames[NAllUArrays];
+
+  /// Names of the classes, the TClonesArrays are arrays of this type
+  static const char* uArrayTypes[NAllUArrays];
+
+  /// Maximum sizes of the TClonesArrays
+  static int uArraySizes[NAllUArrays];
+
+  /// Setup type indices
+  enum typeIndex{ Run=0, Event, Particle };
+};
+
+#endif // UArrays_h

+ 62 - 0
UDst.cxx

@@ -0,0 +1,62 @@
+// C++ headers
+#include <iostream>
+
+// UniGen headers
+#include "URun.h"
+#include "UEvent.h"
+#include "UParticle.h"
+#include "UDst.h" // MUST be the last one
+
+TClonesArray** UDst::uArrays = 0;
+
+//________________
+void UDst::unset() {
+  // Unset pointers
+  uArrays = 0;
+}
+
+//________________
+void UDst::set(TClonesArray** theUArrays) {
+  // Set pointers
+  uArrays = theUArrays;
+}
+
+//________________
+void UDst::print() {
+  // Print all information
+  std::cout << "\n==================== Full event information ====================\n";
+  printRunInfo();
+  printEventInfo();
+  printParticles();
+  std::cout << "\n================================================================\n";
+}
+
+//________________
+void UDst::printRunInfo() {
+  // Print run information
+  run()->print();
+}
+
+//________________
+void UDst::printEventInfo() {
+  // Print event information
+  event()->print();
+}
+
+//________________
+void UDst::printParticles() {
+  // Print all particles
+  if( numberOfParticles() == 0 ) {
+    std::cout << "No particles found!" << std::endl;
+    return;
+  }
+
+  std::cout << "\n Particle list contains: " << numberOfParticles() << " entries\n\n";
+  // Particle loop
+  for(UInt_t iPart=0; iPart<numberOfParticles(); iPart++) {
+    std::cout << "+++ particles #[" << iPart << "/" << numberOfParticles << "]\n";
+    particle(iPart)->print();
+  }
+
+  std::cout << std::endl;
+}

+ 53 - 0
UDst.h

@@ -0,0 +1,53 @@
+#ifndef UDst_h
+#define UDst_h
+
+// ROOT headers
+#include "TClonesArray.h"
+
+// UniGen headers
+#include "UArrays.h"
+
+// Forward declarations
+class UEvent;
+class URun;
+class UParticle;
+
+//________________
+class UDst {
+
+ public:
+  /// Default constructor
+  UDst()  { /* emtpy */ }
+  /// Destructor
+  ~UDst() { /* emtpy */ }
+
+  /// Set pointers to the TClonesArrays
+  static void set(TClonesArray** array);
+  /// Reset pointers to the TClonesArrays to 0
+  static void unset();
+  /// Return pointer to the i-th TClonesArray
+  static TClonesArray* uArray(Int_t type) { return uArrays[type]; }
+  /// Return pointer to the URun information
+  static URun* run() { return (URun*)uArrays[UArrays::Run]->UncheckedAt(0); }
+  /// Return pointer to the UEvent information
+  static UEvent* event() { return (UEvent*)uArrays[UArrays::Event]->UncheckedAt(0); }
+  /// Return pointer to the i-th particle
+  static UParticle* particle(Int_t i) { return (UParticle*)uArrays[UArrays::Particle]->UncheckedAt(i); }
+  /// Return number of particles in the current events
+  static UInt_t numberOfParticles() { return uArrays[UArrays::Particle]->GetEntries(); }
+
+  /// Print information
+  static void print();
+  /// Print run information
+  static void printRunInfo();
+  /// Print event information
+  static void printEventInfo();
+  /// Print particle information
+  static void printParticles();
+
+ private:
+  /// Array of TClonesArrays
+  static TClonesArray** uArrays;
+};
+
+#endif // #define UDst_h

+ 144 - 0
UEvent.cxx

@@ -0,0 +1,144 @@
+// C++ headers
+#include <iostream>
+
+// ROOT headers
+#include "TObject.h"
+#include "TString.h"
+#include "TClonesArray.h"
+
+// UNI headers
+#include "UParticle.h"
+#include "UEvent.h"
+
+ClassImp(UEvent);
+
+//_________________
+UEvent::UEvent() : TObject(), fEventNr(0), fB(0), fPhi(0),
+                   fNes(0), fStepNr(0), fStepT(0), fComment("") {
+  // Default constructor
+  /* empty */
+  fParticles = new TClonesArray("UParticle", 100);
+}
+
+//_________________
+UEvent::UEvent(const UEvent& right) : TObject() {
+  // Copy constructor
+  fEventNr  = right.fEventNr;
+  fB        = right.fB;
+  fPhi      = right.fPhi;
+  fNes      = right.fNes;
+  fStepNr   = right.fStepNr;
+  fStepT    = right.fStepT;
+  fComment  = right.fComment;
+}
+
+//_________________
+UEvent::~UEvent() {
+  // Destructor
+  Clear();
+  delete fParticles;
+}
+
+//_________________
+void UEvent::print(Option_t* option) {
+  // Print data members to the standard output
+  std::cout << "---------------------------------------------" << std::endl
+            << "-I-                 Event                 -I-" << std::endl
+            << "Event number               : " << fEventNr << std::endl
+            << "Impact parameter (fm)      : " << fB << std::endl
+            << "Reaction plane angle (rad) : " << fPhi << std::endl
+            << "Number of time steps       : " << fNes << std::endl
+            << "Time step number           : " << fStepNr << std::endl
+            << "Time of the time step (fm) : " << fStepT << std::endl
+            << "Number of particles        : " << fNpa << std::endl
+            << "Comment                    :\n" << fComment << std::endl;
+  TString opt = option;
+  if(opt.Contains("all")) {
+    UParticle* particle;
+    for(Int_t iPa = 0; iPa < fNpa; iPa++) {
+      particle = (UParticle*) fParticles->At(iPa);
+      particle->print(option);
+    }
+  }
+  std::cout << "---------------------------------------------" << std::endl;
+}
+
+//_________________
+UParticle* UEvent::GetParticle(Int_t index) const {
+  // Get pointer to the particle.
+  // index - index of the particle
+  if(index < 0) {
+    return nullptr;
+  }
+  if(index >= fNpa) {
+    return nullptr;
+  }
+  return ((UParticle*) fParticles->At(index));
+}
+
+//_________________
+void UEvent::AddParticle(Int_t index, Int_t pdg, Int_t status,
+                  			 Int_t parent, Int_t parentDecay,
+                  			 Int_t mate, Int_t decay, Int_t child[2],
+                  			 Double_t px, Double_t py, Double_t pz, Double_t e,
+                  			 Double_t x, Double_t y, Double_t z, Double_t t,
+                  			 Double_t weight) {
+  // Add particle to the array
+  new ((*fParticles)[fNpa]) UParticle(index, pdg, status, parent,
+				      parentDecay, mate, decay, child,
+				      px, py, pz, e, x, y, z, t, weight);
+  fNpa += 1;
+}
+
+//_________________
+void UEvent::AddParticle(Int_t index, Int_t pdg, Int_t status,
+                  			 Int_t parent, Int_t parentDecay,
+                  			 Int_t mate, Int_t decay, Int_t child[2],
+                  			 TLorentzVector mom, TLorentzVector pos,
+                  			 Double_t weight) {
+  // Add particle to the array
+  new ((*fParticles)[fNpa]) UParticle(index, pdg, status, parent,
+				      parentDecay, mate, decay, child,
+				      mom, pos, weight);
+  fNpa += 1;
+}
+
+//_________________
+void UEvent::AddParticle(const UParticle& particle) {
+  // Add particle to the array
+  new ((*fParticles)[fNpa]) UParticle(particle);
+  fNpa += 1;
+}
+
+//_________________
+void UEvent::setParameters(const Int_t& eventNr, const Double_t& b,
+                           const Double_t& phi, const Int_t& nes,
+                  			   const Int_t& stepNr, const Double_t& stepT,
+                           const char* comment) {
+  // Set the event parameters
+  fEventNr = (UInt_t)eventNr;
+  fB = (Float_t)b;
+  fPhi = (Float_t)phi;
+  fNes = ( ( nes > std::numeric_limits<unsigned short>::max() ) ?
+	   std::numeric_limits<unsigned short>::max() : (UShort_t)nes );
+  fStepNr = ( ( stepNr > std::numeric_limits<unsigned short>::max() ) ?
+	      std::numeric_limits<unsigned short>::max() : (UShort_t)stepNr ) ;
+  fStepT = (Float_t)stepT;
+  fComment = comment;
+}
+
+//_________________
+void UEvent::Clear() {
+  // Remove the particles from the array and reset counter
+  fParticles->Clear();
+  fNpa = 0;
+}
+
+//_________________
+void UEvent::RemoveAt(Int_t i) {
+  // Remove one particle from the array.
+  // i - index of the particle.
+  // Array is automaticaly compressed afterwards, mind the indexing
+  fParticles->RemoveAt(i);
+  fParticles->Compress();
+}

+ 126 - 0
UEvent.h

@@ -0,0 +1,126 @@
+#ifndef UEVENT_H
+#define UEVENT_H
+
+// C++ headers
+#include <limits>
+
+// ROOT headers
+#include "TObject.h"
+#include "TLorentzVector.h"
+
+// Forward declarations
+class TString;
+class TClonesArray;
+class UParticle;
+
+//_________________
+class UEvent : public TObject {
+
+ public:
+  /// Default constructor
+  UEvent();
+  /// Copy constructor
+  UEvent(const UEvent& right);
+  /// Default destructor
+  virtual ~UEvent();
+  /// Print event information
+  void print(Option_t* option = "");
+
+  //
+  // Getters
+  //
+
+  /// Return event number
+  Int_t eventNr() const   { return fEventNr; }
+  /// Return imparct parameter (fm)
+  Double_t b() const      { return (Double_t)fB; }
+  /// Return impact parameter (fm)
+  Double_t impact() const { return (Double_t)fB; }
+  /// Return reaction plane angle
+  Double_t phi() const { return (Double_t)fPhi; }
+  /// Return number of event steps
+  Int_t numberOfSteps() const { return (Int_t)fNes; }
+  /// Return time step (stamp) number
+  Int_t stepNumber() const    { return (Int_t)fStepNr; }
+  /// Return time of the step (stamp)
+  Double_t stepT() const      { return (Double_t)fStepT; }
+  /// Return time of the step (stamp)
+  Double_t stepTime() const   { return stepT(); }
+  /// Return comment
+  void comment(TString& comment) const { comment = fComment; }
+
+  Int_t    GetNpa()     const {return (Int_t)fNpa;}
+  TClonesArray* GetParticleList() const {return fParticles;}
+  UParticle* GetParticle(Int_t index) const;
+
+  //
+  // Setters
+  //
+
+  /// Set all event parameters
+  void setParameters(const Int_t& eventNr, const Double_t& b, const Double_t& phi,
+                     const Int_t& nes, const Int_t& stepNr, const Double_t& stepT,
+                     const char* comment = "");
+  /// Set event number
+  void setEventNr(const Int_t& eventNr)  { fEventNr = (UInt_t)eventNr; }
+  /// Set impact parameter
+  void setB(const Double_t& b)           { fB = (Float_t)b; }
+  /// Set impact parameter
+  void setImpact(const Double_t& impact) { setB( impact ); }
+  /// Set reaction plane angle
+  void setPhi(const Double_t& phi)       { fPhi = (Float_t)phi; }
+  /// Set number of steps
+  void setNumberOfSteps(const Int_t& nes)
+  { fNes = ( ( nes > std::numeric_limits<unsigned short>::max() ) ?
+	           std::numeric_limits<unsigned short>::max() : (UShort_t)nes ); }
+  /// Set number of steps
+  void setNes(const Int_t& nes)
+  { fNes = ( ( nes > std::numeric_limits<unsigned short>::max() ) ?
+	     std::numeric_limits<unsigned short>::max() : (UShort_t)nes ); }
+  /// Set the current step number
+  void setStepNr(const Int_t& stepNr)
+  { fStepNr = ( ( stepNr > std::numeric_limits<unsigned short>::max() ) ?
+		std::numeric_limits<unsigned short>::max() : (UShort_t)stepNr ); }
+  /// Set time of the current step
+  void setStepT(const Double_t& stepT)   { fStepT = (Float_t)stepT; }
+  /// Set time of the current step
+  void setStepTime(const Double_t& time) { setStepT( time ); }
+  /// Set comment
+  void setComment(const char* comment)   { fComment = comment; }
+
+  void AddParticle(Int_t index, Int_t pdg, Int_t status, Int_t parent, Int_t parentDecay,
+		   Int_t mate, Int_t decay, Int_t child[2],
+		   Double_t px, Double_t py, Double_t pz, Double_t e,
+		   Double_t x, Double_t y, Double_t z, Double_t t,
+		   Double_t weight);
+  void AddParticle(Int_t index, Int_t pdg, Int_t status, Int_t parent, Int_t parentDecay,
+		   Int_t mate, Int_t decay, Int_t child[2],
+		   TLorentzVector mom, TLorentzVector pos, Double_t weight);
+  void AddParticle(const UParticle& particle);
+  void Clear();
+  void RemoveAt(Int_t i);
+
+ private:
+  /// Event number
+  UInt_t        fEventNr;
+  /// Impact parameter (fm)
+  Float_t       fB;
+  /// Reaction plane angle
+  Float_t       fPhi;
+  /// Number of event steps
+  UShort_t      fNes;
+  // Event step number
+  UShort_t      fStepNr;
+  /// Event step time
+  Float_t       fStepT;
+  /// Number of particles
+  UShort_t      fNpa;
+  /// Generator-specific information
+  TString       fComment;
+  /// Array of particles
+  TClonesArray* fParticles;
+
+  ClassDef(UEvent, 4);
+};
+
+#endif

+ 282 - 0
UManager.cxx

@@ -0,0 +1,282 @@
+#include <iostream>
+using namespace std;
+
+#include "TFile.h"
+#include "TTree.h"
+#include "TList.h"
+
+#include "UTask.h"
+#include "URun.h"
+#include "UEvent.h"
+#include "UManager.h"
+
+ClassImp(UManager)
+
+//____________________________________________________________________
+//
+// UManager
+//
+// This class is the singleton manager for organising I/O and task
+// execution.
+// SetInputFile and SetOutputFile are used to set the input and
+// output files.
+// User tasks, which are derived from the UTask class, with
+// implemented Init and Exec functions, are to be added using
+// AddTask function.
+// Init and Run functions make initialisation and execution
+//
+
+
+UManager *UManager::fgInstance = NULL;
+
+
+//--------------------------------------------------------------------
+UManager::UManager()
+{
+  // Default constructor
+  if(NULL != fgInstance) {
+    Fatal("UManager", "Singleton class instantiated twice!");
+  }
+  fgInstance = this;
+  fInFile = nullptr;
+  fOutFile = nullptr;
+  fInTree = nullptr;
+  fOutTree = nullptr;
+  fEvent = nullptr;
+  fRun = nullptr;
+  fTaskList = new TList();
+  fWrite = kTRUE;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+UManager::~UManager()
+{
+  // Destructor
+  fgInstance = nullptr;
+  CloseInputFile();
+  CloseOutputFile();
+  fInTree = nullptr;
+  fOutTree = nullptr;
+  fEvent = nullptr;
+  fRun = nullptr;
+  delete fTaskList;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+UManager* UManager::Instance()
+{
+  // Get instance of singleton manager
+  return fgInstance;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void UManager::SetInputFile(const char *name)
+{
+  // Open the input file and get the run description and tree of events,
+  // which later can be accessed by GetRun and GetEvent respectively.
+  // name - name of the input file
+  fInFile = TFile::Open(name);
+  if(nullptr == fInFile) {
+    Fatal("SetInputFile", "Input file does not exist!");
+  }
+
+  fRun = (URun*) fInFile->Get("run");
+
+  fInTree = (TTree*) fInFile->Get("events");
+  if(nullptr == fInTree) {
+    Fatal("SetInputFile", "Input file has no events tree!");
+  }
+  cout << "-I- UManager : Input file has " << fInTree->GetEntries() << " events"
+       << endl;
+
+  if(nullptr == fEvent) {
+      fEvent = new UEvent();
+  }
+  fInTree->SetBranchAddress("event", &fEvent);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void UManager::CloseInputFile()
+{
+  // Close the input file
+  if(nullptr != fInFile) {
+    fInFile->Close();
+    fInFile = nullptr;
+  }
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void UManager::SetOutputFile(const char *name, Bool_t writeTree)
+{
+  // Open the output file. Create the output tree with event branch.
+  // name - name of the output file
+  fOutFile = TFile::Open(name, "RECREATE");
+  if(fOutFile == nullptr) {
+    Fatal("SetOutputFile", "Output file can not be created!");
+  }
+  if(writeTree) {
+    // Added by Grigory Nigmatkulov
+    fOutFile->SetCompressionLevel(9);
+    int bufsize =  65536;
+    int split = 99;
+
+    //fOutTree = new TTree("events", "Event data");
+    fOutTree = new TTree("events", "Event data", split);
+    fOutTree->SetAutoSave(1000000);
+    if(fEvent == nullptr) {
+      fEvent = new UEvent();
+    }
+
+    //fOutTree->Branch("event", &fEvent);
+    fOutTree->Branch("event", &fEvent, bufsize, split);
+  }
+}
+
+//--------------------------------------------------------------------
+void UManager::CloseOutputFile()
+{
+  // Close the output file
+  if(nullptr != fOutFile) {
+    fOutFile->Close();
+    fOutFile = nullptr;
+  }
+}
+
+//--------------------------------------------------------------------
+Int_t UManager::GetEntries()
+{
+  // Get the number of entries in input tree
+  if(nullptr == fInTree) return 0;
+  return fInTree->GetEntries();
+}
+
+//--------------------------------------------------------------------
+void UManager::GetEntry(Int_t i)
+{
+  // Get entry from the input tree.
+  // i - index of entry
+  if(nullptr == fInTree) return;
+  fInTree->GetEntry(i);
+}
+
+//--------------------------------------------------------------------
+void UManager::Fill()
+{
+  // Fill the output tree
+  if(nullptr != fOutTree) {
+    if(fWrite) {
+      fOutTree->Fill();
+    } else {
+      fWrite = kTRUE;
+    }
+  }
+}
+
+//--------------------------------------------------------------------
+void UManager::AddTask(UTask *task) {
+  // Add task to the task list.
+  // task - pointer to the task
+  fTaskList->Add(task);
+}
+
+//--------------------------------------------------------------------
+void UManager::createRun(const char* generator, const char* comment,
+			 const Int_t& aProj, const Int_t& zProj, const Double_t& pProj,
+			 const Int_t& aTarg, const Int_t& zTarg, const Double_t& pTarg,
+			 const Double_t& bMin, const Double_t& bMax, const Int_t& bWeight,
+			 const Double_t& phiMin, const Double_t& phiMax,
+			 const Double_t& sigma, const Int_t& nEvents) {
+  // Creates the run description, which later can be accessed by GetRun method
+  fRun = new URun(generator, comment,
+		  aProj, zProj, pProj, aTarg, zTarg, pTarg,
+		  bMin, bMax, bWeight, phiMin, phiMax, sigma, nEvents);
+}
+
+//--------------------------------------------------------------------
+void UManager::Init()
+{
+  // Run initialisation of the tasks
+  UTask *task;
+  for(Int_t i = 0; i < fTaskList->GetSize(); i++) {
+    task = (UTask*) fTaskList->At(i);
+    task->Init();
+  }
+}
+
+//--------------------------------------------------------------------
+void UManager::Run(Int_t a, Int_t b)
+{
+  // Execute the tasks.
+  // Run()    - process all events from input tree.
+  // Run(i)   - process only i-th event
+  // Run(i,j) - process events from i-th to j-th
+  if(nullptr==fInTree && nullptr==fOutTree) return;
+
+  UTask *task;
+  if(nullptr==fInTree) {
+
+    for(Int_t i = 0; i < a; i++) {
+      for(Int_t i = 0; i < fTaskList->GetSize(); i++) {
+	task = (UTask*) fTaskList->At(i);
+	task->Exec();
+      }
+      Fill();
+    }
+
+  } else {
+
+    if(-1==a && -1==b) {
+      for(Int_t iEv = 0; iEv < GetEntries(); iEv++) {
+	GetEntry(iEv);
+	for(Int_t i = 0; i < fTaskList->GetSize(); i++) {
+	  task = (UTask*) fTaskList->At(i);
+	  task->Exec();
+	}
+	Fill();
+      }
+    } else if(a>-1 && -1==b) {
+      GetEntry(a);
+      for(Int_t i = 0; i < fTaskList->GetSize(); i++) {
+	task = (UTask*) fTaskList->At(i);
+	task->Exec();
+      }
+      Fill();
+    } else {
+      for(Int_t iEv = a; iEv < b; iEv++) {
+	GetEntry(iEv);
+	for(Int_t i = 0; i < fTaskList->GetSize(); i++) {
+	  task = (UTask*) fTaskList->At(i);
+	  task->Exec();
+	}
+	Fill();
+      }
+    }
+
+  }
+
+  for(Int_t i = 0; i < fTaskList->GetSize(); i++) {
+    task = (UTask*) fTaskList->At(i);
+    task->Finish();
+  }
+
+  if(nullptr != fOutFile) {
+    if(nullptr != fOutTree) {
+      fOutFile->cd();
+      fOutTree->Write();
+    }
+    if(nullptr != fRun) {
+      fOutFile->cd();
+      fRun->Write();
+    }
+  }
+}

+ 79 - 0
UManager.h

@@ -0,0 +1,79 @@
+#ifndef UManager_h
+#define UManager_h
+
+// ROOT headers
+#include "TObject.h"
+
+// Forward declarations
+class TFile;
+class TTree;
+class TList;
+
+class UTask;
+class URun;
+class UEvent;
+
+//_________________
+class UManager : public TObject {
+ public:
+  /// Constructor
+  UManager();
+  /// Destructor
+  virtual ~UManager();
+
+  static UManager* Instance();
+
+  void SetInputFile(const char *fileName);
+  void CloseInputFile();
+  void SetOutputFile(const char *fileName, Bool_t writeTree = kTRUE);
+  void CloseOutputFile();
+
+  Int_t GetEntries();
+  void GetEntry(Int_t i);
+
+  void AddTask(UTask *task);
+
+  void Init();
+  void Run(Int_t a = -1, Int_t b = -1);
+
+  void WriteEvent(Bool_t flag = kTRUE) {fWrite = flag;}
+
+  void Fill();
+
+  void createRun(const char* generator, const char* comment,
+		 const Int_t& aProj, const Int_t& zProj, const Double_t& pProj,
+		 const Int_t& aTarg, const Int_t& zTarg, const Double_t& pTarg,
+		 const Double_t& bMin, const Double_t& bMax, const Int_t& bWeight,
+		 const Double_t& phiMin, const Double_t& phiMax,
+		 const Double_t& sigma, const Int_t& nEvents);
+
+  URun* run() const     { return fRun; }
+  UEvent* event() const { return fEvent; }
+
+ private:
+  /// Instance of the manager
+  static UManager *fgInstance;
+  /// List of tasks
+  TList  *fTaskList;
+  /// Input file
+  TFile  *fInFile;
+  /// Output file
+  TFile  *fOutFile;
+  /// Input tree
+  TTree  *fInTree;
+  /// Output tree
+  TTree  *fOutTree;
+  /// Run object
+  URun *fRun;
+  /// Event
+  UEvent *fEvent;
+  /// Particle
+  UParticle *fParticle;
+  /// Output flag
+  Bool_t  fWrite;
+
+  ClassDef(UManager, 1);
+};
+
+
+#endif // UManager_h

+ 110 - 0
UPIDConverter.cxx

@@ -0,0 +1,110 @@
+// UNI headers
+#include "UPIDConverter.h"
+
+// ROOT headers
+#include "TROOT.h"
+#include "TSystem.h"
+
+// C++ headers
+#include <fstream>
+
+ClassImp(UPIDConverter);
+
+UPIDConverter* UPIDConverter::fgInstance = NULL;
+
+//_________________
+UPIDConverter::UPIDConverter() : TNamed("PIDConverter", "Any-to-PDG particle-ID converter") {
+  if (fgInstance) {
+    Warning("UPIDConverter", "object already instantiated");
+  }
+  else {
+    fgInstance = this;
+    gROOT->GetListOfSpecials()->Add(this);
+  }
+}
+
+//_________________
+Int_t UPIDConverter::GetPDGCode(const Int_t pid, const EConvention pidType) {
+  /* Trivial case first */
+  if (pidType == ePDG)
+    return pid;
+
+  ConversionTableMap::const_iterator mIt = fConversionTables.find(pidType);
+  
+  /* Either pidType has been set to an unknown value or the conversion table
+     for specified convention hasn't been loaded yet. Assume the latter and
+     try to do so now; if we still cannot find the table afterwards then
+     something is indeed wrong. */
+  if (mIt == fConversionTables.end()) {
+    LoadConversionTable(pidType);
+    mIt = fConversionTables.find(pidType);
+    if (mIt == fConversionTables.end()) {
+      Error("GetPDGCode",
+            "PID conversion table not available for convention=%u",
+            pidType);
+      return 0;
+    }
+  }
+
+  const std::map<Int_t, Int_t>& conversionTable = mIt->second;
+  std::map<Int_t, Int_t>::const_iterator pidIt = conversionTable.find(pid);
+  if (pidIt == conversionTable.end()) {
+    Warning("GetPDGCode", "PDG code not found for convention=%u, pid=%d",
+            pidType, pid);
+    return 0;
+  }
+
+  return pidIt->second;
+}
+
+//_________________
+UPIDConverter* UPIDConverter::Instance() {
+  return (fgInstance) ? fgInstance : new UPIDConverter();
+}
+
+//_________________
+void UPIDConverter::LoadConversionTable(const EConvention pidType) {
+  std::string dataFileName = "/input/";
+  switch (pidType) {
+    case (ePluto):
+      dataFileName += "pluto_pdg.dat";
+      break;
+    case (eUrQMD):
+      dataFileName += "urqmd_pdg.dat";
+      break;
+    case (eWerner):
+      // VENUS, NEXUS, EPOS
+      dataFileName += "werner_pdg.dat";
+      break;
+    default:
+      Error("LoadConversionTable",
+            "I do not know where to find conversion table for convention=%u",
+            pidType);
+      return;
+  }
+
+  std::string unigenBase = gSystem->Getenv("UNIGEN");
+  unigenBase += dataFileName;
+  const char* fullFileName = unigenBase.c_str();
+  std::ifstream fin;
+  fin.open(fullFileName);
+  if (! fin.good()) {
+    Error("LoadConversionTable",
+          "Failed to open conversion-table file %s", fullFileName);
+    return;
+  }
+
+  std::map<Int_t, Int_t>& conversionTable = fConversionTables[pidType];
+  Int_t localPid;
+  Int_t pdgPid;
+  while (1) {
+    // FIXME: we might want to make this more robust against malformed input
+    if (fin.eof())
+      break;
+    fin >> localPid >> pdgPid;
+    conversionTable[localPid] = pdgPid;
+  }
+  fin.close();
+
+  return;
+}

+ 40 - 0
UPIDConverter.h

@@ -0,0 +1,40 @@
+#ifndef UPIDCONVERTER_H
+#define UPIDCONVERTER_H
+
+// C++ headers
+#include <map>
+
+// ROOT headers
+#include "TNamed.h"
+
+//_________________
+class UPIDConverter : public TNamed {
+
+ public:
+  typedef enum {
+    ePDG = -1,
+    ePluto,
+    eUrQMD,
+    eWerner
+  } EConvention;
+
+  UPIDConverter();
+
+  Int_t GetPDGCode(const Int_t pid, const EConvention pidType);
+
+  static UPIDConverter* Instance();
+
+ private:
+  // We should use 'EConvention' as the map key type, however this confused rootcint.
+  // For the time being use UInt_t instead, hopefully fix this later (FIXME).
+  typedef std::map<UInt_t, std::map<Int_t, Int_t> > ConversionTableMap;
+
+  void LoadConversionTable(const EConvention pidType);
+
+  ConversionTableMap fConversionTables;
+  static UPIDConverter* fgInstance;
+
+  ClassDef(UPIDConverter, 0);
+};
+
+#endif

+ 252 - 0
UParticle.cxx

@@ -0,0 +1,252 @@
+// C++ headers
+#include <iostream>
+
+// UNI headers
+#include "UParticle.h"
+
+ClassImp(UParticle);
+
+//----------------
+UParticle::UParticle() : TObject(),
+  fIndex(0), fPdg(0), fStatus(0), fParent(0), fParentDecay(0),
+  fMate(0), fDecay(0), fChild{}, fPx(0), fPy(0), fPz(0),
+  fX(0), fY(0), fZ(0), fT(0), fWeight(0) { // Default constructor
+  /* empty */
+}
+
+//----------------
+UParticle::UParticle(Int_t index, Int_t pdg, Int_t status,
+		                 Int_t parent, Int_t parentDecay,
+            		     Int_t mate, Int_t decay, Int_t child[2],
+            		     Double_t px, Double_t py, Double_t pz, Double_t e,
+            		     Double_t x, Double_t y, Double_t z, Double_t t,
+            		     Double_t weight) : TObject() {
+  // Standard constructor
+  fIndex = ( (index > std::numeric_limits<unsigned short>::max() ) ?
+	     std::numeric_limits<unsigned short>::max() : (UShort_t)index );
+  fPdg         = pdg;
+  if ( status <= std::numeric_limits<char>::min() ) {
+    fStatus = std::numeric_limits<char>::min();
+  }
+  else if ( status >= std::numeric_limits<char>::max() ) {
+    fStatus = std::numeric_limits<char>::max();
+  }
+  else {
+    fStatus = (Char_t)status;
+  }
+  fParent = ( ( parent > std::numeric_limits<unsigned short>::max() ) ?
+	      std::numeric_limits<unsigned short>::max() : (UShort_t)parent );
+  fParentDecay = ( ( parentDecay > std::numeric_limits<unsigned short>::max() ) ?
+		   std::numeric_limits<unsigned short>::max() : (UShort_t)parentDecay );
+  fMate = ( (mate > std::numeric_limits<unsigned short>::max() ) ?
+	    std::numeric_limits<unsigned short>::max() : (UShort_t)mate );
+  fDecay = ( ( TMath::Abs(decay) > std::numeric_limits<short>::max() ) ?
+	     std::numeric_limits<short>::max() : (Short_t)decay );
+  fChild[0] = ( (child[0] > std::numeric_limits<unsigned short>::max() ) ?
+		std::numeric_limits<unsigned short>::max() : (UShort_t)child[0] );
+  fChild[1] = ( (child[1] > std::numeric_limits<unsigned short>::max() ) ?
+		std::numeric_limits<unsigned short>::max() : (UShort_t)child[1] );
+  fPx = (Float_t)px;
+  fPy = (Float_t)py;
+  fPz = (Float_t)pz;
+  fX  = (Float_t)x;
+  fY  = (Float_t)y;
+  fZ  = (Float_t)z;
+  fT  = (Float_t)t;
+  fWeight = (Float_t)weight;
+}
+
+//----------------
+UParticle::UParticle(Int_t index, Int_t pdg, Int_t status,
+		     Int_t parent, Int_t parentDecay,
+		     Int_t mate, Int_t decay, Int_t child[2],
+		     TLorentzVector mom, TLorentzVector pos,
+		     Double_t weight) : TObject() {
+  // Standard constructor
+  fIndex = ( (index > std::numeric_limits<unsigned short>::max() ) ?
+	     std::numeric_limits<unsigned short>::max() : (UShort_t)index );
+  fPdg         = pdg;
+  if ( status <= std::numeric_limits<char>::min() ) {
+    fStatus = std::numeric_limits<char>::min();
+  }
+  else if ( status >= std::numeric_limits<char>::max() ) {
+    fStatus = std::numeric_limits<char>::max();
+  }
+  else {
+    fStatus = (Char_t)status;
+  }
+  fParent = ( ( parent > std::numeric_limits<unsigned short>::max() ) ?
+	      std::numeric_limits<unsigned short>::max() : (UShort_t)parent );
+  fParentDecay = ( ( parentDecay > std::numeric_limits<unsigned short>::max() ) ?
+		   std::numeric_limits<unsigned short>::max() : (UShort_t)parentDecay );
+  fMate = ( (mate > std::numeric_limits<unsigned short>::max() ) ?
+	    std::numeric_limits<unsigned short>::max() : (UShort_t)mate );
+  fDecay = ( ( TMath::Abs(decay) > std::numeric_limits<short>::max() ) ?
+	     std::numeric_limits<short>::max() : (Short_t)decay );
+  fChild[0] = ( (child[0] > std::numeric_limits<unsigned short>::max() ) ?
+		std::numeric_limits<unsigned short>::max() : (UShort_t)child[0] );
+  fChild[1] = ( (child[1] > std::numeric_limits<unsigned short>::max() ) ?
+		std::numeric_limits<unsigned short>::max() : (UShort_t)child[1] );
+  fPx = (Float_t)mom.Px();
+  fPy = (Float_t)mom.Py();
+  fPz = (Float_t)mom.Pz();
+  fX = (Float_t)pos.X();
+  fY = (Float_t)pos.Y();
+  fZ = (Float_t)pos.Z();
+  fT = (Float_t)pos.T();
+  fWeight = (Float_t)weight;
+}
+
+//----------------
+UParticle::UParticle(const UParticle& right) {
+  // Copy constructor
+  fIndex = right.fIndex;
+  fPdg = right.fPdg;
+  fStatus = right.fStatus;
+  fParent = right.fParent;
+  fParentDecay = right.fParentDecay;
+  fMate = right.fMate;
+  fDecay = right.fDecay;
+  fChild[0] = right.fChild[0];
+  fChild[1] = right.fChild[1];
+  fPx = right.fPx;
+  fPy = right.fPy;
+  fPz = right.fPz;
+  fX = right.fX;
+  fY = right.fY;
+  fZ = right.fZ;
+  fT = right.fT;
+  fWeight = right.fWeight;
+}
+
+//----------------
+const UParticle& UParticle::operator=(const UParticle& right) {
+  // Assignment operator
+  if( this != &right ) {
+    fIndex = right.fIndex;
+    fPdg = right.fPdg;
+    fStatus = right.fStatus;
+    fParent = right.fParent;
+    fParentDecay = right.fParentDecay;
+    fMate = right.fMate;
+    fDecay = right.fDecay;
+    fChild[0] = right.fChild[0];
+    fChild[1] = right.fChild[1];
+    fPx = right.fPx;
+    fPy = right.fPy;
+    fPz = right.fPz;
+    fX = right.fX;
+    fY = right.fY;
+    fZ = right.fZ;
+    fT = right.fT;
+    fWeight = right.fWeight;
+  }
+  return (*this);
+}
+
+//----------------
+UParticle::UParticle(const TParticle &right) {
+  // Copy constructor from the TParticle
+  fIndex = 0;
+  fPdg = right.GetPdgCode();
+  fStatus = right.GetStatusCode();
+  fParent = right.GetFirstMother();
+  fParentDecay = 0;
+  fMate = 0;
+  fDecay = 0;
+  fChild[0] = right.GetFirstDaughter();
+  fChild[1] = right.GetLastDaughter();
+  fPx = right.Px();
+  fPy = right.Py();
+  fPz = right.Pz();
+  //fE = right.Energy();
+  fX = right.Vx();
+  fY = right.Vy();
+  fZ = right.Vz();
+  fT = right.T();
+  fWeight = right.GetWeight();
+}
+
+//----------------
+const UParticle& UParticle::operator=(const TParticle &right) {
+  // Assignment operator from the TParticle
+  fIndex = 0;
+  fPdg = right.GetPdgCode();
+  fStatus = right.GetStatusCode();
+  fParent = right.GetFirstMother();
+  fParentDecay = 0;
+  fMate = 0;
+  fDecay = 0;
+  fChild[0] = right.GetFirstDaughter();
+  fChild[1] = right.GetLastDaughter();
+  fPx = right.Px();
+  fPy = right.Py();
+  fPz = right.Pz();
+  //fE = right.Energy();
+  fX = right.Vx();
+  fY = right.Vy();
+  fZ = right.Vz();
+  fT = right.T();
+  fWeight = right.GetWeight();
+
+  return (*this);
+}
+
+//----------------
+UParticle::~UParticle() { // Destructor
+  /* empty */
+}
+
+//----------------
+const Bool_t UParticle::operator == (const UParticle& right) const {
+  // If equal operator
+  return (
+	  fIndex       == right.fIndex &&
+	  fPdg         == right.fPdg &&
+	  fStatus      == right.fStatus &&
+	  fParent      == right.fParent &&
+	  fParentDecay == right.fParentDecay &&
+	  fMate        == right.fMate &&
+	  fDecay       == right.fDecay &&
+	  fChild[0]    == right.fChild[0] &&
+	  fChild[1]    == right.fChild[1] &&
+	  ((TMath::Abs((fPx-right.fPx)/fPx)<0.0001) ||
+	   (TMath::Abs(fPx)<1e-16&&TMath::Abs(right.fPx)<1e-16)) &&
+	  ((TMath::Abs((fPy-right.fPy)/fPy)<0.0001) ||
+	   (TMath::Abs(fPy)<1e-16&&TMath::Abs(right.fPy)<1e-16)) &&
+	  ((TMath::Abs((fPz-right.fPz)/fPz)<0.0001) ||
+	   (TMath::Abs(fPz)<1e-16&&TMath::Abs(right.fPz)<1e-16)) &&
+	  ((TMath::Abs((fX-right.fX)/fX)<0.0001) ||
+	   (TMath::Abs(fX)<1e-16&&TMath::Abs(right.fX)<1e-16)) &&
+	  ((TMath::Abs((fY-right.fY)/fY)<0.0001) ||
+	   (TMath::Abs(fY)<1e-16&&TMath::Abs(right.fY)<1e-16)) &&
+	  ((TMath::Abs((fZ-right.fZ)/fZ)<0.0001) ||
+	   (TMath::Abs(fZ)<1e-16&&TMath::Abs(right.fZ)<1e-16)) &&
+	  ((TMath::Abs((fT-right.fT)/fT)<0.0001) ||
+	   (TMath::Abs(fT)<1e-16&&TMath::Abs(right.fT)<1e-16)) &&
+	  ((TMath::Abs((fWeight-right.fWeight)/fWeight)<0.0001) ||
+	   (TMath::Abs(fWeight)<1e-16&&TMath::Abs(right.fWeight)<1e-16))
+	  );
+}
+
+//----------------
+void UParticle::print(Option_t* option) {
+  // Print the data members to the standard output
+  std::cout << "------------------------------------------------" << std::endl
+           << "-I-                 Particle                 -I-" << std::endl
+           << "Index                       : " << fIndex << std::endl
+           << "PDG code                    : " << fPdg << std::endl
+           << "Status code                 : " << fStatus << std::endl
+           << "Parent index                : " << fParent << std::endl
+           << "Parent decay index          : " << fParentDecay << std::endl
+           << "Last collision partner      : " << fMate << std::endl
+           << "Decay index                 : " << fDecay << std::endl
+           << "First child index           : " << fChild[0] << std::endl
+           << "Last child index            : " << fChild[1] << std::endl
+           << "Momentum (px, py, pz) (GeV) : (" << fPx << ", " << fPy << ", " << fPz << ")" << std::endl
+        // << "Energy (GeV)                : " << fE << std::endl
+           << "Position (x, y, z) (fm)     : (" << fX << ", " << fY << ", " << fZ << ")" << std::endl
+           << "Creation time (fm)          : " << fT << std::endl
+           << "Weight                      : " << fWeight << std::endl
+           << "------------------------------------------------" << std::endl;
+}

+ 233 - 0
UParticle.h

@@ -0,0 +1,233 @@
+#ifndef UPARTICLE_H
+#define UPARTICLE_H
+
+// C++ headers
+#include <limits>
+
+// ROOT headers
+#include "TObject.h"
+#include "TLorentzVector.h"
+#include "TMath.h"
+#include "TDatabasePDG.h"
+#include "TParticlePDG.h"
+#include "TParticle.h"
+
+//_________________
+class UParticle : public TObject {
+
+ public:
+  /// Default constructor
+  UParticle();
+  /// Constructor that takes parameters
+  UParticle(Int_t index, Int_t pdg, Int_t status,
+      	    Int_t parent, Int_t parentDecay,
+      	    Int_t mate, Int_t decay, Int_t child[2],
+      	    Double_t px, Double_t py, Double_t pz, Double_t e,
+      	    Double_t x, Double_t y, Double_t z, Double_t t,
+      	    Double_t weight);
+  /// Another constructor with parameters
+  UParticle(Int_t index, Int_t pdg, Int_t status,
+      	    Int_t parent, Int_t parentDecay,
+      	    Int_t mate, Int_t decay, Int_t child[2],
+      	    TLorentzVector mom, TLorentzVector pos,
+      	    Double_t weight);
+  /// Copy constructor that takes UParticle
+  UParticle(const UParticle& right);
+  /// Copy constructor that takes TParticle
+  UParticle(const TParticle& right);
+  /// Destructor
+  virtual ~UParticle();
+  /// Assignement operator
+  const UParticle& operator=(const UParticle& right);
+  /// Assignement operator
+  const UParticle& operator=(const TParticle& right);
+  /// Comparison operator
+  const Bool_t operator==(const UParticle& right) const;
+  void print(Option_t* option = "");
+
+  //
+  // Getters
+  //
+
+  /// Return particle index
+  Int_t index() const       { return (Int_t)fIndex; }
+  /// Return PDG code
+  Int_t pdg() const         { return fPdg; }
+  /// Return particle status
+  Int_t status() const      { return (Int_t)fStatus; }
+  /// Return parent index
+  Int_t parent() const      { return (Int_t)fParent; }
+  /// Return parent decay index
+  Int_t parentDecay() const { return (Int_t)fParentDecay; }
+  /// Return index of the last collision partner
+  Int_t mate() const        { return (Int_t)fMate; }
+  /// Return decay index (-1 if not decayed)
+  Int_t decay() const       { return (Int_t)fDecay; }
+  /// Return index of the first child
+  Int_t firstChild() const  { return (Int_t)fChild[0]; }
+  /// Return index of the second child
+  Int_t lastChild() const   { return (Int_t)fChild[1]; }
+  /// Return px (GeV/c)
+  Double_t px() const       { return (Double_t)fPx; }
+  /// Return py (GeV/c)
+  Double_t py() const       { return (Double_t)fPy; }
+  /// Return pz (GeV/c)
+  Double_t pz() const       { return (Double_t)fPz; }
+  /// Return p (GeV/c)
+  Double_t ptot() const
+  { return TMath::Sqrt( px()*px() + py()*py() + pz()*pz() ); }
+  /// Return transverse momentum (pT)
+  Double_t pt() const
+  { return TMath::Sqrt( px()*px() + py()*py() ); }
+  /// Return mass (GeV/c^2)
+  Double_t mass() const
+  { return TDatabasePDG::Instance()->GetParticle( fPdg )->Mass(); }
+  /// Return charge
+  Double_t charge() const
+  { return TDatabasePDG::Instance()->GetParticle( fPdg )->Charge(); }
+  /// Return energy of the particle (GeV)
+  Double_t energy() const
+  { return TMath::Sqrt( ptot()*ptot() + mass()*mass() ); }
+  /// Return energy (GeV)
+  Double_t e() const        { return energy(); }
+  /// Return pseudorapidity
+  Double_t eta() const      { return momentum().Eta(); }
+  /// Return pseudorapidity
+  Double_t pseudoRapidity() const { return momentum().Eta(); }
+  /// Return four-momentum (px,py,pz,E)
+  TLorentzVector momentum() const
+  { return TLorentzVector( fPx, fPy, fPz, e() ); }
+  /// Set four-momentum to the mom vector
+  void momentum(TLorentzVector& mom) const
+  { mom.SetXYZM( fPx, fPy, fPz, mass() ); }
+  /// Return x position (fm)
+  Double_t x() const        { return (Double_t)fX; }
+  /// Return y position (fm)
+  Double_t y() const        { return (Double_t)fY; }
+  /// Return z position (fm)
+  Double_t z() const        { return (Double_t)fZ; }
+  /// Return t position (fm)
+  Double_t t() const        { return (Double_t)fT; }
+  /// Return four-coordinate (x,y,z,t)
+  TLorentzVector position() const
+  { return TLorentzVector( fX, fY, fZ, fT ); }
+  /// Set four-coordinate to the pos vector
+  void position(TLorentzVector& pos) const
+  { pos.SetXYZT( fX, fY, fZ, fT); }
+  /// Return weight
+  Double_t weight() const   { return fWeight; }
+
+  //
+  // Setters
+  //
+
+  /// Set particle index
+  void setIndex(const Int_t& index)
+  { fIndex = ( (index > std::numeric_limits<unsigned short>::max() ) ?
+	             std::numeric_limits<unsigned short>::max() : (UShort_t)index ); }
+  /// Set PdgId (pdg code)
+  void setPdg(const Int_t& pdg) {fPdg = pdg;}
+  /// Set status
+  void setStatus(const Int_t& status)
+  { if ( status <= std::numeric_limits<char>::min() ) { fStatus = std::numeric_limits<char>::min(); }
+    else if ( status >= std::numeric_limits<char>::max() ) { fStatus = std::numeric_limits<char>::max(); }
+    else { fStatus = (Char_t)status; } }
+  /// Set parent index
+  void setParent(const Int_t& parent)
+  { fParent = ( ( parent > std::numeric_limits<unsigned short>::max() ) ?
+		            std::numeric_limits<unsigned short>::max() : (UShort_t)parent ); }
+  /// Set parent decay index
+  void setParentDecay(const Int_t& parentDecay)
+  { fParentDecay = ( ( parentDecay > std::numeric_limits<unsigned short>::max() ) ?
+		                 std::numeric_limits<unsigned short>::max() : (UShort_t)parentDecay ); }
+  /// Set index of the last collision partner
+  void setMate(const Int_t& mate)
+  { fMate = ( (mate > std::numeric_limits<unsigned short>::max() ) ?
+	            std::numeric_limits<unsigned short>::max() : (UShort_t)mate ); }
+  /// Set decay index (-1 if not decayed)
+  void setDecay(const Int_t& decay)
+  { fDecay = ( ( TMath::Abs(decay) > std::numeric_limits<short>::max() ) ?
+	             std::numeric_limits<short>::max() : (Short_t)decay ); }
+  /// Set 2 childer indeces
+  void setChild(Int_t child[2])
+  { setFirstChild( child[0] ); setLastChild( child[1] ); }
+  /// Set index of the first child
+  void setFirstChild(const Int_t& child)
+  { fChild[0] = ( (child > std::numeric_limits<unsigned short>::max() ) ?
+		              std::numeric_limits<unsigned short>::max() : (UShort_t)child ); }
+  /// Set index of the second child
+  void setLastChild(const Int_t& child)
+  { fChild[1] = ( (child > std::numeric_limits<unsigned short>::max() ) ?
+		              std::numeric_limits<unsigned short>::max() : (UShort_t)child ); }
+  /// Set px (GeV/c)
+  void setPx(const Double_t& px)       {fPx = (Float_t)px; }
+  /// Set py (GeV/c)
+  void setPy(const Double_t& py)       {fPy = (Float_t)py; }
+  /// Set pz (GeV/c)
+  void setPz(const Double_t& pz)       {fPz = (Float_t)pz; }
+  /// Set energy (GeV). IMPORTANT: This is a dummy method.
+  void setE(const Double_t& e)         { /* fE = (Float_t)e; */}
+  /// Set four-momentum (px,py,pz,E)
+  void setMomentum(const Double_t& px, const Double_t& py,
+                   const Double_t& pz, const Double_t& e)
+  { fPx = (Float_t)px; fPy = (Float_t)py; fPz = (Float_t)pz; /* fE = (Float_t)e; */ }
+  /// Set four-momentum (TLorentzVector)
+  void setMomentum(const TLorentzVector& mom)
+  { fPx=(Float_t)mom.Px(); fPy=(Float_t)mom.Py(); fPz=(Float_t)mom.Pz(); /* fE=(Float_t)mom.E(); */ }
+  /// Set x coordinate (fm)
+  void setX(const Double_t& x)        { fX = (Float_t)x; }
+  /// Set y coordinate (fm)
+  void setY(const Double_t& y)        { fY = (Float_t)y; }
+  /// Set z coordinate (fm)
+  void setZ(const Double_t& z)        { fZ = (Float_t)z; }
+  /// Set t coordinate (fm/c)
+  void setT(const Double_t& t)        { fT = (Float_t)t; }
+  /// Set four-coordinate (x,y,z,t)
+  void setPosition(const Double_t& x, const Double_t& y,
+                   const Double_t& z, const Double_t& t)
+  { fX = (Float_t)x; fY = (Float_t)y; fZ = (Float_t)z; fT = (Float_t)t; }
+  /// Set four-coordinate (TLorentzVector)
+  void setPosition(const TLorentzVector& pos)
+  { fX=(Float_t)pos.X(); fY=(Float_t)pos.Y(); fZ=(Float_t)pos.Z(); fT=(Float_t)pos.T(); }
+  /// Set weight
+  void setWeight(const Double_t& weight) { fWeight = (Float_t)weight; }
+
+ private:
+  /// Index of this particle
+  UShort_t fIndex;
+  /// PDG code
+  Int_t fPdg;
+  /// Status
+  Char_t fStatus;
+  /// Index of the parent
+  UShort_t fParent;
+  /// Parent decay index
+  UShort_t fParentDecay;
+  /// Index of the last collision partner
+  UShort_t fMate;
+  /// Decay index (-1 if not decayed)
+  Short_t fDecay;
+  /// Index of the first and the last child
+  UShort_t fChild[2];
+  /// px (GeV/c)
+  Float_t fPx;
+  /// py (GeV/c)
+  Float_t fPy;
+  /// pz (GeV/c)
+  Float_t fPz;
+  /// x (fm)
+  Float_t fX;
+  /// y (fm)
+  Float_t fY;
+  /// z (fm)
+  Float_t fZ;
+  /// t (fm/c)
+  Float_t fT;
+  /// Weight
+  Float_t fWeight;
+
+  ClassDef(UParticle, 3);
+};
+
+
+#endif

+ 149 - 0
URun.cxx

@@ -0,0 +1,149 @@
+// C++ headers
+#include <iostream>
+
+// ROOT headers
+#include "TMath.h"
+
+// UNI headers
+#include "URun.h"
+
+ClassImp(URun);
+
+Double_t mProtMass = 0.938272029;
+Double_t mNeutMass = 0.939565360;
+Double_t mPionMass = 0.13957018;
+
+//----------------
+URun::URun() : TNamed("run", "Run Header" ),
+	       fGenerator( "" ), fComment( "" ), fDecayer( "" ),
+	       fAProj( 0 ), fZProj( 0 ), fPProj( 0 ),
+	       fATarg( 0 ), fZTarg( 0 ), fPTarg( 0 ),
+	       fBMin( 0 ), fBMax( 0 ), fBWeight( 0 ),
+	       fPhiMin( 0 ), fPhiMax( 0 ), fXSection( 0 ), fNEvents( 0 ) {
+  // Default constructor. Should not be used
+  std::cout << "Warning: Default constructor of URun should not be used!"
+            << std::endl;
+}
+
+//----------------
+URun::URun(const char* generator, const char* comment, const Int_t& aProj,
+	   const Int_t& zProj, const Double_t& pProj, const Int_t& aTarg,
+           const Int_t& zTarg, const Double_t& pTarg, const Double_t& bMin,
+           const Double_t& bMax, const Int_t& bWeight, const Double_t& phiMin,
+           const Double_t& phiMax, const Double_t& sigma, const Int_t& nEvents)
+  : TNamed("run", "Run Header") {
+  // Standard constructor
+  fGenerator = generator;
+  fComment   = comment;
+  fAProj     = ( ( TMath::Abs( aProj ) >= std::numeric_limits<short>::max() ) ?
+		 std::numeric_limits<short>::max() : (Short_t)aProj ) ;
+  fZProj     = ( ( TMath::Abs( zProj ) >= std::numeric_limits<short>::max() ) ?
+		 std::numeric_limits<short>::max() : (Short_t)zProj );
+  fPProj     = (Float_t)pProj;
+  fATarg     = ( ( TMath::Abs( aTarg ) >= std::numeric_limits<short>::max() ) ?
+		 std::numeric_limits<short>::max() : (Short_t)aTarg );
+  fZTarg     = ( ( TMath::Abs( zTarg ) >= std::numeric_limits<short>::max() ) ?
+		 std::numeric_limits<short>::max() : (Short_t)zTarg );
+  fPTarg     = (Float_t)pTarg;
+  fBMin      = (Float_t)bMin;
+  fBMax      = (Float_t)bMax;
+  fBWeight   = bWeight;
+  fPhiMin    = (Float_t)phiMin;
+  fPhiMax    = (Float_t)phiMax;
+  fXSection     = (Float_t)sigma;
+  fNEvents   = nEvents;
+}
+
+//----------------
+URun::~URun() {
+  // Destructor
+}
+
+//----------------
+void URun::print(Option_t* option) {
+  // Print all data members to the standard output
+  std::cout << "--------------------------------------------------" << std::endl
+            << "-I-                 Run Header                 -I-" << std::endl
+            << "Generator                     : " << fGenerator << std::endl
+            << "Comment                       : " << fComment << std::endl
+            << "Decayer                       : " << fDecayer << std::endl
+            << "Projectile mass               : " << fAProj << std::endl
+            << "Projectile charge             : " << fZProj << std::endl
+            << "Projectile momentum (AGeV/c)  : " << fPProj << std::endl
+            << "Target mass                   : " << fATarg << std::endl
+            << "Target charge                 : " << fZTarg << std::endl
+            << "Target momentum (AGeV/c)      : " << fPTarg << std::endl
+            << "Minimal impact parameter (fm) : " << fBMin << std::endl
+            << "Maximal impact parameter (fm) : " << fBMax << std::endl
+            << "Impact parameter weighting    : " << fBWeight << std::endl
+            << "Minimal azimuthal angle (rad) : " << fPhiMin << std::endl
+            << "Maximal azimuthal angle (rad) : " << fPhiMax << std::endl
+            << "Cross-section (mb)            : " << fXSection << std::endl
+            << "Requested number of events    : " << fNEvents << std::endl
+            << "--------------------------------------------------" << std::endl;
+}
+
+//----------------
+Double_t URun::projectileEnergy() {
+  // Get the projectile energy
+  Double_t eProj = 0.;
+  if ( fAProj > 0 )          // nucleus
+    eProj = fZProj  * TMath::Sqrt( fPProj*fPProj + mProtMass*mProtMass ) +
+            (fAProj - fZProj) * TMath::Sqrt( fPProj*fPProj + mNeutMass*mNeutMass );
+  else if ( fAProj ==  0 )   // photon
+    eProj = fPProj;
+  else if ( fAProj == -1 )   // pion
+    eProj = TMath::Sqrt( fPProj*fPProj + mPionMass*mPionMass );
+  else std::cout << "Warning:: URun: Projectile mass " << fAProj
+	               << " not valid! " << std::endl;
+  return eProj;
+}
+
+//----------------
+Double_t URun::targetEnergy() {
+  // Get the target energy
+  Double_t eTarg = 0.;
+  if ( fATarg > 0 )            // nucleus
+    eTarg = fZTarg  * TMath::Sqrt( fPTarg*fPTarg + mProtMass*mProtMass ) +
+            (fATarg - fZTarg) * TMath::Sqrt( fPTarg*fPTarg + mNeutMass*mNeutMass );
+  else if ( fAProj ==  0 )     // photon
+    eTarg = fPTarg;
+  else if ( fAProj == -1 )     // pion
+    eTarg = TMath::Sqrt( fPTarg*fPTarg + mPionMass*mPionMass );
+  else std::cout << "Warning:: URun: Target mass " << fATarg
+	               << " not valid! " << std::endl;
+  return eTarg;
+}
+
+//----------------
+Double_t URun::nnSqrtS() {
+  // Get the cm energy
+  Double_t eSum = ( TMath::Sqrt( fPTarg*fPTarg + mProtMass*mProtMass ) +
+		                TMath::Sqrt( fPProj*fPProj + mNeutMass*mNeutMass ) );
+  Double_t pSum = Double_t(fPProj + fPTarg);
+  Double_t ecm = TMath::Sqrt( eSum*eSum - pSum*pSum );
+  return ecm;
+}
+
+//----------------
+Double_t URun::sqrtS() {
+  // Get the cm energy
+  Double_t eSum = projectileEnergy() + targetEnergy();
+  Double_t pSum = Double_t(fAProj) * fPProj + Double_t(fATarg) * fPTarg;
+  Double_t ecm = TMath::Sqrt( eSum*eSum - pSum*pSum );
+  return ecm;
+}
+
+//----------------
+Double_t URun::betaCM() {
+  // Get cm velocity
+  Double_t eSum = projectileEnergy() + targetEnergy();
+  Double_t pSum = Double_t(fAProj) * fPProj + Double_t(fATarg) * fPTarg;
+  return pSum / eSum;
+}
+
+//----------------
+Double_t URun::gammaCM() {
+  // Get cm gamma factor
+  return 1. / TMath::Sqrt( 1. - betaCM()*betaCM() );
+}

+ 142 - 0
URun.h

@@ -0,0 +1,142 @@
+#ifndef URUN_H
+#define URUN_H
+
+// C++ headers
+#include <limits>
+
+// ROOT headers
+#include "TNamed.h"
+#include "TString.h"
+
+//_________________
+class URun : public TNamed {
+
+ public:
+  /// Default constructor
+  URun();
+  /// Parametrized constructor
+  URun(const char* generator, const char* comment, const Int_t& aProj,
+       const Int_t& zProj, const Double_t& pProj, const Int_t& aTarg,
+       const Int_t& zTarg, const Double_t& pTarg, const Double_t& bMin,
+       const Double_t& bMax, const Int_t& bWeight, const Double_t& phiMin,
+       const Double_t& phiMax, const Double_t& sigma, const Int_t& nEvents);
+  /// Default destructor
+  virtual ~URun();
+  /// Print run info
+  void print(Option_t* option = "");
+
+  /// Proton mass (GeV/c^2)
+  static Double_t mProtMass;
+  /// Neutron mass (GeV/c^2)
+  static Double_t mNeutMass;
+  /// Charged pion mass (GeV/c^2)
+  static Double_t mPionMass;
+
+  //
+  // Getters
+  //
+
+  /// Return generator name
+  void generator(TString& generator) { generator = fGenerator; }
+  /// Return comment
+  void comment(TString& comment)     { comment = fComment; }
+  /// Return decayer name
+  void decayer(TString& decayer)     { decayer = fDecayer; }
+  /// Return number of nucleons in the projectile
+  Int_t aProj() const                { return (Int_t)fAProj; }
+  /// Return number of protons in the projectile
+  Int_t zProj() const                { return (Int_t)fZProj; }
+  /// Return momentum of the projectile
+  Double_t pProj() const             { return (Double_t)fPProj; }
+  /// Return number of nucleons in the target
+  Int_t aTarg() const                { return (Int_t)fATarg; }
+  /// Return number of protons in the target
+  Int_t zTarg() const                { return (Int_t)fZTarg; }
+  /// Return momentum of the target
+  Double_t pTarg() const             { return (Double_t)fPTarg; }
+  /// Return minimal impact parameter requested
+  Double_t bMin() const              { return (Double_t)fBMin; }
+  /// Return maximal impact parameter requested
+  Double_t bMax() const              { return (Double_t)fBMax; }
+  /// Impact parameter weighting:
+  /// \param 0 for geometrical weights (bdb)
+  /// \param 1 for flat distribution
+  Int_t bWeight() const              { return (fBWeight) ? 1 : 0 ; }
+  /// Return maximal phi angle requested
+  Double_t phiMax() const            { return (Double_t)fPhiMax; }
+  /// Return minimal phi angle requested
+  Double_t phiMin() const            { return (Double_t)fPhiMin; }
+  /// Return cross section
+  Double_t xSection() const          { return (Double_t)fXSection; }
+  /// Return requested number of events to generate
+  UInt_t nEvents() const             { return fNEvents; }
+  /// Return center-of-mass energy
+  Double_t sqrtS();
+  /// Return center-of-mass energy per nucleon
+  Double_t nnSqrtS();
+  /// Return energy of the projectile
+  Double_t projectileEnergy();
+  /// Return energy of the target
+  Double_t targetEnergy();
+  /// Return center-of-mass velocity
+  Double_t betaCM();
+  /// Return center-of-mass lorentz factor
+  Double_t gammaCM();
+
+  //
+  // setParameters
+  //
+
+  /// Set amount of event that was requested
+  void setNEvents(const Int_t& nEvents)
+  { if (nEvents<0) {fNEvents=0;}
+    else { fNEvents = ( (nEvents > std::numeric_limits<int>::max() ) ?
+			                  std::numeric_limits<unsigned int>::max() : (UInt_t)nEvents ); } }
+  /// Set momentum of the projectile
+  void setPProj(const Double_t& pProj)  { fPProj = (Float_t)pProj; }
+  /// Set momentum of the target
+  void setPTarg(const Double_t& pTarg)  { fPTarg = (Float_t)pTarg; }
+  /// Set decayer type
+  void setDecayer(TString decayer)      { fDecayer = decayer; }
+
+ private:
+  /// Generator description
+  TString    fGenerator;
+  /// Run comment
+  TString    fComment;
+  /// Decayer description
+  TString    fDecayer;
+  /// Projectile mass number
+  Short_t    fAProj;
+  /// Projectile charge
+  Short_t    fZProj;
+  /// Projectile momentum per nucleon (GeV)
+  Float_t    fPProj;
+  /// Target mass number
+  Short_t    fATarg;
+  /// Target charge
+  Short_t    fZTarg;
+  /// Target momentum per nucleon (GeV)
+  Float_t    fPTarg;
+  /// Minimum impact parameter
+  Float_t    fBMin;
+  /// Maximum impact parameter
+  Float_t    fBMax;
+  /// Impact parameter weighting:
+  /// \param 0 for geometrical weights (bdb)
+  /// \param 1 for flat distribution
+  Bool_t      fBWeight;
+  /// Event plane minimum angle (rad)
+  Float_t    fPhiMin;
+  /// Event plane maximum angle (rad)
+  Float_t    fPhiMax;
+  /// Cross-section (mb)
+  Float_t    fXSection;
+  /// Requested number of events
+  UInt_t     fNEvents;
+
+  ClassDef(URun,3);
+};
+
+
+#endif

+ 41 - 0
UTask.cxx

@@ -0,0 +1,41 @@
+#include "UTask.h"
+
+
+//____________________________________________________________________
+//
+// UTask
+//
+// Base abstract class for tasks. User derived classe has to
+// override pure virtual methods Init, Exec and Finish
+//
+
+
+//--------------------------------------------------------------------
+UTask::UTask()
+{
+  // Default constructor
+  fVerbose = 1;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+UTask::UTask(const char *name, Int_t verbose)
+  : TTask(name, "UTask")
+{
+  // Standard constructor
+  fVerbose = verbose;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+UTask::~UTask()
+{
+  // Destructor
+}
+//--------------------------------------------------------------------
+
+
+ClassImp(UTask);
+

+ 32 - 0
UTask.h

@@ -0,0 +1,32 @@
+#ifndef UTASK
+#define UTASK
+
+// ROOT headers
+#include "TTask.h"
+
+//_________________
+class UTask : public TTask {
+
+ protected:
+  Int_t fVerbose;       // Verbosity level
+
+ public:
+  /// Default constructor
+  UTask();
+  /// Constructor with parameters
+  UTask(const char *name,
+	Int_t verbose = 1);
+  /// Destructor
+  virtual ~UTask();          
+
+  virtual void Init() = 0;                    
+  virtual void Exec(Option_t *option = "") = 0; 
+  virtual void Finish() = 0;                 
+
+  inline void SetVerbose(Int_t verbose) {fVerbose = verbose;}
+
+  ClassDef(UTask, 1);
+};
+
+
+#endif

+ 17 - 0
UniGenLinkDef.h

@@ -0,0 +1,17 @@
+//#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class URun+;
+#pragma link C++ class UEvent+;
+#pragma link C++ class UParticle+;
+#pragma link C++ class UPIDConverter+;
+#pragma link C++ class UManager+;
+#pragma link C++ class UTask+;
+
+#pragma link C++ global gROOT;
+#pragma link C++ global gEnv;
+
+//#endif

+ 13 - 0
input/Makefile

@@ -0,0 +1,13 @@
+INSTALLFILES = $(wildcard *.dat)
+
+.PHONY: all install
+
+all:
+
+install:
+	@echo 'Installing data files for converters...'
+	mkdir -p -m 0755 $(DESTDIR)/input
+	install -m 0644 $(INSTALLFILES) $(DESTDIR)/input
+
+clean:
+

+ 69 - 0
input/pluto_pdg.dat

@@ -0,0 +1,69 @@
+ 1       22
+ 2      -11
+ 3       11
+ 4       12
+ 5      -13
+ 6       13
+ 7      111
+ 8      211
+ 9     -211
+10      130
+11      321
+12     -321
+13     2112
+14     2212
+15    -2212
+16      310
+17      221
+18     3122
+19     3222
+20     3212
+21     3112
+22     3322
+23     3312
+24     3334
+25    -2112
+26    -3122
+27    -3112
+28    -3212
+29    -3222
+30    -3322
+31    -3312
+32    -3334 
+33        0
+34     2114
+35     2224
+36     2214
+37     1114
+38        0
+39        0
+40        0
+41      113
+42      213
+43     -213
+44        0
+45        0
+46        0
+47        0
+48        0
+49        0
+50        0
+51        0
+52      223
+53      331
+54        0
+55      333
+56        0
+57        0
+58        0
+59        0
+60        0
+61        0
+62        0
+63        0
+64        0
+65        0
+66        0
+67      443
+68   100443
+69        0

+ 316 - 0
input/urqmd_pdg.dat

@@ -0,0 +1,316 @@
+   1017   1114
+   1018   31114
+   1019   1112
+   1020   11114
+   1021   11112
+   1022   1116
+   1023   21112
+   1024   21114
+   1025   11116
+   1026   1118
+   1040   3112
+   1041   3114
+   1042   13112
+   1043   13114
+   1044   23112
+   1045   3116
+   1046   13116
+   1047   23114
+   1048   3118
+   1049   3312
+   1050   3314
+   1051   23314
+   1052   13314
+   1053   33314
+   1054   13316
+   1055   3334
+   1101   -211
+   1104   -213
+   1111   -9000211
+   1114   -20213
+   1118   -215
+   1122   -10213
+   1126   -100213
+   1130   -30213
+   2001   2112
+   2002   12112
+   2003   1214
+   2004   22112
+   2005   32112
+   2006   2116
+   2007   12116
+   2008   21214
+   2009   42112
+   2010   31214
+   2011   41214
+   2012   12118
+   2013   52114
+   2016   100012110
+   2017   2114
+   2018   32114
+   2019   1212
+   2020   12114
+   2021   11212
+   2022   1216
+   2023   21212
+   2024   22114
+   2025   11216
+   2026   2118
+   2027   3122
+   2028   13122
+   2029   3124
+   2030   23122
+   2031   33122
+   2032   13124
+   2033   43122
+   2034   53122
+   2035   3126
+   2036   13126
+   2037   23124
+   2038   3128
+   2039   23126
+   2040   3212
+   2041   3214
+   2042   13212
+   2043   13214
+   2044   23212
+   2045   3216
+   2046   13216
+   2047   23214
+   2048   3218
+   2049   3322
+   2050   3324
+   2051   23324
+   2052   13324
+   2053   33324
+   2054   13326
+   2100   22
+   2101   111
+   2102   221
+   2103   223
+   2104   113
+   2105   9000221
+   2106   311
+   2107   331
+   2108   313
+   2109   333
+   2110   333
+   2111   9000111
+   2112   10221
+   2113   20313
+   2114   20113
+   2115   20223
+   2116   20333
+   2117   315
+   2118   115
+   2119   225
+   2120   335
+   2121   10313
+   2122   10113
+   2123   10223
+   2124   10333
+   2125   100313
+   2126   100113
+   2127   100223
+   2128   100333
+   2129   30313
+   2130   30113
+   2131   30223
+   2132   337
+   3001   2212
+   3002   12212
+   3003   2124
+   3004   22212
+   3005   32212
+   3006   2216
+   3007   12216
+   3008   22124
+   3009   42212
+   3010   32124
+   3011   42124
+   3012   12218
+   3013   52214
+   3016   100012210
+   3017   2214
+   3018   32214
+   3019   2122
+   3020   12214
+   3021   12122
+   3022   2126
+   3023   22122
+   3024   22214
+   3025   12126
+   3026   2218
+   3040   3222
+   3041   3224
+   3042   13222
+   3043   13224
+   3044   23222
+   3045   3226
+   3046   13226
+   3047   23224
+   3048   3228
+   3101   211
+   3104   213
+   3106   321
+   3108   323
+   3110   10321
+   3111   9000211
+   3113   20323
+   3114   20213
+   3117   325
+   3118   215
+   3121   10323
+   3122   10213
+   3125   100323
+   3126   100213
+   3129   30323
+   3130   30213
+   4017   2224
+   4018   32224
+   4019   2222
+   4020   12224
+   4021   12222
+   4022   2226
+   4023   22222
+   4024   22224
+   4025   12226
+   4026   2228
+   -3055   -3334
+   -3054   -13316
+   -3053   -33314
+   -3052   -13314
+   -3051   -23314
+   -3050   -3314
+   -3049   -3312
+   -3048   -3118
+   -3047   -23114
+   -3046   -13116
+   -3045   -3116
+   -3044   -23112
+   -3043   -13114
+   -3042   -13112
+   -3041   -3114
+   -3040   -3112
+   -3026   -1118
+   -3025   -11116
+   -3024   -21114
+   -3023   -21112
+   -3022   -1116
+   -3021   -11112
+   -3020   -11114
+   -3019   -1112
+   -3018   -31114
+   -3017   -1114
+   -2129   -30313
+   -2125   -100313
+   -2121   -10313
+   -2117   -315
+   -2113   -20313
+   -2110   -10311
+   -2108   -313
+   -2106   -311
+   -2055   -3334
+   -2054   -13326
+   -2053   -33324
+   -2052   -13324
+   -2051   -23324
+   -2050   -3324
+   -2049   -3322
+   -2048   -3218
+   -2047   -23214
+   -2046   -13216
+   -2045   -3216
+   -2044   -23212
+   -2043   -13214
+   -2042   -13212
+   -2041   -3214
+   -2040   -3212
+   -2039   -23126
+   -2038   -3128
+   -2037   -23124
+   -2036   -13126
+   -2035   -3126
+   -2034   -53122
+   -2033   -43122
+   -2032   -13124
+   -2031   -33122
+   -2030   -23122
+   -2029   -3124
+   -2028   -13122
+   -2027   -3122
+   -2026   -2118
+   -2025   -11216
+   -2024   -22114
+   -2023   -21212
+   -2022   -1216
+   -2021   -11212
+   -2020   -12114
+   -2019   -1212
+   -2018   -32114
+   -2017   -2114
+   -2016   -100012110
+   -2013   -52114
+   -2012   -12118
+   -2011   -41214
+   -2010   -31214
+   -2009   -42112
+   -2008   -21214
+   -2007   -12116
+   -2006   -2116
+   -2005   -32112
+   -2004   -22112
+   -2003   -1214
+   -2002   -12112
+   -2001   -2112
+   -1129   -30323
+   -1125   -100323
+   -1121   -10323
+   -1117   -325
+   -1113   -20323
+   -1110   -10321
+   -1108   -323
+   -1106   -321
+   -1048   -3228
+   -1047   -23224
+   -1046   -13226
+   -1045   -3226
+   -1044   -23222
+   -1043   -13224
+   -1042   -13222
+   -1041   -3224
+   -1040   -3222
+   -1026   -2218
+   -1025   -12126
+   -1024   -22214
+   -1023   -22122
+   -1022   -2126
+   -1021   -12122
+   -1020   -12214
+   -1019   -2122
+   -1018   -32214
+   -1017   -2214
+   -1016   -100012210
+   -1013   -52214
+   -1012   -12218
+   -1011   -42124
+   -1010   -32124
+   -1009   -42212
+   -1008   -22124
+   -1007   -12216
+   -1006   -2216
+   -1005   -32212
+   -1004   -22212
+   -1003   -2124
+   -1002   -12212
+   -1001   -2212
+   -26   -2228
+   -25   -12226
+   -24   -22224
+   -23   -22222
+   -22   -2226
+   -21   -12222
+   -20   -12224
+   -19   -2222
+   -18   -32224
+   -17   -2224

+ 200 - 0
input/urqmd_pdg.dat_old

@@ -0,0 +1,200 @@
+       1       0       0    2112       0    2212       0       0
+       2       0       0   12112       0   12212       0       0
+       3       0       0    1214       0    2124       0       0
+       4       0       0   22112       0   22212       0       0
+       5       0       0   32112       0   32212       0       0
+       6       0       0    2116       0    2216       0       0
+       7       0       0   12116       0   12216       0       0
+       8       0       0   21214       0   22124       0       0
+       9       0       0   42112       0   42212       0       0
+      10       0       0   31214       0   32124       0       0
+      11       0       0       0       0       0       0       0
+      12       0       0       0       0       0       0       0
+      13       0       0       0       0       0       0       0
+      14       0       0    1218       0    2128       0       0
+      15       0       0       0       0       0       0       0
+      16       0       0       0       0       0       0       0
+      17    1114       0    2114       0    2214       0    2224
+      18   31114       0   32114       0   32214       0   32224
+      19    1112       0    1212       0    2122       0    2222
+      20   11114       0   12114       0   12214       0   12224
+      21   11112       0   11212       0   12122       0   12222
+      22    1116       0    1216       0    2126       0    2226
+      23   21112       0   21212       0   22122       0   22222
+      24   21114       0   22114       0   22214       0   22224
+      25   11116       0   11216       0   12126       0   12226
+      26    1118       0    2118       0    2218       0    2228
+      27       0       0       0    3122       0       0       0
+      28       0       0       0   13122       0       0       0
+      29       0       0       0    3124       0       0       0
+      30       0       0       0   23122       0       0       0
+      31       0       0       0   33122       0       0       0
+      32       0       0       0   13124       0       0       0
+      33       0       0       0   43122       0       0       0
+      34       0       0       0   53122       0       0       0
+      35       0       0       0    3126       0       0       0
+      36       0       0       0   13126       0       0       0
+      37       0       0       0   23124       0       0       0
+      38       0       0       0    3128       0       0       0
+      39       0       0       0   23126       0       0       0
+      40       0    3112       0    3212       0    3222       0
+      41       0    3114       0    3214       0    3224       0
+      42       0   13112       0   13212       0   13222       0
+      43       0   13114       0   13214       0   13224       0
+      44       0   23112       0   23212       0   23222       0
+      45       0    3116       0    3216       0    3226       0
+      46       0   13116       0   13216       0   13226       0
+      47       0   23114       0   23214       0   23224       0
+      48       0    3118       0    3218       0    3228       0
+      49       0       0    3312       0    3322       0       0
+      50       0       0    3314       0    3324       0       0
+      51       0       0       0       0       0       0       0
+      52       0       0   13314       0   13324       0       0
+      53       0       0       0       0       0       0       0
+      54       0       0       0       0       0       0       0
+      55       0       0       0    3334       0       0       0
+      56       0       0       0       0       0       0       0
+      57       0       0       0       0       0       0       0
+      58       0       0       0       0       0       0       0
+      59       0       0       0       0       0       0       0
+      60       0       0       0       0       0       0       0
+      61       0       0       0       0       0       0       0
+      62       0       0       0       0       0       0       0
+      63       0       0       0       0       0       0       0
+      64       0       0       0       0       0       0       0
+      65       0       0       0       0       0       0       0
+      66       0       0       0       0       0       0       0
+      67       0       0       0       0       0       0       0
+      68       0       0       0       0       0       0       0
+      69       0       0       0       0       0       0       0
+      70       0       0       0       0       0       0       0
+      71       0       0       0       0       0       0       0
+      72       0       0       0       0       0       0       0
+      73       0       0       0       0       0       0       0
+      74       0       0       0       0       0       0       0
+      75       0       0       0       0       0       0       0
+      76       0       0       0       0       0       0       0
+      77       0       0       0       0       0       0       0
+      78       0       0       0       0       0       0       0
+      79       0       0       0       0       0       0       0
+      80       0       0       0       0       0       0       0
+      81       0       0       0       0       0       0       0
+      82       0       0       0       0       0       0       0
+      83       0       0       0       0       0       0       0
+      84       0       0       0       0       0       0       0
+      85       0       0       0       0       0       0       0
+      86       0       0       0       0       0       0       0
+      87       0       0       0       0       0       0       0
+      88       0       0       0       0       0       0       0
+      89       0       0       0       0       0       0       0
+      90       0       0       0       0       0       0       0
+      91       0       0       0       0       0       0       0
+      92       0       0       0       0       0       0       0
+      93       0       0       0       0       0       0       0
+      94       0       0       0       0       0       0       0
+      95       0       0       0       0       0       0       0
+      96       0       0       0       0       0       0       0
+      97       0       0       0       0       0       0       0
+      98       0       0       0       0       0       0       0
+      99       0       0       0       0       0       0       0
+     100       0       0       0      22       0       0       0
+     101       0    -211       0     111       0     211       0
+     102       0       0       0     221       0       0       0
+     103       0       0       0     223       0       0       0
+     104       0    -213       0     113       0     213       0
+     105       0       0       0   10221       0       0       0
+     106       0       0     311       0     321       0       0
+     107       0       0       0     331       0       0       0
+     108       0       0     313       0     323       0       0
+     109       0       0       0     333       0       0       0
+     110       0       0   10313       0   10323       0       0
+     111       0  -10211       0   10111       0   10211       0
+     112       0       0       0   20221       0       0       0
+     113       0       0   10313       0   10323       0       0
+     114       0  -20213       0   20113       0   20213       0
+     115       0       0       0   20223       0       0       0
+     116       0       0       0   40223       0       0       0
+     117       0       0     315       0     325       0       0
+     118       0    -215       0     115       0     215       0
+     119       0       0       0     225       0       0       0
+     120       0       0       0     335       0       0       0
+     121       0       0   20313       0   20323       0       0
+     122       0  -10213       0   10113       0   10213       0
+     123       0       0       0   10223       0       0       0
+     124       0       0       0       0       0       0       0
+     125       0       0   30313       0   30323       0       0
+     126       0  -40213       0   40113       0   40213       0
+     127       0       0       0   50223       0       0       0
+     128       0       0       0   10333       0       0       0
+     129       0       0   40313       0   40323       0       0
+     130       0  -30213       0   30113       0   30213       0
+     131       0       0       0   60223       0       0       0
+     132       0       0       0     337       0       0       0
+     133       0       0       0       0       0       0       0
+     134       0       0       0       0       0       0       0
+     135       0       0       0       0       0       0       0
+     136       0       0       0       0       0       0       0
+     137       0       0       0       0       0       0       0
+     138       0       0       0       0       0       0       0
+     139       0       0       0       0       0       0       0
+     140       0       0       0       0       0       0       0
+     141       0       0       0       0       0       0       0
+     142       0       0       0       0       0       0       0
+     143       0       0       0       0       0       0       0
+     144       0       0       0       0       0       0       0
+     145       0       0       0       0       0       0       0
+     146       0       0       0       0       0       0       0
+     147       0       0       0       0       0       0       0
+     148       0       0       0       0       0       0       0
+     149       0       0       0       0       0       0       0
+     150       0       0       0       0       0       0       0
+     151       0       0       0       0       0       0       0
+     152       0       0       0       0       0       0       0
+     153       0       0       0       0       0       0       0
+     154       0       0       0       0       0       0       0
+     155       0       0       0       0       0       0       0
+     156       0       0       0       0       0       0       0
+     157       0       0       0       0       0       0       0
+     158       0       0       0       0       0       0       0
+     159       0       0       0       0       0       0       0
+     160       0       0       0       0       0       0       0
+     161       0       0       0       0       0       0       0
+     162       0       0       0       0       0       0       0
+     163       0       0       0       0       0       0       0
+     164       0       0       0       0       0       0       0
+     165       0       0       0       0       0       0       0
+     166       0       0       0       0       0       0       0
+     167       0       0       0       0       0       0       0
+     168       0       0       0       0       0       0       0
+     169       0       0       0       0       0       0       0
+     170       0       0       0       0       0       0       0
+     171       0       0       0       0       0       0       0
+     172       0       0       0       0       0       0       0
+     173       0       0       0       0       0       0       0
+     174       0       0       0       0       0       0       0
+     175       0       0       0       0       0       0       0
+     176       0       0       0       0       0       0       0
+     177       0       0       0       0       0       0       0
+     178       0       0       0       0       0       0       0
+     179       0       0       0       0       0       0       0
+     180       0       0       0       0       0       0       0
+     181       0       0       0       0       0       0       0
+     182       0       0       0       0       0       0       0
+     183       0       0       0       0       0       0       0
+     184       0       0       0       0       0       0       0
+     185       0       0       0       0       0       0       0
+     186       0       0       0       0       0       0       0
+     187       0       0       0       0       0       0       0
+     188       0       0       0       0       0       0       0
+     189       0       0       0       0       0       0       0
+     190       0       0       0       0       0       0       0
+     191       0       0       0       0       0       0       0
+     192       0       0       0       0       0       0       0
+     193       0       0       0       0       0       0       0
+     194       0       0       0       0       0       0       0
+     195       0       0       0       0       0       0       0
+     196       0       0       0       0       0       0       0
+     197       0       0       0       0       0       0       0
+     198       0       0       0       0       0       0       0
+     199       0       0       0       0       0       0       0
+     200       0       0       0       0       0       0       0

+ 85 - 0
input/werner_pdg.dat

@@ -0,0 +1,85 @@
+    1     2
+   -1    -2
+    2     1
+   -2    -1
+    3     3
+   -3    -3
+    4     4
+   -4    -4
+    5     5
+   -5    -5
+    6     6
+   -6    -6
+    9    21
+   10    22
+   11    12
+  -11   -12
+   12    11
+  -12   -11
+   13    14
+  -13   -14
+   14    13
+  -14   -13
+   15    16
+  -15   -16
+   16    15
+  -16   -15
+   20   310
+  -20   130
+   80    24
+  -80   -24
+   90    23
+  110   111
+  120   211
+ -120  -211
+  220   221
+  130   321
+ -130  -321
+  230   311
+ -230  -311
+  330   331
+  140  -421
+ -140   421
+  240  -411
+ -240   411
+  440   441
+  111   113
+  121   213
+ -121  -213
+  221   223
+  131   323
+ -131  -323
+  231   313
+ -231  -313
+  331   333
+  141  -423
+ -141   423
+  241  -413
+ -241   413
+  441   443
+ 1120  2212
+-1120 -2212
+ 1220  2112
+-1220 -2112
+ 1130  3222
+-1130 -3222
+ 1230  3212
+-1230 -3212
+ 2130  3122
+-2130 -3122
+ 2230  3112
+-2230 -3112
+ 1330  3322
+-1330 -3322
+ 2330  3312
+-2330 -3312
+ 1140  4222
+-1140 -4222
+ 1240  4212
+-1240 -4212
+ 2140  4122
+-2140 -4122
+ 2240  4112
+-2240 -4112
+ 3331  3334
+-3331 -3334

+ 16 - 0
unigenlogin.bash

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# assuming that this macro is sitting at its original location, 
+# its path can be used to set the unigen enviroment  
+
+filnam=$BASH_SOURCE            # filename of this (sourced) macro 
+absnam=`readlink -f $filnam`   # absolute filename 
+pather=`dirname $absnam`       # path to the config directory
+#pather=`dirname $pather`       # path to the top unigen directory
+
+export UNIGEN=$pather
+
+export PATH=${UNIGEN}/lib':'${UNIGEN}/bin':'${PATH}
+export LD_LIBRARY_PATH=${UNIGEN}/lib':'${LD_LIBRARY_PATH}
+
+echo UNIGEN = $UNIGEN

+ 219 - 0
urqmd2u.cpp

@@ -0,0 +1,219 @@
+///////////////////////////////////////////////////////////////////////////////
+// urqmd2u reads UrQMD events from the ftn13 or ftn14 ascii files and
+// converts them to the UniGen format and saves on a root file.
+//
+// ftn14 contains snapshots at given times (event steps). The event steps 
+// are converted to separate events. 
+//
+// ftn13 contains the final snapshot and the freeze-out coordinates. 
+// The freeze-out coordinates are used. The final snapshot coordinates 
+// are discarded.
+//
+// D.Miskowiec, February 2006
+///////////////////////////////////////////////////////////////////////////////
+
+// C++ headers
+#include <iostream>
+#include <fstream>
+#include <iomanip>
+#include <map>
+
+// ROOT headers
+#include "TFile.h"
+#include "TTree.h"
+#include "TString.h"
+#include "TBranch.h"
+#include "TMath.h"
+
+// UniGen headers
+#include "URun.h"
+#include "UEvent.h"
+#include "UParticle.h"
+#include "UPIDConverter.h"
+
+using namespace std;
+
+TFile *fi;
+TTree *tr;
+UEvent *ev;
+
+//_________________
+void bomb(const char *myst) {
+  std::cerr << "Error: " << myst << ", bombing" << std::endl;
+  exit(-1);
+}
+
+//_________________
+int trapco(int ityp, int ichg) {
+  // translate UrQMD pid code to pdg code
+
+  /* UrQMD PIDs are in fact composite - a particle is fully defined by the
+     type specifier (ityp), the charge (ichg) and in case of baryons, the
+     third component isospin (iso3; ignored by us at present). For
+     simplicity, our conversion tables collapse these into a single number
+     as follows:
+      - propagate the sign of ityp (particle-antiparticle distinction for
+        baryons, strangeness-antistrangeness distinction for mesons) to that
+        of the stored value;
+      - shift the ichg range from -2..2 (UrQMD does not support nuclear
+        fragments other than protons and neutrons so all particles it
+        produces fall in this range) to 0..4 to make sure it doesn't
+        interfere with the above;
+      - multiply shifted charge by +/-1000 and add it to type. The latter
+        is guaranteed to be smaller than 1000 (baryon types are one- or
+        two-digit, meson types three-digit) so that way no ambiguities
+        occur. */
+  int id;
+  if (ityp >= 0) id = 1000 * (ichg + 2) + ityp;
+  else
+    id = -1000 * (ichg + 2) + ityp;
+
+  /* This will return 0 for unknown input values. */
+  return UPIDConverter::Instance()->GetPDGCode(id, UPIDConverter::eUrQMD);
+}
+
+//_________________
+int main(int argc, char *argv[]) {
+
+  ifstream in;
+  char *inpfile;
+  char *outfile;
+  char c;
+  int nevents;
+  std::string dust;
+
+  URun *ru = 0;
+  std::string version, comment;
+  int filetype, eos, aproj, zproj, atarg, ztarg, nr;
+  double beta, b, bmin, bmax, sigma, elab, plab, sqrts, time, dtime;
+
+  if (argc != 4) {
+    std::cout << "usage:   " << argv[0] << " inpfile outfile nevents\n";
+    std::cout << "example: " << argv[0] << " ftn14 ftn14.root 10\n";
+    exit(0);
+  }
+
+  inpfile = argv[1];
+  outfile = argv[2];
+  nevents = atoi(argv[3]);
+
+  int nout=0;
+  in.open(inpfile);
+  if (in.fail()) bomb("cannot open input file");
+
+  fi = TFile::Open(outfile, "RECREATE", "UrQMD");
+  fi->SetCompressionLevel(9);
+  int bufsize = 65536;
+  int split = 99;
+
+  tr = new TTree("events","UrQMD tree", split);
+  tr->SetAutoSave(1000000);
+  ev = new UEvent();
+  tr->Branch("event", "UEvent", &ev, bufsize, split);
+
+  // event loop
+
+  const int bunch = 10;
+
+  int events_processed=0;
+  for (int n=0; n<nevents; n++) {
+    if ((n%bunch)==0) std::cout << "event "  << setw(5) << n << std::endl;
+    std::string line;
+
+    in >> dust >> dust >> version >> dust >> dust;
+    in >> dust >> filetype >> dust >> dust >> dust >> aproj >> zproj;
+    in >> dust >> dust >> dust >> atarg >> ztarg; 
+    in >> dust >> dust >> dust >> beta >> dust >> dust;
+    in >> dust >> b >> bmin >> bmax >> dust >> sigma;
+    in >> dust >> eos >> dust >> elab >> dust >> sqrts >> dust >> plab;
+    in >> dust >> nr >> dust >> dust >> dust;
+    in >> dust >> dust >> time >> dust >> dtime;
+    in.ignore(777,'\n'); // ignore the rest of the line
+
+    std::cout << "version: " << version << " sqrts: " << sqrts << " dtime: " << dtime << std::endl;
+    comment.clear();
+    // read 4 lines of options and 6 lines of params
+    for (int i=0; i<10; i++) {
+      getline(in,line); 
+      comment.append(line);
+      comment.append("\n");
+    }
+    in.ignore(777,'\n'); 
+
+    ev->Clear();
+    ev->SetEventNr(nr);
+    ev->SetB(b);
+    ev->SetPhi(0);
+    ev->SetNes((int) (time/dtime));
+    events_processed++;
+
+    int step_nr=0;
+    char pee;
+    while (1) { // loop over time slices
+      int mult;
+      double step_time;
+      pee=in.peek();
+      if (pee=='U') break; 
+      if (pee==EOF) break; 
+      in >> mult >> step_time;
+      
+      std::cout << "Number of particles in event: " << mult << std::endl;
+      
+      in.ignore(777,'\n'); // ignore the rest of the line
+      getline(in,line);
+      ev->SetComment(line.data());
+      
+      for (int i=0;  i<mult; i++) {
+	std::cout << "Working on particle i: " << i;
+	double t,x,y,z,e,px,py,pz;
+	double weight = 1.0;
+	int ityp, iso3, ichg, status, parent, parent_decay, mate;
+	int decay, child[2];
+	in >> t >> x >> y >> z;
+	in >> e >> px >> py >> pz >> dust;
+	in >> ityp >> iso3 >> ichg >> mate >> dust >> dust;
+	if (filetype==13) { // freeze-out coordinates
+	  in >> t >> x >> y >> z;
+	  in >> e >> px >> py >> pz;
+	}
+	std::cout << "px: " << px << " py: " << py << " pz: " << pz << std::endl;
+	if (in.fail()) bomb("while reading tracks");
+	status=parent=parent_decay=decay=child[0]=child[1]=0;
+	std::cout << "I am here 1" << std::endl;
+	ev->AddParticle(i, trapco(ityp, ichg), status, parent,
+			parent_decay, mate-1, decay, child,
+			px, py, pz, e, x, y, z, t, weight);
+	std::cout << "I am here 2" << std::endl;
+      } // for (int i=0;  i<mult; i++)
+
+      do in.get(c); while (c!='\n');
+      ev->SetStepNr(step_nr++);
+      ev->SetStepT(step_time);
+      nout += tr->Fill();
+    }
+    if (pee==EOF) break; 
+  }
+  in.close();
+  std::cout << events_processed << " events processed\n";
+
+  // create the run object
+
+  std::string generator = "UrQMD";
+  generator.append(version);
+  double m = 0.938271998;
+  double ecm = sqrts/2; // energy per nucleon in cm
+  double pcm = sqrt(ecm*ecm-m*m); // momentum per nucleon in cm
+  double gamma = 1.0/sqrt(1-beta*beta); 
+  double pproj = gamma*(+pcm-beta*ecm);
+  double ptarg = gamma*(-pcm-beta*ecm);
+  ru = new URun( generator.data(), comment.data(), 
+		 aproj, zproj, pproj, 
+		 atarg, ztarg, ptarg, 
+		 bmin, bmax, -1, 0, 0, sigma, events_processed);
+  ru->Write();
+  fi->Write();
+  fi->Close();
+  return nout;
+  return 0;
+}
+