Noddy Guide To Monte Carlo Generation

Noddy Image


Dont use this unless you really, really want to find out the nasty dirty basic stuff of what goes on with MC software. If you just want MC events with none of the pain, use mc_runjob Its Fantastic!


This is a brief guide to generating a Monte Carlo sample and running it through the necessary packages to make a root compatible ntuple.
Thanks go to Vivek, who helped me learn all this stuff.

Introduction

This is designed for the p05.00.04 version of the DZero software on d0mino. The order in which you need to run the packages is as follows:

  1. Pythia to generate the process
  2. MC_Exam to select interesting particle events
  3. D0gstar to simulate detector response
  4. D0Sim to digitize and create the fake data
  5. D0Reco to reconstruct the events
  6. RecoAnalyze to analyze the events and root-tuple

Some Notes:

Running MC_Exam after Pythia is not necessary until you know exactly what you are doing, so I will leave it until the end. I used the dspack format for some files and evpack format for others, you just have to be consistent in reading in the correct format in the ReadEvent.rcp. To use DSPACK,set the inputformat string to "DSPACK", you can use EVPACK by setting 'string inputformat = ""' (and specifying the compression level to be 5, as this is the best value to use) in the ReadEvent.rcp for any given package. Similarly edit the same line in WriteEvent.rcp files to pick your favourite output.
In the rcp and shell script file examples I have outlined the things that you need to modify with lines of percent signs : //%%%%%%%%%%%%
You could copy the examples if you want to they are just the same ones I use with extra comments.

Using SAM

I cant yet, if someone wants to show me how, then I will stick it on this page as well, some of the packages have specific rcps to use when you run with SAM, all the setups copy these rcps as well as the non-SAM versions, so if you know what you are doing have a go.

Re-Running

Basically when you re-run, you just need to give different input/output files (or rename the old ones).


Setting up


You may want to look at how I do it: have a look at:
/tmp_root/722/lnc_1/evansde/Monte_Carlo/p05.00.04 on d0mino.


You want to get a fairly well organised bit of disk space before you start as you will end up with packages softlinks and RCPs coming out of you nose. So best way to start is to make a dir called 'MonteCarlo' or something to keep everything, then in there make a directory called 'output' to send all of your output files to and point softlinks at. Then make the following directories: Pythia, D0gstar, D0Sim, D0Reco, Reco_analyze and MC_Exam. Next you need to issue the usual setup commands for working in the DZero framework on D0mino:


1. Pythia

Setting up:
Go to your Pythia directory and do the following:

Now make a link to the Pythia executable in the D0RunII framework:

now get the relevant rcp files, pythia and QQ files and put them where the code can find them:

Setting Parameters:
Set options in the various rcp files, make MCWriteEvent.rcp point to your output area, set the number of events/runs in MCNewEvent.rcp. Annotated samples of the main rcp files are here.
Pythia.cards, pythia.cmd and user.dec set the options for the Pythia processes that Pythia will create. Information on these is available in Kin Yips MC Instructions. There are some pythia.cards examples in the directory:
/tmp_root/722/lnc_1/evansde/Monte_Carlo/Pythia/PythiaCardExamples
To use these, copy them to your pythia directory, rename pythia.cards to something else and rename the example as pythia.cards.

Running Pythia:


2. Running D0gstar

Setting up:
Go to your D0gstar directory and do the following:

This sets up the d0gstar_user package and all the stuff that goes with it. There are a couple of versions available but the one you want to use is the ex03 version so, set your input/output rcp parameters in:

You can have a look at these rcps here. You will want to change the Read and Write rcp files for format and number of events. You can tweak minbias merging along with vertex and seed options in the SimMergeKinePkg.rcp. The framework rcp file in this case is framework_mckine.rcp. and is found in the ex03 directory, along with the shell script to run the job:

Then the only bit you need to worry about here is the shell script called run.test_mckine.csh to define your input and output files, an example of it is here.
Then all you need to do is to edit this file and run it (you may have to 'source' it):(best to do this in Batch mode and take three days off if its a big job)


3. Running D0Sim

This one is easy, you dont really need to look at many rcp files }:o) but here is a copy of runD0Sim.rcp just in case.
Setting up:
Go to your D0Sim directory and do the following:

Set the NumEvents and input/output formats in the Read/Write rcps you have just copied to your d0sim/rcp directory. Here are the examples.

Now you have everything you need all set up, now we make links to Minbias events, and input and outputlinks, to avoid having to change the Read/Write RCPs. So first I make softlinks to my input (d0gstar out) file to the inputfile string, and link your desired output file to the outputfile string. In my example this is:

The minbias files I have been using are:

so to link them to the correct d0sim input strings:

To edit the minbias event adding properties:(default is to add 1.1 minbias events to those on the inputfile)

Then find a copy of MergeMinbias.rcp, put it in the pileup/rcp directory and you can edit it as you like.(there is a copy in my version:
/tmp_root/722/lnc_1/evansde/Monte_Carlo/p05.00.04/D0sim/pileup/rcp

Now you are ready to run:(again big jobs require batch queues and something interesting to do...)


4. Running D0Reco

Setting up:
Pretty much the same as in D0Sim:
Go to your D0reco directory:

Right then, modify your rcp parameters, runD0reco_psim01.rcp is the framework rcp file for use with D0Sim data, you can add remove packages in it if you want to. The rcps you must edit are the Read and Write rcps.

Now you have to link your input and output files:

Now you can run the program...

Note:

Ther are piles of ERLOG messages and other complaints thrown up when you run D0reco, if you think any are bad for what you are doing, complain to the developers... :)))


5. Running Reco_Analyze

Setting up:
Go to your reco_analyze directory and do:

Standard output is a root file, not an EVPACK type file, you can set root/HBOOK types in RecoANtupleMgr.rcp. To get the EVPACK type ouput, you need to call the write package in runRecoAnalyze.rcp, which is shown in the example below. Now you need to edit the ReadEvent and WriteEvent(if using) rcp files in the reco_analyze/rcp directory.
Then soft link your D0Reco output to the inputfile string: (similarly for outputfile if you are using it,see rcp examples)

You may want to fiddle with the packages that are used if say, you just wanted to look at jets, you would take out some of the non-jet packages. This is pretty straight forward to do in runRecoAnalyze.rcp
After that you run the program:

The output will be a root file in your reco_analyze area called root_RecoAnalyze.rtpl. All you need to do to look at this in root is to rename it so it ends with a .root

Thats all for now...noddy pic


By Dave Evans
Last modified: Tue Aug 21 13:22:13 CDT 2001