# Detecting and Mitigating Bias in Algorithms Used to Disseminate Information
in Social Networks

Vedran Sekara,1∗† Ivan Dotu,2∗† Manuel Cebrian,3,4
Esteban Moro,5 and Manuel Garcia-Herranz6∗

1IT University of Copenhagen, 2300 Copenhagen, Denmark
2UNICEF/GIGA, New York, NY, USA
3Department of Statistics, Universidad Carlos III de Madrid, Madrid, Spain
4Center for Automation and Robotics, Spanish National Research Council,
Madrid, Spain
5Network Science Institute, Northeastern University, Boston, MA, USA
6UNICEF, New York, NY, USA

∗To whom correspondence should be addressed; E-mail<EMAIL_ADDRESS><EMAIL_ADDRESS>and
<EMAIL_ADDRESS>
†Contributed equally to the paper

> Social connections are a conduit through which individuals communicate,
> information propagates, and diseases spread. Identifying individuals that
> are more likely to adopt ideas or technologies and spread them to others is
> essential in order to develop effective information campaigns, fight
> epidemics, and to maximize the reach of limited resources. Consequently a
> lot of work has focused on identifying sets of influencers. Here we show
> that seeding information using these influence maximization methods, only
> benefits connected and central individuals, consistently leaving the most
> vulnerable behind. Our results highlights troublesome outcomes of influence
> maximization algorithms: they do not disseminate information in an equitable
> manner threatening to create an increasingly unequal society. To overcome
> this issue we devise a simple, multi-objective algorithm, which maximises
> both influence and information equity. Our work demonstrates how to find
> fairer influencer sets, highlighting that in our search for maximizing
> information, we do not need to compromise on information equality.

## Introduction

Social relationships serve as important vectors through which a multitude of
behaviors spread, from health related behaviors (?, ?), innovation (?, ?),
decisions of micro-financing (?), decision to insure (?), happiness (?),
cultural tastes (?), to the emergence of social movements (?, ?). Knowing
through which pathways information spreads is vital for international
development (?, ?) and crucial in developing more efficient methodologies that
maximize the diffusion of potentially life saving information (?, ?). Due to
resource constraints it is unfeasible to send a piece of information to all
individuals within a network. Instead, a frequently adopted strategy is to
seed a small set of individuals, much smaller than the full population,
located at strategic places in the network whose activation (or removal) would
facilitate the spread of information (or in the case of epidemics inhibit a
disease from spreading). Numerous methods have been proposed to identify ”the
set” of influential nodes. These methodologies can be divided up into two
fundamentally distinct classes (?, ?): (1) methods that identify individuals
who are highly connected or central, and effective at diffusing information –
so-called superspreader methods (?, ?, ?, ?, ?, ?, ?). And (2) methods which
highlight individuals that occupy structurally vital positions in a network
whose removal would destroy the network and subsequently block information
from propagating – also called superblocker methods (?, ?, ?, ?, ?, ?).
Although the methods are different there is a general consensus that they both
pinpoint nodes which are highly efficient conduits for information propagation
(?).

Unfortunately, we have a limited understanding of which demographics these
methods reach and which communities they leave behind, but there are alarming
signs in the network science literature. Previous work has demonstrated that
wealth is connected to diversity of social connections, the richer you are the
more diverse is your social network, in turn enabling you to receive
information from many directions (?, ?, ?). Similarly, influence maximisation
has been shown create gaps in information access (?), and to have a gender
skew, with male individuals having an advantage in being selected as
influencers (?, ?, ?). Previous work has also shown that an individuals’
chances of being ranked as an influencer are highly correlated with personal
economic status (?). Further, as social systems display strong levels of
homophily (?), where connections between similar individuals occur at higher
rates than between dissimilar individuals, wealthy individuals are more likely
to befriend people that resemble them, and less likely to interact with the
poor (?). As a consequence, information in social networks tends to be
localized within social strata, restricting diffusion across demographic and
socioeconomic gaps and between majority and minority groups (?). Access to
information is a major factor of social vulnerability (?). By naively using
current influence maximisation methodologies to selects predominantly wealthy
influencers, through which information is inserted, we run the risk of
tailoring information campaigns towards the most affluent groups of our
societies, while severely under-representing the most vulnerable and
marginalized.

### Defining Informational Vulnerability

Vulnerability is a complex issue determined by physical, economic, social, and
environmental factors, which decrease the capacity of individuals and groups
to cope, anticipate, and react to hazards (?). Here we study one aspect of
vulnerability, namely individuals’ access to information. Previous work has
looked into the interplay between influence maximization and different
characteristics of the nodes (such as age, gender, ethnicity) which receive
information (?, ?, ?, ?). However, rather than assuming we have access to this
type of information we focus on the general utility of the information
individuals receive—this has previously been called a ’welfare approach’ (?,
?). As such, we study how access to information is distributed across all
nodes in the network. Specifically, we define informational vulnerability as
the average likelihood that an individual receives information, estimated from
many independent diffusion cascades. We focus on two facets of this stochastic
process: 1) frequency: how often does an individual receive information (i.e.
how often are they reached by cascades), and 2) recency: how old are the
cascades when they reach them (e.g. at what step of the cascade is the
individual reached by it). Looking at just one cascade will reveal very
little, but upon many independent simulations it is easy to see that not every
individual is equally lucky on their network position and that some tend to be
reached by more cascades, or earlier than others. Network structure and node
locations in the network play very important roles in this. To simulate
information diffusion processes on networks we apply the commonly used
Independent Cascade Model (ICM) in its most simple form, unweighted and
undirected (?). ICMs are commonly used to study influence maximisation in
social networks (?, ?) and are a special case of susceptible-infected-
recovered (SIR) models, where the recovery probability is fixed to 1. The ICM
allows an informed individual one attempt to speak to their neighbors and
convince them to adopt a behavior; the neighbors, if convinced, will then try
to convince their neighbors, and so on (see Supplementary Materials (SM) Sec.
S3 for more details).

To identify sets of influencers we focus on four widely used methods: (i)
highest degree (?) (HD), which is a commonly used heuristic where nodes are
selected according to their number of connections, (ii) degree discount (?)
(DD), an efficient method for identifying superspreaders, (iii) coreHD (?)
(CHD), a state-of-the-art method for inferring superblockers, and (iv) k-core
(?) (KC), selecting nodes located in the core of the network. Fig. 1a
illustrates, for a small real-world network, which nodes each method pinpoints
as influencers. As ICM is a stochastic process we average over multiple
simulations. For each realisation of the dynamic process we track which nodes
are activated and how long it takes for the spreading process to reach them.
We quantify this using two measures. The first measure, information frequency:

$\nu_{i}=\frac{1}{M}\>\sum_{n}^{M}a_{i,n}\>,$

summarizes the average fraction of times node $i$ has been reached, where
$a_{i,n}=1$ if node $i$ received information in realisation $n$ and is zero
otherwise, and $M$ is the total number of simulations. Information frequency
($\nu_{i}$) lies in the interval 0 to 1, where zero indicates that a node is
never reached by the $M$ cascades, while a value of 1 indicates the node is
reached by every cascade.

The second measure, information recency:

$\tau_{i}=\frac{1}{M}\>\sum_{n}^{M}\frac{1}{t_{i,n}+1}\>,$

quantifies the temporal delay from process initialization ($t=0$) until node
$i$ is activated. Recency is calculated as the average of the inverse
activation time to handle cases where the information spreading process dies
out before reaching a node. Nodes that on average receive information quickly
have $t_{i,n}\rightarrow 0$ and $\tau\rightarrow 1$, while nodes that are
activated very late, or never, ($t_{i,n}\rightarrow\infty$) have
$\tau\rightarrow 0$.

