47 theDbe->setCurrentFolder(
"DT/DTCalibValidation");
60 recHits1DToken_ = consumes<DTRecHitCollection>(
63 segment2DToken_ = consumes<DTRecSegment2DCollection>(
66 segment4DToken_ = consumes<DTRecSegment4DCollection>(
73 detailedAnalysis =
parameters.getUntrackedParameter<
bool>(
"detailedAnalysis",
false);
85 vector<const DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
86 vector<const DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
87 for (; ch_it != ch_end; ++ch_it) {
88 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
89 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
91 for(; sl_it != sl_end; ++sl_it) {
108 LogVerbatim(
"DTCalibValidation") <<
"Segments used to compute residuals: " << rightSegment;
109 LogVerbatim(
"DTCalibValidation") <<
"Segments not used to compute residuals: " << wrongSegment;
112 bool outputMEsInRootFile =
parameters.getParameter<
bool>(
"OutputMEsInRootFile");
114 if(outputMEsInRootFile){
115 theDbe->showDirStructure();
116 theDbe->save(outputFileName);
119 theDbe->rmdir(
"DT/DTCalibValidation");
127 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Analyze #Run: " <<
event.id().run()
131 map<DTWireId,vector<DTRecHit1DPair> > recHitsPerWire_1S;
134 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire_2S;
136 if(detailedAnalysis){
137 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S1: begin analysis:";
140 event.getByToken(recHits1DToken_, dtRecHits);
141 recHitsPerWire_1S = map1DRecHitsPerWire(dtRecHits.
product());
143 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S2: begin analysis:";
146 event.getByToken(segment2DToken_, segment2Ds);
147 recHitsPerWire_2S = map1DRecHitsPerWire(segment2Ds.
product());
151 LogTrace(
"DTCalibValidation") <<
" -- DTRecHit S3: begin analysis:";
154 event.getByToken(segment4DToken_, segment4Ds);
155 map<DTWireId,vector<DTRecHit1D> > recHitsPerWire_3S = map1DRecHitsPerWire(segment4Ds.
product());
160 segment != segment4Ds->end();
163 if(detailedAnalysis){
164 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 1";
165 compute(dtGeom.product(), (*segment), recHitsPerWire_1S, 1);
167 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 2";
168 compute(dtGeom.product(), (*segment), recHitsPerWire_2S, 2);
171 LogTrace(
"DTCalibValidation") <<
"Anlysis on recHit at step 3";
172 compute(dtGeom.product(), (*segment), recHitsPerWire_3S, 3);
179 map<DTWireId, vector<DTRecHit1DPair> >
181 map<DTWireId, vector<DTRecHit1DPair> >
ret;
184 rechit != dt1DRecHitPairs->end(); ++rechit) {
185 ret[(*rechit).wireId()].push_back(*rechit);
193 map<DTWireId, vector<DTRecHit1D> >
195 map<DTWireId, vector<DTRecHit1D> >
ret;
199 segment != segment2Ds->end();
201 vector<DTRecHit1D> component1DHits= (*segment).specificRecHits();
203 for(vector<DTRecHit1D>::const_iterator
hit = component1DHits.begin();
204 hit != component1DHits.end(); ++
hit) {
205 ret[(*hit).wireId()].push_back(*
hit);
212 map<DTWireId, std::vector<DTRecHit1D> >
214 map<DTWireId, vector<DTRecHit1D> >
ret;
217 segment != segment4Ds->end();
220 vector<const TrackingRecHit*> segment2Ds = (*segment).recHits();
222 for(vector<const TrackingRecHit*>::const_iterator segment2D = segment2Ds.begin();
223 segment2D != segment2Ds.end();
226 vector<const TrackingRecHit*> hits = (*segment2D)->recHits();
228 for(vector<const TrackingRecHit*>::const_iterator
hit = hits.begin();
229 hit != hits.end(); ++
hit) {
231 ret[hit1D->
wireId()].push_back(*hit1D);
242 template <
typename type>
246 const vector<type>& recHits,
247 const float segmDist) {
249 const type* theBestRecHit = 0;
251 for(
typename vector<type>::const_iterator recHit = recHits.begin();
252 recHit != recHits.end();
254 float distTmp = recHitDistFromWire(*recHit, layer);
255 if(fabs(distTmp-segmDist) < res) {
256 res = fabs(distTmp-segmDist);
257 theBestRecHit = &(*recHit);
261 return theBestRecHit;
313 if(fabs(hitPosInChamber_left.
x()-segmentPos)<fabs(hitPosInChamber_right.
x()-segmentPos))
314 recHitPos = hitPosInChamber_left.
x();
316 recHitPos = hitPosInChamber_right.
x();
319 if(fabs(hitPosInChamber_left.
y()-segmentPos)<fabs(hitPosInChamber_right.
y()-segmentPos))
320 recHitPos = hitPosInChamber_left.
y();
322 recHitPos = hitPosInChamber_right.
y();
337 float recHitPos = -1;
339 recHitPos = recHitPosInChamber.
x();
341 recHitPos = recHitPosInChamber.
y();
350 template <
typename type>
355 bool computeResidual =
true;
358 vector<DTRecHit1D> recHits1D_S3;
365 if(phiRecHits.size() != 8) {
366 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Phi segments has: " << phiRecHits.size()
367 <<
" hits, skipping";
368 computeResidual =
false;
370 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
373 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the phi segment! ";
374 computeResidual =
false;
381 if(zRecHits.size() != 4) {
382 LogTrace(
"DTCalibValidation") <<
"[DTCalibValidation] Theta segments has: " << zRecHits.size()
383 <<
" hits, skipping";
384 computeResidual =
false;
386 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
389 LogTrace(
"DTCalibValidation") <<
" [DTCalibValidation] 4D segment has not the z segment! ";
390 computeResidual =
false;
399 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin();
400 recHit1D != recHits1D_S3.end();
402 const DTWireId wireId = (*recHit1D).wireId();
411 LocalPoint wirePosInLay(wireX,(*recHit1D).localPosition().y(),(*recHit1D).localPosition().z());
413 const DTChamber* chamber = dtGeom->
chamber((*recHit1D).wireId().layerId().chamberId());
422 float SegmDistance = -1;
423 if(sl == 1 || sl == 3) {
425 SegmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
426 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
429 SegmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
430 LogTrace(
"DTCalibValidation") <<
"SegmDistance: " << SegmDistance;
432 if(SegmDistance > 2.1)
433 LogTrace(
"DTCalibValidation") <<
" Warning: dist segment-wire: " << SegmDistance;
436 if(recHitsPerWire.find(wireId) == recHitsPerWire.end()) {
437 LogTrace(
"DTCalibValidation") <<
" No RecHit found at Step: " << step <<
" in cell: " << wireId;
439 vector<type> recHits = recHitsPerWire.at(wireId);
440 LogTrace(
"DTCalibValidation") <<
" " << recHits.size() <<
" RecHits, Step " << step <<
" in channel: " << wireId;
445 const type* theBestRecHit = findBestRecHit(layer, wireId, recHits, SegmDistance);
447 float recHitWireDist = recHitDistFromWire(*theBestRecHit, layer);
448 LogTrace(
"DTCalibValidation") <<
"recHitWireDist: " << recHitWireDist;
451 float residualOnDistance = recHitWireDist - SegmDistance;
452 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnDistance: " << residualOnDistance;
453 float residualOnPosition = -1;
454 float recHitPos = -1;
455 if(sl == 1 || sl == 3) {
456 recHitPos = recHitPosition(*theBestRecHit, layer, chamber, segPosAtZWire.
x(), sl);
457 residualOnPosition = recHitPos - segPosAtZWire.
x();
460 recHitPos = recHitPosition(*theBestRecHit, layer, chamber, segPosAtZWire.
y(), sl);
461 residualOnPosition = recHitPos - segPosAtZWire.
y();
463 LogTrace(
"DTCalibValidation") <<
"WireId: " << wireId <<
" ResidualOnPosition: " << residualOnPosition;
466 if(sl == 1 || sl == 3)
467 fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.
x() - segPosAtZWire.
x()), residualOnPosition, step);
469 fillHistos(wireId.superlayerId(), SegmDistance, residualOnDistance, (wirePosInChamber.
y() - segPosAtZWire.
y()), residualOnPosition, step);
482 LogTrace(
"DTCalibValidation") <<
" Booking histos for SL: " << slId;
485 stringstream wheel; wheel << slId.
wheel();
487 stringstream sector; sector << slId.
sector();
488 stringstream superLayer; superLayer << slId.
superlayer();
494 "_STEP" + Step.str() +
496 "_St" + station.str() +
497 "_Sec" + sector.str() +
498 "_SL" + superLayer.str();
500 theDbe->setCurrentFolder(
"DT/DTCalibValidation/Wheel" + wheel.str() +
501 "/Station" + station.str() +
502 "/Sector" + sector.str());
504 vector<MonitorElement *>
histos;
506 histos.push_back(theDbe->book1D(
"hResDist"+slHistoName,
507 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
509 histos.push_back(theDbe->book2D(
"hResDistVsDist"+slHistoName,
510 "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
511 100, 0, 2.5, 200, -0.4, 0.4));
512 if(detailedAnalysis){
513 histos.push_back(theDbe->book1D(
"hResPos"+slHistoName,
514 "Residuals on the position from wire (rec_hit - segm_extr) (cm)",
516 histos.push_back(theDbe->book2D(
"hResPosVsPos"+slHistoName,
517 "Residuals on the position (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
518 200, -2.5, 2.5, 200, -0.4, 0.4));
521 histosPerSL[make_pair(slId, step)] =
histos;
529 float residualOnDistance,
531 float residualOnPosition,
534 vector<MonitorElement *>
histos = histosPerSL[make_pair(slId,step)];
535 histos[0]->Fill(residualOnDistance);
536 histos[1]->Fill(distance, residualOnDistance);
537 if(detailedAnalysis){
538 histos[2]->Fill(residualOnPosition);
539 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.
void compute(const DTGeometry *dtGeom, const DTRecSegment4D &segment, const std::map< DTWireId, std::vector< type > > &recHitsPerWire, int step)
const DTTopology & specificTopology() const
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.