test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
VirtualJetProducer Class Referenceabstract

#include <VirtualJetProducer.h>

Inheritance diagram for VirtualJetProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper cms::CompoundJetProducer cms::SubEventGenJetProducer CMSInsideOutJetProducer FastjetJetProducer SubjetFilterJetProducer cms::SubJetProducer cms::CATopJetProducer

Classes

struct  JetType
 

Public Types

typedef boost::shared_ptr
< fastjet::GhostedAreaSpec > 
ActiveAreaSpecPtr
 
typedef boost::shared_ptr
< fastjet::AreaDefinition > 
AreaDefinitionPtr
 
typedef boost::shared_ptr
< fastjet::ClusterSequence > 
ClusterSequencePtr
 
typedef boost::shared_ptr
< fastjet::JetDefinition > 
JetDefPtr
 
typedef boost::shared_ptr
< fastjet::JetDefinition::Plugin > 
PluginPtr
 
typedef boost::shared_ptr
< fastjet::RangeDefinition > 
RangeDefPtr
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

std::string jetType () const
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 VirtualJetProducer (const edm::ParameterSet &iConfig)
 
virtual ~VirtualJetProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

virtual void copyConstituents (const std::vector< fastjet::PseudoJet > &fjConstituents, reco::Jet *jet)
 
virtual std::vector
< reco::CandidatePtr
getConstituents (const std::vector< fastjet::PseudoJet > &fjConstituents)
 
virtual void inputTowers ()
 
virtual bool isAnomalousTower (reco::CandidatePtr input)
 
bool makeBasicJet (const JetType::Type &fTag)
 
bool makeCaloJet (const JetType::Type &fTag)
 
bool makeGenJet (const JetType::Type &fTag)
 
bool makePFClusterJet (const JetType::Type &fTag)
 
bool makePFJet (const JetType::Type &fTag)
 
virtual void makeProduces (std::string s, std::string tag="")
 
bool makeTrackJet (const JetType::Type &fTag)
 
void offsetCorrectJets (std::vector< fastjet::PseudoJet > &orphanInput)
 
virtual void output (edm::Event &iEvent, edm::EventSetup const &iSetup)
 
virtual void runAlgorithm (edm::Event &iEvent, const edm::EventSetup &iSetup)=0
 
template<typename T >
void writeCompoundJets (edm::Event &iEvent, edm::EventSetup const &iSetup)
 function template to write out the outputs More...
 
template<typename T >
void writeJets (edm::Event &iEvent, edm::EventSetup const &iSetup)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Protected Attributes

bool doAreaDiskApprox_
 
bool doAreaFastjet_
 
bool doFastJetNonUniform_
 
bool doPUOffsetCorr_
 
bool doPVCorrection_
 
bool doRhoFastjet_
 
ActiveAreaSpecPtr fjActiveArea_
 
AreaDefinitionPtr fjAreaDefinition_
 
ClusterSequencePtr fjClusterSeq_
 
std::vector< fastjet::PseudoJet > fjInputs_
 
JetDefPtr fjJetDefinition_
 
std::vector< fastjet::PseudoJet > fjJets_
 
PluginPtr fjPlugin_
 
RangeDefPtr fjRangeDef_
 
edm::EDGetTokenT
< reco::VertexCollection
input_vertex_token_
 
double inputEMin_
 
double inputEtMin_
 
std::vector< edm::Ptr
< reco::Candidate > > 
inputs_
 
std::string jetAlgorithm_
 
std::string jetCollInstanceName_
 
double jetPtMin_
 
std::string jetType_
 
JetType::Type jetTypeE
 
unsigned int maxInputs_
 
unsigned int minSeed_
 
std::string moduleLabel_
 
unsigned int nExclude_
 
std::vector< double > puCenters_
 
std::string puSubtractorName_
 
double puWidth_
 
bool restrictInputs_
 
double rParam_
 
edm::InputTag src_
 
edm::InputTag srcPVs_
 
boost::shared_ptr
< PileUpSubtractor
subtractor_
 
bool useDeterministicSeed_
 
bool useExplicitGhosts_
 
int verbosity_
 
reco::Particle::Point vertex_
 
double voronoiRfact_
 
bool writeCompound_
 

Private Attributes

std::auto_ptr< AnomalousToweranomalousTowerDef_
 
edm::EDGetTokenT< std::vector
< edm::FwdPtr
< reco::PFCandidate > > > 
input_candidatefwdptr_token_
 
edm::EDGetTokenT
< reco::CandidateView
input_candidateview_token_
 
edm::EDGetTokenT< std::vector
< edm::FwdPtr
< pat::PackedCandidate > > > 
input_packedcandidatefwdptr_token_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 31 of file VirtualJetProducer.h.

Member Typedef Documentation

typedef boost::shared_ptr<fastjet::GhostedAreaSpec> VirtualJetProducer::ActiveAreaSpecPtr

Definition at line 84 of file VirtualJetProducer.h.

typedef boost::shared_ptr<fastjet::AreaDefinition> VirtualJetProducer::AreaDefinitionPtr

Definition at line 85 of file VirtualJetProducer.h.

typedef boost::shared_ptr<fastjet::ClusterSequence> VirtualJetProducer::ClusterSequencePtr

Definition at line 81 of file VirtualJetProducer.h.

typedef boost::shared_ptr<fastjet::JetDefinition> VirtualJetProducer::JetDefPtr

Definition at line 83 of file VirtualJetProducer.h.

typedef boost::shared_ptr<fastjet::JetDefinition::Plugin> VirtualJetProducer::PluginPtr

Definition at line 82 of file VirtualJetProducer.h.

typedef boost::shared_ptr<fastjet::RangeDefinition> VirtualJetProducer::RangeDefPtr

Definition at line 86 of file VirtualJetProducer.h.

Constructor & Destructor Documentation

VirtualJetProducer::VirtualJetProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 115 of file VirtualJetProducer.cc.

References HLT_25ns10e33_v2_cff::alias, anomalousTowerDef_, VirtualJetProducer::JetType::byName(), edm::EDConsumerBase::consumesCollector(), doAreaDiskApprox_, doAreaFastjet_, doFastJetNonUniform_, doPUOffsetCorr_, doRhoFastjet_, Exception, edm::ParameterSet::exists(), fjActiveArea_, fjAreaDefinition_, fjJetDefinition_, fjPlugin_, fjRangeDef_, reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), input_candidatefwdptr_token_, input_candidateview_token_, input_packedcandidatefwdptr_token_, input_vertex_token_, jetAlgorithm_, jetCollInstanceName_, jetType_, jetTypeE, edm::InputTag::label(), makeProduces(), maxInputs_, minSeed_, moduleLabel_, nExclude_, puCenters_, puSubtractorName_, puWidth_, restrictInputs_, rParam_, src_, srcPVs_, AlCaHLTBitMon_QueryRunRegistry::string, subtractor_, useDeterministicSeed_, useExplicitGhosts_, verbosity_, voronoiRfact_, and writeCompound_.

