#include <RecoTracker/DeDxEstimatorProducer/src/DeDxEstimatorProducer.cc>
Public Member Functions | |
DeDxEstimatorProducer (const edm::ParameterSet &) | |
~DeDxEstimatorProducer () | |
Private Member Functions | |
virtual void | beginJob (const edm::EventSetup &) |
double | distance (DetId id) |
virtual void | endJob () |
double | normalization (DetId id) |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
double | thickness (DetId id) |
Private Attributes | |
std::map< DetId, double > | m_distanceMap |
BaseDeDxEstimator * | m_estimator |
std::map< DetId, double > | m_normalizationMap |
std::map< DetId, double > | m_thicknessMap |
const TrackerGeometry * | m_tracker |
edm::InputTag | m_tracksTag |
edm::InputTag | m_trajTrackAssociationTag |
double | MeVperADCPixel |
double | MeVperADCStrip |
bool | usePixel |
bool | useStrip |
Implementation: <Notes on="" implementation>="">
Definition at line 24 of file DeDxEstimatorProducer.h.
DeDxEstimatorProducer::DeDxEstimatorProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 46 of file DeDxEstimatorProducer.cc.
References edm::ParameterSet::getParameter(), m_estimator, m_tracksTag, m_trajTrackAssociationTag, MeVperADCPixel, MeVperADCStrip, usePixel, and useStrip.
00047 { 00048 00049 produces<ValueMap<DeDxData> >(); 00050 00051 00052 string estimatorName = iConfig.getParameter<string>("estimator"); 00053 if(estimatorName == "median") m_estimator = new MedianDeDxEstimator(-2.); 00054 if(estimatorName == "generic") m_estimator = new GenericAverageDeDxEstimator (iConfig.getParameter<double>("exponent")); 00055 if(estimatorName == "truncated") m_estimator = new TruncatedAverageDeDxEstimator(iConfig.getParameter<double>("fraction")); 00056 00057 00058 m_tracksTag = iConfig.getParameter<edm::InputTag>("tracks"); 00059 m_trajTrackAssociationTag = iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"); 00060 00061 usePixel = iConfig.getParameter<bool>("UsePixel"); 00062 useStrip = iConfig.getParameter<bool>("UseStrip"); 00063 MeVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel"); 00064 MeVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip"); 00065 00066 if(!usePixel && !useStrip) 00067 edm::LogWarning("DeDxHitsProducer") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file"; 00068 }
DeDxEstimatorProducer::~DeDxEstimatorProducer | ( | ) |
Definition at line 71 of file DeDxEstimatorProducer.cc.
References m_estimator.
00072 { 00073 delete m_estimator; 00074 }
void DeDxEstimatorProducer::beginJob | ( | const edm::EventSetup & | ) | [private, virtual] |
double DeDxEstimatorProducer::distance | ( | DetId | id | ) | [private] |
Definition at line 186 of file DeDxEstimatorProducer.cc.
References d, dist(), TrackerGeometry::idToDetUnit(), it, m_distanceMap, and m_tracker.
Referenced by produce().
00187 { 00188 map<DetId,double>::iterator dist=m_distanceMap.find(id); 00189 if(dist!=m_distanceMap.end()) 00190 return (*dist).second; 00191 else 00192 { 00193 const GeomDetUnit* it = m_tracker->idToDetUnit(DetId(id)); 00194 float d=it->position().mag(); 00195 m_distanceMap[id]=d; 00196 return d; 00197 } 00198 00199 }
double DeDxEstimatorProducer::normalization | ( | DetId | id | ) | [private] |
Definition at line 160 of file DeDxEstimatorProducer.cc.
References TrackerGeometry::idToDetUnit(), it, m_normalizationMap, m_tracker, MeVperADCPixel, MeVperADCStrip, norm, and thickness().
Referenced by produce().
00161 { 00162 map<DetId,double>::iterator norm=m_normalizationMap.find(id); 00163 if(norm!=m_normalizationMap.end()) 00164 return (*norm).second; 00165 else { 00166 double detNormalization=1./thickness(id); 00167 00168 //compute other normalization 00169 const GeomDetUnit* it = m_tracker->idToDetUnit(DetId(id)); 00170 bool isPixel = dynamic_cast<const PixelGeomDetUnit*>(it)!=0; 00171 bool isStrip = dynamic_cast<const StripGeomDetUnit*>(it)!=0; 00172 00173 //FIXME: include gain et al calib 00174 // if(isPixel) detNormalization*=3.61e-06; 00175 // if(isStrip) detNormalization*=3.61e-06*250; 00176 00177 if(isPixel) detNormalization*=MeVperADCPixel; 00178 if(isStrip) detNormalization*=MeVperADCStrip; 00179 00180 m_normalizationMap[id]=detNormalization;//computed value 00181 return detNormalization; 00182 } 00183 }
void DeDxEstimatorProducer::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 77 of file DeDxEstimatorProducer.cc.
References funct::abs(), edm::AssociationMap< Tag >::begin(), BaseDeDxEstimator::dedx(), detId, distance(), edm::AssociationMap< Tag >::end(), edm::EventSetup::get(), edm::Event::getByLabel(), i, j, m_estimator, m_tracker, m_tracksTag, m_trajTrackAssociationTag, n, normalization(), edm::Handle< T >::product(), edm::Event::put(), edm::AssociationMap< Tag >::size(), python::multivaluedict::sort(), thickness(), track, DeDxTools::trajectoryRawHits(), usePixel, and useStrip.
00077 { 00078 00079 auto_ptr<ValueMap<DeDxData> > trackDeDxEstimateAssociation(new ValueMap<DeDxData> ); 00080 ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation); 00081 00082 edm::ESHandle<TrackerGeometry> tkGeom; 00083 iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom ); 00084 m_tracker=&(* tkGeom ); 00085 00086 Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle; 00087 iEvent.getByLabel(m_trajTrackAssociationTag, trajTrackAssociationHandle); 00088 const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product(); 00089 00090 edm::Handle<reco::TrackCollection> trackCollectionHandle; 00091 iEvent.getByLabel(m_tracksTag,trackCollectionHandle); 00092 00093 size_t n = TrajToTrackMap.size(); 00094 std::vector<DeDxData> dedxEstimate(n); 00095 00096 //assume trajectory collection size is equal to track collection size and that order is kept 00097 int j=0; 00098 for(TrajTrackAssociationCollection::const_iterator cit=TrajToTrackMap.begin(); cit!=TrajToTrackMap.end(); cit++,j++){ 00099 00100 const edm::Ref<std::vector<Trajectory> > traj = cit->key; 00101 const reco::TrackRef track = cit->val; 00102 00103 DeDxHitCollection dedxHits; 00104 vector<DeDxTools::RawHits> hits; 00105 DeDxTools::trajectoryRawHits(traj, hits, usePixel, useStrip); 00106 00107 for(size_t i=0; i < hits.size(); i++) 00108 { 00109 float pathLen=thickness(hits[i].detId)/std::abs(hits[i].angleCosine); 00110 float charge=normalization(hits[i].detId)*hits[i].charge*std::abs(hits[i].angleCosine); 00111 dedxHits.push_back( DeDxHit( charge, distance(hits[i].detId), pathLen, hits[i].detId) ); 00112 } 00113 00114 sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>()); 00115 std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits); 00116 00117 dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() ); 00118 } 00119 filler.insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end()); 00120 00121 // really fill the association map 00122 filler.fill(); 00123 // put into the event 00124 iEvent.put(trackDeDxEstimateAssociation); 00125 }
double DeDxEstimatorProducer::thickness | ( | DetId | id | ) | [private] |
Definition at line 134 of file DeDxEstimatorProducer.cc.
References TrackerGeometry::idToDetUnit(), it, m_thicknessMap, and m_tracker.
Referenced by normalization(), and produce().
00135 { 00136 map<DetId,double>::iterator th=m_thicknessMap.find(id); 00137 if(th!=m_thicknessMap.end()) 00138 return (*th).second; 00139 else { 00140 double detThickness=1.; 00141 //compute thickness normalization 00142 const GeomDetUnit* it = m_tracker->idToDetUnit(DetId(id)); 00143 bool isPixel = dynamic_cast<const PixelGeomDetUnit*>(it)!=0; 00144 bool isStrip = dynamic_cast<const StripGeomDetUnit*>(it)!=0; 00145 if (!isPixel && ! isStrip) { 00146 //FIXME throw exception 00147 edm::LogWarning("DeDxHitsProducer") << "\t\t this detID doesn't seem to belong to the Tracker"; 00148 detThickness = 1.; 00149 }else{ 00150 detThickness = it->surface().bounds().thickness(); 00151 } 00152 00153 m_thicknessMap[id]=detThickness;//computed value 00154 return detThickness; 00155 } 00156 00157 }
std::map<DetId,double> DeDxEstimatorProducer::m_distanceMap [private] |
Definition at line 42 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), produce(), and ~DeDxEstimatorProducer().
std::map<DetId,double> DeDxEstimatorProducer::m_normalizationMap [private] |
std::map<DetId,double> DeDxEstimatorProducer::m_thicknessMap [private] |
const TrackerGeometry* DeDxEstimatorProducer::m_tracker [private] |
Definition at line 52 of file DeDxEstimatorProducer.h.
Referenced by distance(), normalization(), produce(), and thickness().
Definition at line 45 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), and produce().
Definition at line 44 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), and produce().
double DeDxEstimatorProducer::MeVperADCPixel [private] |
Definition at line 49 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), and normalization().
double DeDxEstimatorProducer::MeVperADCStrip [private] |
Definition at line 50 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), and normalization().
bool DeDxEstimatorProducer::usePixel [private] |
Definition at line 47 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), and produce().
bool DeDxEstimatorProducer::useStrip [private] |
Definition at line 48 of file DeDxEstimatorProducer.h.
Referenced by DeDxEstimatorProducer(), and produce().