Skip to content

Commit

Permalink
Merge pull request #223 from JeffersonLab/bugfix-docker-extract-analy…
Browse files Browse the repository at this point in the history
…sis-products

Added targz_macros.sh script to pack up the test products (pngs, root, log)
  • Loading branch information
wdconinc committed Mar 16, 2019
2 parents 0637609 + 1820def commit 3da5ee3
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 6 deletions.
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ script:
done
- for suite in unit commit release ; do
docker run -t jeffersonlab/remoll "scripts/tests/test_macros.sh ${suite}" || exit 1 ;
docker start $(docker ps -l -q) ;
docker exec $(docker ps -l -q) "scripts/tests/targz_macros.sh ${suite}" ;
docker cp $(docker ps -l -q):"remolltest.${suite}.log.tar.gz" . ;
docker cp $(docker ps -l -q):"remolltest.${suite}.root.tar.gz" . ;
docker cp $(docker ps -l -q):"remolltest.${suite}.analysis.log.tar.gz" . ;
docker cp $(docker ps -l -q):"remolltest.${suite}.analysis.png.tar.gz" . ;
docker cp $(docker ps -l -q):"remolltest.${suite}.analysis.root.tar.gz" . ;
docker stop $(docker ps -l -q) ;
done

after_success:
Expand All @@ -21,3 +29,24 @@ after_success:

notifications:
slack: jlab12gev:PVp0QYADLTXmFdicK6WXkTGN

deploy:
provider: releases
api_key:
secure: MzvvPA8KxYjEVa8C9rNtAQbtD+mDx2Wn3Em02JKMtwv953Htnv3zRcyGPfF++sLV80RvZ8NZ8pN3WfiAPTBHatUSgWh9w+GRv0G366wxKrAS4O+9BVy96U7A0gFkaXRwXirJWo4u2lJscQ1hC2IDbI2dGAS/VF5Lt1TLjWcPUL8LPcKgF80FG8+9+BUH1cRiW8mULT36EeVAB1K+vwO6Qob5k4ef66eHjkbdpuUktDr6wrehoyGXtFiBfl+XWotvcrer/51J6wn85UqCc/A+KYrVshBH/gKCD7/w6D2akNM2/sJcFdLzv5WkaQOwplsAYuzLn1cNRUKbWay5ClCSm6rsoHGfaagW4/wXk9TxqJhcdmNZ+eeAvNXAxJIeRvb82pwANlSJ658FBw2ov75p3Y6rjvc8CUPsxBXZkw3dzOgwTdjmJI9q+aD4GuVeGiq9MdyJDgXUjxlP2qEtcLJfvvF9q5Bnzy+hoAV+A5yHg0lR0VjsUem2+CdexuHb/LJLx4YVkSrCSyEELAsfyJTCYNLaMKrWKujelqtKwXy4H/rwzaja6IBP77gkisNI82bvnrzn/QsvnueGyWSu/Z2HC2M/d6WAQAl3Et9W6kOb7MK+NAmEMOTW7tzaxjD+lq8aOiLJYndrOYaymin5GLNk3F2iqZMkhMCRC2YcstNr61w=
file:
- remolltest.commit.log.tar.gz
- remolltest.commit.root.tar.gz
- remolltest.commit.analysis.log.tar.gz
- remolltest.commit.analysis.png.tar.gz
- remolltest.commit.analysis.root.tar.gz
- remolltest.release.log.tar.gz
- remolltest.release.root.tar.gz
- remolltest.release.analysis.log.tar.gz
- remolltest.release.analysis.png.tar.gz
- remolltest.release.analysis.root.tar.gz
skip_cleanup: true
on:
repo: JeffersonLab/remoll
tags: true

File renamed without changes.
88 changes: 88 additions & 0 deletions analysis/tests/test_power.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
This program for calculating the power on the collimator 1,2,4,5 for MOLLER
experiment
Chandan Ghosh
part of this is taken from Rakitha's code coll_scan.cc
*/
#include <vector>
#include <iostream>

#include "remolltypes.hh"

#include <TTree.h>
#include <TFile.h>
#include <TChain.h>

