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 66 of file trackTools.py.


Constructor & Destructor Documentation

def trackTools::MakePATTrackCandidates::__init__ (   self)

Definition at line 73 of file trackTools.py.

00074                       :
00075         ConfigToolBase.__init__(self)
00076         self.addParameter(self._defaultParameters,'label','TrackCands', "output will be 'all/selectedLayer1'+label")
00077         self.addParameter(self._defaultParameters,'input',cms.InputTag('patAODTrackCands'), 'name of the input collection')
00078         self.addParameter(self._defaultParameters,'selection','pt > 10', 'selection on PAT Layer 1 objects')
00079         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'])
00080         self.addParameter(self._defaultParameters,'isoDeposits',['tracker','ecalTowers','hcalTowers'], 'iso deposits')
00081         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)
00082 
00083         self._parameters=copy.deepcopy(self._defaultParameters)
00084         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 88 of file trackTools.py.

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

def trackTools::MakePATTrackCandidates::getDefaultParameters (   self)

Definition at line 85 of file trackTools.py.

00086                                   :
00087         return self._defaultParameters

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

Definition at line 115 of file trackTools.py.

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


Member Data Documentation

Definition at line 73 of file trackTools.py.

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

Definition at line 71 of file trackTools.py.

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

Definition at line 70 of file trackTools.py.

Definition at line 73 of file trackTools.py.