//*-- AUTHOR : Ilse Koenig //*-- Created : 20/10/2004 /////////////////////////////////////////////////////////////////// // FairRun // // class for the parameter versions of an event file // // The name of each run is the run id converted to a string. // The run id number identifies the event file. // In the parameter ROOT file the valid parameter versions are // accessible via the name. // Associated with the run is a list of container // names with the versions of the containers in the two // possible inputs and the output (class FairParVersions). // The input versions are used during the initialisation // used during the initialisation of the containers. /////////////////////////////////////////////////////////////////// #include "FairRtdbRun.h" #include #include using std::cout; using std::ios; using std::setw; ClassImp(FairParVersion) ClassImp(FairRtdbRun) FairParVersion::FairParVersion(Text_t* name) :TNamed(name,"version info"), rootVersion(0) { // constructor with the name of the container // rootVersion=0; for(Int_t i=0; i<3; i++) {inputVersions[i]=-1;} } FairRtdbRun::FairRtdbRun(const Text_t* name,const Text_t* refName) : TNamed(name,"run parameters"), parVersions(new TList()), refRun(refName) { // constructor with the run id and reference run as strings // parVersions=new TList(); // refRun=refName; } FairRtdbRun::FairRtdbRun(Int_t r,Int_t rr) // :TNamed(r,""), :TNamed(), parVersions(new TList()), refRun("") { char name[255]; sprintf(name,"%i",r); SetName(name); setRefRun(rr); } FairRtdbRun::FairRtdbRun(FairRtdbRun& run) :TNamed(run), parVersions(new TList()), refRun(run.refRun) { // copy constructor TList* lv=run.getParVersions(); TIter next(lv); FairParVersion* pv; while ((pv=(FairParVersion*)next())) { parVersions->Add(pv); } } FairRtdbRun::FairRtdbRun() :TNamed(), parVersions(NULL), refRun("") { // default Constructor // parVersions has to be set to zero otherwise the // root file is not browsable } FairRtdbRun::~FairRtdbRun() { // destructor if (parVersions) { parVersions->Delete(); delete parVersions; parVersions=0; } } void FairRtdbRun::addParVersion(FairParVersion* pv) { // adds a container version object to the list parVersions->Add(pv); } FairParVersion* FairRtdbRun::getParVersion(const Text_t* name) { // return a container version object called by the name of // the container return (FairParVersion*)parVersions->FindObject(name); } void FairRtdbRun::resetInputVersions() { TIter next(parVersions); FairParVersion* v; while ((v=(FairParVersion*)next())) { v->resetInputVersions(); } } void FairRtdbRun::resetOutputVersions() { TIter next(parVersions); FairParVersion* v; while ((v=(FairParVersion*)next())) { v->setRootVersion(0); } } void FairRtdbRun::print() { // prints the list of container versions for this run cout<<"run: "<GetName(); cout.setf(ios::right,ios::adjustfield); cout<getInputVersion(1) <getInputVersion(2) <getRootVersion()<<'\n'; } } void FairRtdbRun::write(fstream& fout) { // writes the list of container versions for this run to fstream fout<<"run: "<GetName(); fout.setf(ios::right,ios::adjustfield); fout<getInputVersion(1) <getInputVersion(2) <getRootVersion()<<'\n'; } }