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.2 2007/08/28 01:42:29 ratnik Exp $
12 //
13 
14 // system include files
15 #include <memory>
16 #include <sstream>
17 
18 // user include files
24 
28 
36 
37 //
38 // constants, enums and typedefs
39 //
40 
41 //
42 // static data member definitions
43 //
44 
45 //
46 // constructors and destructor
47 //
49 {
50  // register your products
51  siStripElectronsLabel_ = iConfig.getParameter<std::string>("siStripElectronsLabel");
52  trackCandidatesLabel_ = iConfig.getParameter<std::string>("trackCandidatesLabel");
53  produces<reco::SiStripElectronCollection>(siStripElectronsLabel_);
54  produces<TrackCandidateCollection>(trackCandidatesLabel_);
55 
56  // get parameters
57  siHitProducer_ = iConfig.getParameter<std::string>("siHitProducer");
58  siRphiHitCollection_ = iConfig.getParameter<std::string>("siRphiHitCollection");
59  siStereoHitCollection_ = iConfig.getParameter<std::string>("siStereoHitCollection");
60  siMatchedHitCollection_ = iConfig.getParameter<std::string>("siMatchedHitCollection");
61 
62  superClusterProducer_ = iConfig.getParameter<std::string>("superClusterProducer");
63  superClusterCollection_ = iConfig.getParameter<std::string>("superClusterCollection");
64 
66  iConfig.getParameter<int32_t>("maxHitsOnDetId"),
67  iConfig.getParameter<double>("originUncertainty"),
68  iConfig.getParameter<double>("phiBandWidth"), // this is in radians
69  iConfig.getParameter<double>("maxNormResid"),
70  iConfig.getParameter<int32_t>("minHits"),
71  iConfig.getParameter<double>("maxReducedChi2"));
72 
73  LogDebug("") << " Welcome to SiStripElectronProducer " ;
74 
75 }
76 
77 
78 // SiStripElectronProducer::SiStripElectronProducer(const SiStripElectronProducer& rhs)
79 // {
80 // // do actual copying here;
81 // }
82 
84 {
85  // do anything here that needs to be done at desctruction time
86  // (e.g. close files, deallocate resources etc.)
87  delete algo_p;
88 }
89 
90 //
91 // assignment operators
92 //
93 // const SiStripElectronProducer& SiStripElectronProducer::operator=(const SiStripElectronProducer& rhs)
94 // {
95 // //An exception safe implementation is
96 // SiStripElectronProducer temp(rhs);
97 // swap(rhs);
98 //
99 // return *this;
100 // }
101 
102 //
103 // member functions
104 //
105 
106 // ------------ method called to produce the data ------------
107 void
109 {
110  // Extract data from the event
111  edm::ESHandle<TrackerGeometry> trackerHandle;
112  iSetup.get<TrackerDigiGeometryRecord>().get(trackerHandle);
113 
115  iEvent.getByLabel(siHitProducer_, siRphiHitCollection_, rphiHitsHandle);
116 
118  iEvent.getByLabel(siHitProducer_, siStereoHitCollection_, stereoHitsHandle);
119 
121  iEvent.getByLabel(siHitProducer_, siMatchedHitCollection_, matchedHitsHandle);
122 
123  edm::ESHandle<MagneticField> magneticFieldHandle;
124  iSetup.get<IdealMagneticFieldRecord>().get(magneticFieldHandle);
125 
127  iEvent.getByLabel(superClusterProducer_, superClusterCollection_, superClusterHandle);
128 
129  // Set up SiStripElectronAlgo for this event
130  algo_p->prepareEvent(trackerHandle, rphiHitsHandle, stereoHitsHandle, matchedHitsHandle, magneticFieldHandle);
131 
132  // Prepare the output electron candidates and clouds to be filled
133  std::auto_ptr<reco::SiStripElectronCollection> electronOut(new reco::SiStripElectronCollection);
134  std::auto_ptr<TrackCandidateCollection> trackCandidateOut(new TrackCandidateCollection);
135 
136  // counter for electron candidates
137  int siStripElectCands = 0 ;
138 
139  std::ostringstream str;
140 
141 
142  // Loop over clusters
143  str << "Starting loop over superclusters."<< "\n" << std::endl;
144  for (unsigned int i = 0; i < superClusterHandle.product()->size(); i++) {
145  const reco::SuperCluster* sc = &(*reco::SuperClusterRef(superClusterHandle, i));
146  double energy = sc->energy();
147 
148  if (algo_p->findElectron(*electronOut, *trackCandidateOut, reco::SuperClusterRef(superClusterHandle, i))) {
149  str << "Supercluster energy: " << energy << ", FOUND an electron." << "\n" << std::endl;
150  ++siStripElectCands ;
151  }
152  else {
153  str << "Supercluster energy: " << energy << ", DID NOT FIND an electron."<< "\n" << std::endl;
154  }
155  }
156  str << "Ending loop over superclusters." << "\n" << std::endl;
157 
158  str << " Found " << siStripElectCands
159  << " SiStripElectron Candidates before track fit "
160  << "\n" << std::endl ;
161 
162  LogDebug("SiStripElectronProducer") << str.str();
163 
164  // Put the electron candidates and the tracking trajectories into the event
165  iEvent.put(electronOut, siStripElectronsLabel_);
166  iEvent.put(trackCandidateOut, trackCandidatesLabel_);
167 }
168 
169 //
170 // const member functions
171 //
172 
173 //
174 // static member functions
175 //
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
SiStripElectronProducer(const edm::ParameterSet &)
std::vector< TrackCandidate > TrackCandidateCollection
bool findElectron(reco::SiStripElectronCollection &electronOut, TrackCandidateCollection &trackCandidateOut, const reco::SuperClusterRef &superclusterIn)
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:85
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:356
const T & get() const
Definition: EventSetup.h:55
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)