Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning to Use Root for STAR Gene Van Buren (UCLA) for the STAR Collaboration Accessing STAR Data Programming for STAR (Makers) Star => Computing => Tutorials.

Similar presentations


Presentation on theme: "Learning to Use Root for STAR Gene Van Buren (UCLA) for the STAR Collaboration Accessing STAR Data Programming for STAR (Makers) Star => Computing => Tutorials."— Presentation transcript:

1 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/index2.html

2 Root for STAR Accessing STAR Data 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: –gSystem->Load("St_base"); –gSystem->Load("St_Tables");

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

4 Root for STAR Using Datasets Dataset Iterators Navigation of a dataset hierarchy is performed with the St_DataSetIter class. St_DataSetIter 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_DataSetIter myIter("parent_set_name"); or St_DataSetIter myIter(parent_set_pointer); St_DataSet *mySet = myIter("child_set_name");

5 Root for STAR Using Datasets Getting an Event XDF file: St_XDFFile::NextEventGet() St_XDFFile::NextEventGet() –Sequential file access only Root file: keys –Random access (using TKey ) TKey St_XDFFileSt_XDFFile file("file_name","r"); // "r" means "read only" St_DataSet *event; while (event = file.NextEventGet()) {... } TFile file("file_name"); for (Int_t i=0; i<file.GetNKeys(); ++i) { St_DataSet *event = file.GetKey("event_name",i)->ReadObj();... }

6 Root for STAR Using Datasets Creating and Adding a Dataset Instantiating (creating) a dataset: St_DataSet *myNewSet = new St_DataSet("set_name"); Adding a dataset to another: –Upon instantiation: St_DataSet *myNewSet = 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); dataset No parent

7 Root for STAR Using Tables Understanding St_Table Base class for all table classes Derived classes are “wrappers” for StAF tables Nomenclature: (for tables of type table_type_name) Root class name: St_table_type_name StAF struct name: table_type_name_st Provides some basic table functions: –GetNRows() –Print() –AddAt()

8 Root for STAR Using Tables Understanding St_Table Derived from St_DataSet –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_DataSetIter) St_tpt_track *table = new St_tpt_track("tpc_tracks",3000);... myDataSet->Add(table);... table = (St_tpt_track *) myIter["tpc_tracks"]; (Note: Square brackets make dataset iterators find only tables, not sub-datasets).

9 Root for STAR Using Tables Understanding St_Table Derived from TArray –Each row is an array element –Each row is an instance of StAF table struct –GetTable() returns pointer to first row St_tpt_track *table = (St_tpt_track *) myIter["tpc_tracks"]; tpt_track_st *rowTable = table->GetTable(); for (Int_t i=0; i GetNRows(); i++) { hist->Fill(rowTable[i].value1); or hist->Fill(rowTable->value1); rowTable++; }

10 Root for STAR Using Tables Creating and Filling a Table Create new table, specifying name and max # of rows Create an instance of associated StAF 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 rowTable; rowTable.value1 = 100; rowTable.value2 = 3.14159; table->AddAt(&rowTable,0); rowTable.value1 = 200; table->AddAt(&rowTable,23);

11 Root for STAR Programming for STAR Makers A standardized way of doing analysis (base class: StMaker ) StMaker Each Maker is associated with (and responsible for) a dataset Makers are run as links of a processing chain ( StChain ) StChain dataset Maker2 dataset Maker3 dataset MakerN dataset Maker1 event

12 Root for STAR Making Makers Using the Maker template Make a root working directory for yourself Get a copy of the templates: (USE STARPRO!) cvs co StRoot/St_TLA_Maker Files are in $STAR/StRoot/St_TLA_Maker/ St_TLA_Maker.h St_TLA_Maker.cxxSt_TLA_Maker.hSt_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 add additional member functions

13 Root for STAR Making Makers 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)

14 Root for STAR Making Makers 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

15 Root for STAR Making Makers Make() This is where the event processing takes place Create your output tables Add your output tables to the Maker's dataset: ( m_DataSet is inherited from StMaker) m_DataSet->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()

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

17 Root for STAR Making Makers Other member functions Don't be afraid of adding your own member functions Ideas: place histogramming calls in a separate MakeHist() 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)

18 Root for STAR Making Makers Compiling Set directory to root working directory (your StRoot should be a subdirectory of this directory) Use starpro Type: makel St_abc_Maker Run root4star Type: gSystem->Load("St_abc_Maker"); Debug ( dbx `which root4star` ) http://newton.unicc.chalmers.se/ebt-bin/nph- dweb/dynaweb/SGI_Developer/dbx/@Generic__BookTextView/452;td=2 http://newton.unicc.chalmers.se/ebt-bin/nph- dweb/dynaweb/SGI_Developer/dbx/@Generic__BookTextView/452;td=2

19 Root for STAR Chain Macros 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

20 Root for STAR Chain Macros Examples strange.C bfc.C Sample MDC1 Data: (on the BNL unix machines) /disk00000/star/test_data/ –year1 and year2 data –raw data (*.fza files and *.xdf files) –dst data ( *_dst.xdf )


Download ppt "Learning to Use Root for STAR Gene Van Buren (UCLA) for the STAR Collaboration Accessing STAR Data Programming for STAR (Makers) Star => Computing => Tutorials."

Similar presentations


Ads by Google