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 |
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:
1. TTree* strangeFormulas(const char* fname=0); 2. TTree* strangeFormulas(TFile* fptr); 3. Int_t strangeFormulas(TTree* tree);
.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.
TFile file1("myDst.root"); ... .L strangeFormulas.C; myTree = strangeFormulas(file1);The file should again contain a TTree with the name "StrangeMuDst".
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);
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:
myTree.Draw("V0.massK0Short()","","",10);
myTree.SetEstimate(myTree.GetEntries());However, setting a smaller number for the estimate calculations reduces the number of redundant calculations that must be made.
An alternative approach is to use this TTree to fill an already existing histogram. This can be done either with the Project() or Draw() member functions of TTree, and avoids any redundant calculations to find maxima and minima:
TH1F h1("myHist","pt distribution",50,0.,5.); myTree.Draw("Xi.ptXi()>>myHist"); ...or... myTree.Project("myHist","Xi.ptXi()");
f1 = new TTreeFormula("this","that+the_other",tree); gROOT->GetListOfFunctions()->Add(f1);
For example, "a()+a()+a()" repeats everything necessary to find "a()" three times. If "a()" requires 20 values to calculate, then "a()+a()+a()" will fail (for Root 2.24/04), needing 60 values. However, this failure does not get reported to the user! A false value is returned which is the result of the incomplete calculation using only the first 50 values. BE WARNED! In the above example, it is much better to write something like "3*a()", which actually still only requires 20 values.
Complicated formulas in the macro have the number of values used in their calculations documented above them. The user should take note of these values if they decide to add more complicated formulas using these formulas.
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:
mLambda mAntiLambda mK0Short mProton mAntiProton mPiPlus mPiMinus mKaonMinus mXiMinus (only loaded for Xi's) mOmegaMinus (only loaded for Xi's)
Event.run() Event.event() Event.globalTracks() Event.primaryTracks() Event.primaryVertexX() Event.primaryVertexY() Event.primaryVertexZ()
-- decay parameters -- V0.decayLengthV0() V0.decayVertexV0X() V0.decayVertexV0Y() V0.decayVertexV0Z() V0.dcaV0Daughters() V0.dcaV0ToPrimVertex() V0.dcaPosToPrimVertex() V0.dcaNegToPrimVertex() V0.cTauLambda() V0.cTauK0Short() -- geometry parameters -- V0.radtV0() V0.radV0() V0.phiV0() -- momentum -- V0.momPosX() V0.momPosY() V0.momPosZ() V0.ptPos() V0.Ptot2Pos() V0.ptotPos() V0.momNegX() V0.momNegY() V0.momNegZ() V0.ptNeg() V0.Ptot2Neg() V0.ptotNeg() V0.momV0X() V0.momV0Y() V0.momV0Z() V0.Pt2V0() V0.ptV0() V0.Ptot2V0() V0.ptotV0() V0.thetaV0() V0.pseudoRapV0() V0.psiV0() V0.MomPosAlongV0() V0.MomNegAlongV0() V0.alphaV0() V0.ptArmV0() -- energy -- V0.eLambda() V0.eK0Short() V0.ePosProton() V0.eNegAntiProton() V0.ePosPion() V0.eNegPion() -- mass -- V0.massLambda() V0.massAntiLambda() V0.massK0Short() -- rapidity -- V0.rapLambda() V0.rapK0Short() -- topology maps -- * = Pos or Neg V0.topologyMap*.data(i), i=0...1 V0.topologyMap*.bit(i), i=0...63 V0.topologyMap*.ftpcFormat() V0.topologyMap*.primaryVertexUsed() V0.topologyMap*.turnAroundFlag() V0.topologyMap*.hasHitInSvtLayer(i), i=1...6 V0.topologyMap*.numOfSvtHits() V0.topologyMap*.hasHitInSsd() V0.topologyMap*.hasHitInTpcRow(i), i=1...45 V0.topologyMap*.numOfTpcHits() V0.topologyMap*.hasHitInMwpc() V0.topologyMap*.hasHitInCtb() V0.topologyMap*.hasHitInTofPatch() V0.topologyMap*.hasHitInRich() V0.topologyMap*.hasHitInBarrelEmc() V0.topologyMap*.hasHitInEndcapEmc() -- track quality -- V0.chi2V0() V0.clV0() V0.chi2Pos() V0.clPos() V0.dedxPos() V0.numDedxPos() V0.chi2Neg() V0.clNeg() V0.dedxNeg() V0.numDedxNeg()
-- V0 formulas -- Just as for V0 above, but with Xi. replacing V0. -- -- decay parameters -- Xi.decayLengthXi() Xi.decayVertexXiX() Xi.decayVertexXiY() Xi.decayVertexXiZ() Xi.dcaXiDaughters() Xi.dcaXiToPrimVertex() Xi.dcaBachelorToPrimVertex() Xi.cTauXi() Xi.cTauOmega() -- geometry parameters -- Xi.radtXi() Xi.radXi() Xi.phiXi() -- momentum -- Xi.momBachelorX() Xi.momBachelorY() Xi.momBachelorZ() Xi.ptBachelor() Xi.Ptot2Bachelor() Xi.ptotBachelor() Xi.momXiX() Xi.momXiY() Xi.momXiZ() Xi.Pt2Xi() Xi.ptXi() Xi.Ptot2Xi() Xi.ptotXi() Xi.thetaXi() Xi.pseudoRapXi() Xi.psiXi() Xi.MomBachelorAlongXi() Xi.MomV0AlongXi() Xi.alphaXi() Xi.ptArmXi() -- energy -- Xi.eXi() Xi.eOmega() Xi.eBachelorPion() Xi.eBachelorKaon() -- mass -- Xi.massXi() Xi.massOmega() -- rapidity -- Xi.rapXi() Xi.rapOmega() -- misc -- Xi.charge() Xi.keyBachelor() -- topology maps -- * = Pos or Neg (for V0 daughters) or Bachelor Otherwise, just as for V0 above, but with Xi. replacing V0. -- track quality -- Xi.chi2Xi() Xi.clXi() Xi.chi2Bachelor() Xi.clBachelor() Xi.dedxBachelor() Xi.numDedxBachelor()
-- None at present --
V0Mc.decayMode() V0Mc.positiveCommonTpcHits() V0Mc.positiveSimTpcHits() V0Mc.negativeCommonTpcHits() V0Mc.negativeSimTpcHits() V0Mc.geantIdParent() V0Mc.geantIdPositive() V0Mc.geantIdNegative() V0Mc.parentMomentumX() V0Mc.parentMomentumY() V0Mc.parentMomentumZ() V0Mc.positiveMomentumX() V0Mc.positiveMomentumY() V0Mc.positiveMomentumZ() V0Mc.negativeMomentumX() V0Mc.negativeMomentumY() V0Mc.negativeMomentumZ() V0Mc.positionX() V0Mc.positionY() V0Mc.positionZ()
XiMc.decayMode() XiMc.commonTpcHits() XiMc.simTpcHits() XiMc.geantIdParent() XiMc.geantIdDaughter() XiMc.parentMomentumX() XiMc.parentMomentumY() XiMc.parentMomentumZ() XiMc.daughterMomentumX() XiMc.daughterMomentumY() XiMc.daughterMomentumZ() XiMc.positionX() XiMc.positionY() XiMc.positionZ()
Identical to XiMc Formulas with KinkMc. replacing XiMc.