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) {
160 ret[hit1D->
wireId()].push_back(*hit1D);
169 template <
typename type>
173 const float segmDist) {
175 const type* theBestRecHit =
nullptr;
177 for (
typename vector<type>::const_iterator
recHit = recHits.begin();
recHit != recHits.end(); ++
recHit) {
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);
329 LogTrace(
"DTCalibValidation") <<
" " << recHits.size() <<
" RecHits, Step " << step
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;
401 wheel << slId.
wheel();
406 stringstream superLayer;
412 string slHistoName =
"_STEP" + Step.str() +
"_W" + wheel.str() +
"_St" + station.str() +
"_Sec" + sector.str() +
413 "_SL" + superLayer.str();
415 ibooker.
setCurrentFolder(
"DT/DTCalibValidation/Wheel" + wheel.str() +
"/Station" + station.str() +
"/Sector" +
418 vector<MonitorElement*>
histos;
420 histos.push_back(ibooker.
book1D(
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)",
448 histosPerSL[make_pair(slId, step)] =
histos;
458 vector<MonitorElement*>
histos = histosPerSL[make_pair(slId, step)];
459 histos[0]->Fill(residualOnDistance);
460 histos[1]->Fill(distance, residualOnDistance);
462 histos[2]->Fill(residualOnPosition);
463 histos[3]->Fill(position, residualOnPosition);
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)
LocalPoint localPosition() const override
Local position in Chamber frame.
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer)
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
LocalVector localDirection() const override
Local direction in Chamber frame.
ret
prodAgent to be discontinued
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.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Geom::Theta< T > theta() const
void compute(const DTGeometry *dtGeom, const DTRecSegment4D &segment, const std::map< DTWireId, std::vector< type > > &recHitsPerWire, int step)
C::const_iterator const_iterator
constant access iterator type
const DTTopology & specificTopology() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Cos< T >::type cos(const T &t)
std::map< DTWireId, std::vector< DTRecHit1DPair > > map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs)
void fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance, float position, float residualOnPosition, int step)
~DTCalibValidation() override
Destructor.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
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.
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
T const * product() const
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
BeginRun.
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]
DTCalibValidation(const edm::ParameterSet &pset)
Constructor.
LocalPoint localPosition() const override
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
int station() const
Return the station number.
float recHitPosition(const DTRecHit1DPair &hitPair, const DTLayer *layer, const DTChamber *chamber, float segmPos, int sl)
int wheel() const
Return the wheel number.
const type * findBestRecHit(const DTLayer *layer, DTWireId wireId, const std::vector< type > &recHits, const float simHitDist)
DTWireId wireId() const
Return the wireId.