116  : moduleLabel_ (iConfig.getParameter<string> ("@module_label"))
117  , src_ (iConfig.getParameter<edm::InputTag>("src"))
118  , srcPVs_ (iConfig.getParameter<edm::InputTag>("srcPVs"))
119  , jetType_ (iConfig.getParameter<string> ("jetType"))
120  , jetAlgorithm_ (iConfig.getParameter<string> ("jetAlgorithm"))
121  , rParam_ (iConfig.getParameter<double> ("rParam"))
122  , inputEtMin_ (iConfig.getParameter<double> ("inputEtMin"))
123  , inputEMin_ (iConfig.getParameter<double> ("inputEMin"))
124  , jetPtMin_ (iConfig.getParameter<double> ("jetPtMin"))
125  , doPVCorrection_(iConfig.getParameter<bool> ("doPVCorrection"))
126  , restrictInputs_(false)
127  , maxInputs_(99999999)
128  , doAreaFastjet_ (iConfig.getParameter<bool> ("doAreaFastjet"))
129  , useExplicitGhosts_(false)
130  , doAreaDiskApprox_ (false)
131  , doRhoFastjet_ (iConfig.getParameter<bool> ("doRhoFastjet"))
132  , voronoiRfact_ (-9)
133  , doPUOffsetCorr_(iConfig.getParameter<bool> ("doPUOffsetCorr"))
134  , puWidth_(0)
135  , nExclude_(0)
136  , jetCollInstanceName_ ("")
137  , writeCompound_ ( false )
138  , verbosity_(0)
139 {
140  anomalousTowerDef_ = std::auto_ptr<AnomalousTower>(new AnomalousTower(iConfig));
141 
142  //
143  // additional parameters to think about:
144  // - overlap threshold (set to 0.75 for the time being)
145  // - p parameter for generalized kT (set to -2 for the time being)
146  // - fastjet PU subtraction parameters (not yet considered)
147  //
148  if (jetAlgorithm_=="SISCone") {
149  fjPlugin_ = PluginPtr( new fastjet::SISConePlugin(rParam_,0.75,0,0.0,false,
150  fastjet::SISConePlugin::SM_pttilde) );
151  fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(&*fjPlugin_) );
152  }
153  else if (jetAlgorithm_=="IterativeCone") {
154  fjPlugin_ = PluginPtr(new fastjet::CMSIterativeConePlugin(rParam_,1.0));
155  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
156  }
157  else if (jetAlgorithm_=="CDFMidPoint") {
158  fjPlugin_ = PluginPtr(new fastjet::CDFMidPointPlugin(rParam_,0.75));
159  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
160  }
161  else if (jetAlgorithm_=="ATLASCone") {
162  fjPlugin_ = PluginPtr(new fastjet::ATLASConePlugin(rParam_));
163  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
164  }
165  else if (jetAlgorithm_=="Kt")
166  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(fastjet::kt_algorithm,rParam_));
167  else if (jetAlgorithm_=="CambridgeAachen")
168  fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(fastjet::cambridge_algorithm,
169  rParam_) );
170  else if (jetAlgorithm_=="AntiKt")
171  fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(fastjet::antikt_algorithm,rParam_) );
172  else if (jetAlgorithm_=="GeneralizedKt")
173  fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(fastjet::genkt_algorithm,
174  rParam_,-2) );
175  else
176  throw cms::Exception("Invalid jetAlgorithm")
177  <<"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
178 
180 
181  if ( iConfig.exists("jetCollInstanceName") ) {
182  jetCollInstanceName_ = iConfig.getParameter<string>("jetCollInstanceName");
183  }
184 
185  if ( doPUOffsetCorr_ ) {
186 
187  if(iConfig.exists("subtractorName")) puSubtractorName_ = iConfig.getParameter<string> ("subtractorName");
189 
190  if(puSubtractorName_.empty()){
191  edm::LogWarning("VirtualJetProducer") << "Pile Up correction on; however, pile up type is not specified. Using default... \n";
192  subtractor_ = boost::shared_ptr<PileUpSubtractor>(new PileUpSubtractor(iConfig, consumesCollector()));
193  }else{
194  subtractor_ = boost::shared_ptr<PileUpSubtractor>(PileUpSubtractorFactory::get()->create( puSubtractorName_, iConfig, consumesCollector()));
195  }
196  }
197 
198  // use explicit ghosts in the fastjet clustering sequence?
199  if ( iConfig.exists("useExplicitGhosts") ) {
200  useExplicitGhosts_ = iConfig.getParameter<bool>("useExplicitGhosts");
201  }
202 
203  // do approximate disk-based area calculation => warn if conflicting request
204  if (iConfig.exists("doAreaDiskApprox")) {
205  doAreaDiskApprox_ = iConfig.getParameter<bool>("doAreaDiskApprox");
207  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";
208 
209  }
210  // turn off jet collection output for speed
211  // Voronoi-based area calculation allows for an empirical scale factor
212  if (iConfig.exists("voronoiRfact"))
213  voronoiRfact_ = iConfig.getParameter<double>("voronoiRfact");
214 
215 
216  // do fasjet area / rho calcluation? => accept corresponding parameters
217  if ( doAreaFastjet_ || doRhoFastjet_ ) {
218  // Eta range of jets to be considered for Rho calculation
219  // Should be at most (jet acceptance - jet radius)
220  double rhoEtaMax=iConfig.getParameter<double>("Rho_EtaMax");
221  // default Ghost_EtaMax should be 5
222  double ghostEtaMax = iConfig.getParameter<double>("Ghost_EtaMax");
223  // default Active_Area_Repeats 1
224  int activeAreaRepeats = iConfig.getParameter<int> ("Active_Area_Repeats");
225  // default GhostArea 0.01
226  double ghostArea = iConfig.getParameter<double> ("GhostArea");
227  if (voronoiRfact_ <= 0) {
228  fjActiveArea_ = ActiveAreaSpecPtr(new fastjet::GhostedAreaSpec(ghostEtaMax,activeAreaRepeats,ghostArea));
229  fjActiveArea_->set_fj2_placement(true);
230  if ( ! useExplicitGhosts_ ) {
231  fjAreaDefinition_ = AreaDefinitionPtr( new fastjet::AreaDefinition(fastjet::active_area, *fjActiveArea_ ) );
232  } else {
233  fjAreaDefinition_ = AreaDefinitionPtr( new fastjet::AreaDefinition(fastjet::active_area_explicit_ghosts, *fjActiveArea_ ) );
234  }
235  }
236  fjRangeDef_ = RangeDefPtr( new fastjet::RangeDefinition(rhoEtaMax) );
237  }
238 
239  // restrict inputs to first "maxInputs" towers?
240  if ( iConfig.exists("restrictInputs") ) {
241  restrictInputs_ = iConfig.getParameter<bool>("restrictInputs");
242  maxInputs_ = iConfig.getParameter<unsigned int>("maxInputs");
243  }
244 
245 
246  string alias=iConfig.getUntrackedParameter<string>("alias",moduleLabel_);
247 
248 
249  // Check to see if we are writing compound jets for substructure
250  // and jet grooming
251  if ( iConfig.exists("writeCompound") ) {
252  writeCompound_ = iConfig.getParameter<bool>("writeCompound");
253  }
254 
255  // make the "produces" statements
257 
258  doFastJetNonUniform_ = false;
259  if(iConfig.exists("doFastJetNonUniform")) doFastJetNonUniform_ = iConfig.getParameter<bool> ("doFastJetNonUniform");
261  puCenters_ = iConfig.getParameter<std::vector<double> >("puCenters");
262  puWidth_ = iConfig.getParameter<double>("puWidth");
263  nExclude_ = iConfig.getParameter<unsigned int>("nExclude");
264  }
265 
266  useDeterministicSeed_ = false;
267  minSeed_ = 0;
268  if ( iConfig.exists("useDeterministicSeed") ) {
269  useDeterministicSeed_ = iConfig.getParameter<bool>("useDeterministicSeed");
270  minSeed_ = iConfig.getParameter<unsigned int>("minSeed");
271  }
272 
273  if ( iConfig.exists("verbosity" ) ) {
274  verbosity_ = iConfig.getParameter<int>("verbosity");
275  }
276 
277  produces<std::vector<double> >("rhos");
278  produces<std::vector<double> >("sigmas");
279  produces<double>("rho");
280  produces<double>("sigma");
281 
282  if (!srcPVs_.label().empty()) input_vertex_token_ = consumes<reco::VertexCollection>(srcPVs_);
283  input_candidateview_token_ = consumes<reco::CandidateView>(src_);
284  input_candidatefwdptr_token_ = consumes<std::vector<edm::FwdPtr<reco::PFCandidate> > >(src_);
285  input_packedcandidatefwdptr_token_ = consumes<std::vector<edm::FwdPtr<pat::PackedCandidate> > >(src_);
286 
287 }
boost::shared_ptr< fastjet::AreaDefinition > AreaDefinitionPtr
JetType::Type jetTypeE
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::CandidateView > input_candidateview_token_
edm::EDGetTokenT< std::vector< edm::FwdPtr< pat::PackedCandidate > > > input_packedcandidatefwdptr_token_
boost::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string puSubtractorName_
std::vector< double > puCenters_
boost::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
std::string jetCollInstanceName_
boost::shared_ptr< PileUpSubtractor > subtractor_
virtual void makeProduces(std::string s, std::string tag="")
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
std::auto_ptr< AnomalousTower > anomalousTowerDef_
ActiveAreaSpecPtr fjActiveArea_
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
edm::EDGetTokenT< std::vector< edm::FwdPtr< reco::PFCandidate > > > input_candidatefwdptr_token_
std::string const & label() const
Definition: InputTag.h:36
boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
AreaDefinitionPtr fjAreaDefinition_
static Type byName(const std::string &name)
T get(const Candidate &c)
Definition: component.h:55
VirtualJetProducer::~VirtualJetProducer ( )
virtual

