CMS 3D CMS Logo

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

#include <ECFAdder.h>

Inheritance diagram for ECFAdder:
edm::stream::EDProducer<>

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

double alpha_
 
double beta_
 
std::vector< std::string > cuts_
 
std::string ecftype_
 
std::vector< unsigned > Njets_
 
std::vector< std::shared_ptr< fastjet::FunctionOfPseudoJet< double > > > routine_
 
std::vector< StringCutObjectSelector< reco::Jet > > selectors_
 
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
 

Detailed Description

Definition at line 16 of file ECFAdder.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file ECFAdder.cc.

References alpha_, beta_, cuts_, ecftype_, Exception, gen::n, Njets_, routine_, selectors_, and variables_.

9  :
10  src_(iConfig.getParameter<edm::InputTag>("src")),
12  Njets_(iConfig.getParameter<std::vector<unsigned> >("Njets")),
13  cuts_(iConfig.getParameter<std::vector<std::string>>("cuts")),
14  ecftype_(iConfig.getParameter<std::string>("ecftype")),
15  alpha_(iConfig.getParameter<double>("alpha")),
16  beta_(iConfig.getParameter<double>("beta"))
17 {
18 
19  if ( cuts_.size() != Njets_.size() ) {
20  throw cms::Exception("ConfigurationError") << "cuts and Njets must be the same size in ECFAdder" << std::endl;
21  }
22 
23  for ( std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n )
24  {
25  std::ostringstream ecfN_str;
26  std::shared_ptr<fastjet::FunctionOfPseudoJet<double> > pfunc;
27 
28  if ( ecftype_ == "ECF" || ecftype_ == "" ) {
29  ecfN_str << "ecf" << *n;
30  pfunc.reset( new fastjet::contrib::EnergyCorrelator( *n, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) );
31  }
32  else if ( ecftype_ == "C" ) {
33  ecfN_str << "ecfC" << *n;
34  pfunc.reset( new fastjet::contrib::EnergyCorrelatorCseries( *n, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) );
35  }
36  else if ( ecftype_ == "D" ) {
37  ecfN_str << "ecfD" << *n;
38  pfunc.reset( new fastjet::contrib::EnergyCorrelatorGeneralizedD2( alpha_, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) );
39  }
40  else if ( ecftype_ == "N" ) {
41  ecfN_str << "ecfN" << *n;
42  pfunc.reset( new fastjet::contrib::EnergyCorrelatorNseries( *n, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) );
43  }
44  else if ( ecftype_ == "M" ) {
45  ecfN_str << "ecfM" << *n;
46  pfunc.reset( new fastjet::contrib::EnergyCorrelatorMseries( *n, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) );
47  }
48  else if ( ecftype_ == "U" ) {
49  ecfN_str << "ecfU" << *n;
50  pfunc.reset( new fastjet::contrib::EnergyCorrelatorUseries( *n, beta_, fastjet::contrib::EnergyCorrelator::pt_R ) );
51  }
52  variables_.push_back(ecfN_str.str());
53  produces<edm::ValueMap<float> >(ecfN_str.str());
54  routine_.push_back(pfunc);
55 
56 
57 
58  selectors_.push_back( StringCutObjectSelector<reco::Jet>( cuts_[ n - Njets_.begin()] ) );
59  }
60 
61 
62 
63 }
T getParameter(std::string const &) const
std::vector< std::shared_ptr< fastjet::FunctionOfPseudoJet< double > > > routine_
Definition: ECFAdder.h:35
std::string ecftype_
Definition: ECFAdder.h:30
std::vector< StringCutObjectSelector< reco::Jet > > selectors_
Definition: ECFAdder.h:36
std::vector< std::string > variables_
Definition: ECFAdder.h:31
std::vector< std::string > cuts_
Definition: ECFAdder.h:29
double beta_
Definition: ECFAdder.h:33
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
Definition: ECFAdder.h:27
std::vector< unsigned > Njets_
Definition: ECFAdder.h:28
double alpha_
Definition: ECFAdder.h:32
edm::InputTag src_
Definition: ECFAdder.h:26

Member Function Documentation

void ECFAdder::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 137 of file ECFAdder.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, edm::ParameterSetDescription::setComment(), edm::ParameterDescriptionNode::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

138 {
140  iDesc.setComment("Energy Correlation Functions adder");
141 
142  iDesc.add<edm::InputTag>("src", edm::InputTag("no default"))->setComment("input collection");
143  iDesc.add<std::vector<unsigned> >("Njets", {1,2,3} )->setComment("Number of jets to emulate");
144  iDesc.add<std::vector<std::string>> ("cuts", {"", "", ""})->setComment("Jet selections for each N value. Size must match Njets.");
145  iDesc.add<double>("alpha",1.0)->setComment("alpha factor, only valid for N2");
146  iDesc.add<double>("beta",1.0)->setComment("angularity factor");
147  iDesc.add<std::string>("ecftype","")->setComment("ECF type: ECF or empty; C; D; N; M; U;");
148  descriptions.add("ECFAdder", iDesc);
149 }
void setComment(std::string const &value)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
float ECFAdder::getECF ( unsigned  index,
const edm::Ptr< reco::Jet > &  object 
) const

