Perform the real analysis.
114 event.getByLabel(
simHitLabel,
"MuonDTHits", simHits);
117 map<DTSuperLayerId, PSimHitContainer > simHitsPerSl;
118 for(PSimHitContainer::const_iterator simHit = simHits->begin();
119 simHit != simHits->end(); simHit++){
123 simHitsPerSl[slId].push_back(*simHit);
132 for (slId = segment2Ds->id_begin();
133 slId != segment2Ds->id_end();
143 int nMuSimHit = muSimHitPerWire.size();
144 if(nMuSimHit == 0 || nMuSimHit == 1) {
145 if(
debug && nMuSimHit == 1)
146 cout <<
"[DTSegment2DQuality] Only " << nMuSimHit <<
" mu SimHit in this SL, skipping!" << endl;
150 cout <<
"=== SL " << (*slId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
155 if(inAndOutSimHit.first ==inAndOutSimHit.second ) {
156 cout <<
"[DTHitQualityUtils]***Warning: outermost and innermost SimHit are the same!" << endl;
164 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
165 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
167 cout<<
" Simulated segment: local direction "<<simSegmLocalDir<<endl
168 <<
" local position "<<simSegmLocalPos<<endl;
169 const DTSuperLayer* superLayer = dtGeom->superLayer(*slId);
174 float posSimSeg = simSegmLocalPos.
x();
176 float etaSimSeg = simSegmGlobalPos.
eta();
177 float phiSimSeg = simSegmGlobalPos.
phi();
182 bool recHitFound =
false;
184 int nsegm = distance(range.first, range.second);
186 cout <<
" Sl: " << *slId <<
" has " << nsegm
187 <<
" 2D segments" << endl;
196 bool bestRecHitFound =
false;
197 double deltaAlpha = 99999;
201 segment2D!=range.second;
204 if((*segment2D).dimension() != 2) {
205 if(
debug)
cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
209 LocalVector recSegDirection = (*segment2D).localDirection();
210 LocalPoint recSegPosition = (*segment2D).localPosition();
214 cout <<
" RecSegment direction: " << recSegDirection << endl
215 <<
" position : " << recSegPosition << endl
216 <<
" alpha : " << recSegAlpha << endl;
218 if(fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
219 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
220 bestRecHit = &(*segment2D);
221 bestRecHitFound =
true;
225 if(bestRecHitFound) {
236 fabs(bestRecHitLocalPos.
x() - posSimSeg) < 5*
sigmaResPos) {
242 if((*slId).superlayer() == 1 || (*slId).superlayer() == 3) {
244 }
else if((*slId).superlayer() == 2) {
248 bestRecHitLocalPos.
x(),
251 sqrt(bestRecHitLocalPosErr.
xx()),
252 sqrt(bestRecHitLocalDirErr.
xx())
254 if(
abs((*slId).wheel()) == 0)
256 else if(
abs((*slId).wheel()) == 1)
258 else if(
abs((*slId).wheel()) == 2)
261 hRes->
Fill(angleSimSeg,
264 bestRecHitLocalPos.
x(),
267 sqrt(bestRecHitLocalPosErr.
xx()),
268 sqrt(bestRecHitLocalDirErr.
xx())
275 if((*slId).superlayer() == 1 || (*slId).superlayer() == 3) {
277 }
else if((*slId).superlayer() == 2) {
278 h2DHitEff_RZ->
Fill(etaSimSeg, phiSimSeg, posSimSeg, angleSimSeg, recHitFound);
279 if(
abs((*slId).wheel()) == 0)
281 else if(
abs((*slId).wheel()) == 1)
283 else if(
abs((*slId).wheel()) == 2)
286 hEff->
Fill(etaSimSeg, phiSimSeg, posSimSeg, angleSimSeg, recHitFound);
virtual LocalError localPositionError() const
local position error in SL frame
std::pair< const_iterator, const_iterator > range
iterator range
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 ;.
std::string segment2DLabel
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)
HEff2DHit * h2DHitEff_RZ_W0
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...
HEff2DHit * h2DHitEff_RZ_W1
HEff2DHit * h2DHitEff_RPhi
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)
HEff2DHit * h2DHitEff_RZ_W2