25 using namespace boost;
31 ttThresOnCompressedEt_(
false),
42 if(defTtf < 0 || defTtf > 7){
43 throw cms::Exception(
"InvalidParameter") <<
"Value of EcalSelectiveReadoutProducer module parameter defaultTtf, " 44 <<
defaultTtf_ <<
", is out of the valid range 0..7\n";
52 for(
int i = 0;
i < 4; ++
i){
58 bool actionValid =
actions_.size()==8;
64 throw cms::Exception(
"InvalidParameter") <<
"EcalSelectiveReadoutProducer module parameter 'actions' is " 65 "not valid. It must be a vector of 8 integer values comprised between 0 and 7\n";
87 = params.
getParameter<
bool>(
"trigPrimBypassWithPeakFinder");
91 edm::LogWarning(
"Digitization") <<
"Beware a simplified trigger primitive " 92 "computation is used for the ECAL selective readout";
93 if(trigPrimBypassMode_ !=0 && trigPrimBypassMode_ !=1){
95 <<
"Invalid value for EcalSelectiveReadoutProducer parameter 'trigPrimBypassMode_'." 96 " Valid values are 0 and 1.\n";
115 #ifndef ECALSELECTIVEREADOUT_NOGEOM 122 double endcapLowInterest,
123 double barrelHighInterest,
124 double endcapHighInterest){
127 int lowInterestThr[2];
129 int highInterestThr[2];
150 for(
int iSubDet = 0; iSubDet<2; ++iSubDet){
170 for(
size_t i = 0;
i < 8; ++
i){
196 double thr_ = thresholdInGeV /
thrUnit[iSubDet];
205 }
else if(thr_<=-0x7FF-.5){
222 bool gain12saturated =
false;
223 const int gain12 = 0x01;
228 iSample<lastFIRSample; ++iSample, ++iWeight){
229 if(iSample>=0 && iSample < (
int)frame.
size()){
231 if(sample.
gainId()!=gain12) gain12saturated =
true;
234 acc+=sample.
adc()*w[iWeight];
237 ": Not enough samples in data frame or 'ecalDccZs1stSample' module " 238 "parameter is not valid...";
243 if(acc<0) acc = -acc;
251 acc = ((acc + (1<<30)) >>8) - (1 <<(30-8));
257 const bool result = (acc >= thr) || gain12saturated;
277 run(eventSetup, trigPrims, barrelDigis, endcapDigis,
278 &selectedBarrelDigis, &selectedEndcapDigis,
nullptr,
nullptr);
281 barrelDigis.
swap(selectedBarrelDigis);
282 endcapDigis.
swap(selectedEndcapDigis);
299 setTtFlags(eventSetup, barrelDigis, endcapDigis);
304 if(selectedBarrelDigis){
305 selectedBarrelDigis->
reserve(barrelDigis.
size()/20);
309 digiItr != barrelDigis.
end(); ++digiItr){
313 selectedBarrelDigis->
push_back(digiItr->id(), digiItr->begin());
319 if(selectedEndcapDigis){
320 selectedEndcapDigis->
reserve(endcapDigis.
size()/20);
322 digiItr != endcapDigis.
end(); ++digiItr){
327 selectedEndcapDigis->
push_back(digiItr->id(), digiItr->begin());
333 int neb = (selectedBarrelDigis?selectedBarrelDigis->
size():0);
334 if(selectedEndcapDigis)
LogDebug(
"EcalSelectiveReadout")
336 <<
"Number of EB digis passing the SR: " << neb
337 <<
" / " << barrelDigis.
size() <<
"\n";
338 if(selectedEndcapDigis)
LogDebug(
"EcalSelectiveReadout")
340 <<
"\nNumber of EE digis passing the SR: " 341 << selectedEndcapDigis->
size()
342 <<
" / " << endcapDigis.
size() <<
"\n";
345 if(ebSrFlags) ebSrFlags->
reserve(34*72);
346 if(eeSrFlags) eeSrFlags->
reserve(624);
348 for(
int iZ = -1; iZ <=1; iZ+=2){
357 << __FILE__ <<
":" << __LINE__ <<
": " <<
"unknown SR flag. for " 358 <<
" TT " <<
id <<
". Most probably a bug.";
372 for(
int iX = 1; iX <= 20; ++iX){
373 for(
int iY = 1; iY <= 20; ++iY){
391 }
else if(iX < 9 || iX > 12 || iY < 9 || iY >12){
392 edm::LogError(
"EcalSelectiveReadout") << __FILE__ <<
":" << __LINE__ <<
": " 393 <<
"negative interest in EE for SC " 409 trigPrim != trigPrims.
end(); ++trigPrim){
410 int iEta = trigPrim->id().ieta();
413 iEta0 = iEta + nTriggerTowersInEta/2;
415 iEta0 = iEta + nTriggerTowersInEta/2 - 1;
418 unsigned int iPhi0 = trigPrim->id().iphi() - 1;
424 int compressedEt = trigPrim->compressedEt();
440 const static int maxWeight = 0xEFF;
441 for(
unsigned i=0;
i <
min((
size_t)nFIRTaps,
weights.size()); ++
i){
472 bzero(trigPrim,
sizeof(trigPrim));
475 it != ebDigis.
end(); ++it){
488 trigPrim[iTTEta0][iTTPhi0] += e*
sin(theta);
493 it != eeDigis.
end(); ++it){
506 trigPrim[iTTEta0][iTTPhi0] += e*
sin(theta);
511 int innerTTEtas[] = {0, 1, 54, 55};
512 for(
unsigned iRing = 0; iRing <
sizeof(innerTTEtas)/
sizeof(innerTTEtas[0]);
514 int iTTEta0 = innerTTEtas[iRing];
531 double et = .5*(trigPrim[iTTEta0][iTTPhi0]
532 +trigPrim[iTTEta0][iTTPhi0+1]);
536 trigPrim[iTTEta0][iTTPhi0] =
et;
537 trigPrim[iTTEta0][iTTPhi0+1] =
et;
563 double weights[] = {0., -1/3., -1/3., -1/3., 0., 1.};
572 cerr <<
"Severe error. " 573 << __FILE__ <<
":" << __LINE__ <<
": " 574 <<
"this is a bug. Please report it.\n";
579 const int n = min<int>(frame.size(),
sizeof(
weights)/
sizeof(weights[0]));
581 double gainInv[] = {12., 1., 6., 12.};
585 for(
int i=offset;
i <
n; ++
i){
587 if(iframe>=0 && iframe<frame.size()){
588 acc += weights[
i]*frame[iframe].adc()
589 *gainInv[frame[iframe].gainId()]*adc2GeV;
600 bool withHeader)
const{
601 const char tccFlagMarker[] = {
'?',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
606 os <<
"# TCC flag map\n#\n" 607 "# +-->Phi " << tccFlagMarker[1+0] <<
": 000 (low interest)\n" 608 "# | " << tccFlagMarker[1+1] <<
": 001 (mid interest)\n" 609 "# | " << tccFlagMarker[1+2] <<
": 010 (not valid)\n" 610 "# V Eta " << tccFlagMarker[1+3] <<
": 011 (high interest)\n" 611 "# " << tccFlagMarker[1+4] <<
": 1xx forced readout (Hw error)\n";
615 os <<
"#\n#Event " << iEvent <<
"\n";
618 for(
int iEta=0; iEta<
nEta; ++iEta){
619 for(
int iPhi=0; iPhi<
nPhi; ++iPhi){
620 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)
T getParameter(std::string const &) const
void swap(EBDigiCollection &other)
static const int FORCED_MASK
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalSelectiveReadoutSuppressor(const edm::ParameterSet ¶ms, const EcalSRSettings *settings)
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_
std::auto_ptr< EcalSelectiveReadout > ecalSelectiveReadout
Sin< T >::type sin(const T &t)
double frame2Energy(const T &frame, int timeOffset=0) const
double trigPrimBypassHTH_
std::vector< EcalTriggerPrimitiveDigi >::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
int gainId() const
get the gainId (2 bits)
bool ttThresOnCompressedEt_
unsigned ttId(DetId 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)
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_
std::vector< int > firWeights
static const size_t nBarrelTriggerTowersInEta
std::vector< int > deltaPhi_
const_iterator end() const
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_
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
et
define resolution functions of each parameter
std::vector< int > getFIRWeigths()
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.
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