CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NjettinessAdder.cc
Go to the documentation of this file.
2 #include "fastjet/contrib/Njettiness.hh"
3 
5 
7  // read input collection
9  iEvent.getByToken(src_token_, jets);
10 
11  for ( std::vector<unsigned>::const_iterator n = Njets_.begin(); n != Njets_.end(); ++n )
12  {
13  std::ostringstream tauN_str;
14  tauN_str << "tau" << *n;
15 
16  // prepare room for output
17  std::vector<float> tauN;
18  tauN.reserve(jets->size());
19 
20  for ( typename edm::View<reco::Jet>::const_iterator jetIt = jets->begin() ; jetIt != jets->end() ; ++jetIt ) {
21 
22  edm::Ptr<reco::Jet> jetPtr = jets->ptrAt(jetIt - jets->begin());
23 
24  float t=getTau( *n, jetPtr );
25 
26  tauN.push_back(t);
27  }
28 
29  std::auto_ptr<edm::ValueMap<float> > outT(new edm::ValueMap<float>());
30  edm::ValueMap<float>::Filler fillerT(*outT);
31  fillerT.insert(jets, tauN.begin(), tauN.end());
32  fillerT.fill();
33 
34  iEvent.put(outT,tauN_str.str().c_str());
35  }
36 }
37 
38 float NjettinessAdder::getTau(unsigned num, const edm::Ptr<reco::Jet> & object) const
39 {
40  std::vector<fastjet::PseudoJet> FJparticles;
41  for (unsigned k = 0; k < object->numberOfDaughters(); ++k)
42  {
43  const reco::CandidatePtr & dp = object->daughterPtr(k);
44  if ( dp.isNonnull() && dp.isAvailable() )
45  FJparticles.push_back( fastjet::PseudoJet( dp->px(), dp->py(), dp->pz(), dp->energy() ) );
46  else
47  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
48  }
49 
50  fastjet::contrib::NsubParameters paraNsub = fastjet::contrib::NsubParameters(1.0, cone_);
51  fastjet::contrib::Njettiness routine(fastjet::contrib::Njettiness::onepass_kt_axes, paraNsub);
52  return routine.getTau(num, FJparticles);
53 }
54 
55 
56 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
const std::vector< unsigned > Njets_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool isAvailable() const
Definition: Ptr.h:158
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
const double cone_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
vector< PseudoJet > jets
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
int k[5][pyjets_maxn]
float getTau(unsigned num, const edm::Ptr< reco::Jet > &object) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
const edm::EDGetTokenT< edm::View< reco::Jet > > src_token_