CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cmsswVersionTools.py
Go to the documentation of this file.
2 
6 from Configuration.PyReleaseValidation.autoCond import autoCond
7 
8 import os
9 import socket
10 from subprocess import *
11 
12 
13 ## ------------------------------------------------------
14 ## Deal with backweard incompatibilities of conditions
15 ## ------------------------------------------------------
16 
17 def run41xOn3yzMcInput( process
18  , l1MenuTag = 'L1GtTriggerMenu_L1Menu_Commissioning2010_v4_mc' # L1 menu for Fall10 REDIGI (CMSSW_3_8_7)
19  ):
20  """
21  """
22  # Use correct L1 trigger menu
24  process.l1GtTriggerMenu = cms.ESSource( "PoolDBESSource"
25  , CondCore.DBCommon.CondDBCommon_cfi.CondDBCommon
26  , toGet = cms.VPSet(
27  cms.PSet(
28  connect = cms.untracked.string( 'frontier://FrontierProd/CMS_COND_31X_L1T' )
29  , record = cms.string( 'L1GtTriggerMenuRcd' )
30  , tag = cms.string( l1MenuTag )
31  )
32  )
33  )
34  process.preferL1GtTriggerMenu = cms.ESPrefer( "PoolDBESSource", "l1GtTriggerMenu" )
35 
36 
37 ## ------------------------------------------------------
38 ## Re-configuration of PATJetProducer
39 ## ------------------------------------------------------
40 
41 def run36xOn35xInput(process,
42  genJets = "",
43  postfix=""):
44  """
45  ------------------------------------------------------------------
46  Reconfigure the PATJetProducer to be able to run the 36X version
47  of PAT on 35X input samples.
48 
49  process : process
50  ------------------------------------------------------------------
51  """
52  print "*********************************************************************"
53  print "NOTE TO USER: when running on 35X sample with 36X s/w versions you "
54  print " need to adapt for different event contents. The "
55  print " adaptations need to be made: "
56  print " "
57  print " - re-configuration of secondary vertex tag discrimi- "
58  print " nator information. "
59  print " "
60  print "*********************************************************************"
61  ## re-configure b-discriminator sources for pat jets
62  process.patJets.discriminatorSources = cms.VInputTag(
63  cms.InputTag("combinedSecondaryVertexBJetTags"),
64  cms.InputTag("combinedSecondaryVertexMVABJetTags"),
65  cms.InputTag("jetBProbabilityBJetTags"),
66  cms.InputTag("jetProbabilityBJetTags"),
67  cms.InputTag("simpleSecondaryVertexBJetTags"),
68  cms.InputTag("softElectronByPtBJetTags"),
69  cms.InputTag("softElectronByIP3dBJetTags"),
70  cms.InputTag("softMuonBJetTags"),
71  cms.InputTag("softMuonByPtBJetTags"),
72  cms.InputTag("softMuonByIP3dBJetTags"),
73  cms.InputTag("trackCountingHighEffBJetTags"),
74  cms.InputTag("trackCountingHighPurBJetTags"),
75  )
76  if genJets != "" :
77  print "*********************************************************************"
78  print "NOTE TO USER: when running on 31X samples re-recoed in 3.5.x "
79  print " with this CMSSW version of PAT "
80  print " it is required to re-run the GenJet production for "
81  print " anti-kT since that is not part of the re-reco "
82  print "*********************************************************************"
83  process.load("RecoJets.Configuration.GenJetParticles_cff")
84  process.load("RecoJets.JetProducers." + genJets +"_cfi")
85  process.patDefaultSequence.replace( getattr(process,"patCandidates"+postfix), process.genParticlesForJets+getattr(process,genJets)+getattr(process,"patCandidates"+postfix))
86 
87 
88 
89 ## ------------------------------------------------------
90 ## Re-implementation of jetTools
91 ## ------------------------------------------------------
92 
93 class RunBTagging35X(ConfigToolBase):
94 
95  """
96  ------------------------------------------------------------------
97  Define sequence to run b tagging on AOD input for a given jet
98  collection including a JetTracksAssociatorAtVertex module with
99  name 'jetTracksAssociatorAtVertex' + 'label'.
100 
101  Return value is a pair of (sequence, labels) where 'sequence'
102  is the cms.Sequence, and 'labels' is a vector with the follow-
103  ing entries:
104 
105  * labels['jta'] = the name of the JetTrackAssociator module
106  * labels['tagInfos'] = a list of names of the TagInfo modules
107  * labels['jetTags '] = a list of names of the JetTag modules
108 
109  This is a re-implementation to run the 36X version of PAT on 35X
110  input samples.
111  ------------------------------------------------------------------
112  """
113  _label='runBTagging35X'
114  _defaultParameters=dicttypes.SortedKeysDict()
115  def __init__(self):
116  ConfigToolBase.__init__(self)
117  self.addParameter(self._defaultParameters,'jetCollection',self._defaultValue, 'input jet collection',Type=cms.InputTag)
118  self.addParameter(self._defaultParameters,'label',self._defaultValue, 'postfix label to identify new sequence/modules', Type=str)
119  self.addParameter(self._defaultParameters,'postfix',"", "postfix of default sequence (do not confuse with 'label')")
120  self._parameters=copy.deepcopy(self._defaultParameters)
121  self._comment = ""
122 
124  return self._defaultParameters
125 
126  def __call__(self,process,
127  jetCollection = None,
128  label = None,
129  postfix = None) :
130  if jetCollection is None:
131  jetCollection=self._defaultParameters['jetCollection'].value
132  if label is None:
133  label=self._defaultParameters['label'].value
134  if postfix is None:
135  postfix=self._defaultParameters['postfix'].value
136  self.setParameter('jetCollection',jetCollection)
137  self.setParameter('label',label)
138  self.setParameter('postfix',postfix)
139 
140  return self.apply(process)
141 
142  def apply(self, process):
143  jetCollection=self._parameters['jetCollection'].value
144  label=self._parameters['label'].value
145  postfix=self._parameters['postfix'].value
146 
147  if hasattr(process, "addAction"):
148  process.disableRecording()
149 
150  try:
151  comment=inspect.stack(2)[2][4][0].rstrip("\n")
152  if comment.startswith("#"):
153  self.setComment(comment.lstrip("#"))
154  except:
155  pass
156 
157  #############################
158  ### TOOL CODE STARTS HERE ###
159  #############################
160  print "*********************************************************************"
161  print "NOTE TO USER: when running on 35X sample with 36X s/w versions you "
162  print " need to adapt for different event contents. The "
163  print " adaptations need to be made: "
164  print " "
165  print " - re-configuration of secondary vertex tag discrimi- "
166  print " nator information. "
167  print " "
168  print " - take out soft electron tagger information, which "
169  print " is not available on 35X. "
170  print "*********************************************************************"
171 
172  if (label == ''):
173  ## label is not allowed to be empty
174  raise ValueError, "label for re-running b tagging is not allowed to be empty"
175 
176  ## import track associator & b tag configuration
177  process.load("RecoJets.JetAssociationProducers.ak5JTA_cff")
178  from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex
179  process.load("RecoBTag.Configuration.RecoBTag_cff")
181 
182  # add negative tag infos
184 
185  ## define jetTracksAssociator; for switchJetCollection
186  ## the label is 'AOD' as empty labels will lead to crashes
187  ## of crab. In this case the postfix label is skiped,
188  ## otherwise a postfix label is added as for the other
189  ## labels
190  jtaLabel = 'jetTracksAssociatorAtVertex'+postfix
191 
192  if (not label == 'AOD'):
193  jtaLabel += label
194  ## define tag info labels (compare with jetProducer_cfi.py)
195  ipTILabel = 'impactParameterTagInfos' + label
196  svTILabel = 'secondaryVertexTagInfos' + label
197  smTILabel = 'softMuonTagInfos' + label
198 
199  ## produce tag infos
200  setattr( process, ipTILabel, btag.impactParameterTagInfos.clone(jetTracks = cms.InputTag(jtaLabel)) )
201  setattr( process, svTILabel, btag.secondaryVertexTagInfos.clone(trackIPTagInfos = cms.InputTag(ipTILabel)) )
202  setattr( process, smTILabel, btag.softMuonTagInfos.clone(jets = jetCollection) )
203 
204  ## make VInputTag from strings
205  def vit(*args) : return cms.VInputTag( *[ cms.InputTag(x) for x in args ] )
206 
207  ## produce btags
208  setattr( process, 'jetBProbabilityBJetTags'+label, btag.jetBProbabilityBJetTags.clone(tagInfos = vit(ipTILabel)) )
209  setattr( process, 'jetProbabilityBJetTags' +label, btag.jetProbabilityBJetTags.clone (tagInfos = vit(ipTILabel)) )
210  setattr( process, 'trackCountingHighPurBJetTags'+label, btag.trackCountingHighPurBJetTags.clone(tagInfos = vit(ipTILabel)) )
211  setattr( process, 'trackCountingHighEffBJetTags'+label, btag.trackCountingHighEffBJetTags.clone(tagInfos = vit(ipTILabel)) )
212  setattr( process, 'simpleSecondaryVertexBJetTags'+label, btag.simpleSecondaryVertexBJetTags.clone(tagInfos = vit(svTILabel)) )
213  setattr( process, 'combinedSecondaryVertexBJetTags'+label, btag.combinedSecondaryVertexBJetTags.clone(tagInfos = vit(ipTILabel, svTILabel)) )
214  setattr( process, 'combinedSecondaryVertexMVABJetTags'+label, btag.combinedSecondaryVertexMVABJetTags.clone(tagInfos = vit(ipTILabel, svTILabel)) )
215  setattr( process, 'softMuonBJetTags'+label, btag.softMuonBJetTags.clone(tagInfos = vit(smTILabel)) )
216  setattr( process, 'softMuonByPtBJetTags'+label, btag.softMuonByPtBJetTags.clone(tagInfos = vit(smTILabel)) )
217  setattr( process, 'softMuonByIP3dBJetTags'+label, btag.softMuonByIP3dBJetTags.clone(tagInfos = vit(smTILabel)) )
218 
219  ## define vector of (output) labels
220  labels = { 'jta' : jtaLabel,
221  'tagInfos' : (ipTILabel,svTILabel,smTILabel),
222  'jetTags' : [ (x + label) for x in ('jetBProbabilityBJetTags',
223  'jetProbabilityBJetTags',
224  'trackCountingHighPurBJetTags',
225  'trackCountingHighEffBJetTags',
226  'simpleSecondaryVertexBJetTags',
227  'combinedSecondaryVertexBJetTags',
228  'combinedSecondaryVertexMVABJetTags',
229  'softMuonBJetTags',
230  'softMuonByPtBJetTags',
231  'softMuonByIP3dBJetTags'
232  )
233  ]
234  }
235 
236  ## extend an existing sequence by otherLabels
237  def mkseq(process, firstlabel, *otherlabels):
238  seq = getattr(process, firstlabel)
239  for x in otherlabels: seq += getattr(process, x)
240  return cms.Sequence(seq)
241 
242  ## add tag infos to the process
243  setattr( process, 'btaggingTagInfos'+label, mkseq(process, *(labels['tagInfos']) ) )
244  ## add b tags to the process
245  setattr( process, 'btaggingJetTags'+label, mkseq(process, *(labels['jetTags']) ) )
246  ## add a combined sequence to the process
247  seq = mkseq(process, 'btaggingTagInfos'+label, 'btaggingJetTags' + label)
248  setattr( process, 'btagging'+label, seq )
249  ## return the combined sequence and the labels defined above
250 
251  if hasattr(process, "addAction"):
252  process.enableRecording()
253  action=self.__copy__()
254  process.addAction(action)
255  return (seq, labels)
256 
257 
258 runBTagging35X=RunBTagging35X()
259 
260 
261 class AddJetCollection35X(ConfigToolBase):
262 
263  """
264  ------------------------------------------------------------------
265  Add a new collection of jets. Takes the configuration from the
266  already configured standard jet collection as starting point;
267  replaces before calling addJetCollection will also affect the
268  new jet collections. This is a re-implementation to run the
269  36X version of PAT on 35X input samples.
270  ------------------------------------------------------------------
271  """
272  _label='addJetCollection35X'
273  _defaultParameters=dicttypes.SortedKeysDict()
274  def __init__(self):
275  ConfigToolBase.__init__(self)
276  self.addParameter(self._defaultParameters,'jetCollection',self._defaultValue,'Input jet collection', cms.InputTag)
277  self.addParameter(self._defaultParameters,'algoLabel',self._defaultValue, "label to indicate the jet algorithm (e.g.'AK5')",str)
278  self.addParameter(self._defaultParameters,'typeLabel',self._defaultValue, "label to indicate the type of constituents (e.g. 'Calo', 'Pflow', 'Jpt', ...)",str)
279  self.addParameter(self._defaultParameters,'doJTA',True, "run b tagging sequence for new jet collection and add it to the new pat jet collection")
280  self.addParameter(self._defaultParameters,'doBTagging',True, 'run JetTracksAssociation and JetCharge and add it to the new pat jet collection (will autom. be true if doBTagging is set to true)')
281  self.addParameter(self._defaultParameters,'jetCorrLabel',None, "algorithm and type of JEC; use 'None' for no JEC; examples are ('AK5','Calo'), ('SC7','Calo'), ('KT4','PF')", tuple,acceptNoneValue=True)
282  self.addParameter(self._defaultParameters,'doType1MET',True, "if jetCorrLabel is not 'None', set this to 'True' to redo the Type1 MET correction for the new jet colllection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ")
283  self.addParameter(self._defaultParameters,'doL1Cleaning',True, "copy also the producer modules for cleanLayer1 will be set to 'True' automatically when doL1Counters is 'True'")
284  self.addParameter(self._defaultParameters,'doL1Counters',False, "copy also the filter modules that accept/reject the event looking at the number of jets")
285  self.addParameter(self._defaultParameters,'genJetCollection',cms.InputTag("ak5GenJets"), "GenJet collection to match to")
286  self.addParameter(self._defaultParameters,'doJetID',True, "add jetId variables to the added jet collection?")
287  self.addParameter(self._defaultParameters,'jetIdLabel',"ak5", " specify the label prefix of the xxxJetID object; in general it is the jet collection tag like ak5, kt4 sc5, aso. For more information have a look to SWGuidePATTools#add_JetCollection")
288  self.addParameter(self._defaultParameters,'standardAlgo',"AK5", "standard algorithm label of the collection from which the clones for the new jet collection will be taken from (note that this jet collection has to be available in the event before hand)")
289  self.addParameter(self._defaultParameters,'standardType',"Calo", "standard constituent type label of the collection from which the clones for the new jet collection will be taken from (note that this jet collection has to be available in the event before hand)")
290 
291  self._parameters=copy.deepcopy(self._defaultParameters)
292  self._comment = ""
293 
295  return self._defaultParameters
296 
297  def __call__(self,process,
298  jetCollection = None,
299  algoLabel = None,
300  typeLabel = None,
301  doJTA = None,
302  doBTagging = None,
303  jetCorrLabel = None,
304  doType1MET = None,
305  doL1Cleaning = None,
306  doL1Counters = None,
307  genJetCollection = None,
308  doJetID = None,
309  jetIdLabel = None,
310  standardAlgo = None,
311  standardType = None):
312 
313  if jetCollection is None:
314  jetCollection=self._defaultParameters['jetCollection'].value
315  if algoLabel is None:
316  algoLabel=self._defaultParameters['algoLabel'].value
317  if typeLabel is None:
318  typeLabel=self._defaultParameters['typeLabel'].value
319  if doJTA is None:
320  doJTA=self._defaultParameters['doJTA'].value
321  if doBTagging is None:
322  doBTagging=self._defaultParameters['doBTagging'].value
323  if jetCorrLabel is None:
324  jetCorrLabel=self._defaultParameters['jetCorrLabel'].value
325  if doType1MET is None:
326  doType1MET=self._defaultParameters['doType1MET'].value
327  if doL1Cleaning is None:
328  doL1Cleaning=self._defaultParameters['doL1Cleaning'].value
329  if doL1Counters is None:
330  doL1Counters=self._defaultParameters['doL1Counters'].value
331  if genJetCollection is None:
332  genJetCollection=self._defaultParameters['genJetCollection'].value
333  if doJetID is None:
334  doJetID=self._defaultParameters['doJetID'].value
335  if jetIdLabel is None:
336  jetIdLabel=self._defaultParameters['jetIdLabel'].value
337  if standardAlgo is None:
338  standardAlgo=self._defaultParameters['standardAlgo'].value
339  if standardType is None:
340  standardType=self._defaultParameters['standardType'].value
341 
342  self.setParameter('jetCollection',jetCollection)
343  self.setParameter('algoLabel',algoLabel)
344  self.setParameter('typeLabel',typeLabel)
345  self.setParameter('doJTA',doJTA)
346  self.setParameter('doBTagging',doBTagging)
347  self.setParameter('jetCorrLabel',jetCorrLabel)
348  self.setParameter('doType1MET',doType1MET)
349  self.setParameter('doL1Cleaning',doL1Cleaning)
350  self.setParameter('doL1Counters',doL1Counters)
351  self.setParameter('genJetCollection',genJetCollection)
352  self.setParameter('doJetID',doJetID)
353  self.setParameter('jetIdLabel',jetIdLabel)
354  self.setParameter('standardAlgo',standardAlgo)
355  self.setParameter('standardType',standardType)
356 
357  self.apply(process)
358 
359  def toolCode(self, process):
360  jetCollection=self._parameters['jetCollection'].value
361  algoLabel=self._parameters['algoLabel'].value
362  typeLabel=self._parameters['typeLabel'].value
363  doJTA=self._parameters['doJTA'].value
364  doBTagging=self._parameters['doBTagging'].value
365  jetCorrLabel=self._parameters['jetCorrLabel'].value
366  doType1MET =self._parameters['doType1MET'].value
367  doL1Cleaning=self._parameters['doL1Cleaning'].value
368  doL1Counters=self._parameters['doL1Counters'].value
369  genJetCollection=self._parameters['genJetCollection'].value
370  doJetID=self._parameters['doJetID'].value
371  jetIdLabel=self._parameters['jetIdLabel'].value
372  standardAlgo=self._parameters['standardAlgo'].value
373  standardType=self._parameters['standardType'].value
374 
375  ## define common label for pre pat jet
376  ## creation steps in makePatJets
377  #label=standardAlgo+standardType
378 
379  ## create old module label from standardAlgo
380  ## and standardType and return
381  def oldLabel(prefix=''):
382  return jetCollectionString(prefix, '', '')
383 
384  ## create new module label from old module
385  ## label and return
386  def newLabel(oldLabel):
387  newLabel=oldLabel
388  if(oldLabel.find(standardAlgo)>=0 and oldLabel.find(standardType)>=0):
389  oldLabel=oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel)
390  else:
391  oldLabel=oldLabel+algoLabel+typeLabel
392  return oldLabel
393 
394  ## clone module and add it to the patDefaultSequence
395  def addClone(hook, **replaceStatements):
396  ## create a clone of the hook with corresponding
397  ## parameter replacements
398  newModule = getattr(process, hook).clone(**replaceStatements)
399  ## add the module to the sequence
400  addModuleToSequence(hook, newModule)
401 
402  ## add module to the patDefaultSequence
403  def addModuleToSequence(hook, newModule):
404  hookModule = getattr(process, hook)
405  ## add the new module with standardAlgo &
406  ## standardType replaced in module label
407  setattr( process, newLabel(hook), newModule)
408  ## add new module to default sequence
409  ## just behind the hookModule
410  process.patDefaultSequence.replace( hookModule, hookModule*newModule )
411 
412  print "*********************************************************************"
413  print "NOTE TO USER: when running on 35X sample with 36X s/w versions you "
414  print " need to adapt for different event contents. The "
415  print " adaptations need to be made: "
416  print " "
417  print " - re-configuration of secondary vertex tag discrimi- "
418  print " nator information. "
419  print " "
420  print " - take out soft electron tagger information, which "
421  print " is not available on 35X. "
422  print "*********************************************************************"
423 
424  ## add a clone of patJets
425  addClone(oldLabel(), jetSource = jetCollection)
426  ## add a clone of selectedPatJets
427  addClone(oldLabel('selected'), src=cms.InputTag(newLabel(oldLabel())))
428  ## add a clone of cleanPatJets
429  if( doL1Cleaning ):
430  addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
431  ## add a clone of countPatJets
432  if( doL1Counters ):
433  if( doL1Cleaning ):
434  addClone(oldLabel('count'), src=cms.InputTag(newLabel(oldLabel('clean'))))
435  else:
436  addClone(oldLabel('count'), src=cms.InputTag(newLabel(oldLabel('selected'))))
437 
438  ## get attributes of new module
439  l1Jets = getattr(process, newLabel(oldLabel()))
440 
441  ## add a clone of gen jet matching
442  addClone('patJetPartonMatch', src = jetCollection)
443  addClone('patJetGenJetMatch', src = jetCollection, matched = genJetCollection)
444 
445  ## add a clone of parton and flavour associations
446  addClone('patJetPartonAssociation', jets = jetCollection)
447  addClone('patJetFlavourAssociation', srcByReference = cms.InputTag(newLabel('patJetPartonAssociation')))
448 
449  ## fix label for input tag
450  def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel))
451  ## fix label for vector of input tags
452  def fixVInputTag(x): x[0].setModuleLabel(newLabel(x[0].moduleLabel))
453 
454  ## provide allLayer1Jet inputs with individual labels
455  fixInputTag(l1Jets.genJetMatch)
456  fixInputTag(l1Jets.genPartonMatch)
457  fixInputTag(l1Jets.JetPartonMapSource)
458 
459  ## make VInputTag from strings
460  def vit(*args) : return cms.VInputTag( *[ cms.InputTag(x) for x in args ] )
461 
462  if (doJTA or doBTagging):
463  ## add clone of jet track association
464  process.load("RecoJets.JetAssociationProducers.ak5JTA_cff")
465  from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex
466  ## add jet track association module to processes
467  jtaLabel = 'jetTracksAssociatorAtVertex'+algoLabel+typeLabel
468  setattr( process, jtaLabel, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection) )
469  process.makePatJets.replace(process.patJetCharge, getattr(process,jtaLabel)+process.patJetCharge)
470  l1Jets.trackAssociationSource = cms.InputTag(jtaLabel)
471  addClone('patJetCharge', src=cms.InputTag(jtaLabel)),
472  fixInputTag(l1Jets.jetChargeSource)
473  else:
474  ## switch embedding of track association and jet
475  ## charge estimate to 'False'
476  l1Jets.addAssociatedTracks = False
477  l1Jets.addJetCharge = False
478 
479  if (doBTagging):
480  ## define postfixLabel
481  postfixLabel=algoLabel+typeLabel
482  ## add b tagging sequence
483  (btagSeq, btagLabels) = runBTagging35X(process, jetCollection, postfixLabel)
484  ## add b tagging sequence before running the allLayer1Jets modules
485  process.makePatJets.replace(getattr(process,jtaLabel), getattr(process,jtaLabel)+btagSeq)
486  ## replace corresponding tags for pat jet production
487  l1Jets.trackAssociationSource = cms.InputTag(btagLabels['jta'])
488  l1Jets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['tagInfos'] ] )
489  l1Jets.discriminatorSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['jetTags'] ] )
490  else:
491  ## switch general b tagging info switch off
492  l1Jets.addBTagInfo = False
493 
494  if (doJetID):
495  l1Jets.addJetID = cms.bool(True)
496  jetIdLabelNew = jetIdLabel + 'JetID'
497  l1Jets.jetIDMap = cms.InputTag( jetIdLabelNew )
498  else :
499  l1Jets.addJetID = cms.bool(False)
500 
501  if (jetCorrLabel != None):
502  ## add clone of jet energy corrections;
503  ## catch a couple of exceptions first
504  if (jetCorrLabel == False ):
505  raise ValueError, "In addJetCollection 'jetCorrLabel' must be set to 'None', not 'False'"
506  if (jetCorrLabel == "None"):
507  raise ValueError, "In addJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)"
508  ## check for the correct format
509  if type(jetCorrLabel) != type(('AK5','Calo')):
510  raise ValueError, "In addJetCollection 'jetCorrLabel' must be 'None', or of type ('Algo','Type')"
511 
512  ## add clone of jetCorrFactors
513  addClone('patJetCorrFactors', jetSource = jetCollection)
514  switchJECParameters( getattr(process,newLabel('patJetCorrFactors')), jetCorrLabel[0], jetCorrLabel[1], oldAlgo='AK5',oldType='Calo' )
515  fixVInputTag(l1Jets.jetCorrFactorsSource)
516 
517  ## switch type1MET corrections off for PFJets
518  if( jetCollection.__str__().find('PFJets')>=0 ):
519  print '================================================='
520  print 'Type1MET corrections are switched off for PFJets.'
521  print 'of type %s%s.' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
522  print 'Users are recommened to use pfMET together with '
523  print 'PFJets.'
524  print '================================================='
525  doType1MET=False
526 
527  ## add a clone of the type1MET correction for the new jet collection
528  if (doType1MET):
529  ## in case there is no jet correction service in the paths add it
530  ## as L2L3 if possible, as combined from L2 and L3 otherwise
531  if not hasattr( process, '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) ):
532  setattr( process, '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
533  cms.ESSource("JetCorrectionServiceChain",
534  correctors = cms.vstring('%s%sL2Relative' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
535  '%s%sL3Absolute' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
536  )
537  )
538  )
539  ## add a clone of the type1MET correction
540  ## and the following muonMET correction
541  addClone('metJESCorAK5CaloJet', inputUncorJetsLabel = jetCollection.value(),
542  corrector = cms.string('%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]))
543  )
544  addClone('metJESCorAK5CaloJetMuons', uncorMETInputTag = cms.InputTag(newLabel('metJESCorAK5CaloJet')))
545  addClone('patMETs', metSource = cms.InputTag(newLabel('metJESCorAK5CaloJetMuons')))
546  l1MET = getattr(process, newLabel('patMETs'))
547  ## add new met collections output to the pat summary
548  process.patCandidateSummary.candidates += [ cms.InputTag(newLabel('patMETs')) ]
549  else:
550  ## switch jetCorrFactors off
551  l1Jets.addJetCorrFactors = False
552 
553 
554 
555 addJetCollection35X=AddJetCollection35X()
556 
557 
558 class SwitchJetCollection35X(ConfigToolBase):
559 
560  """
561  ------------------------------------------------------------------
562  Switch the collection of jets in PAT from the default value to a
563  new jet collection. This is a re-implementation to run the 36X
564  version of PAT on 35X input samples.
565  ------------------------------------------------------------------
566  """
567  _label='switchJetCollection35X'
568  _defaultParameters=dicttypes.SortedKeysDict()
569  def __init__(self):
570  ConfigToolBase.__init__(self)
571  self.addParameter(self._defaultParameters,'jetCollection',self._defaultValue,'Input jet collection', cms.InputTag)
572  self.addParameter(self._defaultParameters,'doJTA',True, "run b tagging sequence for new jet collection and add it to the new pat jet collection")
573  self.addParameter(self._defaultParameters,'doBTagging',True, 'run JetTracksAssociation and JetCharge and add it to the new pat jet collection (will autom. be true if doBTagging is set to true)')
574  self.addParameter(self._defaultParameters,'jetCorrLabel',None, "algorithm and type of JEC; use 'None' for no JEC; examples are ('AK5','Calo'), ('SC7','Calo'), ('KT4','PF')", tuple,acceptNoneValue=True)
575  self.addParameter(self._defaultParameters,'doType1MET',True, "if jetCorrLabel is not 'None', set this to 'True' to redo the Type1 MET correction for the new jet colleection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ")
576  self.addParameter(self._defaultParameters,'genJetCollection',cms.InputTag("ak5GenJets"), "GenJet collection to match to")
577  self.addParameter(self._defaultParameters,'doJetID',True, "add jetId variables to the added jet collection")
578  self.addParameter(self._defaultParameters,'jetIdLabel',"ak5", " specify the label prefix of the xxxJetID object; in general it is the jet collection tag like ak5, kt4 sc5, aso. For more information have a look to SWGuidePATTools#add_JetCollection")
579  self.addParameter(self._defaultParameters,'postfix',"", "postfix of default sequence")
580 
581  self._parameters=copy.deepcopy(self._defaultParameters)
582  self._comment = ""
583 
585  return self._defaultParameters
586 
587  def __call__(self,process,
588  jetCollection = None,
589  doJTA = None,
590  doBTagging = None,
591  jetCorrLabel = None,
592  doType1MET = None,
593  genJetCollection = None,
594  doJetID = None,
595  jetIdLabel = None,
596  postfix = None):
597 
598  if jetCollection is None:
599  jetCollection=self._defaultParameters['jetCollection'].value
600  if doJTA is None:
601  doJTA=self._defaultParameters['doJTA'].value
602  if doBTagging is None:
603  doBTagging=self._defaultParameters['doBTagging'].value
604  if jetCorrLabel is None:
605  jetCorrLabel=self._defaultParameters['jetCorrLabel'].value
606  if doType1MET is None:
607  doType1MET=self._defaultParameters['doType1MET'].value
608  if genJetCollection is None:
609  genJetCollection=self._defaultParameters['genJetCollection'].value
610  if doJetID is None:
611  doJetID=self._defaultParameters['doJetID'].value
612  if jetIdLabel is None:
613  jetIdLabel=self._defaultParameters['jetIdLabel'].value
614  if postfix is None:
615  postfix=self._defaultParameters['postfix'].value
616 
617  self.setParameter('jetCollection',jetCollection)
618  self.setParameter('doJTA',doJTA)
619  self.setParameter('doBTagging',doBTagging)
620  self.setParameter('jetCorrLabel',jetCorrLabel)
621  self.setParameter('doType1MET',doType1MET)
622  self.setParameter('genJetCollection',genJetCollection)
623  self.setParameter('doJetID',doJetID)
624  self.setParameter('jetIdLabel',jetIdLabel)
625  self.setParameter('postfix',postfix)
626 
627  self.apply(process)
628 
629  def toolCode(self, process):
630  jetCollection=self._parameters['jetCollection'].value
631  doJTA=self._parameters['doJTA'].value
632  doBTagging=self._parameters['doBTagging'].value
633  jetCorrLabel=self._parameters['jetCorrLabel'].value
634  doType1MET =self._parameters['doType1MET'].value
635  genJetCollection=self._parameters['genJetCollection'].value
636  doJetID=self._parameters['doJetID'].value
637  jetIdLabel=self._parameters['jetIdLabel'].value
638  postfix=self._parameters['postfix'].value
639 
640 
641  ## save label of old input jet collection
642  oldLabel = applyPostfix(process, "patJets", postfix).jetSource;
643 
644  ## replace input jet collection for generator matches
645  applyPostfix(process, "patJetPartonMatch", postfix).src = jetCollection
646  applyPostfix(process, "patJetGenJetMatch", postfix).src = jetCollection
647  applyPostfix(process, "patJetGenJetMatch", postfix).matched = genJetCollection
648  applyPostfix(process, "patJetPartonAssociation", postfix).jets = jetCollection
649  ## replace input jet collection for pat jet production
650  applyPostfix(process, "patJets", postfix).jetSource = jetCollection
651 
652  ## make VInputTag from strings
653  def vit(*args) : return cms.VInputTag( *[ cms.InputTag(x) for x in args ] )
654 
655  if (doJTA or doBTagging):
656  ## replace jet track association
657  process.load("RecoJets.JetAssociationProducers.ak5JTA_cff")
658  from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex
659  setattr(process, "jetTracksAssociatorAtVertex"+postfix, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection))
660  getattr(process, "patDefaultSequence"+postfix).replace(
661  applyPostfix(process, "patJetCharge", postfix),
662  getattr(process, "jetTracksAssociatorAtVertex" + postfix) #module with postfix that is not n patDefaultSequence
663  + applyPostfix(process, "patJetCharge", postfix)
664  )
665 
666  applyPostfix(process, "patJetCharge", postfix).src = 'jetTracksAssociatorAtVertex'+postfix
667  applyPostfix(process, "patJets", postfix).trackAssociationSource = 'jetTracksAssociatorAtVertex'+postfix
668  else:
669  ## remove the jet track association from the std
670  ## sequence
671  removeIfInSequence(process, "patJetCharge", "patDefaultSequence", postfix)
672  ## switch embedding of track association and jet
673  ## charge estimate to 'False'
674  applyPostfix(process, "patJets", postfix).addAssociatedTracks = False
675  applyPostfix(process, "patJets", postfix).addJetCharge = False
676 
677  if (doBTagging):
678  ## replace b tagging sequence; add postfix label 'AOD' as crab will
679  ## crash when confronted with empy labels
680  (btagSeq, btagLabels) = runBTagging35X(process, jetCollection, 'AOD',postfix)
681  ## add b tagging sequence before running the allLayer1Jets modules
682  getattr(process, "patDefaultSequence"+postfix).replace(
683  getattr( process,"jetTracksAssociatorAtVertex"+postfix),
684  getattr( process,"jetTracksAssociatorAtVertex"+postfix) + btagSeq
685  )
686 
687  ## replace corresponding tags for pat jet production
688  applyPostfix(process, "patJets", postfix).trackAssociationSource = btagLabels['jta']
689  applyPostfix(process, "patJets", postfix).tagInfoSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['tagInfos'] ] )
690  applyPostfix(process, "patJets", postfix).discriminatorSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['jetTags'] ] )
691  else:
692  ## remove b tagging from the std sequence
693  removeIfInSequence(process, "secondaryVertexNegativeTagInfos", "patDefaultSequence", postfix)
694  removeIfInSequence(process, "simpleSecondaryVertexNegativeBJetTags", "patDefaultSequence", postfix)
695 
696  ## switch embedding of b tagging for pat
697  ## jet production to 'False'
698  applyPostfix(process, "patJets", postfix).addBTagInfo = False
699 
700  if (doJetID):
701  jetIdLabelNew = jetIdLabel + 'JetID'
702  applyPostfix(process, "patJets", postfix).jetIDMap = cms.InputTag( jetIdLabelNew )
703  else:
704  applyPostfix(process, "patJets", postfix).addJetID = cms.bool(False)
705 
706 
707  if (jetCorrLabel!=None):
708  ## replace jet energy corrections; catch
709  ## a couple of exceptions first
710  if (jetCorrLabel == False ):
711  raise ValueError, "In switchJetCollection 'jetCorrLabel' must be set to 'None', not 'False'"
712  if (jetCorrLabel == "None"):
713  raise ValueError, "In switchJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)"
714  ## check for the correct format
715  if (type(jetCorrLabel)!=type(('AK5','Calo'))):
716  raise ValueError, "In switchJetCollection 'jetCorrLabel' must be 'None', or of type ('Algo','Type')"
717 
718  ## switch JEC parameters to the new jet collection
719  applyPostfix(process, "patJetCorrFactors", postfix).jetSource = jetCollection
720  switchJECParameters(applyPostfix(process, "patJetCorrFactors", postfix), jetCorrLabel[0], jetCorrLabel[1], oldAlgo='AK5',oldType='Calo')
721 
722  ## switch type1MET corrections off for PFJets
723  if( jetCollection.__str__().find('PFJets')>=0 ):
724  print '================================================='
725  print 'Type1MET corrections are switched off for PFJets.'
726  print 'of type %s%s.' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
727  print 'Users are recommened to use pfMET together with '
728  print 'PFJets.'
729  print '================================================='
730  doType1MET=False
731 
732  ## redo the type1MET correction for the new jet collection
733  if (doType1MET):
734  ## in case there is no jet correction service in the paths add it
735  ## as L2L3 if possible, as combined from L2 and L3 otherwise
736  if not hasattr( process, '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) ):
737  setattr( process, '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
738  cms.ESSource("JetCorrectionServiceChain",
739  correctors = cms.vstring('%s%sL2Relative' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
740  '%s%sL3Absolute' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
741  )
742  )
743  )
744  ## configure the type1MET correction the following muonMET
745  ## corrections have the metJESCorAK5CaloJet as input and
746  ## are automatically correct
747  applyPostfix(process, "metJESCorAK5CaloJet", postfix).inputUncorJetsLabel = jetCollection.value()
748  applyPostfix(process, "metJESCorAK5CaloJet", postfix).corrector = '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
749  else:
750  ## remove the jetCorrFactors from the std sequence
751  process.patJetMETCorrections.remove(process.patJetCorrFactors)
752  ## switch embedding of jetCorrFactors off
753  ## for pat jet production
754  applyPostfix(process, "patJets", postfix).addJetCorrFactors = False
755 
756 
757 switchJetCollection35X=SwitchJetCollection35X()
758 
759 
760 ## ------------------------------------------------------
761 ## Automatic pick-up of RelVal input files
762 ## ------------------------------------------------------
763 
764 class PickRelValInputFiles( ConfigToolBase ):
765  """ Picks up RelVal input files automatically and
766  returns a vector of strings with the paths to be used in [PoolSource].fileNames
767  PickRelValInputFiles( cmsswVersion, relVal, dataTier, condition, globalTag, maxVersions, skipFiles, numberOfFiles, debug )
768  - cmsswVersion : CMSSW release to pick up the RelVal files from
769  optional; default: the current release (determined automatically from environment)
770  - formerVersion: use the last before the last valid CMSSW release to pick up the RelVal files from
771  applies also, if 'cmsswVersion' is set explicitly
772  optional; default: False
773  - relVal : RelVal sample to be used
774  optional; default: 'RelValTTbar'
775  - dataTier : data tier to be used
776  optional; default: 'GEN-SIM-RECO'
777  - condition : identifier of GlobalTag as defined in Configurations/PyReleaseValidation/python/autoCond.py
778  possibly overwritten, if 'globalTag' is set explicitly
779  optional; default: 'startup'
780  - globalTag : name of GlobalTag as it is used in the data path of the RelVals
781  optional; default: determined automatically as defined by 'condition' in Configurations/PyReleaseValidation/python/autoCond.py
782  !!! Determination is done for the release one runs in, not for the release the RelVals have been produced in.
783  !!! Example of deviation: data RelVals (CMSSW_4_1_X) might not only have the pure name of the GlobalTag 'GR_R_311_V2' in the full path,
784  but also an extension identifying the data: 'GR_R_311_V2_RelVal_wzMu2010B'
785  - maxVersions : max. versioning number of RelVal to check
786  optional; default: 9
787  - skipFiles : number of files to skip for a found RelVal sample
788  optional; default: 0
789  - numberOfFiles: number of files to pick up
790  setting it to 0, returns all found ('skipFiles' remains active though)
791  optional; default: 1
792  - debug : switch to enable enhanced messages in 'stdout'
793  optional; default: False
794  """
795 
796  _label = 'pickRelValInputFiles'
797  _defaultParameters = dicttypes.SortedKeysDict()
798 
799  def getDefaultParameters( self ):
800  return self._defaultParameters
801 
802  def __init__( self ):
803  ConfigToolBase.__init__( self )
804  self.addParameter( self._defaultParameters, 'cmsswVersion' , os.getenv( "CMSSW_VERSION" ) , 'auto from environment' )
805  self.addParameter( self._defaultParameters, 'formerVersion', False , '' )
806  self.addParameter( self._defaultParameters, 'relVal' , 'RelValTTbar' , '' )
807  self.addParameter( self._defaultParameters, 'dataTier' , 'GEN-SIM-RECO' , '' )
808  self.addParameter( self._defaultParameters, 'condition' , 'startup' , '' )
809  self.addParameter( self._defaultParameters, 'globalTag' , autoCond[ self.getDefaultParameters()[ 'condition' ].value ][ : -5 ], 'auto from \'condition\'' )
810  self.addParameter( self._defaultParameters, 'maxVersions' , 9 , '' )
811  self.addParameter( self._defaultParameters, 'skipFiles' , 0 , '' )
812  self.addParameter( self._defaultParameters, 'numberOfFiles', 1 , '' )
813  self.addParameter( self._defaultParameters, 'debug' , False , '' )
814  self._parameters = copy.deepcopy( self._defaultParameters )
815  self._comment = ""
816 
817  def __call__( self
818  , cmsswVersion = None
819  , formerVersion = None
820  , relVal = None
821  , dataTier = None
822  , condition = None
823  , globalTag = None
824  , maxVersions = None
825  , skipFiles = None
826  , numberOfFiles = None
827  , debug = None
828  ):
829  if cmsswVersion is None:
830  cmsswVersion = self.getDefaultParameters()[ 'cmsswVersion' ].value
831  if formerVersion is None:
832  formerVersion = self.getDefaultParameters()[ 'formerVersion' ].value
833  if relVal is None:
834  relVal = self.getDefaultParameters()[ 'relVal' ].value
835  if dataTier is None:
836  dataTier = self.getDefaultParameters()[ 'dataTier' ].value
837  if condition is None:
838  condition = self.getDefaultParameters()[ 'condition' ].value
839  if globalTag is None:
840  globalTag = autoCond[ condition ][ : -5 ] # auto from 'condition'
841  if maxVersions is None:
842  maxVersions = self.getDefaultParameters()[ 'maxVersions' ].value
843  if skipFiles is None:
844  skipFiles = self.getDefaultParameters()[ 'skipFiles' ].value
845  if numberOfFiles is None:
846  numberOfFiles = self.getDefaultParameters()[ 'numberOfFiles' ].value
847  if debug is None:
848  debug = self.getDefaultParameters()[ 'debug' ].value
849  self.setParameter( 'cmsswVersion' , cmsswVersion )
850  self.setParameter( 'formerVersion', formerVersion )
851  self.setParameter( 'relVal' , relVal )
852  self.setParameter( 'dataTier' , dataTier )
853  self.setParameter( 'condition' , condition )
854  self.setParameter( 'globalTag' , globalTag )
855  self.setParameter( 'maxVersions' , maxVersions )
856  self.setParameter( 'skipFiles' , skipFiles )
857  self.setParameter( 'numberOfFiles', numberOfFiles )
858  self.setParameter( 'debug' , debug )
859  return self.apply()
860 
861  def messageEmptyList( self ):
862  print '%s DEBUG: Empty file list returned'%( self._label )
863  print ' This might be overwritten by providing input files explicitly to the source module in the main configuration file.'
864 
865  def apply( self ):
866  cmsswVersion = self._parameters[ 'cmsswVersion' ].value
867  formerVersion = self._parameters[ 'formerVersion' ].value
868  relVal = self._parameters[ 'relVal' ].value
869  dataTier = self._parameters[ 'dataTier' ].value
870  condition = self._parameters[ 'condition' ].value # only used for GT determination in initialization, if GT not explicitly given
871  globalTag = self._parameters[ 'globalTag' ].value
872  maxVersions = self._parameters[ 'maxVersions' ].value
873  skipFiles = self._parameters[ 'skipFiles' ].value
874  numberOfFiles = self._parameters[ 'numberOfFiles' ].value
875  debug = self._parameters[ 'debug' ].value
876 
877  filePaths = []
878 
879  patchId = '_patch'
880  ibId = '_X_'
881  if patchId in cmsswVersion:
882  cmsswVersion = cmsswVersion.split( patchId )[ 0 ]
883  elif ibId in cmsswVersion or formerVersion:
884  outputTuple = Popen( [ 'scram', 'l -c CMSSW' ], stdout = PIPE, stderr = PIPE ).communicate()
885  if len( outputTuple[ 1 ] ) != 0:
886  print '%s INFO : SCRAM error'%( self._label )
887  if debug:
888  print ' from trying to determine last valid releases before \'%s\''%( cmsswVersion )
889  print
890  print outputTuple[ 1 ]
891  print
892  self.messageEmptyList()
893  return filePaths
894  versions = { 'last' :''
895  , 'lastToLast':''
896  }
897  for line in outputTuple[ 0 ].splitlines():
898  version = line.split()[ 1 ]
899  if cmsswVersion.split( ibId )[ 0 ] in version or cmsswVersion.rpartition( '_' )[ 0 ] in version:
900  if not ( patchId in version or ibId in version ):
901  versions[ 'lastToLast' ] = versions[ 'last' ]
902  versions[ 'last' ] = version
903  if version == cmsswVersion:
904  break
905  if formerVersion:
906  cmsswVersion = versions[ 'lastToLast' ]
907  else:
908  cmsswVersion = versions[ 'last' ]
909 
910  if debug:
911  print '%s DEBUG: Called with...'%( self._label )
912  for key in self._parameters.keys():
913  print ' %s:\t'%( key ),
914  print self._parameters[ key ].value,
915  if self._parameters[ key ].value is self.getDefaultParameters()[ key ].value:
916  print ' (default)'
917  else:
918  print
919  if key == 'cmsswVersion' and cmsswVersion != self._parameters[ key ].value:
920  if formerVersion:
921  print ' ==> modified to last to last valid release %s (s. \'formerVersion\' parameter)'%( cmsswVersion )
922  else:
923  print ' ==> modified to last valid release %s'%( cmsswVersion )
924 
925  command = ''
926  storage = ''
927  domain = socket.getfqdn().split( '.' )
928  if len( domain ) == 0:
929  print '%s INFO : Cannot determine domain of this computer'%( self._label )
930  if debug:
931  self.messageEmptyList()
932  return filePaths
933  elif len( domain ) == 1:
934  print '%s INFO : Running on local host \'%s\' without direct access to RelVal files'%( self._label, domain[ 0 ] )
935  if debug:
936  self.messageEmptyList()
937  return filePaths
938  if domain[ -2 ] == 'cern' and domain[ -1 ] == 'ch':
939  command = 'nsls'
940  storage = '/castor/cern.ch/cms'
941  elif domain[ -2 ] == 'fnal' and domain[ -1 ] == 'gov':
942  command = 'ls'
943  storage = '/pnfs/cms/WAX/11'
944  else:
945  print '%s INFO : Running on site \'%s.%s\' without direct access to RelVal files'%( self._label, domain[ -2 ], domain[ -1 ] )
946  if debug:
947  self.messageEmptyList()
948  return filePaths
949  if debug:
950  print '%s DEBUG: Running at site \'%s.%s\''%( self._label, domain[ -2 ], domain[ -1 ] )
951  print ' using command \'%s\''%( command )
952  print ' on storage path %s'%( storage )
953  rfdirPath = '/store/relval/%s/%s/%s/%s-v'%( cmsswVersion, relVal, dataTier, globalTag )
954  argument = '%s%s'%( storage, rfdirPath )
955  validVersion = 0
956 
957  for version in range( maxVersions, 0, -1 ):
958  filePaths = []
959  fileCount = 0
960  if debug:
961  print '%s DEBUG: Checking directory \'%s%i\''%( self._label, argument, version )
962  directories = Popen( [ command, '%s%i'%( argument, version ) ], stdout = PIPE, stderr = PIPE ).communicate()[0]
963  for directory in directories.splitlines():
964  files = Popen( [ command, '%s%i/%s'%( argument, version, directory ) ], stdout = PIPE, stderr = PIPE ).communicate()[0]
965  for file in files.splitlines():
966  if len( file ) > 0:
967  if debug:
968  print '%s DEBUG: File \'%s\' found'%( self._label, file )
969  fileCount += 1
970  validVersion = version
971  if fileCount > skipFiles:
972  filePath = '%s%i/%s/%s'%( rfdirPath, version, directory, file )
973  filePaths.append( filePath )
974  if numberOfFiles != 0 and len( filePaths ) >= numberOfFiles:
975  break
976  if debug:
977  print '%s DEBUG: %i file(s) found'%( self._label, fileCount )
978  if numberOfFiles != 0 and len( filePaths ) >= numberOfFiles:
979  break
980  if numberOfFiles != 0:
981  if len( filePaths ) >= numberOfFiles:
982  break
983  elif validVersion > 0:
984  break
985 
986  if validVersion == 0:
987  print '%s INFO : No RelVal file(s) found at all in \'%s*\''%( self._label, argument )
988  if debug:
989  self.messageEmptyList()
990  elif len( filePaths ) == 0:
991  print '%s INFO : No RelVal file(s) picked up in \'%s%i\''%( self._label, argument, validVersion )
992  if debug:
993  self.messageEmptyList()
994  elif len( filePaths ) < numberOfFiles:
995  print '%s INFO : Only %i RelVal files picked up in \'%s%i\''%( self._label, len( filePaths ), argument, validVersion )
996 
997  if debug:
998  print '%s DEBUG: returning %i file(s)\n%s'%( self._label, len( filePaths ), filePaths )
999  return filePaths
1000 
1001 pickRelValInputFiles = PickRelValInputFiles()
def replace
Definition: linker.py:10
static void * communicate(void *obj)
Definition: DQMNet.cc:1241
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
def jetCollectionString
Definition: helpers.py:217
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def vit
replace input jet collection for pat jet production
def run36xOn35xInput
Re-configuration of PATJetProducer
def run41xOn3yzMcInput
Deal with backweard incompatibilities of conditions
Re-implementation of jetTools
T * clone(const T *tp)
Definition: Ptr.h:42
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def removeIfInSequence
Definition: helpers.py:20
Automatic pick-up of RelVal input files
double split
Definition: MVATrainer.cc:139