00001 #include "DQMServices/Core/interface/MonitorElement.h"
00002
00003 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00004
00005 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
00006
00007 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00008
00009 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00010
00011 #include "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
00012 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00013 #include "DQM/HcalMonitorTasks/interface/HcalBaseDQMonitor.h"
00014 #include "DQM/HcalMonitorTasks/interface/HcalEtaPhiHists.h"
00015 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00016 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00017 #include "CondFormats/HcalObjects/interface/HcalElectronicsMap.h"
00018 #include "DQM/HcalMonitorTasks/interface/HcalEtaPhiHists.h"
00019
00020 #include "TFile.h"
00021 #include "TTree.h"
00022 #include "TSystem.h"
00023 #include <math.h>
00024 #include <iostream>
00025 #include <fstream>
00026
00027
00028 class HcalDetDiagLEDData{
00029 public:
00030 HcalDetDiagLEDData(){
00031 IsRefetence=false;
00032 status=0;
00033 reset();
00034 }
00035 void reset(){
00036 Xe=XXe=Xt=XXt=n=0;
00037 overflow=0;
00038 undeflow=0;
00039 }
00040 void add_statistics(double *data,int nTS){
00041 double e=GetEnergy(data,nTS);
00042 double t=GetTime(data,nTS);
00043 if(e<20) undeflow++; else if(e>10000) overflow++; else{
00044 n++; Xe+=e; XXe+=e*e; Xt+=t; XXt+=t*t;
00045 }
00046 }
00047 void set_reference(float val,float rms){
00048 ref_led=val; ref_rms=rms;
00049 IsRefetence=true;
00050 }
00051 void change_status(int val){
00052 status|=val;
00053 }
00054 int get_status(){
00055 return status;
00056 }
00057 bool get_reference(double *val,double *rms){
00058 *val=ref_led; *rms=ref_rms;
00059 return IsRefetence;
00060 }
00061 bool get_average_led(double *ave,double *rms){
00062 if(n>0){ *ave=Xe/n; *rms=sqrt(XXe/n-(Xe*Xe)/(n*n));} else return false;
00063 return true;
00064 }
00065 bool get_average_time(double *ave,double *rms){
00066 if(n>0){ *ave=Xt/n; *rms=sqrt(XXt/n-(Xt*Xt)/(n*n));} else return false;
00067 return true;
00068 }
00069 int get_statistics(){
00070 return (int)n;
00071 }
00072 int get_overflow(){
00073 return overflow;
00074 }
00075 int get_undeflow(){
00076 return undeflow;
00077 }
00078 private:
00079 double GetEnergy(double *data,int n){
00080 int MaxI=0; double Energy,MaxE=0;
00081 for(int j=0;j<n;++j) if(MaxE<data[j]){ MaxE=data[j]; MaxI=j; }
00082 Energy=data[MaxI];
00083 if(MaxI>0) Energy+=data[MaxI-1];
00084 if(MaxI>1) Energy+=data[MaxI-2];
00085 if(MaxI<(n-1)) Energy+=data[MaxI+1];
00086 if(MaxI<(n-2)) Energy+=data[MaxI+2];
00087 return Energy;
00088 }
00089 double GetTime(double *data,int n=10){
00090 int MaxI=0; double Time=-9999,SumT=0,MaxT=-10;
00091 for(int j=0;j<n;++j) if(MaxT<data[j]){ MaxT=data[j]; MaxI=j; }
00092 Time=MaxI*data[MaxI];
00093 SumT=data[MaxI];
00094 if(MaxI>0){ Time+=(MaxI-1)*data[MaxI-1]; SumT+=data[MaxI-1]; }
00095 if(MaxI<(n-1)){ Time+=(MaxI+1)*data[MaxI+1]; SumT+=data[MaxI+1]; }
00096 Time=Time/SumT;
00097 return Time;
00098 }
00099 int overflow;
00100 int undeflow;
00101 double Xe,XXe,Xt,XXt,n;
00102 bool IsRefetence;
00103 float ref_led;
00104 float ref_rms;
00105 int status;
00106 };
00107
00108 class HcalDetDiagLEDMonitor:public HcalBaseDQMonitor {
00109 public:
00110 HcalDetDiagLEDMonitor(const edm::ParameterSet& ps);
00111 ~HcalDetDiagLEDMonitor();
00112
00113 void beginRun(const edm::Run& run, const edm::EventSetup& c);
00114 void setup();
00115 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00116 void endRun(const edm::Run& run, const edm::EventSetup& c);
00117 void reset();
00118 void cleanup();
00119 void fillHistos();
00120 int GetStatistics(){ return ievt_; }
00121 private:
00122 HcalLogicalMapGenerator *gen;
00123 HcalElectronicsMap emap;
00124 HcalLogicalMap *lmap;
00125 void SaveReference();
00126 void LoadReference();
00127 void CheckStatus();
00128
00129 HcalDetDiagLEDData* GetCalib(std::string sd,int eta,int phi){
00130 int SD=0,ETA=0,PHI=0;
00131 if(sd.compare("HB")==0) SD=1;
00132 if(sd.compare("HE")==0) SD=2;
00133 if(sd.compare("HO")==0) SD=3;
00134 if(sd.compare("HF")==0) SD=4;
00135 if(SD==1 || SD==2){
00136 if(eta>0) ETA=1; else ETA=-1;
00137 if(phi==71 ||phi==72 || phi==1 || phi==2) PHI=71; else PHI=((phi-3)/4)*4+3;
00138 }else if(SD==3){
00139 if(abs(eta)<=4){
00140 ETA=0;
00141 if(phi==71 ||phi==72 || phi==1 || phi==2 || phi==3 || phi==4) PHI=71; else PHI=((phi-5)/6)*6+5;
00142 }else{
00143 if(abs(eta)>4 && abs(eta)<=10) ETA=1;
00144 if(abs(eta)>10 && abs(eta)<=15) ETA=2;
00145 if(eta<0) ETA=-ETA;
00146 if(phi==71 ||phi==72 || (phi>=1 && phi<=10)) PHI=71; else PHI=((phi-11)/12)*12+11;
00147 }
00148 }else if(SD==4){
00149 if(eta>0) ETA=1; else ETA=-1;
00150 if(phi>=1 && phi<=18) PHI=1;
00151 if(phi>=19 && phi<=36) PHI=19;
00152 if(phi>=37 && phi<=54) PHI=37;
00153 if(phi>=55 && phi<=72) PHI=55;
00154 }
00155 return &calib_data[SD][ETA+2][PHI-1];
00156 };
00157 int ievt_;
00158 int run_number;
00159 int dataset_seq_number;
00160 bool IsReference;
00161
00162 double LEDMeanTreshold;
00163 double LEDRmsTreshold;
00164
00165 std::string ReferenceData;
00166 std::string ReferenceRun;
00167 std::string OutputFilePath;
00168 std::string XmlFilePath;
00169
00170 MonitorElement *meEVT_,*meRUN_;
00171 MonitorElement *RefRun_;
00172 MonitorElement *Energy;
00173 MonitorElement *Time;
00174 MonitorElement *EnergyHF;
00175 MonitorElement *TimeHF;
00176 MonitorElement *Time2Dhbhehf;
00177 MonitorElement *Time2Dho;
00178 MonitorElement *Energy2Dhbhehf;
00179 MonitorElement *Energy2Dho;
00180 MonitorElement *EnergyRMS;
00181 MonitorElement *TimeRMS;
00182 MonitorElement *EnergyRMSHF;
00183 MonitorElement *TimeRMSHF;
00184 MonitorElement *EnergyCorr;
00185 MonitorElement *HBPphi;
00186 MonitorElement *HBMphi;
00187 MonitorElement *HEPphi;
00188 MonitorElement *HEMphi;
00189 MonitorElement *HFPphi;
00190 MonitorElement *HFMphi;
00191 MonitorElement *HO0phi;
00192 MonitorElement *HO1Pphi;
00193 MonitorElement *HO2Pphi;
00194 MonitorElement *HO1Mphi;
00195 MonitorElement *HO2Mphi;
00196
00197 HcalDetDiagLEDData hb_data[85][72][4];
00198 HcalDetDiagLEDData he_data[85][72][4];
00199 HcalDetDiagLEDData ho_data[85][72][4];
00200 HcalDetDiagLEDData hf_data[85][72][4];
00201 HcalDetDiagLEDData calib_data[5][5][72];
00202
00203 EtaPhiHists *ChannelsLEDEnergy;
00204 EtaPhiHists *ChannelsLEDEnergyRef;
00205 EtaPhiHists *ChannelStatusMissingChannels;
00206 EtaPhiHists *ChannelStatusUnstableChannels;
00207 EtaPhiHists *ChannelStatusUnstableLEDsignal;
00208 EtaPhiHists *ChannelStatusLEDMean;
00209 EtaPhiHists *ChannelStatusLEDRMS;
00210 EtaPhiHists *ChannelStatusTimeMean;
00211 EtaPhiHists *ChannelStatusTimeRMS;
00212
00213 edm::InputTag digiLabel_;
00214 edm::InputTag calibDigiLabel_;
00215
00216 std::map<unsigned int, int> KnownBadCells_;
00217
00218 void fill_channel_status(std::string subdet,int eta,int phi,int depth,int type,double status);
00219 void fill_energy(std::string subdet,int eta,int phi,int depth,double e,int type);
00220 double get_energy(std::string subdet,int eta,int phi,int depth,int type);
00221 };
00222
00224 static const float adc2fC[128]={-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5, 10.5,11.5,12.5,
00225 13.5,15.,17.,19.,21.,23.,25.,27.,29.5,32.5,35.5,38.5,42.,46.,50.,54.5,59.5,
00226 64.5,59.5,64.5,69.5,74.5,79.5,84.5,89.5,94.5,99.5,104.5,109.5,114.5,119.5,
00227 124.5,129.5,137.,147.,157.,167.,177.,187.,197.,209.5,224.5,239.5,254.5,272.,
00228 292.,312.,334.5,359.5,384.5,359.5,384.5,409.5,434.5,459.5,484.5,509.5,534.5,
00229 559.5,584.5,609.5,634.5,659.5,684.5,709.5,747.,797.,847.,897.,947.,997.,
00230 1047.,1109.5,1184.5,1259.5,1334.5,1422.,1522.,1622.,1734.5,1859.5,1984.5,
00231 1859.5,1984.5,2109.5,2234.5,2359.5,2484.5,2609.5,2734.5,2859.5,2984.5,
00232 3109.5,3234.5,3359.5,3484.5,3609.5,3797.,4047.,4297.,4547.,4797.,5047.,
00233 5297.,5609.5,5984.5,6359.5,6734.5,7172.,7672.,8172.,8734.5,9359.5,9984.5};
00235
00236
00237
00238
00239 HcalDetDiagLEDMonitor::HcalDetDiagLEDMonitor(const edm::ParameterSet& ps) {
00240 ievt_=0;
00241 dataset_seq_number=1;
00242 run_number=-1;
00243 IsReference=false;
00244
00245 Online_ = ps.getUntrackedParameter<bool>("online",false);
00246 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
00247 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
00248 debug_ = ps.getUntrackedParameter<int>("debug",0);
00249 prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00250 if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00251 prefixME_.append("/");
00252 subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","DetDiagLEDMonitor_Hcal");
00253 if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00254 subdir_.append("/");
00255 subdir_=prefixME_+subdir_;
00256 AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00257 skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
00258 NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00259 makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00260
00261 LEDMeanTreshold = ps.getUntrackedParameter<double>("LEDMeanTreshold" , 0.1);
00262 LEDRmsTreshold = ps.getUntrackedParameter<double>("LEDRmsTreshold" , 0.1);
00263
00264 ReferenceData = ps.getUntrackedParameter<std::string>("LEDReferenceData" ,"");
00265 OutputFilePath = ps.getUntrackedParameter<std::string>("OutputFilePath", "");
00266 XmlFilePath = ps.getUntrackedParameter<std::string>("XmlFilePath", "");
00267
00268 digiLabel_ = ps.getUntrackedParameter<edm::InputTag>("digiLabel", edm::InputTag("hcalDigis"));
00269 calibDigiLabel_ = ps.getUntrackedParameter<edm::InputTag>("calibDigiLabel",edm::InputTag("hcalDigis"));
00270 }
00271
00272 HcalDetDiagLEDMonitor::~HcalDetDiagLEDMonitor(){}
00273
00274 void HcalDetDiagLEDMonitor::cleanup(){
00275 if(dbe_){
00276 dbe_->setCurrentFolder(subdir_);
00277 dbe_->removeContents();
00278 dbe_ = 0;
00279 }
00280 }
00281 void HcalDetDiagLEDMonitor::reset(){}
00282
00283 void HcalDetDiagLEDMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00284 {
00285 if (debug_>1) std::cout <<"HcalDetDiagLEDMonitor::beginRun"<<std::endl;
00286 HcalBaseDQMonitor::beginRun(run,c);
00287
00288 if (tevt_==0) this->setup();
00289 if (mergeRuns_==false) this->reset();
00290
00291 edm::ESHandle<HcalChannelQuality> p;
00292 c.get<HcalChannelQualityRcd>().get(p);
00293 HcalChannelQuality* chanquality= new HcalChannelQuality(*p.product());
00294 std::vector<DetId> mydetids = chanquality->getAllChannels();
00295 KnownBadCells_.clear();
00296
00297 for (std::vector<DetId>::const_iterator i = mydetids.begin();i!=mydetids.end();++i){
00298 if (i->det()!=DetId::Hcal) continue;
00299 HcalDetId id=HcalDetId(*i);
00300 int status=(chanquality->getValues(id))->getValue();
00301 if((status & HcalChannelStatus::HcalCellOff) || (status & HcalChannelStatus::HcalCellMask)){
00302 KnownBadCells_[id.rawId()]=status;
00303 }
00304 }
00305
00306 return;
00307 }
00308
00309 void HcalDetDiagLEDMonitor::setup(){
00310
00311 HcalBaseDQMonitor::setup();
00312 if (!dbe_) return;
00313
00314 std::string name;
00315 dbe_->setCurrentFolder(subdir_);
00316 meEVT_ = dbe_->bookInt("HcalDetDiagLEDMonitor Event Number");
00317 meRUN_ = dbe_->bookInt("HcalDetDiagLEDMonitor Run Number");
00318 ReferenceRun="UNKNOWN";
00319 LoadReference();
00320 dbe_->setCurrentFolder(subdir_);
00321 RefRun_= dbe_->bookString("HcalDetDiagLEDMonitor Reference Run",ReferenceRun);
00322 dbe_->setCurrentFolder(subdir_+"Summary Plots");
00323
00324 name="HBHEHO LED Energy Distribution"; Energy = dbe_->book1D(name,name,200,0,3000);
00325 name="HBHEHO LED Timing Distribution"; Time = dbe_->book1D(name,name,200,0,10);
00326 name="HBHEHO LED Energy RMS_div_Energy Distribution";EnergyRMS = dbe_->book1D(name,name,200,0,0.2);
00327 name="HBHEHO LED Timing RMS Distribution"; TimeRMS = dbe_->book1D(name,name,200,0,0.4);
00328 name="HF LED Energy Distribution"; EnergyHF = dbe_->book1D(name,name,200,0,3000);
00329 name="HF LED Timing Distribution"; TimeHF = dbe_->book1D(name,name,200,0,10);
00330 name="HF LED Energy RMS_div_Energy Distribution"; EnergyRMSHF = dbe_->book1D(name,name,200,0,0.5);
00331 name="HF LED Timing RMS Distribution"; TimeRMSHF = dbe_->book1D(name,name,200,0,0.4);
00332 name="LED Energy Corr(PinDiod) Distribution"; EnergyCorr = dbe_->book1D(name,name,200,0,10);
00333 name="LED Timing HBHEHF"; Time2Dhbhehf = dbe_->book2D(name,name,87,-43,43,74,0,73);
00334 name="LED Timing HO"; Time2Dho = dbe_->book2D(name,name,33,-16,16,74,0,73);
00335 name="LED Energy HBHEHF"; Energy2Dhbhehf = dbe_->book2D(name,name,87,-43,43,74,0,73);
00336 name="LED Energy HO"; Energy2Dho = dbe_->book2D(name,name,33,-16,16,74,0,73);
00337
00338 name="HBP Average over HPD LED Ref"; HBPphi = dbe_->book2D(name,name,180,1,73,400,0,2);
00339 name="HBM Average over HPD LED Ref"; HBMphi = dbe_->book2D(name,name,180,1,73,400,0,2);
00340 name="HEP Average over HPD LED Ref"; HEPphi = dbe_->book2D(name,name,180,1,73,400,0,2);
00341 name="HEM Average over HPD LED Ref"; HEMphi = dbe_->book2D(name,name,180,1,73,400,0,2);
00342 name="HFP Average over RM LED Ref"; HFPphi = dbe_->book2D(name,name,180,1,37,400,0,2);
00343 name="HFM Average over RM LED Ref"; HFMphi = dbe_->book2D(name,name,180,1,37,400,0,2);
00344 name="HO0 Average over HPD LED Ref"; HO0phi = dbe_->book2D(name,name,180,1,49,400,0,2);
00345 name="HO1P Average over HPD LED Ref"; HO1Pphi= dbe_->book2D(name,name,180,1,49,400,0,2);
00346 name="HO2P Average over HPD LED Ref"; HO2Pphi= dbe_->book2D(name,name,180,1,49,400,0,2);
00347 name="HO1M Average over HPD LED Ref"; HO1Mphi= dbe_->book2D(name,name,180,1,49,400,0,2);
00348 name="HO2M Average over HPD LED Ref"; HO2Mphi= dbe_->book2D(name,name,180,1,49,400,0,2);
00349
00350 ChannelsLEDEnergy = new EtaPhiHists();
00351 ChannelsLEDEnergy->setup(dbe_," Channel LED Energy");
00352 ChannelsLEDEnergyRef = new EtaPhiHists();
00353 ChannelsLEDEnergyRef->setup(dbe_," Channel LED Energy Reference");
00354
00355 dbe_->setCurrentFolder(subdir_+"channel status");
00356 ChannelStatusMissingChannels = new EtaPhiHists();
00357 ChannelStatusMissingChannels->setup(dbe_," Missing Channels");
00358 ChannelStatusUnstableChannels = new EtaPhiHists();
00359 ChannelStatusUnstableChannels->setup(dbe_," Unstable Channels");
00360 ChannelStatusUnstableLEDsignal = new EtaPhiHists();
00361 ChannelStatusUnstableLEDsignal->setup(dbe_," Unstable LED");
00362 ChannelStatusLEDMean = new EtaPhiHists();
00363 ChannelStatusLEDMean->setup(dbe_," LED Mean");
00364 ChannelStatusLEDRMS = new EtaPhiHists();
00365 ChannelStatusLEDRMS->setup(dbe_," LED RMS");
00366 ChannelStatusTimeMean = new EtaPhiHists();
00367 ChannelStatusTimeMean->setup(dbe_," Time Mean");
00368 ChannelStatusTimeRMS = new EtaPhiHists();
00369 ChannelStatusTimeRMS->setup(dbe_," Time RMS");
00370
00371 gen=new HcalLogicalMapGenerator();
00372 lmap =new HcalLogicalMap(gen->createMap());
00373 emap=lmap->generateHcalElectronicsMap();
00374 return;
00375 }
00376
00377 void HcalDetDiagLEDMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00378 int eta,phi,depth,nTS;
00379 if(!dbe_) return;
00380 bool LEDEvent=false;
00381 bool LocalRun=false;
00382
00383
00384 edm::Handle<HcalTBTriggerData> trigger_data;
00385 iEvent.getByType(trigger_data);
00386 if(trigger_data.isValid()){
00387 if(trigger_data->triggerWord()==6){ LEDEvent=true;LocalRun=true;}
00388 }
00389 if(!LocalRun) return;
00390 if(!LEDEvent) return;
00391
00392 HcalBaseDQMonitor::analyze(iEvent, iSetup);
00393 meEVT_->Fill(++ievt_);
00394 run_number=iEvent.id().run();
00395 meRUN_->Fill(iEvent.id().run());
00396
00397 double data[20];
00398
00399 edm::Handle<HBHEDigiCollection> hbhe;
00400 iEvent.getByLabel(digiLabel_, hbhe);
00401 if(hbhe.isValid()) for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
00402 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
00403 if(digi->id().subdet()==HcalBarrel){
00404 for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()&0xff]-2.5;
00405 hb_data[eta+42][phi-1][depth-1].add_statistics(data,nTS);
00406 }
00407 if(digi->id().subdet()==HcalEndcap){
00408 for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()&0xff]-2.5;
00409 he_data[eta+42][phi-1][depth-1].add_statistics(data,nTS);
00410 }
00411 }
00412
00413 edm::Handle<HODigiCollection> ho;
00414 iEvent.getByLabel(digiLabel_,ho);
00415 if(ho.isValid()) for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
00416 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
00417 for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()&0xff]-2.5;
00418 ho_data[eta+42][phi-1][depth-1].add_statistics(data,nTS);
00419 }
00420
00421 edm::Handle<HFDigiCollection> hf;
00422 iEvent.getByLabel(digiLabel_,hf);
00423 if(hf.isValid()) for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
00424 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
00425 for(int i=0;i<nTS;i++) data[i]=adc2fC[digi->sample(i).adc()&0xff]-2.5;
00426 hf_data[eta+42][phi-1][depth-1].add_statistics(data,nTS);
00427 }
00428
00429 edm::Handle<HcalCalibDigiCollection> calib;
00430 iEvent.getByLabel(calibDigiLabel_, calib);
00431 if(calib.isValid())for(HcalCalibDigiCollection::const_iterator digi=calib->begin();digi!=calib->end();digi++){
00432 if(digi->id().cboxChannel()!=0 || digi->id().hcalSubdet()==0) continue;
00433 nTS=digi->size();
00434 double e=0;
00435 for(int i=0;i<nTS;i++){ data[i]=adc2fC[digi->sample(i).adc()&0xff]; e+=data[i];}
00436 if(e<15000) calib_data[digi->id().hcalSubdet()][digi->id().ieta()+2][digi->id().iphi()-1].add_statistics(data,nTS);
00437 }
00438
00439 if(((ievt_)%500)==0){
00440 fillHistos();
00441 CheckStatus();
00442 }
00443 return;
00444 }
00445
00446
00447 void HcalDetDiagLEDMonitor::fillHistos(){
00448 std::string subdet[4]={"HB","HE","HO","HF"};
00449 Energy->Reset();
00450 Time->Reset();
00451 EnergyRMS->Reset();
00452 TimeRMS->Reset();
00453 EnergyHF->Reset();
00454 TimeHF->Reset();
00455 EnergyRMSHF->Reset();
00456 TimeRMSHF->Reset();
00457 EnergyCorr->Reset();
00458 Time2Dhbhehf->Reset();
00459 Time2Dho->Reset();
00460 Energy2Dhbhehf->Reset();
00461 Energy2Dho->Reset();
00462 HBPphi->Reset();
00463 HBMphi->Reset();
00464 HEPphi->Reset();
00465 HEMphi->Reset();
00466 HFPphi->Reset();
00467 HFMphi->Reset();
00468 HO0phi->Reset();
00469 HO1Pphi->Reset();
00470 HO2Pphi->Reset();
00471 HO1Mphi->Reset();
00472 HO2Mphi->Reset();
00473
00474
00475 for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++){
00476 double T=0,nT=0,E=0,nE=0;
00477 for(int depth=1;depth<=2;depth++){
00478 if(hb_data[eta+42][phi-1][depth-1].get_statistics()>100){
00479 double ave=0;
00480 double rms=0;
00481 double time=0;
00482 double time_rms=0;
00483 hb_data[eta+42][phi-1][depth-1].get_average_led(&ave,&rms);
00484 hb_data[eta+42][phi-1][depth-1].get_average_time(&time,&time_rms);
00485 Energy->Fill(ave);
00486 if(ave>0)EnergyRMS->Fill(rms/ave);
00487 Time->Fill(time);
00488 TimeRMS->Fill(time_rms);
00489 T+=time; nT++; E+=ave; nE++;
00490 if(GetCalib("HB",eta,phi)->get_statistics()>100){
00491 double ave_calib=0;
00492 double rms_calib=0;
00493 GetCalib("HB",eta,phi)->get_average_led(&ave_calib,&rms_calib);
00494 fill_energy("HB",eta,phi,depth,ave/ave_calib,1);
00495 EnergyCorr->Fill(ave_calib/ave);
00496 }
00497 }
00498 }
00499 if(nT>0){Time2Dhbhehf->Fill(eta,phi,T/nT);Energy2Dhbhehf->Fill(eta,phi,E/nE); }
00500 }
00501
00502 for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++){
00503 double T=0,nT=0,E=0,nE=0;
00504 for(int depth=1;depth<=3;depth++){
00505 if(he_data[eta+42][phi-1][depth-1].get_statistics()>100){
00506 double ave=0;
00507 double rms=0;
00508 double time=0;
00509 double time_rms=0;
00510 he_data[eta+42][phi-1][depth-1].get_average_led(&ave,&rms);
00511 he_data[eta+42][phi-1][depth-1].get_average_time(&time,&time_rms);
00512 Energy->Fill(ave);
00513 if(ave>0)EnergyRMS->Fill(rms/ave);
00514 Time->Fill(time);
00515 T+=time; nT++; E+=ave; nE++;
00516 TimeRMS->Fill(time_rms);
00517 if(GetCalib("HE",eta,phi)->get_statistics()>100){
00518 double ave_calib=0;
00519 double rms_calib=0;
00520 GetCalib("HE",eta,phi)->get_average_led(&ave_calib,&rms_calib);
00521 fill_energy("HE",eta,phi,depth,ave/ave_calib,1);
00522 EnergyCorr->Fill(ave_calib/ave);
00523 }
00524 }
00525 }
00526 if(nT>0 && abs(eta)>16 ){Time2Dhbhehf->Fill(eta,phi,T/nT); Energy2Dhbhehf->Fill(eta,phi,E/nE); }
00527 if(nT>0 && abs(eta)>20 ){Time2Dhbhehf->Fill(eta,phi+1,T/nT); Energy2Dhbhehf->Fill(eta,phi+1,E/nE);}
00528 }
00529
00530 for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++){
00531 double T=0,nT=0,E=0,nE=0;
00532 for(int depth=1;depth<=2;depth++){
00533 if(hf_data[eta+42][phi-1][depth-1].get_statistics()>100){
00534 double ave=0;
00535 double rms=0;
00536 double time=0;
00537 double time_rms=0;
00538 hf_data[eta+42][phi-1][depth-1].get_average_led(&ave,&rms);
00539 hf_data[eta+42][phi-1][depth-1].get_average_time(&time,&time_rms);
00540 EnergyHF->Fill(ave);
00541 if(ave>0)EnergyRMSHF->Fill(rms/ave);
00542 TimeHF->Fill(time);
00543 T+=time; nT++; E+=ave; nE++;
00544 TimeRMSHF->Fill(time_rms);
00545 if(GetCalib("HF",eta,phi)->get_statistics()>100){
00546 double ave_calib=0;
00547 double rms_calib=0;
00548 GetCalib("HF",eta,phi)->get_average_led(&ave_calib,&rms_calib);
00549 fill_energy("HF",eta,phi,depth,ave/ave_calib,1);
00550 EnergyCorr->Fill(ave_calib/ave);
00551 }
00552 }
00553 }
00554 if(nT>0 && abs(eta)>29 ){ Time2Dhbhehf->Fill(eta,phi,T/nT); Time2Dhbhehf->Fill(eta,phi+1,T/nT);}
00555 if(nT>0 && abs(eta)>29 ){ Energy2Dhbhehf->Fill(eta,phi,E/nE); Energy2Dhbhehf->Fill(eta,phi+1,E/nE);}
00556 }
00557
00558 for(int eta=-10;eta<=15;eta++) for(int phi=1;phi<=72;phi++){
00559 double T=0,nT=0,E=0,nE=0;
00560 if(eta>10 && !isSiPM(eta,phi,4)) continue;
00561 for(int depth=4;depth<=4;depth++){
00562 if(ho_data[eta+42][phi-1][depth-1].get_statistics()>100){
00563 double ave=0;
00564 double rms=0;
00565 double time=0;
00566 double time_rms=0;
00567 ho_data[eta+42][phi-1][depth-1].get_average_led(&ave,&rms);
00568 ho_data[eta+42][phi-1][depth-1].get_average_time(&time,&time_rms);
00569 Energy->Fill(ave);
00570 if(ave>0)EnergyRMS->Fill(rms/ave);
00571 Time->Fill(time);
00572 T+=time; nT++; E+=ave; nE++;
00573 TimeRMS->Fill(time_rms);
00574 if(GetCalib("HO",eta,phi)->get_statistics()>100){
00575 double ave_calib=0;
00576 double rms_calib=0;
00577 GetCalib("HO",eta,phi)->get_average_led(&ave_calib,&rms_calib);
00578 fill_energy("HO",eta,phi,depth,ave/ave_calib,1);
00579 EnergyCorr->Fill(ave_calib/ave);
00580 }
00581 }
00582 }
00583 if(nT>0){ Time2Dho->Fill(eta,phi,T/nT); Energy2Dho->Fill(eta,phi+1,E/nE) ;}
00584 }
00585
00586 double ave=0.,rms=0.,ave_calib=0.,rms_calib=0.;
00587
00588 for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00589 if(hb_data[eta+42][phi-1][depth-1].get_reference(&ave,&rms) && GetCalib("HB",eta,phi)->get_reference(&ave_calib,&rms_calib)){
00590 fill_energy("HB",eta,phi,depth,ave/ave_calib,2);
00591 }
00592 }
00593
00594 for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=3;depth++){
00595 if(he_data[eta+42][phi-1][depth-1].get_reference(&ave,&rms) && GetCalib("HE",eta,phi)->get_reference(&ave_calib,&rms_calib)){
00596 fill_energy("HE",eta,phi,depth,ave/ave_calib,2);
00597 }
00598 }
00599
00600 for(int eta=-10;eta<=15;eta++) for(int phi=1;phi<=72;phi++) for(int depth=4;depth<=4;depth++){
00601 if(eta>10 && !isSiPM(eta,phi,4)) continue;
00602 if(ho_data[eta+42][phi-1][depth-1].get_reference(&ave,&rms) && GetCalib("HO",eta,phi)->get_reference(&ave_calib,&rms_calib)){
00603 fill_energy("HO",eta,phi,depth,ave/ave_calib,2);
00604 }
00605 }
00606
00607 for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00608 if(hf_data[eta+42][phi-1][depth-1].get_reference(&ave,&rms) && GetCalib("HF",eta,phi)->get_reference(&ave_calib,&rms_calib)){
00609 fill_energy("HF",eta,phi,depth,ave/ave_calib,2);
00610 }
00611 }
00612
00613
00614 double hbp[18][4],nhbp[18][4],hbm[18][4],nhbm[18][4];
00615 double hep[18][4],nhep[18][4],hem[18][4],nhem[18][4];
00616 double hfp[18][4],nhfp[18][4],hfm[18][4],nhfm[18][4];
00617 double ho0[18][4],nho0[18][4];
00618 double ho1p[18][4],nho1p[18][4];
00619 double ho2p[18][4],nho2p[18][4];
00620 double ho1m[18][4],nho1m[18][4];
00621 double ho2m[18][4],nho2m[18][4];
00622 for(int i=0;i<18;i++) for(int j=0;j<4;j++)
00623 hbp[i][j]=nhbp[i][j]=hbm[i][j]=nhbm[i][j]=hep[i][j]=nhep[i][j]=hem[i][j]=nhem[i][j]=hfp[i][j]=nhfp[i][j]=hfm[i][j]=nhfm[i][j]=0;
00624 for(int i=0;i<18;i++) for(int j=0;j<4;j++)
00625 ho0[i][j]=nho0[i][j]=ho1p[i][j]=nho1p[i][j]=ho2p[i][j]=nho2p[i][j]=ho1m[i][j]=nho1m[i][j]=ho2m[i][j]=nho2m[i][j]=0;
00626
00627 std::vector <HcalElectronicsId> AllElIds = emap.allElectronicsIdPrecision();
00628 for(std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++){
00629 DetId detid=emap.lookup(*eid);
00630 if(detid.det()!=DetId::Hcal) continue;
00631 HcalGenericDetId gid(emap.lookup(*eid));
00632 if(!(!(gid.null()) &&
00633 (gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel ||
00634 gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap ||
00635 gid.genericSubdet()==HcalGenericDetId::HcalGenForward ||
00636 gid.genericSubdet()==HcalGenericDetId::HcalGenOuter))) continue;
00637 int sd=0,eta=0,phi=0,depth=0;
00638 if(gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel) sd=0;
00639 else if(gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap) sd=1;
00640 else if(gid.genericSubdet()==HcalGenericDetId::HcalGenOuter) sd=2;
00641 else if(gid.genericSubdet()==HcalGenericDetId::HcalGenForward)sd=3;
00642 HcalDetId hid(detid);
00643 if(KnownBadCells_.find(hid.rawId())==KnownBadCells_.end()) continue;
00644
00645 eta=hid.ieta();
00646 phi=hid.iphi();
00647 depth=hid.depth();
00648
00649 double ave =get_energy(subdet[sd],eta,phi,depth,1);
00650 double ref =get_energy(subdet[sd],eta,phi,depth,2);
00651
00652 HcalFrontEndId lmap_entry=lmap->getHcalFrontEndId(hid);
00653 int rbx;
00654 if(sd==0 || sd==1 || sd==3){
00655 sscanf(&(lmap_entry.rbx().c_str())[3],"%d",&rbx);
00656 }else{
00657 if(abs(eta)<5) sscanf(&(lmap_entry.rbx().c_str())[3],"%d",&rbx);
00658 if(abs(eta)>=5) sscanf(&(lmap_entry.rbx().c_str())[4],"%d",&rbx);
00659 }
00660 if(ave>0 && ref>0){
00661 if(sd==0 && eta>0){ hbp[rbx-1][lmap_entry.rm()-1]+=ave/ref; nhbp[rbx-1][lmap_entry.rm()-1]++; }
00662 if(sd==0 && eta<0){ hbm[rbx-1][lmap_entry.rm()-1]+=ave/ref; nhbm[rbx-1][lmap_entry.rm()-1]++; }
00663 if(sd==1 && eta>0){ hep[rbx-1][lmap_entry.rm()-1]+=ave/ref; nhep[rbx-1][lmap_entry.rm()-1]++; }
00664 if(sd==1 && eta<0){ hem[rbx-1][lmap_entry.rm()-1]+=ave/ref; nhem[rbx-1][lmap_entry.rm()-1]++; }
00665 if(sd==3 && eta>0){ hfp[rbx-1][lmap_entry.rm()-1]+=ave/ref; nhfp[rbx-1][lmap_entry.rm()-1]++; }
00666 if(sd==3 && eta<0){ hfm[rbx-1][lmap_entry.rm()-1]+=ave/ref; nhfm[rbx-1][lmap_entry.rm()-1]++; }
00667 if(sd==2 && abs(eta)<5){ ho0[rbx-1][lmap_entry.rm()-1]+=ave/ref; nho0[rbx-1][lmap_entry.rm()-1]++; }
00668 if(sd==2 && eta>=5 && eta<=10){ ho1p[rbx-1][lmap_entry.rm()-1]+=ave/ref; nho1p[rbx-1][lmap_entry.rm()-1]++; }
00669 if(sd==2 && eta>=11 && eta<=15){ ho2p[rbx-1][lmap_entry.rm()-1]+=ave/ref; nho2p[rbx-1][lmap_entry.rm()-1]++; }
00670 if(sd==2 && eta>=-10 && eta<=-5){ ho1m[rbx-1][lmap_entry.rm()-1]+=ave/ref; nho1m[rbx-1][lmap_entry.rm()-1]++; }
00671 if(sd==2 && eta>=-15 && eta<=-11){ ho2m[rbx-1][lmap_entry.rm()-1]+=ave/ref; nho2m[rbx-1][lmap_entry.rm()-1]++; }
00672 }
00673 }
00674 for(int i=0;i<18;i++)for(int j=0;j<4;j++){
00675 int phi=i*4+j+1;
00676 if(nhbp[i][j]>1) HBPphi->Fill(phi+0.5,hbp[i][j]/nhbp[i][j]);
00677 if(nhbm[i][j]>1) HBMphi->Fill(phi+0.5,hbm[i][j]/nhbm[i][j]);
00678 if(nhep[i][j]>1) HEPphi->Fill(phi+0.5,hep[i][j]/nhep[i][j]);
00679 if(nhem[i][j]>1) HEMphi->Fill(phi+0.5,hem[i][j]/nhem[i][j]);
00680 }
00681 for(int i=0;i<12;i++)for(int j=0;j<3;j++){
00682 int phi=i*3+j+1;
00683 if(nhfp[i][j]>1) HFPphi->Fill(phi+0.5,hfp[i][j]/nhfp[i][j]);
00684 if(nhfm[i][j]>1) HFMphi->Fill(phi+0.5,hfm[i][j]/nhfm[i][j]);
00685 }
00686 for(int i=0;i<12;i++)for(int j=0;j<4;j++){
00687 int phi=i*4+j+1;
00688 if(nho0[i][j]>1) HO0phi->Fill(phi+0.5,ho0[i][j]/nho0[i][j]);
00689 if(nho1p[i][j]>1) HO1Pphi->Fill(phi+0.5,ho1p[i][j]/nho1p[i][j]);
00690 if(nho2p[i][j]>1) HO2Pphi->Fill(phi+0.5,ho2p[i][j]/nho2p[i][j]);
00691 if(nho1m[i][j]>1) HO1Mphi->Fill(phi+0.5,ho1m[i][j]/nho1m[i][j]);
00692 if(nho2m[i][j]>1) HO2Mphi->Fill(phi+0.5,ho2m[i][j]/nho2m[i][j]);
00693 }
00694 }
00695
00696 void HcalDetDiagLEDMonitor::SaveReference(){
00697 double led,rms,Time,time_rms;
00698 int Eta,Phi,Depth,Statistic,Status=0;
00699 char Subdet[10],str[500];
00700 sprintf(str,"%sHcalDetDiagLEDData_run%06i_%i.root",OutputFilePath.c_str(),run_number,dataset_seq_number);
00701 TFile *theFile = new TFile(str, "RECREATE");
00702 if(!theFile->IsOpen()) return;
00703 theFile->cd();
00704 sprintf(str,"%d",run_number); TObjString run(str); run.Write("run number");
00705 sprintf(str,"%d",ievt_); TObjString events(str); events.Write("Total events processed");
00706
00707 TTree *tree =new TTree("HCAL LED data","HCAL LED data");
00708 if(tree==0) return;
00709 tree->Branch("Subdet", &Subdet, "Subdet/C");
00710 tree->Branch("eta", &Eta, "Eta/I");
00711 tree->Branch("phi", &Phi, "Phi/I");
00712 tree->Branch("depth", &Depth, "Depth/I");
00713 tree->Branch("statistic",&Statistic, "Statistic/I");
00714 tree->Branch("status", &Status, "Status/I");
00715 tree->Branch("led", &led, "led/D");
00716 tree->Branch("rms", &rms, "rms/D");
00717 tree->Branch("time", &Time, "time/D");
00718 tree->Branch("time_rms", &time_rms, "time_rms/D");
00719 sprintf(Subdet,"HB");
00720 for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00721 if((Statistic=hb_data[eta+42][phi-1][depth-1].get_statistics())>100){
00722 Eta=eta; Phi=phi; Depth=depth;
00723 Status=hb_data[eta+42][phi-1][depth-1].get_status();
00724 hb_data[eta+42][phi-1][depth-1].get_average_led(&led,&rms);
00725 hb_data[eta+42][phi-1][depth-1].get_average_time(&Time,&time_rms);
00726 tree->Fill();
00727 }
00728 }
00729 sprintf(Subdet,"HE");
00730 for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=3;depth++){
00731 if((Statistic=he_data[eta+42][phi-1][depth-1].get_statistics())>100){
00732 Eta=eta; Phi=phi; Depth=depth;
00733 Status=he_data[eta+42][phi-1][depth-1].get_status();
00734 he_data[eta+42][phi-1][depth-1].get_average_led(&led,&rms);
00735 he_data[eta+42][phi-1][depth-1].get_average_time(&Time,&time_rms);
00736 tree->Fill();
00737 }
00738 }
00739 sprintf(Subdet,"HO");
00740 for(int eta=-15;eta<=15;eta++) for(int phi=1;phi<=72;phi++) for(int depth=4;depth<=4;depth++){
00741 if((Statistic=ho_data[eta+42][phi-1][depth-1].get_statistics())>100){
00742 Eta=eta; Phi=phi; Depth=depth;
00743 Status=ho_data[eta+42][phi-1][depth-1].get_status();
00744 ho_data[eta+42][phi-1][depth-1].get_average_led(&led,&rms);
00745 ho_data[eta+42][phi-1][depth-1].get_average_time(&Time,&time_rms);
00746 tree->Fill();
00747 }
00748 }
00749 sprintf(Subdet,"HF");
00750 for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
00751 if((Statistic=hf_data[eta+42][phi-1][depth-1].get_statistics())>100){
00752 Eta=eta; Phi=phi; Depth=depth;
00753 Status=hf_data[eta+42][phi-1][depth-1].get_status();
00754 hf_data[eta+42][phi-1][depth-1].get_average_led(&led,&rms);
00755 hf_data[eta+42][phi-1][depth-1].get_average_time(&Time,&time_rms);
00756 tree->Fill();
00757 }
00758 }
00759 sprintf(Subdet,"CALIB_HB");
00760 for(int eta=-1;eta<=1;eta++) for(int phi=1;phi<=72;phi++){
00761 if((calib_data[1][eta+2][phi-1].get_statistics())>100){
00762 Eta=eta; Phi=phi; Depth=0;
00763 Status=calib_data[1][eta+2][phi-1].get_status();
00764 calib_data[1][eta+2][phi-1].get_average_led(&led,&rms);
00765 calib_data[1][eta+2][phi-1].get_average_time(&Time,&time_rms);
00766 tree->Fill();
00767 }
00768 }
00769 sprintf(Subdet,"CALIB_HE");
00770 for(int eta=-1;eta<=1;eta++) for(int phi=1;phi<=72;phi++){
00771 if((calib_data[2][eta+2][phi-1].get_statistics())>100){
00772 Eta=eta; Phi=phi; Depth=0;
00773 Status=calib_data[2][eta+2][phi-1].get_status();
00774 calib_data[2][eta+2][phi-1].get_average_led(&led,&rms);
00775 calib_data[2][eta+2][phi-1].get_average_time(&Time,&time_rms);
00776 tree->Fill();
00777 }
00778 }
00779 sprintf(Subdet,"CALIB_HO");
00780 for(int eta=-2;eta<=2;eta++) for(int phi=1;phi<=72;phi++){
00781 if((calib_data[3][eta+2][phi-1].get_statistics())>100){
00782 Eta=eta; Phi=phi; Depth=0;
00783 Status=calib_data[3][eta+2][phi-1].get_status();
00784 calib_data[3][eta+2][phi-1].get_average_led(&led,&rms);
00785 calib_data[3][eta+2][phi-1].get_average_time(&Time,&time_rms);
00786 tree->Fill();
00787 }
00788 }
00789 sprintf(Subdet,"CALIB_HF");
00790 for(int eta=-2;eta<=2;eta++) for(int phi=1;phi<=72;phi++){
00791 if((calib_data[4][eta+2][phi-1].get_statistics())>100){
00792 Eta=eta; Phi=phi; Depth=0;
00793 Status=calib_data[4][eta+2][phi-1].get_status();
00794 calib_data[4][eta+2][phi-1].get_average_led(&led,&rms);
00795 calib_data[4][eta+2][phi-1].get_average_time(&Time,&time_rms);
00796 tree->Fill();
00797 }
00798 }
00799 theFile->Write();
00800 theFile->Close();
00801
00802
00803 if(XmlFilePath.size()>0){
00804
00805 char TIME[40];
00806 Long_t t; t=time(0); strftime(TIME,30,"%F %T",localtime(&t));
00807
00808 sprintf(str,"HcalDetDiagLED_%i_%i.xml",run_number,dataset_seq_number);
00809 std::string xmlName=str;
00810 ofstream xmlFile;
00811 xmlFile.open(xmlName.c_str());
00812
00813 xmlFile<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
00814 xmlFile<<"<ROOT>\n";
00815 xmlFile<<" <HEADER>\n";
00816 xmlFile<<" <HINTS mode='only-det-root'/>\n";
00817 xmlFile<<" <TYPE>\n";
00818 xmlFile<<" <EXTENSION_TABLE_NAME>HCAL_DETMON_LED_LASER_V1</EXTENSION_TABLE_NAME>\n";
00819 xmlFile<<" <NAME>HCAL LED [local]</NAME>\n";
00820 xmlFile<<" </TYPE>\n";
00821 xmlFile<<" <!-- run details -->\n";
00822 xmlFile<<" <RUN>\n";
00823 xmlFile<<" <RUN_TYPE>LOCAL-RUN</RUN_TYPE>\n";
00824 xmlFile<<" <RUN_NUMBER>"<<run_number<<"</RUN_NUMBER>\n";
00825 xmlFile<<" <RUN_BEGIN_TIMESTAMP>2009-01-01 00:00:00</RUN_BEGIN_TIMESTAMP>\n";
00826 xmlFile<<" <COMMENT_DESCRIPTION>hcal LED data</COMMENT_DESCRIPTION>\n";
00827 xmlFile<<" <LOCATION>P5</LOCATION>\n";
00828 xmlFile<<" <INITIATED_BY_USER>dma</INITIATED_BY_USER>\n";
00829 xmlFile<<" </RUN>\n";
00830 xmlFile<<" </HEADER>\n";
00831 xmlFile<<" <DATA_SET>\n";
00832 xmlFile<<" <!-- optional dataset metadata -->\n\n";
00833 xmlFile<<" <SET_NUMBER>"<<dataset_seq_number<<"</SET_NUMBER>\n";
00834 xmlFile<<" <SET_BEGIN_TIMESTAMP>2009-01-01 00:00:00</SET_BEGIN_TIMESTAMP>\n";
00835 xmlFile<<" <SET_END_TIMESTAMP>2009-01-01 00:00:00</SET_END_TIMESTAMP>\n";
00836 xmlFile<<" <NUMBER_OF_EVENTS_IN_SET>"<<ievt_<<"</NUMBER_OF_EVENTS_IN_SET>\n";
00837 xmlFile<<" <COMMENT_DESCRIPTION>Automatic DQM output</COMMENT_DESCRIPTION>\n";
00838 xmlFile<<" <DATA_FILE_NAME>"<< xmlName <<"</DATA_FILE_NAME>\n";
00839 xmlFile<<" <IMAGE_FILE_NAME>data plot url or file path</IMAGE_FILE_NAME>\n";
00840 xmlFile<<" <!-- who and when created this dataset-->\n\n";
00841 xmlFile<<" <CREATE_TIMESTAMP>"<<TIME<<"</CREATE_TIMESTAMP>\n";
00842 xmlFile<<" <CREATED_BY_USER>dma</CREATED_BY_USER>\n";
00843 xmlFile<<" <!-- version (string) and subversion (number) -->\n";
00844 xmlFile<<" <!-- fields are used to read data back from the database -->\n\n";
00845 xmlFile<<" <VERSION>"<<run_number<<dataset_seq_number<<"</VERSION>\n";
00846 xmlFile<<" <SUBVERSION>1</SUBVERSION>\n";
00847 xmlFile<<" <!-- Assign predefined dataset attributes -->\n\n";
00848 xmlFile<<" <PREDEFINED_ATTRIBUTES>\n";
00849 xmlFile<<" <ATTRIBUTE>\n";
00850 xmlFile<<" <NAME>HCAL Dataset Status</NAME>\n";
00851 xmlFile<<" <VALUE>VALID</VALUE>\n";
00852 xmlFile<<" </ATTRIBUTE>\n";
00853 xmlFile<<" </PREDEFINED_ATTRIBUTES>\n";
00854 xmlFile<<" <!-- multiple data block records -->\n\n";
00855
00856 std::vector <HcalElectronicsId> AllElIds = emap.allElectronicsIdPrecision();
00857 for(std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++){
00858 DetId detid=emap.lookup(*eid);
00859 if (detid.det()!=DetId::Hcal) continue;
00860 HcalGenericDetId gid(emap.lookup(*eid));
00861 if(!(!(gid.null()) &&
00862 (gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel ||
00863 gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap ||
00864 gid.genericSubdet()==HcalGenericDetId::HcalGenForward ||
00865 gid.genericSubdet()==HcalGenericDetId::HcalGenOuter))) continue;
00866 int eta,phi,depth;
00867 std::string subdet="";
00868 HcalDetId hid(detid);
00869 eta=hid.ieta();
00870 phi=hid.iphi();
00871 depth=hid.depth();
00872
00873 double e=0,e_rms=0,t=0,t_rms=0;
00874 if(detid.subdetId()==HcalBarrel){
00875 subdet="HB";
00876 Statistic=hb_data[eta+42][phi-1][depth-1].get_statistics();
00877 Status =hb_data[eta+42][phi-1][depth-1].get_status();
00878 hb_data[eta+42][phi-1][depth-1].get_average_led(&e,&e_rms);
00879 hb_data[eta+42][phi-1][depth-1].get_average_time(&t,&t_rms);
00880 }else if(detid.subdetId()==HcalEndcap){
00881 subdet="HE";
00882 Statistic=he_data[eta+42][phi-1][depth-1].get_statistics();
00883 Status =he_data[eta+42][phi-1][depth-1].get_status();
00884 he_data[eta+42][phi-1][depth-1].get_average_led(&e,&e_rms);
00885 he_data[eta+42][phi-1][depth-1].get_average_time(&t,&t_rms);
00886 }else if(detid.subdetId()==HcalForward){
00887 subdet="HF";
00888 Statistic=hf_data[eta+42][phi-1][depth-1].get_statistics();
00889 Status =hf_data[eta+42][phi-1][depth-1].get_status();
00890 hf_data[eta+42][phi-1][depth-1].get_average_led(&e,&e_rms);
00891 hf_data[eta+42][phi-1][depth-1].get_average_time(&t,&t_rms);
00892 }else if(detid.subdetId()==HcalOuter){
00893 subdet="HO";
00894 Statistic=ho_data[eta+42][phi-1][depth-1].get_statistics();
00895 Status =ho_data[eta+42][phi-1][depth-1].get_status();
00896 ho_data[eta+42][phi-1][depth-1].get_average_led(&e,&e_rms);
00897 ho_data[eta+42][phi-1][depth-1].get_average_time(&t,&t_rms);
00898 }else continue;
00899 xmlFile<<" <DATA>\n";
00900 xmlFile<<" <NUMBER_OF_EVENTS_USED>"<<Statistic<<"</NUMBER_OF_EVENTS_USED>\n";
00901 xmlFile<<" <SIGNAL_MEAN>"<<e<<"</SIGNAL_MEAN>\n";
00902 xmlFile<<" <SIGNAL_RMS>"<<e_rms<<"</SIGNAL_RMS>\n";
00903 xmlFile<<" <TIME_MEAN>"<<t<<"</TIME_MEAN>\n";
00904 xmlFile<<" <TIME_RMS>"<<t_rms<<"</TIME_RMS>\n";
00905 xmlFile<<" <CHANNEL_STATUS_WORD>"<<Status<<"</CHANNEL_STATUS_WORD>\n";
00906 xmlFile<<" <CHANNEL_OBJECTNAME>HcalDetId</CHANNEL_OBJECTNAME>\n";
00907 xmlFile<<" <SUBDET>"<<subdet<<"</SUBDET>\n";
00908 xmlFile<<" <IETA>"<<eta<<"</IETA>\n";
00909 xmlFile<<" <IPHI>"<<phi<<"</IPHI>\n";
00910 xmlFile<<" <DEPTH>"<<depth<<"</DEPTH>\n";
00911 xmlFile<<" <TYPE>0</TYPE>\n";
00912 xmlFile<<" </DATA>\n";
00913 }
00915 xmlFile<<" </DATA_SET>\n";
00916 xmlFile<<"</ROOT>\n";
00917 xmlFile.close();
00918
00919
00920 sprintf(str,"HcalDetDiagLEDCalib_%i_%i.xml",run_number,dataset_seq_number);
00921 std::string xmlNameCalib=str;
00922 ofstream xmlFileCalib;
00923 xmlFileCalib.open(xmlNameCalib.c_str());
00924
00925 xmlFileCalib<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
00926 xmlFileCalib<<"<ROOT>\n";
00927 xmlFileCalib<<" <HEADER>\n";
00928 xmlFileCalib<<" <HINTS mode='only-det-root'/>\n";
00929 xmlFileCalib<<" <TYPE>\n";
00930 xmlFileCalib<<" <EXTENSION_TABLE_NAME>HCAL_DETMON_LED_LASER_V1</EXTENSION_TABLE_NAME>\n";
00931 xmlFileCalib<<" <NAME>HCAL LED CALIB [local]</NAME>\n";
00932 xmlFileCalib<<" </TYPE>\n";
00933 xmlFileCalib<<" <!-- run details -->\n";
00934 xmlFileCalib<<" <RUN>\n";
00935 xmlFileCalib<<" <RUN_TYPE>LOCAL-RUN</RUN_TYPE>\n";
00936 xmlFileCalib<<" <RUN_NUMBER>"<<run_number<<"</RUN_NUMBER>\n";
00937 xmlFileCalib<<" <RUN_BEGIN_TIMESTAMP>2009-01-01 00:00:00</RUN_BEGIN_TIMESTAMP>\n";
00938 xmlFileCalib<<" <COMMENT_DESCRIPTION>hcal LED CALIB data</COMMENT_DESCRIPTION>\n";
00939 xmlFileCalib<<" <LOCATION>P5</LOCATION>\n";
00940 xmlFileCalib<<" <INITIATED_BY_USER>dma</INITIATED_BY_USER>\n";
00941 xmlFileCalib<<" </RUN>\n";
00942 xmlFileCalib<<" </HEADER>\n";
00943 xmlFileCalib<<" <DATA_SET>\n";
00944 xmlFileCalib<<" <!-- optional dataset metadata -->\n\n";
00945 xmlFileCalib<<" <SET_NUMBER>"<<dataset_seq_number<<"</SET_NUMBER>\n";
00946 xmlFileCalib<<" <SET_BEGIN_TIMESTAMP>2009-01-01 00:00:00</SET_BEGIN_TIMESTAMP>\n";
00947 xmlFileCalib<<" <SET_END_TIMESTAMP>2009-01-01 00:00:00</SET_END_TIMESTAMP>\n";
00948 xmlFileCalib<<" <NUMBER_OF_EVENTS_IN_SET>"<<ievt_<<"</NUMBER_OF_EVENTS_IN_SET>\n";
00949 xmlFileCalib<<" <COMMENT_DESCRIPTION>Automatic DQM output</COMMENT_DESCRIPTION>\n";
00950 xmlFileCalib<<" <DATA_FILE_NAME>"<< xmlNameCalib <<"</DATA_FILE_NAME>\n";
00951 xmlFileCalib<<" <IMAGE_FILE_NAME>data plot url or file path</IMAGE_FILE_NAME>\n";
00952 xmlFileCalib<<" <!-- who and when created this dataset-->\n\n";
00953 xmlFileCalib<<" <CREATE_TIMESTAMP>"<<TIME<<"</CREATE_TIMESTAMP>\n";
00954 xmlFileCalib<<" <CREATED_BY_USER>dma</CREATED_BY_USER>\n";
00955 xmlFileCalib<<" <!-- version (string) and subversion (number) -->\n";
00956 xmlFileCalib<<" <!-- fields are used to read data back from the database -->\n\n";
00957 xmlFileCalib<<" <VERSION>"<<run_number<<dataset_seq_number<<"</VERSION>\n";
00958 xmlFileCalib<<" <SUBVERSION>1</SUBVERSION>\n";
00959 xmlFileCalib<<" <!-- Assign predefined dataset attributes -->\n\n";
00960 xmlFileCalib<<" <PREDEFINED_ATTRIBUTES>\n";
00961 xmlFileCalib<<" <ATTRIBUTE>\n";
00962 xmlFileCalib<<" <NAME>HCAL Dataset Status</NAME>\n";
00963 xmlFileCalib<<" <VALUE>VALID</VALUE>\n";
00964 xmlFileCalib<<" </ATTRIBUTE>\n";
00965 xmlFileCalib<<" </PREDEFINED_ATTRIBUTES>\n";
00966 xmlFileCalib<<" <!-- multiple data block records -->\n\n";
00967
00968 for(int sd=1;sd<=4;sd++) for(int eta=-2;eta<=2;eta++) for(int phi=1;phi<=72;phi++){
00969 std::string subdet="";
00970 if(sd==1) subdet="HB";
00971 if(sd==2) subdet="HE";
00972 if(sd==3) subdet="HO";
00973 if(sd==4) subdet="HF";
00974 if((calib_data[sd][eta+2][phi-1].get_statistics())>100){
00975 double e=0,e_rms=0,t=0,t_rms=0;
00976 Status=calib_data[sd][eta+2][phi-1].get_status();
00977 Statistic=calib_data[sd][eta+2][phi-1].get_statistics();
00978 calib_data[sd][eta+2][phi-1].get_average_led(&e,&e_rms);
00979 calib_data[sd][eta+2][phi-1].get_average_time(&t,&t_rms);
00980 xmlFileCalib<<" <DATA>\n";
00981 xmlFileCalib<<" <NUMBER_OF_EVENTS_USED>"<<Statistic<<"</NUMBER_OF_EVENTS_USED>\n";
00982 xmlFileCalib<<" <SIGNAL_MEAN>"<<e<<"</SIGNAL_MEAN>\n";
00983 xmlFileCalib<<" <SIGNAL_RMS>"<<e_rms<<"</SIGNAL_RMS>\n";
00984 xmlFileCalib<<" <TIME_MEAN>"<<t<<"</TIME_MEAN>\n";
00985 xmlFileCalib<<" <TIME_RMS>"<<t_rms<<"</TIME_RMS>\n";
00986 xmlFileCalib<<" <CHANNEL_STATUS_WORD>"<<Status<<"</CHANNEL_STATUS_WORD>\n";
00987 xmlFileCalib<<" <CHANNEL_OBJECTNAME>HcalDetId</CHANNEL_OBJECTNAME>\n";
00988 xmlFileCalib<<" <SUBDET>"<<subdet<<"</SUBDET>\n";
00989 xmlFileCalib<<" <IETA>"<<eta<<"</IETA>\n";
00990 xmlFileCalib<<" <IPHI>"<<phi<<"</IPHI>\n";
00991 xmlFileCalib<<" <DEPTH>"<<0<<"</DEPTH>\n";
00992 xmlFileCalib<<" <TYPE>0</TYPE>\n";
00993 xmlFileCalib<<" </DATA>\n";
00994 }
00995 }
00997 xmlFileCalib<<" </DATA_SET>\n";
00998 xmlFileCalib<<"</ROOT>\n";
00999 xmlFileCalib.close();
01000
01001 sprintf(str,"zip %s.zip %s %s",xmlName.c_str(),xmlName.c_str(),xmlNameCalib.c_str());
01002 system(str);
01003 sprintf(str,"rm -f %s %s",xmlName.c_str(),xmlNameCalib.c_str());
01004 system(str);
01005 sprintf(str,"mv -f %s.zip %s",xmlName.c_str(),XmlFilePath.c_str());
01006 system(str);
01007 }
01008
01009
01010 dataset_seq_number++;
01011 }
01012
01013 void HcalDetDiagLEDMonitor::LoadReference(){
01014 double led,rms;
01015 int Eta,Phi,Depth;
01016 char subdet[10];
01017 TFile *f;
01018 if(gSystem->AccessPathName(ReferenceData.c_str())) return;
01019 f = new TFile(ReferenceData.c_str(),"READ");
01020 if(!f->IsOpen()) return ;
01021 TObjString *STR=(TObjString *)f->Get("run number");
01022 if(STR){ std::string Ref(STR->String()); ReferenceRun=Ref;}
01023 TTree* t=(TTree*)f->Get("HCAL LED data");
01024 if(!t) return;
01025 t->SetBranchAddress("Subdet", subdet);
01026 t->SetBranchAddress("eta", &Eta);
01027 t->SetBranchAddress("phi", &Phi);
01028 t->SetBranchAddress("depth", &Depth);
01029 t->SetBranchAddress("led", &led);
01030 t->SetBranchAddress("rms", &rms);
01031 for(int ievt=0;ievt<t->GetEntries();ievt++){
01032
01033 t->GetEntry(ievt);
01034 if(strcmp(subdet,"HB")==0) hb_data[Eta+42][Phi-1][Depth-1].set_reference(led,rms);
01035 if(strcmp(subdet,"HE")==0) he_data[Eta+42][Phi-1][Depth-1].set_reference(led,rms);
01036 if(strcmp(subdet,"HO")==0) ho_data[Eta+42][Phi-1][Depth-1].set_reference(led,rms);
01037 if(strcmp(subdet,"HF")==0) hf_data[Eta+42][Phi-1][Depth-1].set_reference(led,rms);
01038 if(strcmp(subdet,"CALIB_HB")==0) calib_data[1][Eta+2][Phi-1].set_reference(led,rms);
01039 if(strcmp(subdet,"CALIB_HE")==0) calib_data[2][Eta+2][Phi-1].set_reference(led,rms);
01040 if(strcmp(subdet,"CALIB_HO")==0) calib_data[3][Eta+2][Phi-1].set_reference(led,rms);
01041 if(strcmp(subdet,"CALIB_HF")==0) calib_data[4][Eta+2][Phi-1].set_reference(led,rms);
01042 }
01043 f->Close();
01044 IsReference=true;
01045 }
01046 void HcalDetDiagLEDMonitor::CheckStatus(){
01047 for(int i=0;i<4;i++){
01048 ChannelStatusMissingChannels->depth[i]->Reset();
01049 ChannelStatusUnstableChannels->depth[i]->Reset();
01050 ChannelStatusUnstableLEDsignal->depth[i]->Reset();
01051 ChannelStatusLEDMean->depth[i]->Reset();
01052 ChannelStatusLEDRMS->depth[i]->Reset();
01053 ChannelStatusTimeMean->depth[i]->Reset();
01054 ChannelStatusTimeRMS->depth[i]->Reset();
01055 }
01056
01057 std::vector <HcalElectronicsId> AllElIds = emap.allElectronicsIdPrecision();
01058 for (std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++) {
01059 DetId detid=emap.lookup(*eid);
01060 if (detid.det()!=DetId::Hcal) continue;
01061 HcalGenericDetId gid(emap.lookup(*eid));
01062 if(!(!(gid.null()) &&
01063 (gid.genericSubdet()==HcalGenericDetId::HcalGenBarrel ||
01064 gid.genericSubdet()==HcalGenericDetId::HcalGenEndcap ||
01065 gid.genericSubdet()==HcalGenericDetId::HcalGenForward ||
01066 gid.genericSubdet()==HcalGenericDetId::HcalGenOuter))) continue;
01067 int eta=0,phi=0,depth=0;
01068 if(KnownBadCells_.find(gid.rawId())==KnownBadCells_.end()) continue;
01069
01070 HcalDetId hid(detid);
01071 eta=hid.ieta();
01072 phi=hid.iphi();
01073 depth=hid.depth();
01074
01075 double AVE_TIME=Time->getMean();
01076 if(detid.subdetId()==HcalBarrel){
01077 int stat=hb_data[eta+42][phi-1][depth-1].get_statistics()+
01078 hb_data[eta+42][phi-1][depth-1].get_overflow()+hb_data[eta+42][phi-1][depth-1].get_undeflow();
01079 if(stat==0){
01080 fill_channel_status("HB",eta,phi,depth,1,1);
01081 hb_data[eta+42][phi-1][depth-1].change_status(1);
01082 }
01083 if(stat>0 && stat!=(ievt_)){
01084 fill_channel_status("HB",eta,phi,depth,2,(double)stat/(double)(ievt_));
01085 hb_data[eta+42][phi-1][depth-1].change_status(2);
01086 }
01087 if(hb_data[eta+42][phi-1][depth-1].get_statistics()>100){
01088 double ave=0;
01089 double rms=0;
01090 hb_data[eta+42][phi-1][depth-1].get_average_time(&ave,&rms);
01091 if((AVE_TIME-ave)>0.75 || (AVE_TIME-ave)<-0.75){
01092 fill_channel_status("HB",eta,phi,depth,6,AVE_TIME-ave);
01093 hb_data[eta+42][phi-1][depth-1].change_status(8);
01094 }
01095 }
01096 stat=hb_data[eta+42][phi-1][depth-1].get_undeflow();
01097 if(stat>0){
01098 fill_channel_status("HB",eta,phi,depth,3,(double)stat/(double)(ievt_));
01099 hb_data[eta+42][phi-1][depth-1].change_status(4);
01100 }
01101 }
01102 if(detid.subdetId()==HcalEndcap){
01103 int stat=he_data[eta+42][phi-1][depth-1].get_statistics()+
01104 he_data[eta+42][phi-1][depth-1].get_overflow()+he_data[eta+42][phi-1][depth-1].get_undeflow();
01105 if(stat==0){
01106 fill_channel_status("HE",eta,phi,depth,1,1);
01107 he_data[eta+42][phi-1][depth-1].change_status(1);
01108 }
01109 if(stat>0 && stat!=(ievt_)){
01110 fill_channel_status("HE",eta,phi,depth,2,(double)stat/(double)(ievt_));
01111 he_data[eta+42][phi-1][depth-1].change_status(2);
01112 }
01113 if(he_data[eta+42][phi-1][depth-1].get_statistics()>100){
01114 double ave=0;
01115 double rms=0;
01116 he_data[eta+42][phi-1][depth-1].get_average_time(&ave,&rms);
01117 if((AVE_TIME-ave)>0.75 || (AVE_TIME-ave)<-0.75){
01118 fill_channel_status("HE",eta,phi,depth,6,AVE_TIME-ave);
01119 he_data[eta+42][phi-1][depth-1].change_status(8);
01120 }
01121 }
01122 stat=he_data[eta+42][phi-1][depth-1].get_undeflow();
01123 if(stat>0){
01124 fill_channel_status("HE",eta,phi,depth,3,(double)stat/(double)(ievt_));
01125 he_data[eta+42][phi-1][depth-1].change_status(4);
01126 }
01127 }
01128 if(detid.subdetId()==HcalOuter){
01129 int stat=ho_data[eta+42][phi-1][depth-1].get_statistics()+
01130 ho_data[eta+42][phi-1][depth-1].get_overflow()+ho_data[eta+42][phi-1][depth-1].get_undeflow();
01131 if(stat==0){
01132 fill_channel_status("HO",eta,phi,depth,1,1);
01133 ho_data[eta+42][phi-1][depth-1].change_status(1);
01134 }
01135 if(stat>0 && stat!=(ievt_)){
01136 fill_channel_status("HO",eta,phi,depth,2,(double)stat/(double)(ievt_));
01137 ho_data[eta+42][phi-1][depth-1].change_status(2);
01138 }
01139 if(ho_data[eta+42][phi-1][depth-1].get_statistics()>100){
01140 double ave=0;
01141 double rms=0;
01142 ho_data[eta+42][phi-1][depth-1].get_average_time(&ave,&rms);
01143 if((AVE_TIME-ave)>0.75 || (AVE_TIME-ave)<-0.75){
01144 fill_channel_status("HO",eta,phi,depth,6,AVE_TIME-ave);
01145 ho_data[eta+42][phi-1][depth-1].change_status(8);
01146 }
01147 }
01148 stat=ho_data[eta+42][phi-1][depth-1].get_undeflow();
01149 if(stat>0){
01150 fill_channel_status("HO",eta,phi,depth,3,(double)stat/(double)(ievt_));
01151 ho_data[eta+42][phi-1][depth-1].change_status(4);
01152 }
01153 }
01154 if(detid.subdetId()==HcalForward){
01155 AVE_TIME=TimeHF->getMean();
01156 int stat=hf_data[eta+42][phi-1][depth-1].get_statistics()+
01157 hf_data[eta+42][phi-1][depth-1].get_overflow()+hf_data[eta+42][phi-1][depth-1].get_undeflow();
01158 if(stat==0){
01159 fill_channel_status("HF",eta,phi,depth,1,1);
01160 hf_data[eta+42][phi-1][depth-1].change_status(1);
01161 }
01162 if(stat>0 && stat!=(ievt_)){
01163 fill_channel_status("HF",eta,phi,depth,2,(double)stat/(double)(ievt_));
01164 hf_data[eta+42][phi-1][depth-1].change_status(2);
01165 }
01166 if(hf_data[eta+42][phi-1][depth-1].get_statistics()>100){
01167 double ave=0;
01168 double rms=0;
01169 hf_data[eta+42][phi-1][depth-1].get_average_time(&ave,&rms);
01170 if((AVE_TIME-ave)>0.75 || (AVE_TIME-ave)<-0.75){
01171 fill_channel_status("HF",eta,phi,depth,6,AVE_TIME-ave);
01172 hf_data[eta+42][phi-1][depth-1].change_status(8);
01173 }
01174 }
01175 stat=hf_data[eta+42][phi-1][depth-1].get_undeflow();
01176 if(stat>0){
01177 fill_channel_status("HF",eta,phi,depth,3,(double)stat/(double)(ievt_));
01178 hf_data[eta+42][phi-1][depth-1].change_status(4);
01179 }
01180 }
01181 }
01182 }
01183 void HcalDetDiagLEDMonitor::fill_energy(std::string subdet,int eta,int phi,int depth,double e,int type){
01184 int subdetval=-1;
01185 if (subdet.compare("HB")==0) subdetval=(int)HcalBarrel;
01186 else if (subdet.compare("HE")==0) subdetval=(int)HcalEndcap;
01187 else if (subdet.compare("HO")==0) subdetval=(int)HcalOuter;
01188 else if (subdet.compare("HF")==0) subdetval=(int)HcalForward;
01189 else return;
01190
01191 int ietabin=CalcEtaBin(subdetval, eta, depth)+1;
01192 if(type==1) ChannelsLEDEnergy->depth[depth-1] ->setBinContent(ietabin,phi,e);
01193 else if(type==2) ChannelsLEDEnergyRef->depth[depth-1]->setBinContent(ietabin,phi,e);
01194 }
01195
01196 double HcalDetDiagLEDMonitor::get_energy(std::string subdet,int eta,int phi,int depth,int type){
01197 int subdetval=-1;
01198 if (subdet.compare("HB")==0) subdetval=(int)HcalBarrel;
01199 else if (subdet.compare("HE")==0) subdetval=(int)HcalEndcap;
01200 else if (subdet.compare("HO")==0) subdetval=(int)HcalOuter;
01201 else if (subdet.compare("HF")==0) subdetval=(int)HcalForward;
01202 else return -1.0;
01203
01204 int ietabin=CalcEtaBin(subdetval, eta, depth)+1;
01205 if(type==1) return ChannelsLEDEnergy->depth[depth-1] ->getBinContent(ietabin, phi);
01206 else if(type==2) return ChannelsLEDEnergyRef->depth[depth-1] ->getBinContent(ietabin,phi);
01207 return -1.0;
01208 }
01209
01210 void HcalDetDiagLEDMonitor::fill_channel_status(std::string subdet,int eta,int phi,int depth,int type,double status){
01211 int subdetval=-1;
01212 if (subdet.compare("HB")==0) subdetval=(int)HcalBarrel;
01213 else if (subdet.compare("HE")==0) subdetval=(int)HcalEndcap;
01214 else if (subdet.compare("HO")==0) subdetval=(int)HcalOuter;
01215 else if (subdet.compare("HF")==0) subdetval=(int)HcalForward;
01216 else return;
01217 int ietabin=CalcEtaBin(subdetval, eta, depth)+1;
01218
01219 if(type==1) ChannelStatusMissingChannels->depth[depth-1] ->setBinContent(ietabin,phi,status);
01220 if(type==2) ChannelStatusUnstableChannels->depth[depth-1] ->setBinContent(ietabin,phi,status);
01221 if(type==3) ChannelStatusUnstableLEDsignal->depth[depth-1]->setBinContent(ietabin,phi,status);
01222 if(type==4) ChannelStatusLEDMean->depth[depth-1] ->setBinContent(ietabin,phi,status);
01223 if(type==5) ChannelStatusLEDRMS->depth[depth-1] ->setBinContent(ietabin,phi,status);
01224 if(type==6) ChannelStatusTimeMean->depth[depth-1] ->setBinContent(ietabin,phi,status);
01225 if(type==7) ChannelStatusTimeRMS->depth[depth-1] ->setBinContent(ietabin,phi,status);
01226 }
01227 void HcalDetDiagLEDMonitor::endRun(const edm::Run& run, const edm::EventSetup& c){
01228 if(ievt_>=100){
01229 fillHistos();
01230 CheckStatus();
01231 SaveReference();
01232 }
01233 }
01234 DEFINE_FWK_MODULE (HcalDetDiagLEDMonitor);
01235