Definition at line 290 of file VirtualJetProducer.cc.

291 {
292 }

Member Function Documentation

void VirtualJetProducer::copyConstituents ( const std::vector< fastjet::PseudoJet > &  fjConstituents,
reco::Jet jet 
)
protectedvirtual

Definition at line 504 of file VirtualJetProducer.cc.

References reco::CompositePtrCandidate::addDaughter(), i, cmsHarvester::index, and inputs_.

506 {
507  for (unsigned int i=0;i<fjConstituents.size();++i) {
508  int index = fjConstituents[i].user_index();
509  if ( index >= 0 && static_cast<unsigned int>(index) < inputs_.size() )
510  jet->addDaughter(inputs_[index]);
511  }
512 }
int i
Definition: DBlmapReader.cc:9
std::vector< edm::Ptr< reco::Candidate > > inputs_
void addDaughter(const CandidatePtr &)
add a daughter via a reference
vector< reco::CandidatePtr > VirtualJetProducer::getConstituents ( const std::vector< fastjet::PseudoJet > &  fjConstituents)
protectedvirtual

Definition at line 517 of file VirtualJetProducer.cc.

References i, cmsHarvester::index, inputs_, and mps_fire::result.

Referenced by FastjetJetProducer::produceTrackJets(), cms::SubEventGenJetProducer::runAlgorithm(), writeCompoundJets(), and writeJets().

518 {
519  vector<reco::CandidatePtr> result; result.reserve(fjConstituents.size()/2);
520  for (unsigned int i=0;i<fjConstituents.size();i++) {
521  auto index = fjConstituents[i].user_index();
522  if ( index >= 0 && static_cast<unsigned int>(index) < inputs_.size() ) {
523  result.emplace_back(inputs_[index]);
524  }
525  }
526  return result;
527 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:83
std::vector< edm::Ptr< reco::Candidate > > inputs_
void VirtualJetProducer::inputTowers ( )
protectedvirtual

Reimplemented in cms::CompoundJetProducer, SubjetFilterJetProducer, and cms::SubEventGenJetProducer.

Definition at line 445 of file VirtualJetProducer.cc.

References doPVCorrection_, geometryDiff::epsilon, fjInputs_, i, input, inputEMin_, inputEtMin_, inputs_, isAnomalousTower(), edm::isNotFinite(), jetTypeE, makeCaloJet(), maxInputs_, CaloTower::p4(), restrictInputs_, and vertex_.

Referenced by SubjetFilterJetProducer::inputTowers(), cms::CompoundJetProducer::inputTowers(), produce(), and FastjetJetProducer::produceTrackJets().

446 {
447  auto inBegin = inputs_.begin(),
448  inEnd = inputs_.end(), i = inBegin;
449  for (; i != inEnd; ++i ) {
450  auto const & input = **i;
451  // std::cout << "CaloTowerVI jets " << input->pt() << " " << input->et() << ' '<< input->energy() << ' ' << (isAnomalousTower(input) ? " bad" : " ok") << std::endl;
452  if (edm::isNotFinite(input.pt())) continue;
453  if (input.et() <inputEtMin_) continue;
454  if (input.energy()<inputEMin_) continue;
455  if (isAnomalousTower(*i)) continue;
456  // Change by SRR : this is no longer an error nor warning, this can happen with PU mitigation algos.
457  // Also switch to something more numerically safe. (VI: 10^-42GeV????)
458  if (input.pt() < 100 * std::numeric_limits<double>::epsilon() ) {
459  continue;
460  }
462  const CaloTower & tower = dynamic_cast<const CaloTower &>(input);
463  auto const & ct = tower.p4(vertex_); // very expensive as computed in eta/phi
464  fjInputs_.emplace_back(ct.px(),ct.py(),ct.pz(),ct.energy());
465  //std::cout << "tower:" << *tower << '\n';
466  }
467  else {
468  /*
469  if(makePFJet(jetTypeE)) {
470  reco::PFCandidate& pfc = (reco::PFCandidate&)input;
471  std::cout << "PF cand:" << pfc << '\n';
472  }
473  */
474  fjInputs_.emplace_back(input.px(),input.py(),input.pz(),
475  input.energy());
476  }
477  fjInputs_.back().set_user_index(i - inBegin);
478  }
479 
480  if ( restrictInputs_ && fjInputs_.size() > maxInputs_ ) {
482  std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
483  fjInputs_.resize(maxInputs_);
484  edm::LogWarning("JetRecoTooManyEntries") << "Too many inputs in the event, limiting to first " << maxInputs_ << ". Output is suspect.";
485  }
486 }
JetType::Type jetTypeE
int i
Definition: DBlmapReader.cc:9
reco::Particle::Point vertex_
math::PtEtaPhiMLorentzVector p4(double vtxZ) const
Definition: CaloTower.cc:129
static std::string const input
Definition: EdmProvDump.cc:44
virtual bool isAnomalousTower(reco::CandidatePtr input)
std::vector< fastjet::PseudoJet > fjInputs_
bool isNotFinite(T x)
Definition: isFinite.h:10
std::vector< edm::Ptr< reco::Candidate > > inputs_
bool makeCaloJet(const JetType::Type &fTag)
bool VirtualJetProducer::isAnomalousTower ( reco::CandidatePtr  input)
protectedvirtual

