24 using namespace boost;
32 int defTtf =
params.getParameter<
int>(
"defaultTtf");
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";
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;
295 if (selectedBarrelDigis) {
303 selectedBarrelDigis->
push_back(digiItr->id(), digiItr->begin());
309 if (selectedEndcapDigis) {
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();
405 unsigned int iPhi0 = trigPrim->id().iphi() - 1;
410 int compressedEt = trigPrim->compressedEt();
425 const static int maxWeight = 0xEFF;
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";
554 double gainInv[] = {12., 1., 6., 12.};
559 if (iframe >= 0 && iframe <
frame.size()) {
571 const char tccFlagMarker[] = {
'?',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
576 os <<
"# TCC flag map\n#\n" 579 <<
": 000 (low interest)\n" 582 <<
": 001 (mid interest)\n" 585 <<
": 010 (not valid)\n" 588 <<
": 011 (high interest)\n" 590 <<
tccFlagMarker[1 + 4] <<
": 1xx forced readout (Hw error)\n";
594 os <<
"#\n#Event " <<
iEvent <<
"\n";
598 for (
int iPhi = 0; iPhi <
nPhi; ++iPhi) {
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)
EcalSelectiveReadoutSuppressor(const edm::ParameterSet ¶ms, edm::ConsumesCollector iC)
static const int FORCED_MASK
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
static const size_t nTriggerTowersInEta
void initCellThresholds(double barrelLowInterest, double endcapLowInterest, double barrelHighInterest, double endcapHighInterest)
helpers for constructors
bool trigPrimBypassWithPeakFinder_
Sin< T >::type sin(const T &t)
double trigPrimBypassHTH_
std::vector< T >::const_iterator const_iterator
void push_back(T const &t)
std::vector< std::vector< float > > dccNormalizedWeights_
const char tccFlagMarker[]
Log< level::Error, false > LogError
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)
std::vector< float > srpHighInterestChannelZS_
void setTriggerMap(const EcalTrigTowerConstituentsMap *map)
std::unique_ptr< EcalSelectiveReadout > ecalSelectiveReadout
EcalSelectiveReadout::ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]
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_
double trigPrimBypassLTH_
Abs< T >::type abs(const T &t)
EcalSelectiveReadout::ttFlag_t defaultTtf_
const_iterator begin() const
int iTTPhi2cIndex(int iPhi) const
std::vector< int > firWeights
static const size_t nBarrelTriggerTowersInEta
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 > deltaPhi_
const_iterator end() const
const_iterator end() const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
void reserve(size_t isize)
double frame2Energy(const T &frame, int timeOffset=0) const
std::vector< int > symetricZS_
const_iterator begin() const
The iterator returned can not safely be used across threads.
int iTTEta2cIndex(int iEta) const
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
std::vector< int > getFIRWeigths()
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
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 printTTFlags(std::ostream &os, int iEvent=-1, bool withHeader=true) const
Geom::Theta< T > theta() const
std::vector< int > actions_
static const size_t nTriggerTowersInPhi