00001 #include "DQM/HcalMonitorTasks/interface/HcalBeamMonitor.h"
00002 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00003 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
00004 #include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/Framework/interface/LuminosityBlock.h"
00007 #include "FWCore/Framework/interface/Run.h"
00008
00009 #include <iomanip>
00010 #include <cmath>
00011
00012
00013
00014 #define PI 3.1415926535897932
00015 #define HBETASIZE 34 // one more bin than needed, I think
00016 #define HEETASIZE 60 // ""
00017 #define HOETASIZE 32 // ""
00018 #define HFETASIZE 84 // ""
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 HcalBeamMonitor::HcalBeamMonitor(const edm::ParameterSet& ps):
00030 ETA_OFFSET_HB(16),
00031 ETA_OFFSET_HE(29),
00032 ETA_BOUND_HE(17),
00033 ETA_OFFSET_HO(15),
00034 ETA_OFFSET_HF(41),
00035 ETA_BOUND_HF(29)
00036 {
00037 Online_ = ps.getUntrackedParameter<bool>("online",false);
00038 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
00039 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
00040 debug_ = ps.getUntrackedParameter<int>("debug",0);
00041 prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00042 if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00043 prefixME_.append("/");
00044 subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","BeamMonitor_Hcal");
00045 if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00046 subdir_.append("/");
00047 subdir_=prefixME_+subdir_;
00048 AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00049 skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
00050 NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00051 makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00052
00053
00054
00055
00056 digiLabel_ =ps.getUntrackedParameter<edm::InputTag>("digiLabel");
00057 hbheRechitLabel_ = ps.getUntrackedParameter<edm::InputTag>("hbheRechitLabel");
00058 hoRechitLabel_ = ps.getUntrackedParameter<edm::InputTag>("hoRechitLabel");
00059 hfRechitLabel_ = ps.getUntrackedParameter<edm::InputTag>("hfRechitLabel");
00060
00061
00062 minEvents_ = ps.getUntrackedParameter<int>("minEvents",500);
00063 lumiqualitydir_ = ps.getUntrackedParameter<std::string>("lumiqualitydir","");
00064 if (lumiqualitydir_.size()>0 && lumiqualitydir_.substr(lumiqualitydir_.size()-1,lumiqualitydir_.size())!="/")
00065 lumiqualitydir_.append("/");
00066 occThresh_ = ps.getUntrackedParameter<double>("occupancyThresh",0.0625);
00067 hotrate_ = ps.getUntrackedParameter<double>("hotrate",0.25);
00068 minBadCells_ = ps.getUntrackedParameter<int>("minBadCells",10);
00069 Overwrite_ = ps.getUntrackedParameter<bool>("Overwrite",false);
00070 }
00071
00072
00073
00074 HcalBeamMonitor::~HcalBeamMonitor() {}
00075
00076 void HcalBeamMonitor::reset()
00077 {
00078 CenterOfEnergyRadius->Reset();
00079 CenterOfEnergy->Reset();
00080 COEradiusVSeta->Reset();
00081
00082 HBCenterOfEnergyRadius->Reset();
00083 HBCenterOfEnergy->Reset();
00084 HECenterOfEnergyRadius->Reset();
00085 HECenterOfEnergy->Reset();
00086 HOCenterOfEnergyRadius->Reset();
00087 HOCenterOfEnergy->Reset();
00088 HFCenterOfEnergyRadius->Reset();
00089 HFCenterOfEnergy->Reset();
00090
00091 Etsum_eta_L->Reset();
00092 Etsum_eta_S->Reset();
00093 Etsum_phi_L->Reset();
00094 Etsum_phi_S->Reset();
00095 Etsum_ratio_p->Reset();
00096 Etsum_ratio_m->Reset();
00097 Etsum_map_L->Reset();
00098 Etsum_map_S->Reset();
00099 Etsum_ratio_map->Reset();
00100 Etsum_rphi_L->Reset();
00101 Etsum_rphi_S->Reset();
00102 Energy_Occ->Reset();
00103
00104 Occ_rphi_L->Reset();
00105 Occ_rphi_S->Reset();
00106 Occ_eta_L->Reset();
00107 Occ_eta_S->Reset();
00108 Occ_phi_L->Reset();
00109 Occ_phi_S->Reset();
00110 Occ_map_L->Reset();
00111 Occ_map_S->Reset();
00112
00113 HFlumi_ETsum_perwedge->Reset();
00114 HFlumi_Occupancy_above_thr_r1->Reset();
00115 HFlumi_Occupancy_between_thrs_r1->Reset();
00116 HFlumi_Occupancy_below_thr_r1->Reset();
00117 HFlumi_Occupancy_above_thr_r2->Reset();
00118 HFlumi_Occupancy_between_thrs_r2->Reset();
00119 HFlumi_Occupancy_below_thr_r2->Reset();
00120
00121 HFlumi_Occupancy_per_channel_vs_lumiblock_RING1->Reset();
00122 HFlumi_Occupancy_per_channel_vs_lumiblock_RING2->Reset();
00123 HFlumi_Occupancy_per_channel_vs_BX_RING1->Reset();
00124 HFlumi_Occupancy_per_channel_vs_BX_RING2->Reset();
00125 HFlumi_ETsum_vs_BX->Reset();
00126 HFlumi_Et_per_channel_vs_lumiblock->Reset();
00127
00128 HFlumi_occ_LS->Reset();
00129 HFlumi_total_hotcells->Reset();
00130 HFlumi_total_deadcells->Reset();
00131 HFlumi_diag_hotcells->Reset();
00132 HFlumi_diag_deadcells->Reset();
00133
00134
00135 HFlumi_Ring1Status_vs_LS->Reset();
00136 HFlumi_Ring2Status_vs_LS->Reset();
00137 }
00138
00139 void HcalBeamMonitor::cleanup()
00140 {
00141 if (dbe_)
00142 {
00143 dbe_->setCurrentFolder(subdir_);
00144 dbe_->removeContents();
00145 dbe_->setCurrentFolder(subdir_+"LSvalues");
00146 dbe_->removeContents();
00147 }
00148 }
00149
00150
00151 void HcalBeamMonitor::setup()
00152 {
00153 if (debug_>0) std::cout <<"<HcalBeamMonitor::setup> Setup in progress..."<<std::endl;
00154 HcalBaseDQMonitor::setup();
00155 if (!dbe_) return;
00156
00157
00158 dbe_->setCurrentFolder(subdir_);
00159 CenterOfEnergyRadius = dbe_->book1D("CenterOfEnergyRadius",
00160 "Center Of Energy radius",
00161 200,0,1);
00162
00163 CenterOfEnergyRadius->setAxisTitle("(normalized) radius",1);
00164
00165 CenterOfEnergy = dbe_->book2D("CenterOfEnergy",
00166 "Center of Energy;normalized x coordinate;normalize y coordinate",
00167 40,-1,1,
00168 40,-1,1);
00169
00170 COEradiusVSeta = dbe_->bookProfile("COEradiusVSeta",
00171 "Center of Energy radius vs i#eta",
00172 172,-43,43,
00173 20,0,1);
00174 COEradiusVSeta->setAxisTitle("i#eta",1);
00175 COEradiusVSeta->setAxisTitle("(normalized) radius",2);
00176
00177 std::stringstream histname;
00178 std::stringstream histtitle;
00179 dbe_->setCurrentFolder(subdir_+"HB");
00180 HBCenterOfEnergyRadius = dbe_->book1D("HBCenterOfEnergyRadius",
00181 "HB Center Of Energy radius",
00182 200,0,1);
00183 HBCenterOfEnergy = dbe_->book2D("HBCenterOfEnergy",
00184 "HB Center of Energy",
00185 40,-1,1,
00186 40,-1,1);
00187 if (makeDiagnostics_)
00188 {
00189 for (int i=-16;i<=16;++i)
00190 {
00191 if (i==0) continue;
00192 histname.str("");
00193 histtitle.str("");
00194 histname<<"HB_CenterOfEnergyRadius_ieta"<<i;
00195 histtitle<<"HB Center Of Energy ieta = "<<i;
00196 HB_CenterOfEnergyRadius[i+ETA_OFFSET_HB]=dbe_->book1D(histname.str().c_str(),
00197 histtitle.str().c_str(),
00198 200,0,1);
00199 }
00200 }
00201 dbe_->setCurrentFolder(subdir_+"HE");
00202 HECenterOfEnergyRadius = dbe_->book1D("HECenterOfEnergyRadius",
00203 "HE Center Of Energy radius",
00204 200,0,1);
00205 HECenterOfEnergy = dbe_->book2D("HECenterOfEnergy",
00206 "HE Center of Energy",
00207 40,-1,1,
00208 40,-1,1);
00209
00210 if (makeDiagnostics_)
00211 {
00212 for (int i=-29;i<=29;++i)
00213 {
00214 if (abs(i)<ETA_BOUND_HE) continue;
00215 histname.str("");
00216 histtitle.str("");
00217 histname<<"HE_CenterOfEnergyRadius_ieta"<<i;
00218 histtitle<<"HE Center Of Energy ieta = "<<i;
00219 HE_CenterOfEnergyRadius[i+ETA_OFFSET_HE]=dbe_->book1D(histname.str().c_str(),
00220 histtitle.str().c_str(),
00221 200,0,1);
00222 }
00223 }
00224 dbe_->setCurrentFolder(subdir_+"HO");
00225 HOCenterOfEnergyRadius = dbe_->book1D("HOCenterOfEnergyRadius",
00226 "HO Center Of Energy radius",
00227 200,0,1);
00228 HOCenterOfEnergy = dbe_->book2D("HOCenterOfEnergy",
00229 "HO Center of Energy",
00230 40,-1,1,
00231 40,-1,1);
00232 if (makeDiagnostics_)
00233 {
00234 for (int i=-15;i<=15;++i)
00235 {
00236 if (i==0) continue;
00237 histname.str("");
00238 histtitle.str("");
00239 histname<<"HO_CenterOfEnergyRadius_ieta"<<i;
00240 histtitle<<"HO Center Of Energy radius ieta = "<<i;
00241 HO_CenterOfEnergyRadius[i+ETA_OFFSET_HO]=dbe_->book1D(histname.str().c_str(),
00242 histtitle.str().c_str(),
00243 200,0,1);
00244 }
00245 }
00246 dbe_->setCurrentFolder(subdir_+"HF");
00247 HFCenterOfEnergyRadius = dbe_->book1D("HFCenterOfEnergyRadius",
00248 "HF Center Of Energy radius",
00249 200,0,1);
00250 HFCenterOfEnergy = dbe_->book2D("HFCenterOfEnergy",
00251 "HF Center of Energy",
00252 40,-1,1,
00253 40,-1,1);
00254 if (makeDiagnostics_)
00255 {
00256 for (int i=-41;i<=41;++i)
00257 {
00258 if (abs(i)<ETA_BOUND_HF) continue;
00259 histname.str("");
00260 histtitle.str("");
00261 histname<<"HF_CenterOfEnergyRadius_ieta"<<i;
00262 histtitle<<"HF Center Of Energy radius ieta = "<<i;
00263 HF_CenterOfEnergyRadius[i+ETA_OFFSET_HF]=dbe_->book1D(histname.str().c_str(),
00264 histtitle.str().c_str(),
00265 200,0,1);
00266 }
00267 }
00268
00269 dbe_->setCurrentFolder(subdir_+"Lumi");
00270
00271
00272
00273 float radiusbins[13]={169,201,240,286,340,406,483,576,686,818,975,1162,1300};
00274 float phibins[71]={-3.5,-3.4,-3.3,-3.2,-3.1,
00275 -3.0,-2.9,-2.8,-2.7,-2.6,-2.5,-2.4,-2.3,-2.2,-2.1,
00276 -2.0,-1.9,-1.8,-1.7,-1.6,-1.5,-1.4,-1.3,-1.2,-1.1,
00277 -1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,
00278 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
00279 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9,
00280 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9,
00281 3.0, 3.1, 3.2, 3.3, 3.4, 3.5};
00282 Etsum_eta_L=dbe_->bookProfile("Et Sum vs Eta Long Fiber","Et Sum per Area vs Eta Long Fiber",27,0,27,100,0,100);
00283 Etsum_eta_S=dbe_->bookProfile("Et Sum vs Eta Short Fiber","Et Sum per Area vs Eta Short Fiber",27,0,27,100,0,100);
00284 Etsum_phi_L=dbe_->bookProfile("Et Sum vs Phi Long Fiber","Et Sum per Area vs Phi Long Fiber",36,0.5,72.5,100,0,100);
00285 Etsum_phi_S=dbe_->bookProfile("Et Sum vs Phi Short Fiber","Et Sum per Area crossing vs Phi Short Fiber",36,0.5,72.5,100,0,100);
00286
00287 Etsum_ratio_p=dbe_->book1D("Occ vs PMT events HF+","Energy difference of Long and Short Fiber HF+ in PMT events",105,0.,1.05);
00288 Energy_Occ=dbe_->book1D("Occ vs Energy","Occupancy vs Energy",200,0,2000);
00289 Etsum_ratio_m=dbe_->book1D("Occ vs PMT events HF-","Energy difference of Long and Short Fiber HF- in PMT events",105,0.,1.05);
00290 Etsum_map_L=dbe_->book2D("EtSum 2D phi and eta Long Fiber","Et Sum 2D phi and eta Long Fiber",27,0,27,36,0.5,72.5);
00291 Etsum_map_S=dbe_->book2D("EtSum 2D phi and eta Short Fiber","Et Sum 2D phi and eta Short Fiber",27,0,27,36,0.5,72.5);
00292
00293 Etsum_rphi_S=dbe_->book2D("EtSum 2D phi and radius Short Fiber","Et Sum 2D phi and radius Short Fiber",12, radiusbins, 70, phibins);
00294 Etsum_rphi_L=dbe_->book2D("EtSum 2D phi and radius Long Fiber","Et Sum 2D phi and radius Long Fiber",12, radiusbins, 70, phibins);
00295
00296 Etsum_ratio_map=dbe_->book2D("Abnormal PMT events","Abnormal PMT events",
00297 8,0,8,36, 0.5,72.5);
00298 SetEtaLabels(Etsum_ratio_map);
00299
00300 HFlumi_occ_LS = dbe_->book2D("HFlumi_occ_LS","HFlumi occupancy for current LS",
00301 8,0,8,36, 0.5,72.5);
00302 SetEtaLabels(HFlumi_occ_LS);
00303
00304 HFlumi_total_deadcells = dbe_->book2D("HFlumi_total_deadcells","Number of dead lumi channels for LS with at least 10 bad channels",
00305 8,0,8,36,0.5,72.5);
00306 SetEtaLabels(HFlumi_total_deadcells);
00307 HFlumi_total_hotcells = dbe_->book2D("HFlumi_total_hotcells","Number of hot lumi channels for LS with at least 10 bad channels",
00308 8,0,8,36,0.5,72.5);
00309 SetEtaLabels(HFlumi_total_hotcells);
00310
00311 HFlumi_diag_deadcells = dbe_->book2D("HFlumi_diag_deadcells","Channels that had no hit for at least one LS",
00312 8,0,8,36,0.5,72.5);
00313 SetEtaLabels(HFlumi_diag_deadcells);
00314 HFlumi_diag_hotcells = dbe_->book2D("HFlumi_diag_hotcells","Channels that appeared hot for at least one LS",
00315 8,0,8,36,0.5,72.5);
00316 SetEtaLabels(HFlumi_diag_hotcells);
00317
00318
00319
00320 Occ_rphi_S=dbe_->book2D("Occ 2D phi and radius Short Fiber","Occupancy 2D phi and radius Short Fiber",12, radiusbins, 70, phibins);
00321 Occ_rphi_L=dbe_->book2D("Occ 2D phi and radius Long Fiber","Occupancy 2D phi and radius Long Fiber",12, radiusbins, 70, phibins);
00322 Occ_eta_S=dbe_->bookProfile("Occ vs iEta Short Fiber","Occ per Bunch crossing vs iEta Short Fiber",27,0,27,40,0,800);
00323 Occ_eta_L=dbe_->bookProfile("Occ vs iEta Long Fiber","Occ per Bunch crossing vs iEta Long Fiber",27,0,27,40,0,800);
00324
00325 Occ_phi_L=dbe_->bookProfile("Occ vs iPhi Long Fiber","Occ per Bunch crossing vs iPhi Long Fiber",36,0.5,72.5,40,0,800);
00326
00327 Occ_phi_S=dbe_->bookProfile("Occ vs iPhi Short Fiber","Occ per Bunch crossing vs iPhi Short Fiber",36,0.5,72.5,40,0,800);
00328
00329 Occ_map_L=dbe_->book2D("Occ_map Long Fiber","Occ Map long Fiber (above threshold)",27,0,27,36,0.5,72.5);
00330 Occ_map_S=dbe_->book2D("Occ_map Short Fiber","Occ Map Short Fiber (above threshold)",27,0,27,36,0.5,72.5);
00331
00332 std::stringstream binlabel;
00333 for (int zz=0;zz<27;++zz)
00334 {
00335 if (zz<13)
00336 binlabel<<zz-41;
00337 else if (zz==13)
00338 binlabel<<"NULL";
00339 else
00340 binlabel<<zz+15;
00341 Occ_eta_S->setBinLabel(zz+1,binlabel.str().c_str());
00342 Occ_eta_L->setBinLabel(zz+1,binlabel.str().c_str());
00343 Occ_map_S->setBinLabel(zz+1,binlabel.str().c_str());
00344 Occ_map_L->setBinLabel(zz+1,binlabel.str().c_str());
00345 Etsum_eta_S->setBinLabel(zz+1,binlabel.str().c_str());
00346 Etsum_eta_L->setBinLabel(zz+1,binlabel.str().c_str());
00347 Etsum_map_S->setBinLabel(zz+1,binlabel.str().c_str());
00348 Etsum_map_L->setBinLabel(zz+1,binlabel.str().c_str());
00349 binlabel.str("");
00350 }
00351
00352
00353 HFlumi_ETsum_perwedge = dbe_->book1D("HF lumi ET-sum per wedge","HF lumi ET-sum per wedge;wedge",36,1,37);
00354 HFlumi_ETsum_perwedge->getTH1F()->SetMinimum(0);
00355
00356 HFlumi_Occupancy_above_thr_r1 = dbe_->book1D("HF lumi Occupancy above threshold ring1","HF lumi Occupancy above threshold ring1;wedge",36,1,37);
00357 HFlumi_Occupancy_between_thrs_r1 = dbe_->book1D("HF lumi Occupancy between thresholds ring1","HF lumi Occupancy between thresholds ring1;wedge",36,1,37);
00358 HFlumi_Occupancy_below_thr_r1 = dbe_->book1D("HF lumi Occupancy below threshold ring1","HF lumi Occupancy below threshold ring1;wedge",36,1,37);
00359 HFlumi_Occupancy_above_thr_r2 = dbe_->book1D("HF lumi Occupancy above threshold ring2","HF lumi Occupancy above threshold ring2;wedge",36,1,37);
00360 HFlumi_Occupancy_between_thrs_r2 = dbe_->book1D("HF lumi Occupancy between thresholds ring2","HF lumi Occupancy between thresholds ring2;wedge",36,1,37);
00361 HFlumi_Occupancy_below_thr_r2 = dbe_->book1D("HF lumi Occupancy below threshold ring2","HF lumi Occupancy below threshold ring2;wedge",36,1,37);
00362
00363 HFlumi_Occupancy_above_thr_r1->getTH1F()->SetMinimum(0);
00364 HFlumi_Occupancy_between_thrs_r1->getTH1F()->SetMinimum(0);
00365 HFlumi_Occupancy_below_thr_r1->getTH1F()->SetMinimum(0);
00366 HFlumi_Occupancy_above_thr_r2->getTH1F()->SetMinimum(0);
00367 HFlumi_Occupancy_between_thrs_r2->getTH1F()->SetMinimum(0);
00368 HFlumi_Occupancy_below_thr_r2->getTH1F()->SetMinimum(0);
00369
00370 HFlumi_Occupancy_per_channel_vs_lumiblock_RING1 = dbe_->bookProfile("HFlumiRing1OccupancyPerChannelVsLB",
00371 "HFlumi Occupancy per channel vs lumi-block (RING 1);LS; -ln(empty fraction)",
00372 NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
00373 HFlumi_Occupancy_per_channel_vs_lumiblock_RING2 = dbe_->bookProfile("HFlumiRing2OccupancyPerChannelVsLB","HFlumi Occupancy per channel vs lumi-block (RING 2);LS; -ln(empty fraction)",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
00374
00375 HFlumi_Occupancy_per_channel_vs_BX_RING1 = dbe_->bookProfile("HFlumi Occupancy per channel vs BX (RING 1)","HFlumi Occupancy per channel vs BX (RING 1);BX; -ln(empty fraction)",4000,0,4000,100,0,10000);
00376 HFlumi_Occupancy_per_channel_vs_BX_RING2 = dbe_->bookProfile("HFlumi Occupancy per channel vs BX (RING 2)","HFlumi Occupancy per channel vs BX (RING 2);BX; -ln(empty fraction)",4000,0,4000,100,0,10000);
00377 HFlumi_ETsum_vs_BX = dbe_->bookProfile("HFlumi_ETsum_vs_BX","HFlumi ETsum vs BX; BX; ETsum",4000,0,4000,100,0,10000);
00378
00379 HFlumi_Et_per_channel_vs_lumiblock = dbe_->bookProfile("HFlumi Et per channel vs lumi-block","HFlumi Et per channel vs lumi-block;LS;ET",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
00380
00381 HFlumi_Occupancy_per_channel_vs_lumiblock_RING1->getTProfile()->SetMarkerStyle(20);
00382 HFlumi_Occupancy_per_channel_vs_lumiblock_RING2->getTProfile()->SetMarkerStyle(20);
00383 HFlumi_Et_per_channel_vs_lumiblock->getTProfile()->SetMarkerStyle(20);
00384
00385 HFlumi_Ring1Status_vs_LS = dbe_->bookProfile("HFlumi_Ring1Status_vs_LS","Fraction of good Ring 1 channels vs LS;LS; Fraction of Good Channels",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
00386 HFlumi_Ring2Status_vs_LS = dbe_->bookProfile("HFlumi_Ring2Status_vs_LS","Fraction of good Ring 2 channels vs LS;LS; Fraction of Good Channels",NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
00387 HFlumi_Ring1Status_vs_LS->getTProfile()->SetMarkerStyle(20);
00388 HFlumi_Ring2Status_vs_LS->getTProfile()->SetMarkerStyle(20);
00389
00390 return;
00391 }
00392
00393 void HcalBeamMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00394 {
00395 HcalBaseDQMonitor::beginRun(run,c);
00396
00397 if (debug_>1) std::cout <<"HcalBeamMonitor::beginRun"<<std::endl;
00398 HcalBaseDQMonitor::beginRun(run,c);
00399
00400 lastProcessedLS_=0;
00401 runNumber_=run.id().run();
00402 if (lumiqualitydir_.size()>0 && Online_==true)
00403 {
00404 if (Overwrite_==false)
00405 outfile_ <<lumiqualitydir_<<"HcalHFLumistatus_"<<runNumber_<<".txt";
00406 else
00407 outfile_ <<lumiqualitydir_<<"HcalHFLumistatus.txt";
00408 std::ofstream outStream(outfile_.str().c_str());
00409 outStream<<"## Run "<<runNumber_<<std::endl;
00410 outStream<<"## LumiBlock\tRing1Status\t\tRing2Status\t\tGlobalStatus\tNentries"<<std::endl;
00411 outStream.close();
00412 }
00413
00414
00415
00416
00417
00418 ring1totalchannels_=144;
00419 ring2totalchannels_=144;
00420 BadCells_.clear();
00421
00422
00423 edm::ESHandle<HcalChannelQuality> p;
00424 c.get<HcalChannelQualityRcd>().get(p);
00425 HcalChannelQuality* chanquality = new HcalChannelQuality(*p.product());
00426 std::vector<DetId> mydetids = chanquality->getAllChannels();
00427
00428 for (unsigned int i=0;i<mydetids.size();++i)
00429 {
00430 if (mydetids[i].det()!=DetId::Hcal) continue;
00431 HcalDetId id=mydetids[i];
00432
00433 if (id.subdet()!=HcalForward) continue;
00434 if ((id.depth()==1 && (abs(id.ieta())==33 || abs(id.ieta())==34)) ||
00435 (id.depth()==2 && (abs(id.ieta())==35 || abs(id.ieta())==36)))
00436 {
00437 const HcalChannelStatus* origstatus=chanquality->getValues(id);
00438 HcalChannelStatus* mystatus=new HcalChannelStatus(origstatus->rawId(),origstatus->getValue());
00439 if (mystatus->isBitSet(HcalChannelStatus::HcalCellHot))
00440 BadCells_[id]=HcalChannelStatus::HcalCellHot;
00441
00442 else if (mystatus->isBitSet(HcalChannelStatus::HcalCellDead))
00443 BadCells_[id]=HcalChannelStatus::HcalCellDead;
00444
00445 if (mystatus->isBitSet(HcalChannelStatus::HcalCellHot) ||
00446 mystatus->isBitSet(HcalChannelStatus::HcalCellDead))
00447 {
00448 if (id.depth()==1) --ring1totalchannels_;
00449 else if (id.depth()==2) --ring2totalchannels_;
00450 }
00451 delete mystatus;
00452 }
00453 }
00454
00455 if (tevt_==0) this->setup();
00456 if (mergeRuns_==false) this->reset();
00457
00458 return;
00459
00460 }
00461
00462
00463 void HcalBeamMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
00464 {
00465 if (!IsAllowedCalibType()) return;
00466 if (LumiInOrder(e.luminosityBlock())==false) return;
00467
00468
00469 edm::Handle<HFDigiCollection> hf_digi;
00470
00471 edm::Handle<HBHERecHitCollection> hbhe_rechit;
00472 edm::Handle<HORecHitCollection> ho_rechit;
00473 edm::Handle<HFRecHitCollection> hf_rechit;
00474
00475 if (!(e.getByLabel(digiLabel_,hf_digi)))
00476 {
00477 edm::LogWarning("HcalBeamMonitor")<< digiLabel_<<" hf_digi not available";
00478 return;
00479 }
00480
00481 if (!(e.getByLabel(hbheRechitLabel_,hbhe_rechit)))
00482 {
00483 edm::LogWarning("HcalBeamMonitor")<< hbheRechitLabel_<<" hbhe_rechit not available";
00484 return;
00485 }
00486
00487 if (!(e.getByLabel(hfRechitLabel_,hf_rechit)))
00488 {
00489 edm::LogWarning("HcalBeamMonitor")<< hfRechitLabel_<<" hf_rechit not available";
00490 return;
00491 }
00492 if (!(e.getByLabel(hoRechitLabel_,ho_rechit)))
00493 {
00494 edm::LogWarning("HcalBeamMonitor")<< hoRechitLabel_<<" ho_rechit not available";
00495 return;
00496 }
00497
00498
00499 HcalBaseDQMonitor::analyze(e,c);
00500 processEvent(*hbhe_rechit, *ho_rechit, *hf_rechit, *hf_digi, e.bunchCrossing());
00501
00502 }
00503
00504
00505 void HcalBeamMonitor::processEvent(const HBHERecHitCollection& hbheHits,
00506 const HORecHitCollection& hoHits,
00507 const HFRecHitCollection& hfHits,
00508 const HFDigiCollection& hf,
00509 int bunchCrossing
00510 )
00511
00512 {
00513
00514 if (!dbe_)
00515 {
00516 if (debug_>0) std::cout <<"HcalBeamMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
00517 return;
00518 }
00519
00520 HBHERecHitCollection::const_iterator HBHEiter;
00521 HORecHitCollection::const_iterator HOiter;
00522 HFRecHitCollection::const_iterator HFiter;
00523
00524 double totalX=0;
00525 double totalY=0;
00526 double totalE=0;
00527
00528 double HBtotalX=0;
00529 double HBtotalY=0;
00530 double HBtotalE=0;
00531 double HEtotalX=0;
00532 double HEtotalY=0;
00533 double HEtotalE=0;
00534 double HOtotalX=0;
00535 double HOtotalY=0;
00536 double HOtotalE=0;
00537 double HFtotalX=0;
00538 double HFtotalY=0;
00539 double HFtotalE=0;
00540
00541 float hitsp[13][36][2];
00542 float hitsm[13][36][2];
00543 float hitsp_Et[13][36][2];
00544 float hitsm_Et[13][36][2];
00545
00546 for(int m=0;m<13;m++){
00547 for(int n=0;n<36;n++){
00548 hitsp[m][n][0]=0;
00549 hitsp[m][n][1]=0;
00550 hitsm[m][n][0]=0;
00551 hitsm[m][n][1]=0;
00552
00553 hitsp_Et[m][n][0]=0;
00554 hitsp_Et[m][n][1]=0;
00555 hitsm_Et[m][n][0]=0;
00556 hitsm_Et[m][n][1]=0;
00557 }
00558 }
00559
00560 if(hbheHits.size()>0)
00561 {
00562 double HB_weightedX[HBETASIZE]={0.};
00563 double HB_weightedY[HBETASIZE]={0.};
00564 double HB_energy[HBETASIZE]={0.};
00565
00566 double HE_weightedX[HEETASIZE]={0.};
00567 double HE_weightedY[HEETASIZE]={0.};
00568 double HE_energy[HEETASIZE]={0.};
00569
00570 int ieta, iphi;
00571
00572 for (HBHEiter=hbheHits.begin();
00573 HBHEiter!=hbheHits.end();
00574 ++HBHEiter)
00575 {
00576
00577
00578 if (HBHEiter->energy()<0) continue;
00579 HcalDetId id(HBHEiter->detid().rawId());
00580 ieta=id.ieta();
00581 iphi=id.iphi();
00582
00583 int index=-1;
00584 if ((HcalSubdetector)(id.subdet())==HcalBarrel)
00585 {
00586 HBtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
00587 HBtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
00588 HBtotalE+=HBHEiter->energy();
00589
00590 index=ieta+ETA_OFFSET_HB;
00591 if (index<0 || index>= HBETASIZE) continue;
00592 HB_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
00593 HB_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
00594 HB_energy[index]+=HBHEiter->energy();
00595 }
00596
00597 else
00598 {
00599 HEtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
00600 HEtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
00601 HEtotalE+=HBHEiter->energy();
00602
00603 index=ieta+ETA_OFFSET_HE;
00604 if (index<0 || index>= HEETASIZE) continue;
00605 HE_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
00606 HE_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
00607 HE_energy[index]+=HBHEiter->energy();
00608 }
00609 }
00610
00611
00612 int hbeta=ETA_OFFSET_HB;
00613 for (int i=-1*hbeta;i<=hbeta;++i)
00614 {
00615 if (i==0) continue;
00616 int index = i+ETA_OFFSET_HB;
00617 if (index<0 || index>= HBETASIZE) continue;
00618 if (HB_energy[index]==0) continue;
00619 double moment=pow(HB_weightedX[index],2)+pow(HB_weightedY[index],2);
00620 moment=pow(moment,0.5);
00621 moment/=HB_energy[index];
00622 if (moment!=0)
00623 {
00624 if (makeDiagnostics_) HB_CenterOfEnergyRadius[index]->Fill(moment);
00625 COEradiusVSeta->Fill(i,moment);
00626 }
00627 }
00628
00629 int heeta=ETA_OFFSET_HE;
00630 for (int i=-1*heeta;i<=heeta;++i)
00631 {
00632 if (i==0) continue;
00633 if (i>-1*ETA_BOUND_HE && i <ETA_BOUND_HE) continue;
00634 int index = i + ETA_OFFSET_HE;
00635 if (index<0 || index>= HEETASIZE) continue;
00636 if (HE_energy[index]==0) continue;
00637 double moment=pow(HE_weightedX[index],2)+pow(HE_weightedY[index],2);
00638 moment=pow(moment,0.5);
00639 moment/=HE_energy[index];
00640 if (moment!=0)
00641 {
00642 if (makeDiagnostics_) HE_CenterOfEnergyRadius[index]->Fill(moment);
00643 COEradiusVSeta->Fill(i,moment);
00644 }
00645 }
00646
00647 }
00648
00649
00650
00651 if(hoHits.size()>0)
00652 {
00653 double HO_weightedX[HOETASIZE]={0.};
00654 double HO_weightedY[HOETASIZE]={0.};
00655 double HO_energy[HOETASIZE]={0.};
00656 double offset;
00657
00658 int ieta, iphi;
00659 for (HOiter=hoHits.begin();
00660 HOiter!=hoHits.end();
00661 ++HOiter)
00662 {
00663
00664 if (HOiter->energy()<0) continue;
00665 HcalDetId id(HOiter->detid().rawId());
00666 ieta=id.ieta();
00667 iphi=id.iphi();
00668
00669 HOtotalX+=HOiter->energy()*cos(PI*iphi/36.);
00670 HOtotalY+=HOiter->energy()*sin(PI*iphi/36.);
00671 HOtotalE+=HOiter->energy();
00672
00673 int index=ieta+ETA_OFFSET_HO;
00674 if (index<0 || index>= HOETASIZE) continue;
00675 HO_weightedX[index]+=HOiter->energy()*cos(PI*iphi/36.);
00676 HO_weightedY[index]+=HOiter->energy()*sin(PI*iphi/36.);
00677 HO_energy[index]+=HOiter->energy();
00678 }
00679
00680 for (int i=-1*ETA_OFFSET_HO;i<=ETA_OFFSET_HO;++i)
00681 {
00682 if (i==0) continue;
00683 int index = i + ETA_OFFSET_HO;
00684 if (index < 0 || index>= HOETASIZE) continue;
00685 if (HO_energy[index]==0) continue;
00686 double moment=pow(HO_weightedX[index],2)+pow(HO_weightedY[index],2);
00687 moment=pow(moment,0.5);
00688 moment/=HO_energy[index];
00689
00690 offset = (i>0 ? 0.5: -0.5);
00691 if (moment!=0)
00692 {
00693 if (makeDiagnostics_) HO_CenterOfEnergyRadius[index]->Fill(moment);
00694 COEradiusVSeta->Fill(i+offset,moment);
00695 }
00696 }
00697 }
00698
00700
00701
00702 Etsum_ratio_map->Fill(-1,-1,1);
00703 {
00704 if(hfHits.size()>0)
00705 {
00706 double HF_weightedX[HFETASIZE]={0.};
00707 double HF_weightedY[HFETASIZE]={0.};
00708 double HF_energy[HFETASIZE]={0.};
00709 double offset;
00710
00711
00712 double emptytowersRing1 = ring1totalchannels_;
00713 double emptytowersRing2 = ring2totalchannels_;
00714 double ZStowersRing1 = ring1totalchannels_;
00715 double ZStowersRing2 = ring2totalchannels_;
00716
00717 int ieta, iphi;
00718 float et,eta,phi,r;
00719
00720 HFlumi_occ_LS->Fill(-1,-1,1 );
00721
00722
00723
00724 HFlumi_occ_LS->getTH2F()->SetMaximum(HFlumi_occ_LS->getBinContent(0,0));
00725
00726 double etx=0, ety=0;
00727
00728 for (HFiter=hfHits.begin();
00729 HFiter!=hfHits.end();
00730 ++HFiter)
00731 {
00732
00733 ieta = HFiter->id().ieta();
00734 iphi = HFiter->id().iphi();
00735
00736 int binieta=ieta;
00737 if (ieta<0) binieta+=41;
00738 else if (ieta>0) binieta-=15;
00739
00740
00741
00742 if (abs(ieta)>=33 && abs(ieta)<=36)
00743 {
00744
00745 if (BadCells_.find(HFiter->id())==BadCells_.end())
00746 {
00747 if ((abs(ieta)<35) && HFiter->id().depth()==1) --ZStowersRing1;
00748 else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- ZStowersRing2;
00749 }
00750 }
00751
00752 if (HFiter->energy()<0) continue;
00753
00754 eta=theHFEtaBounds[abs(ieta)-29];
00755 et=HFiter->energy()/cosh(eta)/area[abs(ieta)-29];
00756 if (abs(ieta)>=33 && abs(ieta)<=36)
00757 {
00758
00759 if (et>=occThresh_ && BadCells_.find(HFiter->id())==BadCells_.end() )
00760 {
00761 if ((abs(ieta)<35) && HFiter->id().depth()==1) --emptytowersRing1;
00762 else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- emptytowersRing2;
00763 }
00764 }
00765 r=radius[abs(ieta)-29];
00766 if(HFiter->id().iphi()<37)
00767 phi=HFiter->id().iphi()*0.087266;
00768 else phi=(HFiter->id().iphi()-72)*0.087266;
00769
00770
00771 if (HFiter->id().depth()==1)
00772 {
00773 Etsum_eta_L->Fill(binieta,et);
00774 Etsum_phi_L->Fill(iphi,et);
00775 Etsum_map_L->Fill(binieta,iphi,et);
00776 Etsum_rphi_L->Fill(r,phi,et);
00777
00778 if(ieta>0) {
00779 hitsp[ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
00780 hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
00781 }
00782 else if(ieta<0) {
00783 hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
00784 hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
00785 }
00786 }
00787
00788
00789 if (HFiter->id().depth()==2)
00790 {
00791 Etsum_eta_S->Fill(binieta,et);
00792 Etsum_phi_S->Fill(iphi,et);
00793 Etsum_rphi_S->Fill(r,phi,et);
00794 Etsum_map_S->Fill(binieta,iphi,et);
00795 if(ieta>0)
00796 {
00797 hitsp[ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
00798 hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
00799 }
00800 else if(ieta<0) {
00801 hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
00802 hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
00803 }
00804
00805 }
00806 Energy_Occ->Fill(HFiter->energy());
00807
00808
00809
00810 if ((abs(ieta) == 33 || abs(ieta) == 34) && HFiter->id().depth() == 1)
00811 {
00812 etx+=et*cos(PI*iphi/36.);
00813 ety+=et*sin(PI*iphi/36.);
00814
00815 HFlumi_Et_per_channel_vs_lumiblock->Fill(currentLS,et);
00816 if (et>occThresh_)
00817 {
00818 int etabin=0;
00819 if (ieta<0)
00820 etabin=36+ieta;
00821 else
00822 etabin=ieta-29;
00823 HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
00824 }
00825 }
00826
00827 else if ((abs(ieta) == 35 || abs(ieta) == 36) && HFiter->id().depth() == 2)
00828 {
00829 etx+=et*cos(PI*iphi/36.);
00830 ety+=et*sin(PI*iphi/36.);
00831
00832 HFlumi_Et_per_channel_vs_lumiblock->Fill(currentLS,et);
00833 if (et>occThresh_)
00834 {
00835 int etabin=0;
00836 if (ieta<0)
00837 etabin=36+ieta;
00838 else
00839 etabin=ieta-29;
00840 HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
00841 }
00842 }
00843
00844
00845
00846 int value=0;
00847 if(et>occThresh_) value=1;
00848
00849 if (HFiter->id().depth()==1)
00850 {
00851 Occ_eta_L->Fill(binieta,value);
00852 Occ_phi_L->Fill(iphi,value);
00853 Occ_map_L->Fill(binieta,iphi,value);
00854 Occ_rphi_L->Fill(r,phi,value);
00855 }
00856
00857 else if (HFiter->id().depth()==2)
00858 {
00859 Occ_eta_S->Fill(binieta,value);
00860 Occ_phi_S->Fill(iphi,value);
00861 Occ_map_S->Fill(binieta,iphi,value);
00862 Occ_rphi_S->Fill(r,phi,value);
00863 }
00864 HcalDetId id(HFiter->detid().rawId());
00865
00866 HFtotalX+=HFiter->energy()*cos(PI*iphi/36.);
00867 HFtotalY+=HFiter->energy()*sin(PI*iphi/36.);
00868 HFtotalE+=HFiter->energy();
00869
00870 int index=ieta+ETA_OFFSET_HF;
00871 if (index<0 || index>= HFETASIZE) continue;
00872 HF_weightedX[index]+=HFiter->energy()*cos(PI*iphi/36.);
00873 HF_weightedY[index]+=HFiter->energy()*sin(PI*iphi/36.);
00874 HF_energy[index]+=HFiter->energy();
00875
00876 }
00877
00878
00879
00880
00881
00882
00883
00884 double logvalue=-1;
00885 if (ring1totalchannels_>0)
00886 {
00887 if (emptytowersRing1>0)
00888 logvalue=-1.*log(emptytowersRing1/ring1totalchannels_);
00889 HFlumi_Occupancy_per_channel_vs_lumiblock_RING1->Fill(currentLS,logvalue);
00890 HFlumi_Occupancy_per_channel_vs_BX_RING1->Fill(bunchCrossing,logvalue);
00891 }
00892
00893 logvalue=-1;
00894 if (ring2totalchannels_>0)
00895 {
00896 if (emptytowersRing2>0)
00897 logvalue=-1.*log(emptytowersRing2/ring2totalchannels_);
00898 HFlumi_Occupancy_per_channel_vs_lumiblock_RING2->Fill(currentLS,logvalue);
00899 HFlumi_Occupancy_per_channel_vs_BX_RING2->Fill(bunchCrossing,logvalue);
00900 }
00901
00902 HFlumi_ETsum_vs_BX->Fill(bunchCrossing,pow(etx*etx+ety*ety,0.5));
00903 int hfeta=ETA_OFFSET_HF;
00904 for (int i=-1*hfeta;i<=hfeta;++i)
00905 {
00906 if (i==0) continue;
00907 if (i>-1*ETA_BOUND_HF && i <ETA_BOUND_HF) continue;
00908 int index = i + ETA_OFFSET_HF;
00909 if (index<0 || index>= HFETASIZE) continue;
00910 if (HF_energy[index]==0) continue;
00911 double moment=pow(HF_weightedX[index],2)+pow(HF_weightedY[index],2);
00912 moment=pow(moment,0.5);
00913 moment/=HF_energy[index];
00914 offset = (i>0 ? 0.5: -0.5);
00915 if (moment!=0)
00916 {
00917 if (makeDiagnostics_) HF_CenterOfEnergyRadius[index]->Fill(moment);
00918 COEradiusVSeta->Fill(i+offset,moment);
00919 }
00920 }
00921 float ratiom,ratiop;
00922
00923 for(int i=0;i<13;i++){
00924 for(int j=0;j<36;j++){
00925
00926 if(hitsp[i][j][0]==hitsp[i][j][1]) continue;
00927
00928 if (hitsp[i][j][0] < 1.2 && hitsp[i][j][1] < 1.8) continue;
00929
00930 if (((i+29) < 33) || ((i+29) > 36)) continue;
00931 ratiop=fabs((fabs(hitsp[i][j][0])-fabs(hitsp[i][j][1]))/(fabs(hitsp[i][j][0])+fabs(hitsp[i][j][1])));
00932
00933 if ((hitsp_Et[i][j][0] > 5. && hitsp[i][j][1] < 1.8) || (hitsp_Et[i][j][1] > 5. && hitsp[i][j][0] < 1.2)){
00934 Etsum_ratio_p->Fill(ratiop);
00935 if(abs(ratiop>0.95)) Etsum_ratio_map->Fill(i,2*j+1);
00936 }
00937 }
00938 }
00939
00940 for(int p=0;p<13;p++){
00941 for(int q=0;q<36;q++){
00942
00943 if(hitsm[p][q][0]==hitsm[p][q][1]) continue;
00944
00945 if (hitsm[p][q][0] < 1.2 && hitsm[p][q][1] < 1.8) continue;
00946
00947 if (((p+29) < 33) || ((p+29) > 36)) continue;
00948 ratiom=fabs((fabs(hitsm[p][q][0])-fabs(hitsm[p][q][1]))/(fabs(hitsm[p][q][0])+fabs(hitsm[p][q][1])));
00949 if ((hitsm_Et[p][q][0] > 5. && hitsm[p][q][1] < 1.8) || (hitsm_Et[p][q][1] > 5. && hitsm[p][q][0] < 1.2)){
00950 Etsum_ratio_m->Fill(ratiom);
00951 if(abs(ratiom>0.95)) Etsum_ratio_map->Fill(7-p,2*q+1);
00952
00953 }
00954 }
00955 }
00956 }
00957
00958 totalX=HBtotalX+HEtotalX+HOtotalX+HFtotalX;
00959 totalY=HBtotalY+HEtotalY+HOtotalY+HFtotalY;
00960 totalE=HBtotalE+HEtotalE+HOtotalE+HFtotalE;
00961
00962 double moment;
00963 if (HBtotalE>0)
00964 {
00965 moment=pow(HBtotalX*HBtotalX+HBtotalY*HBtotalY,0.5)/HBtotalE;
00966 HBCenterOfEnergyRadius->Fill(moment);
00967 HBCenterOfEnergy->Fill(HBtotalX/HBtotalE, HBtotalY/HBtotalE);
00968 }
00969 if (HEtotalE>0)
00970 {
00971 moment=pow(HEtotalX*HEtotalX+HEtotalY*HEtotalY,0.5)/HEtotalE;
00972 HECenterOfEnergyRadius->Fill(moment);
00973 HECenterOfEnergy->Fill(HEtotalX/HEtotalE, HEtotalY/HEtotalE);
00974 }
00975 if (HOtotalE>0)
00976 {
00977 moment=pow(HOtotalX*HOtotalX+HOtotalY*HOtotalY,0.5)/HOtotalE;
00978 HOCenterOfEnergyRadius->Fill(moment);
00979 HOCenterOfEnergy->Fill(HOtotalX/HOtotalE, HOtotalY/HOtotalE);
00980 }
00981 if (HFtotalE>0)
00982 {
00983 moment=pow(HFtotalX*HFtotalX+HFtotalY*HFtotalY,0.5)/HFtotalE;
00984 HFCenterOfEnergyRadius->Fill(moment);
00985 HFCenterOfEnergy->Fill(HFtotalX/HFtotalE, HFtotalY/HFtotalE);
00986 }
00987 if (totalE>0)
00988 {
00989 moment = pow(totalX*totalX+totalY*totalY,0.5)/totalE;
00990 CenterOfEnergyRadius->Fill(moment);
00991 CenterOfEnergy->Fill(totalX/totalE, totalY/totalE);
00992 }
00993
00994
00995
00996 for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
00997 const HFDataFrame digi = (const HFDataFrame)(*j);
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 int theTStobeused = 6;
01018
01019 int mask=1;
01020 if(mask!=1) continue;
01021
01022 for (int i=0; i<digi.size(); i++) {
01023 if (i==theTStobeused) {
01024 float tmpET =0;
01025 int jadc=digi.sample(i).adc();
01026
01027
01028
01029 tmpET = jadc;
01030
01031
01032
01033 if(digi.id().ieta()>28){
01034 if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
01035 HFlumi_ETsum_perwedge->Fill(1,tmpET);
01036 if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
01037 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(1,1);
01038 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(1,1);
01039 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(1,1);
01040 }
01041 else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
01042 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(1,1);
01043 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(1,1);
01044 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(1,1);
01045 }
01046 }
01047 else {
01048 for (int iwedge=2; iwedge<19; iwedge++) {
01049 int itmp=4*(iwedge-1);
01050 if( (digi.id().iphi()==(itmp+1)) || (digi.id().iphi()==(itmp-1))) {
01051 HFlumi_ETsum_perwedge->Fill(iwedge,tmpET);
01052 if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
01053 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iwedge,1);
01054 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iwedge,1);
01055 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iwedge,1);
01056 }
01057 else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
01058 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iwedge,1);
01059 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iwedge,1);
01060 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iwedge,1);
01061 }
01062 iwedge=99;
01063 }
01064 }
01065 }
01066 }
01067 else if(digi.id().ieta()<-28){
01068 if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
01069 HFlumi_ETsum_perwedge->Fill(19,tmpET);
01070 if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
01071 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(19,1);
01072 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(19,1);
01073 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(19,1);
01074 }
01075 else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
01076 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(19,1);
01077 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(19,1);
01078 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(19,1);
01079 }
01080 }
01081 else {
01082 for (int iw=2; iw<19; iw++) {
01083 int itemp=4*(iw-1);
01084 if( (digi.id().iphi()==(itemp+1)) || (digi.id().iphi()==(itemp-1))) {
01085 HFlumi_ETsum_perwedge->Fill(iw+18,tmpET);
01086 if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
01087 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iw+18,1);
01088 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iw+18,1);
01089 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iw+18,1);
01090 }
01091 else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
01092 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iw+18,1);
01093 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iw+18,1);
01094 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iw+18,1);
01095 }
01096 iw=99;
01097 }
01098 }
01099 }
01100 }
01101 }
01102 }
01103 }
01104 return;
01105 }
01106 }
01107
01108
01109
01110 void HcalBeamMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
01111 const edm::EventSetup& c)
01112
01113 {
01114
01115
01116 if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
01117 HcalBaseDQMonitor::beginLuminosityBlock(lumiSeg,c);
01118
01119 if (lumiSeg.luminosityBlock()==lastProcessedLS_) return;
01120 ProblemsCurrentLB->Reset();
01121 HFlumi_occ_LS->Reset();
01122 std::stringstream title;
01123 title <<"HFlumi occupancy for LS # " <<currentLS;
01124 HFlumi_occ_LS->getTH2F()->SetTitle(title.str().c_str());
01125 return;
01126 }
01127
01128 void HcalBeamMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
01129 const edm::EventSetup& c)
01130 {
01131 if (debug_>1) std::cout <<"<HcalBeamMonitor::endLuminosityBlock>"<<std::endl;
01132 if (LumiInOrder(lumiSeg.luminosityBlock())==false)
01133 {
01134 if (debug_>1)
01135 std::cout <<"<HcalBeamMonitor::endLuminosityBlock> Failed LumiInOrder test!"<<std::endl;
01136 return;
01137 }
01138 lastProcessedLS_=lumiSeg.luminosityBlock();
01139 float Nentries=HFlumi_occ_LS->getBinContent(-1,-1);
01140 if (debug_>3)
01141 std::cout <<"Number of entries in this LB = "<<Nentries<<std::endl;
01142
01143 if (Nentries<minEvents_)
01144 {
01145
01146 HFlumi_Ring1Status_vs_LS->Fill(currentLS,-1);
01147 HFlumi_Ring2Status_vs_LS->Fill(currentLS,-1);
01148 if (Online_==false)
01149 return;
01150
01151 if (lumiqualitydir_.size()==0)
01152 return;
01153
01154 std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
01155 outStream<<currentLS<<"\t\t-1\t\t\t-1\t\t\t-1\t\t"<<Nentries<<std::endl;
01156 outStream.close();
01157 return;
01158 }
01159 if (Nentries==0) return;
01160
01161
01162 HFlumi_total_deadcells->Fill(-1,-1,1);
01163 HFlumi_total_hotcells->Fill(-1,-1,1);
01164 HFlumi_diag_deadcells->Fill(-1,-1,1);
01165 HFlumi_diag_hotcells->Fill(-1,-1,1);
01166
01167
01168 int ietamap[8]={-36,-35,-34,-33,33,34,35,36};
01169 int ieta=-1, iphi = -1, depth=-1;
01170 int badring1=0;
01171 int badring2=0;
01172 int ndeadcells=0;
01173 int nhotcells=0;
01174
01175
01176 for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
01177 {
01178 for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
01179 {
01180
01181
01182 if (x<=8)
01183 ieta=ietamap[x-1];
01184 else
01185 ieta=-1;
01186 iphi=2*y-1;
01187 if (abs(ieta)==33 || abs(ieta)==34) depth=1;
01188 else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
01189 else depth = -1;
01190 if (depth !=-1 && ieta!=1)
01191 {
01192 HcalDetId thisID(HcalForward, ieta, iphi, depth);
01193 if (BadCells_.find(thisID)!=BadCells_.end())
01194 continue;
01195 }
01196 double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
01197 if (Ncellhits==0)
01198 {
01199 ++ndeadcells;
01200 HFlumi_diag_deadcells->Fill(x-1,2*y-1,1);
01201 }
01202
01203 if (Ncellhits>hotrate_*Nentries)
01204 {
01205 ++nhotcells;
01206 HFlumi_diag_hotcells->Fill(x-1,2*y-1,1);
01207 }
01208 if (Ncellhits==0 || Ncellhits>hotrate_*Nentries)
01209 {
01210 if (depth==1) badring1++;
01211 else if (depth==2) badring2++;
01212 }
01213 }
01214 }
01215
01216
01217 ProblemsCurrentLB->Fill(-1,-1,levt_);
01218 if (ndeadcells+nhotcells>=minBadCells_)
01219 {
01220
01221 ProblemsCurrentLB->Fill(6,0,(ndeadcells+nhotcells)*levt_);
01222 for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
01223 {
01224 for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
01225 {
01226 if (x<=8)
01227 ieta=ietamap[x-1];
01228 else
01229 ieta=-1;
01230 iphi=2*y-1;
01231 if (abs(ieta)==33 || abs(ieta)==34) depth=1;
01232 else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
01233 else depth = -1;
01234 if (depth !=-1 && ieta!=1)
01235 {
01236
01237 HcalDetId thisID(HcalForward, ieta, iphi, depth);
01238 if (BadCells_.find(thisID)!=BadCells_.end())
01239 continue;
01240 }
01241 double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
01242 if (Ncellhits==0)
01243 {
01244
01245 HFlumi_total_deadcells->Fill(x-1,2*y-1,1);
01246 }
01247
01248
01249 if (Ncellhits>hotrate_*Nentries)
01250 {
01251 HFlumi_total_hotcells->Fill(x-1,2*y-1,1);
01252 }
01253 }
01254 }
01255 }
01256
01257
01258 double ring1status=0;
01259 double ring2status=0;
01260 if (ring1totalchannels_==0)
01261 ring1status=0;
01262 else
01263 ring1status=1-1.*badring1/ring1totalchannels_;
01264 HFlumi_Ring1Status_vs_LS->Fill(currentLS,ring1status);
01265 if (ring2totalchannels_==0)
01266 ring2status=0;
01267 else
01268 ring2status=1-1.*badring2/ring2totalchannels_;
01269 HFlumi_Ring2Status_vs_LS->Fill(currentLS,ring2status);
01270
01271
01272 int totalstatus=0;
01273 if (ring1status>0.9 && ring2status>0.9)
01274 totalstatus=1;
01275 else
01276 {
01277 if (ring1status<=0.9)
01278 totalstatus-=2;
01279 if (ring2status<=0.9)
01280 totalstatus-=4;
01281 }
01282
01283 if (lumiqualitydir_.size()==0)
01284 return;
01285
01286 std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
01287 outStream.precision(6);
01288 outStream<<currentLS<<"\t\t"<<ring1status<<"\t\t"<<ring2status<<"\t\t"<<totalstatus<<"\t\t"<<Nentries<<std::endl;
01289 outStream.close();
01290 return;
01291 }
01292
01293 const float HcalBeamMonitor::area[]={0.111,0.175,0.175,0.175,0.175,0.175,0.174,0.178,0.172,0.175,0.178,0.346,0.604};
01294 const float HcalBeamMonitor::radius[]={1300,1162,975,818,686,576,483,406,340,286,240,201,169};
01295
01296 void HcalBeamMonitor::SetEtaLabels(MonitorElement * h)
01297 {
01298 h->getTH2F()->GetXaxis()->SetBinLabel(1,"-36S");
01299 h->getTH2F()->GetXaxis()->SetBinLabel(2,"-35S");
01300 h->getTH2F()->GetXaxis()->SetBinLabel(3,"-34L");
01301 h->getTH2F()->GetXaxis()->SetBinLabel(4,"-33L");
01302 h->getTH2F()->GetXaxis()->SetBinLabel(5,"33L");
01303 h->getTH2F()->GetXaxis()->SetBinLabel(6,"34L");
01304 h->getTH2F()->GetXaxis()->SetBinLabel(7,"35S");
01305 h->getTH2F()->GetXaxis()->SetBinLabel(8,"36S");
01306 return;
01307 }
01308
01309 DEFINE_FWK_MODULE(HcalBeamMonitor);
01310