CMS 3D CMS Logo

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

#include <RecoTracker/DeDxEstimatorProducer/src/DeDxEstimatorProducer.cc>

Inheritance diagram for DeDxEstimatorProducer:
edm::stream::EDProducer<>

Public Member Functions

 DeDxEstimatorProducer (const edm::ParameterSet &)
 
 ~DeDxEstimatorProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginRun (edm::Run const &run, const edm::EventSetup &) override
 
void makeCalibrationMap (const TrackerGeometry &tkGeom)
 
void processHit (const TrackingRecHit *recHit, float trackMomentum, float &cosine, reco::DeDxHitCollection &dedxHits, int &NClusterSaturating)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< std::vector< float > > calibGains
 
std::string m_calibrationPath
 
BaseDeDxEstimatorm_estimator
 
unsigned int m_off
 
edm::EDGetTokenT< reco::TrackCollectionm_tracksTag
 
unsigned int MaxNrStrips
 
float meVperADCPixel
 
float meVperADCStrip
 
bool shapetest
 
edm::ESHandle< TrackerGeometrytkGeom
 
bool useCalibration
 
bool usePixel
 
bool useStrip
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 48 of file DeDxEstimatorProducer.h.

Constructor & Destructor Documentation

DeDxEstimatorProducer::DeDxEstimatorProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 51 of file DeDxEstimatorProducer.cc.

References edm::ParameterSet::getParameter(), dedxEstimators_cff::useCalibration, dedxEstimators_cff::usePixel, and dedxEstimators_cff::useStrip.

