135 for (
int j = 0;
j < C::MAXSAMPLES - 5; ++
j) {
137 for (
int i =
j;
i < (
j + 5) &&
i < C::MAXSAMPLES; ++
i) {
138 if ( dataFrame.sample(
i).gainId() == 0 ) ++cnt;
140 if ( cnt == 5 )
return j-1 ;
156 const std::vector<float>& amplitudeBins,
157 const std::vector<float>& shiftBins) {
161 double theCorrection = 0;
164 if (amplitudeBins.size() == 0) {
166 <<
"timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
171 if (amplitudeBins.size() != shiftBins.size()) {
173 <<
"Size of timeCorrAmplitudeBins different from "
174 "timeCorrShiftBins. Forcing no time bias corrections. ";
180 for (
int bin = 0;
bin < (int) amplitudeBins.size();
bin++) {
181 if (ampli > amplitudeBins.at(
bin)) {
189 theCorrection = shiftBins.at(0);
190 }
else if (myBin == ((
int)(amplitudeBins.size() - 1))) {
191 theCorrection = shiftBins.at(myBin);
192 }
else if (-1 < myBin && myBin < ((
int) amplitudeBins.size() - 1)) {
194 theCorrection = (shiftBins.at(myBin + 1) - shiftBins.at(myBin));
195 theCorrection *= (((double) ampli) - amplitudeBins.at(myBin)) /
196 (amplitudeBins.at(myBin + 1) - amplitudeBins.at(myBin));
197 theCorrection += shiftBins.at(myBin);
200 <<
"Assigning time correction impossible. Setting it to 0 ";
205 return theCorrection / 25.;
215 DetId detid(itdg->id());
226 float offsetTime = 0;
230 aped = &
peds->endcap(hashedIndex);
231 aGain = &
gains->endcap(hashedIndex);
232 gid = &
grps->endcap(hashedIndex);
233 offsetTime =
offtime->getEEValue();
236 aped = &
peds->barrel(hashedIndex);
237 aGain = &
gains->barrel(hashedIndex);
238 gid = &
grps->barrel(hashedIndex);
239 offsetTime =
offtime->getEBValue();
255 if( it !=
itime->end() ) {
258 edm::LogError(
"EcalRecHitError") <<
"No time intercalib const found for xtal "
260 <<
"! something wrong with EcalTimeCalibConstants in your DB? ";
265 int leadingSample = -1;
267 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
269 leadingSample = ((
EcalDataFrame)(*itdg)).lastUnsaturatedSample();
272 if ( leadingSample == 4 ) {
277 }
else if ( leadingSample >= 0 ) {
279 double gainratio = 1.;
282 if (gainId==0 || gainId==3) {
286 else if (gainId==1) {
290 else if (gainId==2) {
294 double amplitude = ((double)(((
EcalDataFrame)(*itdg)).sample(5).adc()) - pedestal) * gainratio;
303 EcalTBWeights::EcalTBWeightMap::const_iterator wit;
304 wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
305 if( wit == wgtsMap.end() ) {
306 edm::LogError(
"EcalUncalibRecHitError") <<
"No weights found for EcalGroupId: "
307 << gid->
id() <<
" and EcalTDCId: " << tdcid
308 <<
"\n skipping digi with id: " << detid.rawId();
329 float const clockToNsConstant = 25.;
338 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
356 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
360 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
361 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
362 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
376 uncalibRecHit.
setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
394 float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
398 float sigmat =
std::sqrt( nterm*nterm + cterm*cterm );
399 if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
400 ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
408 double amplitude = uncalibRecHit.
amplitude();
409 double amplitudeOutOfTime = 0.;
410 double jitter= uncalibRecHit.
jitter();
417 (itimeconst + offsetTime),
426 double chi2 = chi2expressEE_.
chi2();
435 bool samplesok =
true;
437 if (!sampleMask_->useSampleEE(
sample)) {
449 double amplitude = uncalibRecHit.
amplitude();
450 double amplitudeOutOfTime = 0.;
451 double jitter= uncalibRecHit.
jitter();
456 (itimeconst + offsetTime),
465 double chi2 = chi2expressEB_.
chi2();
473 bool samplesok =
true;
475 if (!sampleMask_->useSampleEB(
sample)) {
505 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
506 edm::ParameterDescription<std::vector<double>>(
"EBtimeFitParameters", {-2.015452,3.130702,-12.3473,41.88921,-82.83944,91.01147,-50.35761,11.05621},
true) and
514 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
518 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_
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
int hashedIndex() const
get a compact index for arrays
double outOfTimeThreshG61pEE_
void computeAmplitude(std::vector< double > &litudeFitParameters)
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)
const EEShape testbeamEEShape
int gainId(sample_type sample)
get the gainId (2 bits)
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 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
const EBShape testbeamEBShape
int hashedIndex(int ieta, int iphi)
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
double outOfTimeThreshG61mEB_
edm::ESHandle< EcalGainRatios > gains
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::ParameterSetDescription getAlgoDescription()
edm::ESHandle< EcalWeightXtalGroups > grps
double outOfTimeThreshG61mEE_
double outOfTimeThreshG12mEB_
EcalWeightMatrix & getWeightsAfterGainSwitch()
double outOfTimeThreshG61pEB_
std::vector< double > EBamplitudeFitParameters_
std::vector< double > EBchi2Parameters_
EcalWeightMatrix & getWeightsBeforeGainSwitch()
bool fixMGPAslew(const C &dataFrame)
std::vector< Item >::const_iterator const_iterator
T const * product() const
float gain12Over6() const
EcalUncalibRecHitWorkerGlobal()
std::vector< double > EEamplitudeFitParameters_
const EcalWeightSet::EcalWeightMatrix * weights[2]
float EcalTimeCalibConstant
void set(const edm::EventSetup &es)
edm::ESHandle< EcalTimeCalibConstants > itime
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
math::Matrix< 3, 10 >::type EcalWeightMatrix
void setFlagBit(Flags flag)
#define DEFINE_EDM_PLUGIN(factory, type, name)
edm::ESHandle< EcalSampleMask > sampleMaskHand_
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
std::vector< double > EEtimeFitParameters_
static const int MAXSAMPLES
Power< A, B >::type pow(const A &a, const B &b)