Skip to content

Commit

Permalink
Merge pull request #20060 from emanueledimarco/fix-saturationontail-93X
Browse files Browse the repository at this point in the history
Fix for ECAL saturation in the tail of the pulse
  • Loading branch information
cmsbuild committed Aug 28, 2017
2 parents dfbe6f7 + 3d9fd55 commit 566f40c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ double EcalUncalibRecHitWorkerMultiFit::timeCorrection(
double theCorrection = 0;

// sanity check for arrays
if (amplitudeBins.size() == 0) {
if (amplitudeBins.empty()) {
edm::LogError("EcalRecHitError")
<< "timeCorrAmplitudeBins is empty, forcing no time bias corrections.";

Expand Down Expand Up @@ -294,12 +294,12 @@ EcalUncalibRecHitWorkerMultiFit::run( const edm::Event & evt,
// intelligence for recHit computation
float offsetTime = 0;

const EcalPedestals::Item * aped = 0;
const EcalMGPAGainRatio * aGain = 0;
const EcalXtalGroupId * gid = 0;
const EcalPulseShapes::Item * aPulse = 0;
const EcalPulseCovariances::Item * aPulseCov = 0;

const EcalPedestals::Item * aped = nullptr;
const EcalMGPAGainRatio * aGain = nullptr;
const EcalXtalGroupId * gid = nullptr;
const EcalPulseShapes::Item * aPulse = nullptr;
const EcalPulseCovariances::Item * aPulseCov = nullptr;
if (barrel) {
unsigned int hashedIndex = EBDetId(detid).hashedIndex();
aped = &peds->barrel(hashedIndex);
Expand Down Expand Up @@ -340,16 +340,23 @@ EcalUncalibRecHitWorkerMultiFit::run( const edm::Event & evt,
<< "! something wrong with EcalTimeCalibConstants in your DB? ";
}

int lastSampleBeforeSaturation = -2;
for(unsigned int iSample = 0; iSample < EcalDataFrame::MAXSAMPLES; iSample++) {
if ( ((EcalDataFrame)(*itdg)).sample(iSample).gainId() == 0 ) {
lastSampleBeforeSaturation=iSample-1;
break;
}
}

// === amplitude computation ===
int leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();

if ( leadingSample == 4 ) { // saturation on the expected max sample
if ( lastSampleBeforeSaturation == 4 ) { // saturation on the expected max sample
result.emplace_back((*itdg).id(), 4095*12, 0, 0, 0);
auto & uncalibRecHit = result.back();
uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kSaturated );
// do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
uncalibRecHit.setChi2(0);
} else if ( leadingSample >= 0 ) { // saturation on other samples: cannot extrapolate from the fourth one
} else if ( lastSampleBeforeSaturation >= -1 ) { // saturation on other samples: cannot extrapolate from the fourth one
int gainId = ((EcalDataFrame)(*itdg)).sample(5).gainId();
if (gainId==0) gainId=3;
auto pedestal = pedVec[gainId-1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class EcalUncalibRecHitWorkerMultiFit final : public EcalUncalibRecHitWorkerBase
public:
EcalUncalibRecHitWorkerMultiFit(const edm::ParameterSet&, edm::ConsumesCollector& c);
EcalUncalibRecHitWorkerMultiFit() {};
virtual ~EcalUncalibRecHitWorkerMultiFit() {};
~EcalUncalibRecHitWorkerMultiFit() override {};
private:
void set(const edm::EventSetup& es) override;
void set(const edm::Event& evt) override;
Expand Down

0 comments on commit 566f40c

Please sign in to comment.