CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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
 
std::unique_ptr
< BaseDeDxEstimator
m_estimator
 
unsigned int m_off
 
edm::EDGetTokenT
< reco::TrackCollection
m_tracksTag
 
unsigned int MaxNrStrips
 
float meVperADCPixel
 
float meVperADCStrip
 
bool shapetest
 
const TrackerGeometrytkGeom = nullptr
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
tkGeomToken
 
bool useCalibration
 
bool usePixel
 
bool useStrip
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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 48 of file DeDxEstimatorProducer.cc.

References edm::BeginRun, edm::ParameterSet::getParameter(), iConfig, m_calibrationPath, m_estimator, m_tracksTag, meVperADCPixel, meVperADCStrip, shapetest, useCalibration, usePixel, and useStrip.

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

Definition at line 92 of file DeDxEstimatorProducer.cc.

92 {}

Member Function Documentation

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

Definition at line 95 of file DeDxEstimatorProducer.cc.

References calibGains, edm::EventSetup::getData(), m_calibrationPath, m_estimator, m_off, DeDxTools::makeCalibrationMap(), TrackerGeometry::offsetDU(), GeomDetEnumerators::PixelBarrel, tkGeom, tkGeomToken, and useCalibration.

95  {
96  tkGeom = &iSetup.getData(tkGeomToken);
97  if (useCalibration && calibGains.empty()) {
98  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
99 
101  }
102 
103  m_estimator->beginRun(run, iSetup);
104 }
void makeCalibrationMap(const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float >> &calibGains, const unsigned int &m_off)
std::unique_ptr< BaseDeDxEstimator > m_estimator
bool getData(T &iHolder) const
Definition: EventSetup.h:122
unsigned int offsetDU(SubDetector sid) const
const TrackerGeometry * tkGeom
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken
std::vector< std::vector< float > > calibGains
void DeDxEstimatorProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 29 of file DeDxEstimatorProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

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

References Surface::bounds(), calibGains, RecoTauCleanerPlugins::charge, runTheMatrix::const, TrackingRecHit::det(), TrackingRecHit::detUnit(), DeDxTools::getCharge(), TrackerGeometry::idToDet(), m_off, meVperADCPixel, meVperADCStrip, SiStripMatchedRecHit2D::monoCluster(), GluedGeomDet::monoDet(), SiStripMatchedRecHit2D::monoId(), DeDxTools::shapeSelection(), shapetest, SiStripMatchedRecHit2D::stereoCluster(), GluedGeomDet::stereoDet(), SiStripMatchedRecHit2D::stereoId(), GeomDet::surface(), Bounds::thickness(), tkGeom, usePixel, and useStrip.

Referenced by produce().

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

References cms::cuda::assert(), edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, trackerHitRTTI::isFromDet(), dqmiolumiharvest::j, m_estimator, m_tracksTag, eostools::move(), processHit(), edm::Handle< T >::product(), edm::Event::put(), and HLT_FULL_cff::track.

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

Member Data Documentation

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

Definition at line 78 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and processHit().

std::string DeDxEstimatorProducer::m_calibrationPath
private

Definition at line 74 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and DeDxEstimatorProducer().

std::unique_ptr<BaseDeDxEstimator> DeDxEstimatorProducer::m_estimator
private

Definition at line 63 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), DeDxEstimatorProducer(), and produce().

unsigned int DeDxEstimatorProducer::m_off
private

Definition at line 79 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and processHit().

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

Definition at line 65 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and produce().

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.

Referenced by DeDxEstimatorProducer(), and processHit().

float DeDxEstimatorProducer::meVperADCStrip
private

Definition at line 70 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

bool DeDxEstimatorProducer::shapetest
private

Definition at line 76 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

const TrackerGeometry* DeDxEstimatorProducer::tkGeom = nullptr
private

Definition at line 82 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and processHit().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> DeDxEstimatorProducer::tkGeomToken
private

Definition at line 81 of file DeDxEstimatorProducer.h.

Referenced by beginRun().

bool DeDxEstimatorProducer::useCalibration
private

Definition at line 75 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and DeDxEstimatorProducer().

bool DeDxEstimatorProducer::usePixel
private

Definition at line 67 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

bool DeDxEstimatorProducer::useStrip
private

Definition at line 68 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().