CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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 reco::dp, cmsHarvester::index, edm::Ptr< T >::isAvailable(), edm::Ptr< T >::isNonnull(), relval_2017::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
auto dp
Definition: deltaR.h:22
void ECFAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 22 of file ECFAdder.cc.

References edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), getECF(), i, edm::helper::Filler< Map >::insert(), fwrapper::jets, 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  std::auto_ptr<edm::ValueMap<float> > outT(new 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(outT,variables_[i].c_str());
49  ++i;
50  }
51 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
float getECF(unsigned index, const edm::Ptr< reco::Jet > &object) const
Definition: ECFAdder.cc:53
std::vector< std::string > variables_
Definition: ECFAdder.h:26
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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:81

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().