CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 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 Member Functions

std::auto_ptr
< JetCrystalsAssociationCollection
associate (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::auto_ptr< JetCrystalsAssociationCollection > JetCrystalsAssociator::associate ( const edm::Handle< CaloJetCollection > &  jets,
const edm::OrphanHandle< EMLorentzVectorCollection > &  myLorentzRecHits 
) const
private

Definition at line 210 of file JetCrystalsAssociator.cc.

References delta, HLT_25ns14e33_v1_cff::DeltaR, j, p4, and tree::t.

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

Implements edm::EDProducer.

Definition at line 116 of file JetCrystalsAssociator.cc.

References DetId::det(), egHLT::errCodes::EBRecHits, DetId::Ecal, EcalBarrel, EcalEndcap, egHLT::errCodes::EERecHits, relval_parameters_module::energy, eta, PV3DBase< T, PVType, FrameType >::eta(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), CaloCellGeometry::getPosition(), j, fwrapper::jets, M_PI, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), phi(), edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, funct::sin(), DetId::subdetId(), tree::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 
126  const CaloSubdetectorGeometry* EB = geometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
127  const CaloSubdetectorGeometry* EE = geometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
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  std::auto_ptr<EMLorentzVectorCollection> jetRecHits( new 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(jetRecHits);
205 
206  std::auto_ptr<JetCrystalsAssociationCollection> jetCrystals = associate(jets,myRecHits);
207  iEvent.put( jetCrystals );
208 }
tuple t
Definition: tree.py:139
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
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
math::PtEtaPhiELorentzVectorCollection EMLorentzVectorCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
vector< PseudoJet > jets
int j
Definition: DBlmapReader.cc:9
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:420
#define M_PI
std::auto_ptr< JetCrystalsAssociationCollection > associate(const edm::Handle< CaloJetCollection > &jets, const edm::OrphanHandle< EMLorentzVectorCollection > &myLorentzRecHits) const
Definition: DetId.h:18
Detector
Definition: DetId.h:24
const T & get() const
Definition: EventSetup.h:56
math::PtEtaPhiELorentzVector EMLorentzVector
T eta() const
Definition: PV3DBase.h:76
ESHandle< TrackerGeometry > geometry
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.

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.