Exemple #1
0
 def clonedSequence(self):
     if not len(self._sequenceStack) == 1:
         raise Exception("someting went wrong, the sequence stack looks like: %s"%self._sequenceStack)
     for label in self._moduleLabels:
         massSearchReplaceAnyInputTag(self._sequenceStack[-1], label, label+self._postfix, moduleLabelOnly=True, verbose=False)
     self._moduleLabels = [] #prevent the InputTag replacement next time this is called.
     return self._sequenceStack[-1]
Exemple #2
0
 def clonedSequence(self):
     for label in self._moduleLabels:
         massSearchReplaceAnyInputTag(self._clonedSequence,
                                      label,
                                      self._newLabel(label),
                                      moduleLabelOnly=True,
                                      verbose=False)
     self._moduleLabels = [
     ]  # prevent the InputTag replacement next time the 'clonedSequence' function is called.
     return self._clonedSequence
Exemple #3
0
 def clonedTask(self):  #FIXME: can the following be used for Task?
     for label in self._moduleLabels:
         massSearchReplaceAnyInputTag(self._clonedTask,
                                      label,
                                      self._newLabel(label),
                                      moduleLabelOnly=True,
                                      verbose=self._verbose)
     self._moduleLabels = [
     ]  # prevent the InputTag replacement next time the 'clonedTask' function is called.
     return self._clonedTask
Exemple #4
0
def extendWithPrePostfix(process,other,prefix,postfix,loadedProducersAndFilters=None):
    """Look in other and find types which we can use"""
    # enable explicit check to avoid overwriting of existing objects
    #__dict__['_Process__InExtendCall'] = True

    if loadedProducersAndFilters:
        task = getattr(process, loadedProducersAndFilters)
        if not isinstance(task, cms.Task):
            raise Exception("extendWithPrePostfix argument must be name of Task type object attached to the process or None")
    else:
        task = None

    sequence = cms.Sequence()
    sequence._moduleLabels = []
    for name in dir(other):
        #'from XX import *' ignores these, and so should we.
        if name.startswith('_'):
            continue
        item = getattr(other,name)
        if name == "source" or name == "looper" or name == "subProcess":
            continue
        elif isinstance(item,cms._ModuleSequenceType):
            continue
        elif isinstance(item,cms.Task):
            continue
        elif isinstance(item,cms.Schedule):
            continue
        elif isinstance(item,cms.VPSet) or isinstance(item,cms.PSet):
            continue
        elif isinstance(item,cms._Labelable):
            if not item.hasLabel_():
                item.setLabel(name)
            if prefix != '' or postfix != '':
                newModule = item.clone()
                if isinstance(item,cms.ESProducer):
                    newName =name
                else:
                    if 'TauDiscrimination' in name:
                        process.__setattr__(name,item)
                        addToTask(task, item)
                    newName = prefix+name+postfix
                process.__setattr__(newName,newModule)
                addToTask(task, newModule)
                if isinstance(newModule, cms._Sequenceable) and not newName == name:
                    sequence +=getattr(process,newName)
                    sequence._moduleLabels.append(item.label())
            else:
                process.__setattr__(name,item)
                addToTask(task, item)

    if prefix != '' or postfix != '':
        for label in sequence._moduleLabels:
            massSearchReplaceAnyInputTag(sequence, label, prefix+label+postfix,verbose=False,moduleLabelOnly=True)
def nanoAOD_customizeMC(process):
    for name, path in process.paths.iteritems():
        # replace all the non-match embedded inputs with the matched ones
        massSearchReplaceAnyInputTag(path, 'muonTrgSelector:SelectedMuons',
                                     'selectedMuonsMCMatchEmbedded')
        massSearchReplaceAnyInputTag(path, 'tracksBPark:SelectedTracks',
                                     'tracksBParkMCMatchEmbedded')

        # modify the path to include mc-specific info
        path.insert(0, nanoSequenceMC)
        path.replace(process.muonBParkSequence, process.muonBParkMC)
        path.replace(process.tracksBParkSequence, process.tracksBParkMC)
 def clonedSequence(self):
     if not len(self._sequenceStack) == 1:
         raise Exception(
             "someting went wrong, the sequence stack looks like: %s" %
             self._sequenceStack)
     for label in self._moduleLabels:
         massSearchReplaceAnyInputTag(self._sequenceStack[-1],
                                      label,
                                      label + self._postfix,
                                      moduleLabelOnly=True,
                                      verbose=False)
     self._moduleLabels = [
     ]  #prevent the InputTag replacement next time this is called.
     return self._sequenceStack[-1]
