This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into iss1074-geometry
- Loading branch information
Showing
8 changed files
with
269 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Example Configuration Files | ||
|
||
## Test-Beam reconstruction | ||
|
||
### Before you start: | ||
- Verify that you are working with the latest version of the `Hcal/` submodule. | ||
``` | ||
cd ldmx # the parent directory of ldmx-sw | ||
cd ldmx-sw/Hcal | ||
git switch trunk | ||
# rebuild ldmx-sw | ||
cd ../build/ | ||
ldmx make install -j 4 | ||
``` | ||
- Verify that you have the [conditions-data](https://github.com/LDMX-Software/conditions-data) repository installed | ||
``` | ||
cd ldmx # the parent directory of ldmx-sw | ||
git clone [email protected]:ldmx-software/conditions-data | ||
cd ldmx-sw | ||
git checkout trunk | ||
git pull | ||
git submodule update | ||
# rebuild ldmx-sw | ||
cd ../build/ | ||
ldmx make install -j 4 | ||
``` | ||
|
||
### For simulation: | ||
- Use simulated events with prototype geometry ```detector='ldmx-hcal-prototype-v2.0'```. | ||
- Run reconstruction on prototype simulation: | ||
``` | ||
ldmx fire tb_sim.py hcal_XXX_simevents.root | ||
``` | ||
|
||
### For data: | ||
|
||
- Run reconstruction on prototype simulation: | ||
``` | ||
ldmx fire tb_reco.py hcal_run_XXX_decoded.root | ||
``` | ||
|
||
In this configuration file `HcalSingleEndRecProducer` is run by default. A `DoubleEndRecProducer` will be available too. | ||
|
||
#### Decoded inputs | ||
A set of decoded April-2022 TB data is available on the SLAC cluster: | ||
``` | ||
/nfs/slac/g/ldmx/data/hcal-tb | ||
``` | ||
The directory holds the test beam data from the HCal prototype subsystem. | ||
|
||
Since event alignment is a tricky business (and sometimes is broken), | ||
the data has two copies: one with event alignment and one without. | ||
Please look at the README in that directory for more details. | ||
|
||
The following is the table of contents of this folder: | ||
``` | ||
./ | ||
|-- unaligned/ : unification of the two halves of the HCal was not attempted | ||
|-- reformat/ : unpacking of raw data into event objects, no decoding | ||
|-- decoded/ : products decoded into HgcrocDigiCollection objects | ||
|-- decoded-ntuples/ : HgcrocDigiCollection objects ntuplized for easier analysis | ||
|-- fail-decode.list : list of files that failed the decoding step | ||
|-- fail-reformat.list : list of files that failed the reformat/unpack step | ||
|-- aligned/ : two polarfires of the HCal were aligned based on timestamps | ||
|-- reformat/ : simple unpacking and alignemnt, no decoding | ||
|-- decoded/ : decoded into HgcrocDigiCollection objects | ||
|-- decoded-ntuples/ : HgcrocDigiCollection objects ntuplized for easier analysis | ||
|-- reformat_cfg.py : configuration script for `ldmx reformat ` used for unpacking and alignment | ||
|-- decode_cfg.py : configuration script for `ldmx fire ` used for decoding and ntuplization | ||
```` | ||
#### Re-doing data reformatting and decoding | ||
Event building was not done online, so it needs to be done on raw TB data files (if not using the existing set of decoded test-beam data). | ||
A copy of raw April-2022 TB data is available on the SLAC cluster: | ||
``` | ||
/nfs/slac/g/ldmx/CERN-TB-DATA/ldmx/testbeam/data/pf_external/ | ||
``` | ||
- Reformat: | ||
- [Build and install reformat](https://github.com/LDMX-Software/ldmx-tb-online/blob/main/reformat/README.md#Building) | ||
- An [example config: hcal_cfg.py](https://github.com/LDMX-Software/ldmx-tb-online/blob/main/reformat/TestBeam/hcal_cfg.py) exists. A common run example would be: | ||
``` | ||
ldmx reformat TestBeam/hcal_cfg.py \ | ||
--pf0 path/to/fpga_0_run_XXX.raw \ | ||
--pf1 path/to/fpga_1_run_XXX.raw \ | ||
--output_filename hcal_run_XXX_reformat.root | ||
``` | ||
- Decode: | ||
- One can use the decoding producer in ldmx-sw. | ||
- A common example is available in [decode_cfg.py](https://github.com/LDMX-Software/Hcal/blob/trunk/exampleConfigs/decode_cfg.py) | ||
`ldmx-sw fire decode_cfg.py hcal_run_XXX_reformat.root`. By default this decoding does not pedestal subtraction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
"""Decoding configuration for raw testbeam data | ||
Decoding **DOES NOT** attempt | ||
to align the two halves of the HCal. We assume a local home path of ldmx-sw installation e.g. | ||
LDMX_BASE=/local/cms/user/eichl008/ldmx/ | ||
so that we can construct the output path correctly. | ||
The run number is deduced from the file name. | ||
@author Tom Eichlersmith, University of Minnesota | ||
""" | ||
|
||
import argparse, sys | ||
|
||
parser = argparse.ArgumentParser(f'ldmx fire {sys.argv[0]}', | ||
description=__doc__) | ||
|
||
parser.add_argument('input_file') | ||
parser.add_argument('--pause',action='store_true') | ||
parser.add_argument('--max_events',type=int) | ||
parser.add_argument('--pedestals',default=None,type=str) | ||
|
||
arg = parser.parse_args() | ||
|
||
from LDMX.Framework import ldmxcfg | ||
|
||
p = ldmxcfg.Process('decode') | ||
if arg.max_events is not None : | ||
p.maxEvents = arg.max_events | ||
p.termLogLevel = 0 | ||
p.logFrequency = 1000 | ||
|
||
import LDMX.Hcal.hgcrocFormat as hcal_format | ||
import LDMX.Hcal.HcalGeometry | ||
import LDMX.Hcal.hcal_hardcoded_conditions | ||
from LDMX.DQM import dqm | ||
import os | ||
from LDMX.Hcal.DetectorMap import HcalDetectorMap | ||
detmap = HcalDetectorMap(f'{os.environ["LDMX_BASE"]}/ldmx-sw/Hcal/data/testbeam_connections.csv') | ||
detmap.want_d2e = True # helps quicken the det -> elec translation | ||
|
||
# extract and deduce parameters from input file name | ||
params = os.path.basename(arg.input_file).replace('.root','').split('_') | ||
run = params[params.index("run")+1] | ||
day = params[-2] | ||
time = params[-1] | ||
if 'fpga' in params : | ||
alignment = 'unaligned' | ||
pf = params[params.index("fpga")+1] | ||
provided = f'fpga_{pf}' | ||
input_names = [ f'Polarfire{pf}Raw' ] | ||
out_name = input_names[0]+'Digis' | ||
elif 'hcal' in params : | ||
alignment = 'aligned' | ||
provided = 'hcal' | ||
input_names = [ f'Polarfire{pf}Raw' for pf in [0,1] ] | ||
out_name = 'HcalRawDigis' | ||
else : | ||
raise KeyError(f'Unable to deduce alignment from {fp}, need either "fpga" or "hcal" in base file name.') | ||
|
||
dir_name = f'{os.environ["LDMX_BASE"]}/testbeam/{alignment}/v2-decoded' | ||
os.makedirs(dir_name, exist_ok=True) | ||
os.makedirs(dir_name+'-ntuple', exist_ok=True) | ||
|
||
file_name = f'decoded_{provided}_run_{run}_{day}_{time}' | ||
|
||
p.inputFiles = [arg.input_file] | ||
p.outputFiles = [f'{dir_name}/{file_name}.root'] | ||
p.histogramFile = f'{dir_name}-ntuple/ntuple_{file_name}.root' | ||
|
||
# sequence | ||
# 1. decode event packet into digi collection | ||
# 2. ntuplize digi collection | ||
p.sequence = [ | ||
hcal_format.HcalRawDecoder( | ||
input_names = input_names, | ||
output_name = out_name | ||
), | ||
dqm.NtuplizeHgcrocDigiCollection( | ||
input_name = out_name, | ||
pedestal_table = arg.pedestals | ||
) | ||
] | ||
|
||
if arg.pause : | ||
p.pause() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import argparse,sys | ||
from LDMX.Framework import ldmxcfg | ||
|
||
""" | ||
Simulation of particles through TB prototype | ||
""" | ||
|
||
parser = argparse.ArgumentParser(f'ldmx fire {sys.argv[0]}') | ||
parser.add_argument('--nevents',default=100,type=int) | ||
parser.add_argument('--particle',default='neutron') # other options, mu-,e-,pi-,proton | ||
parser.add_argument('--energy',default=2.0,type=float) | ||
arg = parser.parse_args() | ||
|
||
p = ldmxcfg.Process('sim') | ||
p.maxEvents = arg.nevents | ||
p.termLogLevel = 0 | ||
p.logFrequency = 10 | ||
|
||
detector = 'ldmx-hcal-prototype-v2.0' # TODO: CHANGE TO FEFIX version | ||
|
||
p.outputFiles = [ | ||
arg.particle | ||
+"Sim_%.2fGeV_"%arg.energy | ||
+ str(p.maxEvents) | ||
+ "_%s.root"%detector | ||
] | ||
|
||
from LDMX.SimCore import simulator | ||
import LDMX.Ecal.EcalGeometry # geometry required by sim | ||
|
||
mySim = simulator.simulator('mySim') | ||
mySim.setDetector(detector) | ||
|
||
# Get a pre-written generator | ||
from LDMX.SimCore import generators as gen | ||
myGun = gen.gun('myGun') | ||
myGun.particle = arg.particle | ||
myGun.position = [ 0., 0., 0 ] # mm | ||
myGun.direction = [ 0., 0., 1] # forward in z | ||
myGun.energy = arg.energy # GeV | ||
mySim.generators = [ myGun ] | ||
p.sequence.append( mySim ) | ||
# mySim.verbosity = 1 | ||
|
||
# import chip/geometry (hardcoded) conditions | ||
import LDMX.Hcal.HcalGeometry | ||
import LDMX.Hcal.hcal_hardcoded_conditions | ||
import LDMX.Hcal.digi as hcal_digi | ||
|
||
# add them to the sequence | ||
p.sequence.extend( | ||
[ | ||
hcal_digi.HcalDigiProducer(), | ||
hcal_digi.HcalRecProducer(), | ||
hcal_digi.HcalSingleEndRecProducer( | ||
pass_name = 'sim', coll_name = 'HcalDigis', | ||
rec_coll_name = 'HcalSingleEndRecHits', | ||
), | ||
] | ||
) | ||
|
||
# View configuration before actually running | ||
p.pause() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters