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