Definition at line 489 of file VirtualJetProducer.cc.

References anomalousTowerDef_, jetTypeE, and makeCaloJet().

Referenced by cms::SubEventGenJetProducer::inputTowers(), and inputTowers().

490 {
491  if (!makeCaloJet(jetTypeE))
492  return false;
493  else
494  return (*anomalousTowerDef_)(*input);
495 }
JetType::Type jetTypeE
std::auto_ptr< AnomalousTower > anomalousTowerDef_
bool makeCaloJet(const JetType::Type &fTag)
std::string VirtualJetProducer::jetType ( ) const
inline

Definition at line 93 of file VirtualJetProducer.h.

93 { return jetType_; }
bool VirtualJetProducer::makeBasicJet ( const JetType::Type fTag)
inlineprotected

Definition at line 68 of file VirtualJetProducer.h.

bool VirtualJetProducer::makeCaloJet ( const JetType::Type fTag)
inlineprotected

Definition at line 53 of file VirtualJetProducer.h.

Referenced by inputTowers(), isAnomalousTower(), and produce().

53  {
54  return fTag == JetType::CaloJet;
55  }
bool VirtualJetProducer::makeGenJet ( const JetType::Type fTag)
inlineprotected

Definition at line 59 of file VirtualJetProducer.h.

59  {
60  return fTag == JetType::GenJet;
61  }
bool VirtualJetProducer::makePFClusterJet ( const JetType::Type fTag)
inlineprotected

Definition at line 65 of file VirtualJetProducer.h.

bool VirtualJetProducer::makePFJet ( const JetType::Type fTag)
inlineprotected

Definition at line 56 of file VirtualJetProducer.h.

Referenced by produce().

56  {
57  return fTag == JetType::PFJet;
58  }
void VirtualJetProducer::makeProduces ( std::string  s,
std::string  tag = "" 
)
protectedvirtual

Definition at line 82 of file VirtualJetProducer.cc.

References GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by SubjetFilterJetProducer::SubjetFilterJetProducer(), and VirtualJetProducer().

83 {
84 
85 
86  if ( writeCompound_ ) {
87  produces<reco::BasicJetCollection>();
88  }
89 
90  if (makeCaloJet(jetTypeE)) {
91  produces<reco::CaloJetCollection>(tag).setBranchAlias(alias);
92  }
93  else if (makePFJet(jetTypeE)) {
94  produces<reco::PFJetCollection>(tag).setBranchAlias(alias);
95  }
96  else if (makeGenJet(jetTypeE)) {
97  produces<reco::GenJetCollection>(tag).setBranchAlias(alias);
98  }
99  else if (makeTrackJet(jetTypeE)) {
100  produces<reco::TrackJetCollection>(tag).setBranchAlias(alias);
101  }
102  else if (makePFClusterJet(jetTypeE)) {
103  produces<reco::PFClusterJetCollection>(tag).setBranchAlias(alias);
104  }
105  else if (makeBasicJet(jetTypeE)) {
106  produces<reco::BasicJetCollection>(tag).setBranchAlias(alias);
107  }
108 }
JetType::Type jetTypeE
bool makeGenJet(const JetType::Type &fTag)
bool makeBasicJet(const JetType::Type &fTag)
bool makeTrackJet(const JetType::Type &fTag)
bool makePFJet(const JetType::Type &fTag)
bool makePFClusterJet(const JetType::Type &fTag)
bool makeCaloJet(const JetType::Type &fTag)
bool VirtualJetProducer::makeTrackJet ( const JetType::Type fTag)
inlineprotected

Definition at line 62 of file VirtualJetProducer.h.

Referenced by FastjetJetProducer::produce().

void VirtualJetProducer::offsetCorrectJets ( std::vector< fastjet::PseudoJet > &  orphanInput)
protected
void VirtualJetProducer::output ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
protectedvirtual

Reimplemented in cms::CompoundJetProducer, and SubjetFilterJetProducer.

Definition at line 532 of file VirtualJetProducer.cc.

References VirtualJetProducer::JetType::BasicJet, VirtualJetProducer::JetType::CaloJet, Exception, VirtualJetProducer::JetType::GenJet, iEvent, jetTypeE, VirtualJetProducer::JetType::PFClusterJet, VirtualJetProducer::JetType::PFJet, VirtualJetProducer::JetType::TrackJet, and writeCompound_.

Referenced by produce().

533 {
534  // Write jets and constitutents. Will use fjJets_, inputs_
535  // and fjClusterSeq_
536 
537  if ( !writeCompound_ ) {
538  switch( jetTypeE ) {
539  case JetType::CaloJet :
540  writeJets<reco::CaloJet>( iEvent, iSetup);
541  break;
542  case JetType::PFJet :
543  writeJets<reco::PFJet>( iEvent, iSetup);
544  break;
545  case JetType::GenJet :
546  writeJets<reco::GenJet>( iEvent, iSetup);
547  break;
548  case JetType::TrackJet :
549  writeJets<reco::TrackJet>( iEvent, iSetup);
550  break;
551  case JetType::PFClusterJet :
552  writeJets<reco::PFClusterJet>( iEvent, iSetup);
553  break;
554  case JetType::BasicJet :
555  writeJets<reco::BasicJet>( iEvent, iSetup);
556  break;
557  default:
558  throw cms::Exception("InvalidInput") << "invalid jet type in VirtualJetProducer\n";
559  break;
560  };
561  } else {
562  // Write jets and constitutents.
563  switch( jetTypeE ) {
564  case JetType::CaloJet :
565  writeCompoundJets<reco::CaloJet>( iEvent, iSetup );
566  break;
567  case JetType::PFJet :
568  writeCompoundJets<reco::PFJet>( iEvent, iSetup );
569  break;
570  case JetType::GenJet :
571  writeCompoundJets<reco::GenJet>( iEvent, iSetup );
572  break;
573  case JetType::BasicJet :
574  writeCompoundJets<reco::BasicJet>( iEvent, iSetup );
575  break;
576  default:
577  throw cms::Exception("InvalidInput") << "invalid jet type in CompoundJetProducer\n";
578  break;
579  };
580  }
581 }
JetType::Type jetTypeE
int iEvent
Definition: GenABIO.cc:230
void VirtualJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Reimplemented in cms::CATopJetProducer, FastjetJetProducer, SubjetFilterJetProducer, CMSInsideOutJetProducer, cms::SubEventGenJetProducer, and cms::SubJetProducer.

Definition at line 300 of file VirtualJetProducer.cc.

References doPUOffsetCorr_, doPVCorrection_, edm::EventID::event(), fjInputs_, fjJetDefinition_, fjJets_, edm::Event::getByToken(), i, edm::EventBase::id(), input_candidatefwdptr_token_, input_candidateview_token_, input_packedcandidatefwdptr_token_, input_vertex_token_, inputs_, inputTowers(), jetTypeE, LogDebug, makeCaloJet(), makePFJet(), bookConverter::max, minSeed_, output(), edm::EventID::run(), runAlgorithm(), subtractor_, swap(), useDeterministicSeed_, and vertex_.

Referenced by cms::SubJetProducer::produce(), CMSInsideOutJetProducer::produce(), SubjetFilterJetProducer::produce(), and FastjetJetProducer::produce().

