CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DQMOffline/Muon/src/MuonIdDQM.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Muon/interface/MuonIdDQM.h"
00002 
00003 MuonIdDQM::MuonIdDQM(const edm::ParameterSet& iConfig)
00004 {
00005    inputMuonCollection_ = iConfig.getParameter<edm::InputTag>("inputMuonCollection");
00006    inputDTRecSegment4DCollection_ = iConfig.getParameter<edm::InputTag>("inputDTRecSegment4DCollection");
00007    inputCSCSegmentCollection_ = iConfig.getParameter<edm::InputTag>("inputCSCSegmentCollection");
00008    useTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuons");
00009    useGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuons");
00010    useTrackerMuonsNotGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuonsNotGlobalMuons");
00011    useGlobalMuonsNotTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuonsNotTrackerMuons");
00012    baseFolder_ = iConfig.getUntrackedParameter<std::string>("baseFolder");
00013 
00014    dbe_ = 0;
00015    dbe_ = edm::Service<DQMStore>().operator->();
00016 }
00017 
00018 MuonIdDQM::~MuonIdDQM() {}
00019 
00020 void 
00021 MuonIdDQM::beginJob()
00022 {
00023    char name[100], title[200];
00024 
00025    // trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
00026    for (unsigned int i = 0; i < 4; i++) {
00027       if ((i == 0 && ! useTrackerMuons_) || (i == 1 && ! useGlobalMuons_)) continue;
00028       if ((i == 2 && ! useTrackerMuonsNotGlobalMuons_) || (i == 3 && ! useGlobalMuonsNotTrackerMuons_)) continue;
00029       if (i == 0) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00030       if (i == 1) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuons");
00031       if (i == 2) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuonsNotGlobalMuons");
00032       if (i == 3) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuonsNotTrackerMuons");
00033 
00034       hNumChambers[i] = dbe_->book1D("hNumChambers", "Number of Chambers", 17, -0.5, 16.5);
00035       hNumMatches[i] = dbe_->book1D("hNumMatches", "Number of Matches", 11, -0.5, 10.5);
00036       hNumChambersNoRPC[i] = dbe_->book1D("hNumChambersNoRPC", "Number of Chambers No RPC", 11, -0.5, 10.5);
00037 
00038       // by station
00039       for(int station = 0; station < 4; ++station)
00040       {
00041          sprintf(name, "hDT%iNumSegments", station+1);
00042          sprintf(title, "DT Station %i Number of Segments (No Arbitration)", station+1);
00043          hDTNumSegments[i][station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
00044 
00045          sprintf(name, "hDT%iDx", station+1);
00046          sprintf(title, "DT Station %i Delta X", station+1);
00047          hDTDx[i][station] = dbe_->book1D(name, title, 100, -100., 100.);
00048 
00049          sprintf(name, "hDT%iPullx", station+1);
00050          sprintf(title, "DT Station %i Pull X", station+1);
00051          hDTPullx[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00052 
00053          sprintf(name, "hDT%iDdXdZ", station+1);
00054          sprintf(title, "DT Station %i Delta DxDz", station+1);
00055          hDTDdXdZ[i][station] = dbe_->book1D(name, title, 100, -1., 1.);
00056 
00057          sprintf(name, "hDT%iPulldXdZ", station+1);
00058          sprintf(title, "DT Station %i Pull DxDz", station+1);
00059          hDTPulldXdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00060 
00061          if (station < 3) {
00062             sprintf(name, "hDT%iDy", station+1);
00063             sprintf(title, "DT Station %i Delta Y", station+1);
00064             hDTDy[i][station] = dbe_->book1D(name, title, 100, -150., 150.);
00065 
00066             sprintf(name, "hDT%iPully", station+1);
00067             sprintf(title, "DT Station %i Pull Y", station+1);
00068             hDTPully[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00069 
00070             sprintf(name, "hDT%iDdYdZ", station+1);
00071             sprintf(title, "DT Station %i Delta DyDz", station+1);
00072             hDTDdYdZ[i][station] = dbe_->book1D(name, title, 100, -2., 2.);
00073 
00074             sprintf(name, "hDT%iPulldYdZ", station+1);
00075             sprintf(title, "DT Station %i Pull DyDz", station+1);
00076             hDTPulldYdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00077          }
00078 
00079          sprintf(name, "hCSC%iNumSegments", station+1);
00080          sprintf(title, "CSC Station %i Number of Segments (No Arbitration)", station+1);
00081          hCSCNumSegments[i][station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
00082 
00083          sprintf(name, "hCSC%iDx", station+1);
00084          sprintf(title, "CSC Station %i Delta X", station+1);
00085          hCSCDx[i][station] = dbe_->book1D(name, title, 100, -50., 50.);
00086 
00087          sprintf(name, "hCSC%iPullx", station+1);
00088          sprintf(title, "CSC Station %i Pull X", station+1);
00089          hCSCPullx[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00090 
00091          sprintf(name, "hCSC%iDdXdZ", station+1);
00092          sprintf(title, "CSC Station %i Delta DxDz", station+1);
00093          hCSCDdXdZ[i][station] = dbe_->book1D(name, title, 100, -1., 1.);
00094 
00095          sprintf(name, "hCSC%iPulldXdZ", station+1);
00096          sprintf(title, "CSC Station %i Pull DxDz", station+1);
00097          hCSCPulldXdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00098 
00099          sprintf(name, "hCSC%iDy", station+1);
00100          sprintf(title, "CSC Station %i Delta Y", station+1);
00101          hCSCDy[i][station] = dbe_->book1D(name, title, 100, -50., 50.);
00102 
00103          sprintf(name, "hCSC%iPully", station+1);
00104          sprintf(title, "CSC Station %i Pull Y", station+1);
00105          hCSCPully[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00106 
00107          sprintf(name, "hCSC%iDdYdZ", station+1);
00108          sprintf(title, "CSC Station %i Delta DyDz", station+1);
00109          hCSCDdYdZ[i][station] = dbe_->book1D(name, title, 100, -1., 1.);
00110 
00111          sprintf(name, "hCSC%iPulldYdZ", station+1);
00112          sprintf(title, "CSC Station %i Pull DyDz", station+1);
00113          hCSCPulldYdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00114       }// station
00115    }
00116 
00117    dbe_->setCurrentFolder(baseFolder_);
00118    hSegmentIsAssociatedBool = dbe_->book1D("hSegmentIsAssociatedBool", "Segment Is Associated Boolean", 2, -0.5, 1.5);
00119 }
00120 
00121 void
00122 MuonIdDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00123 {
00124    using namespace edm;
00125    using namespace reco;
00126 
00127    iEvent.getByLabel(inputMuonCollection_, muonCollectionH_);
00128    iEvent.getByLabel(inputDTRecSegment4DCollection_, dtSegmentCollectionH_);
00129    iEvent.getByLabel(inputCSCSegmentCollection_, cscSegmentCollectionH_);
00130    iSetup.get<GlobalTrackingGeometryRecord>().get(geometry_);
00131 
00132    for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00133          muon != muonCollectionH_->end(); ++muon)
00134    {
00135       // trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
00136       for (unsigned int i = 0; i < 4; i++) {
00137          if (i == 0 && (! useTrackerMuons_ || ! muon->isTrackerMuon())) continue;
00138          if (i == 1 && (! useGlobalMuons_ || ! muon->isGlobalMuon())) continue;
00139          if (i == 2 && (! useTrackerMuonsNotGlobalMuons_ || (! (muon->isTrackerMuon() && ! muon->isGlobalMuon())))) continue;
00140          if (i == 3 && (! useGlobalMuonsNotTrackerMuons_ || (! (muon->isGlobalMuon() && ! muon->isTrackerMuon())))) continue;
00141 
00142          hNumChambers[i]->Fill(muon->numberOfChambers());
00143          hNumMatches[i]->Fill(muon->numberOfMatches(Muon::SegmentAndTrackArbitration));
00144          hNumChambersNoRPC[i]->Fill(muon->numberOfChambersNoRPC());
00145 
00146          // by station
00147          for(int station = 0; station < 4; ++station)
00148          {
00149             // only fill num segments if we crossed (or nearly crossed) a chamber
00150             if (muon->trackX(station+1, MuonSubdetId::DT, Muon::NoArbitration) < 900000)
00151                hDTNumSegments[i][station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::DT, Muon::NoArbitration));
00152             Fill(hDTDx[i][station], muon->dX(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
00153             Fill(hDTPullx[i][station], muon->pullX(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
00154             Fill(hDTDdXdZ[i][station], muon->dDxDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
00155             Fill(hDTPulldXdZ[i][station], muon->pullDxDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
00156 
00157             if (station < 3) {
00158                Fill(hDTDy[i][station], muon->dY(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
00159                Fill(hDTPully[i][station], muon->pullY(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
00160                Fill(hDTDdYdZ[i][station], muon->dDyDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
00161                Fill(hDTPulldYdZ[i][station], muon->pullDyDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
00162             }
00163 
00164             // only fill num segments if we crossed (or nearly crossed) a chamber
00165             if (muon->trackX(station+1, MuonSubdetId::CSC, Muon::NoArbitration) < 900000)
00166                hCSCNumSegments[i][station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::CSC, Muon::NoArbitration));
00167             Fill(hCSCDx[i][station], muon->dX(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
00168             Fill(hCSCPullx[i][station], muon->pullX(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
00169             Fill(hCSCDdXdZ[i][station], muon->dDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
00170             Fill(hCSCPulldXdZ[i][station], muon->pullDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
00171             Fill(hCSCDy[i][station], muon->dY(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
00172             Fill(hCSCPully[i][station], muon->pullY(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
00173             Fill(hCSCDdYdZ[i][station], muon->dDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
00174             Fill(hCSCPulldYdZ[i][station], muon->pullDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
00175          }
00176       }
00177    }// muon
00178 
00179    for(DTRecSegment4DCollection::const_iterator segment = dtSegmentCollectionH_->begin();
00180          segment != dtSegmentCollectionH_->end(); ++segment)
00181    {
00182       LocalPoint  segmentLocalPosition       = segment->localPosition();
00183       LocalVector segmentLocalDirection      = segment->localDirection();
00184       LocalError  segmentLocalPositionError  = segment->localPositionError();
00185       LocalError  segmentLocalDirectionError = segment->localDirectionError();
00186       bool segmentFound = false;
00187 
00188       for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00189             muon != muonCollectionH_->end(); ++muon)
00190       {
00191          if (! muon->isMatchesValid())
00192             continue;
00193 
00194          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00195                chamberMatch != muon->matches().end(); ++chamberMatch) {
00196             for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00197                   segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00198             {
00199                if (fabs(segmentMatch->x       - segmentLocalPosition.x()                           ) < 1E-6 &&
00200                    fabs(segmentMatch->y       - segmentLocalPosition.y()                           ) < 1E-6 &&
00201                    fabs(segmentMatch->dXdZ    - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00202                    fabs(segmentMatch->dYdZ    - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00203                    fabs(segmentMatch->xErr    - sqrt(segmentLocalPositionError.xx())               ) < 1E-6 &&
00204                    fabs(segmentMatch->yErr    - sqrt(segmentLocalPositionError.yy())               ) < 1E-6 &&
00205                    fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx())              ) < 1E-6 &&
00206                    fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy())              ) < 1E-6)
00207                {
00208                   segmentFound = true;
00209                   break;
00210                }
00211             }// segmentMatch
00212             if (segmentFound) break;
00213          }// chamberMatch
00214          if (segmentFound) break;
00215       }// muon
00216 
00217       if (segmentFound)
00218          hSegmentIsAssociatedBool->Fill(1.);
00219       else
00220          hSegmentIsAssociatedBool->Fill(0.);
00221    }// dt segment
00222 
00223    for(CSCSegmentCollection::const_iterator segment = cscSegmentCollectionH_->begin();
00224          segment != cscSegmentCollectionH_->end(); ++segment)
00225    {
00226       LocalPoint  segmentLocalPosition       = segment->localPosition();
00227       LocalVector segmentLocalDirection      = segment->localDirection();
00228       LocalError  segmentLocalPositionError  = segment->localPositionError();
00229       LocalError  segmentLocalDirectionError = segment->localDirectionError();
00230       bool segmentFound = false;
00231 
00232       for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00233             muon != muonCollectionH_->end(); ++muon)
00234       {
00235          if (! muon->isMatchesValid())
00236             continue;
00237 
00238          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00239                chamberMatch != muon->matches().end(); ++chamberMatch) {
00240             for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00241                   segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00242             {
00243                if (fabs(segmentMatch->x       - segmentLocalPosition.x()                           ) < 1E-6 &&
00244                    fabs(segmentMatch->y       - segmentLocalPosition.y()                           ) < 1E-6 &&
00245                    fabs(segmentMatch->dXdZ    - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00246                    fabs(segmentMatch->dYdZ    - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00247                    fabs(segmentMatch->xErr    - sqrt(segmentLocalPositionError.xx())               ) < 1E-6 &&
00248                    fabs(segmentMatch->yErr    - sqrt(segmentLocalPositionError.yy())               ) < 1E-6 &&
00249                    fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx())              ) < 1E-6 &&
00250                    fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy())              ) < 1E-6)
00251                {
00252                   segmentFound = true;
00253                   break;
00254                }
00255             }// segmentMatch
00256             if (segmentFound) break;
00257          }// chamberMatch
00258          if (segmentFound) break;
00259       }// muon
00260 
00261       if (segmentFound)
00262          hSegmentIsAssociatedBool->Fill(1.);
00263       else
00264          hSegmentIsAssociatedBool->Fill(0.);
00265    }// csc segment
00266 }
00267 
00268 void 
00269 MuonIdDQM::endJob() {}
00270 
00271 void MuonIdDQM::Fill(MonitorElement* me, float f) {
00272    if (fabs(f) > 900000) return;
00273    //if (fabs(f) < 1E-8) return;
00274    me->Fill(f);
00275 }
00276 
00277 //define this as a plug-in
00278 DEFINE_FWK_MODULE(MuonIdDQM);