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
DeDxDiscriminatorProducer Class Reference

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

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

Classes

class  isEqual
 
struct  stModInfo
 

Public Member Functions

 DeDxDiscriminatorProducer (const edm::ParameterSet &)
 
 ~DeDxDiscriminatorProducer ()
 
- 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 ()
 

Private Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &) override
 
int ClusterSaturatingStrip (const SiStripCluster *cluster, const uint32_t &)
 
double ComputeDiscriminator (std::vector< double > &vect_probs)
 
virtual void endStream () override
 
double GetProbability (const SiStripCluster *cluster, TrajectoryStateOnSurface trajState, const uint32_t &)
 
void MakeCalibrationMap ()
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

PhysicsTools::Calibration::HistogramD3D DeDxMap_
 
unsigned int Formula
 
std::string m_calibrationPath
 
const TrackerGeometrym_tracker
 
edm::EDGetTokenT
< reco::TrackCollection
m_tracksTag
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
m_trajTrackAssociationTag
 
unsigned int MaxNrStrips
 
double MaxTrackChiOverNdf
 
double MaxTrackEta
 
double MaxTrackMomentum
 
double MeVperADCPixel
 
double MeVperADCStrip
 
double MinTrackEta
 
unsigned int MinTrackHits
 
double MinTrackMomentum
 
__gnu_cxx::hash_map< unsigned
int, stModInfo
*, __gnu_cxx::hash< unsigned
int >, isEqual
MODsColl
 
TH3D * Prob_ChargePath
 
std::string ProbabilityMode
 
std::string Reccord
 
bool shapetest
 
bool useCalibration
 
bool usePixel
 
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, 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 48 of file DeDxDiscriminatorProducer.h.

Constructor & Destructor Documentation

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

Definition at line 48 of file DeDxDiscriminatorProducer.cc.

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

49 {
50 
51  produces<ValueMap<DeDxData> >();
52 
53  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
54  m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"));
55 
56  usePixel = iConfig.getParameter<bool>("UsePixel");
57  useStrip = iConfig.getParameter<bool>("UseStrip");
58  if(!usePixel && !useStrip)
59  edm::LogWarning("DeDxHitsProducer") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
60 
61  Formula = iConfig.getUntrackedParameter<unsigned>("Formula" , 0);
62  Reccord = iConfig.getUntrackedParameter<string> ("Reccord" , "SiStripDeDxMip_3D_Rcd");
63  ProbabilityMode = iConfig.getUntrackedParameter<string> ("ProbabilityMode" , "Accumulation");
64 
65 
66  MinTrackMomentum = iConfig.getUntrackedParameter<double> ("minTrackMomentum" , 0.0);
67  MaxTrackMomentum = iConfig.getUntrackedParameter<double> ("maxTrackMomentum" , 99999.0);
68  MinTrackEta = iConfig.getUntrackedParameter<double> ("minTrackEta" , -5.0);
69  MaxTrackEta = iConfig.getUntrackedParameter<double> ("maxTrackEta" , 5.0);
70  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
71  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 3);
72 
73  shapetest = iConfig.getParameter<bool>("ShapeTest");
74  useCalibration = iConfig.getParameter<bool>("UseCalibration");
75  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
76 
78 }
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
#define NULL
Definition: scimark2.h:8
DeDxDiscriminatorProducer::~DeDxDiscriminatorProducer ( )

Definition at line 81 of file DeDxDiscriminatorProducer.cc.

81 {}

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 84 of file DeDxDiscriminatorProducer.cc.

References compareJSON::const, DeDxDiscriminatorProducer::stModInfo::DetId, reco::tau::disc::Eta(), DeDxDiscriminatorProducer::stModInfo::Eta, cmsRelvalreport::exit, edm::EventSetup::get(), i, j, gen::k, prof2calltree::l, DeDxDiscriminatorProducer::stModInfo::NAPV, StripTopology::nstrips(), edm::ESHandle< class >::product(), dttmaxenums::R, DeDxDiscriminatorProducer::stModInfo::R, DetId::rawId(), DeDxDiscriminatorProducer::stModInfo::SubDet, DetId::subdetId(), StripSubdetector::TEC, DeDxDiscriminatorProducer::stModInfo::Thickness, StripSubdetector::TIB, StripSubdetector::TID, tmp, StripSubdetector::TOB, SiStripMonitorClusterAlca_cfi::xmax, SiStripMonitorClusterAlca_cfi::xmin, SiStripMonitorClusterAlca_cfi::ymax, SiStripMonitorClusterAlca_cfi::ymin, SiStripMonitorClusterAlca_cfi::zmax, and SiStripMonitorClusterAlca_cfi::zmin.