301 {
302 
303  // If requested, set the fastjet random seed to a deterministic function
304  // of the run/lumi/event.
305  // NOTE!!! The fastjet random number sequence is a global singleton.
306  // Thus, we have to create an object and get access to the global singleton
307  // in order to change it.
308  if ( useDeterministicSeed_ ) {
309  fastjet::GhostedAreaSpec gas;
310  std::vector<int> seeds(2);
311  unsigned int runNum_uint = static_cast <unsigned int> (iEvent.id().run());
312  unsigned int evNum_uint = static_cast <unsigned int> (iEvent.id().event());
313  seeds[0] = std::max(runNum_uint,minSeed_ + 3) + 3 * evNum_uint;
314  seeds[1] = std::max(runNum_uint,minSeed_ + 5) + 5 * evNum_uint;
315  gas.set_random_status(seeds);
316  }
317 
318  LogDebug("VirtualJetProducer") << "Entered produce\n";
319  //determine signal vertex2
320  vertex_=reco::Jet::Point(0,0,0);
322  LogDebug("VirtualJetProducer") << "Adding PV info\n";
324  iEvent.getByToken(input_vertex_token_ , pvCollection);
325  if (pvCollection->size()>0) vertex_=pvCollection->begin()->position();
326  }
327 
328  // For Pileup subtraction using offset correction:
329  // set up geometry map
330  if ( doPUOffsetCorr_ ) {
331  subtractor_->setupGeometryMap(iEvent, iSetup);
332  }
333 
334  // clear data
335  LogDebug("VirtualJetProducer") << "Clear data\n";
336  fjInputs_.clear();
337  fjJets_.clear();
338  inputs_.clear();
339 
340  // get inputs and convert them to the fastjet format (fastjet::PeudoJet)
342 
344  edm::Handle< std::vector<edm::FwdPtr<pat::PackedCandidate> > > packedinputsHandleAsFwdPtr;
345 
346  bool isView = iEvent.getByToken(input_candidateview_token_, inputsHandle);
347  if ( isView ) {
348  if ( inputsHandle->size() == 0) {
349  output( iEvent, iSetup );
350  return;
351  }
352  for (size_t i = 0; i < inputsHandle->size(); ++i) {
353  inputs_.push_back(inputsHandle->ptrAt(i));
354  }
355  } else {
356  bool isPF = iEvent.getByToken(input_candidatefwdptr_token_, pfinputsHandleAsFwdPtr);
357  if ( isPF ) {
358  if ( pfinputsHandleAsFwdPtr->size() == 0) {
359  output( iEvent, iSetup );
360  return;
361  }
362  for (size_t i = 0; i < pfinputsHandleAsFwdPtr->size(); ++i) {
363  if ( (*pfinputsHandleAsFwdPtr)[i].ptr().isAvailable() ) {
364  inputs_.push_back( (*pfinputsHandleAsFwdPtr)[i].ptr() );
365  }
366  else if ( (*pfinputsHandleAsFwdPtr)[i].backPtr().isAvailable() ) {
367  inputs_.push_back( (*pfinputsHandleAsFwdPtr)[i].backPtr() );
368  }
369  }
370  } else {
371  iEvent.getByToken(input_packedcandidatefwdptr_token_, packedinputsHandleAsFwdPtr);
372  if ( packedinputsHandleAsFwdPtr->size() == 0) {
373  output( iEvent, iSetup );
374  return;
375  }
376  for (size_t i = 0; i < packedinputsHandleAsFwdPtr->size(); ++i) {
377  if ( (*packedinputsHandleAsFwdPtr)[i].ptr().isAvailable() ) {
378  inputs_.push_back( (*packedinputsHandleAsFwdPtr)[i].ptr() );
379  }
380  else if ( (*packedinputsHandleAsFwdPtr)[i].backPtr().isAvailable() ) {
381  inputs_.push_back( (*packedinputsHandleAsFwdPtr)[i].backPtr() );
382  }
383  }
384  }
385  }
386  LogDebug("VirtualJetProducer") << "Got inputs\n";
387 
388  // Convert candidates to fastjet::PseudoJets.
389  // Also correct to Primary Vertex. Will modify fjInputs_
390  // and use inputs_
391  fjInputs_.reserve(inputs_.size());
392  inputTowers();
393  LogDebug("VirtualJetProducer") << "Inputted towers\n";
394 
395  // For Pileup subtraction using offset correction:
396  // Subtract pedestal.
397  if ( doPUOffsetCorr_ ) {
398  subtractor_->setDefinition(fjJetDefinition_);
400  subtractor_->calculatePedestal(fjInputs_);
401  subtractor_->subtractPedestal(fjInputs_);
402  LogDebug("VirtualJetProducer") << "Subtracted pedestal\n";
403  }
404  // Run algorithm. Will modify fjJets_ and allocate fjClusterSeq_.
405  // This will use fjInputs_
406  runAlgorithm( iEvent, iSetup );
407 
408  // if ( doPUOffsetCorr_ ) {
409  // subtractor_->setAlgorithm(fjClusterSeq_);
410  // }
411 
412  LogDebug("VirtualJetProducer") << "Ran algorithm\n";
413  // For Pileup subtraction using offset correction:
414  // Now we find jets and need to recalculate their energy,
415  // mark towers participated in jet,
416  // remove occupied towers from the list and recalculate mean and sigma
417  // put the initial towers collection to the jet,
418  // and subtract from initial towers in jet recalculated mean and sigma of towers
419  if ( doPUOffsetCorr_ ) {
420  LogDebug("VirtualJetProducer") << "Do PUOffsetCorr\n";
421  vector<fastjet::PseudoJet> orphanInput;
422  subtractor_->calculateOrphanInput(orphanInput);
423  subtractor_->calculatePedestal(orphanInput);
424  subtractor_->offsetCorrectJets();
425  }
426  // Write the output jets.
427  // This will (by default) call the member function template
428  // "writeJets", but can be overridden.
429  // this will use inputs_
430  output( iEvent, iSetup );
431  LogDebug("VirtualJetProducer") << "Wrote jets\n";
432 
433  // Clear the work vectors so that memory is free for other modules.
434  // Use the trick of swapping with an empty vector so that the memory
435  // is actually given back rather than silently kept.
436  decltype(fjInputs_)().swap(fjInputs_);
437  decltype(fjJets_)().swap(fjJets_);
438  decltype(inputs_)().swap(inputs_);
439 
440  return;
441 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
JetType::Type jetTypeE
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
EventNumber_t event() const
Definition: EventID.h:41
int i
Definition: DBlmapReader.cc:9
reco::Particle::Point vertex_
edm::EDGetTokenT< reco::CandidateView > input_candidateview_token_
std::vector< fastjet::PseudoJet > fjJets_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
virtual void inputTowers()
edm::EDGetTokenT< std::vector< edm::FwdPtr< pat::PackedCandidate > > > input_packedcandidatefwdptr_token_
virtual void runAlgorithm(edm::Event &iEvent, const edm::EventSetup &iSetup)=0
bool makePFJet(const JetType::Type &fTag)
std::vector< fastjet::PseudoJet > fjInputs_
boost::shared_ptr< PileUpSubtractor > subtractor_
std::vector< edm::Ptr< reco::Candidate > > inputs_
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
edm::EDGetTokenT< std::vector< edm::FwdPtr< reco::PFCandidate > > > input_candidatefwdptr_token_
edm::EventID id() const
Definition: EventBase.h:59
virtual void output(edm::Event &iEvent, edm::EventSetup const &iSetup)
bool makeCaloJet(const JetType::Type &fTag)
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
virtual void VirtualJetProducer::runAlgorithm ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
protectedpure virtual
template<class T >
void VirtualJetProducer::writeCompoundJets ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
protected

