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;
153 static const float qie11_tdc_to_ns = 0.5f;
157 static const int qie11_tdc_code_overshoot = 62;
158 static const int qie11_tdc_code_undershoot = 63;
160 const int tdc = s.
tdc();
161 float t = qie11_tdc_to_ns*tdc;
162 if (tdc == qie11_tdc_code_overshoot)
164 else if (tdc == qie11_tdc_code_undershoot)
174 float getDifferentialChargeGain(
const HcalQIECoder& coder,
177 const unsigned capid,
181 static const unsigned mantissaMaskQIE8 = 0x1f;
182 static const unsigned mantissaMaskQIE11 = 0x3f;
184 const float q = coder.
charge(shape, adc, capid);
185 const unsigned mantissaMask = isQIE11 ? mantissaMaskQIE11 : mantissaMaskQIE8;
186 const unsigned mantissa = adc & mantissaMask;
191 if (mantissa == 0
U || mantissa == mantissaMask - 1
U)
192 return coder.
charge(shape, adc+1
U, capid) -
q;
193 else if (mantissa == 1
U || mantissa == mantissaMask)
194 return q - coder.
charge(shape, adc-1
U, capid);
197 const float qup = coder.
charge(shape, adc+1
U, capid);
198 const float qdown = coder.
charge(shape, adc-1
U, capid);
199 const float upGain = qup -
q;
200 const float downGain = q - qdown;
201 const float averageGain = (qup - qdown)/2.
f;
202 if (
std::abs(upGain - downGain) < 0.01f*averageGain)
212 const float q2up = coder.
charge(shape, adc+2
U, capid);
213 const float q2down = coder.
charge(shape, adc-2
U, capid);
214 const float upGain2 = q2up - qup;
215 const float downGain2 = qdown - q2down;
229 bool linkErr =
false;
230 bool capidErr =
false;
233 int expectedCapid = df[0].capid();
234 for (
unsigned i=0;
i<len; ++
i)
238 if (df[
i].capid() != expectedCapid)
240 expectedCapid = (expectedCapid + 1) % 4;
243 return std::pair<bool,bool>(linkErr, capidErr);
252 std::unique_ptr<HBHEStatusBitSetter> parse_HBHEStatusBitSetter(
255 return std::make_unique<HBHEStatusBitSetter>(
259 psdigi.
getParameter<std::vector<edm::ParameterSet> >(
"pulseShapeParameterSets"));
262 std::unique_ptr<HBHEPulseShapeFlagSetter> parse_HBHEPulseShapeFlagSetter(
265 return std::make_unique<HBHEPulseShapeFlagSetter>(
266 psPulseShape.
getParameter<
double>(
"MinimumChargeThreshold"),
267 psPulseShape.
getParameter<
double>(
"TS4TS5ChargeThreshold"),
268 psPulseShape.
getParameter<
double>(
"TS3TS4ChargeThreshold"),
269 psPulseShape.
getParameter<
double>(
"TS3TS4UpperChargeThreshold"),
270 psPulseShape.
getParameter<
double>(
"TS5TS6ChargeThreshold"),
271 psPulseShape.
getParameter<
double>(
"TS5TS6UpperChargeThreshold"),
274 psPulseShape.
getParameter<
unsigned int>(
"TrianglePeakTS"),
275 psPulseShape.
getParameter<std::vector<double> >(
"LinearThreshold"),
276 psPulseShape.
getParameter<std::vector<double> >(
"LinearCut"),
277 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxThreshold"),
278 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxCut"),
279 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeThreshold"),
280 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeCut"),
281 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeThreshold"),
282 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeCut"),
283 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallThreshold"),
284 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallCut"),
285 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerThreshold"),
286 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerCut"),
287 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperThreshold"),
288 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperCut"),
337 std::unique_ptr<AbsHBHEPhase1Algo>
reco_;
350 template<
class DataFrame,
class Collection>
351 void processData(
const Collection&
coll,
355 const bool isRealData,
377 : algoConfigClass_(conf.getParameter<
std::
string>(
"algoConfigClass")),
378 processQIE8_(conf.getParameter<bool>(
"processQIE8")),
379 processQIE11_(conf.getParameter<bool>(
"processQIE11")),
380 saveInfos_(conf.getParameter<bool>(
"saveInfos")),
381 saveDroppedInfos_(conf.getParameter<bool>(
"saveDroppedInfos")),
382 makeRecHits_(conf.getParameter<bool>(
"makeRecHits")),
383 dropZSmarkedPassed_(conf.getParameter<bool>(
"dropZSmarkedPassed")),
384 tsFromDB_(conf.getParameter<bool>(
"tsFromDB")),
385 recoParamsFromDB_(conf.getParameter<bool>(
"recoParamsFromDB")),
386 saveEffectivePedestal_(conf.getParameter<bool>(
"saveEffectivePedestal")),
387 sipmQTSShift_(conf.getParameter<
int>(
"sipmQTSShift")),
388 sipmQNTStoSum_(conf.getParameter<
int>(
"sipmQNTStoSum")),
389 setNegativeFlagsQIE8_(conf.getParameter<bool>(
"setNegativeFlagsQIE8")),
390 setNegativeFlagsQIE11_(conf.getParameter<bool>(
"setNegativeFlagsQIE11")),
391 setNoiseFlagsQIE8_(conf.getParameter<bool>(
"setNoiseFlagsQIE8")),
392 setNoiseFlagsQIE11_(conf.getParameter<bool>(
"setNoiseFlagsQIE11")),
393 setPulseShapeFlagsQIE8_(conf.getParameter<bool>(
"setPulseShapeFlagsQIE8")),
394 setPulseShapeFlagsQIE11_(conf.getParameter<bool>(
"setPulseShapeFlagsQIE11")),
401 <<
"Invalid HBHEPhase1Algo algorithm configuration" 425 tok_qie8_ = consumes<HBHEDigiCollection>(
433 produces<HBHEChannelInfoCollection>();
436 produces<HBHERecHitCollection>();
450 template<
class DFrame,
class Collection>
455 const bool isRealData,
467 for (
typename Collection::const_iterator it = coll.begin();
468 it != coll.end(); ++it)
470 const DFrame& frame(*it);
485 if (taggedBadByDb && skipDroppedChannels)
489 bool dropByZS =
false;
491 if (frame.zsMarkAndPass())
493 if (dropByZS && skipDroppedChannels)
507 const double fcByPE = siPMParameter.getFCByPE();
515 const int nRead = cs.
size();
519 cond, cell, cs, soi, frame, maxTS);
523 for (
int ts = 0; ts <
maxTS; ++ts)
526 const uint8_t adc = s.
adc();
527 const int capid = s.
capid();
531 const double pedestalWidth = calibWidth.
pedestal(capid);
533 const double gainWidth = calibWidth.
gain(capid);
534 const double rawCharge = rcfs.getRawCharge(cs[ts], pedestal);
535 const float t = getTDCTimeFromSample(s);
536 const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
538 channelInfo->
setSample(ts, adc, dfc, rawCharge,
539 pedestal, pedestalWidth,
547 const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
548 channelInfo->
setChannelInfo(cell, pulseShapeID, maxTS, soi, soiCapid,
549 darkCurrent, fcByPE, lambda,
550 hwerr.first, hwerr.second,
551 taggedBadByDb || dropByZS);
554 const bool makeThisRechit = !channelInfo->
isDropped();
559 if (rechits && makeThisRechit)
564 HBHERecHit rh =
reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
615 const unsigned nRead = info.
nSamples();
616 for (
unsigned i=0;
i<nRead; ++
i)
653 unsigned maxOutputSize = 0;
658 maxOutputSize += hbDigis->
size();
665 maxOutputSize += heDigis->
size();
669 std::unique_ptr<HBHEChannelInfoCollection>
infos;
672 infos = std::make_unique<HBHEChannelInfoCollection>();
673 infos->reserve(maxOutputSize);
676 std::unique_ptr<HBHERecHitCollection>
out;
679 out = std::make_unique<HBHERecHitCollection>();
680 out->reserve(maxOutputSize);
691 processData<HBHEDataFrame>(*hbDigis, *conditions, *
p, *mycomputer,
692 isData, &channelInfo, infos.get(), out.get());
703 processData<QIE11DataFrame>(*heDigis, *conditions, *
p, *mycomputer,
704 isData, &channelInfo, infos.get(), out.get());
724 if (
reco_->isConfigurable())
729 <<
"Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \"" 733 <<
"Failed to configure HBHEPhase1Algo algorithm from EventSetup" 750 "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
753 reco_->beginRun(r, es);
762 #define add_param_set(name) \ 763 edm::ParameterSetDescription name; \ 764 name.setAllowAnything(); \ 765 desc.add<edm::ParameterSetDescription>(#name, name) 776 desc.
add<
bool>(
"processQIE8");
777 desc.
add<
bool>(
"processQIE11");
778 desc.
add<
bool>(
"saveInfos");
779 desc.
add<
bool>(
"saveDroppedInfos");
780 desc.
add<
bool>(
"makeRecHits");
781 desc.
add<
bool>(
"dropZSmarkedPassed");
782 desc.
add<
bool>(
"tsFromDB");
783 desc.
add<
bool>(
"recoParamsFromDB");
784 desc.
add<
bool>(
"saveEffectivePedestal",
false);
785 desc.
add<
int>(
"sipmQTSShift", 0);
786 desc.
add<
int>(
"sipmQNTStoSum", 3);
787 desc.
add<
bool>(
"setNegativeFlagsQIE8");
788 desc.
add<
bool>(
"setNegativeFlagsQIE11");
789 desc.
add<
bool>(
"setNoiseFlagsQIE8");
790 desc.
add<
bool>(
"setNoiseFlagsQIE11");
791 desc.
add<
bool>(
"setPulseShapeFlagsQIE8");
792 desc.
add<
bool>(
"setPulseShapeFlagsQIE11");
793 desc.
add<
bool>(
"setLegacyFlagsQIE8");
794 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_
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)
virtual 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)
constexpr float UNKNOWN_T_UNDERSHOOT
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
std::unique_ptr< HcalRecoParams > paramTS_
void addDefault(ParameterSetDescription const &psetDescription)
constexpr float UNKNOWN_T_OVERSHOOT
static const unsigned MAXSAMPLES
bool setNegativeFlagsQIE11_
double pedestal(int fCapId) const
get pedestal width for capid=0..3
virtual 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)
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
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
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_
~HBHEPhase1Reconstructor()
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
virtual 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.