Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

org.lcsim

...

Conditions

...

Database

...

Overview

The conditions database is designed to allow a running analysis or reconstruction module to access information about the run "conditions".

...

In

...

our

...

current

...

environment,

...

conditions

...

include

...

the

...

entire

...

detector

...

description.

...

The

...

org.lcsim

...

conditions

...

framework

...

is

...

designed

...

to

...

be

...

very

...

flexible,

...

both

...

in

...

use

...

and

...

in

...

implementation.

...

Our

...

current

...

implementation

...

looks

...

up

...

conditions

...

based

...

on

...

the

...

detector

...

name.

...

Conditions

...

Formats

...

The

...

recommended

...

format

...

for

...

storing

...

conditions

...

information

...

is

...

in

...

a

...

zip

...

file.

...

The

...

conditions

...

database

...

includes

...

facilities

...

for

...

downloading

...

zip

...

files

...

from

...

the

...

web

...

and

...

caching

...

them,

...

so

...

no

...

web

...

connection

...

is

...

required

...

when

...

running

...

analysis

...

or

...

reconstruction

...

jobs,

...

as

...

long

...

as

...

the

...

required

...

conditions

...

have

...

been

...

previously

...

accessed.

...

The

...

conditions

...

themselves

...

are

...

stored

...

as

...

an

...

arbitrary

...

collection

...

of

...

files,

...

either

...

stored

...

in

...

a

...

filesystem

...

or

...

in

...

a

...

zip

...

file.

...

The

...

most

...

common

...

files

...

used

...

are

...

property

...

files

...

(name,

...

value

...

pairs)

...

or

...

XML

...

files

...

(e.g.

...

for

...

geometry).

...

However,

...

there

...

are

...

no

...

constraints

...

as

...

to

...

which

...

file

...

formats

...

can

...

be

...

used

...

for

...

conditions

...

information.

...

Properties

...

Files

...

Properties

...

files

...

contain

...

line-delimited

...

key,

...

value

...

pairs

...

with

...

the

...

'equals'

...

as

...

a

...

'=',

...

':'

...

or

...

'

...

'

...

(space).

...

The

...

file

...

extension

...

should

...

be

...

'.properties'.

...

For

...

instance,

...

any

...

of

...

the

...

following

...

will

...

assign

...

the

...

value

...

'strange'

...

to

...

the

...

key

...

'charm'.

{
No Format
}
charm = strange 
charm: strange
charm  :strange
{noformat}

Multiple

...

strings

...

can

...

also

...

be

...

associated

...

with

...

a

...

single

...

key,

...

as

...

follows.

{
No Format
}
charm    beauty, truth, strange
{noformat}

The

...

value

...

of

...

the

...

key

...

'charm'

...

will

...

be

...

'beauty,

...

truth,

...

strange'.

...

These

...

strings

...

can

...

be

...

read

...

as

...

individual

...

values

...

using

...

the

...

method

...

String.split() .

Accessing Conditions

For the following sections, we will use as an example the SDJan03 detector with corresponding tag of sdjan03 for conditions lookup.

Detector Alias Files

An alias file is a property file named alias.properties that lists the locations of conditions information for a specific detector tag.

It has the following format.

No Format
_ .

h2. Accessing Conditions

For the following sections, we will use as an example the SDJan03 detector with corresponding tag of _sdjan03_ for conditions lookup.

h3. Detector Alias Files

An alias file is a property file named *alias.properties* that lists the locations of conditions information for a specific detector tag.

It has the following format.

{noformat}
[detector_name]: [conditions]
{noformat}

The

...

value

...

of

...

conditions

...

can

...

be

...

one

...

of

...

the

...

following.

...

  1. Zip

...

  1. file

...

  1. on

...

  1. a

...

  1. website.

...

  1. No Format

...

  1. 
    sdjan03: http://www.example.com/path/to/sdjan03.zip
    

...

  1. Local directory.

...

  1. No Format

...

  1. 
    sdjan03: file:/path/to/my/sdjan03/
    

...

  1. Local zip file.
    No Format
    
    sdjan03: file:/path/to/my/sdjan03.zip
    

