diff --git a/Cargo.lock b/Cargo.lock index e7ce6b0..01b1abf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,7 +530,7 @@ dependencies = [ [[package]] name = "attpc_merger" -version = "0.3.0" +version = "0.3.1" dependencies = [ "eframe", "libattpc_merger", @@ -542,7 +542,7 @@ dependencies = [ [[package]] name = "attpc_merger_cli" -version = "0.3.0" +version = "0.3.1" dependencies = [ "clap", "indicatif", @@ -1872,7 +1872,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libattpc_merger" -version = "0.3.0" +version = "0.3.1" dependencies = [ "bit-set", "bitvec", diff --git a/Cargo.toml b/Cargo.toml index af970f0..a0d9b1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/attpc_merger/src/app.rs b/attpc_merger/src/app.rs index 2f2b76c..e8c1930 100644 --- a/attpc_merger/src/app.rs +++ b/attpc_merger/src/app.rs @@ -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( diff --git a/libattpc_merger/src/config.rs b/libattpc_merger/src/config.rs index 93a8f0d..08e04bb 100644 --- a/libattpc_merger/src/config.rs +++ b/libattpc_merger/src/config.rs @@ -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 { 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 { @@ -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 { - 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() { @@ -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 { - 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 { @@ -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 { diff --git a/libattpc_merger/src/event.rs b/libattpc_merger/src/event.rs index 289d6ac..52a49eb 100644 --- a/libattpc_merger/src/event.rs +++ b/libattpc_merger/src/event.rs @@ -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); } }; } diff --git a/libattpc_merger/src/hdf_writer.rs b/libattpc_merger/src/hdf_writer.rs index fa9c4fe..2a29d70 100644 --- a/libattpc_merger/src/hdf_writer.rs +++ b/libattpc_merger/src/hdf_writer.rs @@ -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, @@ -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::() @@ -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)?, @@ -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::::zeros([physics.fadc1.samples, physics.fadc1.traces.len()]); for i in 0..8 { @@ -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::::zeros([physics.fadc2.samples, physics.fadc2.traces.len()]); for i in 0..8 { @@ -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::::zeros([physics.fadc3.samples, physics.fadc3.traces.len()]); for i in 0..8 { @@ -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::::zeros([physics.fadc4.samples+1, physics.fadc4.channels]); + Array2::::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; diff --git a/libattpc_merger/src/process.rs b/libattpc_merger/src/process.rs index db508b0..1ed5762 100644 --- a/libattpc_merger/src/process.rs +++ b/libattpc_merger/src/process.rs @@ -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: {}", diff --git a/libattpc_merger/src/ring_item.rs b/libattpc_merger/src/ring_item.rs index bcec022..51035e6 100644 --- a/libattpc_merger/src/ring_item.rs +++ b/libattpc_merger/src/ring_item.rs @@ -311,8 +311,9 @@ impl TryFrom 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; } } @@ -499,7 +500,7 @@ impl SIS3316Item { &mut self, cursor: &mut std::io::Cursor>, ) -> Result<(), EvtItemError> { - let mut channel = ((cursor.read_u16::()?)>>4 & 0xf) as usize; + let mut channel = ((cursor.read_u16::()?) >> 4 & 0xf) as usize; let mut _stamp1 = cursor.read_u32::()?; let mut _stamp2 = cursor.read_u16::()?; self.samples = (cursor.read_u16::()? * 2) as usize; @@ -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::()?; + self.traces[channel][i + 1] = cursor.read_u16::()?; } next = cursor.read_u16::()?; - cursor.set_position(cursor.position()-2); + cursor.set_position(cursor.position() - 2); if next == 0xffff { break; } - channel = ((cursor.read_u16::()?)>>4 & 0xf) as usize; + channel = ((cursor.read_u16::()?) >> 4 & 0xf) as usize; _stamp1 = cursor.read_u32::()?; _stamp2 = cursor.read_u16::()?; self.samples = (cursor.read_u16::()? * 2) as usize;