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
 
 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< BaseDeDxEstimatorm_estimator
 
unsigned int m_off
 
edm::EDGetTokenT< reco::TrackCollectionm_tracksTag
 
unsigned int MaxNrStrips
 
float meVperADCPixel
 
float meVperADCStrip
 
bool shapetest
 
const TrackerGeometrytkGeom = nullptr
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtkGeomToken
 
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::DeDxEstimatorProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 49 of file DeDxEstimatorProducer.cc.

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

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

◆ ~DeDxEstimatorProducer()

DeDxEstimatorProducer::~DeDxEstimatorProducer ( )
override

Definition at line 93 of file DeDxEstimatorProducer.cc.

93 {}

Member Function Documentation

◆ beginRun()

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

Definition at line 96 of file DeDxEstimatorProducer.cc.

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

96  {
97  tkGeom = &iSetup.getData(tkGeomToken);
98  if (useCalibration && calibGains.empty()) {
99  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
100 
102  }
103 
104  m_estimator->beginRun(run, iSetup);
105 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
unsigned int offsetDU(SubDetector sid) const
std::unique_ptr< BaseDeDxEstimator > m_estimator
void makeCalibrationMap(const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float >> &calibGains, const unsigned int &m_off)
const TrackerGeometry * tkGeom
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken
std::vector< std::vector< float > > calibGains

◆ fillDescriptions()

void DeDxEstimatorProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 29 of file DeDxEstimatorProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::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>("Record", "SiStripDeDxMip_3D_Rcd");
41  desc.add<string>("ProbabilityMode", "Accumulation");
42  desc.add<double>("fraction", 0.4);
43  desc.add<double>("exponent", -2.0);
44  desc.add<bool>("truncate", true);
45 
46  descriptions.add("DeDxEstimatorProducer", desc);
47 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ makeCalibrationMap()

void DeDxEstimatorProducer::makeCalibrationMap ( const TrackerGeometry tkGeom)
private

◆ processHit()

void DeDxEstimatorProducer::processHit ( const TrackingRecHit recHit,
float  trackMomentum,
float &  cosine,
reco::DeDxHitCollection dedxHits,
int &  NClusterSaturating 
)
private

Definition at line 153 of file DeDxEstimatorProducer.cc.

References Surface::bounds(), calibGains, ALCARECOTkAlJpsiMuMu_cff::charge, runTheMatrix::const, TrackingRecHit::det(), deDxTools::getCharge(), TrackerGeometry::idToDet(), m_off, meVperADCPixel, meVperADCStrip, SiStripMatchedRecHit2D::monoCluster(), GluedGeomDet::monoDet(), SiStripMatchedRecHit2D::monoId(), rpcPointValidation_cfi::recHit, deDxTools::shapeSelection(), shapetest, SiStripMatchedRecHit2D::stereoCluster(), GluedGeomDet::stereoDet(), SiStripMatchedRecHit2D::stereoId(), GeomDet::surface(), Bounds::thickness(), tkGeom, reco::btau::trackMomentum, usePixel, and useStrip.

Referenced by produce().

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

◆ produce()

void DeDxEstimatorProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 107 of file DeDxEstimatorProducer.cc.

References cms::cuda::assert(), trigObjTnPSource_cfi::filler, h, hcalSimParameters_cfi::hb, iEvent, trackerHitRTTI::isFromDet(), dqmiolumiharvest::j, m_estimator, m_tracksTag, eostools::move(), processHit(), edm::Handle< T >::product(), rpcPointValidation_cfi::recHit, jetUpdater_cfi::sort, and HLT_2024v13_cff::track.

107  {
108  auto trackDeDxEstimateAssociation = std::make_unique<ValueMap<DeDxData>>();
109  ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation);
110 
111  edm::Handle<reco::TrackCollection> trackCollectionHandle;
112  iEvent.getByToken(m_tracksTag, trackCollectionHandle);
113 
114  std::vector<DeDxData> dedxEstimate(trackCollectionHandle->size());
115 
116  for (unsigned int j = 0; j < trackCollectionHandle->size(); j++) {
117  const reco::TrackRef track = reco::TrackRef(trackCollectionHandle.product(), j);
118 
119  int NClusterSaturating = 0;
120  DeDxHitCollection dedxHits;
121 
122  auto const& trajParams = track->extra()->trajParams();
123  assert(trajParams.size() == track->recHitsSize());
124  auto hb = track->recHitsBegin();
125  dedxHits.reserve(track->recHitsSize() / 2);
126  for (unsigned int h = 0; h < track->recHitsSize(); h++) {
127  auto recHit = *(hb + h);
129  continue;
130 
131  auto trackDirection = trajParams[h].direction();
132  float cosine = trackDirection.z() / trackDirection.mag();
133  processHit(recHit, track->p(), cosine, dedxHits, NClusterSaturating);
134  }
135 
136  sort(dedxHits.begin(), dedxHits.end(), less<DeDxHit>());
137  std::pair<float, float> val_and_error = m_estimator->dedx(dedxHits);
138 
139  //WARNING: Since the dEdX Error is not properly computed for the moment
140  //It was decided to store the number of saturating cluster in that dataformat
141  val_and_error.second = NClusterSaturating;
142  dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size());
143  }
145 
146  filler.insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
147 
148  // fill the association map and put it into the event
149  filler.fill();
150  iEvent.put(std::move(trackDeDxEstimateAssociation));
151 }
bool isFromDet(TrackingRecHit const &hit)
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
T const * product() const
Definition: Handle.h:70
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:41
assert(be >=bs)
std::unique_ptr< BaseDeDxEstimator > m_estimator
int iEvent
Definition: GenABIO.cc:224
void processHit(const TrackingRecHit *recHit, float trackMomentum, float &cosine, reco::DeDxHitCollection &dedxHits, int &NClusterSaturating)
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
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ calibGains

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

Definition at line 78 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and processHit().

◆ m_calibrationPath

std::string DeDxEstimatorProducer::m_calibrationPath
private

Definition at line 74 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and DeDxEstimatorProducer().

◆ m_estimator

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

Definition at line 63 of file DeDxEstimatorProducer.h.

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

◆ m_off

unsigned int DeDxEstimatorProducer::m_off
private

Definition at line 79 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and processHit().

◆ m_tracksTag

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

Definition at line 65 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and produce().

◆ MaxNrStrips

unsigned int DeDxEstimatorProducer::MaxNrStrips
private

Definition at line 72 of file DeDxEstimatorProducer.h.

◆ meVperADCPixel

float DeDxEstimatorProducer::meVperADCPixel
private

Definition at line 69 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

◆ meVperADCStrip

float DeDxEstimatorProducer::meVperADCStrip
private

Definition at line 70 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

◆ shapetest

bool DeDxEstimatorProducer::shapetest
private

Definition at line 76 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

◆ tkGeom

const TrackerGeometry* DeDxEstimatorProducer::tkGeom = nullptr
private

Definition at line 82 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and processHit().

◆ tkGeomToken

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

Definition at line 81 of file DeDxEstimatorProducer.h.

Referenced by beginRun().

◆ useCalibration

bool DeDxEstimatorProducer::useCalibration
private

Definition at line 75 of file DeDxEstimatorProducer.h.

Referenced by beginRun(), and DeDxEstimatorProducer().

◆ usePixel

bool DeDxEstimatorProducer::usePixel
private

Definition at line 67 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().

◆ useStrip

bool DeDxEstimatorProducer::useStrip
private

Definition at line 68 of file DeDxEstimatorProducer.h.

Referenced by DeDxEstimatorProducer(), and processHit().