41 recHits1DToken_ = consumes<DTRecHitCollection>(
44 segment2DToken_ = consumes<DTRecSegment2DCollection>(
47 segment4DToken_ = consumes<DTRecSegment4DCollection>(
54 detailedAnalysis =
parameters.getUntrackedParameter<
bool>(
"detailedAnalysis",
false);
65 LogVerbatim(
"DTCalibValidation") <<
"Segments used to compute residuals: " << rightSegment;
66 LogVerbatim(
"DTCalibValidation") <<
"Segments not used to compute residuals: " << wrongSegment;
80 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Analyze #Run: " <<
event.id().run()
84 map<DTWireId,vector<DTRecHit1DPair> > recHitsPerWire_1S;
87 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire_2S;
90 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S1: begin analysis:";
93 event.getByToken(recHits1DToken_, dtRecHits);
94 recHitsPerWire_1S = map1DRecHitsPerWire(dtRecHits.
product());
96 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S2: begin analysis:";
99 event.getByToken(segment2DToken_, segment2Ds);
100 recHitsPerWire_2S = map1DRecHitsPerWire(segment2Ds.
product());
104 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S3: begin analysis:";
107 event.getByToken(segment4DToken_, segment4Ds);
108 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire_3S = map1DRecHitsPerWire(segment4Ds.
product());
113 segment != segment4Ds->end();
116 if(detailedAnalysis){
117 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 1";
118 compute(dtGeom.product(), (*segment), recHitsPerWire_1S, 1);
120 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 2";
121 compute(dtGeom.product(), (*segment), recHitsPerWire_2S, 2);
124 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 3";
125 compute(dtGeom.product(), (*segment), recHitsPerWire_3S, 3);
132 map<DTWireId, vector<DTRecHit1DPair> >
134 map<DTWireId, vector<DTRecHit1DPair> > ret;
137 rechit != dt1DRecHitPairs->end(); ++rechit) {
138 ret[(*rechit).wireId()].push_back(*rechit);
146 map<DTWireId, vector<DTRecHit1D> >
148 map<DTWireId, vector<DTRecHit1D> > ret;
152 segment != segment2Ds->end();
154 vector<DTRecHit1D> component1DHits= (*segment).specificRecHits();
156 for(vector<DTRecHit1D>::const_iterator
hit = component1DHits.begin();
157 hit != component1DHits.end(); ++
hit) {
158 ret[(*hit).wireId()].push_back(*
hit);
165 map<DTWireId, std::vector<DTRecHit1D> >
167 map<DTWireId, vector<DTRecHit1D> > ret;
170 segment != segment4Ds->end();
173 vector<const TrackingRecHit*> segment2Ds = (*segment).recHits();
175 for(vector<const TrackingRecHit*>::const_iterator segment2D = segment2Ds.begin();
176 segment2D != segment2Ds.end();
179 vector<const TrackingRecHit*>
hits = (*segment2D)->recHits();
181 for(vector<const TrackingRecHit*>::const_iterator
hit = hits.begin();
182 hit != hits.end(); ++
hit) {
184 ret[hit1D->
wireId()].push_back(*hit1D);
195 template <
typename type>
199 const vector<type>& recHits,
200 const float segmDist) {
202 const type* theBestRecHit =
nullptr;
204 for(
typename vector<type>::const_iterator
recHit = recHits.begin();
207 float distTmp = recHitDistFromWire(*
recHit, layer);
208 if(fabs(distTmp-segmDist) < res) {
209 res = fabs(distTmp-segmDist);
210 theBestRecHit = &(*recHit);
214 return theBestRecHit;
245 if(fabs(hitPosInChamber_left.
x()-segmentPos)<fabs(hitPosInChamber_right.
x()-segmentPos))
246 recHitPos = hitPosInChamber_left.
x();
248 recHitPos = hitPosInChamber_right.
x();
251 if(fabs(hitPosInChamber_left.
y()-segmentPos)<fabs(hitPosInChamber_right.
y()-segmentPos))
252 recHitPos = hitPosInChamber_left.
y();
254 recHitPos = hitPosInChamber_right.
y();
269 float recHitPos = -1;
271 recHitPos = recHitPosInChamber.
x();
273 recHitPos = recHitPosInChamber.
y();
280 template <
typename type>
285 bool computeResidual =
true;
288 vector<DTRecHit1D> recHits1D_S3;
295 if(phiRecHits.size() != 8) {
296 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Phi segments has: " << phiRecHits.size()
297 <<
" hits, skipping";
298 computeResidual =
false;
300 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
303 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the phi segment! ";
304 computeResidual =
false;
311 if(zRecHits.size() != 4) {
312 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Theta segments has: " << zRecHits.size()
313 <<
" hits, skipping";
314 computeResidual =
false;
316 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
319 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the z segment! ";
320 computeResidual =
false;
329 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin();
330 recHit1D != recHits1D_S3.end();
332 const DTWireId wireId = (*recHit1D).wireId();
341 LocalPoint wirePosInLay(wireX,(*recHit1D).localPosition().y(),(*recHit1D).localPosition().z());
352 float SegmDistance = -1;
353 if(sl == 1 || sl == 3) {
355 SegmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
356 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
359 SegmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
360 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
362 if(SegmDistance > 2.1)
363 LogTrace(
"DTCalibValidation") <<
" Warning: dist segment-wire: " << SegmDistance;
366 if(recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
367 LogTrace(
"DTCalibValidation") <<
" No RecHit found at Step: " << step <<
" in cell: " << wireId;
369 const vector<type>& recHits = recHitsPerWire.at(wireId);
370 LogTrace(
"DTCalibValidation") <<
" " << recHits.size() <<
" RecHits, Step " << step <<
" in channel: " << wireId;
375 const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, SegmDistance);
377 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
378 LogTrace(
"DTCalibValidation") <<
"recHitWireDist: " << recHitWireDist;
381 float residualOnDistance = recHitWireDist - SegmDistance;
382 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnDistance: " << residualOnDistance;
383 float residualOnPosition = -1;
384 float recHitPos = -1;
385 if(sl == 1 || sl == 3) {
386 recHitPos = recHitPosition(*theBestRecHit, layer, chamber, segPosAtZWire.
x(), sl);
387 residualOnPosition = recHitPos - segPosAtZWire.
x();
390 recHitPos = recHitPosition(*theBestRecHit, layer, chamber, segPosAtZWire.
y(), sl);
391 residualOnPosition = recHitPos - segPosAtZWire.
y();
393 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnPosition: " << residualOnPosition;
396 if(sl == 1 || sl == 3)
397 fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.
x() - segPosAtZWire.
x()), residualOnPosition, step);
399 fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.
y() - segPosAtZWire.
y()), residualOnPosition, step);
416 vector<const DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
417 vector<const DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
418 for (; ch_it != ch_end; ++ch_it) {
419 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
420 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
422 for(; sl_it != sl_end; ++sl_it) {
423 slId = (*sl_it)->id();
426 if(!detailedAnalysis) firstStep=3;
430 LogTrace(
"DTCalibValidation") <<
" Booking histos for SL: " << slId;
435 stringstream sector; sector << slId.
sector();
436 stringstream superLayer; superLayer << slId.
superlayer();
442 "_STEP" + Step.str() +
444 "_St" + station.str() +
445 "_Sec" + sector.str() +
446 "_SL" + superLayer.str();
449 "/Station" + station.str() +
450 "/Sector" + sector.str());
452 vector<MonitorElement *>
histos;
454 histos.push_back(ibooker.
book1D(
"hResDist"+slHistoName,
455 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
457 histos.push_back(ibooker.
book2D(
"hResDistVsDist"+slHistoName,
458 "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
459 100, 0, 2.5, 200, -0.4, 0.4));
460 if(detailedAnalysis){
461 histos.push_back(ibooker.
book1D(
"hResPos"+slHistoName,
462 "Residuals on the position from wire (rec_hit - segm_extr) (cm)",
464 histos.push_back(ibooker.
book2D(
"hResPosVsPos"+slHistoName,
465 "Residuals on the position (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
466 200, -2.5, 2.5, 200, -0.4, 0.4));
469 histosPerSL[make_pair(slId, step)] =
histos;
479 float residualOnDistance,
481 float residualOnPosition,
484 vector<MonitorElement *>
histos = histosPerSL[make_pair(slId,step)];
485 histos[0]->Fill(residualOnDistance);
486 histos[1]->Fill(distance, residualOnDistance);
487 if(detailedAnalysis){
488 histos[2]->Fill(residualOnPosition);
489 histos[3]->Fill(position, residualOnPosition);
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)
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.
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.
def setup(process, global_tag, zero_tesla=False)
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
void setCurrentFolder(std::string const &fullpath)
Cos< T >::type cos(const T &t)
MonitorElement * book1D(Args &&...args)
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
MonitorElement * book2D(Args &&...args)
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
BeginRun.
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.