#include <RecoEgamma/EgammaElectronProducers/interface/SiStripElectronAssociator.h>
Public Member Functions | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
SiStripElectronAssociator (const edm::ParameterSet &) | |
~SiStripElectronAssociator () | |
Private Attributes | |
std::string | electronsLabel_ |
std::string | siStripElectronCollection_ |
std::string | siStripElectronProducer_ |
std::string | trackCollection_ |
std::string | trackProducer_ |
Implementation: <Notes on="" implementation>="">
Usage: <usage>
Definition at line 40 of file SiStripElectronAssociator.h.
SiStripElectronAssociator::SiStripElectronAssociator | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 52 of file SiStripElectronAssociator.cc.
References electronsLabel_, edm::ParameterSet::getParameter(), siStripElectronCollection_, siStripElectronProducer_, trackCollection_, and trackProducer_.
00053 { 00054 //register your products 00055 electronsLabel_ = iConfig.getParameter<std::string>("electronsLabel"); 00056 produces<reco::ElectronCollection>(electronsLabel_); 00057 00058 //now do what ever other initialization is needed 00059 siStripElectronProducer_ = iConfig.getParameter<std::string>("siStripElectronProducer"); 00060 siStripElectronCollection_ = iConfig.getParameter<std::string>("siStripElectronCollection"); 00061 trackProducer_ = iConfig.getParameter<std::string>("trackProducer"); 00062 trackCollection_ = iConfig.getParameter<std::string>("trackCollection"); 00063 }
SiStripElectronAssociator::~SiStripElectronAssociator | ( | ) |
Definition at line 66 of file SiStripElectronAssociator.cc.
00067 { 00068 00069 // do anything here that needs to be done at desctruction time 00070 // (e.g. close files, deallocate resources etc.) 00071 00072 }
void SiStripElectronAssociator::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 81 of file SiStripElectronAssociator.cc.
References reco::TrackBase::charge(), e, metsig::electron, electronsLabel_, lat::endl(), edm::Event::getByLabel(), i, LogDebug, muonGeometry::mag(), 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_, siStripElectronProducer_, siStripElectrons_cfi::siStripElectrons, trackCollection_, trackProducer_, tracks, reco::TrackBase::vx(), reco::TrackBase::vy(), and reco::TrackBase::vz().
00082 { 00083 00084 // position tolerance for equality of 2 hits set to 10 microns 00085 static const double positionTol = 1e-3 ; 00086 00087 edm::Handle<reco::SiStripElectronCollection> siStripElectrons; 00088 iEvent.getByLabel(siStripElectronProducer_, siStripElectronCollection_, siStripElectrons); 00089 00090 edm::Handle<reco::TrackCollection> tracks; 00091 iEvent.getByLabel(trackProducer_, trackCollection_, tracks); 00092 00093 std::map<const reco::SiStripElectron*, bool> alreadySeen; 00094 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectrons->begin(); strippyIter != siStripElectrons->end(); ++strippyIter) { 00095 alreadySeen[&(*strippyIter)] = false; 00096 } 00097 00098 // Output the high-level Electrons 00099 std::auto_ptr<reco::ElectronCollection> output(new reco::ElectronCollection); 00100 00101 LogDebug("") << " About to loop over tracks " << std::endl ; 00102 LogDebug("") << " Number of tracks in Associator " << tracks.product()->size() ; 00103 LogDebug("") << " Number of SiStripElectron Candidates " << siStripElectrons->size(); 00104 00105 // The reco::Track's hits are a (improper?) subset of the reco::SiStripElectron's 00106 // countSiElFit counts electron candidates that return w/ a good track fit 00107 int countSiElFit = 0 ; 00108 for (unsigned int i = 0; i < tracks.product()->size(); i++) { 00109 const reco::Track* trackPtr = &(*reco::TrackRef(tracks, i)); 00110 00111 std::ostringstream debugstr; 00112 00113 // If the reco::Track and the reco::SiStripElectron share even 00114 // one hit in common, they belong to each other. (Disjoint sets 00115 // of hits are assigned to electrons.) So let's look at one hit. 00116 00117 // But first, make sure the track's hit list is not empty. 00118 if (trackPtr->recHitsBegin() == trackPtr->recHitsEnd()) { continue; } 00119 00120 00121 00122 // Detector id is not enough to completely specify a hit 00123 uint32_t id = (*trackPtr->recHitsBegin())->geographicalId().rawId(); 00124 LocalPoint pos = (*trackPtr->recHitsBegin())->localPosition(); 00125 00126 debugstr << " New Track Candidate " << i 00127 << " DetId " << id 00128 << " pos " << pos << "\n" ; 00129 00130 // Find the electron with that hit! 00131 bool foundElectron = false; 00132 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectrons->begin(); strippyIter != siStripElectrons->end(); ++strippyIter) { 00133 if (!alreadySeen[&(*strippyIter)]) { 00134 00135 00136 00137 bool hitInCommon = false; 00138 00139 debugstr << " Looping over Mono hits " << "\n" ; 00140 00141 for (edm::RefVector<SiStripRecHit2DCollection>::const_iterator hitIter = strippyIter->rphiRecHits().begin(); hitIter != strippyIter->rphiRecHits().end(); ++hitIter) { 00142 00143 debugstr << " SiStripCand " 00144 << " DetId " << (*hitIter)->geographicalId().rawId() 00145 << " localPos " << (*hitIter)->localPosition() 00146 << " deltasPos " << ((*hitIter)->localPosition() - pos).mag() ; 00147 00148 if ((*hitIter)->geographicalId().rawId() == id && 00149 ((*hitIter)->localPosition() - pos).mag() < positionTol ) { 00150 hitInCommon = true; 00151 debugstr << " hitInCommon True " << "\n" ; 00152 break; 00153 } else { 00154 debugstr << " hitInCommon False " << "\n" ; 00155 } 00156 } // end loop over rphi hits 00157 00158 00159 if(!hitInCommon) { 00160 debugstr << " Looping over Stereo hits " << "\n" ; 00161 00162 for (edm::RefVector<SiStripRecHit2DCollection>::const_iterator hitIter = strippyIter->stereoRecHits().begin(); hitIter != strippyIter->stereoRecHits().end(); ++hitIter) { 00163 00164 debugstr << " SiStripCand " 00165 << " DetId " << (*hitIter)->geographicalId().rawId() 00166 << " localPos " << (*hitIter)->localPosition() 00167 << " deltasPos " << ((*hitIter)->localPosition() - pos).mag() ; 00168 00169 if ((*hitIter)->geographicalId().rawId() == id && 00170 ((*hitIter)->localPosition() - pos).mag() < positionTol) { 00171 hitInCommon = true; 00172 debugstr << " hitInCommon True " << "\n" ; 00173 break; 00174 } else { 00175 debugstr << " hitInCommon False " << "\n" ; 00176 } 00177 00178 } // end loop over stereo hits 00179 } // end of hitInCommon check for loop over stereo hits 00180 00181 if (hitInCommon) { 00182 debugstr << " Hit in Common Found \n" ; 00183 ++countSiElFit ; 00184 foundElectron = true; 00185 alreadySeen[&(*strippyIter)] = true; 00186 00187 reco::Electron electron((trackPtr->charge() > 0 ? 1 : -1), 00188 math::XYZTLorentzVector(trackPtr->px(), 00189 trackPtr->py(), 00190 trackPtr->pz(), 00191 trackPtr->p()), 00192 math::XYZPoint(trackPtr->vx(), 00193 trackPtr->vy(), 00194 trackPtr->vz())); 00195 electron.setSuperCluster(strippyIter->superCluster()); 00196 electron.setTrack(reco::TrackRef(tracks, i)); 00197 00198 output->push_back(electron); 00199 break ; // no need to check other SiStripElectrons if this one is good 00200 00201 } else { 00202 00203 debugstr << "Hit in Common NOT found \n" ; 00204 00205 } 00206 // endif this electron belongs to this track 00207 00208 00209 } // endif we haven't seen this electron before 00210 debugstr << "Done with this electron " << "\n\n\n"; 00211 } // end loop over electrons 00212 00213 LogDebug("") << debugstr.str() << std::endl ; 00214 LogDebug("") << "Testing if foundElectron " << foundElectron << std::endl ; 00215 00216 if (!foundElectron) { 00217 edm::LogError("SIStripElectron") 00218 // throw cms::Exception("InconsistentData") 00219 << " It is possible that the trackcollection used '" 00220 << trackCollection_ << "' from producer '" << trackProducer_ 00221 << "' is not consistent with '"<< siStripElectronCollection_ 00222 << "' from the producer '"<< siStripElectronProducer_ 00223 << "' --- Please check your cfg file " << "\n" 00224 << " OR Hit Position don't match " 00225 // << "\n" << std::endl 00226 ; 00227 } 00228 00229 LogDebug("") << "At end of track loop \n" << std::endl; 00230 00231 } // end loop over tracks 00232 00233 00234 LogDebug("") << " Number of SiStripElectrons returned with a good fit " 00235 << countSiElFit << "\n"<< std::endl ; 00236 00237 iEvent.put(output,electronsLabel_); 00238 }
std::string SiStripElectronAssociator::electronsLabel_ [private] |
Definition at line 54 of file SiStripElectronAssociator.h.
Referenced by produce(), and SiStripElectronAssociator().
std::string SiStripElectronAssociator::siStripElectronCollection_ [private] |
Definition at line 50 of file SiStripElectronAssociator.h.
Referenced by produce(), and SiStripElectronAssociator().
std::string SiStripElectronAssociator::siStripElectronProducer_ [private] |
Definition at line 49 of file SiStripElectronAssociator.h.
Referenced by produce(), and SiStripElectronAssociator().
std::string SiStripElectronAssociator::trackCollection_ [private] |
Definition at line 52 of file SiStripElectronAssociator.h.
Referenced by produce(), and SiStripElectronAssociator().
std::string SiStripElectronAssociator::trackProducer_ [private] |
Definition at line 51 of file SiStripElectronAssociator.h.
Referenced by produce(), and SiStripElectronAssociator().