Monte Carlo generation using Pythia and QQ


Kin Yip - March 13, 2000
 

I describe below some steps in producing Monte Carlo samples, mainly for B physics studies, using   Pythia and QQ   which have been incorporated in the Dzero Run II software (mcpp/d0_mcpp). 

(A) Making Generator File:

(1)  There is already a  MCpythia.x  in every release located in
     $BFDIST/releases/$BFCURRENT/bin/$BFARCH
(all these variables are defined after one does "setup D0RunII xx.xx.xx").

One can run as    MCpythia.x -rcp runMCpythia.rcp    in which runMCpythia.rcp * may have

string Packages = "p1 MCpythia p3 p4"

RCP p1 = < d0_mcpp MCNewEvent >
RCP MCpythia = < d0_mcpp MCpythia >
RCP p3 = < d0_mcpp MCDumpEvent >
RCP p4 = < d0_mcpp MCWriteEvent >

assuming that you put the rcp files in the directory d0_mcpp/rcp.

* You have to create runMCpythia.rcp yourself and you may modify from d0_mcpp/rcp/runMCisagen.rcp .

(2) The above rcp files can be found in the release area of d0_mcpp/rcp. The other rcp files which may be changed are mcvertex.rcp and seed.rcp and they can also be found in the same directory.

(3) The other files necessary for Pythia are   pythia.cards   and pythia.cmd.   Both files can be found in the release area of mcpp/doc.   pythia.cmd is customarily written so that mcpp can call pythia codes.   pythia.cards is the standard file to set all the optional parameters for Pythia.

(4) One has to stop the B's generated in Pythia from decaying and let QQ decay the B's.   This is set in pythia.cards.   For example, if you want QQ to decay Bd ,   you should set

MDCY(C511,1) = 0     in pythia.cards

(5) Another important file is "user.dec", which control how the B's would decay.   The default decays are set in "$QQ_DECAY_FILE", which is also defined after you setup D0RunII --- that in turn "setup qq" for you.   "user.dec" would overwrite the information in "$QQ_DECAY_FILE".

In order to activate "user.dec", one needs to define the variable "QQ_USER_FILE" such as
      setenv QQ_USER_FILE   ./user.dec   (in csh).

One example of "user.dec" can be found in the release area of mcpp/doc.   For example, to force B0 to decay to pi + pi - , one can have the following in the file "user.dec":

DECAY B0
CHANNEL 0 1.000 PI+ PI-
ENDDECAY

You probably want to look at the file "$QQ_DECAY_FILE" in order to write your own "user.dec" ("$QQ_USER_FILE").

In certain complicated (and probably rare) cases, if you really want to create your own particle in QQ, read these email correspondences.

(6) Succeeding all these steps, you would have a data file in which each event should have one MCKineChunk (from the generator Pythia/QQ).

(B) Select those events which contain the type of B's that you wish to have in your sample.

To select those events with the B flavor that you are interested,

  • you may use MC_exam. Use the executable "MCexam_x" in $BFDIST/releases/$BFCURRENT/bin/$BFARCH and call only 3 packages "ReadEvent", "MC_exam" and "WriteEvent". You need to change the flag "Flavor_Sel_Part" to "250" and/or "Flavor_Sel_Apart" to "-250" in MC_exam.rcp if you want to select Bd and/or Bd_bar for example. In other words,

    Flavor_Sel_Part=250, Flavor_Sel_Apart=0      to select Bd only
    Flavor_Sel_Part=0, Flavor_Sel_Apart=-250     to select Bd_bar only
    Flavor_Sel_Part=250, Flavor_Sel_Apart=-350 to select Bd & Bs_bar

    OR

  • you may also build a package yourself which can read/write and tag the events of your interest as follows:

    To build the binary, one needs to link with at least the following packages:

    ReadEvent
    WriteEvent

    In the WriteEvent RCP file, one may do :

    // Event tagging
    string WriteEventTags = "save"
    string VetoEventTags = "delete"
    
    to provide tagging switches for your source code to tag only the events that have the B flavor of your interest.

    In the source code (in C++), one has to look at the MCKineChunk and loops over all particles in that generator chunk to see whether this is the B particle that you want.

    Note: If you just do what it is said up to now, you will have only one MCKineChunk. But, if you run it through d0gstar (see section C), you may have more than one MCKineChunk. In this case, you have to look for the first MCKineChunk which is the chunk for information from the generator, NOT from d0gstar nor minimum biased event information.

    **In long term, it is not always safe to look at the first MCKineChunk but this is about the only way at the moment.

    For example, to see whether there is Bd_bar (particle code = -250) in an "edm::Event event", one can do the following :

    list< THandle<MCKineChunk> > mcchunks=_mcKey.findAll(event);
    list< THandle<MCKineChunk> >::iterator  kinechunk ;
    int iichunk=0;
    
    myBflavor = -250 ;
    
    for ( kinechunk=mcchunks.begin(); kinechunk != mcchunks.end() ; ++kinechunk ) {
    
      iichunk++;
    
      if ( iichunk == 1 ) {  // To look at the first MCKineChunk from generator, not d0gstar
    
        MCevt* ptevt=(*kinechunk)->ptrMCevt();  //  get pointer to MC event
    
        list listp;
        ptevt->getParticles(listp);   //  get complete list of particles
        list::iterator jj;
    
        int num_B = 0 ;
        for ( jj=listp.begin(); jj != listp.end()  ; ++jj ) {
    
          if ( (*jj)->isaId() == myBflavor ) {
            num_B++ ;
    	// do something ...
          }
        }	
    
        // "save" and "delete" are used in consistent with what it is put in the RCP file above
        if ( num_B > 0 ) {
          event.tag("save") ;
          // do something ...
        }
        else {
          event.tag("delete") ;
          // do something ...
        }
    
      }
    
    }
    

    (C) Run through d0gstar

    Before running through d0gstar (D0 Geant Simulation for Run II), you would have only one MCKineChunk from the generator (such as Pythia). You have to run the data sample with the one MCKineChunk through d0gstar to get the detector response (in various hit chunks) and the second MCKineChunk. If you merge with minimum biased events, you have more MCKineChunk's.
    To run d0gstar,

  • you may use mc_runjob

    OR

  • you may use the package d0gstar_user as follows.

  • Do the usual steps to set up the D0RunII version "pmc02.01" ( or any version certified by the MC group )
  • addpkg d0gstar_user
  • Goto directory d0gstar_user/ex03

  • Edit the file run.test_mckine.csh and change the line with "dspack_input" to point to the input file with the MCKineChunk
  • Take a look at framework.rcp and see what RCP files are used and change them if you want to do things differently.

  • Modify NewEvent.rcp so that it would generate at least enough number of events for you. The simplest thing is probably to change "EventsPerRun" to be bigger than the number of events that you have in your input file.

  • If you want to merge with minimum biased events, look at SimMergeKinePkg.rcp. Set "AverageEvents" to 0.0 if you don't want to mix with minimum biased events.

  • If you want to change vertex position, you may vary the file ttl.mckine and in that file, change the line starting with "BEAM".

  • You may want to change the seed number in seed.rcp.

  • Run "run.test_mckine.csh".   After initial debugging succeeds, you probably should submit your d0gstar job in the batch mode as d0gstar job will take a long time.


  • If you have any questions, corrections or comments, feel free to contact me.



    Kin Yip (Last modified: 6/7/2000)