lhcb / starterkit-lessons

Lessons taught at the Starterkit workshops.
https://lhcb.github.io/starterkit-lessons/
Other
33 stars 89 forks source link

Simplify LoKi functors lessons #59

Open apuignav opened 6 years ago

apuignav commented 6 years ago

After teaching it, some of the changes #26 have added some material thats is too complicated and doesn't add much to the discussion (the IPCHI2). I think we should roll these back when we update the lesson as mentioned in #58.

vlisovsk commented 6 years ago

Well, the reason why I decided to add the IPCHI2 was that from the physics point of view it's more intuitive than the DIRA shown there. At the same time I agree that in current representation it's way too complicated. Btw, if we use Bender, doesn't it become simpler?

alexpearce commented 6 years ago

The lesson can be made a lot nicer, without losing material, if we use the DaVinciPVTools.Conf module.

>>> from DaVinciPVTools.Conf import P2PVWithIPChi2
>>> print P2PVWithIPChi2()
/***** Public AlgTool GenericParticle2PVRelator<_p2PVWithIPChi2, OfflineDistanceCalculatorName>/GenericParticle2PVRelator<_p2PVWithIPChi2, OfflineDistanceCalculatorName> *****
|-ExtraOutputs           = []  (default: [])
|-StatTableHeader        = ' |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |'
|-AuditReinitialize      = False
|-ErrorsPrint            = True
|-AuditRestart           = False
|-StatEntityList         = []  (default: [])
|-RootInTES              = ''
|-AuditFinalize          = False
|-RegularRowFormat       = ' | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |'
|-UseEfficiencyRowFormat = True
|-ContextService         = 'AlgContextSvc'
|-AuditTools             = False
|-MonitorService         = 'MonitorSvc'
|-AuditInitialize        = False
|-TypePrint              = True
|-OutputLevel            = 0
|-StatPrint              = True
|-ExtraInputs            = []  (default: [])
|-AuditStop              = False
|-Context                = ''
|-PropertiesPrint        = False
|-AuditStart             = False
|-EfficiencyRowFormat    = ' |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%|   -------   |   -------   |'
|-CounterList            = ['.*']  (default: ['.*'])
\----- (End of Public AlgTool GenericParticle2PVRelator<_p2PVWithIPChi2, OfflineDistanceCalculatorName>/GenericParticle2PVRelator<_p2PVWithIPChi2, OfflineDistanceCalculatorName>) -----

So we should be able to change the example to:

from DaVinciPVTools.Conf import P2PVWithIPChi2
pv_finder_tool = P2PVWithIPChi2()
pvs = evt['/Event/Rec/Vertex/Primary']
best_pv = pv_finder_tool.relatedPV(cand, pvs)

I haven't tested it.

apuignav commented 6 years ago

Hi,

@vlisovsk I understand the rationale (and I agree!), but it is "too much magic", especially considering most of the tool loading concepts have not been properly introduced. I would stick with the DIRA or go with @alexpearce's solution, just for the sake of simplicity.

Regarding Bender, a decision was made a long time ago (and I think we still stand by it) to show the basic building blocks, and Bender adds too many "decorations" to be basic, so it doesn't help in the learning process.