CMS 3D CMS Logo

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