-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossSectionMap.C
110 lines (94 loc) · 3.15 KB
/
crossSectionMap.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "FileParams.h"
#include "HistParams.h"
#include "drawPlotCopy.h"
#include "drawFileParams.h"
#include "crossSection.h"
#include "plotMassCutsReturnHist.h"
#include "TFile.h"
#include "TTree.h"
#include "TH1.h"
#include "TCanvas.h"
#include <stdexcept>
#include "TChain.h"
#include "TMath.h"
#include <string>
#include <climits>
#include <vector>
#include <math.h>
#include "TClass.h"
#include "TGraph.h"
#include "TChain.h"
#include "TTreeReader.h"
#include <fstream>
#include <map>
//std::map<FileParams, double> generateXSecMap();
//std::vector<double> retrieveCrossSections(const std::map<FileParams, double>& xSecMap, Helicity helicity, Interference interference, Particle particle, Lambda lambda);
double weightSum(std::string h);
//Makes a big ol' map, associating all the cross sections with their parameters
std::map<FileParams, double> generateXSecMap()
{
std::map<FileParams, double> xSecMap;
std::ifstream file("crossSections.txt");
double crossSection;
std::string str;
std::vector<double> allCrossSections;
while (std::getline(file, str))
{
allCrossSections.push_back(std::stod(str));
}
int n = 0;
for(Helicity h : {Helicity::LL, Helicity::LR, Helicity::RR})
{
for(Interference i : {Interference::Con, Interference::Des})
{
for(MassRange m : {MassRange::First, MassRange::Second, MassRange::Third})
{
for(Particle p : {Particle::Dielectron, Particle::Dimuon})
{
for(Lambda l : {Lambda::L16000, Lambda::L22000, Lambda::L28000, Lambda::L34000})
{
if (h == Helicity::LL || h == Helicity::RR)
{
FileParams fp(h, i, m, l, p);
xSecMap[fp] = allCrossSections[n];
n++;
}
else
{
double LR = weightSum("LR");
double RL = weightSum("RL");
double k = (2 * allCrossSections[n]) / (RL + LR);
FileParams fpLR(Helicity::LR, i, m, l, p);
FileParams fpRL(Helicity::RL, i, m, l, p);
xSecMap[fpLR] = k * LR;
xSecMap[fpRL] = k * RL;
n++;
}
}}}}}
return xSecMap;
}
//uses the xSecMap to retrieve appropriate cross sections for given parameters
std::vector<double> retrieveCrossSections(const std::map<FileParams, double>& xSecMap, Helicity helicity, Interference interference, Particle particle, Lambda lambda)
{
FileParams fp1(helicity, interference, MassRange::First, lambda, particle);
FileParams fp2(helicity, interference, MassRange::Second, lambda, particle);
FileParams fp3(helicity, interference, MassRange::Third, lambda, particle);
std::cout << "\nRetrieved cross sections: " << xSecMap.at(fp1) << xSecMap.at(fp2) << xSecMap.at(fp3) << std::endl;
return {xSecMap.at(fp1), xSecMap.at(fp2), xSecMap.at(fp3)};
}
//calculates sum of weightRL, weightLR in tree
double weightSum(std::string h)
{
static int counter = 0;
std::cerr << "\nCalculating " << h << " weight sum!!! " << counter;
counter++;
auto chain = new TChain("tree");
chain->Add("/uscms/home/jreiter/MassParameters/sample/*.root");
double sum = 0;
TTreeReader reader(chain);
std::string str = "Test.calcValues.weight" + h;
TTreeReaderValue<Double_t> variable(reader, str.c_str());
while (reader.Next())
sum += *variable;
return sum;
}