49 theDbe->setCurrentFolder(
"DT/DTCalibValidation");
62 recHits1DLabel =
parameters.getUntrackedParameter<
string>(
"recHits1DLabel");
64 segment2DLabel =
parameters.getUntrackedParameter<
string>(
"segment2DLabel");
66 segment4DLabel =
parameters.getUntrackedParameter<
string>(
"segment4DLabel");
72 detailedAnalysis =
parameters.getUntrackedParameter<
bool>(
"detailedAnalysis",
false);
84 vector<DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
85 vector<DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
86 for (; ch_it != ch_end; ++ch_it) {
87 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
88 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
90 for(; sl_it != sl_end; ++sl_it) {
107 LogVerbatim(
"DTCalibValidation") <<
"Segments used to compute residuals: " << rightSegment;
108 LogVerbatim(
"DTCalibValidation") <<
"Segments not used to compute residuals: " << wrongSegment;
111 bool outputMEsInRootFile =
parameters.getParameter<
bool>(
"OutputMEsInRootFile");
113 if(outputMEsInRootFile){
114 theDbe->showDirStructure();
115 theDbe->save(outputFileName);
118 theDbe->rmdir(
"DT/DTCalibValidation");
126 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Analyze #Run: " <<
event.id().run()
130 map<DTWireId,vector<DTRecHit1DPair> > recHitsPerWire_1S;
133 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire_2S;
135 if(detailedAnalysis){
136 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S1: begin analysis:";
139 event.getByLabel(recHits1DLabel, dtRecHits);
140 recHitsPerWire_1S = map1DRecHitsPerWire(dtRecHits.
product());
142 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S2: begin analysis:";
145 event.getByLabel(segment2DLabel, segment2Ds);
146 recHitsPerWire_2S = map1DRecHitsPerWire(segment2Ds.
product());
150 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S3: begin analysis:";
153 event.getByLabel(segment4DLabel, segment4Ds);
154 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire_3S = map1DRecHitsPerWire(segment4Ds.
product());
159 segment != segment4Ds->end();
162 if(detailedAnalysis){
163 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 1";
164 compute(dtGeom.product(), (*segment), recHitsPerWire_1S, 1);
166 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 2";
167 compute(dtGeom.product(), (*segment), recHitsPerWire_2S, 2);
170 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 3";
171 compute(dtGeom.product(), (*segment), recHitsPerWire_3S, 3);
178 map<DTWireId, vector<DTRecHit1DPair> >
180 map<DTWireId, vector<DTRecHit1DPair> >
ret;
183 rechit != dt1DRecHitPairs->end(); ++rechit) {
184 ret[(*rechit).wireId()].push_back(*rechit);
192 map<DTWireId, vector<DTRecHit1D> >
194 map<DTWireId, vector<DTRecHit1D> >
ret;
198 segment != segment2Ds->end();
200 vector<DTRecHit1D> component1DHits= (*segment).specificRecHits();
202 for(vector<DTRecHit1D>::const_iterator
hit = component1DHits.begin();
203 hit != component1DHits.end(); ++
hit) {
204 ret[(*hit).wireId()].push_back(*
hit);
211 map<DTWireId, std::vector<DTRecHit1D> >
213 map<DTWireId, vector<DTRecHit1D> >
ret;
216 segment != segment4Ds->end();
219 vector<const TrackingRecHit*> segment2Ds = (*segment).recHits();
221 for(vector<const TrackingRecHit*>::const_iterator segment2D = segment2Ds.begin();
222 segment2D != segment2Ds.end();
225 vector<const TrackingRecHit*> hits = (*segment2D)->recHits();
227 for(vector<const TrackingRecHit*>::const_iterator
hit = hits.begin();
228 hit != hits.end(); ++
hit) {
230 ret[hit1D->
wireId()].push_back(*hit1D);
241 template <
typename type>
245 const vector<type>& recHits,
246 const float segmDist) {
248 const type* theBestRecHit = 0;
250 for(
typename vector<type>::const_iterator recHit = recHits.begin();
251 recHit != recHits.end();
253 float distTmp = recHitDistFromWire(*recHit, layer);
254 if(fabs(distTmp-segmDist) < res) {
255 res = fabs(distTmp-segmDist);
256 theBestRecHit = &(*recHit);
260 return theBestRecHit;
312 if(fabs(hitPosInChamber_left.
x()-segmentPos)<fabs(hitPosInChamber_right.
x()-segmentPos))
313 recHitPos = hitPosInChamber_left.
x();
315 recHitPos = hitPosInChamber_right.
x();
318 if(fabs(hitPosInChamber_left.
y()-segmentPos)<fabs(hitPosInChamber_right.
y()-segmentPos))
319 recHitPos = hitPosInChamber_left.
y();
321 recHitPos = hitPosInChamber_right.
y();
336 float recHitPos = -1;
338 recHitPos = recHitPosInChamber.
x();
340 recHitPos = recHitPosInChamber.
y();
349 template <
typename type>
354 bool computeResidual =
true;
357 vector<DTRecHit1D> recHits1D_S3;
364 if(phiRecHits.size() != 8) {
365 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Phi segments has: " << phiRecHits.size()
366 <<
" hits, skipping";
367 computeResidual =
false;
369 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
372 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the phi segment! ";
373 computeResidual =
false;
380 if(zRecHits.size() != 4) {
381 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Theta segments has: " << zRecHits.size()
382 <<
" hits, skipping";
383 computeResidual =
false;
385 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
388 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the z segment! ";
389 computeResidual =
false;
398 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin();
399 recHit1D != recHits1D_S3.end();
401 const DTWireId wireId = (*recHit1D).wireId();
410 LocalPoint wirePosInLay(wireX,(*recHit1D).localPosition().y(),(*recHit1D).localPosition().z());
412 const DTChamber* chamber = dtGeom->
chamber((*recHit1D).wireId().layerId().chamberId());
421 float SegmDistance = -1;
422 if(sl == 1 || sl == 3) {
424 SegmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
425 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
428 SegmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
429 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
431 if(SegmDistance > 2.1)
432 LogTrace(
"DTCalibValidation") <<
" Warning: dist segment-wire: " << SegmDistance;
435 if(recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
436 LogTrace(
"DTCalibValidation") <<
" No RecHit found at Step: " << step <<
" in cell: " << wireId;
438 vector<type> recHits = recHitsPerWire[wireId];
439 LogTrace(
"DTCalibValidation") <<
" " << recHits.size() <<
" RecHits, Step " << step <<
" in channel: " << wireId;
444 const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, SegmDistance);
446 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
447 LogTrace(
"DTCalibValidation") <<
"recHitWireDist: " << recHitWireDist;
450 float residualOnDistance = recHitWireDist - SegmDistance;
451 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnDistance: " << residualOnDistance;
452 float residualOnPosition = -1;
453 float recHitPos = -1;
454 if(sl == 1 || sl == 3) {
455 recHitPos = recHitPosition(*theBestRecHit, layer, chamber, segPosAtZWire.
x(), sl);
456 residualOnPosition = recHitPos - segPosAtZWire.
x();
459 recHitPos = recHitPosition(*theBestRecHit, layer, chamber, segPosAtZWire.
y(), sl);
460 residualOnPosition = recHitPos - segPosAtZWire.
y();
462 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnPosition: " << residualOnPosition;
465 if(sl == 1 || sl == 3)
466 fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.
x() - segPosAtZWire.
x()), residualOnPosition, step);
468 fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.
y() - segPosAtZWire.
y()), residualOnPosition, step);
481 LogTrace(
"DTCalibValidation") <<
" Booking histos for SL: " << slId;
484 stringstream wheel; wheel << slId.
wheel();
486 stringstream sector; sector << slId.
sector();
487 stringstream superLayer; superLayer << slId.
superlayer();
493 "_STEP" + Step.str() +
495 "_St" + station.str() +
496 "_Sec" + sector.str() +
497 "_SL" + superLayer.str();
499 theDbe->setCurrentFolder(
"DT/DTCalibValidation/Wheel" + wheel.str() +
500 "/Station" + station.str() +
501 "/Sector" + sector.str());
503 vector<MonitorElement *>
histos;
505 histos.push_back(theDbe->book1D(
"hResDist"+slHistoName,
506 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
508 histos.push_back(theDbe->book2D(
"hResDistVsDist"+slHistoName,
509 "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
510 100, 0, 2.5, 200, -0.4, 0.4));
511 if(detailedAnalysis){
512 histos.push_back(theDbe->book1D(
"hResPos"+slHistoName,
513 "Residuals on the position from wire (rec_hit - segm_extr) (cm)",
515 histos.push_back(theDbe->book2D(
"hResPosVsPos"+slHistoName,
516 "Residuals on the position (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
517 200, -2.5, 2.5, 200, -0.4, 0.4));
520 histosPerSL[make_pair(slId, step)] =
histos;
528 float residualOnDistance,
530 float residualOnPosition,
533 vector<MonitorElement *>
histos = histosPerSL[make_pair(slId,step)];
534 histos[0]->Fill(residualOnDistance);
535 histos[1]->Fill(distance, residualOnDistance);
536 if(detailedAnalysis){
537 histos[2]->Fill(residualOnPosition);
538 histos[3]->Fill(position, residualOnPosition);
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer)
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.
static int position[TOTALCHAMBERS][3]
void beginRun(const edm::Run &, const edm::EventSetup &)
BeginRun.
Geom::Theta< T > theta() const
const DTLayer * layer(DTLayerId id) const
Return a layer given its id.
virtual LocalVector localDirection() const
Local direction in Chamber frame.
C::const_iterator const_iterator
constant access iterator type
const DTTopology & specificTopology() const
void compute(const DTGeometry *dtGeom, const DTRecSegment4D &segment, std::map< DTWireId, std::vector< type > > recHitsPerWire, int step)
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)
void analyze(const edm::Event &event, const edm::EventSetup &setup)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual LocalPoint localPosition() const
Local position in Chamber frame.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
virtual int dimension() const
Dimension (in parameter space)
virtual LocalPoint localPosition() const
Return the 3-dimensional local position.
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.
virtual ~DTCalibValidation()
Destructor.
const DTChamber * chamber(DTChamberId id) const
Return a DTChamber given its id.
T const * product() const
void bookHistos(DTSuperLayerId slId, int step)
DTCalibValidation(const edm::ParameterSet &pset)
Constructor.
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.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual LocalPoint localPosition() const
const type * findBestRecHit(const DTLayer *layer, DTWireId wireId, const std::vector< type > &recHits, const float simHitDist)
DTWireId wireId() const
Return the wireId.