CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripElectronProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaElectronProducers
4 // Class : SiStripElectronProducer
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Fri May 26 16:11:30 EDT 2006
11 // $Id: SiStripElectronProducer.cc,v 1.4 2013/01/14 21:33:02 dlange Exp $
12 //
13 
14 // system include files
15 #include <memory>
16 #include <sstream>
17 
18 // user include files
23 
27 
35 
36 //
37 // constants, enums and typedefs
38 //
39 
40 //
41 // static data member definitions
42 //
43 
44 //
45 // constructors and destructor
46 //
48 {
49  // register your products
50  siStripElectronsLabel_ = iConfig.getParameter<std::string>("siStripElectronsLabel");
51  trackCandidatesLabel_ = iConfig.getParameter<std::string>("trackCandidatesLabel");
52  produces<reco::SiStripElectronCollection>(siStripElectronsLabel_);
53  produces<TrackCandidateCollection>(trackCandidatesLabel_);
54 
55  // get parameters
56  siHitProducer_ = iConfig.getParameter<std::string>("siHitProducer");
57  siRphiHitCollection_ = iConfig.getParameter<std::string>("siRphiHitCollection");
58  siStereoHitCollection_ = iConfig.getParameter<std::string>("siStereoHitCollection");
59  siMatchedHitCollection_ = iConfig.getParameter<std::string>("siMatchedHitCollection");
60 
61  superClusterProducer_ = iConfig.getParameter<std::string>("superClusterProducer");
62  superClusterCollection_ = iConfig.getParameter<std::string>("superClusterCollection");
63 
65  iConfig.getParameter<int32_t>("maxHitsOnDetId"),
66  iConfig.getParameter<double>("originUncertainty"),
67  iConfig.getParameter<double>("phiBandWidth"), // this is in radians
68  iConfig.getParameter<double>("maxNormResid"),
69  iConfig.getParameter<int32_t>("minHits"),
70  iConfig.getParameter<double>("maxReducedChi2"));
71 
72  LogDebug("") << " Welcome to SiStripElectronProducer " ;
73 
74 }
75 
76 
77 // SiStripElectronProducer::SiStripElectronProducer(const SiStripElectronProducer& rhs)
78 // {
79 // // do actual copying here;
80 // }
81 
83 {
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86  delete algo_p;
87 }
88 
89 //
90 // assignment operators
91 //
92 // const SiStripElectronProducer& SiStripElectronProducer::operator=(const SiStripElectronProducer& rhs)
93 // {
94 // //An exception safe implementation is
95 // SiStripElectronProducer temp(rhs);
96 // swap(rhs);
97 //
98 // return *this;
99 // }
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called to produce the data ------------
106 void
108 {
109  // Extract data from the event
110  edm::ESHandle<TrackerGeometry> trackerHandle;
111  iSetup.get<TrackerDigiGeometryRecord>().get(trackerHandle);
112 
114  iEvent.getByLabel(siHitProducer_, siRphiHitCollection_, rphiHitsHandle);
115 
117  iEvent.getByLabel(siHitProducer_, siStereoHitCollection_, stereoHitsHandle);
118 
120  iEvent.getByLabel(siHitProducer_, siMatchedHitCollection_, matchedHitsHandle);
121 
122  edm::ESHandle<MagneticField> magneticFieldHandle;
123  iSetup.get<IdealMagneticFieldRecord>().get(magneticFieldHandle);
124 
126  iEvent.getByLabel(superClusterProducer_, superClusterCollection_, superClusterHandle);
127 
128  // Set up SiStripElectronAlgo for this event
129  algo_p->prepareEvent(trackerHandle, rphiHitsHandle, stereoHitsHandle, matchedHitsHandle, magneticFieldHandle);
130 
131  // Prepare the output electron candidates and clouds to be filled
132  std::auto_ptr<reco::SiStripElectronCollection> electronOut(new reco::SiStripElectronCollection);
133  std::auto_ptr<TrackCandidateCollection> trackCandidateOut(new TrackCandidateCollection);
134 
135  //Retrieve tracker topology from geometry
137  iSetup.get<IdealGeometryRecord>().get(tTopoHand);
138  const TrackerTopology *tTopo=tTopoHand.product();
139 
140  // counter for electron candidates
141  int siStripElectCands = 0 ;
142 
143  std::ostringstream str;
144 
145 
146  // Loop over clusters
147  str << "Starting loop over superclusters."<< "\n" << std::endl;
148  for (unsigned int i = 0; i < superClusterHandle.product()->size(); i++) {
149  const reco::SuperCluster* sc = &(*reco::SuperClusterRef(superClusterHandle, i));
150  double energy = sc->energy();
151 
152  if (algo_p->findElectron(*electronOut, *trackCandidateOut, reco::SuperClusterRef(superClusterHandle, i),tTopo)) {
153  str << "Supercluster energy: " << energy << ", FOUND an electron." << "\n" << std::endl;
154  ++siStripElectCands ;
155  }
156  else {
157  str << "Supercluster energy: " << energy << ", DID NOT FIND an electron."<< "\n" << std::endl;
158  }
159  }
160  str << "Ending loop over superclusters." << "\n" << std::endl;
161 
162  str << " Found " << siStripElectCands
163  << " SiStripElectron Candidates before track fit "
164  << "\n" << std::endl ;
165 
166  LogDebug("SiStripElectronProducer") << str.str();
167 
168  // Put the electron candidates and the tracking trajectories into the event
169  iEvent.put(electronOut, siStripElectronsLabel_);
170  iEvent.put(trackCandidateOut, trackCandidatesLabel_);
171 }
172 
173 //
174 // const member functions
175 //
176 
177 //
178 // static member functions
179 //
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
SiStripElectronProducer(const edm::ParameterSet &)
std::vector< TrackCandidate > TrackCandidateCollection
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
std::vector< SiStripElectron > SiStripElectronCollection
collectin of SiStripElectron objects
double energy() const
cluster energy
Definition: CaloCluster.h:120
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool findElectron(reco::SiStripElectronCollection &electronOut, TrackCandidateCollection &trackCandidateOut, const reco::SuperClusterRef &superclusterIn, const TrackerTopology *tTopo)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
virtual void produce(edm::Event &, const edm::EventSetup &)
SiStripElectronAlgo * algo_p
void prepareEvent(const edm::ESHandle< TrackerGeometry > &tracker, const edm::Handle< SiStripRecHit2DCollection > &rphiHits, const edm::Handle< SiStripRecHit2DCollection > &stereoHits, const edm::Handle< SiStripMatchedRecHit2DCollection > &matchedHits, const edm::ESHandle< MagneticField > &magneticField)