CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
coreTools.RemoveMCMatching Class Reference
Inheritance diagram for coreTools.RemoveMCMatching:

Public Member Functions

def __call__ (self, process, names=None, postfix=None, outputModules=None)
 
def __init__ (self)
 
def getDefaultParameters (self)
 
def toolCode (self, process)
 

Private Attributes

 _comment
 
 _parameters
 

Static Private Attributes

 _defaultParameters
 
 _label
 

Detailed Description

Remove monte carlo matching from a given collection or all PAT
candidate collections:

Definition at line 64 of file coreTools.py.

Constructor & Destructor Documentation

def coreTools.RemoveMCMatching.__init__ (   self)

Definition at line 71 of file coreTools.py.

References coreTools.RunOnData._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, root::helper::RootFunctionAdapter< F, args >.addParameter(), root::helper::RootFunctionHelper< F, args, Tag >.addParameter(), ParameterMgr.addParameter(), fit::RootMinuit< Function >.addParameter(), DropBoxMetadata::Parameters.addParameter(), Python11ParameterSet.addParameter(), cmspython3::Python11ParameterSet.addParameter(), l1t::TriggerSystem.addParameter(), LutXml.addParameter(), ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

71  def __init__(self):
72  ConfigToolBase.__init__(self)
73  self.addParameter(self._defaultParameters,'names',['All'],
74  "collection name; supported are 'Photons', 'OOTPhotons', 'Electrons', 'LowPtElectrons', 'Muons', 'Taus', 'TausBoosted', 'Jets', 'METs', 'All', 'PFAll', 'PFElectrons','PFTaus','PFMuons'",
75  allowedValues=['Photons', 'OOTPhotons' ,'Electrons', 'LowPtElectrons', 'Muons', 'Taus', 'TausBoosted', 'Jets', 'METs', 'All', 'PFAll', 'PFElectrons','PFTaus','PFMuons'])
76  self.addParameter(self._defaultParameters,'postfix',"", "postfix of default sequence")
77  self.addParameter(self._defaultParameters,'outputModules',['out'], "names of all output modules specified to be adapted (default is ['out'])")
78  self._parameters=copy.deepcopy(self._defaultParameters)
79  self._comment = ""
80 

Member Function Documentation

def coreTools.RemoveMCMatching.__call__ (   self,
  process,
  names = None,
  postfix = None,
  outputModules = None 
)

Definition at line 87 of file coreTools.py.

References coreTools.RunOnData._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, SignedImpactParameter3D.apply(), gen::PhotosInterfaceBase.apply(), SurveyParameters.apply(), SignedTransverseImpactParameter.apply(), SignedDecayLength3D.apply(), DummyOOTPileupCorrection.apply(), MatrixReader.MatrixReader.apply, gen::PhotosppInterface.apply(), gen::PhotosInterface.apply(), FWPSetCellEditor.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), FWGUIEventFilter.apply(), DeviationsFromFileSensor2D.apply(), ConfigToolBase.ConfigToolBase.apply(), BowedSurfaceAlignmentParameters.apply(), OOTPileupCorrData.apply(), AlignmentParameters.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ApplyTool.apply(), AbsOOTPileupCorrection.apply(), Vispa.Gui.BoxContentDialog.BoxContentDialog.apply(), TwoBowedSurfacesAlignmentParameters.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog.apply(), reco::Add< T >.apply(), reco::Sub< T >.apply(), reco::Mul< T >.apply(), reco::Div< T >.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), reco::And< bool >.apply(), models.RegExp.apply(), reco::Or< bool >.apply(), reco::Less< T >.apply(), reco::LessEqual< T >.apply(), reco::More< T >.apply(), reco::MoreEqual< T >.apply(), reco::Equal< T >.apply(), ArrayND< Num2, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric >.apply(), ArrayND< Numeric, Len, Dim >.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), npstat::ArrayND< Num1, Len1, Dim1 >.apply(), ArrayND< Accumulator >.apply(), ArrayND< Numeric, Len2, Dim2 >.apply(), Config.ProcessModifier.apply(), PedeReader.setParameter(), QIE8Simulator.setParameter(), SiStripLorentzAngleCalibration.setParameter(), AbsElectronicODERHS.setParameter(), IntegratedCalibrationBase.setParameter(), SiPixelLorentzAngleCalibration.setParameter(), SiStripBackplaneCalibration.setParameter(), fit::RootMinuit< Function >.setParameter(), and ConfigToolBase.ConfigToolBase.setParameter().

