CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

trackTools::MakePATTrackCandidates Class Reference

Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.

List of all members.

Public Member Functions

def __call__
def __init__
def getDefaultParameters
def toolCode

Private Attributes

 _comment
 _parameters

Static Private Attributes

tuple _defaultParameters = dicttypes.SortedKeysDict()
string _label = 'makePATTrackCandidates'

Detailed Description

Create pat track candidates from AOD track collections:

Definition at line 68 of file trackTools.py.


Constructor & Destructor Documentation

def trackTools::MakePATTrackCandidates::__init__ (   self)

Definition at line 75 of file trackTools.py.

00076                       :
00077         ConfigToolBase.__init__(self)
00078         self.addParameter(self._defaultParameters,'label','TrackCands', "output will be 'all/selectedLayer1'+label")
00079         self.addParameter(self._defaultParameters,'input',cms.InputTag('patAODTrackCands'), 'name of the input collection')
00080         self.addParameter(self._defaultParameters,'selection','pt > 10', 'selection on PAT Layer 1 objects')
00081         self.addParameter(self._defaultParameters,'isolation',{'tracker':0.3, 'ecalTowers':0.3, 'hcalTowers':0.3}, "solation to use (as 'source': value of dR)\ntracker     : as muon iso from tracks\necalTowers  : as muon iso from calo tower\nhcalTowers  : as muon iso from calo towers",allowedValues=['tracker','ecalTowers','hcalTowers'])
00082         self.addParameter(self._defaultParameters,'isoDeposits',['tracker','ecalTowers','hcalTowers'], 'iso deposits')
00083         self.addParameter(self._defaultParameters,'mcAs',None, "eplicate mc match as the one used by PAT on this AOD collection (None=no mc match); choose 'photon', 'electron', 'muon', 'tau','jet', 'met' as input string",Type=str, allowedValues=['photon', 'electron', 'muon', 'tau','jet', 'met', None], acceptNoneValue = True) 
00084         
00085         self._parameters=copy.deepcopy(self._defaultParameters)
00086         self._comment = ""


Member Function Documentation

def trackTools::MakePATTrackCandidates::__call__ (   self,
  process,
  label = None,
  input = None,
  selection = None,
  isolation = None,
  isoDeposits = None,
  mcAs = None 
)

Definition at line 90 of file trackTools.py.

00097                                      :
00098         if label  is None:
00099             label=self._defaultParameters['label'].value
00100         if input is None:
00101             input=self._defaultParameters['input'].value
00102         if selection is None:
00103             selection=self._defaultParameters['selection'].value
00104         if isolation is None:
00105             isolation=self._defaultParameters['isolation'].value
00106         if isoDeposits is None:
00107             isoDeposits=self._defaultParameters['isoDeposits'].value
00108         if mcAs is None:
00109             mcAs=self._defaultParameters['mcAs'].value    
00110         self.setParameter('label',label)
00111         self.setParameter('input',input)
00112         self.setParameter('selection',selection)
00113         self.setParameter('isolation',isolation)
00114         self.setParameter('isoDeposits',isoDeposits)
00115         self.setParameter('mcAs',mcAs,True)                                                                                              
00116         self.apply(process) 
        
def trackTools::MakePATTrackCandidates::getDefaultParameters (   self)

Definition at line 87 of file trackTools.py.

00088                                   :
00089         return self._defaultParameters

def trackTools::MakePATTrackCandidates::toolCode (   self,
  process 
)

Definition at line 117 of file trackTools.py.

