CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Attributes
JSONExport.JsonExport Class Reference
Inheritance diagram for JSONExport.JsonExport:

Public Member Functions

def __init__
 
def export
 
def produce
 

Static Public Attributes

tuple file_types = ('html','json')
 
dictionary option_types = {}
 
string plugin_name = 'JSON Export'
 

Detailed Description

Definition at line 15 of file JSONExport.py.

Constructor & Destructor Documentation

def JSONExport.JsonExport.__init__ (   self)

Definition at line 19 of file JSONExport.py.

19 
20  def __init__(self):
21  FileExportPlugin.__init__(self)

Member Function Documentation

def JSONExport.JsonExport.export (   self,
  data,
  filename,
  filetype 
)

Definition at line 136 of file JSONExport.py.

References cond::EmptyIOVSource.produce(), DimuonMCMatcher.produce(), ShallowEventDataProducer.produce(), ShallowExampleProducer.produce(), WeakEffectsWeightProducer.produce(), MagneticFieldMapESProducer.produce(), FastStripCPEESProducer.produce(), TrackerInteractionGeometryESProducer.produce(), FastPixelCPEESProducer.produce(), DoubleProducer.produce(), PixelToFEDAssociateFromAsciiESProducer.produce(), PixelToLNKAssociateFromAsciiESProducer.produce(), ShallowTracksProducer.produce(), PatElectronEAIsoCorrectionProducer.produce(), ShallowRechitClustersProducer.produce(), HcalLaserEventFiltProducer2012.produce(), SiPixelFedCablingMapBuilder.produce(), ShallowTrackClustersProducer.produce(), RazorVarProducer.produce(), ShallowSimhitClustersProducer.produce(), reco::modules::CaloRecHitCandidateProducer< HitCollection >.produce(), ElectronSqPtTkIsolationProducer.produce(), SiPixelFakeCPEGenericErrorParmESSource.produce(), ConversionTrackRefFix.produce(), AlphaTVarProducer.produce(), Phase2TrackerCablingESProducer.produce(), sistrip::MeasureLA.produce(), CSCIndexerESProducer.produce(), DummyModule.produce(), CSCChannelMapperESProducer.produce(), MFProducer.produce(), DistortedMETProducer.produce(), SiPixelFakeGenErrorDBObjectESSource.produce(), SiPixelFakeTemplateDBObjectESSource.produce(), ShallowSimTracksProducer.produce(), EventVtxInfoNtupleDumper.produce(), DTDigiToRawModule.produce(), ParticleDecayProducer.produce(), JSONExport.JsonExport.produce(), CandPtrProjector.produce(), Phase2Tracker::Phase2TrackerCommissioningDigiProducer.produce(), AssociationMapOneToOne2Association< CKey, CVal >.produce(), AssociationVectorSelector< KeyRefProd, CVal, KeySelector, ValSelector >.produce(), DiJetVarProducer.produce(), DistortedMuonProducerFromDB.produce(), MuonWithPFIsoProducer.produce(), ESRawToDigi.produce(), CastorFastTowerProducer.produce(), FSPFProducer.produce(), AssociationVector2ValueMap< KeyRefProd, CVal >.produce(), IPTCorrector.produce(), DistortedPFCandProducer.produce(), DistortedMuonProducer.produce(), evf::EvFFEDSelector.produce(), CandViewRefMerger.produce(), RawDataCollectorByLabel.produce(), CastorDbProducer.produce(), CastorFastClusterProducer.produce(), CalibratedPatElectronProducer.produce(), SiStripFedCablingESProducer.produce(), RegressionEnergyPatElectronProducer.produce(), SiStripGainESSource.produce(), SiStripHashedDetIdESProducer.produce(), HcalCalibFEDSelector.produce(), ElectronSeedTrackRefFix.produce(), CollectionAdder< C >.produce(), RPCPerformanceESSource.produce(), ShallowClustersProducer.produce(), SiStripPedestalsESSource.produce(), ISRGammaWeightProducer.produce(), SiStripDelayESProducer.produce(), SiStripNoiseESSource.produce(), SiStripQualityESProducer.produce(), CaloRecHitCopy.produce(), FamosProducer.produce(), SimTrackIdProducer.produce(), FSRWeightProducer.produce(), ISRWeightProducer.produce(), SiStripBackPlaneCorrectionDepESProducer.produce(), SiStripLorentzAngleDepESProducer.produce(), DTUnpackingModule.produce(), EcalLaserCorrectionService.produce(), IsolatedEcalPixelTrackCandidateProducer.produce(), FWRecoGeometryESProducer.produce(), PdfWeightProducer.produce(), CSCDCCUnpacker.produce(), ESDigiToRaw.produce(), PixelTracksProducer.produce(), SiStripTemplateEmptyFakeESSource< TObject, TRecord >.produce(), CaloRecHitsProducer.produce(), FastTSGFromL2Muon.produce(), AlignmentPrescaler.produce(), NtpProducer< C >.produce(), SiStripProcessedRawDigiProducer.produce(), SiStripTemplateFakeESSource< TObject, TRecord, TService >.produce(), CastorHardcodeCalibrations.produce(), LmfSource.produce(), DTFakeTTrigESProducer.produce(), SiPixelGenErrorDBObjectESProducer.produce(), DTFakeVDriftESProducer.produce(), SiPixelTemplateDBObjectESProducer.produce(), ZMuMuTrackUserData.produce(), CastorDigiToRaw.produce(), SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >.produce(), CandReducer.produce(), FRDStreamSource.produce(), CandidateTriggerObjectProducer.produce(), reco::modules::MatcherBase< C1, C2, M >.produce(), reco::modulesNew::Matcher< C1, C2, S, D >.produce(), SiPixelFedFillerWordEventNumber.produce(), TriggerMatchProducer< object >.produce(), CalibratedElectronProducer.produce(), ElectronPATIdMVAProducer.produce(), ZMuMuMuonUserData.produce(), SiStripQualityFakeESSource.produce(), CloneProducer< C >.produce(), ShallowCloneProducer< C >.produce(), HcalDigiToRaw.produce(), HcalHistogramRawToDigi.produce(), AlcaBeamSpotFromDB.produce(), RawDataSelector.produce(), TrackInfoProducer.produce(), ShallowDigisProducer.produce(), PFCandIsolatorFromDeposits.produce(), Phase2Tracker::Phase2TrackerDigiProducer.produce(), RPCPackingModule.produce(), sistrip::RawToDigiModule.produce(), sistrip::DigiToRawModule.produce(), ElectronRecalibSuperClusterAssociator.produce(), ZMuMuUserDataOneTrack.produce(), ZMuMuUserData.produce(), TkAlCaOverlapTagger.produce(), CastorRawToDigi.produce(), EcalDCCTBUnpackingModule.produce(), DeltaBetaWeights.produce(), RPCUnpackingModule.produce(), sistrip::ExcludedFEDListProducer.produce(), CastorTextCalibrations.produce(), EcalDCCTB07UnpackingModule.produce(), HcalRawToDigi.produce(), MillePedeFileConverter.produce(), edm::ThinningProducer< Collection, Selector >.produce(), TrackingRecHitTranslator.produce(), PiZeroDiscriminatorProducer.produce(), L1GctInternJetProducer.produce(), LaserAlignmentProducer.produce(), AlcaBeamSpotProducer.produce(), SubdetFEDSelector.produce(), PuppiProducer.produce(), edm::FwdPtrProducer< T, H >.produce(), EventCountProducer.produce(), Type1PFMET.produce(), PFMET.produce(), HcalOmdsCalibrations.produce(), SiPixelDigiToRaw.produce(), PileUpProducer.produce(), edm::ProductFromFwdPtrProducer< T, H >.produce(), SiStripRegFEDSelector.produce(), CSCTFPacker.produce(), CSCDigiToRawModule.produce(), SiPixelRawToDigi.produce(), pf2pat::PFMETAlgo.produce(), FWTGeoRecoGeometryESProducer.produce(), sistrip::SpyEventSummaryProducer.produce(), EcalGlobalShowerContainmentCorrectionsVsEtaESProducer.produce(), DaqFakeReader.produce(), DTFakeT0ESProducer.produce(), Merger< InputCollection, OutputCollection, P >.produce(), EcalRegionCablingESProducer.produce(), DTTFFEDSim.produce(), EcalShowerContainmentCorrectionsESProducer.produce(), HcalDbProducer.produce(), MatchedProbeMaker< T >.produce(), EcalIsolatedParticleCandidateProducer.produce(), LaserAlignmentT0Producer.produce(), TagProbeMassProducer.produce(), sistrip::SpyDigiConverterModule.produce(), WMuNuProducer.produce(), CSCTFUnpacker.produce(), FastElectronSeedProducer.produce(), L1TriggerKeyListDummyProd.produce(), AlCaEcalHcalReadoutsProducer.produce(), DTTFFEDReader.produce(), edm::TriggerResultInserter.produce(), SiPixelFakeGainESSource.produce(), SiPixelFakeGainForHLTESSource.produce(), SiPixelFakeGainOfflineESSource.produce(), L1TriggerKeyDummyProd.produce(), AlCaElectronTracksReducer.produce(), HcalRecHitRecalib.produce(), EcalRecHitRecalib.produce(), BufferedBoostIOESProducer< DataType, MyRecord >.produce(), ZToLLEdmNtupleDumper.produce(), SiClusterTranslator.produce(), pf2pat::PFIsoDepositAlgo.produce(), PileUpSimulator.produce(), PrimaryVertexSorter< ParticlesCollection >.produce(), FastL1CaloSim.produce(), PFCand_AssoMap.produce(), AlCaHBHEMuonProducer.produce(), PFPileUp.produce(), SiPixelFakeLorentzAngleESSource.produce(), SiPixelFakeQualityESSource.produce(), ECALRegFEDSelector.produce(), L1SubsystemKeysOnlineProd.produce(), KalmanAlignmentAlgorithm.produce(), L1TriggerKeyOnlineProd.produce(), SiStripFineDelayHit.produce(), AlCaDiJetsProducer.produce(), TrackCandidateProducer.produce(), AlCaGammaJetProducer.produce(), HBHENoiseFilterResultProducer.produce(), ScalersRawToDigi.produce(), L1ObjectKeysOnlineProdBase.produce(), cms::HitReCalibrator.produce(), SiPixelQualityESProducer.produce(), LTCRawToDigi.produce(), HcalTextCalibrations.produce(), EventWithHistoryProducer.produce(), L1GlobalTriggerRecordProducer.produce(), GctDigiToRaw.produce(), MisalignedTrackerESProducer.produce(), PF_PU_AssoMap.produce(), HcalTPGCoderULUT.produce(), FromClusterSummaryMultiplicityProducer.produce(), AlCaHcalNoiseProducer.produce(), HITSiStripRawToClustersRoI.produce(), IsolatedPixelTrackCandidateProducer.produce(), EventWithHistoryProducerFromL1ABC.produce(), CaloTPGTranscoderULUTs.produce(), pf2pat::TopProjectorAlgo< Top, Bottom >.produce(), l1t::L1TRawToDigi.produce(), HcalHardcodeCalibrations.produce(), EcalFEDWithCRCErrorProducer.produce(), EcalRawToDigi.produce(), ConfigurableAPVCyclePhaseProducer.produce(), MuonMillepedeTrackRefitter.produce(), MisalignedMuonESProducer.produce(), ValueMapTraslator.produce(), PF_PU_FirstVertexTracks.produce(), SoftKillerProducer.produce(), GctRawToDigi.produce(), AlCaECALRecHitReducer.produce(), l1t::L1TDigiToRaw.produce(), EcalDigiToRaw.produce(), MultiplicityProducer< T >.produce(), CaloMiscalibTools.produce(), CaloMiscalibToolsMC.produce(), ConditionDumperInEdm.produce(), L1GlobalTriggerEvmRawToDigi.produce(), L1ConfigOnlineProdBase< TRcd, TData >.produce(), HLTTauRefProducer.produce(), TcdsRawToDigi.produce(), L1GTEvmDigiToRaw.produce(), L1GtTextToRaw.produce(), JetDeltaRTagInfoValueMapProducer< T, I >.produce(), SiTrackerGaussianSmearingRecHitConverter.produce(), PFCand_NoPU_WithAM.produce(), l1t::AMCDumpToRaw.produce(), l1t::AMC13DumpToRaw.produce(), AlignmentMuonHIPTrajectorySelector.produce(), KalmanAlignmentTrackRefitter.produce(), TGeoMgrFromDdd.produce(), L1GTDigiToRaw.produce(), SiPixelCalibDigiProducer.produce(), sistrip::SpyUnpackerModule.produce(), L1GtTriggerMenuLiteProducer.produce(), reco::modules::TrackFullCloneSelectorBase< Selector >.produce(), APVCyclePhaseProducerFromL1ABC.produce(), L1GlobalTriggerRawToDigi.produce(), MEtoEDMConverter.produce(), ShallowGainCalibration.produce(), l1t::MP7BufferDumpToRaw.produce(), sistrip::FEDEmulatorModule.produce(), edm::stream::EDProducerBase.produce(), TrackerToMuonPropagator.produce(), APVCyclePhaseProducerFromL1TS.produce(), Pi0FixedMassWindowCalibration.produce(), CSCOverlapsTrackPreparation.produce(), TkLasBeamFitter.produce(), reco::PhysObjectMatcher< C1, C2, S, D, Q >.produce(), JetDeltaRValueMapProducer< T >.produce(), edm::EDProducer.produce(), MuonSimHitProducer.produce(), ZeeCalibration.produce(), AlCaIsoTracksProducer.produce(), CandidateProducer< TColl, CColl, Selector, Conv, Creator, Init >.produce(), LaserAlignment.produce(), TrajectorySeedProducer.produce(), SelectedElectronFEDListProducer< TEle, TCand >.produce(), edm::one::EDProducerBase.produce(), edm::global::EDProducerBase.produce(), reco::modules::NamedCandCombiner< Selector, PairSelector, Cloner, Setup, Init >.produce(), MatacqProducer.produce(), reco::modules::CandCombiner< Selector, PairSelector, Cloner, OutputCollection, Setup, Init >.produce(), TopProjector< Top, Bottom, Matcher >.produce(), AlCaHOCalibProducer.produce(), edm::stream::CallBeginRunProduceImpl< T, bool >.produce(), edm::stream::CallBeginRunProduceImpl< T, false >.produce(), edm::stream::CallEndRunProduceImpl< T, bProduce, bSummary >.produce(), edm::stream::CallEndRunProduceImpl< T, true, false >.produce(), edm::stream::CallEndRunProduceImpl< T, true, true >.produce(), edm::stream::CallBeginLuminosityBlockProduceImpl< T, bool >.produce(), edm::stream::CallBeginLuminosityBlockProduceImpl< T, false >.produce(), edm::stream::CallEndLuminosityBlockProduceImpl< T, bProduce, bSummary >.produce(), edm::stream::CallEndLuminosityBlockProduceImpl< T, true, false >.produce(), edm::stream::CallEndLuminosityBlockProduceImpl< T, true, true >.produce(), HTMLExport.HTMLExport.produce(), and HTMLExport.HTMLExportStatic.produce().

