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 25 of file cmstools.py.

References FastTimerService_cff.range.

Referenced by pat::EventHypothesis.all(), HepMCValidationHelper.allStatus1(), HepMCValidationHelper.allStatus2(), HepMCValidationHelper.allStatus3(), HepMCValidationHelper.allVisibleParticles(), SiPixelPhase1GeometryDebug.analyze(), HGcalHitIdCheck.analyze(), HGCalTestScintHits.analyze(), HGCalTestPartialWaferRecHits.analyze(), HGCalTestPartialWaferHits.analyze(), TestPortableAnalyzer.analyze(), TestAlpakaAnalyzer.analyze(), LayerCollector.barrelLayers(), AlignmentMonitorSurvey.book(), DQMGenericTnPClient.calculateEfficiency(), dqmTnP::AbstractFitter.calculateEfficiency(), HGCalCLUEAlgoT< TILE >.calculateLocalDensity(), CastorHardcodeCalibrations.CastorHardcodeCalibrations(), SummaryOutputProducer::TriggerSummary.changed(), combineBTagCalibrationData.check_csv_data(), GlobalMuonRefitter.checkMuonHits(), Phase2L1GMT::ROITempAssociator.clean(), 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(), l1tVertexFinder::AnalysisSettings.genPdgIds(), run_AlCaRecoTriggerBitsUpdateWorkflow.get_iovs(), tools.get_iovs(), tools.get_tags(), SiStripDetCabling.getAllDetectorsContiguousIds(), G2GainsValidator.getExpressGT(), GlobalMuonRefitter.getFirstHits(), 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(), SiStripHitEfficiencyHarvester.makeSummary(), SiStripHitEffFromCalibTree.makeSummary(), AlignableTracker.merge(), mergeLHE.DefaultLHEMerger.merge_headers(), mergeLHE.DefaultLHEMerger.merge_init_blocks(), 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(), Phase2L1GMT::ROITempAssociator.selectLayerBX(), 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().

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

◆ createBranchBuffer()

def python.cmstools.createBranchBuffer (   branch)

auto branch types (Chris Jones)

Definition at line 53 of file cmstools.py.

References caHitNtupletGeneratorKernels.if().

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

◆ loop()

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

Definition at line 46 of file cmstools.py.

46 def loop(begin, end):
47  """Convert a pair of C++ iterators into a python generator"""
48  while (begin != end):
49  yield begin.__deref__() #*b
50  begin.__preinc__() #++b
51 
def loop(begin, end)
Definition: cmstools.py:46