function template to write out the outputs

Definition at line 755 of file VirtualJetProducer.cc.

References gather_cfg::cout, doAreaFastjet_, fjJets_, getConstituents(), metsig::jet, jetCollInstanceName_, moduleLabel_, point, edm::Event::put(), reco::Jet::setJetArea(), verbosity_, and reco::writeSpecific().

756 {
757  if ( verbosity_ >= 1 ) {
758  std::cout << "<VirtualJetProducer::writeCompoundJets (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
759  }
760 
761  // get a list of output jets
762  std::auto_ptr<reco::BasicJetCollection> jetCollection( new reco::BasicJetCollection() );
763  // get a list of output subjets
764  std::auto_ptr<std::vector<T> > subjetCollection( new std::vector<T>() );
765 
766  // This will store the handle for the subjets after we write them
767  edm::OrphanHandle< std::vector<T> > subjetHandleAfterPut;
768  // this is the mapping of subjet to hard jet
769  std::vector< std::vector<int> > indices;
770  // this is the list of hardjet 4-momenta
771  std::vector<math::XYZTLorentzVector> p4_hardJets;
772  // this is the hardjet areas
773  std::vector<double> area_hardJets;
774 
775  // Loop over the hard jets
776  std::vector<fastjet::PseudoJet>::const_iterator it = fjJets_.begin(),
777  iEnd = fjJets_.end(),
778  iBegin = fjJets_.begin();
779  indices.resize( fjJets_.size() );
780  for ( ; it != iEnd; ++it ) {
781  fastjet::PseudoJet const & localJet = *it;
782  unsigned int jetIndex = it - iBegin;
783  // Get the 4-vector for the hard jet
784  p4_hardJets.push_back( math::XYZTLorentzVector(localJet.px(), localJet.py(), localJet.pz(), localJet.e() ));
785  double localJetArea = 0.0;
786  if ( doAreaFastjet_ && localJet.has_area() ) {
787  localJetArea = localJet.area();
788  }
789  area_hardJets.push_back( localJetArea );
790 
791  // create the subjet list
792  std::vector<fastjet::PseudoJet> constituents;
793  if ( it->has_pieces() ) {
794  constituents = it->pieces();
795  } else if ( it->has_constituents() ) {
796  constituents = it->constituents();
797  }
798 
799  std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = constituents.begin(),
800  itSubJet = itSubJetBegin, itSubJetEnd = constituents.end();
801  for (; itSubJet != itSubJetEnd; ++itSubJet ){
802 
803  fastjet::PseudoJet const & subjet = *itSubJet;
804  if ( verbosity_ >= 1 ) {
805  std::cout << "subjet #" << (itSubJet - itSubJetBegin) << ": Pt = " << subjet.pt() << ", eta = " << subjet.eta() << ", phi = " << subjet.phi() << ", mass = " << subjet.m()
806  << " (#constituents = " << subjet.constituents().size() << ")" << std::endl;
807  std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
808  int idx_constituent = 0;
809  for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
810  constituent != subjet_constituents.end(); ++constituent ) {
811  if ( constituent->pt() < 1.e-3 ) continue; // CV: skip ghosts
812  std::cout << " constituent #" << idx_constituent << ": Pt = " << constituent->pt() << ", eta = " << constituent->eta() << ", phi = " << constituent->phi() << ","
813  << " mass = " << constituent->m() << std::endl;
814  ++idx_constituent;
815  }
816  }
817 
818  if ( verbosity_ >= 1 ) {
819  std::cout << "subjet #" << (itSubJet - itSubJetBegin) << ": Pt = " << subjet.pt() << ", eta = " << subjet.eta() << ", phi = " << subjet.phi() << ", mass = " << subjet.m()
820  << " (#constituents = " << subjet.constituents().size() << ")" << std::endl;
821  std::vector<fastjet::PseudoJet> subjet_constituents = subjet.constituents();
822  int idx_constituent = 0;
823  for ( std::vector<fastjet::PseudoJet>::const_iterator constituent = subjet_constituents.begin();
824  constituent != subjet_constituents.end(); ++constituent ) {
825  if ( constituent->pt() < 1.e-3 ) continue; // CV: skip ghosts
826  std::cout << " constituent #" << idx_constituent << ": Pt = " << constituent->pt() << ", eta = " << constituent->eta() << ", phi = " << constituent->phi() << ","
827  << " mass = " << constituent->m() << std::endl;
828  ++idx_constituent;
829  }
830  }
831 
832  math::XYZTLorentzVector p4Subjet(subjet.px(), subjet.py(), subjet.pz(), subjet.e() );
834 
835  // This will hold ptr's to the subjets
836  std::vector<reco::CandidatePtr> subjetConstituents;
837 
838  // Get the transient subjet constituents from fastjet
839  std::vector<fastjet::PseudoJet> subjetFastjetConstituents = subjet.constituents();
840  std::vector<reco::CandidatePtr> constituents =
841  getConstituents(subjetFastjetConstituents );
842 
843  indices[jetIndex].push_back( subjetCollection->size() );
844 
845  // Add the concrete subjet type to the subjet list to write to event record
846  T jet;
847  reco::writeSpecific( jet, p4Subjet, point, constituents, iSetup);
848  double subjetArea = 0.0;
849  if ( doAreaFastjet_ && itSubJet->has_area() ){
850  subjetArea = itSubJet->area();
851  }
852  jet.setJetArea( subjetArea );
853  subjetCollection->push_back( jet );
854  }
855  }
856 
857  // put subjets into event record
858  subjetHandleAfterPut = iEvent.put( subjetCollection, jetCollInstanceName_ );
859 
860  // Now create the hard jets with ptr's to the subjets as constituents
861  std::vector<math::XYZTLorentzVector>::const_iterator ip4 = p4_hardJets.begin(),
862  ip4Begin = p4_hardJets.begin(),
863  ip4End = p4_hardJets.end();
864 
865  for ( ; ip4 != ip4End; ++ip4 ) {
866  int p4_index = ip4 - ip4Begin;
867  std::vector<int> & ind = indices[p4_index];
868  std::vector<reco::CandidatePtr> i_hardJetConstituents;
869  // Add the subjets to the hard jet
870  for( std::vector<int>::const_iterator isub = ind.begin();
871  isub != ind.end(); ++isub ) {
872  reco::CandidatePtr candPtr( subjetHandleAfterPut, *isub, false );
873  i_hardJetConstituents.push_back( candPtr );
874  }
876  reco::BasicJet toput( *ip4, point, i_hardJetConstituents);
877  toput.setJetArea( area_hardJets[ip4 - ip4Begin] );
878  jetCollection->push_back( toput );
879  }
880 
881  // put hard jets into event record
882  iEvent.put( jetCollection);
883 }
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
std::vector< fastjet::PseudoJet > fjJets_
Jets made from CaloTowers.
Definition: BasicJet.h:20
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
std::string jetCollInstanceName_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
math::XYZPoint Point
point in the space
Definition: Particle.h:25
tuple cout
Definition: gather_cfg.py:145
long double T
*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
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
std::vector< BasicJet > BasicJetCollection
collection of BasicJet objects
template<typename T >
void VirtualJetProducer::writeJets ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
protected

