CERN Tutorial, September 2010 3 Job Options and Printing.

Slides:



Advertisements
Similar presentations
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Advertisements

Tutorial 12: Enhancing Excel with Visual Basic for Applications
Gaudi Framework Tutorial, April Accessing Event Data.
Job Options file (HelloWorldOptions.py) Application Configuration options # Full job is a list of algorithms from AthenaCommon.AlgSequence import AlgSequence.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
1 Lab Session-VI CS121 Fall 2000 l HW#2 Assigned l Multiple Choice Selectors l The While Loop l Switch-Case-Break Exercise l The Counter Controlled Loops.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Review of C++ Programming Part II Sheng-Fang Huang.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CIS Computer Programming Logic
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
The Java Programming Language
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
GNU Compiler Collection (GCC) and GNU C compiler (gcc) tools used to compile programs in Linux.
Using Client-Side Scripts to Enhance Web Applications 1.
Job Options and Printing 1 LHCb software tutorial - September 2011.
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
Bookkeeping Tutorial. Bookkeeping & Monitoring Tutorial2 Bookkeeping content  Contains records of all “jobs” and all “files” that are created by production.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++
Week 1 Algorithmization and Programming Languages.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Looping and Counting Lecture 3 Hartmut Kaiser
Use of Gaudi in Reconstruction Weidong Li 23/06/2004.
Gaudi Framework Tutorial, April Algorithm Tools: what they are, how to write them, how to use them.
Dual-use prototype for analysis tools David Adams BNL October 16, 2013 ASG tools working group.
Gaudi Framework Tutorial, April Job Options and Printing.
C++ Programming Part 2 Michael Griffiths Corporate Information and Computing Services The University of Sheffield
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6: Transition to Java Programming with Alice and Java First Edition.
Practice Building Classes Modeling Objects. Problem Write a program that computes the Dean’s List (full-time students whose GPA 3.0), using a student.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Bookkeeping Tutorial. 2 Bookkeeping content  Contains records of all “jobs” and all “files” that are produced by production jobs  Job:  In fact technically.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
Bologna Tutorial, April Job Options and Printing.
Tutorial: Examples (09may00 - ATLAS Software LBNL) May 2000 Prototype Framework Tutorial: Examples Paolo Calafiura, Charles Leggett HCG/NERSC/LBNL.
IS2802 Introduction to Multimedia Applications for Business Lecture 4: JavaScript, Loops, and Conditional Statements Rob Gleasure
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
DaVinciAssociators How to relate physics objects to MC truth.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Proposal for extension of GaudiAlgorithm and GaudiTool classes Vanya Belyaev CERN & ITEP/Moscow.
Gaudi Framework Tutorial, Algorithm Tools: what they are and how to use them.
1 A more complex example Write a program that sums a sequence of integers and displays the result. Assume that the first integer read specifies the number.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Athena StoreGate Tutorial: May 30, Objectives Learn how to access data objects using StoreGate How to record/retrieve by TYPE Optionally using keys.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Gaudi Framework Tutorial, April Histograms And N-tuples.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 4th Edition.
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
C++ Lesson 1.
“Algorithm Tools” what they are, how to get them and how to use them
3 Introduction to Classes and Objects.
Writing Physics Tools Schedule: Timing Topic 20 minutes Lecture
C++ in 90 minutes.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Chapter 3: Input/Output
Programs and Classes A program is made up from classes
Lecture 5: Functions and Parameters
2 Getting Started.
2 Getting Started.
2 Getting Started.
Subject:Object oriented programming
References Revisted (Ch 5)
Accessing Event Data Schedule: Timing Topic 20 minutes Lecture
Presentation transcript:

CERN Tutorial, September Job Options and Printing

3-2 CERN Tutorial, September 2010 Job Options All applications run the same main program (gaudirun.py) All applications run the same main program (gaudirun.py) Job options define personality of the job: Job options define personality of the job: – What to run – In what order – With what data – With which cuts All applications run the same main program (gaudirun.py) All applications run the same main program (gaudirun.py) Job options define personality of the job: Job options define personality of the job: – What to run – In what order – With what data – With which cuts

3-3 CERN Tutorial, September 2010 Job Options: Data Types Primitives –bool, char, short, int, (long, long long), float, double, std::string –And unsigned char, short, int, (long, long long) Vectors of primitives –std::vector, std::vector... Pairs, Maps –e.g. std::pair, std::map Primitives –bool, char, short, int, (long, long long), float, double, std::string –And unsigned char, short, int, (long, long long) Vectors of primitives –std::vector, std::vector... Pairs, Maps –e.g. std::pair, std::map The full list of possible types is documented at:

