CMS 3D CMS Logo

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

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

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

Public Member Functions

 FastTrackDeDxProducer (const edm::ParameterSet &)
 
 ~FastTrackDeDxProducer () override=default
 
- 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 &, const edm::EventSetup &) override
 
void makeCalibrationMap (const TrackerGeometry &tkGeom)
 
void processHit (const FastTrackerRecHit &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
 
bool convertFromGeV2MeV
 
std::string m_calibrationPath
 
std::unique_ptr< BaseDeDxEstimatorm_estimator
 
edm::EDGetTokenT< reco::TrackCollectionm_tracksTag
 
unsigned int MaxNrStrips
 
float meVperADCPixel
 
float meVperADCStrip
 
bool nothick
 
unsigned int offsetDU_
 
bool shapetest
 
edm::EDGetTokenT< FastTrackerRecHitRefCollectionsimHit2RecHitMapToken
 
edm::EDGetTokenT< edm::PSimHitContainersimHitsToken
 
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 67 of file FastTrackDeDxProducer.cc.

Constructor & Destructor Documentation

◆ FastTrackDeDxProducer()

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

Definition at line 138 of file FastTrackDeDxProducer.cc.

References convertFromGeV2MeV, Exception, edm::ParameterSet::getParameter(), m_calibrationPath, m_estimator, m_tracksTag, meVperADCPixel, meVperADCStrip, nothick, shapetest, tkGeomToken, useCalibration, usePixel, and useStrip.

139  : simHitsToken(consumes<edm::PSimHitContainer>(iConfig.getParameter<edm::InputTag>("simHits"))),
141  consumes<FastTrackerRecHitRefCollection>(iConfig.getParameter<edm::InputTag>("simHit2RecHitMap"))) {
142  produces<ValueMap<DeDxData>>();
143 
144  auto cCollector = consumesCollector();
145  string estimatorName = iConfig.getParameter<string>("estimator");
146  if (estimatorName == "median")
147  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new MedianDeDxEstimator(iConfig));
148  else if (estimatorName == "generic")
149  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new GenericAverageDeDxEstimator(iConfig));
150  else if (estimatorName == "truncated")
151  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new TruncatedAverageDeDxEstimator(iConfig));
152  //else if(estimatorName == "unbinnedFit") m_estimator = std::unique_ptr<BaseDeDxEstimator> (new UnbinnedFitDeDxEstimator(iConfig));//estimator used in FullSimVersion
153  else if (estimatorName == "productDiscrim")
154  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new ProductDeDxDiscriminator(iConfig, cCollector));
155  else if (estimatorName == "btagDiscrim")
156  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new BTagLikeDeDxDiscriminator(iConfig, cCollector));
157  else if (estimatorName == "smirnovDiscrim")
158  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new SmirnovDeDxDiscriminator(iConfig, cCollector));
159  else if (estimatorName == "asmirnovDiscrim")
160  m_estimator = std::unique_ptr<BaseDeDxEstimator>(new ASmirnovDeDxDiscriminator(iConfig, cCollector));
161  else
162  throw cms::Exception("fastsim::SimplifiedGeometry::FastTrackDeDxProducer.cc") << " estimator name does not exist";
163 
164  //Commented for now, might be used in the future
165  // MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
166 
167  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
168 
169  usePixel = iConfig.getParameter<bool>("UsePixel");
170  useStrip = iConfig.getParameter<bool>("UseStrip");
171  meVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel");
172  meVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip");
173 
174  shapetest = iConfig.getParameter<bool>("ShapeTest");
175  useCalibration = iConfig.getParameter<bool>("UseCalibration");
176  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
177 
178  convertFromGeV2MeV = iConfig.getParameter<bool>("convertFromGeV2MeV");
179  nothick = iConfig.getParameter<bool>("nothick");
180 
181  if (!usePixel && !useStrip)
182  throw cms::Exception("fastsim::SimplifiedGeometry::FastTrackDeDxProducer.cc")
183  << " neither pixel hits nor strips hits will be used to compute de/dx";
184 
185  if (useCalibration) {
186  tkGeomToken = esConsumes<edm::Transition::BeginRun>();
187  }
188 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken
edm::EDGetTokenT< FastTrackerRecHitRefCollection > simHit2RecHitMapToken
edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken
std::unique_ptr< BaseDeDxEstimator > m_estimator

