Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

19
Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group

Transcript of Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

Page 1: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

Dual-use prototype for analysis tools

David AdamsBNL

October 16, 2013

ASG tools working group

Page 2: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 2

IntroductionTrying to understand how to structure run 2 analysis tools

• Analysis tools must run in both Athena and Rooto Call these “dual-use”o With minimal code duplication (to ease maintenance)

• Jet/Etmiss expanding definition of analysis toolso Any useful tool that can be run without Athena-specific serviceso Services means geometry, magnetic field, conditions DBo Useful means useful to late-stage analysis, e.g.:

– Jet moment calculators: JVF, jet area, …– Association calculators: calo-track, calo-truth, …– Jet finding, grooming, …

• Expect tool standards to be specified by the ASG tools working groupo Requirements for user interface and tool developers interfaceo Plus supporting software

• Here discuss the current implementation: AsgExo See the AsgEx Twiki for additional information

Page 3: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 3

Tool user requirementsTool interfaces

• Different tools have different interfaces• Expect to switch to object (e.g. Jet) based interface

o Instead of a long list of floats (pT, eta, NPV, …)• Tools intended to read and write event data can have no arguments

o Configured with names of input and output collections

Configuration• Users should have means to configure tools in both Athena and ROOT

o For Athena, integrate with job options (or keep current syntax)• For Root, nice to have a C++ interface• Also like to have a common Python interface for Athena and Root

o Same as current job options? More on this later.• Configuration should support tools using other tools

o So individual tools can be simple and interchangeableo Job options support this with ToolHandle as developer interface

Page 4: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 4

Tool developer requirementsWant to make it easy to develop tools

• Not just by expert programmers• Allow development in either Athena or Root

o With easy port to the other environment• Implies we should establish coding conventions and provide

supporting software to enable the above

Configuration• Common means to access the configuration info discussed earlier

Event data• Common means to read and write collections in current event• Common way to access the objects in those collections: xAOD

Status codes• StatusCode in Root but tools can decide to use or not

Logging messages• Enable Athena-like message service and ATH_MSG_XXX macros

Page 5: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 5

PrototypesJet/Etmiss has been developing dual-use prototypes

• To help determine requirements (previous pages)• To see what is possible

Prototype 1: JetEx• D. Adams talk in September

o https://indico.cern.ch/conferenceDisplay.py?confId=271522• Simple interface with wrappers for Athena• Criticized as too different from Athena

Prototype 2: AsgEx• Latest version of this evolving SW described here• Code in SVN: user-dadams/AsgEx (5 packages)• Interface very similar to Athena

o declareProperty(), evtStore()->retrieve(), ToolHandle, ATH_MSG_XXX ,…• Requires some supporting software

o To give appearance of Athena property and event services in Root

Page 6: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 6

AsgEx Python configuration Provide Python-based job configuration in AsgEx

• As in Athena—try to use Athena syntax• See example code fragment below

o Configures low-level tool JetDumper and theno High-level tool AsgRunner which uses the first tool

• Work in progress (PA) to provide the same syntax in Root

Page 7: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 7

AsgEx statusStatus of the AsgEx prototype

• Both low- and high-level tool examples workingo High-level = tool that uses other configured toolso Same tools (JetDumper, AsgRunner) code run in Athena and Rooto Script-generated wrappers provided to allow configuration and event

access in Root using Athena interfaces• Athena configuration with standard job options (previous page)• Root configuration with setProperty in C++

o Work in progress to add Python wrapper (job options syntax)• Separate interface and implementation classes (as in Athena)

Class diagrams follow• Athena only, AsgEx in Root, AsgEx in Athena• Two example tools: low-level JetDumper, high-level AsgRunner• Legend: White = Athena, Red = ASG support, Green = user-supplied,

Blue = automatically-generated Athena wrappers

Page 8: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 8

Athena only (run 1 model for comparison)

Tool interface

Low-level tool High-level tool

Page 9: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 9

AsgEx Root classes

ASG support, mostly replacements for Athena

ToolHandle typedefs

Classes supplied by the tool developer

Page 10: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 10

AsgEx Athena classesAsgEx general support classes

AsgEx Athena tool classes (generated automatically)

Athena classes

ToolHandle typedefs

Page 11: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 11

Comments on AsgExIntended to be prototype

• Used to identify requirements and aid in design of final system• Propose we use this as the starting point for development

o Assuming the user and developer interface are close to what we wanto Allow development of physics tools to start very soono Modular design makes it easy to substitute pieces (e.g. event store)o If we want to re-implement, we should start ASAP

Event access is based on JetAnalysisEDM• Subset of jet AOD interface to either AOD or D3PD• Need to switch this to xAOD

o When xAOD is availableo Do we need/want access to D3PD or AOD with same interface?

Python-based configuration under development• Likely to extend PropertyMgr, add ToolSvc• Latter might be nice to have in C++ world

Page 12: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 12

Example toolCode follows for an example analysis tool

• Creates fast jet inputs from an input collectiono E.g. from clusters, tracks or truth particles

• Just written yesterday—may have some problems• Illustrates the features of the developer interface• Header and source file on following pages

o Code in AsgEx/AsgExJetReco• This package is not (yet) tested in Athena

