CMS 3D CMS Logo

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

#include <RecoTracker/DeDx/plugins/DeDxHitInfoProducer.cc>

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

Public Member Functions

 DeDxHitInfoProducer (const edm::ParameterSet &)
 
 ~DeDxHitInfoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void beginRun (edm::Run const &run, const edm::EventSetup &) override
 
void makeCalibrationMap (const TrackerGeometry &tkGeom)
 
void processHit (const TrackingRecHit *recHit, const float trackMomentum, const float cosine, reco::DeDxHitInfo &hitDeDxInfo, const LocalPoint &hitLocalPos)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
uint64_t xorshift128p (uint64_t state[2])
 

Private Attributes

std::vector< std::vector< float > > calibGains
 
const float lowPtTracksDeDxThreshold
 
GenericTruncatedAverageDeDxEstimator lowPtTracksEstimator
 
const unsigned int lowPtTracksPrescaleFail
 
const unsigned int lowPtTracksPrescalePass
 
const std::string m_calibrationPath
 
unsigned int m_off
 
edm::EDGetTokenT< reco::TrackCollectionm_tracksTag
 
const float maxTrackEta
 
const float MeVperADCPixel
 
const float MeVperADCStrip
 
const unsigned int minTrackHits
 
const float minTrackPt
 
const float minTrackPtPrescale
 
const bool shapetest
 
edm::ESHandle< TrackerGeometrytkGeom
 
const bool useCalibration
 
const bool usePixel
 
const 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 34 of file DeDxHitInfoProducer.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file DeDxHitInfoProducer.cc.

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

27  :
28  usePixel ( iConfig.getParameter<bool> ("usePixel") ),
29  useStrip ( iConfig.getParameter<bool> ("useStrip") ),
30  MeVperADCPixel ( iConfig.getParameter<double> ("MeVperADCPixel") ),
31  MeVperADCStrip ( iConfig.getParameter<double> ("MeVperADCStrip") ),
32  minTrackHits ( iConfig.getParameter<unsigned>("minTrackHits") ),
33  minTrackPt ( iConfig.getParameter<double> ("minTrackPt" ) ),
34  minTrackPtPrescale( iConfig.getParameter<double> ("minTrackPtPrescale") ),
35  maxTrackEta ( iConfig.getParameter<double> ("maxTrackEta" ) ),
36  m_calibrationPath ( iConfig.getParameter<string> ("calibrationPath")),
37  useCalibration ( iConfig.getParameter<bool> ("useCalibration") ),
38  shapetest ( iConfig.getParameter<bool> ("shapeTest") ),
39  lowPtTracksPrescalePass( iConfig.getParameter<uint32_t>("lowPtTracksPrescalePass") ),
40  lowPtTracksPrescaleFail( iConfig.getParameter<uint32_t>("lowPtTracksPrescaleFail") ),
41  lowPtTracksEstimator(iConfig.getParameter<edm::ParameterSet>("lowPtTracksEstimatorParameters")),
42  lowPtTracksDeDxThreshold(iConfig.getParameter<double>("lowPtTracksDeDxThreshold"))
43 {
44  produces<reco::DeDxHitInfoCollection >();
45  produces<reco::DeDxHitInfoAss >();
46  produces<edm::ValueMap<int> >("prescale");
47 
48  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
49 
50  if(!usePixel && !useStrip)
51  edm::LogError("DeDxHitsProducer") << "No Pixel Hits NOR Strip Hits will be saved. Running this module is useless";
52 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
GenericTruncatedAverageDeDxEstimator lowPtTracksEstimator
const unsigned int lowPtTracksPrescalePass
const float lowPtTracksDeDxThreshold
const std::string m_calibrationPath
const unsigned int minTrackHits
const unsigned int lowPtTracksPrescaleFail
const float minTrackPtPrescale
DeDxHitInfoProducer::~DeDxHitInfoProducer ( )
override

Definition at line 55 of file DeDxHitInfoProducer.cc.

55 {}

Member Function Documentation

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

Definition at line 58 of file DeDxHitInfoProducer.cc.

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

59 {
60  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
61  if(useCalibration && calibGains.empty()){
62  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
63 
65  }
66 }
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)
Definition: DeDxTools.cc:196
const std::string m_calibrationPath
unsigned int offsetDU(SubDetector sid) const
T get() const
Definition: EventSetup.h:62
edm::ESHandle< TrackerGeometry > tkGeom
void DeDxHitInfoProducer::makeCalibrationMap ( const TrackerGeometry tkGeom)
private
void DeDxHitInfoProducer::processHit ( const TrackingRecHit recHit,
const float  trackMomentum,
const float  cosine,
reco::DeDxHitInfo hitDeDxInfo,
const LocalPoint hitLocalPos 
)
private

