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)
 

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_
 
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_
 
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.21 2010/02/22 14:54:31 mbluj 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 85 of file PATTauProducer.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file PATTauProducer.cc.

References addEfficiencies_, addGenJetMatch_, addGenMatch_, addResolutions_, addTauID_, pat::EcalIso, efficiencyLoader_, embedGenJetMatch_, embedGenMatch_, embedIsolationPFCands_, embedIsolationPFChargedHadrCands_, embedIsolationPFGammaCands_, embedIsolationPFNeutralHadrCands_, embedIsolationTracks_, embedLeadPFCand_, embedLeadPFChargedHadrCand_, embedLeadPFNeutralCand_, embedLeadTrack_, embedSignalPFCands_, embedSignalPFChargedHadrCands_, embedSignalPFGammaCands_, embedSignalPFNeutralHadrCands_, embedSignalTracks_, 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_, tauSrc_, pat::TrackIso, pat::UserBaseIso, userDataHelper_, and useUserData_.

29  :
30  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), false) ,
31  useUserData_(iConfig.exists("userData"))
32 {
33  // initialize the configurables
34  tauSrc_ = iConfig.getParameter<edm::InputTag>( "tauSource" );
35 
36  embedIsolationTracks_ = iConfig.getParameter<bool> ( "embedIsolationTracks" );
37  embedLeadTrack_ = iConfig.getParameter<bool> ( "embedLeadTrack" );
38  embedSignalTracks_ = iConfig.getParameter<bool> ( "embedSignalTracks" );
39  embedLeadPFCand_ = iConfig.getParameter<bool>( "embedLeadPFCand" );
40  embedLeadPFChargedHadrCand_ = iConfig.getParameter<bool>( "embedLeadPFChargedHadrCand" );
41  embedLeadPFNeutralCand_ = iConfig.getParameter<bool>( "embedLeadPFNeutralCand" );
42  embedSignalPFCands_ = iConfig.getParameter<bool>( "embedSignalPFCands" );
43  embedSignalPFChargedHadrCands_ = iConfig.getParameter<bool>( "embedSignalPFChargedHadrCands" );
44  embedSignalPFNeutralHadrCands_ = iConfig.getParameter<bool>( "embedSignalPFNeutralHadrCands" );
45  embedSignalPFGammaCands_ = iConfig.getParameter<bool>( "embedSignalPFGammaCands" );
46  embedIsolationPFCands_ = iConfig.getParameter<bool>( "embedIsolationPFCands" );
47  embedIsolationPFChargedHadrCands_ = iConfig.getParameter<bool>( "embedIsolationPFChargedHadrCands" );
48  embedIsolationPFNeutralHadrCands_ = iConfig.getParameter<bool>( "embedIsolationPFNeutralHadrCands" );
49  embedIsolationPFGammaCands_ = iConfig.getParameter<bool>( "embedIsolationPFGammaCands" );
50 
51  addGenMatch_ = iConfig.getParameter<bool> ( "addGenMatch" );
52 
53  if (addGenMatch_) {
54  embedGenMatch_ = iConfig.getParameter<bool> ( "embedGenMatch" );
55  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
56  genMatchSrc_.push_back(iConfig.getParameter<edm::InputTag>( "genParticleMatch" ));
57  } else {
58  genMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" );
59  }
60  }
61 
62  addGenJetMatch_ = iConfig.getParameter<bool> ( "addGenJetMatch" );
63  if(addGenJetMatch_) {
64  embedGenJetMatch_ = iConfig.getParameter<bool> ( "embedGenJetMatch" );
65  genJetMatchSrc_ = iConfig.getParameter<edm::InputTag>( "genJetMatch" );
66  }
67 
68 
69  // tau ID configurables
70  addTauID_ = iConfig.getParameter<bool> ( "addTauID" );
71  if ( addTauID_ ) {
72  // it might be a single tau ID
73  if (iConfig.existsAs<edm::InputTag>("tauIDSource")) {
74  tauIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("tauIDSource")));
75  }
76  // or there might be many of them
77  if (iConfig.existsAs<edm::ParameterSet>("tauIDSources")) {
78  // please don't configure me twice
79  if (!tauIDSrcs_.empty()) throw cms::Exception("Configuration") <<
80  "PATTauProducer: you can't specify both 'tauIDSource' and 'tauIDSources'\n";
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 
97  // IsoDeposit configurables
98  if (iConfig.exists("isoDeposits")) {
99  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
100  if ( depconf.exists("tracker") ) isoDepositLabels_.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
101  if ( depconf.exists("ecal") ) isoDepositLabels_.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
102  if ( depconf.exists("hcal") ) isoDepositLabels_.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
103  if ( depconf.exists("pfAllParticles") ) isoDepositLabels_.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
104  if ( depconf.exists("pfChargedHadron") ) isoDepositLabels_.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadron")));
105  if ( depconf.exists("pfNeutralHadron") ) isoDepositLabels_.push_back(std::make_pair(pat::PfNeutralHadronIso,depconf.getParameter<edm::InputTag>("pfNeutralHadron")));
106  if ( depconf.exists("pfGamma") ) isoDepositLabels_.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfGamma")));
107 
108  if ( depconf.exists("user") ) {
109  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
110  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
111  int key = UserBaseIso;
112  for ( ; it != ed; ++it, ++key) {
113  isoDepositLabels_.push_back(std::make_pair(IsolationKeys(key), *it));
114  }
115  }
116  }
117 
118  // Efficiency configurables
119  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
120  if (addEfficiencies_) {
122  }
123 
124  // Resolution configurables
125  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
126  if (addResolutions_) {
128  }
129 
130  // Check to see if the user wants to add user data
131  if ( useUserData_ ) {
133  }
134 
135  // produces vector of taus
136  produces<std::vector<Tau> >();
137 }
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:181
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:189
pat::helper::MultiIsolator isolator_
edm::InputTag tauSrc_
bool embedIsolationPFNeutralHadrCands_
pat::PATUserDataHelper< pat::Tau > userDataHelper_
bool embedSignalPFNeutralHadrCands_
list key
Definition: combine.py:13
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
bool embedSignalPFChargedHadrCands_
static const HistoName names[]
std::vector< NameTag > tauIDSrcs_
PATTauProducer::~PATTauProducer ( )

