CMS 3D CMS Logo

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

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

Inheritance diagram for DeDxEstimatorProducerPixelTripplet:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  isEqual
 
struct  stModInfo
 

Public Member Functions

 DeDxEstimatorProducerPixelTripplet (const edm::ParameterSet &)
 
 ~DeDxEstimatorProducerPixelTripplet ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 

Private Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &) override
 
virtual void endJob ()
 
void MakeCalibrationMap ()
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string m_calibrationPath
 
BaseDeDxEstimatorm_estimator
 
edm::EDGetTokenT
< reco::TrackCollection
m_tracksTag
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
m_trajTrackAssociationTag
 
unsigned int MaxNrStrips
 
double MeVperADCPixel
 
double MeVperADCStrip
 
unsigned int MinTrackHits
 
__gnu_cxx::hash_map< unsigned
int, stModInfo
*, __gnu_cxx::hash< unsigned
int >, isEqual
MODsColl
 
bool shapetest
 
bool useCalibration
 
bool usePixel
 
bool useStrip
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
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 34 of file DeDxEstimatorProducerPixelTripplet.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file DeDxEstimatorProducerPixelTripplet.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

47 {
48 
49  produces<ValueMap<DeDxData> >();
50 
51 
52  string estimatorName = iConfig.getParameter<string>("estimator");
53  if(estimatorName == "median") m_estimator = new MedianDeDxEstimator(-2.);
54  if(estimatorName == "generic") m_estimator = new GenericAverageDeDxEstimator (iConfig.getParameter<double>("exponent"));
55  if(estimatorName == "truncated") m_estimator = new TruncatedAverageDeDxEstimator(iConfig.getParameter<double>("fraction"));
56  if(estimatorName == "unbinnedFit") m_estimator = new UnbinnedFitDeDxEstimator();
57 
58  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
59  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 4);
60 
61  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
62  m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"));
63 
64  usePixel = iConfig.getParameter<bool>("UsePixel");
65  useStrip = iConfig.getParameter<bool>("UseStrip");
66  MeVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel");
67  MeVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip");
68 
69  shapetest = iConfig.getParameter<bool>("ShapeTest");
70  useCalibration = iConfig.getParameter<bool>("UseCalibration");
71  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
72 
73  if(!usePixel && !useStrip)
74  edm::LogWarning("DeDxHitsProducer") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
75 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
DeDxEstimatorProducerPixelTripplet::~DeDxEstimatorProducerPixelTripplet ( )

Definition at line 78 of file DeDxEstimatorProducerPixelTripplet.cc.

79 {
80  delete m_estimator;
81 }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 86 of file DeDxEstimatorProducerPixelTripplet.cc.

References compareJSON::const, DeDxEstimatorProducerPixelTripplet::stModInfo::DetId, DeDxEstimatorProducerPixelTripplet::stModInfo::Distance, DeDxEstimatorProducerPixelTripplet::stModInfo::Gain, edm::EventSetup::get(), i, PV3DBase< T, PVType, FrameType >::mag(), DeDxEstimatorProducerPixelTripplet::stModInfo::Normal, DeDxEstimatorProducerPixelTripplet::stModInfo::Normalization, DetId::rawId(), and DeDxEstimatorProducerPixelTripplet::stModInfo::Thickness.

87 {
88  if(MODsColl.size()!=0)return;
89 
90 
92  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
93 
94  auto const & Det = tkGeom->dets();
95  for(unsigned int i=0;i<Det.size();i++){
96  DetId Detid = Det[i]->geographicalId();
97 
98  auto StripDetUnit = dynamic_cast<StripGeomDetUnit const*> (Det[i]);
99  auto PixelDetUnit = dynamic_cast<PixelGeomDetUnit const*> (Det[i]);
100 
101  stModInfo* MOD = new stModInfo;
102  double Thick=-1, Dist=-1, Norma=-1;
103  if(StripDetUnit){
104  Dist = StripDetUnit->position().mag();
105  Thick = StripDetUnit->surface().bounds().thickness();
106  Norma = MeVperADCStrip/Thick;
107  MOD->Normal = StripDetUnit->surface().normalVector();
108  }else if(PixelDetUnit){
109  Dist = PixelDetUnit->position().mag();
110  Thick = PixelDetUnit->surface().bounds().thickness();
111  Norma = MeVperADCPixel/Thick;
112  MOD->Normal = PixelDetUnit->surface().normalVector();
113  }
114 
115  MOD->DetId = Detid.rawId();
116  MOD->Thickness = Thick;
117  MOD->Distance = Dist;
118  MOD->Normalization = Norma;
119  MOD->Gain = 1;
120  MODsColl[MOD->DetId] = MOD;
121  }
122 
124 }
int i
Definition: DBlmapReader.cc:9
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
string const
Definition: compareJSON.py:14
void DeDxEstimatorProducerPixelTripplet::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 127 of file DeDxEstimatorProducerPixelTripplet.cc.

127  {
128  MODsColl.clear();
129 }
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
void DeDxEstimatorProducerPixelTripplet::MakeCalibrationMap ( )
private

Definition at line 198 of file DeDxEstimatorProducerPixelTripplet.cc.

References DeDxEstimatorProducerPixelTripplet::stModInfo::Gain.

