Skip to content

Commit

Permalink
code runs smoothly except for Snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
emanca committed Dec 21, 2018
1 parent 72d7653 commit fcd9e5c
Show file tree
Hide file tree
Showing 31 changed files with 481 additions and 451 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
__init__.py
*.png
*.pdf
*.root
*.pyc
.*.swp
.#*
Expand Down
42 changes: 15 additions & 27 deletions framework/RDFprocessor.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
import ROOT
import os
import time

# Begin code for casting

# this injection can be replaced by properly having this in a header
# included in the interpreter at framework startup
ROOT.gInterpreter.Declare('''
template <typename T>
class NodeCaster {
public:
static ROOT::RDF::RNode Cast(T rdf)
{
return ROOT::RDF::RNode(rdf);
}
};
''')

def CastToRNode(node):
return ROOT.NodeCaster(node.__cppname__).Cast(node)

# end code for casting
from header import *

class RDFprocessor:
def __init__(self, outputFile, inputFiles, histoFile, modules=[], snapshot = False):
def __init__(self, outputFile, inputFiles, histoFile, keepVars='', modules=[], snapshot = False):

self.outputFile = outputFile
self.inputFiles = inputFiles
self.modules = modules
self.histoFile = ROOT.TFile(histoFile, "recreate")
self.snapshot = snapshot
self.keepVars = keepVars

RDF = ROOT.ROOT.RDataFrame
self.d = RDF("Events", inputFiles)
Expand All @@ -52,13 +31,14 @@ def run(self):
tmp_th2 = m.getTH2()

for obj in tmp_th1:
self.objs.append(obj)
self.objs.append(ROOT.RDF.RResultPtr('TH1D')(obj))

for obj in tmp_th2:
self.objs.append(obj)
self.objs.append(ROOT.RDF.RResultPtr('TH2D')(obj))

if self.snapshot:


""" comment until we understand Snapshot bug
ROOT.ROOT.RDataFrame("LuminosityBlocks", self.inputFiles).Snapshot("LuminosityBlocks",self.outputFile, "")
print time.time()-t0, "first snapshot"
Expand All @@ -77,7 +57,15 @@ def run(self):
#ROOT.ROOT.RDataFrame("ParameterSets", self.inputFiles).Snapshot("ParameterSets", self.outputFile, "", opts)
#print time.time()-t0, "fourth loop"

self.d.Snapshot("Events", self.outputFile)
print self.keepVars
if not self.keepVars == '':
print "qui"
Parser = parser(self.keepVars)
self.d.Snapshot("Events", self.outputFile, Parser.parse())
else:
print "i'm snapshotting!"
self.d.Snapshot("Events", self.outputFile)

print time.time()-start, "events snapshot"

self.histoFile.cd()
Expand Down
20 changes: 20 additions & 0 deletions framework/foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ROOT

class parser:

def __init__(self, file):

self.file = file

self.f = open(self.file)

def parse(self):

list = [x.strip() for x in self.f.readlines()]
branchList = ROOT.vector('string')()

for l in list:
branchList.push_back(l)

return branchList

26 changes: 26 additions & 0 deletions framework/header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Built-in/Generic Imports
import os
import sys
import time
import ROOT
from foo import *

# Begin code for casting

# this injection can be replaced by properly having this in a header
# included in the interpreter at framework startup
ROOT.gInterpreter.Declare('''
template <typename T>
class NodeCaster {
public:
static ROOT::RDF::RNode Cast(T rdf)
{
return ROOT::RDF::RNode(rdf);
}
};
''')

def CastToRNode(node):
return ROOT.NodeCaster(node.__cppname__).Cast(node)

# end code for casting
13 changes: 13 additions & 0 deletions framework/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class parser:

def __init__(self, file):

self.file = file

self.f = open(self.file)

def parse(self):

print [x.strip() for x in self.f.readlines()]
return [x.strip() for x in self.f.readlines()]

66 changes: 0 additions & 66 deletions wmass/AngCoeffNominal/AngCoeff.cpp

This file was deleted.

Binary file removed wmass/AngCoeffNominal/AngCoeff.so
Binary file not shown.
21 changes: 0 additions & 21 deletions wmass/AngCoeffNominal/TemplateBuilder.cpp

This file was deleted.

Binary file removed wmass/AngCoeffNominal/TemplateBuilder.so
Binary file not shown.
96 changes: 0 additions & 96 deletions wmass/AngCoeffNominal/TemplateBuilderOK.cpp

This file was deleted.

Binary file removed wmass/AngCoeffNominal/histo.root
Binary file not shown.
Binary file removed wmass/AngCoeffNominal/templates.root
Binary file not shown.
Loading

0 comments on commit fcd9e5c

Please sign in to comment.