CMS 3D CMS Logo

Classes | Functions
python.cmstools Namespace Reference

Classes

class  cmserror
 
class  Event
 
class  EventBranch
 
class  EventTree
 

Functions

def all (container)
 workaround iterator generators for ROOT classes More...
 
def createBranchBuffer (branch)
 auto branch types (Chris Jones) More...
 
def loop (begin, end)
 

Detailed Description

Python helper tools for CMS FWLite

benedikt.hegner@cern.ch

Function Documentation

◆ all()

def python.cmstools.all (   container)

workaround iterator generators for ROOT classes

Definition at line 26 of file cmstools.py.

26 def all(container):
27 
28  # loop over ROOT::TTree and similar
29  if hasattr(container,'GetEntries'):
30  try:
31  entries = container.GetEntries()
32  for entry in range(entries):
33  yield entry
34  except:
35  raise cmserror("Looping of %s failed" %container)
36 
37  # loop over std::vectors and similar
38  elif hasattr(container, 'size'):
39  try:
40  entries = container.size()
41  for entry in range(entries):
42  yield container[entry]
43  except:
44  pass
45 
46  # loop over containers with begin and end iterators

References FastTimerService_cff.range.

Referenced by pat::EventHypothesis.all(), HepMCValidationHelper.allStatus1(), HepMCValidationHelper.allStatus2(), HepMCValidationHelper.allStatus3(), HepMCValidationHelper.allVisibleParticles(), SiPixelPhase1GeometryDebug.analyze(), HGcalHitIdCheck.analyze(), LayerCollector.barrelLayers(), AlignmentMonitorSurvey.book(), DQMGenericTnPClient.calculateEfficiency(), dqmTnP::AbstractFitter.calculateEfficiency(), HGCalCLUEAlgoT< TILE >.calculateLocalDensity(), CastorHardcodeCalibrations.CastorHardcodeCalibrations(), SummaryOutputProducer::TriggerSummary.changed(), combineBTagCalibrationData.check_csv_data(), GlobalMuonRefitter.checkMuonHits(), CmsShowMain.CmsShowMain(), HcalDbASCIIIO.createObject< HcalFrontEndMap >(), HcalDbASCIIIO.createObject< HcalSiPMCharacteristics >(), EgHLTOfflineClient.createTrigTagProbeEffHists(), EgHLTOfflineClient.createTrigTagProbeEffHists2Leg(), TemplatedJetBProbabilityComputer< Container, Base >.discriminator(), EwkElecDQM.dqmEndRun(), HepMCValidationHelper.findFSRPhotons(), FWDetailViewManager.findViewersFor(), dqmTnP::GaussianPlusLinearFitter.fit(), dqmTnP::VoigtianPlusExponentialFitter.fit(), GlobalTrajectoryBuilderBase.fixTEC(), LayerCollector.forwardLayers(), SummaryOutputProducer::TriggerSummary.gained(), models.generate(), HepMCValidationHelper.genMet(), tools.get_iovs(), tools.get_tags(), SiStripDetCabling.getAllDetectorsContiguousIds(), GlobalMuonRefitter.getFirstHits(), DatabasePDG.GetNParticles(), dataset.Dataset.getrunnumberfromfilename(), dataset.getrunnumbersfromfile(), helperFunctions.getTagsMap(), HcalHardcodeCalibrations.HcalHardcodeCalibrations(), AlignmentParameterStore.hierarchyConstraints(), conddblib.Connection.is_valid(), MuonTrackResidualAnalyzer.isInTheAcceptance(), MuonTrackAnalyzer.isInTheAcceptance(), o2olib.O2OJobMgr.listJobs(), conddblib.listObject(), HGCalDDDConstants.locateCell(), SummaryOutputProducer::TriggerSummary.lost(), LA_Filler_Fitter.make_and_fit_symmchi2(), tmtt::Histos.makeEfficiencyPlot(), EgHLTOfflineClient.makeEffMonElem2Leg(), EgHLTOfflineClient.makeEffMonElemFromPassAndAll(), SiStripHitEffFromCalibTree.makeSummary(), AlignableTracker.merge(), pat::TriggerEvent.pathModules(), MuonSeedOrcaPatternRecognition.produce(), utils_v2.recursive_search_online(), HepMCValidationHelper.removeIsolatedLeptons(), plotBaryCentre_VS_BeamSpot.Run(), checkBTagCalibrationConsistency.run_check_data(), SiStripConfigDb.runs(), utils_v2.search_on_disk(), CSCTrackConfigSelector.select(), GlobalTrajectoryBuilderBase.selectTrackerHits(), DQMImplNet< DQMNet::Object >.sendObjectListToPeer(), DQMImplNet< DQMNet::Object >.sendObjectListToPeers(), heppy::IsolationComputer.setPackedCandidates(), TTDTC.size(), data_formats_tests.data_formats_tests.test_dicts_to_orm_objects(), data_formats_tests.data_formats_tests.test_orm_objects_to_dicts(), data_sources_tests.data_sources_tests.test_type_all_iovs(), data_sources_tests.data_sources_tests.test_type_all_tags(), TrimmedVertexFinder.vertices(), ConfigurableTrimmedVertexFinder.vertices(), and dataset.DatasetBase.writefilelist_hippy().

◆ createBranchBuffer()

def python.cmstools.createBranchBuffer (   branch)

auto branch types (Chris Jones)

Definition at line 54 of file cmstools.py.

54 def createBranchBuffer(branch):
55  reColons = re.compile(r'::')
56  reCloseTemplate =re.compile(r'>')
57  reOpenTemplate =re.compile(r'<')
58  branchType = ROOT.branchToClass(branch)
59  #buffer = eval ('ROOT.'+reColons.sub(".",reOpenTemplate.sub("(ROOT.",reCloseTemplate.sub(")",branchType.GetName())))+'()')
60  buffer = ROOT.MakeRootClass(branchType.GetName()) ()
61  if( branch.GetName()[-1] != '.') and (branch.GetName()!="EventAuxiliary"):
62  branch.SetAddress(buffer)
63  else:
64  branch.SetAddress(ROOT.AddressOf(buffer))
65  return buffer
66 
67 

References if().

◆ loop()

def python.cmstools.loop (   begin,
  end 
)
Convert a pair of C++ iterators into a python generator

Definition at line 47 of file cmstools.py.

47 def loop(begin, end):
48  """Convert a pair of C++ iterators into a python generator"""
49  while (begin != end):
50  yield begin.__deref__() #*b
51  begin.__preinc__() #++b
52 
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
python.cmstools.loop
def loop(begin, end)
Definition: cmstools.py:47
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:48
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:26
python.cmstools.createBranchBuffer
def createBranchBuffer(branch)
auto branch types (Chris Jones)
Definition: cmstools.py:54