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  if ( m_dbe !=NULL ) {
49  m_dbe->setCurrentFolder(rootFolder_+"CastorChannelQuality");
50  reportSummary = m_dbe->bookFloat("RecHit Energy based reportSummary");
51  reportSummaryMap = m_dbe->book2D("RecHitEnergyBasedSummaryMap","RecHitEnergyBasedSummaryMap",14,0.0,14.0,16,0.0,16.0);
52  if(offline_){
54  h_reportSummaryMap->SetOption("textcolz");
55  h_reportSummaryMap->GetXaxis()->SetTitle("module");
56  h_reportSummaryMap->GetYaxis()->SetTitle("sector");
57  }
58 
59  overallStatus = m_dbe->bookFloat("RecHit Energy based fraction of good channels");
60  }
61 
62  else{
63  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::setup - NO DQMStore service" << std::endl;
64  }
65 
66  // baseFolder_ = rootFolder_+"CastorChannelQualityMonitor";
67 
68  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::setup (start)" << std::endl;
69 
71  for (int row=0; row<14; row++) {
72  for (int col=0; col<16; col++){
73  aboveNoisyThreshold[row][col] = 0;
74  belowDThreshold[row][col] = 0;
75  energyArray[row][col] = 0;
76  aboveThr[row][col] = 0;
77  }
78  }
79 
81  ievt_=0; counter1=0; counter2=0; wcounter1=0.; wcounter2=0.;
83  fraction=0.;
86  status = -99; numOK = 0;
88  iRecHit=false;
90  averageEnergy=0.;
91 
92  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::setup (end)" << std::endl;
93 
94  return;
95 }
96 
97 
98 
99 
100 //==========================================================//
101 //================== processEvent ==========================//
102 //==========================================================//
104 
105  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor::processEvent !!!" << std::endl;
106 
107  if(!m_dbe) {
108  if(fVerbosity>0) std::cout <<"CastorChannelQualityMonitor::processEvent => DQMStore is not instantiated !!!"<<std::endl;
109  return;
110  }
111 
112  if(fVerbosity>0){
113  std::cout << "CastorChannelQualityMonitor: Noisy Threshold is set to: "<< nThreshold_ << std::endl;
114  std::cout << "CastorChannelQualityMonitor: Dead Threshold is set to: " << dThreshold_ << std::endl;
115  }
116 
117  castorModule = -1; castorSector = -1; castorEnergy = -1.;
118 
119  if (castorHits.size()>0) iRecHit=true;
120  else iRecHit=false;
121 
122 
124  for(CastorRecHitCollection::const_iterator recHit = castorHits.begin(); recHit != castorHits.end(); ++recHit){
125 
126  HcalCastorDetId CastorID = HcalCastorDetId(recHit->id());
127  if(fVerbosity>0) std::cout << "Castor ID = " << CastorID << std::endl;
128  CastorRecHitCollection::const_iterator rh = castorHits.find(CastorID);
130  castorModule = CastorID.module();
131  castorSector = CastorID.sector();
132  castorEnergy = rh->energy();
133  //if(ievt_ % 1000 == 0) std::cout << "==> module=" << module << " sector=" << sector << " energy= "<< energy << std::endl;
134  iRecHit=true;
135 
141  if(castorEnergy>1) { //if(castorEnergy>0) {
144  }
145 
146  }
147 
148 
149 
150 
152  ievt_++;
153 
154 
158 
159  // if( (ievt_ == 25 || ievt_ % 500 == 0) && iRecHit ) {
160  // no particular event selection done
161  if( iRecHit ) {
162 
163  status = -99; numOK = 0;
164 
166  // if(offline_) reportSummaryMap->Reset();
167 
168 
170  for (int sector=0; sector<16; sector++){
171  for (int module=0; module<14; module++){
172 
173 
175 
176  if(aboveThr[module][sector] >0)
177  averageEnergy= energyArray[module][sector]/double(aboveThr[module][sector]); // calculate the average energy in each channel
178  else averageEnergy=0;
179 
181  if( averageEnergy > nThreshold_ ) status= 0;
182  if( averageEnergy < dThreshold_ ) { status= -1;
183  if(fVerbosity>0) std::cout << "!!! dChannels ===> module="<< module+1 << " sector="<< sector+1 << std::endl;
184  }
185  if( averageEnergy < nThreshold_ && averageEnergy > dThreshold_ ) status= 1;
186 
187  if(fVerbosity>0)
188  std::cout << "===> module="<< module+1 << " sector="<< sector+1 <<" *** average Energy="
189  << averageEnergy << " => energy=" << energyArray[module][sector] << " events="
190  << ievt_ << " aboveThr="<< double(aboveThr[module][sector]) <<std::endl;
191  }
192 
193 
194  else{
195  //-- look at the arrays
196  counter1= aboveNoisyThreshold[module][sector]; //counter1 defines how many times the energy was above a noisythreshold
197  counter2= belowDThreshold[module][sector]; //counter2 defines how many times the energy was below a dthreshold
198  wcounter1= double(counter1)/double(ievt_);
199  wcounter2= double(counter2)/double(ievt_);
201  if( wcounter1 > 0.85 ) status= 0;
202  if( wcounter2 > 0.85 ) {status= -1;
203  if(fVerbosity>0) std::cout << "!!! dChannels ===> module="<< module+1 << " sector="<< sector+1 << std::endl;
204  }
205  if( wcounter1 < 0.85 && wcounter2 < 0.85 ) status= 1;
206 
207  if(fVerbosity>0)
208  std::cout << "===> module="<< module+1 << " sector="<< sector+1 <<" *** counter1="
209  << counter1 << " => counter2=" << counter2 << " events="<< ievt_
210  << " wcounter1=" << wcounter1 << " wcounter2=" << wcounter2
211  << " *** ==> STATUS=" << status <<std::endl;
212  }
213 
215  // reportSummaryMap->Fill(module,sector,status);
216  reportSummaryMap->getTH2F()->SetBinContent(module+1,sector+1,double(status));
217  if (status == 1) numOK++;
218 
219  }
220  }
222  fraction=double(numOK)/224;
224  }
225 
226 
227  return;
228 }
229 
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< T >::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:654
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:845
Definition: vlib.h:209
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
const_iterator begin() const