199 {
200  if(!useCalibration)return;
201 
202  TChain* t1 = new TChain("SiStripCalib/APVGain");
203  t1->Add(m_calibrationPath.c_str());
204 
205  unsigned int tree_DetId;
206  unsigned char tree_APVId;
207  double tree_Gain;
208 
209  t1->SetBranchAddress("DetId" ,&tree_DetId );
210  t1->SetBranchAddress("APVId" ,&tree_APVId );
211  t1->SetBranchAddress("Gain" ,&tree_Gain );
212 
213 
214 
215  for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
216  t1->GetEntry(ientry);
217  stModInfo* MOD = MODsColl[tree_DetId];
218  MOD->Gain = tree_Gain;
219  }
220 
221  delete t1;
222 
223 }
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
void DeDxEstimatorProducerPixelTripplet::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 134 of file DeDxEstimatorProducerPixelTripplet.cc.

References funct::abs(), DeDxDiscriminatorTools::charge(), clone(), cond::rpcobgas::detid, DeDxEstimatorProducerPixelTripplet::stModInfo::Distance, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), h, edm::helper::Filler< Map >::insert(), j, n, DeDxEstimatorProducerPixelTripplet::stModInfo::Normal, DeDxEstimatorProducerPixelTripplet::stModInfo::Normalization, edm::Handle< T >::product(), edm::Event::put(), python.multivaluedict::sort(), DeDxEstimatorProducerPixelTripplet::stModInfo::Thickness, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

135 {
136  auto_ptr<ValueMap<DeDxData> > trackDeDxEstimateAssociation(new ValueMap<DeDxData> );
137  ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation);
138 
139  Handle<TrackCollection> trackCollHandle;
140  iEvent.getByToken(m_trajTrackAssociationTag, trackCollHandle);
141  const TrackCollection trackColl = *trackCollHandle.product();
142 
143  size_t n = trackColl.size();
144  std::vector<DeDxData> dedxEstimate(n);
145 
146  //assume trajectory collection size is equal to track collection size and that order is kept
147  for(unsigned int j=0;j<trackColl.size();j++){
148  const reco::TrackRef track = reco::TrackRef( trackCollHandle.product(), j );
149 
150  DeDxHitCollection dedxHits;
151  vector<DeDxTools::RawHits> hits;
152 // DeDxTools::trajectoryRawHits(traj, hits, usePixel, useStrip);
153 
154 
155  int NClusterSaturating = 0;
156  for(unsigned int h=0;h<track->recHitsSize();h++){
157  //SiStripDetId detid = SiStripDetId((track->recHit(h))->geographicalId());
158  //TrackingRecHit* recHit = (track->recHit(h))->clone();
159 
160  TrackingRecHit* recHit= (track->recHit(h))->clone();
161 
162  if(const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
163  if(!usePixel) continue;
164 
165  unsigned int detid = pixelHit->geographicalId();
166  stModInfo* MOD = MODsColl[detid];
167 
168  double cosine = (track->px()*MOD->Normal.x()+track->py()*MOD->Normal.y()+track->pz()*MOD->Normal.z())/track->p();
169  float pathLen = MOD->Thickness/std::abs(cosine);
170  float charge = MOD->Normalization*pixelHit->cluster()->charge()*std::abs(cosine);
171  dedxHits.push_back( DeDxHit( charge, MOD->Distance, pathLen, detid) );
172 
173  }
174  delete recHit;
175  }
177 
178 
179  sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
180  std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
181 
182  //WARNING: Since the dEdX Error is not properly computed for the moment
183  //It was decided to store the number of saturating cluster in that dataformat
184  val_and_error.second = NClusterSaturating;
185 
186  dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
187  }
188  filler.insert(trackCollHandle, dedxEstimate.begin(), dedxEstimate.end());
189 
190  // really fill the association map
191  filler.fill();
192  // put into the event
193  iEvent.put(trackDeDxEstimateAssociation);
194 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:49
double charge(const std::vector< uint8_t > &Ampls)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
virtual std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits)=0
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
Pixel Reconstructed Hit.

Member Data Documentation

std::string DeDxEstimatorProducerPixelTripplet::m_calibrationPath
private

Definition at line 63 of file DeDxEstimatorProducerPixelTripplet.h.

BaseDeDxEstimator* DeDxEstimatorProducerPixelTripplet::m_estimator
private

Definition at line 50 of file DeDxEstimatorProducerPixelTripplet.h.

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

Definition at line 53 of file DeDxEstimatorProducerPixelTripplet.h.

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

Definition at line 52 of file DeDxEstimatorProducerPixelTripplet.h.

unsigned int DeDxEstimatorProducerPixelTripplet::MaxNrStrips
private

Definition at line 60 of file DeDxEstimatorProducerPixelTripplet.h.

double DeDxEstimatorProducerPixelTripplet::MeVperADCPixel
private

Definition at line 57 of file DeDxEstimatorProducerPixelTripplet.h.

double DeDxEstimatorProducerPixelTripplet::MeVperADCStrip
private

Definition at line 58 of file DeDxEstimatorProducerPixelTripplet.h.

unsigned int DeDxEstimatorProducerPixelTripplet::MinTrackHits
private

Definition at line 61 of file DeDxEstimatorProducerPixelTripplet.h.

__gnu_cxx::hash_map<unsigned int, stModInfo*, __gnu_cxx::hash<unsigned int>, isEqual > DeDxEstimatorProducerPixelTripplet::MODsColl
private

Definition at line 75 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::shapetest
private

Definition at line 65 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::useCalibration
private

Definition at line 64 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::usePixel
private

Definition at line 55 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::useStrip
private

Definition at line 56 of file DeDxEstimatorProducerPixelTripplet.h.