85 {
87  if( strcmp(Reccord.c_str(),"SiStripDeDxMip_3D_Rcd")==0){
88  iSetup.get<SiStripDeDxMip_3D_Rcd>() .get(DeDxMapHandle_);
89  }else if(strcmp(Reccord.c_str(),"SiStripDeDxPion_3D_Rcd")==0){
90  iSetup.get<SiStripDeDxPion_3D_Rcd>().get(DeDxMapHandle_);
91  }else if(strcmp(Reccord.c_str(),"SiStripDeDxKaon_3D_Rcd")==0){
92  iSetup.get<SiStripDeDxKaon_3D_Rcd>().get(DeDxMapHandle_);
93  }else if(strcmp(Reccord.c_str(),"SiStripDeDxProton_3D_Rcd")==0){
94  iSetup.get<SiStripDeDxProton_3D_Rcd>().get(DeDxMapHandle_);
95  }else if(strcmp(Reccord.c_str(),"SiStripDeDxElectron_3D_Rcd")==0){
96  iSetup.get<SiStripDeDxElectron_3D_Rcd>().get(DeDxMapHandle_);
97  }else{
98 // printf("The reccord %s is not known by the DeDxDiscriminatorProducer\n", Reccord.c_str());
99 // printf("Program will exit now\n");
100  exit(0);
101  }
102  DeDxMap_ = *DeDxMapHandle_.product();
103 
104  double xmin = DeDxMap_.rangeX().min;
105  double xmax = DeDxMap_.rangeX().max;
106  double ymin = DeDxMap_.rangeY().min;
107  double ymax = DeDxMap_.rangeY().max;
108  double zmin = DeDxMap_.rangeZ().min;
109  double zmax = DeDxMap_.rangeZ().max;
110 
112  Prob_ChargePath = new TH3D ("Prob_ChargePath" , "Prob_ChargePath" , DeDxMap_.numberOfBinsX(), xmin, xmax, DeDxMap_.numberOfBinsY() , ymin, ymax, DeDxMap_.numberOfBinsZ(), zmin, zmax);
113 
114 
115 
116  if(strcmp(ProbabilityMode.c_str(),"Accumulation")==0){
117 // printf("LOOOP ON P\n");
118  for(int i=0;i<=Prob_ChargePath->GetXaxis()->GetNbins()+1;i++){
119 // printf("LOOOP ON PATH\n");
120  for(int j=0;j<=Prob_ChargePath->GetYaxis()->GetNbins()+1;j++){
121 // printf("LOOOP ON CHARGE\n");
122 
123  double Ni = 0;
124  for(int k=0;k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;k++){ Ni+=DeDxMap_.binContent(i,j,k);}
125 
126  for(int k=0;k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;k++){
127  double tmp = 0;
128  for(int l=0;l<=k;l++){ tmp+=DeDxMap_.binContent(i,j,l);}
129 
130  if(Ni>0){
131  Prob_ChargePath->SetBinContent (i, j, k, tmp/Ni);
132 // printf("P=%6.2f Path=%6.2f Charge%8.2f --> Prob=%8.3f\n",Prob_ChargePath->GetXaxis()->GetBinCenter(i), Prob_ChargePath->GetYaxis()->GetBinCenter(j), Prob_ChargePath->GetZaxis()->GetBinCenter(k), tmp/Ni);
133  }else{
134  Prob_ChargePath->SetBinContent (i, j, k, 0);
135  }
136  }
137  }
138  }
139  }else if(strcmp(ProbabilityMode.c_str(),"Integral")==0){
140 // printf("LOOOP ON P\n");
141  for(int i=0;i<=Prob_ChargePath->GetXaxis()->GetNbins()+1;i++){
142 // printf("LOOOP ON PATH\n");
143  for(int j=0;j<=Prob_ChargePath->GetYaxis()->GetNbins()+1;j++){
144 // printf("LOOOP ON CHARGE\n");
145 
146  double Ni = 0;
147  for(int k=0;k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;k++){ Ni+=DeDxMap_.binContent(i,j,k);}
148 
149  for(int k=0;k<=Prob_ChargePath->GetZaxis()->GetNbins()+1;k++){
150  double tmp = DeDxMap_.binContent(i,j,k);
151 
152  if(Ni>0){
153  Prob_ChargePath->SetBinContent (i, j, k, tmp/Ni);
154 // printf("P=%6.2f Path=%6.2f Charge%8.2f --> Prob=%8.3f\n",Prob_ChargePath->GetXaxis()->GetBinCenter(i), Prob_ChargePath->GetYaxis()->GetBinCenter(j), Prob_ChargePath->GetZaxis()->GetBinCenter(k), tmp/Ni);
155  }else{
156  Prob_ChargePath->SetBinContent (i, j, k, 0);
157  }
158  }
159  }
160  }
161  }else{
162 // printf("The ProbabilityMode: %s is unknown\n",ProbabilityMode.c_str());
163 // printf("The program will stop now\n");
164  exit(0);
165  }
166 
167 
168 
169 /*
170  for(int i=0;i<Prob_ChargePath->GetXaxis()->GetNbins();i++){
171  for(int j=0;j<Prob_ChargePath->GetYaxis()->GetNbins();j++){
172  double tmp = DeDxMap_.binContent(i,j);
173  Prob_ChargePath->SetBinContent (i, j, tmp);
174  printf("%i %i --> %f\n",i,j,tmp);
175  }
176  }
177 */
178 
179 
180 
181  if(MODsColl.size()==0){
183  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
184  m_tracker = tkGeom.product();
185 
186  auto const & Det = tkGeom->dets();
187  for(unsigned int i=0;i<Det.size();i++){
188  DetId Detid = Det[i]->geographicalId();
189  int SubDet = Detid.subdetId();
190 
191  if( SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID ||
192  SubDet == StripSubdetector::TOB || SubDet == StripSubdetector::TEC ){
193 
194  auto DetUnit = dynamic_cast<StripGeomDetUnit const*> (Det[i]);
195  if(!DetUnit)continue;
196 
197  const StripTopology& Topo = DetUnit->specificTopology();
198  unsigned int NAPV = Topo.nstrips()/128;
199 
200  double Eta = DetUnit->position().basicVector().eta();
201  double R = DetUnit->position().basicVector().transverse();
202  double Thick = DetUnit->surface().bounds().thickness();
203 
204  stModInfo* MOD = new stModInfo;
205  MOD->DetId = Detid.rawId();
206  MOD->SubDet = SubDet;
207  MOD->Eta = Eta;
208  MOD->R = R;
209  MOD->Thickness = Thick;
210  MOD->NAPV = NAPV;
211  MODsColl[MOD->DetId] = MOD;
212  }
213  }
214 
216  }
217 
218 }
virtual int nstrips() const =0
int i
Definition: DBlmapReader.cc:9
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
const TrackerGeometry * m_tracker
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
PhysicsTools::Calibration::HistogramD3D DeDxMap_
int j
Definition: DBlmapReader.cc:9
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
int k[5][pyjets_maxn]
Value_t binContent(int bin) const
Definition: Histogram3D.h:90
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
string const
Definition: compareJSON.py:14
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int DeDxDiscriminatorProducer::ClusterSaturatingStrip ( const SiStripCluster cluster,
const uint32_t &  detId 
)
private

