CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBStatusFlagsClient.cc
Go to the documentation of this file.
1 /*
2  * \file EBStatusFlagsClient.cc
3  *
4  * \author G. Della Ricca
5  *
6 */
7 
8 #include <memory>
9 #include <iostream>
10 #include <fstream>
11 #include <iomanip>
12 
14 
17 
18 #ifdef WITH_ECAL_COND_DB
21 #endif
22 
24 
27 
29 
31 
32  // cloneME switch
33  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
34 
35  // verbose switch
36  verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
37 
38  // debug switch
39  debug_ = ps.getUntrackedParameter<bool>("debug", false);
40 
41  // prefixME path
42  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
43 
44  // enableCleanup_ switch
45  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
46 
47  // vector of selected Super Modules (Defaults to all 36).
48  superModules_.reserve(36);
49  for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
50  superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
51 
52  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
53 
54  int ism = superModules_[i];
55 
56  h01_[ism-1] = 0;
57 
58  meh01_[ism-1] = 0;
59 
60  h02_[ism-1] = 0;
61 
62  meh02_[ism-1] = 0;
63 
64  h03_[ism-1] = 0;
65 
66  meh03_[ism-1] = 0;
67 
68  }
69 
70 }
71 
73 
74 }
75 
77 
79 
80  if ( debug_ ) std::cout << "EBStatusFlagsClient: beginJob" << std::endl;
81 
82  ievt_ = 0;
83  jevt_ = 0;
84 
85 }
86 
88 
89  if ( debug_ ) std::cout << "EBStatusFlagsClient: beginRun" << std::endl;
90 
91  jevt_ = 0;
92 
93  this->setup();
94 
95 }
96 
98 
99  if ( debug_ ) std::cout << "EBStatusFlagsClient: endJob, ievt = " << ievt_ << std::endl;
100 
101  this->cleanup();
102 
103 }
104 
106 
107  if ( debug_ ) std::cout << "EBStatusFlagsClient: endRun, jevt = " << jevt_ << std::endl;
108 
109  this->cleanup();
110 
111 }
112 
114 
115  dqmStore_->setCurrentFolder( prefixME_ + "/EBStatusFlagsClient" );
116 
117 }
118 
120 
121  if ( ! enableCleanup_ ) return;
122 
123  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
124 
125  int ism = superModules_[i];
126 
127  if ( cloneME_ ) {
128  if ( h01_[ism-1] ) delete h01_[ism-1];
129  if ( h02_[ism-1] ) delete h02_[ism-1];
130  if ( h03_[ism-1] ) delete h03_[ism-1];
131  }
132 
133  h01_[ism-1] = 0;
134  h02_[ism-1] = 0;
135  h03_[ism-1] = 0;
136 
137  meh01_[ism-1] = 0;
138  meh02_[ism-1] = 0;
139  meh03_[ism-1] = 0;
140 
141  }
142 
143  dqmStore_->setCurrentFolder( prefixME_ + "/EBStatusFlagsClient" );
144 
145 }
146 
147 #ifdef WITH_ECAL_COND_DB
148 bool EBStatusFlagsClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
149 
150  status = true;
151 
152  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
153 
154  int ism = superModules_[i];
155 
156  if ( verbose_ ) {
157  std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
158  std::cout << std::endl;
159  UtilsClient::printBadChannels(meh01_[ism-1], UtilsClient::getHisto<TH2F*>(meh01_[ism-1]), true);
160  }
161 
162  if ( meh01_[ism-1] ) {
163  if ( meh01_[ism-1]->getEntries() != 0 ) status = false;
164  }
165 
166  }
167 
168  return true;
169 
170 }
171 #endif
172 
174 
175  ievt_++;
176  jevt_++;
177  if ( ievt_ % 10 == 0 ) {
178  if ( debug_ ) std::cout << "EBStatusFlagsClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
179  }
180 
181  uint32_t bits01 = 0;
183 
184  MonitorElement* me;
185 
186  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
187 
188  int ism = superModules_[i];
189 
190  me = dqmStore_->get( prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT front-end status " + Numbers::sEB(ism) );
191  h01_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
192  meh01_[ism-1] = me;
193 
194  me = dqmStore_->get( prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT front-end status bits " + Numbers::sEB(ism) );
195  h02_[ism-1] = UtilsClient::getHisto( me, cloneME_, h02_[ism-1] );
196  meh02_[ism-1] = me;
197 
198  me = dqmStore_->get( prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT MEM front-end status " + Numbers::sEB(ism) );
199  h03_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
200  meh03_[ism-1] = me;
201 
202  for ( int ie = 1; ie <= 85; ie++ ) {
203  for ( int ip = 1; ip <= 20; ip++ ) {
204  if ( Masks::maskChannel(ism, ie, ip, bits01, EcalBarrel) ) {
205  int iet = (ie-1)/5 + 1;
206  int ipt = (ip-1)/5 + 1;
207  if ( meh01_[ism-1] ) meh01_[ism-1]->setBinError( iet, ipt, 0.01 );
208  }
209  }
210  }
211 
212  for ( int i = 1; i <= 10; i++ ) {
213  if ( Masks::maskPn(ism, i, bits01, EcalBarrel) ) {
214  int it = (i-1)/5 + 1;
215  if ( meh03_[ism-1] ) meh03_[ism-1]->setBinError( it, 1, 0.01 );
216  }
217  }
218 
219  }
220 
221 }
222 
void endRun(void)
EndRun.
void cleanup(void)
Cleanup.
Cache logicID vector from database.
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static bool maskChannel(int ism, int i1, int i2, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:57
static T getHisto(const MonitorElement *me, bool clone=false, T ret=0)
Returns the histogram contained by the Monitor Element.
Definition: UtilsClient.h:89
Some &quot;id&quot; conversions.
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
EBStatusFlagsClient(const edm::ParameterSet &ps)
Constructor.
std::vector< int > superModules_
static bool maskPn(int ism, int i1, uint32_t bits, const EcalSubdetector subdet)
Definition: Masks.cc:109
static const int STATUS_FLAG_ERROR
void beginRun(void)
BeginRun.
channel masking
MonitorElement * meh03_[36]
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * meh01_[36]
MonitorElement * meh02_[36]
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
void endJob(void)
EndJob.
Ecal Monitor Utils for Client.
void beginJob(void)
BeginJob.
void analyze(void)
Analyze.
virtual ~EBStatusFlagsClient()
Destructor.
void setup(void)
Setup.
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
Definition: RunIOV.h:13
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
static void printBadChannels(const MonitorElement *me, TH1 *hi, bool positive_only=false)
Print the bad channels.
Definition: UtilsClient.cc:14
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584