Learning to Use Root for STAR Gene Van

  • Slides: 20
Download presentation
Learning to Use Root for STAR Gene Van Buren (UCLA) for the STAR Collaboration

Learning to Use Root for STAR Gene Van Buren (UCLA) for the STAR Collaboration Accessing STAR Data Programming for STAR (Makers) Star => Computing => Tutorials => Learning to Use Root for STAR http: //www. star. bnl. gov/STAR/html/comp_l/root/index 2. html

Accessing STAR Data Root for STAR • All data is stored in tables •

Accessing STAR Data Root for STAR • All data is stored in tables • Tables associated with a particular subsystem or physics topic are grouped into datasets • Datasets are placed in a hierarchy of topics inside an event • Events are navigated with dataset iterators to find tables of interest • Need STAR base and table libraries: – g. System->Load("St_base"); – g. System->Load("St_Tables");

Root for STAR Using Datasets The Dataset Hierarchy dataset table dataset table • Each

Root for STAR Using Datasets The Dataset Hierarchy dataset table dataset table • Each dataset is an instance of the St_Data. Set class • In the dataset hierarchy, a dataset can be a subset of another data set • An event is a dataset

Using Datasets Root for STAR Dataset Iterators • Navigation of a dataset hierarchy is

Using Datasets Root for STAR Dataset Iterators • Navigation of a dataset hierarchy is performed with the St_Data. Set. Iter class. • To find a particular child dataset of a parent dataset – Instantiate a new iterator for the parent dataset – Supply the iterator with the name of the child dataset – A pointer to the child dataset is returned St_Data. Set. Iter my. Iter("parent_set_name"); or St_Data. Set. Iter my. Iter(parent_set_pointer); St_Data. Set *my. Set = my. Iter("child_set_name");

Using Datasets Root for STAR Getting an Event • XDF file: St_XDFFile: : Next.

Using Datasets Root for STAR Getting an Event • XDF file: St_XDFFile: : Next. Event. Get() – Sequential file access only St_XDFFile file("file_name", "r"); // "r" means "read only" St_Data. Set *event; while (event = file. Next. Event. Get()) {. . . } • Root file: keys – Random access (using TKey) TFile file("file_name"); for (Int_t i=0; i<file. Get. NKeys(); ++i) { St_Data. Set *event = file. Get. Key("event_name", i)->Read. Obj(); . . . }

Root for STAR Using Datasets Creating and Adding a Dataset • Instantiating (creating) a

Root for STAR Using Datasets Creating and Adding a Dataset • Instantiating (creating) a dataset: St_Data. Set *my. New. Set = new St_Data. Set("set_name"); dataset No parent • Adding a dataset to another: – Upon instantiation: dataset St_Data. Set *my. New. Set = new St_Dataset("new_set_name", parent_set_pointer); – Any other time: parent_set_pointer->Add(child_set_pointer); • Removing a dataset from another: – parent_set_pointer->Remove(child_set_pointer);

Using Tables Root for STAR Understanding St_Table • Base class for all table classes

Using Tables Root for STAR Understanding St_Table • Base class for all table classes • Derived classes are “wrappers” for St. AF tables • Nomenclature: (for tables of type table_type_name) Root class name: St_table_type_name St. AF struct name: table_type_name_st • Provides some basic table functions: – Get. NRows() – Print() – Add. At()

Using Tables Root for STAR Understanding St_Table • Derived from St_Data. Set – Can

Using Tables Root for STAR Understanding St_Table • Derived from St_Data. Set – Can be placed in the data hierarchy just as a dataset would be. – Can be found the same way a dataset is (with an St_Data. Set. Iter) St_tpt_track *table = new St_tpt_track("tpc_tracks", 3000); . . . my. Data. Set->Add(table); . . . table = (St_tpt_track *) my. Iter["tpc_tracks"]; (Note: Square brackets make dataset iterators find only tables, not sub-datasets).

Using Tables Root for STAR Understanding St_Table • Derived from TArray – Each row

Using Tables Root for STAR Understanding St_Table • Derived from TArray – Each row is an array element – Each row is an instance of St. AF table struct – Get. Table() returns pointer to first row St_tpt_track *table = (St_tpt_track *) my. Iter["tpc_tracks"]; tpt_track_st *row. Table = table->Get. Table(); for (Int_t i=0; i<table->Get. NRows(); i++) { hist->Fill(row. Table[i]. value 1); or hist->Fill(row. Table->value 1); row. Table++; }

Using Tables Root for STAR Creating and Filling a Table • • Create new

