user event generator

  1. test of user event generator (code written by J. Webb)

    create your own generator myGenerator.cxx (based on StarSimpleGenerator.cxx)

  2. include it in generator.h

  3. modify myGenerator with your own use.

    After that, a listing of all generators looks like this :

In my case, I wanted to have :

  1. a hijing AuAu central event
  2. a physics event containing 2 different particles :

  • 5 D0 per event with real pT distribution

  • 5D0bar per event with real pT distribution ; the D0,D0bar should be created at the hijing event vertex position

 

The StarSimpleGenerator has :

  • flat pT range distribution
  • flat phi range distribution
  • flat eta range distribution

 

My modifications/tests are :

  • including a real pT distribution : it is done with the following function :

double myStarSimpleGeneratorUpdated::Fun(Int_t para, Double_t parb,Int_t parc,Int_t min,Int_t max)

  • a PreGenerator() method : it's called in  _star_gener -> PreGeneration(eventCounter); but the declaration is in StarVmcGenerator.h

  • This pregeneration function retrieves, on a event basis, the position of the vertex from the hijing event (values Vx,Vy, and Vz are stored in a txt file)

    For this, I put a eventCounter in vmcGenAction.cxx, which is incremented in void AgUsRead( Int_t *meh )

    modification of the event generator to have a flat rapidity range, instead of a flat pseudorapidity range

  • With the pseudo-rapidity range, eta goes from eta_min to eta_max and px,py and pz are calculated according to the current eta.

    With the rapidity range, y goes from y_min to y_max ; the only change is how pz is calculated from y (not eta)

    bug corrected :

In StarSimpleGenerator, pz was miscalculated from the eta value. It was done like the following :

//Double_t pz = pt * TMath::CosH(eta);
//Double_t p  = pt *( 1.0 + TMath::CosH(eta) );

whereas it should be  :

Double_t pz = pt*TMath::SinH(eta);

Examples (done with the default Generator, with 50000 tracks, eta range is flat)

1. default pz

