Skip to content

Commit

Permalink
Merge pull request #4 from ybuch/3-improve-documentation-and-batch-an…
Browse files Browse the repository at this point in the history
…alysis-script

3 improve documentation and batch analysis script
  • Loading branch information
ybuch authored Aug 13, 2024
2 parents 17bab9c + b1428df commit 3dafc2c
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 30 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ Alignment: run `full_align.sh` for each geo_id (telescope and DUT alignment) and
Masking: run `mask_generator.sh` which generates a mask file from a default mask (masking not used frontends) and a yaml file (list of disabeled pixels in the data taking). Please nothe that the default masks do not work for all runs since the frontends were also changed within geo_ids! These masks were adapted by hand and a set of working masks is stored under initial_masks.

Analysis: is done using jobsub which is installed under your corry installation (see corry manual and below). A csv file has to be created with `data_searcher.sh` which contains information of geo and data for each run before starting the analysis.
## Software

Root: 6.24/06, ROOT 6.26/10 seem to work both.
Eudaq: https://github.com/bpilsl/eudaq/tree/monopix2
Corryvreckan: Master branch cf10f1ad0a4ff3e21eb8bdc7235664727f3393f4


## conf

This folder contains all config files for corry which are used for the alignment as well as scripts. The analysis is done via jobsub (see below)
This folder contains all config files for corry which are used for the alignment as well as scripts.

### full_align.sh

Expand All @@ -34,14 +39,6 @@ Folder containing used mask files (applied_masks) and scripts for generating mas

This script copies a default mask from the default folder (containing information about the masking of the not activated frontends) and appends the information of the yaml files depending on the runnumber (by using extract_masked_pixels.py). The output is stored in the folder applied_masks. Please note that the default masks are not propper for all runs since changes in the masking werde done throughout equal geo_ids. Already finished masks can be found in the folder initial_masks.

## jobsub

This folder contains necessary files for jobsub which has to be started from your local corry installation (`<path_to_corry>/jobsub python3 jobsub.py -c <path_to_repo>/jobsub/analysis_jobsub.cfg> -csv <path_to_repo>/jobsub/data_p.csv -s -j 5 <runnumbers>`). For further information about jobsub please have a look at the corry manual. As example csv file, data_examle.csv is given.

### analysis_jobsub.cfg

config file used by jobsub

### data_searcher.sh
### analysis

This script takes `W02R05_standard.csv`, `W05R15_TID.csv` or `W08R06_p.csv` as input and generates the needed csv file for jobsub.
Use conf/analyze.py. This convenience script does a run specific DUT alignment and analyses the run using the analysis.conf.
Binary file removed analysis/alignment_run_1400.root
Binary file not shown.
Binary file removed analysis/alignment_run_1401.root
Binary file not shown.
Binary file removed analysis/analysis_run_1400.root
Binary file not shown.
Binary file removed analysis/analysis_run_1401.root
Binary file not shown.
46 changes: 34 additions & 12 deletions conf/analyze.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
'''
Usage: python3 analyze.py --start 1400 --stop 1568
'''

import argparse
import glob
import re
import os
import pandas as pd


# These paths might need to be changed
data_folder = '/home/bgnet2/s3_cloud/beam_data/desy'
corry_bin = '~/corryvreckan/bin/corry'

# These paths do not need to be changed.
geo_path_tel = '../geo/full_aligned'
geo_path_run = '../geo/temp'
dut_align_conf = '../conf/align_dut_mpx2.conf'
analysis_conf = '../conf/analysis.conf'
run_align_folder = '../geo/run_align'
analysis_folder = '../analysis'
run_start = 1400
run_stop = 1401
do_masking_per_run = True

do_align_per_run = True
do_analysis = True
number_of_events_align = 100000
number_of_events_analyze = 100000000

parser = argparse.ArgumentParser(description='corry analysis wrapper')
parser.add_argument('-r', help='run number', default = 0)
parser.add_argument('--start', help='run number start', default = 0)
parser.add_argument('--stop', help='run number stop', default = 0)
parser.add_argument('-n', help='number of events for analysis', default = 100000000)

