00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020 #include "FWCore/Framework/interface/Frameworkfwd.h"
00021 #include "FWCore/Framework/interface/Event.h"
00022 #include "FWCore/Framework/interface/MakerMacros.h"
00023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00024 #include "FWCore/Utilities/interface/InputTag.h"
00025
00026 #include "DQMServices/Core/interface/DQMStore.h"
00027 #include "DQMServices/Core/interface/MonitorElement.h"
00028 #include "DQM/HcalMonitorTasks/interface/HcalBaseMonitor.h"
00029 #include "DQM/HcalMonitorTasks/interface/HcalEtaPhiHists.h"
00030
00031 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00032 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00033
00034 #include <math.h>
00035
00036 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00037
00038 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
00039
00040 #include "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
00041 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00042
00043 #include "DQM/HcalMonitorTasks/interface/HcalBaseDQMonitor.h"
00044 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00045 #include "DQM/HcalMonitorTasks/interface/HcalEtaPhiHists.h"
00046
00047 #include "TFile.h"
00048 #include "TTree.h"
00049 #include "TSystem.h"
00050
00051 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00052 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00053 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00054 #include "DataFormats/HcalDigi/interface/HcalCalibrationEventTypes.h"
00055 #include "EventFilter/HcalRawToDigi/interface/HcalDCCHeader.h"
00056
00057 #include <iostream>
00058 #include <fstream>
00059
00060 class HcalDetDiagPedestalData{
00061 public:
00062 HcalDetDiagPedestalData(){
00063 reset();
00064 IsReference=false;
00065 status=n=0;
00066 ds_ped=ds_rms=-100;
00067 nChecks=nMissing=nBadPed=nBadRms=nUnstable=0;
00068 }
00069 void reset(){
00070 for(int i=0;i<128;i++) adc[i]=0;
00071 overflow=0;
00072 }
00073 void add_statistics(unsigned int val){
00074 if(val<128){ adc[val&0x7F]++; n++;}else overflow++;
00075 }
00076 void set_reference(float val,float rms){
00077 ref_ped=val; ref_rms=rms;
00078 IsReference=true;
00079 }
00080 void set_data(float val,float rms){
00081 ds_ped=val; ds_rms=rms;
00082 }
00083 void change_status(int val){
00084 status|=val;
00085 }
00086 int get_status(){
00087 return status;
00088 }
00089 bool get_reference(double *val,double *rms){
00090 *val=ref_ped; *rms=ref_rms;
00091 return IsReference;
00092 }
00093 bool get_average(double *ave,double *rms){
00094 if(ds_ped>-100){ *ave=ds_ped; *rms=ds_rms; return true;}
00095 double Sum=0,nSum=0;
00096 int from,to,max=adc[0],maxi=0;
00097 for(int i=1;i<128;i++) if(adc[i]>max){ max=adc[i]; maxi=i;}
00098 from=0; to=maxi+6; if(to>127) to=127;
00099 for(int i=from;i<=to;i++){
00100 Sum+=i*adc[i];
00101 nSum+=adc[i];
00102 }
00103 if(nSum>0) *ave=Sum/nSum; else return false;
00104 Sum=0;
00105 for(int i=from;i<=to;i++) Sum+=adc[i]*(i-*ave)*(i-*ave);
00106 *rms=sqrt(Sum/nSum);
00107 return true;
00108 }
00109 int get_statistics(){
00110 return n;
00111 }
00112 void set_statistics(int stat){
00113 n=stat;
00114 }
00115 int get_overflow(){
00116 return overflow;
00117 }
00118 float nChecks;
00119 float nMissing;
00120 float nUnstable;
00121 float nBadPed;
00122 float nBadRms;
00123 private:
00124 int adc[128];
00125 int overflow;
00126 bool IsReference;
00127 float ref_ped;
00128 float ref_rms;
00129 float ds_ped;
00130 float ds_rms;
00131 int n;
00132 int status;
00133 };
00134
00135
00136 class HcalDetDiagPedestalMonitor : public HcalBaseDQMonitor {
00137 public:
00138 explicit HcalDetDiagPedestalMonitor(const edm::ParameterSet&);
00139 ~HcalDetDiagPedestalMonitor();
00140
00141
00142 private:
00143 void SaveReference();
00144 void LoadReference();
00145 void LoadDataset();
00146
00147 void CheckStatus();
00148 void fillHistos();
00149
00150 const HcalElectronicsMap *emap;
00151 edm::InputTag inputLabelDigi_;
00152 edm::InputTag inputLabelRawData_;
00153
00154 void beginRun(const edm::Run& run, const edm::EventSetup& c);
00155 void endRun(const edm::Run& run, const edm::EventSetup& c);
00156 void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c) ;
00157 void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c);
00158 void analyze(const edm::Event&, const edm::EventSetup&);
00159
00160 int ievt_;
00161 int run_number;
00162 int dataset_seq_number;
00163 bool IsReference;
00164 bool LocalRun;
00165 int nHB,nHE,nHO,nHF;
00166
00167 double HBMeanTreshold;
00168 double HBRmsTreshold;
00169 double HEMeanTreshold;
00170 double HERmsTreshold;
00171 double HOMeanTreshold;
00172 double HORmsTreshold;
00173 double HFMeanTreshold;
00174 double HFRmsTreshold;
00175
00176 std::string ReferenceData;
00177 std::string ReferenceRun;
00178 std::string OutputFilePath;
00179 std::string XmlFilePath;
00180
00181
00182 std::string DatasetName;
00183 std::string htmlOutputPath;
00184 bool createHTMLonly;
00185
00186 std::string prefixME_;
00187 bool Online_;
00188 bool Overwrite;
00189
00190 int nTS_HBHE,nTS_HO,nTS_HF;
00191 MonitorElement *meEVT_,*meRUN_,*htmlFolder;
00192 MonitorElement *RefRun_;
00193 MonitorElement *PedestalsAve4HB;
00194 MonitorElement *PedestalsAve4HE;
00195 MonitorElement *PedestalsAve4HO;
00196 MonitorElement *PedestalsAve4HF;
00197 MonitorElement *PedestalsAve4Simp;
00198
00199 MonitorElement *PedestalsAve4HBref;
00200 MonitorElement *PedestalsAve4HEref;
00201 MonitorElement *PedestalsAve4HOref;
00202 MonitorElement *PedestalsAve4HFref;
00203 MonitorElement *PedestalsRmsHB;
00204 MonitorElement *PedestalsRmsHE;
00205 MonitorElement *PedestalsRmsHO;
00206 MonitorElement *PedestalsRmsHF;
00207 MonitorElement *PedestalsRmsSimp;
00208
00209 MonitorElement *PedestalsRmsHBref;
00210 MonitorElement *PedestalsRmsHEref;
00211 MonitorElement *PedestalsRmsHOref;
00212 MonitorElement *PedestalsRmsHFref;
00213
00214 MonitorElement *Pedestals2DRmsHBHEHF;
00215 MonitorElement *Pedestals2DRmsHO;
00216 MonitorElement *Pedestals2DHBHEHF;
00217 MonitorElement *Pedestals2DHO;
00218 MonitorElement *Pedestals2DErrorHBHEHF;
00219 MonitorElement *Pedestals2DErrorHO;
00220
00221 EtaPhiHists* ProblemCellsByDepth_missing;
00222 EtaPhiHists* ProblemCellsByDepth_unstable;
00223 EtaPhiHists* ProblemCellsByDepth_badped;
00224 EtaPhiHists* ProblemCellsByDepth_badrms;
00225
00226 EtaPhiHists* ProblemCellsByDepth_missing_val;
00227 EtaPhiHists* ProblemCellsByDepth_unstable_val;
00228 EtaPhiHists* ProblemCellsByDepth_badped_val;
00229 EtaPhiHists* ProblemCellsByDepth_badrms_val;
00230 std::vector<std::string> problemnames_;
00231
00232 HcalDetDiagPedestalData hb_data[85][72][4][4];
00233 HcalDetDiagPedestalData he_data[85][72][4][4];
00234 HcalDetDiagPedestalData ho_data[85][72][4][4];
00235 HcalDetDiagPedestalData hf_data[85][72][4][4];
00236
00237 std::map<unsigned int, int> KnownBadCells_;
00238
00239 edm::InputTag hcalTBTriggerDataTag_;
00240 };
00241
00242 HcalDetDiagPedestalMonitor::HcalDetDiagPedestalMonitor(const edm::ParameterSet& iConfig) :
00243 hcalTBTriggerDataTag_(iConfig.getParameter<edm::InputTag>("hcalTBTriggerDataTag"))
00244 {
00245 ievt_=-1;
00246 emap=0;
00247 dataset_seq_number=1;
00248 run_number=-1;
00249 IsReference=false;
00250 LocalRun=false;
00251 nHB=nHE=nHO=nHF=0;
00252 createHTMLonly=false;
00253 nTS_HBHE=nTS_HO=nTS_HF=0;
00254 inputLabelDigi_ = iConfig.getUntrackedParameter<edm::InputTag>("digiLabel");
00255 inputLabelRawData_ = iConfig.getUntrackedParameter<edm::InputTag>("rawDataLabel");
00256 ReferenceData = iConfig.getUntrackedParameter<std::string>("PedestalReferenceData" ,"");
00257 OutputFilePath = iConfig.getUntrackedParameter<std::string>("OutputFilePath", "");
00258 DatasetName = iConfig.getUntrackedParameter<std::string>("PedestalDatasetName", "");
00259 htmlOutputPath = iConfig.getUntrackedParameter<std::string>("htmlOutputPath", "");
00260 XmlFilePath = iConfig.getUntrackedParameter<std::string>("XmlFilePath", "");
00261 Online_ = iConfig.getUntrackedParameter<bool> ("online",false);
00262 Overwrite = iConfig.getUntrackedParameter<bool> ("Overwrite",true);
00263
00264 prefixME_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00265 if (prefixME_.size()>0 && prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00266 prefixME_.append("/");
00267 subdir_ = iConfig.getUntrackedParameter<std::string>("TaskFolder","DetDiagPedestalMonitor_Hcal/");
00268 if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00269 subdir_.append("/");
00270 subdir_=prefixME_+subdir_;
00271
00272 HBMeanTreshold = iConfig.getUntrackedParameter<double>("HBMeanPedestalTreshold" , 0.2);
00273 HBRmsTreshold = iConfig.getUntrackedParameter<double>("HBRmsPedestalTreshold" , 0.3);
00274 HEMeanTreshold = iConfig.getUntrackedParameter<double>("HEMeanPedestalTreshold" , 0.2);
00275 HERmsTreshold = iConfig.getUntrackedParameter<double>("HERmsPedestalTreshold" , 0.3);
00276 HOMeanTreshold = iConfig.getUntrackedParameter<double>("HOMeanPedestalTreshold" , 0.2);
00277 HORmsTreshold = iConfig.getUntrackedParameter<double>("HORmsPedestalTreshold" , 0.3);
00278 HFMeanTreshold = iConfig.getUntrackedParameter<double>("HFMeanPedestalTreshold" , 0.2);
00279 HFRmsTreshold = iConfig.getUntrackedParameter<double>("HFRmsPedestalTreshold" , 0.3);
00280 }
00281 HcalDetDiagPedestalMonitor::~HcalDetDiagPedestalMonitor(){}
00282
00283 void HcalDetDiagPedestalMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c){
00284 edm::ESHandle<HcalDbService> conditions_;
00285 c.get<HcalDbRecord>().get(conditions_);
00286 emap=conditions_->getHcalMapping();
00287
00288 edm::ESHandle<HcalChannelQuality> p;
00289 c.get<HcalChannelQualityRcd>().get(p);
00290 HcalChannelQuality* chanquality= new HcalChannelQuality(*p.product());
00291 std::vector<DetId> mydetids = chanquality->getAllChannels();
00292 KnownBadCells_.clear();
00293
00294 for (std::vector<DetId>::const_iterator i = mydetids.begin();i!=mydetids.end();++i){
00295 if (i->det()!=DetId::Hcal) continue;
00296 HcalDetId id=HcalDetId(*i);
00297 int status=(chanquality->getValues(id))->getValue();
00298 if((status & HcalChannelStatus::HcalCellOff) || (status & HcalChannelStatus::HcalCellMask)){
00299 KnownBadCells_[id.rawId()]=status;
00300 }
00301 }
00302
00303
00304 HcalBaseDQMonitor::setup();
00305 if (!dbe_) return;
00306 std::string name;
00307
00308 dbe_->setCurrentFolder(subdir_);
00309 meEVT_ = dbe_->bookInt("HcalDetDiagPedestalMonitor Event Number");
00310 meRUN_ = dbe_->bookInt("HcalDetDiagPedestalMonitor Run Number");
00311
00312 ReferenceRun="UNKNOWN";
00313 LoadReference();
00314 LoadDataset();
00315 dbe_->setCurrentFolder(subdir_);
00316 RefRun_= dbe_->bookString("HcalDetDiagPedestalMonitor Reference Run",ReferenceRun);
00317 if(DatasetName.size()>0 && createHTMLonly){
00318 char str[200]; sprintf(str,"%sHcalDetDiagPedestalData_run%i_%i/",htmlOutputPath.c_str(),run_number,dataset_seq_number);
00319 htmlFolder=dbe_->bookString("HcalDetDiagPedestalMonitor HTML folder",str);
00320 MonitorElement *me;
00321 dbe_->setCurrentFolder(prefixME_+"HcalInfo");
00322 me=dbe_->bookInt("HBpresent");
00323 if(nHB>0) me->Fill(1);
00324 me=dbe_->bookInt("HEpresent");
00325 if(nHE>0) me->Fill(1);
00326 me=dbe_->bookInt("HOpresent");
00327 if(nHO>0) me->Fill(1);
00328 me=dbe_->bookInt("HFpresent");
00329 if(nHF>0) me->Fill(1);
00330 }
00331
00332 ProblemCellsByDepth_missing = new EtaPhiHists();
00333 ProblemCellsByDepth_missing->setup(dbe_," Problem Missing Channels");
00334 for(unsigned int i=0;i<ProblemCellsByDepth_missing->depth.size();i++)
00335 problemnames_.push_back(ProblemCellsByDepth_missing->depth[i]->getName());
00336 ProblemCellsByDepth_unstable = new EtaPhiHists();
00337 ProblemCellsByDepth_unstable->setup(dbe_," Problem Unstable Channels");
00338 for(unsigned int i=0;i<ProblemCellsByDepth_unstable->depth.size();i++)
00339 problemnames_.push_back(ProblemCellsByDepth_unstable->depth[i]->getName());
00340 ProblemCellsByDepth_badped = new EtaPhiHists();
00341 ProblemCellsByDepth_badped->setup(dbe_," Problem Bad Pedestal Value");
00342 for(unsigned int i=0;i<ProblemCellsByDepth_badped->depth.size();i++)
00343 problemnames_.push_back(ProblemCellsByDepth_badped->depth[i]->getName());
00344 ProblemCellsByDepth_badrms = new EtaPhiHists();
00345 ProblemCellsByDepth_badrms->setup(dbe_," Problem Bad Rms Value");
00346 for(unsigned int i=0;i<ProblemCellsByDepth_badrms->depth.size();i++)
00347 problemnames_.push_back(ProblemCellsByDepth_badrms->depth[i]->getName());
00348
00349 dbe_->setCurrentFolder(subdir_+"Summary Plots");
00350 name="HB Pedestal Distribution (average over 4 caps)"; PedestalsAve4HB = dbe_->book1D(name,name,200,0,6);
00351 name="HE Pedestal Distribution (average over 4 caps)"; PedestalsAve4HE = dbe_->book1D(name,name,200,0,6);
00352 name="HO Pedestal Distribution (average over 4 caps)"; PedestalsAve4HO = dbe_->book1D(name,name,200,0,6);
00353 name="HF Pedestal Distribution (average over 4 caps)"; PedestalsAve4HF = dbe_->book1D(name,name,200,0,6);
00354 name="SIPM Pedestal Distribution (average over 4 caps)"; PedestalsAve4Simp = dbe_->book1D(name,name,200,5,15);
00355
00356 name="HB Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HBref= dbe_->book1D(name,name,1500,-3,3);
00357 name="HE Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HEref= dbe_->book1D(name,name,1500,-3,3);
00358 name="HO Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HOref= dbe_->book1D(name,name,1500,-3,3);
00359 name="HF Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HFref= dbe_->book1D(name,name,1500,-3,3);
00360
00361 name="HB Pedestal RMS Distribution (individual cap)"; PedestalsRmsHB = dbe_->book1D(name,name,200,0,2);
00362 name="HE Pedestal RMS Distribution (individual cap)"; PedestalsRmsHE = dbe_->book1D(name,name,200,0,2);
00363 name="HO Pedestal RMS Distribution (individual cap)"; PedestalsRmsHO = dbe_->book1D(name,name,200,0,2);
00364 name="HF Pedestal RMS Distribution (individual cap)"; PedestalsRmsHF = dbe_->book1D(name,name,200,0,2);
00365 name="SIPM Pedestal RMS Distribution (individual cap)"; PedestalsRmsSimp = dbe_->book1D(name,name,200,0,4);
00366
00367 name="HB Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHBref = dbe_->book1D(name,name,1500,-3,3);
00368 name="HE Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHEref = dbe_->book1D(name,name,1500,-3,3);
00369 name="HO Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHOref = dbe_->book1D(name,name,1500,-3,3);
00370 name="HF Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHFref = dbe_->book1D(name,name,1500,-3,3);
00371
00372 name="HBHEHF pedestal mean map"; Pedestals2DHBHEHF = dbe_->book2D(name,name,87,-43,43,74,0,73);
00373 name="HO pedestal mean map"; Pedestals2DHO = dbe_->book2D(name,name,33,-16,16,74,0,73);
00374 name="HBHEHF pedestal rms map"; Pedestals2DRmsHBHEHF = dbe_->book2D(name,name,87,-43,43,74,0,73);
00375 name="HO pedestal rms map"; Pedestals2DRmsHO = dbe_->book2D(name,name,33,-16,16,74,0,73);
00376 name="HBHEHF pedestal problems map"; Pedestals2DErrorHBHEHF = dbe_->book2D(name,name,87,-43,43,74,0,73);
00377 name="HO pedestal problems map"; Pedestals2DErrorHO = dbe_->book2D(name,name,33,-16,16,74,0,73);
00378
00379 Pedestals2DHBHEHF->setAxisRange(1,5,3);
00380 Pedestals2DHO->setAxisRange(1,5,3);
00381 Pedestals2DRmsHBHEHF->setAxisRange(0,2,3);
00382 Pedestals2DRmsHO->setAxisRange(0,2,3);
00383
00384 Pedestals2DHBHEHF->setAxisTitle("i#eta",1);
00385 Pedestals2DHBHEHF->setAxisTitle("i#phi",2);
00386 Pedestals2DHO->setAxisTitle("i#eta",1);
00387 Pedestals2DHO->setAxisTitle("i#phi",2);
00388 Pedestals2DRmsHBHEHF->setAxisTitle("i#eta",1);
00389 Pedestals2DRmsHBHEHF->setAxisTitle("i#phi",2);
00390 Pedestals2DRmsHO->setAxisTitle("i#eta",1);
00391 Pedestals2DRmsHO->setAxisTitle("i#phi",2);
00392 Pedestals2DErrorHBHEHF->setAxisTitle("i#eta",1);
00393 Pedestals2DErrorHBHEHF->setAxisTitle("i#phi",2);
00394 Pedestals2DErrorHO->setAxisTitle("i#eta",1);
00395 Pedestals2DErrorHO->setAxisTitle("i#phi",2);
00396 PedestalsAve4HB->setAxisTitle("ADC counts",1);
00397 PedestalsAve4HE->setAxisTitle("ADC counts",1);
00398 PedestalsAve4HO->setAxisTitle("ADC counts",1);
00399 PedestalsAve4HF->setAxisTitle("ADC counts",1);
00400 PedestalsAve4Simp->setAxisTitle("ADC counts",1);
00401 PedestalsAve4HBref->setAxisTitle("ADC counts",1);
00402 PedestalsAve4HEref->setAxisTitle("ADC counts",1);
00403 PedestalsAve4HOref->setAxisTitle("ADC counts",1);
00404 PedestalsAve4HFref->setAxisTitle("ADC counts",1);
00405 PedestalsRmsHB->setAxisTitle("ADC counts",1);
00406 PedestalsRmsHE->setAxisTitle("ADC counts",1);
00407 PedestalsRmsHO->setAxisTitle("ADC counts",1);
00408 PedestalsRmsHF->setAxisTitle("ADC counts",1);
00409 PedestalsRmsSimp->setAxisTitle("ADC counts",1);
00410 PedestalsRmsHBref->setAxisTitle("ADC counts",1);
00411 PedestalsRmsHEref->setAxisTitle("ADC counts",1);
00412 PedestalsRmsHOref->setAxisTitle("ADC counts",1);
00413 PedestalsRmsHFref->setAxisTitle("ADC counts",1);
00414
00415 dbe_->setCurrentFolder(subdir_+"Plots for client");
00416 ProblemCellsByDepth_missing_val = new EtaPhiHists();
00417 ProblemCellsByDepth_missing_val->setup(dbe_," Missing channels");
00418 ProblemCellsByDepth_unstable_val = new EtaPhiHists();
00419 ProblemCellsByDepth_unstable_val->setup(dbe_," Channel instability value");
00420 ProblemCellsByDepth_badped_val = new EtaPhiHists();
00421 ProblemCellsByDepth_badped_val->setup(dbe_," Bad Pedestal-Ref Value");
00422 ProblemCellsByDepth_badrms_val = new EtaPhiHists();
00423 ProblemCellsByDepth_badrms_val->setup(dbe_," Bad Rms-ref Value");
00424 }
00425
00426
00427
00428 void HcalDetDiagPedestalMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00429 if(createHTMLonly) return;
00430 HcalBaseDQMonitor::analyze(iEvent, iSetup);
00431 int eta,phi,depth,nTS;
00432 static bool PEDseq;
00433 static int lastPEDorbit,nChecksPED;
00434 if(ievt_==-1){ ievt_=0; PEDseq=false; lastPEDorbit=-1;nChecksPED=0; }
00435 int orbit=iEvent.orbitNumber();
00436 meRUN_->Fill(iEvent.id().run());
00437
00438 bool PedestalEvent=false;
00439
00440
00441 edm::Handle<HcalTBTriggerData> trigger_data;
00442 iEvent.getByLabel(hcalTBTriggerDataTag_, trigger_data);
00443 if(trigger_data.isValid()){
00444 if((trigger_data->triggerWord())==5) PedestalEvent=true;
00445 LocalRun=true;
00446 }
00447
00448 if(LocalRun && !PedestalEvent) return;
00449
00450 if(!LocalRun && Online_){
00451 if(PEDseq && (orbit-lastPEDorbit)>(11223*10) && ievt_>500){
00452 PEDseq=false;
00453 fillHistos();
00454 CheckStatus();
00455 nChecksPED++;
00456 if(nChecksPED==1 || (nChecksPED>1 && ((nChecksPED-1)%12)==0)){
00457 SaveReference();
00458 }
00459 for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) hb_data[i][j][k][l].reset();
00460 for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) he_data[i][j][k][l].reset();
00461 for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) ho_data[i][j][k][l].reset();
00462 for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) hf_data[i][j][k][l].reset();
00463 ievt_=0;
00464 }
00465 }
00466
00467
00468
00469 int calibType = -1 ;
00470 if(LocalRun==false){
00471 edm::Handle<FEDRawDataCollection> rawdata;
00472 iEvent.getByLabel(inputLabelRawData_,rawdata);
00473
00474 for (int i=FEDNumbering::MINHCALFEDID;i<=FEDNumbering::MAXHCALFEDID; i++){
00475 const FEDRawData& fedData = rawdata->FEDData(i) ;
00476 if ( fedData.size() < 24 ) continue ;
00477 int value = ((const HcalDCCHeader*)(fedData.data()))->getCalibType() ;
00478 if ( calibType < 0 ) calibType = value ;
00479 if(value==hc_Pedestal){ PEDseq=true; lastPEDorbit=orbit; break;}
00480 }
00481 }
00482 if(!LocalRun && calibType!=hc_Pedestal) return;
00483
00484 ievt_++;
00485 meEVT_->Fill(ievt_);
00486 run_number=iEvent.id().run();
00487
00488 edm::Handle<HBHEDigiCollection> hbhe;
00489 iEvent.getByLabel(inputLabelDigi_,hbhe);
00490 if(hbhe.isValid()){
00491 if(hbhe->size()<30 && calibType==hc_Pedestal){
00492 ievt_--;
00493 meEVT_->Fill(ievt_);
00494 return;
00495 }
00496 for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
00497 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
00498 if(nTS>8) nTS=8;
00499 if(nTS<8 && nTS>=4) nTS=4;
00500 nTS_HBHE=nTS;
00501 if(digi->id().subdet()==HcalBarrel){
00502 for(int i=0;i<nTS;i++) hb_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
00503 }
00504 if(digi->id().subdet()==HcalEndcap){
00505 for(int i=0;i<nTS;i++) he_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
00506 }
00507 }
00508 }
00509 edm::Handle<HODigiCollection> ho;
00510 iEvent.getByLabel(inputLabelDigi_,ho);
00511 if(ho.isValid()){
00512 for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
00513 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
00514 if(nTS>8) nTS=8;
00515 if(nTS<8 && nTS>=4) nTS=4;
00516 nTS_HO=nTS;
00517 for(int i=0;i<nTS;i++) ho_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
00518 }
00519 }
00520 edm::Handle<HFDigiCollection> hf;
00521 iEvent.getByLabel(inputLabelDigi_,hf);
00522 if(hf.isValid()){
00523 for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
00524 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
00525 if(nTS>8) nTS=8;
00526 if(nTS<8 && nTS>=4) nTS=4;
00527 nTS_HF=nTS;
00528 for(int i=0;i<nTS;i++) hf_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
00529 }
00530 }
00531 }
00532
00533 void HcalDetDiagPedestalMonitor::fillHistos(){
00534 PedestalsRmsHB->Reset();
00535 PedestalsAve4HB->Reset();
00536 PedestalsRmsHE->Reset();
00537 PedestalsAve4HE->Reset();
00538 PedestalsRmsHO->Reset();
00539 PedestalsAve4HO->Reset();
00540 PedestalsRmsHF->Reset();
00541 PedestalsAve4HF->Reset();
00542 PedestalsRmsSimp->Reset();
00543 PedestalsAve4Simp->Reset();
00544 Pedestals2DRmsHBHEHF->Reset();
00545 Pedestals2DRmsHO->Reset();
00546 Pedestals2DHBHEHF->Reset();
00547 Pedestals2DHO->Reset();
00548
00549 for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++){
00550 double PED=0,RMS=0,nped=0,nrms=0,ave=0,rms=0;
00551 for(int depth=1;depth<=3;depth++){
00552 if(hb_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00553 hb_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00554 hb_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00555 hb_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00556 hb_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00557 }
00558 if(he_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00559 he_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00560 he_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00561 he_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00562 he_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00563 }
00564 if(hf_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00565 hf_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00566 hf_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00567 hf_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00568 hf_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00569 }
00570 }
00571 if(nped>0) Pedestals2DHBHEHF->Fill(eta,phi,PED/nped);
00572 if(nrms>0) Pedestals2DRmsHBHEHF->Fill(eta,phi,RMS/nrms);
00573 if(nped>0 && abs(eta)>20) Pedestals2DHBHEHF->Fill(eta,phi+1,PED/nped);
00574 if(nrms>0 && abs(eta)>20) Pedestals2DRmsHBHEHF->Fill(eta,phi+1,RMS/nrms);
00575 }
00576
00577 for(int eta=-10;eta<=15;eta++) for(int phi=1;phi<=72;phi++){
00578 if(eta>10 && !isSiPM(eta,phi,4)) continue;
00579 double PED=0,RMS=0,nped=0,nrms=0,ave=0,rms=0;
00580 if(ho_data[eta+42][phi-1][4-1][0].get_statistics()>100){
00581 ho_data[eta+42][phi-1][4-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00582 ho_data[eta+42][phi-1][4-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00583 ho_data[eta+42][phi-1][4-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00584 ho_data[eta+42][phi-1][4-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
00585 }
00586 if(nped>0) Pedestals2DHO->Fill(eta,phi,PED/nped);
00587 if(nrms>0) Pedestals2DRmsHO->Fill(eta,phi,RMS/nrms);
00588 }
00589
00590 for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00591 if(hb_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00592 double ave=0,rms=0,sum=0;
00593 hb_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
00594 hb_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
00595 hb_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
00596 hb_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
00597 PedestalsAve4HB->Fill(sum/4.0);
00598 }
00599 }
00600
00601 for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=3;depth++){
00602 if(he_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00603 double ave=0,rms=0,sum=0;
00604 he_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
00605 he_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
00606 he_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
00607 he_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
00608 PedestalsAve4HE->Fill(sum/4.0);
00609 }
00610 }
00611
00612 for(int eta=-10;eta<=15;eta++) for(int phi=1;phi<=72;phi++) for(int depth=4;depth<=4;depth++){
00613 if(eta>10 && !isSiPM(eta,phi,4)) continue;
00614 if(ho_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00615 double ave=0,rms=0,sum=0;
00616 if((eta>=11 && eta<=15 && phi>=59 && phi<=70) || (eta>=5 && eta<=10 && phi>=47 && phi<=58)){
00617 ho_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
00618 ho_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
00619 ho_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
00620 ho_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
00621 PedestalsAve4Simp->Fill(sum/4.0);
00622 }else{
00623 ho_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
00624 ho_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
00625 ho_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
00626 ho_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
00627 PedestalsAve4HO->Fill(sum/4.0);
00628 }
00629 }
00630 }
00631
00632 for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00633 if(hf_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
00634 double ave=0,rms=0,sum=0;
00635 hf_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
00636 hf_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
00637 hf_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
00638 hf_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
00639 PedestalsAve4HF->Fill(sum/4.0);
00640 }
00641 }
00642 }
00643 void HcalDetDiagPedestalMonitor::CheckStatus(){
00644 for(int i=0;i<4;i++){
00645 ProblemCellsByDepth_missing->depth[i]->Reset();
00646 ProblemCellsByDepth_unstable->depth[i]->Reset();
00647 ProblemCellsByDepth_badped->depth[i]->Reset();
00648 ProblemCellsByDepth_badrms->depth[i]->Reset();
00649 }
00650 PedestalsRmsHBref->Reset();
00651 PedestalsAve4HBref->Reset();
00652 PedestalsRmsHEref->Reset();
00653 PedestalsAve4HEref->Reset();
00654 PedestalsRmsHOref->Reset();
00655 PedestalsAve4HOref->Reset();
00656 PedestalsRmsHFref->Reset();
00657 PedestalsAve4HFref->Reset();
00658
00659 Pedestals2DErrorHBHEHF->Reset();
00660 Pedestals2DErrorHO->Reset();
00661
00662 if(emap==0) return;
00663
00664 std::vector <HcalElectronicsId> AllElIds = emap->allElectronicsIdPrecision();
00665 for (std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++) {
00666 DetId detid=emap->lookup(*eid);
00667 if (detid.det()!=DetId::Hcal) continue;
00668 HcalGenericDetId gid(emap->lookup(*eid));
00669 if(!(!(gid.null()) &&
00670 (gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel ||
00671 gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap ||
00672 gid.genericSubdet()==HcalGenericDetId::HcalGenForward ||
00673 gid.genericSubdet()==HcalGenericDetId::HcalGenOuter))) continue;
00674 int eta=0,phi=0,depth=0;
00675
00676 HcalDetId hid(detid);
00677 if(KnownBadCells_.find(hid.rawId())==KnownBadCells_.end()) continue;
00678
00679 eta=hid.ieta();
00680 phi=hid.iphi();
00681 depth=hid.depth();
00682 int sd=detid.subdetId();
00683
00684 if(sd==HcalBarrel){
00685 int ovf=hb_data[eta+42][phi-1][depth-1][0].get_overflow();
00686 int stat=hb_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
00687 double status=0;
00688 double ped[4],rms[4],ped_ref[4],rms_ref[4];
00689 hb_data[eta+42][phi-1][depth-1][0].nChecks++;
00690 if(stat==0){
00691 status=1;
00692 int e=CalcEtaBin(sd,eta,depth)+1;
00693 hb_data[eta+42][phi-1][depth-1][0].nMissing++;
00694 double val=hb_data[eta+42][phi-1][depth-1][0].nMissing/hb_data[eta+42][phi-1][depth-1][0].nChecks;
00695 ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
00696 ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
00697 }
00698 if(status) hb_data[eta+42][phi-1][depth-1][0].change_status(1);
00699 if(stat>0 && stat!=(ievt_*2)){ if(nTS_HBHE==8) status=(double)stat/(double)(ievt_*2); else status=(double)stat/(double)(ievt_);
00700 if(status<0.995){
00701 int e=CalcEtaBin(sd,eta,depth)+1;
00702 hb_data[eta+42][phi-1][depth-1][0].nUnstable++;
00703 double val=hb_data[eta+42][phi-1][depth-1][0].nUnstable/hb_data[eta+42][phi-1][depth-1][0].nChecks;
00704 ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
00705 ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
00706 hb_data[eta+42][phi-1][depth-1][0].change_status(2);
00707 }
00708 }
00709 if(hb_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
00710 && hb_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
00711 hb_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
00712 hb_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
00713 hb_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
00714 hb_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
00715 hb_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
00716 hb_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
00717 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
00718 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
00719 double deltaPed=ave-ave_ref; PedestalsAve4HBref->Fill(deltaPed); if(deltaPed<0) deltaPed=-deltaPed;
00720 double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHBref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
00721 for(int i=1;i<4;i++){
00722 double tmp=rms[i]-rms_ref[i]; PedestalsRmsHBref->Fill(tmp);
00723 if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
00724 }
00725 if(deltaPed>HBMeanTreshold){
00726 int e=CalcEtaBin(sd,eta,depth)+1;
00727 hb_data[eta+42][phi-1][depth-1][0].nBadPed++;
00728 double val=hb_data[eta+42][phi-1][depth-1][0].nBadPed/hb_data[eta+42][phi-1][depth-1][0].nChecks;
00729 ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
00730 ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
00731 Pedestals2DErrorHBHEHF->Fill(eta,phi,1);
00732 }
00733 if(deltaRms>HBRmsTreshold){
00734 int e=CalcEtaBin(sd,eta,depth)+1;
00735 hb_data[eta+42][phi-1][depth-1][0].nBadRms++;
00736 double val=hb_data[eta+42][phi-1][depth-1][0].nBadRms/hb_data[eta+42][phi-1][depth-1][0].nChecks;
00737 ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
00738 ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
00739 Pedestals2DErrorHBHEHF->Fill(eta,phi,1);
00740 }
00741 }
00742 }
00743 if(sd==HcalEndcap){
00744 int ovf=he_data[eta+42][phi-1][depth-1][0].get_overflow();
00745 int stat=he_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
00746 double status=0;
00747 double ped[4],rms[4],ped_ref[4],rms_ref[4];
00748 he_data[eta+42][phi-1][depth-1][0].nChecks++;
00749 if(stat==0){
00750 status=1;
00751 int e=CalcEtaBin(sd,eta,depth)+1;
00752 he_data[eta+42][phi-1][depth-1][0].nMissing++;
00753 double val=he_data[eta+42][phi-1][depth-1][0].nMissing/he_data[eta+42][phi-1][depth-1][0].nChecks;
00754 ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
00755 ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
00756 }
00757 if(status) he_data[eta+42][phi-1][depth-1][0].change_status(1);
00758 if(stat>0 && stat!=(ievt_*2)){ if(nTS_HBHE==8) status=(double)stat/(double)(ievt_*2); else status=(double)stat/(double)(ievt_);
00759 if(status<0.995){
00760 int e=CalcEtaBin(sd,eta,depth)+1;
00761 he_data[eta+42][phi-1][depth-1][0].nUnstable++;
00762 double val=he_data[eta+42][phi-1][depth-1][0].nUnstable/he_data[eta+42][phi-1][depth-1][0].nChecks;
00763 ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
00764 ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
00765 he_data[eta+42][phi-1][depth-1][0].change_status(2);
00766 }
00767 }
00768 if(he_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
00769 && he_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
00770 he_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
00771 he_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
00772 he_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
00773 he_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
00774 he_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
00775 he_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
00776 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
00777 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
00778 double deltaPed=ave-ave_ref; PedestalsAve4HEref->Fill(deltaPed); if(deltaPed<0) deltaPed=-deltaPed;
00779 double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHEref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
00780 for(int i=1;i<4;i++){
00781 double tmp=rms[i]-rms_ref[i]; PedestalsRmsHEref->Fill(tmp);
00782 if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
00783 }
00784 if(deltaPed>HEMeanTreshold){
00785 int e=CalcEtaBin(sd,eta,depth)+1;
00786 he_data[eta+42][phi-1][depth-1][0].nBadPed++;
00787 double val=he_data[eta+42][phi-1][depth-1][0].nBadPed/he_data[eta+42][phi-1][depth-1][0].nChecks;
00788 ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
00789 ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
00790 Pedestals2DErrorHBHEHF->Fill(eta,phi,1);
00791 }
00792 if(deltaRms>HERmsTreshold){
00793 int e=CalcEtaBin(sd,eta,depth)+1;
00794 he_data[eta+42][phi-1][depth-1][0].nBadRms++;
00795 double val=he_data[eta+42][phi-1][depth-1][0].nBadRms/he_data[eta+42][phi-1][depth-1][0].nChecks;
00796 ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
00797 ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
00798 Pedestals2DErrorHBHEHF->Fill(eta,phi,1);
00799 }
00800 }
00801 }
00802 if(sd==HcalOuter){
00803 int ovf=ho_data[eta+42][phi-1][depth-1][0].get_overflow();
00804 int stat=ho_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
00805 double status=0;
00806 double ped[4],rms[4],ped_ref[4],rms_ref[4];
00807 ho_data[eta+42][phi-1][depth-1][0].nChecks++;
00808 if(stat==0){
00809 status=1;
00810 int e=CalcEtaBin(sd,eta,depth)+1;
00811 ho_data[eta+42][phi-1][depth-1][0].nMissing++;
00812 double val=ho_data[eta+42][phi-1][depth-1][0].nMissing/ho_data[eta+42][phi-1][depth-1][0].nChecks;
00813 ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
00814 ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
00815 }
00816 if(status) ho_data[eta+42][phi-1][depth-1][0].change_status(1);
00817 if(stat>0 && stat!=(ievt_*2)){ if(nTS_HO==8) status=(double)stat/(double)(ievt_*2); else status=(double)stat/(double)(ievt_);
00818 if(status<0.995){
00819 int e=CalcEtaBin(sd,eta,depth)+1;
00820 ho_data[eta+42][phi-1][depth-1][0].nUnstable++;
00821 double val=ho_data[eta+42][phi-1][depth-1][0].nUnstable/ho_data[eta+42][phi-1][depth-1][0].nChecks;
00822 ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
00823 ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
00824 ho_data[eta+42][phi-1][depth-1][0].change_status(2);
00825 }
00826 }
00827 if(ho_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
00828 && ho_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
00829 ho_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
00830 ho_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
00831 ho_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
00832 ho_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
00833 ho_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
00834 ho_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
00835
00836 double THRESTHOLD=HORmsTreshold;
00837 if((eta>=11 && eta<=15 && phi>=59 && phi<=70) || (eta>=5 && eta<=10 && phi>=47 && phi<=58))THRESTHOLD*=2;
00838 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
00839 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
00840 double deltaPed=ave-ave_ref; PedestalsAve4HOref->Fill(deltaPed);if(deltaPed<0) deltaPed=-deltaPed;
00841 double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHOref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
00842 for(int i=1;i<4;i++){
00843 double tmp=rms[i]-rms_ref[i]; PedestalsRmsHOref->Fill(tmp);
00844 if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
00845 }
00846 if(deltaPed>HOMeanTreshold){
00847 int e=CalcEtaBin(sd,eta,depth)+1;
00848 ho_data[eta+42][phi-1][depth-1][0].nBadPed++;
00849 double val=ho_data[eta+42][phi-1][depth-1][0].nBadPed/ho_data[eta+42][phi-1][depth-1][0].nChecks;
00850 ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
00851 ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
00852 Pedestals2DErrorHO->Fill(eta,phi,1);
00853 }
00854 if(deltaRms>THRESTHOLD){
00855 int e=CalcEtaBin(sd,eta,depth)+1;
00856 ho_data[eta+42][phi-1][depth-1][0].nBadRms++;
00857 double val=ho_data[eta+42][phi-1][depth-1][0].nBadRms/ho_data[eta+42][phi-1][depth-1][0].nChecks;
00858 ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
00859 ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
00860 Pedestals2DErrorHO->Fill(eta,phi,1);
00861 }
00862 }
00863 }
00864 if(sd==HcalForward){
00865 int ovf=hf_data[eta+42][phi-1][depth-1][0].get_overflow();
00866 int stat=hf_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
00867 double status=0;
00868 double ped[4],rms[4],ped_ref[4],rms_ref[4];
00869 hf_data[eta+42][phi-1][depth-1][0].nChecks++;
00870 if(stat==0){
00871 status=1;
00872 int e=CalcEtaBin(sd,eta,depth)+1;
00873 hf_data[eta+42][phi-1][depth-1][0].nMissing++;
00874 double val=hf_data[eta+42][phi-1][depth-1][0].nMissing/hf_data[eta+42][phi-1][depth-1][0].nChecks;
00875 ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
00876 ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
00877 }
00878 if(status) hf_data[eta+42][phi-1][depth-1][0].change_status(1);
00879 if(stat>0 && stat!=(ievt_*2)){ if(nTS_HF==8) status=(double)stat/(double)(ievt_*2); else status=(double)stat/(double)(ievt_);
00880 if(status<0.995){
00881 int e=CalcEtaBin(sd,eta,depth)+1;
00882 hf_data[eta+42][phi-1][depth-1][0].nUnstable++;
00883 double val=hf_data[eta+42][phi-1][depth-1][0].nUnstable/hf_data[eta+42][phi-1][depth-1][0].nChecks;
00884 ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
00885 ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
00886 hf_data[eta+42][phi-1][depth-1][0].change_status(2);
00887 }
00888 }
00889 if(hf_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
00890 && hf_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
00891 hf_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
00892 hf_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
00893 hf_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
00894 hf_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
00895 hf_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
00896 hf_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
00897 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
00898 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
00899 double deltaPed=ave-ave_ref; PedestalsAve4HFref->Fill(deltaPed); if(deltaPed<0) deltaPed=-deltaPed;
00900 double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHFref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
00901 for(int i=1;i<4;i++){
00902 double tmp=rms[i]-rms_ref[i]; PedestalsRmsHFref->Fill(tmp);
00903 if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
00904 }
00905 if(deltaPed>HFMeanTreshold){
00906 int e=CalcEtaBin(sd,eta,depth)+1;
00907 hf_data[eta+42][phi-1][depth-1][0].nBadPed++;
00908 double val=hf_data[eta+42][phi-1][depth-1][0].nBadPed/hf_data[eta+42][phi-1][depth-1][0].nChecks;
00909 ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
00910 ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
00911 Pedestals2DErrorHBHEHF->Fill(eta,phi,1);
00912 }
00913 if(deltaRms>HFRmsTreshold){
00914 int e=CalcEtaBin(sd,eta,depth)+1;
00915 hf_data[eta+42][phi-1][depth-1][0].nBadRms++;
00916 double val=hf_data[eta+42][phi-1][depth-1][0].nBadRms/hf_data[eta+42][phi-1][depth-1][0].nChecks;
00917 ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
00918 ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
00919 Pedestals2DErrorHBHEHF->Fill(eta,phi,1);
00920 }
00921 }
00922 }
00923 }
00924 }
00925
00926 void HcalDetDiagPedestalMonitor::endRun(const edm::Run& run, const edm::EventSetup& c){
00927
00928 if((LocalRun || !Online_ || createHTMLonly) && ievt_>=100){
00929 fillHistos();
00930 CheckStatus();
00931 SaveReference();
00932 }
00933 }
00934
00935 void HcalDetDiagPedestalMonitor::SaveReference(){
00936 double ped[4],rms[4];
00937 int Eta,Phi,Depth,Statistic,Status=0;
00938 char Subdet[10],str[500];
00939 if(OutputFilePath.size()>0){
00940 if(!Overwrite){
00941 sprintf(str,"%sHcalDetDiagPedestalData_run%06i_%i.root",OutputFilePath.c_str(),run_number,dataset_seq_number);
00942 }else{
00943 sprintf(str,"%sHcalDetDiagPedestalData.root",OutputFilePath.c_str());
00944 }
00945 TFile *theFile = new TFile(str, "RECREATE");
00946 if(!theFile->IsOpen()) return;
00947 theFile->cd();
00948 sprintf(str,"%d",run_number); TObjString run(str); run.Write("run number");
00949 sprintf(str,"%d",ievt_); TObjString events(str); events.Write("Total events processed");
00950 sprintf(str,"%d",dataset_seq_number); TObjString dsnum(str); dsnum.Write("Dataset number");
00951 Long_t t; t=time(0); strftime(str,30,"%F %T",localtime(&t)); TObjString tm(str); tm.Write("Dataset creation time");
00952
00953 TTree *tree =new TTree("HCAL Pedestal data","HCAL Pedestal data");
00954 if(tree==0) return;
00955 tree->Branch("Subdet", &Subdet, "Subdet/C");
00956 tree->Branch("eta", &Eta, "Eta/I");
00957 tree->Branch("phi", &Phi, "Phi/I");
00958 tree->Branch("depth", &Depth, "Depth/I");
00959 tree->Branch("statistic",&Statistic, "Statistic/I");
00960 tree->Branch("status", &Status, "Status/I");
00961 tree->Branch("cap0_ped", &ped[0], "cap0_ped/D");
00962 tree->Branch("cap0_rms", &rms[0], "cap0_rms/D");
00963 tree->Branch("cap1_ped", &ped[1], "cap1_ped/D");
00964 tree->Branch("cap1_rms", &rms[1], "cap1_rms/D");
00965 tree->Branch("cap2_ped", &ped[2], "cap2_ped/D");
00966 tree->Branch("cap2_rms", &rms[2], "cap2_rms/D");
00967 tree->Branch("cap3_ped", &ped[3], "cap3_ped/D");
00968 tree->Branch("cap3_rms", &rms[3], "cap3_rms/D");
00969 sprintf(Subdet,"HB");
00970 for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00971 if((Statistic=hb_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
00972 Eta=eta; Phi=phi; Depth=depth;
00973 Status=hb_data[eta+42][phi-1][depth-1][0].get_status();
00974 hb_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
00975 hb_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
00976 hb_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
00977 hb_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
00978 tree->Fill();
00979 }
00980 }
00981 sprintf(Subdet,"HE");
00982 for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=3;depth++){
00983 if((Statistic=he_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
00984 Eta=eta; Phi=phi; Depth=depth;
00985 Status=he_data[eta+42][phi-1][depth-1][0].get_status();
00986 he_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
00987 he_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
00988 he_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
00989 he_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
00990 tree->Fill();
00991 }
00992 }
00993 sprintf(Subdet,"HO");
00994 for(int eta=-15;eta<=15;eta++) for(int phi=1;phi<=72;phi++) for(int depth=4;depth<=4;depth++){
00995 if((Statistic=ho_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
00996 Eta=eta; Phi=phi; Depth=depth;
00997 Status=ho_data[eta+42][phi-1][depth-1][0].get_status();
00998 ho_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
00999 ho_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
01000 ho_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
01001 ho_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
01002 tree->Fill();
01003 }
01004 }
01005 sprintf(Subdet,"HF");
01006 for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
01007 if((Statistic=hf_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
01008 Eta=eta; Phi=phi; Depth=depth;
01009 Status=hf_data[eta+42][phi-1][depth-1][0].get_status();
01010 hf_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
01011 hf_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
01012 hf_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
01013 hf_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
01014 tree->Fill();
01015 }
01016 }
01017 theFile->Write();
01018 theFile->Close();
01019 }
01020
01021 if(XmlFilePath.size()>0){
01022
01023 if(!Overwrite){
01024 sprintf(str,"HcalDetDiagPedestals_%i_%i.xml",run_number,dataset_seq_number);
01025 }else{
01026 sprintf(str,"HcalDetDiagPedestals.xml");
01027 }
01028 printf("%s\n",str);
01029 std::string xmlName=str;
01030 ofstream xmlFile;
01031 xmlFile.open(xmlName.c_str());
01032
01033 xmlFile<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
01034 xmlFile<<"<ROOT>\n";
01035 xmlFile<<" <HEADER>\n";
01036 xmlFile<<" <HINTS mode='only-det-root'/>\n";
01037 xmlFile<<" <TYPE>\n";
01038 xmlFile<<" <EXTENSION_TABLE_NAME>HCAL_DETMON_PEDESTALS_V1</EXTENSION_TABLE_NAME>\n";
01039 xmlFile<<" <NAME>HCAL Pedestals [abort gap global]</NAME>\n";
01040 xmlFile<<" </TYPE>\n";
01041 xmlFile<<" <!-- run details -->\n";
01042 xmlFile<<" <RUN>\n";
01043 xmlFile<<" <RUN_TYPE>GLOBAL-RUN</RUN_TYPE>\n";
01044 xmlFile<<" <RUN_NUMBER>"<<run_number<<"</RUN_NUMBER>\n";
01045 xmlFile<<" <RUN_BEGIN_TIMESTAMP>2009-01-01 00:00:00</RUN_BEGIN_TIMESTAMP>\n";
01046 xmlFile<<" <COMMENT_DESCRIPTION>hcal ped data</COMMENT_DESCRIPTION>\n";
01047 xmlFile<<" <LOCATION>P5</LOCATION>\n";
01048 xmlFile<<" <INITIATED_BY_USER>dma</INITIATED_BY_USER>\n";
01049 xmlFile<<" </RUN>\n";
01050 xmlFile<<" </HEADER>\n";
01051 xmlFile<<" <DATA_SET>\n";
01052 xmlFile<<" <!-- optional dataset metadata -->\n\n";
01053 xmlFile<<" <SET_NUMBER>"<<dataset_seq_number<<"</SET_NUMBER>\n";
01054 xmlFile<<" <SET_BEGIN_TIMESTAMP>2009-01-01 00:00:00</SET_BEGIN_TIMESTAMP>\n";
01055 xmlFile<<" <SET_END_TIMESTAMP>2009-01-01 00:00:00</SET_END_TIMESTAMP>\n";
01056 xmlFile<<" <NUMBER_OF_EVENTS_IN_SET>"<<ievt_<<"</NUMBER_OF_EVENTS_IN_SET>\n";
01057 xmlFile<<" <COMMENT_DESCRIPTION>Automatic DQM output</COMMENT_DESCRIPTION>\n";
01058 xmlFile<<" <DATA_FILE_NAME>"<< xmlName <<"</DATA_FILE_NAME>\n";
01059 xmlFile<<" <IMAGE_FILE_NAME>data plot url or file path</IMAGE_FILE_NAME>\n";
01060 xmlFile<<" <!-- who and when created this dataset-->\n\n";
01061 Long_t t; t=time(0); strftime(str,30,"%F %T",localtime(&t));
01062 xmlFile<<" <CREATE_TIMESTAMP>"<<str<<"</CREATE_TIMESTAMP>\n";
01063 xmlFile<<" <CREATED_BY_USER>dma</CREATED_BY_USER>\n";
01064 xmlFile<<" <!-- version (string) and subversion (number) -->\n";
01065 xmlFile<<" <!-- fields are used to read data back from the database -->\n\n";
01066 xmlFile<<" <VERSION>"<<run_number<<dataset_seq_number<<"</VERSION>\n";
01067 xmlFile<<" <SUBVERSION>1</SUBVERSION>\n";
01068 xmlFile<<" <!-- Assign predefined dataset attributes -->\n\n";
01069 xmlFile<<" <PREDEFINED_ATTRIBUTES>\n";
01070 xmlFile<<" <ATTRIBUTE>\n";
01071 xmlFile<<" <NAME>HCAL Dataset Status</NAME>\n";
01072 xmlFile<<" <VALUE>VALID</VALUE>\n";
01073 xmlFile<<" </ATTRIBUTE>\n";
01074 xmlFile<<" </PREDEFINED_ATTRIBUTES>\n";
01075 xmlFile<<" <!-- multiple data block records -->\n\n";
01076
01077 std::vector <HcalElectronicsId> AllElIds = emap->allElectronicsIdPrecision();
01078 for(std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++){
01079 DetId detid=emap->lookup(*eid);
01080 if (detid.det()!=DetId::Hcal) continue;
01081 HcalGenericDetId gid(emap->lookup(*eid));
01082 if(!(!(gid.null()) &&
01083 (gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel ||
01084 gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap ||
01085 gid.genericSubdet()==HcalGenericDetId::HcalGenForward ||
01086 gid.genericSubdet()==HcalGenericDetId::HcalGenOuter))) continue;
01087 int eta,phi,depth;
01088 std::string subdet="";
01089 HcalDetId hid(detid);
01090 eta=hid.ieta();
01091 phi=hid.iphi();
01092 depth=hid.depth();
01093
01094 double ped[4]={0,0,0,0},rms[4]={0,0,0,0};
01095 if(detid.subdetId()==HcalBarrel){
01096 subdet="HB";
01097 Statistic=hb_data[eta+42][phi-1][depth-1][0].get_statistics();
01098 Status =hb_data[eta+42][phi-1][depth-1][0].get_status();
01099 hb_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
01100 hb_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
01101 hb_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
01102 hb_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
01103 }else if(detid.subdetId()==HcalEndcap){
01104 subdet="HE";
01105 he_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
01106 he_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
01107 he_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
01108 he_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
01109 Statistic=he_data[eta+42][phi-1][depth-1][0].get_statistics();
01110 Status =he_data[eta+42][phi-1][depth-1][0].get_status();
01111 }else if(detid.subdetId()==HcalForward){
01112 subdet="HF";
01113 hf_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
01114 hf_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
01115 hf_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
01116 hf_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
01117 Statistic=hf_data[eta+42][phi-1][depth-1][0].get_statistics();
01118 Status =hf_data[eta+42][phi-1][depth-1][0].get_status();
01119 }else if(detid.subdetId()==HcalOuter){
01120 subdet="HO";
01121 ho_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
01122 ho_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
01123 ho_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
01124 ho_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
01125 Statistic=ho_data[eta+42][phi-1][depth-1][0].get_statistics();
01126 Status =ho_data[eta+42][phi-1][depth-1][0].get_status();
01127 }else continue;
01128 xmlFile<<" <DATA>\n";
01129 xmlFile<<" <NUMBER_OF_EVENTS_USED>"<<Statistic<<"</NUMBER_OF_EVENTS_USED>\n";
01130 xmlFile<<" <MEAN0>"<<ped[0]<<"</MEAN0>\n";
01131 xmlFile<<" <MEAN1>"<<ped[1]<<"</MEAN1>\n";
01132 xmlFile<<" <MEAN2>"<<ped[2]<<"</MEAN2>\n";
01133 xmlFile<<" <MEAN3>"<<ped[3]<<"</MEAN3>\n";
01134 xmlFile<<" <RMS0>"<<rms[0]<<"</RMS0>\n";
01135 xmlFile<<" <RMS1>"<<rms[1]<<"</RMS1>\n";
01136 xmlFile<<" <RMS2>"<<rms[2]<<"</RMS2>\n";
01137 xmlFile<<" <RMS3>"<<rms[3]<<"</RMS3>\n";
01138 xmlFile<<" <CHANNEL_STATUS_WORD>"<<Status<<"</CHANNEL_STATUS_WORD>\n";
01139 xmlFile<<" <CHANNEL_OBJECTNAME>HcalDetId</CHANNEL_OBJECTNAME>\n";
01140 xmlFile<<" <SUBDET>"<<subdet<<"</SUBDET>\n";
01141 xmlFile<<" <IETA>"<<eta<<"</IETA>\n";
01142 xmlFile<<" <IPHI>"<<phi<<"</IPHI>\n";
01143 xmlFile<<" <DEPTH>"<<depth<<"</DEPTH>\n";
01144 xmlFile<<" <TYPE>0</TYPE>\n";
01145 xmlFile<<" </DATA>\n";
01146 }
01148 xmlFile<<" </DATA_SET>\n";
01149 xmlFile<<"</ROOT>\n";
01150 xmlFile.close();
01151 sprintf(str,"zip %s.zip %s",xmlName.c_str(),xmlName.c_str());
01152 system(str);
01153 sprintf(str,"rm -f %s",xmlName.c_str());
01154 system(str);
01155 sprintf(str,"mv -f %s.zip %s",xmlName.c_str(),XmlFilePath.c_str());
01156 system(str);
01157 }
01158 dataset_seq_number++;
01159 }
01160
01161 void HcalDetDiagPedestalMonitor::LoadReference(){
01162 double ped[4],rms[4];
01163 int Eta,Phi,Depth;
01164 char subdet[10];
01165 TFile *f;
01166 if(gSystem->AccessPathName(ReferenceData.c_str())) return;
01167 f = new TFile(ReferenceData.c_str(),"READ");
01168 if(!f->IsOpen()) return ;
01169 TObjString *STR=(TObjString *)f->Get("run number");
01170
01171 if(STR){ std::string Ref(STR->String()); ReferenceRun=Ref;}
01172
01173 TTree* t=(TTree*)f->Get("HCAL Pedestal data");
01174 if(!t) return;
01175 t->SetBranchAddress("Subdet", subdet);
01176 t->SetBranchAddress("eta", &Eta);
01177 t->SetBranchAddress("phi", &Phi);
01178 t->SetBranchAddress("depth", &Depth);
01179 t->SetBranchAddress("cap0_ped", &ped[0]);
01180 t->SetBranchAddress("cap0_rms", &rms[0]);
01181 t->SetBranchAddress("cap1_ped", &ped[1]);
01182 t->SetBranchAddress("cap1_rms", &rms[1]);
01183 t->SetBranchAddress("cap2_ped", &ped[2]);
01184 t->SetBranchAddress("cap2_rms", &rms[2]);
01185 t->SetBranchAddress("cap3_ped", &ped[3]);
01186 t->SetBranchAddress("cap3_rms", &rms[3]);
01187 for(int ievt=0;ievt<t->GetEntries();ievt++){
01188 t->GetEntry(ievt);
01189 if(strcmp(subdet,"HB")==0){
01190 hb_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
01191 hb_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
01192 hb_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
01193 hb_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
01194 }
01195 if(strcmp(subdet,"HE")==0){
01196 he_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
01197 he_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
01198 he_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
01199 he_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
01200 }
01201 if(strcmp(subdet,"HO")==0){
01202 ho_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
01203 ho_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
01204 ho_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
01205 ho_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
01206 }
01207 if(strcmp(subdet,"HF")==0){
01208 hf_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
01209 hf_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
01210 hf_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
01211 hf_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
01212 }
01213 }
01214 f->Close();
01215 IsReference=true;
01216 }
01217
01218 void HcalDetDiagPedestalMonitor::LoadDataset(){
01219 double ped[4],rms[4];
01220 int Eta,Phi,Depth,Statistic;
01221 char subdet[10];
01222 TFile *f;
01223 if(DatasetName.size()==0) return;
01224 createHTMLonly=true;
01225 if(gSystem->AccessPathName(DatasetName.c_str())) return;
01226 f = new TFile(DatasetName.c_str(),"READ");
01227 if(!f->IsOpen()) return ;
01228
01229 TTree* t=0;
01230 t=(TTree*)f->Get("HCAL Pedestal data");
01231 if(!t) return;
01232 t->SetBranchAddress("Subdet", subdet);
01233 t->SetBranchAddress("eta", &Eta);
01234 t->SetBranchAddress("phi", &Phi);
01235 t->SetBranchAddress("depth", &Depth);
01236 t->SetBranchAddress("cap0_ped", &ped[0]);
01237 t->SetBranchAddress("cap0_rms", &rms[0]);
01238 t->SetBranchAddress("cap1_ped", &ped[1]);
01239 t->SetBranchAddress("cap1_rms", &rms[1]);
01240 t->SetBranchAddress("cap2_ped", &ped[2]);
01241 t->SetBranchAddress("cap2_rms", &rms[2]);
01242 t->SetBranchAddress("cap3_ped", &ped[3]);
01243 t->SetBranchAddress("cap3_rms", &rms[3]);
01244 t->SetBranchAddress("statistic",&Statistic);
01245
01246 for(int ievt=0;ievt<t->GetEntries();ievt++){
01247 t->GetEntry(ievt);
01248 if(strcmp(subdet,"HB")==0){ nHB++;
01249 hb_data[Eta+42][Phi-1][Depth-1][0].set_data(ped[0],rms[0]);
01250 hb_data[Eta+42][Phi-1][Depth-1][1].set_data(ped[1],rms[1]);
01251 hb_data[Eta+42][Phi-1][Depth-1][2].set_data(ped[2],rms[2]);
01252 hb_data[Eta+42][Phi-1][Depth-1][3].set_data(ped[3],rms[3]);
01253 hb_data[Eta+42][Phi-1][Depth-1][0].set_statistics(Statistic);
01254 hb_data[Eta+42][Phi-1][Depth-1][1].set_statistics(Statistic);
01255 hb_data[Eta+42][Phi-1][Depth-1][2].set_statistics(Statistic);
01256 hb_data[Eta+42][Phi-1][Depth-1][3].set_statistics(Statistic);
01257 }
01258 if(strcmp(subdet,"HE")==0){ nHE++;
01259 he_data[Eta+42][Phi-1][Depth-1][0].set_data(ped[0],rms[0]);
01260 he_data[Eta+42][Phi-1][Depth-1][1].set_data(ped[1],rms[1]);
01261 he_data[Eta+42][Phi-1][Depth-1][2].set_data(ped[2],rms[2]);
01262 he_data[Eta+42][Phi-1][Depth-1][3].set_data(ped[3],rms[3]);
01263 he_data[Eta+42][Phi-1][Depth-1][0].set_statistics(Statistic);
01264 he_data[Eta+42][Phi-1][Depth-1][1].set_statistics(Statistic);
01265 he_data[Eta+42][Phi-1][Depth-1][2].set_statistics(Statistic);
01266 he_data[Eta+42][Phi-1][Depth-1][3].set_statistics(Statistic);
01267 }
01268 if(strcmp(subdet,"HO")==0){ nHO++;
01269 ho_data[Eta+42][Phi-1][Depth-1][0].set_data(ped[0],rms[0]);
01270 ho_data[Eta+42][Phi-1][Depth-1][1].set_data(ped[1],rms[1]);
01271 ho_data[Eta+42][Phi-1][Depth-1][2].set_data(ped[2],rms[2]);
01272 ho_data[Eta+42][Phi-1][Depth-1][3].set_data(ped[3],rms[3]);
01273 ho_data[Eta+42][Phi-1][Depth-1][0].set_statistics(Statistic);
01274 ho_data[Eta+42][Phi-1][Depth-1][1].set_statistics(Statistic);
01275 ho_data[Eta+42][Phi-1][Depth-1][2].set_statistics(Statistic);
01276 ho_data[Eta+42][Phi-1][Depth-1][3].set_statistics(Statistic);
01277 }
01278 if(strcmp(subdet,"HF")==0){ nHF++;
01279 hf_data[Eta+42][Phi-1][Depth-1][0].set_data(ped[0],rms[0]);
01280 hf_data[Eta+42][Phi-1][Depth-1][1].set_data(ped[1],rms[1]);
01281 hf_data[Eta+42][Phi-1][Depth-1][2].set_data(ped[2],rms[2]);
01282 hf_data[Eta+42][Phi-1][Depth-1][3].set_data(ped[3],rms[3]);
01283 hf_data[Eta+42][Phi-1][Depth-1][0].set_statistics(Statistic);
01284 hf_data[Eta+42][Phi-1][Depth-1][1].set_statistics(Statistic);
01285 hf_data[Eta+42][Phi-1][Depth-1][2].set_statistics(Statistic);
01286 hf_data[Eta+42][Phi-1][Depth-1][3].set_statistics(Statistic);
01287 }
01288 }
01289 TObjString *STR1=(TObjString *)f->Get("run number");
01290 if(STR1){ int run; sscanf(STR1->String(),"%i",&run); meRUN_->Fill(run); run_number=run;}
01291
01292 TObjString *STR2=(TObjString *)f->Get("Total events processed");
01293 if(STR2){ int events; sscanf(STR2->String(),"%i",&events); meEVT_->Fill(events); ievt_=events;}
01294
01295 TObjString *STR3=(TObjString *)f->Get("Dataset number");
01296 if(STR3){ int ds; sscanf(STR3->String(),"%i",&ds); dataset_seq_number=ds;}
01297
01298 f->Close();
01299 }
01300 void HcalDetDiagPedestalMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c){}
01301 void HcalDetDiagPedestalMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c){}
01302
01303
01304 DEFINE_FWK_MODULE(HcalDetDiagPedestalMonitor);