Perform the real analysis.
89 event.getByLabel(
simHitLabel,
"MuonDTHits", simHits);
92 map<DTChamberId, PSimHitContainer > simHitsPerCh;
93 for(PSimHitContainer::const_iterator simHit = simHits->begin();
94 simHit != simHits->end(); simHit++){
96 DTChamberId chamberId = (((
DTWireId(simHit->detUnitId())).layerId()).superlayerId()).chamberId();
98 simHitsPerCh[chamberId].push_back(*simHit);
107 for (chamberId = segment4Ds->id_begin();
108 chamberId != segment4Ds->id_end();
118 int nMuSimHit = muSimHitPerWire.size();
119 if(nMuSimHit == 0 || nMuSimHit == 1) {
120 if(
debug && nMuSimHit == 1)
121 cout <<
"[DTSegment2DSLPhiQuality] Only " << nMuSimHit <<
" mu SimHit in this chamber, skipping!" << endl;
125 cout <<
"=== Chamber " << (*chamberId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
132 (*chamberId),&(*dtGeom));
134 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
135 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
136 const DTChamber* chamber = dtGeom->chamber(*chamberId);
141 float posSimSeg = simSegmLocalPos.
x();
143 float etaSimSeg = simSegmGlobalPos.
eta();
144 float phiSimSeg = simSegmGlobalPos.
phi();
147 cout<<
" Simulated segment: local direction "<<simSegmLocalDir<<endl
148 <<
" local position "<<simSegmLocalPos<<endl
149 <<
" angle "<<angleSimSeg<<endl;
153 bool recHitFound =
false;
155 int nsegm = distance(range.first, range.second);
157 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
158 <<
" 4D segments" << endl;
167 bool bestRecHitFound =
false;
168 double deltaAlpha = 99999;
172 segment4D!=range.second;
175 if((*segment4D).dimension() != 4) {
176 if(
debug)
cout <<
"[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
182 if((*phiSegment2D).dimension() != 2) {
183 if(
debug)
cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
188 LocalVector recSegDirection = (*phiSegment2D).localDirection();
192 cout <<
" RecSegment direction: " << recSegDirection << endl
193 <<
" position : " << (*phiSegment2D).localPosition() << endl
194 <<
" alpha : " << recSegAlpha << endl;
196 if(fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
197 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
198 bestRecHit = &(*phiSegment2D);
199 bestRecHitFound =
true;
203 if(bestRecHitFound) {
213 fabs(bestRecHitLocalPos.
x() - posSimSeg) < 5*
sigmaResPos) {
221 bestRecHitLocalPos.
x(),
224 sqrt(bestRecHitLocalPosErr.
xx()),
225 sqrt(bestRecHitLocalDirErr.
xx())
virtual LocalError localPositionError() const
local position error in SL frame
std::pair< const_iterator, const_iterator > range
iterator range
HEff2DHit * h2DHitEff_SuperPhi
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
virtual LocalError localDirectionError() const
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
static std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
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) ...
C::const_iterator const_iterator
constant access iterator type
void Fill(float angleSimSegment, float angleRecSegment, float posSimSegment, float posRecSegment, float etaSimSegment, float phiSimSegment, float sigmaPos, float sigmaAngle)
HRes2DHit * h2DHitSuperPhi
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
Find the angles from a segment direction:
virtual LocalPoint localPosition() const
local position in SL frame
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...
void Fill(float etaSimSegm, float phiSimSegm, float posSimSegm, float angleSimSegm, bool fillRecHit)
virtual LocalVector localDirection() const
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
std::string segment4DLabel