#ifndef __CINT__ #include #include #include #include #include #include "TStopwatch.h" #include "TSystem.h" #include "TFile.h" #include "TTree.h" #include #include #include "TParticle.h" #include "Test/Event.h" #include "Test/Track.h" #endif void Convert(Int_t Fileno, Int_t Run){ TStopwatch timer; timer.Start(); //Load the Physics library - needed for the boost & rotations gSystem->Load("libPhysics.dylib"); //Load library gSystem->Load("Test/libTTree.dylib"); // Specify directories to read UrQMD files from and to write TTree to Char_t InputFile[200]; Char_t InputDirectory[200] = "Test/Output"; Char_t OutputFile[200]; Char_t OutputDirectory[200] = "Test/Output"; sprintf(InputFile ,"%s/Output_File_%i.txt",InputDirectory,Fileno); sprintf(OutputFile,"%s/Test_%i.root",OutputDirectory,Fileno); printf("Read file : %s\n",InputFile); printf("Outputfile: %s\n",OutputFile); ifstream in(InputFile); TTree *T = new TTree("Test","A Tree with Events"); Event *event = new Event(); Track *track = new Track(); T->Branch("Test", &event); //------------------------------------------------------ char etype[30] = "PbPb"; Int_t Date = 04102007; //change this number to the generated no of UrQMD events Int_t Total_Events = 100; Char_t dummy[1024]; Int_t anz=0; Float_t b, nothing, r0, rx, ry, rz, p0, pX, pY, pZ, mass; Int_t pid_UrQMD, ispin, charge, i_index_coll, i_ncoll, i_hist; for(Int_t i_EvtNo = 0; i_EvtNo < Total_Events; i_EvtNo++){ anz = 0; for(Int_t i = 0; i < 14; i++){ if (i==2) in >> dummy >> dummy >> dummy >> dummy >> dummy; if (i==3) in >> dummy >> b; in.getline(dummy,1000); }//for(Int_t i = 0; i < 14; i++) in >> anz >> nothing; in.getline(dummy,1000); in.getline(dummy,1000); if(anz>0){ event->SetType(etype); event->SetEventNum(i_EvtNo); event->SetRun(Run); event->SetDate(Date); event->SetFlag(1); event->Setb(b); for(Int_t i_TrackNo = 0; i_TrackNo < anz; i_TrackNo++){ in >> r0 >> rx >> ry >> rz >> p0 >> pX >> pY >> pZ >> mass >> pid_UrQMD >> ispin >> charge >> i_index_coll >> i_ncoll >> i_hist; in.getline(dummy,1000); track->SetT(r0); track->SetRx(rx); track->SetRy(ry); track->SetRz(rz); track->SetE(p0); track->SetPx(pX); track->SetPy(pY); track->SetPz(pZ); track->SetMass(mass); track->SetPID_UrQMD(pid_UrQMD); track->SetI3(ispin); track->SetCharge(charge); event->AddTrack(track); }//for(Int_t i_TrackNo = 0; i_TrackNo < anz; i_TrackNo++) T->Fill(); }//if(anz>0) event->Clear(); printf("Event = %i\n",i_EvtNo+1); }//for(Int_t i_EvtNo = 0; i_EvtNo < TotalEvents; i_EvtNo++) TFile *f = new TFile(OutputFile,"RECREATE"); T->Write(); f->Close(); timer.Stop(); timer.Print(); }//end of Macro