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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 45 of file DeDxEstimatorProducer.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file DeDxEstimatorProducer.cc.

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

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

Definition at line 89 of file DeDxEstimatorProducer.cc.

89 { delete m_estimator; }
BaseDeDxEstimator * m_estimator

Member Function Documentation

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

Definition at line 92 of file DeDxEstimatorProducer.cc.

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

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

Definition at line 28 of file DeDxEstimatorProducer.cc.

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

28  {
30  desc.add<string>("estimator", "generic");
31  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
32  desc.add<bool>("UsePixel", false);
33  desc.add<bool>("UseStrip", true);
34  desc.add<double>("MeVperADCPixel", 3.61e-06);
35  desc.add<double>("MeVperADCStrip", 3.61e-06 * 265);
36  desc.add<bool>("ShapeTest", true);
37  desc.add<bool>("UseCalibration", false);
38  desc.add<string>("calibrationPath", "");
39  desc.add<string>("Reccord", "SiStripDeDxMip_3D_Rcd");
40  desc.add<string>("ProbabilityMode", "Accumulation");
41  desc.add<double>("fraction", 0.4);
42  desc.add<double>("exponent", -2.0);
43 
44  descriptions.add("DeDxEstimatorProducer", desc);
45 }
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 149 of file DeDxEstimatorProducer.cc.

References Surface::bounds(), ALCARECOTkAlJpsiMuMu_cff::charge, watchdog::const, DEFINE_FWK_MODULE, TrackingRecHit::det(), TrackingRecHit::detUnit(), 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.

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

Definition at line 103 of file DeDxEstimatorProducer.cc.

References trigObjTnPSource_cfi::filler, edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, trackerHitRTTI::isFromDet(), dqmiolumiharvest::j, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), rpcPointValidation_cfi::recHit, and HLT_2018_cff::track.

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

Member Data Documentation

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

Definition at line 78 of file DeDxEstimatorProducer.h.

std::string DeDxEstimatorProducer::m_calibrationPath
private

Definition at line 74 of file DeDxEstimatorProducer.h.

BaseDeDxEstimator* DeDxEstimatorProducer::m_estimator
private

Definition at line 63 of file DeDxEstimatorProducer.h.

unsigned int DeDxEstimatorProducer::m_off
private

Definition at line 79 of file DeDxEstimatorProducer.h.

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

Definition at line 65 of file DeDxEstimatorProducer.h.

unsigned int DeDxEstimatorProducer::MaxNrStrips
private

Definition at line 72 of file DeDxEstimatorProducer.h.

float DeDxEstimatorProducer::meVperADCPixel
private

Definition at line 69 of file DeDxEstimatorProducer.h.

float DeDxEstimatorProducer::meVperADCStrip
private

Definition at line 70 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::shapetest
private

Definition at line 76 of file DeDxEstimatorProducer.h.

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

Definition at line 81 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useCalibration
private

Definition at line 75 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::usePixel
private

Definition at line 67 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useStrip
private

Definition at line 68 of file DeDxEstimatorProducer.h.