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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DeDxHitInfoProducer (const edm::ParameterSet &)
 
 ~DeDxHitInfoProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual 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)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< std::vector< float > > calibGains
 
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 bool shapetest
 
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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 33 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  maxTrackEta ( iConfig.getParameter<double> ("maxTrackEta" ) ),
35  m_calibrationPath ( iConfig.getParameter<string> ("calibrationPath")),
36  useCalibration ( iConfig.getParameter<bool> ("useCalibration") ),
37  shapetest ( iConfig.getParameter<bool> ("shapeTest") )
38 {
39  produces<reco::DeDxHitInfoCollection >();
40  produces<reco::DeDxHitInfoAss >();
41 
42  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
43 
44  if(!usePixel && !useStrip)
45  edm::LogError("DeDxHitsProducer") << "No Pixel Hits NOR Strip Hits will be saved. Running this module is useless";
46 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
const std::string m_calibrationPath
const unsigned int minTrackHits
DeDxHitInfoProducer::~DeDxHitInfoProducer ( )

Definition at line 49 of file DeDxHitInfoProducer.cc.

49 {}

Member Function Documentation

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

Definition at line 52 of file DeDxHitInfoProducer.cc.

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

53 {
54  if(useCalibration && calibGains.size()==0){
56  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
57  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
58 
60  }
61 }
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
const T & get() const
Definition: EventSetup.h:56
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 114 of file DeDxHitInfoProducer.cc.

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

Referenced by produce().

114  {
115  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
116  if(!thit.isValid())return;
117 
118  float cosineAbs = std::max(0.00000001f,std::abs(cosine));//make sure cosine is not 0
119 
120  auto const & clus = thit.firstClusterRef();
121  if(!clus.isValid())return;
122 
123  if(clus.isPixel()){
124  if(!usePixel) return;
125 
126  auto& detUnit = *(recHit->detUnit());
127  float pathLen = detUnit.surface().bounds().thickness()/cosineAbs;
128  float chargeAbs = clus.pixelCluster().charge();
129  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, clus.pixelCluster() );
130  }else if(clus.isStrip() && !thit.isMatched()){
131  if(!useStrip) return;
132 
133  auto& detUnit = *(recHit->detUnit());
134  int NSaturating = 0;
135  float pathLen = detUnit.surface().bounds().thickness()/cosineAbs;
136  float chargeAbs = DeDxTools::getCharge(&(clus.stripCluster()),NSaturating, detUnit, calibGains, m_off);
137  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, clus.stripCluster() );
138  }else if(clus.isStrip() && thit.isMatched()){
139  if(!useStrip) return;
140  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
141  if(!matchedHit)return;
142 
143  auto& detUnitM = *(matchedHit->monoHit().detUnit());
144  int NSaturating = 0;
145  float pathLen = detUnitM.surface().bounds().thickness()/cosineAbs;
146  float chargeAbs = DeDxTools::getCharge(&(matchedHit->monoHit().stripCluster()),NSaturating, detUnitM, calibGains, m_off);
147  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, matchedHit->monoHit().stripCluster() );
148 
149  auto& detUnitS = *(matchedHit->stereoHit().detUnit());
150  NSaturating = 0;
151  pathLen = detUnitS.surface().bounds().thickness()/cosineAbs;
152  chargeAbs = DeDxTools::getCharge(&(matchedHit->stereoHit().stripCluster()),NSaturating, detUnitS, calibGains, m_off);
153  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, matchedHit->stereoHit().stripCluster() );
154  }
155 }
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
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:82
const GeomDetUnit * detUnit() const
SiStripRecHit2D stereoHit() const
virtual float thickness() const =0
SiStripCluster const & stripCluster() const
SiStripRecHit2D monoHit() const
virtual const GeomDetUnit * detUnit() const
virtual const Surface * surface() const final
void DeDxHitInfoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 65 of file DeDxHitInfoProducer.cc.