To understand the shortcomings of the four methods in selecting influencers we
compare them to a benchmark model where all nodes have equal chance of being
selected (selected at random) — we call this the effective measure. If the
ratio $\nu_{i}^{\text{method}}/\nu_{i}^{\text{benchmark}}>1$ a node will on
average receive information more frequently when seeds are selected using a
specific method as compared to when nodes are selected at random. If
$\nu_{i}^{\text{method}}/\nu_{i}^{\text{benchmark}}<1$ a node will be better
off when information is inserted at random entry points in the network. The
same holds for recency,
$\tau_{i}^{\text{method}}/\tau_{i}^{\text{benchmark}}>1$ indicates that a node
on average receives more recent information when using a influencer
maximisation method, while
$\tau_{i}^{\text{method}}/\tau_{i}^{\text{benchmark}}<1$ denotes that
information is received faster when information is inserted at random nodes.
Fig. 1b illustrates the resulting effective recency-values from using
influencers inferred by the four methods as seeds. Independent on methodology,
the influencer nodes and their surrounding neighbors are always reached by the
influencer set, however, a large fraction of nodes seems to be left behind.
Typically nodes located on the periphery.

Figure 1: Inequalities and diffusion of information in networks. a, Initial
seed sets selected according to HD, CHD, DD, and KC, illustrating variations
in how the four methods select influencers for a social network between
households in a south-Indian village (?). In this example $5\%$ of nodes are
selected as influencers. Colored nodes indicate selected influencers. b,
Effective recency for the social network. Recency is estimated across 1000
runs with $p_{c}=0.069$. (se SM Sec. S3.1) c, Cumulative distribution of
individual node frequency within synthetic scale-free (SF) networks with
$N=10^{4}$, $\gamma=2.5$, and $\langle p_{c}\rangle=0.085$. The curves show
the probability that $\nu$ is less than or equal to $x$, where $x$ is any
arbitrary value. Results are combined over 100 different network realizations.
For each network we select an initial influencer set (1 % of nodes) inferred
from one of the heuristics, run the spreading process, track which nodes
receive information, and repeat the process $M=10N$ times to account for
stochasticity in both the seed selection and the spreading processes. Red
shaded regions denote parts of the distribution where the effective measure
(the ratio) is below 1, while grey shaded indicate places where the ratio is
above 1. d, Cumulative distribution of recency within SF networks. e, Fraction
of nodes that are worse off with respect to information frequency in $n$ of
the seeding heuristics when compared to the benchmark. Error bars are standard
deviation over 100 network realizations. f, Fraction of nodes that are worse
off with respect to recency.

### Quantifying Informational Vulnerability

To formalize the observations from Fig. 1b we first investigate the four
methodologies on a testbed of 100 realizations of synthetic unweighted and
undirected networks with scale-free (SF) degree distributions (see SM Sec. S6
for random networks with normal degree distributions). While perfect SF
networks are rarely observed in nature they are powerful simplifications of
real-world networks (?, ?). In order to compare heuristics we construct
influencer sets from a fixed finite fraction of the network population—1% of
nodes (see SM Sec. S5 for other seed sizes).

Seeding information through random nodes in SF networks results in a near-
homogeneous frequency distribution: i.e. node receives a constant stream of
information (Fig. 1c, black line). In Fig. 1c, a completely equal information
metric would be characterized by a vertical line in the cumulative probability
distribution. Note that the black line of Fig. 1c, characterizing the random
process, is not vertical due to the intrinsic variations of the network
structure. Using the four methods to select influencers sets, however, results
in fundamentally different frequency distributions (Fig. 1c, colored lines).
Approximately half of nodes have effective frequency values
($\nu^{\text{method}}/\nu^{\text{benchmark}}$) above one, meaning they receive
information more frequently then expected using a random process, while half
the network receives much less compared to when seeds are selected at random
(see also SM Sec. S4). The situation is similar for the recency distribution,
albeit slightly more polarized (Fig. 1d). Looking across the different
influencer maximisation heuristics, Fig. 1e, demonstrates that if a node is
under-informed by one method, it will most likely not be better reached by any
other method. On average $42.8\pm 1.7\%$ of nodes are better informed when
information is seeded using any influencer maximization method. We say that
these nodes are always better off. However, $47.0\pm 2.2\%$ of nodes are
consistently left behind, independent of which method is used to select
influencers. With respect to recency, Fig. 1f highlights an even worse
situation, $55.6\pm 2.2\%$ of nodes receive out-of-date information,
independent on which information maximisation methodology is used.

To understand the implications of information inequalities for real-world
networks we look at communication, interaction, and social networks varying in
size from hundreds to tens of thousands of individuals. The networks differ in
context from: face-to-face encounters (?), connections between bloggers and
blogs on political topics (?), digital communication between university
students (?), online friendships (?), and scientific collaborations (?) (see
SM Sec. S2 for more details).

For information frequency, Fig. 2a shows that current state-of-the-art
influencer heuristics identify seed-sets that, on average, leave significant
portions of the network in disadvantaged positions. HD, CHD, and DD methods
result in fairly similar $\nu$ distributions, while selecting influencers
according to KC performs much worse (approx. 80% of nodes are better reached
by randomly selected influencers). This is due to real-world network having a
large numbers of cliques, where small discrepancies in shell numbers can
result in KC only selecting nodes from a single clique (?), effectively
limiting the diffusion of information. Similar behavior is observed for
information recency ($\tau$). Fig. 2b shows that HD, CHD, and DD leave behind
a comparable numbers of nodes, while KC again performs worse. Summarizing the
average reach of influencer heuristics, we find that up to $69.8\%$ of a
network might receive information less frequently compared to if it is input
at random (Fig. 2c), and information can reach up to $79.2\%$ of individuals
slower (Fig. 2d).

There is a connection between access to information and a node’s position in
the network (?). The connection is so strong that a predictive model, based on
structural features such as node degree, k-shell number, clustering,
centrality, and eccentricity, can accurately predict whether a node will fall
into the group of ‘worse off according to all influencer heuristics‘ or
‘better off in all’ (see SM Sec. S7). We can, on average, with 97.4% accuracy
predict the information status of nodes regarding frequency, and with an
average accuracy of 96.9% for recency. This demonstrates that current
influencer heuristics suffer from biases which disadvantage low-connected and
peripheral nodes.

Figure 2: Inequalities and diffusion of information in real-world networks. a,
Cumulative distribution of individual node frequency within five real-world
networks, ordered according to size (number of nodes). Initial seeds sets
comprise $1\%$ of the network, and information frequency is averaged over
$10N$ runs (see SM Table S1 for $N$-values). Curves show the probability that
$\nu$ is less than or equal to x, where x is any arbitrary value. b,
Cumulative distribution of recency within the empirical networks. c, Fraction
of nodes that are worse off with respect to frequency in $n$ of the seeding
heuristics when compared to the a random seeding procedure
($\nu^{\text{method}}/\nu^{\text{benchmark}}$). The fraction of disadvantaged
individuals are: face-to-face ($20.7\%$), political blogs ($17.8\%$), student
communication ($25.1\%$), online friendships ($69.8\%$), and academic
collaborations ($56.0\%$). d, Fraction of nodes that are worse off with
respect to recency ($\tau^{\text{method}}/\tau^{\text{benchmark}}$) for $n$
methods. Disadvantaged percentages include: face-to-face ($48.3\%$), political
blogs ($34.5\%$), student communication ($34.3\%$), online friendships
($79.2\%$), and academic collaborations ($68.7\%$).

### Fair Influence Maximisation

To bridge the information gap different strategies can be employed. Previous
studies have shown that instead of using influencer algorithms to identify $s$
individuals, one can select slightly more individuals $s+x$, but at random
(?). Even for small $x$-values this has been shown to result in larger
cascades. Another solution is to apply acquaintance methods (also called
friendship-nomination, which work by selecting a random neighbor of a randomly
selected node), which have been used to select influencers for maximising mass
drug administration campaigns (?), to seed information about maternal and
child health (?), and for inferring centrally located individuals suitable as
monitors for detecting large scale disease outbreaks (?). Lastly, maximization
of social welfare objective functions, along with the implementation of
different algorithms, has been proposed to bridge the information gap (?).

