CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
DeDxTools Namespace Reference

Classes

struct  RawHits
 

Functions

double genericAverage (const reco::DeDxHitCollection &, float expo=1.)
 
void trajectoryRawHits (const edm::Ref< std::vector< Trajectory > > &trajectory, vector< RawHits > &hits, bool usePixel, bool useStrip)
 
void trajectoryRawHits (const edm::Ref< std::vector< Trajectory > > &trajectory, std::vector< RawHits > &hits, bool usePixel, bool useStrip)
 

Function Documentation

double DeDxTools::genericAverage ( const reco::DeDxHitCollection hits,
float  expo = 1. 
)

Definition at line 129 of file DeDxTools.cc.

References DeDxDiscriminatorTools::charge(), i, n, funct::pow(), and query::result.

Referenced by GenericAverageDeDxEstimator::dedx().

130 {
131  double result=0;
132  size_t n = hits.size();
133  for(size_t i = 0; i< n; i ++)
134  {
135  result+=pow(hits[i].charge(),expo);
136  }
137  return (n>0)?pow(result/n,1./expo):0.;
138 }
int i
Definition: DBlmapReader.cc:9
double charge(const std::vector< uint8_t > &Ampls)
tuple result
Definition: query.py:137
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void DeDxTools::trajectoryRawHits ( const edm::Ref< std::vector< Trajectory > > &  trajectory,
vector< RawHits > &  hits,
bool  usePixel,
bool  useStrip 
)

Definition at line 17 of file DeDxTools.cc.

References DeDxTools::RawHits::angleCosine, DeDxTools::RawHits::charge, SiStripRecHit2D::cluster(), DeDxTools::RawHits::detId, TrackingRecHit::geographicalId(), i, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), DeDxTools::RawHits::NSaturating, DeDxTools::RawHits::trajectoryMeasurement, and PV3DBase< T, PVType, FrameType >::z().

18  {
19 
20  // vector<RawHits> hits;
21 
22  const vector<TrajectoryMeasurement> & measurements = trajectory->measurements();
23  for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
24 
25  //FIXME: check that "updated" State is the best one (wrt state in the middle)
26  TrajectoryStateOnSurface trajState=it->updatedState();
27  if( !trajState.isValid()) continue;
28 
29  const TrackingRecHit * recHit=(*it->recHit()).hit();
30 
31  LocalVector trackDirection = trajState.localDirection();
32  double cosine = trackDirection.z()/trackDirection.mag();
33 
34  if(const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit)){
35  if(!useStrip) continue;
36 
37  RawHits mono,stereo;
38  mono.trajectoryMeasurement = &(*it);
39  stereo.trajectoryMeasurement = &(*it);
40  mono.angleCosine = cosine;
41  stereo.angleCosine = cosine;
42  const std::vector<uint8_t> & amplitudes = matchedHit->monoHit()->cluster()->amplitudes();
43  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
44  mono.NSaturating =0;
45  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
46 
47  const std::vector<uint8_t> & amplitudesSt = matchedHit->stereoHit()->cluster()->amplitudes();
48  stereo.charge = accumulate(amplitudesSt.begin(), amplitudesSt.end(), 0);
49  stereo.NSaturating =0;
50  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)stereo.NSaturating++;}
51 
52  mono.detId= matchedHit->monoHit()->geographicalId();
53  stereo.detId= matchedHit->stereoHit()->geographicalId();
54 
55  hits.push_back(mono);
56  hits.push_back(stereo);
57 
58  }else if(const ProjectedSiStripRecHit2D* projectedHit=dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit)) {
59  if(!useStrip) continue;
60 
61  const SiStripRecHit2D* singleHit=&(projectedHit->originalHit());
62  RawHits mono;
63 
64  mono.trajectoryMeasurement = &(*it);
65 
66  mono.angleCosine = cosine;
67  const std::vector<uint8_t> & amplitudes = singleHit->cluster()->amplitudes();
68  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
69  mono.NSaturating =0;
70  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
71 
72  mono.detId= singleHit->geographicalId();
73  hits.push_back(mono);
74 
75  }else if(const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
76  if(!useStrip) continue;
77 
78  RawHits mono;
79 
80  mono.trajectoryMeasurement = &(*it);
81 
82  mono.angleCosine = cosine;
83  const std::vector<uint8_t> & amplitudes = singleHit->cluster()->amplitudes();
84  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
85  mono.NSaturating =0;
86  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
87 
88  mono.detId= singleHit->geographicalId();
89  hits.push_back(mono);
90 
91  }else if(const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
92  if(!useStrip) continue;
93 
94  RawHits mono;
95 
96  mono.trajectoryMeasurement = &(*it);
97 
98  mono.angleCosine = cosine;
99  const std::vector<uint8_t> & amplitudes = single1DHit->cluster()->amplitudes();
100  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
101  mono.NSaturating =0;
102  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
103 
104  mono.detId= single1DHit->geographicalId();
105  hits.push_back(mono);
106 
107 
108  }else if(const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
109  if(!usePixel) continue;
110 
111  RawHits pixel;
112 
113  pixel.trajectoryMeasurement = &(*it);
114 
115  pixel.angleCosine = cosine;
116  pixel.charge = pixelHit->cluster()->charge();
117  pixel.NSaturating=-1;
118  pixel.detId= pixelHit->geographicalId();
119  hits.push_back(pixel);
120  }
121 
122  }
123  // return hits;
124  }
int i
Definition: DBlmapReader.cc:9
LocalVector localDirection() const
T mag() const
Definition: PV3DBase.h:61
T z() const
Definition: PV3DBase.h:58
ClusterRef const & cluster() const
DetId geographicalId() const
Our base class.
Definition: SiPixelRecHit.h:27
void DeDxTools::trajectoryRawHits ( const edm::Ref< std::vector< Trajectory > > &  trajectory,
std::vector< RawHits > &  hits,
bool  usePixel,
bool  useStrip 
)

