CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorChannelQualityMonitor.cc
Go to the documentation of this file.
4 
5 //***************************************************//
6 //********** CastorChannelQualityMonitor *******************//
7 //********** Author: Dmytro Volyanskyy ************//
8 //********** Date : 04.03.2010 (first version) ******//
9 //***************************************************//
13 
14 //==================================================================//
15 //======================= Constructor ==============================//
16 //==================================================================//
18  ievt_=0;
19  counter1=0;
20  counter2=0;
21 }
22 
23 //==================================================================//
24 //======================= Destructor ==============================//
25 //==================================================================//
26 
28 }
29 
30 
32 }
33 
34 
35 //==========================================================//
36 //========================= setup ==========================//
37 //==========================================================//
38 
40 
42  averageEnergyMethod_ = ps.getUntrackedParameter<bool>("averageEnergyMethod", true);
43  offline_ = ps.getUntrackedParameter<bool>("OfflineMode", false);
44  nThreshold_ = ps.getUntrackedParameter<double>("nThreshold", 0);
45  dThreshold_ = ps.getUntrackedParameter<double>("dThreshold", 0);
46 
47  // baseFolder_ = rootFolder_+"CastorChannelQualityMonitor";
48 
49  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::setup (start)" << std::endl;
50 
52  for (int row=0; row<14; row++) {
53  for (int col=0; col<16; col++){
54  aboveNoisyThreshold[row][col] = 0;
55  belowDThreshold[row][col] = 0;
56  energyArray[row][col] = 0;
57  aboveThr[row][col] = 0;
58  }
59  }
60 
62  ievt_=0; counter1=0; counter2=0; wcounter1=0.; wcounter2=0.;
64  fraction=0.;
66  status = -99; numOK = 0;
68  iRecHit=false;
70  averageEnergy=0.;
71 
72  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::setup (end)" << std::endl;
73 
74  return;
75 }
76 
77 
78 //=================================================================//
79 //========================== beginRun =============================//
80 //================================================================//
82  {
83  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::beginRun (start)" << std::endl;
84 
85  if ( m_dbe !=NULL )
86  {
88  m_dbe->setCurrentFolder(rootFolder_+"CastorChannelQuality");
89  reportSummary = m_dbe->bookFloat("RecHit Energy based reportSummary");
90  reportSummaryMap = m_dbe->book2D("RecHitEnergyBasedSummaryMap","RecHitEnergyBasedSummaryMap",14,0.0,14.0,16,0.0,16.0);
91  if(offline_)
92  {
94  h_reportSummaryMap->SetOption("textcolz");
95  h_reportSummaryMap->GetXaxis()->SetTitle("module");
96  h_reportSummaryMap->GetYaxis()->SetTitle("sector");
97  }
98 
99  overallStatus = m_dbe->bookFloat("RecHit Energy based fraction of good channels");
100 
102  fraction=0.;
104 
105  }
106  else
107  {
108  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::beginRun - NO DQMStore service" << std::endl;
109  }
110 
111 
112  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::beginRun (end)" << std::endl;
113 
114 
115  return;
116 }
117 
118 
119 
120 //==========================================================//
121 //================== processEvent ==========================//
122 //==========================================================//
124  {
125  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::processEvent (begin)" << std::endl;
126 
127  if(!m_dbe) {
128  if(fVerbosity>0) std::cout <<"CastorChannelQualityMonitor::processEvent => DQMStore is not instantiated !!!"<<std::endl;
129  return;
130  }
131 
132  if(fVerbosity>1){
133  std::cout << "CastorChannelQualityMonitor: Noisy Threshold is set to: "<< nThreshold_ << std::endl;
134  std::cout << "CastorChannelQualityMonitor: Dead Threshold is set to: " << dThreshold_ << std::endl;
135  }
136 
137  castorModule = -1; castorSector = -1; castorEnergy = -1.;
138 
139  if (castorHits.size()>0) iRecHit=true;
140  else iRecHit=false;
141 
142 
144  for(CastorRecHitCollection::const_iterator recHit = castorHits.begin(); recHit != castorHits.end(); ++recHit){
145 
146  HcalCastorDetId CastorID = HcalCastorDetId(recHit->id());
147  if(fVerbosity>1) std::cout << "Castor ID = " << CastorID << std::endl;
148  CastorRecHitCollection::const_iterator rh = castorHits.find(CastorID);
150  castorModule = CastorID.module();
151  castorSector = CastorID.sector();
152  castorEnergy = rh->energy();
153  //if(ievt_ % 1000 == 0) std::cout << "==> module=" << module << " sector=" << sector << " energy= "<< energy << std::endl;
154  iRecHit=true;
155 
161  if(castorEnergy>1) { //if(castorEnergy>0) {
164  }
165 
166  }
167 
168 
169 
170 
172  ievt_++;
173 
174 
178 
179  // if( (ievt_ == 25 || ievt_ % 500 == 0) && iRecHit ) {
180  // no particular event selection done
181  if( iRecHit ) {
182 
183  status = -99; numOK = 0;
184 
186  // if(offline_) reportSummaryMap->Reset();
187 
188 
190  for (int sector=0; sector<16; sector++){
191  for (int module=0; module<14; module++){
192 
193 
195 
196  if(aboveThr[module][sector] >0)
197  averageEnergy= energyArray[module][sector]/double(aboveThr[module][sector]); // calculate the average energy in each channel
198  else averageEnergy=0;
199 
201  if( averageEnergy > nThreshold_ ) status= 0;
202  if( averageEnergy < dThreshold_ ) { status= -1;
203  if(fVerbosity>1) std::cout << "!!! dChannels ===> module="<< module+1 << " sector="<< sector+1 << std::endl;
204  }
205  if( averageEnergy < nThreshold_ && averageEnergy > dThreshold_ ) status= 1;
206 
207  if(fVerbosity>1)
208  std::cout << "===> module="<< module+1 << " sector="<< sector+1 <<" *** average Energy="
209  << averageEnergy << " => energy=" << energyArray[module][sector] << " events="
210  << ievt_ << " aboveThr="<< double(aboveThr[module][sector]) <<std::endl;
211  }
212 
213 
214  else{
215  //-- look at the arrays
216  counter1= aboveNoisyThreshold[module][sector]; //counter1 defines how many times the energy was above a noisythreshold
217  counter2= belowDThreshold[module][sector]; //counter2 defines how many times the energy was below a dthreshold
218  wcounter1= double(counter1)/double(ievt_);
219  wcounter2= double(counter2)/double(ievt_);
221  if( wcounter1 > 0.85 ) status= 0;
222  if( wcounter2 > 0.85 ) {status= -1;
223  if(fVerbosity>1) std::cout << "!!! dChannels ===> module="<< module+1 << " sector="<< sector+1 << std::endl;
224  }
225  if( wcounter1 < 0.85 && wcounter2 < 0.85 ) status= 1;
226 
227  if(fVerbosity>1)
228  std::cout << "===> module="<< module+1 << " sector="<< sector+1 <<" *** counter1="
229  << counter1 << " => counter2=" << counter2 << " events="<< ievt_
230  << " wcounter1=" << wcounter1 << " wcounter2=" << wcounter2
231  << " *** ==> STATUS=" << status <<std::endl;
232  }
233 
235  // reportSummaryMap->Fill(module,sector,status);
236  reportSummaryMap->getTH2F()->SetBinContent(module+1,sector+1,double(status));
237  if (status == 1) numOK++;
238 
239  }
240  }
242  fraction=double(numOK)/224;
244  }
245 
246  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::processEvent (end)" << std::endl;
247 
248  return;
249 }
250 
T getUntrackedParameter(std::string const &, T const &) const
virtual void setup(const edm::ParameterSet &ps, DQMStore *dbe)
int sector() const
get the sector (1-16)
std::vector< CastorRecHit >::const_iterator const_iterator
#define NULL
Definition: scimark2.h:8
int module() const
get the module (1-2 for EM, 1-12 for HAD)
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:891
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
void Fill(long long x)
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
const_iterator end() const
void processEvent(const CastorRecHitCollection &castorHits)
iterator find(key_type k)
size_type size() const
std::string rootFolder_
tuple cout
Definition: gather_cfg.py:121
TH2F * getTH2F(void) const
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:1082
int col
Definition: cuy.py:1008
Definition: vlib.h:208
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
const_iterator begin() const
Definition: Run.h:41