We embark on a different solution. Traditionally, influence maximisation has
only focused on maximising a single objective function, information spread.
However, as literature from the field of Artificial Intelligence shows,
focusing solely on optimizing one parameter can lead to troubling and unfair
outcomes (?, ?, ?). Instead, we propose a multi-objective formulation of fair
influence maximisation, where both spread and fairness are taken into account
in the fitness of a candidate solution (i.e. the set of selected influencers).
We measure fairness as the fraction of nodes that receive information at a
higher frequency and speed than what is expected from the benchmark model,
where influencers are selected at random. We say a node is vulnerable if it
receive less information than what can be expected at random (i.e.
$\nu_{i}^{\text{method}}/\nu_{i}^{\text{benchmark}}<1$). In the following we
focus primarily on information frequency, but similar results can be obtained
for recency. As such, the more fair an influencer set is, the fewer nodes will
be vulnerable, so we maximise the number of non-vulnerable nodes. Analytically
calculating how information will spread from a set of nodes according to the
ICM model is a computationally hard problem (NP-hard) (?). As such, we use an
approximation of the fitness of a influencer set (see SM Sec. S8). To find
fairer seeds we then use a genetic algorithm to solve the optimization problem
(see Methods).

Fig. 3a shows the theoretical Pareto front (in multi objective optimization a
Pareto front denotes a line of optimal solutions (?)) for the social network
between households of a south-Indian village (?). Our method identifies seed
sets which are more fair and, at the same time, as effective at maximizing
influence as the influence maximization heuristics (HD, CHD, DD). (We
disregard here seed sets identified by KC as they are far inferior to the ones
produced by the other three heuristics.) For this network, our algorithm
identifies nine possible influencer sets, undiscovered by the traditional
heuristics, with different trade-offs between maximising information reach
(cascade size) and the number of non-vulnerable nodes (fairness). As these
findings are based on an theoretical approximation we also evaluate these
seeds sets using ICMs. Fig. 3b, shows our theoretical predictions are
consistent with results found by numerically simulating information spread. As
such, for a negligible reduction in cascade size we can, for this specific
network, choose fairer seeds that roughly corresponds to 6% to 10$\%$ fewer
vulnerable nodes. Fig. 3c-d illustrates the difference between the seed nodes
inferred from using a state-of-the-art influencer heuristics (CHD) and our
approach. The figure shows initial seed nodes (in black) and the activation of
edges, where an activated edge indicates successful information propagation.
There is a clear difference between the structural locations of the nodes in
the network. Using the average distance from seed nodes to the rest of the
network we calculate how far each seed set is from all nodes in the network.
We find that our method identifies nodes which are more evenly distributed in
the network and, on average, closer to the overall network (see Sec. S10 in
the SM). In turn, this results in larger parts of the network being more
easily reached.

Fig. 3a,b show an example for one specific network, however, our fair
influence maximization method works equally well for other networks (Fig.
3e-h). For other networks (Fig. 3e-h) the traditional heuristics identify
influencer sets which optimize cascade size, however, we find that these seed
sets are not fair in terms of information equality (for numerical results see
Supplementary Materials). It is possible to improve this, with large gains in
fairness being achievable by trading off a small reduction in cascade size.
Overall we find that a $1\%$ trade-off in reach can result in a decrease in
number of vulnerable individual by: $1.9\%$ for the network of political
blogs, $3.1\%$ for student communication, $10.5\%$ for online friendships, and
up to $24\%$ in collaboration networks (here we have disregard the face-to-
face network due to the low number of identified seed sets which makes it
difficult to calculate the proper trade-off value).

Lastly, for the collaboration network (Fig. 3h), we find that using
traditional heuristics are not close to the Pareto frontier. Meaning they are
sub-optimal in term of both cascades sizes and fair information access. In
this situation our algorithm can also be used to identify, previously
undiscovered, seed sets which optimize cascade-size.

Figure 3: Fair influence maximization for a social network between households
in a South Indian village. a, Theoretical Pareto front of optimal influencer
sets found by our algorithm, compared to the the ones found by the influencer
heuristics. We disregard KC as it consistently performs worse, both in terms
of fairness and reach compared to the other heuristics. Higher values of non-
vulnerable nodes indicate higher values of fairness. b, Numerical evaluation
of influencer sets using ICM. Error bars are given as the standard deviation
from 10 realization of $10N$ ICM simulations. c, Edge activations for the set
of influencers identified by HD. Edges are colored and sized according to how
often they were activated during $10N$ simulations. Nodes colored black are
initial seed nodes. d, Edge activations for one of the fairer seed sets
identified by our algorithm. A comprehensive comparison between the two seed
sets if available in the SM Sec. S9.

### Discussion

The United Nations sustainable development goals (SDGs) (?) recognize that
eradicating inequalities in all their forms and dimensions are one of the
greatest global challenges our societies face. Algorithms have the power to
deliver on the SDGs. For example, access to information is critical for
vaccination campaigns and algorithms, such as influence maximization, have a
role to play in effectivizing these campaigns. However, algorithms can also
bring potential biases into play. Our results show there is a group of nodes
that are consistently left behind by influence maximization algorithms. In
particular, for both real-world and synthetic networks, we find that access to
information in unequal, both in terms of how often information is received and
how recent the information is. A behavior that is not limited to low or high
clustered networks, nor to specific types of interactions (see Supplementary
Materials Table S1); we find it present across all networks we investigated.

Although algorithmic systems can be biased due to many factors (?), it is
often thought that biases usually appear due to skews or misrepresentations in
training data. However, that is not the case for influence maximization
algorithms. Here, the issue lies with the problem statement with the choice of
the objective function. By developing algorithms that solely focus on
optimizing reach, without considering equity or fairness aspects creates a
bias. Unfortunately, not receiving information has real-world consequences.
For example, experiences from mass drug administration campaigns have
pinpointed that individuals are left untreated not due to lack of medicine,
but because they never receive information about the campaign (?). Further,
due to the pervasive usage of influence maximization algorithms in social
recommendations (?), network monitoring (?), and even rumor control (?), the
cumulative effects of information inequality in the populations left behind,
in combination with other types of digital gaps, can create large fractures in
the social fabric of our societies.

Thus, it is vital to understand if such algorithms are equitable, to quantify
the level of inequality, and propose potential alternatives that balance
potential reach and equity. Multi-objective-optimization is a well-known
computational tool which adds nuance to optimization problems and makes it
possible to include multiple criteria when selecting influencer sets. As such,
to close the information equity gap we propose a multi-objective formulation
of the fair influence maximization problem and develop a genetic algorithm to
solve it. Our results demonstrate it is possible to find influencer sets that
reduce vulnerability at a relatively low trade-off with respect to spread. For
example, we find that a mere $1\%$ reduction in reach (i.e. cascade size) can
reduce the number of people typically left behind in information campaigns by
up to $24\%$.

Our multi-objective algorithm is a first approach at solving this critical
problem, yet it is not perfect. We believe it can act as a starting point
towards more systematic solutions towards fair information access, as this
issue arise across many other contexts within network science, artificial
intelligence, and computational science problems (?, ?). One particular
application can be online social networks where incorporating additional
algorithmic objectives can be beneficial to: help detect vulnerable
individuals, mitigate and reduce segregation, lessen polarization between
groups, and help guide the design of more equal information dissemination
structures.

Our approach requires information about the full network. Noise and incomplete
mappings of networks will naturally affect this (?). However, we believe the
effect will not differ from what traditional heuristics like degree discount,
CoreHD or highest degree already experience, as they also require information
about the total graph. Another shortcoming is that we focus purely on simple
contagion effects, where nodes have equal, and independent probabilities of
adopting a behavior. Complex contagion (where individuals require social
affirmation from multiple sources) has been observed for certain social
settings, including sharing of hashtags on social media (?), social bots (?),
and certain online behaviors (?). The nature of contagion depends on the type
of the situation, and whether interactions happen at a local, or global,
level. We focus on simple contagion because it is believed to be the main
factor in information spreading (?). For example, if a person is looking for a
new job, it is more beneficial to receive information from the global network,
via weak ties, rather than just from close friends and family (?). However,
future work should understand how information inequalities develop in complex
contagion scenarios. Further, the current study focuses on static and
undirected networks, but information propagation in real world often occurs
through directed and temporal connections. Extending the framework to such
networks and investigating if similar inequalities emerge is an equally
important direction for future work.

