Skip to content

Commit

Permalink
Merge pull request #2 from kreczko/travis-ci
Browse files Browse the repository at this point in the history
Adding continuous integration
  • Loading branch information
kreczko authored Mar 24, 2017
2 parents 61033ae + ee93384 commit 3ee038f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 30 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# travis-ci.org build & test configuration
sudo: required

language: python

services:
- docker

before_install:
- docker pull hepsw/cvmfs-cms

install:
- sudo docker build -t cms-l1t-offline/cms-l1t-analysis -f ci/Dockerfile .

script:
- sudo docker run -t -v $PWD:/analysis --privileged=true cms-l1t-offline/cms-l1t-analysis
cache: apt
1 change: 1 addition & 0 deletions bin/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ unset JAVA_HOME

git submodule init
git submodule update
pip install --user -r requirements.txt

echo "Environment for ${PROJECT_NAME} is ready"
20 changes: 20 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM hepsw/cvmfs-cms

MAINTAINER [email protected]

# mount /cvmfs/grid.cern.ch & /cvmfs/sft.cern.ch
RUN mkdir -p /cvmfs/grid.cern.ch && mkdir -p /cvmfs/sft.cern.ch && \
echo "grid.cern.ch /cvmfs/grid.cern.ch cvmfs defaults 0 0" >> /etc/fstab && \
echo "sft.cern.ch /cvmfs/sft.cern.ch cvmfs defaults 0 0" >> /etc/fstab

RUN yum install -y -q wget git
#RUN yum install -y -q glibc gcc && yum clean all
RUN useradd cmsl1t
RUN mkdir /analysis && chown -R cmsl1t /analysis
WORKDIR /analysis
#USER cmsl1t

# need to execute env.sh and ntp setup in CMD
# as CVMFS needs 'privileged' rights,
# but cannot do that when building the container
CMD ["/bin/bash", "-c", "source bin/env.sh;export PATH=~/.local/bin:$PATH;make test"]
1 change: 0 additions & 1 deletion cmsl1t/collections/efficiency.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class _EfficiencyCurve(object):

def __init__(self, name, bins, threshold):
self._pass = Hist(bins, name=name + '_pass')
#self._efficiency = Graph(name = name + '_efficiency')
self._total = Hist(bins, name=name + '_total')
self._dist = Hist(bins, name=name + '_dist')
self._threshold = threshold
Expand Down
2 changes: 1 addition & 1 deletion cmsl1t/playground/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, tree, indexName):
self._indexName = indexName

def __getitem__(self, index):
if not index in self._cache:
if index not in self._cache:
self._cache[index] = _CachedItem(self._tree, index)
return self._cache[index]

Expand Down
6 changes: 4 additions & 2 deletions cmsl1t/playground/eventreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
from jetfilters import defaultJetFilter
from cmsl1t.playground.cache import CachedIndexedTree
import ROOT
if not 'L1TAnalysisDataformats.so' in ROOT.gSystem.GetLibraries():
from collections import namedtuple

if 'L1TAnalysisDataformats.so' not in ROOT.gSystem.GetLibraries():
ROOT.gSystem.Load('build/L1TAnalysisDataformats.so')
sumTypes = ROOT.l1t.EtSum

# some quick classes
from collections import namedtuple

Sum = namedtuple('Sum', ['et'])
Met = namedtuple('Met', ['et', 'phi'])
Mex = namedtuple('Mex', ['ex'])
Expand Down
1 change: 1 addition & 0 deletions cmsl1t/playground/makeJetResolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

FILES = glob.glob('data/*.root')


def main(n_events, output_folder):
ROOT.PyConfig.IgnoreCommandLineOptions = True
ROOT.gROOT.SetBatch(1)
Expand Down
36 changes: 18 additions & 18 deletions cmsl1t/playground/studyTower28MET.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ def main(nEvents, output_folder):