3-4 CERN Tutorial, September 2010 Declare the property in the Constructor, and initialize it with a default value MyFirstAlgorithm::MyFirstAlgorithm( ) { declareProperty( Declare the property in the Constructor, and initialize it with a default value MyFirstAlgorithm::MyFirstAlgorithm( ) { declareProperty( “MassWindow", m_jPsiMassWin = 0.5*Gaudi::Units::GeV, “The J/Psi mass window cut” ); } Aside: all member data must always be initialised in constructor Declare the property in the Constructor, and initialize it with a default value MyFirstAlgorithm::MyFirstAlgorithm( ) { declareProperty( Declare the property in the Constructor, and initialize it with a default value MyFirstAlgorithm::MyFirstAlgorithm( ) { declareProperty( “MassWindow", m_jPsiMassWin = 0.5*Gaudi::Units::GeV, “The J/Psi mass window cut” ); } Aside: all member data must always be initialised in constructor Declare property variable as data member class MyFirstAlgorithm : public GaudiAlgorithm { private: double m_jPsiMassWin; ///< J/Psi mass window cut... }; Using Job Options LHCb convention for member data Variable, initialized to default value Documentation string, useful from Python Property name, used in job options file Comment for doxygen documentation

3-5 CERN Tutorial, September 2010 Set options in job options file – File path(s) given as argument(s) of executable gaudirun.py../options/myJob.py [also.opts] gaudirun.py../options/myJob.py [also.opts] – Python syntax –Type checking –Expressions, if-then-else, loops etc. –Early Validation of configuration – Example MyFirstAlgorithm(“Alg1”).MassWindow = 10.* GeV MyFirstAlgorithm(“Alg2”).MassWindow = 500. # Default is MeV Class(“ObjectName”).PropertyName = PropertyValue Set options in job options file – File path(s) given as argument(s) of executable gaudirun.py../options/myJob.py [also.opts] gaudirun.py../options/myJob.py [also.opts] – Python syntax –Type checking –Expressions, if-then-else, loops etc. –Early Validation of configuration – Example MyFirstAlgorithm(“Alg1”).MassWindow = 10.* GeV MyFirstAlgorithm(“Alg2”).MassWindow = 500. # Default is MeV Class(“ObjectName”).PropertyName = PropertyValue Setting Job Options

3-6 CERN Tutorial, September 2010 Distinguish job options that organise sequencing of algorithms in LHCb applications: From options that change the behaviour of algorithms and tools: Distinguish job options that organise sequencing of algorithms in LHCb applications: From options that change the behaviour of algorithms and tools: MCITDepCreator = MCSTDepositCreator(“MCITDepCreator“) ApplicationMgr().TopAlg += [ MCITDepCreator ] Types of job options MCITDepCreator.tofVector = [25.9, 28.3, 30.5] TheITTool = STSignalToNoiseTool( “STSignalToNoiseToolIT” ) TheITTool.conversionToADC = ; MCITDepCreator.tofVector = [25.9, 28.3, 30.5] TheITTool = STSignalToNoiseTool( “STSignalToNoiseToolIT” ) TheITTool.conversionToADC = ;

3-7 CERN Tutorial, September 2010 Job options that organize the sequencing of algorithms are released with the application –These are usually set inside “ConfigurableUser” classes (e.g. Brunel(), DaVinci()). See Configurables tutorial Options that change the behaviour of algorithms and tools should be initialized to sensible defaults in the.cpp –If needed, any options different from the defaults (e.g. if there are several instances of the same algorithm with different tunings) are taken from files stored in the corresponding component packages Job options that organize the sequencing of algorithms are released with the application –These are usually set inside “ConfigurableUser” classes (e.g. Brunel(), DaVinci()). See Configurables tutorial Options that change the behaviour of algorithms and tools should be initialized to sensible defaults in the.cpp –If needed, any options different from the defaults (e.g. if there are several instances of the same algorithm with different tunings) are taken from files stored in the corresponding component packages LHCb conventions for job options.opts files can be included (“imported”) into python options importOptions("$STALGORITHMSROOT/options/itDigi.opts“)

3-8 CERN Tutorial, September 2010 ApplicationMgr().EvtMax Job Options You Must Know Maximal number of events to execute (if -1 all events in input files) Maximal number of events to execute (if -1 all events in input files) Top level algorithms to run: Type(“Name”) e.g.: [ MyFirstAlgorithm(“Alg1”), MyFirstAlgorithm(“Alg2”)] Also defines the execution order Top level algorithms to run: Type(“Name”) e.g.: [ MyFirstAlgorithm(“Alg1”), MyFirstAlgorithm(“Alg2”)] Also defines the execution order ApplicationMgr().TopAlg

3-9 CERN Tutorial, September 2010 Printing Why not use std::cout, std::cerr,... ? Yes, it prints, but – Do you always want to print to the log file? – How can you connect std::cout to the message window of an event display? – How can you add a timestamp to the messages? – You may want to switch on/off printing at several levels just for one given algorithm, service etc. Why not use std::cout, std::cerr,... ? Yes, it prints, but – Do you always want to print to the log file? – How can you connect std::cout to the message window of an event display? – How can you add a timestamp to the messages? – You may want to switch on/off printing at several levels just for one given algorithm, service etc.

3-10 CERN Tutorial, September 2010 Printing - MsgStream Using the MsgStream class Using the MsgStream class Usable like std::cout Allows for different levels of printing –MSG::VERBOSE(=1) –MSG::DEBUG(=2) –MSG::INFO(=3) –MSG::WARNING(=4) –MSG::ERROR(=5) –MSG::FATAL(=6) –MSG::ALWAYS(=7) Record oriented Allows to define severity level per object instance Using the MsgStream class Using the MsgStream class Usable like std::cout Allows for different levels of printing –MSG::VERBOSE(=1) –MSG::DEBUG(=2) –MSG::INFO(=3) –MSG::WARNING(=4) –MSG::ERROR(=5) –MSG::FATAL(=6) –MSG::ALWAYS(=7) Record oriented Allows to define severity level per object instance

3-11 CERN Tutorial, September 2010 MsgStream - Usage Print error and return bad status return Error("Cannot retrieve particle properties"); Print error and return bad status return Error("Cannot retrieve particle properties"); Set printlevel in job options MessageSvc().OutputLevel = ERROR MySvc().OutputLevel = WARNING MyAlgorithm().OutputLevel = INFO Set printlevel in job options MessageSvc().OutputLevel = ERROR MySvc().OutputLevel = WARNING MyAlgorithm().OutputLevel = INFO Send to predefined message stream info() << "PDG particle ID of " << m_partName << " is " << m_partID << endmsg; err() << "Cannot retrieve properties for particle " << m_partName << endmsg; Send to predefined message stream info() << "PDG particle ID of " << m_partName << " is " << m_partID << endmsg; err() << "Cannot retrieve properties for particle " << m_partName << endmsg; Formatting with format( “string”, vars ) debug() << format("E: %8.3f GeV", energy ) << endmsg; Print everything of INFO level or higher

3-12 CERN Tutorial, September 2010 Units We use Geant4/CLHEP system of units –mm, MeV, ns are defined to have value 1. –All other units defined relative to this –In header file “GaudiKernel/SystemOfUnits.h” –In namespace Gaudi::Units Multiply by units to set value: Divide by units to print value: Units can be used also in job options: We use Geant4/CLHEP system of units –mm, MeV, ns are defined to have value 1. –All other units defined relative to this –In header file “GaudiKernel/SystemOfUnits.h” –In namespace Gaudi::Units Multiply by units to set value: Divide by units to print value: Units can be used also in job options: double m_jPsiMassWin = 0.5 * Gaudi::Units::GeV; import GaudiKernel.SystemOfUnits as Units SomeAlgorithm().MassWindow = 0.3 * Units.GeV import GaudiKernel.SystemOfUnits as Units SomeAlgorithm().MassWindow = 0.3 * Units.GeV info() << “Mass window: ” << m_jPsiMassWin / Gaudi::Units::MeV << “ MeV” << endmsg; info() << “Mass window: ” << m_jPsiMassWin / Gaudi::Units::MeV << “ MeV” << endmsg;

3-13 CERN Tutorial, September 2010 StatusCode Object returned by many methodsObject returned by many methods –Including GaudiAlgorithm::initialize(), GaudiAlgorithm::execute(), etc. Currently, takes two values: –StatusCode::SUCCESS –StatusCode::FAILURE Should always be tested –If function returns StatusCode, there must be a reason –Report failures: StatusCode sc = someFunctionCall(); if ( sc.isFailure() ) { Warning(“there is a problem”,sc,0).ignore(); } If IAlgorithm methods return StatusCode::FAILURE, processing stops Object returned by many methodsObject returned by many methods –Including GaudiAlgorithm::initialize(), GaudiAlgorithm::execute(), etc. Currently, takes two values: –StatusCode::SUCCESS –StatusCode::FAILURE Should always be tested –If function returns StatusCode, there must be a reason –Report failures: StatusCode sc = someFunctionCall(); if ( sc.isFailure() ) { Warning(“there is a problem”,sc,0).ignore(); } If IAlgorithm methods return StatusCode::FAILURE, processing stops

3-14 CERN Tutorial, September 2010 Exercise Now read the web page attached to this lesson in the agenda and work through the exercise