CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorDigiMonitor.cc
Go to the documentation of this file.
4 
5 //****************************************************//
6 //********** CastorDigiMonitor: ******************//
7 //********** Author: Dmytro Volyanskyy *************//
8 //********** Date : 29.08.2008 (first version) ******//
9 //****************************************************//
12 
13 //==================================================================//
14 //======================= Constructor ==============================//
15 //==================================================================//
17 
18 
19 //==================================================================//
20 //======================= Destructor ===============================//
21 //==================================================================//
23 }
24 
25 
26 //==================================================================//
27 //=========================== reset ===============================//
28 //==================================================================//
30 }
31 
32 //==================================================================//
33 //=========================== setup ===============================//
34 //==================================================================//
37  baseFolder_ = rootFolder_+"CastorDigiMonitor";
38 
39  if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup (start)" << std::endl;
40 
41  doPerChannel_ = ps.getUntrackedParameter<bool>("DigiPerChannel", false);
42  doFCpeds_ = ps.getUntrackedParameter<bool>("DigiInFC", true);
43 
44  ievt_=0;
45 
46  if ( m_dbe !=NULL ) {
48  meEVT_ = m_dbe->bookInt("Digi Task Event Number");
49  meEVT_->Fill(ievt_);
50 
52 
54  std::string type = "Castor Digis ADC counts";
55  castHists.ALLPEDS = m_dbe->book1D(type,type,130,0,130);
56 
58  //type = "Castor Pedestal Mean Reference Values - from CondDB";
59  //castHists.PEDESTAL_REFS = m_dbe->book1D(type,type,50,0,50);
60  //type = "Castor Pedestal RMS Reference Values - from CondDB";
61  //castHists.WIDTH_REFS = m_dbe->book1D(type,type,20,0,10);
67 
68 }
69 
70  else{
71  if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup - NO DQMStore service" << std::endl;
72  }
73 
74 
75  outputFile_ = ps.getUntrackedParameter<std::string>("PedestalFile", "");
76  if ( outputFile_.size() != 0 ) { if(fVerbosity>0) std::cout << "Castor Pedestal Calibrations will be saved to " << outputFile_.c_str() << std::endl;}
77 
78 
79  if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup (end)" << std::endl;
80 
81  return;
82 }
83 
84 
85 
86 
87 //==================================================================//
88 //=========================== processEvent ========================//
89 //==================================================================//
91 {
92 
93  if(fVerbosity>0) std::cout << "==>CastorDigiMonitor::processEvent !!!"<< std::endl;
94 
95 
96  meEVT_->Fill(ievt_);
97 
98  //if(!shape_) shape_ = cond.getCastorShape(); // this one is generic
99 
100 
101  if(!m_dbe) {
102  if(fVerbosity>0) std::cout<<"CastorDigiMonitor::processEvent DQMStore is not instantiated!!!"<<std::endl;
103  return;
104  }
105 
106 
107  CaloSamples tool;
108 
109  if(castorDigis.size()>0) {
110 
111  for (CastorDigiCollection::const_iterator j=castorDigis.begin(); j!=castorDigis.end(); j++){
112  const CastorDataFrame digi = (const CastorDataFrame)(*j);
113 
114 
115  detID_.clear(); capID_.clear(); pedVals_.clear();
116 
117 
119 
120  // const CastorCalibrations& calibrations = cond.getCastorCalibrations(digi.id().rawId());
121  // const CastorPedestal* ped = cond.getPedestal(digi.id());
122  // const CastorPedestalWidth* pedw = cond.getPedestalWidth(digi.id());
125  // const CastorPedestal* ped = cond.getPedestal(digi.id());
126  // const CastorPedestalWidth* pedw = cond.getPedestalWidth(digi.id());
127 
128  /*
130  if(doFCpeds_){
131  channelCoder_ = cond.getCastorCoder(digi.id());
132  CastorCoderDb coderDB(*channelCoder_, *shape_);
133  coderDB.adc2fC(digi,tool);
134  }
135 
136 
138  for(int capID=0; capID<4; capID++){
140  float pedvalue=0;
141  if(ped) pedvalue=ped->getValue(capID);
142  castHists.PEDESTAL_REFS->Fill(pedvalue);
143  PEDESTAL_REFS->Fill(pedvalue);
147  float width=0;
148  if(pedw) width = pedw->getWidth(capID);
149  castHists.WIDTH_REFS->Fill(width);
150  WIDTH_REFS->Fill(width);
151  }
152  */
153 
154 
156 
157  // if(ievt_ %1000 == 0 ) // PK: skip limited number of events
158  // {
159  for (int i=0; i<digi.size(); i++) {
160  if(doFCpeds_) pedVals_.push_back(tool[i]); // default is FALSE
161  else pedVals_.push_back(digi.sample(i).adc());
162  detID_.push_back(digi.id());
163  capID_.push_back(digi.sample(i).capid());
164  castHists.ALLPEDS->Fill(pedVals_[i]);
165  }
166 
167  // }
168 
170  // if( ievt_%100 == 0 && doPerChannel_) perChanHists(detID_,capID_,pedVals_,castHists.PEDVALS, baseFolder_);
171  if( doPerChannel_) perChanHists(detID_,capID_,pedVals_,castHists.PEDVALS, baseFolder_); // PK: no special event selection done
172 
173  }
174  }
175  else {
176  if(fVerbosity>0) std::cout << "CastorPSMonitor::processEvent NO Castor Digis !!!" << std::endl;
177  }
178 
179  if (showTiming) {
180  cpu_timer.stop(); std::cout << " TIMER::CastorDigi -> " << cpu_timer.cpuTime() << std::endl;
182  }
183 
184  ievt_++;
185  return;
186 }
187 
189  return;
190 }
191 
192 
193 //==================================================================//
194 //======================= perChanHists ============================//
195 //==================================================================//
197 void CastorDigiMonitor::perChanHists( std::vector<HcalCastorDetId> detID, std::vector<int> capID, std::vector<float> peds,
198  std::map<HcalCastorDetId, std::map<int, MonitorElement*> > &toolP,
200  std::string baseFolder)
201  {
202 
203  if(m_dbe) m_dbe->setCurrentFolder(baseFolder);
204 
206  for(unsigned int d=0; d<detID.size(); d++){
207  HcalCastorDetId detid = detID[d];
208  int capid = capID[d];
209  float pedVal = peds[d];
211  bool gotit=false;
212  if(REG[detid]) gotit=true;
213 
214  if(gotit){
216  std::map<int, MonitorElement*> _mei = toolP[detid];
217  if(_mei[capid]==NULL){
218  if(fVerbosity>0) std::cout<<"CastorDigiMonitor::perChanHists This histo is NULL!!??"<< std::endl;
219  }
220  else _mei[capid]->Fill(pedVal);
221 
227  }
228  else{
229  if(m_dbe){
230  std::map<int,MonitorElement*> insertP; //-- Pedestal values in ADC
232 
234  for(int i=0; i<4; i++){
235  char name[1024];
236  sprintf(name,"Castor Digi Value (ADC) zside=%d module=%d sector=%d CAPID=%d",
237  detid.zside(),detid.module(),detid.sector(),i);
238  insertP[i] = m_dbe->book1D(name,name,10,-0.5,9.5);
239 
243  }
244 
245  insertP[capid]->Fill(pedVal);
247  toolP[detid] = insertP;
249  }
250  REG[detid] = true;
251  }
252  }
253 }
254 
type
Definition: HCALResponse.h:22
T getUntrackedParameter(std::string const &, T const &) const
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
void perChanHists(std::vector< HcalCastorDetId > detID, std::vector< int > capID, std::vector< float > peds, std::map< HcalCastorDetId, std::map< int, MonitorElement * > > &toolP, std::string baseFolder)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
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
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
dictionary map
Definition: Association.py:205
void Fill(long long x)
std::string baseFolder_
int j
Definition: DBlmapReader.cc:9
MonitorElement * meEVT_
Times stop()
Definition: CPUTimer.cc:94
const_iterator end() const
double cpuTime() const
Definition: CPUTimer.cc:157
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:28
std::vector< float > pedVals_
std::vector< HcalCastorDetId > detID_
size_type size() const
std::vector< int > capID_
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
std::string rootFolder_
std::string outputFile_
tuple cout
Definition: gather_cfg.py:121
const HcalCastorDetId & id() const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:624
int size() const
total number of samples in the digi
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
std::map< HcalCastorDetId, bool > REG
const_iterator begin() const
struct CastorDigiMonitor::@167 castHists