CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
JetCrystalsAssociator Class Reference

#include <RecoBTag/JetCrystalsAssociator/src/JetCrystalsAssociator.cc>

Inheritance diagram for JetCrystalsAssociator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 JetCrystalsAssociator (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~JetCrystalsAssociator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::unique_ptr< JetCrystalsAssociationCollectionassociate (const edm::Handle< CaloJetCollection > &jets, const edm::OrphanHandle< EMLorentzVectorCollection > &myLorentzRecHits) const
 

Private Attributes

double m_deltaRCut
 
edm::InputTag m_EBRecHits
 
edm::InputTag m_EERecHits
 
edm::InputTag m_jetsSrc
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 67 of file JetCrystalsAssociator.cc.

Constructor & Destructor Documentation

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

Definition at line 89 of file JetCrystalsAssociator.cc.

References edm::ParameterSet::getParameter().

90 {
91  produces<reco::JetCrystalsAssociationCollection>();
92  produces<reco::EMLorentzVectorCollection>();
93 
94  m_EBRecHits = iConfig.getParameter<edm::InputTag>("EBRecHits");
95  m_EERecHits = iConfig.getParameter<edm::InputTag>("EERecHits");
96  m_jetsSrc = iConfig.getParameter<edm::InputTag>("jets");
97  m_deltaRCut = iConfig.getParameter<double>("coneSize");
98 }
T getParameter(std::string const &) const
JetCrystalsAssociator::~JetCrystalsAssociator ( )

Definition at line 101 of file JetCrystalsAssociator.cc.

102 {
103 
104  // do anything here that needs to be done at desctruction time
105  // (e.g. close files, deallocate resources etc.)
106 
107 }

Member Function Documentation

std::unique_ptr< JetCrystalsAssociationCollection > JetCrystalsAssociator::associate ( const edm::Handle< CaloJetCollection > &  jets,
const edm::OrphanHandle< EMLorentzVectorCollection > &  myLorentzRecHits 
) const
private

Definition at line 209 of file JetCrystalsAssociator.cc.

References DEFINE_FWK_MODULE, delta, HiRegitMuonDetachedTripletStep_cff::DeltaR, p4, and lumiQTWidget::t.

212 {
213  // we know we will save an element per input jet
214  auto outputCollection = std::make_unique<JetCrystalsAssociationCollection>(jets->size());
215 
216  //loop on jets and associate
217  for (size_t j = 0; j < jets->size(); j++) {
218  (*outputCollection)[j].first = edm::RefToBase<Jet>(CaloJetRef(jets, j));
219  for (size_t t = 0; t < myLorentzRecHits->size(); t++) {
220  double delta = ROOT::Math::VectorUtil::DeltaR((*jets)[j].p4().Vect(), (*myLorentzRecHits)[t]);
221  if (delta < m_deltaRCut)
222  (*outputCollection)[j].second.push_back( EMLorentzVectorRef(myLorentzRecHits, t) );
223  }
224  }
225  return outputCollection;
226 }
dbl * delta
Definition: mlp_gen.cc:36
double p4[4]
Definition: TauolaWrapper.h:92
math::PtEtaPhiELorentzVectorRef EMLorentzVectorRef
edm::Ref< CaloJetCollection > CaloJetRef
edm references
void JetCrystalsAssociator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 116 of file JetCrystalsAssociator.cc.

References CaloTower::constituent(), CaloTower::constituentsSize(), DetId::det(), EB, egHLT::errCodes::EBRecHits, DetId::Ecal, EcalBarrel, EcalEndcap, EE, egHLT::errCodes::EERecHits, edm::SortedCollection< T, SORT >::end(), stringResolutionProvider_cfi::et, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), edm::SortedCollection< T, SORT >::find(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), fwrapper::jets, M_PI, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), edm::Event::put(), funct::sin(), DetId::subdetId(), lumiQTWidget::t, PV3DBase< T, PVType, FrameType >::theta(), and theta().

