# Presentation: 658352

## Level 2 Trigger Software Interface

**R. Moore,**
**Michigan State University**

- R. Moore

- 9/12/99

## L2 Crate

**L2 Crate**

**Data Input**

**Data Output**

**Trigger Control Computer**

**External**
**Communications**

**Internal**
**Communications**

- R. Moore

- 9/12/99

## Software Components

**Software Components**

**Administrator**

**MBus**

**Worker Level**
**User code**

**Tool Level**
**User code**

**L2 Software Framework**

**Physics!**

- R. Moore

- 9/12/99

## L2 Simulator

**Packed**
**Data**

**Raw**
**Chunk**

**Unpack**
**Data**
**Chunk**

_**Online**_

_**Offline**_

**(testing only)**

- dynamic_cast<>

**I/Ogen**

**I/Ogen**

- R. Moore

- 9/12/99

## L2 Simulator

**L2 simulator runs online worker code **_***only***_
**framework code ****(administrator)**** not included because it has no physics impact**
**Online L2 framework replaced by offline code:**
**control hooks replaced by offline framework package**
**data interface replaced to use unpacked data chunks**

- R. Moore

- 9/12/99

## Writing L2 Code

- What you need to know:
- L2 coding guidelines(http://d0lxmsu1.fnal.gov/L2/L2CodingGuidelines.pdf)
- How to use DOC++
- How to use the offline build environment
- CTBuild user guide hopefully appearing soon...?
- Input and output object formats
- tell Dylan and he’ll add them to the L2 I/Ogen configuration file
- Worker algorithm
- What you don’t need to know!
- Unpacked data chunks
- Whether you are running online or offline

- R. Moore

- 9/12/99

## Creating a Worker

- Create a new package for the algorithm code named:
- l2<*worker abbrev*>worker
- e.g. l2gblworker, l2cttworker
- Write the main worker class and put it into this package
- the same class is used online _AND_ offline
- Class name: <*worker*>Worker e.g. GlobalWorker
- Create a new package to interface to trigsim, called:
- tsim_l2<*worker abbrev*>
- e.g. tsim_l2gbl, tsim_l2ctt ...

- R. Moore

- 9/12/99

## Writing the Worker Class

- Worker class is _ONLINE_ code
- ALL L2 workers need one
- Required methods:
- void processEvent(void)
- Plus others to be added later for monitoring, initialization etc.
- MUST obey L2 online coding guidelines: _no STL!_
- processEvent(void)
- processes the current event
- Event I/O handled by offline or online framework

- R. Moore

- 9/12/99

## Offline Interface

- Use L2 specific macros to register with framework
- e.g. tsim_l2gbl.cpp

**#include "framework/Registry.hpp"**
**#include**** ****"l2workersim/FrameworkMacros.hpp"**
**#include "l2gblworker/GlobalWorker.hpp"**
**#include "l2gblworker/GlobalEventIn****put****.hpp"**
**#include "l2gblworker/GlobalEvent****Output****.hpp"**
**#include "l2workersim/WorkerSim.hpp"**
**using namespace l2gblworker;**
**using namespace l2workersim;**
**L2FWK_REGISTRY_IMPL****(****Global,"$Name:  $"****)**

**#include "framework/Registry.hpp"**
**#include "l2workersim/FrameworkMacros.hpp"**
**L2FWK_REGISTRY_DECL****(****Global****)**

- e.g. Regtsim_l2gbl.cpp

- R. Moore

- 9/12/99

## Input Format

**= InputBuffer<Object>**
**= ChunkInputBuffer**
**    ****<Object>**

- Single MBT (or UDC if offline) channel maps to a template class
- Behaves like an array of the given object type
- Inherits from L2Header to allow access to header data

- R. Moore

- 9/12/99

## Output Format

**L3Header**

**L3Trailer**

**Node Header**

- Channel

- Channel

- Channel

- Channel

- Channel

- Module

- _Raw Data_

- _Unpacked Data Chunk_

- R. Moore

- 9/12/99

## High Level Format

- Each worker and administrator has three possible output modules
- Normal L2 output
- Copy of inputs (UBS events)
- Special UBS event data output

- _Raw Data_

- _Unpacked Data Chunk_

**Crate****	****	****	****=****	****System**
**L3 Output**
**UBS Inputs****	****=****	****Module**
**UBS Output**

- R. Moore

- 9/12/99

## Building the Output

- Output created by ‘ChannelFiller’ templates which each fill one channel
- Template parameters:
- Object type stored in channel
- ‘Getter’ class
- ‘Getter’ class fetches the data from the worker code:
- _bool gotData()_ returns true if there is more data to get
- _<Object> &nextObject()_ returns the next object
- _void newEvent()_ notifies class of a new event
- Some standard ‘Getters’ provided

- R. Moore

- 9/12/99

## Event I/O

- Classes to access data created by _evigen_ python script
- <*worker*>EventInput
- <*worker*>EventOutput
- Configuration file similar to Windows .ini files
- Full documentation being worked on...

- R. Moore

- 9/12/99

## Example.evi

**[Worker]**
**package**** = ****l2gblworker**
**name****    = ****Global**
**system****  = ****GBL_L2**
**stdout****  = ****GBL_STD_OUTPUT**
**ubsout****  = ****GBL_UBS_OUTPUT**
**ubsin****   = ****GBL_UBS_INPUTS**
**[Input0]**
**name****    = ****pTTrack**
**object****  = ****CTTPTTrack**
**type****    = ****unpacked**
**limit****   = ****50**
**system **** = ****CTT_L2**
**module **** = ****CTT_STD_OUTPUT**
**channel**** = ****GBL_PTTRACK**
**comment**** = ****pT tracks from CTT**

- R. Moore

- 9/12/99

## Example.evi II

**[StdOutput0]**
**object****   = ****Electron**
**getter****   = ****l2workerbase/Fetch****Tag**
**channel****  = ****GBLOUT_ELECTRON**
**majorver**** = ****0**
**minorver**** = ****1**
**[StdOutput4]**
**object****   = ****Tau**
**getter****   = ****l2workerbase/Fetch****Tag**
**channel****  = ****GBLOUT_TAU**
**majorver**** = ****0**
**minorver**** = ****1**
**[UbsOutput0]**
**object****   = ****Electron**
**getter****   = ****l2workerbase/Fetch****All**
**channel****  = ****GBLOUT_ELECTRON**
**majorver**** = ****0**
**minorver**** = ****1**

- R. Moore

- 9/12/99

## Accessing the Data

- To access the input data inherit the _EventInput_ class

**class ATool :**
**  ****public ****GlobalEventInput**** {**
**...**
**void findElectron(void);**
**...**
**};**
**void ATool::findElectron(void) {**
**if (****pTTrack****.****bunch()**** !=**
**    ****emCluster****.****bunch()****)**
**  ****errlog << “Calling SCL init!”...**
**...**
**  ****dphi=****pTTrack[i]****.****phi()****-****	****	****	****  ****emCluster[j]****.****phi()****;**
**...**
**}**

- R. Moore

- 9/12/99

## Writing the Data

- To use provided “Getter” classes output objects inherit from a “Creator”

- This provides a static method “create()” which returns a pointer to a new class instance
- you cannot use ‘new’ !

**class ****Electron**** :**
**  ****public ****Creator<****Electron****>**** {**
**...**
**};**

**Electron**** *****myelectron**** =**
**  ****Electron****::****create()****;**

- R. Moore

- 9/12/99

## Current Status

- Basic software packages written and docs in progress
- Basic interface stable, only minor changes or additions
- Ready for L2PP’s to start using framework
- BUT still a little rough:
- Need to liase with Dylan/me
- Not everything will work “out of the box” just yet
- Toy “GlobalWorker” written by Dylan
- Can test single Global tools

- R. Moore

- 9/12/99

## Still to do...

- Add interface to L2 low level parser
- L2parser package written and documented
- Can’t use RCP: online code
- Add hook for monitoring data: collectStatus()
- Add support for ‘non-standard’ data formats:
- e.g. CTT has private header
- if L2 input not stored in L3 raw data need to write a package to recreate it
- _BUT_ some L1 packages will use L2 UDC standard (L1Cal)

- R. Moore

- 9/12/99

## Yet more to do...

- Make a L2 release
- Currently all packages in CVS but not in a release
- Understand the build system (CTBuild/SRT/...)
- Need to set compiler options
- e.g. “-DOFFLINE”, “-DDEBUG”
- CTBuild docs promised...

- R. Moore

- 9/12/99

## Conclusion

- The basic L2 framework is complete and ready for use
- should remove a lot of the pain we have had to endure!
- Switching to online is easy... once we have the hardware
- Code written 6+ months ago
- Needs interfacing with low level device drivers
- “Bells and whistles” will be added over the next several months as interfaces are agreed upon
- monitoring
- configuration

- R. Moore

- 9/12/99

## Data I/O

**All L2 I/O done using I/Ogen classes:**
**Python script which generates code to convert between packed memory and C++ class**
**handles multiple format versions in offline**
**centralizes object formats to ensure compatibility**
**interfaces easily to the (new) Unpacked Data Chunks**
**creates routines to print data classes in human-readable form**

- R. Moore

- 9/12/99

## I/Ogen in l2io

**Configuration**
**File**** [l2io.iogen]**

**Python Script**

**IO Classes**

**Data**** ****Classes**

- R. Moore

- 9/12/99