With the default pz, even the eta distribution is not flat (or it should since it'ssupposed to be the input)

2.  corrected pz

With the correction, eta is flat

Now I'm using the flat rapidity as input

So we see  that now the rapidity is flat (the input) but the pseudorapidity has changed.

one correction was also to add a multiplicator factor (10) in StarHepevtStack.cxx to take into account that Pythia used mm , whereas STAR uses cm (the position of vertex were divided by 10 from my vertex file)

 

### update 07/27 ###

A bug was temporarily fixed, namely the first event trigged hadn't any hits (whatever geometry)

So the idea was to trig with 1 event and then retrig with 50 events.

MACRO runit

exec runUserGenerator.kumac

detp geom y2007g
gexec $STAR_LIB/geometry.so
gclose all

vmcgen/use myStarSimpleGeneratorUpdated
*vmcgen/use StarSimpleGenerator
trig 1

make gstar
gfile o 50events.fz
trig 50
*gprint kine

RETURN

 


Check :

event 2 from the event generator :

AgUsRead is called : jb
do something before the generation of the 2 event
curr event = 2 curr line = 1
curr vertex : vx = -0.0108 vy = 0.011 vz = -0.875
Generate: ntrack=5 pid=421 ptmin=  0.0 ptmax=  5.0 ...
myStarSimpleGeneratorUpdated::Exponential() : vx = -0.0108 vy = 0.011 vz= -0.875 myStarSimpleGeneratorUpdated::Exponential() :  min rap = -1 max rap= 1
D0  i =  pt= 0.390009
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1      421     0     0    -1    -1     0.247     0.302    -0.260     1.923     1.865    -0.108     0.110    -8.750
D0bar i =  pt= 0.390009
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1     -421     0     1    -1    -1    -0.151    -0.360    -0.382     1.943     1.865    -0.108     0.110    -8.750

D0  i =  pt= 0.319134
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
 
StarHepevtStack::PushTrack after : vx = -0.108
   -1  1      421     0     2    -1    -1     0.306     0.090    -0.224     1.905     1.865    -0.108     0.110    -8.750
D0bar i =  pt= 0.319134
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1     -421     0     3    -1    -1    -0.319    -0.012    -0.731     2.028     1.865    -0.108     0.110    -8.750
D0  i =  pt= 0.334001
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1      421     0     4    -1    -1    -0.019    -0.333     0.042     1.895     1.865    -0.108     0.110    -8.750
D0bar i =  pt= 0.334001
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1     -421     0     5    -1    -1     0.178     0.283    -0.514     1.963     1.865    -0.108     0.110    -8.750
D0  i =  pt= 0.700897
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1      421     0     6    -1    -1    -0.308    -0.630     0.515     2.057     1.865    -0.108     0.110    -8.750
D0bar i =  pt= 0.700897
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1     -421     0     7    -1    -1    -0.695     0.094     0.810     2.150     1.865    -0.108     0.110    -8.750
D0  i =  pt= 0.211731
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1      421     0     8    -1    -1     0.175     0.119    -0.616     1.975     1.865    -0.108     0.110    -8.750
D0bar i =  pt= 0.211731
StarHepevtStack::PushTrack : vx = -0.0108 vy = 0.011 vz = -0.875
  StarHepevtStack::PushTrack after : vx = -0.108
   -1  1     -421     0     9    -1    -1    -0.209     0.034    -0.239     1.892     1.865    -0.108     0.110    -8.750

 

the same event scanning the .fz file produced :

=====> Event No. 2
NoTracks in this event = 137
particle id = 37 px = 0.247215 py = 0.301649 pz = -0.260454 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875

particle id = 38 px = -0.150501 py = -0.359801 pz = -0.381992 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875

particle id = 37 px = 0.306273 py = 0.0896834 pz = -0.224411 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 38 px = -0.318893 py = -0.012391 pz = -0.730978 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 37 px = -0.019321 py = -0.333442 pz = 0.0417966 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 38 px = 0.177531 py = 0.282912 pz = -0.513783 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 37 px = -0.307942 py = -0.629626 pz = 0.514838 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 38 px = -0.694533 py = 0.0942345 pz = 0.810411 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 37 px = 0.174958 py = 0.119245 pz = -0.615796 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
particle id = 38 px = -0.209055 py = 0.0335511 pz = -0.238796 tpc hit = 0  ssd hit = 0  svtt hit = 0
VertexX = -0.0108 VertexY = 0.011 VertexZ = -0.875
 

Comments :

  1. first we see that the particle generated in the eventGenerator have the same px,py and pz [which was randomly picked in a power law func.]

  2. they're also generated at the vertex position from the file chosen

  3. we also see that these particles (particle id = 37 [D0] and 38 [Dobar]) has no hits in SSD,TPC and SVT (which is expected because of the decay length of the D0)

 

### update 07/30 ###

there was maybe an issue with the event id since we trig the first event and then start the physics file up to the second event.

So the physics fz file have event id from 2 to 51 but the hijing file from 1 to 50

Then during merging both files the first event could be empty of physics event.

So I checked the event id (I know the vertex position input from 1 to 50) :

  1. the .fz file from the event generator
  2. the .fz file from the event generator+hijing = mix
  3. run the bfc chain and check the event id from the geant.root file

step 1 :

The file is at /star/institutions/ksu/bouchet/eventGenerator/dzero_0.fz and the macro to analyze looks for the vertex and Tracks table from the .fz file :

event is quple[0]  = vertexTable[ij].event_p;

first event :

root.exe [4] EVE->Scan("eve:pvx:pvy:pvz")
************************************************************
*    Row   *       eve *       pvx *       pvy *       pvz *
************************************************************
*        0 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        1 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        2 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        3 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        4 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        5 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        6 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        7 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        8 *         2 * 0.0081000 * -0.014900 * -5.963900 *
*        9 *         2 * 0.0081000 * -0.014900 * -5.963900 *

The vertex positions are listed here : so there is a mismatch between the event id (starting to '2') and the event actually processed

 step 2 : now looking at the mix file :

root.exe [10] EVE->Scan("eve:pvx:pvy:pvz")


************************************************************
*    Row   *       eve *       pvx *       pvy *       pvz *
************************************************************
*        0 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        1 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        2 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        3 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        4 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        5 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        6 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        7 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        8 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        9 *         1 * 0.0081185 * -0.014943 * -5.963869 *

The idea here was to loop over tracks table then over vertex table with some conditions by selecting if the current track is a D0 or d0 bar

 if(trackTable[ii].ge_pid != 37 && trackTable[ii].ge_pid!=38 )continue;
        for(int ij = 0; ij < g2t_vertexTablePointer->GetNRows() ; ij++)
        {
          if(vertexTable[ij].id == trackTable[ii].start_vertex_p)

 So it seems that the mix file starts correctly at event id = 1, which correspond to the first event processed

 

step 3 : look at the geant file after reco.

The macro is essentially the same , except that I don't require D0 or D0bar, hence I'm looking at all tracks

root.exe [2] D0GTree->Scan("eve:pvx:pvy:pvz")
************************************************************
*    Row   *       eve *       pvx *       pvy *       pvz *
************************************************************
*        0 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        1 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        2 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        3 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        4 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        5 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        6 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        7 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        8 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*        9 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       10 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       11 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       12 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       13 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       14 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       15 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       16 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       17 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       18 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       19 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       20 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       21 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       22 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       23 *         1 * 0.0081185 * -0.014943 * -5.963869 *
*       24 *         1 * 0.0081185 * -0.014943 * -5.963869 *

So here again we see that the first event at the good event id

The bfc chain used , from event 1 to 3 , was :

root4star -b -q 'bfc.C('$1','$2',"trs srs ssd fss y2007g Idst IAna l0 tpcI fcf ftpc Tree logger ITTF Sti genvtx SsdIt SvtIt
MakeEvent bbcSim tofsim tags emcY2 EEfs -evout -dstout IdTruth geantout big fzin MiniMcMk clearmem -McEvOut","'$myfile'")'

And finally I run an analysis macro over the MuDst file :

Branch MuEvent activated
NEvent processed = 1 event id = 1 pvx = 0.0068496 pvy = -0.0173773 pvz = -5.96256
 NoTracks = 1852 number of D0 candidates = 191
NEvent processed = 2 event id = 2 pvx = -0.544513 pvy = 0.38543 pvz = 3.32325
 NoTracks = 1448 number of D0 candidates = 0
NEvent processed = 3 event id = 3 pvx = 0.011551 pvy = 0.0101286 pvz = -2.55961
 NoTracks = 2047 number of D0 candidates = 273
 end ..
 event processed so far  = 3
 number of tracks so far = 5347
 number of D0 cand so far = 464

root.exe [3] D0Tree->Scan("EventId:Vz")
************************************
*    Row   *   EventId *        Vz *
************************************
*        0 *         1 * -5.962556 *
*        1 *         2 * 3.3232531 *
*        2 *         3 * -2.559614 *
************************************

So to summarize, eventId and vertex positions are agree .

UPDATE 8/02

some tests :

  1. once a generator is instantiated, we cannot use another event generator, which means in order to use 2 different generators for the same event, one has to use the PrepGeneration() method

UPDATE 8/10

run the analysis code on the MuDst files for the physics file (generated by the event generator) and for the mix (physics + background).

The reco chain used is the following :

root4star -b -q 'bfc.C('$1','$2',"trs srs ssd fss y2007g Idst IAna l0 tpcI fcf ftpc Tree logger ITTF Sti genvtx SsdIt SvtIt MakeEvent bbcSim tofsim tags emcY2 EEfs -evout -dstout IdTruth geantout big fzin MiniMcMk clearmem -McEvOut","'$
myfile'")'

Especially there is the genvtx option that used the reco vertex instead of the MC vertex.

This gives differences :

  1. for the physics file :
Attaching file MuKpiTCFIT.root as _file0...
root4star [1] D0Tree->Scan("Vz")                           
************************
*    Row   *        Vz *
************************
*        0 * -5.973163 *
*        1 * -0.883854 *
*        2 * -2.550966 *
*        3 * 0.3294948 *
*        4 * -0.675636 *
*        5 * 0.9601468 *
*        6 * 2.7006979 *
*        7 * -3.473739 *
*        8 * 3.8745305 *
*        9 * -6.275081 *
*       10 * 5.4228739 *

     2. for the mix file :

Attaching file MuKpiMIXTCFIT.root as _file0...
root4star [1] D0Tree->Scan("Vz")                              
************************
*    Row   *        Vz *
************************
*        0 * -5.962556 *
*        1 * 3.3232531 *
*        2 * -2.559614 *
*        3 * -7.601830 *
*        4 * -5.690090 *
*        5 * -11.70377 *
*        6 * -6.278671 *
*        7 * -5.450999 *
*        8 * -12.90697 *
*        9 * -1.89e-05 *
*       10 * -2.338633 *

We see that the primary vertex position for the physics file matches (when it's within 10cm, otherwise the event is rejected) with the vertex positions from the list

But for the mix files some are matching and other are completely off (event 2 for example)