Go to the documentation of this file.00001 #include "Validation/RPCRecHits/interface/RPCPointVsRecHit.h"
00002 #include "FWCore/Framework/interface/MakerMacros.h"
00003
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
00008 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
00009 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00010 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00011
00012 using namespace std;
00013
00014 typedef MonitorElement* MEP;
00015
00016 RPCPointVsRecHit::RPCPointVsRecHit(const edm::ParameterSet& pset)
00017 {
00018 refHitLabel_ = pset.getParameter<edm::InputTag>("refHit");
00019 recHitLabel_ = pset.getParameter<edm::InputTag>("recHit");
00020
00021 dbe_ = edm::Service<DQMStore>().operator->();
00022 if ( !dbe_ )
00023 {
00024 edm::LogError("RPCPointVsRecHit") << "No DQMStore instance\n";
00025 return;
00026 }
00027
00028
00029 const std::string subDir = pset.getParameter<std::string>("subDir");
00030 h_.bookHistograms(dbe_, subDir);
00031 }
00032
00033 RPCPointVsRecHit::~RPCPointVsRecHit()
00034 {
00035 }
00036
00037 void RPCPointVsRecHit::beginJob()
00038 {
00039 }
00040
00041 void RPCPointVsRecHit::endJob()
00042 {
00043 }
00044
00045 void RPCPointVsRecHit::analyze(const edm::Event& event, const edm::EventSetup& eventSetup)
00046 {
00047 if ( !dbe_ )
00048 {
00049 edm::LogError("RPCPointVsRecHit") << "No DQMStore instance\n";
00050 return;
00051 }
00052
00053
00054 edm::ESHandle<RPCGeometry> rpcGeom;
00055 eventSetup.get<MuonGeometryRecord>().get(rpcGeom);
00056
00057
00058 edm::Handle<RPCRecHitCollection> refHitHandle;
00059 if ( !event.getByLabel(refHitLabel_, refHitHandle) )
00060 {
00061 edm::LogInfo("RPCPointVsRecHit") << "Cannot find reference hit collection\n";
00062 return;
00063 }
00064
00065
00066 edm::Handle<RPCRecHitCollection> recHitHandle;
00067 if ( !event.getByLabel(recHitLabel_, recHitHandle) )
00068 {
00069 edm::LogInfo("RPCPointVsRecHit") << "Cannot find recHit collection\n";
00070 return;
00071 }
00072
00073 typedef RPCRecHitCollection::const_iterator RecHitIter;
00074
00075
00076 int nRefHitBarrel = 0, nRefHitEndcap = 0;
00077 for ( RecHitIter refHitIter = refHitHandle->begin();
00078 refHitIter != refHitHandle->end(); ++refHitIter )
00079 {
00080 const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
00081 const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId()));
00082 if ( !roll ) continue;
00083
00084 const int region = roll->id().region();
00085 const int ring = roll->id().ring();
00086
00087 const int station = roll->id().station();
00088
00089
00090
00091 if ( region == 0 )
00092 {
00093 h_.refHitOccupancyBarrel_wheel->Fill(ring);
00094 h_.refHitOccupancyBarrel_station->Fill(station);
00095 h_.refHitOccupancyBarrel_wheel_station->Fill(ring, station);
00096 }
00097 else
00098 {
00099 h_.refHitOccupancyEndcap_disk->Fill(region*station);
00100 h_.refHitOccupancyEndcap_disk_ring->Fill(region*station, ring);
00101 }
00102
00103 }
00104 h_.nRefHitBarrel->Fill(nRefHitBarrel);
00105 h_.nRefHitEndcap->Fill(nRefHitEndcap);
00106
00107
00108 int sumClusterSizeBarrel = 0, sumClusterSizeEndcap = 0;
00109 int nRecHitBarrel = 0, nRecHitEndcap = 0;
00110 for ( RecHitIter recHitIter = recHitHandle->begin();
00111 recHitIter != recHitHandle->end(); ++recHitIter )
00112 {
00113 const RPCDetId detId = static_cast<const RPCDetId>(recHitIter->rpcId());
00114 const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId()));
00115 if ( !roll ) continue;
00116
00117 const int region = roll->id().region();
00118 const int ring = roll->id().ring();
00119
00120 const int station = (roll->id().station());
00121
00122
00123
00124 h_.clusterSize->Fill(recHitIter->clusterSize());
00125
00126 if ( region == 0 )
00127 {
00128 ++nRecHitBarrel;
00129 sumClusterSizeBarrel += recHitIter->clusterSize();
00130 h_.clusterSizeBarrel->Fill(recHitIter->clusterSize());
00131 h_.recHitOccupancyBarrel_wheel->Fill(ring);
00132 h_.recHitOccupancyBarrel_station->Fill(station);
00133 h_.recHitOccupancyBarrel_wheel_station->Fill(ring, station);
00134 }
00135 else
00136 {
00137 ++nRecHitEndcap;
00138 sumClusterSizeEndcap += recHitIter->clusterSize();
00139 h_.clusterSizeEndcap->Fill(recHitIter->clusterSize());
00140 h_.recHitOccupancyEndcap_disk->Fill(region*station);
00141 h_.recHitOccupancyEndcap_disk_ring->Fill(ring, region*station);
00142 }
00143
00144 }
00145 const double nRecHit = nRecHitBarrel+nRecHitEndcap;
00146 h_.nRecHitBarrel->Fill(nRecHitBarrel);
00147 h_.nRecHitEndcap->Fill(nRecHitEndcap);
00148 if ( nRecHit > 0 )
00149 {
00150 const int sumClusterSize = sumClusterSizeBarrel+sumClusterSizeEndcap;
00151 h_.avgClusterSize->Fill(double(sumClusterSize)/nRecHit);
00152
00153 if ( nRecHitBarrel > 0 )
00154 {
00155 h_.avgClusterSizeBarrel->Fill(double(sumClusterSizeBarrel)/nRecHitBarrel);
00156 }
00157 if ( nRecHitEndcap > 0 )
00158 {
00159 h_.avgClusterSizeEndcap->Fill(double(sumClusterSizeEndcap)/nRecHitEndcap);
00160 }
00161 }
00162
00163
00164 typedef std::map<RecHitIter, RecHitIter> RecToRecHitMap;
00165 RecToRecHitMap refToRecHitMap;
00166
00167 for ( RecHitIter refHitIter = refHitHandle->begin();
00168 refHitIter != refHitHandle->end(); ++refHitIter )
00169 {
00170 const RPCDetId refDetId = static_cast<const RPCDetId>(refHitIter->rpcId());
00171 const RPCRoll* refRoll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(refDetId));
00172 if ( !refRoll ) continue;
00173
00174 const double refX = refHitIter->localPosition().x();
00175
00176 for ( RecHitIter recHitIter = recHitHandle->begin();
00177 recHitIter != recHitHandle->end(); ++recHitIter )
00178 {
00179 const RPCDetId recDetId = static_cast<const RPCDetId>(recHitIter->rpcId());
00180 const RPCRoll* recRoll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(recDetId));
00181 if ( !recRoll ) continue;
00182
00183 if ( refDetId != recDetId ) continue;
00184
00185 const double recX = recHitIter->localPosition().x();
00186 const double newDx = fabs(recX - refX);
00187
00188
00189 RecToRecHitMap::const_iterator prevRefToReco = refToRecHitMap.find(refHitIter);
00190 if ( prevRefToReco == refToRecHitMap.end() )
00191 {
00192 refToRecHitMap.insert(std::make_pair(refHitIter, recHitIter));
00193 }
00194 else
00195 {
00196 const double oldDx = fabs(prevRefToReco->second->localPosition().x() - refX);
00197
00198 if ( newDx < oldDx )
00199 {
00200 refToRecHitMap[refHitIter] = recHitIter;
00201 }
00202 }
00203 }
00204 }
00205
00206
00207
00208 for ( RecToRecHitMap::const_iterator match = refToRecHitMap.begin();
00209 match != refToRecHitMap.end(); ++match )
00210 {
00211 RecHitIter refHitIter = match->first;
00212 RecHitIter recHitIter = match->second;
00213
00214 const RPCDetId detId = static_cast<const RPCDetId>(refHitIter->rpcId());
00215 const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId));
00216
00217 const int region = roll->id().region();
00218 const int ring = roll->id().ring();
00219
00220 const int station = roll->id().station();
00221
00222
00223
00224 const double refX = refHitIter->localPosition().x();
00225 const double recX = recHitIter->localPosition().x();
00226 const double errX = sqrt(recHitIter->localPositionError().xx());
00227 const double dX = recX - refX;
00228 const double pull = errX == 0 ? -999 : dX/errX;
00229
00230
00231
00232
00233 if ( region == 0 )
00234 {
00235 h_.resBarrel->Fill(dX);
00236 h_.pullBarrel->Fill(pull);
00237 h_.matchOccupancyBarrel_wheel->Fill(ring);
00238 h_.matchOccupancyBarrel_station->Fill(station);
00239 h_.matchOccupancyBarrel_wheel_station->Fill(ring, station);
00240
00241 h_.res_wheel_res->Fill(ring, dX);
00242 h_.res_station_res->Fill(station, dX);
00243 h_.pull_wheel_pull->Fill(ring, pull);
00244 h_.pull_station_pull->Fill(station, pull);
00245 }
00246 else
00247 {
00248 h_.resEndcap->Fill(dX);
00249 h_.pullEndcap->Fill(pull);
00250 h_.matchOccupancyEndcap_disk->Fill(region*station);
00251 h_.matchOccupancyEndcap_disk_ring->Fill(region*station, ring);
00252
00253 h_.res_disk_res->Fill(region*station, dX);
00254 h_.res_ring_res->Fill(ring, dX);
00255 h_.pull_disk_pull->Fill(region*station, pull);
00256 h_.pull_ring_pull->Fill(ring, pull);
00257 }
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 for ( RecHitIter recHitIter = recHitHandle->begin();
00304 recHitIter != recHitHandle->end(); ++recHitIter )
00305 {
00306 const RPCDetId detId = static_cast<const RPCDetId>(recHitIter->rpcId());
00307 const RPCRoll* roll = dynamic_cast<const RPCRoll*>(rpcGeom->roll(detId));
00308
00309 const int region = roll->id().region();
00310 const int ring = roll->id().ring();
00311
00312 const int station = roll->id().station();
00313
00314
00315
00316 bool matched = false;
00317 for ( RecToRecHitMap::const_iterator match = refToRecHitMap.begin();
00318 match != refToRecHitMap.end(); ++match )
00319 {
00320 if ( recHitIter == match->second )
00321 {
00322 matched = true;
00323 break;
00324 }
00325 }
00326
00327 if ( !matched )
00328 {
00329 if ( region == 0 )
00330 {
00331 h_.umOccupancyBarrel_wheel->Fill(ring);
00332 h_.umOccupancyBarrel_station->Fill(station);
00333 h_.umOccupancyBarrel_wheel_station->Fill(ring, station);
00334 }
00335 else
00336 {
00337 h_.umOccupancyEndcap_disk->Fill(region*station);
00338 h_.umOccupancyEndcap_disk_ring->Fill(region*station, ring);
00339 }
00340
00341
00342
00343 }
00344 }
00345 }
00346
00347 DEFINE_FWK_MODULE(RPCPointVsRecHit);
00348