Skip to content

Commit

Permalink
Splitting of DY data sets into CC and NC - all data sets tested and w…
Browse files Browse the repository at this point in the history
…orking
  • Loading branch information
enocera committed Jun 25, 2023
1 parent 1071478 commit a67fdc3
Show file tree
Hide file tree
Showing 70 changed files with 2,701 additions and 14 deletions.
82 changes: 82 additions & 0 deletions buildmaster/filters/ATLASWRAP11.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
This file implements the W production subset of the ATLASWZRAP11CC data set.
This is required to separate CC DY from NC DY.
Implemented by ERN June 2023.
*/

#include "ATLASWRAP11CC.h"

// Central selection
void ATLASWRAP11CCFilter::ReadData()
{

// Opening files
fstream f1;

stringstream datafile("");
datafile << dataPath() << "rawdata/ATLASWZRAP11CC/wzrap11.dat";

f1.open(datafile.str().c_str(), ios::in);

if (f1.fail()) {
cerr << "Error opening data file " << datafile.str() << endl;
exit(-1);
}

// Dummy string
std::string dummy;

// Read the names of systematics
std::string *sysNames = new std::string[fNSys];
sysNames[0] = "UNCORR";
for (int i=0; i<5; i++) f1 >> dummy;
for (int i=0; i<fNSys; i++)
f1 >> sysNames[i];

const int nBins = 2;
const int ndataWZ[nBins] = {11,22}; // Data thresholds for W+ and W-
const double MWZ2[nBins]= {pow(MW,2.0), pow(MW,2.0)}; //Mass squared of W (+ and -)

int low_bin = 0;
for (int b = 0; b < nBins; b++)
{
for (int i = low_bin; i < ndataWZ[b]; i++)
{
double etamin, etamax;

// Kinematics
f1 >> dummy; f1 >> etamin; f1 >> etamax;
fKin1[i] = etamin + (etamax - etamin)/2.0;
fKin2[i] = MWZ2[b];
fKin3[i] = 7000;

// Observable
f1 >> fData[i];
fData[i] *= 1000; // pb -> fb

// Statistical errors - percentage with respect the observable
f1 >> fStat[i];
fStat[i] *= fData[i]*1e-2;

// Correlated systematic errors
for (int l = 0; l < fNSys; l++)
{
f1 >> fSys[i][l].mult;
fSys[i][l].type = MULT;
fSys[i][l].name = sysNames[l];
}

// Additive errors
for (int l = 0; l < fNSys; l++)
fSys[i][l].add = fSys[i][l].mult*fData[i]*1e-2;
}
// Update lowest point in bin
low_bin = ndataWZ[b];
}

delete[] sysNames;

f1.close();
}


130 changes: 130 additions & 0 deletions buildmaster/filters/ATLASWRAP36PB.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
This file implements the W production subset of the ATLASWZRAP36PB data set.
This is required to separate CC DY from NC DY.
Implemented by ERN June 2023.
*/

#include "ATLASWRAP36PB.h"

