CMS 3D CMS Logo

TestPulseTask.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 #include <iomanip>
5 
9 
11 
13 
14 namespace ecaldqm {
15  TestPulseTask::TestPulseTask() : DQWorkerTask(), gainToME_(), pnGainToME_() {
16  std::fill_n(enable_, nDCC, false);
17  std::fill_n(gain_, nDCC, 0);
18  }
19 
21  std::vector<int> MGPAGains(_params.getUntrackedParameter<std::vector<int> >("MGPAGains"));
22  std::vector<int> MGPAGainsPN(_params.getUntrackedParameter<std::vector<int> >("MGPAGainsPN"));
23 
25 
26  MESetMulti& amplitude(static_cast<MESetMulti&>(MEs_.at("Amplitude")));
27  unsigned nG(MGPAGains.size());
28  for (unsigned iG(0); iG != nG; ++iG) {
29  int gain(MGPAGains[iG]);
30  if (gain != 1 && gain != 6 && gain != 12)
31  throw cms::Exception("InvalidConfiguration") << "MGPA gain";
32  repl["gain"] = std::to_string(gain);
33  gainToME_[gain] = amplitude.getIndex(repl);
34  }
35 
36  repl.clear();
37 
38  MESetMulti& pnAmplitude(static_cast<MESetMulti&>(MEs_.at("PNAmplitude")));
39  unsigned nGPN(MGPAGainsPN.size());
40  for (unsigned iG(0); iG != nGPN; ++iG) {
41  int gain(MGPAGainsPN[iG]);
42  if (gain != 1 && gain != 16)
43  throw cms::Exception("InvalidConfiguration") << "PN MGPA gain";
44  repl["pngain"] = std::to_string(gain);
45  pnGainToME_[gain] = pnAmplitude.getIndex(repl);
46  }
47  }
48 
52  }
53 
54  bool TestPulseTask::filterRunType(short const* _runType) {
55  bool enable(false);
56 
57  for (int iFED(0); iFED < nDCC; iFED++) {
58  if (_runType[iFED] == EcalDCCHeaderBlock::TESTPULSE_MGPA || _runType[iFED] == EcalDCCHeaderBlock::TESTPULSE_GAP) {
59  enable = true;
60  enable_[iFED] = true;
61  } else
62  enable_[iFED] = false;
63  }
64 
65  return enable;
66  }
67 
69  for (EcalRawDataCollection::const_iterator rItr(_rawData.begin()); rItr != _rawData.end(); ++rItr) {
70  unsigned iDCC(rItr->id() - 1);
71 
72  if (!enable_[iDCC]) {
73  gain_[iDCC] = 0;
74  continue;
75  }
76  switch (rItr->getMgpaGain()) {
77  case 1:
78  gain_[iDCC] = 12;
79  break;
80  case 2:
81  gain_[iDCC] = 6;
82  break;
83  case 3:
84  gain_[iDCC] = 1;
85  break;
86  default:
87  break;
88  }
89 
90  if (gainToME_.find(gain_[iDCC]) == gainToME_.end())
91  enable_[iDCC] = false;
92  }
93  }
94 
95  template <typename DigiCollection>
97  MESet& meOccupancy(MEs_.at("Occupancy"));
98  MESet& meShape(MEs_.at("Shape"));
99 
100  unsigned iME(-1);
101 
102  for (typename DigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr) {
103  DetId id(digiItr->id());
104 
105  meOccupancy.fill(getEcalDQMSetupObjects(), id);
106 
107  int iDCC(dccId(id, GetElectronicsMap()) - 1);
108 
109  if (!enable_[iDCC])
110  continue;
111 
112  // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame in the constructor
113  EcalDataFrame dataFrame(*digiItr);
114 
115  if (iME != gainToME_[gain_[iDCC]]) {
116  iME = gainToME_[gain_[iDCC]];
117  static_cast<MESetMulti&>(meShape).use(iME);
118  }
119 
120  for (int iSample(0); iSample < 10; iSample++)
121  meShape.fill(getEcalDQMSetupObjects(), id, iSample + 0.5, float(dataFrame.sample(iSample).adc()));
122  }
123  }
124 
126  MESet& mePNAmplitude(MEs_.at("PNAmplitude"));
127 
128  unsigned iME(-1);
129 
130  for (EcalPnDiodeDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr) {
131  EcalPnDiodeDetId const& id(digiItr->id());
132 
133  int iDCC(dccId(id, GetElectronicsMap()) - 1);
134 
135  if (!enable_[iDCC])
136  continue;
137 
138  int gain(0);
139  switch (digiItr->sample(0).gainId()) {
140  case 0:
141  gain = 1;
142  break;
143  case 1:
144  gain = 16;
145  break;
146  default:
147  continue;
148  }
149 
150  if (pnGainToME_.find(gain) == pnGainToME_.end())
151  continue;
152 
153  if (iME != pnGainToME_[gain]) {
154  iME = pnGainToME_[gain];
155  static_cast<MESetMulti&>(mePNAmplitude).use(iME);
156  }
157 
158  float pedestal(0.);
159  for (int iSample(0); iSample < 4; iSample++)
160  pedestal += digiItr->sample(iSample).adc();
161  pedestal /= 4.;
162 
163  float max(0.);
164  for (int iSample(0); iSample < 50; iSample++)
165  if (digiItr->sample(iSample).adc() > max)
166  max = digiItr->sample(iSample).adc();
167 
168  double amplitude(max - pedestal);
169 
170  mePNAmplitude.fill(getEcalDQMSetupObjects(), id, amplitude);
171  }
172  }
173 
175  MESet& meAmplitude(MEs_.at("Amplitude"));
176 
177  unsigned iME(-1);
178 
179  for (EcalUncalibratedRecHitCollection::const_iterator uhitItr(_uhits.begin()); uhitItr != _uhits.end(); ++uhitItr) {
180  DetId id(uhitItr->id());
181 
182  int iDCC(dccId(id, GetElectronicsMap()) - 1);
183 
184  if (!enable_[iDCC])
185  continue;
186 
187  if (iME != gainToME_[gain_[iDCC]]) {
188  iME = gainToME_[gain_[iDCC]];
189  static_cast<MESetMulti&>(meAmplitude).use(iME);
190  }
191 
192  meAmplitude.fill(getEcalDQMSetupObjects(), id, uhitItr->amplitude());
193  }
194  }
195 
197 } // namespace ecaldqm
ecaldqm::kEBTestPulseUncalibRecHit
Definition: Collections.h:34
ecaldqm::TestPulseTask::setParams
void setParams(edm::ParameterSet const &) override
Definition: TestPulseTask.cc:20
EcalDataFrame::sample
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
ecaldqm::TestPulseTask::runOnUncalibRecHits
void runOnUncalibRecHits(EcalUncalibratedRecHitCollection const &)
Definition: TestPulseTask.cc:174
CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
ecaldqm
Definition: DQWorker.h:29
ecaldqm::TestPulseTask::gain_
int gain_[nDCC]
Definition: TestPulseTask.h:38
remoteMonitoring_LED_IterMethod_cfg.enable
enable
Definition: remoteMonitoring_LED_IterMethod_cfg.py:423
ecaldqm::DependencySet
Definition: DQWorkerTask.h:44
ecaldqm::MESet::PathReplacements
std::map< std::string, std::string > PathReplacements
Definition: MESet.h:46
ecaldqm::TestPulseTask::runOnPnDigis
void runOnPnDigis(EcalPnDiodeDigiCollection const &)
Definition: TestPulseTask.cc:125
l1extraParticles_cfi._params
_params
Definition: l1extraParticles_cfi.py:29
edm::SortedCollection
Definition: SortedCollection.h:49
ecaldqm::Dependency
Definition: DQWorkerTask.h:19
EcalPnDiodeDetId
Definition: EcalPnDiodeDetId.h:22
ecaldqm::kEcalRawData
Definition: Collections.h:10
EcalDataFrame
Definition: EcalDataFrame.h:16
ecaldqm::DQWorker::GetElectronicsMap
const EcalElectronicsMapping * GetElectronicsMap()
Definition: DQWorker.cc:104
EcalDataFrame.h
EcalDCCHeaderBlock::TESTPULSE_GAP
Definition: EcalDCCHeaderBlock.h:43
ecaldqm::kEETestPulseUncalibRecHit
Definition: Collections.h:35
DetId
Definition: DetId.h:17
EcalMGPASample::adc
int adc() const
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:31
PedestalClient_cfi.MGPAGainsPN
MGPAGainsPN
Definition: PedestalClient_cfi.py:27
ecaldqm::TestPulseTask::addDependencies
void addDependencies(DependencySet &) override
Definition: TestPulseTask.cc:49
ecaldqm::DQWorkerTask
Definition: DQWorkerTask.h:71
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
ecaldqm::MESetMulti::getIndex
unsigned getIndex(PathReplacements const &) const
Definition: MESetMulti.cc:142
ecaldqm::TestPulseTask::runOnDigis
void runOnDigis(DigiCollection const &)
Definition: TestPulseTask.cc:96
EcalDCCHeaderBlock::TESTPULSE_MGPA
Definition: EcalDCCHeaderBlock.h:30
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:104
edm::ParameterSet
Definition: ParameterSet.h:47
ecaldqm::TestPulseTask::TestPulseTask
TestPulseTask()
Definition: TestPulseTask.cc:15
ecaldqm::MESetMulti
Definition: MESetMulti.h:13
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ecaldqm::MESetCollection::at
MESet & at(const std::string &key)
Definition: MESet.h:399
ecaldqm::DependencySet::push_back
void push_back(Dependency const &_d)
Definition: DQWorkerTask.h:46
EcalDCCHeaderBlock.h
PedestalClient_cfi.MGPAGains
MGPAGains
Definition: PedestalClient_cfi.py:26
ecaldqm::TestPulseTask::enable_
bool enable_[nDCC]
Definition: TestPulseTask.h:37
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
ecaldqm::TestPulseTask::runOnRawData
void runOnRawData(EcalRawDataCollection const &)
Definition: TestPulseTask.cc:68
ecaldqm::dccId
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
Definition: EcalDQMCommonUtils.cc:16
ecaldqm::TestPulseTask::filterRunType
bool filterRunType(short const *) override
Definition: TestPulseTask.cc:54
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
ecaldqm::TestPulseTask
Definition: TestPulseTask.h:14
ecaldqm::DQWorker::getEcalDQMSetupObjects
const EcalDQMSetupObjects getEcalDQMSetupObjects()
Definition: DQWorker.cc:128
siStripShotFilter_cfi.DigiCollection
DigiCollection
Definition: siStripShotFilter_cfi.py:6
DetId.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
Exception
Definition: hltDiff.cc:245
MESetMulti.h
ecaldqm::nDCC
Definition: EcalDQMCommonUtils.h:91
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:141
ParameterSet.h
TestPulseTask.h
ecaldqm::TestPulseTask::pnGainToME_
std::map< int, unsigned > pnGainToME_
Definition: TestPulseTask.h:35
ecaldqm::MESet
Definition: MESet.h:42
ecaldqm::TestPulseTask::gainToME_
std::map< int, unsigned > gainToME_
Definition: TestPulseTask.h:34