Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = ["Gordon McCann"]
edition = "2021"
license = "MIT"
license-file = "LICENSE.txt"
version = "0.3.0"
version = "0.3.1"
repository = "https://github.com/ATTPC/attpc_merger"
readme = "README.md"

Expand Down
2 changes: 1 addition & 1 deletion attpc_merger/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl eframe::App for MergerApp {
Some(p) => p.to_string_lossy().to_string(),
None => String::from("Default"),
};
ui.label(format!("Pad map: {}", map_render_text));
ui.label(format!("Pad map: {map_render_text}"));
if ui.button("Open...").clicked() {
if let Some(path) = FileDialog::new()
.set_directory(
Expand Down
10 changes: 6 additions & 4 deletions libattpc_merger/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Config {
/// Get the Path to a run file
pub fn get_run_directory(&self, run_number: i32, cobo: &u8) -> Result<PathBuf, ConfigError> {
let mut run_dir: PathBuf = self.graw_path.join(self.get_run_str(run_number));
run_dir = run_dir.join(format!("mm{}", cobo));
run_dir = run_dir.join(format!("mm{cobo}"));
if run_dir.exists() {
Ok(run_dir)
} else {
Expand All @@ -72,7 +72,9 @@ impl Config {

/// Get the path to the online data, assuming the standard AT-TPC Server configuration
pub fn get_online_directory(&self, run_number: i32, cobo: &u8) -> Result<PathBuf, ConfigError> {
let mut online_dir: PathBuf = PathBuf::new().join(format!("/Network/Servers/mm{}.local/Users/attpc/Data/mm{}", cobo, cobo));
let mut online_dir: PathBuf = PathBuf::new().join(format!(
"/Network/Servers/mm{cobo}.local/Users/attpc/Data/mm{cobo}"
));
online_dir = online_dir.join(&self.experiment);
online_dir = online_dir.join(self.get_run_str(run_number));
if online_dir.exists() {
Expand All @@ -84,7 +86,7 @@ impl Config {

/// Get the path to the FRIBDAQ directory, assuming the standard AT-TPC configuration
pub fn get_evt_directory(&self, run_number: i32) -> Result<PathBuf, ConfigError> {
let run_dir: PathBuf = self.evt_path.join(format!("run{}", run_number));
let run_dir: PathBuf = self.evt_path.join(format!("run{run_number}"));
if run_dir.exists() {
Ok(run_dir)
} else {
Expand All @@ -106,7 +108,7 @@ impl Config {

/// Construct the run string using the AT-TPC DAQ format
fn get_run_str(&self, run_number: i32) -> String {
format!("run_{:0>4}", run_number)
format!("run_{run_number:0>4}")
}

pub fn is_n_threads_valid(&self) -> bool {
Expand Down
1 change: 1 addition & 0 deletions libattpc_merger/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl GetEvent {
trace[3] = hw_id.channel as i16;
trace[5] = *channel as i16;
trace[datum.time_bucket_id as usize + SAMPLE_COLUMN_OFFSET] = datum.sample;
traces.insert(*channel, trace);
}
};
}
Expand Down
20 changes: 10 additions & 10 deletions libattpc_merger/src/hdf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl HDFWriter {
let id = event.event_id;
let ts = event.timestamp;
let tso = event.timestampother;
let event_name = format!("event_{}", event_counter);
let event_name = format!("event_{event_counter}");

let event_group = match self.events_group.group(&event_name) {
Ok(group) => group,
Expand Down Expand Up @@ -271,7 +271,7 @@ impl HDFWriter {
.scalers_group
.new_dataset_builder()
.with_data(&scalers.data)
.create(format!("event_{}", counter).as_str())?;
.create(format!("event_{counter}").as_str())?;

scaler_dset
.new_attr::<u32>()
Expand Down Expand Up @@ -303,7 +303,7 @@ impl HDFWriter {
self.last_frib_event = *event_counter;
}

let event_name = format!("event_{}", event_counter);
let event_name = format!("event_{event_counter}");
let event_group = match self.events_group.group(&event_name) {
Ok(group) => group,
Err(_) => self.events_group.create_group(&event_name)?,
Expand All @@ -323,7 +323,7 @@ impl HDFWriter {
.with_data(&[physics.coinc.coinc])
.create("977")?;
// write SIS3300 data if present
if physics.fadc1.hasdata == true {
if physics.fadc1.hasdata {
let mut data_matrix =
Array2::<u16>::zeros([physics.fadc1.samples, physics.fadc1.traces.len()]);
for i in 0..8 {
Expand All @@ -337,7 +337,7 @@ impl HDFWriter {
.create("1903")?;
}
// write SIS3301 data if present
if physics.fadc2.hasdata == true {
if physics.fadc2.hasdata {
let mut data_matrix =
Array2::<u16>::zeros([physics.fadc2.samples, physics.fadc2.traces.len()]);
for i in 0..8 {
Expand All @@ -351,7 +351,7 @@ impl HDFWriter {
.create("1904")?;
}
// write SIS3301 data if present
if physics.fadc3.hasdata == true {
if physics.fadc3.hasdata {
let mut data_matrix =
Array2::<u16>::zeros([physics.fadc3.samples, physics.fadc3.traces.len()]);
for i in 0..8 {
Expand All @@ -365,13 +365,13 @@ impl HDFWriter {
.create("1905")?;
}
// write SIS3316 data if present (channel number is encoded as first element)
if physics.fadc4.hasdata == true {
if physics.fadc4.hasdata {
let mut data_matrix =
Array2::<u16>::zeros([physics.fadc4.samples+1, physics.fadc4.channels]);
Array2::<u16>::zeros([physics.fadc4.samples + 1, physics.fadc4.channels]);
let mut index = 0;
for i in 0..16 {
if physics.fadc4.valid[i] == true {
for j in 0..physics.fadc4.samples+1 {
if physics.fadc4.valid[i] {
for j in 0..physics.fadc4.samples + 1 {
data_matrix[[j, index]] = physics.fadc4.traces[i][j];
}
index += 1;
Expand Down
1 change: 0 additions & 1 deletion libattpc_merger/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ pub fn process_run(
let pad_map = GetChannelMap::new(config.channel_map_path.as_deref())?;

//Initialize the merger, event builder, and hdf writer

let mut merger = Merger::new(config, run_number)?;
spdlog::info!(
"Total run size: {}",
Expand Down
15 changes: 8 additions & 7 deletions libattpc_merger/src/ring_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ impl TryFrom<RingItem> for PhysicsItem {
info.fadc4.extract_data(&mut cursor)?;
} else if tag == 0x977 {
info.coinc.extract_data(&mut cursor)?;
} else { // If unknown tag, assume end of data
cursor.set_position(cursor.position()-2);
} else {
// If unknown tag, assume end of data
cursor.set_position(cursor.position() - 2);
break;
}
}
Expand Down Expand Up @@ -499,7 +500,7 @@ impl SIS3316Item {
&mut self,
cursor: &mut std::io::Cursor<Vec<u8>>,
) -> Result<(), EvtItemError> {
let mut channel = ((cursor.read_u16::<LittleEndian>()?)>>4 & 0xf) as usize;
let mut channel = ((cursor.read_u16::<LittleEndian>()?) >> 4 & 0xf) as usize;
let mut _stamp1 = cursor.read_u32::<LittleEndian>()?;
let mut _stamp2 = cursor.read_u16::<LittleEndian>()?;
self.samples = (cursor.read_u16::<LittleEndian>()? * 2) as usize;
Expand All @@ -509,17 +510,17 @@ impl SIS3316Item {
loop {
self.valid[channel] = true;
self.channels += 1;
self.traces[channel] = vec![0; self.samples+1];
self.traces[channel] = vec![0; self.samples + 1];
self.traces[channel][0] = channel as u16; // Encode channel number as first datum
for i in 0..self.samples {
self.traces[channel][i+1] = cursor.read_u16::<LittleEndian>()?;
self.traces[channel][i + 1] = cursor.read_u16::<LittleEndian>()?;
}
next = cursor.read_u16::<LittleEndian>()?;
cursor.set_position(cursor.position()-2);
cursor.set_position(cursor.position() - 2);
if next == 0xffff {
break;
}
channel = ((cursor.read_u16::<LittleEndian>()?)>>4 & 0xf) as usize;
channel = ((cursor.read_u16::<LittleEndian>()?) >> 4 & 0xf) as usize;
_stamp1 = cursor.read_u32::<LittleEndian>()?;
_stamp2 = cursor.read_u16::<LittleEndian>()?;
self.samples = (cursor.read_u16::<LittleEndian>()? * 2) as usize;
Expand Down
Loading