75 int zdcLUTIndexHelper(
int iDetPos,
int iBXPos);
93 std::unique_ptr<CaloParamsHelper>
params_;
99 etToken_ = produces<EtSumBxCollection>();
103 candidateToken_ = esConsumes<CaloParams, L1TCaloParamsRcd, edm::Transition::BeginRun>();
107 sampleToCenterBX_ = ps.
getParameter<
int>(
"sampleToCenterBX");
115 LogDebug(
"L1TZDCProducer") <<
"L1TZDCProducer::produce function called..." << std::endl;
122 iEvent.getByToken(zdcToken_, zdcDigiCollection);
125 if (zdcDigiCollection.
isValid()) {
131 int sampleToCenterBXChecked = sampleToCenterBX_;
133 if (sampleToCenterBXChecked < 0) {
134 edm::LogWarning(
"L1TZDCProducer") <<
"sampleToCenterBX LT 0; Set bx 0 to sample 0 (minimum allowed)" << std::endl;
135 sampleToCenterBXChecked = 0;
136 }
else if (sampleToCenterBXChecked >=
nSamples) {
138 <<
"sampleToCenterBX GE nsamples; Set bx 0 to sample nsamples-1 (maximum allowed)" << std::endl;
139 sampleToCenterBXChecked =
nSamples - 1;
143 unsigned short rawadc[18][10];
157 if (
section == 1 && (channel < 1 || channel > 5))
159 if (
section == 2 && (channel < 1 || channel > 4))
162 int ihitid = (
zside == 1 ? 9 : 0) + (
section == 2 ? 5 : 0) + (channel - 1);
164 for (
int iTS = 0; iTS <
nSamples; iTS++) {
165 unsigned short adc = (
unsigned short)
frame[iTS].
adc();
166 rawadc[ihitid][iTS] =
adc;
170 for (
int ibx = 0; ibx <
nSamples; ibx++) {
171 double cEMP = 0, cEMM = 0, cHDP = 0, cHDM = 0;
172 double sumcEMP = 0, sumcEMM = 0, sumcHDP = 0, sumcHDM = 0;
174 for (
int idet = 0; idet < 5; idet++) {
175 unsigned short EMP = rawadc[idet + 9][ibx];
176 unsigned short EMM = rawadc[idet][ibx];
178 int cEMP_LUTIndex = zdcLUTIndexHelper(idet + 9, (
int)EMP);
179 int cEMM_LUTIndex = zdcLUTIndexHelper(idet, (
int)EMM);
181 cEMP = ((double)params_->zdcLUT()->data(cEMP_LUTIndex)) / ((
double)scaleFactor_);
182 cEMM = ((double)params_->zdcLUT()->data(cEMM_LUTIndex)) / ((
double)scaleFactor_);
184 sumcEMP = sumcEMP + cEMP;
185 sumcEMM = sumcEMM + cEMM;
188 for (
int idet = 5; idet < 9; idet++) {
189 unsigned short HDP = rawadc[idet + 9][ibx];
190 unsigned short HDM = rawadc[idet][ibx];
192 int cHDP_LUTIndex = zdcLUTIndexHelper(idet + 9, (
int)HDP);
193 int cHDM_LUTIndex = zdcLUTIndexHelper(idet, (
int)HDM);
195 cHDP = ((double)params_->zdcLUT()->data(cHDP_LUTIndex)) / ((
double)scaleFactor_);
196 cHDM = ((double)params_->zdcLUT()->data(cHDM_LUTIndex)) / ((
double)scaleFactor_);
198 sumcHDP = sumcHDP + cHDP;
199 sumcHDM = sumcHDM + cHDM;
201 double sumM = sumcEMM + sumcHDM;
202 double sumP = sumcEMP + sumcHDP;
205 edm::LogInfo(
"L1TZDCProducer") <<
", sumM= " << sumM << std::endl;
206 edm::LogInfo(
"L1TZDCProducer") <<
", sumP= " << sumP << std::endl;
220 if (ibx >= sampleToCenterBXChecked + bxFirst_ && ibx <= sampleToCenterBXChecked + bxLast_) {
228 edm::LogWarning(
"L1TZDCProducer") <<
"zdcDigis not valid; return empty ZDC Et Sum BXCollection" << std::endl;
240 params_ = std::make_unique<CaloParamsHelper>(*candidateHandle.
product());
241 scaleFactor_ = params_->zdcLUT()->data(0);
242 edm::LogInfo(
"L1TZDCProducer") <<
"SCALE FACTOR FOR LUT: " << scaleFactor_ << std::endl;
252 desc.add<
int>(
"bxFirst", -2);
253 desc.add<
int>(
"bxLast", 2);
254 desc.add<
int>(
"sampleToCenterBX", 4);
255 descriptions.
add(
"l1tZDCProducer",
desc);
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &, const edm::EventSetup &) override
int zdcLUTIndexHelper(int iDetPos, int iBXPos)
void setType(EtSumType type)
edm::ESGetToken< CaloParams, L1TCaloParamsRcd > candidateToken_
edm::EDPutTokenT< EtSumBxCollection > etToken_
T const * product() const
L1TZDCProducer(const edm::ParameterSet &ps)
#define DEFINE_FWK_MODULE(type)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const_iterator end() const
Log< level::Info, false > LogInfo
std::unique_ptr< CaloParamsHelper > params_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const_iterator begin() const
The iterator returned can not safely be used across threads.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< QIE10DigiCollection > zdcToken_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
constexpr Section section() const
get the section
constexpr int32_t channel() const
get the channel
void beginRun(edm::Run const &, edm::EventSetup const &) override
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
Log< level::Warning, false > LogWarning
constexpr int samples() const
total number of samples in the digi
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void push_back(int bx, T object)