STAR Computing | Tutorials main page |
I/O and DB Maker Operation | |
Offline computing tutorial | Maintained by Victor Perevoztchikov |
New features preliminary description ==================================== Some remarks about IO in makers. ================================ Maker StTreeMaker provides I/O in postMDC2 format. It is based on StTree class. 1. All the data is split into different branches. 2. Branches can be grouped several to a file, but by default one branch - one file. 3. Each branch has its own I/O mode: "r"=ReadOnly; "w"=WriteOnly; "u"=ReadWrite; "0"=Do nothing Let us write the data StTreeMaker *treeMk = new StTreeMaker("tree","psc0049_08_40evts.root","bfcTree"); // "tree" here is arbitrary name assigned to maker instance // "psc0049_08_40evts.fzd" is the name of input file for run. // Only the part "psc0049_08_40evts" is used by the maker // to construct default output file names. // The directory path and extension is ignored // "bfcTree" is the name of tree. By default it is bfcTree which is used // for main STAR output stream. But user can define his own stream // with different name treeMk->SetIOMode("w"); //define write mode treeMk->SetDebug(); //debug is ON // Now define different branches. // define branch with name "dstBranch" which will be filled // by dataset with name "dst" treeMk->IntoBranch("dstBranch","dst"); treeMk->IntoBranch("ftpc_rawBranch","ftpc_raw/.data"); // trgBranch will be filled by ctf mwc trg structures treeMk->IntoBranch("trgBranch","ctf mwc trg"); // Default output files for these branches will be: // dstBranch: psc0049_08_40evts.dst.root // ftpc_rawBranch: psc0049_08_40evts.ftpc_raw.root // trgBranch: psc0049_08_40evts.trg.root // So you see, the word "Branch" is removed from file name // NOW, redefine output file for trgBranch treeMk->SetBranch("trgBranch","my_trg_data.root"); // NOW, redefine output file for "trgBranch" & "ftpc_rawBranch" // and send them in one file treeMk->SetBranch("dstBranch", "myFile.root") treeMk->SetBranch("ftpc_rawBranch","myFile.root") // OK, let us put all the branches in ONE file treeMk->SetBranch("*", "All.root") // SPECIAL hist(ogram) or hist(ory) branch //If name of branch is started from "hist" it is a special branch. //It is filled only at the end of run, and apart of user defined information //it is filled by all histograms from all makers treeMk->IntoBranch("histBranch","someParams someConst geant/.data/geom "); HOW TO READ BRANCHES ==================== StTreeMaker *treeReadMk = new StTreeMaker("treeRead", "psc0049_08_40evts.root","myTree"); StTreeMaker *treeWriteMk = new StTreeMaker("treeWrite","psc0049_08_40evts.root","myTree"); treeWriteMk->IntoBranch("newBranch","name1 name2 "); // treeRead maker will read existing tree // treeWrite maker will add new branches and will write them HOW to READ OLD FORMATS New maker StIOMaker was developed. 1. This maker does not read anything itself. It supervises other I/O makers. 2. It loads needed makers itself, depending on input file 3. It can read XDF,MDC2 and current StTree formats 4. All I/O makers now inherit from one abstract StIOInterFace I/O maker class which allows StIOMaker to treat other makers in a similar way 5. All the I/O makers including StIOMaker support all methods of StTreeMaker 6. All formats will be accessible via this maker. All detailis are hidden from the user. 7. StIOMaker can handle multiple input files via very simple StFile class StFile *setFile = new StFile(); setFile->AddFile("/disk00001/..../file1.root"); setFile->AddFile("/disk00001/..../file2.xdf"); setFile->AddFile("/disk00001/..../file3.root"); setFile->AddFile("/disk00001/abc/*.root"); // Input Tree StIOMaker *IOMk = new StIOMaker("IO","r",setFile); //StIOMaker *IOMk = new StIOMaker("IO","r",MainFile); IOMk->SetIOMode("r"); IOMk->SetBranch("*",0,"0"); //deactivate all branches IOMk->SetBranch("dstBranch",0,"r"); // activate only dstBranch NEW FEATURES of DB maker ======================== As before DB supports period of validity. The time stamp of start validity is presented in the file name of ROOT macros tcc_params.2001022.234021.C or in symbolic form tcc_params.YYYYMMDD.HHMMSS.C If there is no time-stamp 19950101.000000 is assumed In addition some aliases for validities are allowed sd97 19970101.000000 sd98 19980101.000000 year_1a 19990101.000000 year_1b 19990501.000000 year_1c 19991001.000000 year_1d 19991101.000000 year_1e 19991210.000000 year_2a 20000101.000000 So file name tcc_params.year_1a.C == tcc_params.19990101.000000.C Now we do not have real time-stamp on simulation data you can define special DB time at the beginning St_db_Maker *dbMk = new St_db_Maker("db",mainDB); dbMk->SetDateTime(19990101,000000); OR equivalent dbMk->SetDateTime("year_1a"); After this only macros with appropriate validity will be loaded. OUR database, based on UNIX directories and CINT macros is rather primitive. It can handle only one key == time-stamp Sometimes it is not enough. If 2 CINT macros create the same type of structure, a clash is inevitable. Let us say we have Trs.C TrsTestData.C With the same structure, but only one must be used. We can now select which we want dbMk->SetOff("params/tpc/trspars/Trs*") Off all Trs dbMk->SetOn ("params/tpc/trspars/TrsTest") On TrsTest Now only TrsTest.C will be loaded.