[][src]Crate malice

malice

"milli ALICE" aka malice is a tiny framework defining some sensible defaults to analyze the ALICE open data.

Features

malice supports twp IO backends. The first and recommended one is the pure Rust root-io crate. The second one is behind the cpp feature gate and depends on the c++ ROOT framework.

Example

Here is a very simple example analysis using malice and other crates from the alice-rs repository. It measures the pseudorapidity distribution of the reconstructed tracks. For a more comprehensive, but still small, example (including concurrency) check out simple-analysis.

This example is not tested
extern crate alice_open_data;
extern crate histogram;
extern crate malice;
extern crate root_io;

use histogram::*;
use root_io::RootFile;

use malice::{Event, DatasetIntoIter as DsIntoIter};
use malice::{default_track_filter, default_event_filter};

fn main() {
    // Iterator over files of the Open Data set
    let files: Vec<_> = alice_open_data::all_files_10h()
        .expect("No data files found. Did you download with alice-open-data?")
        .into_iter()
        .collect();

    // Create an iterator over `malice::event::Event`s
    let events = files
        .iter()
        .map(|path| RootFile::new_from_file(&path).expect("Failed to open file"))
        .map(|rf| rf.items()[0].as_tree().unwrap())
        .flat_map(|tree| match DsIntoIter::new(&tree) {
            Ok(s) => s,
            Err(err) => panic!("An error occured! Message: {}", err),
        });

    // Fold the `malice::event::Events` with the analysis
    let _analysis_result: SimpleAnalysis = events
        // Apply a sensible default event filter
        .filter(default_event_filter)
        .fold(SimpleAnalysis::new(), |analysis, ev| { analysis.process_event(&ev) });
    // Do something with the result...
}

pub struct SimpleAnalysis {
    // Histogram of the pseudorapidity (eta) distribution of valid tracks
    pub eta_distribution: Histogram<i32, [usize; 1]>,
}

impl SimpleAnalysis {
    fn new() -> SimpleAnalysis {
	// 50 bins from -0.9 to 0.9
	let (neta, eta_min, eta_max) = (50, -0.9, 0.9);
        SimpleAnalysis {
	    eta_distribution: HistogramBuilder::<[usize; 1]>::new()
                .add_equal_width_axis(neta, eta_min, eta_max)
                .build()
                .expect("Error building histogram"),
        }
    }

    // Update the histogram with the given event
    fn process_event(mut self, event: &Event) -> Self
    {
        // Fill only if we have a valid primary vertex
        if let Some(prime_vtx) = event.primary_vertex() {
            self.eta_distribution
                .extend(
                    event.tracks()
		    // Apply a sensible default "cut" on the valid tracks
			.filter(|tr| default_track_filter(&tr, &prime_vtx))
                        .map(|tr| [tr.eta() as f64]));
	};
        self
    }
}

Structs

Event

A model for a subset of an event as stored in the published data

Flags

Various attributes of tracks. Flags are based on those found in AliRoot's AliVTrack.[h,cxx]

ItsClusters

Clusters in the ITS associated with the curren track See AliESDTrack::HasPointOnITSLayer

PrimaryVertex

The most likely position in the detector where the current event took place. The primary vertex is the most likely common origin of all the reconstructed tracks.

Track

A Track is a reconstruction of the trajectory of a particle traversing the detector.

TriggerMask

Triggers are low level qualifier of an event. One event may "fire" several triggers.

Functions

default_event_filter

A simple but reasonable default event selection Returns true if the given event passes the recommended selection criterion

default_track_filter

Applies a reasonable set of default track cuts returning true if the track is valid

event_stream_from_esd_file

A helper function which turns a path to an ALICE ESD file into a stream over the Events of that file.

event_stream_from_tree
is_hybrid_track

So called hybrid tracks are sometimes used in order to achieve a more uniform distribution of tracks in eta and phi. This function cannot be used with the default_track_filter and might need more debugging. Use with care.