CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
RPCPointVsRecHit Class Reference

#include <RPCPointVsRecHit.h>

Inheritance diagram for RPCPointVsRecHit:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 
void beginJob ()
 
void endJob ()
 
 RPCPointVsRecHit (const edm::ParameterSet &pset)
 
 ~RPCPointVsRecHit ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

DQMStoredbe_
 
RPCValidHistograms h_
 
edm::EDGetTokenT
< RPCRecHitCollection
recHitToken_
 
edm::EDGetTokenT
< RPCRecHitCollection
refHitToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 19 of file RPCPointVsRecHit.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file RPCPointVsRecHit.cc.

References dbe_, edm::ParameterSet::getParameter(), cppFunctionSkipper::operator, and AlCaHLTBitMon_QueryRunRegistry::string.

16 {
17  refHitToken_ = consumes<RPCRecHitCollection>(pset.getParameter<edm::InputTag>("refHit"));
18  recHitToken_ = consumes<RPCRecHitCollection>(pset.getParameter<edm::InputTag>("recHit"));
19 
21  if ( !dbe_ )
22  {
23  edm::LogError("RPCPointVsRecHit") << "No DQMStore instance\n";
24  return;
25  }
26 
27  // Book MonitorElements
28  const std::string subDir = pset.getParameter<std::string>("subDir");
29  h_.bookHistograms(dbe_, subDir);
30 }
T getParameter(std::string const &) const
edm::EDGetTokenT< RPCRecHitCollection > refHitToken_
void bookHistograms(DQMStore *dbe, const std::string subDir)
RPCValidHistograms h_
edm::EDGetTokenT< RPCRecHitCollection > recHitToken_
RPCPointVsRecHit::~RPCPointVsRecHit ( )

Definition at line 32 of file RPCPointVsRecHit.cc.

