CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::PATTauProducer Class Reference

Produces pat::Tau's. More...

#include "PhysicsTools/PatAlgos/interface/PATTauProducer.h"

Inheritance diagram for pat::PATTauProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 PATTauProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 ~PATTauProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::pair< std::string,
edm::InputTag
NameTag
 

Private Member Functions

template<typename TauCollectionType , typename TauDiscrType >
float getTauIdDiscriminator (const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
 

Private Attributes

bool addEfficiencies_
 
bool addGenJetMatch_
 
bool addGenMatch_
 
bool addResolutions_
 
bool addTauID_
 
bool addTauJetCorrFactors_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
bool embedGenJetMatch_
 
bool embedGenMatch_
 
bool embedIsolationPFCands_
 
bool embedIsolationPFChargedHadrCands_
 
bool embedIsolationPFGammaCands_
 
bool embedIsolationPFNeutralHadrCands_
 
bool embedIsolationTracks_
 
bool embedLeadPFCand_
 
bool embedLeadPFChargedHadrCand_
 
bool embedLeadPFNeutralCand_
 
bool embedLeadTrack_
 
bool embedSignalPFCands_
 
bool embedSignalPFChargedHadrCands_
 
bool embedSignalPFGammaCands_
 
bool embedSignalPFNeutralHadrCands_
 
bool embedSignalTracks_
 
edm::InputTag genJetMatchSrc_
 
std::vector< edm::InputTaggenMatchSrc_
 
std::vector< std::pair
< pat::IsolationKeys,
edm::InputTag > > 
isoDepositLabels_
 
pat::helper::MultiIsolator isolator_
 
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
 
GreaterByPt< TaupTTauComparator_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
std::vector< NameTagtauIDSrcs_
 
std::vector< edm::InputTagtauJetCorrFactorsSrc_
 
edm::InputTag tauSrc_
 
pat::PATUserDataHelper< pat::TauuserDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Produces pat::Tau's.

The PATTauProducer produces analysis-level pat::Tau's starting from a collection of objects of TauType.

Author
Steven Lowette, Christophe Delaere
Version
Id:
PATTauProducer.h,v 1.23 2011/09/26 12:36:30 veelken Exp

Definition at line 47 of file PATTauProducer.h.

Member Typedef Documentation

typedef std::pair<std::string, edm::InputTag> pat::PATTauProducer::NameTag
private

Definition at line 89 of file PATTauProducer.h.

Constructor & Destructor Documentation

PATTauProducer::PATTauProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 31 of file PATTauProducer.cc.

References addEfficiencies_, addGenJetMatch_, addGenMatch_, addResolutions_, addTauID_, addTauJetCorrFactors_, pat::EcalIso, efficiencyLoader_, embedGenJetMatch_, embedGenMatch_, embedIsolationPFCands_, embedIsolationPFChargedHadrCands_, embedIsolationPFGammaCands_, embedIsolationPFNeutralHadrCands_, embedIsolationTracks_, embedLeadPFCand_, embedLeadPFChargedHadrCand_, embedLeadPFNeutralCand_, embedLeadTrack_, embedSignalPFCands_, embedSignalPFChargedHadrCands_, embedSignalPFGammaCands_, embedSignalPFNeutralHadrCands_, embedSignalTracks_, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), genJetMatchSrc_, genMatchSrc_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), pat::HcalIso, isoDepositLabels_, combine::key, h::names, pat::PfAllParticleIso, pat::PfChargedHadronIso, pat::PfGammaIso, pat::PfNeutralHadronIso, resolutionLoader_, tauIDSrcs_, tauJetCorrFactorsSrc_, tauSrc_, pat::TrackIso, pat::UserBaseIso, userDataHelper_, and useUserData_.

