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
 
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 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
 
unsigned int m_off
 
edm::EDGetTokenT< reco::TrackCollectionm_tracksTag
 
unsigned int MaxNrStrips
 
float meVperADCPixel
 
float meVperADCStrip
 
bool nothick
 
bool shapetest
 
edm::EDGetTokenT< FastTrackerRecHitRefCollectionsimHit2RecHitMapToken
 
edm::EDGetTokenT< edm::PSimHitContainersimHitsToken
 
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 66 of file FastTrackDeDxProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 137 of file FastTrackDeDxProducer.cc.

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

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

Member Function Documentation

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

Definition at line 185 of file FastTrackDeDxProducer.cc.

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

185  {
186  if (useCalibration && calibGains.empty()) {
188  iSetup.get<TrackerDigiGeometryRecord>().get(tkGeom);
189  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
190 
192  }
193 
194  m_estimator->beginRun(run, iSetup);
195 }
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
std::vector< std::vector< float > > calibGains
unsigned int offsetDU(SubDetector sid) const
T get() const
Definition: EventSetup.h:73
std::unique_ptr< BaseDeDxEstimator > m_estimator
void FastTrackDeDxProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 115 of file FastTrackDeDxProducer.cc.

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

115  {
117  desc.add<string>("estimator", "generic");
118  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
119  desc.add<bool>("UsePixel", false);
120  desc.add<bool>("UseStrip", true);
121  desc.add<double>("MeVperADCStrip", 3.61e-06 * 265);
122  desc.add<double>("MeVperADCPixel", 3.61e-06);
123  desc.add<bool>("ShapeTest", true);
124  desc.add<bool>("UseCalibration", false);
125  desc.add<string>("calibrationPath", "");
126  desc.add<string>("Reccord", "SiStripDeDxMip_3D_Rcd");
127  desc.add<string>("ProbabilityMode", "Accumulation");
128  desc.add<double>("fraction", 0.4);
129  desc.add<double>("exponent", -2.0);
130  desc.add<bool>("convertFromGeV2MeV", true);
131  desc.add<bool>("nothick", false);
132  desc.add<edm::InputTag>("simHits");
133  desc.add<edm::InputTag>("simHit2RecHitMap");
134  descriptions.add("FastTrackDeDxProducer", desc);
135 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void FastTrackDeDxProducer::makeCalibrationMap ( const TrackerGeometry tkGeom)
private
void FastTrackDeDxProducer::processHit ( const FastTrackerRecHit recHit,
float  trackMomentum,
float &  cosine,
reco::DeDxHitCollection dedxHits,
int &  NClusterSaturating 
)
private

Definition at line 241 of file FastTrackDeDxProducer.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, watchdog::const, convertFromGeV2MeV, DEFINE_FWK_MODULE, TrackingRecHit::detUnit(), FastTrackerRecHit::energyLoss(), TrackingRecHit::geographicalId(), FastTrackerRecHit::isPixel(), TrackingRecHit::isValid(), nothick, rpcPointValidation_cfi::recHit, shapetest, usePixel, and useStrip.

Referenced by produce().

245  {
246  if (!recHit.isValid())
247  return;
248 
249  auto const& thit = static_cast<BaseTrackerRecHit const&>(recHit);
250  if (!thit.isValid())
251  return;
252  if (!thit.hasPositionAndError())
253  return;
254 
255  if (recHit.isPixel()) {
256  if (!usePixel)
257  return;
258 
259  auto& detUnit = *(recHit.detUnit());
260  float pathLen = detUnit.surface().bounds().thickness() / fabs(cosine);
261  if (nothick)
262  pathLen = 1.0;
263  float charge = recHit.energyLoss() / pathLen;
264  if (convertFromGeV2MeV)
265  charge *= 1000;
266  dedxHits.push_back(DeDxHit(charge, trackMomentum, pathLen, recHit.geographicalId()));
267  } else if (!recHit.isPixel()) { // && !recHit.isMatched()){//check what recHit.isMatched is doing
268  if (!useStrip)
269  return;
270  auto& detUnit = *(recHit.detUnit());
271  float pathLen = detUnit.surface().bounds().thickness() / fabs(cosine);
272  if (nothick)
273  pathLen = 1.0;
274  float dedxOfRecHit = recHit.energyLoss() / pathLen;
275  if (convertFromGeV2MeV)
276  dedxOfRecHit *= 1000;
277  if (!shapetest) {
278  dedxHits.push_back(DeDxHit(dedxOfRecHit, trackMomentum, pathLen, recHit.geographicalId()));
279  }
280  }
281 }
float energyLoss() const
bool isValid() const
bool isPixel() const override
pixel or strip?
virtual const GeomDetUnit * detUnit() const
DetId geographicalId() const
void FastTrackDeDxProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 197 of file FastTrackDeDxProducer.cc.

References trigObjTnPSource_cfi::filler, edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, TrackingRecHit::isValid(), dqmiolumiharvest::j, m_estimator, m_tracksTag, eostools::move(), processHit(), edm::Handle< T >::product(), edm::Event::put(), rpcPointValidation_cfi::recHit, HLT_2018_cff::track, and duplicaterechits_cfi::trackCollection.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

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

Definition at line 97 of file FastTrackDeDxProducer.cc.

Referenced by beginRun().

bool FastTrackDeDxProducer::convertFromGeV2MeV
private

Definition at line 107 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

std::string FastTrackDeDxProducer::m_calibrationPath
private

Definition at line 95 of file FastTrackDeDxProducer.cc.

Referenced by beginRun(), and FastTrackDeDxProducer().

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

Definition at line 86 of file FastTrackDeDxProducer.cc.

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

unsigned int FastTrackDeDxProducer::m_off
private

Definition at line 98 of file FastTrackDeDxProducer.cc.

Referenced by beginRun().

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

Definition at line 88 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and produce().

unsigned int FastTrackDeDxProducer::MaxNrStrips
private

Definition at line 93 of file FastTrackDeDxProducer.cc.

float FastTrackDeDxProducer::meVperADCPixel
private

Definition at line 90 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer().

float FastTrackDeDxProducer::meVperADCStrip
private

Definition at line 91 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer().

bool FastTrackDeDxProducer::nothick
private

Definition at line 108 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

bool FastTrackDeDxProducer::shapetest
private

Definition at line 106 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

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

Definition at line 101 of file FastTrackDeDxProducer.cc.

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

Definition at line 100 of file FastTrackDeDxProducer.cc.

bool FastTrackDeDxProducer::useCalibration
private

Definition at line 105 of file FastTrackDeDxProducer.cc.

Referenced by beginRun(), and FastTrackDeDxProducer().

bool FastTrackDeDxProducer::usePixel
private

Definition at line 103 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().

bool FastTrackDeDxProducer::useStrip
private

Definition at line 104 of file FastTrackDeDxProducer.cc.

Referenced by FastTrackDeDxProducer(), and processHit().