CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorLEDMonitor.cc
Go to the documentation of this file.
4 
5 //***************************************************//
6 //********** CastorLEDMonitor ***********************//
7 //********** Author: Dmytro Volyanskyy ************//
8 //********** Date : 20.11.2008 (first version) ******//
9 //---------- last revision: 31.05.2011 (Panos Katsas)
10 //***************************************************//
11 
12 //==================================================================//
13 //======================= Constructor ==============================//
14 //==================================================================//
16  {
17 
18  doPerChannel_ = false;
19  sigS0_=0;
20  sigS1_=9;
21 
22  }
23 
24 //==================================================================//
25 //======================= Destructor ==============================//
26 //==================================================================//
28  {
29 
30  }
31 
32 //==========================================================//
33 //========================= setup ==========================//
34 //==========================================================//
35 
37  {
39 
40  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::setup (start)"<<std::endl;
41 
42  baseFolder_ = rootFolder_+"CastorLEDMonitor";
43 
45  if ( ps.getUntrackedParameter<bool>("LEDPerChannel", false) )
46  doPerChannel_ = true;
47 
48  sigS0_ = ps.getUntrackedParameter<int>("FirstSignalBin", 0);
49  sigS1_ = ps.getUntrackedParameter<int>("LastSignalBin", 9);
50  adcThresh_ = ps.getUntrackedParameter<double>("LED_ADC_Thresh", 0);
51  if(fVerbosity>1) std::cout << "LED Monitor threshold set to " << adcThresh_ << std::endl;
52  if(fVerbosity>1) std::cout << "LED Monitor signal window set to " << sigS0_ <<"-"<< sigS1_ << std::endl;
53 
54 
55  if(sigS0_<0)
56  {
57  if(fVerbosity>1) { std::cout << "CastorLEDMonitor::setup, illegal range for first sample: " << sigS0_ << std::endl; }
58  sigS0_=0;
59  }
60 
61  if(sigS1_>9)
62  {
63  if(fVerbosity>1) { std::cout << "CastorLEDMonitor::setup, illegal range for last sample: " << sigS1_ << std::endl; }
64  sigS1_=9;
65  }
66 
67  if(sigS0_ > sigS1_)
68  {
69  if(fVerbosity>1) { std::cout<< "CastorLEDMonitor::setup, illegal range for first: "<< sigS0_ << " and last sample: " << sigS1_ << std::endl; }
70  sigS0_=0; sigS1_=9;
71  }
72 
73  ievt_=0;
74 
75  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::setup (end)"<<std::endl;
76 
77  return;
78 }
79 
80 
81 //==========================================================//
82 //================== createFEDmap ==========================//
83 //==========================================================//
84 
85 void CastorLEDMonitor::createFEDmap(unsigned int fed){
86  fedIter = MEAN_MAP_SHAPE_DCC.find(fed);
87 
88  if(fedIter==MEAN_MAP_SHAPE_DCC.end()){
90  char name[256];
91 
92  sprintf(name,"DCC %d Mean Shape Map",fed);
93  MonitorElement* mean_shape = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
94  sprintf(name,"DCC %d RMS Shape Map",fed);
95  MonitorElement* rms_shape = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
96 
99 
100  sprintf(name,"DCC %d Mean Time Map",fed);
101  MonitorElement* mean_time = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
102  sprintf(name,"DCC %d RMS Time Map",fed);
103  MonitorElement* rms_time = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
105  RMS_MAP_TIME_DCC[fed] = rms_time;
106 
107  sprintf(name,"DCC %d Mean Energy Map",fed);
108  MonitorElement* mean_energy = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
109  sprintf(name,"DCC %d RMS Energy Map",fed);
110  MonitorElement* rms_energy = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
113  }
114 }
115 
116 
117 //=================================================================//
118 //========================== beginRun =============================//
119 //================================================================//
121  {
122  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::beginRun (start)"<<std::endl;
123 
124  if (m_dbe !=NULL)
125  {
127  meEVT_ = m_dbe->bookInt("LED Task Event Number");
128  meEVT_->Fill(ievt_);
129 
130  castHists.shapePED = m_dbe->book1D("Castor Ped Subtracted Pulse Shape","Castor Ped Subtracted Pulse Shape",10,-0.5,9.5);
131  castHists.shapeALL = m_dbe->book1D("Castor Average Pulse Shape","Castor Average Pulse Shape",10,-0.5,9.5);
132  castHists.energyALL = m_dbe->book1D("Castor Average Pulse Energy","Castor Average Pulse Energy",500,0,500);
133  castHists.timeALL = m_dbe->book1D("Castor Average Pulse Time","Castor Average Pulse Time",200,-1,10);
134  castHists.rms_shape = m_dbe->book1D("Castor LED Shape RMS Values","Castor LED Shape RMS Values",100,0,5);
135  castHists.mean_shape = m_dbe->book1D("Castor LED Shape Mean Values","Castor LED Shape Mean Values",100,-0.5,9.5);
136  castHists.rms_time = m_dbe->book1D("Castor LED Time RMS Values","Castor LED Time RMS Values",100,0,5);
137  castHists.mean_time = m_dbe->book1D("Castor LED Time Mean Values","Castor LED Time Mean Values",100,-1,10);
138  castHists.rms_energy = m_dbe->book1D("Castor LED Energy RMS Values","Castor LED Energy RMS Values",100,0,500);
139  castHists.mean_energy = m_dbe->book1D("Castor LED Energy Mean Values","Castor LED Energy Mean Values",100,0,1000);
140  }
141  else
142  {
143  if(fVerbosity>0) std::cout << "CastorLEDMonitor::beginRun - NO DQMStore service" << std::endl;
144  }
145 
146 
147  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::beginRun (end)"<<std::endl;
148  }
149 
150 
151 
152 //==========================================================//
153 //=================== processEvent ========================//
154 //==========================================================//
155 
157  {
158  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::processEvent (start)"<<std::endl;
159 
160  meEVT_->Fill(ievt_);
161 
162 
163  if(!m_dbe){
164  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
165  return;
166  }
167 
168  float vals[10];
169 
170 
171  if(castorDigis.size()>0) {
172 
173  for (CastorDigiCollection::const_iterator j=castorDigis.begin(); j!=castorDigis.end(); j++){
174  const CastorDataFrame digi = (const CastorDataFrame)(*j);
175 
179 
180  float energy=0;
181  float ts =0; float bs=0;
182  int maxi=0; float maxa=0;
183  for(int i=sigS0_; i<=sigS1_; i++){
184  if(digi.sample(i).adc()>maxa){maxa=digi.sample(i).adc(); maxi=i;}
185  }
186  for(int i=sigS0_; i<=sigS1_; i++){
187  float tmp1 =0;
188  int j1=digi.sample(i).adc();
189  tmp1 = (LedMonAdc2fc[j1]+0.5);
190  energy += tmp1-calibs_.pedestal(digi.sample(i).capid());
191  if(i>=(maxi-1) && i<=maxi+1){
192  ts += i*(tmp1-calibs_.pedestal(digi.sample(i).capid()));
193  bs += tmp1-calibs_.pedestal(digi.sample(i).capid());
194  }
195  }
196  if(energy<adcThresh_) continue;
197 
198  castHists.energyALL->Fill(energy);
199  if(bs!=0) castHists.timeALL->Fill(ts/bs);
200 
201  // if(ievt_%1000 == 0 ){
202  for (int i=0; i<digi.size(); i++) {
203  float tmp =0;
204  int j=digi.sample(i).adc();
205  tmp = (LedMonAdc2fc[j]+0.5);
206  castHists.shapeALL->Fill(i,tmp);
207  castHists.shapePED->Fill(i,tmp-calibs_.pedestal(digi.sample(i).capid()));
208  vals[i] = tmp-calibs_.pedestal(digi.sample(i).capid());
209  }
210  // }
211  //do per channel histograms once for each 100 events
212  if( doPerChannel_) perChanHists(digi.id(),vals,castHists.shape, castHists.time, castHists.energy, baseFolder_);
213  }
214  } else {
215  if(fVerbosity > 0) std::cout << "CastorLEDMonitor::processEvent NO Castor Digis !!!" << std::endl;
216  }
217 
218 
219  ievt_++;
220 
221  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::processEvent (end)"<<std::endl;
222 
223  return;
224 }
225 
226 
227 //==========================================================//
228 //=================== done ================================//
229 //==========================================================//
230 
233  return;
234 }
235 
236 
237 //==========================================================//
238 //========================= reset ==========================//
239 //==========================================================//
240 
242 
243  MonitorElement* unpackedFEDS = m_dbe->get("Castor/FEDs Unpacked");
244  if(unpackedFEDS){
245  for(int b=1; b<=unpackedFEDS->getNbinsX(); b++){
246  if(unpackedFEDS->getBinContent(b)>0){
247  createFEDmap(700+(b-1));
248  }
249  }
250  }
251 }
252 
253 
254 //==========================================================//
255 //=================== perChanHists ========================//
256 //==========================================================//
257 
259  std::map<HcalCastorDetId, MonitorElement*> &tShape,
260  std::map<HcalCastorDetId, MonitorElement*> &tTime,
261  std::map<HcalCastorDetId, MonitorElement*> &tEnergy,
262  std::string baseFolder){
263 
264  std::string type = "CastorLEDPerChannel";
265  if(m_dbe) m_dbe->setCurrentFolder(baseFolder+"/"+type);
266 
267  MonitorElement* me;
268  if(m_dbe==NULL) return;
269  meIter=tShape.begin();
270  meIter = tShape.find(DetID);
271 
272  if (meIter!=tShape.end()){
273  me= meIter->second;
274  if(me==NULL && fVerbosity>0) printf("CastorLEDAnalysis::perChanHists This histo is NULL!!??\n");
275  else{
276  float energy=0;
277  float ts =0; float bs=0;
278  int maxi=0; float maxa=0;
279  for(int i=sigS0_; i<=sigS1_; i++){
280  if(vals[i]>maxa){maxa=vals[i]; maxi=i;}
281  }
282  for(int i=sigS0_; i<=sigS1_; i++){
283  energy += vals[i];
284  if(i>=(maxi-1) && i<=maxi+1){
285  ts += i*vals[i];
286  bs += vals[i];
287  }
288  me->Fill(i,vals[i]);
289  }
290  me = tTime[DetID];
291  if(bs!=0) me->Fill(ts/bs);
292  me = tEnergy[DetID];
293  me->Fill(energy);
294  }
295  }
296  else{
297  char name[1024];
298  sprintf(name,"Castor LED Shape zside=%d module=%d sector=%d",DetID.zside(),DetID.module(),DetID.sector());
299  MonitorElement* insert1;
300  insert1 = m_dbe->book1D(name,name,10,-0.5,9.5);
301  float energy=0;
302  float ts =0; float bs=0;
303  int maxi=0; float maxa=0;
304  for(int i=sigS0_; i<=sigS1_; i++){
305  if(vals[i]>maxa){maxa=vals[i]; maxi=i;}
306  insert1->Fill(i,vals[i]);
307  }
308  for(int i=sigS0_; i<=sigS1_; i++){
309  energy += vals[i];
310  if(i>=(maxi-1) && i<=maxi+1){
311  ts += i*vals[i];
312  bs += vals[i];
313  }
314  }
315  tShape[DetID] = insert1;
316 
317  sprintf(name,"Castor LED Time zside=%d module=%d sector=%d",DetID.zside(),DetID.module(),DetID.sector());
318  MonitorElement* insert2 = m_dbe->book1D(name,name,100,0,10);
319  if(bs!=0) insert2->Fill(ts/bs);
320  tTime[DetID] = insert2;
321 
322 
323  sprintf(name,"Castor LED Energy zside=%d module=%d sector=%d",DetID.zside(),DetID.module(),DetID.sector());
324  MonitorElement* insert3 = m_dbe->book1D(name,name,500,0,500);
325  insert3->Fill(energy);
326  tEnergy[DetID] = insert3;
327 
328  }
329 
330  return;
331 
332 }
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::map< unsigned int, MonitorElement * > RMS_MAP_ENERGY_DCC
virtual void setup(const edm::ParameterSet &ps, DQMStore *dbe)
int sector() const
get the sector (1-16)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:971
std::map< unsigned int, MonitorElement * > RMS_MAP_SHAPE_DCC
int adc() const
get the ADC sample
Definition: HcalQIESample.h:22
const HcalQIESample & sample(int i) const
access a sample
std::vector< CastorDataFrame >::const_iterator const_iterator
std::map< unsigned int, MonitorElement * >::iterator fedIter
MonitorElement * meEVT_
#define NULL
Definition: scimark2.h:8
void createFEDmap(unsigned int fed)
int module() const
get the module (1-2 for EM, 1-12 for HAD)
std::map< HcalCastorDetId, MonitorElement * >::iterator meIter
MonitorElement * rms_energy
MonitorElement * mean_energy
void Fill(long long x)
std::map< unsigned int, MonitorElement * > MEAN_MAP_ENERGY_DCC
std::string baseFolder_
std::map< unsigned int, MonitorElement * > MEAN_MAP_TIME_DCC
MonitorElement * rms_time
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
int zside() const
get the z-side of the cell (1/-1)
int j
Definition: DBlmapReader.cc:9
MonitorElement * mean_shape
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1725
MonitorElement * mean_time
double pedestal(int fCapId) const
get pedestal for capid=0..3
const_iterator end() const
static const float LedMonAdc2fc[128]
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:26
double b
Definition: hdecay.h:120
void beginRun(const edm::EventSetup &iSetup)
MonitorElement * rms_shape
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void perChanHists(const HcalCastorDetId DetID, float *vals, std::map< HcalCastorDetId, MonitorElement * > &tShape, std::map< HcalCastorDetId, MonitorElement * > &tTime, std::map< HcalCastorDetId, MonitorElement * > &tEnergy, std::string baseFolder)
double getBinContent(int binx) const
get content of bin (1-D)
size_type size() const
std::map< unsigned int, MonitorElement * > RMS_MAP_TIME_DCC
int getNbinsX(void) const
get # of bins in X-axis
std::string rootFolder_
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
tuple cout
Definition: gather_cfg.py:121
std::map< unsigned int, MonitorElement * > MEAN_MAP_SHAPE_DCC
const HcalCastorDetId & id() const
struct CastorLEDMonitor::@277 castHists
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:878
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:1099
std::map< HcalCastorDetId, MonitorElement * > energy
int size() const
total number of samples in the digi
CastorCalibrations calibs_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:684
const_iterator begin() const