52 {
53 
54  produces<ValueMap<DeDxData> >();
55 
56  string estimatorName = iConfig.getParameter<string>("estimator");
57  if (estimatorName == "median") m_estimator = new MedianDeDxEstimator(iConfig);
58  else if(estimatorName == "generic") m_estimator = new GenericAverageDeDxEstimator (iConfig);
59  else if(estimatorName == "truncated") m_estimator = new TruncatedAverageDeDxEstimator(iConfig);
60  else if(estimatorName == "genericTruncated") m_estimator = new GenericTruncatedAverageDeDxEstimator(iConfig);
61  else if(estimatorName == "unbinnedFit") m_estimator = new UnbinnedFitDeDxEstimator(iConfig);
62  else if(estimatorName == "productDiscrim") m_estimator = new ProductDeDxDiscriminator(iConfig);
63  else if(estimatorName == "btagDiscrim") m_estimator = new BTagLikeDeDxDiscriminator(iConfig);
64  else if(estimatorName == "smirnovDiscrim") m_estimator = new SmirnovDeDxDiscriminator(iConfig);
65  else if(estimatorName == "asmirnovDiscrim") m_estimator = new ASmirnovDeDxDiscriminator(iConfig);
66 
67  //Commented for now, might be used in the future
68 // MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
69 
70  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
71 
72  usePixel = iConfig.getParameter<bool>("UsePixel");
73  useStrip = iConfig.getParameter<bool>("UseStrip");
74  meVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel");
75  meVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip");
76 
77  shapetest = iConfig.getParameter<bool>("ShapeTest");
78  useCalibration = iConfig.getParameter<bool>("UseCalibration");
79  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
80 
81  if(!usePixel && !useStrip)
82  edm::LogWarning("DeDxHitsProducer") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
83 
84 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
BaseDeDxEstimator * m_estimator
DeDxEstimatorProducer::~DeDxEstimatorProducer ( )
override

Definition at line 87 of file DeDxEstimatorProducer.cc.

88 {
89  delete m_estimator;
90 }
BaseDeDxEstimator * m_estimator

Member Function Documentation

void DeDxEstimatorProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 93 of file DeDxEstimatorProducer.cc.

References edm::EventSetup::get(), DeDxTools::makeCalibrationMap(), GeomDetEnumerators::PixelBarrel, and dedxEstimators_cff::useCalibration.

94 {
95  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
96  if(useCalibration && calibGains.empty()){
97  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
98 
100  }
101 
102  m_estimator->beginRun(run, iSetup);
103 }
void makeCalibrationMap(const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:196
unsigned int offsetDU(SubDetector sid) const
std::vector< std::vector< float > > calibGains
BaseDeDxEstimator * m_estimator
edm::ESHandle< TrackerGeometry > tkGeom
virtual void beginRun(edm::Run const &run, const edm::EventSetup &iSetup)
T get() const
Definition: EventSetup.h:71
void DeDxEstimatorProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 31 of file DeDxEstimatorProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

31  {
33  desc.add<string>("estimator","generic");
34  desc.add<edm::InputTag>("tracks",edm::InputTag("generalTracks"));
35  desc.add<bool>("UsePixel",false);
36  desc.add<bool>("UseStrip",true);
37  desc.add<double>("MeVperADCPixel",3.61e-06);
38  desc.add<double>("MeVperADCStrip",3.61e-06*265);
39  desc.add<bool>("ShapeTest",true);
40  desc.add<bool>("UseCalibration",false);
41  desc.add<string>("calibrationPath", "");
42  desc.add<string>("Reccord", "SiStripDeDxMip_3D_Rcd");
43  desc.add<string>("ProbabilityMode", "Accumulation");
44  desc.add<double>("fraction", 0.4);
45  desc.add<double>("exponent",-2.0);
46 
47  descriptions.add("DeDxEstimatorProducer",desc);
48 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void DeDxEstimatorProducer::makeCalibrationMap ( const TrackerGeometry tkGeom)
private
void DeDxEstimatorProducer::processHit ( const TrackingRecHit recHit,
float  trackMomentum,
float &  cosine,
reco::DeDxHitCollection dedxHits,
int &  NClusterSaturating 
)
private

Definition at line 155 of file DeDxEstimatorProducer.cc.

References Surface::bounds(), ALCARECOTkAlJpsiMuMu_cff::charge, DEFINE_FWK_MODULE, TrackingRecHit::det(), TrackingRecHit::detUnit(), BaseTrackerRecHit::firstClusterRef(), DeDxTools::getCharge(), SiStripMatchedRecHit2D::monoCluster(), GluedGeomDet::monoDet(), SiStripMatchedRecHit2D::monoId(), rpcPointValidation_cfi::recHit, DeDxTools::shapeSelection(), SiStripMatchedRecHit2D::stereoCluster(), GluedGeomDet::stereoDet(), SiStripMatchedRecHit2D::stereoId(), GeomDet::surface(), Bounds::thickness(), dedxEstimators_cff::usePixel, and dedxEstimators_cff::useStrip.

155  {
156  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
157  if(!thit.isValid())return;
158 
159  auto const & clus = thit.firstClusterRef();
160  if(!clus.isValid())return;
161 
162  if(clus.isPixel()){
163  if(!usePixel) return;
164 
165  const auto * detUnit = recHit->detUnit();
166  if (detUnit == nullptr) detUnit = tkGeom->idToDet(thit.geographicalId());
167  float pathLen = detUnit->surface().bounds().thickness()/fabs(cosine);
168  float chargeAbs = clus.pixelCluster().charge();
169  float charge = meVperADCPixel*chargeAbs/pathLen;
170  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, thit.geographicalId()) );
171  }else if(clus.isStrip() && !thit.isMatched()){
172  if(!useStrip) return;
173 
174  const auto * detUnit = recHit->detUnit();
175  if (detUnit == nullptr) detUnit = tkGeom->idToDet(thit.geographicalId());
176  int NSaturating = 0;
177  float pathLen = detUnit->surface().bounds().thickness()/fabs(cosine);
178  float chargeAbs = DeDxTools::getCharge(&(clus.stripCluster()),NSaturating, *detUnit, calibGains, m_off);
179  float charge = meVperADCStrip*chargeAbs/pathLen;
180  if(!shapetest || (shapetest && DeDxTools::shapeSelection(clus.stripCluster()))){
181  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, thit.geographicalId()) );
182  if(NSaturating>0)NClusterSaturating++;
183  }
184  }else if(clus.isStrip() && thit.isMatched()){
185  if(!useStrip) return;
186  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
187  if(!matchedHit)return;
188  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(matchedHit->det());
189  if (gdet == nullptr) gdet = static_cast<const GluedGeomDet*>(tkGeom->idToDet(thit.geographicalId()));
190 
191  auto& detUnitM = *(gdet->monoDet());
192  int NSaturating = 0;
193  float pathLen = detUnitM.surface().bounds().thickness()/fabs(cosine);
194  float chargeAbs = DeDxTools::getCharge(&(matchedHit->monoCluster()),NSaturating, detUnitM, calibGains, m_off);
195  float charge = meVperADCStrip*chargeAbs/pathLen;
196  if(!shapetest || (shapetest && DeDxTools::shapeSelection(matchedHit->monoCluster()))){
197  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, matchedHit->monoId()) );
198  if(NSaturating>0)NClusterSaturating++;
199  }
200 
201  auto& detUnitS = *(gdet->stereoDet());
202  NSaturating = 0;
203  pathLen = detUnitS.surface().bounds().thickness()/fabs(cosine);
204  chargeAbs = DeDxTools::getCharge(&(matchedHit->stereoCluster()),NSaturating, detUnitS, calibGains, m_off);
205  charge = meVperADCStrip*chargeAbs/pathLen;
206  if(!shapetest || (shapetest && DeDxTools::shapeSelection(matchedHit->stereoCluster()))){
207  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, matchedHit->stereoId()) );
208  if(NSaturating>0)NClusterSaturating++;
209  }
210  }
211 }
unsigned int stereoId() const
int getCharge(const SiStripCluster *cluster, int &nSatStrip, const GeomDetUnit &detUnit, const std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:161
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
SiStripCluster const & monoCluster() const
const Bounds & bounds() const
Definition: Surface.h:120
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
const GeomDet * det() const
bool shapeSelection(const SiStripCluster &ampls)
Definition: DeDxTools.cc:10
std::vector< std::vector< float > > calibGains
edm::ESHandle< TrackerGeometry > tkGeom
virtual float thickness() const =0
SiStripCluster const & stereoCluster() const
virtual const GeomDetUnit * detUnit() const
virtual OmniClusterRef const & firstClusterRef() const =0
const TrackerGeomDet * idToDet(DetId) const override
unsigned int monoId() const
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
void DeDxEstimatorProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 107 of file DeDxEstimatorProducer.cc.

References objects.autophobj::filler, edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, trackerHitRTTI::isFromDet(), eostools::move(), edm::Handle< T >::product(), edm::Event::put(), rpcPointValidation_cfi::recHit, and HiIsolationCommonParameters_cff::track.

108 {
109  auto trackDeDxEstimateAssociation = std::make_unique<ValueMap<DeDxData>>();
110  ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation);
111 
112  edm::Handle<reco::TrackCollection> trackCollectionHandle;
113  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
114 
115 
116  std::vector<DeDxData> dedxEstimate( trackCollectionHandle->size() );
117 
118  for(unsigned int j=0;j<trackCollectionHandle->size();j++){
119  const reco::TrackRef track = reco::TrackRef( trackCollectionHandle.product(), j );
120 
121  int NClusterSaturating = 0;
122  DeDxHitCollection dedxHits;
123 
124  auto const & trajParams = track->extra()->trajParams();
125  assert(trajParams.size()==track->recHitsSize());
126  auto hb = track->recHitsBegin();
127  dedxHits.reserve(track->recHitsSize()/2);
128  for(unsigned int h=0;h<track->recHitsSize();h++){
129  auto recHit = *(hb+h);
130  if (!trackerHitRTTI::isFromDet(*recHit) ) continue;
131 
132  auto trackDirection = trajParams[h].direction();
133  float cosine = trackDirection.z()/trackDirection.mag();
134  processHit(recHit, track->p(), cosine, dedxHits, NClusterSaturating);
135  }
136 
137  sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
138  std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
139 
140  //WARNING: Since the dEdX Error is not properly computed for the moment
141  //It was decided to store the number of saturating cluster in that dataformat
142  val_and_error.second = NClusterSaturating;
143  dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
144  }
146 
147  filler.insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
148 
149  // fill the association map and put it into the event
150  filler.fill();
151  iEvent.put(std::move(trackDeDxEstimateAssociation));
152 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool isFromDet(TrackingRecHit const &hit)
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:58
void processHit(const TrackingRecHit *recHit, float trackMomentum, float &cosine, reco::DeDxHitCollection &dedxHits, int &NClusterSaturating)
BaseDeDxEstimator * m_estimator
virtual std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits)=0
T const * product() const
Definition: Handle.h:74
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:21
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::vector< std::vector<float> > DeDxEstimatorProducer::calibGains
private

