|
|
Go to the documentation of this file.
31 : isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<
edm::
ParameterSet>(
"userIsolation")
35 useUserData_(iConfig.exists(
"userData")) {
64 iConfig.
getParameter<std::vector<edm::InputTag>>(
"genParticleMatch"),
65 [
this](
edm::InputTag const&
tag) { return consumes<edm::Association<reco::GenParticleCollection>>(tag); });
76 iConfig.
getParameter<std::vector<edm::InputTag>>(
"tauJetCorrFactorsSource"),
77 [
this](
edm::InputTag const&
tag) { return mayConsume<edm::ValueMap<TauJetCorrFactors>>(tag); });
84 std::map<std::string, IDContainerData> idContainerMap;
90 if (prov_cfg_label.empty()) {
93 if (prov_cfg_label !=
"rawValues" && prov_cfg_label !=
"workingPoints" && prov_cfg_label !=
"IDdefinitions" &&
94 prov_cfg_label !=
"IDWPdefinitions" && prov_cfg_label !=
"direct_rawValues" &&
95 prov_cfg_label !=
"direct_workingPoints")
97 <<
"PATTauProducer: Parameter 'provenanceConfigLabel' does only accept 'rawValues', 'workingPoints', "
98 "'IDdefinitions', 'IDWPdefinitions', 'direct_rawValues', 'direct_workingPoints'\n";
99 std::map<std::string, IDContainerData>::iterator it;
100 it = idContainerMap.insert({
tag.label() +
tag.instance(), {
tag, std::vector<NameWPIdx>()}}).
first;
105 if (
tauIDSrcs_.empty() && idContainerMap.empty())
106 throw cms::Exception(
"Configuration") <<
"PATTauProducer: id addTauID is true, you must specify either:\n"
107 <<
"\tPSet tauIDSources = { \n"
108 <<
"\t\tInputTag <someName> = <someTag> // as many as you want \n "
111 for (
auto const& mapEntry : idContainerMap) {
120 if (iConfig.
exists(
"isoDeposits")) {
122 if (depconf.
exists(
"tracker"))
124 if (depconf.
exists(
"ecal"))
126 if (depconf.
exists(
"hcal"))
128 if (depconf.
exists(
"pfAllParticles"))
131 if (depconf.
exists(
"pfChargedHadron"))
134 if (depconf.
exists(
"pfNeutralHadron"))
137 if (depconf.
exists(
"pfGamma"))
140 if (depconf.
exists(
"user")) {
141 std::vector<edm::InputTag> userdeps = depconf.
getParameter<std::vector<edm::InputTag>>(
"user");
142 std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
144 for (; it != ed; ++it, ++
key) {
151 return consumes<edm::ValueMap<IsoDeposit>>(
label.second);
169 produces<std::vector<Tau>>();
176 if (
iEvent.isRealData()) {
187 edm::LogWarning(
"DataSource") <<
"WARNING! No Tau collection found. This missing input will not block the job. "
188 "Instead, an empty tau collection is being be produced.";
189 auto patTaus = std::make_unique<std::vector<Tau>>();
203 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
208 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection>>> genMatches(
genMatchTokens_.size());
220 std::vector<edm::ValueMap<TauJetCorrFactors>> tauJetCorrs;
225 tauJetCorrs.push_back(*tauJetCorr);
229 auto patTaus = std::make_unique<std::vector<Tau>>();
247 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
248 "from a reco::PFTau is impossible.\n";
254 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
255 "from a reco::PFTau is impossible.\n";
261 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
262 "from a reco::PFTau is impossible.\n";
268 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
269 "from a reco::PFTau is impossible.\n";
275 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
276 "from a reco::PFTau is impossible.\n";
282 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
283 "from a reco::PFTau is impossible.\n";
289 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
290 "from a reco::PFTau is impossible.\n";
296 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
297 "from a reco::PFTau is impossible.\n";
303 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
304 "from a reco::PFTau is impossible.\n";
310 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
311 "from a reco::PFTau is impossible.\n";
317 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made "
318 "from a reco::PFTau is impossible.\n";
323 for (
unsigned int i = 0;
i < tauJetCorrs.size(); ++
i) {
329 std::vector<std::string>
levels = tauJetCorrs[0][tausRef].correctionLabels();
331 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
333 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
335 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
338 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
339 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain"
348 for (
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
367 size_t numberTauIds = numberPlainTauIds;
369 numberTauIds += it.size();
373 if (numberPlainTauIds != numberTauIds &&
phID_ !=
iEvent.processHistoryID()) {
377 if (!pfTauIdDiscr.isValid())
381 std::string prov_cfg_label = idcfg.second.first.first;
382 std::string prov_ID_label = idcfg.second.first.second;
384 if (prov_cfg_label ==
"rawValues" || prov_cfg_label ==
"workingPoints") {
385 const std::vector<std::string> psetsFromProvenance =
387 .getParameter<std::vector<std::string>>(prov_cfg_label);
388 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
389 if (psetsFromProvenance[
i] == prov_ID_label) {
391 if (prov_cfg_label ==
"rawValues")
392 idcfg.second.second = -1 -
i;
394 idcfg.second.second =
i;
398 }
else if (prov_cfg_label ==
"IDdefinitions" || prov_cfg_label ==
"IDWPdefinitions") {
399 const std::vector<edm::ParameterSet> psetsFromProvenance =
401 .getParameter<std::vector<edm::ParameterSet>>(prov_cfg_label);
402 for (
size_t i = 0;
i < psetsFromProvenance.size(); ++
i) {
403 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") == prov_ID_label) {
405 if (prov_cfg_label ==
"IDdefinitions")
406 idcfg.second.second = -1 -
i;
408 idcfg.second.second =
i;
415 int i = std::stoi(prov_ID_label);
416 if (prov_cfg_label ==
"direct_rawValues")
417 idcfg.second.second = -
i;
419 idcfg.second.second =
i;
420 }
catch (std::invalid_argument
const&
e) {
421 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Direct access to ID container requested, so "
422 "argument of 'idLabel' must be convertable to int!\n";
426 throw cms::Exception(
"Configuration") <<
"PATTauProducer: Requested working point '" << prov_ID_label
427 <<
"' for ID '" << idcfg.first <<
"' not found!\n";
433 std::vector<pat::Tau::IdPair> ids(numberTauIds);
434 auto const& tausDeref = *tausRef;
438 for (
size_t i = 0;
i < numberPlainTauIds; ++
i) {
444 if (!missingDiscriminators.empty()) {
445 missingDiscriminators +=
", ";
457 if (!missingDiscriminators.empty()) {
458 missingDiscriminators +=
", ";
460 missingDiscriminators += it.first;
473 <<
"PATTauProducer: unsupported datatype '" <<
typeid(tausDeref).
name() <<
"' for tauSource\n";
476 edm::LogWarning(
"DataSource") <<
"The following tau discriminators have not been found in the event:\n"
477 << missingDiscriminators <<
"\n"
478 <<
"They will not be embedded into the pat::Tau object.\n"
479 <<
"Note: this message will be printed only at first occurence.";
501 float ecalEnergy = 0;
502 float hcalEnergy = 0;
503 float sumPhiTimesEnergy = 0.;
504 float sumEtaTimesEnergy = 0.;
505 float sumEnergy = 0.;
506 float leadChargedCandPt = -99;
507 float leadChargedCandEtaAtEcalEntrance = -99;
508 const std::vector<reco::CandidatePtr>& signalCands = pfTauRef->signalCands();
509 for (
const auto& it : signalCands) {
510 const reco::PFCandidate* icand = dynamic_cast<const reco::PFCandidate*>(it.get());
511 if (icand !=
nullptr) {
516 sumEnergy += icand->
energy();
529 if (
track->pt() > leadChargedCandPt) {
531 leadChargedCandPt =
track->pt();
538 sumEnergy += it->energy();
540 if (
track !=
nullptr) {
541 if (
track->pt() > leadChargedCandPt) {
542 leadChargedCandPt =
track->pt();
551 if (sumEnergy != 0.) {
558 float leadingTrackNormChi2 = 0;
559 float ecalEnergyLeadChargedHadrCand = -99.;
560 float hcalEnergyLeadChargedHadrCand = -99.;
561 float emFraction = -1.;
562 float myHCALenergy = 0.;
563 float myECALenergy = 0.;
566 const reco::PFCandidate* pfCandPtr = dynamic_cast<const reco::PFCandidate*>(leadingPFCharged.
get());
567 if (pfCandPtr !=
nullptr) {
568 ecalEnergyLeadChargedHadrCand = pfCandPtr->
ecalEnergy();
569 hcalEnergyLeadChargedHadrCand = pfCandPtr->
hcalEnergy();
572 leadingTrackNormChi2 = trackRef->normalizedChi2();
573 for (
const auto& isoPFCand : pfTauRef->isolationPFCands()) {
574 myHCALenergy += isoPFCand->hcalEnergy();
575 myECALenergy += isoPFCand->ecalEnergy();
577 for (
const auto& signalPFCand : pfTauRef->signalPFCands()) {
578 myHCALenergy += signalPFCand->hcalEnergy();
579 myECALenergy += signalPFCand->ecalEnergy();
581 if (myHCALenergy + myECALenergy != 0.) {
582 emFraction = myECALenergy / (myHCALenergy + myECALenergy);
587 if (packedCandPtr !=
nullptr) {
590 if (
track !=
nullptr) {
591 leadingTrackNormChi2 =
track->normalizedChi2();
608 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
613 aTauPFEssential.
ip3d_ = tauLifetimeInfo.
ip3d();
631 for (
size_t j = 0, nd =
deposits.size();
j < nd; ++
j) {
661 template <
typename TauCollectionType,
typename TauDiscrType>
666 return (*tauIdDiscr)[tauRef];
675 if ((*tauIdDiscr)[tauRef].
rawValues.size() == 1)
676 return (*tauIdDiscr)[tauRef].rawValues.at(0);
678 return (*tauIdDiscr)[tauRef].rawValues.at(-1 - wpIdx);
683 return (*tauIdDiscr)[tauRef].workingPoints.at(wpIdx);
696 iDesc.
add<
bool>(
"embedIsolationTracks",
false)->setComment(
"embed external isolation tracks");
697 iDesc.
add<
bool>(
"embedLeadTrack",
false)->setComment(
"embed external leading track");
698 iDesc.
add<
bool>(
"embedLeadTracks",
false)->setComment(
"embed external signal tracks");
701 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
702 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
703 std::vector<edm::InputTag> emptySourceVector;
707 ->
setComment(
"input with MC match information");
710 iDesc.
add<
bool>(
"addGenJetMatch",
true)->setComment(
"add MC jet matching");
711 iDesc.
add<
bool>(
"embedGenJetMatch",
false)->setComment(
"embed MC jet matched jet information");
717 iDesc.
add<
bool>(
"addTauID",
true)->setComment(
"add tau ID variables");
725 iDesc.
add<
bool>(
"skipMissingTauID",
false)
726 ->setComment(
"allow to skip a tau ID variable when not present in the event");
737 isoDepositsPSet.
addOptional<std::vector<edm::InputTag>>(
"user");
743 iDesc.
add(
"efficiencies", efficienciesPSet);
744 iDesc.
add<
bool>(
"addEfficiencies",
false);
753 iDesc.
add(
"userIsolation", isolationPSet);
reco::TrackRef trackRef() const
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
edm::EDGetTokenT< reco::PFTauCollection > pfTauToken_
void embedSignalPFCands()
method to store the signal candidates internally
Assists in assimilating all pat::UserData into pat objects.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setGenJet(const reco::GenJetRef &ref)
set the matched GenJet
PATTauProducer(const edm::ParameterSet &iConfig)
std::vector< std::vector< NameWPIdx > > tauIDSrcContainers_
float etaAtEcalEntranceLeadChargedCand_
void embedLeadPFChargedHadrCand()
method to store the leading charged hadron candidate internally
std::pair< WPCfg, int > WPIdx
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
void embedSignalPFNeutralHadrCands()
method to store the signal neutral hadrons candidates internally
bool embedIsolationPFNeutralHadrCands_
static void fillDescription(edm::ParameterSetDescription &iDesc)
bool embedIsolationTracks_
const math::XYZPointF & positionAtECALEntrance() const
void embedLeadPFNeutralCand()
method to store the leading neutral candidate internally
void setIsolation(IsolationKeys key, float value)
bool enabled() const
'true' if this there is at least one efficiency configured
T const * get() const
Returns C++ pointer to the item.
std::vector< pat::tau::TauPFEssential > pfEssential_
U second(std::pair< T, U > const &p)
void addGenParticleRef(const reco::GenParticleRef &ref)
bool embedIsolationPFGammaCands_
T const * get() const
Returns C++ pointer to the item.
bool embedLeadPFChargedHadrCand_
pat::helper::MultiIsolator isolator_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
void addJECFactors(const TauJetCorrFactors &jec)
add more sets of energy correction factors
std::vector< edm::EDGetTokenT< reco::TauDiscriminatorContainer > > pfTauIDContainerTokens_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
bool enabled() const
'true' if this there is at least one efficiency configured
edm::ProcessHistoryID phID_
bool enabled() const
True if it has a non null configuration.
bool embedSignalPFGammaCands_
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
reco::MuonRef muonRef() const
std::pair< std::string, edm::InputTag > NameTag
#define DEFINE_FWK_MODULE(type)
std::vector< std::pair< pat::IsolationKeys, edm::InputTag > > isoDepositLabels_
double flightLengthSig() const
const std::string names[nVars_]
bool isPFTau() const
Returns true if this pat::Tau was made from a reco::PFTau.
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
void embedSignalTracks()
method to store the signal tracks internally
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
std::pair< std::string, WPIdx > NameWPIdx
void initializeJEC(unsigned int level, const unsigned int set=0)
initialize the jet to a given JEC level during creation starting from Uncorrected
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
~PATTauProducer() override
void embedSignalPFGammaCands()
method to store the signal gamma candidates internally
std::vector< NameTag > tauIDSrcs_
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetMatchToken_
bool addTauJetCorrFactors_
void embedIsolationTracks()
method to store the isolation tracks internally
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 >
bool hasSecondaryVertex() const
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::pair< std::string, std::string > WPCfg
virtual const reco::Track & pseudoTrack() const
void embedIsolationPFCands()
method to store the isolation candidates internally
void setComment(std::string const &value)
reco::GsfTrackRef gsfTrackRef() const
bool embedSignalPFChargedHadrCands_
genJetMatch
switch on/off embedding of matched genJet's
pat::helper::EfficiencyLoader efficiencyLoader_
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
std::vector< edm::EDGetTokenT< reco::PFTauDiscriminator > > pfTauIDTokens_
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< edm::View< reco::BaseTau > > baseTauToken_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
bool embedSignalPFNeutralHadrCands_
bool embedIsolationPFCands_
double ip3d_error() const
void embedLeadTrack()
method to store the leading track internally
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
float leadingTrackNormChi2_
const Point & dxy_PCA() const
void embedSignalPFChargedHadrCands()
method to store the signal charged hadrons candidates internally
void setAllowAnything()
allow any parameter label/value pairs
void embedIsolationPFGammaCands()
method to store the isolation gamma candidates internally
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
void setDecayMode(int)
set decay mode
double ecalEnergy() const
return corrected Ecal energy
T getParameter(std::string const &) const
GreaterByPt< Tau > pTTauComparator_
float ecalEnergyLeadChargedHadrCand_
IsolationKeys
Enum defining isolation keys.
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
double hcalEnergy() const
return corrected Hcal energy
pat::PATUserDataHelper< pat::Tau > userDataHelper_
bool embedIsolationPFChargedHadrCands_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool embedLeadPFNeutralCand_
float getTauIdDiscriminator(const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
float getTauIdDiscriminatorFromContainer(const edm::Handle< reco::PFTauCollection > &, size_t, const edm::Handle< reco::TauDiscriminatorContainer > &, int)
bool isNonnull() const
Checks for non-null.
double energy() const final
energy
Particle reconstructed by the particle flow algorithm.
std::vector< edm::EDGetTokenT< edm::ValueMap< TauJetCorrFactors > > > tauJetCorrFactorsTokens_
pat::helper::KinResolutionsLoader resolutionLoader_
edm::EDGetTokenT< PFTauTIPAssociationByRef > tauTransverseImpactParameterToken_
edm::InputTag tauTransverseImpactParameterSrc_
void setComment(std::string const &value)
void setTauIDs(const std::vector< IdPair > &ids)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void embedIsolationPFNeutralHadrCands()
method to store the isolation neutral hadrons candidates internally
void embedIsolationPFChargedHadrCands()
method to store the isolation charged hadrons candidates internally
const Vector & flightLength() const
float hcalEnergyLeadChargedHadrCand_