00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Validation/RPCRecHits/interface/RPCRecHitValid.h"
00010
00011 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
00012
00013 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
00014 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00015 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00016 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00017
00018 #include "FWCore/Framework/interface/MakerMacros.h"
00019 #include "FWCore/Framework/interface/Frameworkfwd.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/Framework/interface/ESHandle.h"
00022 #include "DQMServices/Core/interface/DQMStore.h"
00023
00024 using namespace std;
00025 using namespace edm;
00026
00027
00028 RPCRecHitValid::RPCRecHitValid(const ParameterSet& pset){
00029 cout << "--- [RPCRecHitValid] Constructor called" << endl;
00030 rootFileName = pset.getUntrackedParameter<string>("rootFileName", "rpcRecHitValidPlots.root");
00031
00032
00033 dbe_ = Service<DQMStore>().operator->();
00034
00035 if ( dbe_ ) {
00036
00037 Rechisto = dbe_->book1D("RecHits", "RPC RecHits", 300, -150, 150);
00038 Simhisto = dbe_->book1D("SimHits", "Simulated Hits", 300, -150, 150);
00039 Pulls = dbe_->book1D("Global Pulls", "RPC Global Pulls", 100, -4,4);
00040 ClSize = dbe_->book1D("Global ClSize", "Global Cluster Size", 10, 0, 10);
00041 res1cl = dbe_->book1D("Residuals CS = 1", "Residuals for ClSize = 1", 300, -8, 8);
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 dbe_->setCurrentFolder("Residuals and Occupancy");
00054 occRB1IN = dbe_->book1D("RB1 IN Occupancy", "RB1 IN Occupancy", 100, 0, 100);
00055 occRB1OUT = dbe_->book1D("RB1 OUT Occupancy", "RB1 OUT Occupancy", 100, 0, 100);
00056
00057
00058 Res = dbe_->book1D("Global Residuals", "Global Residuals", 300, -8, 8);
00059 ResWmin2 = dbe_->book1D("W-2 Residuals", "Residuals for Wheel -2", 300, -8, 8);
00060 ResWmin1 = dbe_->book1D("W-1 Residuals", "Residuals for Wheel -1", 300, -8, 8);
00061 ResWzer0 = dbe_->book1D("W 0 Residuals", "Residuals for Wheel 0", 300, -8, 8);
00062 ResWplu1 = dbe_->book1D("W+1 Residuals", "Residuals for Wheel +1", 300, -8, 8);
00063 ResWplu2 = dbe_->book1D("W+2 Residuals", "Residuals for Wheel +2", 300, -8, 8);
00064 ResS1 = dbe_->book1D("Sector 1 Residuals", "Sector 1 Residuals", 300, -8, 8);
00065 ResS3 = dbe_->book1D("Sector 3 Residuals", "Sector 3 Residuals", 300, -8, 8);
00066
00067
00068
00069
00070 }
00071 }
00072
00073 void RPCRecHitValid::beginJob(const edm::EventSetup& evs) {}
00074
00075
00076 RPCRecHitValid::~RPCRecHitValid(){
00077 cout << "--- [RPCRecHitValid] Destructor called" << endl;
00078 }
00079
00080 void RPCRecHitValid::endJob() {
00081 if ( rootFileName.size() != 0 && dbe_ ) dbe_->save(rootFileName);
00082 }
00083
00084
00085
00086 void RPCRecHitValid::analyze(const Event & event, const EventSetup& eventSetup){
00087 cout << endl <<"--- [RPCRecHitValid] Analysing Event: #Run: " << event.id().run()
00088 << " #Event: " << event.id().event() << endl;
00089
00090
00091 ESHandle<RPCGeometry> rpcGeom;
00092 eventSetup.get<MuonGeometryRecord>().get(rpcGeom);
00093
00094 Handle<PSimHitContainer> simHit;
00095 event.getByLabel("g4SimHits", "MuonRPCHits", simHit);
00096 std::map<double, int> mapsim;
00097 std::map<int, double> nmapsim;
00098 std::map<double, int> simWmin2;
00099 std::map<double, int> simWmin1;
00100 std::map<double, int> simWzer0;
00101 std::map<double, int> simWplu1;
00102 std::map<double, int> simWplu2;
00103 std::map<double, int> simS1;
00104 std::map<double, int> simS3;
00105 std::map<int, double> nsimWmin2;
00106 std::map<int, double> nsimWmin1;
00107 std::map<int, double> nsimWzer0;
00108 std::map<int, double> nsimWplu1;
00109 std::map<int, double> nsimWplu2;
00110 std::map<int, double> nsimS1;
00111 std::map<int, double> nsimS3;
00112
00113 Handle<RPCRecHitCollection> recHit;
00114 event.getByLabel("rpcRecHits", recHit);
00115 std::map<double, int> maprec;
00116 std::map<int, double> nmaprec;
00117 std::map<double, double> nmaperr;
00118 std::map<int, double> nmapres;
00119
00120 std::map<double, int> maprecCL1;
00121 std::map<int, double> nmaprecCL1;
00122
00123 std::map<double, int> recWmin2;
00124 std::map<double, int> recWmin1;
00125 std::map<double, int> recWzer0;
00126 std::map<double, int> recWplu1;
00127 std::map<double, int> recWplu2;
00128 std::map<double, int> recS1;
00129 std::map<double, int> recS3;
00130 std::map<int, double> nrecWmin2;
00131 std::map<int, double> nrecWmin1;
00132 std::map<int, double> nrecWzer0;
00133 std::map<int, double> nrecWplu1;
00134 std::map<int, double> nrecWplu2;
00135 std::map<int, double> nrecS1;
00136 std::map<int, double> nrecS3;
00137 std::map<double, double> errWmin2;
00138 std::map<double, double> errWmin1;
00139 std::map<double, double> errWzer0;
00140 std::map<double, double> errWplu1;
00141 std::map<double, double> errWplu2;
00142
00143
00144
00145 RPCRecHitCollection::const_iterator recIt;
00146 int nrec = 0;
00147 int nrecCL1 = 0;
00148 int nrecmin2 = 0;
00149 int nrecmin1 = 0;
00150 int nreczer0 = 0;
00151 int nrecplu1 = 0;
00152 int nrecplu2 = 0;
00153 int nrecS1c = 0;
00154 int nrecS3c = 0;
00155
00156 for (recIt = recHit->begin(); recIt != recHit->end(); recIt++) {
00157 RPCDetId Rid = (RPCDetId)(*recIt).rpcId();
00158 const RPCRoll* roll = dynamic_cast<const RPCRoll* >( rpcGeom->roll(Rid));
00159 if((roll->isForward())) return;
00160 int clsize = (*recIt).clusterSize();
00161 int fstrip = (*recIt).firstClusterStrip();
00162
00163 nrec = nrec + 1;
00164 LocalPoint rhitlocal = (*recIt).localPosition();
00165 LocalError locerr = (*recIt).localPositionError();
00166 double rhitlocalx = rhitlocal.x();
00167 double rhiterrx = locerr.xx();
00168 Rechisto->Fill(rhitlocalx);
00169 int wheel = roll->id().ring();
00170 int sector = roll->id().sector();
00171 int station = roll->id().station();
00172 int k = roll->id().layer();
00173
00174
00175
00176 if (clsize == 1) {
00177 maprecCL1[rhitlocalx] = nrec;
00178 nrecCL1 = nrecCL1 + 1;
00179 }
00180
00181
00182 ClSize->Fill(clsize);
00183
00184
00185
00186 for (int occ = 0; occ < clsize; occ++) {
00187 int occup = fstrip + occ;
00188 if (station == 1 && k == 1) {
00189 occRB1IN->Fill(occup);
00190 }
00191 if (station == 1 && k == 2) {
00192 occRB1OUT->Fill(occup);
00193 }
00194 }
00195
00196
00197 maprec[rhitlocalx] = nrec;
00198 nmaperr[rhitlocalx] = rhiterrx;
00199
00200
00201 if(sector == 1) {
00202 recS1[rhitlocalx] = nrec;
00203 nrecS1c = nrecS1c + 1;
00204 }
00205 if(sector == 3) {
00206 recS3[rhitlocalx] = nrec;
00207 nrecS3c = nrecS3c + 1;
00208 }
00209
00210
00211 if(wheel == -2) {
00212 recWmin2[rhitlocalx] = nrec;
00213 errWmin2[rhitlocalx] = rhiterrx;
00214 nrecmin2 = nrecmin2 + 1;
00215 }
00216 if(wheel == -1) {
00217 recWmin1[rhitlocalx] = nrec;
00218 errWmin1[rhitlocalx] = rhiterrx;
00219 nrecmin1 = nrecmin1 + 1;
00220 }
00221 if(wheel == 0) {
00222 recWzer0[rhitlocalx] = nrec;
00223 errWzer0[rhitlocalx] = rhiterrx;
00224 nreczer0 = nreczer0 + 1;
00225 }
00226 if(wheel == 1) {
00227 recWplu1[rhitlocalx] = nrec;
00228 errWplu1[rhitlocalx] = rhiterrx;
00229 nrecplu1 = nrecplu1 + 1;
00230 }
00231 if(wheel == 2) {
00232 recWplu2[rhitlocalx] = nrec;
00233 errWplu2[rhitlocalx] = rhiterrx;
00234 nrecplu2 = nrecplu2 + 1;
00235 }
00236 }
00237 cout << " --> Found " << nrec << " rechit in event " << event.id().event() << endl;
00238
00239
00240 int i = 0;
00241 for (map<double, int>::iterator iter = maprec.begin(); iter != maprec.end(); iter++) {
00242 i = i + 1;
00243 nmaprec[i] = (*iter).first;
00244 }
00245
00246 i = 0;
00247 for (map<double, int>::iterator iter = maprecCL1.begin(); iter != maprecCL1.end(); iter++) {
00248 i = i + 1;
00249 nmaprecCL1[i] = (*iter).first;
00250 }
00251
00252 i = 0;
00253 for (map<double, int>::iterator iter = recWmin2.begin(); iter != recWmin2.end(); iter++) {
00254 i = i + 1;
00255 nrecWmin2[i] = (*iter).first;
00256 }
00257
00258 i = 0;
00259 for (map<double, int>::iterator iter = recWmin1.begin(); iter != recWmin1.end(); iter++) {
00260 i = i + 1;
00261 nrecWmin1[i] = (*iter).first;
00262 }
00263
00264 i = 0;
00265 for (map<double, int>::iterator iter = recWzer0.begin(); iter != recWzer0.end(); iter++) {
00266 i = i + 1;
00267 nrecWzer0[i] = (*iter).first;
00268 }
00269
00270 i = 0;
00271 for (map<double, int>::iterator iter = recWplu1.begin(); iter != recWplu1.end(); iter++) {
00272 i = i + 1;
00273 nrecWplu1[i] = (*iter).first;
00274 }
00275
00276 i = 0;
00277 for (map<double, int>::iterator iter = recWplu2.begin(); iter != recWplu2.end(); iter++) {
00278 i = i + 1;
00279 nrecWplu2[i] = (*iter).first;
00280 }
00281
00282 i = 0;
00283 for (map<double, int>::iterator iter = recS1.begin(); iter != recS1.end(); iter++) {
00284 i = i + 1;
00285 nrecS1[i] = (*iter).first;
00286 }
00287
00288 i = 0;
00289 for (map<double, int>::iterator iter = recS3.begin(); iter != recS3.end(); iter++) {
00290 i = i + 1;
00291 nrecS3[i] = (*iter).first;
00292 }
00293
00294
00295
00296 PSimHitContainer::const_iterator simIt;
00297 int nsim = 0;
00298 int nsimmin2 = 0;
00299 int nsimmin1 = 0;
00300 int nsimzer0 = 0;
00301 int nsimplu1 = 0;
00302 int nsimplu2 = 0;
00303 int nsimS1c = 0;
00304 int nsimS3c = 0;
00305
00306 for (simIt = simHit->begin(); simIt != simHit->end(); simIt++) {
00307 int ptype = (*simIt).particleType();
00308 RPCDetId Rsid = (RPCDetId)(*simIt).detUnitId();
00309 const RPCRoll* roll = dynamic_cast<const RPCRoll* >( rpcGeom->roll(Rsid));
00310 int Swheel = roll->id().ring();
00311 int Ssector = roll->id().sector();
00312
00313
00314 if (ptype == 13 || ptype == -13) {
00315 nsim = nsim + 1;
00316 LocalPoint shitlocal = (*simIt).localPosition();
00317 double shitlocalx = shitlocal.x();
00318 Simhisto->Fill(shitlocalx);
00319
00320 mapsim[shitlocalx] = nsim;
00321
00322
00323 if(Ssector == 1) {
00324 simS1[shitlocalx] = nsim;
00325 nsimS1c = nsimS1c + 1;
00326 }
00327 if(Ssector == 3) {
00328 simS3[shitlocalx] = nsim;
00329 nsimS3c = nsimS3c + 1;
00330 }
00331
00332
00333
00334 if(Swheel == -2) {
00335 simWmin2[shitlocalx] = nsim;
00336 nsimmin2 = nsimmin2 + 1;
00337 }
00338 if(Swheel == -1) {
00339 simWmin1[shitlocalx] = nsim;
00340 nsimmin1 = nsimmin1 + 1;
00341 }
00342 if(Swheel == 0) {
00343 simWzer0[shitlocalx] = nsim;
00344 nsimzer0 = nsimzer0 + 1;
00345 }
00346 if(Swheel == 1) {
00347 simWplu1[shitlocalx] = nsim;
00348 nsimplu1 = nsimplu1 + 1;
00349 }
00350 if(Swheel == 2) {
00351 simWplu2[shitlocalx] = nsim;
00352 nsimplu2 = nsimplu2 + 1;
00353 }
00354
00355 }
00356 }
00357 cout << " --> Found " << nsim <<" simhits in event " << event.id().event() << endl;
00358
00359
00360 i = 0;
00361 for (map<double, int>::iterator iter = mapsim.begin(); iter != mapsim.end(); iter++) {
00362 i = i + 1;
00363 nmapsim[i] = (*iter).first;
00364 }
00365
00366 i = 0;
00367 for (map<double, int>::iterator iter = simWmin2.begin(); iter != simWmin2.end(); iter++) {
00368 i = i + 1;
00369 nsimWmin2[i] = (*iter).first;
00370 }
00371
00372 i = 0;
00373 for (map<double, int>::iterator iter = simWmin1.begin(); iter != simWmin1.end(); iter++) {
00374 i = i + 1;
00375 nsimWmin1[i] = (*iter).first;
00376 }
00377
00378 i = 0;
00379 for (map<double, int>::iterator iter = simWzer0.begin(); iter != simWzer0.end(); iter++) {
00380 i = i + 1;
00381 nsimWzer0[i] = (*iter).first;
00382 }
00383
00384 i = 0;
00385 for (map<double, int>::iterator iter = simWplu1.begin(); iter != simWplu1.end(); iter++) {
00386 i = i + 1;
00387 nsimWplu1[i] = (*iter).first;
00388 }
00389
00390 i = 0;
00391 for (map<double, int>::iterator iter = simWplu2.begin(); iter != simWplu2.end(); iter++) {
00392 i = i + 1;
00393 nsimWplu2[i] = (*iter).first;
00394 }
00395
00396 i = 0;
00397 for (map<double, int>::iterator iter = simS1.begin(); iter != simS1.end(); iter++) {
00398 i = i + 1;
00399 nsimS1[i] = (*iter).first;
00400 }
00401
00402 i = 0;
00403 for (map<double, int>::iterator iter = simS3.begin(); iter != simS3.end(); iter++) {
00404 i = i + 1;
00405 nsimS3[i] = (*iter).first;
00406 }
00407
00408
00409 double res,resmin2,resmin1,reszer0,resplu1,resplu2,resS1,resS3;
00410 if (nsim == nrec) {
00411 for (int r=0; r<nsim; r++) {
00412 res = nmapsim[r+1] - nmaprec[r+1];
00413 nmapres[r+1] = res;
00414 Res->Fill(res);
00415 }
00416 }
00417 if (nsim == nrecCL1) {
00418 for (int r=0; r<nsim; r++) {
00419 res = nmapsim[r+1] - nmaprecCL1[r+1];
00420
00421 if (abs(res) < 3) {
00422 res1cl->Fill(res);
00423 }
00424 }
00425 }
00426 if (nsimmin2 == nrecmin2) {
00427 for (int r=0; r<nsimmin2; r++) {
00428 resmin2 = nsimWmin2[r+1] - nrecWmin2[r+1];
00429 ResWmin2->Fill(resmin2);
00430 }
00431 }
00432 if (nsimmin1 == nrecmin1) {
00433 for (int r=0; r<nsimmin1; r++) {
00434 resmin1 = nsimWmin1[r+1] - nrecWmin1[r+1];
00435 ResWmin1->Fill(resmin1);
00436 }
00437 }
00438 if (nsimzer0 == nreczer0) {
00439 for (int r=0; r<nsimzer0; r++) {
00440 reszer0 = nsimWzer0[r+1] - nrecWzer0[r+1];
00441 ResWzer0->Fill(reszer0);
00442 }
00443 }
00444 if (nsimplu1 == nrecplu1) {
00445 for (int r=0; r<nsimplu1; r++) {
00446 resplu1 = nsimWplu1[r+1] - nrecWplu1[r+1];
00447 ResWplu1->Fill(resplu1);
00448 }
00449 }
00450 if (nsimplu2 == nrecplu2) {
00451 for (int r=0; r<nsimplu2; r++) {
00452 resplu2 = nsimWplu2[r+1] - nrecWplu2[r+1];
00453 ResWplu2->Fill(resplu2);
00454 }
00455 }
00456 if (nsimS1c == nrecS1c) {
00457 for (int r=0; r<nsimS1c; r++) {
00458 resS1 = nsimS1[r+1] - nrecS1[r+1];
00459 ResS1->Fill(resS1);
00460 }
00461 }
00462 if (nsimS3c == nrecS3c) {
00463 for (int r=0; r<nsimS3c; r++) {
00464 resS3 = nsimS3[r+1] - nrecS3[r+1];
00465 ResS3->Fill(resS3);
00466 }
00467 }
00468
00469
00470
00471 double pull;
00472 if (nsim == nrec) {
00473 for (int r=0; r<nsim; r++) {
00474 pull = nmapres[r+1] / nmaperr[nmaprec[r+1]];
00475 Pulls->Fill(pull);
00476 }
00477 }
00478 }
00479
00480