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