CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PresampleTask.cc
Go to the documentation of this file.
1 #include "../interface/PresampleTask.h"
2 
4 
6 
8 
9 namespace ecaldqm
10 {
12  DQWorkerTask(),
13  pulseMaxPosition_(0),
14  nSamples_(0)
15  {
16  }
17 
18  void
20  {
21  pulseMaxPosition_ = _params.getUntrackedParameter<int>("pulseMaxPosition");
22  nSamples_ = _params.getUntrackedParameter<int>("nSamples");
23  }
24 
25  bool
26  PresampleTask::filterRunType(short const* _runType)
27  {
28  for(int iFED(0); iFED < nDCC; iFED++){
29  if(_runType[iFED] == EcalDCCHeaderBlock::COSMIC ||
30  _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
31  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
32  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
33  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
34  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL) return true;
35  }
36 
37  return false;
38  }
39 
40  template<typename DigiCollection>
41  void
42  PresampleTask::runOnDigis(DigiCollection const& _digis)
43  {
44  MESet& mePedestal(MEs_.at("Pedestal"));
45 
46  for(typename DigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
47  DetId id(digiItr->id());
48 
49  // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame in the constructor
50  EcalDataFrame dataFrame(*digiItr);
51 
52  bool gainSwitch(false);
53  int iMax(-1);
54  int maxADC(0);
55  for(int iSample(0); iSample < EcalDataFrame::MAXSAMPLES; ++iSample){
56  int adc(dataFrame.sample(iSample).adc());
57  if(adc > maxADC){
58  iMax = iSample;
59  maxADC = adc;
60  }
61  if(iSample < nSamples_ && dataFrame.sample(iSample).gainId() != 1){
62  gainSwitch = true;
63  break;
64  }
65  }
66  if(iMax != pulseMaxPosition_ || gainSwitch) continue;
67 
68  for(int iSample(0); iSample < nSamples_; ++iSample)
69  mePedestal.fill(id, double(dataFrame.sample(iSample).adc()));
70  }
71  }
72 
74 }
75 
int adc(sample_type sample)
get the ADC sample (12 bits)
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:108
void runOnDigis(DigiCollection const &)
void setParams(edm::ParameterSet const &) override
Definition: DetId.h:18
MESetCollection MEs_
Definition: DQWorker.h:75
static const int MAXSAMPLES
Definition: EcalDataFrame.h:48
bool filterRunType(short const *) override