CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorPSMonitor.cc
Go to the documentation of this file.
4 
10 
24 
29 
32 
35 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" //-- CastorRecHitCollection
36 
37 //***************************************************//
38 //********** CastorPSMonitor: *******************//
39 //********** Author: D.Volyanskyy/I.Katkov *********//
40 //********** Date : 03.03.2010 (first version) ******//
41 //***************************************************//
45 
46 
47 //==================================================================//
48 //======================= Constructor ==============================//
49 //==================================================================//
51  doPerChannel_ = true;
52  ievt_=0;
55  status=-99;
56  statusRS=-99;
57  statusSaturated=-99;
58 }
59 
60 //==================================================================//
61 //======================= Destructor ==============================//
62 //==================================================================//
64 }
65 
67 }
68 
69 //==========================================================//
70 //========================= setup ==========================//
71 //==========================================================//
72 
74 
76  baseFolder_ = rootFolder_+"CastorPSMonitor";
77 
79  numberSigma_ = ps.getUntrackedParameter<double>("numberSigma", 1.5);
80  thirdRegionThreshold_ = ps.getUntrackedParameter<double>("thirdRegionThreshold", 300);
81  saturatedThreshold_ = ps.getUntrackedParameter<double>("saturatedThreshold", 0.05); //-- fraction of events in which chargeTS > 127 ADC
82  offline_ = ps.getUntrackedParameter<bool>("OfflineMode", false);
83 
84  if(fVerbosity>0) std::cout << "CastorPSMonitor::setup (start)" << std::endl;
85 
86  ievt_=0; firstTime_ = true;
89  numOK = 0;
90  fraction=0.;
91 
93  for (int row=0; row<14; row++){
94  for (int col=0; col<16; col++){
95  sumDigiForEachChannel[row][col] = 0;
96  saturatedMap [row][col] = 0;
97  }
98  }
99 
100  if ( m_dbe !=NULL ) {
102 
104  meEvt_ = m_dbe->bookInt("PS Event Number");
105  castorDigiHists.meDigi_pulseBX = m_dbe->book1D("CASTOR average pulse in bunch crossings","CASTOR average pulse in bunch crossings", 3600, -0.5, 3600);
106  TH1F* h_meDigi_pulseBX = castorDigiHists.meDigi_pulseBX->getTH1F();
107  h_meDigi_pulseBX->GetXaxis()->SetTitle("orbit");
108 
109  //---- Pulse Shape per sector
110  char name[1024];
111  for(int i=0; i<16; i++){
112  sprintf(name,"Castor Pulse Shape for sector=%d (in all 14 modules)",i+1);
113  PSsector[i] = m_dbe->book1D(name,name,140,-0.5,139.5);
114  }
115 
117  DigiOccupancyMap = m_dbe->book2D("CASTOR Digi Occupancy Map","CASTOR Digi Occupancy Map",14,0.0,14.0,16,0.0,16.0);
119  ChannelSummaryMap = m_dbe->book2D("CASTOR Digi ChannelSummaryMap","CASTOR Digi ChannelSummaryMap",14,0.0,14.0,20,0.0,20.0); // put 20 instead of 16 to get some space for the legend
120 
123  SaturationSummaryMap = m_dbe->book2D("CASTOR Digi SaturationSummaryMap","CASTOR Digi SaturationSummaryMap",14,0.0,14.0,20,0.0,20.0); // put 20 instead of 16 to get some space for the legend
124 
125 
126 
128  m_dbe->setCurrentFolder(rootFolder_+"EventInfo");
129  reportSummary = m_dbe->bookFloat("reportSummary");
130  reportSummaryMap = m_dbe->book2D("reportSummaryMap","CASTOR reportSummaryMap",14,0.0,14.0,16,0.0,16.0);
131  if(offline_){
133  h_reportSummaryMap->SetOption("textcolz");
134  h_reportSummaryMap->GetXaxis()->SetTitle("module");
135  h_reportSummaryMap->GetYaxis()->SetTitle("sector");
136  }
137  m_dbe->setCurrentFolder(rootFolder_+"EventInfo/reportSummaryContents");
138  overallStatus = m_dbe->bookFloat("fraction of good channels");
140  }
141 
142  else{
143  if(fVerbosity>0) std::cout << "CastorPSMonitor::setup - NO DQMStore service" << std::endl;
144  }
145 
146  if(fVerbosity>0) std::cout << "CastorPSMonitor::setup (end)" << std::endl;
147 
148  return;
149 }
150 
151 //==========================================================//
152 //================== processEvent ==========================//
153 //==========================================================//
154 
155 void CastorPSMonitor::processEvent(const CastorDigiCollection& castorDigis, const CastorDbService& conditions, std::vector<HcalGenericDetId> listEMap, int iBunch, float PedSigmaInChannel[14][16])
156  {
157 
158 
159  if(fVerbosity>0) std::cout << "==>CastorPSMonitor::processEvent !!!" << std::endl;
160 
161  if(!m_dbe) {
162  if(fVerbosity>0) std::cout <<"CastorPSMonitor::processEvent => DQMStore not instantiated !!!"<<std::endl;
163  return;
164  }
165 
166  meEvt_->Fill(ievt_);
167 
169  ievt_++;
170 
171  status = -99; statusRS = -99; statusSaturated=-99;
172 
174  const CastorQIEShape* shape = conditions.getCastorShape();
175 
176  if(firstTime_)
177  {
178  //===> show the array of sigmas
179  for (int i=0; i<14; i++){
180  for (int k=0; k<16; k++){
181  if(fVerbosity>0) std::cout<< "module:"<<i+1<< " sector:"<<k+1<< " Sigma=" << PedSigmaInChannel[i][k] << std::endl;
182  }
183  }
184  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++)
185  {
186  HcalGenericDetId mygenid(it->rawId());
187  if(mygenid.isHcalCastorDetId())
188  {
189  NewBunch myBunch;
190  HcalCastorDetId chanid(mygenid.rawId());
191  myBunch.detid = chanid;
192  myBunch.usedflag = false;
193  std::string type;
194  type = "CASTOR";
195  for(int i = 0; i != 20; i++)
196  {
197  myBunch.tsCapId[i] = 0;
198  myBunch.tsAdc[i] = 0;
199  myBunch.tsfC[i] = 0.0;
200  }
201  Bunches_.push_back(myBunch);
202  }
203  }
204 
205  firstTime_ = false;
206  }
207 
208 
209  if(castorDigis.size()>0) {
211  int firstTS = 0;
212  int lastTS = 9;
213  std::vector<NewBunch>::iterator bunch_it;
214  int numBunches = 0;
215  bool firstDigi = true;
216  bool saturated = false;
217 
219  for(CastorDigiCollection::const_iterator j = castorDigis.begin(); j != castorDigis.end(); j++)
220  {
221 
222  const CastorDataFrame digi = (const CastorDataFrame)(*j);
223  if ( lastTS+1 > digi.size() ) lastTS = digi.size()-1;
224  for(bunch_it = Bunches_.begin(); bunch_it != Bunches_.end(); bunch_it++)
225  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
226  bunch_it->usedflag = true;
227 
228  numBunches++;
229  //
230  //---- Skip noisy channels present in 2009 beam data:
231  // if ( (bunch_it->detid.sector() == 16 && bunch_it->detid.module() == 6) ||
232  // (bunch_it->detid.sector() == 3 && bunch_it->detid.module() == 8) ||
233  // (bunch_it->detid.sector() == 8 && bunch_it->detid.module() == 8) ) continue;
234  //
235 
236  if ( lastTS+1 > digi.size() ) lastTS = digi.size()-1;
237 
239  const CastorCalibrations& calibrations=conditions.getCastorCalibrations(digi.id().rawId());
240 
242  double sumDigi=0.; double sumDigiADC=0.; int bxTS=-9999; saturated = false;
243 
245  for(int ts = firstTS; ts != lastTS+1; ts++)
246  {
247  if (firstDigi) {
248  bxTS = (iBunch+ts-1-digi.presamples());
249  if ( bxTS < 0 ) bxTS += 3563;
250  bxTS = ( bxTS % 3563 ) + 1;
251  if(fVerbosity>0) std::cout << "!!! " << bxTS << " " << iBunch <<" "<< ts << " " << digi.presamples() << std::endl;
252  }
253 
254  const CastorQIECoder* coder = conditions.getCastorCoder(digi.id().rawId());
255  bunch_it->tsCapId[ts] = digi.sample(ts).capid();
256  bunch_it->tsAdc[ts] = digi.sample(ts).adc();
257 
259  double charge_fC = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
260 
262  bunch_it->tsfC[ts] = charge_fC - calibrations.pedestal(digi.sample(ts).capid());
264  castorDigiHists.meDigi_pulseBX->Fill(static_cast<double>(bxTS),(bunch_it->tsfC[ts])/224.);
266 
267  // PK: do not normalize histograms
268  // PSsector[bunch_it->detid.sector()-1]->Fill(10*(bunch_it->detid.module()-1)+ts, bunch_it->tsfC[ts]/double(ievt_));
269  PSsector[bunch_it->detid.sector()-1]->Fill(10*(bunch_it->detid.module()-1)+ts, bunch_it->tsfC[ts]);
270 
272  sumDigi += bunch_it->tsfC[ts]; //std::cout<< " signal(fC) in TS:"<<ts << " =" << bunch_it->tsfC[ts] << std::endl;
274  sumDigiADC += bunch_it->tsAdc[ts]; //std::cout<< " signal(ADC) in TS:"<<ts << " =" << bunch_it->tsAdc[ts] << std::endl;
275 
277  if(bunch_it->tsAdc[ts]>126.95) {
278  saturated = true;
279  if(fVerbosity>0)
280  std::cout<< "WARNING: ==> Module:" << bunch_it->detid.module() << " Sector:" << bunch_it->detid.sector() << " SATURATED !!! in TS:"<< ts <<std::endl;
281  }
282 
283  } //-- end of the loop for time slices
284 
286  sumDigiForEachChannel[bunch_it->detid.module()-1][bunch_it->detid.sector()-1] += sumDigi;
287 
289  if(saturated) saturatedMap[bunch_it->detid.module()-1][bunch_it->detid.sector()-1] += 1;
290 
292  DigiOccupancyMap->Fill(bunch_it->detid.module()-1,bunch_it->detid.sector()-1, double(sumDigi/10)); //std::cout<< "=====> sumDigi=" << sumDigi << std::endl;
293 
294 
295  if(fVerbosity>0){
296  std::cout<< "==> Module:" << bunch_it->detid.module() << " Sector:" << bunch_it->detid.sector() << std::endl;
297  std::cout<< "==> Total charge in fC:" << sumDigi << std::endl;
298  std::cout<< "==> Total charge in ADC:" << sumDigiADC << std::endl;
299  }
300 
301  firstDigi = false;
302  } //-- end of the loop over digis
303 
304 
305 
306 
307 
311 
312 
313  // if( ievt_ == 25 || ievt_ % 500 == 0 ) { // no event selection - get all events
314 
315  numOK = 0;
316 
318  for (int sector=0; sector<16; sector++){
319  for (int module=0; module<14; module++){
320 
322  firstRegionThreshold_ = (-1)*(numberSigma_*PedSigmaInChannel[module][sector]);
323  secondRegionThreshold_ = numberSigma_*PedSigmaInChannel[module][sector] ;
324 
325 
327  if(double(sumDigiForEachChannel[module][sector]/(10*ievt_)) < firstRegionThreshold_ )
328  { status = -1.; statusRS=0.; }
329 
332  { status = 0.25; statusRS=0.95; }
333 
336  { status = 1.; statusRS=1.0; }
337 
338  //---- leave it out for the time being
340  // if(double(sumDigiForEachChannel[module][sector]/(10*ievt_)) > thirdRegionThreshold_ )
341  // { status = -0.25; statusRS=0.88 ; }
342 
343  //-- define the fraction of saturated events for a particular channel
344  double fractionSaturated = double(saturatedMap[module][sector])/double(ievt_) ;
346  if(fVerbosity>0) std::cout<< "==> module: " << module << " sector: " << sector << " ==> N_saturation:" << saturatedMap[module][sector] << " events:"<< ievt_ << " fraction:" << fractionSaturated << std::endl;
347 
348  if( fractionSaturated > saturatedThreshold_ )
349  { status = -0.25; statusRS=0.88 ; statusSaturated=-1.0; }
350 
352  if( saturatedMap[module][sector] > 0 && fractionSaturated < saturatedThreshold_ )
353  { statusSaturated= 0; }
354 
356  if( saturatedMap[module][sector] == 0 )
357  { statusSaturated= 1; }
358 
360  ChannelSummaryMap->getTH2F()->SetBinContent(module+1,sector+1,status);
361 
363  reportSummaryMap->getTH2F()->SetBinContent(module+1,sector+1,statusRS);
364 
366  SaturationSummaryMap->getTH2F()->SetBinContent(module+1,sector+1,double(statusSaturated));
367 
369  if ( statusRS > 0.9) numOK++;
370 
371  } //-- end of the loop over the modules
372  } //-- end of the loop over the sectors
373 
375  fraction=double(numOK)/224;
377 
378  // } //-- end of if for the number of events // update ( PK ):
379 
380 
382  for (int sector=16; sector<20; sector++){
383  for (int module=0; module<14; module++){
384  ChannelSummaryMap->getTH2F()->SetBinContent(module+1,sector+1,99);
385  }
386  }
388  for (int sector=16; sector<20; sector++){
389  for (int module=0; module<14; module++){
390  SaturationSummaryMap->getTH2F()->SetBinContent(module+1,sector+1, 99);
391  }
392  }
393 
394 
395 
396 
397 
398  } //-- end of the if castDigi
399 
400  else { if(fVerbosity>0) std::cout<<"CastorPSMonitor::processEvent NO Castor Digis !!!"<<std::endl; }
401 
402 
403  if (showTiming) {
404  cpu_timer.stop(); std::cout << " TIMER::CastorPS -> " << cpu_timer.cpuTime() << std::endl;
406  }
407 
408 
409  return;
410 }
411 
412 
413 
414 
415 
416 
417 
418 
419 
420 
421 
type
Definition: HCALResponse.h:22
std::vector< NewBunch > Bunches_
T getUntrackedParameter(std::string const &, T const &) const
struct CastorPSMonitor::@187 castorDigiHists
int i
Definition: DBlmapReader.cc:9
edm::CPUTimer cpu_timer
virtual void setup(const edm::ParameterSet &ps, DQMStore *dbe)
void start()
Definition: CPUTimer.cc:74
TH2F * h_reportSummaryMap
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
MonitorElement * SaturationSummaryMap
MonitorElement * DigiOccupancyMap
int adc() const
get the ADC sample
Definition: HcalQIESample.h:24
const HcalQIESample & sample(int i) const
access a sample
MonitorElement * meEvt_
std::vector< T >::const_iterator const_iterator
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
double tsfC[20]
Definition: CastorBunch.h:13
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
MonitorElement * reportSummary
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
void Fill(long long x)
HcalCastorDetId detid
Definition: CastorBunch.h:8
double sumDigiForEachChannel[14][16]
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::string baseFolder_
double saturatedThreshold_
int saturatedMap[14][16]
const CastorQIEShape * getCastorShape() const
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
double thirdRegionThreshold_
int j
Definition: DBlmapReader.cc:9
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
double tsCapId[20]
Definition: CastorBunch.h:10
MonitorElement * ChannelSummaryMap
bool usedflag
Definition: CastorBunch.h:9
Times stop()
Definition: CPUTimer.cc:94
double secondRegionThreshold_
int k[5][pyjets_maxn]
double pedestal(int fCapId) const
get pedestal for capid=0..3
const_iterator end() const
double cpuTime() const
Definition: CPUTimer.cc:157
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:28
double firstRegionThreshold_
MonitorElement * reportSummaryMap
size_type size() const
double tsAdc[20]
Definition: CastorBunch.h:11
std::string rootFolder_
tuple cout
Definition: gather_cfg.py:121
MonitorElement * overallStatus
std::map< int, MonitorElement * > PSsector
TH2F * getTH2F(void) const
const HcalCastorDetId & id() const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:624
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
int size() const
total number of samples in the digi
Definition: vlib.h:209
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void processEvent(const CastorDigiCollection &castorDigis, const CastorDbService &conditions, std::vector< HcalGenericDetId > listEMap, int iBunch, float PedSigmaInChannel[14][16])
const_iterator begin() const
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const