CentralityClasses
- class CentralityClasses.CentralityClasses(events_multiplicity: List[float] | ndarray, centrality_bins: List[float] | ndarray)[source]
Class for defining centrality classes based on event multiplicity.
Note
It is the user’s responsibility to ensure that the amount of events used to determine the centrality classes is sufficient to provide reliable results. The recommended minimum number of events is at least a few hundred.
- Parameters:
- events_multiplicitylist or numpy.ndarray
List or array containing the multiplicity values for each event.
- centrality_binslist or numpy.ndarray
List or array defining the boundaries of centrality classes as percentages.
- Raises:
- TypeError
If
events_multiplicity
orcentrality_bins
is not a list ornumpy.ndarray
.
Examples
1>>> from sparkx import * 2>>> import random as rd 3>>> rd.seed(0) 4 5>>> # generate 300 random event multiplicities between 50 and 1500 6>>> events_multiplicity = [rd.randint(50, 1500) for _ in range(300)] 7>>> centrality_bins = [0, 10, 30, 50, 70, 90, 100] 8>>> centrality_obj = CentralityClasses(events_multiplicity=events_multiplicity, 9... centrality_bins=centrality_bins) 10>>> centrality_obj.get_centrality_class(1490) 110 12>>> centrality_obj.output_centrality_classes('centrality_output.txt')
- Attributes:
- events_multiplicity_list or numpy.ndarray
Stores the input multiplicity values for each event.
- centrality_bins_list or numpy.ndarray
Stores the input boundaries of centrality classes.
- dNchdetaMin_list
Minimum values of multiplicity for each centrality class.
- dNchdetaMax_list
Maximum values of multiplicity for each centrality class.
- dNchdetaAvg_list
Average values of multiplicity for each centrality class.
- dNchdetaAvgErr_list
Average errors of multiplicity for each centrality class.
Methods
get_centrality_class:
Return the index of the centrality bin for a given multiplicity value.
output_centrality_classes:
Write centrality class information to a file.
- CentralityClasses.get_centrality_class(dNchdEta: float) int [source]
This function determines the index of the centrality bin for a given multiplicity value based on the predefined centrality classes.
In the case that the multiplicity input exceeds the largest or smallest value of the multiplicity used to determine the centrality classes, the function returns the index of the most central or most peripheral bin, respectively.
- Parameters:
- dNchdEtafloat
Multiplicity value.
- Returns:
- int
Index of the centrality bin.
- CentralityClasses.output_centrality_classes(fname: str) None [source]
Write centrality class information to a file.
- Parameters:
- fnamestr
Name of the output file.
- Raises:
- TypeError
If
fname
is not a string.
Notes
This function writes the centrality class information, including minimum, maximum, average multiplicities, and average errors, to the specified file.