Exemple #7
0
 def clonedSequence(self):
     for label in self._moduleLabels:
         massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=False)
     self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
     return self._clonedSequence
def nanoAOD_customizeMC(process,
                        ancestor_particles=[511, 521, 531, 541, 9900015]):
    for name, path in process.paths.iteritems():
        # replace all the non-match embedded inputs with the matched ones
        massSearchReplaceAnyInputTag(path, 'muonTrgSelector:SelectedMuons',
                                     'selectedMuonsMCMatchEmbedded')
        massSearchReplaceAnyInputTag(path, 'muonTrgSelector:trgMuons',
                                     'triggerMuonsMCMatchEmbedded')
        massSearchReplaceAnyInputTag(path,
                                     'electronsForAnalysis:SelectedElectrons',
                                     'selectedElectronsMCMatchEmbedded')
        massSearchReplaceAnyInputTag(path, 'tracksBPark:SelectedTracks',
                                     'tracksBParkMCMatchEmbedded')

        # make the BToMuMuPiTable/count talk to the correct producer
        massSearchReplaceAnyInputTag(path, 'BToMuMuPi', 'BToMuMuPiMC')

        # make the BToKMuMuTable/count talk to the correct producer
        massSearchReplaceAnyInputTag(path, 'BToKmumu', 'BToKmumuMC')

        # make the BToMuEPiTable/count talk to the correct producer
        massSearchReplaceAnyInputTag(path, 'BToMuEPi',
                                     'BToMuEPiMC')  #adding electron channel

        # save the all descendants of ancestor_particles
        to_save = ' || '.join(
            ['abs(pdgId) == %d' % ipdg for ipdg in ancestor_particles])
        to_save = 'keep++ (%s)' % to_save
        finalGenParticlesBPark.select.append(to_save)

        # modify the path to include mc-specific info
        path.insert(0, nanoSequenceMC)
        path.replace(process.muonBParkSequence, process.muonBParkMC)
        path.replace(process.electronsBParkSequence, process.electronBParkMC)
        path.replace(process.tracksBParkSequence, process.tracksBParkMC)
#--------------------------------------------------------------------------------
# CV: run HLT Pixel vertex reconstruction
#process.load("HLTrigger.Phase2HLTPFTaus.hltPixelVertices_cff")
#process.reconstruction_step.replace(process.offlinePrimaryVertices, process.offlinePrimaryVertices + process.hltPhase2PixelTracksSequence + process.hltPhase2PixelVerticesSequence)
#process.reconstruction_step += process.offlinePrimaryVertices
#process.reconstruction_step += process.hltPhase2PixelTracksSequence
#process.reconstruction_step += process.hltPhase2PixelVerticesSequence

# CV: switch vertex collection in particle-flow algorithm
if srcVertices != "offlinePrimaryVertices":
    print(
        "Switching all vertex-related InputTags in 'reconstruction_step' path from '%s' to '%s'..."
        % ('offlinePrimaryVertices', srcVertices))
    from FWCore.ParameterSet.MassReplace import massSearchReplaceAnyInputTag
    massSearchReplaceAnyInputTag(process.reconstruction_step,
                                 'offlinePrimaryVertices', srcVertices)
#--------------------------------------------------------------------------------

#--------------------------------------------------------------------------------
# CV: add HLT tau reconstruction
process.taucustomreco = cms.Sequence()

# run HLT tau reconstruction
from HLTrigger.Phase2HLTPFTaus.tools.addHLTPFTaus import addHLTPFTaus
srcPFCandidates = "particleFlowTmp"
for algorithm in ["hps", "shrinking-cone"]:
    for isolation_maxDeltaZOption in ["primaryVertex", "leadTrack"]:
        for isolation_minTrackHits in [3, 5, 8]:

            suffix = "%iHits" % isolation_minTrackHits
            isolation_maxDeltaZ = None