Lastly, our definition of information inequality relies on benchmarking
existing methods to random information spreading scenarios, as this is the
most ‘fair’ system we can imagine. Other definitions can also be used, and
future work should focus on testing them. Independent of the choice of
definition, it is vital that inequalities, which arise, or are amplified, as
result of algorithms, be quantified and measured. As our world is becoming
increasingly digitalized, access to correct, timely, and factual information
will grow in significance. As such, it is critical to know how well algorithms
which deal with information dissemination and delivery work, and which groups
and individuals they leave behind.

## References

  * 1. D. Centola, Science 329, 1194 (2010).
  * 2. N. A. Christakis, J. H. Fowler, New England journal of medicine 357, 370 (2007).
  * 3. J. S. Coleman, E. Katz, H. Menzel, Medical innovation: A diffusion study (Bobbs-Merrill Co, 1966).
  * 4. E. M. Rogers, Diffusion of innovations (Simon and Schuster, 2010).
  * 5. A. Banerjee, A. G. Chandrasekhar, E. Duflo, M. O. Jackson, Science 341, 1236498 (2013).
  * 6. J. Cai, A. De Janvry, E. Sadoulet, American Economic Journal: Applied Economics 7, 81 (2015).
  * 7. J. H. Fowler, N. A. Christakis, Bmj 337, a2338 (2008).
  * 8. J. Berger, G. Le Mens, Proceedings of the National Academy of Sciences 106, 8146 (2009).
  * 9. S. González-Bailón, J. Borge-Holthoefer, A. Rivero, Y. Moreno, Scientific reports 1, 197 (2011).
  * 10. R. M. Bond, et al., Nature 489, 295 (2012).
  * 11. L. Beaman, A. BenYishay, J. Magruder, A. M. Mobarak, Working Paper (2015).
  * 12. C. B. Barrett, M. A. Constas, Proceedings of the National Academy of Sciences 111, 14625 (2014).
  * 13. G. F. Chami, et al., Clinical Infectious Diseases 62, 200 (2016).
  * 14. M. Alexander, L. Forastiere, S. Gupta, N. A. Christakis, Proceedings of the National Academy of Sciences 119, e2120742119 (2022).
  * 15. S. P. Borgatti, Computational & Mathematical Organization Theory 12, 21 (2006).
  * 16. F. Radicchi, C. Castellano, Physical Review E 95, 012318 (2017).
  * 17. D. Kempe, J. Kleinberg, É. Tardos, Proceedings of the ninth ACM SIGKDD international conference on Knowledge discovery and data mining (ACM, 2003), pp. 137–146.
  * 18. W. Chen, Y. Wang, S. Yang, Proceedings of the 15th ACM SIGKDD international conference on Knowledge discovery and data mining (ACM, 2009), pp. 199–208.
  * 19. M. Kitsak, et al., Nature Physics 6, 888 (2010).
  * 20. S. Pei, L. Muchnik, J. S. Andrade Jr, Z. Zheng, H. A. Makse, Scientific reports 4, 5547 (2014).
  * 21. A. Y. Lokhov, D. Saad, Proceedings of the National Academy of Sciences p. 201614694 (2017).
  * 22. S. Aral, P. S. Dhillon, Nature Human Behaviour p. 1 (2018).
  * 23. Y. Chen, G. Paul, S. Havlin, F. Liljeros, H. E. Stanley, Physical review letters 101, 058701 (2008).
  * 24. F. Morone, H. A. Makse, Nature 524, 65 (2015).
  * 25. P. Clusella, P. Grassberger, F. J. Pérez-Reche, A. Politi, Physical review letters 117, 208301 (2016).
  * 26. L. Zdeborová, P. Zhang, H.-J. Zhou, Scientific reports 6 (2016).
  * 27. S. Mugisha, H.-J. Zhou, Physical Review E 94, 012305 (2016).
  * 28. A. Braunstein, L. Dall’Asta, G. Semerjian, L. Zdeborová, Proceedings of the National Academy of Sciences p. 201605083 (2016).
  * 29. N. Eagle, M. Macy, R. Claxton, Science 328, 1029 (2010).
  * 30. R. Chetty, et al., Nature 608, 108 (2022).
  * 31. R. Chetty, et al., Nature 608, 122 (2022).
  * 32. B. Fish, et al., The World Wide Web Conference (2019), pp. 480–490.
  * 33. A.-A. Stoica, A. Chaintreau, Companion Proceedings of The 2019 World Wide Web Conference (2019), pp. 569–574.
  * 34. A.-A. Stoica, J. X. Han, A. Chaintreau, Proceedings of The Web Conference 2020 (2020), pp. 2089–2098.
  * 35. Z. S. Jalali, W. Wang, M. Kim, H. Raghavan, S. Soundarajan, Proceedings of the 2020 SIAM International Conference on Data Mining (SIAM, 2020), pp. 613–521.
  * 36. S. Luo, F. Morone, C. Sarraute, M. Travizano, H. A. Makse, Nature communications 8, 15227 (2017).
  * 37. M. McPherson, L. Smith-Lovin, J. M. Cook, Annual review of sociology 27, 415 (2001).
  * 38. Y. Leo, E. Fleury, J. I. Alvarez-Hamelin, C. Sarraute, M. Karsai, Journal of The Royal Society Interface 13, 20160598 (2016).
  * 39. F. Karimi, M. Génois, C. Wagner, P. Singer, M. Strohmaier, Scientific reports 8 (2018).
  * 40. W. L. Shirley, B. J. Boruff, S. L. Cutter, Hazards Vulnerability and Environmental Justice (Routledge, 2012), pp. 143–160.
  * 41. B. L. Turner, et al., Proceedings of the national academy of sciences 100, 8074 (2003).
  * 42. A. Tsang, B. Wilder, E. Rice, M. Tambe, Y. Zick, arXiv preprint arXiv:1903.00967 (2019).
  * 43. X. Wang, O. Varol, T. Eliassi-Rad, Applied Network Science 7, 1 (2022).
  * 44. H. Heidari, C. Ferrari, K. Gummadi, A. Krause, Advances in neural information processing systems 31 (2018).
  * 45. J. Goldenberg, B. Libai, E. Muller, Marketing letters 12, 211 (2001).
  * 46. R. Albert, H. Jeong, A.-L. Barabási, nature 406, 378 (2000).
  * 47. A.-L. Barabási, R. Albert, science 286, 509 (1999).
  * 48. A. D. Broido, A. Clauset, arXiv preprint arXiv:1801.03400 (2018).
  * 49. SocioPatterns, Infectious contact networks. Http://www.sociopatterns.org/datasets/. Accessed 09/12/12.
  * 50. L. A. Adamic, N. Glance, Proceedings of the 3rd international workshop on Link discovery (ACM, 2005), pp. 36–43.
  * 51. T. Opsahl, P. Panzarasa, Social networks 31, 155 (2009).
  * 52. E. Cho, S. A. Myers, J. Leskovec, Proceedings of the 17th ACM SIGKDD international conference on Knowledge discovery and data mining (ACM, 2011), pp. 1082–1090.
  * 53. J. Leskovec, J. Kleinberg, C. Faloutsos, ACM Transactions on Knowledge Discovery from Data (TKDD) 1, 2 (2007).
  * 54. M. Akbarpour, S. Malladi, A. Saberi, Available at SSRN (2017).
  * 55. G. F. Chami, S. E. Ahnert, N. B. Kabatereine, E. M. Tukahebwa, Proceedings of the National Academy of Sciences p. 201700166 (2017).
  * 56. E. M. Airoldi, N. A. Christakis, Science 384, eadi5147 (2024).
  * 57. M. Garcia-Herranz, E. Moro, M. Cebrian, N. A. Christakis, J. H. Fowler, PloS one 9, e92413 (2014).
  * 58. Z. Obermeyer, B. Powers, C. Vogeli, S. Mullainathan, Science 366, 447 (2019).
  * 59. M. H. Ribeiro, R. Ottoni, R. West, V. A. Almeida, W. Meira Jr, Proceedings of the 2020 conference on fairness, accountability, and transparency (2020), pp. 131–141.
  * 60. R. L. Thomas, D. Uminsky, Patterns 3, 100476 (2022).
  * 61. A. Ishizaka, P. Nemery, Multi-criteria decision analysis: methods and software (John Wiley & Sons, 2013).
  * 62. United Nations General Assembly, Transforming our world: the 2030 Agenda for Sustainable Development, https://sustainabledevelopment.un.org/post2015/transformingourworld (2015).
  * 63. N. Mehrabi, F. Morstatter, N. Saxena, K. Lerman, A. Galstyan, ACM computing surveys (CSUR) 54, 1 (2021).
  * 64. F. Coró, G. D’angelo, Y. Velaj, ACM Transactions on Knowledge Discovery from Data (TKDD) 15, 1 (2021).
  * 65. J. Leskovec, et al., Proceedings of the 13th ACM SIGKDD international conference on Knowledge discovery and data mining (2007), pp. 420–429.
  * 66. C. Budak, D. Agrawal, A. El Abbadi, Proceedings of the 20th international conference on World wide web (2011), pp. 665–674.
  * 67. C. Wagner, et al., Nature 595, 197 (2021).
  * 68. I. Chami, S. Abu-El-Haija, B. Perozzi, C. Ré, K. Murphy, Journal of Machine Learning Research 23, 1 (2022).
  * 69. L. Peel, T. P. Peixoto, M. De Domenico, Nature Communications 13, 6794 (2022).
  * 70. D. M. Romero, B. Meeder, J. Kleinberg, Proceedings of the 20th international conference on World wide web (2011), pp. 695–704.
  * 71. B. Mønsted, P. Sapieżyński, E. Ferrara, S. Lehmann, PloS one 12, e0184148 (2017).
  * 72. D. Centola, M. Macy, American journal of Sociology 113, 702 (2007).
  * 73. M. S. Granovetter, American journal of sociology 78, 1360 (1973).
  * 74. C. Castellano, R. Pastor-Satorras, The European Physical Journal B 89, 243 (2016).
  * 75. F.-A. Fortin, F.-M. De Rainville, M.-A. Gardner, M. Parizeau, C. Gagné, Journal of Machine Learning Research 13, 2171 (2012).

