58 LogVerbatim(
"DTCalibValidation") <<
"Segments used to compute residuals: " << rightSegment;
59 LogVerbatim(
"DTCalibValidation") <<
"Segments not used to compute residuals: " << wrongSegment;
69 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Analyze #Run: " <<
event.id().run() <<
" #Event: " <<
nevent;
72 map<DTWireId, vector<DTRecHit1DPair> > recHitsPerWire_1S;
75 map<DTWireId, vector<DTRecHit1D> > recHitsPerWire_2S;
78 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S1: begin analysis:";
81 event.getByToken(recHits1DToken_, dtRecHits);
82 recHitsPerWire_1S = map1DRecHitsPerWire(dtRecHits.
product());
84 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S2: begin analysis:";
87 event.getByToken(segment2DToken_, segment2Ds);
88 recHitsPerWire_2S = map1DRecHitsPerWire(segment2Ds.
product());
92 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S3: begin analysis:";
95 event.getByToken(segment4DToken_, segment4Ds);
96 map<DTWireId, vector<DTRecHit1D> > recHitsPerWire_3S = map1DRecHitsPerWire(segment4Ds.
product());
102 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 1";
103 compute(dtGeom.product(), (*segment), recHitsPerWire_1S, 1);
105 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 2";
106 compute(dtGeom.product(), (*segment), recHitsPerWire_2S, 2);
109 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 3";
110 compute(dtGeom.product(), (*segment), recHitsPerWire_3S, 3);
117 map<DTWireId, vector<DTRecHit1DPair> >
ret;
121 ret[(*rechit).wireId()].push_back(*rechit);
129 map<DTWireId, vector<DTRecHit1D> >
ret;
134 vector<DTRecHit1D> component1DHits = (*segment).specificRecHits();
136 for (vector<DTRecHit1D>::const_iterator
hit = component1DHits.begin();
hit != component1DHits.end(); ++
hit) {
137 ret[(*hit).wireId()].push_back(*
hit);
146 map<DTWireId, vector<DTRecHit1D> >
ret;
151 vector<const TrackingRecHit*> segment2Ds = (*segment).recHits();
153 for (vector<const TrackingRecHit*>::const_iterator segment2D = segment2Ds.begin(); segment2D != segment2Ds.end();
156 vector<const TrackingRecHit*>
hits = (*segment2D)->recHits();
158 for (vector<const TrackingRecHit*>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
159 const DTRecHit1D* hit1D = dynamic_cast<const DTRecHit1D*>(*
hit);
169 template <
typename type>
173 const float segmDist) {
175 const type* theBestRecHit =
nullptr;
178 float distTmp = recHitDistFromWire(*
recHit, layer);
179 if (fabs(distTmp - segmDist) <
res) {
180 res = fabs(distTmp - segmDist);
181 theBestRecHit = &(*recHit);
185 return theBestRecHit;
207 float recHitPos = -1;
209 if (fabs(hitPosInChamber_left.
x() - segmentPos) < fabs(hitPosInChamber_right.
x() - segmentPos))
210 recHitPos = hitPosInChamber_left.
x();
212 recHitPos = hitPosInChamber_right.
x();
214 if (fabs(hitPosInChamber_left.
y() - segmentPos) < fabs(hitPosInChamber_right.
y() - segmentPos))
215 recHitPos = hitPosInChamber_left.
y();
217 recHitPos = hitPosInChamber_right.
y();
230 float recHitPos = -1;
232 recHitPos = recHitPosInChamber.
x();
234 recHitPos = recHitPosInChamber.
y();
240 template <
typename type>
245 bool computeResidual =
true;
248 vector<DTRecHit1D> recHits1D_S3;
255 if (phiRecHits.size() != 8) {
256 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Phi segments has: " << phiRecHits.size()
257 <<
" hits, skipping";
258 computeResidual =
false;
260 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
263 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the phi segment! ";
264 computeResidual =
false;
271 if (zRecHits.size() != 4) {
272 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Theta segments has: " << zRecHits.size()
273 <<
" hits, skipping";
274 computeResidual =
false;
276 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
279 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the z segment! ";
280 computeResidual =
false;
284 if (!computeResidual)
286 if (computeResidual) {
289 for (vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin(); recHit1D != recHits1D_S3.end();
291 const DTWireId wireId = (*recHit1D).wireId();
300 LocalPoint wirePosInLay(wireX, (*recHit1D).localPosition().y(), (*recHit1D).localPosition().z());
311 float SegmDistance = -1;
312 if (sl == 1 || sl == 3) {
314 SegmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
315 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
316 }
else if (sl == 2) {
318 SegmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
319 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
321 if (SegmDistance > 2.1)
322 LogTrace(
"DTCalibValidation") <<
" Warning: dist segment-wire: " << SegmDistance;
325 if (recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
326 LogTrace(
"DTCalibValidation") <<
" No RecHit found at Step: " <<
step <<
" in cell: " << wireId;
328 const vector<type>&
recHits = recHitsPerWire.at(wireId);
330 <<
" in channel: " << wireId;
335 const type* theBestRecHit = findBestRecHit(layer, wireId,
recHits, SegmDistance);
337 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
338 LogTrace(
"DTCalibValidation") <<
"recHitWireDist: " << recHitWireDist;
341 float residualOnDistance = recHitWireDist - SegmDistance;
342 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnDistance: " << residualOnDistance;
343 float residualOnPosition = -1;
344 float recHitPos = -1;
345 if (sl == 1 || sl == 3) {
346 recHitPos = recHitPosition(*theBestRecHit, layer,
chamber, segPosAtZWire.
x(), sl);
347 residualOnPosition = recHitPos - segPosAtZWire.
x();
349 recHitPos = recHitPosition(*theBestRecHit, layer,
chamber, segPosAtZWire.
y(), sl);
350 residualOnPosition = recHitPos - segPosAtZWire.
y();
352 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnPosition: " << residualOnPosition;
355 if (sl == 1 || sl == 3)
356 fillHistos(wireId.superlayerId(),
359 (wirePosInChamber.
x() - segPosAtZWire.
x()),
363 fillHistos(wireId.superlayerId(),
366 (wirePosInChamber.
y() - segPosAtZWire.
y()),
383 vector<const DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
384 vector<const DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
385 for (; ch_it != ch_end; ++ch_it) {
386 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
387 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
389 for (; sl_it != sl_end; ++sl_it) {
390 slId = (*sl_it)->id();
397 LogTrace(
"DTCalibValidation") <<
" Booking histos for SL: " << slId;
406 stringstream superLayer;
412 string slHistoName =
"_STEP" + Step.str() +
"_W" +
wheel.str() +
"_St" +
station.str() +
"_Sec" + sector.str() +
413 "_SL" + superLayer.str();
418 vector<MonitorElement*>
histos;
421 "hResDist" + slHistoName,
"Residuals on the distance from wire (rec_hit - segm_extr) (cm)", 200, -0.4, 0.4));
423 ibooker.
book2D(
"hResDistVsDist" + slHistoName,
424 "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
432 histos.push_back(ibooker.
book1D(
"hResPos" + slHistoName,
433 "Residuals on the position from wire (rec_hit - segm_extr) (cm)",
438 ibooker.
book2D(
"hResPosVsPos" + slHistoName,
439 "Residuals on the position (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
458 vector<MonitorElement*>
histos = histosPerSL[make_pair(slId,
step)];
459 histos[0]->Fill(residualOnDistance);
462 histos[2]->Fill(residualOnPosition);