Perform the real analysis.
76 map<DTChamberId, PSimHitContainer > simHitsPerCh;
77 for (
const auto &
simHit : *simHits) {
81 simHitsPerCh[chamberId].push_back(
simHit);
90 cout <<
"[DTSegment2DSLPhiQuality]**Warning: no 4D Segments with label: " <<
segment4DLabel_ 91 <<
" in this event, skipping!" << endl;
97 DTRecSegment4DCollection::id_iterator chamberId;
98 for (chamberId = segment4Ds->id_begin();
99 chamberId != segment4Ds->id_end();
109 int nMuSimHit = muSimHitPerWire.size();
110 if (nMuSimHit == 0 || nMuSimHit == 1) {
111 if (
debug_ && nMuSimHit == 1) {
112 cout <<
"[DTSegment2DSLPhiQuality] Only " << nMuSimHit <<
" mu SimHit in this chamber, skipping!" << endl;
117 cout <<
"=== Chamber " << (*chamberId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
125 (*chamberId),&(*dtGeom));
127 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
128 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
134 float posSimSeg = simSegmLocalPos.
x();
136 float etaSimSeg = simSegmGlobalPos.
eta();
137 float phiSimSeg = simSegmGlobalPos.
phi();
140 cout <<
" Simulated segment: local direction " << simSegmLocalDir << endl
141 <<
" local position " << simSegmLocalPos << endl
142 <<
" angle " << angleSimSeg << endl;
147 bool recHitFound =
false;
149 int nsegm =
distance(range.first, range.second);
151 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
152 <<
" 4D segments" << endl;
162 bool bestRecHitFound =
false;
163 double deltaAlpha = 99999;
167 segment4D!= range.second;
170 if ((*segment4D).dimension() != 4) {
171 if (
debug_) {
cout <<
"[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
178 if ((*phiSegment2D).dimension() != 2) {
179 if (
debug_) {
cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
185 LocalVector recSegDirection = (*phiSegment2D).localDirection();
189 cout <<
" RecSegment direction: " << recSegDirection << endl
190 <<
" position : " << (*phiSegment2D).localPosition() << endl
191 <<
" alpha : " << recSegAlpha << endl;
194 if (fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
195 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
196 bestRecHit = &(*phiSegment2D);
197 bestRecHitFound =
true;
201 if (bestRecHitFound) {
219 bestRecHitLocalPos.
x(),
222 sqrt(bestRecHitLocalPosErr.
xx()),
223 sqrt(bestRecHitLocalDirErr.
xx())
230 histograms.h2DHitEff_SuperPhi->fill(etaSimSeg,
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
LocalError localPositionError() const override
local position error in SL frame
std::pair< const_iterator, const_iterator > range
iterator range
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
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)
std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
LocalPoint localPosition() const override
local position in SL frame
edm::InputTag segment4DLabel_
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...
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) ...
LocalVector localDirection() const override
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
LocalError localDirectionError() const override
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.