CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
RecoTauJetRegionProducer Class Reference
Inheritance diagram for RecoTauJetRegionProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef edm::AssociationMap
< edm::OneToMany< std::vector
< reco::PFJet >, std::vector
< reco::PFCandidate >
, unsigned int > > 
JetToPFCandidateAssociation
 
typedef edm::Association
< reco::PFJetCollection
PFJetMatchMap
 
- 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

void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauJetRegionProducer (const edm::ParameterSet &pset)
 
 ~RecoTauJetRegionProducer ()
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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 ()
 

Private Attributes

double deltaR2_
 
edm::InputTag inputJets_
 
edm::EDGetTokenT
< reco::CandidateView
Jets_token
 
std::string moduleLabel_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pf_token
 
edm::EDGetTokenT
< JetToPFCandidateAssociation
pfCandAssocMap_token
 
edm::InputTag pfCandAssocMapSrc_
 
edm::InputTag pfCandSrc_
 
int verbosity_
 

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)
 
- 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)
 

Detailed Description

Definition at line 32 of file RecoTauJetRegionProducer.cc.

Member Typedef Documentation

Definition at line 36 of file RecoTauJetRegionProducer.cc.

Definition at line 35 of file RecoTauJetRegionProducer.cc.

Constructor & Destructor Documentation

RecoTauJetRegionProducer::RecoTauJetRegionProducer ( const edm::ParameterSet pset)
explicit

Definition at line 58 of file RecoTauJetRegionProducer.cc.

References deltaR(), deltaR2_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), inputJets_, Jets_token, pf_token, pfCandAssocMap_token, pfCandAssocMapSrc_, pfCandSrc_, and verbosity_.

59  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
60 {
61  inputJets_ = cfg.getParameter<edm::InputTag>("src");
62  pfCandSrc_ = cfg.getParameter<edm::InputTag>("pfCandSrc");
63  pfCandAssocMapSrc_ = cfg.getParameter<edm::InputTag>("pfCandAssocMapSrc");
64 
65  pf_token = consumes<reco::PFCandidateCollection>(pfCandSrc_);
66  Jets_token = consumes<reco::CandidateView>(inputJets_);
67  pfCandAssocMap_token = consumes<JetToPFCandidateAssociation>(pfCandAssocMapSrc_);
68 
69  double deltaR = cfg.getParameter<double>("deltaR");
70  deltaR2_ = deltaR*deltaR;
71 
72  verbosity_ = ( cfg.exists("verbosity") ) ?
73  cfg.getParameter<int>("verbosity") : 0;
74 
75  produces<reco::PFJetCollection>("jets");
76  produces<PFJetMatchMap>();
77 }
tuple cfg
Definition: looper.py:259
edm::EDGetTokenT< reco::PFCandidateCollection > pf_token
edm::EDGetTokenT< reco::CandidateView > Jets_token
edm::EDGetTokenT< JetToPFCandidateAssociation > pfCandAssocMap_token
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
RecoTauJetRegionProducer::~RecoTauJetRegionProducer ( )
inline

Definition at line 38 of file RecoTauJetRegionProducer.cc.

38 {}

Member Function Documentation

void RecoTauJetRegionProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 79 of file RecoTauJetRegionProducer.cc.

References reco::CompositePtrCandidate::addDaughter(), edm::RefVector< C, T, F >::begin(), reco::CompositePtrCandidate::clearDaughters(), gather_cfg::cout, reco::deltaR2(), deltaR2_, alignCSCRings::e, edm::RefVector< C, T, F >::end(), edm::helper::Filler< Map >::fill(), edm::Event::get(), edm::Event::getByToken(), reco::PFJet::getPFConstituents(), edm::RefVector< C, T, F >::id(), customizeTrackingMonitorSeedNumber::idx, inputJets_, edm::helper::Filler< Map >::insert(), fwrapper::jets, Jets_token, edm::Ref< C, T, F >::key(), edm::InputTag::label(), moduleLabel_, pf_token, pfCandAssocMap_token, pfCandAssocMapSrc_, pfCandSrc_, edm::Event::put(), edm::RefVector< C, T, F >::size(), and verbosity_.

