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  // prepare room for output
12  std::vector<float> tau1; tau1.reserve(jets->size());
13  std::vector<float> tau2; tau2.reserve(jets->size());
14  std::vector<float> tau3; tau3.reserve(jets->size());
15 
16  for ( typename edm::View<reco::PFJet>::const_iterator jetIt = jets->begin() ; jetIt != jets->end() ; ++jetIt ) {
17  reco::PFJet newCand(*jetIt);
18  edm::Ptr<reco::PFJet> jetPtr = jets->ptrAt(jetIt - jets->begin());
19 
20  float t1=getTau(1, jetPtr );
21  float t2=getTau(2, jetPtr );
22  float t3=getTau(3, jetPtr );
23 
24  tau1.push_back(t1);
25  tau2.push_back(t2);
26  tau3.push_back(t3);
27  }
28 
29  std::auto_ptr<edm::ValueMap<float> > outT1(new edm::ValueMap<float>());
30  std::auto_ptr<edm::ValueMap<float> > outT2(new edm::ValueMap<float>());
31  std::auto_ptr<edm::ValueMap<float> > outT3(new edm::ValueMap<float>());
32  edm::ValueMap<float>::Filler fillerT1(*outT1);
33  edm::ValueMap<float>::Filler fillerT2(*outT2);
34  edm::ValueMap<float>::Filler fillerT3(*outT3);
35  fillerT1.insert(jets, tau1.begin(), tau1.end());
36  fillerT2.insert(jets, tau2.begin(), tau2.end());
37  fillerT3.insert(jets, tau3.begin(), tau3.end());
38  fillerT1.fill();
39  fillerT2.fill();
40  fillerT3.fill();
41 
42  iEvent.put(outT1,"tau1");
43  iEvent.put(outT2,"tau2");
44  iEvent.put(outT3,"tau3");
45 }
46 
48 {
49  std::vector<const reco::PFCandidate*> all_particles;
50  for (unsigned k =0; k < object->getPFConstituents().size(); k++)
51  all_particles.push_back( object->getPFConstituent(k).get() );
52 
53  std::vector<fastjet::PseudoJet> FJparticles;
54  for (unsigned particle = 0; particle < all_particles.size(); particle++){
55  const reco::PFCandidate *thisParticle = all_particles.at(particle);
56  FJparticles.push_back( fastjet::PseudoJet( thisParticle->px(), thisParticle->py(), thisParticle->pz(), thisParticle->energy() ) );
57  }
58  fastjet::contrib::NsubParameters paraNsub = fastjet::contrib::NsubParameters(1.0, cone_); //assume R=0.7 jet clusering used
59  fastjet::contrib::Njettiness routine(fastjet::contrib::Njettiness::onepass_kt_axes, paraNsub);
60  return routine.getTau(num, FJparticles);
61 }
62 
63 
64 
virtual double energy() const GCC11_FINAL
energy
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
Jets made from PFObjects.
Definition: PFJet.h:21
int iEvent
Definition: GenABIO.cc:230
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
vector< PseudoJet > jets
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
int k[5][pyjets_maxn]
float getTau(int num, edm::Ptr< reco::PFJet > object) const
edm::EDGetTokenT< edm::View< reco::PFJet > > src_token_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)