File indexing completed on 2024-04-06 12:01:56
0001 #include <assert.h>
0002 #include <iostream>
0003 #include <sstream>
0004 #include <string>
0005
0006 #include "CondFormats/BTauObjects/src/headers.h"
0007
0008 int main() {
0009 using namespace std;
0010
0011 string csv1(
0012 "0, comb, up, 0, 1, 2, 3, 4, 5, 6, \"2*x\" \n"
0013 "0, comb, central, 0, 1, 2, 3, 4, 5, 6, \"2*x\" \n"
0014 "0, comb, central, 0, 1, 2, 3, 4, 6, 7, \"2*x\" \n"
0015 " \n \t \t"
0016 "0, ttbar, central, 0, 1, 2, 3, 4, 6, 7, \"2*x\" \n"
0017 "1, comb, central, 0, 1, 2, 3, 4, 6, 7, \"2*x\" \n"
0018 "0, comb, down, 0, 1, 2, 3, 4, 5, 6, \"2*x\" \n");
0019 stringstream csv1Stream(csv1);
0020 BTagCalibration b1("csv");
0021 b1.readCSV(csv1Stream, true);
0022
0023
0024 auto e1 = b1.getEntries(BTagEntry::Parameters(BTagEntry::OP_LOOSE, "comb", "central"));
0025 assert(e1.size() == 2);
0026 auto e2 = b1.getEntries(BTagEntry::Parameters(BTagEntry::OP_LOOSE, "comb", "up"));
0027 assert(e2.size() == 1);
0028 auto e3 = b1.getEntries(BTagEntry::Parameters(BTagEntry::OP_MEDIUM, "comb", "central"));
0029 assert(e3.size() == 1);
0030
0031
0032 string tggr = "testTagger";
0033 string csv2_1("0, comb, up, 0, 1, 2, 3, 4, 5, 6, \"2*x\" \n");
0034 string csv2_2("0, comb, down, 0, 1, 2, 3, 4, 5, 6, \"2*x\" \n");
0035 stringstream csv2Stream1;
0036 stringstream csv2Stream2;
0037 csv2Stream1 << tggr << ";" << BTagEntry::makeCSVHeader() << csv2_1 << csv2_2;
0038 csv2Stream2 << tggr << ";" << BTagEntry::makeCSVHeader() << csv2_2 << csv2_1;
0039 BTagCalibration b2(tggr);
0040 b2.readCSV(csv2Stream1, true);
0041
0042 stringstream csv3Stream;
0043 b2.makeCSV(csv3Stream);
0044 assert(csv2Stream1.str() == csv3Stream.str() || csv2Stream2.str() == csv3Stream.str());
0045
0046 return 0;
0047 }