17 #include <boost/ptr_container/ptr_vector.hpp>
40 template<
typename Prod>
74 template<
typename Prod>
78 tau_token=consumes<reco::PFTauCollection>(tauSrc_);
80 typedef std::vector<edm::ParameterSet> VPSet;
82 const VPSet& cleaners = pset.
getParameter<VPSet>(
"cleaners");
83 for ( VPSet::const_iterator cleanerPSet = cleaners.begin();
84 cleanerPSet != cleaners.end(); ++cleanerPSet ) {
90 cleanerEntry->
tolerance_ = ( cleanerPSet->exists(
"tolerance") ) ?
91 cleanerPSet->getParameter<
double>(
"tolerance") : 0.;
92 cleaners_.push_back(cleanerEntry);
96 if ( pset.
exists(
"outputSelection") ) {
98 if ( selection !=
"" ) {
104 verbosity_ = ( pset.
exists(
"verbosity") ) ?
111 template<
typename Prod>
114 for (
typename CleanerList::const_iterator it = cleaners_.begin();
115 it != cleaners_.end(); ++it ) {
138 template <
typename T>
141 std::ostringstream os;
144 for (
unsigned iEntry = 0; iEntry <
numEntries; ++iEntry ) {
146 if ( iEntry < (numEntries - 1) ) os <<
", ";
155 : idx_(tauRef.
key()),
161 std::cout << label <<
" (" << tauRef_.id() <<
":" << tauRef_.key() <<
", idx = " << idx_ <<
"):";
162 assert(tauRef_.key() == idx_);
163 std::cout <<
" Pt = " << tauRef_->pt() <<
", eta = " << tauRef_->eta() <<
", phi = " << tauRef_->phi() <<
", mass = " << tauRef_->mass() <<
" (decayMode = " << tauRef_->decayMode() <<
")";
166 if ( tauRef_->jetRef().isNonnull() ) {
167 std::cout <<
" Pt = " << tauRef_->jetRef()->pt() <<
", eta = " << tauRef_->jetRef()->eta() <<
", phi = " << tauRef_->jetRef()->phi()
168 <<
", mass = " << tauRef_->jetRef()->mass() <<
", area = " << tauRef_->jetRef()->jetArea();
172 const std::vector<reco::PFRecoTauChargedHadron>& signalTauChargedHadronCandidates = tauRef_->signalTauChargedHadronCandidates();
173 size_t numChargedHadrons = signalTauChargedHadronCandidates.size();
174 for (
size_t iChargedHadron = 0; iChargedHadron < numChargedHadrons; ++iChargedHadron ) {
176 std::cout <<
" chargedHadron #" << iChargedHadron <<
":" << std::endl;
179 const std::vector<reco::RecoTauPiZero>& signalPiZeroCandidates = tauRef_->signalPiZeroCandidates();
180 size_t numPiZeros = signalPiZeroCandidates.size();
181 std::cout <<
"signalPiZeroCandidates = " << numPiZeros << std::endl;
182 for (
size_t iPiZero = 0; iPiZero < numPiZeros; ++iPiZero ) {
184 std::cout <<
" piZero #" << iPiZero <<
": Pt = " << piZero.
pt() <<
", eta = " << piZero.
eta() <<
", phi = " << piZero.
phi() <<
", mass = " << piZero.
mass() << std::endl;
186 const std::vector<reco::PFCandidatePtr>& isolationPFCands = tauRef_->isolationPFCands();
187 size_t numPFCands = isolationPFCands.size();
188 std::cout <<
"isolationPFCands = " << numPFCands << std::endl;
189 for (
size_t iPFCand = 0; iPFCand < numPFCands; ++iPFCand ) {
191 std::cout <<
" pfCand #" << iPFCand <<
" (" << pfCand.
id() <<
":" << pfCand.
key() <<
"):"
192 <<
" Pt = " << pfCand->pt() <<
", eta = " << pfCand->eta() <<
", phi = " << pfCand->phi() << std::endl;
194 std::cout <<
" ranks = " << format_vT(ranks_) << std::endl;
195 std::cout <<
" tolerances = " << format_vT(tolerances_) << std::endl;
200 std::vector<float> ranks_;
201 std::vector<float> tolerances_;
204 bool isHigherRank(
const PFTauRankType* tau1,
const PFTauRankType* tau2)
211 assert(tau1->N_ == tau1->ranks_.size());
212 assert(tau1->N_ == tau2->ranks_.size());
213 assert(tau1->N_ == tau1->tolerances_.size());
214 for (
size_t i = 0;
i < tau1->N_; ++
i ) {
215 const float& val1 = tau1->ranks_[
i];
216 const float& val2 = tau2->ranks_[
i];
217 double av = 0.5*(val1 + val2);
218 double thresh = av*tau1->tolerances_[
i];
219 if ( val1 < (val2 - thresh) )
return true;
220 else if ( val2 < (val1 - thresh) )
return false;
226 template<
typename Prod>
230 std::cout <<
"<RecoTauCleanerImpl::produce>:" << std::endl;
234 for (
typename CleanerList::iterator cleaner = cleaners_.begin();
235 cleaner != cleaners_.end(); ++cleaner ) {
236 (*cleaner)->plugin_->setup(evt, es);
244 std::list<PFTauRankType*> rankedTaus;
245 size_t N = inputTaus->size();
248 PFTauRankType* rankedTau =
new PFTauRankType(inputRef);
249 rankedTau->N_ = cleaners_.size();
250 rankedTau->ranks_.reserve(rankedTau->N_);
251 rankedTau->tolerances_.reserve(rankedTau->N_);
252 for (
typename CleanerList::const_iterator cleaner = cleaners_.begin();
253 cleaner != cleaners_.end(); ++cleaner ) {
254 rankedTau->ranks_.push_back((*(*cleaner)->plugin_)(inputRef));
255 rankedTau->tolerances_.push_back((*cleaner)->tolerance_);
258 std::ostringstream os;
259 os <<
"rankedTau #" <<
idx;
260 rankedTau->print(os.str());
262 rankedTaus.push_back(rankedTau);
264 rankedTaus.sort(isHigherRank);
267 typedef std::vector<reco::PFTauRef> PFTauRefs;
268 PFTauRefs dirty(inputTaus->size());
269 size_t idx_sorted = 0;
270 for ( std::list<PFTauRankType*>::const_iterator rankedTau = rankedTaus.begin();
271 rankedTau != rankedTaus.end(); ++rankedTau ) {
272 dirty[idx_sorted] = (*rankedTau)->tauRef_;
274 std::cout <<
"dirty[" << idx_sorted <<
"] = " << dirty[idx_sorted].id() <<
":" << dirty[idx_sorted].key() << std::endl;
281 PFTauRefs cleanTaus = reco::tau::cleanOverlaps<PFTauRefs, RemoveDuplicateJets>(dirty);
284 std::auto_ptr<Prod>
output(
new Prod());
288 for ( PFTauRefs::const_iterator
tau = cleanTaus.begin();
289 tau != cleanTaus.end(); ++
tau ) {
291 bool selected =
true;
292 if ( outputSelector_.get() && !(*outputSelector_)(**tau) ) {
296 output->push_back(convert<output_type>(*
tau));
T getParameter(std::string const &) const
RecoTauCleanerImpl< reco::PFTauRefVector > RecoTauRefCleaner
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
#define DEFINE_FWK_MODULE(type)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
bool operator()(const reco::PFTauRef &a, const reco::PFTauRef &b)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
RecoTauCleanerImpl< reco::PFTauCollection > RecoTauCleaner
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
edm::EDGetTokenT< reco::PFTauCollection > tau_token
void print(std::ostream &stream=std::cout) const
virtual double mass() const
mass
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Long64_t numEntries(TFile *hdl, std::string const &trname)
Container::value_type value_type
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
ProductID id() const
Accessor for product ID.
reco::tau::RecoTauCleanerPlugin Cleaner
void produce(edm::Event &evt, const edm::EventSetup &es) override
boost::shared_ptr< Cleaner > plugin_
virtual double phi() const
momentum azimuthal angle
Prod::value_type output_type
std::vector< CleanerEntryType * > CleanerList
T get(const Candidate &c)
RecoTauCleanerImpl(const edm::ParameterSet &pset)