Definition at line 595 of file VirtualJetProducer.cc.

References reco::deltaR2(), HLT_25ns10e33_v2_cff::distance, doAreaDiskApprox_, doAreaFastjet_, doFastJetNonUniform_, doPUOffsetCorr_, doRhoFastjet_, eta, Exception, plotBeamSpotDB::first, fjClusterSeq_, fjJets_, fjRangeDef_, getConstituents(), reco::helper::VirtualJetProducerHelper::intersection(), edm::isNotFinite(), metsig::jet, jetCollInstanceName_, fwrapper::jets, relval_2017::k, M_PI, eostools::move(), HLT_25ns10e33_v2_cff::nEta, nExclude_, puCenters_, edm::Event::put(), puWidth_, dt_dqm_sourceclient_common_cff::reco, rho, fastjet::BackgroundEstimator::rho(), rParam_, edm::second(), fastjet::BackgroundEstimator::set_excluded_jets(), fastjet::BackgroundEstimator::sigma(), mathSSE::sqrt(), subtractor_, vertex_, and reco::writeSpecific().

596 {
597  // std::cout << "writeJets " << typeid(T).name()
598  // << (doRhoFastjet_ ? " doRhoFastjet " : "")
599  // << (doAreaFastjet_ ? " doAreaFastjet " : "")
600  // << (doAreaDiskApprox_ ? " doAreaDiskApprox " : "")
601  // << std::endl;
602 
603  if (doRhoFastjet_) {
604  // declare jet collection without the two jets,
605  // for unbiased background estimation.
606  std::vector<fastjet::PseudoJet> fjexcluded_jets;
607  fjexcluded_jets=fjJets_;
608 
609  if(fjexcluded_jets.size()>2) fjexcluded_jets.resize(nExclude_);
610 
612  std::auto_ptr<std::vector<double> > rhos(new std::vector<double>);
613  std::auto_ptr<std::vector<double> > sigmas(new std::vector<double>);
614  int nEta = puCenters_.size();
615  rhos->reserve(nEta);
616  sigmas->reserve(nEta);
617  fastjet::ClusterSequenceAreaBase const* clusterSequenceWithArea =
618  dynamic_cast<fastjet::ClusterSequenceAreaBase const *> ( &*fjClusterSeq_ );
619 
620  if (clusterSequenceWithArea ==nullptr ){
621  if (fjJets_.size() > 0) {
622  throw cms::Exception("LogicError")<<"fjClusterSeq is not initialized while inputs are present\n ";
623  }
624  } else {
625  for(int ie = 0; ie < nEta; ++ie){
626  double eta = puCenters_[ie];
627  double etamin=eta-puWidth_;
628  double etamax=eta+puWidth_;
629  fastjet::RangeDefinition range_rho(etamin,etamax);
630  fastjet::BackgroundEstimator bkgestim(*clusterSequenceWithArea,range_rho);
631  bkgestim.set_excluded_jets(fjexcluded_jets);
632  rhos->push_back(bkgestim.rho());
633  sigmas->push_back(bkgestim.sigma());
634  }
635  }
636  iEvent.put(rhos,"rhos");
637  iEvent.put(sigmas,"sigmas");
638  }else{
639  std::auto_ptr<double> rho(new double(0.0));
640  std::auto_ptr<double> sigma(new double(0.0));
641  double mean_area = 0;
642 
643  fastjet::ClusterSequenceAreaBase const* clusterSequenceWithArea =
644  dynamic_cast<fastjet::ClusterSequenceAreaBase const *> ( &*fjClusterSeq_ );
645  /*
646  const double nemptyjets = clusterSequenceWithArea->n_empty_jets(*fjRangeDef_);
647  if(( nemptyjets < -15 ) || ( nemptyjets > fjRangeDef_->area()+ 15)) {
648  edm::LogWarning("StrangeNEmtpyJets") << "n_empty_jets is : " << clusterSequenceWithArea->n_empty_jets(*fjRangeDef_) << " with range " << fjRangeDef_->description() << ".";
649  }
650  */
651  if (clusterSequenceWithArea ==nullptr ){
652  if (fjJets_.size() > 0) {
653  throw cms::Exception("LogicError")<<"fjClusterSeq is not initialized while inputs are present\n ";
654  }
655  } else {
656  clusterSequenceWithArea->get_median_rho_and_sigma(*fjRangeDef_,false,*rho,*sigma,mean_area);
657  if((*rho < 0)|| (edm::isNotFinite(*rho))) {
658  edm::LogError("BadRho") << "rho value is " << *rho << " area:" << mean_area << " and n_empty_jets: " << clusterSequenceWithArea->n_empty_jets(*fjRangeDef_) << " with range " << fjRangeDef_->description()
659  <<". Setting rho to rezo.";
660  *rho = 0;
661  }
662  }
663  iEvent.put(rho,"rho");
664  iEvent.put(sigma,"sigma");
665  }
666  } // doRhoFastjet_
667 
668  // produce output jet collection
669 
670  using namespace reco;
671 
672  // allocate fjJets_.size() Ts in vector
673  auto jets = std::make_unique<std::vector<T>>(fjJets_.size());
674 
675  // Distance between jet centers and overlap area -- for disk-based area calculation
676  using RIJ = std::pair<double,double>;
677  std::vector<RIJ> rijStorage(fjJets_.size()*(fjJets_.size()/2));
678  RIJ * rij[fjJets_.size()];
679  unsigned int k=0;
680  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
681  rij[ijet] = &rijStorage[k]; k+=ijet;
682  }
683 
684  float etaJ[fjJets_.size()], phiJ[fjJets_.size()];
685 
686  auto orParam_ = 1./rParam_;
687  // fill jets
688  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
689  auto & jet = (*jets)[ijet];
690  // get the fastjet jet
691  const fastjet::PseudoJet& fjJet = fjJets_[ijet];
692  // get the constituents from fastjet
693  std::vector<fastjet::PseudoJet> const & fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
694  // convert them to CandidatePtr vector
695  std::vector<CandidatePtr> const & constituents = getConstituents(fjConstituents);
696 
697  // write the specifics to the jet (simultaneously sets 4-vector, vertex).
698  // These are overridden functions that will call the appropriate
699  // specific allocator.
701  Particle::LorentzVector(fjJet.px(),
702  fjJet.py(),
703  fjJet.pz(),
704  fjJet.E()),
705  vertex_,
706  constituents, iSetup);
707  phiJ[ijet] = jet.phi();
708  etaJ[ijet] = jet.eta();
709  }
710 
711  // calcuate the jet area
712  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
713  // calcuate the jet area
714  double jetArea=0.0;
715  // get the fastjet jet
716  const auto & fjJet = fjJets_[ijet];
717  if ( doAreaFastjet_ && fjJet.has_area() ) {
718  jetArea = fjJet.area();
719  }
720  else if ( doAreaDiskApprox_ ) {
721  // Here it is assumed that fjJets_ is in decreasing order of pT,
722  // which should happen in FastjetJetProducer::runAlgorithm()
723  jetArea = M_PI;
724  RIJ * distance = rij[ijet];
725  for (unsigned jJet = 0; jJet < ijet; ++jJet) {
726  distance[jJet].first = std::sqrt(reco::deltaR2(etaJ[ijet],phiJ[ijet], etaJ[jJet],phiJ[jJet]))*orParam_;
727  distance[jJet].second = reco::helper::VirtualJetProducerHelper::intersection(distance[jJet].first);
728  jetArea -=distance[jJet].second;
729  for (unsigned kJet = 0; kJet < jJet; ++kJet) {
730  jetArea += reco::helper::VirtualJetProducerHelper::intersection(distance[jJet].first, distance[kJet].first, rij[jJet][kJet].first,
731  distance[jJet].second, distance[kJet].second, rij[jJet][kJet].second);
732  } // end loop over harder jets
733  } // end loop over harder jets
734  jetArea *= (rParam_*rParam_);
735  }
736  auto & jet = (*jets)[ijet];
737  jet.setJetArea (jetArea);
738 
739  if(doPUOffsetCorr_){
740  jet.setPileup(subtractor_->getPileUpEnergy(ijet));
741  }else{
742  jet.setPileup (0.0);
743  }
744 
745  // std::cout << "area " << ijet << " " << jetArea << " " << Area<T>::get(jet) << std::endl;
746  // std::cout << "JetVI " << ijet << ' '<< jet.pt() << " " << jet.et() << ' '<< jet.energy() << ' '<< jet.mass() << std::endl;
747 
748  }
749  // put the jets in the collection
751 }
reco::Particle::Point vertex_
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
std::vector< fastjet::PseudoJet > fjJets_
std::vector< double > puCenters_
U second(std::pair< T, U > const &p)
std::string jetCollInstanceName_
boost::shared_ptr< PileUpSubtractor > subtractor_
bool isNotFinite(T x)
Definition: isFinite.h:10
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
ClusterSequencePtr fjClusterSeq_
T sqrt(T t)
Definition: SSEVec.h:18
vector< PseudoJet > jets
def move
Definition: eostools.py:510
#define M_PI
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
math::PtEtaPhiELorentzVectorF LorentzVector
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