Definition at line 165 of file DeDxHitInfoProducer.cc.

References funct::abs(), reco::DeDxHitInfo::addHit(), Surface::bounds(), calibGains, DEFINE_FWK_MODULE, TrackerSingleRecHit::detUnit(), TrackingRecHit::detUnit(), f, TrackingRecHit::geographicalId(), DeDxTools::getCharge(), TrackerGeometry::idToDet(), m_off, SiStripPI::max, SiStripMatchedRecHit2D::monoHit(), rpcPointValidation_cfi::recHit, SiStripMatchedRecHit2D::stereoHit(), TrackerSingleRecHit::stripCluster(), GeomDet::surface(), Bounds::thickness(), tkGeom, usePixel, and useStrip.

Referenced by produce().

165  {
166  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
167  if(!thit.isValid())return;
168 
169  float cosineAbs = std::max(0.00000001f,std::abs(cosine));//make sure cosine is not 0
170 
171  auto const & clus = thit.firstClusterRef();
172  if(!clus.isValid())return;
173 
174 
175  if(clus.isPixel()){
176  if(!usePixel) return;
177 
178  const auto * detUnit = recHit->detUnit();
179  if (detUnit == nullptr) detUnit = tkGeom->idToDet(thit.geographicalId());
180  float pathLen = detUnit->surface().bounds().thickness()/cosineAbs;
181  float chargeAbs = clus.pixelCluster().charge();
182  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, clus.pixelCluster() );
183  }else if(clus.isStrip() && !thit.isMatched()){
184  if(!useStrip) return;
185 
186  const auto * detUnit = recHit->detUnit();
187  if (detUnit == nullptr) detUnit = tkGeom->idToDet(thit.geographicalId());
188  int NSaturating = 0;
189  float pathLen = detUnit->surface().bounds().thickness()/cosineAbs;
190  float chargeAbs = DeDxTools::getCharge(&(clus.stripCluster()),NSaturating, *detUnit, calibGains, m_off);
191  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, clus.stripCluster() );
192  }else if(clus.isStrip() && thit.isMatched()){
193  if(!useStrip) return;
194  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
195  if(!matchedHit)return;
196 
197  const auto * detUnitM = matchedHit->monoHit().detUnit();
198  if (detUnitM == nullptr) detUnitM = tkGeom->idToDet(matchedHit->monoHit().geographicalId());
199  int NSaturating = 0;
200  float pathLen = detUnitM->surface().bounds().thickness()/cosineAbs;
201  float chargeAbs = DeDxTools::getCharge(&(matchedHit->monoHit().stripCluster()),NSaturating, *detUnitM, calibGains, m_off);
202  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, matchedHit->monoHit().stripCluster() );
203 
204  const auto * detUnitS = matchedHit->stereoHit().detUnit();
205  if (detUnitS == nullptr) detUnitS = tkGeom->idToDet(matchedHit->stereoHit().geographicalId());
206  NSaturating = 0;
207  pathLen = detUnitS->surface().bounds().thickness()/cosineAbs;
208  chargeAbs = DeDxTools::getCharge(&(matchedHit->stereoHit().stripCluster()),NSaturating, *detUnitS, calibGains, m_off);
209  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, matchedHit->stereoHit().stripCluster() );
210  }
211 }
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:161
std::vector< std::vector< float > > calibGains
const Bounds & bounds() const
Definition: Surface.h:120
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
void addHit(const float charge, const float pathlength, const DetId &detId, const LocalPoint &pos, const SiStripCluster &stripCluster)
Definition: DeDxHitInfo.h:83
SiStripRecHit2D stereoHit() const
virtual float thickness() const =0
SiStripCluster const & stripCluster() const
const GeomDetUnit * detUnit() const override
SiStripRecHit2D monoHit() const
virtual const GeomDetUnit * detUnit() const
const TrackerGeomDet * idToDet(DetId) const override
DetId geographicalId() const
edm::ESHandle< TrackerGeometry > tkGeom
void DeDxHitInfoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 70 of file DeDxHitInfoProducer.cc.

