35 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation") : edm::
ParameterSet(), consumesCollector(),
false) ,
36 useUserData_(iConfig.exists(
"userData"))
68 addGenJetMatch_ = iConfig.getParameter<
bool>(
"addGenJetMatch" );
70 embedGenJetMatch_ = iConfig.getParameter<
bool>(
"embedGenJetMatch" );
71 genJetMatchToken_ = consumes<edm::Association<reco::GenJetCollection> >(iConfig.getParameter<
edm::InputTag>(
"genJetMatch" ));
73 addTauJetCorrFactors_ = iConfig.getParameter<
bool>(
"addTauJetCorrFactors" );
76 addTauID_ = iConfig.getParameter<
bool>(
"addTauID" );
80 tauIDSrcs_.push_back(NameTag(
"", iConfig.getParameter<
edm::InputTag>(
"tauIDSource")));
85 if (!tauIDSrcs_.empty()){
86 throw cms::Exception(
"Configuration") <<
"PATTauProducer: you can't specify both 'tauIDSource' and 'tauIDSources'\n";
91 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
97 "PATTauProducer: id addTauID is true, you must specify either:\n" <<
98 "\tInputTag tauIDSource = <someTag>\n" <<
"or\n" <<
99 "\tPSet tauIDSources = { \n" <<
100 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
103 caloTauIDTokens_ =
edm::vector_transform(tauIDSrcs_, [
this](NameTag
const &
tag){
return mayConsume<reco::CaloTauDiscriminator>(tag.second);});
104 pfTauIDTokens_ =
edm::vector_transform(tauIDSrcs_, [
this](NameTag
const & tag){
return mayConsume<reco::PFTauDiscriminator>(tag.second);});
106 if (iConfig.exists(
"isoDeposits")) {
116 if ( depconf.
exists(
"user") ) {
117 std::vector<edm::InputTag> userdeps = depconf.
getParameter<std::vector<edm::InputTag> >(
"user");
118 std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
120 for ( ; it != ed; ++it, ++
key) {
121 isoDepositLabels_.push_back(std::make_pair(
IsolationKeys(key), *it));
125 isoDepositTokens_ =
edm::vector_transform(isoDepositLabels_, [
this](std::pair<IsolationKeys,edm::InputTag>
const &
label){
return consumes<edm::ValueMap<IsoDeposit> >(label.second);});
127 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
128 if (addEfficiencies_) {
132 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions");
133 if (addResolutions_) {
137 if ( useUserData_ ) {
141 produces<std::vector<Tau> >();
144 PATTauProducer::~PATTauProducer()
162 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.";
163 std::auto_ptr<std::vector<Tau> >
patTaus(
new std::vector<Tau>());
173 std::vector<edm::Handle<edm::ValueMap<IsoDeposit> > > deposits(
isoDepositTokens_.size());
174 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
179 std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > >genMatches(
genMatchTokens_.size());
190 std::vector<edm::ValueMap<TauJetCorrFactors> > tauJetCorrs;
195 tauJetCorrs.push_back( *tauJetCorr );
199 std::auto_ptr<std::vector<Tau> >
patTaus(
new std::vector<Tau>());
202 for (
size_t idx = 0, ntaus = anyTaus->size();
idx < ntaus; ++
idx) {
214 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
220 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
226 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
232 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
238 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
244 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
250 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
256 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
262 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made 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 from a reco::PFTau is impossible.\n";
274 edm::LogWarning(
"Type Error") <<
"Embedding a PFTau-specific information into a pat::Tau which wasn't made from a reco::PFTau is impossible.\n";
279 for (
unsigned int i=0;
i<tauJetCorrs.size(); ++
i ) {
285 std::vector<std::string> levels = tauJetCorrs[0][tausRef].correctionLabels();
286 if(
std::find(levels.begin(), levels.end(),
"L2L3Residual")!=levels.end()){
287 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L2L3Residual"));
289 else if(
std::find(levels.begin(), levels.end(),
"L3Absolute")!=levels.end()){
290 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"L3Absolute"));
293 aTau.
initializeJEC(tauJetCorrs[0][tausRef].jecLevel(
"Uncorrected"));
296 <<
"L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
297 <<
"of module " << tauJetCorrs[0][tausRef].jecSet() <<
" jets will remain"
306 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
323 std::vector<pat::Tau::IdPair> ids(
tauIDSrcs_.size());
331 iEvent.
getByToken(pfTauIDTokens_[
i], pfTauIdDiscr);
347 "PATTauProducer: unsupported datatype '" <<
typeid(*tausRef).name() <<
"' for tauSource\n";
375 aTauPFEssential.
dxy_ = tauLifetimeInfo.
dxy();
401 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
417 patTaus->push_back(aTau);
430 template <
typename TauCollectionType,
typename TauDiscrType>
434 return (*tauIdDiscr)[tauRef];
447 iDesc.
add<
bool>(
"embedIsolationTracks",
false)->setComment(
"embed external isolation tracks");
448 iDesc.
add<
bool>(
"embedLeadTrack",
false)->setComment(
"embed external leading track");
449 iDesc.
add<
bool>(
"embedLeadTracks",
false)->setComment(
"embed external signal tracks");
452 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
453 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
454 std::vector<edm::InputTag> emptySourceVector;
457 )->
setComment(
"input with MC match information");
460 iDesc.
add<
bool>(
"addGenJetMatch",
true)->setComment(
"add MC jet matching");
461 iDesc.
add<
bool>(
"embedGenJetMatch",
false)->setComment(
"embed MC jet matched jet information");
468 iDesc.
add<
bool>(
"addTauID",
true)->setComment(
"add tau ID variables");
473 )->
setComment(
"input with electron ID variables");
484 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
490 iDesc.
add(
"efficiencies", efficienciesPSet);
491 iDesc.
add<
bool>(
"addEfficiencies",
false);
500 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.
bool hasSecondaryVertex() const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
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_
static const HistoName names[]
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
bool addTauJetCorrFactors_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
void embedLeadPFChargedHadrCand()
method to store the leading charged hadron candidate internally
pat::helper::EfficiencyLoader efficiencyLoader_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
pat::helper::KinResolutionsLoader resolutionLoader_
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void embedSignalPFGammaCands()
method to store the signal gamma candidates internally
float getTauIdDiscriminator(const edm::Handle< TauCollectionType > &, size_t, const edm::Handle< TauDiscrType > &)
void embedIsolationPFCands()
method to store the isolation candidates internally
void embedIsolationPFGammaCands()
method to store the isolation gamma candidates internally
void setTauIDs(const std::vector< IdPair > &ids)
IsolationKeys
Enum defining isolation keys.
void embedSignalTracks()
method to store the signal 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 >
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_
void initializeJEC(unsigned int level, const unsigned int set=0)
initialize the jet to a given JEC level during creation starting from Uncorrected ...
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.
bool isNonnull() const
Checks for non-null.
void embedSignalPFChargedHadrCands()
method to store the signal charged hadrons candidates internally
void setComment(std::string const &value)
void embedSignalPFCands()
method to store the signal candidates internally
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< edm::View< reco::BaseTau > > baseTauToken_
bool embedIsolationPFNeutralHadrCands_
reco::PFTauTransverseImpactParameter::Vector flightLength_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void embedLeadTrack()
method to store the leading track internally
edm::EDGetTokenT< reco::CaloTauCollection > caloTauToken_
pat::PATUserDataHelper< pat::Tau > userDataHelper_
bool embedSignalPFNeutralHadrCands_
std::vector< pat::tau::TauPFEssential > pfEssential_
bool embedIsolationPFCands_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Analysis-level tau class.
void embedIsolationPFNeutralHadrCands()
method to store the isolation neutral hadrons candidates internally
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_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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.
void embedSignalPFNeutralHadrCands()
method to store the signal neutral hadrons candidates internally
edm::EDGetTokenT< edm::Association< reco::GenJetCollection > > genJetMatchToken_
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void setDecayMode(int)
set decay mode
bool embedSignalPFGammaCands_
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
void embedIsolationPFChargedHadrCands()
method to store the isolation charged hadrons candidates internally
void addJECFactors(const TauJetCorrFactors &jec)
add more sets of energy correction factors
PATTauProducer(const edm::ParameterSet &iConfig)
bool embedLeadPFNeutralCand_
bool isPFTau() const
Returns true if this pat::Tau was made from a reco::PFTau.
void setGenJet(const reco::GenJetRef &ref)
set the matched GenJet
void embedIsolationTracks()
method to store the isolation tracks internally
volatile std::atomic< bool > shutdown_flag false
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.
void embedLeadPFCand()
method to store the leading candidate internally
std::vector< NameTag > tauIDSrcs_
edm::EDGetTokenT< reco::PFTauCollection > pfTauToken_
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
GreaterByPt< Tau > pTTauComparator_
reco::PFTauTransverseImpactParameter::Point dxy_PCA_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const