Processing of simulation data in Bender is rather simple, one just needs to inherit the algorithm from base class AlgoMC, this class can be imported from Bender.MainMC module.
from Bender.MainMC import * # it imports also the whole content of Bender.Main module
class MyAlg(AlgoMC):And the corresponsing wrapper for Selection-framework is BenderMCSelection
- One needs to use
Simulation=Trueflag forDaVinci-configurable
from Configurables import DaVinci
dv = DaVinci ( Simulation = True , ## <--- HERE!
...
TupleFile = 'MCtruth.root' )- It is very important to specify the correct
DDDB/SIMCOND-tags for the simulated data. It is very easy to get efficiencies wrong up to 30% if simulated data a processed with the wrongDDDB/SIMCOND-tags.
from Configurables import DaVinci
dv = DaVinci ( Simulation = True , ##
...
DDDBtag = 'dddb-20130929-1' , ## <--- HERE!
CondDBtag = 'sim-20130522-1-vc-mu100' , ## <--- HERE!
...
TupleFile = 'MCtruth.root' )Correct DDDB/SIMCOND-tags can be retrived in several ways:
- from
bookkeeping-DBfor the given production type {% challenge "Challenge (only for those who knows how to do it)" %} Do you know how to do it? If so make a try to use this way.
- Please use the timer for comparison. {% endchallenge %}
- using the helper Bender scripts
get-dbtagsorget-metainfofor the given file {% challenge "Challenge" %} Try to use these scripts form the command line.
- Start with
get-dbtags -handget-metainfo -hand follow the instructions. {% solution "Solution" %}
{% endchallenge %}
3. using dirac-bookkeeping-decays-path script from LHCbDirac/prod for the given MC eventype:
lb-run -c x86_64-slc6-gcc49-opt LHCbDirac/prod dirac-bookkeeping-decays-path 13104231{% challenge "Challenge" %} Make a try with this command (do not forget to obtain valid Grid proxy).
- Is the output clear enough?
{% solution "Solution" %}
The output is a list of record. Each record consists of
- The path in
bookkeeping-DB DDDB-tagSIMCOND-tag- Number of files
- Number of events
- Unique production ID, that coudl be used to get more detailed information
- The path in
{% endchallenge %}
4. for Ganga/Grid there is a way to combine the function getBKInfo2/getBKInfo to obtain the information on flight from bookkeeping-DB and to propagate this information to Bender using params-argument of the configurefunction. This way is built around (3)
{% discussion "In details,..." %}
template = JobTemplate(
application = prepareBender (
version = 'v31r0' ,
module = my_module ,
use_tmp = True ) ,
...
)
productions = getBKInfo2 ( 13104231 )
for entry in productions :
print 'INFORMATION: %s' % entry
path = entry ['path' ] ## "long path"
dddbtag = entry ['DDDBtag' ]
conddbtag = entry ['CondDBtag']
year = entry ['Year']
j = Job ( template )
j.name = ... ## construct name here
j.inputdata = BKQuery ( path ).getDataset()
j.application.params = { 'DDBtag' : dddbtag , 'CondDBtag' : conddbtag , 'Year' : year }
j.submit() where it is assumed that configure-function is instrumented properly to accept params and to propagate the tags further to DaVinci-configurable. The function getBKInfo2 comes from here:
{% enddiscussion %}
In practice, none of the step described above are really needed, since one can just instruct Bender to obtain the tags directly from the input files. In this recommended scenario, no DDDBtag/CondDBtags to be specified for DaVinci-configurable, but one needs to activate useDBtags=True flag for setData-function:
dv = DaVinci ( Simulation = True ,
...
## DDDBtag = 'dddb-20130929-1' , ## NOT NEEDED
## CondDBtag = 'sim-20130522-1-vc-mu100' , ## NOT NEEDED
...
TupleFile = 'MCtruth.root' )
...
setData ( inputdata , catalogs , castor , useDBtags = True ) ## <--- HERE!This is, probably, the most robust, safe and simultaneously the most convinient way
to treat DDDB/SIMCOND-tags for your application :-)
The price to pay: since internally it relies on the functionality provided by get-dbtags-script,
for processing it could take addtional O(1-2) minutes to open the first input file
and to read DDDB/SIMCOND-tags from it.