## Acknowledgments

MGH and ID want to thank AECID (Spanish Agency for International Development
Cooperation) for their support to data innovation and Frontier Data
Technologies through UNICEF’s Frontier Data Network. MC wishes to acknowledge
the following funding: Ministerio de Ciencia, Innovación y Universidades” y a
la ”Convocatoria de la Universidad Carlos III de Madrid de Ayudas para la
recualificación del sistema universitario español para 2021-2023, de 1 de
julio de 2021” en base al Real Decreto 289/2021, de 20 de abril de 2021 por el
que se regula la concesión directa de subvenciones a universidades públicas
para la recualificación del sistema universitario español”. Furthermore, MC is
thankful for the support of project “Ayuda PID2022-137243OB-I00 financiada por
MCIN/AEI/10.13039/501100011033” and by “FEDER Una manera de hacer Europa”. EM
acknowledges support by the National Sience Foundation under grant No.
2218748.

## Methods

#### Independent cascade model

The ICM process is as follows: at time $t=0$ all nodes are inactive, except
for a set of initial seed nodes. At each time step $t$ an activated node $i$
will contacts all its neighbors, which have previously not been activated, and
try to activate them according to an independent transmission probability $p$.
After attempting to activate all its neighbors a node becomes inactive and
cannot be activated again in subsequent stages of the dynamic. The process is
iterated until no more active nodes remain.

#### Infection probability

For ICM the only parameter is the activation probability $p$ (probability of
convincing people to adopt a behavior); a too high probability will correspond
to a global information cascade with the full network adopting a behavior, a
too low would entail no information spreading. We set $p=p_{c}$ where $p_{c}$
is the critical probability separating the region of the phase diagram where
cascades (outbreaks) are subextensive ($p<p_{c}$) from the supercritical
region ($p>p_{c}$) where outbreaks reach a finite fraction of the whole
network (?). For each network we calculate the critical value of the
transmission probability ($p_{c}$) as the position of the maximum of the
susceptibility $\langle s^{2}\rangle/\langle s\rangle^{2}$, where $\langle
s^{n}\rangle$ is the n-th moment of the outbreak size distribution computed
for random selected initial single spreaders (?). See the Supplementary
Information for more information.

#### Fair Influence Maximization

We have implemented a simple version of a non-dominated sorting genetic
algorithm (NSGAIII) using the distributed evolutionary algorithms in python
(DEAP) library (?). The code is freely available at [link]. Briefly, the main
modelling set-up is the following:

  * •

Individual sets are sets of nodes.

  * •

Initialization is performed by generating one set of individuals with each of
the heuristics mentioned in this paper and the rest completely at random.

  * •

Crossover of two individual sets is performed by generating the union of both
sets and choosing from that sets the seeds for both new individuals at random.

  * •

Mutation is composed of two operators that are performed with different
frequencies:

    1. 1.

Random where $10\%$ of the seeds are removed from a individual set and new
ones selected at random.

    2. 2.

Tabu-like where one seed is removed at random and a certain number (or all) of
random seeds are inspected for addition to the set, and the one with lowest
vulnerability is finally selected.

All experiments on empirical networks were run with a population of $100$
individual sets, a mximum of $100$ generations, crossover probability of
$0.8$, mutation probability of $1$, Tabu-like mutation frequency of $0.4$ and
size of the tabu neighborhood of $20\%$ of the total number of nodes on the
network.


[a]Shandong University,
Qingdao,Shandong, 266237, China [b]Key Laboratory of Particle Physics and
Particle Irradiation (MOE), Shandong University,
Qingdao, Shandong, 266237, China [c]University of Science and Technology of
China,
HeFei, Anhui, 230026, China [d]State Key Laboratory of Particle Detection and
Electronics Department of Modern Physics,
HeFei, Anhui, 230026, China [e]Shandong Institute of Advanced Technology,
Jinan, Shandong, 250100, China<EMAIL_ADDRESS>
# Design and Development of the Core Software for STCF Offline Data Processing

W. H. Huang  H. Li  H. Zhou  T. Li  Q. Y. Li  X. T. Huang Corresponding author

###### Abstract

The Super Tau Charm Facility (STCF) is a proposed electron-positron collider
working at $\sqrt{s}=2\sim 7$ GeV, and the peak luminosity is designed to be
above $0.5\times 10^{35}cm^{-2}s^{-1}$. The huge amount of scientific data
brings great challenges to the offline data processing software, including the
Monte Carlo simulation, calibration, reconstruction as well as the data
analysis. To facilitate efficient offline data processing, the offline
software of Super Tau Charm Facility (OSCAR) is developed based on SNiPER, a
lightweight framework designed for HEP experiments, as well as a few state-of-
art software in the HEP community, such as podio and DD4hep.

This paper describes the design and implementation of the core software of the
OSCAR, which provides the foundation for the development of complex algorithms
to be applied on the large data sets produced by STCF, particularly the way to
integrate the common HEP software toolkits, such as Geant4, DD4hep and podio,
into SNiPER. The software framework also provides a potential solution for
other lightweight HEP experiments as well.

Core software; Offline data processing; STCF; OSCAR; SNiPER [c]

##  1 Introduction