df = pd.read_csv("../run_properties.csv", sep=",")
print(df)
data_in_files = glob.glob(data_folder + '/*.raw')
# print('available raws: ', data_in_files)
args = parser.parse_args()

number_of_events_analyze = args.n

if args.r == 0 and (args.start == 0 or args.stop == 0):
print("Either use run number or start/stop to give a range of runs to be analyzed.")

if args.r != 0:
run_start = args.r
run_stop = args.r
else:
run_start = args.start
run_stop = args.stop

df = pd.read_csv("../run_properties.csv", sep=",")
data_in_files = glob.glob(data_folder + '/*.raw')

for current_run in range(run_start,run_stop+1):
if not current_run in df['run_number'].unique():
Expand All @@ -40,16 +60,17 @@
m = re.search(f'telescope.+run(0*{current_run})', f)
if m:
current_tel_file = f

if current_dut_file == '' or current_tel_file == '':
print(f'raw_files empty for run {current_run}')
continue
print(f'processing tel: {current_tel_file}, dut: {current_dut_file}')
geo_id = df.loc[df['run_number'] == current_run]['geoid'].values[0]
print(type(geo_id))
tel_full_aligned = geo_path_tel+'/'+f'geo_id{geo_id}_full_aligned.geo'
run_aligned = run_align_folder+'/'+f'alignment_run_{current_run}.geo'
run_aligned_histo = '/'+f'alignment_run_{current_run}.root'
analysis_histo = analysis_folder+'/'+f'analysis_run_{current_run}.root'

if do_masking_per_run:
if do_align_per_run:
print(f'Running alignment for run {current_run}')
corry_cmd = f'{corry_bin} -c {dut_align_conf} -o number_of_events={number_of_events_align} -o output_directory={run_align_folder} -o detectors_file={tel_full_aligned} -o detectors_file_updated={run_aligned} -o histogram_file={run_aligned_histo} -o EventLoaderEUDAQ2.file_name={current_tel_file} -o EventLoaderEUDAQ2:Monopix2_0.file_name={current_dut_file}'
print(corry_cmd)
Expand All @@ -69,4 +90,5 @@
if do_analysis:
print(f'Running anaylsis for run {current_run}')
corry_cmd = f'{corry_bin} -c {analysis_conf} -o number_of_events={number_of_events_analyze} -o output_directory={analysis_folder} -o detectors_file={run_aligned} -o histogram_file={analysis_histo} -o EventLoaderEUDAQ2.file_name={current_tel_file} -o EventLoaderEUDAQ2:Monopix2_0.file_name={current_dut_file}'
print(corry_cmd)
os.system(corry_cmd)
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id10_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 0deg,0deg,89.7485deg
orientation_mode = "xyz"
Expand Down
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id3_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 180deg,180deg,0.116024deg
orientation_mode = "xyz"
Expand Down
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id5_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 0deg,0deg,89.8731deg
orientation_mode = "xyz"
Expand Down
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id6_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 2.24422deg,-1.25592deg,89.8deg
orientation_mode = "xyz"
Expand Down
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id7_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 0deg,0deg,89.6663deg
orientation_mode = "xyz"
Expand Down
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id8_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 0deg,0deg,89.72deg
orientation_mode = "xyz"
Expand Down
2 changes: 1 addition & 1 deletion geo/full_aligned/geo_id9_full_aligned.geo
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "mimosa26"

[Monopix2_0]
coordinates = "cartesian"
material_budget = 0.00075
material_budget = 0.0032
number_of_pixels = 512, 512
orientation = 0deg,0deg,89.7388deg
orientation_mode = "xyz"
Expand Down
Binary file removed geo/run_align/alignment_run_1400.root
Binary file not shown.
Binary file removed geo/run_align/alignment_run_1401.root
Binary file not shown.

0 comments on commit 3dafc2c

Please sign in to comment.