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);
101 float dr =
sqrt(dx * dx + dy * dy);
103 selectedSegment4Ds.push_back(&(*segment));
109 for (
auto segment : selectedSegment4Ds) {
110 LogTrace(
"DTCalibValidationFromMuons") <<
"Anlysis on recHit at step 3";
111 compute(dtGeom.product(), *segment);
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();
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;
314 wheel << slId.
wheel();
319 stringstream superLayer;
325 string slHistoName =
"_STEP" + Step.str() +
"_W" + wheel.str() +
"_St" + station.str() +
"_Sec" + sector.str() +
326 "_SL" + superLayer.str();
328 ibooker.
setCurrentFolder(
"DT/DTCalibValidationFromMuons/Wheel" + wheel.str() +
"/Station" + station.str() +
329 "/Sector" + sector.str());
331 vector<MonitorElement *>
histos;
333 histos.push_back(ibooker.
book1D(
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)",
345 histosPerSL[make_pair(slId, step)] =
histos;
355 vector<MonitorElement *>
histos = histosPerSL[make_pair(slId, step)];
356 histos[0]->Fill(residualOnDistance);
357 histos[1]->Fill(distance, residualOnDistance);
LocalPoint localPosition() const override
Return the 3-dimensional local position.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
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.
void setCurrentFolder(std::string const &fullpath)
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)
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)
Cos< T >::type cos(const T &t)
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
~DTCalibValidationFromMuons() override
Destructor.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
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.