Perform the real analysis.
140 map<DTChamberId, PSimHitContainer > simHitsPerCh;
141 for(PSimHitContainer::const_iterator simHit = simHits->begin();
142 simHit != simHits->end(); simHit++){
144 DTChamberId chamberId = (((
DTWireId(simHit->detUnitId())).layerId()).superlayerId()).chamberId();
146 simHitsPerCh[chamberId].push_back(*simHit);
155 <<
" in this event, skipping!" << endl;
161 for (chamberId = segment4Ds->id_begin();
162 chamberId != segment4Ds->id_end();
165 if((*chamberId).station() == 4)
175 int nMuSimHit = muSimHitPerWire.size();
176 if(nMuSimHit == 0 || nMuSimHit == 1) {
177 if(
debug && nMuSimHit == 1)
178 cout <<
"[DTSegment4DQuality] Only " << nMuSimHit <<
" mu SimHit in this chamber, skipping!" << endl;
182 cout <<
"=== Chamber " << (*chamberId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
189 (*chamberId),&(*dtGeom));
191 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
192 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
193 const DTChamber* chamber = dtGeom->chamber(*chamberId);
201 float xSimSeg = simSegmLocalPos.
x();
202 float ySimSeg = simSegmLocalPos.
y();
204 float etaSimSeg = simSegmGlobalPos.
eta();
205 float phiSimSeg = simSegmGlobalPos.
phi();
208 cout<<
" Simulated segment: local direction "<<simSegmLocalDir<<endl
209 <<
" local position "<<simSegmLocalPos<<endl
210 <<
" alpha "<<alphaSimSeg<<endl
211 <<
" beta "<<betaSimSeg<<endl;
215 bool recHitFound =
false;
217 int nsegm = distance(range.first, range.second);
219 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
220 <<
" 4D segments" << endl;
229 bool bestRecHitFound =
false;
230 double deltaAlpha = 99999;
234 segment4D!=range.second;
237 if((*segment4D).dimension() != 4) {
238 if(
debug)
cout <<
"[DTSegment4DQuality]***Error: This is not 4D segment!!!" << endl;
242 LocalVector recSegDirection = (*segment4D).localDirection();
247 cout <<
" RecSegment direction: " << recSegDirection << endl
248 <<
" position : " << (*segment4D).localPosition() << endl
249 <<
" alpha : " << recSegAlpha << endl
252 if(fabs(recSegAlpha - alphaSimSeg) < deltaAlpha) {
253 deltaAlpha = fabs(recSegAlpha - alphaSimSeg);
254 bestRecHit = &(*segment4D);
255 bestRecHitFound =
true;
259 if(bestRecHitFound) {
289 simSegLocalPosRZTmp + simSegLocalDirRZ*(-simSegLocalPosRZTmp.
z()/(
cos(simSegLocalDirRZ.
theta())));
293 "RZ SL: recPos " << bestRecHitLocalPosRZ <<
294 "recDir " << bestRecHitLocalDirRZ <<
295 "recAlpha " << alphaBestRHitRZ << endl <<
296 "RZ SL: simPos " << simSegLocalPosRZ <<
297 "simDir " << simSegLocalDirRZ <<
298 "simAlpha " << alphaSimSegRZ << endl ;
304 fabs(bestRecHitLocalPos.
x() - xSimSeg) < 5*
sigmaResX &&
305 fabs(bestRecHitLocalPos.
y() - ySimSeg) < 5*
sigmaResY) {
312 if((*chamberId).wheel() == 0)
314 else if(
abs((*chamberId).wheel()) == 1)
316 else if(
abs((*chamberId).wheel()) == 2)
319 histo->
Fill(alphaSimSeg,
324 bestRecHitLocalPos.
x(),
326 bestRecHitLocalPos.
y(),
329 bestRecHitLocalPosRZ.
x(),
330 simSegLocalPosRZ.
x(),
333 sqrt(bestRecHitLocalDirErr.
xx()),
334 sqrt(bestRecHitLocalDirErr.
yy()),
335 sqrt(bestRecHitLocalPosErr.
xx()),
336 sqrt(bestRecHitLocalPosErr.
yy()),
337 sqrt(bestRecHitLocalDirErrRZ.
xx()),
338 sqrt(bestRecHitLocalPosErrRZ.
xx())
346 bestRecHitLocalPos.
x(),
348 bestRecHitLocalPos.
y(),
351 bestRecHitLocalPosRZ.
x(),
352 simSegLocalPosRZ.
x(),
355 sqrt(bestRecHitLocalDirErr.
xx()),
356 sqrt(bestRecHitLocalDirErr.
yy()),
357 sqrt(bestRecHitLocalPosErr.
xx()),
358 sqrt(bestRecHitLocalPosErr.
yy()),
359 sqrt(bestRecHitLocalDirErrRZ.
xx()),
360 sqrt(bestRecHitLocalPosErrRZ.
xx())
369 if((*chamberId).wheel() == 0)
371 else if(
abs((*chamberId).wheel()) == 1)
373 else if(
abs((*chamberId).wheel()) == 2)
375 heff->
Fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, recHitFound);
376 hEff_All->
Fill(etaSimSeg, phiSimSeg, xSimSeg, ySimSeg, alphaSimSeg, betaSimSeg, 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
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
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 ;.
Geom::Theta< T > theta() const
virtual LocalError localPositionError() const
Local position error in Chamber frame.
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) ...
virtual LocalVector localDirection() const
Local direction in Chamber frame.
edm::InputTag segment4DLabel
C::const_iterator const_iterator
constant access iterator type
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)
Cos< T >::type cos(const T &t)
A set of histograms for efficiency 4D RecHits.
virtual LocalPoint localPosition() const
Local position in Chamber frame.
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
Find the angles from a segment direction:
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
virtual LocalPoint localPosition() const
local position in SL frame
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...
edm::InputTag simHitLabel
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)
void Fill(float etaSimSegm, float phiSimSegm, float xSimSegm, float ySimSegm, float alphaSimSegm, float betaSimSegm, bool fillRecHit)
virtual LocalError localDirectionError() const
Local direction error in the Chamber frame.