Processing of simulated data in Bender
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
Important notes: Simulation=True and DDDB/SIMCOND-tags
- One needs to use
Simulation=Trueflag forDaVinci-configurablefrom 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 typeChallenge (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.
- using the helper Bender scripts
get-dbtagsorget-metainfofor the given fileChallenge
Try to use these scripts form the command line.
- Start with
get-dbtags -handget-metainfo -hand follow the instructions.
Solution
- Start with
- using
dirac-bookkeeping-decays-pathscript fromLHCbDirac/prodfor the given MC eventype:lb-run -c x86_64-slc6-gcc49-opt LHCbDirac/prod dirac-bookkeeping-decays-path 13104231Challenge
Make a try with this command (do not forget to obtain valid Grid proxy).
- Is the output clear enough?
Solution
The output is a list of record. Each record consists of
1. The path in `bookkeeping-DB` 2. `DDDB`-tag 3. `SIMCOND`-tag 4. Number of files 5. Number of events 6. Unique production ID, that coudl be used to get more detailed information - for Ganga/Grid there is a way to combine the function
getBKInfo2/getBKInfoto obtain the information on flight frombookkeeping-DBand to propagate this information to Bender usingparams-argument of theconfigurefunction. This way is built around (3)In details,...Click to expand
Easy, safe and robust alternative :-)
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.