117 {
118  using namespace edm;
119  using namespace reco;
120  using namespace std;
121 
122  // geometry initialization
124  iSetup.get<CaloGeometryRecord>().get(geometry);
125 
128  // end
129 
131  iEvent.getByLabel(m_jetsSrc, jets);
132 
133  // get calo towers collection
134  // Handle<CaloTowerCollection> caloTowers;
135  // iEvent.getByLabel(m_towersSrc, caloTowers);
136 
137  // calculation of ECAL isolation
140  iEvent.getByLabel( m_EBRecHits, EBRecHits );
141  iEvent.getByLabel( m_EERecHits, EERecHits );
142 
143  auto jetRecHits = std::make_unique<EMLorentzVectorCollection>();
144  //loop on jets and associate
145  for (size_t t = 0; t < jets->size(); t++)
146  {
147  const std::vector<CaloTowerPtr> myTowers=(*jets)[t].getCaloConstituents();
148  // cout <<"Jet id "<<t<<endl;
149  // cout <<"Tower size "<<myTowers.size()<<endl;
150  for (unsigned int iTower = 0; iTower < myTowers.size(); iTower++)
151  {
152  CaloTowerPtr theTower = myTowers[iTower];
153  size_t numRecHits = theTower->constituentsSize();
154  // access CaloRecHits
155  for (size_t j = 0; j < numRecHits; j++) {
156  DetId RecHitDetID=theTower->constituent(j);
157  DetId::Detector DetNum=RecHitDetID.det();
158  if( DetNum == DetId::Ecal ){
159  int EcalNum = RecHitDetID.subdetId();
160  if( EcalNum == 1 ){
161  EBDetId EcalID = RecHitDetID;
162  EBRecHitCollection::const_iterator theRecHit=EBRecHits->find(EcalID);
163  if(theRecHit != EBRecHits->end()){
164  DetId id = theRecHit->detid();
165  const CaloCellGeometry* this_cell = EB->getGeometry(id);
166  if (this_cell) {
167  GlobalPoint posi = this_cell->getPosition();
168  double energy = theRecHit->energy();
169  double eta = posi.eta();
170  double phi = posi.phi();
171  double theta = posi.theta();
172  if(theta > M_PI) theta = 2 * M_PI- theta;
173  double et = energy * sin(theta);
174  // cout <<"Et "<<et<<endl;
175  EMLorentzVector p(et, eta, phi, energy);
176  jetRecHits->push_back(p);
177  }
178  }
179  } else if ( EcalNum == 2 ) {
180  EEDetId EcalID = RecHitDetID;
181  EERecHitCollection::const_iterator theRecHit=EERecHits->find(EcalID);
182  if(theRecHit != EBRecHits->end()){
183  DetId id = theRecHit->detid();
184  const CaloCellGeometry* this_cell = EE->getGeometry(id);
185  if (this_cell) {
186  GlobalPoint posi = this_cell->getPosition();
187  double energy = theRecHit->energy();
188  double eta = posi.eta();
189  double phi = posi.phi();
190  double theta = posi.theta();
191  if (theta > M_PI) theta = 2 * M_PI - theta;
192  double et = energy * sin(theta);
193  // cout <<"Et "<<et<<endl;
194  EMLorentzVector p(et, eta, phi, energy);
195  jetRecHits->push_back(p);
196  }
197  }
198  }
199  }
200  }
201  }
202  }
203 
204  edm::OrphanHandle <reco::EMLorentzVectorCollection> myRecHits = iEvent.put(std::move(jetRecHits));
205 
206  iEvent.put(associate(jets,myRecHits));
207 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
size_t constituentsSize() const
Definition: CaloTower.h:105
std::unique_ptr< JetCrystalsAssociationCollection > associate(const edm::Handle< CaloJetCollection > &jets, const edm::OrphanHandle< EMLorentzVectorCollection > &myLorentzRecHits) const
DetId constituent(size_t i) const
Definition: CaloTower.h:106
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
vector< PseudoJet > jets
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
#define M_PI
const_iterator end() const
Definition: DetId.h:18
Detector
Definition: DetId.h:24
const T & get() const
Definition: EventSetup.h:55
math::PtEtaPhiELorentzVector EMLorentzVector
et
define resolution functions of each parameter
T eta() const
Definition: PV3DBase.h:76
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
fixed size matrix
HLT enums.
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

double JetCrystalsAssociator::m_deltaRCut
private

Definition at line 86 of file JetCrystalsAssociator.cc.

edm::InputTag JetCrystalsAssociator::m_EBRecHits
private

Definition at line 83 of file JetCrystalsAssociator.cc.

edm::InputTag JetCrystalsAssociator::m_EERecHits
private

Definition at line 84 of file JetCrystalsAssociator.cc.

edm::InputTag JetCrystalsAssociator::m_jetsSrc
private

Definition at line 82 of file JetCrystalsAssociator.cc.