CMS 3D CMS Logo

GenJetTauTaggerProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PhysicsTools/NanoAOD
4 // Class: GenJetTauTaggerProducer
5 //
13 //
14 // Original Author: Elisabetta Manca
15 // Created: Wed, 08 May 2019 13:09:28 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
35 
36 
37 //
38 // class declaration
39 //
40 
42  public:
43  explicit GenJetTauTaggerProducer(const edm::ParameterSet &iConfig):
44  src_(consumes<std::vector<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src")))
45  {
46  produces<edm::ValueMap<bool>>();
47  }
48  ~GenJetTauTaggerProducer() override;
49 
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
51 
52  private:
53  void produce(edm::Event&, const edm::EventSetup&) override;
55 
56 };
57 
58 
59 
61 {
62 
63 }
64 
65 
66 //
67 // member functions
68 //
69 
70 // ------------ method called to produce the data ------------
71 void
73 {
74  using namespace edm;
75 
77  iEvent.getByToken(src_, jets);
78 
79  std::vector<bool> tags;
80 
81  for(auto jet = jets->begin(); jet != jets->end(); ++jet){
82 
83  bool found = false;
84  for(auto cand : jet->getJetConstituentsQuick()){
85  if( abs(cand->pdgId()) == 15) found = true;
86 
87  }
88  tags.push_back(found);
89  }
90 
91  std::unique_ptr<edm::ValueMap<bool>> tagsV(new edm::ValueMap<bool>());
92  edm::ValueMap<bool>::Filler fillerCorr(*tagsV);
93  fillerCorr.insert(jets,tags.begin(),tags.end());
94  fillerCorr.fill();
95  iEvent.put(std::move(tagsV));
96 }
97 
98 
99 void
101  //The following says we do not know what parameters are allowed so do no validation
102  // Please change this to state exactly what you do use, even if it is no parameters
104  desc.add<edm::InputTag>("src")->setComment("input physics object collection");
105  descriptions.addDefault(desc);
106 }
107 
108 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
vector< PseudoJet > jets
GenJetTauTaggerProducer(const edm::ParameterSet &iConfig)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
fixed size matrix
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
def move(src, dest)
Definition: eostools.py:511