24 using namespace boost;
33 if (defTtf < 0 || defTtf > 7) {
34 throw cms::Exception(
"InvalidParameter") <<
"Value of EcalSelectiveReadoutProducer module parameter defaultTtf, "
35 <<
defaultTtf_ <<
", is out of the valid range 0..7\n";
46 edm::LogWarning(
"Digitization") <<
"Beware a simplified trigger primitive "
47 "computation is used for the ECAL selective readout";
48 if (trigPrimBypassMode_ != 0 && trigPrimBypassMode_ != 1) {
50 <<
"Invalid value for EcalSelectiveReadoutProducer parameter 'trigPrimBypassMode_'."
51 " Valid values are 0 and 1.\n";
66 for (
int i = 0;
i < 4; ++
i) {
71 bool actionValid =
actions_.size() == 8;
79 <<
"EcalSelectiveReadoutProducer module parameter 'actions' is "
80 "not valid. It must be a vector of 8 integer values comprised between 0 and 7\n";
107 #ifndef ECALSELECTIVEREADOUT_NOGEOM
113 double endcapLowInterest,
114 double barrelHighInterest,
115 double endcapHighInterest) {
118 int lowInterestThr[2];
120 int highInterestThr[2];
141 for (
int iSubDet = 0; iSubDet < 2; ++iSubDet) {
161 for (
size_t i = 0;
i < 8; ++
i) {
165 else if ((
actions_[
i] & ~FORCED_MASK) == 1)
167 else if ((
actions_[
i] & ~FORCED_MASK) == 2)
190 double thr_ = thresholdInGeV /
thrUnit[iSubDet];
197 if (thr_ >= 0x7FF + .5) {
199 }
else if (thr_ <= -0x7FF - .5) {
215 bool gain12saturated =
false;
216 const int gain12 = 0x01;
220 for (
int iSample =
firstFIRSample - 1; iSample < lastFIRSample; ++iSample, ++iWeight) {
221 if (iSample >= 0 && iSample < (
int)frame.
size()) {
223 if (sample.
gainId() != gain12)
224 gain12saturated =
true;
227 acc += sample.
adc() * w[iWeight];
230 <<
": Not enough samples in data frame or 'ecalDccZs1stSample' module "
231 "parameter is not valid...";
245 acc = ((acc + (1 << 30)) >> 8) - (1 << (30 - 8));
251 const bool result = (acc >= thr) || gain12saturated;
271 run(eventSetup, trigPrims, barrelDigis, endcapDigis, &selectedBarrelDigis, &selectedEndcapDigis,
nullptr,
nullptr);
274 barrelDigis.
swap(selectedBarrelDigis);
275 endcapDigis.
swap(selectedEndcapDigis);
290 setTtFlags(eventSetup, barrelDigis, endcapDigis);
295 if (selectedBarrelDigis) {
296 selectedBarrelDigis->
reserve(barrelDigis.
size() / 20);
303 selectedBarrelDigis->
push_back(digiItr->id(), digiItr->begin());
309 if (selectedEndcapDigis) {
310 selectedEndcapDigis->
reserve(endcapDigis.
size() / 20);
315 selectedEndcapDigis->
push_back(digiItr->id(), digiItr->begin());
321 int neb = (selectedBarrelDigis ? selectedBarrelDigis->
size() : 0);
322 if (selectedEndcapDigis)
325 <<
"Number of EB digis passing the SR: " << neb <<
" / " << barrelDigis.
size() <<
"\n";
326 if (selectedEndcapDigis)
329 <<
"\nNumber of EE digis passing the SR: " << selectedEndcapDigis->
size() <<
" / " << endcapDigis.
size()
338 for (
int iZ = -1; iZ <= 1; iZ += 2) {
345 throw cms::Exception(
"EcalSelectiveReadout") << __FILE__ <<
":" << __LINE__ <<
": "
346 <<
"unknown SR flag. for "
347 <<
" TT " <<
id <<
". Most probably a bug.";
362 for (
int iX = 1; iX <= 20; ++iX) {
363 for (
int iY = 1; iY <= 20; ++iY) {
380 }
else if (iX < 9 || iX > 12 || iY < 9 || iY > 12) {
381 edm::LogError(
"EcalSelectiveReadout") << __FILE__ <<
":" << __LINE__ <<
": "
382 <<
"negative interest in EE for SC " <<
id <<
"\n";
397 int iEta = trigPrim->id().ieta();
400 iEta0 = iEta + nTriggerTowersInEta / 2;
402 iEta0 = iEta + nTriggerTowersInEta / 2 - 1;
405 unsigned int iPhi0 = trigPrim->id().iphi() - 1;
410 int compressedEt = trigPrim->compressedEt();
425 const static int maxWeight = 0xEFF;
426 for (
unsigned i = 0;
i <
min((
size_t)nFIRTaps,
weights.size()); ++
i) {
453 bzero(trigPrim,
sizeof(trigPrim));
467 trigPrim[iTTEta0][iTTPhi0] += e *
sin(theta);
483 trigPrim[iTTEta0][iTTPhi0] += e *
sin(theta);
488 int innerTTEtas[] = {0, 1, 54, 55};
489 for (
unsigned iRing = 0; iRing <
sizeof(innerTTEtas) /
sizeof(innerTTEtas[0]); ++iRing) {
490 int iTTEta0 = innerTTEtas[iRing];
507 double et = .5 * (trigPrim[iTTEta0][iTTPhi0] + trigPrim[iTTEta0][iTTPhi0 + 1]);
511 trigPrim[iTTEta0][iTTPhi0] = et;
512 trigPrim[iTTEta0][iTTPhi0 + 1] = et;
537 double weights[] = {0., -1 / 3., -1 / 3., -1 / 3., 0., 1.};
546 cerr <<
"Severe error. " << __FILE__ <<
":" << __LINE__ <<
": "
547 <<
"this is a bug. Please report it.\n";
552 const int n = min<int>(frame.size(),
sizeof(
weights) /
sizeof(weights[0]));
554 double gainInv[] = {12., 1., 6., 12.};
557 for (
int i = offset;
i <
n; ++
i) {
559 if (iframe >= 0 && iframe < frame.size()) {
560 acc += weights[
i] * frame[iframe].adc() * gainInv[frame[iframe].gainId()] * adc2GeV;
571 const char tccFlagMarker[] = {
'?',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
576 os <<
"# TCC flag map\n#\n"
578 << tccFlagMarker[1 + 0]
579 <<
": 000 (low interest)\n"
581 << tccFlagMarker[1 + 1]
582 <<
": 001 (mid interest)\n"
584 << tccFlagMarker[1 + 2]
585 <<
": 010 (not valid)\n"
587 << tccFlagMarker[1 + 3]
588 <<
": 011 (high interest)\n"
590 << tccFlagMarker[1 + 4] <<
": 1xx forced readout (Hw error)\n";
594 os <<
"#\n#Event " << iEvent <<
"\n";
597 for (
int iEta = 0; iEta <
nEta; ++iEta) {
598 for (
int iPhi = 0; iPhi <
nPhi; ++iPhi) {
599 os << tccFlagMarker[
ttFlags[iEta][iPhi] + 1];
void push_back(const Digi &digi)
void setGeometry(const CaloGeometry *caloGeometry)
static bool validDetId(int ix, int iy, int iz)
void setSettings(const EcalSRSettings *settings)
void swap(EBDigiCollection &other)
EcalSelectiveReadoutSuppressor(const edm::ParameterSet ¶ms, edm::ConsumesCollector iC)
static const int FORCED_MASK
uint16_t *__restrict__ id
static const size_t nTriggerTowersInEta
void initCellThresholds(double barrelLowInterest, double endcapLowInterest, double barrelHighInterest, double endcapHighInterest)
helpers for constructors
void printTTFlags(std::ostream &os, int iEvent=-1, bool withHeader=true) const
bool trigPrimBypassWithPeakFinder_
Sin< T >::type sin(const T &t)
double frame2Energy(const T &frame, int timeOffset=0) const
double trigPrimBypassHTH_
std::vector< T >::const_iterator const_iterator
Geom::Theta< T > theta() const
void push_back(T const &t)
std::vector< std::vector< float > > dccNormalizedWeights_
const char tccFlagMarker[]
const_iterator begin() const
The iterator returned can not safely be used across threads.
Log< level::Error, false > LogError
int gainId() const
get the gainId (2 bits)
bool ttThresOnCompressedEt_
unsigned ttId(DetId const &, EcalElectronicsMapping const *)
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
int ieta() const
get the tower ieta
int iTTPhi2cIndex(int iPhi) const
std::vector< float > srpHighInterestChannelZS_
void setTriggerMap(const EcalTrigTowerConstituentsMap *map)
std::unique_ptr< EcalSelectiveReadout > ecalSelectiveReadout
EcalSelectiveReadout::ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]
bool getData(T &iHolder) const
std::vector< int > actions_
std::vector< float > weights
void run(const edm::EventSetup &eventSetup, const EcalTrigPrimDigiCollection &trigPrims, EBDigiCollection &barrelDigis, EEDigiCollection &endcapDigis)
int internalThreshold(double thresholdInGeV, int iSubDet) const
std::vector< int > ecalDccZs1stSample_
constexpr size_type size() const
double trigPrimBypassLTH_
Abs< T >::type abs(const T &t)
EcalSelectiveReadout::ttFlag_t defaultTtf_
std::vector< int > firWeights
static const size_t nBarrelTriggerTowersInEta
std::vector< int > deltaPhi_
const_iterator end() const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
void reserve(size_t isize)
int iphi() const
get the tower iphi
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< int > symetricZS_
T getParameter(std::string const &) const
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
int iTTEta2cIndex(int iEta) const
std::vector< int > getFIRWeigths()
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const_iterator end() const
std::vector< float > srpLowInterestChannelZS_
std::vector< int > deltaEta_
bool accept(const edm::DataFrame &frame, int thr)
void push_back(const Digi &digi)
static const int nFIRTaps
void setTtFlags(const edm::EventSetup &eventSetup, const EBDigiCollection &ebDigis, const EEDigiCollection &eeDigis)
void reserve(size_type n)
void setElecMap(const EcalElectronicsMapping *map)
const EcalTrigTowerConstituentsMap * theTriggerMap
float eeDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EE.
Log< level::Warning, false > LogWarning
void swap(EEDigiCollection &other)
const_iterator begin() const
int adc() const
get the ADC sample (12 bits)
std::vector< int > actions_
static const size_t nTriggerTowersInPhi