Definition at line 315 of file DeDxDiscriminatorProducer.cc.

References SiStripCluster::amplitudes(), DeDxDiscriminatorProducer::stModInfo::Gain, i, and NULL.

316  {
317  const vector<uint8_t>& ampls = cluster->amplitudes();
318 
319  stModInfo* MOD = NULL;
320  if(useCalibration)MOD = MODsColl[detId];
321 
322  int SaturatingStrip = 0;
323  for(unsigned int i=0;i<ampls.size();i++){
324  int StripCharge = ampls[i];
325  if(MOD){StripCharge = (int)(StripCharge / MOD->Gain);}
326  if(StripCharge>=254)SaturatingStrip++;
327  }
328  return SaturatingStrip;
329 }
int i
Definition: DBlmapReader.cc:9
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
#define NULL
Definition: scimark2.h:8
const std::vector< uint8_t > & amplitudes() const
double DeDxDiscriminatorProducer::ComputeDiscriminator ( std::vector< double > &  vect_probs)
private

Definition at line 375 of file DeDxDiscriminatorProducer.cc.

References create_public_lumi_plots::exp, i, prof2calltree::l, log, bookConverter::max, min(), P, funct::pow(), findQualityFiles::size, and python.multivaluedict::sort().

376 {
377  double estimator = -1;
378  int size = vect_probs.size();
379  if(size<=0)return estimator;
380 
381  if(Formula==0){
382  double P = 1;
383  for(int i=0;i<size;i++){
384  if(vect_probs[i]<=0.0001){P *= pow(0.0001 , 1.0/size);}
385  else {P *= pow(vect_probs[i], 1.0/size);}
386  }
387  estimator = P;
388  }else if(Formula==1){
389  std::sort(vect_probs.begin(), vect_probs.end(), std::less<double>() );
390  for(int i=0;i<size;i++){if(vect_probs[i]<=0.0001)vect_probs[i] = 0.0001; }
391 
392  double SumJet = 0.;
393  for(int i=0;i<size;i++){ SumJet+= log(vect_probs[i]); }
394 
395  double Loginvlog=log(-SumJet);
396  double Prob =1.;
397  double lfact=1.;
398 
399  for(int l=1; l!=size; l++){
400  lfact*=l;
401  Prob+=exp(l*Loginvlog-log(1.*lfact));
402  }
403 
404  double LogProb=log(Prob);
405  double ProbJet=std::min(exp(std::max(LogProb+SumJet,-30.)),1.);
406  estimator = -log10(ProbJet)/4.;
407  estimator = 1-estimator;
408  }else if(Formula==2){
409  std::sort(vect_probs.begin(), vect_probs.end(), std::less<double>() );
410  double P = 1.0/(12*size);
411  for(int i=1;i<=size;i++){
412  P += pow(vect_probs[i-1] - ((2.0*i-1.0)/(2.0*size)),2);
413  }
414  P *= (3.0/size);
415  estimator = P;
416  }else{
417  std::sort(vect_probs.begin(), vect_probs.end(), std::less<double>() );
418  double P = 1.0/(12*size);
419  for(int i=1;i<=size;i++){
420  P += vect_probs[i-1] * pow(vect_probs[i-1] - ((2.0*i-1.0)/(2.0*size)),2);
421  }
422  P *= (3.0/size);
423  estimator = P;
424  }
425 
426  return estimator;
427 }
int i
Definition: DBlmapReader.cc:9
static std::vector< std::string > checklist log
#define P
T min(T a, T b)
Definition: MathUtil.h:58
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void DeDxDiscriminatorProducer::endStream ( )
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 220 of file DeDxDiscriminatorProducer.cc.

