Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove asserts in hcal tp emulator #8605

Merged
merged 1 commit into from
Apr 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 39 additions & 19 deletions SimCalorimetry/HcalTrigPrimAlgos/src/HcalTriggerPrimitiveAlgo.cc
Expand Up @@ -179,7 +179,6 @@ void HcalTriggerPrimitiveAlgo::addSignal(const IntegerCaloSamples & samples) {

void HcalTriggerPrimitiveAlgo::analyze(IntegerCaloSamples & samples, HcalTriggerPrimitiveDigi & result) {
int shrink = weights_.size() - 1;
std::vector<bool> finegrain(numberOfSamples_,false);
std::vector<bool>& msb = fgMap_[samples.id()];
IntegerCaloSamples sum(samples.id(), samples.size());

Expand All @@ -196,18 +195,28 @@ void HcalTriggerPrimitiveAlgo::analyze(IntegerCaloSamples & samples, HcalTrigger
else sum[ibin] = algosumvalue; //assign value to sum[]
}

IntegerCaloSamples output(samples.id(), numberOfSamples_);
output.setPresamples(numberOfPresamples_);

// Align digis and TP
int shift = samples.presamples() - numberOfPresamples_;
if (peakfind_) {
assert (shift >= (peakfind_ ? shrink : 0));
assert(shift + numberOfSamples_ + shrink <= samples.size() - (peak_finder_algorithm_ - 1));
int dgPresamples=samples.presamples();
int tpPresamples=numberOfPresamples_;
int shift = dgPresamples - tpPresamples;
int dgSamples=samples.size();
int tpSamples=numberOfSamples_;
if(peakfind_){
if((shift<shrink) || (shift + tpSamples + shrink > dgSamples - (peak_finder_algorithm_ - 1) ) ){
edm::LogInfo("HcalTriggerPrimitiveAlgo::analyze") <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
shift=shrink;
tpPresamples=dgPresamples-shrink;
tpSamples=dgSamples-(peak_finder_algorithm_-1)-shrink-shift;
}
}

std::vector<bool> finegrain(tpSamples,false);

IntegerCaloSamples output(samples.id(), tpSamples);
output.setPresamples(tpPresamples);

for (int ibin = 0; ibin < numberOfSamples_; ++ibin) {
for (int ibin = 0; ibin < tpSamples; ++ibin) {
// ibin - index for output TP
// idx - index for samples + shift
int idx = ibin + shift;
Expand Down Expand Up @@ -243,19 +252,29 @@ void HcalTriggerPrimitiveAlgo::analyze(IntegerCaloSamples & samples, HcalTrigger
if (samples[idx] >= 0x3FF)
output[ibin] = 0x3FF;
}
outcoder_->compress(output, finegrain, result);
}
outcoder_->compress(output, finegrain, result);
}


void HcalTriggerPrimitiveAlgo::analyzeHF(IntegerCaloSamples & samples, HcalTriggerPrimitiveDigi & result, float rctlsb) {
std::vector<bool> finegrain(numberOfSamples_, false);
HcalTrigTowerDetId detId(samples.id());

// Align digis and TP
int shift = samples.presamples() - numberOfPresamples_;
assert(shift >= 0);
assert((shift + numberOfSamples_) <= samples.size());
int dgPresamples=samples.presamples();
int tpPresamples=numberOfPresamples_;
int shift = dgPresamples - tpPresamples;
int dgSamples=samples.size();
int tpSamples=numberOfSamples_;
if(shift<0 || shift+tpSamples>dgSamples){
edm::LogInfo("HcalTriggerPrimitiveAlgo::analyzeHF") <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
tpPresamples=dgPresamples;
shift=0;
tpSamples=dgSamples;
}

std::vector<bool> finegrain(tpSamples, false);

TowerMapFGSum::const_iterator tower2fg = theTowerMapFGSum.find(detId);
assert(tower2fg != theTowerMapFGSum.end());
Expand All @@ -265,20 +284,21 @@ void HcalTriggerPrimitiveAlgo::analyzeHF(IntegerCaloSamples & samples, HcalTrigg
// Note: 1 samples.id() = 6 x (L+S) without noZS
for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
const std::vector<bool>& veto = HF_Veto[sumFGItr->id().rawId()];
for (int ibin = 0; ibin < numberOfSamples_; ++ibin) {
for (int ibin = 0; ibin < tpSamples; ++ibin) {
int idx = ibin + shift;
// if not vetod, add L+S to total sum and calculate FG
if (!(veto[idx] && (*sumFGItr)[idx] > PMT_NoiseThreshold_)) {
bool vetoed = idx<int(veto.size()) && veto[idx];
if (!(vetoed && (*sumFGItr)[idx] > PMT_NoiseThreshold_)) {
samples[idx] += (*sumFGItr)[idx];
finegrain[ibin] = (finegrain[ibin] || (*sumFGItr)[idx] >= FG_threshold_);
}
}
}

IntegerCaloSamples output(samples.id(), numberOfSamples_);
output.setPresamples(numberOfPresamples_);
IntegerCaloSamples output(samples.id(), tpSamples);
output.setPresamples(tpPresamples);

for (int ibin = 0; ibin < numberOfSamples_; ++ibin) {
for (int ibin = 0; ibin < tpSamples; ++ibin) {
int idx = ibin + shift;
output[ibin] = samples[idx] / (rctlsb == 0.25 ? 4 : 8);
if (output[ibin] > 0x3FF) output[ibin] = 0x3FF;
Expand Down