Definition at line 139 of file PATTauProducer.cc.

140 {
141 }

Member Function Documentation

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

Definition at line 374 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().

375 {
377  iDesc.setComment("PAT tau producer module");
378 
379  // input source
380  iDesc.add<edm::InputTag>("tauSource", edm::InputTag())->setComment("input collection");
381 
382  // embedding
383  iDesc.add<bool>("embedIsolationTracks", false)->setComment("embed external isolation tracks");
384  iDesc.add<bool>("embedLeadTrack", false)->setComment("embed external leading track");
385  iDesc.add<bool>("embedLeadTracks", false)->setComment("embed external signal tracks");
386 
387  // MC matching configurables
388  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
389  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
390  std::vector<edm::InputTag> emptySourceVector;
391  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
392  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
393  )->setComment("input with MC match information");
394 
395  // MC jet matching variables
396  iDesc.add<bool>("addGenJetMatch", true)->setComment("add MC jet matching");
397  iDesc.add<bool>("embedGenJetMatch", false)->setComment("embed MC jet matched jet information");
398  iDesc.add<edm::InputTag>("genJetMatch", edm::InputTag("tauGenJetMatch"));
399 
400 
402 
403  // tau ID configurables
404  iDesc.add<bool>("addTauID", true)->setComment("add tau ID variables");
405  edm::ParameterSetDescription tauIDSourcesPSet;
406  tauIDSourcesPSet.setAllowAnything();
407  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("tauIDSource", edm::InputTag(), true) xor
408  edm::ParameterDescription<edm::ParameterSetDescription>("tauIDSources", tauIDSourcesPSet, true)
409  )->setComment("input with electron ID variables");
410 
411  // IsoDeposit configurables
412  edm::ParameterSetDescription isoDepositsPSet;
413  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
414  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
415  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
416  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
417  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadron");
418  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadron");
419  isoDepositsPSet.addOptional<edm::InputTag>("pfGamma");
420  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
421  iDesc.addOptional("isoDeposits", isoDepositsPSet);
422 
423  // Efficiency configurables
424  edm::ParameterSetDescription efficienciesPSet;
425  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
426  iDesc.add("efficiencies", efficienciesPSet);
427  iDesc.add<bool>("addEfficiencies", false);
428 
429  // Check to see if the user wants to add user data
430  edm::ParameterSetDescription userDataPSet;
432  iDesc.addOptional("userData", userDataPSet);
433 
434  edm::ParameterSetDescription isolationPSet;
435  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
436  iDesc.add("userIsolation", isolationPSet);
437 
438 }
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 367 of file PATTauProducer.cc.

Referenced by produce().