Using Tables Root for STAR Creating and Filling a Table • • Create new table, specifying name and max # of rows Create an instance of associated St. AF table struct Fill values of row Insert row into table (row table is copied) St_tpt_track *table = new St_tpt_track("tpc_tracks", 3000); tpt_track_st row. Table; row. Table. value 1 = 100; row. Table. value 2 = 3. 14159; table->Add. At(&row. Table, 0); row. Table. value 1 = 200; table->Add. At(&row. Table, 23);

Programming for STAR Root for STAR Makers • A standardized way of doing analysis

Programming for STAR Root for STAR Makers • A standardized way of doing analysis (base class: St. Maker) • Each Maker is associated with (and responsible for) a dataset • Makers are run as links of a processing chain (St. Chain) St. Chain event Maker 1 dataset Maker 2 dataset Maker 3 dataset Maker. N dataset

Making Makers Root for STAR Using the Maker template • Make a root working

Making Makers Root for STAR Using the Maker template • Make a root working directory for yourself • Get a copy of the templates: (USE STARPRO!) cvs co St. Root/St_TLA_Maker • Files are in $STAR/St. Root/St_TLA_Maker/ St_TLA_Maker. h St_TLA_Maker. cxx – Constructor : Name the associated dataset – Init(): Initialize any variables or tables to be used for all events – Make(): Process each event – Finish(): Post-event-loop processing – Can additional member functions

Making Makers Root for STAR Constructor and header file (. h) • First, edit

Making Makers Root for STAR Constructor and header file (. h) • First, edit St_TLA_Maker. h and St_TLA_Maker. cxx files, and perform a global replace on "TLA" with the name you wish to give your Maker. • Change the constructor prototype (in the. h file) to specify the name and title you wish to give the dataset to be associated with this Maker. • Probably don't need to do anything for constructor in. cxx file • Add data members and new methods in. h file as necessary for the. cxx file. • Use "//!" after data members which are pointers (prevents them from being saved when writing objects to file)

Making Makers Root for STAR Init() • Initalize any variables which you will be

Making Makers Root for STAR Init() • Initalize any variables which you will be using for all events. • Create any tables you will be using in all events • Be sure you have made variables (and table pointers) available to the whole Maker by defining them in the. h file (remember scope) • Tables should be made with the "new" command, and a pointer kept. Otherwise they will be lost when the scope of Init() ends. • Insert #include "class. h" at the top of the. cxx file for any classes which you are using

Making Makers Root for STAR Make() • This is where the event processing takes

Making Makers Root for STAR Make() • This is where the event processing takes place • Create your output tables • Add your output tables to the Maker's dataset: (m_Data. Set is inherited from St. Maker) m_Data. Set->Add(table_pointer); • Get pointers to your input tables • If you're wrapping a PAM, place a call to that PAM • If you're writing a new analysis module, just place your code at the end of Make()

Making Makers Root for STAR Finish() • Not necessary (if you don't have any

Making Makers Root for STAR Finish() • Not necessary (if you don't have any post-event-loop processing) • Perform calculations on histograms you've made • Create run summary information

Making Makers Root for STAR Other member functions • Don't be afraid of adding

Making Makers Root for STAR Other member functions • Don't be afraid of adding your own member functions • Ideas: place histogramming calls in a separate Make. Hist() member function which is called from the Make() member function • Remember to place prototype in. h file • Keep these member functions out of public: if you are going to place your Maker where others can use it (good programming practice)

Making Makers Root for STAR Compiling • Set directory to root working directory (your

Making Makers Root for STAR Compiling • Set directory to root working directory (your St. Root should be a subdirectory of this directory) • Use starpro • Type: makel St_abc_Maker • Run root 4 star • Type: g. System->Load("St_abc_Maker"); • Debug (dbx `which root 4 star`) http: //newton. unicc. chalmers. se/ebt-bin/nphdweb/dynaweb/SGI_Developer/dbx/@Generic__Book. Text. View/452; td=2

Chain Macros Root for STAR Macro Outline 1. Load software libraries 2. Define input

Chain Macros Root for STAR Macro Outline 1. Load software libraries 2. Define input file(s), and any output file(s) 3. Construct a chain which controls the flow of the analysis 4. Construct the Makers which contain the analysis modules 5. Initialize the chain (which in turn intializes all the Makers) 6. Loop over events to process from the input. For each event: a. Call the Make() member function of the chain - this calls each Maker to perform its analysis b. Output each event as desired c. Clear the chain 7. Call the Finish() member function of the chain to perform any post-run processing

Chain Macros Root for STAR Examples • strange. C • bfc. C • Sample

Chain Macros Root for STAR Examples • strange. C • bfc. C • Sample MDC 1 Data: (on the BNL unix machines) /disk 00000/star/test_data/ – year 1 and year 2 data – raw data (*. fza files and *. xdf files) – dst data (*_dst. xdf)