Page 13: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013

13

Example tool header 1/2// PseudoJetGetter.h

#ifndef jetreco_PseudoJetGetter#define jetreco_PseudoJetGetter

// David Adams// October 2013//// Tool to fetch pseudo jets.

#include "AsgExTool/AsgTool.h"#include "AsgExToolInterface/IProcessTool.h"#include "fastjet/PseudoJet.hh"#include "JetAnalysisEDM/JetDualUseEDMInclude.h"

namespace jetreco {

class PseudoJetGetter: virtual public asgex::IProcessTool, virtual public asg::AsgTool {

public: typedef std::vector<fastjet::PseudoJet> PseudoJetList;

// Constructor. PseudoJetGetter();

// Append from a collection to a list of PseudoJets. template<typename TList> int append(const TList& inputs, PseudoJetList& psjs) const;

// Append from named collection to a list of PseudoJets. int appendTo(PseudoJetList& psjs) const;

// Append from named input collection to named output collection. int process() const;

// Dump to log. void print() const;

private: //data // Job options. std::string m_incoll; std::string m_outcoll;

Tool must be in a namespace

Inherit both interface and implementation

Ctor takes no arguments.

User interface

Configuration parameters

From IProcessTool

Page 14: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 14

Example tool header 2/2};

} // end namespace jetreco

#ifndef __CINT__

template<typename TList>int jetreco::PseudoJetGetter::append(const TList& inputs, PseudoJetList& psjs) const { for ( typename TList::const_iterator iinp=inputs.begin(); iinp!=inputs.end(); ++iinp ) { const JetAnalysisEDM::Particle* ppar = *iinp; fastjet::PseudoJet psj(ppar->px(), ppar->py(), ppar->pz(), ppar->e()); psjs.push_back(psj); } ATH_MSG_DEBUG("After append, PseudoJet count is " << psjs.size()); return 0;}

#endif // CINT

#endif

Templated method: constructs fastjetPseudoVector’s from particles using four-vector interface

Page 15: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013

Example tool source 1/2// PseudoJetGetter.cxx

#include "AsgExJetReco/PseudoJetGetter.h"using jetreco::PseudoJetGetter;

//**********************************************************************PseudoJetGetter::PseudoJetGetter() { declareProperty("Input", m_incoll); declareProperty("Output", m_outcoll);}

//**********************************************************************int PseudoJetGetter::appendTo(PseudoJetList& psjs) const { ATH_MSG_VERBOSE("Entering appendTo(PseudoJetList)..."); const JetCollection* pjets = 0; StatusCode sc = evtStore()->retrieve(pjets, m_incoll); if ( sc.isFailure() || pjets == 0 ) { ATH_MSG_ERROR("Unable to find input collection: " << m_incoll); return 1; } return append(*pjets, psjs);}

15

Properties declared in ctor

Athena-style message logging

Data retrieved from event store

Athena-style return code

Page 16: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 16

Example tool source 2/2//**********************************************************************int PseudoJetGetter::process() const { ATH_MSG_VERBOSE("Entering process()..."); PseudoJetList* ppsjs; const PseudoJetList* ppsjs_const; ppsjs_const = evtStore()->retrieve<PseudoJetList>(m_outcoll); ppsjs = const_cast<PseudoJetList*>(ppsjs_const); if ( ppsjs == 0 ) { ATH_MSG_VERBOSE("Creating new PseudoJet collection"); ppsjs = new PseudoJetList; evtStore()->record(m_outcoll, ppsjs); } else { ATH_MSG_VERBOSE("Using existing PseudoJet collection"); } return appendTo(*ppsjs);}//**********************************************************************void PseudoJetGetter::print() const { ATH_MSG_INFO(" Input collection: " << m_incoll); ATH_MSG_INFO(" Output collection: " << m_outcoll); ATH_MSG_INFO(" Output level: " << msg_level_name());}

Common tool interface includes print method to show properties

Recording transient data in event store

Page 17: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 17

ConclusionsDual-use tool example (AsgEx) in place

• See the AsgEx Twiki for details• Example tools JetDumper and AsgRunner run in Root and Athena

o Syntax very similar to Athenao No #ifdef or CPP macros in tool developer code

Plans• ASG working group should decide whether to use AsgEx as the basis

for future development or to re-implement• Starting to adding jet reconstruction tools based on AsgEx

o New package AsgEx/AsgExJetReco• Migrate to xAOD

o When xAOD specified (at least for jets and jet inputs: cluster, track, truth)o And data is available in xAOD or means provided to access common D3PD

through xAOD interface• Add Python configuration for Root using Athena job options syntax

Page 18: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 18

ExtrasUpdated run 2 jet analysis use cases

Page 19: Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.

D. Adams, BNL Dual-use tool prototype for run 2 ASG tools working group October 16, 2013 19

Run 2 jet analysis use cases

Tier0 Train Post-train

Athena Athena Athena Root

xAOD xAOD ntuple

Apply jet calibration yes yes yes yes no

Systematic variation of jet calib no no yes yes yes?

(Re)calculate jet moment(s) yes yes yes yes no?

Create new jet coll. for physics yes yes yes yes no

Perf. study varying jet pars no no yes yes no

Tool code development no no yes yes no