368 {
369  edm::Ref<TauCollectionType> tauRef(tauCollection, tauIdx);
370  return (*tauIdDiscr)[tauRef];
371 }
void PATTauProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 143 of file PATTauProducer.cc.

References addGenJetMatch_, addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), addTauID_, pat::helper::MultiIsolator::beginEvent(), 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(), first, genJetMatchSrc_, genMatchSrc_, edm::Event::getByLabel(), getTauIdDiscriminator(), i, 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, python.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_, tauSrc_, userDataHelper_, and useUserData_.

144 {
145  // Get the collection of taus from the event
147  try {
148  iEvent.getByLabel(tauSrc_, anyTaus);
149  } catch (const edm::Exception &e) {
150  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.";
151  std::auto_ptr<std::vector<Tau> > patTaus(new std::vector<Tau>());
152  iEvent.put(patTaus);
153  return;
154  }
155 
156  if (iEvent.isRealData()){
157  addGenMatch_ = false;
158  embedGenMatch_ = false;
159  addGenJetMatch_ = false;
160  }
161 
162  if (isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
163 
165  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
166 
167  std::vector<edm::Handle<edm::ValueMap<IsoDeposit> > > deposits(isoDepositLabels_.size());
168  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
169  iEvent.getByLabel(isoDepositLabels_[j].second, deposits[j]);
170  }
171 
172  // prepare the MC matching
173  std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > genMatches(genMatchSrc_.size());
174  if (addGenMatch_) {
175  for (size_t j = 0, nd = genMatchSrc_.size(); j < nd; ++j) {
176  iEvent.getByLabel(genMatchSrc_[j], genMatches[j]);
177  }
178  }
179 
181  if (addGenJetMatch_) iEvent.getByLabel(genJetMatchSrc_, genJetMatch);
182 
183  std::auto_ptr<std::vector<Tau> > patTaus(new std::vector<Tau>());
184 
185  for (size_t idx = 0, ntaus = anyTaus->size(); idx < ntaus; ++idx) {
186  edm::RefToBase<reco::BaseTau> tausRef = anyTaus->refAt(idx);
187  edm::Ptr<reco::BaseTau> tausPtr = anyTaus->ptrAt(idx);
188 
189  Tau aTau(tausRef);
190  if (embedLeadTrack_) aTau.embedLeadTrack();
191  if (embedSignalTracks_) aTau.embedSignalTracks();
192  if (embedIsolationTracks_) aTau.embedIsolationTracks();
193  if (embedLeadPFCand_) {
194  if (aTau.isPFTau() )
195  aTau.embedLeadPFCand();
196  else
197  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
198  }
200  if (aTau.isPFTau() )
201  aTau.embedLeadPFChargedHadrCand();
202  else
203  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
204  }
206  if (aTau.isPFTau() )
207  aTau.embedLeadPFNeutralCand();
208  else
209  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
210  }
211  if (embedSignalPFCands_) {
212  if (aTau.isPFTau() )
213  aTau.embedSignalPFCands();
214  else
215  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
216  }
218  if (aTau.isPFTau() )
219  aTau.embedSignalPFChargedHadrCands();
220  else
221  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
222  }
224  if (aTau.isPFTau() )
225  aTau.embedSignalPFNeutralHadrCands();
226  else
227  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
228  }
230  if (aTau.isPFTau() )
231  aTau.embedSignalPFGammaCands();
232  else
233  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
234  }
236  if (aTau.isPFTau() )
237  aTau.embedIsolationPFCands();
238  else
239  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
240  }
242  if (aTau.isPFTau() )
243  aTau.embedIsolationPFChargedHadrCands();
244  else
245  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
246  }
248  if (aTau.isPFTau() )
249  aTau.embedIsolationPFNeutralHadrCands();
250  else
251  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
252  }
254  if (aTau.isPFTau() )
255  aTau.embedIsolationPFGammaCands();
256  else
257  edm::LogWarning("Type Error") << "Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
258  }
259 
260  // store the match to the generated final state muons
261  if (addGenMatch_) {
262  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
263  reco::GenParticleRef genTau = (*genMatches[i])[tausRef];
264  aTau.addGenParticleRef(genTau);
265  }
266  if (embedGenMatch_) aTau.embedGenParticle();
267  }
268 
269  // store the match to the visible part of the generated tau
270  if (addGenJetMatch_) {
271  reco::GenJetRef genJetTau = (*genJetMatch)[tausRef];
272  if (genJetTau.isNonnull() && genJetTau.isAvailable() ) {
273  aTau.setGenJet( genJetTau );
274  } // leave empty if no match found
275  }
276 
277  // prepare ID extraction
278  if ( addTauID_ ) {
279  std::vector<pat::Tau::IdPair> ids(tauIDSrcs_.size());
280  for ( size_t i = 0; i < tauIDSrcs_.size(); ++i ) {
282  iEvent.getByLabel(tauIDSrcs_[i].second, caloTauIdDiscr);
283 
285  iEvent.getByLabel(tauIDSrcs_[i].second, pfTauIdDiscr);
286 
287  if ( typeid(*tausRef) == typeid(reco::PFTau) ) {
288  //std::cout << "filling PFTauDiscriminator '" << tauIDSrcs_[i].first << "' into pat::Tau object..." << std::endl;
289  edm::Handle<reco::PFTauCollection> pfTauCollection;
290  iEvent.getByLabel(tauSrc_, pfTauCollection);
291 
293  iEvent.getByLabel(tauIDSrcs_[i].second, pfTauIdDiscr);
294 
295  ids[i].first = tauIDSrcs_[i].first;
296  ids[i].second = getTauIdDiscriminator(pfTauCollection, idx, pfTauIdDiscr);
297  } else if ( typeid(*tausRef) == typeid(reco::CaloTau) ) {
298  //std::cout << "filling CaloTauDiscriminator '" << tauIDSrcs_[i].first << "' into pat::Tau object..." << std::endl;
299  edm::Handle<reco::CaloTauCollection> caloTauCollection;
300  iEvent.getByLabel(tauSrc_, caloTauCollection);
301 
303  iEvent.getByLabel(tauIDSrcs_[i].second, caloTauIdDiscr);
304 
305  ids[i].first = tauIDSrcs_[i].first;
306  ids[i].second = getTauIdDiscriminator(caloTauCollection, idx, caloTauIdDiscr);
307  } else {
308  throw cms::Exception("Type Mismatch") <<
309  "PATTauProducer: unsupported datatype '" << typeid(*tausRef).name() << "' for tauSource\n";
310  }
311  }
312 
313  aTau.setTauIDs(ids);
314  }
315 
316  // extraction of reconstructed tau decay mode
317  // (only available for PFTaus)
318  if ( aTau.isPFTau() ) {
320  iEvent.getByLabel(tauSrc_, pfTaus);
321  reco::PFTauRef pfTauRef(pfTaus, idx);
322 
323  aTau.setDecayMode(pfTauRef->decayMode());
324  }
325 
326  // Isolation
327  if (isolator_.enabled()) {
328  isolator_.fill(*anyTaus, idx, isolatorTmpStorage_);
329  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
330  // better to loop backwards, so the vector is resized less times
331  for ( IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(),
332  ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
333  aTau.setIsolation(it->first, it->second);
334  }
335  }
336 
337  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
338  aTau.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[tausRef]);
339  }
340 
341  if (efficiencyLoader_.enabled()) {
342  efficiencyLoader_.setEfficiencies( aTau, tausRef );
343  }
344 
345  if (resolutionLoader_.enabled()) {
347  }
348 
349  if ( useUserData_ ) {
350  userDataHelper_.add( aTau, iEvent, iSetup );
351  }
352 
353  patTaus->push_back(aTau);
354  }
355 
356  // sort taus in pT
357  std::sort(patTaus->begin(), patTaus->end(), pTTauComparator_);
358 
359  // put genEvt object in Event
360  iEvent.put(patTaus);
361 
362  // clean up
364 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
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:275
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:249
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:84
bool embedIsolationPFNeutralHadrCands_
int j
Definition: DBlmapReader.cc:9
pat::PATUserDataHelper< pat::Tau > userDataHelper_
bool embedSignalPFNeutralHadrCands_
bool first
Definition: L1TdeRCT.cc:79
Analysis-level tau class.
Definition: Tau.h:51
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
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< 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 95 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 98 of file PATTauProducer.h.

Referenced by PATTauProducer().

bool pat::PATTauProducer::addTauID_
private

Definition at line 84 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

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

Definition at line 96 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 93 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

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

Definition at line 91 of file PATTauProducer.h.

Referenced by produce().

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

Definition at line 92 of file PATTauProducer.h.

Referenced by produce().

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

Definition at line 89 of file PATTauProducer.h.

Referenced by produce().

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

Definition at line 99 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

std::vector<NameTag> pat::PATTauProducer::tauIDSrcs_
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 102 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().

bool pat::PATTauProducer::useUserData_
private

Definition at line 101 of file PATTauProducer.h.

Referenced by PATTauProducer(), and produce().