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