80 {
81  if ( verbosity_ ) {
82  std::cout << "<RecoTauJetRegionProducer::produce (moduleLabel = " << moduleLabel_ << ")>:" << std::endl;
83  std::cout << " inputJets = " << inputJets_ << std::endl;
84  std::cout << " pfCandSrc = " << pfCandSrc_ << std::endl;
85  std::cout << " pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl;
86  }
87 
89  evt.getByToken(pf_token, pfCandsHandle);
90 
91  // Build Ptrs for all the PFCandidates
92  typedef edm::Ptr<reco::PFCandidate> PFCandPtr;
93  std::vector<PFCandPtr> pfCands;
94  pfCands.reserve(pfCandsHandle->size());
95  for ( size_t icand = 0; icand < pfCandsHandle->size(); ++icand ) {
96  pfCands.push_back(PFCandPtr(pfCandsHandle, icand));
97  }
98 
99  // Get the jets
101  evt.getByToken(Jets_token, jetView);
102  // Convert to a vector of PFJetRefs
103  reco::PFJetRefVector jets = reco::tau::castView<reco::PFJetRefVector>(jetView);
104  size_t nJets = jets.size();
105 
106  // Get the association map matching jets to PFCandidates
107  // (needed for recinstruction of boosted taus)
109  if ( pfCandAssocMapSrc_.label() != "" ) {
110  evt.getByToken(pfCandAssocMap_token, jetToPFCandMap);
111  }
112 
113  // Get the original product, so we can match against it - otherwise the
114  // indices don't match up.
115  edm::ProductID originalId = jets.id();
117  size_t nOriginalJets = 0;
118  // We have to make sure that we have some selected jets, otherwise we don't
119  // actually have a valid product ID to the original jets.
120  if ( nJets ) {
121  try {
122  evt.get(originalId, originalJets);
123  } catch(const cms::Exception &e) {
124  edm::LogError("MissingOriginalCollection")
125  << "Can't get the original jets that made: " << inputJets_
126  << " that have product ID: " << originalId
127  << " from the event!!";
128  throw e;
129  }
130  nOriginalJets = originalJets->size();
131  }
132 
133  std::auto_ptr<reco::PFJetCollection> newJets(new reco::PFJetCollection);
134 
135  // Keep track of the indices of the current jet and the old (original) jet
136  // -1 indicates no match.
137  std::vector<int> matchInfo(nOriginalJets, -1);
138  newJets->reserve(nJets);
139  for ( size_t ijet = 0; ijet < nJets; ++ijet ) {
140  // Get a ref to jet
141  reco::PFJetRef jetRef = jets[ijet];
142  // Make an initial copy.
143  newJets->emplace_back(*jetRef);
144  reco::PFJet& newJet = newJets->back();
145  // Clear out all the constituents
146  newJet.clearDaughters();
147  // Loop over all the PFCands
148  for ( std::vector<PFCandPtr>::const_iterator pfCand = pfCands.begin();
149  pfCand != pfCands.end(); ++pfCand ) {
150  bool isMappedToJet = false;
151  if ( pfCandAssocMapSrc_.label() != "" ) {
152  edm::RefVector<reco::PFCandidateCollection> pfCandsMappedToJet = (*jetToPFCandMap)[jetRef];
153  for ( edm::RefVector<reco::PFCandidateCollection>::const_iterator pfCandMappedToJet = pfCandsMappedToJet.begin();
154  pfCandMappedToJet != pfCandsMappedToJet.end(); ++pfCandMappedToJet ) {
155  if ( reco::deltaR2(**pfCandMappedToJet, **pfCand) < 1.e-8 ) {
156  isMappedToJet = true;
157  break;
158  }
159  }
160  } else {
161  isMappedToJet = true;
162  }
163  if ( reco::deltaR2(*jetRef, **pfCand) < deltaR2_ && isMappedToJet ) newJet.addDaughter(*pfCand);
164  }
165  if ( verbosity_ ) {
166  std::cout << "jet #" << ijet << ": Pt = " << jetRef->pt() << ", eta = " << jetRef->eta() << ", phi = " << jetRef->eta() << ","
167  << " mass = " << jetRef->mass() << ", area = " << jetRef->jetArea() << std::endl;
168  std::vector<reco::PFCandidatePtr> jetConstituents = newJet.getPFConstituents();
169  int idx = 0;
170  for ( std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = jetConstituents.begin();
171  jetConstituent != jetConstituents.end(); ++jetConstituent ) {
172  std::cout << " constituent #" << idx << ": Pt = " << (*jetConstituent)->pt() << ", eta = " << (*jetConstituent)->eta() << ", phi = " << (*jetConstituent)->phi() << std::endl;
173  }
174  }
175  // Match the index of the jet we just made to the index into the original
176  // collection.
177  matchInfo[jetRef.key()] = ijet;
178  }
179 
180  // Put our new jets into the event
181  edm::OrphanHandle<reco::PFJetCollection> newJetsInEvent = evt.put(newJets, "jets");
182 
183  // Create a matching between original jets -> extra collection
184  std::auto_ptr<PFJetMatchMap> matching(new PFJetMatchMap(newJetsInEvent));
185  if ( nJets ) {
186  PFJetMatchMap::Filler filler(*matching);
187  filler.insert(originalJets, matchInfo.begin(), matchInfo.end());
188  filler.fill();
189  }
190  evt.put(matching);
191 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::Association< reco::PFJetCollection > PFJetMatchMap
edm::EDGetTokenT< reco::PFCandidateCollection > pf_token
key_type key() const
Accessor for product key.
Definition: Ref.h:264
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
Jets made from PFObjects.
Definition: PFJet.h:21
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:114
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
edm::EDGetTokenT< reco::CandidateView > Jets_token
vector< PseudoJet > jets
edm::EDGetTokenT< JetToPFCandidateAssociation > pfCandAssocMap_token
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:326
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:170
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void clearDaughters()
clear daughter references
std::string const & label() const
Definition: InputTag.h:43
std::vector< PFJet > PFJetCollection
collection of PFJet objects
void addDaughter(const CandidatePtr &)
add a daughter via a reference
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:52
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

double RecoTauJetRegionProducer::deltaR2_
private

Definition at line 53 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::InputTag RecoTauJetRegionProducer::inputJets_
private

Definition at line 45 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::EDGetTokenT<reco::CandidateView> RecoTauJetRegionProducer::Jets_token
private

Definition at line 50 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

std::string RecoTauJetRegionProducer::moduleLabel_
private
edm::EDGetTokenT<reco::PFCandidateCollection> RecoTauJetRegionProducer::pf_token
private

Definition at line 49 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::EDGetTokenT<JetToPFCandidateAssociation> RecoTauJetRegionProducer::pfCandAssocMap_token
private

Definition at line 51 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::InputTag RecoTauJetRegionProducer::pfCandAssocMapSrc_
private

Definition at line 47 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::InputTag RecoTauJetRegionProducer::pfCandSrc_
private

Definition at line 46 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

int RecoTauJetRegionProducer::verbosity_
private

Definition at line 55 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().