CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes
DTHitQualityUtils Class Reference

#include <DTHitQualityUtils.h>

Public Member Functions

 DTHitQualityUtils ()
 Constructor. More...
 
virtual ~DTHitQualityUtils ()
 Destructor. More...
 

Static Public Member Functions

static const PSimHitfindMuSimHit (const edm::PSimHitContainer &hits)
 Select the SimHit from a muon in a vector of SimHits. More...
 
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) More...
 
static std::pair< LocalVector, LocalPointfindMuSimSegmentDirAndPos (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 object Det. More...
 
static std::pair< double, double > findSegmentAlphaAndBeta (const LocalVector &direction)
 
static std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire (const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
 Create a map between the Mu SimHits and corresponding MuBarWireId ;. More...
 
static std::map< DTWireId, edm::PSimHitContainermapSimHitsPerWire (const edm::PSimHitContainer &simhits)
 
static double sigmaAngle (double Angle, double sigma2TanAngle)
 

Static Public Attributes

static bool debug
 

Detailed Description

Provide basic functionalities useful for MuScleFit

Author
S. Bolognesi - INFN Torino / T. Dorigo - INFN Padova Revised S. Casasso, E. Migliore - UniTo & INFN Torino

Define some basic tools and utilities for 1D DT Rec Hit and 2D, 4D DT Segment analysis

Author
S. Bolognesi and G. Cerminara - INFN Torino

Definition at line 23 of file DTHitQualityUtils.h.

Constructor & Destructor Documentation

DTHitQualityUtils::DTHitQualityUtils ( )

Constructor.

Definition at line 23 of file DTHitQualityUtils.cc.

23  {
24  //DTHitQualityUtils::setDebug(debug);
25 }
DTHitQualityUtils::~DTHitQualityUtils ( )
virtual

Destructor.

Definition at line 28 of file DTHitQualityUtils.cc.

28  {
29 }

Member Function Documentation

const PSimHit * DTHitQualityUtils::findMuSimHit ( const edm::PSimHitContainer hits)
static

Select the SimHit from a muon in a vector of SimHits.

Definition at line 67 of file DTHitQualityUtils.cc.

References funct::abs(), gather_cfg::cout, and debug.

Referenced by DTRecHitQuality::compute(), GlobalRecHitsAnalyzer::compute(), and GlobalRecHitsProducer::compute().

67  {
68  //PSimHitContainer muHits;
69  vector<const PSimHit*> muHits;
70 
71  // Loop over simhits
72  for (PSimHitContainer::const_iterator hit=hits.begin();
73  hit != hits.end(); hit++) {
74  if (abs((*hit).particleType())==13) muHits.push_back(&(*hit));
75  }
76 
77  if (muHits.empty())
78  return nullptr; //FIXME: Throw of exception???
79  else if (muHits.size()>1)
80  if(debug)
81  cout << "[DTHitQualityUtils]***WARNING: # muSimHits in a wire = " << muHits.size() << endl;
82 
83  return (muHits.front());
84 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
pair< const PSimHit *, const PSimHit * > DTHitQualityUtils::findMuSimSegment ( const std::map< DTWireId, const PSimHit * > &  mapWireAndMuSimHit)
static

Find Innermost and outermost SimHit from Mu in a SL (they identify a simulated segment)

Definition at line 89 of file DTHitQualityUtils.cc.

References gather_cfg::cout, debug, and DTWireId::layerId().

Referenced by DTSegment2DQuality::dqmAnalyze(), DTSegment2DSLPhiQuality::dqmAnalyze(), and DTSegment4DQuality::dqmAnalyze().

89  {
90 
91  int outSL = 0;
92  int inSL = 4;
93  int outLayer = 0;
94  int inLayer = 5;
95  const PSimHit *inSimHit = nullptr;
96  const PSimHit *outSimHit = nullptr;
97 
98  for(map<DTWireId, const PSimHit*>::const_iterator wireAndMuSimHit = mapWireAndMuSimHit.begin();
99  wireAndMuSimHit != mapWireAndMuSimHit.end();
100  wireAndMuSimHit++) {
101 
102  const DTWireId wireId = (*wireAndMuSimHit).first;
103  const PSimHit *theMuHit = (*wireAndMuSimHit).second;
104 
105  int sl = ((wireId.layerId()).superlayerId()).superLayer();
106  int layer = (wireId.layerId()).layer();
107 
108  if(sl == outSL) {
109  if(layer > outLayer) {
110  outLayer = layer;
111  outSimHit = theMuHit;
112  }
113  }
114  if(sl > outSL) {
115  outSL = sl;
116  outLayer = layer;
117  outSimHit = theMuHit;
118  }
119  if(sl == inSL) {
120  if(layer < inLayer) {
121  inLayer = layer;
122  inSimHit = theMuHit;
123  }
124  }
125  if(sl < inSL) {
126  inSL = sl;
127  inLayer = layer;
128  inSimHit = theMuHit;
129  }
130  }
131 
132  if(inSimHit != nullptr) {
133  if(debug)
134  cout << "Innermost SimHit on SL: " << inSL << " layer: " << inLayer << endl;
135  } else {
136  cout << "[DTHitQualityUtils]***Error: No Innermost SimHit found!!!" << endl;
137  abort();
138  }
139 
140  if(outSimHit != nullptr) {
141  if(debug)
142  cout << "Outermost SimHit on SL: " << outSL << " layer: " << outLayer << endl;
143  } else {
144  cout << "[DTHitQualityUtils]***Error: No Outermost SimHit found!!!" << endl;
145  abort();
146  }
147 
148  // //Check that outermost and innermost SimHit are not the same
149  // if(outSimHit == inSimHit) {
150  // cout << "[DTHitQualityUtils]***Warning: outermost and innermost SimHit are the same!" << endl;
151  // abort();
152  // }
153  return make_pair(inSimHit, outSimHit);
154 }
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
pair< LocalVector, LocalPoint > DTHitQualityUtils::findMuSimSegmentDirAndPos ( const std::pair< const PSimHit *, const PSimHit * > &  inAndOutSimHit,
const DetId  detId,
const DTGeometry muonGeom 
)
static

Find direction and position of a segment (in local RF) from outer and inner mu SimHit in the RF of object Det.

Definition at line 161 of file DTHitQualityUtils.cc.

References funct::cos(), PSimHit::detUnitId(), DTGeometry::idToDet(), DTGeometry::layer(), PSimHit::localPosition(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::theta(), GeomDet::toGlobal(), toLocal(), Vector3DBase< T, FrameTag >::unit(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by DTSegment2DQuality::dqmAnalyze(), DTSegment2DSLPhiQuality::dqmAnalyze(), and DTSegment4DQuality::dqmAnalyze().

162  {
163 
164  //FIXME: What should happen if outSimHit = inSimHit???? Now, this case is not considered
165  const PSimHit* innermostMuSimHit = inAndOutSimHit.first;
166  const PSimHit* outermostMuSimHit = inAndOutSimHit.second;
167 
168  //Find simulated segment direction from SimHits position
169  const DTLayer* layerIn = muonGeom->layer((DTWireId(innermostMuSimHit->detUnitId())).layerId());
170  const DTLayer* layerOut = muonGeom->layer((DTWireId(outermostMuSimHit->detUnitId())).layerId());
171  GlobalPoint inGlobalPos = layerIn->toGlobal(innermostMuSimHit->localPosition());
172  GlobalPoint outGlobalPos = layerOut->toGlobal(outermostMuSimHit->localPosition());
173  LocalVector simHitDirection = (muonGeom->idToDet(detId))->toLocal(inGlobalPos - outGlobalPos);
174  simHitDirection = -simHitDirection.unit();
175 
176  //SimHit position extrapolated at z=0 in the Det RF
177  LocalPoint outLocalPos = (muonGeom->idToDet(detId))->toLocal(outGlobalPos);
178  LocalPoint simSegLocalPosition =
179  outLocalPos + simHitDirection*(-outLocalPos.z()/(simHitDirection.mag()*cos(simHitDirection.theta())));
180 
181  return make_pair(simHitDirection, simSegLocalPosition);
182 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
Local3DPoint localPosition() const
Definition: PSimHit.h:44
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Vector3DBase unit() const
Definition: Vector3DBase.h:57
const GeomDet * idToDet(DetId) const override
Definition: DTGeometry.cc:75
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:109
unsigned int detUnitId() const
Definition: PSimHit.h:93
pair< double, double > DTHitQualityUtils::findSegmentAlphaAndBeta ( const LocalVector direction)
static

Find the angles from a segment direction: atan(dx/dz) = "phi" angle in the chamber RF atan(dy/dz) = "theta" angle in the chamber RF (note: this has opposite sign in the SLZ RF!)

Definition at line 187 of file DTHitQualityUtils.cc.

References PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by DTSegment2DQuality::dqmAnalyze(), DTSegment2DSLPhiQuality::dqmAnalyze(), and DTSegment4DQuality::dqmAnalyze().

187  {
188  return make_pair(atan(direction.x()/direction.z()), atan(direction.y()/direction.z()));
189 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
map< DTWireId, const PSimHit * > DTHitQualityUtils::mapMuSimHitsPerWire ( const std::map< DTWireId, edm::PSimHitContainer > &  simHitWireMap)
static

Create a map between the Mu SimHits and corresponding MuBarWireId ;.

Definition at line 48 of file DTHitQualityUtils.cc.

Referenced by DTSegment2DQuality::dqmAnalyze(), DTSegment2DSLPhiQuality::dqmAnalyze(), and DTSegment4DQuality::dqmAnalyze().

48  {
49 
50  map<DTWireId, const PSimHit*> ret;
51 
52  for(map<DTWireId, PSimHitContainer>::const_iterator wireAndSimHit = simHitWireMap.begin();
53  wireAndSimHit != simHitWireMap.end();
54  wireAndSimHit++) {
55 
56  const PSimHit* muHit = findMuSimHit((*wireAndSimHit).second);
57  if(muHit != nullptr) {
58  ret[(*wireAndSimHit).first]=(muHit);
59  }
60  }
61  return ret;
62 }
static const PSimHit * findMuSimHit(const edm::PSimHitContainer &hits)
Select the SimHit from a muon in a vector of SimHits.
map< DTWireId, PSimHitContainer > DTHitQualityUtils::mapSimHitsPerWire ( const edm::PSimHitContainer simhits)
static

Operations Create a map between the SimHits in a chamber and the corrisponding MuBarWireId

Definition at line 34 of file DTHitQualityUtils.cc.

Referenced by DTSegment2DQuality::dqmAnalyze(), DTSegment2DSLPhiQuality::dqmAnalyze(), DTSegment4DQuality::dqmAnalyze(), DTRecHitQuality::dqmAnalyze(), GlobalRecHitsAnalyzer::fillMuon(), and GlobalRecHitsProducer::fillMuon().

34  {
35  map<DTWireId, PSimHitContainer > hitWireMapResult;
36 
37  for(PSimHitContainer::const_iterator simhit = simhits.begin();
38  simhit != simhits.end();
39  simhit++) {
40  hitWireMapResult[DTWireId((*simhit).detUnitId())].push_back(*simhit);
41  }
42 
43  return hitWireMapResult;
44 }
double DTHitQualityUtils::sigmaAngle ( double  Angle,
double  sigma2TanAngle 
)
static

Definition at line 192 of file DTHitQualityUtils.cc.

References funct::tan().

Referenced by DTSegment4DQuality::dqmAnalyze().

192  {
193 
194  double XdivZ = tan(Angle);
195  double sigma2Angle = 1/(1+XdivZ*XdivZ);
196  sigma2Angle *= sigma2Angle*sigma2TanAngle;
197 
198  return sigma2Angle;
199 }
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Definition: Angle.h:17

Member Data Documentation

bool DTHitQualityUtils::debug
static