73 template<
class DFrame>
74 class RawChargeFromSample
80 inline double getRawCharge(
const double decodedCharge,
82 {
return decodedCharge;}
91 : siPMParameter_(*cond.getHcalSiPMParameter(id)),
92 fcByPE_(siPMParameter_.getFCByPE()),
93 corr_(cond.getHcalSiPMCharacteristics()->getNonLinearities(siPMParameter_.getType()))
97 <<
"Invalid fC/PE conversion factor for SiPM " <<
id 101 inline double getRawCharge(
const double decodedCharge,
104 const double sipmQ = decodedCharge -
pedestal;
105 const double nPixelsFired = sipmQ/fcByPE_;
106 return sipmQ*corr_.getRecoCorrectionFactor(nPixelsFired) +
pedestal;
118 static const float qie11_tdc_to_ns = 0.5f;
122 static const int qie11_tdc_code_overshoot = 62;
123 static const int qie11_tdc_code_undershoot = 63;
125 const int tdc = s.
tdc();
126 float t = qie11_tdc_to_ns*tdc;
127 if (tdc == qie11_tdc_code_overshoot)
129 else if (tdc == qie11_tdc_code_undershoot)
139 float getDifferentialChargeGain(
const HcalQIECoder& coder,
142 const unsigned capid,
146 static const unsigned mantissaMaskQIE8 = 0x1f;
147 static const unsigned mantissaMaskQIE11 = 0x3f;
149 const float q = coder.
charge(shape, adc, capid);
150 const unsigned mantissaMask = isQIE11 ? mantissaMaskQIE11 : mantissaMaskQIE8;
151 const unsigned mantissa = adc & mantissaMask;
156 if (mantissa == 0
U || mantissa == mantissaMask - 1
U)
157 return coder.
charge(shape, adc+1
U, capid) -
q;
158 else if (mantissa == 1
U || mantissa == mantissaMask)
159 return q - coder.
charge(shape, adc-1
U, capid);
162 const float qup = coder.
charge(shape, adc+1
U, capid);
163 const float qdown = coder.
charge(shape, adc-1
U, capid);
164 const float upGain = qup -
q;
165 const float downGain = q - qdown;
166 const float averageGain = (qup - qdown)/2.
f;
167 if (
std::abs(upGain - downGain) < 0.01f*averageGain)
177 const float q2up = coder.
charge(shape, adc+2
U, capid);
178 const float q2down = coder.
charge(shape, adc-2
U, capid);
179 const float upGain2 = q2up - qup;
180 const float downGain2 = qdown - q2down;
194 bool linkErr =
false;
195 bool capidErr =
false;
198 int expectedCapid = df[0].capid();
199 for (
unsigned i=0;
i<len; ++
i)
203 if (df[
i].capid() != expectedCapid)
205 expectedCapid = (expectedCapid + 1) % 4;
208 return std::pair<bool,bool>(linkErr, capidErr);
217 std::unique_ptr<HBHEStatusBitSetter> parse_HBHEStatusBitSetter(
220 return std::make_unique<HBHEStatusBitSetter>(
224 psdigi.
getParameter<std::vector<edm::ParameterSet> >(
"pulseShapeParameterSets"));
227 std::unique_ptr<HBHEPulseShapeFlagSetter> parse_HBHEPulseShapeFlagSetter(
230 return std::make_unique<HBHEPulseShapeFlagSetter>(
231 psPulseShape.
getParameter<
double>(
"MinimumChargeThreshold"),
232 psPulseShape.
getParameter<
double>(
"TS4TS5ChargeThreshold"),
233 psPulseShape.
getParameter<
double>(
"TS3TS4ChargeThreshold"),
234 psPulseShape.
getParameter<
double>(
"TS3TS4UpperChargeThreshold"),
235 psPulseShape.
getParameter<
double>(
"TS5TS6ChargeThreshold"),
236 psPulseShape.
getParameter<
double>(
"TS5TS6UpperChargeThreshold"),
239 psPulseShape.
getParameter<
unsigned int>(
"TrianglePeakTS"),
240 psPulseShape.
getParameter<std::vector<double> >(
"LinearThreshold"),
241 psPulseShape.
getParameter<std::vector<double> >(
"LinearCut"),
242 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxThreshold"),
243 psPulseShape.
getParameter<std::vector<double> >(
"RMS8MaxCut"),
244 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeThreshold"),
245 psPulseShape.
getParameter<std::vector<double> >(
"LeftSlopeCut"),
246 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeThreshold"),
247 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeCut"),
248 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallThreshold"),
249 psPulseShape.
getParameter<std::vector<double> >(
"RightSlopeSmallCut"),
250 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerThreshold"),
251 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5LowerCut"),
252 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperThreshold"),
253 psPulseShape.
getParameter<std::vector<double> >(
"TS4TS5UpperCut"),
300 std::unique_ptr<AbsHBHEPhase1Algo>
reco_;
313 template<
class DataFrame,
class Collection>
314 void processData(
const Collection&
coll,
318 const bool isRealData,
340 : algoConfigClass_(conf.getParameter<
std::
string>(
"algoConfigClass")),
341 processQIE8_(conf.getParameter<bool>(
"processQIE8")),
342 processQIE11_(conf.getParameter<bool>(
"processQIE11")),
343 saveInfos_(conf.getParameter<bool>(
"saveInfos")),
344 saveDroppedInfos_(conf.getParameter<bool>(
"saveDroppedInfos")),
345 makeRecHits_(conf.getParameter<bool>(
"makeRecHits")),
346 dropZSmarkedPassed_(conf.getParameter<bool>(
"dropZSmarkedPassed")),
347 tsFromDB_(conf.getParameter<bool>(
"tsFromDB")),
348 recoParamsFromDB_(conf.getParameter<bool>(
"recoParamsFromDB")),
349 saveEffectivePedestal_(conf.getParameter<bool>(
"saveEffectivePedestal")),
350 setNegativeFlagsQIE8_(conf.getParameter<bool>(
"setNegativeFlagsQIE8")),
351 setNegativeFlagsQIE11_(conf.getParameter<bool>(
"setNegativeFlagsQIE11")),
352 setNoiseFlagsQIE8_(conf.getParameter<bool>(
"setNoiseFlagsQIE8")),
353 setNoiseFlagsQIE11_(conf.getParameter<bool>(
"setNoiseFlagsQIE11")),
354 setPulseShapeFlagsQIE8_(conf.getParameter<bool>(
"setPulseShapeFlagsQIE8")),
355 setPulseShapeFlagsQIE11_(conf.getParameter<bool>(
"setPulseShapeFlagsQIE11")),
362 <<
"Invalid HBHEPhase1Algo algorithm configuration" 386 tok_qie8_ = consumes<HBHEDigiCollection>(
394 produces<HBHEChannelInfoCollection>();
397 produces<HBHERecHitCollection>();
411 template<
class DFrame,
class Collection>
416 const bool isRealData,
428 for (
typename Collection::const_iterator it = coll.begin();
429 it != coll.end(); ++it)
431 const DFrame& frame(*it);
446 if (taggedBadByDb && skipDroppedChannels)
450 bool dropByZS =
false;
452 if (frame.zsMarkAndPass())
454 if (dropByZS && skipDroppedChannels)
464 const RawChargeFromSample<DFrame> rcfs(cond, cell);
469 const double fcByPE = siPMParameter.getFCByPE();
477 const int nRead = cs.
size();
483 for (
int ts = 0; ts <
maxTS; ++ts)
486 const uint8_t adc = s.
adc();
487 const int capid = s.
capid();
491 const double pedestalWidth = calibWidth.
pedestal(capid);
493 const double gainWidth = calibWidth.
gain(capid);
494 const double rawCharge = rcfs.getRawCharge(cs[ts], pedestal);
495 const float t = getTDCTimeFromSample(s);
496 const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
498 channelInfo->
setSample(ts, adc, dfc, rawCharge,
499 pedestal, pedestalWidth,
507 const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
508 channelInfo->
setChannelInfo(cell, pulseShapeID, maxTS, soi, soiCapid,
509 darkCurrent, fcByPE, lambda,
510 hwerr.first, hwerr.second,
511 taggedBadByDb || dropByZS);
514 const bool makeThisRechit = !channelInfo->
isDropped();
519 if (rechits && makeThisRechit)
524 HBHERecHit rh =
reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
575 const unsigned nRead = info.
nSamples();
576 for (
unsigned i=0;
i<nRead; ++
i)
613 unsigned maxOutputSize = 0;
618 maxOutputSize += hbDigis->
size();
625 maxOutputSize += heDigis->
size();
629 std::unique_ptr<HBHEChannelInfoCollection>
infos;
632 infos = std::make_unique<HBHEChannelInfoCollection>();
633 infos->reserve(maxOutputSize);
636 std::unique_ptr<HBHERecHitCollection>
out;
639 out = std::make_unique<HBHERecHitCollection>();
640 out->reserve(maxOutputSize);
651 processData<HBHEDataFrame>(*hbDigis, *conditions, *
p, *mycomputer,
652 isData, &channelInfo, infos.get(), out.get());
663 processData<QIE11DataFrame>(*heDigis, *conditions, *
p, *mycomputer,
664 isData, &channelInfo, infos.get(), out.get());
684 if (
reco_->isConfigurable())
689 <<
"Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \"" 693 <<
"Failed to configure HBHEPhase1Algo algorithm from EventSetup" 710 "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
713 reco_->beginRun(r, es);
722 #define add_param_set(name) \ 723 edm::ParameterSetDescription name; \ 724 name.setAllowAnything(); \ 725 desc.add<edm::ParameterSetDescription>(#name, name) 736 desc.
add<
bool>(
"processQIE8");
737 desc.
add<
bool>(
"processQIE11");
738 desc.
add<
bool>(
"saveInfos");
739 desc.
add<
bool>(
"saveDroppedInfos");
740 desc.
add<
bool>(
"makeRecHits");
741 desc.
add<
bool>(
"dropZSmarkedPassed");
742 desc.
add<
bool>(
"tsFromDB");
743 desc.
add<
bool>(
"recoParamsFromDB");
744 desc.
add<
bool>(
"saveEffectivePedestal",
false);
745 desc.
add<
bool>(
"setNegativeFlagsQIE8");
746 desc.
add<
bool>(
"setNegativeFlagsQIE11");
747 desc.
add<
bool>(
"setNoiseFlagsQIE8");
748 desc.
add<
bool>(
"setNoiseFlagsQIE11");
749 desc.
add<
bool>(
"setPulseShapeFlagsQIE8");
750 desc.
add<
bool>(
"setPulseShapeFlagsQIE11");
751 desc.
add<
bool>(
"setLegacyFlagsQIE8");
752 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.