CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::TrackCollection
m_tracksTag
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
m_trajTrackAssociationTag
 
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
 
const bool useTrajectory
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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, m_trajTrackAssociationTag, usePixel, and useStrip.

27  :
28  useTrajectory ( iConfig.getParameter<bool> ("useTrajectory") ),
29  usePixel ( iConfig.getParameter<bool> ("usePixel") ),
30  useStrip ( iConfig.getParameter<bool> ("useStrip") ),
31  MeVperADCPixel ( iConfig.getParameter<double> ("MeVperADCPixel") ),
32  MeVperADCStrip ( iConfig.getParameter<double> ("MeVperADCStrip") ),
33  minTrackHits ( iConfig.getParameter<unsigned>("minTrackHits") ),
34  minTrackPt ( iConfig.getParameter<double> ("minTrackPt" ) ),
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 {
40  produces<reco::DeDxHitInfoCollection >();
41  produces<reco::DeDxHitInfoAss >();
42 
43  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
44  m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"));
45 
46  if(!usePixel && !useStrip)
47  edm::LogError("DeDxHitsProducer") << "No Pixel Hits NOR Strip Hits will be saved. Running this module is useless";
48 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
const std::string m_calibrationPath
const unsigned int minTrackHits
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
DeDxHitInfoProducer::~DeDxHitInfoProducer ( )

Definition at line 51 of file DeDxHitInfoProducer.cc.

51 {}

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 54 of file DeDxHitInfoProducer.cc.

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

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

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

Referenced by produce().

139  {
140  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
141  if(!thit.isValid())return;
142 
143  float cosineAbs = std::max(0.00000001f,std::abs(cosine));//make sure cosine is not 0
144 
145  auto const & clus = thit.firstClusterRef();
146  if(!clus.isValid())return;
147 
148  if(clus.isPixel()){
149  if(!usePixel) return;
150 
151  auto& detUnit = *(recHit->detUnit());
152  float pathLen = detUnit.surface().bounds().thickness()/cosineAbs;
153  float chargeAbs = clus.pixelCluster().charge();
154  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, clus.pixelCluster() );
155  }else if(clus.isStrip() && !thit.isMatched()){
156  if(!useStrip) return;
157 
158  auto& detUnit = *(recHit->detUnit());
159  int NSaturating = 0;
160  float pathLen = detUnit.surface().bounds().thickness()/cosineAbs;
161  float chargeAbs = DeDxTools::getCharge(&(clus.stripCluster()),NSaturating, detUnit, calibGains, m_off);
162  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, clus.stripCluster() );
163  }else if(clus.isStrip() && thit.isMatched()){
164  if(!useStrip) return;
165  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
166  if(!matchedHit)return;
167 
168  auto& detUnitM = *(matchedHit->monoHit().detUnit());
169  int NSaturating = 0;
170  float pathLen = detUnitM.surface().bounds().thickness()/cosineAbs;
171  float chargeAbs = DeDxTools::getCharge(&(matchedHit->monoHit().stripCluster()),NSaturating, detUnitM, calibGains, m_off);
172  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, matchedHit->monoHit().stripCluster() );
173 
174  auto& detUnitS = *(matchedHit->stereoHit().detUnit());
175  NSaturating = 0;
176  pathLen = detUnitS.surface().bounds().thickness()/cosineAbs;
177  chargeAbs = DeDxTools::getCharge(&(matchedHit->stereoHit().stripCluster()),NSaturating, detUnitS, calibGains, m_off);
178  hitDeDxInfo.addHit(chargeAbs, pathLen, thit.geographicalId(), hitLocalPos, matchedHit->stereoHit().stripCluster() );
179  }
180 }
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:128
virtual float thickness() const =0
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
SiStripCluster const & stripCluster() const
string const
Definition: compareJSON.py:14
SiStripRecHit2D monoHit() const
virtual const GeomDetUnit * detUnit() const
virtual const Surface * surface() const
void DeDxHitInfoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 67 of file DeDxHitInfoProducer.cc.

