CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
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 object Det. More...
 
static std::pair< double, double > findSegmentAlphaAndBeta (const LocalVector &direction)
 Find the angles from a segment direction: More...
 
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::PSimHitContainer
mapSimHitsPerWire (const edm::PSimHitContainer &simhits)
 

Static Public Attributes

static bool debug
 

Detailed Description

Provide basic functionalities useful for MuScleFit

Date:
2012/12/20 16:09:29
Revision:
1.11
Author
S. Bolognesi - INFN Torino / T. Dorigo - INFN Padova

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

Date:
2007/10/25 12:00:46
Revision:
1.1
Author
S. Bolognesi and G. Cerminara - INFN Torino

Definition at line 25 of file DTHitQualityUtils.h.

Constructor & Destructor Documentation

DTHitQualityUtils::DTHitQualityUtils ( )

Constructor.

Definition at line 25 of file DTHitQualityUtils.cc.

25  {
26  //DTHitQualityUtils::setDebug(debug);
27 }
DTHitQualityUtils::~DTHitQualityUtils ( )
virtual

Destructor.

Definition at line 30 of file DTHitQualityUtils.cc.

30  {
31 }

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 69 of file DTHitQualityUtils.cc.

References abs, gather_cfg::cout, and debug.

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

69  {
70  //PSimHitContainer muHits;
71  vector<const PSimHit*> muHits;
72 
73  // Loop over simhits
74  for (PSimHitContainer::const_iterator hit=hits.begin();
75  hit != hits.end(); hit++) {
76  if (abs((*hit).particleType())==13) muHits.push_back(&(*hit));
77  }
78 
79  if (muHits.size()==0)
80  return 0; //FIXME: Throw of exception???
81  else if (muHits.size()>1)
82  if(debug)
83  cout << "[DTHitQualityUtils]***WARNING: # muSimHits in a wire = " << muHits.size() << endl;
84 
85  return (muHits.front());
86 }
#define abs(x)
Definition: mlp_lapack.h:159
tuple cout
Definition: gather_cfg.py:121
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 91 of file DTHitQualityUtils.cc.

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

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

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

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

Find the angles from a segment direction:

Definition at line 191 of file DTHitQualityUtils.cc.

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

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

191  {
192  //return make_pair(atan(direction.x()/direction.z()), atan(direction.y()/direction.z()));
193  return make_pair((direction.x()/direction.z()), (direction.y()/direction.z()));
194 }
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 50 of file DTHitQualityUtils.cc.

References run_regression::ret.

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

50  {
51 
52  map<DTWireId, const PSimHit*> ret;
53 
54  for(map<DTWireId, PSimHitContainer>::const_iterator wireAndSimHit = simHitWireMap.begin();
55  wireAndSimHit != simHitWireMap.end();
56  wireAndSimHit++) {
57 
58  const PSimHit* muHit = findMuSimHit((*wireAndSimHit).second);
59  if(muHit != 0) {
60  ret[(*wireAndSimHit).first]=(muHit);
61  }
62  }
63  return ret;
64 }
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 36 of file DTHitQualityUtils.cc.

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

36  {
37  map<DTWireId, PSimHitContainer > hitWireMapResult;
38 
39  for(PSimHitContainer::const_iterator simhit = simhits.begin();
40  simhit != simhits.end();
41  simhit++) {
42  hitWireMapResult[DTWireId((*simhit).detUnitId())].push_back(*simhit);
43  }
44 
45  return hitWireMapResult;
46 }

Member Data Documentation

bool DTHitQualityUtils::debug
static