00117                                :                
00118         label=self._parameters['label'].value
00119         input=self._parameters['input'].value
00120         selection=self._parameters['selection'].value
00121         isolation=self._parameters['isolation'].value
00122         isoDeposits=self._parameters['isoDeposits'].value
00123         mcAs=self._parameters['mcAs'].value
00124                                                 
00125         ## add patTracks to the process
00126         from PhysicsTools.PatAlgos.producersLayer1.genericParticleProducer_cfi import patGenericParticles
00127         setattr(process, 'pat' + label, patGenericParticles.clone(src = input))
00128         ## add selectedPatTracks to the process
00129         setattr(process, 'selectedPat' + label, cms.EDFilter("PATGenericParticleSelector",
00130                                                              src = cms.InputTag("pat"+label),
00131                                                              cut = cms.string(selection) 
00132                                                              ) 
00133                 )
00134         ## add cleanPatTracks to the process
00135         from PhysicsTools.PatAlgos.cleaningLayer1.genericTrackCleaner_cfi import cleanPatTracks
00136         setattr(process, 'cleanPat' + label, cleanPatTracks.clone(src = cms.InputTag('selectedPat' + label)))
00137         
00138         ## get them as variables, so we can put them in the sequences and/or configure them
00139         l1cands         = getattr(process, 'pat' + label)
00140         selectedL1cands = getattr(process, 'selectedPat' + label)
00141         cleanL1cands    = getattr(process, 'cleanPat' + label)
00142         
00143         ## insert them in sequence, after the electrons
00144         process.patCandidates.replace(process.patElectrons, l1cands + process.patElectrons)
00145         process.selectedPatCandidates.replace(process.selectedPatElectrons, process.selectedPatElectrons + selectedL1cands)
00146         process.cleanPatCandidates.replace(process.cleanPatElectrons, process.cleanPatElectrons + cleanL1cands)
00147     
00148         ## add them to the Summary Tables
00149         process.patCandidateSummary.candidates += [ cms.InputTag("allPat"+label) ]
00150         process.selectedPatCandidateSummary.candidates += [ cms.InputTag("selectedPat"+label) ]
00151         process.cleanPatCandidateSummary.candidates += [ cms.InputTag("cleanPat"+label) ]
00152     
00153         ## isolation: start with empty config
00154         if(isolation or isoDeposits):
00155             process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi")
00156             process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi")
00157             process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi")
00158         isoModules = []
00159         runIsoDeps = {'tracker':False, 'caloTowers':False}
00160     
00161         for source,deltaR in isolation.items():
00162             ## loop items in isolation
00163             if(source == 'tracker'):
00164                 runIsoDeps['tracker'] = True
00165                 l1cands.userIsolation.tracker = cms.PSet(
00166                     src    = cms.InputTag('pat'+label+'IsoDepositTracks'),
00167                     deltaR = cms.double(deltaR),
00168                     )
00169             elif(source == 'ecalTowers'):
00170                 runIsoDeps['caloTowers'] = True
00171                 l1cands.userIsolation.ecal = cms.PSet(
00172                     src    = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'ecal'),
00173                     deltaR = cms.double(deltaR),
00174                     )
00175             elif(source == 'hcalTowers'):
00176                 runIsoDeps['caloTowers'] = True
00177                 l1cands.userIsolation.hcal = cms.PSet(
00178                     src    = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'hcal'),
00179                     deltaR = cms.double(deltaR),
00180                     )
00181             
00182         for source in isoDeposits:
00183             ## loop items in isoDeposits
00184             if(source == 'tracker'):
00185                 runIsoDeps['tracker'] = True
00186                 l1cands.isoDeposits.tracker = cms.InputTag('pat'+label+'IsoDepositTracks') 
00187             elif(source == 'ecalTowers'):
00188                 runIsoDeps['caloTowers'] = True
00189                 l1cands.isoDeposits.ecal = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'ecal') 
00190             elif(source == 'hcalTowers'):
00191                 runIsoDeps['caloTowers'] = True
00192                 l1cands.isoDeposits.hcal = cms.InputTag('pat'+label+'IsoDepositCaloTowers', 'hcal')
00193             
00194         for dep in [ dep for dep,runme in runIsoDeps.items() if runme == True ]:
00195             if(dep == 'tracker'):
00196                 from RecoMuon.MuonIsolationProducers.trackExtractorBlocks_cff import MIsoTrackExtractorCtfBlock
00197                 setattr(process, 'pat'+label+'IsoDepositTracks',
00198                         cms.EDProducer("CandIsoDepositProducer",
00199                                        src                  = input,
00200                                        trackType            = cms.string('best'),
00201                                        MultipleDepositsFlag = cms.bool(False),
00202                                        ExtractorPSet        = cms.PSet( MIsoTrackExtractorCtfBlock )
00203                                        )
00204                         )
00205                 isoModules.append( getattr(process, 'pat'+label+'IsoDepositTracks') )
00206             elif(dep == 'caloTowers'):
00207                 from RecoMuon.MuonIsolationProducers.caloExtractorByAssociatorBlocks_cff import MIsoCaloExtractorByAssociatorTowersBlock
00208                 setattr(process, 'pat'+label+'IsoDepositCaloTowers',
00209                         cms.EDProducer("CandIsoDepositProducer",
00210                                        src                  = input,
00211                                        trackType            = cms.string('best'),
00212                                        MultipleDepositsFlag = cms.bool(True),
00213                                        ExtractorPSet        = cms.PSet( MIsoCaloExtractorByAssociatorTowersBlock )
00214                                        )
00215                         )
00216                 isoModules.append( getattr(process, 'pat'+label+'IsoDepositCaloTowers') )
00217         for m in isoModules:
00218             process.patDefaultSequence.replace(l1cands, m * l1cands)
00219         # ES
00220         process.load( 'TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff' ) 
00221         # MC
00222         from PhysicsTools.PatAlgos.tools.helpers import MassSearchParamVisitor
00223         if(type(mcAs) != type(None)):
00224             findMatch= []
00225             findMatch.append(getattr(process, mcAs+'Match'))
00226             
00227             ## clone mc matchiong module of object mcAs and add it to the path
00228             setattr(process, 'pat'+label+'MCMatch', findMatch[0].clone(src = input))
00229             process.patDefaultSequence.replace( l1cands, getattr(process, 'pat'+label+'MCMatch') * l1cands)
00230             l1cands.addGenMatch = True
00231             l1cands.genParticleMatch = cms.InputTag('pat'+label+'MCMatch')
00232 
00233       
00234 makePATTrackCandidates=MakePATTrackCandidates()
00235 
00236 

Member Data Documentation

Definition at line 75 of file trackTools.py.

tuple trackTools::MakePATTrackCandidates::_defaultParameters = dicttypes.SortedKeysDict() [static, private]

Definition at line 73 of file trackTools.py.

string trackTools::MakePATTrackCandidates::_label = 'makePATTrackCandidates' [static, private]

Definition at line 72 of file trackTools.py.

Definition at line 75 of file trackTools.py.