map(add_met_variable, [
'RecalcL1EmuMet',
# 'RecalcL1EmuMetHF',
# 'RecalcL1EmuMet28Only',
# 'RecalcL1EmuMetNot28',
# 'RecalcL1EmuMetPUS',
# 'RecalcL1EmuMetPUSHF',
# 'RecalcL1EmuMetPUS28',
# 'RecalcL1EmuMetPUSThresh',
# 'RecalcL1EmuMetPUSThreshHF',
# 'RecalcL1Met',
# 'RecalcL1Met28Only',
# 'RecalcL1EmuMetHF',
# 'RecalcL1EmuMet28Only',
# 'RecalcL1EmuMetNot28',
# 'RecalcL1EmuMetPUS',
# 'RecalcL1EmuMetPUSHF',
# 'RecalcL1EmuMetPUS28',
# 'RecalcL1EmuMetPUSThresh',
# 'RecalcL1EmuMetPUSThreshHF',
# 'RecalcL1Met',
# 'RecalcL1Met28Only',
])

reader = EventReader(FILES, events=nEvents)
Expand All @@ -53,16 +53,16 @@ def main(nEvents, output_folder):
l1Sums = event.l1Sums
if 'L1Met' not in l1Sums:
print(l1Sums)
l1Met = l1Sums['L1Met'].et
# l1Met = l1Sums['L1Met'].et

l1Met28Only = rmet.l1Met28Only(event.caloTowers)
metNot28HF = rmet.l1MetNot28HF(event.caloTowers)
metNot28 = rmet.l1MetNot28(event.caloTowers)
# l1Met28Only = rmet.l1Met28Only(event.caloTowers)
# metNot28HF = rmet.l1MetNot28HF(event.caloTowers)
# metNot28 = rmet.l1MetNot28(event.caloTowers)

l1EmuMet = l1Sums['L1EmuMet'].et
l1EmuMetHF = l1Sums['L1EmuMetHF'].et
l1EmuMet28Only = rmet.l1Met28Only(event.emuCaloTowers)
l1EmuMetNot28 = rmet.l1MetNot28(event.emuCaloTowers)
# l1EmuMetHF = l1Sums['L1EmuMetHF'].et
# l1EmuMet28Only = rmet.l1Met28Only(event.emuCaloTowers)
# l1EmuMetNot28 = rmet.l1MetNot28(event.emuCaloTowers)

histograms.fill('RecalcL1EmuMet', caloMetBE, l1EmuMet)

Expand All @@ -85,7 +85,7 @@ def main(nEvents, output_folder):
for name in objects:
if 'pickle' in name:
continue
obj = f.get(name)
# obj = f.get(name)
# plot(obj, name, output_folder)
print('Processed', entry + 1, 'events')

Expand Down
12 changes: 4 additions & 8 deletions cmsl1t/recalc/met.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@


def recalcMET(caloTowers, exclude=None):
met = (0, 0)
metx = []
ets = []
phis = []
for tower in caloTowers:
ieta = tower.ieta
# ieta = tower.ieta
if exclude is not None:
if exclude(tower):
continue
Expand All @@ -22,17 +21,14 @@ def recalcMET(caloTowers, exclude=None):


def l1Met28Only(caloTowers):
exclude = lambda tower: not abs(tower.ieta) == 28
return recalcMET(caloTowers, exclude=exclude)
return recalcMET(caloTowers, exclude=lambda tower: not abs(tower.ieta) == 28)

# TODO: find better name


def l1MetNot28(caloTowers):
exclude = lambda tower: abs(tower.ieta) >= 28
return recalcMET(caloTowers, exclude=exclude)
return recalcMET(caloTowers, exclude=lambda tower: abs(tower.ieta) >= 28)


def l1MetNot28HF(caloTowers):
exclude = lambda tower: abs(tower.ieta) == 28
return recalcMET(caloTowers, exclude=exclude)
return recalcMET(caloTowers, exclude=lambda tower: abs(tower.ieta) == 28)
1 change: 1 addition & 0 deletions test/playground/test_cachedTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def __init__(self, size):
self.eta = np.random.rand(size)
self.size = size


class TestEvent(object):
def __init__(self):
self._tree = CachedIndexedTree(TestTree(3), 'size')
Expand Down

0 comments on commit 3ee038f

Please sign in to comment.