31  :
32  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), false) ,
33  useUserData_(iConfig.exists("userData"))
34 {
35  // initialize the configurables
36  tauSrc_ = iConfig.getParameter<edm::InputTag>( "tauSource" );
37  embedIsolationTracks_ = iConfig.getParameter<bool>( "embedIsolationTracks" );
38  embedLeadTrack_ = iConfig.getParameter<bool>( "embedLeadTrack" );
39  embedSignalTracks_ = iConfig.getParameter<bool>( "embedSignalTracks" );
40  embedLeadPFCand_ = iConfig.getParameter<bool>( "embedLeadPFCand" );
41  embedLeadPFChargedHadrCand_ = iConfig.getParameter<bool>( "embedLeadPFChargedHadrCand" );
42  embedLeadPFNeutralCand_ = iConfig.getParameter<bool>( "embedLeadPFNeutralCand" );
43  embedSignalPFCands_ = iConfig.getParameter<bool>( "embedSignalPFCands" );
44  embedSignalPFChargedHadrCands_ = iConfig.getParameter<bool>( "embedSignalPFChargedHadrCands" );
45  embedSignalPFNeutralHadrCands_ = iConfig.getParameter<bool>( "embedSignalPFNeutralHadrCands" );
46  embedSignalPFGammaCands_ = iConfig.getParameter<bool>( "embedSignalPFGammaCands" );
47  embedIsolationPFCands_ = iConfig.getParameter<bool>( "embedIsolationPFCands" );
48  embedIsolationPFChargedHadrCands_ = iConfig.getParameter<bool>( "embedIsolationPFChargedHadrCands" );
49  embedIsolationPFNeutralHadrCands_ = iConfig.getParameter<bool>( "embedIsolationPFNeutralHadrCands" );
50  embedIsolationPFGammaCands_ = iConfig.getParameter<bool>( "embedIsolationPFGammaCands" );
51  addGenMatch_ = iConfig.getParameter<bool>( "addGenMatch" );
52  if (addGenMatch_) {
53  embedGenMatch_ = iConfig.getParameter<bool>( "embedGenMatch" );
54  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
55  genMatchSrc_.push_back(iConfig.getParameter<edm::InputTag>( "genParticleMatch" ));
56  }
57  else {
58  genMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" );
59  }
60  }
61  addGenJetMatch_ = iConfig.getParameter<bool>( "addGenJetMatch" );
62  if(addGenJetMatch_) {
63  embedGenJetMatch_ = iConfig.getParameter<bool>( "embedGenJetMatch" );
64  genJetMatchSrc_ = iConfig.getParameter<edm::InputTag>( "genJetMatch" );
65  }
66  addTauJetCorrFactors_ = iConfig.getParameter<bool>( "addTauJetCorrFactors" );
67  tauJetCorrFactorsSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "tauJetCorrFactorsSource" );
68  // tau ID configurables
69  addTauID_ = iConfig.getParameter<bool>( "addTauID" );
70  if ( addTauID_ ) {
71  // it might be a single tau ID
72  if (iConfig.existsAs<edm::InputTag>("tauIDSource")) {
73  tauIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("tauIDSource")));
74  }
75  // or there might be many of them
76  if (iConfig.existsAs<edm::ParameterSet>("tauIDSources")) {
77  // please don't configure me twice
78  if (!tauIDSrcs_.empty()){
79  throw cms::Exception("Configuration") << "PATTauProducer: you can't specify both 'tauIDSource' and 'tauIDSources'\n";
80  }
81  // read the different tau ID names
82  edm::ParameterSet idps = iConfig.getParameter<edm::ParameterSet>("tauIDSources");
83  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
84  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
85  tauIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
86  }
87  }
88  // but in any case at least once
89  if (tauIDSrcs_.empty()) throw cms::Exception("Configuration") <<
90  "PATTauProducer: id addTauID is true, you must specify either:\n" <<
91  "\tInputTag tauIDSource = <someTag>\n" << "or\n" <<
92  "\tPSet tauIDSources = { \n" <<
93  "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
94  "\t}\n";
95  }
96  // IsoDeposit configurables
97  if (iConfig.exists("isoDeposits")) {
98  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
99  if ( depconf.exists("tracker") ) isoDepositLabels_.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
100  if ( depconf.exists("ecal") ) isoDepositLabels_.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
101  if ( depconf.exists("hcal") ) isoDepositLabels_.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
102  if ( depconf.exists("pfAllParticles") ) isoDepositLabels_.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
103  if ( depconf.exists("pfChargedHadron") ) isoDepositLabels_.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadron")));
104  if ( depconf.exists("pfNeutralHadron") ) isoDepositLabels_.push_back(std::make_pair(pat::PfNeutralHadronIso,depconf.getParameter<edm::InputTag>("pfNeutralHadron")));
105  if ( depconf.exists("pfGamma") ) isoDepositLabels_.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfGamma")));
106 
107  if ( depconf.exists("user") ) {
108  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
109  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
110  int key = UserBaseIso;
111  for ( ; it != ed; ++it, ++key) {
112  isoDepositLabels_.push_back(std::make_pair(IsolationKeys(key), *it));
113  }
114  }
115  }
116  // Efficiency configurables
117  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
118  if (addEfficiencies_) {
120  }
121  // Resolution configurables
122  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
123  if (addResolutions_) {
125  }
126  // Check to see if the user wants to add user data
127  if ( useUserData_ ) {
129  }
130  // produces vector of taus
131  produces<std::vector<Tau> >();
132 }
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
std::pair< std::string, edm::InputTag > NameTag
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
pat::helper::EfficiencyLoader efficiencyLoader_
bool exists(std::string const &parameterName) const
checks if a parameter exists
pat::helper::KinResolutionsLoader resolutionLoader_
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
edm::InputTag genJetMatchSrc_
std::vector< edm::InputTag > genMatchSrc_
bool embedIsolationPFChargedHadrCands_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:195
pat::helper::MultiIsolator isolator_
edm::InputTag tauSrc_
bool embedIsolationPFNeutralHadrCands_
pat::PATUserDataHelper< pat::Tau > userDataHelper_
bool embedSignalPFNeutralHadrCands_
list key
Definition: combine.py:13
std::vector< edm::InputTag > tauJetCorrFactorsSrc_
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
bool embedSignalPFChargedHadrCands_
static const HistoName names[]
std::vector< NameTag > tauIDSrcs_
PATTauProducer::~PATTauProducer ( )