Definition at line 17 of file DeDxTools.cc.

References DeDxTools::RawHits::angleCosine, DeDxTools::RawHits::charge, SiStripRecHit2D::cluster(), DeDxTools::RawHits::detId, TrackingRecHit::geographicalId(), i, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), DeDxTools::RawHits::NSaturating, DeDxTools::RawHits::trajectoryMeasurement, and PV3DBase< T, PVType, FrameType >::z().

18  {
19 
20  // vector<RawHits> hits;
21 
22  const vector<TrajectoryMeasurement> & measurements = trajectory->measurements();
23  for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
24 
25  //FIXME: check that "updated" State is the best one (wrt state in the middle)
26  TrajectoryStateOnSurface trajState=it->updatedState();
27  if( !trajState.isValid()) continue;
28 
29  const TrackingRecHit * recHit=(*it->recHit()).hit();
30 
31  LocalVector trackDirection = trajState.localDirection();
32  double cosine = trackDirection.z()/trackDirection.mag();
33 
34  if(const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit)){
35  if(!useStrip) continue;
36 
37  RawHits mono,stereo;
38  mono.trajectoryMeasurement = &(*it);
39  stereo.trajectoryMeasurement = &(*it);
40  mono.angleCosine = cosine;
41  stereo.angleCosine = cosine;
42  const std::vector<uint8_t> & amplitudes = matchedHit->monoHit()->cluster()->amplitudes();
43  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
44  mono.NSaturating =0;
45  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
46 
47  const std::vector<uint8_t> & amplitudesSt = matchedHit->stereoHit()->cluster()->amplitudes();
48  stereo.charge = accumulate(amplitudesSt.begin(), amplitudesSt.end(), 0);
49  stereo.NSaturating =0;
50  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)stereo.NSaturating++;}
51 
52  mono.detId= matchedHit->monoHit()->geographicalId();
53  stereo.detId= matchedHit->stereoHit()->geographicalId();
54 
55  hits.push_back(mono);
56  hits.push_back(stereo);
57 
58  }else if(const ProjectedSiStripRecHit2D* projectedHit=dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit)) {
59  if(!useStrip) continue;
60 
61  const SiStripRecHit2D* singleHit=&(projectedHit->originalHit());
62  RawHits mono;
63 
64  mono.trajectoryMeasurement = &(*it);
65 
66  mono.angleCosine = cosine;
67  const std::vector<uint8_t> & amplitudes = singleHit->cluster()->amplitudes();
68  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
69  mono.NSaturating =0;
70  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
71 
72  mono.detId= singleHit->geographicalId();
73  hits.push_back(mono);
74 
75  }else if(const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
76  if(!useStrip) continue;
77 
78  RawHits mono;
79 
80  mono.trajectoryMeasurement = &(*it);
81 
82  mono.angleCosine = cosine;
83  const std::vector<uint8_t> & amplitudes = singleHit->cluster()->amplitudes();
84  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
85  mono.NSaturating =0;
86  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
87 
88  mono.detId= singleHit->geographicalId();
89  hits.push_back(mono);
90 
91  }else if(const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
92  if(!useStrip) continue;
93 
94  RawHits mono;
95 
96  mono.trajectoryMeasurement = &(*it);
97 
98  mono.angleCosine = cosine;
99  const std::vector<uint8_t> & amplitudes = single1DHit->cluster()->amplitudes();
100  mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
101  mono.NSaturating =0;
102  for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
103 
104  mono.detId= single1DHit->geographicalId();
105  hits.push_back(mono);
106 
107 
108  }else if(const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
109  if(!usePixel) continue;
110 
111  RawHits pixel;
112 
113  pixel.trajectoryMeasurement = &(*it);
114 
115  pixel.angleCosine = cosine;
116  pixel.charge = pixelHit->cluster()->charge();
117  pixel.NSaturating=-1;
118  pixel.detId= pixelHit->geographicalId();
119  hits.push_back(pixel);
120  }
121 
122  }
123  // return hits;
124  }
int i
Definition: DBlmapReader.cc:9
LocalVector localDirection() const
T mag() const
Definition: PV3DBase.h:61
T z() const
Definition: PV3DBase.h:58
ClusterRef const & cluster() const
DetId geographicalId() const
Our base class.
Definition: SiPixelRecHit.h:27