20 #include <Eigen/Eigenvalues>
25 namespace ActsExamples {
37 float gaussianValue(TH1F
const* histo,
const float mom) {
39 TH1F* normalised = (TH1F*)histo->DrawNormalized();
40 TH1F* cumulative = (TH1F*)normalised->GetCumulative();
42 const float binContent = cumulative->GetBinContent(cumulative->FindBin(mom));
44 const float value = TMath::ErfInverse(2. * binContent - 1.);
63 return std::sqrt(energy * energy - momentum * momentum);
71 for (
const std::vector<float>&
event : events) {
76 mean /= (float)events.size();
82 for (
unsigned int k = 0;
k < events.size();
k++) {
87 covariance /= (float)events.size();
89 return std::make_pair(mean, covariance);
95 Eigen::EigenSolver<Matrix> es(covariance);
96 Vector eigenvalues = es.eigenvalues().real();
97 Matrix eigenvectors = es.eigenvectors().real();
106 unsigned int nBins) {
109 if (momenta.empty()) {
118 auto meanAndCovariance =
124 return std::make_pair(eigenspaceElements, histos);
135 if (
event.multiplicity == multiplicity &&
event.soft == soft) {
136 const float initialMomentum =
event.initialParticle.absoluteMomentum();
138 std::vector<float> momenta;
139 momenta.reserve(multiplicity + 1);
146 momenta.push_back(sum / initialMomentum);
154 unsigned int nBins) {
156 if (events.empty()) {
159 const unsigned int multMax = events[0].size();
162 std::vector<float>
min(multMax, std::numeric_limits<float>::max());
163 std::vector<float> max(multMax, 0);
164 for (
const std::vector<float>&
event : events) {
165 for (
unsigned int i = 0;
i < multMax;
i++) {
167 max[
i] = std::max(
event[i], max[i]);
173 std::vector<float> diff(multMax);
174 for (
unsigned int i = 0;
i < multMax;
i++) {
175 diff[
i] = (max[
i] - min[
i]) * 0.1;
180 for (
unsigned int i = 0;
i < multMax;
i++) {
181 histos[
i] =
new TH1F(
"",
"", nBins, min[
i] - diff[
i], max[i] + diff[i]);
185 for (
const std::vector<float>&
event : events) {
186 for (
unsigned int i = 0;
i < multMax;
i++) {
196 if (events.empty()) {
199 const unsigned int multMax = events[0].size();
203 for (
const std::vector<float>&
event : events) {
205 std::vector<float> gaussianEvent;
206 for (
unsigned int i = 0;
i < multMax;
i++) {
207 gaussianEvent.push_back(gaussianValue(histos[
i],
event[i]));
210 gaussianEvents.push_back(gaussianEvent);
212 return gaussianEvents;
221 if (
event.multiplicity == multiplicity &&
event.soft == soft) {
222 const auto fourVectorBefore =
event.interactingParticle.fourMomentum();
223 std::vector<float> invariantMasses;
224 invariantMasses.reserve(multiplicity);
228 invariantMasses.push_back(invariantMass(fourVectorBefore, fourVector));
230 result.push_back(invariantMasses);
238 bool soft,
unsigned int nBins) {
241 if (invariantMasses.empty()) {
249 auto invariantMassesGaussian =
251 auto meanAndCovariance =
257 return std::make_pair(eigenspaceElements, histos);
260 std::unordered_map<int, std::unordered_map<int, float>>
262 std::unordered_map<int, std::unordered_map<int, float>> counter;
266 if (
event.finalParticles.empty()) {
270 counter[
event.initialParticle.pdg()][
event.finalParticles[0].pdg()]++;
272 for (
unsigned int i = 1;
i <
event.multiplicity;
i++) {
273 counter[
event.finalParticles[
i - 1].pdg()]
274 [
event.finalParticles[
i].pdg()]++;
279 for (
const auto&
element : counter) {
281 auto prevIt = counter[
element.first].begin();
282 for (
auto it1 = counter[
element.first].begin();
283 it1 != counter[
element.first].end(); it1++) {
285 if (it1 == counter[
element.first].begin()) {
286 binEntry = it1->second;
289 binEntry = it1->second - prevIt->second;
295 it2->second += binEntry;
300 for (
auto it1 = counter[
element.first].begin();
301 it1 != counter[
element.first].end(); it1++) {
308 std::pair<CumulativeDistribution, CumulativeDistribution>
310 unsigned int multiplicityMax) {
312 unsigned int minSoft = std::numeric_limits<unsigned int>::max();
313 unsigned int maxSoft = 0;
314 unsigned int minHard = std::numeric_limits<unsigned int>::max();
315 unsigned int maxHard = 0;
319 maxSoft = std::max(
event.multiplicity, maxSoft);
322 maxHard = std::max(
event.multiplicity, maxHard);
328 new TH1F(
"",
"",
std::min(maxSoft, multiplicityMax) + 1 - minSoft,
329 minSoft,
std::min(maxSoft, multiplicityMax) + 1);
331 new TH1F(
"",
"",
std::min(maxHard, multiplicityMax) + 1 - minHard,
332 minHard,
std::min(maxHard, multiplicityMax) + 1);
334 if (
event.multiplicity <= multiplicityMax) {
336 softHisto->Fill(
event.multiplicity);
338 hardHisto->Fill(
event.multiplicity);
343 return std::make_pair(softHisto, hardHisto);
356 result[0] = counter / (float)events.size();
363 float min = std::numeric_limits<float>::max();
367 max = std::max((
float)
event.interactingParticle.pathInL0(), max);
371 TH1F* histo =
new TH1F(
"",
"", interactionProbabilityBins, min, max);
373 histo->Fill(
event.interactingParticle.pathInL0());