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 baseFolder_ = iConfig.getUntrackedParameter<std::string>("baseFolder");
00011
00012 dbe_ = 0;
00013 dbe_ = edm::Service<DQMStore>().operator->();
00014 }
00015
00016 MuonIdDQM::~MuonIdDQM() {}
00017
00018 void
00019 MuonIdDQM::beginJob(const edm::EventSetup&)
00020 {
00021
00022 for (unsigned int i = 0; i < 2; i++) {
00023 if ((i == 0 && ! useTrackerMuons_) || (i == 1 && ! useGlobalMuons_)) continue;
00024 if (i == 0) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00025 if (i == 1) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuons");
00026
00027 hNumChambers[i] = dbe_->book1D("hNumChambers", "Number of Chambers", 11, -0.5, 10.5);
00028 hNumMatches[i] = dbe_->book1D("hNumMatches", "Number of Matches", 11, -0.5, 10.5);
00029 }
00030
00031 if (useTrackerMuons_) {
00032 dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00033
00034 char name[100], title[200];
00035
00036
00037 for(int station = 0; station < 4; ++station)
00038 {
00039 sprintf(name, "hDT%iNumSegments", station+1);
00040 sprintf(title, "DT Station %i Number of Segments (No Arbitration)", station+1);
00041 hDTNumSegments[station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
00042
00043 sprintf(name, "hDT%iDx", station+1);
00044 sprintf(title, "DT Station %i Delta X", station+1);
00045 hDTDx[station] = dbe_->book1D(name, title, 100, -100., 100.);
00046
00047 sprintf(name, "hDT%iPullx", station+1);
00048 sprintf(title, "DT Station %i Pull X", station+1);
00049 hDTPullx[station] = dbe_->book1D(name, title, 100, -20., 20.);
00050
00051 if (station < 3) {
00052 sprintf(name, "hDT%iDy", station+1);
00053 sprintf(title, "DT Station %i Delta Y", station+1);
00054 hDTDy[station] = dbe_->book1D(name, title, 100, -150., 150.);
00055
00056 sprintf(name, "hDT%iPully", station+1);
00057 sprintf(title, "DT Station %i Pull Y", station+1);
00058 hDTPully[station] = dbe_->book1D(name, title, 100, -20., 20.);
00059 }
00060
00061 sprintf(name, "hCSC%iNumSegments", station+1);
00062 sprintf(title, "CSC Station %i Number of Segments (No Arbitration)", station+1);
00063 hCSCNumSegments[station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
00064
00065 sprintf(name, "hCSC%iDx", station+1);
00066 sprintf(title, "CSC Station %i Delta X", station+1);
00067 hCSCDx[station] = dbe_->book1D(name, title, 100, -50., 50.);
00068
00069 sprintf(name, "hCSC%iPullx", station+1);
00070 sprintf(title, "CSC Station %i Pull X", station+1);
00071 hCSCPullx[station] = dbe_->book1D(name, title, 100, -20., 20.);
00072
00073 sprintf(name, "hCSC%iDy", station+1);
00074 sprintf(title, "CSC Station %i Delta Y", station+1);
00075 hCSCDy[station] = dbe_->book1D(name, title, 100, -50., 50.);
00076
00077 sprintf(name, "hCSC%iPully", station+1);
00078 sprintf(title, "CSC Station %i Pull Y", station+1);
00079 hCSCPully[station] = dbe_->book1D(name, title, 100, -20., 20.);
00080 }
00081
00082 hSegmentIsAssociatedBool = dbe_->book1D("hSegmentIsAssociatedBool", "Segment Is Associated Boolean", 2, -0.5, 1.5);
00083 }
00084 }
00085
00086 void
00087 MuonIdDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00088 {
00089 using namespace edm;
00090 using namespace reco;
00091
00092 iEvent.getByLabel(inputMuonCollection_, muonCollectionH_);
00093 iEvent.getByLabel(inputDTRecSegment4DCollection_, dtSegmentCollectionH_);
00094 iEvent.getByLabel(inputCSCSegmentCollection_, cscSegmentCollectionH_);
00095 iSetup.get<GlobalTrackingGeometryRecord>().get(geometry_);
00096
00097 for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00098 muon != muonCollectionH_->end(); ++muon)
00099 {
00100
00101 for (unsigned int i = 0; i < 2; i++) {
00102 if (i == 0 && (! useTrackerMuons_ || ! muon->isTrackerMuon())) continue;
00103 if (i == 1 && (! useGlobalMuons_ || ! muon->isGlobalMuon())) continue;
00104
00105 hNumChambers[i]->Fill(muon->numberOfChambers());
00106 hNumMatches[i]->Fill(muon->numberOfMatches());
00107 }
00108
00109 if (! useTrackerMuons_ || ! muon->isTrackerMuon()) continue;
00110
00111
00112 for(int station = 0; station < 4; ++station)
00113 {
00114 hDTNumSegments[station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::DT, Muon::NoArbitration));
00115 hDTDx[station]->Fill(muon->dX(station+1, MuonSubdetId::DT));
00116 hDTPullx[station]->Fill(muon->pullX(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, true));
00117
00118 if (station < 3) {
00119 hDTDy[station]->Fill(muon->dY(station+1, MuonSubdetId::DT));
00120 hDTPully[station]->Fill(muon->pullY(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, true));
00121 }
00122
00123 hCSCNumSegments[station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::CSC, Muon::NoArbitration));
00124 hCSCDx[station]->Fill(muon->dX(station+1, MuonSubdetId::CSC));
00125 hCSCPullx[station]->Fill(muon->pullX(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, true));
00126 hCSCDy[station]->Fill(muon->dY(station+1, MuonSubdetId::CSC));
00127 hCSCPully[station]->Fill(muon->pullY(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, true));
00128 }
00129 }
00130
00131 if (! useTrackerMuons_) return;
00132
00133 for(DTRecSegment4DCollection::const_iterator segment = dtSegmentCollectionH_->begin();
00134 segment != dtSegmentCollectionH_->end(); ++segment)
00135 {
00136 LocalPoint segmentLocalPosition = segment->localPosition();
00137 LocalVector segmentLocalDirection = segment->localDirection();
00138 LocalError segmentLocalPositionError = segment->localPositionError();
00139 LocalError segmentLocalDirectionError = segment->localDirectionError();
00140 const GeomDet* segmentGeomDet = geometry_->idToDet(segment->geographicalId());
00141 GlobalPoint segmentGlobalPosition = segmentGeomDet->toGlobal(segment->localPosition());
00142 bool segmentFound = false;
00143
00144 for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00145 muon != muonCollectionH_->end(); ++muon)
00146 {
00147 if (! muon->isMatchesValid())
00148 continue;
00149
00150 for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00151 chamberMatch != muon->matches().end(); ++chamberMatch) {
00152 for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00153 segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00154 {
00155 if (fabs(segmentMatch->x - segmentLocalPosition.x() ) < 1E-6 &&
00156 fabs(segmentMatch->y - segmentLocalPosition.y() ) < 1E-6 &&
00157 fabs(segmentMatch->dXdZ - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00158 fabs(segmentMatch->dYdZ - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00159 fabs(segmentMatch->xErr - sqrt(segmentLocalPositionError.xx()) ) < 1E-6 &&
00160 fabs(segmentMatch->yErr - sqrt(segmentLocalPositionError.yy()) ) < 1E-6 &&
00161 fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx()) ) < 1E-6 &&
00162 fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy()) ) < 1E-6)
00163 {
00164 segmentFound = true;
00165 break;
00166 }
00167 }
00168 if (segmentFound) break;
00169 }
00170 if (segmentFound) break;
00171 }
00172
00173 if (segmentFound)
00174 hSegmentIsAssociatedBool->Fill(1.);
00175 else
00176 hSegmentIsAssociatedBool->Fill(0.);
00177 }
00178
00179 for(CSCSegmentCollection::const_iterator segment = cscSegmentCollectionH_->begin();
00180 segment != cscSegmentCollectionH_->end(); ++segment)
00181 {
00182 LocalPoint segmentLocalPosition = segment->localPosition();
00183 LocalVector segmentLocalDirection = segment->localDirection();
00184 LocalError segmentLocalPositionError = segment->localPositionError();
00185 LocalError segmentLocalDirectionError = segment->localDirectionError();
00186 const GeomDet* segmentGeomDet = geometry_->idToDet(segment->geographicalId());
00187 GlobalPoint segmentGlobalPosition = segmentGeomDet->toGlobal(segment->localPosition());
00188 bool segmentFound = false;
00189
00190 for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00191 muon != muonCollectionH_->end(); ++muon)
00192 {
00193 if (! muon->isMatchesValid())
00194 continue;
00195
00196 for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00197 chamberMatch != muon->matches().end(); ++chamberMatch) {
00198 for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00199 segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00200 {
00201 if (fabs(segmentMatch->x - segmentLocalPosition.x() ) < 1E-6 &&
00202 fabs(segmentMatch->y - segmentLocalPosition.y() ) < 1E-6 &&
00203 fabs(segmentMatch->dXdZ - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00204 fabs(segmentMatch->dYdZ - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00205 fabs(segmentMatch->xErr - sqrt(segmentLocalPositionError.xx()) ) < 1E-6 &&
00206 fabs(segmentMatch->yErr - sqrt(segmentLocalPositionError.yy()) ) < 1E-6 &&
00207 fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx()) ) < 1E-6 &&
00208 fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy()) ) < 1E-6)
00209 {
00210 segmentFound = true;
00211 break;
00212 }
00213 }
00214 if (segmentFound) break;
00215 }
00216 if (segmentFound) break;
00217 }
00218
00219 if (segmentFound)
00220 hSegmentIsAssociatedBool->Fill(1.);
00221 else
00222 hSegmentIsAssociatedBool->Fill(0.);
00223 }
00224 }
00225
00226 void
00227 MuonIdDQM::endJob() {}
00228
00229
00230 DEFINE_FWK_MODULE(MuonIdDQM);