The Super Tau Charm Facility (STCF) [1] is a new-generation facility of
electron positron collider operating at center-of-mass energies of $2-7$ GeV,
the transition region between perturbative and non-perturbative quantum
chromodynamics. STCF will play a leading role in the tau, charm and hadron
physics of high energy physics intensity frontier in the world. The peak
luminosity of STCF is designed to be $0.5\times 10^{35}cm^{-2}s^{-1}$, almost
two orders of magnitude higher than the present Tau-Charm factory. Meanwhile,
STCF is expected to produce huge amount of scientific data, which poses many
challenges to the STCF detector, online data acquisition (DAQ) as well as
offline data processing. STCF is currently under extensive exploration with a
technology research and development program covering design and optimization
of the STCF accelerator, detector, trigger, DAQ and offline software. To
facilitate current detector conceptual design, physics potential studies as
well as future raw data analysis, an offline software of Super Tau Charm
Facility (OSCAR) is designed and developed to provide a common and high
performance platform for STCF offline applications, including physics
generators, detailed detector simulation, data calibration, event
reconstruction as well as physics analysis.

[height=180pt, width=140pt]generaldesignnew.png

Figure 1: The architecture of OSCAR.

The architecture of OSCAR is depicted in Figure 1. It mainly consists of three
layers: the bottom layer is for external libraries, the middle layer is for
the core software and the top layer is for STCF specific applications.
External libraries used by OSCAR contain the software and toolkits not only
frequently used in HEP experiments, like ROOT [2] and Geant4 [3], but also
some of the Common Turnkey Software Stack (Key4hep) [4], such as DD4hep [5]
and podio [6], which are adopted for the detector description and the event
data model, respectively. The core software mainly consists of an underlying
framework, parallel computing supports, event data model and a data management
system. It provides key and common functionalities for the whole offline data
processing. Experiment specific applications refer to the software of physics
generators, detector simulation, digitization, calibration, reconstruction as
well as physics analysis, which are developed based on the functionalities and
interfaces provided by the core software. Therefore, the core software plays
very crucial roles for performance of OSCAR.

This paper aims to present the design and implementation of the core software
of OSCAR. Section 1 gives a brief introduction to the offline software system.
Section 2 outlines the challenges and requirements of STCF offline software.
In Section 3, the implementation of the core software of OSCAR is described in
more detail, including the SNiPER framework and its parallel computing
supports, the event data model, the management of event data as well as
detector data. Section 4 presents some performance of applications developed
based on the core software. Finally, Section 5 summarizes the current status
and gives an outlook on the development of OSCAR.

##  2 Requirements and Design

###  2.1 Requirements and Challenges

The core software is the base of the whole offline software. It builds the
skeleton of the offline software for all application developers and physicists
to develop their application algorithms, services and tools for event
generators, detector simulation, event reconstruction and physics analysis.
Furthermore, the wide center-of-mass energy covering region, high peaking
luminosity as well as high readout channel density of the STCF accelerator and
detector pose severe challenges for the core software of OSCAR.

$\bullet$High event rate and huge data volume. The center-of-mass energy
region of STCF spans from 2 to 7 GeV and event rates vary with different
center-of-mass energies. The highest one is estimated to be approximately 400
kHz at $J/\psi$ peak. In one operating year, STCF will collect the order of
$10^{12}$ $J/\psi$ data sample. In addition, the average event size is
expected about 45.7 KB. Therefore, the total data volume of raw data could
reach the order of 100 PB per year. All of the data produced in one year
should be fully reconstructed in less than six months for physics analysis.
Furthermore, at least the same size of the Monte Carlo (MC) data will be
produced for systematical uncertainty study. So the core software should adopt
versatile technologies to meet these requirements and challenges.

$\bullet$Long timescale and high flexibility. The STCF team has completed the
preliminary conceptual design and delivered the Conceptual Design Report at
the end of 2022. Now the key technology research and development projects are
expected to be finished and a Technology Design Report will be released by the
end of 2025. STCF is expected to start commissioning in 2031-2033 after 5-7
years’ construction and to keep operating for 10-15 years. During such a long
timescale, OSCAR serves as the key software system for the offline data
processing and physics analysis. So the core software should have good
friendliness for developers and physicists as well as high flexibility for new
technologies, including machine learning and parallel computing.

###  2.2 Overall Design

To meet the requirements and challenges above, the core software of the OSCAR
is designed with following key criteria:

$\bullet$ Parallelism. Given the huge data volume produced at STCF each year,
parallelism is one of the necessary options for the OSCAR to speed up the data
processing and meet the physics requirements. As a kernel part of the OSCAR,
the core software provides key functionalities of event data processing
mechanism, data management as well as Input/Output (I/O) system. Therefore,
parallel computing should be well supported with versatile technologies.

$\bullet$ Modularity and Low Coupling. OSCAR consists of lots of components
and packages for different applications which evolve with the design,
construction and operation of STCF. The core software should provide
mechanisms to ensure modulariy of OSCAR and low coupling between different
components. In this way, every component takes care of specific functionality
and provides well defined interfaces by which different components interact
with each other. At the same time, key components should be independent with
each other and shield the implementation of certain functionality from
technologies adopted by OSCAR.

$\bullet$ Flexibility, Stability and Compatibility. Given the long lifetime of
STCF, the core software should provide standard interfaces for developers and
physicists to easily plug in their applications in term of specific
algorithms. Meanwhile, the impact of changes from new software or technologies
should be minimized for users.

##  3 Key Components and Implementations

The core software for STCF offline data processing adopts SNiPER as the
underlying framework. Intel Threading Building Blocks (TBB) [7] based MT-
SNiPER [8] provides well support for parallel computing within SNiPER. The
data management system handles not only event data but also detector data.
Together with OSCAR based applications, the event data model and event data
management system form the key components of offline event data processing and
data flow as shown in Figure 2. The event data model defines event data
objects for different applications including simulation, digitization,
reconstruction and analysis, which are developed based on the interfaces of
SNiPER framework. Every application is a producer and/or consumer of event
data for other stages. All applications retrieve event data from the event
data management system and register updated event data or new event data back
to the event data management system. The event data in different application
stages contains different kinds of event information as illustrated in Figure
5. It could be written out to the disk as the format of root files and be read
from root files back in any stage. All the data files will be well managed by
a file catalogue management system and would be accessed with the meta data by
users. These key components and their implementations are described in more
detail as following.

[width=0.98]dataflow.png

Figure 2: The STCF data processing applications and data flow.

###  3.1 SNiPER Framework

SNiPER is a lightweight software developed for HEP experiments and has been
successfully used in a few experiments, such as Jiangmen Underground Neutrino
Observation (JUNO) [9], Large High Altitude Air Shower Observation (LHAASO)
[10], Neutrinoless double beta decay experiment (nEXO) [11] and so on.
Distinguishing features of SNiPER are described as follows:

[height=8pc, width=18pc]task.png

Figure 3: Components trees in _Task_ s.

$\bullet$ Support flexible event processing sequences. As shown in Figure 3,
the unit of SNiPER is _Task_ , where developers can embed their _Algorithm_ s
and _Service_ s to perform certain manipulation on event data. Each _Task_
instance has its own _DataStore_ , which handles even data in the memory and
manages its lifetime. With this mechanism, every _Task_ controls its own event
loop independently. Furthermore, SNiPER provides well support for multiple
_Task_ s. As shown in Figure 4, typical multiple _Task_ s are built with a
nested _Task_ structure which can be easily configured in a single SNiPER job.
_Algorithm_ s in one _Task_ would be executed in order and _Algorithm_ s in
_Sub-Task_ should be executed on demand with the _Incident_ mechanism. For
example, in an event mixing procedure, signal and background samples are
produced independently. Then each sample can be configured as an input for
each _Sub-Task_ instance. In this way, the event mixing algorithm in upper
_Task_ triggers signal and background inputs on demand according to signal-to-
noise ratio.

[width=0.75height=13pc]sequence.png

Figure 4: Conditional execution of multiple _Task_ s.

$\bullet$ Support custom data management and I/O. SNiPER defines the abstract
interfaces for applications to access to event data from the data management
system and provides a novel mechanism to manage multiple events within certain
time windows (called event buffering). In addition, SNiPER does not constrain
implementations of data management and I/O system based on experiment specific
requirements. For instance, a first input first output (FIFO) data buffer [12]
is developed, which enables high efficiency data access and storage, as well
as the capability to retrieve the events within a defined time window. FIFO
data buffer stores adjacent events and provides a sophisticated method of
memory updating. When turning off the time window, FIFO serves as a buffer
which holds event data objects only for one independent event.