Definition at line 134 of file PATTauProducer.cc.

135 {
136 }

Member Function Documentation

void PATTauProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 408 of file PATTauProducer.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), edm::ParameterSetDescription::setComment(), and edm::ParameterDescriptionNode::setComment().

409 {
411  iDesc.setComment("PAT tau producer module");
412 
413  // input source
414  iDesc.add<edm::InputTag>("tauSource", edm::InputTag())->setComment("input collection");
415 
416  // embedding
417  iDesc.add<bool>("embedIsolationTracks", false)->setComment("embed external isolation tracks");
418  iDesc.add<bool>("embedLeadTrack", false)->setComment("embed external leading track");
419  iDesc.add<bool>("embedLeadTracks", false)->setComment("embed external signal tracks");
420 
421  // MC matching configurables
422  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
423  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
424  std::vector<edm::InputTag> emptySourceVector;
425  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
426  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
427  )->setComment("input with MC match information");
428 
429  // MC jet matching variables
430  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC jet matching");
431  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC jet matched jet information");
432  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag("tauGenJetMatch"));
433 
434 
436 
437  // tau ID configurables
438  iDesc.add<bool>("addTauID", true)->setComment("add tau ID variables");
439  edm::ParameterSetDescription tauIDSourcesPSet;
440  tauIDSourcesPSet.setAllowAnything();
441  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("tauIDSource", edm::InputTag(), true) xor
442  edm::ParameterDescription<edm::ParameterSetDescription>("tauIDSources", tauIDSourcesPSet, true)
443  )->setComment("input with electron ID variables");
444 
445  // IsoDeposit configurables
446  edm::ParameterSetDescription isoDepositsPSet;
447  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
448  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
449  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
450  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
451  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadron");
452  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadron");
453  isoDepositsPSet.addOptional<edm::InputTag>("pfGamma");
454  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
455  iDesc.addOptional("isoDeposits", isoDepositsPSet);
456 
457  // Efficiency configurables
458  edm::ParameterSetDescription efficienciesPSet;
459  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
460  iDesc.add("efficiencies", efficienciesPSet);
461  iDesc.add<bool>("addEfficiencies", false);
462 
463  // Check to see if the user wants to add user data
464  edm::ParameterSetDescription userDataPSet;
466  iDesc.addOptional("userData", userDataPSet);
467 
468  edm::ParameterSetDescription isolationPSet;
469  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
470  iDesc.add("userIsolation", isolationPSet);
471 
472 }
void setComment(std::string const &value)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
template<typename TauCollectionType , typename TauDiscrType >
float PATTauProducer::getTauIdDiscriminator ( const edm::Handle< TauCollectionType > &  tauCollection,
size_t  tauIdx,
const edm::Handle< TauDiscrType > &  tauIdDiscr 
)
private