...

  1. Alias to another detector name.
    No Format
    
    sdjan03_local: sdjan03
    

...

Multiple

...

detector

...

tags

...

can

...

be

...

used

...

used

...

in

...

the

...

same

...

alias.properties

...

file,

...

but

...

each

...

detector

...

tag

...

should

...

eventually

...

resolve

...

to

...

a

...

single

...

location.

...

Recursive

...

Name

...

Translation

...

If

...

the

...

name

...

is

...

not

...

a

...

URL,

...

then

...

it

...

is

...

assumed

...

to

...

be

...

an

...

alias,

...

which

...

is

...

recursively

...

translated.

...

Suppose

...

the

...

following

...

is

...

listed

...

in

...

the

...

alias.properties

...

.

{
No Format
}
a: b
b: c
c: http://www.example.com/d.zip
{noformat}

The

...

final

...

value

...

of

...

a

...

will

...

be

{
No Format
}http://www.example.com/d.zip{noformat}

If

...

the

...

alias

...

translation

...

results

...

in

...

a

...

URL,

...

then

...

the

...

previous

...

algorithm

...

is

...

used

...

to

...

look

...

up

...

the

...

conditions.

...

The

...

value

...

after

...

translation

...

need

...

not

...

be

...

a

...

URL

...

or

...

file.

...

It

...

can

...

be

...

a

...

detector

...

tag.

...

In

...

the

...

following

...

case,

...

the

...

value

...

of

...

a

...

will

...

be

...

d

...

.

{
No Format
}
a: b
b: c
c: d
{noformat}

The *d* name will still need to be resolved using the conditions lookup algorithm.

h3. Alias File Locations

The alias file is stored at one or more of the following locations.
  
# The LCSim work directory in the user home directory.
{noformat}~/.lcsim/{noformat}
# Within the lcsim.jar file at the following path.
{noformat}

The d name will still need to be resolved using the conditions lookup algorithm.

Alias File Locations

The alias file is stored at one or more of the following locations.

  1. The LCSim work directory in the user home directory.
    No Format
    ~/.lcsim/
  2. Within the lcsim.jar file at the following path.
    No Format
    org/lcsim/detector/

...

  1. At a URL on the LCSim website.
    No Format
    http://www.lcsim.org/detectors/

...

Your

...

custom

...

aliases

...

belong

...

at

{
No Format
}~/.lcsim/alias.properties{noformat}

as

...

this

...

is

...

likely

...

the

...

only

...

place

...

to

...

which

...

you'll

...

have

...

write

...

access,

...

and

...

your

...

own

...

aliases

...

should

...

be

...

kept

...

separate

...

from

...

the

...

common

...

ones.

...

Conditions

...

Lookup

...

Conditions

...

information

...

is

...

retrieved

...

as

...

follows.

...

  1. If

...

  1. the

...

  1. value

...

  1. is

...

  1. a

...

  1. URL

...

  1. with

...

  1. a

...

  1. protocol

...

  1. of

...

  1. file:,

...

  1. the

...

  1. local

...

  1. file

...

  1. (zip

...

  1. format)

...

  1. or

...

  1. directory

...

  1. path

...

  1. specified

...

  1. is

...

  1. assumed

...

  1. to

...

  1. contain

...

  1. the

...

  1. conditions.

...

  1. If

...

  1. the

...

  1. name

...

  1. is

...

  1. a

...

  1. zip

...

  1. file

...

  1. at

...

  1. a

...

  1. remote

...

  1. URL,

...

  1. an

...

  1. attempt

...

  1. is

...

  1. made

...

  1. to

...

  1. download

...

  1. the

...

  1. file

...

  1. from

...

  1. that

...

  1. location,

...

  1. unless

...

  1. the

...

  1. zip

...

  1. file

...

  1. is

...

  1. already

...

  1. in

...

  1. the

...

  1. local

...

  1. cache

...

  1. (~/.lcsim/cache).

...

  1. In

...

  1. this

...

  1. case,

...

  1. the

...

  1. local

...

  1. copy

...

  1. is

...

  1. used

...

  1. instead.

...

In

...

the

...

case

...

of

...

an

...

alias,

...

once

