CMS 3D CMS Logo

VirtualJetProducer.cc
Go to the documentation of this file.
1 //
3 // VirtualJetProducer
4 // ------------------
5 //
6 // 04/21/2009 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
8 
14 
18 
27 
42 
43 #include "fastjet/SISConePlugin.hh"
44 #include "fastjet/CMSIterativeConePlugin.hh"
45 #include "fastjet/ATLASConePlugin.hh"
46 #include "fastjet/CDFMidPointPlugin.hh"
47 
48 #include <iostream>
49 #include <memory>
50 #include <algorithm>
51 #include <limits>
52 #include <cmath>
53 #include <vdt/vdtMath.h>
54 
55 using namespace std;
56 using namespace edm;
57 
58 
59 namespace reco {
60  namespace helper {
62  bool operator()( const fastjet::PseudoJet & t1, const fastjet::PseudoJet & t2 ) const {
63  return t1.perp2() > t2.perp2();
64  }
65  };
66 
67  }
68 }
69 
70 //______________________________________________________________________________
71 const char *const VirtualJetProducer::JetType::names[] = {
72  "BasicJet","GenJet","CaloJet","PFJet","TrackJet","PFClusterJet"
73 };
74 
75 
76 //______________________________________________________________________________
79 {
80  const char *const *pos = std::find(names, names + LastJetType, name);
81  if (pos == names + LastJetType) {
82  std::string errorMessage="Requested jetType not supported: "+name+"\n";
83  throw cms::Exception("Configuration",errorMessage);
84  }
85  return (Type)(pos-names);
86 }
87 
88 
90 {
91 
92 
93  if ( writeCompound_ ) {
94  produces<reco::BasicJetCollection>();
95  }
96 
97  if ( writeJetsWithConst_ ) {
98  produces<reco::PFCandidateCollection>(tag).setBranchAlias(alias);
99  produces<reco::PFJetCollection>();
100  } else {
101  if (makeCaloJet(jetTypeE)) {
102  produces<reco::CaloJetCollection>(tag).setBranchAlias(alias);
103  }
104  else if (makePFJet(jetTypeE)) {
105  produces<reco::PFJetCollection>(tag).setBranchAlias(alias);
106  }
107  else if (makeGenJet(jetTypeE)) {
108  produces<reco::GenJetCollection>(tag).setBranchAlias(alias);
109  }
110  else if (makeTrackJet(jetTypeE)) {
111  produces<reco::TrackJetCollection>(tag).setBranchAlias(alias);
112  }
113  else if (makePFClusterJet(jetTypeE)) {
114  produces<reco::PFClusterJetCollection>(tag).setBranchAlias(alias);
115  }
116  else if (makeBasicJet(jetTypeE)) {
117  produces<reco::BasicJetCollection>(tag).setBranchAlias(alias);
118  }
119  }
120 }
121 
123 // construction / destruction
125 
126 //______________________________________________________________________________
128 
129  moduleLabel_ = iConfig.getParameter<string> ("@module_label");
130  src_ = iConfig.getParameter<edm::InputTag>("src");
131  srcPVs_ = iConfig.getParameter<edm::InputTag>("srcPVs");
132  jetType_ = iConfig.getParameter<string> ("jetType");
133  jetAlgorithm_ = iConfig.getParameter<string> ("jetAlgorithm");
134  rParam_ = iConfig.getParameter<double> ("rParam");
135  inputEtMin_ = iConfig.getParameter<double> ("inputEtMin");
136  inputEMin_ = iConfig.getParameter<double> ("inputEMin");
137  jetPtMin_ = iConfig.getParameter<double> ("jetPtMin");
138  doPVCorrection_ = iConfig.getParameter<bool> ("doPVCorrection");
139  doAreaFastjet_ = iConfig.getParameter<bool> ("doAreaFastjet");
140  doRhoFastjet_ = iConfig.getParameter<bool> ("doRhoFastjet");
141  jetCollInstanceName_ = iConfig.getParameter<string> ("jetCollInstanceName");
142  doPUOffsetCorr_ = iConfig.getParameter<bool> ("doPUOffsetCorr");
143  puSubtractorName_ = iConfig.getParameter<string> ("subtractorName");
144  useExplicitGhosts_ = iConfig.getParameter<bool> ("useExplicitGhosts"); // use explicit ghosts in the fastjet clustering sequence?
145  doAreaDiskApprox_ = iConfig.getParameter<bool> ("doAreaDiskApprox");
146  voronoiRfact_ = iConfig.getParameter<double> ("voronoiRfact"); // Voronoi-based area calculation allows for an empirical scale factor
147  rhoEtaMax_ = iConfig.getParameter<double> ("Rho_EtaMax"); // do fasjet area / rho calcluation? => accept corresponding parameters
148  ghostEtaMax_ = iConfig.getParameter<double> ("Ghost_EtaMax");
149  activeAreaRepeats_ = iConfig.getParameter<int> ("Active_Area_Repeats");
150  ghostArea_ = iConfig.getParameter<double> ("GhostArea");
151  restrictInputs_ = iConfig.getParameter<bool> ("restrictInputs"); // restrict inputs to first "maxInputs" towers?
152  maxInputs_ = iConfig.getParameter<unsigned int>("maxInputs");
153  writeCompound_ = iConfig.getParameter<bool> ("writeCompound"); // Check to see if we are writing compound jets for substructure and jet grooming
154  writeJetsWithConst_ = iConfig.getParameter<bool>("writeJetsWithConst"); //write subtracted jet constituents
155  doFastJetNonUniform_ = iConfig.getParameter<bool> ("doFastJetNonUniform");
156  puCenters_ = iConfig.getParameter<vector<double> >("puCenters");
157  puWidth_ = iConfig.getParameter<double> ("puWidth");
158  nExclude_ = iConfig.getParameter<unsigned int>("nExclude");
159  useDeterministicSeed_ = iConfig.getParameter<bool> ("useDeterministicSeed");
160  minSeed_ = iConfig.getParameter<unsigned int>("minSeed");
161  verbosity_ = iConfig.getParameter<int> ("verbosity");
162 
163  anomalousTowerDef_ = auto_ptr<AnomalousTower>(new AnomalousTower(iConfig));
164 
165  input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
166  input_candidateview_token_ = consumes<reco::CandidateView>(src_);
167  input_candidatefwdptr_token_ = consumes<vector<edm::FwdPtr<reco::PFCandidate> > >(iConfig.getParameter<edm::InputTag>("src"));
168  input_packedcandidatefwdptr_token_ = consumes<vector<edm::FwdPtr<pat::PackedCandidate> > >(iConfig.getParameter<edm::InputTag>("src"));
169  input_gencandidatefwdptr_token_ = consumes<vector<edm::FwdPtr<reco::GenParticle> > >(iConfig.getParameter<edm::InputTag>("src"));
170  input_packedgencandidatefwdptr_token_ = consumes<vector<edm::FwdPtr<pat::PackedGenParticle> > >(iConfig.getParameter<edm::InputTag>("src"));
171 
172  //
173  // additional parameters to think about:
174  // - overlap threshold (set to 0.75 for the time being)
175  // - p parameter for generalized kT (set to -2 for the time being)
176  // - fastjet PU subtraction parameters (not yet considered)
177  //
178  if (jetAlgorithm_=="Kt")
179  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(fastjet::kt_algorithm,rParam_));
180 
181  else if (jetAlgorithm_=="CambridgeAachen")
182  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(fastjet::cambridge_algorithm,rParam_) );
183 
184  else if (jetAlgorithm_=="AntiKt")
185  fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(fastjet::antikt_algorithm,rParam_) );
186 
187  else if (jetAlgorithm_=="GeneralizedKt")
188  fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(fastjet::genkt_algorithm,rParam_,-2) );
189 
190  else if (jetAlgorithm_=="SISCone") {
191 
192  fjPlugin_ = PluginPtr( new fastjet::SISConePlugin(rParam_,0.75,0,0.0,false,fastjet::SISConePlugin::SM_pttilde) );
193  fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(&*fjPlugin_) );
194 
195  } else if (jetAlgorithm_=="IterativeCone") {
196 
197  fjPlugin_ = PluginPtr(new fastjet::CMSIterativeConePlugin(rParam_,1.0));
198  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
199 
200  } else if (jetAlgorithm_=="CDFMidPoint") {
201 
202  fjPlugin_ = PluginPtr(new fastjet::CDFMidPointPlugin(rParam_,0.75));
203  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
204 
205  } else if (jetAlgorithm_=="ATLASCone") {
206 
207  fjPlugin_ = PluginPtr(new fastjet::ATLASConePlugin(rParam_));
208  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
209 
210  } else {
211  throw cms::Exception("Invalid jetAlgorithm") <<"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
212  }
213 
214  jetTypeE=JetType::byName(jetType_);
215 
216  if ( doPUOffsetCorr_ ) {
217  if(puSubtractorName_.empty()){
218  LogWarning("VirtualJetProducer") << "Pile Up correction on; however, pile up type is not specified. Using default... \n";
219  subtractor_ = boost::shared_ptr<PileUpSubtractor>(new PileUpSubtractor(iConfig, consumesCollector()));
220  } else subtractor_ = boost::shared_ptr<PileUpSubtractor>(
221  PileUpSubtractorFactory::get()->create( puSubtractorName_, iConfig, consumesCollector()));
222  }
223 
224  // do approximate disk-based area calculation => warn if conflicting request
225  if (doAreaDiskApprox_ && doAreaFastjet_)
226  throw cms::Exception("Conflicting area calculations") << "Both the calculation of jet area via fastjet and via an analytical disk approximation have been requested. Please decide on one.\n";
227 
228  if ( doAreaFastjet_ || doRhoFastjet_ ) {
229 
230  if (voronoiRfact_ <= 0) {
231  fjActiveArea_ = ActiveAreaSpecPtr(new fastjet::GhostedAreaSpec(ghostEtaMax_,activeAreaRepeats_,ghostArea_));
232 
233 
234  if ( !useExplicitGhosts_ ) {
235  fjAreaDefinition_ = AreaDefinitionPtr( new fastjet::AreaDefinition(fastjet::active_area, *fjActiveArea_ ) );
236  } else {
237  fjAreaDefinition_ = AreaDefinitionPtr( new fastjet::AreaDefinition(fastjet::active_area_explicit_ghosts, *fjActiveArea_ ) );
238  }
239  }
240  fjSelector_ = SelectorPtr( new fastjet::Selector( fastjet::SelectorAbsRapMax(rhoEtaMax_) ) );
241  }
242 
243  if( ( doFastJetNonUniform_ ) && ( puCenters_.empty() ) )
244  throw cms::Exception("doFastJetNonUniform") << "Parameter puCenters for doFastJetNonUniform is not defined." << std::endl;
245 
246  // make the "produces" statements
247  makeProduces( moduleLabel_, jetCollInstanceName_ );
248  produces<vector<double> >("rhos");
249  produces<vector<double> >("sigmas");
250  produces<double>("rho");
251  produces<double>("sigma");
252 
253 
254 }
255 
256 //______________________________________________________________________________
258 {
259 }
260 
261 
263 // implementation of member functions
265 
266 //______________________________________________________________________________
268 {
269 
270  // If requested, set the fastjet random seed to a deterministic function
271  // of the run/lumi/event.
272  // NOTE!!! The fastjet random number sequence is a global singleton.
273  // Thus, we have to create an object and get access to the global singleton
274  // in order to change it.
275  if ( useDeterministicSeed_ ) {
276  fastjet::GhostedAreaSpec gas;
277  std::vector<int> seeds(2);
278  unsigned int runNum_uint = static_cast <unsigned int> (iEvent.id().run());
279  unsigned int evNum_uint = static_cast <unsigned int> (iEvent.id().event());
280  seeds[0] = std::max(runNum_uint,minSeed_ + 3) + 3 * evNum_uint;
281  seeds[1] = std::max(runNum_uint,minSeed_ + 5) + 5 * evNum_uint;
282  gas.set_random_status(seeds);
283  }
284 
285  LogDebug("VirtualJetProducer") << "Entered produce\n";
286  //determine signal vertex2
287  vertex_=reco::Jet::Point(0,0,0);
288  if ( (makeCaloJet(jetTypeE) || makePFJet(jetTypeE)) &&doPVCorrection_) {
289  LogDebug("VirtualJetProducer") << "Adding PV info\n";
291  iEvent.getByToken(input_vertex_token_ , pvCollection);
292  if (!pvCollection->empty()) vertex_=pvCollection->begin()->position();
293  }
294 
295  // For Pileup subtraction using offset correction:
296  // set up geometry map
297  if ( doPUOffsetCorr_ ) {
298  subtractor_->setupGeometryMap(iEvent, iSetup);
299  }
300 
301  // clear data
302  LogDebug("VirtualJetProducer") << "Clear data\n";
303  fjInputs_.clear();
304  fjJets_.clear();
305  inputs_.clear();
306 
307  // get inputs and convert them to the fastjet format (fastjet::PeudoJet)
309 
311  edm::Handle< std::vector<edm::FwdPtr<pat::PackedCandidate> > > packedinputsHandleAsFwdPtr;
312  edm::Handle< std::vector<edm::FwdPtr<reco::GenParticle> > > geninputsHandleAsFwdPtr;
313  edm::Handle< std::vector<edm::FwdPtr<pat::PackedGenParticle> > > packedgeninputsHandleAsFwdPtr;
314 
315  bool isView = iEvent.getByToken(input_candidateview_token_, inputsHandle);
316  if ( isView ) {
317  if ( inputsHandle->empty()) {
318  output( iEvent, iSetup );
319  return;
320  }
321  for (size_t i = 0; i < inputsHandle->size(); ++i) {
322  inputs_.push_back(inputsHandle->ptrAt(i));
323  }
324  } else {
325  bool isPF = iEvent.getByToken(input_candidatefwdptr_token_, pfinputsHandleAsFwdPtr);
326  bool isPFFwdPtr = iEvent.getByToken(input_packedcandidatefwdptr_token_, packedinputsHandleAsFwdPtr);
327  bool isGen = iEvent.getByToken(input_gencandidatefwdptr_token_, geninputsHandleAsFwdPtr);
328  bool isGenFwdPtr = iEvent.getByToken(input_packedgencandidatefwdptr_token_, packedgeninputsHandleAsFwdPtr);
329 
330  if ( isPF ) {
331  if ( pfinputsHandleAsFwdPtr->empty()) {
332  output( iEvent, iSetup );
333  return;
334  }
335  for (size_t i = 0; i < pfinputsHandleAsFwdPtr->size(); ++i) {
336  if ( (*pfinputsHandleAsFwdPtr)[i].ptr().isAvailable() ) {
337  inputs_.push_back( (*pfinputsHandleAsFwdPtr)[i].ptr() );
338  }
339  else if ( (*pfinputsHandleAsFwdPtr)[i].backPtr().isAvailable() ) {
340  inputs_.push_back( (*pfinputsHandleAsFwdPtr)[i].backPtr() );
341  }
342  }
343  } else if ( isPFFwdPtr ) {
344  if ( packedinputsHandleAsFwdPtr->empty()) {
345  output( iEvent, iSetup );
346  return;
347  }
348  for (size_t i = 0; i < packedinputsHandleAsFwdPtr->size(); ++i) {
349  if ( (*packedinputsHandleAsFwdPtr)[i].ptr().isAvailable() ) {
350  inputs_.push_back( (*packedinputsHandleAsFwdPtr)[i].ptr() );
351  }
352  else if ( (*packedinputsHandleAsFwdPtr)[i].backPtr().isAvailable() ) {
353  inputs_.push_back( (*packedinputsHandleAsFwdPtr)[i].backPtr() );
354  }
355  }
356  } else if ( isGen ) {
357  if ( geninputsHandleAsFwdPtr->empty()) {
358  output( iEvent, iSetup );
359  return;
360  }
361  for (size_t i = 0; i < geninputsHandleAsFwdPtr->size(); ++i) {
362  if ( (*geninputsHandleAsFwdPtr)[i].ptr().isAvailable() ) {
363  inputs_.push_back( (*geninputsHandleAsFwdPtr)[i].ptr() );
364  }
365  else if ( (*geninputsHandleAsFwdPtr)[i].backPtr().isAvailable() ) {
366  inputs_.push_back( (*geninputsHandleAsFwdPtr)[i].backPtr() );
367  }
368  }
369  } else if ( isGenFwdPtr ) {
370  if ( geninputsHandleAsFwdPtr->empty()) {
371  output( iEvent, iSetup );
372  return;
373  }
374  for (size_t i = 0; i < packedgeninputsHandleAsFwdPtr->size(); ++i) {
375  if ( (*packedgeninputsHandleAsFwdPtr)[i].ptr().isAvailable() ) {
376  inputs_.push_back( (*packedgeninputsHandleAsFwdPtr)[i].ptr() );
377  }
378  else if ( (*packedgeninputsHandleAsFwdPtr)[i].backPtr().isAvailable() ) {
379  inputs_.push_back( (*packedgeninputsHandleAsFwdPtr)[i].backPtr() );
380  }
381  }
382  }
383  else {
384  throw cms::Exception("Invalid Jet Inputs") <<"Did not specify appropriate inputs for VirtualJetProducer, Abort!\n";
385  }
386  }
387  LogDebug("VirtualJetProducer") << "Got inputs\n";
388 
389  // Convert candidates to fastjet::PseudoJets.
390  // Also correct to Primary Vertex. Will modify fjInputs_
391  // and use inputs_
392  fjInputs_.reserve(inputs_.size());
393  inputTowers();
394  LogDebug("VirtualJetProducer") << "Inputted towers\n";
395 
396  // For Pileup subtraction using offset correction:
397  // Subtract pedestal.
398  if ( doPUOffsetCorr_ ) {
399  subtractor_->setDefinition(fjJetDefinition_);
400  subtractor_->reset(inputs_,fjInputs_,fjJets_);
401  subtractor_->calculatePedestal(fjInputs_);
402  subtractor_->subtractPedestal(fjInputs_);
403  LogDebug("VirtualJetProducer") << "Subtracted pedestal\n";
404  }
405  // Run algorithm. Will modify fjJets_ and allocate fjClusterSeq_.
406  // This will use fjInputs_
407  runAlgorithm( iEvent, iSetup );
408 
409  // if ( doPUOffsetCorr_ ) {
410  // subtractor_->setAlgorithm(fjClusterSeq_);
411  // }
412 
413  LogDebug("VirtualJetProducer") << "Ran algorithm\n";
414  // For Pileup subtraction using offset correction:
415  // Now we find jets and need to recalculate their energy,
416  // mark towers participated in jet,
417  // remove occupied towers from the list and recalculate mean and sigma
418  // put the initial towers collection to the jet,
419  // and subtract from initial towers in jet recalculated mean and sigma of towers
420  if ( doPUOffsetCorr_ ) {
421  LogDebug("VirtualJetProducer") << "Do PUOffsetCorr\n";
422  vector<fastjet::PseudoJet> orphanInput;
423  subtractor_->calculateOrphanInput(orphanInput);
424  subtractor_->calculatePedestal(orphanInput);
425  subtractor_->offsetCorrectJets();
426  }
427  // Write the output jets.
428  // This will (by default) call the member function template
429  // "writeJets", but can be overridden.
430  // this will use inputs_
431  output( iEvent, iSetup );
432  LogDebug("VirtualJetProducer") << "Wrote jets\n";
433 
434  // Clear the work vectors so that memory is free for other modules.
435  // Use the trick of swapping with an empty vector so that the memory
436  // is actually given back rather than silently kept.
437  decltype(fjInputs_)().swap(fjInputs_);
438  decltype(fjJets_)().swap(fjJets_);
439  decltype(inputs_)().swap(inputs_);
440 
441  return;
442 }
443 
444 //______________________________________________________________________________
445 
447 {
448  auto inBegin = inputs_.begin(),
449  inEnd = inputs_.end(), i = inBegin;
450  for (; i != inEnd; ++i ) {
451  auto const & input = **i;
452  // std::cout << "CaloTowerVI jets " << input->pt() << " " << input->et() << ' '<< input->energy() << ' ' << (isAnomalousTower(input) ? " bad" : " ok") << std::endl;
453  if (edm::isNotFinite(input.pt())) continue;
454  if (input.et() <inputEtMin_) continue;
455  if (input.energy()<inputEMin_) continue;
456  if (isAnomalousTower(*i)) continue;
457  // Change by SRR : this is no longer an error nor warning, this can happen with PU mitigation algos.
458  // Also switch to something more numerically safe. (VI: 10^-42GeV????)
459  if (input.pt() < 100 * std::numeric_limits<double>::epsilon() ) {
460  continue;
461  }
462  if (makeCaloJet(jetTypeE)&&doPVCorrection_) {
463  const CaloTower & tower = dynamic_cast<const CaloTower &>(input);
464  auto const & ct = tower.p4(vertex_); // very expensive as computed in eta/phi
465  fjInputs_.emplace_back(ct.px(),ct.py(),ct.pz(),ct.energy());
466  //std::cout << "tower:" << *tower << '\n';
467  }
468  else {
469  /*
470  if(makePFJet(jetTypeE)) {
471  reco::PFCandidate& pfc = (reco::PFCandidate&)input;
472  std::cout << "PF cand:" << pfc << '\n';
473  }
474  */
475  fjInputs_.emplace_back(input.px(),input.py(),input.pz(),
476  input.energy());
477  }
478  fjInputs_.back().set_user_index(i - inBegin);
479  }
480 
481  if ( restrictInputs_ && fjInputs_.size() > maxInputs_ ) {
483  std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
484  fjInputs_.resize(maxInputs_);
485  edm::LogWarning("JetRecoTooManyEntries") << "Too many inputs in the event, limiting to first " << maxInputs_ << ". Output is suspect.";
486  }
487 }
488 
489 //______________________________________________________________________________
491 {
492  if (!makeCaloJet(jetTypeE))
493  return false;
494  else
495  return (*anomalousTowerDef_)(*input);
496 }
497 
498 //------------------------------------------------------------------------------
499 // This is pure virtual.
500 //______________________________________________________________________________
501 // void VirtualJetProducer::runAlgorithm( edm::Event & iEvent, edm::EventSetup const& iSetup,
502 // std::vector<edm::Ptr<reco::Candidate> > const & inputs_);
503 
504 //______________________________________________________________________________
505 void VirtualJetProducer::copyConstituents(const vector<fastjet::PseudoJet>& fjConstituents,
506  reco::Jet* jet)
507 {
508  for (unsigned int i=0;i<fjConstituents.size();++i) {
509  int index = fjConstituents[i].user_index();
510  if ( index >= 0 && static_cast<unsigned int>(index) < inputs_.size() )
511  jet->addDaughter(inputs_[index]);
512  }
513 }
514 
515 
516 //______________________________________________________________________________
517 vector<reco::CandidatePtr>
518 VirtualJetProducer::getConstituents(const vector<fastjet::PseudoJet>&fjConstituents)
519 {
520  vector<reco::CandidatePtr> result; result.reserve(fjConstituents.size()/2);
521  for (unsigned int i=0;i<fjConstituents.size();i++) {
522  auto index = fjConstituents[i].user_index();
523  if ( index >= 0 && static_cast<unsigned int>(index) < inputs_.size() ) {
524  result.emplace_back(inputs_[index]);
525  }
526  }
527  return result;
528 }
529 
530 
531 //_____________________________________________________________________________
532 
534 {
535  // Write jets and constitutents. Will use fjJets_, inputs_
536  // and fjClusterSeq_
537 
538  if ( writeCompound_ ) {
539  // Write jets and subjets
540  switch( jetTypeE ) {
541  case JetType::CaloJet :
542  writeCompoundJets<reco::CaloJet>( iEvent, iSetup );
543  break;
544  case JetType::PFJet :
545  writeCompoundJets<reco::PFJet>( iEvent, iSetup );
546  break;
547  case JetType::GenJet :
548  writeCompoundJets<reco::GenJet>( iEvent, iSetup );
549  break;
550  case JetType::BasicJet :
551  writeCompoundJets<reco::BasicJet>( iEvent, iSetup );
552  break;
553  default:
554  throw cms::Exception("InvalidInput") << "invalid jet type in CompoundJetProducer\n";
555  break;
556  };
557  } else if ( writeJetsWithConst_ ) {
558  // Write jets and new constituents.
559  writeJetsWithConstituents<reco::PFJet>( iEvent, iSetup );
560  } else {
561  switch( jetTypeE ) {
562  case JetType::CaloJet :
563  writeJets<reco::CaloJet>( iEvent, iSetup);
564  break;
565  case JetType::PFJet :
566  writeJets<reco::PFJet>( iEvent, iSetup);
567  break;
568  case JetType::GenJet :
569  writeJets<reco::GenJet>( iEvent, iSetup);
570  break;
571  case JetType::TrackJet :
572  writeJets<reco::TrackJet>( iEvent, iSetup);
573  break;
574  case JetType::PFClusterJet :
575  writeJets<reco::PFClusterJet>( iEvent, iSetup);
576  break;
577  case JetType::BasicJet :
578  writeJets<reco::BasicJet>( iEvent, iSetup);
579  break;
580  default:
581  throw cms::Exception("InvalidInput") << "invalid jet type in VirtualJetProducer\n";
582  break;
583  };
584  }
585 
586 }
587 
588 namespace {
589 template< typename T >
590 struct Area { static float get(T const &) {return 0;}};
591 
592 template<>
593 struct Area<reco::CaloJet>{ static float get(reco::CaloJet const & jet) {
594  return jet.getSpecific().mTowersArea;
595 }
596 };
597 }
598 
599 template< typename T >
601 {
602  // std::cout << "writeJets " << typeid(T).name()
603  // << (doRhoFastjet_ ? " doRhoFastjet " : "")
604  // << (doAreaFastjet_ ? " doAreaFastjet " : "")
605  // << (doAreaDiskApprox_ ? " doAreaDiskApprox " : "")
606  // << std::endl;
607 
608  if (doRhoFastjet_) {
609  // declare jet collection without the two jets,
610  // for unbiased background estimation.
611  std::vector<fastjet::PseudoJet> fjexcluded_jets;
612  fjexcluded_jets=fjJets_;
613 
614  if(fjexcluded_jets.size()>2) fjexcluded_jets.resize(nExclude_);
615 
616  if(doFastJetNonUniform_){
617  auto rhos = std::make_unique<std::vector<double>>();
618  auto sigmas = std::make_unique<std::vector<double>>();
619  int nEta = puCenters_.size();
620  rhos->reserve(nEta);
621  sigmas->reserve(nEta);
622  fastjet::ClusterSequenceAreaBase const* clusterSequenceWithArea =
623  dynamic_cast<fastjet::ClusterSequenceAreaBase const *> ( &*fjClusterSeq_ );
624 
625  if (clusterSequenceWithArea ==nullptr ){
626  if (!fjJets_.empty()) {
627  throw cms::Exception("LogicError")<<"fjClusterSeq is not initialized while inputs are present\n ";
628  }
629  } else {
630  for(int ie = 0; ie < nEta; ++ie){
631  double eta = puCenters_[ie];
632  double etamin=eta-puWidth_;
633  double etamax=eta+puWidth_;
634  fastjet::RangeDefinition range_rho(etamin,etamax);
635  fastjet::BackgroundEstimator bkgestim(*clusterSequenceWithArea,range_rho);
636  bkgestim.set_excluded_jets(fjexcluded_jets);
637  rhos->push_back(bkgestim.rho());
638  sigmas->push_back(bkgestim.sigma());
639  }
640  }
641  iEvent.put(std::move(rhos),"rhos");
642  iEvent.put(std::move(sigmas),"sigmas");
643  }else{
644  auto rho = std::make_unique<double>(0.0);
645  auto sigma = std::make_unique<double>(0.0);
646  double mean_area = 0;
647 
648  fastjet::ClusterSequenceAreaBase const* clusterSequenceWithArea =
649  dynamic_cast<fastjet::ClusterSequenceAreaBase const *> ( &*fjClusterSeq_ );
650  if (clusterSequenceWithArea ==nullptr ){
651  if (!fjJets_.empty()) {
652  throw cms::Exception("LogicError")<<"fjClusterSeq is not initialized while inputs are present\n ";
653  }
654  } else {
655  clusterSequenceWithArea->get_median_rho_and_sigma(*fjSelector_,false,*rho,*sigma,mean_area);
656  if((*rho < 0)|| (edm::isNotFinite(*rho))) {
657  edm::LogError("BadRho") << "rho value is " << *rho << " area:" << mean_area << " and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjSelector_) << " with range " << fjSelector_->description()
658  <<". Setting rho to rezo.";
659  *rho = 0;
660  }
661  }
662  iEvent.put(std::move(rho),"rho");
663  iEvent.put(std::move(sigma),"sigma");
664  }
665  } // doRhoFastjet_
666 
667  // produce output jet collection
668 
669  using namespace reco;
670 
671  // allocate fjJets_.size() Ts in vector
672  auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
673 
674  // Distance between jet centers and overlap area -- for disk-based area calculation
675  using RIJ = std::pair<double,double>;
676  std::vector<RIJ> rijStorage(fjJets_.size()*(fjJets_.size()/2));
677  RIJ * rij[fjJets_.size()];
678  unsigned int k=0;
679  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
680  rij[ijet] = &rijStorage[k]; k+=ijet;
681  }
682 
683  float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
684 
685  auto orParam_ = 1./rParam_;
686  // fill jets
687  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
688  auto & jet = (*jets)[ijet];
689  // get the fastjet jet
690  const fastjet::PseudoJet& fjJet = fjJets_[ijet];
691  // get the constituents from fastjet
692  std::vector<fastjet::PseudoJet> const & fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
693  // convert them to CandidatePtr vector
694  std::vector<CandidatePtr> const & constituents = getConstituents(fjConstituents);
695 
696  // write the specifics to the jet (simultaneously sets 4-vector, vertex).
697  // These are overridden functions that will call the appropriate
698  // specific allocator.
700  Particle::LorentzVector(fjJet.px(),
701  fjJet.py(),
702  fjJet.pz(),
703  fjJet.E()),
704  vertex_,
705  constituents, iSetup);
706  phiJ[ijet] = jet.phi();
707  etaJ[ijet] = jet.eta();
708  }
709 
710  // calcuate the jet area
711  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
712  // calcuate the jet area
713  double jetArea=0.0;
714  // get the fastjet jet
715  const auto & fjJet = fjJets_[ijet];
716  if ( doAreaFastjet_ && fjJet.has_area() ) {
717  jetArea = fjJet.area();
718  }
719  else if ( doAreaDiskApprox_ ) {
720  // Here it is assumed that fjJets_ is in decreasing order of pT,
721  // which should happen in FastjetJetProducer::runAlgorithm()
722  jetArea = M_PI;
723  RIJ * distance = rij[ijet];
724  for (unsigned jJet = 0; jJet < ijet; ++jJet) {
725  distance[jJet].first = std::sqrt(reco::deltaR2(etaJ[ijet],phiJ[ijet], etaJ[jJet],phiJ[jJet]))*orParam_;
726  distance[jJet].second = reco::helper::VirtualJetProducerHelper::intersection(distance[jJet].first);
727  jetArea -=distance[jJet].second;
728  for (unsigned kJet = 0; kJet < jJet; ++kJet) {
729  jetArea += reco::helper::VirtualJetProducerHelper::intersection(distance[jJet].first, distance[kJet].first, rij[jJet][kJet].first,
730  distance[jJet].second, distance[kJet].second, rij[jJet][kJet].second);
731  } // end loop over harder jets
732  } // end loop over harder jets
733  jetArea *= (rParam_*rParam_);
734  }
735  auto & jet = (*jets)[ijet];
736  jet.setJetArea (jetArea);
737 
738  if(doPUOffsetCorr_){
739  jet.setPileup(subtractor_->getPileUpEnergy(ijet));
740  }else{
741  jet.setPileup (0.0);
742  }
743 
744  // std::cout << "area " << ijet << " " << jetArea << " " << Area<T>::get(jet) << std::endl;
745  // std::cout << "JetVI " << ijet << ' '<< jet.pt() << " " << jet.et() << ' '<< jet.energy() << ' '<< jet.mass() << std::endl;
746 
747  }
748  // put the jets in the collection
749  iEvent.put(std::move(jets),jetCollInstanceName_);
750 }
751 
753 template< class T>
755 {
756  if ( verbosity_ >= 1 ) {
757  std::cout << "<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
758  }
759 
760  // get a list of output jets
761  auto jetCollection = std::make_unique<reco::BasicJetCollection>();
762  // get a list of output subjets
763  auto subjetCollection = std::make_unique<std::vector<T>>();
764 
765  // This will store the handle for the subjets after we write them
766  edm::OrphanHandle< std::vector<T> > subjetHandleAfterPut;
767  // this is the mapping of subjet to hard jet
768  std::vector< std::vector<int> > indices;
769  // this is the list of hardjet 4-momenta
770  std::vector<math::XYZTLorentzVector> p4_hardJets;
771  // this is the hardjet areas
772  std::vector<double> area_hardJets;
773 
774  // Loop over the hard jets
775  std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
776  iEnd = fjJets_.end(),
777  iBegin = fjJets_.begin();
778  indices.resize( fjJets_.size() );
779  for ( ; it != iEnd; ++it ) {
780  fastjet::PseudoJet const & localJet = *it;
781  unsigned int jetIndex = it - iBegin;
782  // Get the 4-vector for the hard jet
783  p4_hardJets.push_back( math::XYZTLorentzVector(localJet.px(), localJet.py(), localJet.pz(), localJet.e() ));
784  double localJetArea = 0.0;
785  if ( doAreaFastjet_ && localJet.has_area() ) {
786  localJetArea = localJet.area();
787  }
788  area_hardJets.push_back( localJetArea );
789 
790  // create the subjet list
791  std::vector<fastjet::PseudoJet> constituents;
792  if ( it->has_pieces() ) {
793  constituents = it->pieces();
794  } else if ( it->has_constituents() ) {
795  constituents = it->constituents();
796  }
797 
798  std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(),
799  itSubJet = itSubJetBegin, itSubJetEnd = constituents.end();
800  for (; itSubJet != itSubJetEnd; ++itSubJet ){
801 
802  fastjet::PseudoJet const & subjet = *itSubJet;
803  if ( verbosity_ >= 1 ) {
804  std::cout << "subjet #" << (itSubJet - itSubJetBegin) << ": Pt = " << subjet.pt() << ", eta = " << subjet.eta() << ", phi = " << subjet.phi() << ", mass = " << subjet.m()
805  << " (#constituents = " << subjet.constituents().size() << ")" << std::endl;
806  std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
807  int idx_constituent = 0;
808  for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
809  constituent != subjet_constituents.end(); ++constituent ) {
810  if ( constituent->pt() < 1.e-3 ) continue; // CV: skip ghosts
811  std::cout << " constituent #" << idx_constituent << ": Pt = " << constituent->pt() << ", eta = " << constituent->eta() << ", phi = " << constituent->phi() << ","
812  << " mass = " << constituent->m() << std::endl;
813  ++idx_constituent;
814  }
815  }
816 
817  if ( verbosity_ >= 1 ) {
818  std::cout << "subjet #" << (itSubJet - itSubJetBegin) << ": Pt = " << subjet.pt() << ", eta = " << subjet.eta() << ", phi = " << subjet.phi() << ", mass = " << subjet.m()
819  << " (#constituents = " << subjet.constituents().size() << ")" << std::endl;
820  std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
821  int idx_constituent = 0;
822  for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
823  constituent != subjet_constituents.end(); ++constituent ) {
824  if ( constituent->pt() < 1.e-3 ) continue; // CV: skip ghosts
825  std::cout << " constituent #" << idx_constituent << ": Pt = " << constituent->pt() << ", eta = " << constituent->eta() << ", phi = " << constituent->phi() << ","
826  << " mass = " << constituent->m() << std::endl;
827  ++idx_constituent;
828  }
829  }
830 
831  math::XYZTLorentzVector p4Subjet(subjet.px(), subjet.py(), subjet.pz(), subjet.e() );
833 
834  // This will hold ptr's to the subjets
835  std::vector<reco::CandidatePtr> subjetConstituents;
836 
837  // Get the transient subjet constituents from fastjet
838  std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
839  std::vector<reco::CandidatePtr> constituents =
840  getConstituents(subjetFastjetConstituents );
841 
842  indices[jetIndex].push_back( subjetCollection->size() );
843 
844  // Add the concrete subjet type to the subjet list to write to event record
845  T jet;
846  reco::writeSpecific( jet, p4Subjet, point, constituents, iSetup);
847  double subjetArea = 0.0;
848  if ( doAreaFastjet_ && itSubJet->has_area() ){
849  subjetArea = itSubJet->area();
850  }
851  jet.setJetArea( subjetArea );
852  subjetCollection->push_back( jet );
853  }
854  }
855 
856  // put subjets into event record
857  subjetHandleAfterPut = iEvent.put(std::move(subjetCollection), jetCollInstanceName_);
858 
859  // Now create the hard jets with ptr's to the subjets as constituents
860  std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(),
861  ip4Begin = p4_hardJets.begin(),
862  ip4End = p4_hardJets.end();
863 
864  for ( ; ip4 != ip4End; ++ip4 ) {
865  int p4_index = ip4 - ip4Begin;
866  std::vector<int> & ind = indices[p4_index];
867  std::vector<reco::CandidatePtr> i_hardJetConstituents;
868  // Add the subjets to the hard jet
869  for( std::vector<int>::const_iterator isub = ind.begin();
870  isub != ind.end(); ++isub ) {
871  reco::CandidatePtr candPtr( subjetHandleAfterPut, *isub, false );
872  i_hardJetConstituents.push_back( candPtr );
873  }
875  reco::BasicJet toput( *ip4, point, i_hardJetConstituents);
876  toput.setJetArea( area_hardJets[ip4 - ip4Begin] );
877  jetCollection->push_back( toput );
878  }
879 
880  // put hard jets into event record
881  // Store the Orphan handle for adding HTT information
882  edm::OrphanHandle<reco::BasicJetCollection> oh = iEvent.put(std::move(jetCollection));
883 
884  if (fromHTTTopJetProducer_){
885  addHTTTopJetTagInfoCollection( iEvent, iSetup, oh);
886  }
887 
888 }
889 
891 template< class T>
893 {
894  if ( verbosity_ >= 1 ) {
895  std::cout << "<VirtualJetProducer::writeJetsWithConstituents (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
896  }
897 
898  // get a list of output jets MV: make this compatible with template
899  auto jetCollection = std::make_unique<reco::PFJetCollection>();
900 
901  // this is the mapping of jet to constituents
902  std::vector< std::vector<int> > indices;
903  // this is the list of jet 4-momenta
904  std::vector<math::XYZTLorentzVector> p4_Jets;
905  // this is the jet areas
906  std::vector<double> area_Jets;
907 
908  // get a list of output constituents
909  auto constituentCollection = std::make_unique<reco::PFCandidateCollection>();
910 
911  // This will store the handle for the constituents after we write them
912  edm::OrphanHandle<reco::PFCandidateCollection> constituentHandleAfterPut;
913 
914  // Loop over the jets and extract constituents
915  std::vector<fastjet::PseudoJet> constituentsSub;
916  std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
917  iEnd = fjJets_.end(),
918  iBegin = fjJets_.begin();
919  indices.resize( fjJets_.size() );
920 
921  for ( ; it != iEnd; ++it ) {
922  fastjet::PseudoJet const & localJet = *it;
923  unsigned int jetIndex = it - iBegin;
924  // Get the 4-vector for the hard jet
925  p4_Jets.push_back( math::XYZTLorentzVector(localJet.px(), localJet.py(), localJet.pz(), localJet.e() ));
926  double localJetArea = 0.0;
927  if ( doAreaFastjet_ && localJet.has_area() ) {
928  localJetArea = localJet.area();
929  }
930  area_Jets.push_back( localJetArea );
931 
932  // create the constituent list
933  std::vector<fastjet::PseudoJet> constituents,ghosts;
934  if ( it->has_pieces() )
935  constituents = it->pieces();
936  else if ( it->has_constituents() )
937  fastjet::SelectorIsPureGhost().sift(it->constituents(), ghosts, constituents); //filter out ghosts
938 
939  //loop over constituents of jet (can be subjets or normal constituents)
940  indices[jetIndex].reserve(constituents.size());
941  constituentsSub.reserve(constituentsSub.size()+constituents.size());
942  for (fastjet::PseudoJet const& constit : constituents) {
943  indices[jetIndex].push_back( constituentsSub.size() );
944  constituentsSub.push_back(constit);
945  }
946  }
947 
948  //Loop over constituents and store in the event
949  static const reco::PFCandidate dummySinceTranslateIsNotStatic;
950  for (fastjet::PseudoJet const& constit : constituentsSub) {
951  auto orig = inputs_[constit.user_index()];
952  auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(orig->pdgId());
953  reco::PFCandidate pCand( reco::PFCandidate(orig->charge(), orig->p4(), id) );
955  pVec.SetPxPyPzE(constit.px(),constit.py(),constit.pz(),constit.e());
956  pCand.setP4(pVec);
957  pCand.setSourceCandidatePtr( orig->sourceCandidatePtr(0) );
958  constituentCollection->push_back(pCand);
959  }
960  // put constituents into event record
961  constituentHandleAfterPut = iEvent.put(std::move(constituentCollection), jetCollInstanceName_ );
962 
963  // Now create the jets with ptr's to the constituents
964  std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_Jets.begin(),
965  ip4Begin = p4_Jets.begin(),
966  ip4End = p4_Jets.end();
967 
968  for ( ; ip4 != ip4End; ++ip4 ) {
969  int p4_index = ip4 - ip4Begin;
970  std::vector<int> & ind = indices[p4_index];
971  std::vector<reco::CandidatePtr> i_jetConstituents;
972  // Add the constituents to the jet
973  for( std::vector<int>::const_iterator iconst = ind.begin(); iconst != ind.end(); ++iconst ) {
974  reco::CandidatePtr candPtr( constituentHandleAfterPut, *iconst, false );
975  i_jetConstituents.push_back( candPtr );
976  }
977  if(!i_jetConstituents.empty()) { //only keep jets which have constituents after subtraction
980  reco::writeSpecific(jet,*ip4,point,i_jetConstituents,iSetup);
981  jet.setJetArea( area_Jets[ip4 - ip4Begin] );
982  jetCollection->emplace_back( jet );
983  }
984  }
985 
986  // put jets into event record
987  iEvent.put(std::move(jetCollection));
988 }
989 
990 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
992 
994  fillDescriptionsFromVirtualJetProducer(desc);
995  desc.add<string>("jetCollInstanceName", "" );
996 
997  // addDefault must be used here instead of add unless
998  // all the classes that inherit from this class redefine
999  // the fillDescriptions function. Otherwise, the autogenerated
1000  // cfi filenames are the same and conflict.
1001  descriptions.addDefault(desc);
1002 }
1003 
1005 {
1006  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow") );
1007  desc.add<edm::InputTag>("srcPVs", edm::InputTag("") );
1008  desc.add<string>("jetType", "PFJet" );
1009  desc.add<string>("jetAlgorithm", "AntiKt" );
1010  desc.add<double>("rParam", 0.4 );
1011  desc.add<double>("inputEtMin", 0.0 );
1012  desc.add<double>("inputEMin", 0.0 );
1013  desc.add<double>("jetPtMin", 5. );
1014  desc.add<bool> ("doPVCorrection", false );
1015  desc.add<bool> ("doAreaFastjet", false );
1016  desc.add<bool> ("doRhoFastjet", false );
1017  desc.add<bool> ("doPUOffsetCorr", false );
1018  desc.add<double>("puPtMin", 10.);
1019  desc.add<double>("nSigmaPU", 1.0 );
1020  desc.add<double>("radiusPU", 0.5 );
1021  desc.add<string>("subtractorName", "" );
1022  desc.add<bool> ("useExplicitGhosts", false );
1023  desc.add<bool> ("doAreaDiskApprox", false );
1024  desc.add<double>("voronoiRfact", -0.9 );
1025  desc.add<double>("Rho_EtaMax", 4.4 );
1026  desc.add<double>("Ghost_EtaMax", 5. );
1027  desc.add<int> ("Active_Area_Repeats", 1 );
1028  desc.add<double>("GhostArea", 0.01 );
1029  desc.add<bool> ("restrictInputs", false );
1030  desc.add<unsigned int> ("maxInputs", 1 );
1031  desc.add<bool> ("writeCompound", false );
1032  desc.add<bool> ("writeJetsWithConst", false );
1033  desc.add<bool> ("doFastJetNonUniform", false );
1034  desc.add<bool> ("useDeterministicSeed",false );
1035  desc.add<unsigned int> ("minSeed", 14327 );
1036  desc.add<int> ("verbosity", 0 );
1037  desc.add<double>("puWidth", 0. );
1038  desc.add<unsigned int>("nExclude", 0 );
1039  desc.add<unsigned int>("maxBadEcalCells", 9999999 );
1040  desc.add<unsigned int>("maxBadHcalCells", 9999999 );
1041  desc.add<unsigned int>("maxProblematicEcalCells", 9999999 );
1042  desc.add<unsigned int>("maxProblematicHcalCells", 9999999 );
1043  desc.add<unsigned int>("maxRecoveredEcalCells", 9999999 );
1044  desc.add<unsigned int>("maxRecoveredHcalCells", 9999999 );
1045  vector<double> puCentersDefault;
1046  desc.add<vector<double>>("puCenters", puCentersDefault);
1047 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
boost::shared_ptr< fastjet::AreaDefinition > AreaDefinitionPtr
void writeJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
std::shared_ptr< fastjet::JetDefinition > JetDefPtr
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
Definition: helper.py:1
Jets made from CaloTowers.
Definition: CaloJet.h:29
static const HistoName names[]
math::PtEtaPhiMLorentzVector p4(double vtxZ) const
Definition: CaloTower.cc:129
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
Ptr< value_type > ptrAt(size_type i) const
virtual void inputTowers()
Base class for all types of Jets.
Definition: Jet.h:20
boost::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
size_type size() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setSourceCandidatePtr(const PFCandidatePtr &ptr)
Definition: PFCandidate.h:126
virtual void copyConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents, reco::Jet *jet)
Jets made from CaloTowers.
Definition: BasicJet.h:20
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void writeJetsWithConstituents(edm::Event &iEvent, edm::EventSetup const &iSetup)
function template to write out the outputs
Jets made from PFObjects.
Definition: PFJet.h:21
static std::string const input
Definition: EdmProvDump.cc:44
void writeCompoundJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
function template to write out the outputs
bool operator()(const fastjet::PseudoJet &t1, const fastjet::PseudoJet &t2) const
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual bool isAnomalousTower(reco::CandidatePtr input)
virtual void setJetArea(float fArea)
set jet area
Definition: Jet.h:103
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
bool isNotFinite(T x)
Definition: isFinite.h:10
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
virtual void makeProduces(std::string s, std::string tag="")
T sqrt(T t)
Definition: SSEVec.h:18
vector< PseudoJet > jets
bool empty() const
math::XYZPoint Point
point in the space
Definition: Particle.h:25
void set_excluded_jets(const std::vector< PseudoJet > &excluded_jets)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define M_PI
int k[5][pyjets_maxn]
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17
double rho()
synonym for median rho [[do we have this? Both?]]
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:233
static const char *const names[]
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
double sigma()
get the sigma
edm::EventID id() const
Definition: EventBase.h:60
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
HLT enums.
VirtualJetProducer(const edm::ParameterSet &iConfig)
boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
void addDaughter(const CandidatePtr &)
add a daughter via a reference
static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription &desc)
virtual void output(edm::Event &iEvent, edm::EventSetup const &iSetup)
long double T
static Type byName(const std::string &name)
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:510
T get(const Candidate &c)
Definition: component.h:55
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
math::PtEtaPhiELorentzVectorF LorentzVector
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, edm::EventSetup const &c)
Definition: JetSpecific.cc:41