◆ ~FastTrackDeDxProducer()

FastTrackDeDxProducer::~FastTrackDeDxProducer ( )
overridedefault

Member Function Documentation

◆ beginRun()

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

Definition at line 191 of file FastTrackDeDxProducer.cc.

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

191  {
192  if (useCalibration && calibGains.empty()) {
193  auto const& tkGeom = iSetup.getData(tkGeomToken);
194  offsetDU_ = tkGeom.offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
195 
197  }
198 
199  m_estimator->beginRun(run, iSetup);
200 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken
std::vector< std::vector< float > > calibGains
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

◆ fillDescriptions()

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

Definition at line 116 of file FastTrackDeDxProducer.cc.

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

116  {
118  desc.add<string>("estimator", "generic");
119  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
120  desc.add<bool>("UsePixel", false);
121  desc.add<bool>("UseStrip", true);
122  desc.add<double>("MeVperADCStrip", 3.61e-06 * 265);
123  desc.add<double>("MeVperADCPixel", 3.61e-06);
124  desc.add<bool>("ShapeTest", true);
125  desc.add<bool>("UseCalibration", false);
126  desc.add<string>("calibrationPath", "");
127  desc.add<string>("Record", "SiStripDeDxMip_3D_Rcd");
128  desc.add<string>("ProbabilityMode", "Accumulation");
129  desc.add<double>("fraction", 0.4);
130  desc.add<double>("exponent", -2.0);
131  desc.add<bool>("convertFromGeV2MeV", true);
132  desc.add<bool>("nothick", false);
133  desc.add<edm::InputTag>("simHits");
134  desc.add<edm::InputTag>("simHit2RecHitMap");
135  descriptions.add("FastTrackDeDxProducer", desc);
136 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ makeCalibrationMap()

void FastTrackDeDxProducer::makeCalibrationMap ( const TrackerGeometry tkGeom)
private

◆ processHit()

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

Definition at line 246 of file FastTrackDeDxProducer.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, runTheMatrix::const, convertFromGeV2MeV, nothick, rpcPointValidation_cfi::recHit, shapetest, reco::btau::trackMomentum, usePixel, and useStrip.

Referenced by produce().

250  {
251  if (!recHit.isValid())
252  return;
253 
254  auto const& thit = static_cast<BaseTrackerRecHit const&>(recHit);
255  if (!thit.isValid())
256  return;
257  if (!thit.hasPositionAndError())
258  return;
259 
260  if (recHit.isPixel()) {
261  if (!usePixel)
262  return;
263 
264  auto& detUnit = *(recHit.detUnit());
265  float pathLen = detUnit.surface().bounds().thickness() / fabs(cosine);
266  if (nothick)
267  pathLen = 1.0;
268  float charge = recHit.energyLoss() / pathLen;
269  if (convertFromGeV2MeV)
270  charge *= 1000;
271  dedxHits.push_back(DeDxHit(charge, trackMomentum, pathLen, recHit.geographicalId()));
272  } else if (!recHit.isPixel()) { // && !recHit.isMatched()){//check what recHit.isMatched is doing
273  if (!useStrip)
274  return;
275  auto& detUnit = *(recHit.detUnit());
276  float pathLen = detUnit.surface().bounds().thickness() / fabs(cosine);
277  if (nothick)
278  pathLen = 1.0;
279  float dedxOfRecHit = recHit.energyLoss() / pathLen;
280  if (convertFromGeV2MeV)
281  dedxOfRecHit *= 1000;
282  if (!shapetest) {
283  dedxHits.push_back(DeDxHit(dedxOfRecHit, trackMomentum, pathLen, recHit.geographicalId()));
284  }
285  }
286 }

◆ produce()

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

Definition at line 202 of file FastTrackDeDxProducer.cc.

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

202  {
203  auto trackDeDxEstimateAssociation = std::make_unique<ValueMap<DeDxData>>();
204  ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation);
205 
206  edm::Handle<reco::TrackCollection> trackCollectionHandle;
207  iEvent.getByToken(m_tracksTag, trackCollectionHandle);
208  const auto& trackCollection = *trackCollectionHandle;
209  std::vector<DeDxData> dedxEstimate(trackCollection.size());
210 
211  for (unsigned int j = 0; j < trackCollection.size(); j++) {
212  const reco::TrackRef track = reco::TrackRef(trackCollectionHandle.product(), j);
213 
214  int NClusterSaturating = 0;
215  DeDxHitCollection dedxHits;
216 
217  auto const& trajParams = track->extra()->trajParams();
218  assert(trajParams.size() == track->recHitsSize());
219 
220  auto hb = track->recHitsBegin();
221  dedxHits.reserve(track->recHitsSize() / 2);
222 
223  for (unsigned int h = 0; h < track->recHitsSize(); h++) {
224  const FastTrackerRecHit& recHit = static_cast<const FastTrackerRecHit&>(*(*(hb + h)));
225  if (!recHit.isValid())
226  continue; //FastTrackerRecHit recHit = *(hb+h);
227  auto trackDirection = trajParams[h].direction();
228  float cosine = trackDirection.z() / trackDirection.mag();
229  processHit(recHit, track->p(), cosine, dedxHits, NClusterSaturating);
230  }
231 
232  sort(dedxHits.begin(), dedxHits.end(), less<DeDxHit>());
233  std::pair<float, float> val_and_error = m_estimator->dedx(dedxHits);
234  //WARNING: Since the dEdX Error is not properly computed for the moment
235  //It was decided to store the number of saturating cluster in that dataformat
236  val_and_error.second = NClusterSaturating;
237  dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size());
238  }
239 
240  filler.insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
241  // fill the association map and put it into the event
242  filler.fill();
243  iEvent.put(std::move(trackDeDxEstimateAssociation));
244 }
void processHit(const FastTrackerRecHit &recHit, float trackMomentum, float &cosine, reco::DeDxHitCollection &dedxHits, int &NClusterSaturating)
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:45
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
trackCollection
Definition: JetHT_cfg.py:51
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
std::unique_ptr< BaseDeDxEstimator > m_estimator
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> > FastTrackDeDxProducer::calibGains
private

