33 useUserData_(iConfig.exists(
"userData"))
83 throw cms::Exception(
"Configuration") <<
"PATTauProducer: you can't specify both 'tauIDSource' and 'tauIDSources'\n";
88 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
94 "PATTauProducer: id addTauID is true, you must specify either:\n" <<
95 "\tInputTag tauIDSource = <someTag>\n" <<
"or\n" <<
96 "\tPSet tauIDSources = { \n" <<
97 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
103 if (iConfig.
exists(
"isoDeposits")) {
113 if ( depconf.
exists(
"user") ) {
114 std::vector<edm::InputTag> userdeps = depconf.
getParameter<std::vector<edm::InputTag> >(
"user");
115 std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
117 for ( ; it != ed; ++it, ++
key) {
125 if (addEfficiencies_) {
138 produces<std::vector<Tau> >();
159 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.";
160 auto patTaus = std::make_unique<std::vector<Tau>>();
171 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
176 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
187 std::vector<edm::ValueMap<TauJetCorrFactors> > tauJetCorrs;
192 tauJetCorrs.push_back( *tauJetCorr );
196 auto patTaus = std::make_unique<std::vector<Tau>>();
199 for (
size_t idx = 0, ntaus = anyTaus->size();
idx < ntaus; ++
idx) {
211 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 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 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 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 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 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 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 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 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 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
271 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
276 for (
unsigned int i=0;
i<tauJetCorrs.size(); ++
i ) {
282 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
283 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
284 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
286 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
287 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
290 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
293 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n" 294 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain" 303 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
320 std::vector<pat::Tau::IdPair> ids(
tauIDSrcs_.size());
344 "PATTauProducer: unsupported datatype '" <<
typeid(*tausRef).name() <<
"' for tauSource\n";
367 float ecalEnergy = 0;
368 float hcalEnergy = 0;
369 float sumPhiTimesEnergy = 0.;
370 float sumEtaTimesEnergy = 0.;
371 float sumEnergy = 0.;
372 float leadChargedCandPt = -99;
373 float leadChargedCandEtaAtEcalEntrance = -99;
374 const std::vector<reco::PFCandidatePtr>& signalCands = pfTauRef->signalPFCands();
375 for(std::vector<reco::PFCandidatePtr>::const_iterator it = signalCands.begin(); it != signalCands.end(); ++it) {
377 ecalEnergy += icand->ecalEnergy();
378 hcalEnergy += icand->hcalEnergy();
379 sumPhiTimesEnergy += icand->positionAtECALEntrance().phi()*icand->energy();
380 sumEtaTimesEnergy += icand->positionAtECALEntrance().eta()*icand->energy();
381 sumEnergy += icand->energy();
383 if ( icand->trackRef().
isNonnull() ) track = icand->trackRef().
get();
384 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->innerTrack().
isNonnull() ) track = icand->muonRef()->innerTrack().
get();
385 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->globalTrack().
isNonnull() ) track = icand->muonRef()->globalTrack().
get();
386 else if ( icand->muonRef().
isNonnull() && icand->muonRef()->outerTrack().
isNonnull() ) track = icand->muonRef()->outerTrack().
get();
387 else if ( icand->gsfTrackRef().
isNonnull() ) track = icand->gsfTrackRef().
get();
389 if( track->
pt() > leadChargedCandPt ) {
390 leadChargedCandEtaAtEcalEntrance = icand->positionAtECALEntrance().eta();
391 leadChargedCandPt = track->
pt();
399 if (sumEnergy != 0.) {
407 float leadingTrackNormChi2 = 0;
408 float ecalEnergyLeadChargedHadrCand = -99.;
409 float hcalEnergyLeadChargedHadrCand = -99.;
410 float emFraction = -1.;
411 float myHCALenergy = 0.;
412 float myECALenergy = 0.;
415 ecalEnergyLeadChargedHadrCand = leadingPFCharged->ecalEnergy();
416 hcalEnergyLeadChargedHadrCand = leadingPFCharged->hcalEnergy();
419 leadingTrackNormChi2 = trackRef->normalizedChi2();
420 for( std::vector<reco::PFCandidatePtr>::const_iterator tauIt = pfTauRef->isolationPFCands().begin(); tauIt!=pfTauRef->isolationPFCands().end(); ++tauIt ){
421 myHCALenergy += (*tauIt)->hcalEnergy();
422 myECALenergy += (*tauIt)->ecalEnergy();
424 for( std::vector<reco::PFCandidatePtr>::const_iterator tauIt = pfTauRef->signalPFCands().begin(); tauIt!=pfTauRef->signalPFCands().end(); ++tauIt ){
425 myHCALenergy += (*tauIt)->hcalEnergy();
426 myECALenergy += (*tauIt)->ecalEnergy();
428 if( myHCALenergy + myECALenergy != 0. ) {
429 emFraction = myECALenergy/( myHCALenergy + myECALenergy);
444 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
449 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
465 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
494 template <
typename TauCollectionType,
typename TauDiscrType>
498 return (*tauIdDiscr)[tauRef];
511 iDesc.
add<
bool>(
"embedIsolationTracks",
false)->setComment(
"embed external isolation tracks");
512 iDesc.
add<
bool>(
"embedLeadTrack",
false)->setComment(
"embed external leading track");
513 iDesc.
add<
bool>(
"embedLeadTracks",
false)->setComment(
"embed external signal tracks");
516 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
517 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
518 std::vector<edm::InputTag> emptySourceVector;
521 )->
setComment(
"input with MC match information");
524 iDesc.
add<
bool>(
"addGenJetMatch",
true)->setComment(
"add MC jet matching");
525 iDesc.
add<
bool>(
"embedGenJetMatch",
false)->setComment(
"embed MC jet matched jet information");
532 iDesc.
add<
bool>(
"addTauID",
true)->setComment(
"add tau ID variables");
537 )->
setComment(
"input with electron ID variables");
548 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
554 iDesc.
add(
"efficiencies", efficienciesPSet);
555 iDesc.
add<
bool>(
"addEfficiencies",
false);
564 iDesc.
add(
"userIsolation", isolationPSet);
bool enabled() const
'true' if this there is at least one efficiency configured
T getParameter(std::string const &) const
void setComment(std::string const &value)
Assists in assimilating all pat::UserData into pat objects.
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
std::pair< std::string, edm::InputTag > NameTag
float etaAtEcalEntranceLeadChargedCand_
bool hasSecondaryVertex() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
void setIsolation(IsolationKeys key, float value)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
void embedIsolationPFCands()
method to store the isolation candidates internally
static const HistoName names[]
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
void embedIsolationPFGammaCands()
method to store the isolation gamma candidates internally
bool addTauJetCorrFactors_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
T const * get() const
Returns C++ pointer to the item.
pat::helper::EfficiencyLoader efficiencyLoader_
void embedLeadTrack()
method to store the leading track internally
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void embedSignalPFChargedHadrCands()
method to store the signal charged hadrons candidates internally
pat::helper::KinResolutionsLoader resolutionLoader_
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
float getTauIdDiscriminator(const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
void setDecayMode(int)
set decay mode
void setTauIDs(const std::vector< IdPair > &ids)
IsolationKeys
Enum defining isolation keys.
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
const Point & dxy_PCA() const
bool enabled() const
'true' if this there is at least one efficiency configured
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
bool embedIsolationPFChargedHadrCands_
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
bool enabled() const
True if it has a non null configuration.
void setComment(std::string const &value)
void embedSignalPFCands()
method to store the signal candidates internally
double ip3d_error() const
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
double flightLengthSig() const
edm::EDGetTokenT< PFTauTIPAssociationByRef > tauTransverseImpactParameterToken_
pat::helper::MultiIsolator isolator_
const Vector & flightLength() const
edm::EDGetTokenT< edm::View< reco::BaseTau > > baseTauToken_
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
bool embedIsolationPFNeutralHadrCands_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double pt() const
track transverse momentum
edm::EDGetTokenT< reco::CaloTauCollection > caloTauToken_
pat::PATUserDataHelper< pat::Tau > userDataHelper_
genJetMatch
switch on/off embedding of matched genJet's
bool embedSignalPFNeutralHadrCands_
std::vector< pat::tau::TauPFEssential > pfEssential_
void embedIsolationPFNeutralHadrCands()
method to store the isolation neutral hadrons candidates internally
bool embedIsolationPFCands_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void embedLeadPFChargedHadrCand()
method to store the leading charged hadron candidate internally
void embedIsolationPFChargedHadrCands()
method to store the isolation charged hadrons candidates internally
bool isNonnull() const
Checks for non-null.
void setGenJet(const reco::GenJetRef &ref)
set the matched GenJet
void embedLeadPFNeutralCand()
method to store the leading neutral candidate internally
std::vector< edm::EDGetTokenT< reco::CaloTauDiscriminator > > caloTauIDTokens_
void addGenParticleRef(const reco::GenParticleRef &ref)
std::vector< edm::EDGetTokenT< edm::ValueMap< TauJetCorrFactors > > > tauJetCorrFactorsTokens_
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
edm::InputTag tauTransverseImpactParameterSrc_
bool embedIsolationTracks_
bool embedLeadPFChargedHadrCand_
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
bool embedIsolationPFGammaCands_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetMatchToken_
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void initializeJEC(unsigned int level, const unsigned int set=0)
initialize the jet to a given JEC level during creation starting from Uncorrected ...
void embedSignalPFNeutralHadrCands()
method to store the signal neutral hadrons candidates internally
bool embedSignalPFGammaCands_
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
void addJECFactors(const TauJetCorrFactors &jec)
add more sets of energy correction factors
PATTauProducer(const edm::ParameterSet &iConfig)
bool embedLeadPFNeutralCand_
float leadingTrackNormChi2_
void embedSignalTracks()
method to store the signal tracks internally
bool isPFTau() const
Returns true if this pat::Tau was made from a reco::PFTau.
void embedSignalPFGammaCands()
method to store the signal gamma candidates internally
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
float ecalEnergyLeadChargedHadrCand_
bool embedSignalPFChargedHadrCands_
std::vector< edm::EDGetTokenT< reco::PFTauDiscriminator > > pfTauIDTokens_
void embedIsolationTracks()
method to store the isolation tracks internally
std::vector< NameTag > tauIDSrcs_
edm::EDGetTokenT< reco::PFTauCollection > pfTauToken_
float hcalEnergyLeadChargedHadrCand_
GreaterByPt< Tau > pTTauComparator_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const