Definition at line 12 of file CSV_InDetExporter.py.
◆ __init__()
def CSV_InDetExporter.CSVDumper.__init__ |
( |
|
self, |
|
|
|
inputAOD, |
|
|
|
outputDir, |
|
|
|
dict_variables_types, |
|
|
|
treename = "CollectionTree" , |
|
|
|
nEvents = -1 |
|
) |
| |
Definition at line 14 of file CSV_InDetExporter.py.
14 def __init__(self, inputAOD, outputDir, dict_variables_types, treename="CollectionTree", nEvents=-1):
17 self.tree = xAOD.MakeTransientTree( TFile(inputAOD), treename )
18 self.n_entries = self.tree.GetEntriesFast()
19 self.outputDir = outputDir
21 if nEvents < 0
or nEvents > self.n_entries:
22 self.nEvents = self.n_entries
24 self.nEvents = nEvents
25 print(f
"Running on {self.nEvents} events")
27 os.system(
"mkdir -p "+self.outputDir)
35 self.dict_variables_types = dict_variables_types
◆ ArrayFloat3_to_CppArray()
def CSV_InDetExporter.CSVDumper.ArrayFloat3_to_CppArray |
( |
|
self, |
|
|
|
ArrayFloat3 |
|
) |
| |
Definition at line 45 of file CSV_InDetExporter.py.
45 def ArrayFloat3_to_CppArray(self, ArrayFloat3):
47 arr = ArrayFloat3.data()
◆ ProcessEvent()
def CSV_InDetExporter.CSVDumper.ProcessEvent |
( |
|
self, |
|
|
|
evt |
|
) |
| |
Definition at line 54 of file CSV_InDetExporter.py.
54 def ProcessEvent(self, evt):
58 self.tree.GetEntry(evt)
59 EventNumber = self.tree.EventInfo.mcEventNumber()
62 for container
in self.dict_variables_types.
keys():
64 dict_container = self.dict_variables_types[container]
66 tp = getattr(self.tree, container)
68 print(
".. Missing ", container)
72 print(
".. Empty ", container)
75 for var,fmt
in dict_container.items():
77 sp = tp.getConstDataSpan[ fmt ]( var)
80 print(
"getConstDataSpan failed for variable ",var,fmt, container)
81 sp = [ getattr(element, var)()
for element
in tp ]
85 list_of_lists = [
list(std_vector)
for std_vector
in sp]
87 max_len =
max(len(ll)
for ll
in list_of_lists)
89 for ll
in list_of_lists:
90 ll.extend([np.nan] * (max_len - len(ll)))
95 sp = np.array(list_of_lists)
97 if "ArrayFloat3" in fmt
and len(sp) > 0:
98 sp =
array(
list( map(self.ArrayFloat3_to_CppArray, sp) ) )
100 if (
"unsigned char" in fmt
or "uint8" in fmt)
and len(sp) > 0:
101 sp = sp.view(np.int32)
107 for column
in range(sp.shape[1]):
108 dict_lists[var+f
"_at{column}"] = sp.T[column]
110 self.WriteCSV( filename=
getCSVFilename(self.outputDir, container, EventNumber), dictionary=dict_lists )
◆ Run()
def CSV_InDetExporter.CSVDumper.Run |
( |
|
self | ) |
|
◆ WriteCSV()
def CSV_InDetExporter.CSVDumper.WriteCSV |
( |
|
self, |
|
|
|
filename, |
|
|
|
dictionary |
|
) |
| |
Definition at line 37 of file CSV_InDetExporter.py.
37 def WriteCSV(self, filename, dictionary):
39 with open(filename,
"w")
as out:
40 writer = csv.writer(out)
41 writer.writerow(dictionary.keys())
42 writer.writerows( zip(*dictionary.values()) )
43 print(f
"New file saved: {filename}")
◆ dict_variables_types
CSV_InDetExporter.CSVDumper.dict_variables_types |
◆ n_entries
CSV_InDetExporter.CSVDumper.n_entries |
◆ nEvents
CSV_InDetExporter.CSVDumper.nEvents |
◆ outputDir
CSV_InDetExporter.CSVDumper.outputDir |
◆ tree
CSV_InDetExporter.CSVDumper.tree |
The documentation for this class was generated from the following file:
StatusCode Init(const char *appname, int *argc, char **argv)
Function initialising an application for using the ATLAS EDM.