32 for (
unsigned int ibx=0; ibx<activeBXs.size(); ++ibx) {
33 activeBX.coeffRef(ibx) = activeBXs[ibx];
40 if (useLumiInfoRunHeader_) {
69 else if(timeAlgoName!=
"None")
70 edm::LogError(
"EcalUncalibRecHitError") <<
"No time estimation algorithm defined";
140 int nnoise = SampleVector::RowsAtCompileTime;
148 for (
int i=0;
i<nnoise; ++
i) {
149 for (
int j=0; j<nnoise; ++j) {
165 unsigned int bunchspacing = 450;
171 bunchspacing = *bunchSpacingH;
178 if (bunchspacing == 25) {
180 activeBX << -5,-4,-3,-2,-1,0,1,2,3,4;
202 const std::vector<float>& amplitudeBins,
203 const std::vector<float>& shiftBins) {
207 double theCorrection = 0;
210 if (amplitudeBins.empty()) {
212 <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
217 if (amplitudeBins.size() != shiftBins.size()) {
219 <<
"Size of timeCorrAmplitudeBins different from " 220 "timeCorrShiftBins. Forcing no time bias corrections. ";
227 for (
int bin = 0;
bin < (
int) amplitudeBins.size();
bin++) {
228 if (ampli > amplitudeBins[
bin]) {
236 theCorrection = shiftBins[0];
237 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
238 theCorrection = shiftBins[myBin];
241 theCorrection = (shiftBins[myBin + 1] - shiftBins[myBin]);
242 theCorrection *= (((double) ampli) - amplitudeBins[myBin]) /
243 (amplitudeBins[myBin + 1] - amplitudeBins[myBin]);
244 theCorrection += shiftBins[myBin];
249 return theCorrection * inv25;
288 for (
auto itdg = digis.
begin(); itdg != digis.
end(); ++itdg)
290 DetId detid(itdg->id());
295 float offsetTime = 0;
305 aped = &
peds->barrel(hashedIndex);
306 aGain = &
gains->barrel(hashedIndex);
307 gid = &
grps->barrel(hashedIndex);
313 aped = &
peds->endcap(hashedIndex);
314 aGain = &
gains->endcap(hashedIndex);
315 gid = &
grps->endcap(hashedIndex);
330 fullpulsecov(
i+7,j+7) = aPulseCov->
covval[
i][j];
335 if( it !=
itime->end() ) {
338 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal " 340 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
343 int lastSampleBeforeSaturation = -2;
346 lastSampleBeforeSaturation=iSample-1;
353 if ( lastSampleBeforeSaturation == 4 ) {
354 result.emplace_back((*itdg).id(), 4095*12, 0, 0, 0);
355 auto & uncalibRecHit = result.
back();
358 uncalibRecHit.setChi2(0);
359 }
else if ( lastSampleBeforeSaturation >= -1 ) {
361 if (gainId==0) gainId=3;
363 auto gainratio = gainRatios[gainId-1];
365 result.emplace_back((*itdg).id(),
amplitude, 0, 0, 0);
366 auto & uncalibRecHit = result.
back();
369 uncalibRecHit.setChi2(0);
375 auto & uncalibRecHit = result.
back();
381 constexpr float invClockToNs = 1./clockToNsConstant;
387 double theTimeCorrectionEE =
timeCorrection(uncalibRecHit.amplitude(),
390 uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
400 if (uncalibRecHit.amplitude() > 3000.){
409 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
411 float sigmaped = pedRMSVec[0];
412 float nterm =
EEtimeNconst_*sigmaped/uncalibRecHit.amplitude();
413 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
414 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
415 ( correctedTime < -sigmat*outOfTimeThreshM) )
426 double theTimeCorrectionEB =
timeCorrection(uncalibRecHit.amplitude(),
429 uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
430 uncalibRecHit.setJitterError( std::hypot(crh.timeError,
EBtimeConstantTerm_ / clockToNsConstant) );
439 if (uncalibRecHit.amplitude() > 3000.){
447 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
449 float sigmaped = pedRMSVec[0];
450 float nterm =
EBtimeNconst_*sigmaped/uncalibRecHit.amplitude();
451 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
452 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
453 ( correctedTime < -sigmat*outOfTimeThreshM ))
462 std::vector<double> amplitudes;
463 for(
unsigned int ibx=0; ibx<
activeBX.
size(); ++ibx) amplitudes.push_back(uncalibRecHit.outOfTimeAmplitude(ibx));
467 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
468 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
469 if( wit == wgtsMap.end() ) {
470 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: " 471 << gid->
id() <<
" and EcalTDCId: " << tdcid
472 <<
"\n skipping digi with id: " << detid.rawId();
490 uncalibRecHit.setJitter( timerh );
491 uncalibRecHit.setJitterError( 0. );
493 uncalibRecHit.setJitter( 0. );
494 uncalibRecHit.setJitterError( 0. );
499 auto & uncalibRecHit = result.
back();
510 psd0.
addNode((
edm::ParameterDescription<std::vector<double>>(
"EBPulseShapeTemplate", {1.13979e-02, 7.58151e-01, 1.00000e+00, 8.87744e-01, 6.73548e-01, 4.74332e-01, 3.19561e-01, 2.15144e-01, 1.47464e-01, 1.01087e-01, 6.93181e-02, 4.75044e-02},
true) and
511 edm::ParameterDescription<std::vector<double>>(
"EEPulseShapeTemplate", {1.16442e-01, 7.56246e-01, 1.00000e+00, 8.97182e-01, 6.86831e-01, 4.91506e-01, 3.44111e-01, 2.45731e-01, 1.74115e-01, 1.23361e-01, 8.74288e-02, 6.19570e-02},
true)));
517 edm::ParameterDescription<std::vector<double>>(
"EBCorrNoiseMatrixG12", {1.00000, 0.71073, 0.55721, 0.46089, 0.40449, 0.35931, 0.33924, 0.32439, 0.31581, 0.30481 },
true) and
518 edm::ParameterDescription<std::vector<double>>(
"EECorrNoiseMatrixG12", {1.00000, 0.71373, 0.44825, 0.30152, 0.21609, 0.14786, 0.11772, 0.10165, 0.09465, 0.08098 },
true) and
519 edm::ParameterDescription<std::vector<double>>(
"EBCorrNoiseMatrixG06", {1.00000, 0.70946, 0.58021, 0.49846, 0.45006, 0.41366, 0.39699, 0.38478, 0.37847, 0.37055 },
true) and
520 edm::ParameterDescription<std::vector<double>>(
"EECorrNoiseMatrixG06", {1.00000, 0.71217, 0.47464, 0.34056, 0.26282, 0.20287, 0.17734, 0.16256, 0.15618, 0.14443 },
true) and
521 edm::ParameterDescription<std::vector<double>>(
"EBCorrNoiseMatrixG01", {1.00000, 0.73354, 0.64442, 0.58851, 0.55425, 0.53082, 0.51916, 0.51097, 0.50732, 0.50409 },
true) and
522 edm::ParameterDescription<std::vector<double>>(
"EECorrNoiseMatrixG01", {1.00000, 0.72698, 0.62048, 0.55691, 0.51848, 0.49147, 0.47813, 0.47007, 0.46621, 0.46265 },
true) and
526 psd0.
addOptionalNode((
edm::ParameterDescription<std::vector<double>>(
"EBPulseShapeCovariance", {3.001e-06, 1.233e-05, 0.000e+00, -4.416e-06, -4.571e-06, -3.614e-06, -2.636e-06, -1.286e-06, -8.410e-07, -5.296e-07, 0.000e+00, 0.000e+00,
527 1.233e-05, 6.154e-05, 0.000e+00, -2.200e-05, -2.309e-05, -1.838e-05, -1.373e-05, -7.334e-06, -5.088e-06, -3.745e-06, -2.428e-06, 0.000e+00,
528 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,
529 -4.416e-06, -2.200e-05, 0.000e+00, 8.319e-06, 8.545e-06, 6.792e-06, 5.059e-06, 2.678e-06, 1.816e-06, 1.223e-06, 8.245e-07, 5.589e-07,
530 -4.571e-06, -2.309e-05, 0.000e+00, 8.545e-06, 9.182e-06, 7.219e-06, 5.388e-06, 2.853e-06, 1.944e-06, 1.324e-06, 9.083e-07, 6.335e-07,
531 -3.614e-06, -1.838e-05, 0.000e+00, 6.792e-06, 7.219e-06, 6.016e-06, 4.437e-06, 2.385e-06, 1.636e-06, 1.118e-06, 7.754e-07, 5.556e-07,
532 -2.636e-06, -1.373e-05, 0.000e+00, 5.059e-06, 5.388e-06, 4.437e-06, 3.602e-06, 1.917e-06, 1.322e-06, 9.079e-07, 6.529e-07, 4.752e-07,
533 -1.286e-06, -7.334e-06, 0.000e+00, 2.678e-06, 2.853e-06, 2.385e-06, 1.917e-06, 1.375e-06, 9.100e-07, 6.455e-07, 4.693e-07, 3.657e-07,
534 -8.410e-07, -5.088e-06, 0.000e+00, 1.816e-06, 1.944e-06, 1.636e-06, 1.322e-06, 9.100e-07, 9.115e-07, 6.062e-07, 4.436e-07, 3.422e-07,
535 -5.296e-07, -3.745e-06, 0.000e+00, 1.223e-06, 1.324e-06, 1.118e-06, 9.079e-07, 6.455e-07, 6.062e-07, 7.217e-07, 4.862e-07, 3.768e-07,
536 0.000e+00, -2.428e-06, 0.000e+00, 8.245e-07, 9.083e-07, 7.754e-07, 6.529e-07, 4.693e-07, 4.436e-07, 4.862e-07, 6.509e-07, 4.418e-07,
537 0.000e+00, 0.000e+00, 0.000e+00, 5.589e-07, 6.335e-07, 5.556e-07, 4.752e-07, 3.657e-07, 3.422e-07, 3.768e-07, 4.418e-07, 6.142e-07},
true) and
538 edm::ParameterDescription<std::vector<double>>(
"EEPulseShapeCovariance", {3.941e-05, 3.333e-05, 0.000e+00, -1.449e-05, -1.661e-05, -1.424e-05, -1.183e-05, -6.842e-06, -4.915e-06, -3.411e-06, 0.000e+00, 0.000e+00,
539 3.333e-05, 2.862e-05, 0.000e+00, -1.244e-05, -1.431e-05, -1.233e-05, -1.032e-05, -5.883e-06, -4.154e-06, -2.902e-06, -2.128e-06, 0.000e+00,
540 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00,
541 -1.449e-05, -1.244e-05, 0.000e+00, 5.840e-06, 6.649e-06, 5.720e-06, 4.812e-06, 2.708e-06, 1.869e-06, 1.330e-06, 9.186e-07, 6.446e-07,
542 -1.661e-05, -1.431e-05, 0.000e+00, 6.649e-06, 7.966e-06, 6.898e-06, 5.794e-06, 3.157e-06, 2.184e-06, 1.567e-06, 1.084e-06, 7.575e-07,
543 -1.424e-05, -1.233e-05, 0.000e+00, 5.720e-06, 6.898e-06, 6.341e-06, 5.347e-06, 2.859e-06, 1.991e-06, 1.431e-06, 9.839e-07, 6.886e-07,
544 -1.183e-05, -1.032e-05, 0.000e+00, 4.812e-06, 5.794e-06, 5.347e-06, 4.854e-06, 2.628e-06, 1.809e-06, 1.289e-06, 9.020e-07, 6.146e-07,
545 -6.842e-06, -5.883e-06, 0.000e+00, 2.708e-06, 3.157e-06, 2.859e-06, 2.628e-06, 1.863e-06, 1.296e-06, 8.882e-07, 6.108e-07, 4.283e-07,
546 -4.915e-06, -4.154e-06, 0.000e+00, 1.869e-06, 2.184e-06, 1.991e-06, 1.809e-06, 1.296e-06, 1.217e-06, 8.669e-07, 5.751e-07, 3.882e-07,
547 -3.411e-06, -2.902e-06, 0.000e+00, 1.330e-06, 1.567e-06, 1.431e-06, 1.289e-06, 8.882e-07, 8.669e-07, 9.522e-07, 6.717e-07, 4.293e-07,
548 0.000e+00, -2.128e-06, 0.000e+00, 9.186e-07, 1.084e-06, 9.839e-07, 9.020e-07, 6.108e-07, 5.751e-07, 6.717e-07, 7.911e-07, 5.493e-07,
549 0.000e+00, 0.000e+00, 0.000e+00, 6.446e-07, 7.575e-07, 6.886e-07, 6.146e-07, 4.283e-07, 3.882e-07, 4.293e-07, 5.493e-07, 7.027e-07},
true)),
true);
552 psd.
addNode(
edm::ParameterDescription<std::vector<int>>(
"activeBXs", {-5,-4,-3,-2,-1,0,1,2,3,4},
true) and
572 edm::ParameterDescription<std::vector<double>>(
"EBtimeFitParameters", {-2.015452e+00, 3.130702e+00, -1.234730e+01, 4.188921e+01, -8.283944e+01, 9.101147e+01, -5.035761e+01, 1.105621e+01},
true) and
573 edm::ParameterDescription<std::vector<double>>(
"EEtimeFitParameters", {-2.390548e+00, 3.553628e+00, -1.762341e+01, 6.767538e+01, -1.332130e+02, 1.407432e+02, -7.541106e+01, 1.620277e+01},
true) and
595 edm::ParameterDescription<std::vector<double>>(
"ebPulseShape", {5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194},
true) and
596 edm::ParameterDescription<std::vector<double>>(
"eePulseShape", {5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194},
true) and
edm::ParameterSetDescription getAlgoDescription() override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
T getParameter(std::string const &) const
bool mitigateBadSamplesEB_
std::array< SampleMatrixGainArray, 2 > noisecors_
int hashedIndex() const
get a compact index for arrays
void computeAmplitude(std::vector< double > &litudeFitParameters)
unsigned size(int bx) const
std::array< SampleMatrix, NGains > SampleMatrixGainArray
std::vector< float > EBTimeCorrShiftBins
EcalUncalibRecHitMultiFitAlgo multiFitMethod_
bool simplifiedNoiseModelForGainSwitch_
int gainId(sample_type sample)
get the gainId (2 bits)
EcalUncalibRecHitTimeWeightsAlgo< EEDataFrame > weightsMethod_endcap_
double EEtimeConstantTerm_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool useLumiInfoRunHeader_
bool mitigateBadSamplesEE_
double addPedestalUncertaintyEE_
double time(const C &dataFrame, const std::vector< double > &litudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, const EcalWeightSet::EcalWeightMatrix **weights)
Compute time.
CalculatedRecHit getCalculatedRecHit()
double outOfTimeThreshG12pEE_
std::vector< double > EBG12SamplesCorrelation
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &litudeFitParameters)
static const int TEMPLATESAMPLES
edm::ESHandle< EcalWeightXtalGroups > grps
void push_back(T const &t)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
double amplitudeThreshEE_
std::pair< double, double > EEtimeFitLimits_
const_iterator begin() const
double outOfTimeThreshG61pEE_
edm::ESHandle< EcalGainRatios > gains
bool selectiveBadSampleCriteriaEE_
edm::EDGetTokenT< unsigned int > bunchSpacing_
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
bool gainSwitchUseMaxSampleEE_
const unsigned int id() const
std::vector< double > EBG6SamplesCorrelation
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
edm::ESHandle< EcalPedestals > peds
int hashedIndex(int ieta, int iphi)
void setAddPedestalUncertainty(double x)
std::vector< double > EBtimeFitParameters_
std::vector< double > ebPulseShape_
std::vector< double > EBamplitudeFitParameters_
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
std::vector< float > EETimeCorrAmplitudeBins
edm::ESHandle< EcalPulseShapes > pulseshapes
void setDynamicPedestals(bool b)
Abs< T >::type abs(const T &t)
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
void setMitigateBadSamples(bool b)
edm::ESHandle< EcalTimeCalibConstants > itime
double timeCorrection(float ampli, const std::vector< float > &litudeBins, const std::vector< float > &shiftBins)
double outOfTimeThreshG12mEB_
void disableErrorCalculation()
double outOfTimeThreshG61mEB_
double outOfTimeThreshG12mEE_
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG12pEB_
float covval[EcalPulseShape::TEMPLATESAMPLES][EcalPulseShape::TEMPLATESAMPLES]
std::vector< double > eePulseShape_
void setSelectiveBadSampleCriteria(bool b)
EcalUncalibratedRecHit makeRecHit(const EcalDataFrame &dataFrame, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const SampleMatrixGainArray &noisecors, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const BXVector &activeBX)
compute rechits
bin
set the eta bin as selection string.
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
bool ampErrorCalculation_
void set(const edm::EventSetup &es) override
edm::ESHandle< EcalPulseCovariances > pulsecovariances
void setPrefitMaxChiSq(double x)
EcalWeightMatrix & getWeightsBeforeGainSwitch()
std::vector< double > EBG1SamplesCorrelation
bool fixMGPAslew(const C &dataFrame)
double outOfTimeThreshG61mEE_
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
std::vector< Item >::const_iterator const_iterator
void resize(int bx, unsigned size)
Eigen::Matrix< double, SampleVectorSize, SampleVectorSize > SampleMatrix
float gain12Over6() const
std::pair< double, double > EBtimeFitLimits_
EcalUncalibRecHitTimeWeightsAlgo< EBDataFrame > weightsMethod_barrel_
edm::ESHandle< EcalTimeOffsetConstant > offtime
const_iterator end() const
bool selectiveBadSampleCriteriaEB_
std::vector< double > EEG1SamplesCorrelation
bool gainSwitchUseMaxSampleEB_
float pdfval[TEMPLATESAMPLES]
float EcalTimeCalibConstant
const EcalTBWeightMap & getMap() const
math::Matrix< 3, 10 >::type EcalWeightMatrix
void reserve(size_type n)
double outOfTimeThreshG61pEB_
void setGainSwitchUseMaxSample(bool b)
#define DEFINE_EDM_PLUGIN(factory, type, name)
void run(const edm::Event &evt, const EcalDigiCollection &digis, EcalUncalibratedRecHitCollection &result) override
const SampleMatrix & noisecor(bool barrel, int gain) const
void setSimplifiedNoiseModelForGainSwitch(bool b)
edm::ESHandle< EcalSampleMask > sampleMaskHand_
const EcalWeightSet::EcalWeightMatrix * weights[2]
std::vector< double > EEG12SamplesCorrelation
edm::ESHandle< EcalSamplesCorrelation > noisecovariances
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
double amplitudeThreshEB_
std::vector< double > EEG6SamplesCorrelation
edm::ESHandle< EcalTBWeights > wgts
T const * product() const
static const int MAXSAMPLES
std::vector< double > EEamplitudeFitParameters_
Power< A, B >::type pow(const A &a, const B &b)
const_reference back() const
double addPedestalUncertaintyEB_
EcalUncalibRecHitWorkerMultiFit()
std::vector< double > EEtimeFitParameters_
double EBtimeConstantTerm_