Perform the real analysis.
116 map<DTChamberId, PSimHitContainer > simHitsPerCh;
117 for (
const auto &
simHit : *simHits) {
124 simHitsPerCh[chamberId].push_back(
simHit);
134 cout <<
"[DTSegment4DQuality]**Warning: no 4D Segments with label: " <<
segment4DLabel_ <<
" in this event, skipping!" << endl;
140 for (
auto & simHitsInChamber : simHitsPerCh) {
144 if (station == 4 && !(
local_) ) {
continue;
155 int nMuSimHit = muSimHitPerWire.size();
160 cout <<
"=== Chamber " << chamberId <<
" has " << nMuSimHit <<
" SimHits" << endl;
167 if ((
DTWireId(inAndOutSimHit.first->detUnitId())).superlayer() == (
DTWireId(inAndOutSimHit.second->detUnitId())).superLayer()) {
continue;
172 chamberId,&(*dtGeom));
174 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
175 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
184 float xSimSeg = simSegmLocalPos.
x();
185 float ySimSeg = simSegmLocalPos.
y();
187 float etaSimSeg = simSegmGlobalPos.
eta();
188 float phiSimSeg = simSegmGlobalPos.
phi();
190 double count_seg = 0;
193 cout <<
" Simulated segment: local direction " << simSegmLocalDir << endl
194 <<
" local position " << simSegmLocalPos << endl
195 <<
" alpha " << alphaSimSeg << endl
196 <<
" beta " << betaSimSeg << endl;
201 bool recHitFound =
false;
203 int nsegm =
distance(range.first, range.second);
205 cout <<
" Chamber: " << chamberId <<
" has " << nsegm
206 <<
" 4D segments" << endl;
216 double deltaAlpha = 99999;
217 double deltaBeta = 99999;
221 segment4D!= range.second;
225 if (station!= 4 && (*segment4D).dimension() != 4) {
229 LocalVector recSegDirection = (*segment4D).localDirection();
230 LocalPoint recSegPosition = (*segment4D).localPosition();
233 float recSegAlpha = ab.first;
234 float recSegBeta = ab.second;
237 cout << &(*segment4D)
238 <<
" RecSegment direction: " << recSegDirection << endl
239 <<
" position : " << (*segment4D).localPosition() << endl
240 <<
" alpha : " << recSegAlpha << endl
241 <<
" beta : " << recSegBeta << endl
242 <<
" nhits : " << (*segment4D).phiSegment()->recHits().size() <<
" " << (((*segment4D).zSegment()!=
nullptr)?(*segment4D).zSegment()->recHits().size():0)
247 float dAlphaRecSim = fabs(recSegAlpha - alphaSimSeg);
248 float dBetaRecSim = fabs(recSegBeta - betaSimSeg);
251 if ((fabs(recSegPosition.
x()-simSegmLocalPos.
x())<4)
252 && ((fabs(recSegPosition.
y()-simSegmLocalPos.
y())<4)||(*segment4D).dimension()<4)) {
255 if (fabs(dAlphaRecSim-deltaAlpha) <
epsilon) {
256 if (dBetaRecSim < deltaBeta) {
257 deltaAlpha = dAlphaRecSim;
258 deltaBeta = dBetaRecSim;
259 bestRecHit = &(*segment4D);
262 }
else if (dAlphaRecSim < deltaAlpha) {
263 deltaAlpha = dAlphaRecSim;
264 deltaBeta = dBetaRecSim;
265 bestRecHit = &(*segment4D);
273 cout << endl <<
"Chosen: " << bestRecHit << endl;
283 float alphaBestRHit = ab.first;
284 float betaBestRHit = ab.second;
297 float alphaBestRHitRZ = 0;
298 float alphaSimSegRZ = betaSimSeg;
314 simSegLocalPosRZTmp + simSegLocalDirRZ*(-simSegLocalPosRZTmp.
z()/(
cos(simSegLocalDirRZ.
theta())));
319 "RZ SL: recPos " << bestRecHitLocalPosRZ <<
320 "recDir " << bestRecHitLocalDirRZ <<
321 "recAlpha " << alphaBestRHitRZ << endl <<
322 "RZ SL: simPos " << simSegLocalPosRZ <<
323 "simDir " << simSegLocalDirRZ <<
324 "simAlpha " << alphaSimSegRZ << endl ;
332 float t0theta = -999;
337 t0phi = phiSeg->
t0();
338 nHitPhi = phiSeg->
recHits().size();
342 t0theta = zedRecSeg->
t0();
343 nHitTheta = zedRecSeg->
recHits().size();
349 if (mirrorMinusWheels && wheel<0) {
361 }
else if (
abs(wheel) == 1) {
363 }
else if (
abs(wheel) == 2) {
371 histo->
fill(alphaSimSeg,
376 bestRecHitLocalPos.
x(),
378 bestRecHitLocalPos.
y(),
381 bestRecHitLocalPosRZ.
x(),
382 simSegLocalPosRZ.
x(),
387 sqrt(bestRecHitLocalPosErr.
xx()),
388 sqrt(bestRecHitLocalPosErr.
yy()),
389 sigmaAlphaBestRhitRZ,
390 sqrt(bestRecHitLocalPosErrRZ.
xx()),
391 nHitPhi, nHitTheta, t0phi, t0theta);
398 bestRecHitLocalPos.
x(),
400 bestRecHitLocalPos.
y(),
403 bestRecHitLocalPosRZ.
x(),
404 simSegLocalPosRZ.
x(),
409 sqrt(bestRecHitLocalPosErr.
xx()),
410 sqrt(bestRecHitLocalPosErr.
yy()),
411 sigmaAlphaBestRhitRZ,
412 sqrt(bestRecHitLocalPosErrRZ.
xx()),
413 nHitPhi, nHitTheta, t0phi, t0theta);
420 bestRecHitLocalPos.
x(),
422 bestRecHitLocalPos.
y(),
425 bestRecHitLocalPosRZ.
x(),
426 simSegLocalPosRZ.
x(),
431 sqrt(bestRecHitLocalPosErr.
xx()),
432 sqrt(bestRecHitLocalPosErr.
yy()),
433 sigmaAlphaBestRhitRZ,
434 sqrt(bestRecHitLocalPosErrRZ.
xx()),
435 nHitPhi, nHitTheta, t0phi, t0theta);
448 }
else if (
abs(wheel) == 1) {
450 }
else if (
abs(wheel) == 2) {
453 heff->
fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
454 histograms.hEff_All->fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
456 histograms.hEffWS[
abs(wheel)][station-1]->fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound, count_seg);
LocalError localPositionError() const override
local position error in SL frame
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.
static double sigmaAngle(double Angle, double sigma2TanAngle)
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.
Geom::Phi< T > phi() const
def setup(process, global_tag, zero_tesla=False)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
edm::InputTag segment4DLabel_
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
static std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
Geom::Theta< T > theta() const
static std::pair< const PSimHit *, const PSimHit * > findMuSimSegment(const std::map< DTWireId, const PSimHit * > &mapWireAndMuSimHit)
Find Innermost and outermost SimHit from Mu in a SL (they identify a simulated segment) ...
void fill(float etaSimSegm, float phiSimSegm, float xSimSegm, float ySimSegm, float alphaSimSegm, float betaSimSegm, bool fillRecHit, int nSeg)
Cos< T >::type cos(const T &t)
LocalError localPositionError() const override
Local position error in Chamber frame.
A set of histograms for efficiency 4D RecHits (producer)
Abs< T >::type abs(const T &t)
LocalError localDirectionError() const override
Local direction error in the Chamber frame.
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
static std::pair< LocalVector, LocalPoint > findMuSimSegmentDirAndPos(const std::pair< const PSimHit *, const PSimHit * > &inAndOutSimHit, const DetId detId, const DTGeometry *muonGeom)
Find direction and position of a segment (in local RF) from outer and inner mu SimHit in the RF of ob...
LocalPoint localPosition() const override
local position in SL frame
void fill(float simDirectionAlpha, float recDirectionAlpha, float simDirectionBeta, float recDirectionBeta, float simX, float recX, float simY, float recY, float simEta, float simPhi, float recYRZ, float simYRZ, float recBetaRZ, float simBetaRZ, float sigmaAlpha, float sigmaBeta, float sigmaX, float sigmaY, float sigmaBetaRZ, float sigmaYRZ, int nHitsPhi, int nHitsTheta, float t0Phi, float t0Theta)
LocalVector localDirection() const override
the local direction in SL frame
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
int station() const
Return the station number.
LocalError localDirectionError() const override
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
int wheel() const
Return the wheel number.
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.