CMS 3D CMS Logo

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