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  doPerChannel_ = false;
20 
21  }
22 
23 
24 //==================================================================//
25 //======================= Destructor ===============================//
26 //==================================================================//
28  {
29 
30  }
31 
32 
33 //==================================================================//
34 //=========================== reset ===============================//
35 //==================================================================//
37  {
38 
39  }
40 
41 //==================================================================//
42 //=========================== setup ===============================//
43 //==================================================================//
45  {
46 
48 
49  if(fVerbosity>0) { std::cout << "CastorDigiMonitor::setup (start)" << std::endl; }
50 
51  //set base folder
52  baseFolder_ = rootFolder_+"CastorDigiMonitor";
53 
54  doPerChannel_ = ps.getUntrackedParameter<bool>("DigiPerChannel", false);
55  doFCpeds_ = ps.getUntrackedParameter<bool>("DigiInFC", true);
56 
57  ievt_=0;
58 
59  outputFile_ = ps.getUntrackedParameter<std::string>("PedestalFile", "");
60  if ( outputFile_.size() != 0 )
61  {
62  if(fVerbosity>0) { std::cout << "Castor Pedestal Calibrations will be saved to " << outputFile_.c_str() << std::endl; }
63  }
64 
65 
66  if(fVerbosity>0) { std::cout << "CastorDigiMonitor::setup (end)" << std::endl; }
67 
68  return;
69 }
70 
71 
72 //==================================================================//
73 //=========================== beginRun =============================//
74 //==================================================================//
76  {
77  if(fVerbosity>0) std::cout << "CastorDigiMonitor::beginRun (start)" << std::endl;
78 
79  if ( m_dbe !=NULL )
80  {
82  meEVT_ = m_dbe->bookInt("Digi Task Event Number");
83  meEVT_->Fill(ievt_);
84 
86 
88  std::string type = "Castor Digis ADC counts";
89  castHists.ALLPEDS = m_dbe->book1D(type,type,130,0,130);
90 
92  //type = "Castor Pedestal Mean Reference Values - from CondDB";
93  //castHists.PEDESTAL_REFS = m_dbe->book1D(type,type,50,0,50);
94  //type = "Castor Pedestal RMS Reference Values - from CondDB";
95  //castHists.WIDTH_REFS = m_dbe->book1D(type,type,20,0,10);
101  }
102  else
103  {
104  if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup - NO DQMStore service" << std::endl;
105  }
106 
107 
108  if(fVerbosity>0) std::cout << "CastorDigiMonitor::beginRun (end)" << std::endl;
109 
110  return;
111 }
112 
113 
114 //==================================================================//
115 //=========================== processEvent ========================//
116 //==================================================================//
118  {
119  if(fVerbosity>0) std::cout << "CastorDigiMonitor::processEvent (begin)"<< std::endl;
120 
121  if(!m_dbe) {
122  if(fVerbosity>0) std::cout<<"CastorDigiMonitor::processEvent DQMStore is not instantiated!!!"<<std::endl;
123  return;
124  }
125 
126  //if(!shape_) shape_ = cond.getCastorShape(); // this one is generic
127 
128  meEVT_->Fill(ievt_);
129 
130  CaloSamples tool;
131 
132  if(castorDigis.size()>0) {
133 
134  for (CastorDigiCollection::const_iterator j=castorDigis.begin(); j!=castorDigis.end(); j++){
135  const CastorDataFrame digi = (const CastorDataFrame)(*j);
136 
137 
138  detID_.clear(); capID_.clear(); pedVals_.clear();
139 
140 
142 
143  // const CastorCalibrations& calibrations = cond.getCastorCalibrations(digi.id().rawId());
144  // const CastorPedestal* ped = cond.getPedestal(digi.id());
145  // const CastorPedestalWidth* pedw = cond.getPedestalWidth(digi.id());
148  // const CastorPedestal* ped = cond.getPedestal(digi.id());
149  // const CastorPedestalWidth* pedw = cond.getPedestalWidth(digi.id());
150 
151  /*
153  if(doFCpeds_){
154  channelCoder_ = cond.getCastorCoder(digi.id());
155  CastorCoderDb coderDB(*channelCoder_, *shape_);
156  coderDB.adc2fC(digi,tool);
157  }
158 
159 
161  for(int capID=0; capID<4; capID++){
163  float pedvalue=0;
164  if(ped) pedvalue=ped->getValue(capID);
165  castHists.PEDESTAL_REFS->Fill(pedvalue);
166  PEDESTAL_REFS->Fill(pedvalue);
170  float width=0;
171  if(pedw) width = pedw->getWidth(capID);
172  castHists.WIDTH_REFS->Fill(width);
173  WIDTH_REFS->Fill(width);
174  }
175  */
176 
177 
179 
180  // if(ievt_ %1000 == 0 ) // PK: skip limited number of events
181  // {
182  for (int i=0; i<digi.size(); i++) {
183  if(doFCpeds_) pedVals_.push_back(tool[i]); // default is FALSE
184  else pedVals_.push_back(digi.sample(i).adc());
185  detID_.push_back(digi.id());
186  capID_.push_back(digi.sample(i).capid());
187  castHists.ALLPEDS->Fill(pedVals_[i]);
188  }
189 
190  // }
191 
193  // if( ievt_%100 == 0 && doPerChannel_) perChanHists(detID_,capID_,pedVals_,castHists.PEDVALS, baseFolder_);
194  if( doPerChannel_) perChanHists(detID_,capID_,pedVals_,castHists.PEDVALS, baseFolder_); // PK: no special event selection done
195 
196  }
197  }
198  else {
199  if(fVerbosity>0) std::cout << "CastorPSMonitor::processEvent NO Castor Digis !!!" << std::endl;
200  }
201 
202  if (showTiming) {
203  cpu_timer.stop(); std::cout << " TIMER::CastorDigi -> " << cpu_timer.cpuTime() << std::endl;
205  }
206 
207  ievt_++;
208 
209  if(fVerbosity>0) std::cout << "CastorDigiMonitor::processEvent (end)"<< std::endl;
210 
211 
212  return;
213  }
214 
215 
216 //==================================================================//
217 //======================= done =====================================//
218 //==================================================================//
220  {
221 
222  return;
223  }
224 
225 
226 //==================================================================//
227 //======================= perChanHists ============================//
228 //==================================================================//
230 void CastorDigiMonitor::perChanHists( const std::vector<HcalCastorDetId>& detID, const std::vector<int>& capID, const std::vector<float>& peds,
231  std::map<HcalCastorDetId, std::map<int, MonitorElement*> > &toolP,
233  std::string baseFolder)
234  {
235 
236  if(m_dbe) m_dbe->setCurrentFolder(baseFolder);
237 
239  for(unsigned int d=0; d<detID.size(); d++){
240  HcalCastorDetId detid = detID[d];
241  int capid = capID[d];
242  float pedVal = peds[d];
244  bool gotit=false;
245  if(REG[detid]) gotit=true;
246 
247  if(gotit){
249  std::map<int, MonitorElement*> _mei = toolP[detid];
250  if(_mei[capid]==NULL){
251  if(fVerbosity>0) std::cout<<"CastorDigiMonitor::perChanHists This histo is NULL!!??"<< std::endl;
252  }
253  else _mei[capid]->Fill(pedVal);
254 
260  }
261  else{
262  if(m_dbe){
263  std::map<int,MonitorElement*> insertP; //-- Pedestal values in ADC
265 
267  for(int i=0; i<4; i++){
268  char name[1024];
269  sprintf(name,"Castor Digi Value (ADC) zside=%d module=%d sector=%d CAPID=%d",
270  detid.zside(),detid.module(),detid.sector(),i);
271  insertP[i] = m_dbe->book1D(name,name,10,-0.5,9.5);
272 
276  }
277 
278  insertP[capid]->Fill(pedVal);
280  toolP[detid] = insertP;
282  }
283  REG[detid] = true;
284  }
285  }
286 }
287 
type
Definition: HCALResponse.h:21
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
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
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
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
void perChanHists(const std::vector< HcalCastorDetId > &detID, const std::vector< int > &capID, const std::vector< float > &peds, std::map< HcalCastorDetId, std::map< int, MonitorElement * > > &toolP, std::string baseFolder)
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
void beginRun(const edm::EventSetup &iSetup)
double cpuTime() const
Definition: CPUTimer.cc:158
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:26
struct CastorDigiMonitor::@253 castHists
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:779
int size() const
total number of samples in the digi
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
std::map< HcalCastorDetId, bool > REG
const_iterator begin() const