17 #include <boost/ptr_container/ptr_vector.hpp>
40 template<
typename Prod>
49 typedef std::vector<std::unique_ptr<CleanerEntryType> >
CleanerList;
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_.emplace_back(cleanerEntry);
96 if ( pset.
exists(
"outputSelection") ) {
98 if ( selection !=
"" ) {
104 verbosity_ = ( pset.
exists(
"verbosity") ) ?
111 template<
typename Prod>
134 template <
typename T>
137 std::ostringstream os;
140 for (
unsigned iEntry = 0; iEntry <
numEntries; ++iEntry ) {
142 if ( iEntry < (numEntries - 1) ) os <<
", ";
151 : idx_(tauRef.
key()),
157 std::cout << label <<
" (" << tauRef_.id() <<
":" << tauRef_.key() <<
", idx = " << idx_ <<
"):";
158 assert(tauRef_.key() == idx_);
159 std::cout <<
" Pt = " << tauRef_->pt() <<
", eta = " << tauRef_->eta() <<
", phi = " << tauRef_->phi() <<
", mass = " << tauRef_->mass() <<
" (decayMode = " << tauRef_->decayMode() <<
")";
162 if ( tauRef_->jetRef().isNonnull() ) {
163 std::cout <<
" Pt = " << tauRef_->jetRef()->pt() <<
", eta = " << tauRef_->jetRef()->eta() <<
", phi = " << tauRef_->jetRef()->phi()
164 <<
", mass = " << tauRef_->jetRef()->mass() <<
", area = " << tauRef_->jetRef()->jetArea();
168 const std::vector<reco::PFRecoTauChargedHadron>& signalTauChargedHadronCandidates = tauRef_->signalTauChargedHadronCandidates();
169 size_t numChargedHadrons = signalTauChargedHadronCandidates.size();
170 for (
size_t iChargedHadron = 0; iChargedHadron < numChargedHadrons; ++iChargedHadron ) {
172 std::cout <<
" chargedHadron #" << iChargedHadron <<
":" << std::endl;
175 const std::vector<reco::RecoTauPiZero>& signalPiZeroCandidates = tauRef_->signalPiZeroCandidates();
176 size_t numPiZeros = signalPiZeroCandidates.size();
177 std::cout <<
"signalPiZeroCandidates = " << numPiZeros << std::endl;
178 for (
size_t iPiZero = 0; iPiZero < numPiZeros; ++iPiZero ) {
180 std::cout <<
" piZero #" << iPiZero <<
": Pt = " << piZero.
pt() <<
", eta = " << piZero.
eta() <<
", phi = " << piZero.
phi() <<
", mass = " << piZero.
mass() << std::endl;
182 const std::vector<reco::PFCandidatePtr>& isolationPFCands = tauRef_->isolationPFCands();
183 size_t numPFCands = isolationPFCands.size();
184 std::cout <<
"isolationPFCands = " << numPFCands << std::endl;
185 for (
size_t iPFCand = 0; iPFCand < numPFCands; ++iPFCand ) {
187 std::cout <<
" pfCand #" << iPFCand <<
" (" << pfCand.
id() <<
":" << pfCand.
key() <<
"):"
188 <<
" Pt = " << pfCand->pt() <<
", eta = " << pfCand->eta() <<
", phi = " << pfCand->phi() << std::endl;
190 std::cout <<
" ranks = " << format_vT(ranks_) << std::endl;
191 std::cout <<
" tolerances = " << format_vT(tolerances_) << std::endl;
196 std::vector<float> ranks_;
197 std::vector<float> tolerances_;
200 bool isHigherRank(
const PFTauRankType* tau1,
const PFTauRankType* tau2)
207 assert(tau1->N_ == tau1->ranks_.size());
208 assert(tau1->N_ == tau2->ranks_.size());
209 assert(tau1->N_ == tau1->tolerances_.size());
210 for (
size_t i = 0;
i < tau1->N_; ++
i ) {
211 const float&
val1 = tau1->ranks_[
i];
212 const float&
val2 = tau2->ranks_[
i];
213 double av = 0.5*(val1 +
val2);
214 double thresh = av*tau1->tolerances_[
i];
215 if ( val1 < (val2 - thresh) )
return true;
216 else if ( val2 < (val1 - thresh) )
return false;
222 template<
typename Prod>
226 std::cout <<
"<RecoTauCleanerImpl::produce>:" << std::endl;
230 for (
typename CleanerList::iterator cleaner = cleaners_.begin();
231 cleaner != cleaners_.end(); ++cleaner ) {
232 (*cleaner)->plugin_->setup(evt, es);
240 std::list<PFTauRankType*> rankedTaus;
241 size_t N = inputTaus->size();
244 PFTauRankType* rankedTau =
new PFTauRankType(inputRef);
245 rankedTau->N_ = cleaners_.size();
246 rankedTau->ranks_.reserve(rankedTau->N_);
247 rankedTau->tolerances_.reserve(rankedTau->N_);
248 for (
typename CleanerList::const_iterator cleaner = cleaners_.begin();
249 cleaner != cleaners_.end(); ++cleaner ) {
250 rankedTau->ranks_.push_back((*(*cleaner)->plugin_)(inputRef));
251 rankedTau->tolerances_.push_back((*cleaner)->tolerance_);
254 std::ostringstream os;
255 os <<
"rankedTau #" <<
idx;
256 rankedTau->print(os.str());
258 rankedTaus.push_back(rankedTau);
260 rankedTaus.sort(isHigherRank);
263 typedef std::vector<reco::PFTauRef> PFTauRefs;
264 PFTauRefs dirty(inputTaus->size());
265 size_t idx_sorted = 0;
266 for ( std::list<PFTauRankType*>::const_iterator rankedTau = rankedTaus.begin();
267 rankedTau != rankedTaus.end(); ++rankedTau ) {
268 dirty[idx_sorted] = (*rankedTau)->tauRef_;
270 std::cout <<
"dirty[" << idx_sorted <<
"] = " << dirty[idx_sorted].id() <<
":" << dirty[idx_sorted].key() << std::endl;
277 PFTauRefs cleanTaus = reco::tau::cleanOverlaps<PFTauRefs, RemoveDuplicateJets>(dirty);
280 std::auto_ptr<Prod>
output(
new Prod());
284 for ( PFTauRefs::const_iterator
tau = cleanTaus.begin();
285 tau != cleanTaus.end(); ++
tau ) {
287 bool selected =
true;
288 if ( outputSelector_.get() && !(*outputSelector_)(**tau) ) {
292 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
bool operator()(const reco::PFTauRef &a, const reco::PFTauRef &b) const
#define DEFINE_FWK_MODULE(type)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
std::vector< std::unique_ptr< CleanerEntryType > > CleanerList
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
ProductID id() const
Accessor for product ID.
reco::tau::RecoTauCleanerPlugin Cleaner
std::unique_ptr< const StringCutObjectSelector< reco::PFTau > > outputSelector_
void produce(edm::Event &evt, const edm::EventSetup &es) override
virtual double phi() const
momentum azimuthal angle
Prod::value_type output_type
T get(const Candidate &c)
RecoTauCleanerImpl(const edm::ParameterSet &pset)
std::shared_ptr< Cleaner > plugin_