ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
SampleHandler
Root
ToolsMeta.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
//
9
// includes
10
//
11
12
#include <
SampleHandler/ToolsMeta.h
>
13
14
#include <
RootCoreUtils/Assert.h
>
15
#include <
SampleHandler/MetaFields.h
>
16
#include <
SampleHandler/MetaObject.h
>
17
#include <
SampleHandler/SampleHandler.h
>
18
#include <
SampleHandler/Sample.h
>
19
#include <TSystem.h>
20
#include <fstream>
21
#include <sstream>
22
#include <stdexcept>
23
24
//
25
// method implementations
26
//
27
28
namespace
SH
29
{
30
void
readSusyMeta
(
const
SampleHandler
&
sh
,
const
std::string& inputFile)
31
{
32
TString myfile = inputFile;
33
gSystem->ExpandPathName (myfile);
34
std::ifstream
file
(myfile.Data());
35
std::string line;
36
37
if
(!
file
)
38
throw
std::runtime_error (
"failed to read file: "
+ inputFile);
39
40
while
(std::getline (
file
, line))
41
{
42
if
(line[0] >=
'0'
&& line[0] <=
'9'
)
43
{
44
std::istringstream
str
(line);
45
std::string DSID, name;
46
float
crossSection = 0, kFactor = 0, filterEfficiency = 0,
47
xsUncertainty = 0;
48
49
if
(!(
str
>> DSID >> name >> crossSection >> kFactor >> filterEfficiency
50
>> xsUncertainty))
51
throw
std::runtime_error (
"readSusyMeta: failed to parse line: "
+ line);
52
53
std::string mydsid =
"."
+ DSID +
"."
;
54
for
(
SampleHandler::iterator
sample =
sh
.begin(),
55
end =
sh
.end(); sample != end; ++ sample)
56
{
57
if
((*sample)->name().find (mydsid) != std::string::npos)
58
{
59
double
oldCrossSection
60
= (*sample)->meta()->castDouble (
MetaFields::crossSection
);
61
(*sample)->meta()->setDouble (
MetaFields::crossSection
, oldCrossSection + crossSection);
62
(*sample)->meta()->setDouble (
MetaFields::kfactor
, kFactor);
63
(*sample)->meta()->setDouble (
MetaFields::filterEfficiency
, filterEfficiency);
64
(*sample)->meta()->setDouble (
MetaFields::crossSectionRelUncertainty
, xsUncertainty);
65
}
66
}
67
}
68
}
69
}
70
71
void
readSusyMetaDir
(
const
SampleHandler
&
sh
,
const
std::string& inputDir)
72
{
73
TString mydir = inputDir;
74
gSystem->ExpandPathName (mydir);
75
void
*dirp = 0;
76
77
try
78
{
79
dirp = gSystem->OpenDirectory (mydir.Data());
80
const
char
*
file
= 0;
81
while
((
file
= gSystem->GetDirEntry (dirp)))
82
{
83
std::string myfile = inputDir +
"/"
+
file
;
84
if
(myfile.size() > 4 && myfile.substr (myfile.size()-4) ==
".txt"
)
85
readSusyMeta
(
sh
, myfile);
86
}
87
gSystem->FreeDirectory (dirp);
88
}
catch
(...)
89
{
90
gSystem->FreeDirectory (dirp);
91
throw
;
92
}
93
}
94
}
Assert.h
MetaFields.h
MetaObject.h
SampleHandler.h
Sample.h
ToolsMeta.h
SH::SampleHandler
A class that manages a list of Sample objects.
Definition
SampleHandler.h:53
SH::SampleHandler::iterator
boost::transform_iterator< SamplePtrToRawSample, std::vector< std::shared_ptr< Sample > >::const_iterator > iterator
the iterator to use
Definition
SampleHandler.h:457
RCU::Shell
Definition
ShellExec.cxx:26
SH
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition
PrunDriver.h:15
SH::readSusyMeta
void readSusyMeta(const SampleHandler &sh, const std::string &inputFile)
effects: read the susy-meta-data file and add its information to the samples from the given sample ha...
Definition
ToolsMeta.cxx:30
SH::readSusyMetaDir
void readSusyMetaDir(const SampleHandler &sh, const std::string &inputDir)
effects: read an entire directory of susy-meta-data files and add their information to the samples fr...
Definition
ToolsMeta.cxx:71
str
Definition
BTagTrackIpAccessor.cxx:11
SH::MetaFields::crossSectionRelUncertainty
static const std::string crossSectionRelUncertainty
the relative uncertainty on the cross section
Definition
MetaFields.h:53
SH::MetaFields::kfactor
static const std::string kfactor
the k-factor of the sample
Definition
MetaFields.h:74
SH::MetaFields::crossSection
static const std::string crossSection
the cross section field
Definition
MetaFields.h:50
SH::MetaFields::filterEfficiency
static const std::string filterEfficiency
the filter efficiency of the sample
Definition
MetaFields.h:77
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0