-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdijetAna_pp5020.cxx
234 lines (202 loc) · 7.89 KB
/
dijetAna_pp5020.cxx
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// C++ headers
#include <iostream>
// Jet analysis headers
#include "Manager.h"
#include "ForestAODReader.h"
#include "DiJetAnalysis.h"
#include "HistoManagerDiJet.h"
#include "EventCut.h"
#include "JetCut.h"
// ROOT headers
#include "TFile.h"
#include "TMath.h"
#include "TString.h"
//________________
void usage() {
std::cout << "./programName inputFileList oFileName isMc isPbGoingDir ptHatLow ptHatHi jeuSyst jerSyst" << std::endl;
}
//________________
/// @brief The prorgram that launches the physics analysis
/// @param argc Number of arguments
/// @param argv Argument list
/// @return 0 in case of OKAY
int main(int argc, char const *argv[]) {
// Set default values for arguments
bool isMc{true};
bool isCentWeightCalc{false};
bool isPbGoingDir{};
TString inFileName{};
int collEnergyGeV{5020}; // Keep this value intentionally to use the corrections
int collisionSystem{0}; // 0 - pp, 1 -pPb, 2 - PbPb
TString collisionSystemName{"pp"};
int collYear{2016};
// TString recoJetBranchName{"akCs4PFJetAnalyzer"};
TString recoJetBranchName{"ak4PFJetAnalyzer"};
TString oFileName{};
TString JECFileName;
TString JECFileDataName;
TString JEUFileName;
TString path2JEC = "..";
double ptHatCut[2] {-100000000, 100000000};
int useJEUSyst{0}; // 0-default, 1-JEU+, -1-JEU-
int useJERSyst{0}; // 0-default, 1-JER+, -1-JER-
double etaShift = 0.465;
// Sequence of command line arguments:
//
// inputFileList (or forest.root) - input file list with forest
// outputFileName.root - output file name
// isMc - 1 (embedding), 0 (data)
// isPbGoingDir - 1 (Pb-going), 0 (p-going)
// ptHatLow - Low ptHat cut (for embedding)
// ptHatHi - High ptHat cut (for embedding)
// useJEUSyst - 0 (default), 1 (JEU+), -1 (JEU-)
// useJERSyst - 0 (default), 1 (JER+), -1 (JER-)
// Read input argument list
if (argc <= 1) {
std::cout << "Too few arguments passed. Terminating" << std::endl;
usage();
return -1;
}
else {
inFileName = argv[1];
oFileName = argv[2];
isMc = atoi(argv[3]);
isPbGoingDir = atoi(argv[4]);
ptHatCut[0] = atoi(argv[5]);
ptHatCut[1] = atoi(argv[6]);
useJEUSyst = atoi( argv[7] );
useJERSyst = atoi( argv[8] );
}
std::cout << "Arguments passed:\n"
<< "Input file name : " << inFileName << std::endl
<< "Output file name : " << oFileName << std::endl
<< "Is MC : " << isMc << std::endl
<< "Collision system (0-pp, 1-pPb, 2-PbPb) : " << collisionSystem << std::endl
<< "Collision system name : " << collisionSystemName.Data() << std::endl
<< "Is Pb-going direction : " << isPbGoingDir << std::endl
<< "ptHat range : " << ptHatCut[0] << "-" << ptHatCut[1] << std::endl
<< "Use centrality weight : " << isCentWeightCalc << std::endl
<< "Use JEU systematics : " << useJEUSyst << std::endl
<< "Use JER systematics : " << useJERSyst << std::endl
<< std::endl;
if (isMc) {
JECFileName = "Spring18_ppRef5TeV_V6_DATA_L2Relative_AK4PF.txt";
}
else {
JECFileName = "Spring18_ppRef5TeV_V6_DATA_L2Relative_AK4PF.txt";
JECFileDataName = "/Spring18_ppRef5TeV_V6_DATA_L2L3Residual_AK4PF.txt";
JEUFileName = "Spring18_ppRef5TeV_V6_DATA_Uncertainty_AK4PF.txt";
} // else
// Initialize package manager
Manager *manager = new Manager{};
// Initialize event cut
EventCut *eventCut = new EventCut{};
eventCut->setVz(-15., 15.);
// Skim
eventCut->usePBeamScrapingFilter();
eventCut->usePPAprimaryVertexFilter();
eventCut->useHBHENoiseFilterResultRun2Loose();
//eventCut->usePhfCoincFilter();
// Default cut
// eventCut->usePVertexFilterCutdz1p0();
// Pile-up systematics
// eventCut->usePVertexFilterCutGplus();
// Pile-up systematics
//eventCut->usePVertexFilterCutVtx1();
// Triggers from Vipul
if ( !isMc ) {
eventCut->useHLT_HIAK4PFJet60_v1();
// eventCut->useHLT_HIAK4PFJet80_v1();
//eventCut->useHLT_HIAK4CaloJet60_v1();
// eventCut->useHLT_HIAK4CaloJet80_v1();
}
// Set ptHat cut for embedding
if ( isMc ) {
eventCut->setPtHat(ptHatCut[0], ptHatCut[1]);
}
//eventCut->setVerbose();
// Initialize jet cut
JetCut *jetCut = new JetCut{};
//jetCut->setMustHaveGenMathing();
jetCut->setPt(20., 1500.);
jetCut->setEta(-5.1, 5.1);
//jetCut->setVerbose();
// Initialize event reader
ForestAODReader *reader = new ForestAODReader(inFileName);
if (isMc) {
// If is MC
reader->setIsMc();
if ( isCentWeightCalc ) {
// Apply hiBin shift and centrality weight calculation
reader->setCorrectCentMC();
}
}
reader->useHltBranch();
reader->useSkimmingBranch();
reader->useRecoJetBranch();
reader->setRecoJetBranchName( recoJetBranchName.Data() );
if ( recoJetBranchName.CompareTo("akcs4pfjetanalyzer", TString::kIgnoreCase) == 0 ) {
std::cout << "Extra correction will be used for JEC" << std::endl;
reader->useExtraJECCorr();
}
reader->setCollidingSystem( collisionSystemName.Data() );
reader->setCollidingEnergy( collEnergyGeV ) ;
reader->setYearOfDataTaking( collYear );
reader->setEventCut(eventCut);
reader->fixJetArrays();
// Set path to jet analysis (then will automatically add path to aux_files)
reader->setPath2JetAnalysis( path2JEC.Data() );
reader->addJECFile( JECFileName.Data() );
if ( !isMc ) {
reader->setUseJEU( useJEUSyst );
reader->addJECFile( JECFileDataName.Data() );
reader->setJEUFileName( JEUFileName );
}
if ( isMc ) {
reader->useJERSystematics( useJERSyst ); // 0-default, 1-JER+, -1-JER-, other - not use
reader->setJERFitParams(0.0415552, 0.960013);
//reader->setJERSystParams();
}
//reader->setVerbose();
// Pass reader to the manager
manager->setEventReader(reader);
// Initialize analysis
DiJetAnalysis *analysis = new DiJetAnalysis{};
analysis->setCollisionSystem( collisionSystem );
analysis->setCollisionEnergyInGeV( collEnergyGeV );
analysis->setIsMc(isMc);
if (isMc) {
analysis->setPtHatRange(ptHatCut[0], ptHatCut[1]);
}
analysis->setEtaShift( etaShift );
analysis->setLeadJetPtLow( 30. );
analysis->setSubLeadJetPtLow( 20. );
analysis->setJetEtaLabRange( -3., 3. );
analysis->setJetEtaCMRange( -2.5, 2.5 );
analysis->setDijetPhiCut( 2. * TMath::Pi() / 3 );
if ( isMc ) {
analysis->setUseMcReweighting(0); // 0 - no reweighting, 1 - reweight to MB, 2 - reweight to Jet60, 3 - reweight to Jet80, 4 - reweight to Jet100
}
//analysis->setVerbose();
// Initialize histogram manager
HistoManagerDiJet *hm = new HistoManagerDiJet{};
hm->setIsMc( isMc );
hm->init(); // true stands up for use MC; need to FIX
// Add histogram manager to analysis
analysis->addHistoManager(hm);
// Add analysis to manager
manager->addAnalysis(analysis);
// Run chain of analyses
manager->init();
// Important for embedding reweightening
if ( isMc ) {
analysis->setNEventsInSample( reader->nEventsTotal() );
}
manager->performAnalysis();
manager->finish();
// Create output file and store results of calculations
TFile* oFile = new TFile(oFileName, "recreate");
hm->writeOutput();
oFile->Close();
return 0;
}