CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
RecoTauCleanerImpl< Prod > Class Template Reference
Inheritance diagram for RecoTauCleanerImpl< Prod >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

class  RemoveDuplicateJets
 

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es)
 
 RecoTauCleanerImpl (const edm::ParameterSet &pset)
 
 ~RecoTauCleanerImpl ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

typedef
reco::tau::RecoTauCleanerPlugin 
Cleaner
 
typedef boost::ptr_vector
< Cleaner
CleanerList
 
typedef Prod::value_type output_type
 

Private Attributes

CleanerList cleaners_
 
std::auto_ptr
< StringCutObjectSelector
< reco::PFTau > > 
outputSelector_
 
edm::InputTag tauSrc_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

template<typename Prod>
class RecoTauCleanerImpl< Prod >

Definition at line 38 of file RecoTauCleaner.cc.

Member Typedef Documentation

template<typename Prod >
typedef reco::tau::RecoTauCleanerPlugin RecoTauCleanerImpl< Prod >::Cleaner
private

Definition at line 39 of file RecoTauCleaner.cc.

template<typename Prod >
typedef boost::ptr_vector<Cleaner> RecoTauCleanerImpl< Prod >::CleanerList
private

Definition at line 40 of file RecoTauCleaner.cc.

template<typename Prod >
typedef Prod::value_type RecoTauCleanerImpl< Prod >::output_type
private

Definition at line 42 of file RecoTauCleaner.cc.

Constructor & Destructor Documentation

template<typename Prod >
RecoTauCleanerImpl< Prod >::RecoTauCleanerImpl ( const edm::ParameterSet pset)
explicit

Definition at line 64 of file RecoTauCleaner.cc.

References SurfaceDeformationFactory::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), and corrVsCorr::selection.

64  {
65  tauSrc_ = pset.getParameter<edm::InputTag>("src");
66  // Build our list of quality plugins
67  typedef std::vector<edm::ParameterSet> VPSet;
68  // Get each of our tau builders
69  const VPSet& cleaners = pset.getParameter<VPSet>("cleaners");
70  for (VPSet::const_iterator cleanerPSet = cleaners.begin();
71  cleanerPSet != cleaners.end(); ++cleanerPSet) {
72  // Get plugin name
73  const std::string& pluginType =
74  cleanerPSet->getParameter<std::string>("plugin");
75  // Build the plugin
76  cleaners_.push_back(
77  RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet));
78  }
79 
80  // Check if we want to apply a final output selection
81  if (pset.exists("outputSelection")) {
82  std::string selection = pset.getParameter<std::string>("outputSelection");
83  if (selection != "") {
84  outputSelector_.reset(
86  }
87  }
88 
89  // Build the predicate that ranks our taus.
90  produces<Prod>();
91 }
T getParameter(std::string const &) const
edm::InputTag tauSrc_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
selection
main part
Definition: corrVsCorr.py:98
bool exists(std::string const &parameterName) const
checks if a parameter exists
CleanerList cleaners_
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:56
template<typename Prod >
RecoTauCleanerImpl< Prod >::~RecoTauCleanerImpl ( )
inline

Definition at line 53 of file RecoTauCleaner.cc.

53 {}

Member Function Documentation

template<typename Prod >
void RecoTauCleanerImpl< Prod >::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 110 of file RecoTauCleaner.cc.

References cl, reco::tau::cleanOverlaps(), edm::Event::getByLabel(), i, getHLTprescales::index, LaserDQM_cfg::input, j, N, convertSQLitetoXML_cfg::output, edm::Event::put(), findQualityFiles::rr, edm::RefVector< C, T, F >::size(), python.multivaluedict::sort(), and metsig::tau.

111  {
112  // Update all our cleaners with the event info if they need it
113  for (CleanerList::iterator cleaner = cleaners_.begin();
114  cleaner != cleaners_.end(); ++cleaner) {
115  cleaner->setup(evt, es);
116  }
117 
118  // Get the input collection to clean
120  evt.getByLabel(tauSrc_, input);
121 
122  // Cast the input candidates to Refs to real taus
123  reco::PFTauRefVector inputRefs =
124  reco::tau::castView<reco::PFTauRefVector>(input);
125 
126  // Make an STL algorithm friendly vector of refs
127  typedef std::vector<reco::PFTauRef> PFTauRefs;
128  // Collection of all taus. Some are from the same PFJet. We must clean them.
129  PFTauRefs dirty(inputRefs.size());
130 
131  // Sort the input tau refs according to our predicate
132  auto N = inputRefs.size();
133  auto CN = cleaners_.size();
134  int index[N];
135  for (decltype(N) i=0; i!=N; ++i) index[i]=i;
136  float ranks[N*CN];
137  // auto ranks = [rr,CN](int i, int j){return rr[i*CN+j];};
138  // float const * * rr = ranks;
139  decltype(N) ii=0;
140  for (decltype(N) ir=0; ir!=N; ++ir)
141  for(decltype(N) cl=0;cl!=CN;++cl)
142  ranks[ii++]=cleaners_[cl](inputRefs[ir]);
143  assert(ii==(N*CN));
144  const float * rr = ranks;
145  std::sort(index,index+N,[rr,CN](int i, int j) { return std::lexicographical_compare(rr+i*CN,rr+i*CN+CN,rr+j*CN,rr+j*CN+CN);});
146  for (decltype(N) ir=0; ir!=N; ++ir)
147  dirty[ir]=inputRefs[index[ir]];
148 
149  // Clean the taus, ensuring that only one tau per jet is produced
150  PFTauRefs cleanTaus = reco::tau::cleanOverlaps<PFTauRefs,
151  RemoveDuplicateJets>(dirty);
152 
153  // create output collection
154  std::auto_ptr<Prod> output(new Prod());
155  //output->reserve(cleanTaus.size());
156 
157  // Copy clean refs into output
158  for (PFTauRefs::const_iterator tau = cleanTaus.begin();
159  tau != cleanTaus.end(); ++tau) {
160  // If we are applying an output selection, check if it passes
161  bool selected = true;
162  if (outputSelector_.get() && !(*outputSelector_)(**tau)) {
163  selected = false;
164  }
165  if (selected) {
166  output->push_back(convert<output_type>(*tau));
167  }
168  }
169  evt.put(output);
170 }
int i
Definition: DBlmapReader.cc:9
edm::InputTag tauSrc_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
CleanerList cleaners_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
float cl
Definition: Combine.cc:71
#define N
Definition: blowfish.cc:9
string const
Definition: compareJSON.py:14
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
Container cleanOverlaps(const Container &dirty)

Member Data Documentation

template<typename Prod >
CleanerList RecoTauCleanerImpl< Prod >::cleaners_
private

Definition at line 58 of file RecoTauCleaner.cc.

template<typename Prod >
std::auto_ptr<StringCutObjectSelector<reco::PFTau> > RecoTauCleanerImpl< Prod >::outputSelector_
private

Definition at line 60 of file RecoTauCleaner.cc.

template<typename Prod >
edm::InputTag RecoTauCleanerImpl< Prod >::tauSrc_
private

Definition at line 57 of file RecoTauCleaner.cc.