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  doPerChannel_ = false;
17  sigS0_=0;
18  sigS1_=9;
19 }
20 
21 //==================================================================//
22 //======================= Destructor ==============================//
23 //==================================================================//
25 
26 
27 //==========================================================//
28 //========================= setup ==========================//
29 //==========================================================//
30 
32 
34 
35  baseFolder_ = rootFolder_+"CastorLEDMonitor";
36 
38  if ( ps.getUntrackedParameter<bool>("LEDPerChannel", false) )
39  doPerChannel_ = true;
40 
41  sigS0_ = ps.getUntrackedParameter<int>("FirstSignalBin", 0);
42  sigS1_ = ps.getUntrackedParameter<int>("LastSignalBin", 9);
43  adcThresh_ = ps.getUntrackedParameter<double>("LED_ADC_Thresh", 0);
44  std::cout << "LED Monitor threshold set to " << adcThresh_ << std::endl;
45  std::cout << "LED Monitor signal window set to " << sigS0_ <<"-"<< sigS1_ << std::endl;
46 
47  if(sigS0_<0){
48  std::cout << "CastorLEDMonitor::setup, illegal range for first sample: " << sigS0_ << std::endl;
49  sigS0_=0;
50  }
51  if(sigS1_>9){
52  std::cout << "CastorLEDMonitor::setup, illegal range for last sample: " << sigS1_ << std::endl;
53  sigS1_=9;
54  }
55 
56  if(sigS0_ > sigS1_){
57  std::cout<< "CastorLEDMonitor::setup, illegal range for first: "<< sigS0_ << " and last sample: " << sigS1_ << std::endl;
58  sigS0_=0; sigS1_=9;
59  }
60 
61  ievt_=0;
62 
63  if ( m_dbe ) {
64 
66  meEVT_ = m_dbe->bookInt("LED Task Event Number");
67  meEVT_->Fill(ievt_);
68 
69  castHists.shapePED = m_dbe->book1D("Castor Ped Subtracted Pulse Shape","Castor Ped Subtracted Pulse Shape",10,-0.5,9.5);
70  castHists.shapeALL = m_dbe->book1D("Castor Average Pulse Shape","Castor Average Pulse Shape",10,-0.5,9.5);
71  castHists.energyALL = m_dbe->book1D("Castor Average Pulse Energy","Castor Average Pulse Energy",500,0,500);
72  castHists.timeALL = m_dbe->book1D("Castor Average Pulse Time","Castor Average Pulse Time",200,-1,10);
73  castHists.rms_shape = m_dbe->book1D("Castor LED Shape RMS Values","Castor LED Shape RMS Values",100,0,5);
74  castHists.mean_shape = m_dbe->book1D("Castor LED Shape Mean Values","Castor LED Shape Mean Values",100,-0.5,9.5);
75  castHists.rms_time = m_dbe->book1D("Castor LED Time RMS Values","Castor LED Time RMS Values",100,0,5);
76  castHists.mean_time = m_dbe->book1D("Castor LED Time Mean Values","Castor LED Time Mean Values",100,-1,10);
77  castHists.rms_energy = m_dbe->book1D("Castor LED Energy RMS Values","Castor LED Energy RMS Values",100,0,500);
78  castHists.mean_energy = m_dbe->book1D("Castor LED Energy Mean Values","Castor LED Energy Mean Values",100,0,1000);
79 
80  }
81 
82  return;
83 }
84 
85 
86 //==========================================================//
87 //================== createFEDmap ==========================//
88 //==========================================================//
89 
90 void CastorLEDMonitor::createFEDmap(unsigned int fed){
91  fedIter = MEAN_MAP_SHAPE_DCC.find(fed);
92 
93  if(fedIter==MEAN_MAP_SHAPE_DCC.end()){
95  char name[256];
96 
97  sprintf(name,"DCC %d Mean Shape Map",fed);
98  MonitorElement* mean_shape = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
99  sprintf(name,"DCC %d RMS Shape Map",fed);
100  MonitorElement* rms_shape = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
101 
104 
105  sprintf(name,"DCC %d Mean Time Map",fed);
106  MonitorElement* mean_time = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
107  sprintf(name,"DCC %d RMS Time Map",fed);
108  MonitorElement* rms_time = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
110  RMS_MAP_TIME_DCC[fed] = rms_time;
111 
112  sprintf(name,"DCC %d Mean Energy Map",fed);
113  MonitorElement* mean_energy = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
114  sprintf(name,"DCC %d RMS Energy Map",fed);
115  MonitorElement* rms_energy = m_dbe->book2D(name,name,24,0.5,24.5,15,0.5,15.5);
118  }
119 }
120 
121 
122 //==========================================================//
123 //========================= reset ==========================//
124 //==========================================================//
125 
127 
128  MonitorElement* unpackedFEDS = m_dbe->get("Castor/FEDs Unpacked");
129  if(unpackedFEDS){
130  for(int b=1; b<=unpackedFEDS->getNbinsX(); b++){
131  if(unpackedFEDS->getBinContent(b)>0){
132  createFEDmap(700+(b-1));
133  }
134  }
135  }
136 }
137 
138 
139 //==========================================================//
140 //=================== processEvent ========================//
141 //==========================================================//
142 
144 
145 
146  meEVT_->Fill(ievt_);
147 
148 
149  if(!m_dbe){
150  if(fVerbosity>0) std::cout<<"CastorLEDMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
151  return;
152  }
153  float vals[10];
154 
155 
156  if(castorDigis.size()>0) {
157 
158  for (CastorDigiCollection::const_iterator j=castorDigis.begin(); j!=castorDigis.end(); j++){
159  const CastorDataFrame digi = (const CastorDataFrame)(*j);
160 
164 
165  float energy=0;
166  float ts =0; float bs=0;
167  int maxi=0; float maxa=0;
168  for(int i=sigS0_; i<=sigS1_; i++){
169  if(digi.sample(i).adc()>maxa){maxa=digi.sample(i).adc(); maxi=i;}
170  }
171  for(int i=sigS0_; i<=sigS1_; i++){
172  float tmp1 =0;
173  int j1=digi.sample(i).adc();
174  tmp1 = (LedMonAdc2fc[j1]+0.5);
175  energy += tmp1-calibs_.pedestal(digi.sample(i).capid());
176  if(i>=(maxi-1) && i<=maxi+1){
177  ts += i*(tmp1-calibs_.pedestal(digi.sample(i).capid()));
178  bs += tmp1-calibs_.pedestal(digi.sample(i).capid());
179  }
180  }
181  if(energy<adcThresh_) continue;
182 
183  castHists.energyALL->Fill(energy);
184  if(bs!=0) castHists.timeALL->Fill(ts/bs);
185 
186  // if(ievt_%1000 == 0 ){
187  for (int i=0; i<digi.size(); i++) {
188  float tmp =0;
189  int j=digi.sample(i).adc();
190  tmp = (LedMonAdc2fc[j]+0.5);
191  castHists.shapeALL->Fill(i,tmp);
192  castHists.shapePED->Fill(i,tmp-calibs_.pedestal(digi.sample(i).capid()));
193  vals[i] = tmp-calibs_.pedestal(digi.sample(i).capid());
194  }
195  // }
196  //do per channel histograms once for each 100 events
197  if( doPerChannel_) perChanHists(digi.id(),vals,castHists.shape, castHists.time, castHists.energy, baseFolder_);
198  }
199  } else {
200  if(fVerbosity > 0) std::cout << "CastorPSMonitor::processEvent NO Castor Digis !!!" << std::endl;
201  }
202 
203 
204  ievt_++;
205 
206  return;
207 }
208 
209 
210 //==========================================================//
211 //=================== done ================================//
212 //==========================================================//
213 
216  return;
217 }
218 
219 //==========================================================//
220 //=================== perChanHists ========================//
221 //==========================================================//
222 
224  std::map<HcalCastorDetId, MonitorElement*> &tShape,
225  std::map<HcalCastorDetId, MonitorElement*> &tTime,
226  std::map<HcalCastorDetId, MonitorElement*> &tEnergy,
227  std::string baseFolder){
228 
229  std::string type = "CastorLEDPerChannel";
230  if(m_dbe) m_dbe->setCurrentFolder(baseFolder+"/"+type);
231 
232  MonitorElement* me;
233  if(m_dbe==NULL) return;
234  meIter=tShape.begin();
235  meIter = tShape.find(DetID);
236 
237  if (meIter!=tShape.end()){
238  me= meIter->second;
239  if(me==NULL && fVerbosity>0) printf("CastorLEDAnalysis::perChanHists This histo is NULL!!??\n");
240  else{
241  float energy=0;
242  float ts =0; float bs=0;
243  int maxi=0; float maxa=0;
244  for(int i=sigS0_; i<=sigS1_; i++){
245  if(vals[i]>maxa){maxa=vals[i]; maxi=i;}
246  }
247  for(int i=sigS0_; i<=sigS1_; i++){
248  energy += vals[i];
249  if(i>=(maxi-1) && i<=maxi+1){
250  ts += i*vals[i];
251  bs += vals[i];
252  }
253  me->Fill(i,vals[i]);
254  }
255  me = tTime[DetID];
256  if(bs!=0) me->Fill(ts/bs);
257  me = tEnergy[DetID];
258  me->Fill(energy);
259  }
260  }
261  else{
262  char name[1024];
263  sprintf(name,"Castor LED Shape zside=%d module=%d sector=%d",DetID.zside(),DetID.module(),DetID.sector());
264  MonitorElement* insert1;
265  insert1 = m_dbe->book1D(name,name,10,-0.5,9.5);
266  float energy=0;
267  float ts =0; float bs=0;
268  int maxi=0; float maxa=0;
269  for(int i=sigS0_; i<=sigS1_; i++){
270  if(vals[i]>maxa){maxa=vals[i]; maxi=i;}
271  insert1->Fill(i,vals[i]);
272  }
273  for(int i=sigS0_; i<=sigS1_; i++){
274  energy += vals[i];
275  if(i>=(maxi-1) && i<=maxi+1){
276  ts += i*vals[i];
277  bs += vals[i];
278  }
279  }
280  tShape[DetID] = insert1;
281 
282  sprintf(name,"Castor LED Time zside=%d module=%d sector=%d",DetID.zside(),DetID.module(),DetID.sector());
283  MonitorElement* insert2 = m_dbe->book1D(name,name,100,0,10);
284  if(bs!=0) insert2->Fill(ts/bs);
285  tTime[DetID] = insert2;
286 
287 
288  sprintf(name,"Castor LED Energy zside=%d module=%d sector=%d",DetID.zside(),DetID.module(),DetID.sector());
289  MonitorElement* insert3 = m_dbe->book1D(name,name,500,0,500);
290  insert3->Fill(energy);
291  tEnergy[DetID] = insert3;
292 
293  }
294 
295  return;
296 
297 }
type
Definition: HCALResponse.h:22
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:717
std::map< unsigned int, MonitorElement * > RMS_MAP_SHAPE_DCC
int adc() const
get the ADC sample
Definition: HcalQIESample.h:24
const HcalQIESample & sample(int i) const
access a sample
std::vector< T >::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:1468
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:28
double b
Definition: hdecay.h:120
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
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
struct CastorLEDMonitor::@185 castHists
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:429
const_iterator begin() const