First Steps with the Analysis


Last Modified on 05/02/2019 09:27:59 by Todd


You have now learned a few interactive root commands, but to do the full data analysis you will need to learn how to write macros- longer programs that can be executed in root.  You should have an example of a root macro already- it is called JPsiMass.C and it runs over the Mphys data to find pairs of muons and reconstruct the J/ψ meson candidate that decayed to produce them.  There is a header file called JPsiMass.h that includes information about which files to use as input for this process.  Also notice LsqFit.cc and LsqFit.hh - LsqFit is a vertex-fitting program called on in JPsiMass.C.  Finally, the file called JPRun.C is another macro that simply contains the root commands necessary to compile and run JPsiMass.C.  To run, all you need to do is start up root and type:
                    .x JPRun.C
This will run for some time, outputting occasional status updates to confirm that it is running correctly and not stalled.  The updates go logarithmically with the number of events run over, so you will see more updates near the beginning of the run than near the end.  There will be a few "warning" messages at the very beginning, but these can be ignored.  When the program eventually finishes you will notice a new file in the directory you ran it from called jpm.root.  This is a root tree containing mass and vertex information for the J/Ψ candidate and some information about the muons produced.

There is another way to run the macro without booting up root, which you may want to do to make it a background process.  Without starting root, the command is:
                    nice root -b -q JPRun.C >& jpm.log &
Note the use of the "nice" command. This is important in multi-user environments as it places the program run at a lower priority thus making the computer still useable for others. The ampersands make the process run in the background. To view the output of the program type the following:
                    tail -20 jpm.log
which will display the last 20 lines of jpm.log.

Once the program completes, open the output root file.  A useful shortcut is the following:
                    root jpm.root
which will automatically open the file when root starts up.  You can use the TBrowser as before to have a look around the file.  Stored in the file there is a tree called "output" and a histogram called "jpm."  While both can be used to display a plot of the J/Ψ mass, using the tree gives you more flexibility in plotting the mass, since you can apply various cuts. You will want to play around with varying the cuts to understand how they affect the signal and the background.

 

When you ran the macro earlier, it used the data from only one of the Mphys project files, jpmm0d_stripped.root (the same one we opened up and looked at earlier).  To get even more output, you will need to edit the header file to change which file(s) are opened.  Open it up in emacs:
                    emacs JPsiMass.h &
Do a search (Ctrl+s) for jpmm0d_stripped and go to the second result (on line 673).  The code in this area is creating a chain of multiple root files and setting the chain as the "tree" of data to be run over.  Right now the chain contains only a single file, but the commented-out lines below show you how to add more trees to the chain.  The * wildcard works for this purpose, so you can add "jpmm0d_stripped*" to the chain to get all of the files from the jpmm0d dataset.  This is a lot of data and will increase the macro running time considerably, so you may want to run overnight if you are chaining up this many files.  Eventually you will be using all of the available datasets- "/data/cdfjpsi/jpmm0d/jpmm0d_stripped*", "/data/cdfjpsi/jpmm0h/jpmm0h_stripped*", and "/data/cdfjpsi/jpmm0i/jpmm0i_stripped*".

 

Finally, This part you should not need, but I think you should be aware how it is done anyway.
You may need to know how to make your own macro.  ROOT has a MakeClass command which generates a .C and .h file to run over a pre-existing tree structure- so if you open up one of the data files (the files with the *.root extension) and do MakeClass on it, you will have created a new macro that works on any tree of the same structure as the data file.  The macro MakeClass.C contains the necessary commands to open jpmm0d_stripped and make a new class called MyClass.  Assuming that you have a data file in your working directory called...say "filename.root" and within that data file is a TTree with the name TreeName (you can find this out using the TBrowser), you run MakeClass the following way in root:

                    TFile *f = new TFile("filename.root"); // attach the data file to the root session.
                    TreeName->MakeClass("NewClassName");

This ought to create two files in the directory you are working. NewClassName.C and NewClassName.h. NewClassName.h will have all the variables declared that are stored in the original data file. NewClassName.C will contain the bare-bones bit of code that you would need to be able to loop over all the entries in the data file. What you actually do with that data is then your own choice and can be added to the code inside NewClassName.C.

You will need to modify these files just a bit. In the NewClassName.h file you will need to add the line #include <TSystem> near the top. You might find also in the *.h file multiple #include statements of the same thing, if so just delete the redundant declarations.
You'll need to edit the "if (tree == 0)" part of the .h file to open up the correct input tree(s), but you can copy this code from JPsiMass.h.

Of course you can cheat a bit in this case by simply making copies of JPsiMass.h and JPsiMass.C under new names instead of running MakeClass.C- just make sure that you go through your copies to find and replace every instance of "JPsiMass" with the new macro name.  This shortcut works because both JPsiMass and your new macro run over the "prod" tree within jpmm0d_stripped and the other identically-structured Mphys data files.  You can do this and avoid having to use "MakeClass" yourself as explained in the previous paragraph. The JPsiMass.C macro's header file contains information about all of the branches and leaves in "prod," so the macro only works on the Mphys data files.  To make a macro that runs on a tree with different branches/leaves, you'd need to open that tree file in root and use MakeClass on it as above.

You will be creating a macro that builds on the JPsiMass.C code to add a charged kaon track and create a mass plot for B meson candidates.