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 // system include files
21 #include <memory>
22 
23 // user include files
26 
30 
32 
34 
35 // my includes
36 
37 #include <string>
38 #include <set>
39 #include <numeric>
40 
41 #include "TH1F.h"
42 
44 
47 
49 
52 
58 //
59 // class decleration
60 //
61 
63 public:
64  explicit DuplicateRecHits(const edm::ParameterSet&);
65  ~DuplicateRecHits() override;
66 
67 private:
68  void beginJob() override;
69  void beginRun(const edm::Run&, const edm::EventSetup&) override;
70  void endRun(const edm::Run&, const edm::EventSetup&) override;
71  void analyze(const edm::Event&, const edm::EventSetup&) override;
72  void endJob() override;
73 
74  // ----------member data ---------------------------
75 
79 
80  TH1F* m_nduplicate;
81  TH1F* m_nduplmod;
82 };
83 
84 //
85 // constants, enums and typedefs
86 //
87 
88 //
89 // static data member definitions
90 //
91 
92 //
93 // constructors and destructor
94 //
96  : m_trkcollToken(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackCollection"))),
97  m_buildername(iConfig.getParameter<std::string>("TTRHBuilder"))
98 
99 {
100  //now do what ever initialization is needed
101 
102  // histogram parameters
103 
104  edm::LogInfo("TrackCollection") << "Using collection "
105  << iConfig.getParameter<edm::InputTag>("trackCollection").label().c_str();
106 
108 
109  m_nduplicate = tfserv->make<TH1F>("nduplicate", "Number of duplicated clusters per track", 10, -0.5, 9.5);
110  m_nduplmod = tfserv->make<TH1F>("nduplmod", "Number of duplicated clusters per module", 10, -0.5, 9.5);
111  m_nduplmod->SetCanExtend(TH1::kXaxis);
112 }
113 
115  // do anything here that needs to be done at desctruction time
116  // (e.g. close files, deallocate resources etc.)
117 }
118 
119 //
120 // member functions
121 //
122 
123 // ------------ method called to for each event ------------
125  using namespace edm;
127 
129  iEvent.getByToken(m_trkcollToken, tracks);
130 
131  for (reco::TrackCollection::const_iterator it = tracks->begin(); it != tracks->end(); it++) {
132  std::set<SiPixelRecHit::ClusterRef::key_type> clusters;
133  int nduplicate = 0;
134  for (trackingRecHit_iterator rh = it->recHitsBegin(); rh != it->recHitsEnd(); ++rh) {
136  const SiPixelRecHit* pxrh = dynamic_cast<const SiPixelRecHit*>(ttrh->hit());
137  if (pxrh) {
138  // LogTrace("DuplicateHitFinder") << ttrh->det()->geographicalId() << " " << pxrh->cluster().index();
139  if (clusters.find(pxrh->cluster().index()) != clusters.end()) {
140  nduplicate++;
141  std::stringstream detidstr;
142  detidstr << ttrh->det()->geographicalId().rawId();
143  m_nduplmod->Fill(detidstr.str().c_str(), 1.);
144  LogDebug("DuplicateHitFinder") << "Track with " << it->recHitsSize() << " RecHits";
145  LogTrace("DuplicateHitFinder") << "Duplicate found " << ttrh->det()->geographicalId().rawId() << " "
146  << pxrh->cluster().index();
147  }
148  clusters.insert(pxrh->cluster().index());
149  }
150  m_nduplicate->Fill(nduplicate);
151  }
152  }
153 }
154 
155 void DuplicateRecHits::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
157  iSetup.get<TransientRecHitRecord>().get(m_buildername, theBuilder);
158  m_builder = theBuilder.product();
159 }
160 
162 
163 // ------------ method called once each job just before starting event loop ------------
165 
166 // ------------ method called once each job just after ending the event loop ------------
168 
169 //define this as a plug-in
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
DuplicateRecHits::DuplicateRecHits
DuplicateRecHits(const edm::ParameterSet &)
Definition: DuplicateRecHits.cc:95
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
MessageLogger.h
DuplicateRecHits::m_builder
const TransientTrackingRecHitBuilder * m_builder
Definition: DuplicateRecHits.cc:78
ESHandle.h
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
TransientRecHitRecord.h
DuplicateRecHits::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DuplicateRecHits.cc:155
TrackingRecHit::det
const GeomDet * det() const
Definition: TrackingRecHit.h:122
edm::LogInfo
Definition: MessageLogger.h:254
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
TrackingRecHitFwd.h
TransientTrackingRecHit.h
EDAnalyzer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
TransientTrackingRecHitBuilder::build
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
edm::Ref::index
key_type index() const
Definition: Ref.h:253
edm::Handle< reco::TrackCollection >
SiPixelRecHit::cluster
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
DuplicateRecHits::~DuplicateRecHits
~DuplicateRecHits() override
Definition: DuplicateRecHits.cc:114
DuplicateRecHits::m_buildername
std::string m_buildername
Definition: DuplicateRecHits.cc:77
MakerMacros.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
Run.h
edm::ESHandle< TransientTrackingRecHitBuilder >
DuplicateRecHits::endJob
void endJob() override
Definition: DuplicateRecHits.cc:167
SiPixelRecHit.h
DuplicateRecHits::m_nduplicate
TH1F * m_nduplicate
Definition: DuplicateRecHits.cc:80
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
DuplicateRecHits::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: DuplicateRecHits.cc:161
get
#define get
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DuplicateRecHits::m_trkcollToken
edm::EDGetTokenT< reco::TrackCollection > m_trkcollToken
Definition: DuplicateRecHits.cc:76
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Frameworkfwd.h
TransientTrackingRecHitBuilder.h
DuplicateRecHits::beginJob
void beginJob() override
Definition: DuplicateRecHits.cc:164
DuplicateRecHits::m_nduplmod
TH1F * m_nduplmod
Definition: DuplicateRecHits.cc:81
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
ParameterSet.h
edm::Event
Definition: Event.h:73
DuplicateRecHits::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DuplicateRecHits.cc:124
TransientTrackingRecHitBuilder
Definition: TransientTrackingRecHitBuilder.h:6
DuplicateRecHits
Definition: DuplicateRecHits.cc:62
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
label
const char * label
Definition: PFTauDecayModeTools.cc:11
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64