Referenced by coreTools.RemoveMCMatching.getDefaultParameters().

87  outputModules = None) :
88  if names is None:
89  names=self._defaultParameters['names'].value
90  if postfix is None:
91  postfix=self._defaultParameters['postfix'].value
92  if outputModules is None:
93  outputModules=self._defaultParameters['outputModules'].value
94  self.setParameter('names',names)
95  self.setParameter('postfix',postfix)
96  self.setParameter('outputModules',outputModules)
97  self.apply(process)
98 
def coreTools.RemoveMCMatching.getDefaultParameters (   self)
def coreTools.RemoveMCMatching.toolCode (   self,
  process 
)

Definition at line 99 of file coreTools.py.

References editorTools.UserCodeTool._parameters, coreTools.RunOnData._parameters, Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigFolder._parameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._parameters, ConfigToolBase.ConfigToolBase._parameters, editorTools.ChangeSource._parameters, TAbsFitConstraint._parameters, TAbsFitParticle._parameters, cmsswVersionTools.PickRelValInputFiles._parameters, coreTools.RemoveMCMatching._parameters, coreTools._removeMCMatchingForPATObject(), helpers.jetCollectionString(), edm.print(), python.rootplot.root2matplotlib.replace(), and split.

99  def toolCode(self, process):
100  names=self._parameters['names'].value
101  postfix=self._parameters['postfix'].value
102  outputModules=self._parameters['outputModules'].value
103 
104  print("************** MC dependence removal ************")
105  attrsToDelete = []
106  for obj in range(len(names)):
107  if( names[obj] == 'Photons' or names[obj] == 'All' ):
108  print("removing MC dependencies for photons")
109  _removeMCMatchingForPATObject(process, 'photonMatch', 'patPhotons', postfix)
110  if( names[obj] == 'OOTPhotons' or names[obj] == 'All' ):
111  print("removing MC dependencies for out of time photons")
112  _removeMCMatchingForPATObject(process, 'ootPhotonMatch', 'patOOTPhotons', postfix)
113  if( names[obj] == 'Electrons' or names[obj] == 'All' ):
114  print("removing MC dependencies for electrons")
115  _removeMCMatchingForPATObject(process, 'electronMatch', 'patElectrons', postfix)
116  if( names[obj] == 'LowPtElectrons' or names[obj] == 'All' ):
117  print("removing MC dependencies for LowPtElectrons")
118  _removeMCMatchingForPATObject(process, 'lowPtElectronMatch', 'patLowPtElectrons', postfix)
119  if( names[obj] == 'Muons' or names[obj] == 'All' ):
120  print("removing MC dependencies for muons")
121  _removeMCMatchingForPATObject(process, 'muonMatch', 'patMuons', postfix)
122  if( names[obj] == 'Taus' or names[obj] == 'All' ):
123  print("removing MC dependencies for taus")
124  _removeMCMatchingForPATObject(process, 'tauMatch', 'patTaus', postfix)
125  ## remove mc extra configs for taus
126  tauProducer = getattr(process,'patTaus'+postfix)
127  tauProducer.addGenJetMatch = False
128  tauProducer.embedGenJetMatch = False
129  attrsToDelete += [tauProducer.genJetMatch.getModuleLabel()]
130  tauProducer.genJetMatch = ''
131  attrsToDelete += ['tauGenJets'+postfix]
132  attrsToDelete += ['tauGenJetsSelectorAllHadrons'+postfix]
133  #Boosted Taus
134  if( names[obj] == 'TausBoosted' or names[obj] == 'All' ):
135  print("removing MC dependencies for taus boosted %s" %postfix)
136  if hasattr(process, 'tauMatchBoosted'+postfix) and hasattr(process, 'patTausBoosted'+postfix) :
137  _removeMCMatchingForPATObject(process, 'tauMatchBoosted', 'patTausBoosted', postfix)
138  ## remove mc extra configs for taus
139  tauProducer = getattr(process,'patTausBoosted'+postfix)
140  tauProducer.addGenJetMatch = False
141  tauProducer.embedGenJetMatch = False
142  attrsToDelete += [tauProducer.genJetMatch.getModuleLabel()]
143  tauProducer.genJetMatch = ''
144  attrsToDelete += ['tauGenJetsBoosted'+postfix]
145  attrsToDelete += ['tauGenJetsSelectorAllHadronsBoosted'+postfix]
146  else :
147  print("...skipped since taus boosted %s" %postfix, "are not part of process.")
148  if( names[obj] == 'Jets' or names[obj] == 'All' ):
149  print("removing MC dependencies for jets")
150  jetPostfixes = []
151  for mod in process.producerNames().split():
152  if mod.startswith('patJets') and getattr(process,mod).type_() == "PATJetProducer":
153  jetPostfixes.append(getattr(process, mod).label_().replace("patJets",""))
154  for pfix in jetPostfixes:
155  ## remove mc extra configs for jets
156  jetProducer = getattr(process, jetCollectionString()+pfix)
157  jetProducer.addGenPartonMatch = False
158  jetProducer.embedGenPartonMatch = False
159  #attrsToDelete += [jetProducer.genPartonMatch.getModuleLabel()] #MM needed for potential jet backuping
160  jetProducer.genPartonMatch = ''
161  jetProducer.addGenJetMatch = False
162  #attrsToDelete += [jetProducer.genJetMatch.getModuleLabel()] #MM needed for potential jet backuping
163  jetProducer.genJetMatch = ''
164  jetProducer.getJetMCFlavour = False
165  jetProducer.useLegacyJetMCFlavour = False
166  jetProducer.addJetFlavourInfo = False
167  #attrsToDelete += [jetProducer.JetPartonMapSource.getModuleLabel()] #MM needed for potential jet backuping
168  jetProducer.JetPartonMapSource = ''
169  #attrsToDelete += [jetProducer.JetFlavourInfoSource.getModuleLabel()] #MM needed for potential jet backuping
170  jetProducer.JetFlavourInfoSource = ''
171  attrsToDelete += ['slimmedGenJets'+pfix]
172  ## adjust output
173  for outMod in outputModules:
174  if hasattr(process,outMod):
175  getattr(process,outMod).outputCommands.append("drop *_selectedPatJets*_genJets_*")
176  getattr(process,outMod).outputCommands.append("drop recoGenJets_*_*_*")
177  else:
178  raise KeyError("process has no OutModule named " + outMod)
179 
180  if( names[obj] == 'METs' or names[obj] == 'All' ):
181  for mod in process.producerNames().split():
182  if mod.startswith('pat') and getattr(process,mod).type_() == "PATMETProducer":
183  ## remove mc extra configs for MET
184  metProducer = getattr(process, mod)
185  metProducer.addGenMET = False
186  attrsToDelete += [metProducer.genMETSource.getModuleLabel()]
187  metProducer.genMETSource = ''
188  attrsToDelete += [
189  'prunedGenParticles',
190  'prunedGenParticlesWithStatusOne',
191  'packedGenParticles',
192  'packedPFCandidateToGenAssociation',
193  'lostTracksToGenAssociation',
194  ]
195  for attr in attrsToDelete:
196  if hasattr(process,attr): delattr(process,attr)
197 
198 removeMCMatching=RemoveMCMatching()
199 
def _removeMCMatchingForPATObject(process, matcherName, producerName, postfix="")
Definition: coreTools.py:200
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def toolCode(self, process)
Definition: coreTools.py:99
def jetCollectionString(prefix='', algo='', type='')
Definition: helpers.py:217
double split
Definition: MVATrainer.cc:139

