-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Permanently enabling method 3 #11507
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,10 @@ HcalSimpleRecAlgo::HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForPul | |
correctForTimeslew_(correctForTimeslew), | ||
correctForPulse_(correctForPulse), | ||
phaseNS_(phaseNS), runnum_(0), setLeakCorrection_(false), puCorrMethod_(0) | ||
{ | ||
|
||
pulseCorr_ = std::auto_ptr<HcalPulseContainmentManager>( | ||
new HcalPulseContainmentManager(MaximumFractionalError) | ||
); | ||
} | ||
|
||
|
||
HcalSimpleRecAlgo::HcalSimpleRecAlgo() : | ||
correctForTimeslew_(false), runnum_(0), puCorrMethod_(0) | ||
{ | ||
{ | ||
pulseCorr_ = std::auto_ptr<HcalPulseContainmentManager>(new HcalPulseContainmentManager(MaximumFractionalError)); | ||
pedSubFxn_ = std::auto_ptr<PedestalSub>(new PedestalSub()); | ||
hltOOTpuCorr_ = std::auto_ptr<HcalDeterministicFit>(new HcalDeterministicFit()); | ||
} | ||
|
||
|
||
|
@@ -324,9 +317,9 @@ namespace HcalSimpleRecAlgoImpl { | |
const HcalTimeSlew::BiasSetting slewFlavor, | ||
const int runnum, const bool useLeak, | ||
const AbsOOTPileupCorrection* pileupCorrection, | ||
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub /* whatever don't know what to do with the pointer...*/)// const on end | ||
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub /* whatever don't know what to do with the pointer...*/, std::vector<double>& buffer)// const on end | ||
{ | ||
double fc_ampl =0, ampl =0, uncorr_ampl =0, maxA = -1.e300; | ||
double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300; | ||
int nRead = 0, maxI = -1; | ||
bool leakCorrApplied = false; | ||
float t0 =0, t2 =0; | ||
|
@@ -361,36 +354,39 @@ namespace HcalSimpleRecAlgoImpl { | |
|
||
// Note that uncorr_ampl is always set from outside of method 2! | ||
if( puCorrMethod == 2 ){ | ||
std::vector<double> correctedOutput; | ||
buffer.clear(); | ||
|
||
CaloSamples cs; | ||
coder.adc2fC(digi,cs); | ||
std::vector<int> capidvec; | ||
CaloSamples cs; | ||
coder.adc2fC(digi,cs); | ||
std::vector<int> capidvec; | ||
for(int ip=0; ip<cs.size(); ip++){ | ||
const int capid = digi[ip].capid(); | ||
capidvec.push_back(capid); | ||
} | ||
psFitOOTpuCorr->apply(cs, capidvec, calibs, correctedOutput); | ||
if( correctedOutput.back() == 0 && correctedOutput.size() >1 ){ | ||
time = correctedOutput[1]; ampl = correctedOutput[0]; | ||
psFitOOTpuCorr->apply(cs, capidvec, calibs, buffer); | ||
if( buffer.back() == 0 && buffer.size() >1 ){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like the size is used mainly to signal the quality of the fit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point, I don't really want to change the interface of two classes written by somebody else. |
||
time = buffer[1]; ampl = buffer[0]; | ||
} | ||
} | ||
|
||
// S. Brandt - Feb 19th : Adding Section for HLT | ||
// Turn on HLT here with puCorrMethod = 3 | ||
if ( puCorrMethod == 3){ | ||
std::vector<double> hltCorrOutput; | ||
// Run "Method 3" all the time. | ||
{ | ||
buffer.clear(); | ||
|
||
CaloSamples cs; | ||
coder.adc2fC(digi,cs); | ||
std::vector<int> capidvec; | ||
for(int ip=0; ip<cs.size(); ip++){ | ||
const int capid = digi[ip].capid(); | ||
capidvec.push_back(capid); | ||
} | ||
hltOOTpuCorr->apply(cs, capidvec, calibs, digi, hltCorrOutput); | ||
if( hltCorrOutput.size() > 1 ){ | ||
time = hltCorrOutput[1]; ampl = hltCorrOutput[0]; | ||
hltOOTpuCorr->apply(cs, capidvec, calibs, digi, buffer); | ||
if( buffer.size() > 1 ){ | ||
m3_ampl = buffer[0]; | ||
if (puCorrMethod == 3) { | ||
time = buffer[1]; ampl = buffer[0]; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -400,33 +396,36 @@ namespace HcalSimpleRecAlgoImpl { | |
if (cell.subdet() == HcalBarrel) { | ||
const int ieta = cell.ieta(); | ||
const int iphi = cell.iphi(); | ||
ampl *= eCorr(ieta, iphi, ampl, runnum); | ||
uncorr_ampl *= eCorr(ieta, iphi, uncorr_ampl, runnum); | ||
ampl *= eCorr(ieta, iphi, ampl, runnum); | ||
m3_ampl *= eCorr(ieta, iphi, m3_ampl, runnum); | ||
} | ||
} | ||
|
||
// Correction for a leak to pre-sample | ||
if(useLeak && !leakCorrApplied) { | ||
ampl *= leakCorr(ampl); | ||
uncorr_ampl *= leakCorr(uncorr_ampl); | ||
uncorr_ampl *= leakCorr(uncorr_ampl); | ||
if (puCorrMethod < 2) | ||
ampl *= leakCorr(ampl); | ||
} | ||
|
||
RecHit rh(digi.id(),ampl,time); | ||
setRawEnergy(rh, static_cast<float>(uncorr_ampl)); | ||
setAuxEnergy(rh, static_cast<float>(m3_ampl)); | ||
return rh; | ||
} | ||
|
||
template<class Digi, class RecHit> | ||
template<class Digi, class RecHit> | ||
inline RecHit recoHBHE(const Digi& digi, const HcalCoder& coder, | ||
const HcalCalibrations& calibs, | ||
const int ifirst, const int n, const bool slewCorrect, | ||
const bool pulseCorrect, const HcalPulseContainmentCorrection* corr, | ||
const HcalTimeSlew::BiasSetting slewFlavor, | ||
const int runnum, const bool useLeak, | ||
const AbsOOTPileupCorrection* pileupCorrection, | ||
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub )// const on end | ||
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub, std::vector<double>& buffer)// const on end | ||
{ | ||
double fc_ampl =0, ampl =0, uncorr_ampl =0, maxA = -1.e300; | ||
double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300; | ||
int nRead = 0, maxI = -1; | ||
bool leakCorrApplied = false; | ||
float t0 =0, t2 =0; | ||
|
@@ -462,63 +461,69 @@ template<class Digi, class RecHit> | |
|
||
// Note that uncorr_ampl is always set from outside of method 2! | ||
if( puCorrMethod == 2 ){ | ||
std::vector<double> correctedOutput; | ||
buffer.clear(); | ||
|
||
CaloSamples cs; | ||
coder.adc2fC(digi,cs); | ||
std::vector<int> capidvec; | ||
for(int ip=0; ip<cs.size(); ip++){ | ||
const int capid = digi[ip].capid(); | ||
capidvec.push_back(capid); | ||
} | ||
psFitOOTpuCorr->apply(cs, capidvec, calibs, correctedOutput); | ||
if( correctedOutput.back() == 0 && correctedOutput.size() >1 ){ | ||
time = correctedOutput[1]; ampl = correctedOutput[0]; | ||
useTriple = correctedOutput[4]; | ||
psFitOOTpuCorr->apply(cs, capidvec, calibs, buffer); | ||
if( buffer.back() == 0 && buffer.size() >1 ){ | ||
time = buffer[1]; ampl = buffer[0]; | ||
useTriple = buffer[4]; | ||
} | ||
} | ||
|
||
// S. Brandt - Feb 19th : Adding Section for HLT | ||
// Turn on HLT here with puCorrMethod = 3 | ||
if ( puCorrMethod == 3){ | ||
std::vector<double> hltCorrOutput; | ||
// Run "Method 3" all the time. | ||
{ | ||
buffer.clear(); | ||
|
||
CaloSamples cs; | ||
coder.adc2fC(digi,cs); | ||
std::vector<int> capidvec; | ||
for(int ip=0; ip<cs.size(); ip++){ | ||
const int capid = digi[ip].capid(); | ||
capidvec.push_back(capid); | ||
} | ||
hltOOTpuCorr->apply(cs, capidvec, calibs, digi, hltCorrOutput); | ||
if( hltCorrOutput.size() > 1 ){ | ||
time = hltCorrOutput[1]; ampl = hltCorrOutput[0]; | ||
hltOOTpuCorr->apply(cs, capidvec, calibs, digi, buffer); | ||
if (buffer.size() > 1) { | ||
m3_ampl = buffer[0]; | ||
if (puCorrMethod == 3) { | ||
time = buffer[1]; ampl = buffer[0]; | ||
} | ||
} | ||
} | ||
|
||
// Temporary hack to apply energy-dependent corrections to some HB- cells | ||
if (runnum > 0) { | ||
const HcalDetId& cell = digi.id(); | ||
if (cell.subdet() == HcalBarrel) { | ||
const int ieta = cell.ieta(); | ||
const int iphi = cell.iphi(); | ||
ampl *= eCorr(ieta, iphi, ampl, runnum); | ||
uncorr_ampl *= eCorr(ieta, iphi, uncorr_ampl, runnum); | ||
ampl *= eCorr(ieta, iphi, ampl, runnum); | ||
m3_ampl *= eCorr(ieta, iphi, m3_ampl, runnum); | ||
} | ||
} | ||
|
||
// Correction for a leak to pre-sample | ||
if(useLeak && !leakCorrApplied) { | ||
ampl *= leakCorr(ampl); | ||
uncorr_ampl *= leakCorr(uncorr_ampl); | ||
if (puCorrMethod < 2) | ||
ampl *= leakCorr(ampl); | ||
} | ||
|
||
HBHERecHit rh(digi.id(),ampl,time); | ||
if(useTriple) | ||
{ | ||
rh.setFlagField(1, HcalCaloFlagLabels::HBHEPulseFitBit); | ||
} | ||
setRawEnergy(rh, static_cast<float>(uncorr_ampl)); | ||
setAuxEnergy(rh, static_cast<float>(m3_ampl)); | ||
return rh; | ||
} | ||
} | ||
|
@@ -531,7 +536,7 @@ HBHERecHit HcalSimpleRecAlgo::reconstruct(const HBHEDataFrame& digi, int first, | |
HcalTimeSlew::Medium, | ||
runnum_, setLeakCorrection_, | ||
hbhePileupCorr_.get(), | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get()); | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get(),vectorBuffer_); | ||
} | ||
|
||
|
||
|
@@ -541,7 +546,7 @@ HORecHit HcalSimpleRecAlgo::reconstruct(const HODataFrame& digi, int first, int | |
pulseCorr_->get(digi.id(), toadd, phaseNS_), | ||
HcalTimeSlew::Slow, | ||
runnum_, false, hoPileupCorr_.get(), | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get()); | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get(),vectorBuffer_); | ||
} | ||
|
||
|
||
|
@@ -551,7 +556,7 @@ HcalCalibRecHit HcalSimpleRecAlgo::reconstruct(const HcalCalibDataFrame& digi, i | |
pulseCorr_->get(digi.id(), toadd, phaseNS_), | ||
HcalTimeSlew::Fast, | ||
runnum_, false, 0, | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get()); | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get(),vectorBuffer_); | ||
} | ||
|
||
|
||
|
@@ -561,7 +566,7 @@ HBHERecHit HcalSimpleRecAlgo::reconstructHBHEUpgrade(const HcalUpgradeDataFrame& | |
pulseCorr_->get(digi.id(), toadd, phaseNS_), | ||
HcalTimeSlew::Medium, 0, false, | ||
hbhePileupCorr_.get(), | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get()); | ||
bunchCrossingInfo_, lenBunchCrossingInfo_, puCorrMethod_, psFitOOTpuCorr_.get(),/*hlt*/hltOOTpuCorr_.get(),pedSubFxn_.get(),vectorBuffer_); | ||
HcalTDCReco tdcReco; | ||
tdcReco.reconstruct(digi, result); | ||
return result; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the size of the saving from this buffer?
I'd much rather see no mutables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this.
I don't see much benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The saving does not come from the "size" of the vector. It is instead about not allocating (and then deallocating) the memory from the heap for each calorimeter cell processed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are several more allocations in the methods called internally.
So, if a fix needs to be done, better do it properly.
Your change with a mutable opens a possibility to pass information between hits.
This is not good.
Cleaning and clearing is apparently done correctly now, but this makes the code much more fragile in the future developments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is with 25ns hlt in 760pre5
https://slava77sk.web.cern.ch/slava77sk/reco/cgi-bin/igprof-navigator/CMSSW_7_6_0_pre5-orig.256729.step2-hlt.pp/797
i don't see any cpu cost reasons for this buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The allocations internal to "Method 2" and "Method 3" classes are, of course, irrelevant to this discussion. Bug the authors of the corresponding classes if you are so inclined.
The change with a mutable, of course, does not open any possibility to pass information between hits. The vector is cleared any time it is used.
Any code is "fragile" to some degree. I believe, the advantages outweigh the drawbacks in this particular case. The "mutable" keyword is included into the language precisely for the uses similar to this.
The cost reasons are obvious: we avoid allocating the contents of the vector on the heap for every hcal rechit.