CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
edmPickEvents Namespace Reference

Classes

class  Event
 Event helper class ##. More...
 

Functions

def fullCPMpath
 
def getFileNames
 Subroutines ##. More...
 
def getFileNames_das_client
 
def getFileNames_dasgoclient
 
def guessEmail
 
def setupCrabDict
 

Variables

tuple colonRE = re.compile(r':')
 
string command = 'edmCopyPickMerge outputFile=%s.root \\\n eventsToProcess=%s \\\n inputFiles=%s'
 
tuple commentRE = re.compile(r'#.+$')
 
tuple crabDict = setupCrabDict(options)
 
string crabTemplate
 
string das_cli = ''
 
string default = 'pickevents'
 
tuple email = guessEmail()
 

Main Program

More...
 
tuple event = Event(piece)
 
tuple eventFiles = getFileNames(event, options.das_cli)
 
list eventList = []
 
list eventPurgeList = []
 
string eventsToProcess = '\n'
 
list files = []
 Interactive ##. More...
 
tuple fileSet = set()
 
string help
 
tuple json = LumiList(lumis = runsAndLumis)
 
tuple line = commentRE.sub('', line)
 
tuple parser
 
list runsAndLumis = [ (event.run, event.lumi) for event in eventList]
 CRAB ##. More...
 
tuple source = open(args[0], 'r')
 
tuple target = open(crabDict['runEvent'], 'w')
 
list uniqueFiles = []
 

Function Documentation

def edmPickEvents.fullCPMpath ( )

Definition at line 138 of file edmPickEvents.py.

Referenced by setupCrabDict().

139 def fullCPMpath():
140  base = os.environ.get ('CMSSW_BASE')
141  if not base:
142  raise RuntimeError("CMSSW Environment not set")
143  retval = "%s/src/PhysicsTools/Utilities/configuration/copyPickMerge_cfg.py" \
144  % base
145  if os.path.exists (retval):
146  return retval
147  base = os.environ.get ('CMSSW_RELEASE_BASE')
148  retval = "%s/src/PhysicsTools/Utilities/configuration/copyPickMerge_cfg.py" \
149  % base
150  if os.path.exists (retval):
151  return retval
152  raise RuntimeError("Could not find copyPickMerge_cfg.py")
def edmPickEvents.getFileNames (   event,
  client = None 
)

Subroutines ##.

Return files for given DAS query

Definition at line 86 of file edmPickEvents.py.

References getFileNames_das_client(), getFileNames_dasgoclient(), and submitPVValidationJobs.split().

86 
87 def getFileNames(event, client=None):
88  """Return files for given DAS query"""
89  if client == 'das_client':
90  return getFileNames_das_client(event)
91  elif client == 'dasgoclient':
92  return getFileNames_dasgoclient(event)
93  # default action
94  for path in os.getenv('PATH').split(':'):
95  if os.path.isfile(os.path.join(path, 'dasgoclient')):
96  return getFileNames_dasgoclient(event)
97  return getFileNames_das_client(event)
def getFileNames
Subroutines ##.
def getFileNames_das_client
def getFileNames_dasgoclient
def edmPickEvents.getFileNames_das_client (   event)
Return files for given DAS query via das_client

Definition at line 98 of file edmPickEvents.py.

References das_client.get_data(), das_client.get_value(), and print().

Referenced by getFileNames().

98 
99 def getFileNames_das_client(event):
100  """Return files for given DAS query via das_client"""
101  files = []
102 
103  query = "file dataset=%(dataset)s run=%(run)i lumi=%(lumi)i | grep file.name" % event
104  jsondict = das_client.get_data(query)
105  status = jsondict['status']
106  if status != 'ok':
107  print("DAS query status: %s"%(status))
108  return files
109 
110  mongo_query = jsondict['mongo_query']
111  filters = mongo_query['filters']
112  data = jsondict['data']
113 
114  files = []
115  for row in data:
116  file = [r for r in das_client.get_value(row, filters['grep'])][0]
117  if len(file) > 0 and not file in files:
118  files.append(file)
119 
120  return files
def get_data
Definition: das_client.py:276
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def get_value
Definition: das_client.py:248
def getFileNames_das_client
def edmPickEvents.getFileNames_dasgoclient (   event)
Return files for given DAS query via dasgoclient

