$ cvs co StRoot/StarGenerator/macros/starsim.kinematics.C # check out the macro $ ln -s StRoot/StarGenerator/macros/starsim.kinematics.C starsim.C # create a link named starsim.C $ root4star starsim.C # run the code using STAR's version of ROOTYou're going to see alot of output here, but in the end you'll have two output files: starsim.kinematics.root and starsim.kinematics.fzd
$ ls starsim.kinematics.fzd starsim.kinematics.root starsim.C StRoot/
These two files are the so called "zebra" file (.fzd), containing the Monte Carlo hits, geometry and other associated event information, and the event generator record (.root), containing a ROOT TTree which saves all of the particles generated by the primary event generator.
Once we have the output files, it's time to run them through the reconstruction chain. STAR's reconstruction code is steered using the "big full chain" macro bfc.C. For most jobs you'll want to provide BFC three arguements: the number of events to produce, the set of chain options to run, and an input file. For more complicated tasks you're encouraged to ask questions on the STAR software list.
$ emacs runBfc.C # Feel free to use your favorite editor instead of emacs 0001 | void runBfc() { 0002 | gROOT->LoadMacro("bfc.C"); // Load in BFC macro 0003 | TString _file = "kinematics.starsim.fzd"; // This is our input file 0004 | TString _chain; // We'll build this up 0005 | _chain += "ry2012a "; // Start by specifying the geometry tag (note the trailing space...) 0006 | _chain += "AgML USExgeom "; // Tells BFC which geometry package to use. When in doubt, use agml. 0007 | _chain += "fzin "; // Tells BFC that we'll be reading in a zebra file. 0008 | _chain += "TpcFastSim "; // Runs TPC fast simulation 0009 | _chain += "sti ittf "; // Runs track finding and reconstruction using the "sti" tracker 0010 | _chain += "cmudst "; // Creates the MuDst file for output 0011 | _chain += "geantout "; // Saves the "geant.root" file 0012 | bfc(10, _chain, _file ); // Runs the simulation chain 0013 | } ctrl-x ctrl-s ctrl-x ctrl-q # i.e. save and quit $ root4star runBfc.C # run the reconstruction job $ ls -l ...
If all has gone well, you now have several files in your directory including the MuDst which you'll use in your analysis.
$ ls -1 *.root kinematics.geant.root kinematics.hist.root kinematics.MuDst.root kinematics.runco.root kinematics.starsim.root
C. idTruth and qaTruth
During the first phase of the simulation job we had full access to the state of the simulated particles at every step as they propagated through the STAR detector. As particles propagate through active layers, the simulation package can register "hits" in those sensitive layers. These hits tell us how much energy was deposited, in which layer and at what location. They also save the association between the particle which deposited the energy and the resulting hit. This association is saved as the "idTruth" of the hit. It corresponds to the unique id (primary key) assigned to the particle by the simulation package. This idTruth value is exceedingly useful, as it allows us to compare important information between reconstructed objects and the particles which are responsible for them.
Global and Primary tracks contain two truth variables: idTruth and qaTruth. idTruth tells us which Monte Carlo track was the dominant contributor (i.e. provided the most TPC hits) on the track, while qaTruth tells us the percentage of hits which thath particle provided. With idTruth you can lookup the corresponding Monte Carlo track in the StMuMcTrack branch of the MuDst. In the event that idTruth is zero, no MC particle was responsible for hits on the track.
With the MC track, you can compare the thrown and reconstructed kinematics of the track (pT, eta, phi, etc...).
Primary vertex also contains an idTruth, which can be used to access the Monte Carlo vertex which it corresponds to in the StMuMcVertex branch of the MuDst.
D. Taking it further
In starsim.kinematics.C we use the StarKinematics event generator, which allows you to push particles onto the simulation stack on an event-by-event basis. You can throw them flat in phase space, or sample them from a pT and eta distribution. These methods are illustrated in the macro, which throws muons and pions in the simulation. You can modify this to suit your needs, throwing whatever particles you want according to your own distribtions. The list of available particles can be obtained from StarParticleData.
$ root4star starsim.C\(0\) root [0] StarParticleData &data = StarParticleData::instance(); root [1] data.GetParticles().Print()
Additionally, you can define your own particles. See starsim.addparticle.C.
Primary Event Generation