Definition at line 401 of file PATTauProducer.cc.

Referenced by produce().

402 {
403  edm::Ref<TauCollectionType> tauRef(tauCollection, tauIdx);
404  return (*tauIdDiscr)[tauRef];
405 }
void PATTauProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 138 of file PATTauProducer.cc.

References addGenJetMatch_, addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), pat::Tau::addJECFactors(), addTauID_, addTauJetCorrFactors_, pat::helper::MultiIsolator::beginEvent(), alignCSCRings::e, efficiencyLoader_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::Tau::embedIsolationPFCands(), embedIsolationPFCands_, pat::Tau::embedIsolationPFChargedHadrCands(), embedIsolationPFChargedHadrCands_, pat::Tau::embedIsolationPFGammaCands(), embedIsolationPFGammaCands_, pat::Tau::embedIsolationPFNeutralHadrCands(), embedIsolationPFNeutralHadrCands_, pat::Tau::embedIsolationTracks(), embedIsolationTracks_, pat::Tau::embedLeadPFCand(), embedLeadPFCand_, pat::Tau::embedLeadPFChargedHadrCand(), embedLeadPFChargedHadrCand_, pat::Tau::embedLeadPFNeutralCand(), embedLeadPFNeutralCand_, pat::Tau::embedLeadTrack(), embedLeadTrack_, pat::Tau::embedSignalPFCands(), embedSignalPFCands_, pat::Tau::embedSignalPFChargedHadrCands(), embedSignalPFChargedHadrCands_, pat::Tau::embedSignalPFGammaCands(), embedSignalPFGammaCands_, pat::Tau::embedSignalPFNeutralHadrCands(), embedSignalPFNeutralHadrCands_, pat::Tau::embedSignalTracks(), embedSignalTracks_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), pat::helper::MultiIsolator::enabled(), pat::helper::MultiIsolator::endEvent(), edm::hlt::Exception, pat::helper::MultiIsolator::fill(), spr::find(), first, genJetMatchSrc_, genMatchSrc_, edm::Event::getByLabel(), getTauIdDiscriminator(), i, pat::Tau::initializeJEC(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), isoDepositLabels_, isolator_, isolatorTmpStorage_, pat::Tau::isPFTau(), edm::EventBase::isRealData(), j, n, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), tauProducer_cfi::patTaus, pfTaus_cff::pfTaus, pTTauComparator_, edm::Event::put(), resolutionLoader_, edm::second(), pat::Tau::setDecayMode(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Tau::setGenJet(), pat::Lepton< LeptonType >::setIsoDeposit(), pat::Lepton< LeptonType >::setIsolation(), pat::helper::KinResolutionsLoader::setResolutions(), pat::Tau::setTauIDs(), python.multivaluedict::sort(), tauIDSrcs_, tauJetCorrFactorsSrc_, tauSrc_, userDataHelper_, and useUserData_.

139 {
140  // switch off embedding (in unschedules mode)
141  if (iEvent.isRealData()){
142  addGenMatch_ = false;
143  embedGenMatch_ = false;
144  addGenJetMatch_ = false;
145  }
146 
147  // Get the collection of taus from the event
149  try {
150  iEvent.getByLabel(tauSrc_, anyTaus);
151  } catch (const edm::Exception &e) {
152  edm::LogWarning("DataSource") << "WARNING! No Tau collection found. This missing input will not block the job. Instead, an empty tau collection is being be produced.";
153  std::auto_ptr<std::vector<Tau> > patTaus(new std::vector<Tau>());
154  iEvent.put(patTaus);
155  return;
156  }
157 
158  if (isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
159 
161  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
162 
163  std::vector<edm::Handle<edm::ValueMap<IsoDeposit> > > deposits(isoDepositLabels_.size());
164  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
165  iEvent.getByLabel(isoDepositLabels_[j].second, deposits[j]);
166  }
167 
168  // prepare the MC matching
169  std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > genMatches(genMatchSrc_.size());
170  if (addGenMatch_) {
171  for (size_t j = 0, nd = genMatchSrc_.size(); j < nd; ++j) {
172  iEvent.getByLabel(genMatchSrc_[j], genMatches[j]);
173  }
174  }
175 
177  if (addGenJetMatch_) iEvent.getByLabel(genJetMatchSrc_, genJetMatch);
178 
179  // read in the jet correction factors ValueMap
180  std::vector<edm::ValueMap<TauJetCorrFactors> > tauJetCorrs;
181  if (addTauJetCorrFactors_) {
182  for ( size_t i = 0; i < tauJetCorrFactorsSrc_.size(); ++i ) {
184  iEvent.getByLabel(tauJetCorrFactorsSrc_[i], tauJetCorr);
185  tauJetCorrs.push_back( *tauJetCorr );
186  }
187  }
188 
189  std::auto_ptr<std::vector<Tau> > patTaus(new std::vector<Tau>());
190 
191  bool first=true; // this is introduced to issue warnings only for the first tau-jet
192  for (size_t idx = 0, ntaus = anyTaus->size(); idx < ntaus; ++idx) {
193  edm::RefToBase<reco::BaseTau> tausRef = anyTaus->refAt(idx);
194  edm::Ptr<reco::BaseTau> tausPtr = anyTaus->ptrAt(idx);
195 
196  Tau aTau(tausRef);
197  if (embedLeadTrack_) aTau.embedLeadTrack();
198  if (embedSignalTracks_) aTau.embedSignalTracks();
199  if (embedIsolationTracks_) aTau.embedIsolationTracks();
200  if (embedLeadPFCand_) {
201  if (aTau.isPFTau() )
202  aTau.embedLeadPFCand();
203  else
204  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
205  }
207  if (aTau.isPFTau() )
208  aTau.embedLeadPFChargedHadrCand();
209  else
210  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
211  }
213  if (aTau.isPFTau() )
214  aTau.embedLeadPFNeutralCand();
215  else
216  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
217  }
218  if (embedSignalPFCands_) {
219  if (aTau.isPFTau() )
220  aTau.embedSignalPFCands();
221  else
222  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
223  }
225  if (aTau.isPFTau() )
226  aTau.embedSignalPFChargedHadrCands();
227  else
228  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
229  }
231  if (aTau.isPFTau() )
232  aTau.embedSignalPFNeutralHadrCands();
233  else
234  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
235  }
237  if (aTau.isPFTau() )
238  aTau.embedSignalPFGammaCands();
239  else
240  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
241  }
243  if (aTau.isPFTau() )
244  aTau.embedIsolationPFCands();
245  else
246  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
247  }
249  if (aTau.isPFTau() )
250  aTau.embedIsolationPFChargedHadrCands();
251  else
252  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
253  }
255  if (aTau.isPFTau() )
256  aTau.embedIsolationPFNeutralHadrCands();
257  else
258  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
259  }
261  if (aTau.isPFTau() )
262  aTau.embedIsolationPFGammaCands();
263  else
264  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
265  }
266 
267  if (addTauJetCorrFactors_) {
268  // add additional JetCorrs to the jet
269  for ( unsigned int i=0; i<tauJetCorrFactorsSrc_.size(); ++i ) {
270  const TauJetCorrFactors& tauJetCorr = tauJetCorrs[i][tausRef];
271  // uncomment for debugging
272  // tauJetCorr.print();
273  aTau.addJECFactors(tauJetCorr);
274  }
275  std::vector<std::string> levels = tauJetCorrs[0][tausRef].correctionLabels();
276  if(std::find(levels.begin(), levels.end(), "L2L3Residual")!=levels.end()){
277  aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel("L2L3Residual"));
278  }
279  else if(std::find(levels.begin(), levels.end(), "L3Absolute")!=levels.end()){
280  aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel("L3Absolute"));
281  }
282  else{
283  aTau.initializeJEC(tauJetCorrs[0][tausRef].jecLevel("Uncorrected"));
284  if(first){
285  edm::LogWarning("L3Absolute not found")
286  << "L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
287  << "of module " << tauJetCorrs[0][tausRef].jecSet() << " jets will remain"
288  << " uncorrected.";
289  first=false;
290  }
291  }
292  }
293 
294  // store the match to the generated final state muons
295  if (addGenMatch_) {
296  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
297  reco::GenParticleRef genTau = (*genMatches[i])[tausRef];
298  aTau.addGenParticleRef(genTau);
299  }
300  if (embedGenMatch_) aTau.embedGenParticle();
301  }
302 
303  // store the match to the visible part of the generated tau
304  if (addGenJetMatch_) {
305  reco::GenJetRef genJetTau = (*genJetMatch)[tausRef];
306  if (genJetTau.isNonnull() && genJetTau.isAvailable() ) {
307  aTau.setGenJet( genJetTau );
308  } // leave empty if no match found
309  }
310 
311  // prepare ID extraction
312  if ( addTauID_ ) {
313  std::vector<pat::Tau::IdPair> ids(tauIDSrcs_.size());
314  for ( size_t i = 0; i < tauIDSrcs_.size(); ++i ) {
316  iEvent.getByLabel(tauIDSrcs_[i].second, caloTauIdDiscr);
317 
319  iEvent.getByLabel(tauIDSrcs_[i].second, pfTauIdDiscr);
320 
321  if ( typeid(*tausRef) == typeid(reco::PFTau) ) {
322  //std::cout << "filling PFTauDiscriminator '" << tauIDSrcs_[i].first << "' into pat::Tau object..." << std::endl;
323  edm::Handle<reco::PFTauCollection> pfTauCollection;
324  iEvent.getByLabel(tauSrc_, pfTauCollection);
325 
327  iEvent.getByLabel(tauIDSrcs_[i].second, pfTauIdDiscr);
328 
329  ids[i].first = tauIDSrcs_[i].first;
330  ids[i].second = getTauIdDiscriminator(pfTauCollection, idx, pfTauIdDiscr);
331  } else if ( typeid(*tausRef) == typeid(reco::CaloTau) ) {
332  //std::cout << "filling CaloTauDiscriminator '" << tauIDSrcs_[i].first << "' into pat::Tau object..." << std::endl;
333  edm::Handle<reco::CaloTauCollection> caloTauCollection;
334  iEvent.getByLabel(tauSrc_, caloTauCollection);
335 
337  iEvent.getByLabel(tauIDSrcs_[i].second, caloTauIdDiscr);
338 
339  ids[i].first = tauIDSrcs_[i].first;
340  ids[i].second = getTauIdDiscriminator(caloTauCollection, idx, caloTauIdDiscr);
341  } else {
342  throw cms::Exception("Type Mismatch") <<
343  "PATTauProducer: unsupported datatype '" << typeid(*tausRef).name() << "' for tauSource\n";
344  }
345  }
346 
347  aTau.setTauIDs(ids);
348  }
349 
350  // extraction of reconstructed tau decay mode
351  // (only available for PFTaus)
352  if ( aTau.isPFTau() ) {
354  iEvent.getByLabel(tauSrc_, pfTaus);
355  reco::PFTauRef pfTauRef(pfTaus, idx);
356 
357  aTau.setDecayMode(pfTauRef->decayMode());
358  }
359 
360  // Isolation
361  if (isolator_.enabled()) {
362  isolator_.fill(*anyTaus, idx, isolatorTmpStorage_);
363  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
364  // better to loop backwards, so the vector is resized less times
365  for ( IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(),
366  ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
367  aTau.setIsolation(it->first, it->second);
368  }
369  }
370 
371  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
372  aTau.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[tausRef]);
373  }
374 
375  if (efficiencyLoader_.enabled()) {
376  efficiencyLoader_.setEfficiencies( aTau, tausRef );
377  }
378 
379  if (resolutionLoader_.enabled()) {
381  }
382 
383  if ( useUserData_ ) {
384  userDataHelper_.add( aTau, iEvent, iSetup );
385  }
386 
387  patTaus->push_back(aTau);
388  }
389 
390  // sort taus in pT
391  std::sort(patTaus->begin(), patTaus->end(), pTTauComparator_);
392 
393  // put genEvt object in Event
394  iEvent.put(patTaus);
395 
396  // clean up
398 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
tuple pfTaus
Definition: pfTaus_cff.py:119
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
float getTauIdDiscriminator(const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
edm::InputTag genJetMatchSrc_
bool isAvailable() const
Definition: Ref.h:276
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
std::vector< edm::InputTag > genMatchSrc_
bool isRealData() const
Definition: EventBase.h:60
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
bool embedIsolationPFChargedHadrCands_
U second(std::pair< T, U > const &p)
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
pat::helper::MultiIsolator isolator_
edm::InputTag tauSrc_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool embedIsolationPFNeutralHadrCands_
int j
Definition: DBlmapReader.cc:9
pat::PATUserDataHelper< pat::Tau > userDataHelper_
bool embedSignalPFNeutralHadrCands_
bool first
Definition: L1TdeRCT.cc:94
Analysis-level tau class.
Definition: Tau.h:50
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
std::vector< edm::InputTag > tauJetCorrFactorsSrc_
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
bool embedSignalPFChargedHadrCands_
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
std::vector< NameTag > tauIDSrcs_
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
GreaterByPt< Tau > pTTauComparator_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82

Member Data Documentation

bool pat::PATTauProducer::addEfficiencies_
private

Definition at line 99 of file PATTauProducer.h.

Referenced by PATTauProducer().

bool pat::PATTauProducer::addGenJetMatch_
private

Definition at line 81 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::addGenMatch_
private

Definition at line 77 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::addResolutions_
private

Definition at line 102 of file PATTauProducer.h.

Referenced by PATTauProducer().

bool pat::PATTauProducer::addTauID_
private

Definition at line 88 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::addTauJetCorrFactors_
private

Definition at line 85 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

pat::helper::EfficiencyLoader pat::PATTauProducer::efficiencyLoader_
private

Definition at line 100 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedGenJetMatch_
private

Definition at line 82 of file PATTauProducer.h.

Referenced by PATTauProducer().

bool pat::PATTauProducer::embedGenMatch_
private

Definition at line 78 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedIsolationPFCands_
private

Definition at line 72 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedIsolationPFChargedHadrCands_
private

Definition at line 73 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedIsolationPFGammaCands_
private

Definition at line 75 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedIsolationPFNeutralHadrCands_
private

Definition at line 74 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedIsolationTracks_
private

Definition at line 62 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedLeadPFCand_
private

Definition at line 65 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedLeadPFChargedHadrCand_
private

Definition at line 66 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedLeadPFNeutralCand_
private

Definition at line 67 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedLeadTrack_
private

Definition at line 63 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedSignalPFCands_
private

Definition at line 68 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedSignalPFChargedHadrCands_
private

Definition at line 69 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedSignalPFGammaCands_
private

Definition at line 71 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedSignalPFNeutralHadrCands_
private

Definition at line 70 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::embedSignalTracks_
private

Definition at line 64 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

edm::InputTag pat::PATTauProducer::genJetMatchSrc_
private

Definition at line 83 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

std::vector<edm::InputTag> pat::PATTauProducer::genMatchSrc_
private

Definition at line 79 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

std::vector<std::pair<pat::IsolationKeys,edm::InputTag> > pat::PATTauProducer::isoDepositLabels_
private

Definition at line 97 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

pat::helper::MultiIsolator pat::PATTauProducer::isolator_
private

Definition at line 95 of file PATTauProducer.h.

Referenced by produce().

pat::helper::MultiIsolator::IsolationValuePairs pat::PATTauProducer::isolatorTmpStorage_
private

Definition at line 96 of file PATTauProducer.h.

Referenced by produce().

GreaterByPt<Tau> pat::PATTauProducer::pTTauComparator_
private

Definition at line 93 of file PATTauProducer.h.

Referenced by produce().

pat::helper::KinResolutionsLoader pat::PATTauProducer::resolutionLoader_
private

Definition at line 103 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

std::vector<NameTag> pat::PATTauProducer::tauIDSrcs_
private

Definition at line 90 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

std::vector<edm::InputTag> pat::PATTauProducer::tauJetCorrFactorsSrc_
private

Definition at line 86 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

edm::InputTag pat::PATTauProducer::tauSrc_
private

Definition at line 61 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

pat::PATUserDataHelper<pat::Tau> pat::PATTauProducer::userDataHelper_
private

Definition at line 106 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::useUserData_
private

Definition at line 105 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().