CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
output.FullOutput Class Reference
Inheritance diagram for output.FullOutput:
output.OutputTree

Public Member Functions

def __init__ (self, inputFile, inputTree, outputFile, branchSelection=None, outputbranchSelection=None, fullClone=False, maxEntries=None, firstEntry=0, provenance=False, jsonFilter=None)
 
def fill (self)
 
def write (self)
 
- Public Member Functions inherited from output.OutputTree
def __init__ (self, tfile, ttree, intree)
 
def branch (self, name, rootBranchType, n=1, lenVar=None, title=None, limitedPrecision=False)
 
def fill (self)
 
def fillBranch (self, name, val)
 
def tree (self)
 
def write (self)
 

Public Attributes

 firstEntry
 
 maxEntries
 
 outputbranchSelection
 

Private Attributes

 _inputTree
 
 _otherObjects
 
 _otherTrees
 
 _tree
 

Detailed Description

Definition at line 109 of file output.py.

Constructor & Destructor Documentation

◆ __init__()

def output.FullOutput.__init__ (   self,
  inputFile,
  inputTree,
  outputFile,
  branchSelection = None,
  outputbranchSelection = None,
  fullClone = False,
  maxEntries = None,
  firstEntry = 0,
  provenance = False,
  jsonFilter = None 
)

Definition at line 122 of file output.py.

122  ):
123  outputFile.cd()
124 
125  self.outputbranchSelection = outputbranchSelection
126  self.maxEntries = maxEntries
127  self.firstEntry = firstEntry
128  if fullClone:
129  outputTree = inputTree.CopyTree(
130  '1', "", maxEntries if maxEntries else ROOT.TVirtualTreePlayer.kMaxEntries, firstEntry)
131  else:
132  outputTree = inputTree.CloneTree(0)
133 
134  # enable back all branches in inputTree, then disable for computation
135  # the branches as requested in branchSelection
136  inputTree.SetBranchStatus("*", 1)
137  if branchSelection:
138  branchSelection.selectBranches(inputTree)
139 
140  OutputTree.__init__(self, outputFile, outputTree, inputTree)
141  self._inputTree = inputTree
142  self._otherTrees = {}
143  self._otherObjects = {}
144  for k in inputFile.GetListOfKeys():
145  kn = k.GetName()
146  if kn == "Events":
147  continue # this we are doing
148  elif kn in ("MetaData", "ParameterSets"):
149  if provenance:
150  # treat content of other trees as if associated to event 0
151  self._otherTrees[kn] = inputFile.Get(
152  kn).CopyTree('1' if firstEntry == 0 else '0')
153  elif kn in ("LuminosityBlocks", "Runs"):
154  if not jsonFilter:
155  self._otherTrees[kn] = inputFile.Get(
156  kn).CopyTree('1' if firstEntry == 0 else '0')
157  elif firstEntry == 0:
158  _isRun = (kn == "Runs")
159  _it = inputFile.Get(kn)
160  _ot = _it.CloneTree(0)
161  for ev in _it:
162  if (jsonFilter.filterRunOnly(ev.run) if _isRun else jsonFilter.filterRunLumi(ev.run, ev.luminosityBlock)):
163  _ot.Fill()
164  self._otherTrees[kn] = _ot
165  elif k.GetClassName() == "TTree":
166  print("Not copying unknown tree %s" % kn)
167  else:
168  self._otherObjects[kn] = inputFile.Get(kn)
169 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Member Function Documentation

◆ fill()

def output.FullOutput.fill (   self)

Definition at line 170 of file output.py.

References output.FullOutput._inputTree, datamodel.Event._tree, output.OutputTree._tree, and HcalObjRepresent.Fill().

170  def fill(self):
171  self._inputTree.readAllBranches()
172  self._tree.Fill()
173 
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)

◆ write()

def output.FullOutput.write (   self)

Definition at line 174 of file output.py.

References datamodel.Event._tree, output.OutputTree._tree, and output.FullOutput.outputbranchSelection.

174  def write(self):
175  if self.outputbranchSelection:
176  self.outputbranchSelection.selectBranches(self._tree)
177  self._tree = self.tree().CopyTree('1', "",
178  self.maxEntries if self.maxEntries else ROOT.TVirtualTreePlayer.kMaxEntries, 0)
179 
180  OutputTree.write(self)
181  for t in self._otherTrees.values():
182  t.Write()
183  for on, ov in self._otherObjects.items():
184  self._file.WriteTObject(ov, on)
185 
186 

Member Data Documentation

◆ _inputTree

output.FullOutput._inputTree
private

Definition at line 141 of file output.py.

Referenced by output.FullOutput.fill().

◆ _otherObjects

output.FullOutput._otherObjects
private

Definition at line 143 of file output.py.

◆ _otherTrees

output.FullOutput._otherTrees
private

Definition at line 142 of file output.py.

◆ _tree

output.FullOutput._tree
private

Definition at line 177 of file output.py.

