README.md 8.33 KB
Newer Older
1
2
# Deadline for next release

3
Deadline for contributions to DecFiles v30r12 is Friday 23rd February 2018 at 14:00. Merge requests created after deadline are not guaranteed to be accepted for this release.
4
5
6
7
8
9
10
11
12
13

# Steps to add decay file
1. Find if a DecFile you want (or similar enough so you can use it) already exists
1. Read the [event type numbering convention](https://cds.cern.ch/record/855452?ln=en) or check out [the (unofficial) event type finder](http://eventtype.boosted.science/).
1. If you are using an old DecFile as a template, note that it might not follow the established conventions.
1. Test your DecFile (both that it runs and that it produces output you want)
1. After you've modified the release notes in the doc folder of the package commit to branch and create merge request against master.
1. Day or two after commit check in [nightlies](https://lhcb-nightlies.cern.ch/nightly/summary/) slot lhcb-decfilestests that
  1. there are no warning or errors from your decay file at build stage
  1. your file passes test. Look for positive evidence as that will also allow you to check that file was really committed.
14
  1. If anything fails, please correct and recheck again day after commit. If you do not understand failure, get in touch with [lhcb-gauss-manager@cernNOSPAMPLEASE.ch](mailto://lhcb-gauss-manager@cernNOSPAMPLEASE.ch)
15
16
17
1. Email the lhcb-gauss-manager mailing list with a link to your DecFile after you placed it in a publicly accessible location on the AFS (eg. ~/public). They will also check and have the last word on the event type ID (some some special cases or newer rules may not be covered in 2). (We are going to update this step eventually, but for now it is helpful if we do not have to checkout your branch locally).

# Testing a decay file
18
19
 This is done in three steps:
## Write the decay file and create the options
Michal Kreps's avatar
Michal Kreps committed
20
If you do not already have the environment set up, prepare it to run one of the latest Gauss version (v49rX for Sim09 productions, or v50rX for upgrade productions). In the examples below, v49r9 is used.
21
```shell
Michal Kreps's avatar
Michal Kreps committed
22
23
24
SetupProject Gauss v49r9 --build-env
cd ~/cmtuser/Gauss_v49r9
SetupProject Gauss v49r9
25
26
27
28
29
30
31
```
Then get the Gen/DecFiles package from gitlab.
```shell
git lb-clone-pkg  Gen/DecFiles 
```
Add the new decay file in the dkfiles subdirectory and create the options to be used by Gauss.
```shell
Michal Kreps's avatar
Michal Kreps committed
32
cd ~/cmtuser/Gauss_v49r9/Gen/DecFiles/
33
34
35
36
make
```
If there is no mistake in the decay file, an option file called NNNNNNNN.py is present in the options subdirectory, where NNNNNNNN is the event type number of the decay file.  It is also recommended to run the decay file convention parser
```shell
Michal Kreps's avatar
Michal Kreps committed
37
cd ~/cmtuser/Gauss_v49r9/Gen/DecFiles/cmt
38
39
40
41
42
43
./decparser.sh ../dkfiles/DecFile.dec
```
This should check for convention correctness for the event type and some basic mistakes, but it also has some limitations. This is our tool to help in checking, but at the end all failures are individually considered. Feel free to email any comments to lhcb-gauss-manager.  
## Run Gauss to create a .xgen file 
The .xgen file contains the generator level information (both in HepMC and MCParticles format) when running Gauss with only the generator part, without the simulation and Geant4 being activated.
```shell
Michal Kreps's avatar
Michal Kreps committed
44
45
SetupProject Gauss v49r9
cd ~/cmtuser/Gauss_v49r9
46
47
gaudirun.py $GAUSSOPTS/Gauss-Job.py $GAUSSOPTS/Gauss-2016.py $GAUSSOPTS/GenStandAlone.py \
            $DECFILESROOT/options/NNNNNNNN.py $LBPYTHIA8ROOT/options/Pythia8.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
```
The number of events to generate (5 by default) is set in the Gauss-Job.py file.  Gauss will then produce a file called by default Gauss-NNNNNNNN-5ev-YYYYMMDD.xgen, with a name formed from the event type (NNNNNNNN), the number of events (5ev by default) and the day (in format YYYYMMDD).  
## Create a MCDecayTreeTuple from the .xgen file
Use DaVinci to read the file produced by Gauss and to create a ROOT file with the information from the generator level history.
```shell
SetupProject DaVinci
gaudirun.py tupleResult.py
```
where tupleResult.py contains
```python
from Configurables import (
    DaVinci,
    EventSelector,
    PrintMCTree,
    MCDecayTreeTuple
)
from DecayTreeTuple.Configuration import *

"""Configure the variables below with:
decay: Decay you want to inspect, using 'newer' LoKi decay descriptor syntax,
decay_heads: Particles you'd like to see the decay tree of,
datafile: Where the file created by the Gauss generation phase is, and
year: What year the MC is simulating.
"""

# https://twiki.cern.ch/twiki/bin/view/LHCb/FAQ/LoKiNewDecayFinders
decay = "[B0 => ^(Lambda_c~- ==> ^p~- ^K+ ^pi-) ^p+ ^pi- ^pi+]CC"
decay_heads = ["B0", "B~0"]
datafile = "Gauss-11166070-5ev-20140429.xgen"
year = 2012

# For a quick and dirty check, you don't need to edit anything below here.
##########################################################################

# Create an MC DTT containing any candidates matching the decay descriptor
mctuple = MCDecayTreeTuple("MCDecayTreeTuple")
mctuple.Decay = decay
mctuple.ToolList = [
    "MCTupleToolHierarchy",
    "LoKi::Hybrid::MCTupleTool/LoKi_Photos"
]
# Add a 'number of photons' branch
mctuple.addTupleTool("MCTupleToolKinematic").Verbose = True
mctuple.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_Photos").Variables = {
    "nPhotos": "MCNINTREE(('gamma' == MCABSID))"
}

# Print the decay tree for any particle in decay_heads
printMC = PrintMCTree()
printMC.ParticleNames = decay_heads

# Name of the .xgen file produced by Gauss
EventSelector().Input = ["DATAFILE='{0}' TYP='POOL_ROOTTREE'
Opt='READ'".format(datafile)]

# Configure DaVinci
DaVinci().TupleFile = "DVntuple.root"
DaVinci().Simulation = True
DaVinci().Lumi = False
DaVinci().DataType = str(year)
DaVinci().UserAlgorithms = [printMC, mctuple]
```
If you get the error
```
ToolSvc.OdinTim...  FATAL ODINDecodeTool:: Exception throw: Cannot find RawEvent in [Trigger/RawEvent, DAQ/RawEvent] StatusCode=FAILURE
```
try adding this to your file (copied from https://gitlab.cern.ch/lhcb/Bender/blob/master/Phys/BenderTools/python/BenderTools/GenFiles.py):
```python
def doIt():
    """
    specific post-config action for (x)GEN-files 
    """
    extension = "xgen"
    ext = extension.upper()

    from Configurables import DataOnDemandSvc
    dod  = DataOnDemandSvc ()
    from copy import deepcopy 
    algs = deepcopy ( dod.AlgMap ) 
    bad  = set() 
    for key in algs :
        if     0 <= key.find ( 'Rec'     )                  : bad.add ( key )
        elif   0 <= key.find ( 'Raw'     )                  : bad.add ( key )
        elif   0 <= key.find ( 'DAQ'     )                  : bad.add ( key )
        elif   0 <= key.find ( 'Trigger' )                  : bad.add ( key )
        elif   0 <= key.find ( 'Phys'    )                  : bad.add ( key )
        elif   0 <= key.find ( 'Prev/'   )                  : bad.add ( key )
        elif   0 <= key.find ( 'Next/'   )                  : bad.add ( key )
        elif   0 <= key.find ( '/MC/'    ) and 'GEN' == ext : bad.add ( key )
        
    for b in bad :
        del algs[b]
            
    dod.AlgMap = algs
    
    from Configurables import EventClockSvc, CondDB 
    EventClockSvc ( EventTimeDecoder = "FakeEventTime" )
    CondDB  ( IgnoreHeartBeat = True )
    
appendPostConfigAction( doIt )
```
149

150
151
152
153
154
155
156
157
158
159
160
161
# Efficiency of generator level cuts
This number can be extracted from the GeneratorLog.xml file (produced by your gauss job), where the printout is of the form
```xml
<efficiency name = "generator level cut">
    <after> 5 </after>
    <before> 27 </before>
    <value> 0.18519 </value>
    <error> 0.074757 </error>
  </efficiency>
```
the efficiency is therefore 5/27 in this example.

162
163

# Commiting a decay file
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Pre-requisite: have account on gitlab.cern.ch 
You must commit your decay file to separate branch and create merge request against master branch. It is recommended that you check out a clean version
```shell
git lb-clone-pkg  Gen/DecFiles
cd Gen/DecFiles
git checkout -b ${USER}/my-changes
```
Copy your decfile(s) into `dkfiles/` and add them to commit
```shell
git add dkfiles/[your decfile]
```
Update doc/release.notes using the same format as previous entries (with event type). Commit everything, push to the gitlab server
```shell
git add doc/release.notes
178
179
git status #(check that release.notes is updated and your decfile is added)
git commit #(with a commit message of what you updated the release notes with)
180
181
182
183
git push -u origin ${USER}/my-changes
```
Go to [gitlab.cern.ch](gitlab.cern.ch) and create merge request.

184