CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HTTTopJetProducer.cc
Go to the documentation of this file.
4 #include "HTTTopJetProducer.h"
5 
6 #include <memory>
7 
8 using namespace edm;
9 using namespace cms;
10 using namespace reco;
11 using namespace std;
12 
13 HTTTopJetProducer::HTTTopJetProducer(edm::ParameterSet const& conf)
14  : FastjetJetProducer(conf),
15  optimalR_(false),
16  qJets_(false),
17  minFatjetPt_(200.),
18  minSubjetPt_(20.),
19  minCandPt_(200.),
20  maxFatjetAbsEta_(2.5),
21  subjetMass_(30.),
22  muCut_(0.8),
23  filtR_(0.3),
24  filtN_(5),
25  mode_(0),
26  minCandMass_(150.),
27  maxCandMass_(200.),
28  massRatioWidth_(15),
29  minM23Cut_(0.35),
30  minM13Cut_(0.2),
31  maxM13Cut_(1.3),
32  maxR_(1.5),
33  minR_(0.5),
34  rejectMinR_(false),
35  verbose_(false) {
36  // Read in all the options from the configuration
37  optimalR_ = conf.getParameter<bool>("optimalR");
38  qJets_ = conf.getParameter<bool>("qJets");
39  minFatjetPt_ = conf.getParameter<double>("minFatjetPt");
40  minSubjetPt_ = conf.getParameter<double>("minSubjetPt");
41  minCandPt_ = conf.getParameter<double>("minCandPt");
42  maxFatjetAbsEta_ = conf.getParameter<double>("maxFatjetAbsEta");
43  subjetMass_ = conf.getParameter<double>("subjetMass");
44  muCut_ = conf.getParameter<double>("muCut");
45  filtR_ = conf.getParameter<double>("filtR");
46  filtN_ = conf.getParameter<int>("filtN");
47  mode_ = conf.getParameter<int>("mode");
48  minCandMass_ = conf.getParameter<double>("minCandMass");
49  maxCandMass_ = conf.getParameter<double>("maxCandMass");
50  massRatioWidth_ = conf.getParameter<double>("massRatioWidth");
51  minM23Cut_ = conf.getParameter<double>("minM23Cut");
52  minM13Cut_ = conf.getParameter<double>("minM13Cut");
53  maxM13Cut_ = conf.getParameter<double>("maxM13Cut");
54  maxR_ = conf.getParameter<double>("maxR");
55  minR_ = conf.getParameter<double>("minR");
56  rejectMinR_ = conf.getParameter<bool>("rejectMinR");
57  verbose_ = conf.getParameter<bool>("verbose");
58 
59  // Create the tagger-wrapper
60  produces<HTTTopJetTagInfoCollection>();
61 
62  // Signal to the VirtualJetProducer that we have to add HTT information
64 
65  fjHEPTopTagger_ = std::make_unique<fastjet::HEPTopTaggerV2>(optimalR_,
66  qJets_,
68  minCandPt_,
70  muCut_,
71  filtR_,
72  filtN_,
73  mode_,
77  minM23Cut_,
78  minM13Cut_,
79  maxM13Cut_,
80  rejectMinR_);
81 }
82 
84  if (qJets_) {
86  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
87  fjHEPTopTagger_->set_rng(engine);
88  }
89 
91 }
92 
94  if (!doAreaFastjet_ && !doRhoFastjet_) {
95  fjClusterSeq_ = std::make_shared<fastjet::ClusterSequence>(fjInputs_, *fjJetDefinition_);
96  } else if (voronoiRfact_ <= 0) {
98  ClusterSequencePtr(new fastjet::ClusterSequenceArea(fjInputs_, *fjJetDefinition_, *fjAreaDefinition_));
99  } else {
101  new fastjet::ClusterSequenceVoronoiArea(fjInputs_, *fjJetDefinition_, fastjet::VoronoiAreaSpec(voronoiRfact_)));
102  }
103 
104  //Run the jet clustering
105  vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq_->inclusive_jets(minFatjetPt_);
106 
107  if (verbose_)
108  cout << "Getting central jets" << endl;
109  // Find the transient central jets
110  vector<fastjet::PseudoJet> centralJets;
111  for (unsigned int i = 0; i < inclusiveJets.size(); i++) {
112  if (inclusiveJets[i].perp() > minFatjetPt_ && fabs(inclusiveJets[i].rapidity()) < maxFatjetAbsEta_) {
113  centralJets.push_back(inclusiveJets[i]);
114  }
115  }
116 
117  fastjet::HEPTopTaggerV2& HEPTagger = *fjHEPTopTagger_;
118 
119  vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(), centralJetsEnd = centralJets.end();
120  if (verbose_)
121  cout << "Loop over jets" << endl;
122  for (; jetIt != centralJetsEnd; ++jetIt) {
123  if (verbose_)
124  cout << "CMS FJ jet pt: " << (*jetIt).perp() << endl;
125 
126  fastjet::PseudoJet taggedJet;
127 
128  taggedJet = HEPTagger.result(*jetIt);
129 
130  if (taggedJet != 0) {
131  fjJets_.push_back(taggedJet);
132  }
133  }
134 }
135 
137  const edm::EventSetup& iSetup,
139  // Set up output list
140  auto tagInfos = std::make_unique<HTTTopJetTagInfoCollection>();
141 
142  // Loop over jets
143  for (size_t ij = 0; ij != fjJets_.size(); ij++) {
144  HTTTopJetProperties properties;
146 
147  // Black magic:
148  // In the standard CA treatment the RefToBase is made from the handle directly
149  // Since we only have a OrphanHandle (the JetCollection is created by this process)
150  // we have to take the detour via the Ref
152  edm::RefToBase<reco::Jet> rtb(ref);
153 
154  fastjet::HEPTopTaggerV2Structure* s = (fastjet::HEPTopTaggerV2Structure*)fjJets_[ij].structure_non_const_ptr();
155 
156  properties.fjMass = s->fj_mass();
157  properties.fjPt = s->fj_pt();
158  properties.fjEta = s->fj_eta();
159  properties.fjPhi = s->fj_phi();
160 
161  properties.topMass = s->top_mass();
162  properties.unfilteredMass = s->unfiltered_mass();
163  properties.prunedMass = s->pruned_mass();
164  properties.fRec = s->fRec();
165  properties.massRatioPassed = s->mass_ratio_passed();
166 
167  properties.ropt = s->ropt();
168  properties.roptCalc = s->roptCalc();
169  properties.ptForRoptCalc = s->ptForRoptCalc();
170 
171  properties.tau1Unfiltered = s->Tau1Unfiltered();
172  properties.tau2Unfiltered = s->Tau2Unfiltered();
173  properties.tau3Unfiltered = s->Tau3Unfiltered();
174  properties.tau1Filtered = s->Tau1Filtered();
175  properties.tau2Filtered = s->Tau2Filtered();
176  properties.tau3Filtered = s->Tau3Filtered();
177  properties.qWeight = s->qweight();
178  properties.qEpsilon = s->qepsilon();
179  properties.qSigmaM = s->qsigmaM();
180 
181  tagInfo.insert(rtb, properties);
182  tagInfos->push_back(tagInfo);
183  }
184 
185  iEvent.put(std::move(tagInfos));
186 };
187 
190 
191  desc.add<bool>("optimalR", true);
192  desc.add<bool>("qJets", false);
193  desc.add<double>("minFatjetPt", 200.);
194  desc.add<double>("minSubjetPt", 0.);
195  desc.add<double>("minCandPt", 0.);
196  desc.add<double>("maxFatjetAbsEta", 99.);
197  desc.add<double>("subjetMass", 30.);
198  desc.add<double>("filtR", 0.3);
199  desc.add<int>("filtN", 5);
200  desc.add<int>("mode", 4);
201  desc.add<double>("minCandMass", 0.);
202  desc.add<double>("maxCandMass", 999999.);
203  desc.add<double>("massRatioWidth", 999999.);
204  desc.add<double>("minM23Cut", 0.);
205  desc.add<double>("minM13Cut", 0.);
206  desc.add<double>("maxM13Cut", 999999.);
207  desc.add<double>("maxR", 1.5);
208  desc.add<double>("minR", 0.5);
209  desc.add<bool>("rejectMinR", false);
210  desc.add<bool>("verbose", false);
211 
212  desc.add<int>("algorithm", 1); // where is it needed?
213 
217  desc.add<std::string>("jetCollInstanceName", "SubJets");
219 
220  descriptions.add("HTTTopJetProducer", desc);
221 }
222 
223 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
std::vector< fastjet::PseudoJet > fjJets_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
void insert(const edm::RefToBase< Jet > &jet, const HTTTopJetProperties &properties)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< fastjet::PseudoJet > fjInputs_
int iEvent
Definition: GenABIO.cc:224
ClusterSequencePtr fjClusterSeq_
def move
Definition: eostools.py:511
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void addHTTTopJetTagInfoCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, edm::OrphanHandle< reco::BasicJetCollection > &oh) override
static void fillDescriptionsFromFastJetProducer(edm::ParameterSetDescription &desc)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T perp() const
Magnitude of transverse component.
StreamID streamID() const
Definition: Event.h:98
std::unique_ptr< fastjet::HEPTopTaggerV2 > fjHEPTopTagger_
tuple cout
Definition: gather_cfg.py:144
AreaDefinitionPtr fjAreaDefinition_
static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription &desc)
void runAlgorithm(edm::Event &iEvent, const edm::EventSetup &iSetup) override