{"id":21987025,"url":"https://github.com/marcodeltutto/sbnd-crt-scripts","last_synced_at":"2025-10-05T23:32:40.890Z","repository":{"id":68609074,"uuid":"373903239","full_name":"marcodeltutto/sbnd-crt-scripts","owner":"marcodeltutto","description":"Scripts to process SBND CRT data files from 2017-2018","archived":false,"fork":false,"pushed_at":"2022-09-22T20:00:50.000Z","size":206,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-28T05:27:52.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcodeltutto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-04T16:38:17.000Z","updated_at":"2021-11-23T18:50:16.000Z","dependencies_parsed_at":"2023-03-06T08:30:30.536Z","dependency_job_id":null,"html_url":"https://github.com/marcodeltutto/sbnd-crt-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcodeltutto%2Fsbnd-crt-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcodeltutto%2Fsbnd-crt-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcodeltutto%2Fsbnd-crt-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcodeltutto%2Fsbnd-crt-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcodeltutto","download_url":"https://codeload.github.com/marcodeltutto/sbnd-crt-scripts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245046379,"owners_count":20552186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T18:26:42.776Z","updated_at":"2025-10-05T23:32:40.793Z","avatar_url":"https://github.com/marcodeltutto.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Processing of the CRT data files\n\nCRT data files are located at `/sbnd/data/CRT/CRT_data/`.\n\n\n## Setup\n\nSetup with `source setup.sh`.\n\n\n## Step 0 - Preliminary (POT)\n\n### Get BNB POT info from database\n\nUse the scripts `pot/extract201*.sh` to download the BNB spill information for all the days in 2017 and 2018. These scripts will create a file for each day containing `second, millisecond, pot` information for each spill from the accelerator database. These files are created in txt format. Run the script `database_to_pickle.py` to have them in pkl format as well.\nCopy the folder `extract_from_database` into the sbnd/data area: `/sbnd/data/users/mdeltutt/crt_data/pot/`.\n\nYou don't need to do this step, as files are already present in `/sbnd/data/users/mdeltutt/crt_data/pot/`.\n\n\n## Step 1 - Pair Builder\n\nRun the `pair_builder` to extract beam-triggered events. \nThis code takes as input raw DAQ files and makes files in binary format that contain\nbeam-triggered events.\n\nSteps to run:\n- Go in `pair_builder/`\n- Compile with `make`\n- Test run with `source test_run.sh` (make sure you open change the destination path in the script first)\n\nThe `pair_builder` will create an ouptput binary file for each input binary file, plus an\nadditional txt file with all the processed T1 events (beam spills). This txt file\nis needed for step 2, as it will be correlated with the accelerator database to retrieve\nthe POT per spill.\n\n\n## Step 2 - POT Correlation\n\nIn the same `pair_builder/`, run the `parse_spill_files.py` to correlate the T1 spills with the POTs:\n```\npython parse_spill_files.py --file /path/to/step1/output/file\n```\n\nYou can run both Step 1 and 2 with:\n- Adjust the output file path in `run_pair_builder.sh`\n- `source run_pair_builder.sh`.\n\n\n## Step 3 - From Binary to libCRT ROOT Files\n\nConvert the files from binary to libCRT ROOT format. This is done in the `conversion` folder.\nThe `ConvertRawPairsToRun.C` macro takes as input\nbinary files from the previous step, gets the 1D hits from them, makes 2D hits out of every two\ncoincident 1D hits, and saves all these hits in libCRT format to an output ROOT file.\n\n- Orignal libCRT: https://github.com/kreslo/libCRT\n- Currently used libCRT: https://github.com/marcodeltutto/libCRT\n\nAfter this step, one can merge all the output ROOT files into one.\n\nThis is what get run:\n- `ConvertRawPairsToRun`: From the binary file, it takes two consecutive 1D hits to make a 2D hit.\n- `GroupAndClassify`: Groups 2D hits together based on time coincidence. We use a 50000 ns (50 ms) time\ncoincidence for this, as we want to group hits belonging to the same spill.\n- `ExtractPassing`: Not used.\n\nRun a test:\n- Go in `conversion/`\n- Set the right file paths in `test_run.sh`\nRun with `source test_run.sh`\n\nRun on all files:\n- Set the right file paths in `ReprocessAllRuns.sh`\n- Run with `source ReprocessAllRuns.sh`\n\n\n## Step 4 - From libCRT to flat ROOT TTree\n\nFlat the libCRT tree. This is done by `flat_crt_tree.C` in the `conversion` folder.\nThis script converts root files from libCRT to simple flat tree for easy analysis.\n\n\n## Step 5 - Convert to art-ROOT\n\nFinally, we want to convert to LArSoft art-ROOT format. Code to do this is in feature branch\n`feature/mdeltutt_bt_data_import`\ninside the `sbndcode/CRTBeamTelescope/DataImport` folder.\n\nRun with \n`lar -c import_crt_data_sbnd.fcl -s /sbnd/data/users/mdeltutt/crt_data/test/ProdRun20170623_152137.beam.classified.flat.root`\n\n\n## Step 6 - Custom Reconstruction\n\nTo be done. Work started in `sbndcode/CRTBeamTelescope/Reconstruction/` in feature branch\n`feature/mdeltutt_bt_data_import`.\n\n\n\n\n\n## Processed Files\n\n### May 2022\n\nOutput of step 2 is in:\n`/sbnd/data/users/mdeltutt/crt_data/beam_with_pot/`\n\nOutput of step 3 is in:\n`/sbnd/data/users/mdeltutt/crt_data/beam_converted_may2022/`\n\nFiles called `ProdRun????????_??????.beam.classified.root` need to go to step 4.\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcodeltutto%2Fsbnd-crt-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcodeltutto%2Fsbnd-crt-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcodeltutto%2Fsbnd-crt-scripts/lists"}