-
Notifications
You must be signed in to change notification settings - Fork 4
/
mk_GamHistosFill.C
171 lines (144 loc) · 6.37 KB
/
mk_GamHistosFill.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Purpose: Fill gamma+jet analysis histograms
// Author: [email protected]
// Created: June 6, 2021
//#include "CondFormats/JetMETObjects/src/Utilities.cc"
#include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
#include "CondFormats/JetMETObjects/interface/SimpleJetCorrector.h"
#include "CondFormats/JetMETObjects/interface/FactorizedJetCorrector.h"
#include "CondFormats/JetMETObjects/interface/SimpleJetCorrectionUncertainty.h"
#include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h"
#include "GamHistosFill.h"
#include "TSystem.h"
#include <fstream>
#include <string>
#define GPU
//#define LOCAL
#ifdef LOCAL
// Compile these libraries into *.so first with root -l -b -q mk_CondFormats.C
// (works for 6.18.04?)
/*
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/JetCorrectorParameters.cc+)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/SimpleJetCorrector.cc+)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/FactorizedJetCorrector.cc+)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty.cc+)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/JetCorrectionUncertainty.cc+)
*/
//R__LOAD_LIBRARY(GamHistosFill.C+g)
// As in jetphys/mk2_histosFill.C:
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/JetCorrectorParameters_cc)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/SimpleJetCorrector_cc)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/FactorizedJetCorrector_cc)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty_cc)
R__LOAD_LIBRARY(CondFormats/JetMETObjects/src/JetCorrectionUncertainty_cc)
R__LOAD_LIBRARY(GamHistosFill_C)
#else
// (works for 6.26/10)
R__LOAD_LIBRARY(GamHistosFill_C.so)
#endif
void mk_GamHistosFill(string dataset = "X", string version = "vX") {
// Settings
bool addData = (dataset=="2016B" || dataset=="2016C" || dataset=="2016D" ||
dataset=="2016E" || dataset=="2016F" ||
dataset=="2016FG" || dataset=="2016H" ||
dataset=="2016BCD"|| dataset=="2016EF"|| dataset=="2016FGH" ||
//dataset=="2016BCDEF" ||
dataset=="2017B" || dataset=="2017C" || dataset=="2017D" ||
dataset=="2017E" || dataset=="2017F" ||
//dataset=="2017BCDEF" ||
dataset=="2018A" || dataset=="2018B" ||
dataset=="2018C" || dataset=="2018D" ||
dataset=="2018A1" || dataset=="2018A2" ||
dataset=="2018D1" || dataset=="2018D2" ||
dataset=="2018D3" || dataset=="2018D4" ||
//dataset=="2018ABCD");
dataset=="2022C" || dataset=="2022D" || dataset=="2022E" ||
dataset=="2022F" || dataset=="2022G" ||
dataset=="2023B" || dataset=="2023Cv123" ||
dataset=="2023Cv4" || dataset=="2023D" ||
dataset=="2024B");
bool addMC = (dataset=="2016P8" || dataset=="2017P8" || dataset=="2018P8" ||
dataset=="2016APVP8" ||
dataset=="2022P8" || //dataset=="2022QCD" ||
dataset=="2022EEP8" || //dataset=="2022EEQCD" ||
dataset=="2023P8" || dataset=="2023BPixP8");
bool addQCD = (dataset=="2016QCD" || dataset=="2016APVQCD" ||
dataset=="2017QCD" || dataset=="2018QCD" ||
dataset=="2022QCD" || dataset=="2022EEQCD" ||
dataset=="2023QCD" || dataset=="2023BPixQCD");
//cout << "Clean old shared objects and link files" << endl << flush;
//gSystem->Exec("rm *.d");
//gSystem->Exec("rm *.so");
//gSystem->Exec("rm *.pcm");
string path = gSystem->pwd();
cout << "Current path: " << path << endl << flush;
/*
gSystem->AddIncludePath(Form("-I%s",path.c_str()));
gSystem->AddIncludePath(Form("-I%s/CondFormats/JetMETObjects/interface",path.c_str()));
*/
#ifdef GPU
// Compile these libraries into *.so first with root -l -b -q mk_CondFormats.C
gROOT->ProcessLine(".L CondFormats/JetMETObjects/src/Utilities.cc+");
gROOT->ProcessLine(".L CondFormats/JetMETObjects/src/JetCorrectorParameters.cc+");
gROOT->ProcessLine(".L CondFormats/JetMETObjects/src/SimpleJetCorrector.cc+");
gROOT->ProcessLine(".L CondFormats/JetMETObjects/src/FactorizedJetCorrector.cc+");
gROOT->ProcessLine(".L CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty.cc+");
gROOT->ProcessLine(".L CondFormats/JetMETObjects/src/JetCorrectionUncertainty.cc+");
gROOT->ProcessLine(".L GamHistosFill.C+g");
#endif
TChain *c = new TChain("Events");
//c->AddFile("files/mc-ht-200to400.root");
//c->AddFile("files/mc-ht-600toInf.root");
//c->AddFile("files/mc-pt-15to6000.root");
//c->AddFile("files/data-2018a.root");
// Automatically figure out where we are running the job
bool runGPU = (path=="/media/storage/gamjet");
bool runLocal = (path=="/Users/voutila/Dropbox/Cern/gamjet" ||
path=="/Users/voutila/Library/CloudStorage/Dropbox/Cern/gamjet" ||
path=="/Users/manvouti/Dropbox/Cern/gamjet" ||
path=="/home/bschilli/Cern/gamjet");
if (!runLocal) assert(runGPU);
if (runGPU) cout << "Running on Hefaistos (runGPU)" << endl;
if (runLocal) cout << "Running on iMac (runLocal)" << endl;
if (addData) {
ifstream fin(runLocal ? Form("input_files/dataFiles_local_%s.txt",dataset.c_str()) :
Form("input_files/dataFiles_Run%s.txt",dataset.c_str()), ios::in);
string filename;
cout << "Chaining data files:" << endl << flush;
int nFiles(0), nFilesMax(827);//9999);
while (fin >> filename && nFiles<nFilesMax) {
++nFiles;
c->AddFile(filename.c_str());
}
cout << "Chained " << nFiles << " files" << endl << flush;
GamHistosFill filler(c,0,dataset,version);
filler.Loop();
}
if (addMC) {
ifstream fin(runLocal ? Form("input_files/mcFiles_local_%s.txt",dataset.c_str()) :
Form("input_files/mcFiles_%s.txt",dataset.c_str()), ios::in);
string filename;
cout << "Chaining MC files:" << endl << flush;
int nFiles(0), nFilesMax(1437);//100);
while (fin >> filename && nFiles<nFilesMax) {
++nFiles;
c->AddFile(filename.c_str());
}
cout << "Chained " << nFiles << " files" << endl << flush;
GamHistosFill filler(c,1,dataset,version);
filler.Loop();
}
if (addQCD) {
ifstream fin(runLocal ? Form("input_files/mcFiles_local_%s.txt",dataset.c_str()) :
Form("input_files/mcFiles_%s.txt",dataset.c_str()), ios::in);
string filename;
cout << "Chaining QCD MC files:" << endl << flush;
int nFiles(0), nFilesMax(5097);
while (fin >> filename && nFiles<nFilesMax) {
++nFiles;
c->AddFile(filename.c_str());
}
cout << "Chained " << nFiles << " files" << endl << flush;
GamHistosFill filler(c,1,dataset,version);
filler.Loop();
}
}