$\bullet$Support parallel computing. With multiple _Task_ s and FIFO , SNiPER
has intrinsic superiorities in parallel computing. To simplify the development
of paralleled applications, MT-SNiPER is developed as a non-invasive wrapper
of SNiPER kernel modules, so that it is almost transparent for developers and
physicists to execute their applications in parallel without much
modifications. The implementation of parallelism of the OSCAR will be further
discussed in Section 3.2.3.

###  3.2 Event Data Model and Data Management

Event data model, serving as the heart part of offline software, does not only
define event information and correlations between event data objects in
different processing stages, but also provides interfaces and communication
channels between different application algorithms as well. The data management
system is the fundamental component for event data transmissions,
communications between OSCAR based applications and data version control in
offline data processing. Furthermore, the data management system should
provide well supports for parallel computing throughout all stages of data.
Therefore, event data model and data management are very essential and the
most complicated components for the design and development of the STCF offline
software system.

####  3.2.1 Event Data Model Based on Podio

During the offline data processing, application algorithms would not directly
use event data objects in the persistency store (persistent data), but
instead, use event data objects in memory (transient data). In OSCAR, both
persistent data and transient data are defined with one set of description for
event data objects. Therefore, it is crucial to design an efficient event data
model that meets all use cases in offline data processing and physics
analysis.

[width=0.98height=20pc]datamodel.png

Figure 5: Podio based event data model for STCF.

Traditional HEP event data models are heavily object oriented. These kinds of
event data objects do have good encapsulation on event information and play
very important roles in past decades. However, they are not so suitable for
parallel computing. Now, a new C++ toolkit to define event data models with
plain-old-data data structures and high efficient I/O performance (podio) is
emerging. Podio favors composition over inheritance and has well supports for
parallel computing. The EDM4hep, aiming to design a common event data model
for future collider experiments, has been developed based on podio and been
adopted by Future Circular Collider (FCC) [13], The Circular Electron Positron
Collider (CEPC) [14] and some other experiments. The event data model for STCF
is also developed based on podio. The event information and relationships
between different event data objects are described in yaml [15] files, based
on which C++ code for event data classes are automatically generated.
According to compositions of the STCF detector, the classes for MC simulation
(MC Truth and MC Data) and reconstruction (DST) are defined as described in
Figure 5. For instance, _ECALShower_ , _ECALCluster_ , _ECALRecHit_ are
created for Electromagnetic Calorimeter (ECAL) reconstruction and _ECALHit_ ,
_ECALPoint_ are created for ECAL simulation. For other sub detectors, like
Inner Tracker, Main Drift Chamber (MDC) and Particle Identification (PID),
corresponding classes are also created. Meanwhile, the relationships between
different event data objects are implemented with “one to many” or “one to
one” mechanism. In Figure 5, single arrow between classes means they have the
“one to one” relationship while multiple arrows between classes represents the
“one to many” relationship. With this strategy and implementation, the event
data model for STCF is naturally thread-safe and provides well supports for
parallel computing.

####  3.2.2 Event Data Management for Serial Computing

Both SNiPER and podio have their own event data management system. Therefore,
integrating the event data management of podio into OSCAR is a more vital and
complicated procedure in order to use podio based event data model
efficiently. The first step of the integration is adopting podio based event
data model in the serial computing of OSCAR.

[height=180pt, width=200pt]datastoreinpodio.png

Figure 6: Event data management for serial computing.

The event data management of podio mainly consists of three parts:
_EventStore_ handles transient data, while _ROOTReader_ and _ROOTWriter_
manage data input and output, respectively. As illustrated in Figure 6,
_PodioDataSvc_ , _PodioInputSvc_ , _PodioOutputSvc_ and _DataHandle_ are
developed to integrate podio within OSCAR. Based on _EventStore_ of podio,
_PodioDataSvc_ is developed to manage transient event data within OSCAR. In
one _Task_ , there is a pair of _Incident_ s named _BeginEvtHdl_ and
_EndEvtHdl_. Both _BeginEvtHdl_ and _EndEvtHdl_ are triggered automatically at
the beginning and end of an event loop, respectively. Via _PodioDataSvc_ ,
_PodioInputSvc_ is invoked by _BeginEvtHdl_ to convert persistent event data
from files into transient event data in _EventStore_ , while _PodioOutputSvc_
is invoked by _EndEvtHdl_ to perform conversion from transient event data in
_EventStore_ into persistent event data in files. _DataHandle_ is developed as
an user end template class to provide interfaces of identifying and accessing
event data objects from _PodioDataSvc_. In this way, the event data management
system and event data model could match together and work in serial computing
within OSCAR. Many simulation and reconstruction algorithms have been
developed based on them.

####  3.2.3 Event Data Management for Parallel Computing

To speed up data processing and make full use of computing resources, parallel
computing should be well supported by not only the underlying SNiPER but also
the podio compatible OSCAR. MT-SNiPER is developed to support the parallelism
of SNiPER based on Intel TBB. Multiple SNiPER Task Scheduler (_Muster_) [8] is
one of key components of MT-SNiPER. When using _Muster_ , multiple instances
of _Task_ would be created and their corresponding TBB-based _Worker_ s are
also automatically created for multiple threads’ execution.

[width=0.98height=13pc]parr.png

Figure 7: Event data management for parallel computing.

Since _Muster_ already provides the task scheduler for parallel computing,
design and development of an event data management system for parallel
computing in podio compatible OSCAR is an important assignment. As illustrated
in Section 3.2.1 and 3.2.2, the event data model for STCF is developed based
on podio. However, podio handles event data in memory with _EventStore_ ,
which only holds data objects for one single event. To fulfill requirements of
parallel computing, a new mechanism called _GlobalBuffer_ is developed to hold
multiple transient data objects simultaneously. _GlobalBuffer_ manages most of
the information which are managed by _EventStore_ but for multiple events.
Furthermore, it decouples the I/O function from the _EventStore_ and assigns
reading and writing to two dedicated threads, _Input Thread_ and _Output
Thread_ , respectively. As illustrated in Figure 7, the _Input thread_ would
read several event objects and transform them to the _GlobalBuffer_ until the
_GlobalBuffer_ reaches the _Watermark_ , a configurable variable to define the
number of events. All the events stored in _GlobalBuffer_ have _READY_ or
_FINISH_ status. When an event is tagged as _REDAY_ , _Muster_ scheduler would
send it to one dedicated _Worker_ for processing. When completed, the event
would be tagged as _FINISH_ , and finally the _Output Thread_ would write the
event into a file as persistent data. Then the _GlobalBuffer_ would clear the
space of this event and wait for next event loop.

With this design, a typical sequence of parallel job could be described as
follows: There is one dedicated single thread for reading/writing and the
transient data to/from a _GlobalBuffer_ which simultaneously holds multiple
events. When processing, different events are dispatched to different _Worker_
s. _Muster_ is mainly based on Intel TBB’s scheduler, and it creates these
_Worker_ s and manages their lifetime. Then _Worker_ s can be executed in
threads concurrently. When a _Worker_ is invoked, it grabs and locks an event
from _GlobalBuffer_ until it is completed. During the execution of a _Worker_
, the event is handled by a thread local SNiPER _Task_. This feature ensures
that a _Worker_ looks the same as a serial SNiPER application. When an event
is completed, _Worker_ s would try to send it to a dedicated writing thread.
As a successful application, parallel simulation based on SNiPER TBB has been
adopted in JUNO by integrating Geant4 into _Muster_ , which achieves a linear
speedup for simulation [16].

####  3.2.4 Detector Data Management Based on DD4hep

To facilitate the detailed detector simulation, a detector simulation
framework has been developed as a middleware between Geant4 and SNiPER. It
consists of the integration of Geant4 and SNiPER, configurable user
interfaces, geometry management and modularized user actions [16]. Based on
DD4hep, a geometry management system (GMS)[17] is also designed to provide a
consistent detector description for simulation, reconstruction and
visualization. In GMS, the library of elements and materials is shared and
each sub-detector is described in a separated XML file, while the full
detector is defined and configured in a mother XML file. Each sub-detector has
a version number in order to support different design schemes.

