JeffersonLab / analyzer

HallA C++ Analyzer
BSD 3-Clause "New" or "Revised" License
7 stars 54 forks source link

Bankdat #156

Closed rwmichaels closed 6 years ago

rwmichaels commented 6 years ago

How to use the BankData class.

May 1, 2018 Bob Michaels

In the analysis script you need to add the module.

gHaPhysics->Add( new BankData("BD","bank data for a roc" ));

The module will read the database in the $pwd of the analyzer. (I'd like to put it in $DB_DIR/20180104 or whatever, but I don't understand the rules for how to find that yet.)

Example of a db_BD.dat file:

.# lines starting with # are a comment .# variable crate bank Nskip Nelement

rfadc 20 250

skip5 20 250 5

xarray 20 250 8 10

norf 20 7 0 4

This produces global variables which can be added to the output tree

analyzer [2] gHaVars->Print() Collection name='THaVarList', class='THaVarList', size=23 OBJ: THaVar BD.rfadc Bank Data rfadc OBJ: THaVar BD.skip5 Bank Data skip5 OBJ: THaVar BD.xarray0 Bank Data xarray OBJ: THaVar BD.xarray1 Bank Data xarray OBJ: THaVar BD.xarray2 Bank Data xarray OBJ: THaVar BD.xarray3 Bank Data xarray OBJ: THaVar BD.xarray4 Bank Data xarray OBJ: THaVar BD.xarray5 Bank Data xarray OBJ: THaVar BD.xarray6 Bank Data xarray OBJ: THaVar BD.xarray7 Bank Data xarray OBJ: THaVar BD.xarray8 Bank Data xarray OBJ: THaVar BD.xarray9 Bank Data xarray OBJ: THaVar BD.norf0 Bank Data norf OBJ: THaVar BD.norf1 Bank Data norf OBJ: THaVar BD.norf2 Bank Data norf OBJ: THaVar BD.norf3 Bank Data norf

Notice that rfadc and skip5 are scalars, while xarray and norf expand to vectors.

rfadc is from roc20 bank250, the first word

skip5 is from the same roc and bank, but skip 5 words.

xarray is an array of length 10 (the last parameter), skip the first 8 in roc20 bank250

norf is an array of length 4, skip 0, from roc20 bank8.

This is a first (working) version. Two issues to work on:

  1. Getting database to read from $DB_DIR/YYYYMMDD

  2. The banks are not "self-discovered". There must be at least one module (like an FADC) in the db_cratemap.dat for that roc and that bank, else the bank will not be entered.

rwmichaels commented 6 years ago

So, a "pound" sign causes this software (at github) to turn the line into a bold-face large-font line ? hmmm...

hansenjo commented 6 years ago

Yeah, it's "markdown" formatting. A # indicates a title/header, like "h1." in a Wiki or

in HTML. The fast workaround is to put all code in preformatted blocks. Also, you can "preview" your posts, which I find essential to avoid surprises ...

Ole

hansenjo commented 6 years ago

I note that the database format does not follow the key/value format introduced in analyzer 1.6. One could define keys like BD.rfadc = 20 250, where "rfadc" is the variable name and the numbers following are the parameters (crate, bank, etc.), but unfortunately the current database system requires key names to be fully known in advance, which wouldn't be the case here. We need to add support for requesting keys via wildcard: BD.*. A vector or map would be returned, which user code could then parse.