24 map<DTWireId, PSimHitContainer> hitWireMapResult;
26 for (PSimHitContainer::const_iterator simhit = simhits.begin(); simhit != simhits.end(); simhit++) {
27 hitWireMapResult[
DTWireId((*simhit).detUnitId())].push_back(*simhit);
30 return hitWireMapResult;
35 const map<DTWireId, PSimHitContainer> &simHitWireMap) {
36 map<DTWireId, const PSimHit *> ret;
38 for (map<DTWireId, PSimHitContainer>::const_iterator wireAndSimHit = simHitWireMap.begin();
39 wireAndSimHit != simHitWireMap.end();
42 if (muHit !=
nullptr) {
43 ret[(*wireAndSimHit).first] = (muHit);
53 vector<const PSimHit *> muHits;
56 for (PSimHitContainer::const_iterator
hit = hits.begin();
hit != hits.end();
hit++) {
57 if (
abs((*hit).particleType()) == 13)
58 muHits.push_back(&(*
hit));
63 else if (muHits.size() > 1)
65 cout <<
"[DTHitQualityUtils]***WARNING: # muSimHits in a wire = " << muHits.size() << endl;
67 return (muHits.front());
73 const map<DTWireId, const PSimHit *> &mapWireAndMuSimHit) {
78 const PSimHit *inSimHit =
nullptr;
79 const PSimHit *outSimHit =
nullptr;
81 for (map<DTWireId, const PSimHit *>::const_iterator wireAndMuSimHit = mapWireAndMuSimHit.begin();
82 wireAndMuSimHit != mapWireAndMuSimHit.end();
84 const DTWireId wireId = (*wireAndMuSimHit).first;
85 const PSimHit *theMuHit = (*wireAndMuSimHit).second;
87 int sl = ((wireId.
layerId()).superlayerId()).superLayer();
88 int layer = (wireId.
layerId()).layer();
91 if (layer > outLayer) {
102 if (layer < inLayer) {
114 if (inSimHit !=
nullptr) {
116 cout <<
"Innermost SimHit on SL: " << inSL <<
" layer: " << inLayer << endl;
118 cout <<
"[DTHitQualityUtils]***Error: No Innermost SimHit found!!!" << endl;
122 if (outSimHit !=
nullptr) {
124 cout <<
"Outermost SimHit on SL: " << outSL <<
" layer: " << outLayer << endl;
126 cout <<
"[DTHitQualityUtils]***Error: No Outermost SimHit found!!!" << endl;
135 return make_pair(inSimHit, outSimHit);
142 const pair<const PSimHit *, const PSimHit *> &inAndOutSimHit,
const DetId detId,
const DTGeometry *muonGeom) {
145 const PSimHit *innermostMuSimHit = inAndOutSimHit.first;
146 const PSimHit *outermostMuSimHit = inAndOutSimHit.second;
154 simHitDirection = -simHitDirection.
unit();
159 outLocalPos + simHitDirection * (-outLocalPos.
z() / (simHitDirection.
mag() *
cos(simHitDirection.
theta())));
161 return make_pair(simHitDirection, simSegLocalPosition);
169 return make_pair(atan(direction.
x() / direction.
z()), atan(direction.
y() / direction.
z()));
175 double XdivZ =
tan(Angle);
176 double sigma2Angle = 1 / (1 + XdivZ * XdivZ);
177 sigma2Angle *= sigma2Angle * sigma2TanAngle;
std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
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
Local3DPoint localPosition() const
std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
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.
std::pair< const PSimHit *, const PSimHit * > findMuSimSegment(const std::map< DTWireId, const PSimHit * > &mapWireAndMuSimHit)
Vector3DBase unit() const
std::pair< LocalVector, LocalPoint > findMuSimSegmentDirAndPos(const std::pair< const PSimHit *, const PSimHit * > &inAndOutSimHit, const DetId detId, const DTGeometry *muonGeom)
DTLayerId layerId() const
Return the corresponding LayerId.
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