33 {
34 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 44 of file RPCPointVsRecHit.cc.

References dbe_, edm::EventSetup::get(), edm::Event::getByToken(), RPCRoll::id(), match(), RPCDetId::region(), relativeConstraints::ring, RPCDetId::ring(), mathSSE::sqrt(), relativeConstraints::station, and RPCDetId::station().

45 {
46  if ( !dbe_ )
47  {
48  edm::LogError("RPCPointVsRecHit") << "No DQMStore instance\n";
49  return;
50  }
51 
52  // Get the RPC Geometry
54  eventSetup.get<MuonGeometryRecord>().get(rpcGeom);
55 
56  // Retrieve RefHits from the event
58  if ( !event.getByToken(refHitToken_, refHitHandle) )
59  {
60  edm::LogInfo("RPCPointVsRecHit") << "Cannot find reference hit collection\n";
61  return;
62  }
63 
64  // Retrieve RecHits from the event
66  if ( !event.getByToken(recHitToken_, recHitHandle) )
67  {
68  edm::LogInfo("RPCPointVsRecHit") << "Cannot find recHit collection\n";
69  return;
70  }
71 
72  typedef RPCRecHitCollection::const_iterator RecHitIter;
73 
74  // Loop over refHits, fill histograms which does not need associations
75  int nRefHitBarrel = 0, nRefHitEndcap = 0;
76  for ( RecHitIter refHitIter = refHitHandle->begin();
77  refHitIter != refHitHandle->end(); ++refHitIter )
78  {
79  const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
80  const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId()));
81  if ( !roll ) continue;
82 
83  const int region = roll->id().region();
84  const int ring = roll->id().ring();
85  //const int sector = roll->id().sector();
86  const int station = roll->id().station();
87  //const int layer = roll->id().layer();
88  //const int subSector = roll->id().subsector();
89 
90  if ( region == 0 )
91  {
95  }
96  else
97  {
98  h_.refHitOccupancyEndcap_disk->Fill(region*station);
99  h_.refHitOccupancyEndcap_disk_ring->Fill(region*station, ring);
100  }
101 
102  }
103  h_.nRefHitBarrel->Fill(nRefHitBarrel);
104  h_.nRefHitEndcap->Fill(nRefHitEndcap);
105 
106  // Loop over recHits, fill histograms which does not need associations
107  int sumClusterSizeBarrel = 0, sumClusterSizeEndcap = 0;
108  int nRecHitBarrel = 0, nRecHitEndcap = 0;
109  for ( RecHitIter recHitIter = recHitHandle->begin();
110  recHitIter != recHitHandle->end(); ++recHitIter )
111  {
112  const RPCDetId detId = static_cast<const RPCDetId>(recHitIter->rpcId());
113  const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId()));
114  if ( !roll ) continue;
115 
116  const int region = roll->id().region();
117  const int ring = roll->id().ring();
118  //const int sector = roll->id().sector();
119  const int station = (roll->id().station());
120  //const int layer = roll->id().layer();
121  //const int subSector = roll->id().subsector();
122 
123  h_.clusterSize->Fill(recHitIter->clusterSize());
124 
125  if ( region == 0 )
126  {
127  ++nRecHitBarrel;
128  sumClusterSizeBarrel += recHitIter->clusterSize();
129  h_.clusterSizeBarrel->Fill(recHitIter->clusterSize());
133  }
134  else
135  {
136  ++nRecHitEndcap;
137  sumClusterSizeEndcap += recHitIter->clusterSize();
138  h_.clusterSizeEndcap->Fill(recHitIter->clusterSize());
139  h_.recHitOccupancyEndcap_disk->Fill(region*station);
140  h_.recHitOccupancyEndcap_disk_ring->Fill(ring, region*station);
141  }
142 
143  }
144  const double nRecHit = nRecHitBarrel+nRecHitEndcap;
145  h_.nRecHitBarrel->Fill(nRecHitBarrel);
146  h_.nRecHitEndcap->Fill(nRecHitEndcap);
147  if ( nRecHit > 0 )
148  {
149  const int sumClusterSize = sumClusterSizeBarrel+sumClusterSizeEndcap;
150  h_.avgClusterSize->Fill(double(sumClusterSize)/nRecHit);
151 
152  if ( nRecHitBarrel > 0 )
153  {
154  h_.avgClusterSizeBarrel->Fill(double(sumClusterSizeBarrel)/nRecHitBarrel);
155  }
156  if ( nRecHitEndcap > 0 )
157  {
158  h_.avgClusterSizeEndcap->Fill(double(sumClusterSizeEndcap)/nRecHitEndcap);
159  }
160  }
161 
162  // Start matching RefHits to RecHits
163  typedef std::map<RecHitIter, RecHitIter> RecToRecHitMap;
164  RecToRecHitMap refToRecHitMap;
165 
166  for ( RecHitIter refHitIter = refHitHandle->begin();
167  refHitIter != refHitHandle->end(); ++refHitIter )
168  {
169  const RPCDetId refDetId = static_cast<const RPCDetId>(refHitIter->rpcId());
170  const RPCRoll* refRoll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(refDetId));
171  if ( !refRoll ) continue;
172 
173  const double refX = refHitIter->localPosition().x();
174 
175  for ( RecHitIter recHitIter = recHitHandle->begin();
176  recHitIter != recHitHandle->end(); ++recHitIter )
177  {
178  const RPCDetId recDetId = static_cast<const RPCDetId>(recHitIter->rpcId());
179  const RPCRoll* recRoll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(recDetId));
180  if ( !recRoll ) continue;
181 
182  if ( refDetId != recDetId ) continue;
183 
184  const double recX = recHitIter->localPosition().x();
185  const double newDx = fabs(recX - refX);
186 
187  // Associate RefHit to RecHit
188  RecToRecHitMap::const_iterator prevRefToReco = refToRecHitMap.find(refHitIter);
189  if ( prevRefToReco == refToRecHitMap.end() )
190  {
191  refToRecHitMap.insert(std::make_pair(refHitIter, recHitIter));
192  }
193  else
194  {
195  const double oldDx = fabs(prevRefToReco->second->localPosition().x() - refX);
196 
197  if ( newDx < oldDx )
198  {
199  refToRecHitMap[refHitIter] = recHitIter;
200  }
201  }
202  }
203  }
204 
205  // Now we have refHit-recHit mapping
206  // So we can fill up relavant histograms
207  for ( RecToRecHitMap::const_iterator match = refToRecHitMap.begin();
208  match != refToRecHitMap.end(); ++match )
209  {
210  RecHitIter refHitIter = match->first;
211  RecHitIter recHitIter = match->second;
212 
213  const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
214  const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId));
215 
216  const int region = roll->id().region();
217  const int ring = roll->id().ring();
218  //const int sector = roll->id().sector();
219  const int station = roll->id().station();
220  //const int layer = roll->id().layer();
221  //const int subsector = roll->id().subsector();
222 
223  const double refX = refHitIter->localPosition().x();
224  const double recX = recHitIter->localPosition().x();
225  const double errX = sqrt(recHitIter->localPositionError().xx());
226  const double dX = recX - refX;
227  const double pull = errX == 0 ? -999 : dX/errX;
228 
229  //const GlobalPoint refPos = roll->toGlobal(refHitIter->localPosition());
230  //const GlobalPoint recPos = roll->toGlobal(recHitIter->localPosition());
231 
232  if ( region == 0 )
233  {
234  h_.resBarrel->Fill(dX);
235  h_.pullBarrel->Fill(pull);
239 
240  h_.res_wheel_res->Fill(ring, dX);
241  h_.res_station_res->Fill(station, dX);
242  h_.pull_wheel_pull->Fill(ring, pull);
243  h_.pull_station_pull->Fill(station, pull);
244  }
245  else
246  {
247  h_.resEndcap->Fill(dX);
248  h_.pullEndcap->Fill(pull);
249  h_.matchOccupancyEndcap_disk->Fill(region*station);
250  h_.matchOccupancyEndcap_disk_ring->Fill(region*station, ring);
251 
252  h_.res_disk_res->Fill(region*station, dX);
253  h_.res_ring_res->Fill(ring, dX);
254  h_.pull_disk_pull->Fill(region*station, pull);
255  h_.pull_ring_pull->Fill(ring, pull);
256  }
257  }
258 
259 /*
260  // Find Lost hits
261  for ( RecHitIter refHitIter = refHitHandle->begin();
262  refHitIter != refHitHandle->end(); ++refHitIter )
263  {
264  const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
265  const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId));
266 
267  const int region = roll->id().region();
268  const int ring = roll->id().ring();
269  //const int sector = roll->id().sector();
270  const int station = roll->id().station();
271  //const int layer = roll->id().layer();
272  //const int subsector = roll->id().subsector();
273 
274  bool matched = false;
275  for ( RecToRecHitMap::const_iterator match = refToRecHitMap.begin();
276  match != refToRecHitMap.end(); ++match )
277  {
278  if ( refHitIter == match->first )
279  {
280  matched = true;
281  break;
282  }
283  }
284 
285  if ( !matched )
286  {
287  if ( region == 0 )
288  {
289  h_.nUrefHitOccupancyBarrel_wheel->Fill(ring);
290  h_.nUrefHitOccupancyBarrel_wheel_ring->Fill(ring, station);
291  }
292  else
293  {
294  h_.nUnMatchedRefHit_disk->Fill(region*station);
295  h_.nUnMatchedRefHit_disk_ring->Fill(region*station, ring);
296  }
297  }
298  }
299 */
300 
301  // Find Noisy hits
302  for ( RecHitIter recHitIter = recHitHandle->begin();
303  recHitIter != recHitHandle->end(); ++recHitIter )
304  {
305  const RPCDetId detId = static_cast<const RPCDetId>(recHitIter->rpcId());
306  const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId));
307 
308  const int region = roll->id().region();
309  const int ring = roll->id().ring();
310  //const int sector = roll->id().sector();
311  const int station = roll->id().station();
312  //const int layer = roll->id().layer();
313  //const int subsector = roll->id().subsector();
314 
315  bool matched = false;
316  for ( RecToRecHitMap::const_iterator match = refToRecHitMap.begin();
317  match != refToRecHitMap.end(); ++match )
318  {
319  if ( recHitIter == match->second )
320  {
321  matched = true;
322  break;
323  }
324  }
325 
326  if ( !matched )
327  {
328  if ( region == 0 )
329  {
332  h_.umOccupancyBarrel_wheel_station->Fill(ring, station);
333  }
334  else
335  {
336  h_.umOccupancyEndcap_disk->Fill(region*station);
337  h_.umOccupancyEndcap_disk_ring->Fill(region*station, ring);
338  }
339 
340  //const GlobalPoint pos = roll->toGlobal(recHitIter->localPosition());
341  //h_[HName::NoisyHitEta]->Fill(pos.eta());
342  }
343  }
344 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< RPCRecHitCollection > refHitToken_
void Fill(long long x)
RPCDetId id() const
Definition: RPCRoll.cc:24
int ring() const
Definition: RPCDetId.h:72
T sqrt(T t)
Definition: SSEVec.h:48
const T & get() const
Definition: EventSetup.h:55
RPCValidHistograms h_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
edm::EDGetTokenT< RPCRecHitCollection > recHitToken_
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96
void RPCPointVsRecHit::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 36 of file RPCPointVsRecHit.cc.

37 {
38 }
void RPCPointVsRecHit::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file RPCPointVsRecHit.cc.

41 {
42 }

Member Data Documentation

DQMStore* RPCPointVsRecHit::dbe_
private

Definition at line 32 of file RPCPointVsRecHit.h.

RPCValidHistograms RPCPointVsRecHit::h_
private

Definition at line 34 of file RPCPointVsRecHit.h.

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

Definition at line 30 of file RPCPointVsRecHit.h.

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

Definition at line 30 of file RPCPointVsRecHit.h.