139 for (
int j = 0; j < C::MAXSAMPLES - 5; ++j) {
141 for (
int i = j;
i < (j + 5) &&
i < C::MAXSAMPLES; ++
i) {
142 if ( dataFrame.sample(
i).gainId() == 0 ) ++cnt;
144 if ( cnt == 5 )
return j-1 ;
160 const std::vector<float>& amplitudeBins,
161 const std::vector<float>& shiftBins) {
165 double theCorrection = 0;
168 if (amplitudeBins.empty()) {
170 <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
175 if (amplitudeBins.size() != shiftBins.size()) {
177 <<
"Size of timeCorrAmplitudeBins different from " 178 "timeCorrShiftBins. Forcing no time bias corrections. ";
184 for (
int bin = 0;
bin < (
int) amplitudeBins.size();
bin++) {
185 if (ampli > amplitudeBins.at(
bin)) {
193 theCorrection = shiftBins.at(0);
194 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
195 theCorrection = shiftBins.at(myBin);
196 }
else if (-1 < myBin && myBin < ((
int) amplitudeBins.size() - 1)) {
198 theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
199 theCorrection *= (((double) ampli) - amplitudeBins.at(myBin)) /
200 (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
201 theCorrection += shiftBins.at(myBin);
204 <<
"Assigning time correction impossible. Setting it to 0 ";
209 return theCorrection / 25.;
219 DetId detid(itdg->id());
230 float offsetTime = 0;
234 aped = &
peds->endcap(hashedIndex);
235 aGain = &
gains->endcap(hashedIndex);
236 gid = &
grps->endcap(hashedIndex);
240 aped = &
peds->barrel(hashedIndex);
241 aGain = &
gains->barrel(hashedIndex);
242 gid = &
grps->barrel(hashedIndex);
259 if( it !=
itime->end() ) {
262 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal " 264 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
269 int leadingSample = -1;
271 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
273 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
276 if ( leadingSample == 4 ) {
281 }
else if ( leadingSample >= 0 ) {
283 double gainratio = 1.;
286 if (gainId==0 || gainId==3) {
290 else if (gainId==1) {
294 else if (gainId==2) {
307 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
308 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
309 if( wit == wgtsMap.end() ) {
310 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: " 311 << gid->
id() <<
" and EcalTDCId: " << tdcid
312 <<
"\n skipping digi with id: " << detid.rawId();
333 float const clockToNsConstant = 25.;
342 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
360 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
364 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
365 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
366 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
380 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
398 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
402 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
403 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
404 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
413 double amplitudeOutOfTime = 0.;
414 double jitter= uncalibRecHit.
jitter();
421 (itimeconst + offsetTime),
430 double chi2 = chi2expressEE_.
chi2();
439 bool samplesok =
true;
441 if (!sampleMask_->useSampleEE(
sample)) {
454 double amplitudeOutOfTime = 0.;
455 double jitter= uncalibRecHit.
jitter();
460 (itimeconst + offsetTime),
469 double chi2 = chi2expressEB_.
chi2();
477 bool samplesok =
true;
479 if (!sampleMask_->useSampleEB(
sample)) {
509 psd.
addNode(
edm::ParameterDescription<std::vector<double>>(
"eePulseShape", {5.2e-05,-5.26e-05,6.66e-05,0.1168,0.7575,1.0,0.8876,0.6732,0.4741,0.3194},
true) and
510 edm::ParameterDescription<std::vector<double>>(
"EBtimeFitParameters", {-2.015452,3.130702,-12.3473,41.88921,-82.83944,91.01147,-50.35761,11.05621},
true) and
518 edm::ParameterDescription<std::vector<double>>(
"ebPulseShape", {5.2e-05,-5.26e-05,6.66e-05,0.1168,0.7575,1.0,0.8876,0.6732,0.4741,0.3194},
true) and
522 edm::ParameterDescription<std::vector<double>>(
"EEtimeFitParameters", {-2.390548,3.553628,-17.62341,67.67538,-133.213,140.7432,-75.41106,16.20277},
true) and
edm::ESHandle< EcalTimeOffsetConstant > offtime
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
T getParameter(std::string const &) const
double amplitudeThreshEE_
double outOfTimeThreshG12pEB_
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
int hashedIndex() const
get a compact index for arrays
double outOfTimeThreshG61pEE_
void computeAmplitude(std::vector< double > &litudeFitParameters)
std::vector< float > EBTimeCorrShiftBins
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
double timeCorrection(float ampli, const std::vector< float > &litudeBins, const std::vector< float > &shiftBins)
void setJitter(float jitter)
int isSaturated(const C &digi)
std::pair< double, double > EBtimeFitLimits_
CalculatedRecHit getCalculatedRecHit()
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &litudeFitParameters)
void push_back(T const &t)
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > weightsMethod_barrel_
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::vector< double > EBtimeFitParameters_
double outOfTimeThreshG12mEE_
void set(const edm::EventSetup &es) override
void setJitterError(float jitterErr)
std::vector< double > EEchi2Parameters_
std::vector< double > eePulseShape_
std::vector< double > ebPulseShape_
std::pair< double, double > EEtimeFitLimits_
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
const unsigned int id() const
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
int hashedIndex(int ieta, int iphi)
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
double outOfTimeThreshG61mEB_
edm::ESHandle< EcalGainRatios > gains
std::vector< float > EETimeCorrAmplitudeBins
edm::ESHandle< EcalPedestals > peds
double EEtimeConstantTerm_
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
double outOfTimeThreshG12pEE_
double amplitudeThreshEB_
double EBtimeConstantTerm_
edm::ESHandle< EcalTBWeights > wgts
edm::ESHandle< EcalWeightXtalGroups > grps
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result) override
double outOfTimeThreshG61mEE_
double outOfTimeThreshG12mEB_
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG61pEB_
bin
set the eta bin as selection string.
std::vector< double > EBamplitudeFitParameters_
std::vector< double > EBchi2Parameters_
EcalWeightMatrix & getWeightsBeforeGainSwitch()
bool fixMGPAslew(const C &dataFrame)
std::vector< Item >::const_iterator const_iterator
float gain12Over6() const
EcalUncalibRecHitWorkerGlobal()
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
float EcalTimeCalibConstant
edm::ESHandle< EcalTimeCalibConstants > itime
void setEventSetup(const edm::EventSetup &evtSetup)
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
const EcalTBWeightMap & getMap() const
math::Matrix< 3, 10 >::type EcalWeightMatrix
void setFlagBit(Flags flag)
#define DEFINE_EDM_PLUGIN(factory, type, name)
static constexpr int MAXSAMPLES
edm::ParameterSetDescription getAlgoDescription() override
edm::ESHandle< EcalSampleMask > sampleMaskHand_
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
T const * product() const
std::vector< double > EEtimeFitParameters_
Power< A, B >::type pow(const A &a, const B &b)