CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ECFAdder Class Reference

#include <ECFAdder.h>

Inheritance diagram for ECFAdder:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ECFAdder (const edm::ParameterSet &iConfig)
 
float getECF (unsigned index, const edm::Ptr< reco::Jet > &object) const
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double beta_
 
std::vector< unsigned > Njets_
 
std::vector< std::auto_ptr< fastjet::contrib::EnergyCorrelator > > routine_
 
edm::InputTag src_
 
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
 
std::vector< std::string > variables_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 15 of file ECFAdder.h.

Constructor & Destructor Documentation

ECFAdder::ECFAdder ( const edm::ParameterSet iConfig)
explicit

Definition at line 6 of file ECFAdder.cc.

References beta_, gen::n, Njets_, routine_, and variables_.

6  :
7  src_(iConfig.getParameter<edm::InputTag>("src")),
9  Njets_(iConfig.getParameter<std::vector<unsigned> >("Njets")),
10  beta_(iConfig.getParameter<double>("beta"))
11 {
12  for ( std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n )
13  {
14  std::ostringstream ecfN_str;
15  ecfN_str << "ecf" << *n;
16  variables_.push_back(ecfN_str.str());
17  produces<edm::ValueMap<float> >(ecfN_str.str().c_str());
18  routine_.push_back(std::auto_ptr<fastjet::contrib::EnergyCorrelator> ( new fastjet::contrib::EnergyCorrelator( *n, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) ));
19  }
20 }
T getParameter(std::string const &) const
std::vector< std::string > variables_
Definition: ECFAdder.h:26
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
double beta_
Definition: ECFAdder.h:27
std::vector< std::auto_ptr< fastjet::contrib::EnergyCorrelator > > routine_
Definition: ECFAdder.h:29
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
Definition: ECFAdder.h:24
std::vector< unsigned > Njets_
Definition: ECFAdder.h:25
edm::InputTag src_
Definition: ECFAdder.h:23

Member Function Documentation

float ECFAdder::getECF ( unsigned  index,
const edm::Ptr< reco::Jet > &  object 
) const

Definition at line 53 of file ECFAdder.cc.

References DEFINE_FWK_MODULE, reco::dp, diffTreeTool::index, edm::Ptr< T >::isAvailable(), edm::Ptr< T >::isNonnull(), gen::k, and routine_.

Referenced by produce().

54 {
55  std::vector<fastjet::PseudoJet> FJparticles;
56  for (unsigned k = 0; k < object->numberOfDaughters(); ++k)
57  {
58  const reco::CandidatePtr & dp = object->daughterPtr(k);
59  if ( dp.isNonnull() && dp.isAvailable() )
60  FJparticles.push_back( fastjet::PseudoJet( dp->px(), dp->py(), dp->pz(), dp->energy() ) );
61  else
62  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for ECF computation is missing!";
63  }
64  fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, 999);
65  fastjet::ClusterSequence thisClustering_basic(FJparticles, jetDef);
66  std::vector<fastjet::PseudoJet> out_jets_basic = thisClustering_basic.inclusive_jets(0);
67  if(out_jets_basic.size()!=1) return -1;
68  return routine_[index]->result(out_jets_basic[0]);
69 }
bool isAvailable() const
Definition: Ptr.h:259
std::vector< std::auto_ptr< fastjet::contrib::EnergyCorrelator > > routine_
Definition: ECFAdder.h:29
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
int k[5][pyjets_maxn]
auto dp
Definition: deltaR.h:22
void ECFAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 22 of file ECFAdder.cc.

References edm::Event::getByToken(), getECF(), mps_fire::i, fwrapper::jets, eostools::move(), gen::n, Njets_, edm::Event::put(), src_token_, lumiQTWidget::t, and variables_.

22  {
23  // read input collection
25  iEvent.getByToken(src_token_, jets);
26 
27  unsigned i=0;
28  for ( std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n )
29  {
30  // prepare room for output
31  std::vector<float> ecfN;
32  ecfN.reserve(jets->size());
33 
34  for ( typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin() ; jetIt != jets->end() ; ++jetIt ) {
35 
36  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
37 
38  float t=getECF( i, jetPtr );
39 
40  ecfN.push_back(t);
41  }
42 
43  auto outT = std::make_unique<edm::ValueMap<float>>();
44  edm::ValueMap<float>::Filler fillerT(*outT);
45  fillerT.insert(jets, ecfN.begin(), ecfN.end());
46  fillerT.fill();
47 
48  iEvent.put(std::move(outT),variables_[i].c_str());
49  ++i;
50  }
51 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
float getECF(unsigned index, const edm::Ptr< reco::Jet > &object) const
Definition: ECFAdder.cc:53
std::vector< std::string > variables_
Definition: ECFAdder.h:26
vector< PseudoJet > jets
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
Definition: ECFAdder.h:24
std::vector< unsigned > Njets_
Definition: ECFAdder.h:25
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

double ECFAdder::beta_
private

Definition at line 27 of file ECFAdder.h.

Referenced by ECFAdder().

std::vector<unsigned> ECFAdder::Njets_
private

Definition at line 25 of file ECFAdder.h.

Referenced by ECFAdder(), and produce().

std::vector<std::auto_ptr<fastjet::contrib::EnergyCorrelator> > ECFAdder::routine_
private

Definition at line 29 of file ECFAdder.h.

Referenced by ECFAdder(), and getECF().

edm::InputTag ECFAdder::src_
private

Definition at line 23 of file ECFAdder.h.

edm::EDGetTokenT<edm::View<reco::Jet> > ECFAdder::src_token_
private

Definition at line 24 of file ECFAdder.h.

Referenced by produce().

std::vector<std::string> ECFAdder::variables_
private

Definition at line 26 of file ECFAdder.h.

Referenced by ECFAdder(), and produce().