CMS 3D CMS Logo

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

#include <EcalUncalibRecHitWorkerMultiFit.h>

Inheritance diagram for EcalUncalibRecHitWorkerMultiFit:
EcalUncalibRecHitWorkerBaseClass

Public Member Functions

 EcalUncalibRecHitWorkerMultiFit (const edm::ParameterSet &, edm::ConsumesCollector &c)
 
bool run (const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
 
void set (const edm::EventSetup &es)
 
virtual ~EcalUncalibRecHitWorkerMultiFit ()
 
- Public Member Functions inherited from EcalUncalibRecHitWorkerBaseClass
 EcalUncalibRecHitWorkerBaseClass (const edm::ParameterSet &, edm::ConsumesCollector &c)
 
 EcalUncalibRecHitWorkerBaseClass (const edm::ParameterSet &)
 
virtual ~EcalUncalibRecHitWorkerBaseClass ()
 

Protected Member Functions

const SampleMatrixnoisecor (bool barrel, int gain) const
 
double timeCorrection (float ampli, const std::vector< float > &amplitudeBins, const std::vector< float > &shiftBins)
 

Protected Attributes

BXVector activeBX
 
bool ampErrorCalculation_
 
double chi2ThreshEB_
 
double chi2ThreshEE_
 
std::vector< double > EBamplitudeFitParameters_
 
std::vector< double > ebPulseShape_
 
double EBtimeConstantTerm_
 
std::pair< double, double > EBtimeFitLimits_
 
std::vector< double > EBtimeFitParameters_
 
edm::ParameterSet EcalPulseShapeParameters_
 
std::vector< double > EEamplitudeFitParameters_
 
std::vector< double > eePulseShape_
 
double EEtimeConstantTerm_
 
std::pair< double, double > EEtimeFitLimits_
 
std::vector< double > EEtimeFitParameters_
 
FullSampleMatrix fullpulsecovEB
 
FullSampleMatrix fullpulsecovEE
 
FullSampleVector fullpulseEB
 
FullSampleVector fullpulseEE
 
double gainRatios [3]
 
edm::ESHandle< EcalGainRatiosgains
 
edm::ESHandle
< EcalWeightXtalGroups
grps
 
edm::ESHandle
< EcalTimeCalibConstants
itime
 
bool kPoorRecoFlagEB_
 
bool kPoorRecoFlagEE_
 
EcalUncalibRecHitLeadingEdgeAlgo
< EBDataFrame
leadingEdgeMethod_barrel_
 
EcalUncalibRecHitLeadingEdgeAlgo
< EEDataFrame
leadingEdgeMethod_endcap_
 
EcalUncalibRecHitMultiFitAlgo multiFitMethod_
 
SampleMatrix noisecorEBg1
 
SampleMatrix noisecorEBg12
 
SampleMatrix noisecorEBg6
 
SampleMatrix noisecorEEg1
 
SampleMatrix noisecorEEg12
 
SampleMatrix noisecorEEg6
 
edm::ESHandle
< EcalTimeOffsetConstant
offtime
 
double pedRMSVec [3]
 
edm::ESHandle< EcalPedestalspeds
 
double pedVec [3]
 
EcalUncalibRecHitRatioMethodAlgo
< EBDataFrame
ratioMethod_barrel_
 
EcalUncalibRecHitRatioMethodAlgo
< EEDataFrame
ratioMethod_endcap_
 
edm::ESHandle< EcalSampleMasksampleMaskHand_
 
std::string timealgo_
 
edm::ESHandle
< EcalTimeBiasCorrections
timeCorrBias_
 
const
EcalWeightSet::EcalWeightMatrix
weights [2]
 
EcalUncalibRecHitTimeWeightsAlgo
< EBDataFrame
weightsMethod_barrel_
 
EcalUncalibRecHitTimeWeightsAlgo
< EEDataFrame
weightsMethod_endcap_
 
edm::ESHandle< EcalTBWeightswgts
 

Private Member Functions

void fillInputs (const edm::ParameterSet &params)
 

Detailed Description

Definition at line 37 of file EcalUncalibRecHitWorkerMultiFit.h.

Constructor & Destructor Documentation

EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit ( const edm::ParameterSet ps,
edm::ConsumesCollector c 
)

Definition at line 18 of file EcalUncalibRecHitWorkerMultiFit.cc.

References activeBX, ampErrorCalculation_, chi2ThreshEB_, chi2ThreshEE_, EBamplitudeFitParameters_, ebPulseShape_, EBtimeConstantTerm_, EBtimeFitLimits_, EBtimeFitParameters_, EcalPulseShapeParameters_, EEamplitudeFitParameters_, eePulseShape_, EEtimeConstantTerm_, EEtimeFitLimits_, EEtimeFitParameters_, fillInputs(), edm::ParameterSet::getParameter(), kPoorRecoFlagEB_, kPoorRecoFlagEE_, BXVector< T >::resize(), AlCaHLTBitMon_QueryRunRegistry::string, and timealgo_.

18  :
20  noisecorEBg12(SampleMatrix::Zero()), noisecorEEg12(SampleMatrix::Zero()),
21  noisecorEBg6(SampleMatrix::Zero()), noisecorEEg6(SampleMatrix::Zero()),
22  noisecorEBg1(SampleMatrix::Zero()), noisecorEEg1(SampleMatrix::Zero()),
23  fullpulseEB(FullSampleVector::Zero()),fullpulseEE(FullSampleVector::Zero()),
24  fullpulsecovEB(FullSampleMatrix::Zero()),fullpulsecovEE(FullSampleMatrix::Zero()) {
25 
26  // get the pulse shape, amplitude covariances and noise correlations
27  EcalPulseShapeParameters_ = ps.getParameter<edm::ParameterSet>("EcalPulseShapeParameters");
29 
30  // get the BX for the pulses to be activated
31  std::vector<int32_t> activeBXs = ps.getParameter< std::vector<int32_t> >("activeBXs");
32  activeBX.resize(activeBXs.size());
33  for (unsigned int ibx=0; ibx<activeBXs.size(); ++ibx) {
34  activeBX.coeffRef(ibx) = activeBXs[ibx];
35  }
36 
37  // uncertainty calculation (CPU intensive)
38  ampErrorCalculation_ = ps.getParameter<bool>("ampErrorCalculation");
39 
40  // algorithm to be used for timing
41  timealgo_ = ps.getParameter<std::string>("timealgo");
42 
43  // ratio method parameters
44  EBtimeFitParameters_ = ps.getParameter<std::vector<double> >("EBtimeFitParameters");
45  EEtimeFitParameters_ = ps.getParameter<std::vector<double> >("EEtimeFitParameters");
46  EBamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EBamplitudeFitParameters");
47  EEamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EEamplitudeFitParameters");
48  EBtimeFitLimits_.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
49  EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
50  EEtimeFitLimits_.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
51  EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
52  EBtimeConstantTerm_=ps.getParameter<double>("EBtimeConstantTerm");
53  EEtimeConstantTerm_=ps.getParameter<double>("EEtimeConstantTerm");
54 
55  // leading edge parameters
56  ebPulseShape_ = ps.getParameter<std::vector<double> >("ebPulseShape");
57  eePulseShape_ = ps.getParameter<std::vector<double> >("eePulseShape");
58 
59  // chi2 parameters for flags determination
60  kPoorRecoFlagEB_ = ps.getParameter<bool>("kPoorRecoFlagEB");
61  kPoorRecoFlagEE_ = ps.getParameter<bool>("kPoorRecoFlagEE");;
62  chi2ThreshEB_=ps.getParameter<double>("chi2ThreshEB_");
63  chi2ThreshEE_=ps.getParameter<double>("chi2ThreshEE_");
64 
65 }
T getParameter(std::string const &) const
EcalUncalibRecHitWorkerBaseClass(const edm::ParameterSet &, edm::ConsumesCollector &c)
void resize(int bx, unsigned size)
void fillInputs(const edm::ParameterSet &params)
virtual EcalUncalibRecHitWorkerMultiFit::~EcalUncalibRecHitWorkerMultiFit ( )
inlinevirtual

Definition at line 42 of file EcalUncalibRecHitWorkerMultiFit.h.

42 {};

Member Function Documentation

void EcalUncalibRecHitWorkerMultiFit::fillInputs ( const edm::ParameterSet params)
private

Definition at line 437 of file EcalUncalibRecHitWorkerMultiFit.cc.

References funct::abs(), fullpulsecovEB, fullpulsecovEE, fullpulseEB, fullpulseEE, edm::ParameterSet::getParameter(), i, j, gen::k, noisecorEBg1, noisecorEBg12, noisecorEBg6, noisecorEEg1, noisecorEEg12, noisecorEEg6, and funct::pow().

Referenced by EcalUncalibRecHitWorkerMultiFit().

437  {
438 
439  const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
440  const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
441  const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
442  const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
443  const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
444  const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
445 
446  int nnoise = ebCorMatG12.size();
447 
448  // fill correlation matrices: noise (HF (+) LF)
449  for (int i=0; i<nnoise; ++i) {
450  for (int j=0; j<nnoise; ++j) {
451  int vidx = std::abs(j-i);
452  noisecorEBg12(i,j) = ebCorMatG12[vidx];
453  noisecorEEg12(i,j) = eeCorMatG12[vidx];
454  noisecorEBg6(i,j) = ebCorMatG06[vidx];
455  noisecorEEg6(i,j) = eeCorMatG06[vidx];
456  noisecorEBg1(i,j) = ebCorMatG01[vidx];
457  noisecorEEg1(i,j) = eeCorMatG01[vidx];
458  }
459  }
460 
461  // fill shape: from simulation for samples 3-9, from alpha/beta shape for 10-14
462  const std::vector<double> ebPulse = params.getParameter< std::vector<double> >("EBPulseShapeTemplate");
463  const std::vector<double> eePulse = params.getParameter< std::vector<double> >("EEPulseShapeTemplate");
464  int nShapeSamples = ebPulse.size();
465  for (int i=0; i<nShapeSamples; ++i) {
466  fullpulseEB(i+7) = ebPulse[i];
467  fullpulseEE(i+7) = eePulse[i];
468  }
469 
470  const std::vector<double> ebPulseCov = params.getParameter< std::vector<double> >("EBPulseShapeCovariance");
471  const std::vector<double> eePulseCov = params.getParameter< std::vector<double> >("EEPulseShapeCovariance");
472  for(int k=0; k<std::pow(nShapeSamples,2); ++k) {
473  int i = k/nShapeSamples;
474  int j = k%nShapeSamples;
475  fullpulsecovEB(i+7,j+7) = ebPulseCov[k];
476  fullpulsecovEE(i+7,j+7) = eePulseCov[k];
477  }
478 
479 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const SampleMatrix & EcalUncalibRecHitWorkerMultiFit::noisecor ( bool  barrel,
int  gain 
) const
protected

Definition at line 409 of file EcalUncalibRecHitWorkerMultiFit.cc.

References noisecorEBg1, noisecorEBg12, noisecorEBg6, noisecorEEg1, noisecorEEg12, and noisecorEEg6.

Referenced by run().

409  {
410  if (barrel) {
411  if (gain==6) {
412  return noisecorEBg6;
413  }
414  else if (gain==1) {
415  return noisecorEBg1;
416  }
417  else {
418  return noisecorEBg12;
419  }
420  }
421  else {
422  if (gain==6) {
423  return noisecorEEg6;
424  }
425  else if (gain==1) {
426  return noisecorEEg1;
427  }
428  else {
429  return noisecorEEg12;
430  }
431  }
432 
433  return noisecorEBg12;
434 
435 }
bool EcalUncalibRecHitWorkerMultiFit::run ( const edm::Event evt,
const EcalDigiCollection::const_iterator digi,
EcalUncalibratedRecHitCollection result 
)
virtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 196 of file EcalUncalibRecHitWorkerMultiFit.cc.

References activeBX, EcalUncalibratedRecHit::amplitude(), Reference_intrackfit_cff::barrel, EcalUncalibRecHitRatioMethodAlgo< C >::computeAmplitude(), EcalUncalibRecHitRatioMethodAlgo< C >::computeTime(), cond::rpcobgas::detid, EBamplitudeFitParameters_, ebPulseShape_, EBtimeConstantTerm_, EBtimeFitLimits_, EBtimeFitParameters_, EcalBarrel, EcalEndcap, EEamplitudeFitParameters_, eePulseShape_, EEtimeConstantTerm_, EEtimeFitLimits_, EEtimeFitParameters_, EcalUncalibRecHitRatioMethodAlgo< C >::fixMGPAslew(), fullpulsecovEB, fullpulsecovEE, fullpulseEB, fullpulseEE, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), gainRatios, gains, EcalUncalibRecHitRatioMethodAlgo< C >::getCalculatedRecHit(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), grps, ecalpyutils::hashedIndex(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EcalXtalGroupId::id(), EcalUncalibRecHitRatioMethodAlgo< C >::init(), EcalUncalibratedRecHit::kHasSwitchToGain1, EcalUncalibratedRecHit::kHasSwitchToGain6, EcalUncalibratedRecHit::kLeadingEdgeRecovered, EcalUncalibratedRecHit::kSaturated, leadingEdgeMethod_barrel_, leadingEdgeMethod_endcap_, EcalUncalibRecHitMultiFitAlgo::makeRecHit(), EcalUncalibRecHitLeadingEdgeAlgo< C >::makeRecHit(), EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, multiFitMethod_, noisecor(), EcalUncalibratedRecHit::outOfTimeAmplitude(), pedRMSVec, peds, pedVec, funct::pow(), edm::ESHandle< class >::product(), edm::SortedCollection< T, SORT >::push_back(), ratioMethod_barrel_, ratioMethod_endcap_, EcalPedestal::rms_x1, EcalPedestal::rms_x12, EcalPedestal::rms_x6, sampleMaskHand_, EcalUncalibratedRecHit::setChi2(), EcalUncalibratedRecHit::setFlagBit(), EcalUncalibratedRecHit::setJitter(), EcalUncalibratedRecHit::setJitterError(), EcalUncalibRecHitLeadingEdgeAlgo< C >::setLeadingEdgeSample(), EcalUncalibRecHitLeadingEdgeAlgo< C >::setPulseShape(), BXVector< T >::size(), mathSSE::sqrt(), EcalUncalibRecHitTimeWeightsAlgo< C >::time(), timealgo_, timeCorrBias_, timeCorrection(), weights, weightsMethod_barrel_, weightsMethod_endcap_, and wgts.

199 {
200  DetId detid(itdg->id());
201 
202  const EcalSampleMask *sampleMask_ = sampleMaskHand_.product();
203 
204  // intelligence for recHit computation
205  EcalUncalibratedRecHit uncalibRecHit;
206 
207 
208  const EcalPedestals::Item * aped = 0;
209  const EcalMGPAGainRatio * aGain = 0;
210  const EcalXtalGroupId * gid = 0;
211 
212  if (detid.subdetId()==EcalEndcap) {
213  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
214  aped = &peds->endcap(hashedIndex);
215  aGain = &gains->endcap(hashedIndex);
216  gid = &grps->endcap(hashedIndex);
217  } else {
218  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
219  aped = &peds->barrel(hashedIndex);
220  aGain = &gains->barrel(hashedIndex);
221  gid = &grps->barrel(hashedIndex);
222  }
223 
224  pedVec[0] = aped->mean_x12;
225  pedVec[1] = aped->mean_x6;
226  pedVec[2] = aped->mean_x1;
227  pedRMSVec[0] = aped->rms_x12;
228  pedRMSVec[1] = aped->rms_x6;
229  pedRMSVec[2] = aped->rms_x1;
230  gainRatios[0] = 1.;
231  gainRatios[1] = aGain->gain12Over6();
232  gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
233 
234 
235  // === amplitude computation ===
236  int leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
237 
238  if ( leadingSample >= 0 ) { // saturation
239  if ( leadingSample != 4 ) {
240  // all samples different from the fifth are not reliable for the amplitude estimation
241  // put by default the energy at the saturation threshold and flag as saturated
242  float sratio = 1;
243  if ( detid.subdetId()==EcalBarrel) {
244  sratio = ebPulseShape_[5] / ebPulseShape_[4];
245  } else {
246  sratio = eePulseShape_[5] / eePulseShape_[4];
247  }
248  uncalibRecHit = EcalUncalibratedRecHit( (*itdg).id(), 4095*12*sratio, 0, 0, 0);
250  } else {
251  // float clockToNsConstant = 25.;
252  // reconstruct the rechit
253  if (detid.subdetId()==EcalEndcap) {
255  // float mult = (float)eePulseShape_.size() / (float)(*itdg).size();
256  // bin (or some analogous mapping) will be used instead of the leadingSample
257  //int bin = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
258  // bin is not uset for the moment
260  uncalibRecHit = leadingEdgeMethod_endcap_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
263  } else {
265  // float mult = (float)ebPulseShape_.size() / (float)(*itdg).size();
266  // bin (or some analogous mapping) will be used instead of the leadingSample
267  //int bin = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
268  // bin is not uset for the moment
270  uncalibRecHit = leadingEdgeMethod_barrel_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
273  }
274  }
275  // do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
276  uncalibRecHit.setChi2(0);
277  } else {
278  // multifit
279  bool barrel = detid.subdetId()==EcalBarrel;
280  int gain = 12;
281  if (((EcalDataFrame)(*itdg)).hasSwitchToGain6()) {
282  gain = 6;
283  }
284  if (((EcalDataFrame)(*itdg)).hasSwitchToGain1()) {
285  gain = 1;
286  }
287  const SampleMatrix &noisecormat = noisecor(barrel,gain);
288  const FullSampleVector &fullpulse = barrel ? fullpulseEB : fullpulseEE;
289  const FullSampleMatrix &fullpulsecov = barrel ? fullpulsecovEB : fullpulsecovEE;
290 
291  uncalibRecHit = multiFitMethod_.makeRecHit(*itdg, aped, aGain, noisecormat,fullpulse,fullpulsecov,activeBX);
292 
293  // === time computation ===
294  if(timealgo_.compare("RatioMethod")==0) {
295  // ratio method
296  float const clockToNsConstant = 25.;
297  if (detid.subdetId()==EcalEndcap) {
298  ratioMethod_endcap_.init( *itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios );
302  double theTimeCorrectionEE = timeCorrection(uncalibRecHit.amplitude(),
303  timeCorrBias_->EETimeCorrAmplitudeBins, timeCorrBias_->EETimeCorrShiftBins);
304 
305  uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
306  uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) + std::pow(EEtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
307 
308  } else {
309  ratioMethod_barrel_.init( *itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios );
314 
315  double theTimeCorrectionEB = timeCorrection(uncalibRecHit.amplitude(),
316  timeCorrBias_->EBTimeCorrAmplitudeBins, timeCorrBias_->EBTimeCorrShiftBins);
317 
318  uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
319 
320  uncalibRecHit.setJitterError( std::sqrt(std::pow(crh.timeError,2) + std::pow(EBtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
321  }
322  } else if(timealgo_.compare("WeightsMethod")==0) {
323  // weights method on the PU subtracted pulse shape
324  std::vector<double> amplitudes;
325  for(unsigned int ibx=0; ibx<activeBX.size(); ++ibx) amplitudes.push_back(uncalibRecHit.outOfTimeAmplitude(ibx));
326 
327  EcalTBWeights::EcalTDCId tdcid(1);
328  EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
329  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
330  wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
331  if( wit == wgtsMap.end() ) {
332  edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: "
333  << gid->id() << " and EcalTDCId: " << tdcid
334  << "\n skipping digi with id: " << detid.rawId();
335 
336  return false;
337  }
338  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
339 
342 
343  weights[0] = &mat1;
344  weights[1] = &mat2;
345 
346  double timerh;
347  if (detid.subdetId()==EcalEndcap) {
348  timerh = weightsMethod_endcap_.time( *itdg, amplitudes, aped, aGain, fullpulse, weights);
349  } else {
350  timerh = weightsMethod_barrel_.time( *itdg, amplitudes, aped, aGain, fullpulse, weights);
351  }
352  uncalibRecHit.setJitter( timerh );
353  uncalibRecHit.setJitterError( 0. ); // not computed with weights
354  } else if(timealgo_.compare("None")==0) {
355  uncalibRecHit.setJitter( 0. );
356  uncalibRecHit.setJitterError( 0. );
357  } else {
358  edm::LogError("EcalUncalibRecHitError") << "No time estimation algorithm called "
359  << timealgo_
360  << "\n setting jitter to 0. and jitter uncertainty to 10000. ";
361 
362  uncalibRecHit.setJitter( 0. );
363  uncalibRecHit.setJitterError( 10000. );
364  }
365  }
366 
367  // set flags if gain switch has occurred
368  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
369  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
370 
371  // set quality flags based on chi2 of the the fit
372  /*
373  if(detid.subdetId()==EcalEndcap) {
374  if(kPoorRecoFlagEE_ && uncalibRecHit.chi2()>chi2ThreshEE_) {
375  bool samplesok = true;
376  for (int sample =0; sample < EcalDataFrame::MAXSAMPLES; ++sample) {
377  if (!sampleMask_->useSampleEE(sample)) {
378  samplesok = false;
379  break;
380  }
381  }
382  if (samplesok) uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kPoorReco);
383  }
384  } else {
385  if(kPoorRecoFlagEB_ && uncalibRecHit.chi2()>chi2ThreshEB_) {
386  bool samplesok = true;
387  for (int sample =0; sample < EcalDataFrame::MAXSAMPLES; ++sample) {
388  if (!sampleMask_->useSampleEB(sample)) {
389  samplesok = false;
390  break;
391  }
392  }
393  if (samplesok) uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kPoorReco);
394  }
395  }
396  */
397 
398  // put the recHit in the collection
399  if (detid.subdetId()==EcalEndcap) {
400  result.push_back( uncalibRecHit );
401  } else {
402  result.push_back( uncalibRecHit );
403  }
404 
405  return true;
406 }
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:21
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
void computeAmplitude(std::vector< double > &amplitudeFitParameters)
unsigned size(int bx) const
EcalUncalibRecHitMultiFitAlgo multiFitMethod_
const SampleMatrix & noisecor(bool barrel, int gain) const
void setJitter(float jitter)
EcalUncalibRecHitTimeWeightsAlgo< EEDataFrame > weightsMethod_endcap_
EcalUncalibRecHitLeadingEdgeAlgo< EBDataFrame > leadingEdgeMethod_barrel_
double time(const C &dataFrame, const std::vector< double > &amplitudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, const EcalWeightSet::EcalWeightMatrix **weights)
Compute time.
EcalUncalibratedRecHit makeRecHit(const EcalDataFrame &dataFrame, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const SampleMatrix &noisecor, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const BXVector &activeBX)
compute rechits
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &amplitudeFitParameters)
edm::ESHandle< EcalWeightXtalGroups > grps
void push_back(T const &t)
void setJitterError(float jitterErr)
Eigen::Matrix< double, 19, 19 > FullSampleMatrix
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
void setPulseShape(std::vector< double > &shape)
const unsigned int id() const
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
float outOfTimeAmplitude(int bx) const
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
T sqrt(T t)
Definition: SSEVec.h:48
double timeCorrection(float ampli, const std::vector< float > &amplitudeBins, const std::vector< float > &shiftBins)
float gain6Over1() const
Eigen::Matrix< double, 19, 1 > FullSampleVector
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:30
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix)
Compute parameters.
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
Definition: DetId.h:18
EcalUncalibRecHitLeadingEdgeAlgo< EEDataFrame > leadingEdgeMethod_endcap_
int hashedIndex() const
Definition: EEDetId.h:182
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:29
T const * product() const
Definition: ESHandle.h:86
float gain12Over6() const
EcalUncalibRecHitTimeWeightsAlgo< EBDataFrame > weightsMethod_barrel_
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:22
edm::ESHandle< EcalSampleMask > sampleMaskHand_
const EcalWeightSet::EcalWeightMatrix * weights[2]
Eigen::Matrix< double, 10, 10 > SampleMatrix
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void EcalUncalibRecHitWorkerMultiFit::set ( const edm::EventSetup es)
virtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 103 of file EcalUncalibRecHitWorkerMultiFit.cc.

References ampErrorCalculation_, EcalUncalibRecHitMultiFitAlgo::disableErrorCalculation(), gains, edm::EventSetup::get(), grps, itime, multiFitMethod_, offtime, peds, sampleMaskHand_, timeCorrBias_, and wgts.

Referenced by betterConfigParser.BetterConfigParser::getGeneral().

104 {
105 
106  // common setup
107  es.get<EcalGainRatiosRcd>().get(gains);
108  es.get<EcalPedestalsRcd>().get(peds);
109 
110  // for the multifit method
112 
113  // weights parameters for the time
114  es.get<EcalWeightXtalGroupsRcd>().get(grps);
115  es.get<EcalTBWeightsRcd>().get(wgts);
116 
117  // which of the samples need be used
119 
120  // for the ratio method
121 
122  // for the leading edge method
125 
126  // for the time correction methods
128 }
EcalUncalibRecHitMultiFitAlgo multiFitMethod_
edm::ESHandle< EcalWeightXtalGroups > grps
edm::ESHandle< EcalTimeCalibConstants > itime
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< EcalTimeOffsetConstant > offtime
edm::ESHandle< EcalSampleMask > sampleMaskHand_
double EcalUncalibRecHitWorkerMultiFit::timeCorrection ( float  ampli,
const std::vector< float > &  amplitudeBins,
const std::vector< float > &  shiftBins 
)
protected

Amplitude-dependent time corrections; EE and EB have separate corrections: EXtimeCorrAmplitudes (ADC) and EXtimeCorrShifts (ns) need to have the same number of elements Bins must be ordered in amplitude. First-last bins take care of under-overflows.

The algorithm is the same for EE and EB, only the correction vectors are different.

Returns
Jitter (in clock cycles) which will be added to UncalibRechit.setJitter(), 0 if no correction is applied.

Definition at line 139 of file EcalUncalibRecHitWorkerMultiFit.cc.

References newFWLiteAna::bin.

Referenced by run().

142  {
143 
144  // computed initially in ns. Than turned in the BX's, as
145  // EcalUncalibratedRecHit need be.
146  double theCorrection = 0;
147 
148  // sanity check for arrays
149  if (amplitudeBins.size() == 0) {
150  edm::LogError("EcalRecHitError")
151  << "timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
152 
153  return 0;
154  }
155 
156  if (amplitudeBins.size() != shiftBins.size()) {
157  edm::LogError("EcalRecHitError")
158  << "Size of timeCorrAmplitudeBins different from "
159  "timeCorrShiftBins. Forcing no time bias corrections. ";
160 
161  return 0;
162  }
163 
164  int myBin = -1;
165  for (int bin = 0; bin < (int) amplitudeBins.size(); bin++) {
166  if (ampli > amplitudeBins.at(bin)) {
167  myBin = bin;
168  } else {
169  break;
170  }
171  }
172 
173  if (myBin == -1) {
174  theCorrection = shiftBins.at(0);
175  } else if (myBin == ((int)(amplitudeBins.size() - 1))) {
176  theCorrection = shiftBins.at(myBin);
177  } else if (-1 < myBin && myBin < ((int) amplitudeBins.size() - 1)) {
178  // interpolate linearly between two assingned points
179  theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
180  theCorrection *= (((double) ampli) - amplitudeBins.at(myBin)) /
181  (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
182  theCorrection += shiftBins.at(myBin);
183  } else {
184  edm::LogError("EcalRecHitError")
185  << "Assigning time correction impossible. Setting it to 0 ";
186  theCorrection = 0.;
187  }
188 
189  // convert ns into clocks
190  return theCorrection / 25.;
191 }

Member Data Documentation

BXVector EcalUncalibRecHitWorkerMultiFit::activeBX
protected

Definition at line 74 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

bool EcalUncalibRecHitWorkerMultiFit::ampErrorCalculation_
protected

Definition at line 75 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and set().

double EcalUncalibRecHitWorkerMultiFit::chi2ThreshEB_
protected

Definition at line 120 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit().

double EcalUncalibRecHitWorkerMultiFit::chi2ThreshEE_
protected

Definition at line 121 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit().

std::vector<double> EcalUncalibRecHitWorkerMultiFit::EBamplitudeFitParameters_
protected

Definition at line 95 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

std::vector<double> EcalUncalibRecHitWorkerMultiFit::ebPulseShape_
protected

Definition at line 111 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

double EcalUncalibRecHitWorkerMultiFit::EBtimeConstantTerm_
protected

Definition at line 103 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

std::pair<double,double> EcalUncalibRecHitWorkerMultiFit::EBtimeFitLimits_
protected

Definition at line 97 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

std::vector<double> EcalUncalibRecHitWorkerMultiFit::EBtimeFitParameters_
protected

Definition at line 93 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

edm::ParameterSet EcalUncalibRecHitWorkerMultiFit::EcalPulseShapeParameters_
protected

Definition at line 49 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit().

std::vector<double> EcalUncalibRecHitWorkerMultiFit::EEamplitudeFitParameters_
protected

Definition at line 96 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

std::vector<double> EcalUncalibRecHitWorkerMultiFit::eePulseShape_
protected

Definition at line 112 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

double EcalUncalibRecHitWorkerMultiFit::EEtimeConstantTerm_
protected

Definition at line 104 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

std::pair<double,double> EcalUncalibRecHitWorkerMultiFit::EEtimeFitLimits_
protected

Definition at line 98 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

std::vector<double> EcalUncalibRecHitWorkerMultiFit::EEtimeFitParameters_
protected

Definition at line 94 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

FullSampleMatrix EcalUncalibRecHitWorkerMultiFit::fullpulsecovEB
protected

Definition at line 72 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and run().

FullSampleMatrix EcalUncalibRecHitWorkerMultiFit::fullpulsecovEE
protected

Definition at line 73 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and run().

FullSampleVector EcalUncalibRecHitWorkerMultiFit::fullpulseEB
protected

Definition at line 70 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and run().

FullSampleVector EcalUncalibRecHitWorkerMultiFit::fullpulseEE
protected

Definition at line 71 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and run().

double EcalUncalibRecHitWorkerMultiFit::gainRatios[3]
protected

Definition at line 53 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

edm::ESHandle<EcalGainRatios> EcalUncalibRecHitWorkerMultiFit::gains
protected

Definition at line 56 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().

edm::ESHandle<EcalWeightXtalGroups> EcalUncalibRecHitWorkerMultiFit::grps
protected

Definition at line 86 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().

edm::ESHandle<EcalTimeCalibConstants> EcalUncalibRecHitWorkerMultiFit::itime
protected

Definition at line 109 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by set().

bool EcalUncalibRecHitWorkerMultiFit::kPoorRecoFlagEB_
protected

Definition at line 118 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit().

bool EcalUncalibRecHitWorkerMultiFit::kPoorRecoFlagEE_
protected

Definition at line 119 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit().

EcalUncalibRecHitLeadingEdgeAlgo<EBDataFrame> EcalUncalibRecHitWorkerMultiFit::leadingEdgeMethod_barrel_
protected

Definition at line 113 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

EcalUncalibRecHitLeadingEdgeAlgo<EEDataFrame> EcalUncalibRecHitWorkerMultiFit::leadingEdgeMethod_endcap_
protected

Definition at line 114 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

EcalUncalibRecHitMultiFitAlgo EcalUncalibRecHitWorkerMultiFit::multiFitMethod_
protected

Definition at line 76 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().

SampleMatrix EcalUncalibRecHitWorkerMultiFit::noisecorEBg1
protected

Definition at line 68 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and noisecor().

SampleMatrix EcalUncalibRecHitWorkerMultiFit::noisecorEBg12
protected

Definition at line 64 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and noisecor().

SampleMatrix EcalUncalibRecHitWorkerMultiFit::noisecorEBg6
protected

Definition at line 66 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and noisecor().

SampleMatrix EcalUncalibRecHitWorkerMultiFit::noisecorEEg1
protected

Definition at line 69 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and noisecor().

SampleMatrix EcalUncalibRecHitWorkerMultiFit::noisecorEEg12
protected

Definition at line 65 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and noisecor().

SampleMatrix EcalUncalibRecHitWorkerMultiFit::noisecorEEg6
protected

Definition at line 67 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by fillInputs(), and noisecor().

edm::ESHandle<EcalTimeOffsetConstant> EcalUncalibRecHitWorkerMultiFit::offtime
protected

Definition at line 110 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by set().

double EcalUncalibRecHitWorkerMultiFit::pedRMSVec[3]
protected

Definition at line 52 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

edm::ESHandle<EcalPedestals> EcalUncalibRecHitWorkerMultiFit::peds
protected

Definition at line 55 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().

double EcalUncalibRecHitWorkerMultiFit::pedVec[3]
protected

Definition at line 51 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

EcalUncalibRecHitRatioMethodAlgo<EBDataFrame> EcalUncalibRecHitWorkerMultiFit::ratioMethod_barrel_
protected

Definition at line 100 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

EcalUncalibRecHitRatioMethodAlgo<EEDataFrame> EcalUncalibRecHitWorkerMultiFit::ratioMethod_endcap_
protected

Definition at line 101 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

edm::ESHandle<EcalSampleMask> EcalUncalibRecHitWorkerMultiFit::sampleMaskHand_
protected

Definition at line 80 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().

std::string EcalUncalibRecHitWorkerMultiFit::timealgo_
protected

Definition at line 83 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by EcalUncalibRecHitWorkerMultiFit(), and run().

edm::ESHandle<EcalTimeBiasCorrections> EcalUncalibRecHitWorkerMultiFit::timeCorrBias_
protected

Definition at line 106 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().

const EcalWeightSet::EcalWeightMatrix* EcalUncalibRecHitWorkerMultiFit::weights[2]
protected

Definition at line 88 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

EcalUncalibRecHitTimeWeightsAlgo<EBDataFrame> EcalUncalibRecHitWorkerMultiFit::weightsMethod_barrel_
protected

Definition at line 89 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

EcalUncalibRecHitTimeWeightsAlgo<EEDataFrame> EcalUncalibRecHitWorkerMultiFit::weightsMethod_endcap_
protected

Definition at line 90 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run().

edm::ESHandle<EcalTBWeights> EcalUncalibRecHitWorkerMultiFit::wgts
protected

Definition at line 87 of file EcalUncalibRecHitWorkerMultiFit.h.

Referenced by run(), and set().