Perform the real analysis.
72 map<DTChamberId, PSimHitContainer > simHitsPerCh;
73 for (
const auto &
simHit : *simHits) {
77 simHitsPerCh[chamberId].push_back(
simHit);
86 cout <<
"[DTSegment2DSLPhiQuality]**Warning: no 4D Segments with label: " <<
segment4DLabel_ 87 <<
" in this event, skipping!" << endl;
93 DTRecSegment4DCollection::id_iterator chamberId;
94 for (chamberId = segment4Ds->id_begin();
95 chamberId != segment4Ds->id_end();
105 int nMuSimHit = muSimHitPerWire.size();
106 if (nMuSimHit == 0 || nMuSimHit == 1) {
107 if (
debug_ && nMuSimHit == 1) {
108 cout <<
"[DTSegment2DSLPhiQuality] Only " << nMuSimHit <<
" mu SimHit in this chamber, skipping!" << endl;
113 cout <<
"=== Chamber " << (*chamberId) <<
" has " << nMuSimHit <<
" SimHits" << endl;
121 (*chamberId),&(*dtGeom));
123 LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
124 LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
130 float posSimSeg = simSegmLocalPos.
x();
132 float etaSimSeg = simSegmGlobalPos.
eta();
133 float phiSimSeg = simSegmGlobalPos.
phi();
136 cout <<
" Simulated segment: local direction " << simSegmLocalDir << endl
137 <<
" local position " << simSegmLocalPos << endl
138 <<
" angle " << angleSimSeg << endl;
143 bool recHitFound =
false;
145 int nsegm =
distance(range.first, range.second);
147 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
148 <<
" 4D segments" << endl;
158 bool bestRecHitFound =
false;
159 double deltaAlpha = 99999;
163 segment4D!= range.second;
166 if ((*segment4D).dimension() != 4) {
167 if (
debug_) {
cout <<
"[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
174 if ((*phiSegment2D).dimension() != 2) {
175 if (
debug_) {
cout <<
"[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
181 LocalVector recSegDirection = (*phiSegment2D).localDirection();
185 cout <<
" RecSegment direction: " << recSegDirection << endl
186 <<
" position : " << (*phiSegment2D).localPosition() << endl
187 <<
" alpha : " << recSegAlpha << endl;
190 if (fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
191 deltaAlpha = fabs(recSegAlpha - angleSimSeg);
192 bestRecHit = &(*phiSegment2D);
193 bestRecHitFound =
true;
197 if (bestRecHitFound) {
215 bestRecHitLocalPos.
x(),
218 sqrt(bestRecHitLocalPosErr.
xx()),
219 sqrt(bestRecHitLocalDirErr.
xx())
226 histograms.h2DHitEff_SuperPhi->fill(etaSimSeg,
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
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.
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)
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) ...
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
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
edm::InputTag segment4DLabel_
LocalVector localDirection() const override
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
LocalError localDirectionError() const override
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.