CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
datamodel.Event Class Reference

Public Member Functions

def __getattr__ (self, name)
 
def __getitem__ (self, attr)
 
def __init__ (self, tree, entry)
 
def eval (self, expr)
 

Private Attributes

 _entry
 
 _tree
 

Detailed Description

Class that allows seeing an entry of a PyROOT TTree as an Event

Definition at line 20 of file datamodel.py.

Constructor & Destructor Documentation

◆ __init__()

def datamodel.Event.__init__ (   self,
  tree,
  entry 
)

Definition at line 23 of file datamodel.py.

23  def __init__(self, tree, entry):
24  self._tree = tree
25  self._entry = entry
26  self._tree.gotoEntry(entry)
27 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __getattr__()

def datamodel.Event.__getattr__ (   self,
  name 
)

Definition at line 28 of file datamodel.py.

References datamodel.Event._tree, and treeReaderArrayTools.readBranch().

Referenced by datamodel.Event.__getitem__(), and datamodel.Object.__getitem__().

28  def __getattr__(self, name):
29  if name in self.__dict__:
30  return self.__dict__[name]
31  return self._tree.readBranch(name)
32 
def readBranch(tree, branchName)

◆ __getitem__()

def datamodel.Event.__getitem__ (   self,
  attr 
)

◆ eval()

def datamodel.Event.eval (   self,
  expr 
)
Evaluate an expression, as TTree::Draw would do. 

   This is added for convenience, but it may perform poorly and the implementation is not bulletproof,
   so it's better to rely on reading values, collections or objects directly

Definition at line 36 of file datamodel.py.

References datamodel.Event._entry, and datamodel.Event._tree.

36  def eval(self, expr):
37  """Evaluate an expression, as TTree::Draw would do.
38 
39  This is added for convenience, but it may perform poorly and the implementation is not bulletproof,
40  so it's better to rely on reading values, collections or objects directly
41  """
42  if not hasattr(self._tree, '_exprs'):
43  self._tree._exprs = {}
44  # remove useless warning about EvalInstance()
45  import warnings
46  warnings.filterwarnings(action='ignore', category=RuntimeWarning,
47  message='creating converter for unknown type "const char\*\*"$')
48  warnings.filterwarnings(action='ignore', category=RuntimeWarning,
49  message='creating converter for unknown type "const char\*\[\]"$')
50  if expr not in self._tree._exprs:
51  formula = ROOT.TTreeFormula(expr, expr, self._tree)
52  if formula.IsInteger():
53  formula.go = formula.EvalInstance64
54  else:
55  formula.go = formula.EvalInstance
56  self._tree._exprs[expr] = formula
57  # force sync, to be safe
58  self._tree.GetEntry(self._entry)
59  self._tree.entry = self._entry
60  # self._tree._exprs[expr].SetQuickLoad(False)
61  else:
62  self._tree.gotoEntry(self._entry)
63  formula = self._tree._exprs[expr]
64  if "[" in expr: # unclear why this is needed, but otherwise for some arrays x[i] == 0 for all i > 0
65  formula.GetNdata()
66  return formula.go()
67 
68 

Member Data Documentation

◆ _entry

datamodel.Event._entry
private

Definition at line 25 of file datamodel.py.

Referenced by ntupleDataFormat.Event.entry(), and datamodel.Event.eval().

◆ _tree

datamodel.Event._tree
private

Definition at line 24 of file datamodel.py.

Referenced by datamodel.Event.__getattr__(), 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(), output.OutputTree.branch(), python.cmstools.EventTree.branch(), python.cmstools.EventTree.cppCode(), ntupleDataFormat.TrackingVertex.daughterTrackingParticles(), ntupleDataFormat.TrackingParticle.decayVertices(), ntupleDataFormat._DetIdStrAdaptor.detIdStr(), datamodel.Event.eval(), ntupleDataFormat.Event.event(), ntupleDataFormat.Event.eventId(), output.OutputTree.fill(), output.FullOutput.fill(), 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(), output.OutputTree.tree(), python.cmstools.EventTree.tree(), ntupleDataFormat.TrackingNtuple.tree(), ntupleDataFormat.Track.vertex(), ntupleDataFormat.Event.vertices(), output.OutputTree.write(), and output.FullOutput.write().