73 template<
class DFrame>
74 class RawChargeFromSample
87 inline double getRawCharge(
const double decodedCharge,
89 {
return decodedCharge;}
105 : siPMParameter_(*cond.getHcalSiPMParameter(id)),
106 fcByPE_(siPMParameter_.getFCByPE()),
107 corr_(cond.getHcalSiPMCharacteristics()->getNonLinearities(siPMParameter_.getType()))
111 <<
"Invalid fC/PE conversion factor for SiPM " <<
id 115 const double darkCurrent = siPMParameter_.getDarkCurrent();
117 const int firstTS =
std::max(soi + sipmQTSShift, 0);
118 const int lastTS =
std::min(firstTS + sipmQNTStoSum, maxTS);
121 for (
int ts = firstTS; ts < lastTS; ++ts)
124 (saveEffectivePedestal ? darkCurrent * 25. / (1. - lambda) : 0.);
128 const double effectivePixelsFired = sipmQ/fcByPE_;
129 factor_ = corr_.getRecoCorrectionFactor(effectivePixelsFired);
132 inline double getRawCharge(
const double decodedCharge,
133 const double pedestal)
const 135 return (decodedCharge - pedestal)*factor_ +
pedestal;
160 float getDifferentialChargeGain(
const HcalQIECoder& coder,
163 const unsigned capid,
167 static const unsigned mantissaMaskQIE8 = 0x1f;
168 static const unsigned mantissaMaskQIE11 = 0x3f;
170 const float q = coder.
charge(shape, adc, capid);
171 const unsigned mantissaMask = isQIE11 ? mantissaMaskQIE11 : mantissaMaskQIE8;
172 const unsigned mantissa = adc & mantissaMask;
177 if (mantissa == 0
U || mantissa == mantissaMask - 1
U)
178 return coder.
charge(shape, adc+1
U, capid) -
q;
179 else if (mantissa == 1
U || mantissa == mantissaMask)
180 return q - coder.
charge(shape, adc-1
U, capid);
183 const float qup = coder.
charge(shape, adc+1
U, capid);
184 const float qdown = coder.
charge(shape, adc-1
U, capid);
185 const float upGain = qup -
q;
186 const float downGain = q - qdown;
187 const float averageGain = (qup - qdown)/2.
f;
188 if (
std::abs(upGain - downGain) < 0.01f*averageGain)
198 const float q2up = coder.
charge(shape, adc+2
U, capid);
199 const float q2down = coder.
charge(shape, adc-2
U, capid);
200 const float upGain2 = q2up - qup;
201 const float downGain2 = qdown - q2down;
215 bool linkErr =
false;
216 bool capidErr =
false;
219 int expectedCapid = df[0].capid();
220 for (
unsigned i=0;
i<len; ++
i)
224 if (df[
i].capid() != expectedCapid)
226 expectedCapid = (expectedCapid + 1) % 4;
229 return std::pair<bool,bool>(linkErr, capidErr);
238 std::unique_ptr<HBHEStatusBitSetter> parse_HBHEStatusBitSetter(
241 return std::make_unique<HBHEStatusBitSetter>(
245 psdigi.
getParameter<std::vector<edm::ParameterSet> >(
"pulseShapeParameterSets"));
248 std::unique_ptr<HBHEPulseShapeFlagSetter> parse_HBHEPulseShapeFlagSetter(
251 return std::make_unique<HBHEPulseShapeFlagSetter>(
252 psPulseShape.
getParameter<
double>(
"MinimumChargeThreshold"),
253 psPulseShape.
getParameter<
double>(
"TS4TS5ChargeThreshold"),
254 psPulseShape.
getParameter<
double>(
"TS3TS4ChargeThreshold"),
255 psPulseShape.
getParameter<
double>(
"TS3TS4UpperChargeThreshold"),
256 psPulseShape.
getParameter<
double>(
"TS5TS6ChargeThreshold"),
257 psPulseShape.
getParameter<
double>(
"TS5TS6UpperChargeThreshold"),
260 psPulseShape.
getParameter<
unsigned int>(
"TrianglePeakTS"),
261 psPulseShape.
getParameter<std::vector<double> >(
"LinearThreshold"),
262 psPulseShape.
getParameter<std::vector<double> >(
"LinearCut"),
263 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxThreshold"),
264 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxCut"),
265 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeThreshold"),
266 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeCut"),
267 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeThreshold"),
268 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeCut"),
269 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallThreshold"),
270 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallCut"),
271 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerThreshold"),
272 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerCut"),
273 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperThreshold"),
274 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperCut"),
323 std::unique_ptr<AbsHBHEPhase1Algo>
reco_;
336 template<
class DataFrame,
class Collection>
337 void processData(
const Collection&
coll,
341 const bool isRealData,
363 : algoConfigClass_(conf.getParameter<
std::
string>(
"algoConfigClass")),
364 processQIE8_(conf.getParameter<
bool>(
"processQIE8")),
365 processQIE11_(conf.getParameter<
bool>(
"processQIE11")),
366 saveInfos_(conf.getParameter<
bool>(
"saveInfos")),
367 saveDroppedInfos_(conf.getParameter<
bool>(
"saveDroppedInfos")),
368 makeRecHits_(conf.getParameter<
bool>(
"makeRecHits")),
369 dropZSmarkedPassed_(conf.getParameter<
bool>(
"dropZSmarkedPassed")),
370 tsFromDB_(conf.getParameter<
bool>(
"tsFromDB")),
371 recoParamsFromDB_(conf.getParameter<
bool>(
"recoParamsFromDB")),
372 saveEffectivePedestal_(conf.getParameter<
bool>(
"saveEffectivePedestal")),
373 sipmQTSShift_(conf.getParameter<
int>(
"sipmQTSShift")),
374 sipmQNTStoSum_(conf.getParameter<
int>(
"sipmQNTStoSum")),
375 setNegativeFlagsQIE8_(conf.getParameter<
bool>(
"setNegativeFlagsQIE8")),
376 setNegativeFlagsQIE11_(conf.getParameter<
bool>(
"setNegativeFlagsQIE11")),
377 setNoiseFlagsQIE8_(conf.getParameter<
bool>(
"setNoiseFlagsQIE8")),
378 setNoiseFlagsQIE11_(conf.getParameter<
bool>(
"setNoiseFlagsQIE11")),
379 setPulseShapeFlagsQIE8_(conf.getParameter<
bool>(
"setPulseShapeFlagsQIE8")),
380 setPulseShapeFlagsQIE11_(conf.getParameter<
bool>(
"setPulseShapeFlagsQIE11")),
387 <<
"Invalid HBHEPhase1Algo algorithm configuration" 411 tok_qie8_ = consumes<HBHEDigiCollection>(
419 produces<HBHEChannelInfoCollection>();
422 produces<HBHERecHitCollection>();
436 template<
class DFrame,
class Collection>
441 const bool isRealData,
453 for (
typename Collection::const_iterator it = coll.begin();
454 it != coll.end(); ++it)
456 const DFrame& frame(*it);
471 if (taggedBadByDb && skipDroppedChannels)
475 bool dropByZS =
false;
477 if (frame.zsMarkAndPass())
479 if (dropByZS && skipDroppedChannels)
493 const double fcByPE = siPMParameter.getFCByPE();
501 const int nRead = cs.
size();
505 cond, cell, cs, soi, frame, maxTS);
509 for (
int ts = 0; ts <
maxTS; ++ts)
512 const uint8_t adc = s.
adc();
513 const int capid = s.
capid();
517 const double pedestalWidth = calibWidth.
pedestal(capid);
519 const double gainWidth = calibWidth.
gain(capid);
520 const double rawCharge = rcfs.getRawCharge(cs[ts], pedestal);
521 const float t = getTDCTimeFromSample(s);
522 const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
524 channelInfo->
setSample(ts, adc, dfc, rawCharge,
525 pedestal, pedestalWidth,
533 const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
534 channelInfo->
setChannelInfo(cell, pulseShapeID, maxTS, soi, soiCapid,
535 darkCurrent, fcByPE, lambda,
536 hwerr.first, hwerr.second,
537 taggedBadByDb || dropByZS);
540 const bool makeThisRechit = !channelInfo->
isDropped();
545 if (rechits && makeThisRechit)
550 HBHERecHit rh =
reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
601 const unsigned nRead = info.
nSamples();
602 for (
unsigned i=0;
i<nRead; ++
i)
639 unsigned maxOutputSize = 0;
644 maxOutputSize += hbDigis->
size();
651 maxOutputSize += heDigis->
size();
655 std::unique_ptr<HBHEChannelInfoCollection>
infos;
658 infos = std::make_unique<HBHEChannelInfoCollection>();
659 infos->reserve(maxOutputSize);
662 std::unique_ptr<HBHERecHitCollection>
out;
665 out = std::make_unique<HBHERecHitCollection>();
666 out->reserve(maxOutputSize);
677 processData<HBHEDataFrame>(*hbDigis, *conditions, *
p, *mycomputer,
678 isData, &channelInfo, infos.get(), out.get());
689 processData<QIE11DataFrame>(*heDigis, *conditions, *
p, *mycomputer,
690 isData, &channelInfo, infos.get(), out.get());
710 if (
reco_->isConfigurable())
715 <<
"Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \"" 719 <<
"Failed to configure HBHEPhase1Algo algorithm from EventSetup" 736 "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
739 reco_->beginRun(r, es);
748 #define add_param_set(name) \ 749 edm::ParameterSetDescription name; \ 750 name.setAllowAnything(); \ 751 desc.add<edm::ParameterSetDescription>(#name, name) 762 desc.
add<
bool>(
"processQIE8");
763 desc.
add<
bool>(
"processQIE11");
764 desc.
add<
bool>(
"saveInfos");
765 desc.
add<
bool>(
"saveDroppedInfos");
766 desc.
add<
bool>(
"makeRecHits");
767 desc.
add<
bool>(
"dropZSmarkedPassed");
768 desc.
add<
bool>(
"tsFromDB");
769 desc.
add<
bool>(
"recoParamsFromDB");
770 desc.
add<
bool>(
"saveEffectivePedestal",
false);
771 desc.
add<
int>(
"sipmQTSShift", 0);
772 desc.
add<
int>(
"sipmQNTStoSum", 3);
773 desc.
add<
bool>(
"setNegativeFlagsQIE8");
774 desc.
add<
bool>(
"setNegativeFlagsQIE11");
775 desc.
add<
bool>(
"setNoiseFlagsQIE8");
776 desc.
add<
bool>(
"setNoiseFlagsQIE11");
777 desc.
add<
bool>(
"setPulseShapeFlagsQIE8");
778 desc.
add<
bool>(
"setPulseShapeFlagsQIE11");
779 desc.
add<
bool>(
"setLegacyFlagsQIE8");
780 desc.
add<
bool>(
"setLegacyFlagsQIE11");
int adc(sample_type sample)
get the ADC sample (12 bits)
HBHEPhase1Reconstructor(const edm::ParameterSet &)
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE8_
unsigned int firstSample() const
T getParameter(std::string const &) const
const HBHENegativeEFilter * negEFilter_
float getTDCTime(const int tdc)
double gain(int fCapId) const
get gain width for capid=0..3
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
auto_ptr< ClusterSequence > cs
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_
#define DEFINE_FWK_MODULE(type)
void beginRun(edm::Run const &, edm::EventSetup const &) override
HcalDetId id() const
get the id
void setFlagField(uint32_t value, int base, int width=1)
std::string algoConfigClass_
void push_back(T const &t)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) 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)
float getCrossTalk(int type) const
get cross talk
bool setPulseShapeFlagsQIE11_
bool checkPassFilter(const HcalDetId &id, const double *ts, unsigned lenTS) const
uint32_t rawId() const
get the raw id
void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const override
std::unique_ptr< HcalRecoParams > paramTS_
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
void processData(const Collection &coll, const HcalDbService &cond, const HcalChannelQuality &qual, const HcalSeverityLevelComputer &severity, const bool isRealData, HBHEChannelInfo *info, HBHEChannelInfoCollection *infoColl, HBHERecHitCollection *rechits)
edm::EDGetTokenT< QIE11DigiCollection > tok_qie11_
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_
bool saveEffectivePedestal_
float getDarkCurrent() const
get dark current
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void runHBHENegativeEFilter(const HBHEChannelInfo &info, HBHERecHit *rh)
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
pulseShapeParametersQIE11
unsigned int pulseShapeID() const
bool setPulseShapeFlagsQIE8_
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE11_
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
void produce(edm::Event &, const edm::EventSetup &) override
#define add_param_set(name)
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.