Definition at line 121 of file edmPickEvents.py.

References print().

Referenced by getFileNames().

122 def getFileNames_dasgoclient(event):
123  """Return files for given DAS query via dasgoclient"""
124  query = "file dataset=%(dataset)s run=%(run)i lumi=%(lumi)i" % event
125  cmd = ['dasgoclient', '-query', query, '-json']
126  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
127  files = []
128  err = proc.stderr.read()
129  if err:
130  print("DAS error: %s" % err)
131  else:
132  for row in json.load(proc.stdout):
133  for rec in row.get('file', []):
134  fname = rec.get('name', '')
135  if fname:
136  files.append(fname)
137  return files
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def getFileNames_dasgoclient
def edmPickEvents.guessEmail ( )

Definition at line 153 of file edmPickEvents.py.

References join(), and submitPVValidationJobs.split().

154 def guessEmail():
155  return '%s@%s' % (subprocess.getoutput ('whoami'),
156  '.'.join(subprocess.getoutput('hostname').split('.')[-2:]))
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def edmPickEvents.setupCrabDict (   options)

Definition at line 157 of file edmPickEvents.py.

References fullCPMpath().

158 def setupCrabDict (options):
159  date = datetime.now().strftime('%Y%m%d_%H%M%S')
160  crab = {}
161  base = options.base
162  crab['runEvent'] = '%s_runEvents.txt' % base
163  crab['copyPickMerge'] = fullCPMpath()
164  crab['output'] = '%s.root' % base
165  crab['crabcfg'] = '%s_crab.py' % base
166  crab['json'] = '%s.json' % base
167  crab['dataset'] = Event.dataset
168  crab['email'] = options.email
169  crab['WorkArea'] = date
170  if options.crabCondor:
171  crab['scheduler'] = 'condor'
172 # crab['useServer'] = ''
173  else:
174  crab['scheduler'] = 'remoteGlidein'
175 # crab['useServer'] = 'use_server = 1'
176  crab['useServer'] = ''
177  return crab
178 
# crab template

Variable Documentation

tuple edmPickEvents.colonRE = re.compile(r':')

Definition at line 267 of file edmPickEvents.py.

string edmPickEvents.command = 'edmCopyPickMerge outputFile=%s.root \\\n eventsToProcess=%s \\\n inputFiles=%s'

Definition at line 351 of file edmPickEvents.py.

tuple edmPickEvents.commentRE = re.compile(r'#.+$')

Definition at line 266 of file edmPickEvents.py.

tuple edmPickEvents.crabDict = setupCrabDict(options)

Definition at line 308 of file edmPickEvents.py.

string edmPickEvents.crabTemplate

Definition at line 179 of file edmPickEvents.py.

string edmPickEvents.das_cli = ''

Definition at line 251 of file edmPickEvents.py.

string edmPickEvents.default = 'pickevents'

Definition at line 235 of file edmPickEvents.py.

tuple edmPickEvents.email = guessEmail()

Main Program

Definition at line 230 of file edmPickEvents.py.

tuple edmPickEvents.event = Event(piece)

Definition at line 273 of file edmPickEvents.py.