void test_power (const TString& inputdir = ".", const TString& inputname = "remollout")
{
// Input files
TChain* T = new TChain("T");
T->Add(inputdir + "/" + inputname + ".root");

// Output files
TString outputdir = inputdir + "/" + "analysis";
TFile file(outputdir + "/" + inputname + ".root","RECREATE");

// Collimators and particles to track
std::vector<Int_t> collimators = {2001, 2006, 2002, 2004, 2005};
std::vector<Int_t> particles = {11, -11, 22, 2112};

// Energy vectors
std::vector<Double_t> esum(collimators.size(), 0.0);
std::vector<std::vector<Double_t>> esum2(collimators.size(), std::vector<Double_t>(particles.size(), 0.0));

// Connect to tree
std::vector<remollGenericDetectorSum_t>* fGenDetSum = 0;
T->SetBranchAddress("sum",&fGenDetSum);

// Event loop
Int_t nentries = T->GetEntries();
std::cout << "Number of entries in TChain " << nentries << std::endl;
for (int ev = 0; ev < T->GetEntries(); ev++) {

T->GetEntry(ev);

for (size_t isum = 0; isum < fGenDetSum->size(); isum++) {

Int_t volume = fGenDetSum->at(isum).det;
Double_t edep = fGenDetSum->at(isum).edep;

for (size_t coll = 0; coll < collimators.size(); coll++) {

if (volume == collimators[coll]) {

esum[coll] += edep;

std::vector<remollGenericDetectorSumByPID_t> sumbypid = fGenDetSum->at(isum).by_pid;

for (size_t isum2 = 0; isum2 < sumbypid.size(); isum2++) {

Double_t edep = sumbypid.at(isum2).edep;
Int_t pid = sumbypid.at(isum2).pid;

for (size_t part = 0; part < particles.size(); part++) {
if (pid == particles[part])
esum2[coll][part] += edep;
}
}
}
}
}
}

for (size_t coll = 0; coll < collimators.size(); coll++) {
std::cout << "Collimator " << collimators[coll] << std::endl;
std::vector<Double_t> esum_pid(collimators.size(), 0.0);
std::cout << "Deposited energy (from sum.edep) " << std::setw(8) << esum[coll]*85./nentries << " W/85uA" << std::endl;
for (size_t part = 0; part < particles.size(); part++) {
std::cout << "particle " << std::setw(5) << particles[part] << " energy deposited (from by_pid) " << std::setw(6) << esum2[coll][part]*85./nentries << " W/85uA" << std::endl;
esum_pid[coll] += esum2[coll][part];
}
std::cout << "By pid sum edep (from by_pid) " << esum_pid[coll]*85./nentries << " W/85uA" << std::endl;
}
std::cout << "Total energy deposited inside collimator (from sum.edep) " << esum[0]*85./nentries + esum[1]*85./nentries << " W/85uA" <<std::endl;

// Cleanup
delete T;
}

4 changes: 0 additions & 4 deletions macros/issues/issue179.mac
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
/remoll/evgen/set beam
/remoll/beamene 11 GeV
/remoll/kryptonite/set true
/remoll/kryptonite/del Lead
/remoll/kryptonite/del CW95
/remoll/kryptonite/del Tungsten
/remoll/kryptonite/del Copper
/remoll/kryptonite/add Lead_kryp
/process/list
/remoll/filename remollout1.root
Expand Down
12 changes: 12 additions & 0 deletions macros/tests/commit/test_power.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/remoll/setgeofile geometry/mollerMother_merged.gdml

/run/initialize

/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt
/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt

/remoll/evgen/set beam
/remoll/beamene 11 GeV

/remoll/filename test_power.root
/run/beamOn 10000
1 change: 0 additions & 1 deletion macros/tests/unit/test_kryptonite.mac
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/run/initialize
/remoll/filename test_kryptonite.root

/remoll/kryptonite/del Lead
/remoll/kryptonite/add G4_Pb
/remoll/kryptonite/list

Expand Down
19 changes: 19 additions & 0 deletions scripts/tests/targz_macros.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Exit whenever non-zero exit code occurs
set -euo pipefail

# Determine absolute path of this script
dir=`dirname $0`/../..
dir=`readlink -f ${dir}`

# The test suite can be specified as first argument, default is "commit"
suite="${1:-commit}"

# Pack log files
tar -czvf remolltest.${suite}.log.tar.gz --transform 's|logfiles/tests/||g' logfiles/tests/${suite}/*.log
tar -czvf remolltest.${suite}.analysis.log.tar.gz --transform 's|logfiles/tests/||g' logfiles/tests/${suite}/analysis/*.log
# Pack analysis products
tar -czvf remolltest.${suite}.root.tar.gz --transform 's|rootfiles/tests/||g' rootfiles/tests/${suite}/*.root
tar -czvf remolltest.${suite}.analysis.png.tar.gz --transform 's|rootfiles/tests/||g' rootfiles/tests/${suite}/analysis/*.png
tar -czvf remolltest.${suite}.analysis.root.tar.gz --transform 's|rootfiles/tests/||g' rootfiles/tests/${suite}/analysis/*.root
2 changes: 1 addition & 1 deletion scripts/tests/test_macros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ for macro in ${macros}/${macroglob} ; do
echo "Starting analysis..." | tee ${logfiles}/analysis/${name}.log
for rootmacro in ${analysis1}/${analysisglob} ${analysis2}/${analysisglob} ; do
echo "Running analysis macro `basename ${rootmacro} .C`..."
root -q -b -l "${rootmacro}+(\"${rootfiles}\",\"${name}\")" 2>&1 | tee -a ${logfiles}/analysis/${name}.log
build/reroot -q -b -l "${rootmacro}+(\"${rootfiles}\",\"${name}\")" 2>&1 | tee -a ${logfiles}/analysis/${name}.log
done

done

0 comments on commit 3da5ee3

Please sign in to comment.