221 {
222  MODsColl.clear();
223 }
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
double DeDxDiscriminatorProducer::GetProbability ( const SiStripCluster cluster,
TrajectoryStateOnSurface  trajState,
const uint32_t &  detId 
)
private

Definition at line 331 of file DeDxDiscriminatorProducer.cc.

References SiStripCluster::amplitudes(), reco_application_tbsim_DetSim-Digi_cfg::BinX, reco_application_tbsim_DetSim-Digi_cfg::BinY, DeDxDiscriminatorTools::charge(), DeDxDiscriminatorProducer::stModInfo::Gain, i, TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localMomentum(), PV3DBase< T, PVType, FrameType >::mag(), DeDxDiscriminatorTools::path(), cmsHarvester::path, DeDxDiscriminatorProducer::stModInfo::Thickness, and PV3DBase< T, PVType, FrameType >::z().

333 {
334  // Get All needed variables
335  LocalVector trackDirection = trajState.localDirection();
336  double cosine = trackDirection.z()/trackDirection.mag();
337  const vector<uint8_t>& ampls = cluster->amplitudes();
338  // uint32_t detId = cluster->geographicalId();
339  // int firstStrip = cluster->firstStrip();
340  stModInfo* MOD = MODsColl[detId];
341 
342 
343  // Sanity Checks
344  if( ampls.size()>MaxNrStrips) {return -1;}
345 // if( DeDxDiscriminatorTools::IsSaturatingStrip (ampls)) {return -1;}
346 // if( DeDxDiscriminatorTools::IsSpanningOver2APV (firstStrip, ampls.size())) {return -1;}
347 // if(!DeDxDiscriminatorTools::IsFarFromBorder (trajState, m_tracker->idToDetUnit(DetId(detId)) )) {return -1;}
348 
349 
350  // Find Probability for this given Charge and Path
351  double charge = 0;
352  if(useCalibration){
353  for(unsigned int i=0;i<ampls.size();i++){
354  int CalibratedCharge = ampls[i];
355  CalibratedCharge = (int)(CalibratedCharge / MOD->Gain);
356  if(CalibratedCharge>=1024){
357  CalibratedCharge = 255;
358  }else if(CalibratedCharge>254){
359  CalibratedCharge = 254;
360  }
361  charge+=CalibratedCharge;
362  }
363  }else{
364  charge = DeDxDiscriminatorTools::charge(ampls);
365  }
366  double path = DeDxDiscriminatorTools::path(cosine,MOD->Thickness);
367 
368  int BinX = Prob_ChargePath->GetXaxis()->FindBin(trajState.localMomentum().mag());
369  int BinY = Prob_ChargePath->GetYaxis()->FindBin(path);
370  int BinZ = Prob_ChargePath->GetZaxis()->FindBin(charge/path);
371  return Prob_ChargePath->GetBinContent(BinX,BinY,BinZ);
372 }
double path(double cosine, double thickness)
int i
Definition: DBlmapReader.cc:9
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
LocalVector localDirection() const
double charge(const std::vector< uint8_t > &Ampls)
LocalVector localMomentum() const
T mag() const
Definition: PV3DBase.h:67
tuple path
else: Piece not in the list, fine.
T z() const
Definition: PV3DBase.h:64
const std::vector< uint8_t > & amplitudes() const
void DeDxDiscriminatorProducer::MakeCalibrationMap ( )
private