References funct::abs(), reco::DeDxHitInfo::charge(), GenericTruncatedAverageDeDxEstimator::dedx(), reco::DeDxHitInfo::detId(), reco::TrackBase::eta(), edm::EventID::event(), reco::Track::extra(), objects.autophobj::filler, edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, hfClusterShapes_cfi::hits, mps_fire::i, edm::EventBase::id(), lowPtTracksDeDxThreshold, lowPtTracksEstimator, lowPtTracksPrescaleFail, lowPtTracksPrescalePass, edm::EventID::luminosityBlock(), m_tracksTag, maxTrackEta, MeVperADCPixel, MeVperADCStrip, minTrackHits, minTrackPt, minTrackPtPrescale, eostools::move(), gen::n, reco::TrackBase::numberOfValidHits(), reco::TrackBase::p(), reco::DeDxHitInfo::pathlength(), processHit(), edm::Handle< T >::product(), reco::TrackBase::pt(), edm::Event::put(), rpcPointValidation_cfi::recHit, reco::Track::recHitsBegin(), reco::Track::recHitsSize(), DeDxTools::shapeSelection(), shapetest, reco::DeDxHitInfo::size(), reco::DeDxHitInfo::stripCluster(), DetId::subdetId(), HiIsolationCommonParameters_cff::track, findElectronsInSiStrips_cfi::trackCollection, and xorshift128p().

71 {
72  edm::Handle<reco::TrackCollection> trackCollectionHandle;
73  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
74  const TrackCollection& trackCollection(*trackCollectionHandle.product());
75 
76  // creates the output collection
77  auto resultdedxHitColl = std::make_unique<reco::DeDxHitInfoCollection>();
78 
79  std::vector<int> indices; std::vector<int> prescales;
80  uint64_t state[2] = { iEvent.id().event(), iEvent.id().luminosityBlock() };
81  for(unsigned int j=0;j<trackCollection.size();j++){
82  const reco::Track& track = trackCollection[j];
83 
84  //track selection
85  bool passPt = (track.pt() >= minTrackPt), passLowDeDx = false, passHighDeDx = false, pass = passPt;
86  if (!pass && (track.pt() >= minTrackPtPrescale)) {
87  if (lowPtTracksPrescalePass > 0) {
88  passHighDeDx = ((xorshift128p(state) % lowPtTracksPrescalePass) == 0);
89  }
90  if (lowPtTracksPrescaleFail > 0) {
91  passLowDeDx = ((xorshift128p(state) % lowPtTracksPrescaleFail) == 0);
92  }
93  pass = passHighDeDx || passLowDeDx;
94  }
95  if(!pass || std::abs(track.eta())>maxTrackEta ||track.numberOfValidHits()<minTrackHits){
96  indices.push_back(-1);
97  continue;
98  }
99 
100  reco::DeDxHitInfo hitDeDxInfo;
101  auto const & trajParams = track.extra()->trajParams();
102  auto hb = track.recHitsBegin();
103  for(unsigned int h=0;h<track.recHitsSize();h++){
104  auto recHit = *(hb+h);
105  if(!recHit->isValid()) continue;
106 
107  auto trackDirection = trajParams[h].direction();
108  float cosine = trackDirection.z()/trackDirection.mag();
109 
110  processHit(recHit, track.p(), cosine, hitDeDxInfo, trajParams[h].position());
111  }
112 
113  if (!passPt) {
114  std::vector<DeDxHit> hits; hits.reserve(hitDeDxInfo.size());
115  for (unsigned int i = 0, n = hitDeDxInfo.size(); i < n; ++i) {
116  if (hitDeDxInfo.detId(i).subdetId() <= 2) {
117  hits.push_back( DeDxHit(hitDeDxInfo.charge(i)/hitDeDxInfo.pathlength(i) * MeVperADCPixel, 0,0,0) );
118  } else {
119  if (shapetest && !DeDxTools::shapeSelection(*hitDeDxInfo.stripCluster(i))) continue;
120  hits.push_back( DeDxHit(hitDeDxInfo.charge(i)/hitDeDxInfo.pathlength(i) * MeVperADCStrip, 0,0,0) );
121  }
122  }
123  std::sort(hits.begin(), hits.end(), std::less<DeDxHit>());
125  if (passLowDeDx) {
126  prescales.push_back(lowPtTracksPrescaleFail);
127  } else {
128  indices.push_back(-1);
129  continue;
130  }
131  } else {
132  if (passHighDeDx) {
133  prescales.push_back(lowPtTracksPrescalePass);
134  } else {
135  indices.push_back(-1);
136  continue;
137  }
138 
139  }
140  } else {
141  prescales.push_back(1);
142  }
143  indices.push_back(resultdedxHitColl->size());
144  resultdedxHitColl->push_back(hitDeDxInfo);
145  }
147 
148 
149  edm::OrphanHandle<reco::DeDxHitInfoCollection> dedxHitCollHandle = iEvent.put(std::move(resultdedxHitColl));
150 
151  //create map passing the handle to the matched collection
152  auto dedxMatch = std::make_unique<reco::DeDxHitInfoAss>(dedxHitCollHandle);
154  filler.insert(trackCollectionHandle, indices.begin(), indices.end());
155  filler.fill();
156  iEvent.put(std::move(dedxMatch));
157 
158  auto dedxPrescale = std::make_unique<edm::ValueMap<int>>();
159  edm::ValueMap<int>::Filler pfiller(*dedxPrescale);
160  pfiller.insert(dedxHitCollHandle, prescales.begin(), prescales.end());
161  pfiller.fill();
162  iEvent.put(std::move(dedxPrescale), "prescale");
163 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:189
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
GenericTruncatedAverageDeDxEstimator lowPtTracksEstimator
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
const unsigned int lowPtTracksPrescalePass
const float lowPtTracksDeDxThreshold
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
bool shapeSelection(const SiStripCluster &ampls)
Definition: DeDxTools.cc:10
void processHit(const TrackingRecHit *recHit, const float trackMomentum, const float cosine, reco::DeDxHitInfo &hitDeDxInfo, const LocalPoint &hitLocalPos)
double pt() const
track transverse momentum
Definition: TrackBase.h:621
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:820
const unsigned int minTrackHits
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
const unsigned int lowPtTracksPrescaleFail
uint64_t xorshift128p(uint64_t state[2])
T const * product() const
Definition: Handle.h:81
unsigned long long uint64_t
Definition: Time.h:15
std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits) override
edm::EventID id() const
Definition: EventBase.h:60
def move(src, dest)
Definition: eostools.py:511
const float minTrackPtPrescale
uint64_t DeDxHitInfoProducer::xorshift128p ( uint64_t  state[2])
inlineprivate

