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"),
318 std::unique_ptr<AbsHBHEPhase1Algo>
reco_;
331 template<
class DataFrame,
class Collection>
332 void processData(
const Collection&
coll,
336 const bool isRealData,
358 : algoConfigClass_(conf.getParameter<
std::
string>(
"algoConfigClass")),
359 processQIE8_(conf.getParameter<
bool>(
"processQIE8")),
360 processQIE11_(conf.getParameter<
bool>(
"processQIE11")),
361 saveInfos_(conf.getParameter<
bool>(
"saveInfos")),
362 saveDroppedInfos_(conf.getParameter<
bool>(
"saveDroppedInfos")),
363 makeRecHits_(conf.getParameter<
bool>(
"makeRecHits")),
364 dropZSmarkedPassed_(conf.getParameter<
bool>(
"dropZSmarkedPassed")),
365 tsFromDB_(conf.getParameter<
bool>(
"tsFromDB")),
366 recoParamsFromDB_(conf.getParameter<
bool>(
"recoParamsFromDB")),
367 saveEffectivePedestal_(conf.getParameter<
bool>(
"saveEffectivePedestal")),
368 sipmQTSShift_(conf.getParameter<
int>(
"sipmQTSShift")),
369 sipmQNTStoSum_(conf.getParameter<
int>(
"sipmQNTStoSum")),
370 setNegativeFlagsQIE8_(conf.getParameter<
bool>(
"setNegativeFlagsQIE8")),
371 setNegativeFlagsQIE11_(conf.getParameter<
bool>(
"setNegativeFlagsQIE11")),
372 setNoiseFlagsQIE8_(conf.getParameter<
bool>(
"setNoiseFlagsQIE8")),
373 setNoiseFlagsQIE11_(conf.getParameter<
bool>(
"setNoiseFlagsQIE11")),
374 setPulseShapeFlagsQIE8_(conf.getParameter<
bool>(
"setPulseShapeFlagsQIE8")),
375 setPulseShapeFlagsQIE11_(conf.getParameter<
bool>(
"setPulseShapeFlagsQIE11")),
382 <<
"Invalid HBHEPhase1Algo algorithm configuration" 406 tok_qie8_ = consumes<HBHEDigiCollection>(
414 produces<HBHEChannelInfoCollection>();
417 produces<HBHERecHitCollection>();
431 template<
class DFrame,
class Collection>
436 const bool isRealData,
448 for (
typename Collection::const_iterator it = coll.begin();
449 it != coll.end(); ++it)
451 const DFrame& frame(*it);
466 if (taggedBadByDb && skipDroppedChannels)
470 bool dropByZS =
false;
472 if (frame.zsMarkAndPass())
474 if (dropByZS && skipDroppedChannels)
488 const double fcByPE = siPMParameter.getFCByPE();
497 const int nRead = cs.
size();
501 cond, cell, cs, soi, frame, maxTS);
505 for (
int ts = 0; ts <
maxTS; ++ts)
508 const uint8_t adc = s.
adc();
509 const int capid = s.
capid();
512 const double pedestal = saveEffectivePeds ? calib.
effpedestal(capid) : calib.
pedestal(capid);
513 const double pedestalWidth = saveEffectivePeds ? calibWidth.
effpedestal(capid) : calibWidth.
pedestal(capid);
515 const double gainWidth = calibWidth.
gain(capid);
517 const double rawCharge = rcfs.getRawCharge(cs[ts], calib.
pedestal(capid));
518 const float t = getTDCTimeFromSample(s);
519 const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
521 channelInfo->
setSample(ts, adc, dfc, rawCharge,
522 pedestal, pedestalWidth,
530 const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
531 channelInfo->
setChannelInfo(cell, pulseShapeID, maxTS, soi, soiCapid,
532 darkCurrent, fcByPE, lambda,
533 hwerr.first, hwerr.second,
534 taggedBadByDb || dropByZS);
537 const bool makeThisRechit = !channelInfo->
isDropped();
542 if (rechits && makeThisRechit)
547 HBHERecHit rh =
reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
598 const unsigned nRead = info.
nSamples();
599 for (
unsigned i=0;
i<nRead; ++
i)
636 unsigned maxOutputSize = 0;
641 maxOutputSize += hbDigis->
size();
648 maxOutputSize += heDigis->
size();
652 std::unique_ptr<HBHEChannelInfoCollection>
infos;
655 infos = std::make_unique<HBHEChannelInfoCollection>();
656 infos->reserve(maxOutputSize);
659 std::unique_ptr<HBHERecHitCollection>
out;
662 out = std::make_unique<HBHERecHitCollection>();
663 out->reserve(maxOutputSize);
674 processData<HBHEDataFrame>(*hbDigis, *conditions, *
p, *mycomputer,
675 isData, &channelInfo, infos.get(), out.get());
686 processData<QIE11DataFrame>(*heDigis, *conditions, *
p, *mycomputer,
687 isData, &channelInfo, infos.get(), out.get());
707 if (
reco_->isConfigurable())
712 <<
"Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \"" 716 <<
"Failed to configure HBHEPhase1Algo algorithm from EventSetup" 733 "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
736 reco_->beginRun(r, es);
745 #define add_param_set(name) \ 746 edm::ParameterSetDescription name; \ 747 name.setAllowAnything(); \ 748 desc.add<edm::ParameterSetDescription>(#name, name) 759 desc.
add<
bool>(
"processQIE8");
760 desc.
add<
bool>(
"processQIE11");
761 desc.
add<
bool>(
"saveInfos");
762 desc.
add<
bool>(
"saveDroppedInfos");
763 desc.
add<
bool>(
"makeRecHits");
764 desc.
add<
bool>(
"dropZSmarkedPassed");
765 desc.
add<
bool>(
"tsFromDB");
766 desc.
add<
bool>(
"recoParamsFromDB");
767 desc.
add<
bool>(
"saveEffectivePedestal",
false);
768 desc.
add<
int>(
"sipmQTSShift", 0);
769 desc.
add<
int>(
"sipmQNTStoSum", 3);
770 desc.
add<
bool>(
"setNegativeFlagsQIE8");
771 desc.
add<
bool>(
"setNegativeFlagsQIE11");
772 desc.
add<
bool>(
"setNoiseFlagsQIE8");
773 desc.
add<
bool>(
"setNoiseFlagsQIE11");
774 desc.
add<
bool>(
"setPulseShapeFlagsQIE8");
775 desc.
add<
bool>(
"setPulseShapeFlagsQIE11");
776 desc.
add<
bool>(
"setLegacyFlagsQIE8");
777 desc.
add<
bool>(
"setLegacyFlagsQIE11");
int adc(sample_type sample)
get the ADC sample (12 bits)
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.
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
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_
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_
constexpr double effpedestal(int fCapId) const
get effective pedestal for capid=0..3
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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
bool setPulseShapeFlagsQIE8_
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE11_
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
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)
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.