Member Data Documentation

coreTools.RemoveMCMatching._comment
private

Definition at line 79 of file coreTools.py.

coreTools.RemoveMCMatching._defaultParameters
staticprivate

Definition at line 70 of file coreTools.py.

Referenced by HiCoreTools.RestrictInputToAOD.__call__(), trackTools.MakeAODTrackCandidates.__call__(), runJetUncertainties.RunJetUncertainties.__call__(), metTools.AddMETCollection.__call__(), editorTools.ChangeSource.__call__(), HiCoreTools.RemoveMCMatching.__call__(), coreTools.RemoveMCMatching.__call__(), trackTools.MakePATTrackCandidates.__call__(), trigTools.SwitchOnTrigger.__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__call__(), HiCoreTools.RemoveAllPATObjectsBut.__call__(), HiCoreTools.RemoveSpecificPATObjects.__call__(), trigTools.SwitchOnTriggerStandAlone.__call__(), trackTools.MakeTrackCandidates.__call__(), tauTools.AddTauCollection.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), HiCoreTools.RemoveCleaning.__call__(), HiCoreTools.AddCleaning.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), jetTools.AddJetCollection.__call__(), jetTools.SwitchJetCollection.__call__(), jetTools.UpdateJetCollection.__call__(), jetTools.AddJetID.__call__(), jetTools.SetTagInfos.__call__(), editorTools.UserCodeTool.__init__(), metTools.AddMETCollection.__init__(), trackTools.MakeAODTrackCandidates.__init__(), HiCoreTools.RestrictInputToAOD.__init__(), runJetUncertainties.RunJetUncertainties.__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.__init__(), editorTools.ChangeSource.__init__(), HiCoreTools.RemoveMCMatching.__init__(), coreTools.RemoveMCMatching.__init__(), trackTools.MakePATTrackCandidates.__init__(), trigTools.SwitchOnTrigger.__init__(), HiCoreTools.RemoveAllPATObjectsBut.__init__(), HiCoreTools.RemoveSpecificPATObjects.__init__(), trigTools.SwitchOnTriggerStandAlone.__init__(), trackTools.MakeTrackCandidates.__init__(), tauTools.AddTauCollection.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), HiCoreTools.RemoveCleaning.__init__(), HiCoreTools.AddCleaning.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), jetTools.AddJetCollection.__init__(), jetTools.SwitchJetCollection.__init__(), jetTools.UpdateJetCollection.__init__(), jetTools.AddJetID.__init__(), jetTools.SetTagInfos.__init__(), ConfigToolBase.ConfigToolBase.dumpPython(), ConfigToolBase.ConfigToolBase.getAllowedValues(), heavyIonTools.ConfigureHeavyIons.getDefaultParameters(), HiCoreTools.RestrictInputToAOD.getDefaultParameters(), trackTools.MakeAODTrackCandidates.getDefaultParameters(), metTools.AddMETCollection.getDefaultParameters(), heavyIonTools.ProductionDefaults.getDefaultParameters(), editorTools.ChangeSource.getDefaultParameters(), HiCoreTools.RemoveMCMatching.getDefaultParameters(), coreTools.RemoveMCMatching.getDefaultParameters(), trackTools.MakePATTrackCandidates.getDefaultParameters(), trigTools.SwitchOnTrigger.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getDefaultParameters(), heavyIonTools.SelectionDefaults.getDefaultParameters(), HiCoreTools.RemoveAllPATObjectsBut.getDefaultParameters(), heavyIonTools.DisbaleMonteCarloDeps.getDefaultParameters(), HiCoreTools.RemoveSpecificPATObjects.getDefaultParameters(), trigTools.SwitchOnTriggerStandAlone.getDefaultParameters(), trackTools.MakeTrackCandidates.getDefaultParameters(), tauTools.AddTauCollection.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), HiCoreTools.RemoveCleaning.getDefaultParameters(), HiCoreTools.AddCleaning.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), jetTools.AddJetCollection.getDefaultParameters(), jetTools.SwitchJetCollection.getDefaultParameters(), jetTools.UpdateJetCollection.getDefaultParameters(), jetTools.AddJetID.getDefaultParameters(), jetTools.SetTagInfos.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.initializeInputTag(), ConfigToolBase.ConfigToolBase.reset(), and ConfigToolBase.ConfigToolBase.setParameter().