Definition at line 430 of file DeDxDiscriminatorProducer.cc.

References DeDxDiscriminatorProducer::stModInfo::Gain.

430  {
431  if(!useCalibration)return;
432 
433 
434  TChain* t1 = new TChain("SiStripCalib/APVGain");
435  t1->Add(m_calibrationPath.c_str());
436 
437  unsigned int tree_DetId;
438  unsigned char tree_APVId;
439  double tree_Gain;
440 
441  t1->SetBranchAddress("DetId" ,&tree_DetId );
442  t1->SetBranchAddress("APVId" ,&tree_APVId );
443  t1->SetBranchAddress("Gain" ,&tree_Gain );
444 
445  for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
446  t1->GetEntry(ientry);
447  stModInfo* MOD = MODsColl[tree_DetId];
448  MOD->Gain = tree_Gain;
449  }
450 
451  delete t1;
452 
453 }
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
void DeDxDiscriminatorProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 227 of file DeDxDiscriminatorProducer.cc.

References edm::AssociationMap< Tag >::begin(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, edm::AssociationMap< Tag >::end(), reco::TrackBase::eta(), edm::helper::Filler< Map >::fill(), reco::Track::found(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), DeDxTools::GetCluster(), edm::helper::Filler< Map >::insert(), TrajectoryStateOnSurface::isValid(), Trajectory::measurements(), SiStripMatchedRecHit2D::monoHit(), SiStripMatchedRecHit2D::monoId(), reco::TrackBase::p(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), DeDxTools::shapeSelection(), edm::AssociationMap< Tag >::size(), findQualityFiles::size, SiStripMatchedRecHit2D::stereoHit(), and SiStripMatchedRecHit2D::stereoId().

228 {
229  auto_ptr<ValueMap<DeDxData> > trackDeDxDiscrimAssociation(new ValueMap<DeDxData> );
230  ValueMap<DeDxData>::Filler filler(*trackDeDxDiscrimAssociation);
231 
232  Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
233  iEvent.getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
234  const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();
235 
236  edm::Handle<reco::TrackCollection> trackCollectionHandle;
237  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
238 
240  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
241  m_tracker = tkGeom.product();
242 
243  std::vector<DeDxData> dEdxDiscrims( TrajToTrackMap.size() );
244 
245  unsigned track_index = 0;
246  for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it, track_index++) {
247  dEdxDiscrims[track_index] = DeDxData(-1, -2, 0 );
248 
249  const Track track = *it->val;
250  const Trajectory traj = *it->key;
251 
252  if(track.eta() <MinTrackEta || track.eta()>MaxTrackEta ){continue;}
253  if(track.p() <MinTrackMomentum || track.p() >MaxTrackMomentum){continue;}
254  if(track.found()<MinTrackHits ){continue;}
255 
256  std::vector<double> vect_probs;
257  vector<TrajectoryMeasurement> measurements = traj.measurements();
258 
259  unsigned int NClusterSaturating = 0;
260  for(vector<TrajectoryMeasurement>::const_iterator measurement_it = measurements.begin(); measurement_it!=measurements.end(); measurement_it++){
261 
262  TrajectoryStateOnSurface trajState = measurement_it->updatedState();
263  if( !trajState.isValid() ) continue;
264 
265  const TrackingRecHit* hit = (*measurement_it->recHit()).hit();
266  const SiStripRecHit2D* sistripsimplehit = dynamic_cast<const SiStripRecHit2D*>(hit);
267  const SiStripMatchedRecHit2D* sistripmatchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>(hit);
268  const SiStripRecHit1D* sistripsimple1dhit = dynamic_cast<const SiStripRecHit1D*>(hit);
269 
270  double Prob;
271  if(sistripsimplehit){
272  Prob = GetProbability(DeDxTools::GetCluster(sistripsimplehit), trajState,sistripsimplehit->geographicalId());
273  if(shapetest && !(DeDxTools::shapeSelection(DeDxTools::GetCluster(sistripsimplehit)->amplitudes()))) Prob=-1.0;
274  if(Prob>=0) vect_probs.push_back(Prob);
275 
276  if(ClusterSaturatingStrip(DeDxTools::GetCluster(sistripsimplehit),sistripsimplehit->geographicalId())>0)NClusterSaturating++;
277 
278  }else if(sistripmatchedhit){
279  Prob = GetProbability(DeDxTools::GetCluster(sistripmatchedhit->monoHit()), trajState, sistripmatchedhit->monoId());
280  if(shapetest && !(DeDxTools::shapeSelection(DeDxTools::GetCluster(sistripmatchedhit->monoHit())->amplitudes()))) Prob=-1.0;
281  if(Prob>=0) vect_probs.push_back(Prob);
282 
283  Prob = GetProbability(DeDxTools::GetCluster(sistripmatchedhit->stereoHit()), trajState,sistripmatchedhit->stereoId());
284  if(Prob>=0) vect_probs.push_back(Prob);
285 
286  if(ClusterSaturatingStrip(DeDxTools::GetCluster(sistripmatchedhit->monoHit()),sistripmatchedhit->monoId()) >0)NClusterSaturating++;
287  if(ClusterSaturatingStrip(DeDxTools::GetCluster(sistripmatchedhit->stereoHit()),sistripmatchedhit->stereoId())>0)NClusterSaturating++;
288  }else if(sistripsimple1dhit){
289  Prob = GetProbability(DeDxTools::GetCluster(sistripsimple1dhit), trajState, sistripsimple1dhit->geographicalId());
290  if(shapetest && !(DeDxTools::shapeSelection(DeDxTools::GetCluster(sistripsimple1dhit)->amplitudes()))) Prob=-1.0;
291  if(Prob>=0) vect_probs.push_back(Prob);
292  if(ClusterSaturatingStrip(DeDxTools::GetCluster(sistripsimple1dhit),sistripsimple1dhit->geographicalId())>0)NClusterSaturating++;
293  }else{
294  }
295  }
296 
297  double estimator = ComputeDiscriminator(vect_probs);
298  int size = vect_probs.size();
299  float Error = -1;
300 
301  //WARNING: Since the dEdX Error is not properly computed for the moment
302  //It was decided to store the number of saturating cluster in that dataformat
303  Error = NClusterSaturating;
304  dEdxDiscrims[track_index] = DeDxData(estimator, Error, size );
305 
306 // printf("%i --> %g\n",size,estimator);
307  }
308 
309  filler.insert(trackCollectionHandle, dEdxDiscrims.begin(), dEdxDiscrims.end());
310  filler.fill();
311  iEvent.put(trackDeDxDiscrimAssociation);
312 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
unsigned int stereoId() const
const SiStripCluster * GetCluster(const TrackerSingleRecHit *hit)
Definition: DeDxTools.h:27
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const TrackerGeometry * m_tracker
double GetProbability(const SiStripCluster *cluster, TrajectoryStateOnSurface trajState, const uint32_t &)
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
fixed size error matrix
Definition: Error.h:38
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
DataContainer const & measurements() const
Definition: Trajectory.h:203
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
SiStripRecHit2D stereoHit() const
bool shapeSelection(const std::vector< uint8_t > &ampls)
Definition: DeDxTools.cc:133
size_type size() const
map size
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
int ClusterSaturatingStrip(const SiStripCluster *cluster, const uint32_t &)
T const * product() const
Definition: Handle.h:81
SiStripRecHit2D monoHit() const
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:100
double ComputeDiscriminator(std::vector< double > &vect_probs)
unsigned int monoId() const
const_iterator begin() const
first iterator over the map (read only)
DetId geographicalId() const
tuple size
Write out results.

Member Data Documentation

PhysicsTools::Calibration::HistogramD3D DeDxDiscriminatorProducer::DeDxMap_
private

Definition at line 83 of file DeDxDiscriminatorProducer.h.

unsigned int DeDxDiscriminatorProducer::Formula
private

Definition at line 93 of file DeDxDiscriminatorProducer.h.

std::string DeDxDiscriminatorProducer::m_calibrationPath
private

Definition at line 76 of file DeDxDiscriminatorProducer.h.

const TrackerGeometry* DeDxDiscriminatorProducer::m_tracker
private

Definition at line 81 of file DeDxDiscriminatorProducer.h.

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

Definition at line 69 of file DeDxDiscriminatorProducer.h.

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

Definition at line 68 of file DeDxDiscriminatorProducer.h.

unsigned int DeDxDiscriminatorProducer::MaxNrStrips
private

Definition at line 89 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MaxTrackChiOverNdf
private

Definition at line 91 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MaxTrackEta
private

Definition at line 88 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MaxTrackMomentum
private

Definition at line 86 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MeVperADCPixel
private

Definition at line 73 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MeVperADCStrip
private

Definition at line 74 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MinTrackEta
private

Definition at line 87 of file DeDxDiscriminatorProducer.h.

unsigned int DeDxDiscriminatorProducer::MinTrackHits
private

Definition at line 90 of file DeDxDiscriminatorProducer.h.

double DeDxDiscriminatorProducer::MinTrackMomentum
private

Definition at line 85 of file DeDxDiscriminatorProducer.h.

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

Definition at line 110 of file DeDxDiscriminatorProducer.h.

TH3D* DeDxDiscriminatorProducer::Prob_ChargePath
private

Definition at line 98 of file DeDxDiscriminatorProducer.h.

std::string DeDxDiscriminatorProducer::ProbabilityMode
private

Definition at line 95 of file DeDxDiscriminatorProducer.h.

std::string DeDxDiscriminatorProducer::Reccord
private

Definition at line 94 of file DeDxDiscriminatorProducer.h.

bool DeDxDiscriminatorProducer::shapetest
private

Definition at line 78 of file DeDxDiscriminatorProducer.h.

bool DeDxDiscriminatorProducer::useCalibration
private

Definition at line 77 of file DeDxDiscriminatorProducer.h.

bool DeDxDiscriminatorProducer::usePixel
private

Definition at line 71 of file DeDxDiscriminatorProducer.h.

bool DeDxDiscriminatorProducer::useStrip
private

Definition at line 72 of file DeDxDiscriminatorProducer.h.