Referenced by ntupleDataFormat._Object.__getattr__(), ntupleDataFormat.BeamSpot.__getattr__(), ntupleDataFormat._Collection.__getitem__(), python.cmstools.EventTree.__getitem__(), ntupleDataFormat._Collection.__iter__(), python.cmstools.EventTree.__iter__(), ntupleDataFormat.TrackingNtuple.__iter__(), ntupleDataFormat.TrackingParticle._nMatchedSeeds(), ntupleDataFormat._SimHitMatchAdaptor._nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor._nMatchedTrackingParticles(), ntupleDataFormat.TrackingParticle._nMatchedTracks(), ntupleDataFormat.Event.beamspot(), ntupleDataFormat.TrackingParticle.bestMatchingTrack(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticle(), ntupleDataFormat._TrackingParticleMatchAdaptor.bestMatchingTrackingParticleFromFirstHit(), python.cmstools.EventTree.branch(), python.cmstools.EventTree.cppCode(), ntupleDataFormat.TrackingVertex.daughterTrackingParticles(), ntupleDataFormat.TrackingParticle.decayVertices(), ntupleDataFormat._DetIdStrAdaptor.detIdStr(), ntupleDataFormat.Event.event(), ntupleDataFormat.Event.eventId(), ntupleDataFormat.TrackingNtuple.getEvent(), ntupleDataFormat._RecoHitAdaptor.gluedHits(), ntupleDataFormat.Event.gluedHits(), ntupleDataFormat.TrackingNtuple.hasHits(), ntupleDataFormat.TrackingNtuple.hasSeeds(), ntupleDataFormat._RecoHitAdaptor.hits(), ntupleDataFormat.Seed.indexWithinAlgo(), ntupleDataFormat._RecoHitAdaptor.invalidHits(), ntupleDataFormat.TrackingParticle.isLooper(), ntupleDataFormat._DetIdStrAdaptor.layerStr(), ntupleDataFormat.InvalidHit.layerStr(), ntupleDataFormat.Event.lumi(), ntupleDataFormat.TrackingParticle.matchedSeedInfos(), ntupleDataFormat._SimHitMatchAdaptor.matchedSimHitInfos(), ntupleDataFormat.TrackingParticle.matchedTrackInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor.matchedTrackingParticleInfos(), ntupleDataFormat.GluedHit.monoHit(), ntupleDataFormat.TrackingVertex.nDaughterTrackingParticles(), ntupleDataFormat.SimHit.nRecHits(), ntupleDataFormat._HitObject.nseeds(), ntupleDataFormat.GluedHit.nseeds(), ntupleDataFormat.Seeds.nSeedsForAlgo(), ntupleDataFormat.TrackingVertex.nSourceTrackingParticles(), ntupleDataFormat._HitObject.ntracks(), ntupleDataFormat.Vertex.nTracks(), ntupleDataFormat.TrackingParticle.parentVertex(), ntupleDataFormat._RecoHitAdaptor.phase2OTHits(), ntupleDataFormat.Event.phase2OTHits(), ntupleDataFormat._RecoHitAdaptor.pixelHits(), ntupleDataFormat.Event.pixelHits(), ntupleDataFormat.Event.run(), ntupleDataFormat.SeedMatchInfo.seed(), ntupleDataFormat.Track.seed(), ntupleDataFormat.Seeds.seedForAlgo(), ntupleDataFormat._HitObject.seeds(), ntupleDataFormat.Event.seeds(), ntupleDataFormat.GluedHit.seeds(), ntupleDataFormat.Seeds.seedsForAlgo(), ntupleDataFormat.SimHitMatchInfo.simHit(), ntupleDataFormat.TrackingParticle.simHits(), ntupleDataFormat._Collection.size(), ntupleDataFormat.TrackingVertex.sourceTrackingParticles(), ntupleDataFormat.GluedHit.stereoHit(), ntupleDataFormat._RecoHitAdaptor.stripHits(), ntupleDataFormat.Event.stripHits(), ntupleDataFormat.TrackMatchInfo.track(), ntupleDataFormat.Seed.track(), ntupleDataFormat.TrackingParticleMatchInfo.trackingParticle(), ntupleDataFormat.SimHit.trackingParticle(), ntupleDataFormat.Event.trackingParticles(), ntupleDataFormat.Event.trackingVertices(), ntupleDataFormat._HitObject.tracks(), ntupleDataFormat.Event.tracks(), ntupleDataFormat.Vertex.tracks(), python.cmstools.EventTree.tree(), ntupleDataFormat.TrackingNtuple.tree(), ntupleDataFormat.Track.vertex(), and ntupleDataFormat.Event.vertices().

◆ firstEntry

output.FullOutput.firstEntry

Definition at line 127 of file output.py.

Referenced by postprocessor.PostProcessor.run().

◆ maxEntries

output.FullOutput.maxEntries

Definition at line 126 of file output.py.

Referenced by postprocessor.PostProcessor.run().

◆ outputbranchSelection

output.FullOutput.outputbranchSelection

Definition at line 125 of file output.py.

Referenced by output.FullOutput.write().