CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DeDxEstimatorProducer Class Reference

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

Inheritance diagram for DeDxEstimatorProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DeDxEstimatorProducer (const edm::ParameterSet &)
 
 ~DeDxEstimatorProducer ()
 
- 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &) override
 
void makeCalibrationMap (const TrackerGeometry &tkGeom)
 
void processHit (const TrackingRecHit *recHit, float trackMomentum, float &cosine, reco::DeDxHitCollection &dedxHits, int &NClusterSaturating)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< std::vector< float > > calibGains
 
std::string m_calibrationPath
 
BaseDeDxEstimatorm_estimator
 
unsigned int m_off
 
edm::EDGetTokenT
< reco::TrackCollection
m_tracksTag
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
m_trajTrackAssociationTag
 
unsigned int MaxNrStrips
 
float meVperADCPixel
 
float meVperADCStrip
 
bool shapetest
 
bool useCalibration
 
bool usePixel
 
bool useStrip
 
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
 
- 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 47 of file DeDxEstimatorProducer.h.

Constructor & Destructor Documentation

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

Definition at line 53 of file DeDxEstimatorProducer.cc.

References edm::ParameterSet::getParameter().

54 {
55 
56  produces<ValueMap<DeDxData> >();
57 
58  string estimatorName = iConfig.getParameter<string>("estimator");
59  if (estimatorName == "median") m_estimator = new MedianDeDxEstimator(iConfig);
60  else if(estimatorName == "generic") m_estimator = new GenericAverageDeDxEstimator (iConfig);
61  else if(estimatorName == "truncated") m_estimator = new TruncatedAverageDeDxEstimator(iConfig);
62  else if(estimatorName == "unbinnedFit") m_estimator = new UnbinnedFitDeDxEstimator(iConfig);
63  else if(estimatorName == "productDiscrim") m_estimator = new ProductDeDxDiscriminator(iConfig);
64  else if(estimatorName == "btagDiscrim") m_estimator = new BTagLikeDeDxDiscriminator(iConfig);
65  else if(estimatorName == "smirnovDiscrim") m_estimator = new SmirnovDeDxDiscriminator(iConfig);
66  else if(estimatorName == "asmirnovDiscrim") m_estimator = new ASmirnovDeDxDiscriminator(iConfig);
67 
68  //Commented for now, might be used in the future
69 // MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
70 
71  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
72  m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"));
73  useTrajectory = iConfig.getParameter<bool>("UseTrajectory");
74 
75  usePixel = iConfig.getParameter<bool>("UsePixel");
76  useStrip = iConfig.getParameter<bool>("UseStrip");
77  meVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel");
78  meVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip");
79 
80  shapetest = iConfig.getParameter<bool>("ShapeTest");
81  useCalibration = iConfig.getParameter<bool>("UseCalibration");
82  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
83 
84  if(!usePixel && !useStrip)
85  edm::LogWarning("DeDxHitsProducer") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
86 
87 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
BaseDeDxEstimator * m_estimator
DeDxEstimatorProducer::~DeDxEstimatorProducer ( )

Definition at line 90 of file DeDxEstimatorProducer.cc.

91 {
92  delete m_estimator;
93 }
BaseDeDxEstimator * m_estimator

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 96 of file DeDxEstimatorProducer.cc.

References edm::EventSetup::get(), DeDxTools::makeCalibrationMap(), and GeomDetEnumerators::PixelBarrel.

97 {
98  if(useCalibration && calibGains.size()==0){
100  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
101  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
102 
104  }
105 
106  m_estimator->beginRun(run, iSetup);
107 }
void makeCalibrationMap(const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:187
std::vector< std::vector< float > > calibGains
BaseDeDxEstimator * m_estimator
const T & get() const
Definition: EventSetup.h:55
virtual void beginRun(edm::Run const &run, const edm::EventSetup &iSetup)
void DeDxEstimatorProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 31 of file DeDxEstimatorProducer.cc.

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

31  {
33  desc.add<string>("estimator","generic");
34  desc.add<edm::InputTag>("tracks",edm::InputTag("generalTracks"));
35  desc.add<edm::InputTag>("trajectoryTrackAssociation",edm::InputTag("generalTracks"));
36  desc.add<bool>("UseTrajectory",true);
37  desc.add<bool>("UsePixel",false);
38  desc.add<bool>("UseStrip",true);
39  desc.add<double>("MeVperADCPixel",3.61e-06*265);
40  desc.add<double>("MeVperADCStrip",3.61e-06);
41  desc.add<bool>("ShapeTest",true);
42  desc.add<bool>("UseCalibration",false);
43  desc.add<string>("calibrationPath", "");
44  desc.add<string>("Reccord", "SiStripDeDxMip_3D_Rcd");
45  desc.add<string>("ProbabilityMode", "Accumulation");
46  desc.add<double>("fraction", 0.4);
47  desc.add<double>("exponent",-2.0);
48 
49  descriptions.add("DeDxEstimatorProducer",desc);
50 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void DeDxEstimatorProducer::makeCalibrationMap ( const TrackerGeometry tkGeom)
private
void DeDxEstimatorProducer::processHit ( const TrackingRecHit recHit,
float  trackMomentum,
float &  cosine,
reco::DeDxHitCollection dedxHits,
int &  NClusterSaturating 
)
private

Definition at line 179 of file DeDxEstimatorProducer.cc.

References SiStripCluster::amplitudes(), Surface::bounds(), compareJSON::const, TrackingRecHit::det(), TrackingRecHit::detUnit(), DeDxTools::getCharge(), SiStripMatchedRecHit2D::monoCluster(), GluedGeomDet::monoDet(), SiStripMatchedRecHit2D::monoId(), DeDxTools::shapeSelection(), SiStripMatchedRecHit2D::stereoCluster(), GluedGeomDet::stereoDet(), SiStripMatchedRecHit2D::stereoId(), GeomDet::surface(), and Bounds::thickness().

179  {
180  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
181  if(!thit.isValid())return;
182 
183  auto const & clus = thit.firstClusterRef();
184  if(!clus.isValid())return;
185 
186  if(clus.isPixel()){
187  if(!usePixel) return;
188 
189  auto& detUnit = *(recHit->detUnit());
190  float pathLen = detUnit.surface().bounds().thickness()/fabs(cosine);
191  float chargeAbs = clus.pixelCluster().charge();
192  float charge = meVperADCPixel*chargeAbs/pathLen;
193  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, thit.geographicalId()) );
194  }else if(clus.isStrip() && !thit.isMatched()){
195  if(!useStrip) return;
196 
197  auto& detUnit = *(recHit->detUnit());
198  int NSaturating = 0;
199  float pathLen = detUnit.surface().bounds().thickness()/fabs(cosine);
200  float chargeAbs = DeDxTools::getCharge(&(clus.stripCluster()),NSaturating, detUnit, calibGains, m_off);
201  float charge = meVperADCStrip*chargeAbs/pathLen;
202  if(!shapetest || (shapetest && DeDxTools::shapeSelection(clus.stripCluster().amplitudes()))){
203  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, thit.geographicalId()) );
204  if(NSaturating>0)NClusterSaturating++;
205  }
206  }else if(clus.isStrip() && thit.isMatched()){
207  if(!useStrip) return;
208  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
209  if(!matchedHit)return;
210  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(matchedHit->det());
211 
212  auto& detUnitM = *(gdet->monoDet());
213  int NSaturating = 0;
214  float pathLen = detUnitM.surface().bounds().thickness()/fabs(cosine);
215  float chargeAbs = DeDxTools::getCharge(&(matchedHit->monoCluster()),NSaturating, detUnitM, calibGains, m_off);
216  float charge = meVperADCStrip*chargeAbs/pathLen;
218  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, matchedHit->monoId()) );
219  if(NSaturating>0)NClusterSaturating++;
220  }
221 
222  auto& detUnitS = *(gdet->stereoDet());
223  NSaturating = 0;
224  pathLen = detUnitS.surface().bounds().thickness()/fabs(cosine);
225  chargeAbs = DeDxTools::getCharge(&(matchedHit->stereoCluster()),NSaturating, detUnitS, calibGains, m_off);
226  charge = meVperADCStrip*chargeAbs/pathLen;
228  dedxHits.push_back( DeDxHit( charge, trackMomentum, pathLen, matchedHit->stereoId()) );
229  if(NSaturating>0)NClusterSaturating++;
230  }
231  }
232 }
unsigned int stereoId() const
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:160
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
SiStripCluster const & monoCluster() const
const Bounds & bounds() const
Definition: Surface.h:128
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
virtual float thickness() const =0
const GeomDet * det() const
std::vector< std::vector< float > > calibGains
bool shapeSelection(const std::vector< uint8_t > &ampls)
Definition: DeDxTools.cc:10
string const
Definition: compareJSON.py:14
SiStripCluster const & stereoCluster() const
virtual const GeomDetUnit * detUnit() const
unsigned int monoId() const
const std::vector< uint8_t > & amplitudes() const
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
void DeDxEstimatorProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 111 of file DeDxEstimatorProducer.cc.