Definition at line 73 of file DeDxHitInfoProducer.h.

References x, and y.

Referenced by produce().

73  {
74  uint64_t x = state[0];
75  uint64_t const y = state[1];
76  state[0] = y;
77  x ^= x << 23; // a
78  state[1] = x ^ y ^ (x >> 17) ^ (y >> 26); // b, c
79  return state[1] + y;
80  }
unsigned long long uint64_t
Definition: Time.h:15

Member Data Documentation

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

Definition at line 68 of file DeDxHitInfoProducer.h.

Referenced by beginRun(), and processHit().

const float DeDxHitInfoProducer::lowPtTracksDeDxThreshold
private

Definition at line 66 of file DeDxHitInfoProducer.h.

Referenced by produce().

GenericTruncatedAverageDeDxEstimator DeDxHitInfoProducer::lowPtTracksEstimator
private

Definition at line 65 of file DeDxHitInfoProducer.h.

Referenced by produce().

const unsigned int DeDxHitInfoProducer::lowPtTracksPrescaleFail
private

Definition at line 64 of file DeDxHitInfoProducer.h.

Referenced by produce().

const unsigned int DeDxHitInfoProducer::lowPtTracksPrescalePass
private

Definition at line 64 of file DeDxHitInfoProducer.h.

Referenced by produce().

const std::string DeDxHitInfoProducer::m_calibrationPath
private

Definition at line 60 of file DeDxHitInfoProducer.h.

Referenced by beginRun().

unsigned int DeDxHitInfoProducer::m_off
private

Definition at line 69 of file DeDxHitInfoProducer.h.

Referenced by beginRun(), and processHit().

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

Definition at line 48 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and produce().

const float DeDxHitInfoProducer::maxTrackEta
private

Definition at line 58 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::MeVperADCPixel
private

Definition at line 52 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::MeVperADCStrip
private

Definition at line 53 of file DeDxHitInfoProducer.h.

Referenced by produce().

const unsigned int DeDxHitInfoProducer::minTrackHits
private

Definition at line 55 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::minTrackPt
private

Definition at line 56 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::minTrackPtPrescale
private

Definition at line 57 of file DeDxHitInfoProducer.h.

Referenced by produce().

const bool DeDxHitInfoProducer::shapetest
private

Definition at line 62 of file DeDxHitInfoProducer.h.

Referenced by produce().

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

Definition at line 71 of file DeDxHitInfoProducer.h.

Referenced by beginRun(), and processHit().

const bool DeDxHitInfoProducer::useCalibration
private

Definition at line 61 of file DeDxHitInfoProducer.h.

Referenced by beginRun().

const bool DeDxHitInfoProducer::usePixel
private

Definition at line 50 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and processHit().

const bool DeDxHitInfoProducer::useStrip
private

Definition at line 51 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and processHit().