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 Attributes
SiStripElectronAssociator Class Reference

#include <RecoEgamma/EgammaElectronProducers/interface/SiStripElectronAssociator.h>

Inheritance diagram for SiStripElectronAssociator:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 
 SiStripElectronAssociator (const edm::ParameterSet &)
 
 ~SiStripElectronAssociator ()
 
- 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

edm::InputTag electronsLabel_
 
edm::EDGetTokenT
< reco::SiStripElectronCollection
siStripElectronCollection_
 
edm::EDGetTokenT
< reco::TrackCollection
trackCollection_
 

Additional Inherited Members

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

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

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

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

Usage: <usage>

Definition at line 42 of file SiStripElectronAssociator.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file SiStripElectronAssociator.cc.

References electronsLabel_, edm::ParameterSet::getParameter(), edm::InputTag::label(), siStripElectronCollection_, and trackCollection_.

51 {
52  //register your products
53  electronsLabel_ = iConfig.getParameter<edm::InputTag>("electronsLabel");
54  produces<reco::ElectronCollection>(electronsLabel_.label());
55 
56  //now do what ever other initialization is needed
57  siStripElectronCollection_ = consumes<reco::SiStripElectronCollection>(iConfig.getParameter<edm::InputTag>("siStripElectronCollection"));
58  trackCollection_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackCollection"));
59 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > trackCollection_
std::string const & label() const
Definition: InputTag.h:43
edm::EDGetTokenT< reco::SiStripElectronCollection > siStripElectronCollection_
SiStripElectronAssociator::~SiStripElectronAssociator ( )

Definition at line 62 of file SiStripElectronAssociator.cc.

63 {}

Member Function Documentation

void SiStripElectronAssociator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::stream::EDProducerBase.

Definition at line 67 of file SiStripElectronAssociator.cc.

References reco::TrackBase::charge(), alignCSCRings::e, metsig::electron, electronsLabel_, Exception, edm::Event::getByToken(), i, edm::InputTag::label(), LogDebug, mag(), convertSQLitetoXML_cfg::output, reco::TrackBase::p(), edm::Handle< T >::product(), edm::Event::put(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), reco::Electron::setSuperCluster(), reco::Electron::setTrack(), siStripElectronCollection_, siStripElectrons_cfi::siStripElectrons, trackCollection_, testEve_cfg::tracks, reco::TrackBase::vx(), reco::TrackBase::vy(), and reco::TrackBase::vz().

68 {
69 
70  // position tolerance for equality of 2 hits set to 10 microns
71  static const double positionTol = 1e-3 ;
72 
74  iEvent.getByToken(siStripElectronCollection_, siStripElectrons);
75 
77  iEvent.getByToken(trackCollection_, tracks);
78 
79  std::map<const reco::SiStripElectron*, bool> alreadySeen;
80  for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectrons->begin(); strippyIter != siStripElectrons->end(); ++strippyIter) {
81  alreadySeen[&(*strippyIter)] = false;
82  }
83 
84  // Output the high-level Electrons
85  std::auto_ptr<reco::ElectronCollection> output(new reco::ElectronCollection);
86 
87  LogDebug("SiStripElectronAssociator") << " About to loop over tracks " << std::endl ;
88  LogDebug("SiStripElectronAssociator") << " Number of tracks in Associator " << tracks.product()->size() ;
89  LogDebug("SiStripElectronAssociator") << " Number of SiStripElectron Candidates " << siStripElectrons->size();
90 
91  // The reco::Track's hits are a (improper?) subset of the reco::SiStripElectron's
92  // countSiElFit counts electron candidates that return w/ a good track fit
93  int countSiElFit = 0 ;
94  for (unsigned int i = 0; i < tracks.product()->size(); i++) {
95  const reco::Track* trackPtr = &(*reco::TrackRef(tracks, i));
96 
97  // If the reco::Track and the reco::SiStripElectron share even
98  // one hit in common, they belong to each other. (Disjoint sets
99  // of hits are assigned to electrons.) So let's look at one hit.
100 
101  // But first, make sure the track's hit list is not empty.
102  if (trackPtr->recHitsBegin() == trackPtr->recHitsEnd()) { continue; }
103 
104  // Detector id is not enough to completely specify a hit
105  uint32_t id = (*trackPtr->recHitsBegin())->geographicalId().rawId();
106  LocalPoint pos = (*trackPtr->recHitsBegin())->localPosition();
107 
108  LogDebug("SiStripElectronAssociator") << " New Track Candidate " << i
109  << " DetId " << id
110  << " pos " << pos << "\n";
111 
112  // Find the electron with that hit!
113  bool foundElectron = false;
114  for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectrons->begin(); strippyIter != siStripElectrons->end(); ++strippyIter) {
115  if (!alreadySeen[&(*strippyIter)]) {
116 
117  bool hitInCommon = false;
118  LogDebug("SiStripElectronAssociator") << " Looping over Mono hits " << "\n" ;
119 
120  for (std::vector<SiStripRecHit2D>::const_iterator hitIter = strippyIter->rphiRecHits().begin(); hitIter != strippyIter->rphiRecHits().end(); ++hitIter) {
121 
122  LogDebug("SiStripElectronAssociator") << " SiStripCand "
123  << " DetId " << hitIter->geographicalId().rawId()
124  << " localPos " << hitIter->localPosition()
125  << " deltasPos " << (hitIter->localPosition() - pos).mag() ;
126 
127  if (hitIter->geographicalId().rawId() == id &&
128  (hitIter->localPosition() - pos).mag() < positionTol ) {
129  hitInCommon = true;
130  LogDebug("SiStripElectronAssociator") << " hitInCommon True " << "\n" ;
131  break;
132  } else {
133  LogDebug("SiStripElectronAssociator") << " hitInCommon False " << "\n" ;
134  }
135  } // end loop over rphi hits
136 
137  if(!hitInCommon) {
138  LogDebug("SiStripElectronAssociator") << " Looping over Stereo hits " << "\n" ;
139 
140  for (std::vector<SiStripRecHit2D>::const_iterator hitIter = strippyIter->stereoRecHits().begin(); hitIter != strippyIter->stereoRecHits().end(); ++hitIter) {
141 
142  LogDebug("SiStripElectronAssociator") << " SiStripCand "
143  << " DetId " << hitIter->geographicalId().rawId()
144  << " localPos " << hitIter->localPosition()
145  << " deltasPos " << (hitIter->localPosition() - pos).mag() ;
146 
147  if (hitIter->geographicalId().rawId() == id &&
148  (hitIter->localPosition() - pos).mag() < positionTol) {
149  hitInCommon = true;
150  LogDebug("SiStripElectronAssociator") << " hitInCommon True " << "\n" ;
151  break;
152  } else {
153  LogDebug("SiStripElectronAssociator") << " hitInCommon False " << "\n" ;
154  }
155 
156  } // end loop over stereo hits
157  } // end of hitInCommon check for loop over stereo hits
158 
159  if (hitInCommon) {
160  LogDebug("SiStripElectronAssociator") << " Hit in Common Found \n" ;
161  ++countSiElFit ;
162  foundElectron = true;
163  alreadySeen[&(*strippyIter)] = true;
164 
165  reco::Electron electron((trackPtr->charge() > 0 ? 1 : -1),
166  math::XYZTLorentzVector(trackPtr->px(),
167  trackPtr->py(),
168  trackPtr->pz(),
169  trackPtr->p()),
170  math::XYZPoint(trackPtr->vx(),
171  trackPtr->vy(),
172  trackPtr->vz()));
173  electron.setSuperCluster(strippyIter->superCluster());
174  electron.setTrack(reco::TrackRef(tracks, i));
175 
176  output->push_back(electron);
177  break ; // no need to check other SiStripElectrons if this one is good
178 
179  } else {
180  LogDebug("SiStripElectronAssociator") << "Hit in Common NOT found \n" ;
181  }
182  // endif this electron belongs to this track
183 
184 
185  } // endif we haven't seen this electron before
186  LogDebug("SiStripElectronAssociator") << "Done with this electron " << "\n\n\n";
187  } // end loop over electrons
188 
189  LogDebug("SiStripElectronAssociator") << "Testing if foundElectron " << foundElectron << std::endl;
190 
191  if (!foundElectron) {
192  throw cms::Exception("Configuration")
193  << " Inconsistent track collection!";
194  }
195 
196  LogDebug("SiStripElectronAssociator") << "At end of track loop \n" << std::endl;
197 
198  } // end loop over tracks
199 
200 
201  LogDebug("SiStripElectronAssociator") << " Number of SiStripElectrons returned with a good fit "
202  << countSiElFit << "\n"<< std::endl ;
203  iEvent.put(output, electronsLabel_.label());
204 }
#define LogDebug(id)
double p() const
momentum vector magnitude
Definition: TrackBase.h:602
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:614
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::EDGetTokenT< reco::TrackCollection > trackCollection_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:626
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:656
T const * product() const
Definition: Handle.h:81
hitCont::const_iterator hitIter
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
std::string const & label() const
Definition: InputTag.h:43
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:650
int charge() const
track electric charge
Definition: TrackBase.h:554
edm::EDGetTokenT< reco::SiStripElectronCollection > siStripElectronCollection_
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:620
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:644
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109

Member Data Documentation

edm::InputTag SiStripElectronAssociator::electronsLabel_
private

Definition at line 54 of file SiStripElectronAssociator.h.

Referenced by produce(), and SiStripElectronAssociator().

edm::EDGetTokenT<reco::SiStripElectronCollection> SiStripElectronAssociator::siStripElectronCollection_
private

Definition at line 51 of file SiStripElectronAssociator.h.

Referenced by produce(), and SiStripElectronAssociator().

edm::EDGetTokenT<reco::TrackCollection> SiStripElectronAssociator::trackCollection_
private

Definition at line 52 of file SiStripElectronAssociator.h.

Referenced by produce(), and SiStripElectronAssociator().