Definition at line 77 of file DeDxEstimatorProducer.h.

std::string DeDxEstimatorProducer::m_calibrationPath
private

Definition at line 73 of file DeDxEstimatorProducer.h.

BaseDeDxEstimator* DeDxEstimatorProducer::m_estimator
private

Definition at line 62 of file DeDxEstimatorProducer.h.

unsigned int DeDxEstimatorProducer::m_off
private

Definition at line 78 of file DeDxEstimatorProducer.h.

edm::EDGetTokenT<reco::TrackCollection> DeDxEstimatorProducer::m_tracksTag
private

Definition at line 64 of file DeDxEstimatorProducer.h.

unsigned int DeDxEstimatorProducer::MaxNrStrips
private

Definition at line 71 of file DeDxEstimatorProducer.h.

float DeDxEstimatorProducer::meVperADCPixel
private

Definition at line 68 of file DeDxEstimatorProducer.h.

float DeDxEstimatorProducer::meVperADCStrip
private

Definition at line 69 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::shapetest
private

Definition at line 75 of file DeDxEstimatorProducer.h.

edm::ESHandle<TrackerGeometry> DeDxEstimatorProducer::tkGeom
private

Definition at line 80 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useCalibration
private

Definition at line 74 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::usePixel
private

Definition at line 66 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useStrip
private

Definition at line 67 of file DeDxEstimatorProducer.h.