Referenced by DQMGlobalEDAnalyzerBase< Histograms_TICLTrackstersEdgesValidation, Args...>.accumulate(), DQMEDAnalyzer.accumulate(), SummaryOutputProducer::GenericSummary.addEntry(), HcalLaserEventFilter2012.addEventString(), DTVDriftSegmentCalibration.analyze(), PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo.analyze(), SiPixelPhase1RecHitsV.analyze(), DTTTrigOffsetCalibration.analyze(), DTResidualCalibration.analyze(), TkConvValidator.analyze(), DTChamberEfficiency.analyze(), TreeProducerCalibSimul.analyze(), Rivet::CMS_2013_I1224539_DIJET.analyze(), fwlite::AnalyzerWrapper< T >.analyze(), Rivet::RivetAnalysis.analyze(), GeneralPurposeTrackAnalyzer.analyze(), edm::BeamMomentumGunProducer.BeamMomentumGunProducer(), GsfElectronAlgo.beginEvent(), FWTrackingParticleProxyBuilderFullFramework.build(), FWMagField.checkFieldInfo(), Rivet::HiggsTemplateCrossSections.classifyEvent(), HltDiff.compare(), CSCFileDumper.CSCFileDumper(), FWTriggerTableView.dataChanged(), BiasedTauDecayer.decay(), edm.decode(), edm::global::outputmodule::ExternalWork< T >.doAcquire_(), edm::EDLooperBase.doDuringLoop(), FWFFMetadataManager.doUpdate(), HGCalValidator.dqmAnalyze(), fwlite::EventHistoryGetter.EventHistoryGetter(), CSCValHists.fill2DHistByEvent(), SiPixelRecHitsValid.fillBarrel(), edm::IndexIntoFile.fillEventNumbersOrEntries(), FedRawDataInputSource.fillFEDRawDataCollection(), SiPixelRecHitsValid.fillForward(), Py8toJetInputHEPEVT.fillJetAlgoInput(), FWHLTTriggerTableView.fillTable(), MultiEventFilter.filter(), edm::FilterWrapper< T >.filter(), edm::GeneratorFilter< HAD, DEC >.filter(), edm::HadronizerFilter< HAD, DEC >.filter(), EcalDeadCellTriggerPrimitiveFilter.filter(), edm::ConcurrentGeneratorFilter< HAD, DEC >.filter(), edm::ConcurrentHadronizerFilter< HAD, DEC >.filter(), PhotonConversionTrajectorySeedProducerFromSingleLegAlgo.find(), edm::IndexIntoFile.findPosition(), VertexClassifier.genPrimaryVertices(), TrackClassifier.genPrimaryVertices(), cms::cuda::EventCache.get(), sistrip::SpyEventMatcher.getCollections(), sistrip::SpyEventMatcher.getCounters(), ExpressionEvaluatorCutWithEventContent.getEventContent(), edm::PoolSource.getNextItemType(), sistrip::SpyEventMatcher.getProduct(), PrimaryVertexAnalyzer4PUSlimmed.getSimPVs(), PrescaleEventFilter.globalEndJob(), HLTPrescaler.globalEndJob(), CmsShowNavigator.goTo(), FWGLEventHandler.HandleKey(), HFShowerLibrary.HFShowerLibrary(), CastorShowerLibrary.initFile(), HcalSignalGenerator< HBHEDigitizerTraits >.initializeEvent(), TrackingTruthAccumulator.initializeEvent(), EcalSignalGenerator< EEDigitizerTraits >.initializeEvent(), main(), gen::TauolappInterface.make_simple_tau_event(), TSToSCAssociatorByEnergyScoreImpl.makeConnections(), LCToSCAssociatorByEnergyScoreImpl.makeConnections(), cms::cuda::EventCache.makeOrGet(), helper::MasterCollection< edm::View< T > >.MasterCollection(), TrackingNtuple.matchCluster(), rpcrawtodigi::EventRecords.mergeRecords(), lhef::LHEReader.next(), CSCFileReader.nextEventFromFUs(), SummaryOutputProducer::Event.operator<(), edm::SetRunHelper.overrideRunNumber(), edm::SetRunForEachLumiHelper.overrideRunNumber(), edm::FirstLuminosityBlockForEachRunHelper.overrideRunNumber(), edm::service::MessageLogger.preEvent(), SummaryOutputProducer.prepareSummaries(), VariableHelper.printValues(), TFWLiteSelectorBasic.Process(), NtpProducer< C >.produce(), LowPtGsfElectronIDProducer.produce(), RPCUnpackingModule.produce(), TotemVFATRawToDigi.produce(), CSCDigiFilter.produce(), MuonProducer.produce(), L1TowerCalibrator.produce(), TriggerMatcherToHLTDebug.produce(), edm::ThinningProducer< Collection, Selector >.produce(), CSCChamberMasker.produce(), L1TPFProducer.produce(), EgammaHLTExtraProducer.produce(), EgammaHLTPhase2ExtraProducer.produce(), HLTCaloObjInRegionsProducer< CaloObjType, CaloObjCollType >.produce(), HLTRecHitInAllL1RegionsProducer< RecHitType >.produce(), GenPUProtonProducer.produce(), FileReaderDCC.read(), FileReaderDDU.read(), edm::EventProcessor.readEvent(), edm::PoolSource.readIt(), edm::RootEmbeddedFileSequence.readOneSpecified(), removeCPFromPU(), fwlite::Scanner< Collection >.scan(), CosmicTrackingParticleSelector.select(), FWFFNavigator.setCurrentEvent(), CompositeTSG.setEvent(), LHAupLesHouches.setEvent(), TrackerSeedGenerator.setEvent(), MuonTrackingRegionByPtBuilder.setEvent(), MuonTrackingRegionBuilder.setEvent(), GlobalTrajectoryBuilderBase.setEvent(), MTDDetLayerMeasurements.setEvent(), MuonDetLayerMeasurements.setEvent(), edm::EventPrincipal.setRunAndLumiNumber(), AliDaqEventHeader.SetRunEvt(), MuonsGrabber.startNewEvent(), TB06TreeH2.store(), TB06Tree.store(), fwlite::MultiChainEvent.to(), fwlite::Event.to(), pat::helper::TriggerMatchHelper.triggerMatchCandidates(), pat::helper::TriggerMatchHelper.triggerMatchObject(), pat::helper::TriggerMatchHelper.triggerMatchObjects(), L1TdeStage2CaloLayer1.updateMismatch(), FWEventAnnotation.updateOverlayText(), and MuIsolatorResultProducer< BT >.writeOut().

