CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonIdDQM.cc
Go to the documentation of this file.
2 
4  inputMuonCollection_ = consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("inputMuonCollection"));
5  inputDTRecSegment4DCollection_ = consumes<DTRecSegment4DCollection>(iConfig.getParameter<edm::InputTag>("inputDTRecSegment4DCollection"));
6  inputCSCSegmentCollection_ = consumes<CSCSegmentCollection>(iConfig.getParameter<edm::InputTag>("inputCSCSegmentCollection"));
7  useTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuons");
8  useGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuons");
9  useTrackerMuonsNotGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuonsNotGlobalMuons");
10  useGlobalMuonsNotTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuonsNotTrackerMuons");
11  baseFolder_ = iConfig.getUntrackedParameter<std::string>("baseFolder");
12 
13  dbe_ = 0;
14  dbe_ = edm::Service<DQMStore>().operator->();
15 }
16 
18 
20 }
21 
22 void MuonIdDQM::beginRun(const edm::Run& irun, const edm::EventSetup& isetup){
23 
24  char name[100], title[200];
25 
26  dbe_->cd();
28  // trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
29 
30  hSegmentIsAssociatedBool = dbe_->book1D("hSegmentIsAssociatedBool", "Segment Is Associated Boolean", 2, -0.5, 1.5);
31 
32  for (unsigned int i = 0; i < 4; i++) {
33  if ((i == 0 && ! useTrackerMuons_) || (i == 1 && ! useGlobalMuons_)) continue;
34  if ((i == 2 && ! useTrackerMuonsNotGlobalMuons_) || (i == 3 && ! useGlobalMuonsNotTrackerMuons_)) continue;
35  if (i == 0) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
36  if (i == 1) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuons");
37  if (i == 2) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuonsNotGlobalMuons");
38  if (i == 3) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuonsNotTrackerMuons");
39 
40  hNumChambers[i] = dbe_->book1D("hNumChambers", "Number of Chambers", 17, -0.5, 16.5);
41  hNumMatches[i] = dbe_->book1D("hNumMatches", "Number of Matches", 11, -0.5, 10.5);
42  hNumChambersNoRPC[i] = dbe_->book1D("hNumChambersNoRPC", "Number of Chambers No RPC", 11, -0.5, 10.5);
43 
44  // by station
45  for(int station = 0; station < 4; ++station)
46  {
47  sprintf(name, "hDT%iNumSegments", station+1);
48  sprintf(title, "DT Station %i Number of Segments (No Arbitration)", station+1);
49  hDTNumSegments[i][station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
50 
51  sprintf(name, "hDT%iDx", station+1);
52  sprintf(title, "DT Station %i Delta X", station+1);
53  hDTDx[i][station] = dbe_->book1D(name, title, 100, -100., 100.);
54 
55  sprintf(name, "hDT%iPullx", station+1);
56  sprintf(title, "DT Station %i Pull X", station+1);
57  hDTPullx[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
58 
59  sprintf(name, "hDT%iDdXdZ", station+1);
60  sprintf(title, "DT Station %i Delta DxDz", station+1);
61  hDTDdXdZ[i][station] = dbe_->book1D(name, title, 100, -1., 1.);
62 
63  sprintf(name, "hDT%iPulldXdZ", station+1);
64  sprintf(title, "DT Station %i Pull DxDz", station+1);
65  hDTPulldXdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
66 
67  if (station < 3) {
68  sprintf(name, "hDT%iDy", station+1);
69  sprintf(title, "DT Station %i Delta Y", station+1);
70  hDTDy[i][station] = dbe_->book1D(name, title, 100, -150., 150.);
71 
72  sprintf(name, "hDT%iPully", station+1);
73  sprintf(title, "DT Station %i Pull Y", station+1);
74  hDTPully[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
75 
76  sprintf(name, "hDT%iDdYdZ", station+1);
77  sprintf(title, "DT Station %i Delta DyDz", station+1);
78  hDTDdYdZ[i][station] = dbe_->book1D(name, title, 100, -2., 2.);
79 
80  sprintf(name, "hDT%iPulldYdZ", station+1);
81  sprintf(title, "DT Station %i Pull DyDz", station+1);
82  hDTPulldYdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
83  }
84 
85  sprintf(name, "hCSC%iNumSegments", station+1);
86  sprintf(title, "CSC Station %i Number of Segments (No Arbitration)", station+1);
87  hCSCNumSegments[i][station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
88 
89  sprintf(name, "hCSC%iDx", station+1);
90  sprintf(title, "CSC Station %i Delta X", station+1);
91  hCSCDx[i][station] = dbe_->book1D(name, title, 100, -50., 50.);
92 
93  sprintf(name, "hCSC%iPullx", station+1);
94  sprintf(title, "CSC Station %i Pull X", station+1);
95  hCSCPullx[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
96 
97  sprintf(name, "hCSC%iDdXdZ", station+1);
98  sprintf(title, "CSC Station %i Delta DxDz", station+1);
99  hCSCDdXdZ[i][station] = dbe_->book1D(name, title, 100, -1., 1.);
100 
101  sprintf(name, "hCSC%iPulldXdZ", station+1);
102  sprintf(title, "CSC Station %i Pull DxDz", station+1);
103  hCSCPulldXdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
104 
105  sprintf(name, "hCSC%iDy", station+1);
106  sprintf(title, "CSC Station %i Delta Y", station+1);
107  hCSCDy[i][station] = dbe_->book1D(name, title, 100, -50., 50.);
108 
109  sprintf(name, "hCSC%iPully", station+1);
110  sprintf(title, "CSC Station %i Pull Y", station+1);
111  hCSCPully[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
112 
113  sprintf(name, "hCSC%iDdYdZ", station+1);
114  sprintf(title, "CSC Station %i Delta DyDz", station+1);
115  hCSCDdYdZ[i][station] = dbe_->book1D(name, title, 100, -1., 1.);
116 
117  sprintf(name, "hCSC%iPulldYdZ", station+1);
118  sprintf(title, "CSC Station %i Pull DyDz", station+1);
119  hCSCPulldYdZ[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
120  }// station
121  }
122 
123 }
124 
126  using namespace edm;
127  using namespace reco;
128 
133 
134  for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
135  muon != muonCollectionH_->end(); ++muon)
136  {
137  // trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
138  for (unsigned int i = 0; i < 4; i++) {
139  if (i == 0 && (! useTrackerMuons_ || ! muon->isTrackerMuon())) continue;
140  if (i == 1 && (! useGlobalMuons_ || ! muon->isGlobalMuon())) continue;
141  if (i == 2 && (! useTrackerMuonsNotGlobalMuons_ || (! (muon->isTrackerMuon() && ! muon->isGlobalMuon())))) continue;
142  if (i == 3 && (! useGlobalMuonsNotTrackerMuons_ || (! (muon->isGlobalMuon() && ! muon->isTrackerMuon())))) continue;
143 
144  hNumChambers[i]->Fill(muon->numberOfChambers());
145  hNumMatches[i]->Fill(muon->numberOfMatches(Muon::SegmentAndTrackArbitration));
146  hNumChambersNoRPC[i]->Fill(muon->numberOfChambersNoRPC());
147 
148  // by station
149  for(int station = 0; station < 4; ++station)
150  {
151  // only fill num segments if we crossed (or nearly crossed) a chamber
152  if (muon->trackX(station+1, MuonSubdetId::DT, Muon::NoArbitration) < 900000)
153  hDTNumSegments[i][station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::DT, Muon::NoArbitration));
154  Fill(hDTDx[i][station], muon->dX(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
155  Fill(hDTPullx[i][station], muon->pullX(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
156  Fill(hDTDdXdZ[i][station], muon->dDxDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
157  Fill(hDTPulldXdZ[i][station], muon->pullDxDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
158 
159  if (station < 3) {
160  Fill(hDTDy[i][station], muon->dY(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
161  Fill(hDTPully[i][station], muon->pullY(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
162  Fill(hDTDdYdZ[i][station], muon->dDyDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration));
163  Fill(hDTPulldYdZ[i][station], muon->pullDyDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, true));
164  }
165 
166  // only fill num segments if we crossed (or nearly crossed) a chamber
167  if (muon->trackX(station+1, MuonSubdetId::CSC, Muon::NoArbitration) < 900000)
168  hCSCNumSegments[i][station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::CSC, Muon::NoArbitration));
169  Fill(hCSCDx[i][station], muon->dX(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
170  Fill(hCSCPullx[i][station], muon->pullX(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
171  Fill(hCSCDdXdZ[i][station], muon->dDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
172  Fill(hCSCPulldXdZ[i][station], muon->pullDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
173  Fill(hCSCDy[i][station], muon->dY(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
174  Fill(hCSCPully[i][station], muon->pullY(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
175  Fill(hCSCDdYdZ[i][station], muon->dDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration));
176  Fill(hCSCPulldYdZ[i][station], muon->pullDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, true));
177  }
178  }
179  }// muon
180 
182  segment != dtSegmentCollectionH_->end(); ++segment)
183  {
184  LocalPoint segmentLocalPosition = segment->localPosition();
185  LocalVector segmentLocalDirection = segment->localDirection();
186  LocalError segmentLocalPositionError = segment->localPositionError();
187  LocalError segmentLocalDirectionError = segment->localDirectionError();
188  bool segmentFound = false;
189 
190  for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
191  muon != muonCollectionH_->end(); ++muon)
192  {
193  if (! muon->isMatchesValid())
194  continue;
195 
196  for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
197  chamberMatch != muon->matches().end(); ++chamberMatch) {
198  for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
199  segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
200  {
201  if (fabs(segmentMatch->x - segmentLocalPosition.x() ) < 1E-6 &&
202  fabs(segmentMatch->y - segmentLocalPosition.y() ) < 1E-6 &&
203  fabs(segmentMatch->dXdZ - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
204  fabs(segmentMatch->dYdZ - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
205  fabs(segmentMatch->xErr - sqrt(segmentLocalPositionError.xx()) ) < 1E-6 &&
206  fabs(segmentMatch->yErr - sqrt(segmentLocalPositionError.yy()) ) < 1E-6 &&
207  fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx()) ) < 1E-6 &&
208  fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy()) ) < 1E-6)
209  {
210  segmentFound = true;
211  break;
212  }
213  }// segmentMatch
214  if (segmentFound) break;
215  }// chamberMatch
216  if (segmentFound) break;
217  }// muon
218 
219  if (segmentFound)
221  else
223  }// dt segment
224 
226  segment != cscSegmentCollectionH_->end(); ++segment)
227  {
228  LocalPoint segmentLocalPosition = segment->localPosition();
229  LocalVector segmentLocalDirection = segment->localDirection();
230  LocalError segmentLocalPositionError = segment->localPositionError();
231  LocalError segmentLocalDirectionError = segment->localDirectionError();
232  bool segmentFound = false;
233 
234  for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
235  muon != muonCollectionH_->end(); ++muon)
236  {
237  if (! muon->isMatchesValid())
238  continue;
239 
240  for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
241  chamberMatch != muon->matches().end(); ++chamberMatch) {
242  for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
243  segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
244  {
245  if (fabs(segmentMatch->x - segmentLocalPosition.x() ) < 1E-6 &&
246  fabs(segmentMatch->y - segmentLocalPosition.y() ) < 1E-6 &&
247  fabs(segmentMatch->dXdZ - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
248  fabs(segmentMatch->dYdZ - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
249  fabs(segmentMatch->xErr - sqrt(segmentLocalPositionError.xx()) ) < 1E-6 &&
250  fabs(segmentMatch->yErr - sqrt(segmentLocalPositionError.yy()) ) < 1E-6 &&
251  fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx()) ) < 1E-6 &&
252  fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy()) ) < 1E-6)
253  {
254  segmentFound = true;
255  break;
256  }
257  }// segmentMatch
258  if (segmentFound) break;
259  }// chamberMatch
260  if (segmentFound) break;
261  }// muon
262 
263  if (segmentFound)
265  else
267  }// csc segment
268 }
269 
270 void
272 
273 void MuonIdDQM::Fill(MonitorElement* me, float f) {
274  if (fabs(f) > 900000) return;
275  //if (fabs(f) < 1E-8) return;
276  me->Fill(f);
277 }
278 
279 //define this as a plug-in
bool useTrackerMuons_
Definition: MuonIdDQM.h:68
T getParameter(std::string const &) const
MonitorElement * hCSCDx[4][4]
Definition: MuonIdDQM.h:95
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:561
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * hCSCDdYdZ[4][4]
Definition: MuonIdDQM.h:101
MuonIdDQM(const edm::ParameterSet &)
Definition: MuonIdDQM.cc:3
virtual void endJob()
Definition: MuonIdDQM.cc:271
MonitorElement * hCSCDdXdZ[4][4]
Definition: MuonIdDQM.h:97
MonitorElement * hCSCPulldXdZ[4][4]
Definition: MuonIdDQM.h:98
T y() const
Definition: PV3DBase.h:63
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: MuonIdDQM.cc:125
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DCollection_
Definition: MuonIdDQM.h:66
bool useGlobalMuonsNotTrackerMuons_
Definition: MuonIdDQM.h:71
DQMStore * dbe_
Definition: MuonIdDQM.h:62
bool useTrackerMuonsNotGlobalMuons_
Definition: MuonIdDQM.h:70
virtual void beginJob()
Definition: MuonIdDQM.cc:19
MonitorElement * hDTDdYdZ[4][3]
Definition: MuonIdDQM.h:92
void Fill(long long x)
MonitorElement * hDTPully[4][3]
Definition: MuonIdDQM.h:91
MonitorElement * hCSCDy[4][4]
Definition: MuonIdDQM.h:99
int iEvent
Definition: GenABIO.cc:243
static const int CSC
Definition: MuonSubdetId.h:13
edm::Handle< DTRecSegment4DCollection > dtSegmentCollectionH_
Definition: MuonIdDQM.h:75
MonitorElement * hCSCPully[4][4]
Definition: MuonIdDQM.h:100
MonitorElement * hSegmentIsAssociatedBool
Definition: MuonIdDQM.h:105
float yy() const
Definition: LocalError.h:26
MonitorElement * hDTPullx[4][4]
Definition: MuonIdDQM.h:87
MonitorElement * hCSCPullx[4][4]
Definition: MuonIdDQM.h:96
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
bool useGlobalMuons_
Definition: MuonIdDQM.h:69
double f[11][100]
MonitorElement * hNumMatches[4]
Definition: MuonIdDQM.h:81
MonitorElement * hDTDdXdZ[4][4]
Definition: MuonIdDQM.h:88
edm::Handle< reco::MuonCollection > muonCollectionH_
Definition: MuonIdDQM.h:74
edm::EDGetTokenT< reco::MuonCollection > inputMuonCollection_
Definition: MuonIdDQM.h:65
MonitorElement * hDTDx[4][4]
Definition: MuonIdDQM.h:86
MonitorElement * hDTPulldYdZ[4][3]
Definition: MuonIdDQM.h:93
MonitorElement * hDTDy[4][3]
Definition: MuonIdDQM.h:90
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: MuonIdDQM.cc:22
MonitorElement * hCSCPulldYdZ[4][4]
Definition: MuonIdDQM.h:102
const T & get() const
Definition: EventSetup.h:55
virtual void Fill(MonitorElement *, float)
Definition: MuonIdDQM.cc:273
MonitorElement * hDTNumSegments[4][4]
Definition: MuonIdDQM.h:85
MonitorElement * hCSCNumSegments[4][4]
Definition: MuonIdDQM.h:94
MonitorElement * hNumChambersNoRPC[4]
Definition: MuonIdDQM.h:82
edm::ESHandle< GlobalTrackingGeometry > geometry_
Definition: MuonIdDQM.h:77
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentCollection_
Definition: MuonIdDQM.h:67
std::string baseFolder_
Definition: MuonIdDQM.h:72
static const int DT
Definition: MuonSubdetId.h:12
T x() const
Definition: PV3DBase.h:62
MonitorElement * hDTPulldXdZ[4][4]
Definition: MuonIdDQM.h:89
~MuonIdDQM()
Definition: MuonIdDQM.cc:17
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
MonitorElement * hNumChambers[4]
Definition: MuonIdDQM.h:80
Definition: Run.h:41
edm::Handle< CSCSegmentCollection > cscSegmentCollectionH_
Definition: MuonIdDQM.h:76