137  def export(self,data,filename,filetype):
138  if not data.process():
139  raise "JSONExport requires a cms.Process object"
140 
141  json = self.produce(data)
142 
143  if filetype=='json':
144  jsonfile = open(filename,'w')
145  jsonfile.write(json)
146  jsonfile.close()
147  if filetype=='html':
148  #open the HTML template and inject the JSON...
149  pass
150 
def JSONExport.JsonExport.produce (   self,
  data 
)

Definition at line 22 of file JSONExport.py.

Referenced by JSONExport.JsonExport.export().

22 
23  def produce(self,data):
24 
25  #pset = lambda pdict: [[k,repr(v).split('(',1)[0],(repr(v).split('(',1)[1][:-1])] for k,v in pdict.items()]
26  def pset(pdict):
27  result = []
28  for k,v in pdict.items():
29  if v.pythonTypeName()=='cms.PSet' or v.pythonTypeName()=='cms.untracked.PSet':
30  result.append([k,v.pythonTypeName(),'pset',pset(v.parameters_())])
31  elif v.pythonTypeName()=='cms.VPSet' or v.pythonTypeName()=='cms.untracked.VPSet':
32  result.append([k,v.pythonTypeName(),'vpset',[pset(a.parameters_()) for a in v]])
33  elif v.pythonTypeName().lower().startswith('cms.v') or v.pythonTypeName().lower().startswith('cms.untracked.v'):
34  result.append([k,v.pythonTypeName(),'list',[repr(a) for a in v]])
35  else:
36  result.append([k,v.pythonTypeName(),'single',repr(v.pythonValue())])
37  return result
38 
39  #allObjects = [d for d in data._allObjects if (data.type(d) in ("EDProducer","EDFilter","EDAnalyzer","OutputModule"))]
40  #data.readConnections(allObjects)
41 
42  def moduledict(mod,prefix,links=False):
43  result={}
44  result['label']=data.label(mod)
45  result['class']=data.classname(mod)
46  result['file']=data.pypath(mod)
47  result['line']=data.lineNumber(mod)
48  result['package']=data.pypackage(mod)
49  result['pset']=pset(mod.parameters_())
50  result['type']=data.type(mod)
51  if links:
52  result['uses']=[data.uses(mod)]
53  result['usedby']=[data.usedBy(mod)]
54  result['id']='%s_%s'%(prefix,data.label(mod))
55  return result
56 
57  all={}
58  for tlo in data.topLevelObjects():
59  children=data.children(tlo)
60  if children:
61  all[tlo._label]=children
62 
63  process = {'name':data.process().name_(),'src':data._filename}
64 
65  #now unavailable
66  #schedule = []
67  #if 'Schedule' in all:
68  # for s in all['Schedule']:
69  # schedule.append(data.label(s))
70 
71  source={}
72  if 'source' in all:
73  s = all['source'][0]
74  source['class']=data.classname(s)
75  source['pset']=pset(s.parameters_())
76 
77  essources=[]
78  if 'essources' in all:
79  for e in all['essources']:
80  essources.append(moduledict(e,'essource'))
81  esproducers=[]
82  if 'esproducers' in all:
83  for e in all['esproducers']:
84  essources.append(moduledict(e,'esproducer'))
85  esprefers=[]
86  if 'esprefers' in all:
87  for e in all['esprefers']:
88  essources.append(moduledict(e,'esprefers'))
89  services=[]
90  if 'services' in all:
91  for s in all['services']:
92  services.append({'class':data.classname(s),'pset':pset(s.parameters_())})
93 
94 
95  def jsonPathRecursive(p,prefix):
96  #print "At:",self.label(p),self.type(p)
97  children = data.children(p)
98  if children:
99  children = [jsonPathRecursive(c,prefix) for c in children]
100  return {'type':'Sequence','label':'Sequence %s'%(data.label(p)),'id':'seq_%s' % data.label(p),'children':children}
101  else:
102  return moduledict(p,prefix,True)
103 
104 
105  paths=[]
106  if 'paths' in all:
107  for p in all['paths']:
108  path=jsonPathRecursive(p,data.label(p))
109  if path:
110  if not type(path)==type([]):
111  if path['type']=='Sequence':
112  path = path['children']
113  else:
114  path = [path]
115  else:
116  path=[]
117  paths.append({'label':data.label(p),'path':path})
118  endpaths=[]
119  if 'endpaths' in all:
120  for p in all['endpaths']:
121  path=jsonPathRecursive(p,data.label(p))
122  if path:
123  if not type(path)==type([]):
124  if path['type']=='Sequence':
125  path = path['children']
126  else:
127  path = [path]
128  else:
129  path=[]
130  endpaths.append({'label':data.label(p),'path':path})
131 
132  #json={'process':process,'schedule':schedule,'source':source,'essources':essources,'esproducers':esproducers,'esprefers':esprefers,'services':services,'paths':paths,'endpaths':endpaths}
133  json={'process':process,'source':source,'essources':essources,'esproducers':esproducers,'esprefers':esprefers,'services':services,'paths':paths,'endpaths':endpaths}
134 
135  return repr(json)

Member Data Documentation

tuple JSONExport.JsonExport.file_types = ('html','json')
static

Definition at line 18 of file JSONExport.py.

dictionary JSONExport.JsonExport.option_types = {}
static

Definition at line 16 of file JSONExport.py.

string JSONExport.JsonExport.plugin_name = 'JSON Export'
static

Definition at line 17 of file JSONExport.py.