References compareJSON::const, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, TrackingRecHit::detUnit(), edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), h, edm::helper::Filler< Map >::insert(), TrajectoryStateOnSurface::isValid(), TrackingRecHit::isValid(), j, edm::Ref< C, T, F >::key(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localMomentum(), PV3DBase< T, PVType, FrameType >::mag(), Plane::normalVector(), edm::Handle< T >::product(), edm::Event::put(), python.multivaluedict::sort(), GeomDet::surface(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

112 {
113  auto_ptr<ValueMap<DeDxData> > trackDeDxEstimateAssociation(new ValueMap<DeDxData> );
114  ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation);
115 
116  edm::Handle<reco::TrackCollection> trackCollectionHandle;
117  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
118 
119  Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
120  if(useTrajectory)iEvent.getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
121 
122  std::vector<DeDxData> dedxEstimate( trackCollectionHandle->size() );
123 
125  if(useTrajectory)cit = trajTrackAssociationHandle->begin();
126  for(unsigned int j=0;j<trackCollectionHandle->size();j++){
127  const reco::TrackRef track = reco::TrackRef( trackCollectionHandle.product(), j );
128 
129  int NClusterSaturating = 0;
130  DeDxHitCollection dedxHits;
131 
132  if(useTrajectory){ //trajectory allows to take into account the local direction of the particle on the module sensor --> muc much better 'dx' measurement
133  const edm::Ref<std::vector<Trajectory> > traj = cit->key; cit++;
134  const vector<TrajectoryMeasurement> & measurements = traj->measurements();
135  for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
136  TrajectoryStateOnSurface trajState=it->updatedState();
137  if( !trajState.isValid()) continue;
138 
139  const TrackingRecHit * recHit=(*it->recHit()).hit();
140  if(!recHit || !recHit->isValid())continue;
141  LocalVector trackDirection = trajState.localDirection();
142  float cosine = trackDirection.z()/trackDirection.mag();
143 
144  processHit(recHit, trajState.localMomentum().mag(), cosine, dedxHits, NClusterSaturating);
145  }
146 
147  }else{ //assume that the particles trajectory is a straight line originating from the center of the detector (can be improved)
148  for(unsigned int h=0;h<track->recHitsSize();h++){
149  const TrackingRecHit* recHit = &(*(track->recHit(h)));
150  if(!recHit || !recHit->isValid())continue;
151  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
152  if(!thit.isValid())continue;//make sure it's a tracker hit
153 
154  const GlobalVector& ModuleNormal = recHit->detUnit()->surface().normalVector();
155  float cosine = (track->px()*ModuleNormal.x()+track->py()*ModuleNormal.y()+track->pz()*ModuleNormal.z())/track->p();
156 
157  processHit(recHit, track->p(), cosine, dedxHits, NClusterSaturating);
158  }
159  }
160 
161  sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
162  std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
163 
164  //WARNING: Since the dEdX Error is not properly computed for the moment
165  //It was decided to store the number of saturating cluster in that dataformat
166  val_and_error.second = NClusterSaturating;
167  dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
168  }
170 
171  filler.insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
172 
173  // fill the association map and put it into the event
174  filler.fill();
175  iEvent.put(trackDeDxEstimateAssociation);
176 }
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
LocalVector localDirection() const
GlobalVector normalVector() const
Definition: Plane.h:45
T y() const
Definition: PV3DBase.h:63
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:67
key_type key() const
Accessor for product key.
Definition: Ref.h:266
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
LocalVector localMomentum() const
T mag() const
Definition: PV3DBase.h:67
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
T z() const
Definition: PV3DBase.h:64
int j
Definition: DBlmapReader.cc:9
void processHit(const TrackingRecHit *recHit, float trackMomentum, float &cosine, reco::DeDxHitCollection &dedxHits, int &NClusterSaturating)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
BaseDeDxEstimator * m_estimator
virtual std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits)=0
T const * product() const
Definition: Handle.h:81
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:19
bool isValid() const
string const
Definition: compareJSON.py:14
virtual const GeomDetUnit * detUnit() const
T x() const
Definition: PV3DBase.h:62