coreTools.RemoveMCMatching._label
staticprivate
coreTools.RemoveMCMatching._parameters
private

Definition at line 78 of file coreTools.py.

Referenced by runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.ak4JetReclustering(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.createMVAMETModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.createSmearedJetModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.extractMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getCorrectedMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getMETUncertainties(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getUnclusteredVariationsForMVAMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getVariations(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.jetCleaning(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.jetConfiguration(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.miniAODConfiguration(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.miniAODConfigurationPost(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.recomputeRawMetFromPfcs(), HiCoreTools.RestrictInputToAOD.toolCode(), trackTools.MakeAODTrackCandidates.toolCode(), metTools.AddMETCollection.toolCode(), runJetUncertainties.RunJetUncertainties.toolCode(), HiCoreTools.RemoveMCMatching.toolCode(), coreTools.RemoveMCMatching.toolCode(), trigTools.SwitchOnTrigger.toolCode(), trackTools.MakePATTrackCandidates.toolCode(), HiCoreTools.RemoveAllPATObjectsBut.toolCode(), HiCoreTools.RemoveSpecificPATObjects.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.toolCode(), trackTools.MakeTrackCandidates.toolCode(), tauTools.AddTauCollection.toolCode(), HiCoreTools.RemoveCleaning.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), HiCoreTools.AddCleaning.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), jetTools.AddJetCollection.toolCode(), jetTools.SwitchJetCollection.toolCode(), jetTools.UpdateJetCollection.toolCode(), jetTools.AddJetID.toolCode(), jetTools.SetTagInfos.toolCode(), and runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.updateJECs().