Member Data Documentation

std::auto_ptr<AnomalousTower> VirtualJetProducer::anomalousTowerDef_
private

Definition at line 207 of file VirtualJetProducer.h.

Referenced by isAnomalousTower(), and VirtualJetProducer().

bool VirtualJetProducer::doAreaDiskApprox_
protected

Definition at line 169 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

bool VirtualJetProducer::doAreaFastjet_
protected
bool VirtualJetProducer::doFastJetNonUniform_
protected

Definition at line 172 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

bool VirtualJetProducer::doPUOffsetCorr_
protected

Definition at line 176 of file VirtualJetProducer.h.

Referenced by produce(), VirtualJetProducer(), and writeJets().

bool VirtualJetProducer::doPVCorrection_
protected

Definition at line 160 of file VirtualJetProducer.h.

Referenced by inputTowers(), and produce().

bool VirtualJetProducer::doRhoFastjet_
protected
ActiveAreaSpecPtr VirtualJetProducer::fjActiveArea_
protected

Definition at line 185 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer().

AreaDefinitionPtr VirtualJetProducer::fjAreaDefinition_
protected
ClusterSequencePtr VirtualJetProducer::fjClusterSeq_
protected
std::vector<fastjet::PseudoJet> VirtualJetProducer::fjInputs_
protected
JetDefPtr VirtualJetProducer::fjJetDefinition_
protected
std::vector<fastjet::PseudoJet> VirtualJetProducer::fjJets_
protected
PluginPtr VirtualJetProducer::fjPlugin_
protected

Definition at line 184 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer().

RangeDefPtr VirtualJetProducer::fjRangeDef_
protected

Definition at line 187 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

edm::EDGetTokenT<std::vector<edm::FwdPtr<reco::PFCandidate> > > VirtualJetProducer::input_candidatefwdptr_token_
private

Definition at line 211 of file VirtualJetProducer.h.

Referenced by produce(), and VirtualJetProducer().

edm::EDGetTokenT<reco::CandidateView> VirtualJetProducer::input_candidateview_token_
private

Definition at line 210 of file VirtualJetProducer.h.

Referenced by produce(), and VirtualJetProducer().

edm::EDGetTokenT<std::vector<edm::FwdPtr<pat::PackedCandidate> > > VirtualJetProducer::input_packedcandidatefwdptr_token_
private

Definition at line 212 of file VirtualJetProducer.h.

Referenced by produce(), and VirtualJetProducer().

edm::EDGetTokenT<reco::VertexCollection> VirtualJetProducer::input_vertex_token_
protected
double VirtualJetProducer::inputEMin_
protected

Definition at line 158 of file VirtualJetProducer.h.

Referenced by cms::SubEventGenJetProducer::inputTowers(), and inputTowers().

double VirtualJetProducer::inputEtMin_
protected

Definition at line 157 of file VirtualJetProducer.h.

Referenced by cms::SubEventGenJetProducer::inputTowers(), and inputTowers().

std::vector<edm::Ptr<reco::Candidate> > VirtualJetProducer::inputs_
protected
std::string VirtualJetProducer::jetAlgorithm_
protected

Definition at line 155 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer().

std::string VirtualJetProducer::jetCollInstanceName_
protected
double VirtualJetProducer::jetPtMin_
protected
std::string VirtualJetProducer::jetType_
protected

Definition at line 154 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer().

JetType::Type VirtualJetProducer::jetTypeE
protected
unsigned int VirtualJetProducer::maxInputs_
protected

Definition at line 164 of file VirtualJetProducer.h.

Referenced by inputTowers(), and VirtualJetProducer().

unsigned int VirtualJetProducer::minSeed_
protected

Definition at line 201 of file VirtualJetProducer.h.

Referenced by produce(), and VirtualJetProducer().

std::string VirtualJetProducer::moduleLabel_
protected
unsigned int VirtualJetProducer::nExclude_
protected

Definition at line 194 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

std::vector<double> VirtualJetProducer::puCenters_
protected

Definition at line 192 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

std::string VirtualJetProducer::puSubtractorName_
protected

Definition at line 177 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer().

double VirtualJetProducer::puWidth_
protected

Definition at line 193 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

bool VirtualJetProducer::restrictInputs_
protected

Definition at line 163 of file VirtualJetProducer.h.

Referenced by inputTowers(), and VirtualJetProducer().

double VirtualJetProducer::rParam_
protected

Definition at line 156 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer(), and writeJets().

edm::InputTag VirtualJetProducer::src_
protected
edm::InputTag VirtualJetProducer::srcPVs_
protected

Definition at line 153 of file VirtualJetProducer.h.

Referenced by VirtualJetProducer().

boost::shared_ptr<PileUpSubtractor> VirtualJetProducer::subtractor_
protected

Definition at line 198 of file VirtualJetProducer.h.

Referenced by produce(), VirtualJetProducer(), and writeJets().

bool VirtualJetProducer::useDeterministicSeed_
protected

Definition at line 200 of file VirtualJetProducer.h.

Referenced by produce(), and VirtualJetProducer().

bool VirtualJetProducer::useExplicitGhosts_
protected
int VirtualJetProducer::verbosity_
protected
reco::Particle::Point VirtualJetProducer::vertex_
protected
double VirtualJetProducer::voronoiRfact_
protected
bool VirtualJetProducer::writeCompound_
protected

Definition at line 197 of file VirtualJetProducer.h.

Referenced by output(), and VirtualJetProducer().