CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PedestalTask.cc
Go to the documentation of this file.
1 #include "../interface/PedestalTask.h"
2 
3 #include <algorithm>
4 
8 
10 
11 namespace ecaldqm {
12 
14  DQWorkerTask(_params, _paths, "PedestalTask"),
15  MGPAGains_(),
16  MGPAGainsPN_()
17  {
18  using namespace std;
19 
21  (0x1 << kEBDigi) |
22  (0x1 << kEEDigi) |
23  (0x1 << kPnDiodeDigi);
24 
25  edm::ParameterSet const& commonParams(_params.getUntrackedParameterSet("Common"));
26  MGPAGains_ = commonParams.getUntrackedParameter<std::vector<int> >("MGPAGains");
27  MGPAGainsPN_ = commonParams.getUntrackedParameter<std::vector<int> >("MGPAGainsPN");
28 
29  for(std::vector<int>::iterator gainItr(MGPAGains_.begin()); gainItr != MGPAGains_.end(); ++gainItr)
30  if(*gainItr != 1 && *gainItr != 6 && *gainItr != 12) throw cms::Exception("InvalidConfiguration") << "MGPA gain" << std::endl;
31 
32  for(std::vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr)
33  if(*gainItr != 1 && *gainItr != 16) throw cms::Exception("InvalidConfiguration") << "PN diode gain" << std::endl;
34 
35  map<string, string> replacements;
36  stringstream ss;
37 
38  for(vector<int>::iterator gainItr(MGPAGains_.begin()); gainItr != MGPAGains_.end(); ++gainItr){
39  ss.str("");
40  ss << *gainItr;
41  replacements["gain"] = ss.str();
42 
43  unsigned offset(0);
44  switch(*gainItr){
45  case 1: offset = 0; break;
46  case 6: offset = 1; break;
47  case 12: offset = 2; break;
48  default: break;
49  }
50 
51  MEs_[kOccupancy + offset]->name(replacements);
52  MEs_[kPedestal + offset]->name(replacements);
53  }
54 
55  for(vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr){
56  ss.str("");
57  ss << *gainItr;
58  replacements["pngain"] = ss.str();
59 
60  unsigned offset(0);
61  switch(*gainItr){
62  case 1: offset = 0; break;
63  case 16: offset = 1; break;
64  default: break;
65  }
66 
67  MEs_[kPNOccupancy + offset]->name(replacements);
68  MEs_[kPNPedestal + offset]->name(replacements);
69  }
70  }
71 
73  {
74  }
75 
76  void
78  {
79  for(std::vector<int>::iterator gainItr(MGPAGains_.begin()); gainItr != MGPAGains_.end(); ++gainItr){
80  unsigned offset(0);
81  switch(*gainItr){
82  case 1: offset = 0; break;
83  case 6: offset = 1; break;
84  case 12: offset = 2; break;
85  default: break;
86  }
87 
88  MEs_[kOccupancy + offset]->book();
89  MEs_[kPedestal + offset]->book();
90  }
91  for(std::vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr){
92  unsigned offset(0);
93  switch(*gainItr){
94  case 1: offset = 0; break;
95  case 16: offset = 1; break;
96  default: break;
97  }
98 
99  MEs_[kPNOccupancy + offset]->book();
100  MEs_[kPNPedestal + offset]->book();
101  }
102  }
103 
104  bool
105  PedestalTask::filterRunType(const std::vector<short>& _runType)
106  {
107  bool enable(false);
108 
109  for(int iFED(0); iFED < 54; iFED++){
110  if(_runType[iFED] == EcalDCCHeaderBlock::PEDESTAL_STD ||
111  _runType[iFED] == EcalDCCHeaderBlock::PEDESTAL_GAP){
112  enable = true;
113  enable_[iFED] = true;
114  }
115  }
116 
117  return enable;
118  }
119 
120  void
122  {
123  for(EcalDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
124  DetId id(digiItr->id());
125 
126  int iDCC(dccId(id) - 1);
127 
128  if(!enable_[iDCC]) continue;
129 
130  // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame in the constructor
131  EcalDataFrame dataFrame(*digiItr);
132 
133  unsigned offset(0);
134  int gain(0);
135  switch(dataFrame.sample(0).gainId()){
136  case 1: offset = 2; gain = 12; break;
137  case 2: offset = 1; gain = 6; break;
138  case 3: offset = 0; gain = 1; break;
139  default: continue;
140  }
141 
142  if(std::find(MGPAGains_.begin(), MGPAGains_.end(), gain) == MGPAGains_.end()) continue;
143 
144  MEs_[kOccupancy + offset]->fill(id);
145 
146  float mean(0.);
147  for(int iSample(0); iSample < 10; iSample++)
148  mean += dataFrame.sample(iSample).adc();
149  mean /= 10.;
150 
151  MEs_[kPedestal + offset]->fill(id, mean);
152  }
153  }
154 
155  void
157  {
158  for(EcalPnDiodeDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
159  EcalPnDiodeDetId id(digiItr->id());
160 
161  int iDCC(dccId(id) - 1);
162 
163  if(!enable_[iDCC]) continue;
164 
165  unsigned offset(0);
166  int gain(0);
167  switch(digiItr->sample(0).gainId()){
168  case 0: offset = 0; gain = 1; break;
169  case 1: offset = 1; gain = 16; break;
170  default: continue;
171  }
172 
173  if(std::find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), gain) == MGPAGainsPN_.end()) continue;
174 
175  MEs_[kPNOccupancy + offset]->fill(id);
176 
177  float mean(0.);
178  for(int iSample(0); iSample < 50; iSample++)
179  mean += digiItr->sample(iSample).adc();
180  mean /= 50.;
181 
182  MEs_[kPNPedestal + offset]->fill(id, mean);
183  }
184  }
185 
186  /*static*/
187  void
188  PedestalTask::setMEData(std::vector<MEData>& _data)
189  {
190  for(unsigned iGain(0); iGain < nGain; iGain++){
193  }
194  for(unsigned iPNGain(0); iPNGain < nPNGain; iPNGain++){
197  }
198  }
199 
201 }
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
std::vector< EcalPnDiodeDigi >::const_iterator const_iterator
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
unsigned dccId(const DetId &)
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void runOnDigis(const EcalDigiCollection &)
const_iterator begin() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int gainId() const
get the gainId (2 bits)
std::vector< int > MGPAGains_
Definition: PedestalTask.h:40
unsigned int offset(bool)
std::vector< int > MGPAGainsPN_
Definition: PedestalTask.h:41
static void setMEData(std::vector< MEData > &)
const_iterator end() const
Definition: DetId.h:18
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
bool filterRunType(const std::vector< short > &) override
const_iterator end() const
void bookMEs() override
Definition: PedestalTask.cc:77
DEFINE_ECALDQM_WORKER(CertificationClient)
void runOnPnDigis(const EcalPnDiodeDigiCollection &)
bool enable_[BinService::nDCC]
Definition: PedestalTask.h:43
PedestalTask(const edm::ParameterSet &, const edm::ParameterSet &)
Definition: PedestalTask.cc:13
const_iterator begin() const
int adc() const
get the ADC sample (12 bits)