-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileParams.C
executable file
·356 lines (301 loc) · 8.5 KB
/
FileParams.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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/*
* This is the Source file for FileParams, which will be used to find files
* Written by: Jay Reiter, Matt Hokinson, and John Woods
* Last Edited: May 9th, 2018
* Edits to merge fileLocator to FileParams by Kaushal Gumpula and Emily Springer
* Last Edited: June 11th, 2018
*/
#include "TROOT.h"
#include "TTree.h"
#include "TBrowser.h"
#include "TH2.h"
#include "TH1.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
#include "TCanvas.h"
#include "TString.h"
#include "TLegend.h"
#include "TChain.h"
#include "drawPlot.h"
#include "HistParams.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <stdexcept>
#include "FileParams.h"
using std::map;
using std::cout;
using std::string;
//Declaring the Maps
const map<Helicity, string> FileParams::helicityMap = { { Helicity::LL, "LL" },{ Helicity::LR, "LR" },{ Helicity::RL, "RL" },{ Helicity::RR, "RR" } };
const map<Interference, string> FileParams::interferenceMap = { { Interference::Con, "Con" },{ Interference::Des, "Des" } };
const map<MassRange, string> FileParams::massRangeMap = { { MassRange::First, "300to800" },{ MassRange::Second, "800to1300" },{ MassRange::Third, "1300to2000" },{ MassRange::Fourth, "2000toInf" } };
const map<Lambda, string> FileParams::lambdaMap = { { Lambda::L1000, "1000" },{ Lambda::L10000, "10000" },{ Lambda::L16000, "16000"},{ Lambda::L22000, "22000" },{ Lambda::L28000, "28000" },{ Lambda::L34000, "34000" },{ Lambda::L100000, "100000" }};
const map<Particle, string> FileParams::particleMap = { { Particle::Dielectron, "EE" },{ Particle::Dimuon, "MUMU" } };
//constructor for fileParams
FileParams::FileParams(Helicity heli, Interference inter, MassRange mrange, Lambda L, Particle part) :
helicity(heli),
interference(inter),
massRange(mrange),
lambda(L),
particle(part)
{}
std::ostream& operator<<(std::ostream& stream, FileParams params)
{
stream << "Your Parameters: " << "\n";
stream << "Helicity: " << params.getHelicity() << "\n";
stream << "Interference: " << params.getInterference() << "\n";
stream << "Mass Range: " << params.getMassRange() << "\n";
stream << "Lambda: " << params.getLambda() << "\n";
stream << "Particle: " << params.getParticle() << "\n";
stream << "\n";
return stream;
}
int FileParams::fpToInt() const
{
int n = 0;
if (this->helicity == Helicity::LL)
n += 1;
else if (this->helicity == Helicity::LR)
n += 2;
else if (this->helicity == Helicity::RL)
n += 3;
else if (this->helicity == Helicity::RR)
n += 4;
n *= 10;
if (this->interference == Interference::Con)
n += 1;
else if (this->interference == Interference::Des)
n += 2;
n *= 10;
if (this->massRange == MassRange::First)
n += 1;
else if (this->massRange == MassRange::Second)
n += 2;
else if (this->massRange == MassRange::Third)
n += 3;
else if (this->massRange == MassRange:: Fourth)
n += 4;
n *= 10;
switch(this->lambda)
{
case Lambda::L1000:
n += 1; break;
case Lambda::L10000:
n += 2; break;
case Lambda::L16000:
n += 3; break;
case Lambda::L22000:
n += 4; break;
case Lambda::L28000:
n += 5; break;
case Lambda::L34000:
n += 6; break;
case Lambda::L100000:
n += 7;
}
return n;
}
//parses through the vector of root files and creates a TChain
TChain* FileParams::createTChainTextFile(FileParams params, std::string treename)
{
std::vector<std::string>rootfileVector = fileVector(params);
TChain *chain = new TChain(treename.c_str());
for(std::size_t i = 0; i < rootfileVector.size(); ++i)
{
std::string str = "root://cmsxrootd.fnal.gov//"+rootfileVector[i];
if(!chain)
{
throw std::runtime_error("invalid chain");
}
chain->Add(str.c_str());
}
return chain;
}
//parses through the vector of root files and creates a TChain
TChain* FileParams::TESTcreateTChainTextFile(FileParams params, std::string treename)
{
std::vector<std::string>rootfileVector = fileVector(params);
TChain *chain = new TChain(treename.c_str());
for(std::size_t i = 0; i < 1; ++i)
{
std::string str = "root://cmsxrootd.fnal.gov//"+rootfileVector[i];
if(!chain)
{
throw std::runtime_error("invalid chain");
}
chain->Add(str.c_str());
}
return chain;
}
//creates a vector of root files through parsing through the text file given by the path
std::vector<std::string> FileParams::fileVector(FileParams params)
{
string textfilepath = params.locateTextFile();
std::cout <<textfilepath<<std::endl;
std::vector<std::string> rootfileVector;
string line;
ifstream myfile (textfilepath);
if (myfile.is_open())
{
while(getline(myfile,line))
{
rootfileVector.push_back(line);
}
}
return rootfileVector;
}
//finds text file path
string FileParams::locateTextFile()
{
string directory = "/uscms/home/pdong/work/IMSACMS/scripts/newData/fileQueryTest";
directory += getParticlePathTextFile();
directory += getMassRangePathTextFile();
directory += getLambdaPathTextFile();
directory += getInterferencePathTextFile();
directory += getHelicityPath();
directory += ".txt";
return directory;
}
//finds text file with designated particles
string FileParams::getParticlePathTextFile()
{
switch(particle)
{
case Particle::Dielectron:
return "E";
case Particle::Dimuon:
return "Mu";
}
}
//finds text file with designated mass range
string FileParams::getMassRangePathTextFile()
{
switch(massRange)
{
case MassRange::First:
return "M300";
case MassRange::Second:
return "M800";
case MassRange::Third:
return "M1300";
case MassRange::Fourth:
throw std::runtime_error("Not a valid mass range for Text File");
}
}
//finds text file with designated energy scale
string FileParams::getLambdaPathTextFile()
{
switch(lambda)
{
case Lambda::L100000:
throw std::runtime_error("Not a valid Lambda Value for Text File");
case Lambda::L34000:
return "L34";
case Lambda::L28000:
return "L28";
case Lambda::L22000:
return "L22";
case Lambda::L16000:
return "L16";
case Lambda::L10000:
throw std::runtime_error("Not a valid Lambda Value for Text File");
case Lambda::L1000:
return "L1";
}
}
//finds text file with designated interference
string FileParams::getInterferencePathTextFile()
{
switch(interference)
{
case Interference::Con:
return "Con";
case Interference::Des:
return "Des";
}
}
string FileParams::locateFile()
{
string directory = "/uscms/physics_grp/lpcci2dileptons/nobackup/CI_study/Samples/";
directory += getLambdaPath();
directory += getParticlePath();
directory += getHelicityPath();
directory += getInterferencePath();
directory += getMassRangePath();
return directory;
}
//finds file with designated energy scale
string FileParams::getLambdaPath()
{
switch(lambda)
{
case Lambda::L100000:
return "Lambda_100kTeV/";
case Lambda::L34000:
return "Lambda_34TeV/";
case Lambda::L28000:
return "Lambda_28TeV/";
case Lambda::L22000:
return "Lambda_22TeV/";
case Lambda::L16000:
return "Lambda_16TeV/";
case Lambda::L10000:
return "Lambda_10TeV/";
case Lambda::L1000:
return "Lambda_1TeV/";
}
}
//finds file with designated particles
string FileParams::getParticlePath()
{
switch(particle)
{
case Particle::Dimuon:
return "CITo2Mu/";
case Particle::Dielectron:
return "CITo2E/";
}
}
//finds file with designated helicity model
string FileParams::getHelicityPath()
{
switch(helicity)
{
case Helicity::LL:
return "LL";
case Helicity::LR:
return "LR";
case Helicity::RR:
return "RR";
case Helicity::RL:
throw std::runtime_error("Use LR instead of RL");
}
}
//finds file with designated interference
string FileParams::getInterferencePath()
{
switch(interference)
{
case Interference::Con:
return "Con/";
case Interference::Des:
return "Des/";
}
}
//finds file with designated mass range
string FileParams::getMassRangePath()
{
switch(massRange)
{
case MassRange::First:
return "M300/";
case MassRange::Second:
return "M800/";
case MassRange::Third:
return "M1300/";
case MassRange::Fourth:
return "M2000/";
}
}