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  doPulseMaxCheck_(true),
14  pulseMaxPosition_(0),
15  nSamples_(0)
16  {
17  }
18 
19  void
21  {
22  doPulseMaxCheck_ = _params.getUntrackedParameter<bool>("doPulseMaxCheck");
23  pulseMaxPosition_ = _params.getUntrackedParameter<int>("pulseMaxPosition");
24  nSamples_ = _params.getUntrackedParameter<int>("nSamples");
25  }
26 
27  bool
28  PresampleTask::filterRunType(short const* _runType)
29  {
30  for(int iFED(0); iFED < nDCC; iFED++){
31  if(_runType[iFED] == EcalDCCHeaderBlock::COSMIC ||
32  _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
33  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
34  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
35  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
36  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL) return true;
37  }
38 
39  return false;
40  }
41 
42  template<typename DigiCollection>
43  void
44  PresampleTask::runOnDigis(DigiCollection const& _digis)
45  {
46  MESet& mePedestal(MEs_.at("Pedestal"));
47 
48  for(typename DigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
49  DetId id(digiItr->id());
50 
51  // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame in the constructor
52  EcalDataFrame dataFrame(*digiItr);
53 
54  // Check that the digi pulse maximum occurs on the 6th sample
55  // For cosmics: disable this check to preserve statistics
56  if ( doPulseMaxCheck_ ) {
57  bool gainSwitch(false);
58  int iMax(-1);
59  int maxADC(0);
60  for(int iSample(0); iSample < EcalDataFrame::MAXSAMPLES; ++iSample){
61  int adc(dataFrame.sample(iSample).adc());
62  if(adc > maxADC){
63  iMax = iSample;
64  maxADC = adc;
65  }
66  if(iSample < nSamples_ && dataFrame.sample(iSample).gainId() != 1){
67  gainSwitch = true;
68  break;
69  }
70  } // iSample
71  if(iMax != pulseMaxPosition_ || gainSwitch) continue;
72  } // PulseMaxCheck
73 
74  for(int iSample(0); iSample < nSamples_; ++iSample)
75  mePedestal.fill(id, double(dataFrame.sample(iSample).adc()));
76 
77  } // _digis loop
78  } // runOnDigis
79 
81 }
82 
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