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 107 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 120 of file output.py.

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

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

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

◆ write()

def output.FullOutput.write (   self)

Definition at line 172 of file output.py.

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

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

Member Data Documentation

◆ _inputTree

output.FullOutput._inputTree
private

Definition at line 139 of file output.py.

Referenced by output.FullOutput.fill().

◆ _otherObjects

output.FullOutput._otherObjects
private

Definition at line 141 of file output.py.

◆ _otherTrees

output.FullOutput._otherTrees
private

Definition at line 140 of file output.py.

◆ _tree

output.FullOutput._tree
private

Definition at line 175 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 125 of file output.py.

Referenced by postprocessor.PostProcessor.run().

◆ maxEntries

output.FullOutput.maxEntries

Definition at line 124 of file output.py.

Referenced by postprocessor.PostProcessor.run().

◆ outputbranchSelection

output.FullOutput.outputbranchSelection

Definition at line 123 of file output.py.

Referenced by output.FullOutput.write().