Member Data Documentation

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

Definition at line 78 of file DeDxEstimatorProducer.h.

std::string DeDxEstimatorProducer::m_calibrationPath
private

Definition at line 74 of file DeDxEstimatorProducer.h.

BaseDeDxEstimator* DeDxEstimatorProducer::m_estimator
private

Definition at line 61 of file DeDxEstimatorProducer.h.

unsigned int DeDxEstimatorProducer::m_off
private

Definition at line 79 of file DeDxEstimatorProducer.h.

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

Definition at line 64 of file DeDxEstimatorProducer.h.

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

Definition at line 63 of file DeDxEstimatorProducer.h.

unsigned int DeDxEstimatorProducer::MaxNrStrips
private

Definition at line 72 of file DeDxEstimatorProducer.h.

float DeDxEstimatorProducer::meVperADCPixel
private

Definition at line 69 of file DeDxEstimatorProducer.h.

float DeDxEstimatorProducer::meVperADCStrip
private

Definition at line 70 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::shapetest
private

Definition at line 76 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useCalibration
private

Definition at line 75 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::usePixel
private

Definition at line 67 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useStrip
private

Definition at line 68 of file DeDxEstimatorProducer.h.

bool DeDxEstimatorProducer::useTrajectory
private

Definition at line 66 of file DeDxEstimatorProducer.h.