From 4cb22520adad6ce655d8f45df96e013432fa51be Mon Sep 17 00:00:00 2001 From: Chao Peng <cpeng@anl.gov> Date: Wed, 22 Jul 2020 12:32:26 -0500 Subject: [PATCH] modify the old analysis script to adapt previous data --- {config/json => database}/esb_module.json | 0 {config/json => database}/esb_timing.json | 0 database/fadc_459_pos_cut.json | 1 + database/lappd_module.json | 151 +++++++++++++++++++ database/mapmt_module.json | 151 +++++++++++++++++++ scalers/scalers_run158/solid.0 | 144 ++++++++++++++++++ scalers/scalers_run158/solid.15 | 144 ++++++++++++++++++ scalers/scalers_run158/solid.30 | 144 ++++++++++++++++++ scalers/scalers_run158/solidcer.cnf.20200323 | 146 ++++++++++++++++++ scalers/scalers_run160/solid.0 | 144 ++++++++++++++++++ scalers/scalers_run160/solid.15 | 144 ++++++++++++++++++ scalers/scalers_run160/solid.30 | 144 ++++++++++++++++++ scalers/scalers_run160/solidcer.cnf.20200323 | 146 ++++++++++++++++++ scripts/analyze_waveform.py | 14 +- scripts/analyze_waveform_first.py | 101 +++++++++++++ scripts/analyze_waveform_max.py | 80 ++++++++++ scripts/analyze_waveform_time.py | 141 ----------------- scripts/old/batch_run.py | 78 ++++++---- src/analyze.cpp | 23 ++- src/conf2json.cpp | 76 ++++++++++ 20 files changed, 1782 insertions(+), 190 deletions(-) rename {config/json => database}/esb_module.json (100%) rename {config/json => database}/esb_timing.json (100%) create mode 100644 database/fadc_459_pos_cut.json create mode 100644 database/lappd_module.json create mode 100644 database/mapmt_module.json create mode 100644 scalers/scalers_run158/solid.0 create mode 100644 scalers/scalers_run158/solid.15 create mode 100644 scalers/scalers_run158/solid.30 create mode 100644 scalers/scalers_run158/solidcer.cnf.20200323 create mode 100644 scalers/scalers_run160/solid.0 create mode 100644 scalers/scalers_run160/solid.15 create mode 100644 scalers/scalers_run160/solid.30 create mode 100644 scalers/scalers_run160/solidcer.cnf.20200323 create mode 100644 scripts/analyze_waveform_first.py create mode 100644 scripts/analyze_waveform_max.py delete mode 100644 scripts/analyze_waveform_time.py create mode 100644 src/conf2json.cpp diff --git a/config/json/esb_module.json b/database/esb_module.json similarity index 100% rename from config/json/esb_module.json rename to database/esb_module.json diff --git a/config/json/esb_timing.json b/database/esb_timing.json similarity index 100% rename from config/json/esb_timing.json rename to database/esb_timing.json diff --git a/database/fadc_459_pos_cut.json b/database/fadc_459_pos_cut.json new file mode 100644 index 0000000..1fdb96d --- /dev/null +++ b/database/fadc_459_pos_cut.json @@ -0,0 +1 @@ +{"Cer0": [-5.5, -1.5], "Cer1": [-7.5, -3.5], "Cer2": [-8.5, -4.5], "Cer3": [-8.5, -4.5], "Cer4": [-8.5, -4.5], "Cer5": [-8.5, -4.5], "Cer6": [-7.5, -3.5], "Cer7": [-7.5, -3.5], "Cer8": [-7.5, -3.5], "Cer9": [-8.5, -4.5], "Cer10": [-7.5, -3.5], "Cer11": [-62, 62], "Cer12": [-8.5, -4.5], "Cer13": [-8.5, -4.5], "Cer14": [-8.5, -4.5], "Cer15": [-8.5, -4.5]} diff --git a/database/lappd_module.json b/database/lappd_module.json new file mode 100644 index 0000000..ed7b34f --- /dev/null +++ b/database/lappd_module.json @@ -0,0 +1,151 @@ +{ + "module_1_6": { + "channels": [ + { + "channel": 0, + "name": "Cer0", + "type": "LAPPD" + }, + { + "channel": 1, + "name": "Cer1", + "type": "LAPPD" + }, + { + "channel": 2, + "name": "Cer2", + "type": "LAPPD" + }, + { + "channel": 3, + "name": "Cer3", + "type": "LAPPD" + }, + { + "channel": 4, + "name": "Cer4", + "type": "LAPPD" + }, + { + "channel": 5, + "name": "Cer5", + "type": "LAPPD" + }, + { + "channel": 6, + "name": "Cer6", + "type": "LAPPD" + }, + { + "channel": 7, + "name": "Cer7", + "type": "LAPPD" + }, + { + "channel": 8, + "name": "Cer8", + "type": "LAPPD" + }, + { + "channel": 9, + "name": "Cer9", + "type": "LAPPD" + }, + { + "channel": 10, + "name": "Cer10", + "type": "LAPPD" + }, + { + "channel": 11, + "name": "Cer11", + "type": "LAPPD" + }, + { + "channel": 12, + "name": "Cer12", + "type": "LAPPD" + }, + { + "channel": 13, + "name": "Cer13", + "type": "LAPPD" + }, + { + "channel": 14, + "name": "Cer14", + "type": "LAPPD" + }, + { + "channel": 15, + "name": "Cer15", + "type": "LAPPD" + } + ], + "crate": 1, + "slot": 6, + "type": "FADC250" + }, + "module_1_7": { + "channels": [ + { + "channel": 0, + "name": "Calo2", + "type": "Calo" + }, + { + "channel": 1, + "name": "Calo3", + "type": "Calo" + }, + { + "channel": 2, + "name": "Calo4", + "type": "Calo" + }, + { + "channel": 3, + "name": "Calo5", + "type": "Calo" + }, + { + "channel": 4, + "name": "CaloSum", + "type": "Calo" + }, + { + "channel": 8, + "name": "LED", + "type": "LED" + }, + { + "channel": 11, + "name": "Ref", + "type": "Ref" + }, + { + "channel": 12, + "name": "ScintLR", + "type": "Scint" + }, + { + "channel": 13, + "name": "ScintLL", + "type": "Scint" + }, + { + "channel": 14, + "name": "ScintUR", + "type": "Scint" + }, + { + "channel": 15, + "name": "ScintUL", + "type": "Scint" + } + ], + "crate": 1, + "slot": 7, + "type": "FADC250" + } +} diff --git a/database/mapmt_module.json b/database/mapmt_module.json new file mode 100644 index 0000000..f9b51a2 --- /dev/null +++ b/database/mapmt_module.json @@ -0,0 +1,151 @@ +{ + "module_1_6": { + "channels": [ + { + "channel": 0, + "name": "Cer0", + "type": "Signal" + }, + { + "channel": 1, + "name": "Cer1", + "type": "Signal" + }, + { + "channel": 2, + "name": "Cer2", + "type": "Signal" + }, + { + "channel": 3, + "name": "Cer3", + "type": "Signal" + }, + { + "channel": 4, + "name": "Cer4", + "type": "Signal" + }, + { + "channel": 5, + "name": "Cer5", + "type": "Signal" + }, + { + "channel": 6, + "name": "Cer6", + "type": "Signal" + }, + { + "channel": 7, + "name": "Cer7", + "type": "Signal" + }, + { + "channel": 8, + "name": "Cer8", + "type": "Signal" + }, + { + "channel": 9, + "name": "Cer9", + "type": "Signal" + }, + { + "channel": 10, + "name": "Cer10", + "type": "Signal" + }, + { + "channel": 11, + "name": "Cer11", + "type": "Signal" + }, + { + "channel": 12, + "name": "Cer12", + "type": "Signal" + }, + { + "channel": 13, + "name": "Cer13", + "type": "Signal" + }, + { + "channel": 14, + "name": "Cer14", + "type": "Signal" + }, + { + "channel": 15, + "name": "Cer15", + "type": "Signal" + } + ], + "crate": 1, + "slot": 6, + "type": "FADC250" + }, + "module_1_7": { + "channels": [ + { + "channel": 0, + "name": "Calo2", + "type": "Trigger" + }, + { + "channel": 1, + "name": "Calo3", + "type": "Trigger" + }, + { + "channel": 2, + "name": "Calo4", + "type": "Trigger" + }, + { + "channel": 3, + "name": "Calo5", + "type": "Trigger" + }, + { + "channel": 4, + "name": "CaloSum", + "type": "Trigger" + }, + { + "channel": 8, + "name": "LED", + "type": "Trigger" + }, + { + "channel": 11, + "name": "Ref", + "type": "Reference" + }, + { + "channel": 12, + "name": "ScintLR", + "type": "Trigger" + }, + { + "channel": 13, + "name": "ScintLL", + "type": "Trigger" + }, + { + "channel": 14, + "name": "ScintUR", + "type": "Trigger" + }, + { + "channel": 15, + "name": "ScintUL", + "type": "Trigger" + } + ], + "crate": 1, + "slot": 7, + "type": "FADC250" + } +} diff --git a/scalers/scalers_run158/solid.0 b/scalers/scalers_run158/solid.0 new file mode 100644 index 0000000..ebc3d80 --- /dev/null +++ b/scalers/scalers_run158/solid.0 @@ -0,0 +1,144 @@ +Slots: 4 +Clock Channel: 141 +0: 1(0) +1: 39450(0) +2: 35998(0) +3: 29604(0) +4: 32398(0) +5: 1(0) +6: 22311(0) +7: 29433(0) +8: 35714(0) +9: 31289(0) +10: 1(0) +11: 32905(0) +12: 33813(0) +13: 34531(0) +14: 35034(0) +15: 1(0) +16: 40377(0) +17: 1(0) +18: 41846(0) +19: 41711(0) +20: 46225(0) +21: 42915(0) +22: 1(0) +23: 41673(0) +24: 41210(0) +25: 38963(0) +26: 37189(0) +27: 1(0) +28: 31707(0) +29: 31603(0) +30: 26578(0) +31: 27006(0) +32: 0(0) +33: 33298(0) +34: 1(0) +35: 42378(0) +36: 47329(0) +37: 39548(0) +38: 39665(0) +39: 1(0) +40: 38800(0) +41: 42743(0) +42: 45571(0) +43: 40778(0) +44: 1(0) +45: 37199(0) +46: 41741(0) +47: 45305(0) +48: 42792(0) +49: 37802(0) +50: 33443(0) +51: 1(0) +52: 32013(0) +53: 38448(0) +54: 37380(0) +55: 32100(0) +56: 1(0) +57: 35679(0) +58: 38390(0) +59: 39156(0) +60: 37940(0) +61: 1(0) +62: 32097(0) +63: 41790(0) +64: 1(0) +65: 1(0) +66: 1(0) +67: 1(0) +68: 1(0) +69: 1(0) +70: 1(0) +71: 1(0) +72: 1(0) +73: 1(0) +74: 1(0) +75: 1(0) +76: 1(0) +77: 1(0) +78: 1(0) +79: 1(0) +80: 26374(0) +81: 1(0) +82: 32415(0) +83: 38876(0) +84: 34554(0) +85: 30491(0) +86: 1(0) +87: 40057(0) +88: 1(0) +89: 1(0) +90: 1(0) +91: 1(0) +92: 1(0) +93: 1(0) +94: 1(0) +95: 1(0) +96: 43238(0) +97: 1(0) +98: 36752(0) +99: 34486(0) +100: 33286(0) +101: 35360(0) +102: 1(0) +103: 30911(0) +104: 37998(0) +105: 1(0) +106: 1(0) +107: 1(0) +108: 1(0) +109: 1(0) +110: 1(0) +111: 1(0) +112: 1(0) +113: 1(0) +114: 1(0) +115: 1(0) +116: 1(0) +117: 1(0) +118: 1(0) +119: 1(0) +120: 1(0) +121: 1(0) +122: 1(0) +123: 1(0) +124: 1(0) +125: 1(0) +126: 1(0) +127: 1(0) +128: 438564977(0) +129: 1272933711(0) +130: 1(0) +131: 0(0) +132: 0(0) +133: 0(0) +134: 0(0) +135: 0(0) +136: 54694791(0) +137: 0(0) +138: 0(0) +139: 562703702(0) +140: 187(0) +141: 10440(4) diff --git a/scalers/scalers_run158/solid.15 b/scalers/scalers_run158/solid.15 new file mode 100644 index 0000000..b191127 --- /dev/null +++ b/scalers/scalers_run158/solid.15 @@ -0,0 +1,144 @@ +Slots: 4 +Clock Channel: 141 +0: 1(0) +1: 49652(0) +2: 45320(0) +3: 37231(0) +4: 40770(0) +5: 1(0) +6: 28042(0) +7: 36948(0) +8: 45042(0) +9: 39335(0) +10: 1(0) +11: 41167(0) +12: 42598(0) +13: 43565(0) +14: 44145(0) +15: 1(0) +16: 50897(0) +17: 1(0) +18: 52554(0) +19: 52414(0) +20: 58216(0) +21: 53984(0) +22: 1(0) +23: 52562(0) +24: 51803(0) +25: 49248(0) +26: 46962(0) +27: 1(0) +28: 39958(0) +29: 39705(0) +30: 33462(0) +31: 33973(0) +32: 0(0) +33: 41953(0) +34: 1(0) +35: 53352(0) +36: 59436(0) +37: 49614(0) +38: 49859(0) +39: 1(0) +40: 48785(0) +41: 53933(0) +42: 57535(0) +43: 51410(0) +44: 1(0) +45: 46841(0) +46: 52522(0) +47: 57073(0) +48: 53829(0) +49: 47744(0) +50: 42099(0) +51: 1(0) +52: 40383(0) +53: 48436(0) +54: 47226(0) +55: 40515(0) +56: 1(0) +57: 44939(0) +58: 48234(0) +59: 49530(0) +60: 47837(0) +61: 1(0) +62: 40584(0) +63: 52600(0) +64: 1(0) +65: 1(0) +66: 1(0) +67: 1(0) +68: 1(0) +69: 1(0) +70: 1(0) +71: 1(0) +72: 1(0) +73: 1(0) +74: 1(0) +75: 1(0) +76: 1(0) +77: 1(0) +78: 1(0) +79: 1(0) +80: 33375(0) +81: 1(0) +82: 41085(0) +83: 49187(0) +84: 43641(0) +85: 38349(0) +86: 1(0) +87: 50358(0) +88: 1(0) +89: 1(0) +90: 1(0) +91: 1(0) +92: 1(0) +93: 1(0) +94: 1(0) +95: 1(0) +96: 54268(0) +97: 1(0) +98: 46209(0) +99: 43368(0) +100: 41819(0) +101: 44655(0) +102: 1(0) +103: 38976(0) +104: 47924(0) +105: 1(0) +106: 1(0) +107: 1(0) +108: 1(0) +109: 1(0) +110: 1(0) +111: 1(0) +112: 1(0) +113: 1(0) +114: 1(0) +115: 1(0) +116: 1(0) +117: 1(0) +118: 1(0) +119: 1(0) +120: 1(0) +121: 1(0) +122: 1(0) +123: 1(0) +124: 1(0) +125: 1(0) +126: 1(0) +127: 1(0) +128: 440650249(0) +129: 1272933711(0) +130: 2(0) +131: 0(0) +132: 0(0) +133: 0(0) +134: 0(0) +135: 0(0) +136: 54694791(0) +137: 0(0) +138: 0(0) +139: 562703703(0) +140: 195(0) +141: 11401(4) diff --git a/scalers/scalers_run158/solid.30 b/scalers/scalers_run158/solid.30 new file mode 100644 index 0000000..a88da97 --- /dev/null +++ b/scalers/scalers_run158/solid.30 @@ -0,0 +1,144 @@ +Slots: 4 +Clock Channel: 141 +0: 1(0) +1: 58602(0) +2: 53720(0) +3: 43831(0) +4: 48154(0) +5: 1(0) +6: 33127(0) +7: 43566(0) +8: 53129(0) +9: 46399(0) +10: 1(0) +11: 48530(0) +12: 50328(0) +13: 51380(0) +14: 52187(0) +15: 1(0) +16: 60263(0) +17: 1(0) +18: 62152(0) +19: 62200(0) +20: 68677(0) +21: 63629(0) +22: 1(0) +23: 61926(0) +24: 61258(0) +25: 58302(0) +26: 55411(0) +27: 5(0) +28: 47290(0) +29: 46989(0) +30: 39478(0) +31: 40112(0) +32: 0(0) +33: 49582(0) +34: 1(0) +35: 63054(0) +36: 70427(0) +37: 58643(0) +38: 58795(0) +39: 1(0) +40: 57532(0) +41: 63776(0) +42: 68003(0) +43: 60565(0) +44: 1(0) +45: 55394(0) +46: 62053(0) +47: 67527(0) +48: 63619(0) +49: 56274(0) +50: 49635(0) +51: 1(0) +52: 47682(0) +53: 57388(0) +54: 55863(0) +55: 47818(0) +56: 1(0) +57: 53071(0) +58: 57031(0) +59: 58261(0) +60: 56384(0) +61: 1(0) +62: 47894(0) +63: 62049(0) +64: 1(0) +65: 1(0) +66: 1(0) +67: 1(0) +68: 1(0) +69: 1(0) +70: 1(0) +71: 1(0) +72: 1(0) +73: 1(0) +74: 1(0) +75: 1(0) +76: 1(0) +77: 1(0) +78: 1(0) +79: 1(0) +80: 39451(0) +81: 1(0) +82: 48473(0) +83: 58121(0) +84: 51510(0) +85: 45215(0) +86: 1(0) +87: 59438(0) +88: 1(0) +89: 1(0) +90: 1(0) +91: 1(0) +92: 1(0) +93: 1(0) +94: 1(0) +95: 1(0) +96: 64000(0) +97: 1(0) +98: 54666(0) +99: 51149(0) +100: 49230(0) +101: 52735(0) +102: 1(0) +103: 45997(0) +104: 56444(0) +105: 1(0) +106: 1(0) +107: 1(0) +108: 1(0) +109: 1(0) +110: 1(0) +111: 1(0) +112: 1(0) +113: 1(0) +114: 1(0) +115: 1(0) +116: 1(0) +117: 1(0) +118: 1(0) +119: 1(0) +120: 1(0) +121: 1(0) +122: 1(0) +123: 1(0) +124: 1(0) +125: 1(0) +126: 1(0) +127: 1(0) +128: 442474601(0) +129: 1272933711(0) +130: 2(0) +131: 0(0) +132: 0(0) +133: 0(0) +134: 0(0) +135: 0(0) +136: 54694791(0) +137: 0(0) +138: 0(0) +139: 562703703(0) +140: 202(0) +141: 12239(4) diff --git a/scalers/scalers_run158/solidcer.cnf.20200323 b/scalers/scalers_run158/solidcer.cnf.20200323 new file mode 100644 index 0000000..b581234 --- /dev/null +++ b/scalers/scalers_run158/solidcer.cnf.20200323 @@ -0,0 +1,146 @@ +# +# fadc250 config file - example +# +# this file contains settings for +# fADC250 - JLAB VXS Flash ADC 12-bit 250 Msps 16 ch +# +# format: +# ~~~~~~~ +# FADC250_CRATE rocbcal1 <- ROC name, crate name, usually IP name +# FADC250_ALLSLOTS <- just keyword - all settings after this line will be implemented +# for all slots, till FADC250_SLOTS will be met +# FADC250_SLOTS 3 8 15 <- slot_numbers - in which next settings will be implemented +# till file ends or next FADC250_SLOTS will be met +# +# FADC250_F_REV 0x02c1 <- firmware revision (0x0 Bits:7-0) +# FADC250_B_REV 0x0a03 <- board revision (0x0 Bits:15-8) +# FADC250_ID 0xfadc <- board type (0x0 Bits:31-16) +# +# FADC250_MODE 1 <- process mode: 1-4 (0x10C Bits:2-0) +# FADC250_W_OFFSET 50 <- number of ns back from trigger point. (0x120) +# (in Manual it is PL=Trigger_Window(ns) * 250MHz) +# FADC250_W_WIDTH 49 <- number of ns to include in trigger window. (0x11C) +# (in M: PTW=Trigger_Window(ns) * 250MHz, minimum is 6) +# FADC250_NSB 3 <- number of ns before trigger point to include in data processing. (0x124) +# This include the trigger Point. (minimum is 2 samples (8 ns) in all mode) +# FADC250_NSA 6 <- number of ns after trigger point to include in data processing. (0x128) +# Minimum is 6 samples (mode 2) and 3 samples (mode 0 and 1). +# Number of sample report is 1 more for odd and 2 more for even NSA number. +# FADC250_NPEAK 1 <- number of Pulses in Mode 2 and 3. (0x10C Bits:6-5) +# +# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - channels ## +# FADC250_ADC_MASK 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 <- channel enable mask +# +# FADC250_TRG_MASK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 <- trigger enable mask +# +# FADC250_TET 110 <- board Trigger Energy Threshold (TET), same for all 16 channels +# FADC250_CH_TET 0 110 <- channel# and TET_value for this channel +# FADC250_ALLCH_TET 111 222 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <- 16 TETs (0x12C - 0x148) +# +# FADC250_DAC 3300 <- board DAC, one and the same for all 16 channels +# FADC250_CH_DAC 0 3300 <- channel# and DAC_value for this channel +# FADC250_ALLCH_DAC 3300 3280 3310 3280 3310 3280 3310 3280 3300 3280 3300 3280 3310 3280 3310 3280 <- 16 DACs +# +# FADC250_PED 210 <- board Pedestals, same for all channels +# FADC250_CH_PED 0 210 <- channel# and Pedestal_value for this channel +# FADC250_ALLCH_PED 210 220 210 215 215 220 220 210 210 215 215 220 220 210 215 220 <- 16 PEDs +# +# FADC250_GAIN 210 <- board Gains, same for all channels +# FADC250_CH_GAIN 0 210 <- channel# and Gain_value for this channel +# FADC250_ALLCH_GAIN 210 220 210 215 215 220 220 210 210 215 215 220 220 210 215 220 <- 16 GAINs +# FADC250_TRG_MODE_MASK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <- 0=normal pulse trigger mode, 1=discriminator mode +# FADC250_TET_IGNORE_MASK 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +# setting 1: always readout channel (threshold only applies to trigger path) +# setting 0: only readout when TET is reached + +FADC250_CRATE all + +FADC250_SLOT all + +FADC250_DAC 3100 +FADC250_W_OFFSET 3680 +FADC250_W_WIDTH 200 + +#raw mode +FADC250_MODE 1 +FADC250_NPEAK 3 + +FADC250_NSB 20 +FADC250_NSA 100 + +# channel: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +FADC250_ADC_MASK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +FADC250_TRG_MASK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + +FADC250_GAIN 1.0 +FADC250_TET 20 + +# channel: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +FADC250_SLOT 3 +FADC250_INVERT_MASK 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 +FADC250_ALLCH_DAC 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 300 300 3100 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 4 +FADC250_INVERT_MASK 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 +FADC250_ALLCH_DAC 300 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 300 300 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 5 +FADC250_INVERT_MASK 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 +FADC250_ALLCH_DAC 300 300 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 300 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 6 +FADC250_INVERT_MASK 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 +FADC250_ALLCH_DAC 300 300 300 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 7 +FADC250_INVERT_MASK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +FADC250_ALLCH_DAC 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 +FADC250_ALLCH_TET 150 150 150 150 150 150 150 150 100 100 100 100 100 100 100 100 + +FADC250_SLOT 8 +FADC250_INVERT_MASK 1 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 +FADC250_ALLCH_DAC 300 3100 300 300 300 300 3100 300 3100 3100 3100 3100 3100 3100 3100 3100 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 150 150 150 150 150 150 150 150 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 40 40 40 40 40 40 40 40 + +FADC250_SLOT 9 +FADC250_INVERT_MASK 1 0 1 1 1 1 0 1 1 1 0 0 0 0 0 0 +FADC250_ALLCH_DAC 300 3100 300 300 300 300 3100 300 300 300 3100 3100 3100 3100 3100 3100 +#FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 120 120 120 120 120 120 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 200 200 200 200 200 200 + + +FADC250_SLOT 10 +FADC250_INVERT_MASK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +FADC250_ALLCH_DAC 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 +#FADC250_ALLCH_TET 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 +FADC250_ALLCH_TET 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 + + +FADC250_SLOT 3 +FADC250_ALLCH_PED 158.589 175.627 192.295 225.772 220.640 162.266 213.348 193.050 192.393 201.376 158.962 218.705 178.638 184.968 199.701 136.195 +FADC250_SLOT 4 +FADC250_ALLCH_PED 188.784 142.948 199.310 209.346 239.665 209.279 170.830 212.802 197.626 219.343 204.576 162.422 187.781 169.509 198.156 188.256 +FADC250_SLOT 5 +FADC250_ALLCH_PED 4095.000 187.532 128.578 197.484 208.710 210.179 202.816 145.931 180.070 184.371 190.519 214.126 145.376 190.283 213.879 226.554 +FADC250_SLOT 6 +FADC250_ALLCH_PED 201.886 207.383 205.968 155.402 198.695 211.778 192.218 192.630 151.976 228.621 242.654 215.899 229.321 154.001 206.512 233.111 +FADC250_SLOT 7 +FADC250_ALLCH_PED 490.724 454.406 451.599 483.905 480.858 473.400 493.646 479.955 455.427 496.947 478.708 508.040 449.487 506.953 455.700 493.099 +FADC250_SLOT 8 +FADC250_ALLCH_PED 226.446 146.415 241.116 219.924 197.915 209.639 129.521 209.184 463.004 493.023 464.406 459.854 410.840 471.335 453.408 480.788 +FADC250_SLOT 9 +FADC250_ALLCH_PED 183.940 140.231 218.352 184.903 209.842 205.076 125.469 198.391 234.129 198.131 344.913 368.231 361.869 340.051 315.956 315.940 +FADC250_SLOT 10 +FADC250_ALLCH_PED 369.854 323.637 345.462 341.254 332.602 344.053 332.267 380.828 338.170 311.598 360.776 335.915 355.254 336.429 358.864 346.114 + +FADC250_CRATE end + diff --git a/scalers/scalers_run160/solid.0 b/scalers/scalers_run160/solid.0 new file mode 100644 index 0000000..2aac32c --- /dev/null +++ b/scalers/scalers_run160/solid.0 @@ -0,0 +1,144 @@ +Slots: 4 +Clock Channel: 141 +0: 41949161(0) +1: 11439603(0) +2: 11138251(0) +3: 11310705(0) +4: 11653817(0) +5: 39779784(0) +6: 10157215(0) +7: 10195276(0) +8: 11964776(0) +9: 12773338(0) +10: 39715205(0) +11: 14955656(0) +12: 12253531(0) +13: 15252204(0) +14: 20965691(0) +15: 56691834(0) +16: 12294157(0) +17: 41296280(0) +18: 13272948(0) +19: 12725835(0) +20: 13150011(0) +21: 13527244(0) +22: 46116686(0) +23: 12310520(0) +24: 12811604(0) +25: 12457215(0) +26: 11639013(0) +27: 43433398(0) +28: 11633306(0) +29: 11846539(0) +30: 12106341(0) +31: 11823087(0) +32: 1(0) +33: 10333015(0) +34: 38050811(0) +35: 10437117(0) +36: 11886508(0) +37: 11638314(0) +38: 9991133(0) +39: 37836533(0) +40: 12750234(0) +41: 13727559(0) +42: 13658909(0) +43: 12522909(0) +44: 45626311(0) +45: 11125093(0) +46: 11634212(0) +47: 12315634(0) +48: 12115950(0) +49: 11976435(0) +50: 12386943(0) +51: 43290788(0) +52: 12273644(0) +53: 12510001(0) +54: 12244586(0) +55: 12281198(0) +56: 43337053(0) +57: 11463740(0) +58: 11864875(0) +59: 12145374(0) +60: 12160928(0) +61: 41441844(0) +62: 10680429(0) +63: 11419423(0) +64: 60196(0) +65: 50807(0) +66: 21257(0) +67: 46063(0) +68: 47114(0) +69: 4570388(0) +70: 24399(0) +71: 27470(0) +72: 410866(0) +73: 183299(0) +74: 500548(0) +75: 441452(0) +76: 1872974(0) +77: 1362722(0) +78: 1993011(0) +79: 2034310(0) +80: 10927744(0) +81: 36541001(0) +82: 9348535(0) +83: 9846861(0) +84: 9759575(0) +85: 9497051(0) +86: 32806847(0) +87: 13946885(0) +88: 26381(0) +89: 20(0) +90: 117351(0) +91: 101796(0) +92: 91950(0) +93: 41245(0) +94: 53553(0) +95: 118795(0) +96: 11095957(0) +97: 0(0) +98: 12903677(0) +99: 11473238(0) +100: 12402693(0) +101: 14703900(0) +102: 45523740(0) +103: 10295489(0) +104: 10670073(0) +105: 72301(0) +106: 98308530(0) +107: 135896309(0) +108: 49696872(0) +109: 126573349(0) +110: 130075258(0) +111: 115487953(0) +112: 84232203(0) +113: 57561941(0) +114: 58593722(0) +115: 118023249(0) +116: 86166577(0) +117: 249890202(0) +118: 488217717(0) +119: 928245592(0) +120: 309949400(0) +121: 910081036(0) +122: 368042417(0) +123: 632167393(0) +124: 601558966(0) +125: 776423186(0) +126: 642190724(0) +127: 807362612(0) +128: 908494338(0) +129: 177934225(0) +130: 570575(0) +131: 0(0) +132: 0(0) +133: 0(0) +134: 0(0) +135: 0(0) +136: 7644248(0) +137: 0(0) +138: 0(0) +139: 89761593(0) +140: 462(0) +141: 15600(6) diff --git a/scalers/scalers_run160/solid.15 b/scalers/scalers_run160/solid.15 new file mode 100644 index 0000000..2aac32c --- /dev/null +++ b/scalers/scalers_run160/solid.15 @@ -0,0 +1,144 @@ +Slots: 4 +Clock Channel: 141 +0: 41949161(0) +1: 11439603(0) +2: 11138251(0) +3: 11310705(0) +4: 11653817(0) +5: 39779784(0) +6: 10157215(0) +7: 10195276(0) +8: 11964776(0) +9: 12773338(0) +10: 39715205(0) +11: 14955656(0) +12: 12253531(0) +13: 15252204(0) +14: 20965691(0) +15: 56691834(0) +16: 12294157(0) +17: 41296280(0) +18: 13272948(0) +19: 12725835(0) +20: 13150011(0) +21: 13527244(0) +22: 46116686(0) +23: 12310520(0) +24: 12811604(0) +25: 12457215(0) +26: 11639013(0) +27: 43433398(0) +28: 11633306(0) +29: 11846539(0) +30: 12106341(0) +31: 11823087(0) +32: 1(0) +33: 10333015(0) +34: 38050811(0) +35: 10437117(0) +36: 11886508(0) +37: 11638314(0) +38: 9991133(0) +39: 37836533(0) +40: 12750234(0) +41: 13727559(0) +42: 13658909(0) +43: 12522909(0) +44: 45626311(0) +45: 11125093(0) +46: 11634212(0) +47: 12315634(0) +48: 12115950(0) +49: 11976435(0) +50: 12386943(0) +51: 43290788(0) +52: 12273644(0) +53: 12510001(0) +54: 12244586(0) +55: 12281198(0) +56: 43337053(0) +57: 11463740(0) +58: 11864875(0) +59: 12145374(0) +60: 12160928(0) +61: 41441844(0) +62: 10680429(0) +63: 11419423(0) +64: 60196(0) +65: 50807(0) +66: 21257(0) +67: 46063(0) +68: 47114(0) +69: 4570388(0) +70: 24399(0) +71: 27470(0) +72: 410866(0) +73: 183299(0) +74: 500548(0) +75: 441452(0) +76: 1872974(0) +77: 1362722(0) +78: 1993011(0) +79: 2034310(0) +80: 10927744(0) +81: 36541001(0) +82: 9348535(0) +83: 9846861(0) +84: 9759575(0) +85: 9497051(0) +86: 32806847(0) +87: 13946885(0) +88: 26381(0) +89: 20(0) +90: 117351(0) +91: 101796(0) +92: 91950(0) +93: 41245(0) +94: 53553(0) +95: 118795(0) +96: 11095957(0) +97: 0(0) +98: 12903677(0) +99: 11473238(0) +100: 12402693(0) +101: 14703900(0) +102: 45523740(0) +103: 10295489(0) +104: 10670073(0) +105: 72301(0) +106: 98308530(0) +107: 135896309(0) +108: 49696872(0) +109: 126573349(0) +110: 130075258(0) +111: 115487953(0) +112: 84232203(0) +113: 57561941(0) +114: 58593722(0) +115: 118023249(0) +116: 86166577(0) +117: 249890202(0) +118: 488217717(0) +119: 928245592(0) +120: 309949400(0) +121: 910081036(0) +122: 368042417(0) +123: 632167393(0) +124: 601558966(0) +125: 776423186(0) +126: 642190724(0) +127: 807362612(0) +128: 908494338(0) +129: 177934225(0) +130: 570575(0) +131: 0(0) +132: 0(0) +133: 0(0) +134: 0(0) +135: 0(0) +136: 7644248(0) +137: 0(0) +138: 0(0) +139: 89761593(0) +140: 462(0) +141: 15600(6) diff --git a/scalers/scalers_run160/solid.30 b/scalers/scalers_run160/solid.30 new file mode 100644 index 0000000..377815b --- /dev/null +++ b/scalers/scalers_run160/solid.30 @@ -0,0 +1,144 @@ +Slots: 4 +Clock Channel: 141 +0: 47313312(0) +1: 12876723(0) +2: 12553309(0) +3: 12730924(0) +4: 13085149(0) +5: 44730328(0) +6: 11378704(0) +7: 11459547(0) +8: 13385770(0) +9: 14223257(0) +10: 44399045(0) +11: 16513568(0) +12: 13655777(0) +13: 16876453(0) +14: 22938398(0) +15: 62452438(0) +16: 13863855(0) +17: 46549305(0) +18: 14932815(0) +19: 14346045(0) +20: 14824457(0) +21: 15217385(0) +22: 51896969(0) +23: 13890364(0) +24: 14464761(0) +25: 14056100(0) +26: 13128477(0) +27: 48986818(0) +28: 13131727(0) +29: 13378963(0) +30: 13657395(0) +31: 13335499(0) +32: 1(0) +33: 11668270(0) +34: 42935535(0) +35: 11789087(0) +36: 13427564(0) +37: 13142105(0) +38: 11277350(0) +39: 42707611(0) +40: 14395708(0) +41: 15492010(0) +42: 15413001(0) +43: 14129771(0) +44: 51463642(0) +45: 12548554(0) +46: 13123658(0) +47: 13892088(0) +48: 13650350(0) +49: 13472110(0) +50: 13890025(0) +51: 48624960(0) +52: 13816810(0) +53: 14093597(0) +54: 13797056(0) +55: 13797964(0) +56: 48752264(0) +57: 12932586(0) +58: 13385773(0) +59: 13702185(0) +60: 13716900(0) +61: 46724892(0) +62: 12060217(0) +63: 12888126(0) +64: 68548(0) +65: 57472(0) +66: 24097(0) +67: 52213(0) +68: 53280(0) +69: 5182551(0) +70: 27643(0) +71: 30798(0) +72: 465011(0) +73: 207164(0) +74: 567110(0) +75: 499532(0) +76: 2123002(0) +77: 1541401(0) +78: 2256858(0) +79: 2303766(0) +80: 12269397(0) +81: 41077384(0) +82: 10546414(0) +83: 11103010(0) +84: 10994664(0) +85: 10690234(0) +86: 36954269(0) +87: 15666860(0) +88: 29905(0) +89: 21(0) +90: 132752(0) +91: 115507(0) +92: 103926(0) +93: 46665(0) +94: 60543(0) +95: 135262(0) +96: 12523836(0) +97: 0(0) +98: 14411970(0) +99: 12889109(0) +100: 13895376(0) +101: 16333355(0) +102: 50810841(0) +103: 11583569(0) +104: 12021459(0) +105: 81647(0) +106: 111805427(0) +107: 154456531(0) +108: 56340556(0) +109: 143709639(0) +110: 148135278(0) +111: 131070533(0) +112: 95572548(0) +113: 65299281(0) +114: 66436467(0) +115: 134290203(0) +116: 97780350(0) +117: 250669889(0) +118: 499298590(0) +119: 1007108238(0) +120: 310460091(0) +121: 983848630(0) +122: 372471653(0) +123: 659265080(0) +124: 617084765(0) +125: 816793912(0) +126: 665063363(0) +127: 851173466(0) +128: 908494338(0) +129: 177934225(0) +130: 665510(0) +131: 0(0) +132: 0(0) +133: 0(0) +134: 0(0) +135: 0(0) +136: 7644248(0) +137: 0(0) +138: 0(0) +139: 89856528(0) +140: 470(0) +141: 16561(6) diff --git a/scalers/scalers_run160/solidcer.cnf.20200323 b/scalers/scalers_run160/solidcer.cnf.20200323 new file mode 100644 index 0000000..b581234 --- /dev/null +++ b/scalers/scalers_run160/solidcer.cnf.20200323 @@ -0,0 +1,146 @@ +# +# fadc250 config file - example +# +# this file contains settings for +# fADC250 - JLAB VXS Flash ADC 12-bit 250 Msps 16 ch +# +# format: +# ~~~~~~~ +# FADC250_CRATE rocbcal1 <- ROC name, crate name, usually IP name +# FADC250_ALLSLOTS <- just keyword - all settings after this line will be implemented +# for all slots, till FADC250_SLOTS will be met +# FADC250_SLOTS 3 8 15 <- slot_numbers - in which next settings will be implemented +# till file ends or next FADC250_SLOTS will be met +# +# FADC250_F_REV 0x02c1 <- firmware revision (0x0 Bits:7-0) +# FADC250_B_REV 0x0a03 <- board revision (0x0 Bits:15-8) +# FADC250_ID 0xfadc <- board type (0x0 Bits:31-16) +# +# FADC250_MODE 1 <- process mode: 1-4 (0x10C Bits:2-0) +# FADC250_W_OFFSET 50 <- number of ns back from trigger point. (0x120) +# (in Manual it is PL=Trigger_Window(ns) * 250MHz) +# FADC250_W_WIDTH 49 <- number of ns to include in trigger window. (0x11C) +# (in M: PTW=Trigger_Window(ns) * 250MHz, minimum is 6) +# FADC250_NSB 3 <- number of ns before trigger point to include in data processing. (0x124) +# This include the trigger Point. (minimum is 2 samples (8 ns) in all mode) +# FADC250_NSA 6 <- number of ns after trigger point to include in data processing. (0x128) +# Minimum is 6 samples (mode 2) and 3 samples (mode 0 and 1). +# Number of sample report is 1 more for odd and 2 more for even NSA number. +# FADC250_NPEAK 1 <- number of Pulses in Mode 2 and 3. (0x10C Bits:6-5) +# +# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - channels ## +# FADC250_ADC_MASK 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 <- channel enable mask +# +# FADC250_TRG_MASK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 <- trigger enable mask +# +# FADC250_TET 110 <- board Trigger Energy Threshold (TET), same for all 16 channels +# FADC250_CH_TET 0 110 <- channel# and TET_value for this channel +# FADC250_ALLCH_TET 111 222 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <- 16 TETs (0x12C - 0x148) +# +# FADC250_DAC 3300 <- board DAC, one and the same for all 16 channels +# FADC250_CH_DAC 0 3300 <- channel# and DAC_value for this channel +# FADC250_ALLCH_DAC 3300 3280 3310 3280 3310 3280 3310 3280 3300 3280 3300 3280 3310 3280 3310 3280 <- 16 DACs +# +# FADC250_PED 210 <- board Pedestals, same for all channels +# FADC250_CH_PED 0 210 <- channel# and Pedestal_value for this channel +# FADC250_ALLCH_PED 210 220 210 215 215 220 220 210 210 215 215 220 220 210 215 220 <- 16 PEDs +# +# FADC250_GAIN 210 <- board Gains, same for all channels +# FADC250_CH_GAIN 0 210 <- channel# and Gain_value for this channel +# FADC250_ALLCH_GAIN 210 220 210 215 215 220 220 210 210 215 215 220 220 210 215 220 <- 16 GAINs +# FADC250_TRG_MODE_MASK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <- 0=normal pulse trigger mode, 1=discriminator mode +# FADC250_TET_IGNORE_MASK 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +# setting 1: always readout channel (threshold only applies to trigger path) +# setting 0: only readout when TET is reached + +FADC250_CRATE all + +FADC250_SLOT all + +FADC250_DAC 3100 +FADC250_W_OFFSET 3680 +FADC250_W_WIDTH 200 + +#raw mode +FADC250_MODE 1 +FADC250_NPEAK 3 + +FADC250_NSB 20 +FADC250_NSA 100 + +# channel: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +FADC250_ADC_MASK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +FADC250_TRG_MASK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + +FADC250_GAIN 1.0 +FADC250_TET 20 + +# channel: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +FADC250_SLOT 3 +FADC250_INVERT_MASK 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 +FADC250_ALLCH_DAC 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 300 300 3100 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 4 +FADC250_INVERT_MASK 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 +FADC250_ALLCH_DAC 300 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 300 300 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 5 +FADC250_INVERT_MASK 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 +FADC250_ALLCH_DAC 300 300 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 300 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 6 +FADC250_INVERT_MASK 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 +FADC250_ALLCH_DAC 300 300 300 3100 300 300 300 300 3100 300 300 300 300 3100 300 300 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + +FADC250_SLOT 7 +FADC250_INVERT_MASK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +FADC250_ALLCH_DAC 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 +FADC250_ALLCH_TET 150 150 150 150 150 150 150 150 100 100 100 100 100 100 100 100 + +FADC250_SLOT 8 +FADC250_INVERT_MASK 1 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 +FADC250_ALLCH_DAC 300 3100 300 300 300 300 3100 300 3100 3100 3100 3100 3100 3100 3100 3100 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 150 150 150 150 150 150 150 150 +#FADC250_ALLCH_TET 100 100 100 100 100 100 100 100 40 40 40 40 40 40 40 40 + +FADC250_SLOT 9 +FADC250_INVERT_MASK 1 0 1 1 1 1 0 1 1 1 0 0 0 0 0 0 +FADC250_ALLCH_DAC 300 3100 300 300 300 300 3100 300 300 300 3100 3100 3100 3100 3100 3100 +#FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 120 120 120 120 120 120 +FADC250_ALLCH_TET 20 20 20 20 20 20 20 20 20 20 200 200 200 200 200 200 + + +FADC250_SLOT 10 +FADC250_INVERT_MASK 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +FADC250_ALLCH_DAC 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 3100 +#FADC250_ALLCH_TET 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 120 +FADC250_ALLCH_TET 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 + + +FADC250_SLOT 3 +FADC250_ALLCH_PED 158.589 175.627 192.295 225.772 220.640 162.266 213.348 193.050 192.393 201.376 158.962 218.705 178.638 184.968 199.701 136.195 +FADC250_SLOT 4 +FADC250_ALLCH_PED 188.784 142.948 199.310 209.346 239.665 209.279 170.830 212.802 197.626 219.343 204.576 162.422 187.781 169.509 198.156 188.256 +FADC250_SLOT 5 +FADC250_ALLCH_PED 4095.000 187.532 128.578 197.484 208.710 210.179 202.816 145.931 180.070 184.371 190.519 214.126 145.376 190.283 213.879 226.554 +FADC250_SLOT 6 +FADC250_ALLCH_PED 201.886 207.383 205.968 155.402 198.695 211.778 192.218 192.630 151.976 228.621 242.654 215.899 229.321 154.001 206.512 233.111 +FADC250_SLOT 7 +FADC250_ALLCH_PED 490.724 454.406 451.599 483.905 480.858 473.400 493.646 479.955 455.427 496.947 478.708 508.040 449.487 506.953 455.700 493.099 +FADC250_SLOT 8 +FADC250_ALLCH_PED 226.446 146.415 241.116 219.924 197.915 209.639 129.521 209.184 463.004 493.023 464.406 459.854 410.840 471.335 453.408 480.788 +FADC250_SLOT 9 +FADC250_ALLCH_PED 183.940 140.231 218.352 184.903 209.842 205.076 125.469 198.391 234.129 198.131 344.913 368.231 361.869 340.051 315.956 315.940 +FADC250_SLOT 10 +FADC250_ALLCH_PED 369.854 323.637 345.462 341.254 332.602 344.053 332.267 380.828 338.170 311.598 360.776 335.915 355.254 336.429 358.864 346.114 + +FADC250_CRATE end + diff --git a/scripts/analyze_waveform.py b/scripts/analyze_waveform.py index d2e7b2e..42557d5 100644 --- a/scripts/analyze_waveform.py +++ b/scripts/analyze_waveform.py @@ -21,13 +21,12 @@ def get_maximum_peaks(tree, chan_pos, ref_pos=0.): for i, (c, twin) in enumerate(chan_pos.items()): cpeaks = branch_to_array1d(tree.__getattr__(c + '_Ppeak'), np.float32) - cposes = branch_to_array1d(tree.__getattr__(c + '_Ptime'), np.float32) - ref_pos - # find maximum peak inside window - mask = (cposes <= twin[1]) & (cposes >= twin[0]) - cpeaks = cpeaks[mask] - cposes = cposes[mask] + cposes = branch_to_array1d(tree.__getattr__(c + '_Ptime'), np.float32) if not len(cpeaks): continue + # find maximum peak inside window + mask = (cposes <= (twin[1] + ref_pos)) & (cposes >= (twin[0] + ref_pos)) + cpeaks[~mask] = 0. idx = np.argmax(cpeaks) if cpeaks[idx] > 1e-5: peaks[i] = cpeaks[idx] @@ -41,14 +40,11 @@ parser.add_argument('root_file', help='a root file of waveform data') parser.add_argument('output', help='path to the output csv file') parser.add_argument('-n', '--number-events', type=int, default=0, dest='nev', help='number of events to process, <= 0 means all') -parser.add_argument('--timing-config', type=str, default='config/json/esb_timing.json', dest='tconfig', +parser.add_argument('--config-timing', type=str, default='database/esb_timing.json', dest='tconfig', help='path to the json file for channel timings') args = parser.parse_args() -figsize = (16, 16) -nrows, ncols = 4, 4 - dbf = open(args.tconfig) ch_pos = json.load(dbf) diff --git a/scripts/analyze_waveform_first.py b/scripts/analyze_waveform_first.py new file mode 100644 index 0000000..872702a --- /dev/null +++ b/scripts/analyze_waveform_first.py @@ -0,0 +1,101 @@ +""" +For the first Cherenkov Prototype Test (16 PMT quadrants, data recorded in evio 3) +""" +import ROOT +import os +import json +import numpy as np +import pandas as pd +import argparse +from collections import OrderedDict +from matplotlib import pyplot as plt +from scipy import signal +from collections.abc import Iterable + + +def branch_to_array1d(br, t): + return np.ndarray((len(br), ), dtype=t, buffer=br) + + +def get_maximum_peaks(tree, chan_pos, ref_pos=0.): + # init + peaks = np.zeros(len(chan_pos), dtype=np.float32) + poses = np.zeros(len(chan_pos), dtype=np.float32) + + for i, (c, twin) in enumerate(chan_pos.items()): + cpeaks = branch_to_array1d(tree.__getattr__(c + '_Ppeak'), np.float32) + cposes = branch_to_array1d(tree.__getattr__(c + '_Ptime'), np.float32) + if not len(cpeaks): + continue + # find maximum peak inside window + mask = (cposes <= (twin[1] + ref_pos)) & (cposes >= (twin[0] + ref_pos)) + cpeaks[~mask] = 0. + idx = np.argmax(cpeaks) + if cpeaks[idx] > 1e-5: + peaks[i] = cpeaks[idx] + poses[i] = cposes[idx] + return peaks, poses + + +parser = argparse.ArgumentParser('Raw waveform analysis') + +parser.add_argument('root_file', help='a root file of waveform data') +parser.add_argument('output', help='path to the output csv file') +parser.add_argument('-n', '--number-events', type=int, default=0, dest='nev', + help='number of events to process, <= 0 means all') +parser.add_argument('--config-timing', type=str, default='database/fadc_459_pos_cut.json', dest='tconfig', + help='path to the json file for channel timings') + +args = parser.parse_args() + +dbf = open(args.tconfig) +ch_pos = json.load(dbf) +ch_pos.update({ + 'LED': (-192, 192), 'Ref': (-192, 192), 'ScintLL': (-192, 192), 'ScintLR': (-192, 192), +}) + +# trigger channels +# calorimeter +ec_ch = ['CaloSum'] +ec_pos = OrderedDict([(ch, (15, 35)) for ch in ec_ch]) + +f = ROOT.TFile.Open(args.root_file, 'read') +tree = f.EvTree +nev = tree.GetEntries() +if args.nev > 0 and args.nev <= nev: + nev = args.nev + +# init buffers +trg_cols = ['peak', 'pos', 'nhits', 'sum'] +ec_names = np.ndarray(shape=(nev, ), dtype=object) +ec_vals = np.zeros(shape=(nev, len(trg_cols)), dtype=np.float32) +ch_vals = np.zeros(shape=(nev, len(ch_pos)*2), dtype=np.float32) + +count = 0 +for iev in np.arange(0, nev): + tree.GetEntry(iev) + if iev % 1000 == 0: + print('processed {}, {} good events'.format(iev, count), end='\r') + + count += 1 + ec_peaks, ec_poses = get_maximum_peaks(tree, ec_pos) + + # save result to buffer, EC + iec = np.argmax(ec_peaks) + ec_names[iev] = list(ec_pos)[iec] + ec_vals[iev] = (ec_peaks[iec], ec_poses[iec], np.sum(ec_peaks > 0), np.sum(ec_peaks)) + ref = ec_poses[0] + + # CHER + ch_peaks, ch_poses = get_maximum_peaks(tree, ch_pos, ref) + ch_vals[iev] = np.concatenate([ch_peaks, ch_poses]) + +print('processed {}'.format(iev)) + +cols = ['ec_' + col for col in trg_cols] \ + + [c + '_peak' for c, _ in ch_pos.items()] + [c + '_pos' for c, _ in ch_pos.items()] +result = pd.DataFrame(index=np.arange(nev), columns=cols, + data=np.concatenate((ec_vals, ch_vals), axis=1)) +result.loc[:, 'ec_ch'] = ec_names +result.to_csv(args.output) + diff --git a/scripts/analyze_waveform_max.py b/scripts/analyze_waveform_max.py new file mode 100644 index 0000000..dd1c134 --- /dev/null +++ b/scripts/analyze_waveform_max.py @@ -0,0 +1,80 @@ +import ROOT +import os +import json +import numpy as np +import pandas as pd +import argparse +from collections import OrderedDict +from matplotlib import pyplot as plt +from scipy import signal +from collections.abc import Iterable + + +def branch_to_array1d(br, t): + return np.ndarray((len(br), ), dtype=t, buffer=br) + + +def get_maximum_peaks(tree, chan): + # init + peaks = np.zeros(len(chan), dtype=np.float32) + poses = np.zeros(len(chan), dtype=np.float32) + + for i, c in enumerate(chan): + cpeaks = branch_to_array1d(tree.__getattr__(c + '_Ppeak'), np.float32) + cposes = branch_to_array1d(tree.__getattr__(c + '_Ptime'), np.float32) + # find maximum peak inside window + if not len(cpeaks): + continue + idx = np.argmax(cpeaks) + if cpeaks[idx] > 1e-5: + peaks[i] = cpeaks[idx] + poses[i] = cposes[idx] + return peaks, poses + + +def get_channels(json_path): + dbf = open(json_path) + db = json.load(dbf) + channels = dict() + for mod, mod_prop in db.items(): + for ch in mod_prop['channels']: + channels[ch['name']] = ch['type'] + return channels + + +parser = argparse.ArgumentParser('Raw waveform analysis') + +parser.add_argument('root_file', help='a root file of waveform data') +parser.add_argument('output', help='path to the output csv file') +parser.add_argument('--config-module', type=str, default='config/json/esb_module.json', dest='mconfig', + help='path to the json file for module configuration') +parser.add_argument('-n', '--number-events', type=int, default=0, dest='nev', + help='number of events to process, <= 0 means all') + +args = parser.parse_args() + +channels = get_channels(args.mconfig) + +f = ROOT.TFile.Open(args.root_file, 'read') +tree = f.EvTree +nev = tree.GetEntries() +if args.nev > 0 and args.nev <= nev: + nev = args.nev + +# init buffers +ch_vals = np.zeros(shape=(nev, len(channels)*2), dtype=np.float32) + +for iev in np.arange(0, nev): + tree.GetEntry(iev) + if iev % 1000 == 0: + print('processed {}'.format(iev), end='\r') + # CHER + ch_peaks, ch_poses = get_maximum_peaks(tree, channels) + ch_vals[iev] = np.concatenate([ch_peaks, ch_poses]) + +print('processed {}'.format(iev)) + +cols = [c + '_peak' for c in channels] + [c + '_pos' for c in channels] +result = pd.DataFrame(index=np.arange(nev), columns=cols, data=ch_vals) +result.to_csv(args.output) + diff --git a/scripts/analyze_waveform_time.py b/scripts/analyze_waveform_time.py deleted file mode 100644 index f179ea9..0000000 --- a/scripts/analyze_waveform_time.py +++ /dev/null @@ -1,141 +0,0 @@ -import ROOT -import os -import json -import numpy as np -import pandas as pd -import argparse -from matplotlib import pyplot as plt -from scipy import signal -from collections.abc import Iterable - - -def branch_to_array1d(br, t): - return np.ndarray((len(br), ), dtype=t, buffer=br) - - -def get_channels(json_path): - dbf = open(json_path) - db = json.load(dbf) - channels = dict() - for mod, mod_prop in db.items(): - for ch in mod_prop['channels']: - channels[ch['name']] = ch['type'] - return channels - - -parser = argparse.ArgumentParser('Raw waveform analysis') - -parser.add_argument('root_file', help='a root file of waveform data') -parser.add_argument('output_dir', help='output directory') -parser.add_argument('--prefix', dest='prefix', help='prefix for the output files', default='') -parser.add_argument('--peak-thres', dest='pthres', help='sigma threshold for finding the peak, default 8', type=float, default=8) -parser.add_argument('--peak-min', dest='pmin', help='lower limit of the peak adc value, default 10', type=int, default=10) -parser.add_argument('--peak-max', dest='pmax', help='upper limit of the peak adc value, default 8000', type=int, default=8000) -parser.add_argument('--time-min', dest='tmin', help='lower limit of the time window, default 0', type=int, default=0) -parser.add_argument('--time-max', dest='tmax', help='upper limit of the time window, default 63', type=int, default=63) - -args = parser.parse_args() - -# figsize = (24, 16) -# nrows, ncols = 3, 4 -# ch = [ -# 'S2_1', 'S2_2', 'S2_3', 'S2_4', -# 'S2_5', 'S2_6', 'S2_7', 'S2_8', -# 'S2_9', 'S2_10', 'S2_11', -# ] - -# figsize = (16, 16) -# nrows, ncols = 3, 3 -# ch = [ -# 'C4', 'C6_4', 'C7_4', -# 'C5_4', 'C9_4', 'C8_4', -# 'C1', 'C2', 'C3', -# ] - -figsize = (16, 16) -nrows, ncols = 4, 4 -ch = [ - 'Cer11_5', 'Cer12_5', 'Cer13_5', 'Cer14_5', - 'Cer21_5', 'Cer22_5', 'Cer23_5', 'Cer24_5', - 'Cer31_5', 'Cer32_5', 'Cer33_5', 'Cer34_5', - 'Cer41_5', 'Cer42_5', 'Cer43_5', 'Cer44_5', -] - -ch_pos = [ - (20, 30), (20, 30), (20, 30), (20, 30), - (25, 35), (25, 35), (25, 35), (23, 33), - (23, 33), (23, 33), (23, 33), (23, 33), - (20, 30), (20, 30), (15, 25), (25, 35), -] - -f = ROOT.TFile.Open(args.root_file, 'read') -tree = f.EvTree - -props = {c: [np.array([]), np.array([])] for c in ch} -cher_sums = pd.DataFrame(index=np.arange(0, tree.GetEntries()), columns=['sum', 'nhits'], dtype=('float64', 'int64')) - -for iev in np.arange(0, tree.GetEntries()): - tree.GetEntry(iev) - if iev > 1000: - break - if iev % 1000 == 0: - print('processed {}'.format(iev), end='\r') - - csum = 0 - cnhits = 0 - # channels - evpeaks, evposes = [], [] - for p, (c, prop) in zip(ch_pos, props.items()): - epeak, epos = 0, 0 - peaks = branch_to_array1d(tree.__getattr__(c + '_Ppeak'), np.float32) - poses = branch_to_array1d(tree.__getattr__(c + '_Ptime'), np.float32) - for pos, peak in zip(poses, peaks): - if pos <= p[1] and pos >= p[0] and peak > epeak: - epeak = peak - epos = pos - - if epeak >= 1: - cnhits += 1 - csum += epeak - prop[0] = np.append(prop[0], epeak) - prop[1] = np.append(prop[1], epos) - - cher_sums.loc[iev] = (csum, cnhits) -print('processed {}'.format(iev)) - - -bins = np.arange(0, 5000, step=1) -indices = (bins[1:] + bins[:-1])/2. -peaks = pd.DataFrame(index=indices, data={c: np.histogram(prop[0], bins)[0] for c, prop in props.items()}) - -bins = np.arange(0, 64, step=1) -indices = (bins[1:] + bins[:-1])/2. -poses = pd.DataFrame(index=indices, data={c: np.histogram(prop[1], bins)[0] for c, prop in props.items()}) - - -# plot -def plot_hist(df, ny, nx, x_label, y_label, fs=(16, 16), fontsize=18): - box = dict(boxstyle='round', facecolor='wheat', alpha=0.3) - fig, axs = plt.subplots(ny, nx, figsize=fs) - for i, ax in enumerate(axs.flat): - if i >= len(df.columns): - continue - ax.text(0.75, 0.90, df.columns[i], transform=ax.transAxes, fontsize=fontsize - 4, verticalalignment='top', bbox=box) - ax.bar(df.index.values, df.iloc[:, i].values, width=pd.Series(data=df.index).diff(1).mean()) - # ax.patch.set_facecolor('wheat') - # ax.patch.set_alpha(0.05) - # ax.set_yscale('log') - fig.tight_layout(rect=(0.03, 0.05, 0.98, 0.95)) - fig.text(0.5, 0.02, x_label, ha='center', fontsize=fontsize) - fig.text(0.02, 0.5, y_label, ha='center', rotation=90, fontsize=fontsize) - return fig - - -plot_hist(peaks, nrows, ncols, 'ADC Value', 'Counts', figsize).savefig(os.path.join(args.output_dir, args.prefix + 'peaks.png')) -plot_hist(poses, nrows, ncols, 'Sample Number', 'Counts', figsize).savefig(os.path.join(args.output_dir, args.prefix + 'timings.png')) - -peaks.to_csv(os.path.join(args.output_dir, args.prefix + 'peaks.csv')) -poses.to_csv(os.path.join(args.output_dir, args.prefix + 'timings.csv')) - -cher_sums[cher_sums.notnull().all(axis=1)].to_csv(os.path.join(args.output_dir, args.prefix + 'sum.csv')) - diff --git a/scripts/old/batch_run.py b/scripts/old/batch_run.py index a672f55..aebb846 100644 --- a/scripts/old/batch_run.py +++ b/scripts/old/batch_run.py @@ -4,36 +4,41 @@ import getpass import paramiko -root_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../..') +root_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..') exec_path = os.path.join(root_path, 'bin/analyze') # options -raw_data_fmt = os.path.join(root_path, 'raw_data/fadc_%i.dat') -# output_fmt = os.path.join(root_path, 'processed_data/fadc_%i_proc.root') -output_fmt = os.path.join(root_path, 'raw_data/fadc_%i.root') -tcut = 2.0 -fire_thres = 30.0 -modules = os.path.join(root_path, 'config/mapmt_module.conf') -timing = os.path.join(root_path, 'config/mapmt_timing.conf') -# modules = os.path.join(root_path, 'config/lappd_module.conf') -# timing = os.path.join(root_path, 'config/lappd_timing.conf') - +raw_data_fmt = os.path.join(root_path, 'raw_data', 'fadc_{run}.dat') +# output_fmt = os.path.join(root_path, 'processed_data/fadc_{run}_proc.root') +output_fmt = os.path.join(root_path, 'raw_data', 'fadc_{run}.root') +# tcut = 2.0 +# fire_thres = 30.0 +modules = os.path.join(root_path, 'config', '{rtype}_module.conf') +# timing = os.path.join(root_path, 'config', '{rtype}_timing.conf') run_options = [ - '--config-module=%s' % modules, - # '--config-timing=%s' % timing, + '--config-module={}'.format(modules), + # '--config-timing={}'.format(timing), # '-c', str(tcut), # '-f', str(fire_thres), # '--raw-output' ] +proc_fmt = os.path.join(root_path, 'processed_data', 'fadc_{run}.csv') +proc_script = os.path.join(root_path, 'scripts', 'analyze_waveform_max.py') +proc_modules = os.path.join(root_path, 'config', 'json', '{rtype}_module.json') +proc_options = [ + '--module-config={}'.format(proc_modules), +] # runs -# runs = [ 579, 580, 581, 582, 583 ] # LAPPD -runs = [459, 460, 461, 462, 464, 466, 467, 468, 469, 470, 475] # MAPMT +run_types = { + 'lappd': [579, 580, 581, 582, 583], + 'mapmt': [459, 460, 461, 462, 464, 466, 467, 468, 469, 470, 475], +} # download setting download_host = 'agave.phy.anl.gov' -download_fmt = '/globus/sjoosten/jlab/solid/subsystem/lgc/hallc_beam_test/fadc_%i.dat' +download_fmt = '/globus/sjoosten/jlab/solid/subsystem/lgc/hallc_beam_test/fadc_{run}.dat' download_raw_data = True delete_download = True @@ -60,23 +65,30 @@ if download_raw_data: # batch run -for (i, run) in enumerate(runs): - print('--- run %i started (%i/%i)---' % (run, i + 1, len(runs))) - downloaded = False - if download_raw_data and not os.path.exists(raw_data_fmt%run): - print('Downloading raw data for run %i' % run) - sftp = ssh.open_sftp() - sftp.get(download_fmt%run, raw_data_fmt%run, callback=show_progress) - sftp.close() - downloaded = True - - command = [exec_path, raw_data_fmt%run, output_fmt%run] + run_options - print(str.join(' ', command)) - subprocess.call(command) - - if downloaded & delete_download: - os.remove(raw_data_fmt%run) - print('--- run %i finished (%i/%i)---' % (run, i + 1, len(runs))) +for t, runs in run_types.items(): + for (i, run) in enumerate(runs): + print('--- %s run %i started (%i/%i) ---' % (t, run, i + 1, len(runs))) + downloaded = False + if download_raw_data and not os.path.exists(raw_data_fmt.format(run=run)): + print('Downloading raw data for run %i' % run) + sftp = ssh.open_sftp() + sftp.get(download_fmt.format(run=run), raw_data_fmt.format(run=run), callback=show_progress) + sftp.close() + downloaded = True + + run_opt = [opt.format(rtype=t) for opt in run_options] + command = [exec_path, raw_data_fmt.format(run=run), output_fmt.format(run=run)] + run_opt + print(str.join(' ', command)) + subprocess.call(command) + + proc_opt = [opt.format(rtype=t) for opt in proc_options] + command = ['python', proc_script, output_fmt.format(run=run), proc_fmt.format(run=run)] + proc_opt + print(str.join(' ', command)) + subprocess.call(command) + + if downloaded & delete_download: + os.remove(raw_data_fmt.format(run)) + print('--- run %i finished (%i/%i)---' % (run, i + 1, len(runs))) # close ssh client ssh.close() diff --git a/src/analyze.cpp b/src/analyze.cpp index 0f248f8..1f4666c 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -46,8 +46,8 @@ Fadc250Data pack_fadc250_data(Decoder::Fadc250Module* fadc) event.channels[i].time.push_back(time); } - if (fadc->GetNumSamples(i) > 0) { - event.channels[i].raw = fadc->GetPulseSamplesVector(i); + if (res.mode == 1 || res.mode == 8 || res.mode == 10) { + if (fadc->GetNumSamples(i) > 0) { event.channels[i].raw = fadc->GetPulseSamplesVector(i); } } } return res; @@ -89,7 +89,7 @@ int main(int argc, char* argv[]) } } - auto modules = read_modules(mconf); + auto modules = read_modules(mconf, true); write_raw_data(conf_opt.GetArgument(0), conf_opt.GetArgument(1), nev, modules); } @@ -192,6 +192,15 @@ void waveform_analysis(const std::vector<uint32_t> &raw, BranchData &res) for (int i = 0; i < npeaks; ++i) { int j = pos[i]; if (wfbuf[j] < 5.*res.ped_err) { continue; } + // search possible derivative signal + bool cross_talk = false; + for (int k = std::max(0, j - 20); k < j; ++k) { + if ((wfbuf[k] < 0.) && (std::abs(wfbuf[k]) > 0.3*wfbuf[j])) { + cross_talk = true; + break; + } + } + if (cross_talk) { continue; } res.time[res.npul] = j; res.peak[res.npul] = wfbuf[j]; /* @@ -231,7 +240,7 @@ void fill_branch(const Fadc250Data &slot_data, const Module &mod, std::unordered // fill branch data into the root tree void fill_tree(TTree *tree, std::unordered_map<std::string, BranchData> &brdata, bool &init, int mode) { - if ((mode != 1) && (mode != 3) && (mode != 10)) { + if ((mode != 1) && (mode != 3) && (mode != 10) && (mode != 9)) { std::cout << "Warning: unsupported mode " << mode << ", data won't be recorded." << std::endl; return; } @@ -243,9 +252,9 @@ void fill_tree(TTree *tree, std::unordered_map<std::string, BranchData> &brdata, tree->Branch((n + "_Npulse").c_str(), &brdata[n].npul, (n + "_N/I").c_str()); tree->Branch((n + "_Pint").c_str(), &brdata[n].integral[0], (n + "_Pint[" + n + "_N]/F").c_str()); tree->Branch((n + "_Ptime").c_str(), &brdata[n].time[0], (n + "_Ptime[" + n + "_N]/F").c_str()); + tree->Branch((n + "_Ppeak").c_str(), &brdata[n].peak[0], (n + "_Ppeak[" + n + "_N]/F").c_str()); // raw waveform provides more information - if (mode == 1) { - tree->Branch((n + "_Ppeak").c_str(), &brdata[n].peak[0], (n + "_Ppeak[" + n + "_N]/F").c_str()); + if (mode == 1 || mode == 10) { tree->Branch((n + "_Nraw").c_str(), &brdata[n].nraw, (n + "_Nraw/I").c_str()); tree->Branch((n + "_raw").c_str(), &brdata[n].raw[0], (n + "_raw[" + n + "_Nraw]/I").c_str()); tree->Branch((n + "_ped_mean").c_str(), &brdata[n].ped_mean, (n + "_ped_mean/F").c_str()); @@ -283,6 +292,7 @@ void write_raw_data(const std::string &dpath, const std::string &opath, int nev, int count = 0; bool init_tree = false; + int data_mode = -1; while ((datafile.codaRead() == S_SUCCESS) && (nev-- != 0)) { // read-in data evdata->LoadEvent(datafile.getEvBuffer()); @@ -292,7 +302,6 @@ void write_raw_data(const std::string &dpath, const std::string &opath, int nev, std::cout << "Processed events - " << count << "\r" << std::flush; } - int data_mode = -1; for (auto &mod : modules) { auto *fadc = dynamic_cast<Decoder::Fadc250Module*>(evdata->GetModule(mod.crate, mod.slot)); // no data diff --git a/src/conf2json.cpp b/src/conf2json.cpp new file mode 100644 index 0000000..737f49b --- /dev/null +++ b/src/conf2json.cpp @@ -0,0 +1,76 @@ +#include "ConfigParser.h" +#include "ConfigObject.h" +#include "utils.h" +#include "nlohmann/json.hpp" +#include <iomanip> +#include <string> +#include <vector> + + +using json = nlohmann::json; + +int main(int argc, char *argv[]) +{ + std::string path = argv[1]; + // read in file + std::string buffer = ConfigParser::file_to_string(path); + + // remove comments + ConfigParser::comment_line(buffer, "#", "\n"); + + // get content blocks + auto text = ConfigParser::break_into_blocks(buffer, "{", "}"); + + ConfigObject conf; + std::vector<Module> res; + for(auto &b : text.blocks) + { + // module + if (!ConfigParser::case_ins_equal("Module", b.label)) + continue; + + auto btext = ConfigParser::break_into_blocks(b.content, "{", "}"); + conf.ReadConfigString(btext.residual); + + // module attributes + Module mod; + mod.crate = conf.GetConfigValue("crate").Int(); + mod.slot = conf.GetConfigValue("slot").Int(); + mod.type = str2ModuleType(conf.GetConfigValue("type").c_str()); + + // channels + for (auto &sub : btext.blocks) { + if (!ConfigParser::case_ins_equal("Channels", sub.label)) + continue; + ConfigParser parser; + parser.ReadBuffer(sub.content.c_str()); + while(parser.ParseLine()) { + mod.channels.emplace_back(Channel{ + parser.TakeFirst().Int(), + parser.TakeFirst().String(), + str2ChannelType(parser.TakeFirst().c_str()) + }); + } + } + res.emplace_back(mod); + } + + // print out all channels to json + json db; + for (auto &mod : res) { + auto name = "module_" + std::to_string(mod.crate) + "_" + std::to_string(mod.slot); + db[name]["crate"] = mod.crate; + db[name]["slot"] = mod.slot; + db[name]["type"] = ModuleType2str(mod.type); + auto chs = json::array(); + for (auto &ch : mod.channels) { + chs.push_back({{"channel", ch.id}, {"name", ch.name}, {"type", ChannelType2str(ch.type)}}); + } + db[name]["channels"] = chs; + } + + std::ofstream output_file(argv[2]); + output_file << std::setw(4) << db << "\n"; +} + + -- GitLab