References funct::abs(), compareJSON::const, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, TrackingRecHit::detUnit(), reco::TrackBase::eta(), edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), h, edm::helper::Filler< Map >::insert(), TrajectoryStateOnSurface::isValid(), j, edm::Ref< C, T, F >::key(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localMomentum(), TrajectoryStateOnSurface::localPosition(), m_tracksTag, m_trajTrackAssociationTag, PV3DBase< T, PVType, FrameType >::mag(), maxTrackEta, minTrackHits, minTrackPt, Plane::normalVector(), reco::TrackBase::numberOfValidHits(), reco::TrackBase::p(), processHit(), edm::Handle< T >::product(), reco::TrackBase::pt(), edm::Event::put(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), reco::Track::recHit(), reco::Track::recHitsSize(), GeomDet::surface(), HLT_25ns14e33_v3_cff::trackCollection, useTrajectory, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

68 {
69  edm::Handle<reco::TrackCollection> trackCollectionHandle;
70  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
71  const TrackCollection& trackCollection(*trackCollectionHandle.product());
72 
73  Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
74  if(useTrajectory)iEvent.getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
75 
76  // creates the output collection
77  std::auto_ptr<reco::DeDxHitInfoCollection> resultdedxHitColl(new reco::DeDxHitInfoCollection);
78 
79  std::vector<int> indices;
80 
82  if(useTrajectory)cit = trajTrackAssociationHandle->begin();
83  for(unsigned int j=0;j<trackCollection.size();j++){
84  const reco::Track& track = trackCollection[j];
85 
86  //track selection
87  if(track.pt()<minTrackPt || std::abs(track.eta())>maxTrackEta ||track.numberOfValidHits()<minTrackHits){
88  cit++;
89  indices.push_back(-1);
90  continue;
91  }
92 
93  reco::DeDxHitInfo hitDeDxInfo;
94 
95  if(useTrajectory){ //trajectory allows to take into account the local direction of the particle on the module sensor --> muc much better 'dx' measurement
96  const edm::Ref<std::vector<Trajectory> > traj = cit->key; cit++;
97  const vector<TrajectoryMeasurement> & measurements = traj->measurements();
98  for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
99  const TrajectoryStateOnSurface& trajState=it->updatedState();
100  if( !trajState.isValid()) continue;
101 
102  const TrackingRecHit* recHit=(*it->recHit()).hit();
103  if(!recHit)continue;
104  const LocalVector& trackDirection = trajState.localDirection();
105  float cosine = trackDirection.z()/trackDirection.mag();
106 
107  processHit(recHit, trajState.localMomentum().mag(), cosine, hitDeDxInfo, trajState.localPosition());
108  }
109 
110  }else{ //assume that the particles trajectory is a straight line originating from the center of the detector (can be improved)
111  for(unsigned int h=0;h<track.recHitsSize();h++){
112  const TrackingRecHit* recHit = &(*(track.recHit(h)));
113  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
114  if(!thit.isValid())continue;//make sure it's a tracker hit
115 
116  const GlobalVector& ModuleNormal = recHit->detUnit()->surface().normalVector();
117  float cosine = (track.px()*ModuleNormal.x()+track.py()*ModuleNormal.y()+track.pz()*ModuleNormal.z())/track.p();
118 
119  processHit(recHit, track.p(), cosine, hitDeDxInfo, LocalPoint(0.0,0.0));
120  }
121  }
122 
123  indices.push_back(resultdedxHitColl->size());
124  resultdedxHitColl->push_back(hitDeDxInfo);
125  }
127 
128 
129  edm::OrphanHandle<reco::DeDxHitInfoCollection> dedxHitCollHandle = iEvent.put(resultdedxHitColl);
130 
131  //create map passing the handle to the matched collection
132  std::auto_ptr<reco::DeDxHitInfoAss> dedxMatch(new reco::DeDxHitInfoAss(dedxHitCollHandle));
133  reco::DeDxHitInfoAss::Filler filler(*dedxMatch);
134  filler.insert(trackCollectionHandle, indices.begin(), indices.end());
135  filler.fill();
136  iEvent.put(dedxMatch);
137 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:568
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
LocalVector localDirection() const
GlobalVector normalVector() const
Definition: Plane.h:45
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
T y() const
Definition: PV3DBase.h:63
key_type key() const
Accessor for product key.
Definition: Ref.h:266
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:580
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
LocalVector localMomentum() const
T mag() const
Definition: PV3DBase.h:67
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:604
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
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:574
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:773
const unsigned int minTrackHits
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:592
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
std::vector< DeDxHitInfo > DeDxHitInfoCollection
Definition: DeDxHitInfo.h:97
T const * product() const
Definition: Handle.h:81
string const
Definition: compareJSON.py:14
virtual const GeomDetUnit * detUnit() const
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:114
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
T x() const
Definition: PV3DBase.h:62
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:586

Member Data Documentation

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

Definition at line 64 of file DeDxHitInfoProducer.h.

Referenced by beginRun(), and processHit().

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 65 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().

edm::EDGetTokenT<TrajTrackAssociationCollection> DeDxHitInfoProducer::m_trajTrackAssociationTag
private

Definition at line 47 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 53 of file DeDxHitInfoProducer.h.

const float DeDxHitInfoProducer::MeVperADCStrip
private

Definition at line 54 of file DeDxHitInfoProducer.h.

const unsigned int DeDxHitInfoProducer::minTrackHits
private

Definition at line 56 of file DeDxHitInfoProducer.h.

Referenced by produce().

const float DeDxHitInfoProducer::minTrackPt
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.

const bool DeDxHitInfoProducer::useCalibration
private

Definition at line 61 of file DeDxHitInfoProducer.h.

Referenced by beginRun().

const bool DeDxHitInfoProducer::usePixel
private

Definition at line 51 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and processHit().

const bool DeDxHitInfoProducer::useStrip
private

Definition at line 52 of file DeDxHitInfoProducer.h.

Referenced by DeDxHitInfoProducer(), and processHit().

const bool DeDxHitInfoProducer::useTrajectory
private

Definition at line 50 of file DeDxHitInfoProducer.h.

Referenced by produce().