CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
RPCPointVsRecHit Class Reference

#include <RPCPointVsRecHit.h>

Inheritance diagram for RPCPointVsRecHit:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
 RPCPointVsRecHit (const edm::ParameterSet &pset)
 
 ~RPCPointVsRecHit () override
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

RPCValidHistograms h_
 
edm::EDGetTokenT< RPCRecHitCollectionrecHitToken_
 
edm::EDGetTokenT< RPCRecHitCollectionrefHitToken_
 
edm::ESGetToken< RPCGeometry, MuonGeometryRecordrpcGeomToken_
 
std::string subDir_
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 21 of file RPCPointVsRecHit.h.

Constructor & Destructor Documentation

◆ RPCPointVsRecHit()

RPCPointVsRecHit::RPCPointVsRecHit ( const edm::ParameterSet pset)

Definition at line 13 of file RPCPointVsRecHit.cc.

References deDxTools::esConsumes(), muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

13  {
14  refHitToken_ = consumes<RPCRecHitCollection>(pset.getParameter<edm::InputTag>("refHit"));
15  recHitToken_ = consumes<RPCRecHitCollection>(pset.getParameter<edm::InputTag>("recHit"));
16 
17  subDir_ = pset.getParameter<std::string>("subDir");
18 
20 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
edm::EDGetTokenT< RPCRecHitCollection > refHitToken_
std::string subDir_
edm::EDGetTokenT< RPCRecHitCollection > recHitToken_

◆ ~RPCPointVsRecHit()

RPCPointVsRecHit::~RPCPointVsRecHit ( )
inlineoverride

Definition at line 24 of file RPCPointVsRecHit.h.

24 {};

Member Function Documentation

◆ analyze()

void RPCPointVsRecHit::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
overridevirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 22 of file RPCPointVsRecHit.cc.

References hcalRecHitTable_cff::detId, dX(), fftjetvertexadder_cfi::errX, options_cfi::eventSetup, nano_mu_digi_cff::region, relativeConstraints::ring, nano_mu_digi_cff::roll, mathSSE::sqrt(), and relativeConstraints::station.

22  {
23  // Get the RPC Geometry
24  auto rpcGeom = eventSetup.getHandle(rpcGeomToken_);
25 
26  // Retrieve RefHits from the event
28  if (!event.getByToken(refHitToken_, refHitHandle)) {
29  edm::LogInfo("RPCPointVsRecHit") << "Cannot find reference hit collection\n";
30  return;
31  }
32 
33  // Retrieve RecHits from the event
35  if (!event.getByToken(recHitToken_, recHitHandle)) {
36  edm::LogInfo("RPCPointVsRecHit") << "Cannot find recHit collection\n";
37  return;
38  }
39 
40  typedef RPCRecHitCollection::const_iterator RecHitIter;
41 
42  // Loop over refHits, fill histograms which does not need associations
43  int nRefHitBarrel = 0, nRefHitEndcap = 0;
44  for (RecHitIter refHitIter = refHitHandle->begin(); refHitIter != refHitHandle->end(); ++refHitIter) {
45  const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
46  const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(detId()));
47  if (!roll)
48  continue;
49 
50  const int region = roll->id().region();
51  const int ring = roll->id().ring();
52  // const int sector = roll->id().sector();
53  const int station = roll->id().station();
54  // const int layer = roll->id().layer();
55  // const int subSector = roll->id().subsector();
56 
57  if (region == 0) {
61  } else {
64  }
65  }
66  h_.nRefHitBarrel->Fill(nRefHitBarrel);
67  h_.nRefHitEndcap->Fill(nRefHitEndcap);
68 
69  // Loop over recHits, fill histograms which does not need associations
70  int sumClusterSizeBarrel = 0, sumClusterSizeEndcap = 0;
71  int nRecHitBarrel = 0, nRecHitEndcap = 0;
72  for (RecHitIter recHitIter = recHitHandle->begin(); recHitIter != recHitHandle->end(); ++recHitIter) {
73  const RPCDetId detId = static_cast<const RPCDetId>(recHitIter->rpcId());
74  const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(detId()));
75  if (!roll)
76  continue;
77 
78  const int region = roll->id().region();
79  const int ring = roll->id().ring();
80  // const int sector = roll->id().sector();
81  const int station = (roll->id().station());
82  // const int layer = roll->id().layer();
83  // const int subSector = roll->id().subsector();
84 
85  h_.clusterSize->Fill(recHitIter->clusterSize());
86 
87  if (region == 0) {
88  ++nRecHitBarrel;
89  sumClusterSizeBarrel += recHitIter->clusterSize();
90  h_.clusterSizeBarrel->Fill(recHitIter->clusterSize());
94  } else {
95  ++nRecHitEndcap;
96  sumClusterSizeEndcap += recHitIter->clusterSize();
97  h_.clusterSizeEndcap->Fill(recHitIter->clusterSize());
100  }
101  }
102  const double nRecHit = nRecHitBarrel + nRecHitEndcap;
103  h_.nRecHitBarrel->Fill(nRecHitBarrel);
104  h_.nRecHitEndcap->Fill(nRecHitEndcap);
105  if (nRecHit > 0) {
106  const int sumClusterSize = sumClusterSizeBarrel + sumClusterSizeEndcap;
107  h_.avgClusterSize->Fill(double(sumClusterSize) / nRecHit);
108 
109  if (nRecHitBarrel > 0) {
110  h_.avgClusterSizeBarrel->Fill(double(sumClusterSizeBarrel) / nRecHitBarrel);
111  }
112  if (nRecHitEndcap > 0) {
113  h_.avgClusterSizeEndcap->Fill(double(sumClusterSizeEndcap) / nRecHitEndcap);
114  }
115  }
116 
117  // Start matching RefHits to RecHits
118  typedef std::map<RecHitIter, RecHitIter> RecToRecHitMap;
119  RecToRecHitMap refToRecHitMap;
120 
121  for (RecHitIter refHitIter = refHitHandle->begin(); refHitIter != refHitHandle->end(); ++refHitIter) {
122  const RPCDetId refDetId = static_cast<const RPCDetId>(refHitIter->rpcId());
123  const RPCRoll *refRoll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(refDetId));
124  if (!refRoll)
125  continue;
126 
127  const double refX = refHitIter->localPosition().x();
128 
129  for (RecHitIter recHitIter = recHitHandle->begin(); recHitIter != recHitHandle->end(); ++recHitIter) {
130  const RPCDetId recDetId = static_cast<const RPCDetId>(recHitIter->rpcId());
131  const RPCRoll *recRoll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(recDetId));
132  if (!recRoll)
133  continue;
134 
135  if (refDetId != recDetId)
136  continue;
137 
138  const double recX = recHitIter->localPosition().x();
139  const double newDx = fabs(recX - refX);
140 
141  // Associate RefHit to RecHit
142  RecToRecHitMap::const_iterator prevRefToReco = refToRecHitMap.find(refHitIter);
143  if (prevRefToReco == refToRecHitMap.end()) {
144  refToRecHitMap.insert(std::make_pair(refHitIter, recHitIter));
145  } else {
146  const double oldDx = fabs(prevRefToReco->second->localPosition().x() - refX);
147 
148  if (newDx < oldDx) {
149  refToRecHitMap[refHitIter] = recHitIter;
150  }
151  }
152  }
153  }
154 
155  // Now we have refHit-recHit mapping
156  // So we can fill up relavant histograms
157  for (RecToRecHitMap::const_iterator match = refToRecHitMap.begin(); match != refToRecHitMap.end(); ++match) {
158  RecHitIter refHitIter = match->first;
159  RecHitIter recHitIter = match->second;
160 
161  const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
162  const RPCRoll *roll = dynamic_cast<const RPCRoll *>(rpcGeom->roll(detId));
163 
164  const int region = roll->id().region();
165  const int ring = roll->id().ring();
166  // const int sector = roll->id().sector();
167  const int station = roll->id().station();
168  // const int layer = roll->id().layer();
169  // const int subsector = roll->id().subsector();
170 
171  const double refX = refHitIter->localPosition().x();
172  const double recX = recHitIter->localPosition().x();
173  const double errX = sqrt(recHitIter->localPositionError().xx());
174  const double dX = recX - refX;
175  const double pull = errX == 0 ? -999 : dX / errX;
176 
177  // const GlobalPoint refPos = roll->toGlobal(refHitIter->localPosition());
178  // const GlobalPoint recPos = roll->toGlobal(recHitIter->localPosition());
179 
180  if (region == 0) {
181  h_.resBarrel->Fill(dX);
182  h_.pullBarrel->Fill(pull);
186 
189  h_.pull_wheel_pull->Fill(ring, pull);
191  } else {
192  h_.resEndcap->Fill(dX);
193  h_.pullEndcap->Fill(pull);
196 
199  h_.pull_disk_pull->Fill(region * station, pull);
200  h_.pull_ring_pull->Fill(ring, pull);
201  }
202  }
203 }
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
edm::EDGetTokenT< RPCRecHitCollection > refHitToken_
void Fill(long long x)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
T sqrt(T t)
Definition: SSEVec.h:19
Log< level::Info, false > LogInfo
float dX(const MatchPair &match)
RPCValidHistograms h_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Definition: event.py:1
edm::EDGetTokenT< RPCRecHitCollection > recHitToken_

