Go to the documentation of this file.00001 #include "RecoTracker/DeDx/interface/DeDxTools.h"
00002 #include <vector>
00003 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00004 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00005 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
00006 #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h"
00007 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
00008 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00009 #include "DataFormats/TrackReco/interface/DeDxHit.h"
00010
00011 #include <numeric>
00012 namespace DeDxTools {
00013 using namespace std;
00014 using namespace reco;
00015
00016
00017 void trajectoryRawHits(const edm::Ref<std::vector<Trajectory> >& trajectory, vector<RawHits>& hits, bool usePixel, bool useStrip)
00018 {
00019
00020
00021
00022 const vector<TrajectoryMeasurement> & measurements = trajectory->measurements();
00023 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
00024
00025
00026 TrajectoryStateOnSurface trajState=it->updatedState();
00027 if( !trajState.isValid()) continue;
00028
00029 const TrackingRecHit * recHit=(*it->recHit()).hit();
00030
00031 LocalVector trackDirection = trajState.localDirection();
00032 double cosine = trackDirection.z()/trackDirection.mag();
00033
00034 if(const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit)){
00035 if(!useStrip) continue;
00036
00037 RawHits mono,stereo;
00038 mono.trajectoryMeasurement = &(*it);
00039 stereo.trajectoryMeasurement = &(*it);
00040 mono.angleCosine = cosine;
00041 stereo.angleCosine = cosine;
00042 const std::vector<uint8_t> & amplitudes = matchedHit->monoHit()->cluster()->amplitudes();
00043 mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
00044 mono.NSaturating =0;
00045 for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
00046
00047 const std::vector<uint8_t> & amplitudesSt = matchedHit->stereoHit()->cluster()->amplitudes();
00048 stereo.charge = accumulate(amplitudesSt.begin(), amplitudesSt.end(), 0);
00049 stereo.NSaturating =0;
00050 for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)stereo.NSaturating++;}
00051
00052 mono.detId= matchedHit->monoHit()->geographicalId();
00053 stereo.detId= matchedHit->stereoHit()->geographicalId();
00054
00055 hits.push_back(mono);
00056 hits.push_back(stereo);
00057
00058 }else if(const ProjectedSiStripRecHit2D* projectedHit=dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit)) {
00059 if(!useStrip) continue;
00060
00061 const SiStripRecHit2D* singleHit=&(projectedHit->originalHit());
00062 RawHits mono;
00063
00064 mono.trajectoryMeasurement = &(*it);
00065
00066 mono.angleCosine = cosine;
00067 const std::vector<uint8_t> & amplitudes = singleHit->cluster()->amplitudes();
00068 mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
00069 mono.NSaturating =0;
00070 for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
00071
00072 mono.detId= singleHit->geographicalId();
00073 hits.push_back(mono);
00074
00075 }else if(const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
00076 if(!useStrip) continue;
00077
00078 RawHits mono;
00079
00080 mono.trajectoryMeasurement = &(*it);
00081
00082 mono.angleCosine = cosine;
00083 const std::vector<uint8_t> & amplitudes = singleHit->cluster()->amplitudes();
00084 mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
00085 mono.NSaturating =0;
00086 for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
00087
00088 mono.detId= singleHit->geographicalId();
00089 hits.push_back(mono);
00090
00091 }else if(const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
00092 if(!useStrip) continue;
00093
00094 RawHits mono;
00095
00096 mono.trajectoryMeasurement = &(*it);
00097
00098 mono.angleCosine = cosine;
00099 const std::vector<uint8_t> & amplitudes = single1DHit->cluster()->amplitudes();
00100 mono.charge = accumulate(amplitudes.begin(), amplitudes.end(), 0);
00101 mono.NSaturating =0;
00102 for(unsigned int i=0;i<amplitudes.size();i++){if(amplitudes[i]>=254)mono.NSaturating++;}
00103
00104 mono.detId= single1DHit->geographicalId();
00105 hits.push_back(mono);
00106
00107
00108 }else if(const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
00109 if(!usePixel) continue;
00110
00111 RawHits pixel;
00112
00113 pixel.trajectoryMeasurement = &(*it);
00114
00115 pixel.angleCosine = cosine;
00116 pixel.charge = pixelHit->cluster()->charge();
00117 pixel.NSaturating=-1;
00118 pixel.detId= pixelHit->geographicalId();
00119 hits.push_back(pixel);
00120 }
00121
00122 }
00123
00124 }
00125
00126
00127
00128
00129 double genericAverage(const reco::DeDxHitCollection &hits, float expo )
00130 {
00131 double result=0;
00132 size_t n = hits.size();
00133 for(size_t i = 0; i< n; i ++)
00134 {
00135 result+=pow(hits[i].charge(),expo);
00136 }
00137 return (n>0)?pow(result/n,1./expo):0.;
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 }