...

the

...

final

...

detector

...

name

...

is

...

determined,

...

the

...

algorithm

...

searches

...

for

...

a

...

directory

...

or

...

zip

...

file

...

with

...

the

...

same

...

name

...

in

...

the

...

following

...

"canonical"

...

locations:

...

  1. ~/.lcsim/detectors

...

  1. Within

...

  1. the

...

  1. lcsim.jar

...

  1. file

...

  1. at

...

  1. No Format

...

  1. /org/lcsim/detector/

...

  1. At
    No Format
    http://www.lcsim.org/detectors/

...

The

...

following

...

canonical

...

locations

...

would

...

be

...

scanned

...

for

...

sdjan03

...

conditions.

...

Within

...

the

...

home

...

directory.

{
No Format
}
~/.lcsim/detectors/sdjan03.zip
~/.lcsim/detectors/sdjan03/

In

...

the

...

jar

...

file.

{
No Format
}
/org/lcsim/detector/sdjan03.zip
/org/lcsim/detector/sdjan03/
{noformat}

On

...

the

...

LCSim

...

website.

{
No Format
}
http://www.lcsim.org/detectors/sdjan03.zip
{noformat}

If

...

the

...

lookup

...

process

...

does

...

not

...

result

...

in

...

a

...

valid

...

set

...

of

...

conditions,

...

the

...

program

...

will

...

terminate

...

with

...

an

...

error.

...

(In

...

Java,

...

this

...

is

...

a

...

ConditionsNotFoundException

...

).

...

Java

...

Example

...

Here

...

is

...

an

...

example

...

of

...

accessing

...

conditions

...

of

...

the

...

sdjan03

...

detector

...

from

...

Java

...

code.

...

First,

...

retrieve

...

the

...

default

...

instance

...

of

...

the

...

ConditionsManager.

{
No Format
}
ConditionsManager mgr = ConditionsManager.defaultInstance();
{noformat}

Then

...

look

...

up

...

the

...

conditions.

...

The

...

base

...

location

...

is

...

http://www.lcsim.org/detectors/sdjan03.zip

...

.

{
No Format
}
mgr.setDetector("sdjan03", 0);
{noformat}

Conditions

...

are

...

stored

...

in

...

sets,

...

usually

...

organized

...

by

...

single

...

files

...

or

...

directories.

...

For

...

example,

...

sampling

...

fractions

...

can

...

be

...

found

...

in

...

the

...

SamplingFractions.properties

...

file,

...

which

...

is

...

referred

...

to

...

as

...

SamplingFractions

...

when

...

using

...

the

...

ConditionsManager.

{
No Format
}
ConditionsSet cs = mgr.getConditions("SamplingFractions");
{noformat}

Now,

...

the

...

sampling

...

fractions

...

are

...

available

...

by

...

their

...

keys.

...

This

...

code

...

simply

...

iterates

...

over

...

the

...

keys

...

and

...

prints

...

their

...

keys

...

and

...

values.

{
No Format
}
for ( Object o : cs.keySet() )
{
    System.out.println(o.toString() + "=" + cs.getString(o.toString()) );
}
{noformat}

Most

...

likely,

...

the

...

typed

...

values

...

from

...

the

...

ConditionsSet

...

need

...

to

...

be

...

retrieved

...

in

...

order

...

to

...

do

...

anything

...

useful.

...

Here

...

is

...

an

...

example

...

showing

...

how

...

to

...

convert

...

conditions

...

in

...

a

...

ConditionSet

...

to

...

their

...

typed

...

values,

...

one-by-one.

{
No Format
}
for ( Object o : cs.keySet() )
{
    String k = (String) o;

    Class typ = cs.getType(k);

    if ( typ == double.class )
    {
        double dblVal = cs.getDouble(k);
    }
    else if ( typ == int.class )
    {
        int intVal = cs.getInt(k);
    }
    else if ( typ == java.lang.String.class )
    {
        String strVal = cs.getString(k);
    } 
}
{noformat}

Presumably,

...

an

...

algorithm

...

will

...

do

...

something

...

with

...

the

...

value

...

once

...

it

...

is

...

retrieved.

...