23 map<DTWireId, PSimHitContainer >
25 map<DTWireId, PSimHitContainer > hitWireMapResult;
27 for(PSimHitContainer::const_iterator simhit = simhits.begin();
28 simhit != simhits.end();
30 hitWireMapResult[
DTWireId((*simhit).detUnitId())].push_back(*simhit);
33 return hitWireMapResult;
37 map<DTWireId, const PSimHit*>
40 map<DTWireId, const PSimHit*> ret;
42 for(map<DTWireId, PSimHitContainer>::const_iterator wireAndSimHit = simHitWireMap.begin();
43 wireAndSimHit != simHitWireMap.end();
47 if(muHit !=
nullptr) {
48 ret[(*wireAndSimHit).first]=(muHit);
59 vector<const PSimHit*> muHits;
62 for (PSimHitContainer::const_iterator
hit=hits.begin();
63 hit != hits.end();
hit++) {
64 if (
abs((*hit).particleType())==13) muHits.push_back(&(*
hit));
69 else if (muHits.size()>1)
71 cout <<
"[DTHitQualityUtils]***WARNING: # muSimHits in a wire = " << muHits.size() << endl;
73 return (muHits.front());
78 pair<const PSimHit*, const PSimHit*>
85 const PSimHit *inSimHit =
nullptr;
86 const PSimHit *outSimHit =
nullptr;
88 for(map<DTWireId, const PSimHit*>::const_iterator wireAndMuSimHit = mapWireAndMuSimHit.begin();
89 wireAndMuSimHit != mapWireAndMuSimHit.end();
92 const DTWireId wireId = (*wireAndMuSimHit).first;
93 const PSimHit *theMuHit = (*wireAndMuSimHit).second;
95 int sl = ((wireId.
layerId()).superlayerId()).superLayer();
96 int layer = (wireId.
layerId()).layer();
99 if(layer > outLayer) {
101 outSimHit = theMuHit;
107 outSimHit = theMuHit;
110 if(layer < inLayer) {
122 if(inSimHit !=
nullptr) {
124 cout <<
"Innermost SimHit on SL: " << inSL <<
" layer: " << inLayer << endl;
126 cout <<
"[DTHitQualityUtils]***Error: No Innermost SimHit found!!!" << endl;
130 if(outSimHit !=
nullptr) {
132 cout <<
"Outermost SimHit on SL: " << outSL <<
" layer: " << outLayer << endl;
134 cout <<
"[DTHitQualityUtils]***Error: No Outermost SimHit found!!!" << endl;
143 return make_pair(inSimHit, outSimHit);
150 pair<LocalVector, LocalPoint>
155 const PSimHit* innermostMuSimHit = inAndOutSimHit.first;
156 const PSimHit* outermostMuSimHit = inAndOutSimHit.second;
164 simHitDirection = -simHitDirection.
unit();
169 outLocalPos + simHitDirection*(-outLocalPos.
z()/(simHitDirection.
mag()*
cos(simHitDirection.
theta())));
171 return make_pair(simHitDirection, simSegLocalPosition);
178 return make_pair(atan(direction.
x()/direction.
z()), atan(direction.
y()/direction.
z()));
184 double XdivZ =
tan(Angle);
185 double sigma2Angle = 1/(1+XdivZ*XdivZ);
186 sigma2Angle *= sigma2Angle*sigma2TanAngle;
std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
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.
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
std::atomic< bool > debug
Geom::Theta< T > theta() const
std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
Local3DPoint localPosition() const
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
const PSimHit * findMuSimHit(const edm::PSimHitContainer &hits)
Select the SimHit from a muon in a vector of SimHits.
Vector3DBase unit() const
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...
DTLayerId layerId() const
Return the corresponding LayerId.
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) ...
const GeomDet * idToDet(DetId) const override
std::vector< PSimHit > PSimHitContainer
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
double sigmaAngle(double Angle, double sigma2TanAngle)
unsigned int detUnitId() const