[width=0.98]ddxmlsvc.png

Figure 8:  Data flow of geometry information managed with _DDXMLSvc_.

A service for detector description in XML format (_DDXMLSvc_) is developed to
manage detector data as a middleware between DD4hep and OSCAR. It manages
transformations of detector descriptions for simulation, reconstruction and
visualization. When transmitted into _DDXMLSvc_ , the detector geometry
defined in XML would be parsed and constructed into corresponding sub-
detectors or the full detector. Thus, _DDXMLSvc_ has all the information of
detectors. Information would be delivered to different plugins of DD4hep on
demand. For example, information of detector would be delivered to DDG4 [18]
to transform the geometry into Geant4 format and then used by the detector
simulation. Similarly, DDRec [18] for reconstruction and DDEve [18] for
visualization are also integrated, as illustrated in Figure 8. With current
implementations, OSCAR fully supports simulation, reconstruction and
visualization work with one single source geometry definition, which naturally
guarantees the consistency of geometry information in different applications.

##  4 Performance

Based on the functionality of the core software, the MC data production chain
has been set up, including event generator, full detector simulation and event
reconstruction. A typical exclusive process $e^{+}e^{-}\to
J/\psi\to\rho(\to\pi^{+}\pi^{-})\pi^{0}(\to\gamma\gamma)$ is used to
commission the underlying algorithms and validate the basic software function.
The known decays $J/\psi\to\rho(\to\pi^{+}\pi^{-})\pi^{0}(\to\gamma\gamma)$
are generated by STCFEvtGen, which is reused from BesEvtGen[19]. The $J/\psi$
resonance in electron positron collision is simulated by the MC event
generator KKMC [20]. Objects of final-state particles, including charged
tracks ($\pi^{+}\pi^{-}$)and neutral photon showers, are reconstructed with
simulated hits through the full reconstruction algorithms.

(a)

(a) *

(b)

(b) *

(c)

(c) * Figure 9:  Plot (a) shows the invariant mass of reconstructed $\pi^{0}$
particles ($M_{\gamma\gamma}$), plot (b) shows the invariant mass of
reconstructed $\rho$ particles ($M_{\pi^{+}\pi^{-}}$) and plot (c) shows the
invariant mass of reconstructed $J/\psi$ particles ($M_{\rho\pi^{0}}$) . The
dots with error bars indicate MC samples and the red solid lines indicate the
fit results of the distribution. In the fit, the $M_{\gamma\gamma}$
distribution in plot (a) and $M_{\rho\pi^{0}}$ distribution in plot (c) are
modeled by Crystal-Ball function and the $M_{\pi^{+}\pi^{-}}$ distribution in
plot (b) is described with Breit-Wigner function.

[width=0.3]mpi0.png [width=0.3]mrho.png [width=0.3]mjpsi.png

For each $J/\psi$ candidate, it is required to have two charged tracks with
zero net charge and at least two good photons. To suppress final state
radiation photons, the angle between photon and the original direction of the
nearest charged track must be greater than $15^{\circ}$. The combination with
the closest mass to $\pi^{0}$ is considered to be from $\pi^{0}$. The
invariant mass distributions of $\pi^{0}$ ($M_{\gamma\gamma}$), $\rho(770)$
($M_{\pi^{+}\pi^{-}}$) and $J/\psi$ ($M_{\rho\pi^{0}}$) are shown in Figure
9(a) (a), (b) and (c), respectively. The Crystal-Ball function is used to
describe the $M_{\gamma\gamma}$ and $M_{\rho\pi^{0}}$ distribution, and the
Breit-Wigner function is used to describe the $M_{\pi^{+}\pi^{-}}$
distribution. The fitted results are $133.9\pm 6.2$ MeV, $3085.2\pm 32.1$ MeV
and (M, $\Gamma$) = ($773.6\pm 0.9$ MeV, $144.8\pm 2.1$ MeV), respectively. In
the MC sample, the input values of $\pi^{0}$, $\rho(770)$ and $J/\psi$ are
quoted from PDG [21], and they are $134.9770\pm 0.0005$ MeV, $775.26\pm 0.25$
MeV, and $3096.900\pm 0.006$ MeV. The reconstructed value and corresponding
input value are in good agreement, indicating that the reconstruction of the
signal process works well.

At present, a test run of the simulation software is implemented on a
dedicated high performance computing cluster under CENTOS 7. Together with the
job submission system, large amount of MC samples have been generated, which
can be used in further studies of the detector performance and physical
potential capabilities.

##  5 Conclusion

In this paper, we present the design and development of the core software of
the STCF Offline Data Processing Software, which is based on SNiPER and
adopted new technologies and tools, such as DD4hep and podio. Based on current
implementations, a chain for full simulation and reconstruction has been set
up and large MC samples have been generated for detector performance studies.
The study shows the performance of detector simulation and reconstruction
could fulfill the requirements of STCF. Meanwhile, OSCAR is also provide a
potential solution for other lightweight HEP experiments.

This work was supported by National Natural Science Foundation of China (NSFC)
under Contracts Nos. 12025502, 12105158; the international partnership program
of the Chinese Academy of Sciences under Grant No. 211134KYSB20200057 ; Double
First-Class university project foundation of USTC.

## References

  * [1] H. P. Peng, Y. H. Zheng and X. R. Zhou, Physics 49, no.8, 513-524 (2020)
  * [2] https://root.cern.ch/doc/master/classTObject.html
  * [3] S. Agostinelli et al. [GEANT4], Nucl. Instrum. Meth. A 506, 250-303 (2003)
  * [4] G. Ganis, C. Helsens and V. Völkl, Eur. Phys. J. Plus 137, no.1, 149 (2022)
  * [5] M. Frank, F. Gaede, C. Grefe and P. Mato, J. Phys. Conf. Ser. 513, 022010 (2014)
  * [6] F. Gaede, G. Ganis, B. Hegner, C. Helsens, T. Madlener, A. Sailer, G. A. Stewart, V. Volkl and J. Wang, EPJ Web Conf. 251, 03026 (2021)
  * [7] James Reinders. Intel Threading Building Blocks. O’Reilly Media, Sebastopol, CA, 2007
  * [8] J. Zou, T. Lin, W. Li, X. Huang, Z. Deng, G. Cao and Z. You, EPJ Web Conf. 214, 05026 (2019)
  * [9] F. An et al. [JUNO], J. Phys. G 43, no.3, 030401 (2016)
  * [10] A. Addazi et al. [LHAASO], Chin. Phys. C 46, 035001-035007 (2022)
  * [11] S. A. Kharusi et al. [nEXO], [arXiv:1805.11142 [physics.ins-det]].
  * [12] J. H. Zou, X. T. Huang, W. D. Li, T. Lin, T. Li, K. Zhang, Z. Y. Deng and G. F. Cao, J. Phys. Conf. Ser. 664, no.7, 072053 (2015)
  * [13] A. Abada et al. [FCC], Eur. Phys. J. C 79, no.6, 474 (2019)
  * [14] J. B. Guimarães da Costa et al. [CEPC Study Group], [arXiv:1811.10545 [hep-ex]].
  * [15] https://github.com/yaml
  * [16] T. Lin et al. [JUNO], J. Phys. Conf. Ser. 1085, no.3, 032048 (2018)
  * [17] H. Li, W. H. Huang, D. Liu, Y. Song, M. Shao and X. T. Huang, JINST 16, no.04, T04004 (2021)
  * [18] https://dd4hep.web.cern.ch/dd4hep/reference
  * [19] R. G. Ping, Chin. Phys. C 32, 599 (2008)
  * [20] S. Jadach, B. F. L. Ward and Z. Was, Comput. Phys. Commun. 130, 260-325 (2000)
  * [21] P. A. Zyla et al. [Particle Data Group], PTEP 2020, no.8, 083C01 (2020)