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_builderToken(esConsumes<edm::Transition::BeginRun>(
98  edm::ESInputTag{"", iConfig.getParameter<std::string>("TTRHBuilder")})) {
99  //now do what ever initialization is needed
100 
101  // histogram parameters
102 
103  edm::LogInfo("TrackCollection") << "Using collection "
104  << iConfig.getParameter<edm::InputTag>("trackCollection").label().c_str();
105 
107 
108  m_nduplicate = tfserv->make<TH1F>("nduplicate", "Number of duplicated clusters per track", 10, -0.5, 9.5);
109  m_nduplmod = tfserv->make<TH1F>("nduplmod", "Number of duplicated clusters per module", 10, -0.5, 9.5);
110  m_nduplmod->SetCanExtend(TH1::kXaxis);
111 }
112 
114  // do anything here that needs to be done at desctruction time
115  // (e.g. close files, deallocate resources etc.)
116 }
117 
118 //
119 // member functions
120 //
121 
122 // ------------ method called to for each event ------------
124  using namespace edm;
126 
128  iEvent.getByToken(m_trkcollToken, tracks);
129 
130  for (reco::TrackCollection::const_iterator it = tracks->begin(); it != tracks->end(); it++) {
131  std::set<SiPixelRecHit::ClusterRef::key_type> clusters;
132  int nduplicate = 0;
133  for (trackingRecHit_iterator rh = it->recHitsBegin(); rh != it->recHitsEnd(); ++rh) {
135  const SiPixelRecHit* pxrh = dynamic_cast<const SiPixelRecHit*>(ttrh->hit());
136  if (pxrh) {
137  // LogTrace("DuplicateHitFinder") << ttrh->det()->geographicalId() << " " << pxrh->cluster().index();
138  if (clusters.find(pxrh->cluster().index()) != clusters.end()) {
139  nduplicate++;
140  std::stringstream detidstr;
141  detidstr << ttrh->det()->geographicalId().rawId();
142  m_nduplmod->Fill(detidstr.str().c_str(), 1.);
143  LogDebug("DuplicateHitFinder") << "Track with " << it->recHitsSize() << " RecHits";
144  LogTrace("DuplicateHitFinder") << "Duplicate found " << ttrh->det()->geographicalId().rawId() << " "
145  << pxrh->cluster().index();
146  }
147  clusters.insert(pxrh->cluster().index());
148  }
149  m_nduplicate->Fill(nduplicate);
150  }
151  }
152 }
153 
154 void DuplicateRecHits::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
155  m_builder = &iSetup.getData(m_builderToken);
156 }
157 
159 
160 // ------------ method called once each job just before starting event loop ------------
162 
163 // ------------ method called once each job just after ending the event loop ------------
165 
166 //define this as a plug-in
DuplicateRecHits::DuplicateRecHits
DuplicateRecHits(const edm::ParameterSet &)
Definition: DuplicateRecHits.cc:95
MessageLogger.h
DuplicateRecHits::m_builder
const TransientTrackingRecHitBuilder * m_builder
Definition: DuplicateRecHits.cc:78
ESHandle.h
ESInputTag
DuplicateRecHits::m_builderToken
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > m_builderToken
Definition: DuplicateRecHits.cc:77
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:154
TrackingRecHit::det
const GeomDet * det() const
Definition: TrackingRecHit.h:122
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
TrackingRecHitFwd.h
TransientTrackingRecHit.h
EDAnalyzer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
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:28
DuplicateRecHits::~DuplicateRecHits
~DuplicateRecHits() override
Definition: DuplicateRecHits.cc:113
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
Run.h
DuplicateRecHits::endJob
void endJob() override
Definition: DuplicateRecHits.cc:164
SiPixelRecHit.h
DuplicateRecHits::m_nduplicate
TH1F * m_nduplicate
Definition: DuplicateRecHits.cc:80
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
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
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
DuplicateRecHits::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: DuplicateRecHits.cc:158
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord >
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
DuplicateRecHits::m_trkcollToken
edm::EDGetTokenT< reco::TrackCollection > m_trkcollToken
Definition: DuplicateRecHits.cc:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Frameworkfwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TransientTrackingRecHitBuilder.h
DuplicateRecHits::beginJob
void beginJob() override
Definition: DuplicateRecHits.cc:161
DuplicateRecHits::m_nduplmod
TH1F * m_nduplmod
Definition: DuplicateRecHits.cc:81
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
DuplicateRecHits::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DuplicateRecHits.cc:123
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