◆ bookHistograms()

void RPCPointVsRecHit::bookHistograms ( DQMStore::IBooker booker,
edm::Run const &  run,
edm::EventSetup const &  eventSetup 
)
overridevirtual

Implements DQMEDAnalyzer.

Definition at line 205 of file RPCPointVsRecHit.cc.

207  {
208  // Book MonitorElements
209  h_.bookHistograms(booker, subDir_);
210 }
void bookHistograms(DQMStore::IBooker &booker, const std::string &subDir)
std::string subDir_
RPCValidHistograms h_

Member Data Documentation

◆ h_

RPCValidHistograms RPCPointVsRecHit::h_
private

Definition at line 34 of file RPCPointVsRecHit.h.

◆ recHitToken_

edm::EDGetTokenT<RPCRecHitCollection> RPCPointVsRecHit::recHitToken_
private

Definition at line 30 of file RPCPointVsRecHit.h.

◆ refHitToken_

edm::EDGetTokenT<RPCRecHitCollection> RPCPointVsRecHit::refHitToken_
private

Definition at line 30 of file RPCPointVsRecHit.h.

◆ rpcGeomToken_

edm::ESGetToken<RPCGeometry, MuonGeometryRecord> RPCPointVsRecHit::rpcGeomToken_
private

Definition at line 31 of file RPCPointVsRecHit.h.

◆ subDir_

std::string RPCPointVsRecHit::subDir_
private

Definition at line 33 of file RPCPointVsRecHit.h.