CMS 3D CMS Logo

DuplicateRecHits.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DuplicateRecHits
4 // Class: DuplicateRecHits
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Thu Sep 25 16:32:56 CEST 2008
16 // $Id: DuplicateRecHits.cc,v 1.15 2011/11/15 10:09:24 venturia Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
31 
33 
35 
36 // my includes
37 
38 #include <string>
39 #include <set>
40 #include <numeric>
41 
42 #include "TH1F.h"
43 
45 
48 
50 
53 
59 //
60 // class decleration
61 //
62 
64 public:
65  explicit DuplicateRecHits(const edm::ParameterSet&);
66  ~DuplicateRecHits() override;
67 
68 
69 private:
70  void beginJob() override ;
71  void beginRun(const edm::Run&, const edm::EventSetup&) override;
72  void endRun(const edm::Run&, const edm::EventSetup&) override;
73  void analyze(const edm::Event&, const edm::EventSetup&) override;
74  void endJob() override ;
75 
76  // ----------member data ---------------------------
77 
81 
82  TH1F* m_nduplicate;
83  TH1F* m_nduplmod;
84 
85 };
86 
87 //
88 // constants, enums and typedefs
89 //
90 
91 //
92 // static data member definitions
93 //
94 
95 //
96 // constructors and destructor
97 //
99  m_trkcollToken(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackCollection"))),
100  m_buildername(iConfig.getParameter<std::string>("TTRHBuilder"))
101 
102 {
103  //now do what ever initialization is needed
104 
105  // histogram parameters
106 
107  edm::LogInfo("TrackCollection") << "Using collection " << iConfig.getParameter<edm::InputTag>("trackCollection").label().c_str() ;
108 
109 
111 
112  m_nduplicate = tfserv->make<TH1F>("nduplicate","Number of duplicated clusters per track",10,-0.5,9.5);
113  m_nduplmod = tfserv->make<TH1F>("nduplmod","Number of duplicated clusters per module",10,-0.5,9.5);
114  m_nduplmod->SetCanExtend(TH1::kXaxis);
115 }
116 
117 
119 {
120 
121  // do anything here that needs to be done at desctruction time
122  // (e.g. close files, deallocate resources etc.)
123 
124 }
125 
126 
127 //
128 // member functions
129 //
130 
131 // ------------ method called to for each event ------------
132 void
134 {
135  using namespace edm;
137 
139  iEvent.getByToken(m_trkcollToken,tracks);
140 
141 
142  for(reco::TrackCollection::const_iterator it = tracks->begin();it!=tracks->end();it++) {
143 
144  std::set<SiPixelRecHit::ClusterRef::key_type> clusters;
145  int nduplicate=0;
146  for(trackingRecHit_iterator rh= it->recHitsBegin(); rh!=it->recHitsEnd();++rh) {
148  const SiPixelRecHit * pxrh = dynamic_cast<const SiPixelRecHit*>(ttrh->hit());
149  if (pxrh) {
150  // LogTrace("DuplicateHitFinder") << ttrh->det()->geographicalId() << " " << pxrh->cluster().index();
151  if(clusters.find(pxrh->cluster().index())!=clusters.end()) {
152  nduplicate++;
153  std::stringstream detidstr;
154  detidstr << ttrh->det()->geographicalId().rawId();
155  m_nduplmod->Fill(detidstr.str().c_str(),1.);
156  LogDebug("DuplicateHitFinder") << "Track with " << it->recHitsSize() << " RecHits";
157  LogTrace("DuplicateHitFinder") << "Duplicate found " << ttrh->det()->geographicalId().rawId() << " " << pxrh->cluster().index();
158  }
159  clusters.insert(pxrh->cluster().index());
160  }
161  m_nduplicate->Fill(nduplicate);
162  }
163 
164  }
165 
166 }
167 
168 void
170 {
172  iSetup.get<TransientRecHitRecord>().get(m_buildername, theBuilder);
173  m_builder = theBuilder.product();
174 }
175 
176 void
178 {
179 }
180 
181 
182 
183 // ------------ method called once each job just before starting event loop ------------
184 void
186 {
187 }
188 
189 // ------------ method called once each job just after ending the event loop ------------
190 void
192 {
193 }
194 
195 //define this as a plug-in
#define LogDebug(id)
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
key_type index() const
Definition: Ref.h:268
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
~DuplicateRecHits() override
std::string m_buildername
const TransientTrackingRecHitBuilder * m_builder
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int iEvent
Definition: GenABIO.cc:230
const GeomDet * det() const
void endRun(const edm::Run &, const edm::EventSetup &) override
void endJob() override
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
#define LogTrace(id)
std::shared_ptr< TrackingRecHit const > RecHitPointer
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
void beginJob() override
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< reco::TrackCollection > m_trkcollToken
fixed size matrix
HLT enums.
DuplicateRecHits(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
T const * product() const
Definition: ESHandle.h:86
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: Run.h:43
Our base class.
Definition: SiPixelRecHit.h:23