CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBTriggerTowerClient.cc
Go to the documentation of this file.
1 /*
2  * \file EBTriggerTowerClient.cc
3  *
4  * \author G. Della Ricca
5  * \author F. Cossutti
6  *
7 */
8 
9 #include <memory>
10 #include <iostream>
11 #include <fstream>
12 #include <iomanip>
13 
15 
18 
21 
23 
25 
26  // cloneME switch
27  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
28 
29  // verbose switch
30  verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
31 
32  // debug switch
33  debug_ = ps.getUntrackedParameter<bool>("debug", false);
34 
35  // prefixME path
36  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
37 
38  // enableCleanup_ switch
39  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
40 
41  // vector of selected Super Modules (Defaults to all 36).
42  superModules_.reserve(36);
43  for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
44  superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
45 
46  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
47 
48  int ism = superModules_[i];
49 
50  l01_[ism-1] = 0;
51  o01_[ism-1] = 0;
52 
53  mel01_[ism-1] = 0;
54  meo01_[ism-1] = 0;
55 
56  }
57 
58  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
59 
60  int ism = superModules_[i];
61 
62  me_o01_[ism-1] = 0;
63  me_o02_[ism-1] = 0;
64 
65  }
66 
67 }
68 
70 
71 }
72 
74 
76 
77  if ( debug_ ) std::cout << "EBTriggerTowerClient: beginJob" << std::endl;
78 
79  ievt_ = 0;
80  jevt_ = 0;
81 
82 }
83 
85 
86  if ( debug_ ) std::cout << "EBTriggerTowerClient: beginRun" << std::endl;
87 
88  jevt_ = 0;
89 
90  this->setup();
91 
92 }
93 
95 
96  if ( debug_ ) std::cout << "EBTriggerTowerClient: endJob, ievt = " << ievt_ << std::endl;
97 
98  this->cleanup();
99 
100 }
101 
103 
104  if ( debug_ ) std::cout << "EBTriggerTowerClient: endRun, jevt = " << jevt_ << std::endl;
105 
106  this->cleanup();
107 
108 }
109 
111 
113 
114  dqmStore_->setCurrentFolder( prefixME_ + "/EBTriggerTowerClient" );
115 
116  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
117 
118  int ism = superModules_[i];
119 
120  if ( me_o01_[ism-1] ) dqmStore_->removeElement( me_o01_[ism-1]->getName() );
121  name = "EBTTT Trigger Primitives Timing " + Numbers::sEB(ism);
122  me_o01_[ism-1] = dqmStore_->book2D(name, name, 17, 0., 17., 4, 0., 4.);
123  me_o01_[ism-1]->setAxisTitle("ieta'", 1);
124  me_o01_[ism-1]->setAxisTitle("iphi'", 2);
125 
126  if ( me_o02_[ism-1] ) dqmStore_->removeElement( me_o02_[ism-1]->getName() );
127  name = "EBTTT Non Single Timing " + Numbers::sEB(ism);
128  me_o02_[ism-1] = dqmStore_->book2D(name, name, 17, 0., 17., 4, 0., 4.);
129  me_o02_[ism-1]->setAxisTitle("ieta'", 1);
130  me_o02_[ism-1]->setAxisTitle("iphi'", 2);
131  me_o02_[ism-1]->setAxisTitle("fraction", 3);
132 
133  }
134 
135  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
136 
137  int ism = superModules_[i];
138 
139  if ( me_o01_[ism-1] ) me_o01_[ism-1]->Reset();
140  if ( me_o02_[ism-1] ) me_o02_[ism-1]->Reset();
141 
142  }
143 
144 }
145 
147 
148  if ( ! enableCleanup_ ) return;
149 
150  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
151 
152  int ism = superModules_[i];
153 
154  if ( cloneME_ ) {
155  if ( l01_[ism-1] ) delete l01_[ism-1];
156  if ( o01_[ism-1] ) delete o01_[ism-1];
157  }
158 
159  l01_[ism-1] = 0;
160  o01_[ism-1] = 0;
161 
162  mel01_[ism-1] = 0;
163  meo01_[ism-1] = 0;
164 
165  }
166 
167  dqmStore_->setCurrentFolder( prefixME_ + "/EBTriggerTowerClient" );
168 
169  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
170 
171  int ism = superModules_[i];
172 
173  if ( me_o01_[ism-1] ) dqmStore_->removeElement( me_o01_[ism-1]->getName() );
174  me_o01_[ism-1] = 0;
175  if ( me_o02_[ism-1] ) dqmStore_->removeElement( me_o02_[ism-1]->getName() );
176  me_o02_[ism-1] = 0;
177 
178  }
179 
180 }
181 
182 #ifdef WITH_ECAL_COND_DB
183 bool EBTriggerTowerClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
184 
185  status = true;
186 
187  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
188 
189  int ism = superModules_[i];
190 
191  if ( verbose_ ) {
192  std::cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << std::endl;
193  std::cout << std::endl;
194  UtilsClient::printBadChannels(mel01_[ism-1], UtilsClient::getHisto<TH2F*>(mel01_[ism-1]), true);
195  }
196 
197  }
198 
199  return true;
200 
201 }
202 #endif
203 
205 
206  ievt_++;
207  jevt_++;
208  if ( ievt_ % 10 == 0 ) {
209  if ( debug_ ) std::cout << "EBTriggerTowerClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
210  }
211 
212  MonitorElement* me;
213 
214  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
215 
216  int ism = superModules_[i];
217 
218  me = dqmStore_->get( prefixME_ + "/EBTriggerTowerTask/EBTTT EmulError " + Numbers::sEB(ism) );
219  l01_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, l01_[ism-1] );
220  mel01_[ism-1] = me;
221 
222  me = dqmStore_->get( prefixME_ + "/EBTriggerTowerTask/EBTTT EmulFineGrainVetoError " + Numbers::sEB(ism) );
223  l02_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, l02_[ism-1] );
224  mel02_[ism-1] = me;
225 
226  me = dqmStore_->get( prefixME_ + "/EBTriggerTowerTask/EBTTT EmulMatch " + Numbers::sEB(ism) );
227  o01_[ism-1] = UtilsClient::getHisto<TH3F*>( me, cloneME_, o01_[ism-1] );
228  meo01_[ism-1] = me;
229 
230  if ( me_o01_[ism-1] ) me_o01_[ism-1]->Reset();
231  if ( me_o02_[ism-1] ) me_o02_[ism-1]->Reset();
232 
233  for (int ie = 1; ie <= 17; ie++) {
234  for (int ip = 1; ip <= 4; ip++) {
235 
236  if ( o01_[ism-1] ) {
237  // find the most frequent TP timing that matches the emulator
238  float index=-1;
239  double max=0;
240  double total=0;
241  for (int j=0; j<6; j++) {
242  double sampleEntries = o01_[ism-1]->GetBinContent(ie, ip, j+1);
243  if(sampleEntries > max) {
244  index=j;
245  max = sampleEntries;
246  }
247  total += sampleEntries;
248  }
249  if ( max > 0 ) {
250  if ( index == 0 ) {
251  me_o01_[ism-1]->setBinContent(ie, ip, -1);
252  } else {
253  me_o01_[ism-1]->setBinContent(ie, ip, index );
254  }
255  }
256  double fraction = (total > 0) ? 1.0 - max/total : 0.;
257  if ( me_o02_[ism-1] ) me_o02_[ism-1]->setBinContent(ie, ip, fraction);
258  }
259 
260  }
261  }
262 
263  }
264 
265 }
266 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * me_o02_[36]
Some &quot;id&quot; conversions.
MonitorElement * mel01_[36]
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:91
MonitorElement * mel02_[36]
void cleanup(void)
Cleanup.
MonitorElement * meo01_[36]
void analyze(void)
Analyze.
const T & max(const T &a, const T &b)
std::vector< int > superModules_
void endRun(void)
EndRun.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
void endJob(void)
EndJob.
int j
Definition: DBlmapReader.cc:9
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 beginJob(void)
BeginJob.
Ecal Monitor Utils for Client.
MonitorElement * me_o01_[36]
void beginRun(void)
BeginRun.
tuple cout
Definition: gather_cfg.py:121
EBTriggerTowerClient(const edm::ParameterSet &ps)
Constructor.
tuple status
Definition: ntuplemaker.py:245
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
Definition: RunIOV.h:13
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
virtual ~EBTriggerTowerClient()
Destructor.
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