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: 2010/08/08 08:46:07 $
5  * $Revision: 1.96 $
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 
19 
22 
24 
26 
27  // cloneME switch
28  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
29 
30  // verbose switch
31  verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
32 
33  // debug switch
34  debug_ = ps.getUntrackedParameter<bool>("debug", false);
35 
36  // prefixME path
37  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
38 
39  // enableCleanup_ switch
40  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
41 
42  // vector of selected Super Modules (Defaults to all 18).
43  superModules_.reserve(18);
44  for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
45  superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
46 
47  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
48 
49  int ism = superModules_[i];
50 
51  l01_[ism-1] = 0;
52  o01_[ism-1] = 0;
53 
54  mel01_[ism-1] = 0;
55  meo01_[ism-1] = 0;
56 
57  }
58 
59  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
60 
61  int ism = superModules_[i];
62 
63  me_o01_[ism-1] = 0;
64  me_o02_[ism-1] = 0;
65 
66  }
67 
68 }
69 
71 
72 }
73 
75 
77 
78  if ( debug_ ) std::cout << "EETriggerTowerClient: beginJob" << std::endl;
79 
80  ievt_ = 0;
81  jevt_ = 0;
82 
83 }
84 
86 
87  if ( debug_ ) std::cout << "EETriggerTowerClient: beginRun" << std::endl;
88 
89  jevt_ = 0;
90 
91  this->setup();
92 
93 }
94 
96 
97  if ( debug_ ) std::cout << "EETriggerTowerClient: endJob, ievt = " << ievt_ << std::endl;
98 
99  this->cleanup();
100 
101 }
102 
104 
105  if ( debug_ ) std::cout << "EETriggerTowerClient: endRun, jevt = " << jevt_ << std::endl;
106 
107  this->cleanup();
108 
109 }
110 
112 
113  char histo[200];
114 
115  dqmStore_->setCurrentFolder( prefixME_ + "/EETriggerTowerClient" );
116 
117  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
118 
119  int ism = superModules_[i];
120 
121  if ( me_o01_[ism-1] ) dqmStore_->removeElement( me_o01_[ism-1]->getName() );
122  sprintf(histo, "EETTT Trigger Primitives Timing %s", Numbers::sEE(ism).c_str());
123  me_o01_[ism-1] = dqmStore_->book2D(histo, histo, 50, Numbers::ix0EE(ism)+0., Numbers::ix0EE(ism)+50., 50, Numbers::iy0EE(ism)+0., Numbers::iy0EE(ism)+50.);
124  me_o01_[ism-1]->setAxisTitle("ix", 1);
125  if ( ism >= 1 && ism <= 9 ) me_o01_[ism-1]->setAxisTitle("101-ix", 1);
126  me_o01_[ism-1]->setAxisTitle("iy", 2);
127 
128  if ( me_o02_[ism-1] ) dqmStore_->removeElement( me_o02_[ism-1]->getName() );
129  sprintf(histo, "EETTT Non Single Timing %s", Numbers::sEE(ism).c_str());
130  me_o02_[ism-1] = dqmStore_->book2D(histo, histo, 50, Numbers::ix0EE(ism)+0., Numbers::ix0EE(ism)+50., 50, Numbers::iy0EE(ism)+0., Numbers::iy0EE(ism)+50.);
131  me_o02_[ism-1]->setAxisTitle("ix", 1);
132  if ( ism >= 1 && ism <= 9 ) me_o02_[ism-1]->setAxisTitle("101-ix", 1);
133  me_o02_[ism-1]->setAxisTitle("iy", 2);
134  me_o02_[ism-1]->setAxisTitle("fraction", 3);
135 
136  }
137 
138  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
139 
140  int ism = superModules_[i];
141 
142  if ( me_o01_[ism-1] ) me_o01_[ism-1]->Reset();
143  if ( me_o02_[ism-1] ) me_o02_[ism-1]->Reset();
144 
145  }
146 
147 }
148 
150 
151  if ( ! enableCleanup_ ) return;
152 
153  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
154 
155  int ism = superModules_[i];
156 
157  if ( cloneME_ ) {
158  if ( l01_[ism-1] ) delete l01_[ism-1];
159  if ( o01_[ism-1] ) delete o01_[ism-1];
160  }
161 
162  l01_[ism-1] = 0;
163  o01_[ism-1] = 0;
164 
165  mel01_[ism-1] = 0;
166  meo01_[ism-1] = 0;
167 
168  }
169 
170  dqmStore_->setCurrentFolder( prefixME_ + "/EETriggerTowerClient" );
171 
172  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
173 
174  int ism = superModules_[i];
175 
176  if ( me_o01_[ism-1] ) dqmStore_->removeElement( me_o01_[ism-1]->getName() );
177  me_o01_[ism-1] = 0;
178  if ( me_o02_[ism-1] ) dqmStore_->removeElement( me_o02_[ism-1]->getName() );
179  me_o02_[ism-1] = 0;
180 
181  }
182 
183 }
184 
185 #ifdef WITH_ECAL_COND_DB
186 bool EETriggerTowerClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
187 
188  status = true;
189 
190  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
191 
192  int ism = superModules_[i];
193 
194  if ( verbose_ ) {
195  std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
196  std::cout << std::endl;
197  UtilsClient::printBadChannels(mel01_[ism-1], UtilsClient::getHisto<TH2F*>(mel01_[ism-1]), true);
198  }
199 
200  }
201 
202  return true;
203 
204 }
205 #endif
206 
208 
209  ievt_++;
210  jevt_++;
211  if ( ievt_ % 10 == 0 ) {
212  if ( debug_ ) std::cout << "EETriggerTowerClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
213  }
214 
215  char histo[200];
216 
217  MonitorElement* me;
218 
219  for ( unsigned int i=0; i<superModules_.size(); i++ ) {
220 
221  int ism = superModules_[i];
222 
223  sprintf(histo, (prefixME_ + "/EETriggerTowerTask/EETTT EmulError %s").c_str(), Numbers::sEE(ism).c_str());
224  me = dqmStore_->get(histo);
225  l01_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, l01_[ism-1] );
226  mel01_[ism-1] = me;
227 
228  sprintf(histo, (prefixME_ + "/EETriggerTowerTask/EETTT EmulFineGrainVetoError %s").c_str(), Numbers::sEE(ism).c_str());
229  me = dqmStore_->get(histo);
230  l02_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, l02_[ism-1] );
231  mel02_[ism-1] = me;
232 
233  sprintf(histo, (prefixME_ + "/EETriggerTowerTask/EETTT EmulMatch %s").c_str(), Numbers::sEE(ism).c_str());
234  me = dqmStore_->get(histo);
235  o01_[ism-1] = UtilsClient::getHisto<TH3F*>( me, cloneME_, o01_[ism-1] );
236  meo01_[ism-1] = me;
237 
238  if ( me_o01_[ism-1] ) me_o01_[ism-1]->Reset();
239  if ( me_o02_[ism-1] ) me_o02_[ism-1]->Reset();
240 
241  for (int ix = 1; ix <= 50; ix++) {
242  for (int iy = 1; iy <= 50; iy++) {
243 
244  if ( o01_[ism-1] ) {
245  // find the most frequent TP timing that matches the emulator
246  float index=-1;
247  double max=0;
248  double total=0;
249  for (int j=0; j<6; j++) {
250  double sampleEntries = o01_[ism-1]->GetBinContent(ix, iy, j+1);
251  if(sampleEntries > max) {
252  index=j;
253  max = sampleEntries;
254  }
255  total += sampleEntries;
256  }
257  if ( max > 0 ) {
258  if ( index == 0 ) {
259  me_o01_[ism-1]->setBinContent(ix, iy, -1);
260  } else {
261  me_o01_[ism-1]->setBinContent(ix, iy, index );
262  }
263  }
264  double fraction = (total > 0) ? 1.0 - max/total : 0.;
265  if ( me_o02_[ism-1] ) me_o02_[ism-1]->setBinContent(ix, iy, fraction);
266  }
267 
268  }
269  }
270 
271  }
272 
273 }
274 
static void printBadChannels(const MonitorElement *me, const T *hi, bool positive_only=false)
Print the bad channels.
Definition: UtilsClient.h:67
MonitorElement * meo01_[18]
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void beginJob(void)
BeginJob.
void setBinContent(int binx, double content)
set content of bin (1-D)
static int iy0EE(const int ism)
Definition: Numbers.cc:964
MonitorElement * me_o01_[18]
Some &quot;id&quot; conversions.
static std::string sEE(const int ism)
Definition: Numbers.cc:199
tuple histo
Definition: trackerHits.py:12
void beginRun(void)
BeginRun.
virtual ~EETriggerTowerClient()
Destructor.
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:2338
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:1270
MonitorElement * me_o02_[18]
Ecal Monitor Utils for Client.
MonitorElement * mel02_[18]
void analyze(void)
Analyze.
MonitorElement * mel01_[18]
void cleanup(void)
Cleanup.
static int ix0EE(const int ism)
Definition: Numbers.cc:946
tuple cout
Definition: gather_cfg.py:41
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:647
Definition: RunIOV.h:13
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:47
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)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237