void ATLASWRAP36PBFilter::ReadData()
{
// Opening files
fstream fWZ[2];

stringstream datafile("");
datafile << dataPath() << "rawdata/ATLASWZRAP36PB/ATLAS-36pb-Wplrap.data";
fWZ[0].open(datafile.str().c_str(), ios::in);

if (fWZ[0].fail()) {
cerr << "Error opening data file " << datafile.str() << endl;
exit(-1);
}

stringstream datafile2("");
datafile2 << dataPath() << "rawdata/ATLASWZRAP36PB/ATLAS-36pb-Wmlrap.data";
fWZ[1].open(datafile2.str().c_str(), ios::in);

if (fWZ[1].fail()) {
cerr << "Error opening data file " << datafile2.str() << endl;
exit(-1);
}

// Starting filter
const double lcorr = 1.0187; // correction factor due to luminosity upgrade
const int ndataWZ[2] = {11,11}; //Number of data for W+, W-
const double convfac = lcorr*1000.; // Must multiply from pb to fb
const double MWZ2[2] = {pow(MW,2.0), pow(MW,2.0)}; //Mass squared of W (+ and -) and Z

string line;
int idat = 0;
double etamin,etamax,tmp;

for (int iWZ = 0; iWZ < 2; iWZ++)
{
// rapidity
getline(fWZ[iWZ],line);
istringstream lstream(line);
for (int i = 0; i < ndataWZ[iWZ]; i++)
{
lstream >> etamin >> etamax;
fKin1[idat+i] = etamin + (etamax-etamin)*0.5;
}

// M_W
for (int i = 0; i < ndataWZ[iWZ]; i++)
fKin2[idat+i] = MWZ2[iWZ];

// sqrt(s)
for (int i = 0; i < ndataWZ[iWZ]; i++)
fKin3[idat+i] = 7000;

// obs
getline(fWZ[iWZ],line);
istringstream lstream2(line);
for (int i = 0; i < ndataWZ[iWZ]; i++)
{
lstream2 >> fData[idat+i];
fData[idat+i] *= convfac;
}

// stat (%, converted later)
getline(fWZ[iWZ],line);
istringstream lstream3(line);
for (int i = 0; i < ndataWZ[iWZ]; i++)
lstream3 >> fStat[idat+i];

// uncorrelated sys
getline(fWZ[iWZ],line);
istringstream lstream4(line);
for (int i = 0; i < ndataWZ[iWZ]; i++)
{
lstream4 >> fSys[idat+i][0].mult;
fSys[idat+i][0].name = "UNCORR";
}

// total correlated sys (unused)
getline(fWZ[iWZ],line);

// total uncertainty (unused)
getline(fWZ[iWZ],line);

// correlated systematics
for (int isys = 2; isys < fNSys; isys++) //2 to skip uncorr and lumi
{
getline(fWZ[iWZ],line);
istringstream lstream(line);
lstream >> tmp;
for (int i = 0; i < ndataWZ[iWZ]; i++)
{
lstream >> fSys[idat+i][isys].mult;
ostringstream sysname;
sysname << "ATLASWZRAP36PB_" << isys-2;
fSys[idat+1][isys].name = sysname.str();
}
}

// luminosity: 3.4%
for (int i = 0; i < ndataWZ[iWZ]; i++)
{
fSys[idat+i][1].mult = 3.5;
fSys[idat+i][1].name = "ATLASLUMI10";
}

idat+=ndataWZ[iWZ];
}

// Convert additive uncertainties to absolute form
for (int i = 0; i < fNData; i++)
{
fStat[i] *= fData[i]*1e-2;
for(int l = 0; l < fNSys; l++)
{
fSys[i][l].type = MULT; // All systematics multiplicative
fSys[i][l].add = fSys[i][l].mult*fData[i]*1e-2;
}
}


fWZ[0].close();
fWZ[1].close();
}
84 changes: 84 additions & 0 deletions buildmaster/filters/ATLASZRAP11.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
This file implements the Z production subset of the ATLASWZRAP11CC data set.
This is required to separate NC DY from CC DY.
Implemented by ERN June 2023.
*/

#include "ATLASZRAP11CC.h"

// Central selection
void ATLASZRAP11CCFilter::ReadData()
{

// Opening files
fstream f1;

stringstream datafile("");
datafile << dataPath() << "rawdata/ATLASWZRAP11CC/wzrap11.dat";

f1.open(datafile.str().c_str(), ios::in);

if (f1.fail()) {
cerr << "Error opening data file " << datafile.str() << endl;
exit(-1);
}

// Dummy string
std::string dummy;

// Read the names of systematics
std::string *sysNames = new std::string[fNSys];
sysNames[0] = "UNCORR";
for (int i=0; i<5; i++) f1 >> dummy;
for (int i=0; i<fNSys; i++)
f1 >> sysNames[i];

const int nBins = 3;
const int ndataWZ[nBins] = {6,18,24}; // Data thresholds for (Z_low, Z_peak, Z_high) respectively
const double MWZ2[nBins]= {pow(56.0,2.0), pow(91.0,2.0), pow(133.0,2.0)}; //Mass squared of (Z_low, Z_peak, Z_high)

string line;
for(int iline=0; iline<23; iline++)
getline(f1,line);

int low_bin = 0;
for (int b = 0; b < nBins; b++)
{
for (int i = low_bin; i < ndataWZ[b]; i++)
{
double etamin, etamax;

// Kinematics
f1 >> dummy; f1 >> etamin; f1 >> etamax;
fKin1[i] = etamin + (etamax - etamin)/2.0;
fKin2[i] = MWZ2[b];
fKin3[i] = 7000;

// Observable
f1 >> fData[i];
fData[i] *= 1000; // pb -> fb

// Statistical errors - percentage with respect the observable
f1 >> fStat[i];
fStat[i] *= fData[i]*1e-2;

// Correlated systematic errors
for (int l = 0; l < fNSys; l++)
{
f1 >> fSys[i][l].mult;
fSys[i][l].type = MULT;
fSys[i][l].name = sysNames[l];
}

// Additive errors
for (int l = 0; l < fNSys; l++)
fSys[i][l].add = fSys[i][l].mult*fData[i]*1e-2;
}
// Update lowest point in bin
low_bin = ndataWZ[b];
}

delete[] sysNames;

f1.close();
}
Loading

0 comments on commit a67fdc3

Please sign in to comment.