26 using namespace boost;
32 ttThresOnCompressedEt_(
false),
43 if(defTtf < 0 || defTtf > 7){
44 throw cms::Exception(
"InvalidParameter") <<
"Value of EcalSelectiveReadoutProducer module parameter defaultTtf, "
45 <<
defaultTtf_ <<
", is out of the valid range 0..7\n";
53 for(
int i = 0;
i < 4; ++
i){
59 bool actionValid =
actions_.size()==8;
65 throw cms::Exception(
"InvalidParameter") <<
"EcalSelectiveReadoutProducer module parameter 'actions' is "
66 "not valid. It must be a vector of 8 integer values comprised between 0 and 7\n";
88 = params.
getParameter<
bool>(
"trigPrimBypassWithPeakFinder");
92 edm::LogWarning(
"Digitization") <<
"Beware a simplified trigger primitive "
93 "computation is used for the ECAL selective readout";
94 if(trigPrimBypassMode_ !=0 && trigPrimBypassMode_ !=1){
96 <<
"Invalid value for EcalSelectiveReadoutProducer parameter 'trigPrimBypassMode_'."
97 " Valid values are 0 and 1.\n";
116 #ifndef ECALSELECTIVEREADOUT_NOGEOM
123 double endcapLowInterest,
124 double barrelHighInterest,
125 double endcapHighInterest){
128 int lowInterestThr[2];
130 int highInterestThr[2];
151 for(
int iSubDet = 0; iSubDet<2; ++iSubDet){
171 for(
size_t i = 0;
i < 8; ++
i){
197 double thr_ = thresholdInGeV /
thrUnit[iSubDet];
206 }
else if(thr_<=-0x7FF-.5){
223 bool gain12saturated =
false;
224 const int gain12 = 0x01;
229 iSample<lastFIRSample; ++iSample, ++iWeight){
230 if(iSample>=0 && iSample < (
int)frame.
size()){
232 if(sample.
gainId()!=gain12) gain12saturated =
true;
235 acc+=sample.
adc()*w[iWeight];
238 ": Not enough samples in data frame or 'ecalDccZs1stSample' module "
239 "parameter is not valid...";
244 if(acc<0) acc = -acc;
252 acc = ((acc + (1<<30)) >>8) - (1 <<(30-8));
258 const bool result = (acc >= thr) || gain12saturated;
278 run(eventSetup, trigPrims, barrelDigis, endcapDigis,
279 &selectedBarrelDigis, &selectedEndcapDigis, 0, 0);
282 barrelDigis.
swap(selectedBarrelDigis);
283 endcapDigis.
swap(selectedEndcapDigis);
300 setTtFlags(eventSetup, barrelDigis, endcapDigis);
305 if(selectedBarrelDigis){
306 selectedBarrelDigis->
reserve(barrelDigis.
size()/20);
310 digiItr != barrelDigis.
end(); ++digiItr){
314 selectedBarrelDigis->
push_back(digiItr->id(), digiItr->begin());
320 if(selectedEndcapDigis){
321 selectedEndcapDigis->
reserve(endcapDigis.
size()/20);
323 digiItr != endcapDigis.
end(); ++digiItr){
328 selectedEndcapDigis->
push_back(digiItr->id(), digiItr->begin());
334 if(selectedEndcapDigis)
LogDebug(
"EcalSelectiveReadout")
336 <<
"Number of EB digis passing the SR: "
337 << selectedBarrelDigis->
size()
338 <<
" / " << barrelDigis.
size() <<
"\n";
339 if(selectedEndcapDigis)
LogDebug(
"EcalSelectiveReadout")
341 <<
"\nNumber of EE digis passing the SR: "
342 << selectedEndcapDigis->
size()
343 <<
" / " << endcapDigis.
size() <<
"\n";
346 if(ebSrFlags) ebSrFlags->
reserve(34*72);
347 if(eeSrFlags) eeSrFlags->
reserve(624);
349 for(
int iZ = -1; iZ <=1; iZ+=2){
358 << __FILE__ <<
":" << __LINE__ <<
": " <<
"unknown SR flag. for "
359 <<
" TT " <<
id <<
". Most probably a bug.";
373 for(
int iX = 1; iX <= 20; ++iX){
374 for(
int iY = 1; iY <= 20; ++iY){
392 }
else if(iX < 9 || iX > 12 || iY < 9 || iY >12){
393 edm::LogError(
"EcalSelectiveReadout") << __FILE__ <<
":" << __LINE__ <<
": "
394 <<
"negative interest in EE for SC "
410 trigPrim != trigPrims.
end(); ++trigPrim){
411 int iEta = trigPrim->id().ieta();
414 iEta0 = iEta + nTriggerTowersInEta/2;
416 iEta0 = iEta + nTriggerTowersInEta/2 - 1;
419 unsigned int iPhi0 = trigPrim->id().iphi() - 1;
425 int compressedEt = trigPrim->compressedEt();
441 const static int maxWeight = 0xEFF;
442 for(
unsigned i=0;
i <
min((
size_t)nFIRTaps,
weights.size()); ++
i){
473 bzero(trigPrim,
sizeof(trigPrim));
476 it != ebDigis.
end(); ++it){
489 trigPrim[iTTEta0][iTTPhi0] += e*
sin(theta);
494 it != eeDigis.
end(); ++it){
507 trigPrim[iTTEta0][iTTPhi0] += e*
sin(theta);
512 int innerTTEtas[] = {0, 1, 54, 55};
513 for(
unsigned iRing = 0; iRing <
sizeof(innerTTEtas)/
sizeof(innerTTEtas[0]);
515 int iTTEta0 = innerTTEtas[iRing];
532 double et = .5*(trigPrim[iTTEta0][iTTPhi0]
533 +trigPrim[iTTEta0][iTTPhi0+1]);
537 trigPrim[iTTEta0][iTTPhi0] = et;
538 trigPrim[iTTEta0][iTTPhi0+1] = et;
564 double weights[] = {0., -1/3., -1/3., -1/3., 0., 1.};
573 cerr <<
"Severe error. "
574 << __FILE__ <<
":" << __LINE__ <<
": "
575 <<
"this is a bug. Please report it.\n";
580 const int n = min<int>(frame.size(),
sizeof(
weights)/
sizeof(weights[0]));
582 double gainInv[] = {12., 1., 6., 12.};
586 for(
int i=offset;
i <
n; ++
i){
588 if(iframe>=0 && iframe<frame.size()){
589 acc += weights[
i]*frame[iframe].adc()
590 *gainInv[frame[iframe].gainId()]*adc2GeV;
601 bool withHeader)
const{
602 const char tccFlagMarker[] = {
'?',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
607 os <<
"# TCC flag map\n#\n"
608 "# +-->Phi " << tccFlagMarker[1+0] <<
": 000 (low interest)\n"
609 "# | " << tccFlagMarker[1+1] <<
": 001 (mid interest)\n"
610 "# | " << tccFlagMarker[1+2] <<
": 010 (not valid)\n"
611 "# V Eta " << tccFlagMarker[1+3] <<
": 011 (high interest)\n"
612 "# " << tccFlagMarker[1+4] <<
": 1xx forced readout (Hw error)\n";
616 os <<
"#\n#Event " << iEvent <<
"\n";
619 for(
int iEta=0; iEta<nEta; ++iEta){
620 for(
int iPhi=0; iPhi<nPhi; ++iPhi){
621 os << tccFlagMarker[
ttFlags[iEta][iPhi]+1];
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< 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
int gainId() const
get the gainId (2 bits)
bool ttThresOnCompressedEt_
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
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
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
const T & max(const T &a, const T &b)
std::vector< int > ecalDccZs1stSample_
double trigPrimBypassLTH_
EcalSelectiveReadout::ttFlag_t defaultTtf_
std::vector< int > firWeights
unsigned int offset(bool)
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
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
void push_back(id_type iid, data_type const *idata)
std::vector< int > getFIRWeigths()
const_iterator end() const
unsigned ttId(const DetId &)
std::vector< float > srpLowInterestChannelZS_
std::vector< int > deltaEta_
bool accept(const edm::DataFrame &frame, int thr)
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