Definition at line 99 of file ECFAdder.cc.

References edm::Ptr< T >::get(), edm::Ptr< T >::isAvailable(), edm::Ptr< T >::isNonnull(), join(), gen::k, checklumidiff::l, Njets_, and routine_.

Referenced by produce().

100 {
101  std::vector<fastjet::PseudoJet> FJparticles;
102  for (unsigned k = 0; k < object->numberOfDaughters(); ++k)
103  {
104  const reco::CandidatePtr & dp = object->daughterPtr(k);
105  if ( dp.isNonnull() && dp.isAvailable() ){
106 
107  // Here, the daughters are the "end" node, so this is a PFJet
108  if ( dp->numberOfDaughters() == 0 ) {
109  FJparticles.push_back( fastjet::PseudoJet( dp->px(), dp->py(), dp->pz(), dp->energy() ) );
110  } else { // Otherwise, this is a BasicJet, so you need to descend further.
111  auto subjet = dynamic_cast<reco::Jet const * >( dp.get() );
112  for ( unsigned l = 0; l < subjet->numberOfDaughters(); ++l ) {
113  if ( subjet != nullptr ) {
114  const reco::CandidatePtr & ddp = subjet->daughterPtr(l);
115  FJparticles.push_back( fastjet::PseudoJet( ddp->px(), ddp->py(), ddp->pz(), ddp->energy() ) );
116  } else {
117  edm::LogWarning("MissingJetConstituent") << "BasicJet constituent required for ECF computation is missing!";
118  }
119  }
120  } // end if basic jet
121  } // end if daughter pointer is nonnull and available
122  else
123  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for ECF computation is missing!";
124  }
125  if ( FJparticles.size() > Njets_[index] )
126  {
127  return routine_[index]->result(join(FJparticles));
128  }
129  else
130  {
131  return -1.0;
132  }
133 }
std::vector< std::shared_ptr< fastjet::FunctionOfPseudoJet< double > > > routine_
Definition: ECFAdder.h:35
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
Base class for all types of Jets.
Definition: Jet.h:20
bool isAvailable() const
Definition: Ptr.h:258
std::vector< unsigned > Njets_
Definition: ECFAdder.h:28
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
int k[5][pyjets_maxn]
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
void ECFAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 65 of file ECFAdder.cc.

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

65  {
66  // read input collection
68  iEvent.getByToken(src_token_, jets);
69 
70  unsigned i=0;
71  for ( std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n )
72  {
73  // prepare room for output
74  std::vector<float> ecfN;
75  ecfN.reserve(jets->size());
76 
77  for ( typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin() ; jetIt != jets->end() ; ++jetIt ) {
78 
79  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
80 
81 
82  float t= -1.0;
83  if ( selectors_[n - Njets_.begin()] (*jetIt) )
84  t = getECF( i, jetPtr );
85 
86  ecfN.push_back(t);
87  }
88 
89  auto outT = std::make_unique<edm::ValueMap<float>>();
90  edm::ValueMap<float>::Filler fillerT(*outT);
91  fillerT.insert(jets, ecfN.begin(), ecfN.end());
92  fillerT.fill();
93 
94  iEvent.put(std::move(outT),variables_[i]);
95  ++i;
96  }
97 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
float getECF(unsigned index, const edm::Ptr< reco::Jet > &object) const
Definition: ECFAdder.cc:99
std::vector< StringCutObjectSelector< reco::Jet > > selectors_
Definition: ECFAdder.h:36
std::vector< std::string > variables_
Definition: ECFAdder.h:31
vector< PseudoJet > jets
edm::EDGetTokenT< edm::View< reco::Jet > > src_token_
Definition: ECFAdder.h:27
std::vector< unsigned > Njets_
Definition: ECFAdder.h:28
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::alpha_
private

Definition at line 32 of file ECFAdder.h.

Referenced by ECFAdder().

double ECFAdder::beta_
private

Definition at line 33 of file ECFAdder.h.

Referenced by ECFAdder().

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

Definition at line 29 of file ECFAdder.h.

Referenced by ECFAdder().

std::string ECFAdder::ecftype_
private

Definition at line 30 of file ECFAdder.h.

Referenced by ECFAdder().

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

Definition at line 28 of file ECFAdder.h.

Referenced by ECFAdder(), getECF(), and produce().

std::vector< std::shared_ptr<fastjet::FunctionOfPseudoJet<double> > > ECFAdder::routine_
private

Definition at line 35 of file ECFAdder.h.

Referenced by ECFAdder(), and getECF().

std::vector< StringCutObjectSelector<reco::Jet> > ECFAdder::selectors_
private

Definition at line 36 of file ECFAdder.h.

Referenced by ECFAdder(), and produce().

edm::InputTag ECFAdder::src_
private

Definition at line 26 of file ECFAdder.h.

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

Definition at line 27 of file ECFAdder.h.

Referenced by produce().

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

Definition at line 31 of file ECFAdder.h.

Referenced by ECFAdder(), and produce().