CMS 3D CMS Logo

SelectiveReadoutTask.cc
Go to the documentation of this file.
2 
5 
8 
10 
14 
15 namespace ecaldqm {
16 
18  : DQWorkerTask(),
19  useCondDb_(false),
20  iFirstSample_(0),
21  ZSFIRWeights_(nFIRTaps, 0.),
22  suppressed_(),
23  flags_(nRU, -1) {}
24 
26  useCondDb_ = _params.getUntrackedParameter<bool>("useCondDb");
27  iFirstSample_ = _params.getUntrackedParameter<int>("DCCZS1stSample");
28 
29  if (!useCondDb_) {
30  std::vector<double> normWeights(_params.getUntrackedParameter<std::vector<double> >("ZSFIRWeights"));
31  setFIRWeights_(normWeights);
32  }
33  }
34 
37  }
38 
42  }
43 
45  using namespace std;
46 
47  if (useCondDb_) {
48  auto const& vSr = &_es.getData(hSr);
49  vector<vector<float> > weights(vSr->dccNormalizedWeights_);
50  if (weights.size() == 1) {
51  vector<double> normWeights;
52  for (vector<float>::iterator it(weights[0].begin()); it != weights[0].end(); it++)
53  normWeights.push_back(*it);
54 
55  setFIRWeights_(normWeights);
56  } else
57  edm::LogWarning("EcalDQM") << "SelectiveReadoutTask: DCC weight set is not exactly 1.";
58  }
59  }
60 
61  void SelectiveReadoutTask::beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) {
62  flags_.assign(nRU, -1);
63  suppressed_.clear();
64  }
65 
67  MESet& meDCCSize(MEs_.at("DCCSize"));
68  MESet& meDCCSizeProf(MEs_.at("DCCSizeProf"));
69  MESet& meEventSize(MEs_.at("EventSize"));
70 
71  float ebSize(0.), eemSize(0.), eepSize(0.);
72 
73  // DCC event size
74  for (int iFED(601); iFED <= 654; iFED++) {
75  float size(_fedRaw.FEDData(iFED).size() / 1024.);
76  meDCCSize.fill(getEcalDQMSetupObjects(), iFED - 600, size);
77  meDCCSizeProf.fill(getEcalDQMSetupObjects(), iFED - 600, size);
78  if (iFED - 601 <= kEEmHigh)
79  eemSize += size;
80  else if (iFED - 601 >= kEEpLow)
81  eepSize += size;
82  else
83  ebSize += size;
84  }
85 
86  meEventSize.fill(getEcalDQMSetupObjects(), -EcalEndcap, eemSize / 9.);
87  meEventSize.fill(getEcalDQMSetupObjects(), EcalEndcap, eepSize / 9.);
88  meEventSize.fill(getEcalDQMSetupObjects(), EcalBarrel, ebSize / 36.);
89  }
90 
92  for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr) {
93  std::vector<short> const& feStatus(dcchItr->getFEStatus());
94  unsigned nFE(feStatus.size());
95  for (unsigned iFE(0); iFE < nFE; ++iFE)
96  if (feStatus[iFE] == Disabled)
97  suppressed_.insert(std::make_pair(dcchItr->id(), iFE + 1));
98  }
99  }
100 
101  template <typename SRFlagCollection>
102  void SelectiveReadoutTask::runOnSrFlags(SRFlagCollection const& _srfs, Collections _col) {
103  MESet& meFlagCounterMap(MEs_.at("FlagCounterMap"));
104  MESet& meFullReadoutMap(MEs_.at("FullReadoutMap"));
105  MESet& meZS1Map(MEs_.at("ZS1Map"));
106  MESet& meZSMap(MEs_.at("ZSMap"));
107  MESet& meRUForcedMap(MEs_.at("RUForcedMap"));
108 
109  double nFR(0.);
110 
111  std::for_each(_srfs.begin(), _srfs.end(), [&](typename SRFlagCollection::value_type const& srf) {
112  DetId const& id(srf.id());
113  int flag(srf.value());
114 
115  meFlagCounterMap.fill(getEcalDQMSetupObjects(), id);
116 
117  unsigned iRU(-1);
118  if (id.subdetId() == EcalTriggerTower)
119  iRU = EcalTrigTowerDetId(id).hashedIndex();
120  else
122  flags_[iRU] = flag;
123 
124  switch (flag & ~EcalSrFlag::SRF_FORCED_MASK) {
126  meFullReadoutMap.fill(getEcalDQMSetupObjects(), id);
127  nFR += 1.;
128  break;
129  case EcalSrFlag::SRF_ZS1:
130  meZS1Map.fill(getEcalDQMSetupObjects(), id);
131  // fallthrough
132  case EcalSrFlag::SRF_ZS2:
133  meZSMap.fill(getEcalDQMSetupObjects(), id);
134  break;
135  default:
136  break;
137  }
138 
140  meRUForcedMap.fill(getEcalDQMSetupObjects(), id);
141  });
142 
143  MEs_.at("FullReadout").fill(getEcalDQMSetupObjects(), _col == kEBSrFlag ? EcalBarrel : EcalEndcap, nFR);
144  }
145 
146  template <typename DigiCollection>
148  MESet& meHighIntOutput(MEs_.at("HighIntOutput"));
149  MESet& meLowIntOutput(MEs_.at("LowIntOutput"));
150  MESet& meHighIntPayload(MEs_.at("HighIntPayload"));
151  MESet& meLowIntPayload(MEs_.at("LowIntPayload"));
152  MESet& meTowerSize(MEs_.at("TowerSize"));
153  MESet& meZSFullReadoutMap(MEs_.at("ZSFullReadoutMap"));
154  MESet& meFRDroppedMap(MEs_.at("FRDroppedMap"));
155  MESet& meZSFullReadout(MEs_.at("ZSFullReadout"));
156  MESet& meFRDropped(MEs_.at("FRDropped"));
157 
158  bool isEB(_collection == kEBDigi);
159 
160  unsigned const nTower(isEB ? unsigned(EcalTrigTowerDetId::kEBTotalTowers)
162 
163  std::vector<unsigned> sizes(nTower, 0);
164 
165  int nHighInt[] = {0, 0};
166  int nLowInt[] = {0, 0};
167 
168  for (typename DigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr) {
169  DetId const& id(digiItr->id());
170 
171  unsigned iTower(-1);
172  unsigned iRU(-1);
173 
174  if (isEB) {
175  iTower = EBDetId(id).tower().hashedIndex();
176  iRU = iTower;
177  } else {
178  iTower = EEDetId(id).sc().hashedIndex();
179  iRU = iTower + EcalTrigTowerDetId::kEBTotalTowers;
180  }
181 
182  if (flags_[iRU] < 0)
183  continue;
184 
185  sizes[iTower] += 1;
186 
187  // SR filter output calculation
188 
189  EcalDataFrame frame(*digiItr);
190 
191  int ZSFIRValue(0); // output
192 
193  bool gain12saturated(false);
194  const int gain12(0x01);
195 
196  for (int iWeight(0); iWeight < nFIRTaps; ++iWeight) {
197  int iSample(iFirstSample_ + iWeight - 1);
198 
199  if (iSample >= 0 && iSample < frame.size()) {
200  EcalMGPASample sample(frame[iSample]);
201  if (sample.gainId() != gain12) {
202  gain12saturated = true;
203  break;
204  }
205  ZSFIRValue += sample.adc() * ZSFIRWeights_[iWeight];
206  } else {
207  edm::LogWarning("EcalDQM") << "SelectiveReadoutTask: Not enough samples in data frame or "
208  "'ecalDccZs1stSample' module parameter is not valid";
209  }
210  }
211 
212  if (gain12saturated)
213  ZSFIRValue = std::numeric_limits<int>::max();
214  else
215  ZSFIRValue /= (0x1 << 8); //discards the 8 LSBs
216 
217  //ZS passed if weighted sum above ZS threshold or if
218  //one sample has a lower gain than gain 12 (that is gain 12 output
219  //is saturated)
220 
221  bool highInterest((flags_[iRU] & ~EcalSrFlag::SRF_FORCED_MASK) == EcalSrFlag::SRF_FULL);
222 
223  if (highInterest) {
224  meHighIntOutput.fill(getEcalDQMSetupObjects(), id, ZSFIRValue);
225  if (isEB || dccId(id, GetElectronicsMap()) - 1 <= kEEmHigh)
226  nHighInt[0] += 1;
227  else
228  nHighInt[1] += 1;
229  } else {
230  meLowIntOutput.fill(getEcalDQMSetupObjects(), id, ZSFIRValue);
231  if (isEB || dccId(id, GetElectronicsMap()) - 1 <= kEEmHigh)
232  nLowInt[0] += 1;
233  else
234  nLowInt[1] += 1;
235  }
236  }
237 
238  if (isEB) {
239  meHighIntPayload.fill(getEcalDQMSetupObjects(), EcalBarrel, nHighInt[0] * bytesPerCrystal / 1024. / nEBDCC);
240  meLowIntPayload.fill(getEcalDQMSetupObjects(), EcalBarrel, nLowInt[0] * bytesPerCrystal / 1024. / nEBDCC);
241  } else {
242  meHighIntPayload.fill(
243  getEcalDQMSetupObjects(), -EcalEndcap, nHighInt[0] * bytesPerCrystal / 1024. / (nEEDCC / 2));
244  meHighIntPayload.fill(getEcalDQMSetupObjects(), EcalEndcap, nHighInt[1] * bytesPerCrystal / 1024. / (nEEDCC / 2));
245  meLowIntPayload.fill(getEcalDQMSetupObjects(), -EcalEndcap, nLowInt[0] * bytesPerCrystal / 1024. / (nEEDCC / 2));
246  meLowIntPayload.fill(getEcalDQMSetupObjects(), EcalEndcap, nLowInt[1] * bytesPerCrystal / 1024. / (nEEDCC / 2));
247  }
248 
249  unsigned iRU(isEB ? 0 : EcalTrigTowerDetId::kEBTotalTowers);
250  for (unsigned iTower(0); iTower < nTower; ++iTower, ++iRU) {
251  DetId id;
252  if (isEB)
254  else
255  id = EcalScDetId::unhashIndex(iTower);
256 
257  double towerSize(sizes[iTower] * bytesPerCrystal);
258 
259  meTowerSize.fill(getEcalDQMSetupObjects(), id, towerSize);
260 
261  if (flags_[iRU] < 0)
262  continue;
263 
264  int dccid(dccId(id, GetElectronicsMap()));
265  int towerid(towerId(id, GetElectronicsMap()));
266 
267  if (suppressed_.find(std::make_pair(dccid, towerid)) != suppressed_.end())
268  continue;
269 
271 
272  bool ruFullyReadout(sizes[iTower] == GetElectronicsMap()->dccTowerConstituents(dccid, towerid).size());
273 
274  if (ruFullyReadout && (flag == EcalSrFlag::SRF_ZS1 || flag == EcalSrFlag::SRF_ZS2)) {
275  meZSFullReadoutMap.fill(getEcalDQMSetupObjects(), id);
276  meZSFullReadout.fill(getEcalDQMSetupObjects(), id);
277  }
278 
279  if (sizes[iTower] == 0 && flag == EcalSrFlag::SRF_FULL) {
280  meFRDroppedMap.fill(getEcalDQMSetupObjects(), id);
281  meFRDropped.fill(getEcalDQMSetupObjects(), id);
282  }
283  }
284  }
285 
286  void SelectiveReadoutTask::setFIRWeights_(std::vector<double> const& _normWeights) {
287  if (_normWeights.size() < nFIRTaps)
288  throw cms::Exception("InvalidConfiguration") << "weightsForZsFIR" << std::endl;
289 
290  bool notNormalized(false), notInt(false);
291  for (std::vector<double>::const_iterator it(_normWeights.begin()); it != _normWeights.end(); ++it) {
292  if (*it > 1.)
293  notNormalized = true;
294  if (int(*it) != *it)
295  notInt = true;
296  }
297  if (notInt && notNormalized) {
298  throw cms::Exception("InvalidConfiguration") << "weigtsForZsFIR paramater values are not valid: they "
299  << "must either be integer and uses the hardware representation "
300  << "of the weights or less or equal than 1 and used the normalized "
301  << "representation.";
302  }
303 
304  ZSFIRWeights_.clear();
305  ZSFIRWeights_.resize(_normWeights.size());
306 
307  if (notNormalized) {
308  for (unsigned i(0); i < ZSFIRWeights_.size(); ++i)
309  ZSFIRWeights_[i] = int(_normWeights[i]);
310  } else {
311  const int maxWeight(0xEFF); //weights coded on 11+1 signed bits
312  for (unsigned i(0); i < ZSFIRWeights_.size(); ++i) {
313  ZSFIRWeights_[i] = lround(_normWeights[i] * (0x1 << 10));
314  if (std::abs(ZSFIRWeights_[i]) > maxWeight) //overflow
315  ZSFIRWeights_[i] = ZSFIRWeights_[i] < 0 ? -maxWeight : maxWeight;
316  }
317  }
318  }
319 
321 } // namespace ecaldqm
ecaldqm::SelectiveReadoutTask::bytesPerCrystal
Definition: SelectiveReadoutTask.h:42
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
ecaldqm
Definition: DQWorker.h:37
ecaldqm::SelectiveReadoutTask
Definition: SelectiveReadoutTask.h:20
ESHandle.h
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
ecaldqm::DependencySet
Definition: DQWorkerTask.h:44
edm::Run
Definition: Run.h:45
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
EBDetId
Definition: EBDetId.h:17
ecaldqm::SelectiveReadoutTask::addDependencies
void addDependencies(DependencySet &) override
Definition: SelectiveReadoutTask.cc:39
ecaldqm::kEEDigi
Definition: Collections.h:26
ecaldqm::MESet::fill
virtual void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:74
ecaldqm::SelectiveReadoutTask::ZSFIRWeights_
std::vector< int > ZSFIRWeights_
Definition: SelectiveReadoutTask.h:53
EcalDetIdCollections.h
EcalScDetId::unhashIndex
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:117
l1extraParticles_cfi._params
_params
Definition: l1extraParticles_cfi.py:29
ecaldqm::nEBDCC
Definition: EcalDQMCommonUtils.h:92
ecaldqm::kEESrFlag
Definition: Collections.h:24
edm::SortedCollection
Definition: SortedCollection.h:49
ecaldqm::Dependency
Definition: DQWorkerTask.h:19
EcalTrigTowerDetId::kEBTotalTowers
Definition: EcalTrigTowerDetId.h:116
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
ecaldqm::kEcalRawData
Definition: Collections.h:10
ecaldqm::SelectiveReadoutTask::SelectiveReadoutTask
SelectiveReadoutTask()
Definition: SelectiveReadoutTask.cc:17
EcalDataFrame
Definition: EcalDataFrame.h:16
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
ecaldqm::DQWorker::GetElectronicsMap
const EcalElectronicsMapping * GetElectronicsMap()
Definition: DQWorker.cc:118
ecaldqm::SelectiveReadoutTask::runOnDigis
void runOnDigis(DigiCollection const &, Collections)
Definition: SelectiveReadoutTask.cc:147
EcalBarrel
Definition: EcalSubdetector.h:10
FEFlags.h
ecaldqm::towerId
unsigned towerId(DetId const &, EcalElectronicsMapping const *)
Definition: EcalDQMCommonUtils.cc:77
DetId
Definition: DetId.h:17
ecaldqm::SelectiveReadoutTask::hSr
edm::ESGetToken< EcalSRSettings, EcalSRSettingsRcd > hSr
Definition: SelectiveReadoutTask.h:57
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
EcalSrFlag::SRF_ZS1
static const int SRF_ZS1
Definition: EcalSrFlag.h:18
EBDetId::tower
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
ecaldqm::DQWorkerTask
Definition: DQWorkerTask.h:71
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99207
EcalSrFlag::SRF_ZS2
static const int SRF_ZS2
Definition: EcalSrFlag.h:21
EcalScDetId
Definition: EcalScDetId.h:24
ecaldqm::SelectiveReadoutTask::nFIRTaps
Definition: SelectiveReadoutTask.h:41
ecaldqm::kEEmHigh
Definition: EcalDQMCommonUtils.h:81
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
ecaldqm::nEEDCC
Definition: EcalDQMCommonUtils.h:93
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:125
ecaldqm::Disabled
Definition: FEFlags.h:10
EEDetId
Definition: EEDetId.h:14
ecaldqm::SelectiveReadoutTask::nRU
Definition: SelectiveReadoutTask.h:43
EcalEndcap
Definition: EcalSubdetector.h:10
ecaldqm::SelectiveReadoutTask::suppressed_
std::set< std::pair< int, int > > suppressed_
Definition: SelectiveReadoutTask.h:55
EcalScDetId::hashedIndex
int hashedIndex() const
Definition: EcalScDetId.h:106
ecaldqm::SelectiveReadoutTask::runOnSrFlags
void runOnSrFlags(SRFlagCollection const &, Collections)
Definition: SelectiveReadoutTask.cc:102
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ecaldqm::SelectiveReadoutTask::setFIRWeights_
void setFIRWeights_(std::vector< double > const &)
Definition: SelectiveReadoutTask.cc:286
ecaldqm::MESetCollection::at
MESet & at(const std::string &key)
Definition: MESet.h:399
SelectiveReadoutTask.h
ecaldqm::kEBSrFlag
Definition: Collections.h:23
ecaldqm::DependencySet::push_back
void push_back(Dependency const &_d)
Definition: DQWorkerTask.h:46
EcalTrigTowerDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
Definition: EcalTrigTowerDetId.cc:93
ecaldqm::Collections
Collections
Definition: Collections.h:8
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
ecaldqm::SelectiveReadoutTask::runOnRawData
void runOnRawData(EcalRawDataCollection const &)
Definition: SelectiveReadoutTask.cc:91
EEDetId::sc
EcalScDetId sc() const
Definition: EEDetId.h:89
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
ecaldqm::SelectiveReadoutTask::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: SelectiveReadoutTask.cc:44
ecaldqm::SelectiveReadoutTask::runOnSource
void runOnSource(FEDRawDataCollection const &)
Definition: SelectiveReadoutTask.cc:66
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
EcalMGPASample
Definition: EcalMGPASample.h:22
ecaldqm::dccId
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
Definition: EcalDQMCommonUtils.cc:16
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
ecaldqm::DQWorker::getEcalDQMSetupObjects
const EcalDQMSetupObjects getEcalDQMSetupObjects()
Definition: DQWorker.cc:142
siStripShotFilter_cfi.DigiCollection
DigiCollection
Definition: siStripShotFilter_cfi.py:6
EcalTrigTowerConstituentsMap.h
ecaldqm::SelectiveReadoutTask::beginEvent
void beginEvent(edm::Event const &, edm::EventSetup const &, bool const &, bool &) override
Definition: SelectiveReadoutTask.cc:61
std
Definition: JetResolutionObject.h:76
EcalTriggerTower
Definition: EcalSubdetector.h:10
ecaldqm::kEBDigi
Definition: Collections.h:25
EcalSrFlag::SRF_FULL
static const int SRF_FULL
Definition: EcalSrFlag.h:24
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
edm::Transition::BeginRun
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
ecaldqm::kEEpLow
Definition: EcalDQMCommonUtils.h:82
Exception
Definition: hltDiff.cc:245
ecaldqm::SelectiveReadoutTask::useCondDb_
bool useCondDb_
Definition: SelectiveReadoutTask.h:51
EcalTrigTowerDetId::detIdFromDenseIndex
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
Definition: EcalTrigTowerDetId.cc:104
ecaldqm::SelectiveReadoutTask::setTokens
void setTokens(edm::ConsumesCollector &) override
Definition: SelectiveReadoutTask.cc:35
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:162
ConsumesCollector.h
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ecaldqm::SelectiveReadoutTask::setParams
void setParams(edm::ParameterSet const &) override
Definition: SelectiveReadoutTask.cc:25
EcalSrFlag::SRF_FORCED_MASK
static const int SRF_FORCED_MASK
Definition: EcalSrFlag.h:29
edm::Event
Definition: Event.h:73
ecaldqm::SelectiveReadoutTask::flags_
std::vector< short > flags_
Definition: SelectiveReadoutTask.h:56
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
EcalDQMCommonUtils.h
ecaldqm::MESet
Definition: MESet.h:42
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
ecaldqm::SelectiveReadoutTask::iFirstSample_
int iFirstSample_
Definition: SelectiveReadoutTask.h:52
EcalScDetId::kSizeForDenseIndexing
Definition: EcalScDetId.h:188