Go to the documentation of this file.00001 #include "DQM/CastorMonitor/interface/CastorDigiMonitor.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQMServices/Core/interface/MonitorElement.h"
00004
00005
00006
00007
00008
00009
00012
00013
00014
00015
00016 CastorDigiMonitor::CastorDigiMonitor() { doPerChannel_ = false; }
00017
00018
00019
00020
00021
00022 CastorDigiMonitor::~CastorDigiMonitor() {
00023 }
00024
00025
00026
00027
00028
00029 void CastorDigiMonitor::reset(){
00030 }
00031
00032
00033
00034
00035 void CastorDigiMonitor::setup(const edm::ParameterSet& ps, DQMStore* dbe){
00036 CastorBaseMonitor::setup(ps,dbe);
00037 baseFolder_ = rootFolder_+"CastorDigiMonitor";
00038
00039 if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup (start)" << std::endl;
00040
00041 doPerChannel_ = ps.getUntrackedParameter<bool>("DigiPerChannel", false);
00042 doFCpeds_ = ps.getUntrackedParameter<bool>("DigiInFC", true);
00043
00044 ievt_=0;
00045
00046 if ( m_dbe !=NULL ) {
00047 m_dbe->setCurrentFolder(baseFolder_);
00048 meEVT_ = m_dbe->bookInt("Digi Task Event Number");
00049 meEVT_->Fill(ievt_);
00050
00051 m_dbe->setCurrentFolder(baseFolder_);
00052
00054 std::string type = "Castor Digis ADC counts";
00055 castHists.ALLPEDS = m_dbe->book1D(type,type,130,0,130);
00056
00058
00059
00060
00061
00067
00068 }
00069
00070 else{
00071 if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup - NO DQMStore service" << std::endl;
00072 }
00073
00074
00075 outputFile_ = ps.getUntrackedParameter<std::string>("PedestalFile", "");
00076 if ( outputFile_.size() != 0 ) { if(fVerbosity>0) std::cout << "Castor Pedestal Calibrations will be saved to " << outputFile_.c_str() << std::endl;}
00077
00078
00079 if(fVerbosity>0) std::cout << "CastorDigiMonitor::setup (end)" << std::endl;
00080
00081 return;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 void CastorDigiMonitor::processEvent(const CastorDigiCollection& castorDigis, const CastorDbService& cond)
00091 {
00092
00093 if(fVerbosity>0) std::cout << "==>CastorDigiMonitor::processEvent !!!"<< std::endl;
00094
00095
00096 meEVT_->Fill(ievt_);
00097
00098
00099
00100
00101 if(!m_dbe) {
00102 if(fVerbosity>0) std::cout<<"CastorDigiMonitor::processEvent DQMStore is not instantiated!!!"<<std::endl;
00103 return;
00104 }
00105
00106
00107 CaloSamples tool;
00108
00109 if(castorDigis.size()>0) {
00110
00111 for (CastorDigiCollection::const_iterator j=castorDigis.begin(); j!=castorDigis.end(); j++){
00112 const CastorDataFrame digi = (const CastorDataFrame)(*j);
00113
00114
00115 detID_.clear(); capID_.clear(); pedVals_.clear();
00116
00117
00119
00120
00121
00122
00125
00126
00127
00128
00130
00131
00132
00133
00134
00135
00136
00138
00140
00141
00142
00143
00147
00148
00149
00150
00151
00152
00153
00154
00156
00157
00158
00159 for (int i=0; i<digi.size(); i++) {
00160 if(doFCpeds_) pedVals_.push_back(tool[i]);
00161 else pedVals_.push_back(digi.sample(i).adc());
00162 detID_.push_back(digi.id());
00163 capID_.push_back(digi.sample(i).capid());
00164 castHists.ALLPEDS->Fill(pedVals_[i]);
00165 }
00166
00167
00168
00170
00171 if( doPerChannel_) perChanHists(detID_,capID_,pedVals_,castHists.PEDVALS, baseFolder_);
00172
00173 }
00174 }
00175 else {
00176 if(fVerbosity>0) std::cout << "CastorPSMonitor::processEvent NO Castor Digis !!!" << std::endl;
00177 }
00178
00179 if (showTiming) {
00180 cpu_timer.stop(); std::cout << " TIMER::CastorDigi -> " << cpu_timer.cpuTime() << std::endl;
00181 cpu_timer.reset(); cpu_timer.start();
00182 }
00183
00184 ievt_++;
00185 return;
00186 }
00187
00188 void CastorDigiMonitor::done(){
00189 return;
00190 }
00191
00192
00193
00194
00195
00197 void CastorDigiMonitor::perChanHists( std::vector<HcalCastorDetId> detID, std::vector<int> capID, std::vector<float> peds,
00198 std::map<HcalCastorDetId, std::map<int, MonitorElement*> > &toolP,
00200 std::string baseFolder)
00201 {
00202
00203 if(m_dbe) m_dbe->setCurrentFolder(baseFolder);
00204
00206 for(unsigned int d=0; d<detID.size(); d++){
00207 HcalCastorDetId detid = detID[d];
00208 int capid = capID[d];
00209 float pedVal = peds[d];
00211 bool gotit=false;
00212 if(REG[detid]) gotit=true;
00213
00214 if(gotit){
00216 std::map<int, MonitorElement*> _mei = toolP[detid];
00217 if(_mei[capid]==NULL){
00218 if(fVerbosity>0) std::cout<<"CastorDigiMonitor::perChanHists This histo is NULL!!??"<< std::endl;
00219 }
00220 else _mei[capid]->Fill(pedVal);
00221
00227 }
00228 else{
00229 if(m_dbe){
00230 std::map<int,MonitorElement*> insertP;
00232
00234 for(int i=0; i<4; i++){
00235 char name[1024];
00236 sprintf(name,"Castor Digi Value (ADC) zside=%d module=%d sector=%d CAPID=%d",
00237 detid.zside(),detid.module(),detid.sector(),i);
00238 insertP[i] = m_dbe->book1D(name,name,10,-0.5,9.5);
00239
00243 }
00244
00245 insertP[capid]->Fill(pedVal);
00247 toolP[detid] = insertP;
00249 }
00250 REG[detid] = true;
00251 }
00252 }
00253 }
00254