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();
496 const int nRead = cs.
size();
500 cond, cell, cs, soi, frame, maxTS);
504 for (
int ts = 0; ts <
maxTS; ++ts)
507 const uint8_t adc = s.
adc();
508 const int capid = s.
capid();
514 const double gainWidth = calibWidth.
gain(capid);
516 const double rawCharge = rcfs.getRawCharge(cs[ts], calib.
pedestal(capid));
517 const float t = getTDCTimeFromSample(s);
518 const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
520 channelInfo->
setSample(ts, adc, dfc, rawCharge,
521 pedestal, pedestalWidth,
529 const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
530 channelInfo->
setChannelInfo(cell, pulseShapeID, maxTS, soi, soiCapid,
531 darkCurrent, fcByPE, lambda,
532 hwerr.first, hwerr.second,
533 taggedBadByDb || dropByZS);
536 const bool makeThisRechit = !channelInfo->
isDropped();
541 if (rechits && makeThisRechit)
546 HBHERecHit rh =
reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
597 const unsigned nRead = info.
nSamples();
598 for (
unsigned i=0;
i<nRead; ++
i)
635 unsigned maxOutputSize = 0;
640 maxOutputSize += hbDigis->
size();
647 maxOutputSize += heDigis->
size();
651 std::unique_ptr<HBHEChannelInfoCollection>
infos;
654 infos = std::make_unique<HBHEChannelInfoCollection>();
655 infos->reserve(maxOutputSize);
658 std::unique_ptr<HBHERecHitCollection>
out;
661 out = std::make_unique<HBHERecHitCollection>();
662 out->reserve(maxOutputSize);
673 processData<HBHEDataFrame>(*hbDigis, *conditions, *
p, *mycomputer,
674 isData, &channelInfo, infos.get(), out.get());
685 processData<QIE11DataFrame>(*heDigis, *conditions, *
p, *mycomputer,
686 isData, &channelInfo, infos.get(), out.get());
706 if (
reco_->isConfigurable())
711 <<
"Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \"" 715 <<
"Failed to configure HBHEPhase1Algo algorithm from EventSetup" 732 "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
735 reco_->beginRun(r, es);
744 #define add_param_set(name) \ 745 edm::ParameterSetDescription name; \ 746 name.setAllowAnything(); \ 747 desc.add<edm::ParameterSetDescription>(#name, name) 758 desc.
add<
bool>(
"processQIE8");
759 desc.
add<
bool>(
"processQIE11");
760 desc.
add<
bool>(
"saveInfos");
761 desc.
add<
bool>(
"saveDroppedInfos");
762 desc.
add<
bool>(
"makeRecHits");
763 desc.
add<
bool>(
"dropZSmarkedPassed");
764 desc.
add<
bool>(
"tsFromDB");
765 desc.
add<
bool>(
"recoParamsFromDB");
766 desc.
add<
bool>(
"saveEffectivePedestal",
false);
767 desc.
add<
int>(
"sipmQTSShift", 0);
768 desc.
add<
int>(
"sipmQNTStoSum", 3);
769 desc.
add<
bool>(
"setNegativeFlagsQIE8");
770 desc.
add<
bool>(
"setNegativeFlagsQIE11");
771 desc.
add<
bool>(
"setNoiseFlagsQIE8");
772 desc.
add<
bool>(
"setNoiseFlagsQIE11");
773 desc.
add<
bool>(
"setPulseShapeFlagsQIE8");
774 desc.
add<
bool>(
"setPulseShapeFlagsQIE11");
775 desc.
add<
bool>(
"setLegacyFlagsQIE8");
776 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 effpedestal(int fCapId) const
get effective pedestal width for capid=0..3
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
double effpedestal(int fCapId) const
get effective pedestal for capid=0..3
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.