STAR   Computing   Documentation  
strangeFormulas.C Documentation
Offline Software using ROOT in STAR Maintained by G. Van Buren
Last modified Tue Apr 11 15:30:19 2000

StStrangeMuDstMaker


The Formulas Macro

Introduction
Loading
Using
Technical
Formulas


Introduction

The Root macro strangeFormulas.C is intended to improve ease-of-use for users of the strangeness physics working group micro-DST created by the StStrangeMuDstMaker package. This micro-DST is in the form of a TTree, which allows it much flexibility and efficient performance characteristics. To take advantage of these characteristics, it is best to treat the micro-DST as a TTree, and not as instances of the component classes that make up the TTree. However, doing so prevents the direct use of member functions associated with the component classes when calling the Draw() and Scan() member functions of TTree.

But strangeFormulas.C provides a way to use most of those member functions. This is done via the TTreeFormula Root class. These formulas allow a simple mapping of a formula name to a collection of arithmetic calculations on data members of the TTree. Additionally, TTreeFormula can take as arguments other formulas. TTreeFormula is just a special case of TFormula which allows the usage of data members of a particular TTree, and are thus tied to a particular TTree.

To see which formulas are provided, go to the Formulas section below, or look at the macro itself, which is located in:
$STAR/StRoot/macros/analysis/strangeFormulas.C
Some examples include:

As with using the data members of the TTree, these functions begin with a component name, such as Event or V0. The Formulas section also describes how to find a specific formula for which you might be looking.


Loading the Formulas

To use these functions provided by strangeFormulas.C, one need only have either a pointer to a strangeness micro-DST TTree (in memory or on file, it doesn't matter), or simply know file which contains the root of such a TTree. It is unnecessary to load any STAR libraries into Root, and even unnecessary to use root4star (i.e. one can run generic Root). The user has three possible forms for loading the functions:
1.  TTree* strangeFormulas(const char* fname=0);
2.  TTree* strangeFormulas(TFile* fptr);
3.  Int_t strangeFormulas(TTree* tree);
  1. The first form allows the user to enter a filename with the root of the TTree for the strangeness micro-DST. It loads the functions, and then returns a pointer to the TTree. Example usage would be as follows:
      .L strangeFormulas.C;
      myTree = strangeFormulas("myDst.root");
    
    If no filename is entered (e.g. myTree = strangeFormulas();), the default filename of "evMuDst.root" is used. The name of the TTree inside the file should be "StrangeMuDst" and this is the default name as given when constructed by the StStrangeMuDstMaker package.

  2. The second form is useful if the user has already opened the file containing the TTree:
      TFile file1("myDst.root");
      ...
      .L strangeFormulas.C;
      myTree = strangeFormulas(file1);
    
    The file should again contain a TTree with the name "StrangeMuDst".

  3. The last form is for a TTree which is in memory, or one on file for which the user has a pointer. An example of this case is if the micro-DST was just created via a chain, and the user still has access to the maker which created it:
      myTree = strangeDstMaker.GetTree();
      .x strangeFormulas.C(myTree);
    
    The last line is an abreviated version of:
      .L strangeFormulas.C;
      strangeFormulas(myTree);
    
    This shortcut is not very useful for the first two forms for loading the formulas because the user needs to get the returned TTree pointer. In this case the return value is unimportant.

    The user can always get a pointer a TTree on file via something like:

      TFile file1("myDst.root");
      myTree = (TTree*) file1.Get("StrangeMuDst");
      .x strangeFormulas.C(myTree);
    


Using the Formulas

Once the formulas have been loaded, usage is simply like the usage of data members of the TTree. For example, the strangeness micro-DST TTree contains a data member Event.mPrimaryVertexX, and there is a TTreeFormula provided named Event.primaryVertexX() which simply maps to the same data member. The following two lines would then give identical results:
  myTree.Scan("Event.mPrimaryVertexX");
  myTree.Scan("Event.primaryVertexX()");
More complicated formulas would be of the mass and rapidity of a V0 under the assumption that the decay was that of a lambda (postive daughter is a proton, and negative daughter is a pion). Such formulas are provided, allowing the user to make a phase space plot like:
  myTree.Draw("V0.ptV0():V0.rapLambda()","abs(V0.massLambda()-mLambda)<0.05");
As with any call to Scan() or Draw(), the second parameter is a selection criteria. This example also shows the use of a formula with the name "mLambda". This is available because the macro also loads some useful mass formulas:
  TFormula("mLambda","1.11563");
  TFormula("mAntiLambda","1.11563");
  TFormula("mK0Short","0.497671");
  TFormula("mProton","0.938272");
  TFormula("mAntiProton","0.938272");
  TFormula("mPiPlus","0.139568");
  TFormula("mPiMinus","0.139568");
  TFormula("mKaonMinus","0.493646");
  TFormula("mXiMinus","1.32133");
  TFormula("mOmegaMinus","1.67243");
Some notes on improving performance:


Technical Issues


Available Formulas

In addition to the listing below, the macro provides two functions to help you find a specific formula. The first of these is the findFormulas() function, which takes up to three strings as arguments, and returns all formulas whose names contain the strings (case-insensitive):
  findFormulas("lambda","V0");
    V0.eLambda()
    V0.massLambda()
    V0.massAntiLambda()
    V0.rapLambda()
    V0.cTauLambda()
The second helpful function is findDefinition(). This function takes the name of a formula and returns its definition:
  findDefinition("V0.massLambda()");
    Name       : V0.massLambda()
    # of Codes : 12
    Definition : sqrt(sq(V0.ePosProton()+V0.eNegPion())-V0.Ptot2V0())
Here is an overview of the formulas provided: