39 segment4DToken_ = consumes<DTRecSegment4DCollection>(
edm::InputTag(
40 parameters.getUntrackedParameter<
string>(
"segment4DLabel")));
42 muonToken_ = consumes<reco::MuonCollection>(
57 <<
"Segments used to compute residuals: " << rightSegment;
59 <<
"Segments not used to compute residuals: " << wrongSegment;
73 LogTrace(
"DTCalibValidationFromMuons")
74 <<
"[DTCalibValidationFromMuons] Analyze #Run: " <<
event.id().run()
78 LogTrace(
"DTCalibValidationFromMuons") <<
" -- DTRecHit S3: begin analysis:";
81 event.getByToken(muonToken_, muonH);
86 event.getByToken(segment4DToken_, segment4Ds);
88 vector<const DTRecSegment4D *> selectedSegment4Ds;
90 for (
auto &imuon : *muons) {
91 for (
const auto &ch : imuon.matches()) {
92 DetId chId(ch.id.rawId());
99 if (!imuon.isGlobalMuon())
102 int nsegs = ch.segmentMatches.size();
110 segment != segs.second; ++segment) {
112 float dx = (posHit.
x() ? posHit.
x() - ch.x : 0);
113 float dy = (posHit.
y() ? posHit.
y() - ch.y : 0);
114 float dr =
sqrt(dx * dx + dy * dy);
116 selectedSegment4Ds.push_back(&(*segment));
122 for (
auto segment : selectedSegment4Ds) {
123 LogTrace(
"DTCalibValidationFromMuons") <<
"Anlysis on recHit at step 3";
124 compute(dtGeom.product(), *segment);
147 float segmentPos,
int sl) {
157 float recHitPos = -1;
159 if (fabs(hitPosInChamber_left.
x() - segmentPos) <
160 fabs(hitPosInChamber_right.
x() - segmentPos))
161 recHitPos = hitPosInChamber_left.
x();
163 recHitPos = hitPosInChamber_right.
x();
165 if (fabs(hitPosInChamber_left.
y() - segmentPos) <
166 fabs(hitPosInChamber_right.
y() - segmentPos))
167 recHitPos = hitPosInChamber_left.
y();
169 recHitPos = hitPosInChamber_right.
y();
179 float segmentPos,
int sl) {
185 float recHitPos = -1;
187 recHitPos = recHitPosInChamber.
x();
189 recHitPos = recHitPosInChamber.
y();
198 bool computeResidual =
true;
201 vector<DTRecHit1D> recHits1D_S3;
208 if (phiRecHits.size() < 7) {
209 LogTrace(
"DTCalibValidationFromMuons")
210 <<
"[DTCalibValidationFromMuons] Phi segments has: " 211 << phiRecHits.size() <<
" hits, skipping";
212 computeResidual =
false;
214 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
217 LogTrace(
"DTCalibValidationFromMuons")
218 <<
" [DTCalibValidationFromMuons] 4D segment has no phi segment! ";
219 computeResidual =
false;
226 if (zRecHits.size() != 4) {
227 LogTrace(
"DTCalibValidationFromMuons")
228 <<
"[DTCalibValidationFromMuons] Theta segments has: " 229 << zRecHits.size() <<
" hits, skipping";
230 computeResidual =
false;
232 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
235 LogTrace(
"DTCalibValidationFromMuons")
236 <<
" [DTCalibValidationFromMuons] 4D segment has not the z segment! ";
237 computeResidual =
false;
241 if (!computeResidual)
244 if (computeResidual) {
248 for (vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin();
249 recHit1D != recHits1D_S3.end(); ++recHit1D) {
250 const DTWireId wireId = (*recHit1D).wireId();
260 LocalPoint wirePosInLay(wireX, (*recHit1D).localPosition().y(),
261 (*recHit1D).localPosition().z());
264 dtGeom->
chamber((*recHit1D).wireId().layerId().chamberId());
270 wirePosInChamber.
z() /
275 float SegmDistance = -1;
276 if (sl == 1 || sl == 3) {
278 SegmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
279 LogTrace(
"DTCalibValidationFromMuons")
280 <<
"SegmDistance: " << SegmDistance;
281 }
else if (sl == 2) {
283 SegmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
284 LogTrace(
"DTCalibValidationFromMuons")
285 <<
"SegmDistance: " << SegmDistance;
288 if (SegmDistance > 2.1)
289 LogTrace(
"DTCalibValidationFromMuons")
290 <<
" Warning: dist segment-wire: " << SegmDistance;
293 float recHitWireDist = recHitDistFromWire(*recHit1D, layer);
294 LogTrace(
"DTCalibValidationFromMuons")
295 <<
"recHitWireDist: " << recHitWireDist;
298 float residualOnDistance = recHitWireDist - SegmDistance;
299 LogTrace(
"DTCalibValidationFromMuons")
300 <<
"WireId: " << wireId
301 <<
" ResidualOnDistance: " << residualOnDistance;
302 float residualOnPosition = -1;
303 float recHitPos = -1;
304 if (sl == 1 || sl == 3) {
306 recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.
x(), sl);
307 residualOnPosition = recHitPos - segPosAtZWire.
x();
310 recHitPosition(*recHit1D, layer, chamber, segPosAtZWire.
y(), sl);
311 residualOnPosition = recHitPos - segPosAtZWire.
y();
313 LogTrace(
"DTCalibValidationFromMuons")
314 <<
"WireId: " << wireId
315 <<
" ResidualOnPosition: " << residualOnPosition;
318 if (sl == 1 || sl == 3)
319 fillHistos(wireId.
superlayerId(), SegmDistance, residualOnDistance,
320 (wirePosInChamber.
x() - segPosAtZWire.
x()),
321 residualOnPosition, 3);
323 fillHistos(wireId.
superlayerId(), SegmDistance, residualOnDistance,
324 (wirePosInChamber.
y() - segPosAtZWire.
y()),
325 residualOnPosition, 3);
340 vector<const DTChamber *>::const_iterator ch_it = dtGeom->chambers().begin();
341 vector<const DTChamber *>::const_iterator ch_end = dtGeom->chambers().end();
342 for (; ch_it != ch_end; ++ch_it) {
343 vector<const DTSuperLayer *>::const_iterator sl_it =
344 (*ch_it)->superLayers().begin();
345 vector<const DTSuperLayer *>::const_iterator sl_end =
346 (*ch_it)->superLayers().end();
348 for (; sl_it != sl_end; ++sl_it) {
349 slId = (*sl_it)->id();
356 LogTrace(
"DTCalibValidationFromMuons")
357 <<
" Booking histos for SL: " << slId;
361 wheel << slId.
wheel();
366 stringstream superLayer;
372 string slHistoName =
"_STEP" + Step.str() +
"_W" + wheel.str() +
"_St" +
373 station.str() +
"_Sec" + sector.str() +
"_SL" +
377 wheel.str() +
"/Station" + station.str() +
378 "/Sector" + sector.str());
380 vector<MonitorElement *>
histos;
382 histos.push_back(ibooker.
book1D(
383 "hResDist" + slHistoName,
384 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
387 ibooker.
book2D(
"hResDistVsDist" + slHistoName,
388 "Residuals on the distance (cm) from wire (rec_hit " 389 "- segm_extr) vs distance (cm)",
390 100, 0, 2.5, 200, -0.4, 0.4));
392 histosPerSL[make_pair(slId, step)] =
histos;
400 float residualOnDistance,
402 float residualOnPosition,
405 vector<MonitorElement *>
histos = histosPerSL[make_pair(slId, step)];
406 histos[0]->Fill(residualOnDistance);
407 histos[1]->Fill(distance, residualOnDistance);
LocalPoint localPosition() const override
Return the 3-dimensional local position.
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
int dimension() const override
Dimension (in parameter space)
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
LocalPoint localPosition() const override
Local position in Chamber frame.
std::pair< const_iterator, const_iterator > range
iterator range
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
LocalVector localDirection() const override
Local direction in Chamber frame.
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance, float position, float residualOnPosition, int step)
float recHitPosition(const DTRecHit1DPair &hitPair, const DTLayer *layer, const DTChamber *chamber, float segmPos, int sl)
def setup(process, global_tag, zero_tesla=False)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
DTCalibValidationFromMuons(const edm::ParameterSet &pset)
Constructor.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
BeginRun.
void compute(const DTGeometry *dtGeom, const DTRecSegment4D &segment)
Geom::Theta< T > theta() const
C::const_iterator const_iterator
constant access iterator type
const DTTopology & specificTopology() const
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer)
void setCurrentFolder(std::string const &fullpath)
Cos< T >::type cos(const T &t)
MonitorElement * book1D(Args &&...args)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int wire() const
Return the wire number.
int superlayer() const
Return the superlayer number (deprecated method name)
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
T const * product() const
MonitorElement * book2D(Args &&...args)
~DTCalibValidationFromMuons() override
Destructor.
static int position[264][3]
LocalPoint localPosition() const override
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
int station() const
Return the station number.
int wheel() const
Return the wheel number.
DTWireId wireId() const
Return the wireId.