Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <memory>
00016 #include <sstream>
00017
00018
00019 #include "DataFormats/EgammaCandidates/interface/SiStripElectronFwd.h"
00020 #include "SiStripElectronProducer.h"
00021 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00022 #include "DataFormats/RoadSearchCloud/interface/RoadSearchCloudCollection.h"
00023 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00024
00025 #include "FWCore/Framework/interface/Event.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028
00029 #include "DataFormats/Common/interface/Handle.h"
00030 #include "FWCore/Framework/interface/ESHandle.h"
00031 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00032 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00033 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
00034 #include "MagneticField/Engine/interface/MagneticField.h"
00035 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 SiStripElectronProducer::SiStripElectronProducer(const edm::ParameterSet& iConfig)
00049 {
00050
00051 siStripElectronsLabel_ = iConfig.getParameter<std::string>("siStripElectronsLabel");
00052 trackCandidatesLabel_ = iConfig.getParameter<std::string>("trackCandidatesLabel");
00053 produces<reco::SiStripElectronCollection>(siStripElectronsLabel_);
00054 produces<TrackCandidateCollection>(trackCandidatesLabel_);
00055
00056
00057 siHitProducer_ = iConfig.getParameter<std::string>("siHitProducer");
00058 siRphiHitCollection_ = iConfig.getParameter<std::string>("siRphiHitCollection");
00059 siStereoHitCollection_ = iConfig.getParameter<std::string>("siStereoHitCollection");
00060 siMatchedHitCollection_ = iConfig.getParameter<std::string>("siMatchedHitCollection");
00061
00062 superClusterProducer_ = iConfig.getParameter<std::string>("superClusterProducer");
00063 superClusterCollection_ = iConfig.getParameter<std::string>("superClusterCollection");
00064
00065 algo_p = new SiStripElectronAlgo(
00066 iConfig.getParameter<int32_t>("maxHitsOnDetId"),
00067 iConfig.getParameter<double>("originUncertainty"),
00068 iConfig.getParameter<double>("phiBandWidth"),
00069 iConfig.getParameter<double>("maxNormResid"),
00070 iConfig.getParameter<int32_t>("minHits"),
00071 iConfig.getParameter<double>("maxReducedChi2"));
00072
00073 LogDebug("") << " Welcome to SiStripElectronProducer " ;
00074
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 SiStripElectronProducer::~SiStripElectronProducer()
00084 {
00085
00086
00087 delete algo_p;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 void
00108 SiStripElectronProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00109 {
00110
00111 edm::ESHandle<TrackerGeometry> trackerHandle;
00112 iSetup.get<TrackerDigiGeometryRecord>().get(trackerHandle);
00113
00114 edm::Handle<SiStripRecHit2DCollection> rphiHitsHandle;
00115 iEvent.getByLabel(siHitProducer_, siRphiHitCollection_, rphiHitsHandle);
00116
00117 edm::Handle<SiStripRecHit2DCollection> stereoHitsHandle;
00118 iEvent.getByLabel(siHitProducer_, siStereoHitCollection_, stereoHitsHandle);
00119
00120 edm::Handle<SiStripMatchedRecHit2DCollection> matchedHitsHandle;
00121 iEvent.getByLabel(siHitProducer_, siMatchedHitCollection_, matchedHitsHandle);
00122
00123 edm::ESHandle<MagneticField> magneticFieldHandle;
00124 iSetup.get<IdealMagneticFieldRecord>().get(magneticFieldHandle);
00125
00126 edm::Handle<reco::SuperClusterCollection> superClusterHandle;
00127 iEvent.getByLabel(superClusterProducer_, superClusterCollection_, superClusterHandle);
00128
00129
00130 algo_p->prepareEvent(trackerHandle, rphiHitsHandle, stereoHitsHandle, matchedHitsHandle, magneticFieldHandle);
00131
00132
00133 std::auto_ptr<reco::SiStripElectronCollection> electronOut(new reco::SiStripElectronCollection);
00134 std::auto_ptr<TrackCandidateCollection> trackCandidateOut(new TrackCandidateCollection);
00135
00136
00137 int siStripElectCands = 0 ;
00138
00139 std::ostringstream str;
00140
00141
00142
00143 str << "Starting loop over superclusters."<< "\n" << std::endl;
00144 for (unsigned int i = 0; i < superClusterHandle.product()->size(); i++) {
00145 const reco::SuperCluster* sc = &(*reco::SuperClusterRef(superClusterHandle, i));
00146 double energy = sc->energy();
00147
00148 if (algo_p->findElectron(*electronOut, *trackCandidateOut, reco::SuperClusterRef(superClusterHandle, i))) {
00149 str << "Supercluster energy: " << energy << ", FOUND an electron." << "\n" << std::endl;
00150 ++siStripElectCands ;
00151 }
00152 else {
00153 str << "Supercluster energy: " << energy << ", DID NOT FIND an electron."<< "\n" << std::endl;
00154 }
00155 }
00156 str << "Ending loop over superclusters." << "\n" << std::endl;
00157
00158 str << " Found " << siStripElectCands
00159 << " SiStripElectron Candidates before track fit "
00160 << "\n" << std::endl ;
00161
00162 LogDebug("SiStripElectronProducer") << str.str();
00163
00164
00165 iEvent.put(electronOut, siStripElectronsLabel_);
00166 iEvent.put(trackCandidateOut, trackCandidatesLabel_);
00167 }
00168
00169
00170
00171
00172
00173
00174
00175