39 muonToken_ = consumes<reco::MuonCollection>(
edm::InputTag(
parameters.getUntrackedParameter<
string>(
"muonLabel")));
51 LogVerbatim(
"DTCalibValidationFromMuons") <<
"Segments used to compute residuals: " << rightSegment;
52 LogVerbatim(
"DTCalibValidationFromMuons") <<
"Segments not used to compute residuals: " << wrongSegment;
62 LogTrace(
"DTCalibValidationFromMuons") <<
"[DTCalibValidationFromMuons] Analyze #Run: " <<
event.id().run()
66 LogTrace(
"DTCalibValidationFromMuons") <<
" -- DTRecHit S3: begin analysis:";
69 event.getByToken(muonToken_, muonH);
74 event.getByToken(segment4DToken_, segment4Ds);
76 vector<const DTRecSegment4D *> selectedSegment4Ds;
78 for (
auto &imuon : *
muons) {
79 for (
const auto &ch : imuon.matches()) {
80 DetId chId(ch.id.rawId());
87 if (!imuon.isGlobalMuon())
90 int nsegs = ch.segmentMatches.size();
99 float dx = (posHit.
x() ? posHit.
x() - ch.x : 0);
100 float dy = (posHit.
y() ? posHit.
y() - ch.y : 0);
103 selectedSegment4Ds.push_back(&(*segment));
109 for (
auto segment : selectedSegment4Ds) {
110 LogTrace(
"DTCalibValidationFromMuons") <<
"Anlysis on recHit at step 3";
111 compute(dtGeom.product(), *segment);
122 return fabs(
recHit.localPosition().x() -
layer->specificTopology().wirePosition(
recHit.wireId().wire()));
134 float recHitPos = -1;
136 if (fabs(hitPosInChamber_left.
x() - segmentPos) < fabs(hitPosInChamber_right.
x() - segmentPos))
137 recHitPos = hitPosInChamber_left.
x();
139 recHitPos = hitPosInChamber_right.
x();
141 if (fabs(hitPosInChamber_left.
y() - segmentPos) < fabs(hitPosInChamber_right.
y() - segmentPos))
142 recHitPos = hitPosInChamber_left.
y();
144 recHitPos = hitPosInChamber_right.
y();
157 float recHitPos = -1;
159 recHitPos = recHitPosInChamber.
x();
161 recHitPos = recHitPosInChamber.
y();
168 bool computeResidual =
true;
171 vector<DTRecHit1D> recHits1D_S3;
178 if (phiRecHits.size() < 7) {
179 LogTrace(
"DTCalibValidationFromMuons") <<
"[DTCalibValidationFromMuons] Phi segments has: " << phiRecHits.size()
180 <<
" hits, skipping";
181 computeResidual =
false;
183 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
186 LogTrace(
"DTCalibValidationFromMuons") <<
" [DTCalibValidationFromMuons] 4D segment has no phi segment! ";
187 computeResidual =
false;
194 if (zRecHits.size() != 4) {
195 LogTrace(
"DTCalibValidationFromMuons") <<
"[DTCalibValidationFromMuons] Theta segments has: " << zRecHits.size()
196 <<
" hits, skipping";
197 computeResidual =
false;
199 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
202 LogTrace(
"DTCalibValidationFromMuons") <<
" [DTCalibValidationFromMuons] 4D segment has not the z segment! ";
203 computeResidual =
false;
207 if (!computeResidual)
210 if (computeResidual) {
214 for (vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin(); recHit1D != recHits1D_S3.end();
216 const DTWireId wireId = (*recHit1D).wireId();
220 float wireX =
layer->specificTopology().wirePosition(wireId.
wire());
226 LocalPoint wirePosInLay(wireX, (*recHit1D).localPosition().y(), (*recHit1D).localPosition().z());
237 float SegmDistance = -1;
238 if (sl == 1 || sl == 3) {
240 SegmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
241 LogTrace(
"DTCalibValidationFromMuons") <<
"SegmDistance: " << SegmDistance;
242 }
else if (sl == 2) {
244 SegmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
245 LogTrace(
"DTCalibValidationFromMuons") <<
"SegmDistance: " << SegmDistance;
248 if (SegmDistance > 2.1)
249 LogTrace(
"DTCalibValidationFromMuons") <<
" Warning: dist segment-wire: " << SegmDistance;
252 float recHitWireDist = recHitDistFromWire(*recHit1D,
layer);
253 LogTrace(
"DTCalibValidationFromMuons") <<
"recHitWireDist: " << recHitWireDist;
256 float residualOnDistance = recHitWireDist - SegmDistance;
257 LogTrace(
"DTCalibValidationFromMuons") <<
"WireId: " << wireId <<
" ResidualOnDistance: " << residualOnDistance;
258 float residualOnPosition = -1;
259 float recHitPos = -1;
260 if (sl == 1 || sl == 3) {
261 recHitPos = recHitPosition(*recHit1D,
layer,
chamber, segPosAtZWire.
x(), sl);
262 residualOnPosition = recHitPos - segPosAtZWire.
x();
264 recHitPos = recHitPosition(*recHit1D,
layer,
chamber, segPosAtZWire.
y(), sl);
265 residualOnPosition = recHitPos - segPosAtZWire.
y();
267 LogTrace(
"DTCalibValidationFromMuons") <<
"WireId: " << wireId <<
" ResidualOnPosition: " << residualOnPosition;
270 if (sl == 1 || sl == 3)
274 (wirePosInChamber.
x() - segPosAtZWire.
x()),
281 (wirePosInChamber.
y() - segPosAtZWire.
y()),
297 vector<const DTChamber *>::const_iterator ch_it = dtGeom->chambers().begin();
298 vector<const DTChamber *>::const_iterator ch_end = dtGeom->chambers().end();
299 for (; ch_it != ch_end; ++ch_it) {
300 vector<const DTSuperLayer *>::const_iterator sl_it = (*ch_it)->superLayers().begin();
301 vector<const DTSuperLayer *>::const_iterator sl_end = (*ch_it)->superLayers().end();
303 for (; sl_it != sl_end; ++sl_it) {
304 slId = (*sl_it)->id();
310 LogTrace(
"DTCalibValidationFromMuons") <<
" Booking histos for SL: " << slId;
319 stringstream superLayer;
325 string slHistoName =
"_STEP" + Step.str() +
"_W" +
wheel.str() +
"_St" +
station.str() +
"_Sec" + sector.str() +
326 "_SL" + superLayer.str();
329 "/Sector" + sector.str());
331 vector<MonitorElement *>
histos;
334 "hResDist" + slHistoName,
"Residuals on the distance from wire (rec_hit - segm_extr) (cm)", 200, -0.4, 0.4));
335 histos.push_back(ibooker.
book2D(
"hResDistVsDist" + slHistoName,
336 "Residuals on the distance (cm) from wire (rec_hit "
337 "- segm_extr) vs distance (cm)",
355 vector<MonitorElement *>
histos = histosPerSL[make_pair(slId,
step)];
356 histos[0]->Fill(residualOnDistance);