CMS 3D CMS Logo

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