Definition at line 97 of file FastTrackDeDxProducer.cc.

Referenced by beginRun().

◆ convertFromGeV2MeV

bool FastTrackDeDxProducer::convertFromGeV2MeV
private

Definition at line 108 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

◆ m_calibrationPath

std::string FastTrackDeDxProducer::m_calibrationPath
private

Definition at line 95 of file FastTrackDeDxProducer.cc.

Referenced by beginRun(), and FastTrackDeDxProducer().

◆ m_estimator

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

Definition at line 86 of file FastTrackDeDxProducer.cc.

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

◆ m_tracksTag

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

Definition at line 88 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and produce().

◆ MaxNrStrips

unsigned int FastTrackDeDxProducer::MaxNrStrips
private

Definition at line 93 of file FastTrackDeDxProducer.cc.

◆ meVperADCPixel

float FastTrackDeDxProducer::meVperADCPixel
private

Definition at line 90 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer().

◆ meVperADCStrip

float FastTrackDeDxProducer::meVperADCStrip
private

Definition at line 91 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer().

◆ nothick

bool FastTrackDeDxProducer::nothick
private

Definition at line 109 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

◆ offsetDU_

unsigned int FastTrackDeDxProducer::offsetDU_
private

Definition at line 98 of file FastTrackDeDxProducer.cc.

Referenced by beginRun().

◆ shapetest

bool FastTrackDeDxProducer::shapetest
private

Definition at line 107 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

◆ simHit2RecHitMapToken

edm::EDGetTokenT<FastTrackerRecHitRefCollection> FastTrackDeDxProducer::simHit2RecHitMapToken
private

Definition at line 101 of file FastTrackDeDxProducer.cc.

◆ simHitsToken

edm::EDGetTokenT<edm::PSimHitContainer> FastTrackDeDxProducer::simHitsToken
private

Definition at line 100 of file FastTrackDeDxProducer.cc.

◆ tkGeomToken

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> FastTrackDeDxProducer::tkGeomToken
private

Definition at line 102 of file FastTrackDeDxProducer.cc.

Referenced by beginRun(), and FastTrackDeDxProducer().

◆ useCalibration

bool FastTrackDeDxProducer::useCalibration
private

Definition at line 106 of file FastTrackDeDxProducer.cc.

Referenced by beginRun(), and FastTrackDeDxProducer().

◆ usePixel

bool FastTrackDeDxProducer::usePixel
private

Definition at line 104 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

◆ useStrip

bool FastTrackDeDxProducer::useStrip
private

Definition at line 105 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().