tuple edmPickEvents.eventFiles = getFileNames(event, options.das_cli)

Definition at line 331 of file edmPickEvents.py.

list edmPickEvents.eventList = []

Definition at line 268 of file edmPickEvents.py.

list edmPickEvents.eventPurgeList = []

Definition at line 329 of file edmPickEvents.py.

string edmPickEvents.eventsToProcess = '\n'

Definition at line 306 of file edmPickEvents.py.

list edmPickEvents.files = []

Interactive ##.

Definition at line 328 of file edmPickEvents.py.

tuple edmPickEvents.fileSet = set()

Definition at line 341 of file edmPickEvents.py.

Referenced by TauDQMFileLoader.endRun(), and TauDQMFileLoader.TauDQMFileLoader().

string edmPickEvents.help
Initial value:
1 = """
2 How to use:
3 
4 edmPickEvent.py dataset run1:lumi1:event1 run2:lumi2:event2
5 
6 - or -
7 
8 edmPickEvent.py dataset listOfEvents.txt
9 
10 listOfEvents is a text file:
11 # this line is ignored as a comment
12 # since '#' is a valid comment character
13 run1 lumi_section1 event1
14 run2 lumi_section2 event2
15 
16 For example:
17 # run lum event
18 46968 2 4
19 47011 105 23
20 47011 140 12312
21 
22 run, lumi_section, and event are integers that you can get from
23 edm::Event(Auxiliary)
24 
25 dataset: it just a name of the physics dataset, if you don't know exact name
26  you can provide a mask, e.g.: *QCD*RAW
27 
28 For updated information see Wiki:
29 https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookPickEvents
30 """

Definition at line 21 of file edmPickEvents.py.

tuple edmPickEvents.json = LumiList(lumis = runsAndLumis)

Definition at line 305 of file edmPickEvents.py.

tuple edmPickEvents.line = commentRE.sub('', line)

Definition at line 281 of file edmPickEvents.py.

tuple edmPickEvents.parser
Initial value:
1 = optparse.OptionParser("Usage: %prog [options] dataset events_or_events.txt", description='''This program
2 facilitates picking specific events from a data set. For full details, please visit
3 https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookPickEvents ''')

Definition at line 231 of file edmPickEvents.py.

list edmPickEvents.runsAndLumis = [ (event.run, event.lumi) for event in eventList]

CRAB ##.

Definition at line 304 of file edmPickEvents.py.

string edmPickEvents.source = open(args[0], 'r')

Definition at line 279 of file edmPickEvents.py.

tuple edmPickEvents.target = open(crabDict['runEvent'], 'w')

Definition at line 310 of file edmPickEvents.py.

list edmPickEvents.uniqueFiles = []

Definition at line 342 of file edmPickEvents.py.