A TGC API 'how to'
Related links
How to query TGC conditions, using TGC API command line interface (CLI)
Goals:
- This 'how to' shows how to use TGC CLI to query conditions from TGC DB.
- Using this technique is being used for debugging TGC conditions:
looking for anomalies in insertion of conditions
and may be used as well in order to check the values of conditions,
looking for anomalies in managed (HW) entities
Notation:
- Commands that may be typed appear as bold Courier New fonts
Setting the environment to use compiled TGC CLI at atlastgc@lxplus, and running an example to read conditions:
1) Run from lxplus
This tutorial refers to querying TGC conditions from lxplus hosts.
Hence, you should have a user at lxplus, to run this tutorial.
Remark:
Querying may also be done from computers at Point 1 or any other personal computer.
The only difference has to do with how to setup the environment.
(TBD: detail how to do this per environment)
ssh into lxplus 32 bit machine, slc4 operating system:
ssh <your lxplus user>@lx32slc4.cern.ch
Example:
2) Be at bash:
If your lxplus user uses a shell other than bash *, type the following :
* In order to know what shell you use, type: echo $SHELL
3) You need file ~/private/authentication.xml, in order to access the DB:
mkdir ~/private
cp ~atlastgc/private/authentication.xml ~/private
4) Setting the environment
Per lxplus user session, one has to setup the environment to use TGC CLI:
(In order for this to happen automatically, per your lxplus user session,
you may add the 'source ...' command to your ~/.bashrc file.)
- In order to use the latest centrally compiled API version at user atlastgc:
source ~atlastgc/setupDAQ.sh
- Alternatively, if you develop TGC API code, you should rather checkout the code from svn, and:
source ~/detectors/muons/TGCRodOperation/scripts/setupDAQ.sh
If the DB is not updated according to the API, and hence the API throws when trying to connect the DB,
one may work around this by setting environment variables that prevent methods from throwing:
To prevent method
M from throwing, set the environment variable called
TGCAPI_NOTHROW_M.
This may be done from the shell level or from the CLI.
Following are typical CLI commands to prevent throwing if the DB is not updated according to the API:
setenv TGCAPI_NOTHROW_tableSchemaIsConsistent
setenv TGCAPI_NOTHROW_getDbVersionIsCompatible
- In order for CLI commands to be done at the beginning of each CLI session,
such CLI commands may be added to ~/.TGCnavigaterc
For example, one may put various setenv CLI commands at ~/.TGCnavigaterc
5) Using TGC API CLI interactively:
To use it interactively:
TGCnavigate
<command>
<command>
...
quit
Example: navigate within a product tree
# Start an interactive CLI session:
TGCnavigate
?
pop a1 dcs # populate sector a01, with products of hierarchy dcs
? naming # get help for command 'naming*'
naming dcslogical # select naming scheme to be dcslogical
static on # show static field values of current product
find a # find a product whose name starts with a
? navigation # show help of all navigation commands
tree on # show parents and descendants of selected product
hist # show commands history
quit
Exercise:
As a small example, try to use the CLI:
use the command 'help',
and look into command-group 'general' (help general),
now, use the command 'trace' or 'system' to find the current time.
(solution at the bottom of the document)
6) Using TGC API in batch mode: TGCnavigate -bc <commands>
Important example: Verify that you may access the DB via TGC CLI, by running the following example command:
TGCnavigate -bc dbopen
The expected response is:
Setting Partition name from variable $TDAQ_PARTITION : part_TGC_noConfig
Setting Connection name to its default: P1_R
7) The 'meat': Using CLI scripts to read conditions
Copy scripts to local directory, in order to:
- be able to edit them
- run from a directory with read/write access
- (the following example runs under ~/public, simply in order to allow access of others, to help you debug)
mkdir -p ~/public/dbCheck
cd ~/public/dbCheck
cp ~atlastgc/dbCheck/threshcond ~atlastgc/dbCheck/hvcond ~atlastgc/dbCheck/hvconf .
- You may edit scripts before running them
- Running script 'hvcond' interactively:
TGCnavigate
#trace on # Print each CLI command before running it (commented out, more relevant for batch mode)
pop A01 # Populate the memory with static data - products - or sector A01
dbopen # Read some data from the DB, needed for future DB queries
subset HVCHANNE # Select products of type HVCHANNEL in current sector (using name completion)
timewindow db last 3 weeks # Define the DB time window: last 3 weeks
readcond actual.vmon # Read conditions of field actual.vmon
readcond actual.imon # The same, for field actual.imon
find hvchan # findfirst product of type hvchan
dynamic on # show dunamic fields of selected product
lastup 1 # Do display last update of condition fields
fieldshist 1 # Do display history of condition fields
timewindow memory last week # Define the memory time window: last week (further restricts the DB time window)
export cond all monitoringHV.txt # Export conditions of all fields to file monitoringHV.txt
- Alternatively, you may run the main commands of the same script in batch mode:
TGCnavigate -bc 'exec hvcond'
- Remarks at CLI script 'hvcond' explain what it does
- according to the command 'export cond all settingsHv.txt' of hvcond, exported values will be written to settingsHv.txt
- Same logic to run threshcond and hvconf.
- To get current conditions, use readcurrentcond insted of readcond, and there is not need for a time window. example:
pop A01
dbopen
subset HVCHANNE
#timewindow db last 3 weeks
readcurrentcond actual.vmon
Summary script:
- You may run the following command, CAREFULLY, from bash, to:
-- Setup the environment according to atlastgc
-- Read example conditions from the DB
-- the log of running this will go to your ~/public/tutorial.log
script -c ~atlastgc/dbCheck/tutorial.sh ~/public/tutorial.log
Planned API enhancements:
- Deeper condition analysis (Expectations of Shikma):
-- Looking for times when value changed frequently
-- Looking for times when the value changed by a big amount (Example: trip may be defined as a value drop from 3000V to 50V)
Exercise solution:
- If you type the CLI command: trace on
each following CLI command is prefixed by the date/time
- The command 'system' ... runs it arguments as a system command(, at a shell),
hence, the following command shows the date/time: system date
How to build an environment using the online and TGCDaq
The TGC online environment has been modified to allow code developping in an hierarchical way
Online > Tgc >
UserCode?
Hence one does not have to compile any code except for that of packages that she is developing code for.
This can be done at:
–Point1,
–Offline machines: lxplus, il01
–(TBD: or at personal machines)
Recipe:
1. Create a <myRepository> directory for your code repository.
An example of <myRepository>" $HOME/detectors/muons
mkdir <myRepository>
cd <myRepository>
mkdir cmt
cd cmt
#Create the file project.cmt with one line: "use muons"
echo "use muons"> project.cmt
2. Modify your .bashrc, adding:
# Setting $USER_REPOSITORY:
# - To checkout the code of a package from svn:
# cd $USER_REPOSITORY
# svn co $SVNROOT/<package>/trunk <package>
# - In case you start from an existing local installation of
TGChwRepresentation?,
# REPOSITORY=$HOME/detectors/muons
export USER_REPOSITORY=<myRepository>
# Select one of the following, depending on where you are running from:
source ~atlastgc/setupDAQ.sh # if at lxplus or il01
source /det/muon/TGC/sw/scripts/setupGlobal.sh # if at P1, alternatives: setupStandAlone.sh, setupDAQ.sh, setupDevelopment.sh ...
3. For each session:
(Enter bash to) run your updated .bashrc
How to manage sector logic configuration
A session to demonstrate configuring of sector logic: enabling, disabling listing and exporting of sector logic SSCs
Seting up the environment:
- online: see 'How to build an environment using the online and TGCDaq'
- offline: see first part (1-5) of 'How to query TGC conditions, using TGC API command line interface (CLI)'
TGCnavigate # Start the TGC API command line interface
Cmd > populate # Fill the memory with the 'products' - the parameters of HW entities
Cmd > find slogboard # Find a sector logic board product
-> SLOGBOARD_C09_F09 (SLOGBOARD Forward)
Cmd > tree 1 # show the fathers of current product at different hierarchies and show its sons
-> SLOGBOARD_C09_F09 (SLOGBOARD Forward)
-3 TWELFTH_C09 [ Trigger ]
-2 SLOGPROCESSOR_C_3 [ SLog ]
-1 SLOGCRATE_C_T2 [ Power ]
1 SECTORTRIGGER_C09_F_PHI01 [ Trigger | SLog | Power ]
2 SECTORTRIGGER_C09_F_PHI23 [ Trigger | SLog | Power ]
Cmd > +1 # navigate within the products tree: Go to first SECTORTRIGGER son
-> SECTORTRIGGER_C09_F_PHI01 (SECTORTRIGGER Forward)
...
10 SSC_C09_F_PHI01_05 [ Trigger | SLog | Power ]
...
Cmd > tree 0 # Do not show tree
Cmd > 10 # Go to a SSC son
-> SSC_C09_F_PHI01_05 (SSC Forward)
Cmd > disable # Disable current SSC (SSC_C09_F_PHI01_05)
# Demonstrate the 3 means to see enabled/disabled fields:
# 1) the dynamic fields
# 2) command: showdisabled
# 3) command: showunusualmask
Cmd > dynamic on # Show changeable fields of current product
opmode_inherited MC 1 Disabled
opmode_intrinsic MC 1 Disabled
Cmd > -1 # Go up one level to the sectortrigger. The mask has one '.' for the disabled SSC:
-> SECTORTRIGGER_C09_F_PHI01 (SECTORTRIGGER Forward)
settings.maskSSC MC 0x000df 7 ++.+++++ 0
Cmd > dynamic off # Do not show dynamic fields
Cmd > ? showdisabled # ? is like help
ShowDisabled yes|no : show disabled products in current set
yes/no limited to intrinsically disabled [Specialized]
Cmd > ShowDisabled? # should show SSC_C09_F_PHI01_05
Only intrinsically disabled [yes | no] ? yes
SSC_C09_F_PHI01_05
Cmd > ?showun
ShowUnusualMask : show products with not standad mask values [Specialized]
Cmd > ShowUnusualMask?
SECTORTRIGGER_C09_F_PHI01 settings.maskSSC 0x000df
# Exporting sector logic configuration as: <address> <value> <field name>
# Exporting the configuration. The enabled/disabled SSCs show at the slogboard level
Cmd > ? slogexport
SLOGExport [file] [lev] Export SLOG commands from objects in the subset
defaults: l=1, file=cout [FEoperations]
Cmd > SLOGExport /tmp/SLOGExport.log
Cmd > sys more /tmp/SLOGExport.log # the command 'sys' run argument system command
# ---- 1 Elx interactions ---
0x09200448 0xdf "settings.maskSSC"
--
DavidFront - 12 Apr 2010
professional resumes