73 template<
class DFrame>
74 class RawChargeFromSample
86 inline double getRawCharge(
const double decodedCharge,
88 {
return decodedCharge;}
103 : siPMParameter_(*cond.getHcalSiPMParameter(id)),
104 fcByPE_(siPMParameter_.getFCByPE()),
105 corr_(cond.getHcalSiPMCharacteristics()->getNonLinearities(siPMParameter_.getType()))
109 <<
"Invalid fC/PE conversion factor for SiPM " <<
id 113 const int firstTS =
std::max(soi + sipmQTSShift, 0);
114 const int lastTS =
std::min(firstTS + sipmQNTStoSum, maxTS);
117 for (
int ts = firstTS; ts < lastTS; ++ts)
123 const double effectivePixelsFired = sipmQ/fcByPE_;
124 factor_ = corr_.getRecoCorrectionFactor(effectivePixelsFired);
127 inline double getRawCharge(
const double decodedCharge,
128 const double pedestal)
const 130 return (decodedCharge - pedestal)*factor_ +
pedestal;
155 float getDifferentialChargeGain(
const HcalQIECoder& coder,
158 const unsigned capid,
162 static const unsigned mantissaMaskQIE8 = 0x1f;
163 static const unsigned mantissaMaskQIE11 = 0x3f;
165 const float q = coder.
charge(shape, adc, capid);
166 const unsigned mantissaMask = isQIE11 ? mantissaMaskQIE11 : mantissaMaskQIE8;
167 const unsigned mantissa = adc & mantissaMask;
172 if (mantissa == 0
U || mantissa == mantissaMask - 1
U)
173 return coder.
charge(shape, adc+1
U, capid) -
q;
174 else if (mantissa == 1
U || mantissa == mantissaMask)
175 return q - coder.
charge(shape, adc-1
U, capid);
178 const float qup = coder.
charge(shape, adc+1
U, capid);
179 const float qdown = coder.
charge(shape, adc-1
U, capid);
180 const float upGain = qup -
q;
181 const float downGain = q - qdown;
182 const float averageGain = (qup - qdown)/2.
f;
183 if (
std::abs(upGain - downGain) < 0.01f*averageGain)
193 const float q2up = coder.
charge(shape, adc+2
U, capid);
194 const float q2down = coder.
charge(shape, adc-2
U, capid);
195 const float upGain2 = q2up - qup;
196 const float downGain2 = qdown - q2down;
210 bool linkErr =
false;
211 bool capidErr =
false;
214 int expectedCapid = df[0].capid();
215 for (
unsigned i=0;
i<len; ++
i)
219 if (df[
i].capid() != expectedCapid)
221 expectedCapid = (expectedCapid + 1) % 4;
224 return std::pair<bool,bool>(linkErr, capidErr);
233 std::unique_ptr<HBHEStatusBitSetter> parse_HBHEStatusBitSetter(
236 return std::make_unique<HBHEStatusBitSetter>(
240 psdigi.
getParameter<std::vector<edm::ParameterSet> >(
"pulseShapeParameterSets"));
243 std::unique_ptr<HBHEPulseShapeFlagSetter> parse_HBHEPulseShapeFlagSetter(
246 return std::make_unique<HBHEPulseShapeFlagSetter>(
247 psPulseShape.
getParameter<
double>(
"MinimumChargeThreshold"),
248 psPulseShape.
getParameter<
double>(
"TS4TS5ChargeThreshold"),
249 psPulseShape.
getParameter<
double>(
"TS3TS4ChargeThreshold"),
250 psPulseShape.
getParameter<
double>(
"TS3TS4UpperChargeThreshold"),
251 psPulseShape.
getParameter<
double>(
"TS5TS6ChargeThreshold"),
252 psPulseShape.
getParameter<
double>(
"TS5TS6UpperChargeThreshold"),
255 psPulseShape.
getParameter<
unsigned int>(
"TrianglePeakTS"),
256 psPulseShape.
getParameter<std::vector<double> >(
"LinearThreshold"),
257 psPulseShape.
getParameter<std::vector<double> >(
"LinearCut"),
258 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxThreshold"),
259 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxCut"),
260 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeThreshold"),
261 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeCut"),
262 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeThreshold"),
263 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeCut"),
264 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallThreshold"),
265 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallCut"),
266 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerThreshold"),
267 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerCut"),
268 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperThreshold"),
269 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperCut"),
319 std::unique_ptr<AbsHBHEPhase1Algo>
reco_;
332 template<
class DataFrame,
class Collection>
333 void processData(
const Collection&
coll,
337 const bool isRealData,
360 : algoConfigClass_(conf.getParameter<
std::
string>(
"algoConfigClass")),
361 processQIE8_(conf.getParameter<
bool>(
"processQIE8")),
362 processQIE11_(conf.getParameter<
bool>(
"processQIE11")),
363 saveInfos_(conf.getParameter<
bool>(
"saveInfos")),
364 saveDroppedInfos_(conf.getParameter<
bool>(
"saveDroppedInfos")),
365 makeRecHits_(conf.getParameter<
bool>(
"makeRecHits")),
366 dropZSmarkedPassed_(conf.getParameter<
bool>(
"dropZSmarkedPassed")),
367 tsFromDB_(conf.getParameter<
bool>(
"tsFromDB")),
368 recoParamsFromDB_(conf.getParameter<
bool>(
"recoParamsFromDB")),
369 saveEffectivePedestal_(conf.getParameter<
bool>(
"saveEffectivePedestal")),
370 use8ts_(conf.getParameter<
bool>(
"use8ts")),
371 sipmQTSShift_(conf.getParameter<
int>(
"sipmQTSShift")),
372 sipmQNTStoSum_(conf.getParameter<
int>(
"sipmQNTStoSum")),
373 setNegativeFlagsQIE8_(conf.getParameter<
bool>(
"setNegativeFlagsQIE8")),
374 setNegativeFlagsQIE11_(conf.getParameter<
bool>(
"setNegativeFlagsQIE11")),
375 setNoiseFlagsQIE8_(conf.getParameter<
bool>(
"setNoiseFlagsQIE8")),
376 setNoiseFlagsQIE11_(conf.getParameter<
bool>(
"setNoiseFlagsQIE11")),
377 setPulseShapeFlagsQIE8_(conf.getParameter<
bool>(
"setPulseShapeFlagsQIE8")),
378 setPulseShapeFlagsQIE11_(conf.getParameter<
bool>(
"setPulseShapeFlagsQIE11")),
385 <<
"Invalid HBHEPhase1Algo algorithm configuration" 409 tok_qie8_ = consumes<HBHEDigiCollection>(
417 produces<HBHEChannelInfoCollection>();
420 produces<HBHERecHitCollection>();
434 template<
class DFrame,
class Collection>
439 const bool isRealData,
452 for (
typename Collection::const_iterator it = coll.begin();
453 it != coll.end(); ++it)
455 const DFrame& frame(*it);
470 if (taggedBadByDb && skipDroppedChannels)
474 bool dropByZS =
false;
476 if (frame.zsMarkAndPass())
478 if (dropByZS && skipDroppedChannels)
492 const double fcByPE = siPMParameter.getFCByPE();
501 const int nRead = cs.
size();
505 cond, cell, cs, soi, frame, maxTS);
510 const int nCycles = maxTS - shiftOneTS;
513 for (
int inputTS = shiftOneTS; inputTS < nCycles; ++inputTS)
515 auto s(frame[inputTS]);
516 const uint8_t adc = s.
adc();
517 const int capid = s.
capid();
520 const double pedestal = saveEffectivePeds ? calib.
effpedestal(capid) : calib.
pedestal(capid);
521 const double pedestalWidth = saveEffectivePeds ? calibWidth.
effpedestal(capid) : calibWidth.
pedestal(capid);
523 const double gainWidth = calibWidth.
gain(capid);
525 const double rawCharge = rcfs.getRawCharge(cs[inputTS], calib.
pedestal(capid));
526 const float t = getTDCTimeFromSample(s);
527 const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
529 const int fitTS = inputTS-shiftOneTS;
530 channelInfo->
setSample(fitTS, adc, dfc, rawCharge,
531 pedestal, pedestalWidth,
538 const int maxFitTS = maxTS-2*shiftOneTS;
539 const int fitSoi = soi-shiftOneTS;
541 const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
542 channelInfo->
setChannelInfo(cell, pulseShapeID, maxFitTS, fitSoi, soiCapid,
543 darkCurrent, fcByPE, lambda,
544 hwerr.first, hwerr.second,
545 taggedBadByDb || dropByZS);
548 const bool makeThisRechit = !channelInfo->
isDropped();
553 if (rechits && makeThisRechit)
558 HBHERecHit rh =
reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
609 const unsigned nRead = info.
nSamples();
610 for (
unsigned i=0;
i<nRead; ++
i)
647 unsigned maxOutputSize = 0;
652 maxOutputSize += hbDigis->
size();
659 maxOutputSize += heDigis->
size();
663 std::unique_ptr<HBHEChannelInfoCollection>
infos;
666 infos = std::make_unique<HBHEChannelInfoCollection>();
667 infos->reserve(maxOutputSize);
670 std::unique_ptr<HBHERecHitCollection>
out;
673 out = std::make_unique<HBHERecHitCollection>();
674 out->reserve(maxOutputSize);
685 processData<HBHEDataFrame>(*hbDigis, *conditions, *
p, *mycomputer,
686 isData, &channelInfo, infos.get(), out.get(),
use8ts_);
697 processData<QIE11DataFrame>(*heDigis, *conditions, *
p, *mycomputer,
698 isData, &channelInfo, infos.get(), out.get(),
use8ts_);
718 if (
reco_->isConfigurable())
723 <<
"Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \"" 727 <<
"Failed to configure HBHEPhase1Algo algorithm from EventSetup" 744 "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
747 reco_->beginRun(r, es);
756 #define add_param_set(name) \ 757 edm::ParameterSetDescription name; \ 758 name.setAllowAnything(); \ 759 desc.add<edm::ParameterSetDescription>(#name, name) 770 desc.
add<
bool>(
"processQIE8");
771 desc.
add<
bool>(
"processQIE11");
772 desc.
add<
bool>(
"saveInfos");
773 desc.
add<
bool>(
"saveDroppedInfos");
774 desc.
add<
bool>(
"makeRecHits");
775 desc.
add<
bool>(
"dropZSmarkedPassed");
776 desc.
add<
bool>(
"tsFromDB");
777 desc.
add<
bool>(
"recoParamsFromDB");
778 desc.
add<
bool>(
"saveEffectivePedestal",
false);
779 desc.
add<
bool>(
"use8ts",
false);
780 desc.
add<
int>(
"sipmQTSShift", 0);
781 desc.
add<
int>(
"sipmQNTStoSum", 3);
782 desc.
add<
bool>(
"setNegativeFlagsQIE8");
783 desc.
add<
bool>(
"setNegativeFlagsQIE11");
784 desc.
add<
bool>(
"setNoiseFlagsQIE8");
785 desc.
add<
bool>(
"setNoiseFlagsQIE11");
786 desc.
add<
bool>(
"setPulseShapeFlagsQIE8");
787 desc.
add<
bool>(
"setPulseShapeFlagsQIE11");
788 desc.
add<
bool>(
"setLegacyFlagsQIE8");
789 desc.
add<
bool>(
"setLegacyFlagsQIE11");
HBHEPhase1Reconstructor(const edm::ParameterSet &)
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE8_
T getParameter(std::string const &) const
constexpr unsigned int pulseShapeID() const
const HBHENegativeEFilter * negEFilter_
double gain(int fCapId) const
get gain width for capid=0..3
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
int maxTS(DIGI const &digi, double ped=0)
HcalSubdetector subdet() const
get the subdetector
void setCommonStatusBits(const HBHEChannelInfo &info, const HcalCalibrations &calib, HBHERecHit *rh)
std::unique_ptr< HBHEStatusBitSetter > hbheFlagSetterQIE11_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< HBHEStatusBitSetter > hbheFlagSetterQIE8_
unique_ptr< ClusterSequence > cs
void beginRun(edm::Run const &, edm::EventSetup const &) override
HcalDetId id() const
get the id
constexpr uint32_t rawId() const
get the raw id
std::string algoConfigClass_
void push_back(T const &t)
double effpedestal(int fCapId) const
get effective pedestal width for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool hasEffectivePedestals() const
std::unique_ptr< AbsHcalAlgoData > fetchHcalAlgoData(const std::string &className, const edm::EventSetup &es)
void setSample(const unsigned ts, const uint8_t rawADC, const float differentialChargeGain, const double q, const double ped, const double pedWidth, const double g, const double gainWidth, const float t)
constexpr void setFlagField(uint32_t value, int base, int width=1)
float getCrossTalk(int type) const
get cross talk
bool setPulseShapeFlagsQIE11_
bool checkPassFilter(const HcalDetId &id, const double *ts, unsigned lenTS) const
constexpr float getTDCTime(const int tdc)
void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const override
std::unique_ptr< HcalRecoParams > paramTS_
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
static const unsigned MAXSAMPLES
bool setNegativeFlagsQIE11_
double pedestal(int fCapId) const
get pedestal width for capid=0..3
void endRun(edm::Run const &, edm::EventSetup const &) override
bool linkError() const
was there a link error?
edm::EDGetTokenT< QIE11DigiCollection > tok_qie11_
constexpr double effpedestal(int fCapId) const
get effective pedestal for capid=0..3
edm::EDGetTokenT< HBHEDigiCollection > tok_qie8_
std::unique_ptr< AbsHBHEPhase1Algo > parseHBHEPhase1AlgoDescription(const edm::ParameterSet &ps)
Abs< T >::type abs(const T &t)
bool dropChannel(const uint32_t &mystatus) const
double tsCharge(const unsigned ts) const
~HBHEPhase1Reconstructor() override
std::unique_ptr< AbsHBHEPhase1Algo > reco_
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
bool saveEffectivePedestal_
float getDarkCurrent() const
get dark current
void processData(const Collection &coll, const HcalDbService &cond, const HcalChannelQuality &qual, const HcalSeverityLevelComputer &severity, const bool isRealData, HBHEChannelInfo *info, HBHEChannelInfoCollection *infoColl, HBHERecHitCollection *rechits, const bool use8ts)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void runHBHENegativeEFilter(const HBHEChannelInfo &info, HBHERecHit *rh)
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
pulseShapeParametersQIE11
bool setPulseShapeFlagsQIE8_
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE11_
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int size() const
get the size
const HcalSiPMCharacteristics * getHcalSiPMCharacteristics() const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
void setAsicSpecificBits(const HBHEDataFrame &frame, const HcalCoder &coder, const HBHEChannelInfo &info, const HcalCalibrations &calib, HBHERecHit *rh)
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr float UNKNOWN_T_NOTDC
bool setNegativeFlagsQIE8_
void setChannelInfo(const HcalDetId &detId, const int recoShape, const unsigned nSamp, const unsigned iSoi, const int iCapid, const double darkCurrent, const double fcByPE, const double lambda, const bool linkError, const bool capidError, const bool dropThisChannel)
std::unique_ptr< AbsHcalAlgoData > recoConfig_
unsigned nSamples() const
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const HcalSiPMParameter * getHcalSiPMParameter(const HcalGenericDetId &fId) const
T const * product() const
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
void produce(edm::Event &, const edm::EventSetup &) override
constexpr unsigned int firstSample() const
#define add_param_set(name)
edm::ParameterSetDescription fillDescriptionForParseHBHEPhase1Algo()
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.