References funct::abs(), reco::TrackBase::eta(), reco::Track::extra(), objects.autophobj::filler, edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, m_tracksTag, maxTrackEta, minTrackHits, minTrackPt, eostools::move(), reco::TrackBase::numberOfValidHits(), reco::TrackBase::p(), processHit(), edm::Handle< T >::product(), reco::TrackBase::pt(), edm::Event::put(), rpcPointValidation_cfi::recHit, reco::Track::recHitsBegin(), reco::Track::recHitsSize(), HiIsolationCommonParameters_cff::track, and findElectronsInSiStrips_cfi::trackCollection.

66 {
67  edm::Handle<reco::TrackCollection> trackCollectionHandle;
68  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
69  const TrackCollection& trackCollection(*trackCollectionHandle.product());
70 
71  // creates the output collection
72  auto resultdedxHitColl = std::make_unique<reco::DeDxHitInfoCollection>();
73 
74  std::vector<int> indices;
75 
76  for(unsigned int j=0;j<trackCollection.size();j++){
77  const reco::Track& track = trackCollection[j];
78 
79  //track selection
80  if(track.pt()<minTrackPt || std::abs(track.eta())>maxTrackEta ||track.numberOfValidHits()<minTrackHits){
81  indices.push_back(-1);
82  continue;
83  }
84 
85  reco::DeDxHitInfo hitDeDxInfo;
86  auto const & trajParams = track.extra()->trajParams();
87  auto hb = track.recHitsBegin();
88  for(unsigned int h=0;h<track.recHitsSize();h++){
89  auto recHit = *(hb+h);
90  if(!recHit->isValid()) continue;
91 
92  auto trackDirection = trajParams[h].direction();
93  float cosine = trackDirection.z()/trackDirection.mag();
94 
95  processHit(recHit, track.p(), cosine, hitDeDxInfo, trajParams[h].position());
96  }
97 
98  indices.push_back(resultdedxHitColl->size());
99  resultdedxHitColl->push_back(hitDeDxInfo);
100  }
102 
103 
104  edm::OrphanHandle<reco::DeDxHitInfoCollection> dedxHitCollHandle = iEvent.put(std::move(resultdedxHitColl));
105 
106  //create map passing the handle to the matched collection
107  auto dedxMatch = std::make_unique<reco::DeDxHitInfoAss>(dedxHitCollHandle);
109  filler.insert(trackCollectionHandle, indices.begin(), indices.end());
110  filler.fill();
111  iEvent.put(std::move(dedxMatch));
112 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:610
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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:457
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
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:616
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:815
const unsigned int minTrackHits
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
T const * product() const
Definition: Handle.h:81
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 62 of file DeDxHitInfoProducer.h.

Referenced by beginRun(), and processHit().

const std::string DeDxHitInfoProducer::m_calibrationPath
private

Definition at line 58 of file DeDxHitInfoProducer.h.

Referenced by beginRun().

unsigned int DeDxHitInfoProducer::m_off
private

Definition at line 63 of file DeDxHitInfoProducer.h.

Referenced by beginRun(), and processHit().

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

Definition at line 47 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and produce().

const float DeDxHitInfoProducer::maxTrackEta
private

Definition at line 56 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::MeVperADCPixel
private

Definition at line 51 of file DeDxHitInfoProducer.h.

const float DeDxHitInfoProducer::MeVperADCStrip
private

Definition at line 52 of file DeDxHitInfoProducer.h.

const unsigned int DeDxHitInfoProducer::minTrackHits
private

Definition at line 54 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::minTrackPt
private

Definition at line 55 of file DeDxHitInfoProducer.h.

Referenced by produce().

const bool DeDxHitInfoProducer::shapetest
private

Definition at line 60 of file DeDxHitInfoProducer.h.

const bool DeDxHitInfoProducer::useCalibration
private

Definition at line 59 of file DeDxHitInfoProducer.h.

Referenced by beginRun().

const bool DeDxHitInfoProducer::usePixel
private

Definition at line 49 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and processHit().

const bool DeDxHitInfoProducer::useStrip
private

Definition at line 50 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and processHit().