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 }
00452 }
00453
00454 if (tevt_==0) this->setup();
00455 if (mergeRuns_==false) this->reset();
00456
00457 return;
00458
00459 }
00460
00461
00462 void HcalBeamMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
00463 {
00464 if (!IsAllowedCalibType()) return;
00465 if (LumiInOrder(e.luminosityBlock())==false) return;
00466
00467
00468 edm::Handle<HFDigiCollection> hf_digi;
00469
00470 edm::Handle<HBHERecHitCollection> hbhe_rechit;
00471 edm::Handle<HORecHitCollection> ho_rechit;
00472 edm::Handle<HFRecHitCollection> hf_rechit;
00473
00474 if (!(e.getByLabel(digiLabel_,hf_digi)))
00475 {
00476 edm::LogWarning("HcalBeamMonitor")<< digiLabel_<<" hf_digi not available";
00477 return;
00478 }
00479
00480 if (!(e.getByLabel(hbheRechitLabel_,hbhe_rechit)))
00481 {
00482 edm::LogWarning("HcalBeamMonitor")<< hbheRechitLabel_<<" hbhe_rechit not available";
00483 return;
00484 }
00485
00486 if (!(e.getByLabel(hfRechitLabel_,hf_rechit)))
00487 {
00488 edm::LogWarning("HcalBeamMonitor")<< hfRechitLabel_<<" hf_rechit not available";
00489 return;
00490 }
00491 if (!(e.getByLabel(hoRechitLabel_,ho_rechit)))
00492 {
00493 edm::LogWarning("HcalBeamMonitor")<< hoRechitLabel_<<" ho_rechit not available";
00494 return;
00495 }
00496
00497
00498 HcalBaseDQMonitor::analyze(e,c);
00499 processEvent(*hbhe_rechit, *ho_rechit, *hf_rechit, *hf_digi, e.bunchCrossing());
00500
00501 }
00502
00503
00504 void HcalBeamMonitor::processEvent(const HBHERecHitCollection& hbheHits,
00505 const HORecHitCollection& hoHits,
00506 const HFRecHitCollection& hfHits,
00507 const HFDigiCollection& hf,
00508 int bunchCrossing
00509 )
00510
00511 {
00512
00513 if (!dbe_)
00514 {
00515 if (debug_>0) std::cout <<"HcalBeamMonitor::processEvent DQMStore not instantiated!!!"<<std::endl;
00516 return;
00517 }
00518
00519 HBHERecHitCollection::const_iterator HBHEiter;
00520 HORecHitCollection::const_iterator HOiter;
00521 HFRecHitCollection::const_iterator HFiter;
00522
00523 double totalX=0;
00524 double totalY=0;
00525 double totalE=0;
00526
00527 double HBtotalX=0;
00528 double HBtotalY=0;
00529 double HBtotalE=0;
00530 double HEtotalX=0;
00531 double HEtotalY=0;
00532 double HEtotalE=0;
00533 double HOtotalX=0;
00534 double HOtotalY=0;
00535 double HOtotalE=0;
00536 double HFtotalX=0;
00537 double HFtotalY=0;
00538 double HFtotalE=0;
00539
00540 float hitsp[13][36][2];
00541 float hitsm[13][36][2];
00542 float hitsp_Et[13][36][2];
00543 float hitsm_Et[13][36][2];
00544
00545 for(int m=0;m<13;m++){
00546 for(int n=0;n<36;n++){
00547 hitsp[m][n][0]=0;
00548 hitsp[m][n][1]=0;
00549 hitsm[m][n][0]=0;
00550 hitsm[m][n][1]=0;
00551
00552 hitsp_Et[m][n][0]=0;
00553 hitsp_Et[m][n][1]=0;
00554 hitsm_Et[m][n][0]=0;
00555 hitsm_Et[m][n][1]=0;
00556 }
00557 }
00558
00559 if(hbheHits.size()>0)
00560 {
00561 double HB_weightedX[HBETASIZE]={0.};
00562 double HB_weightedY[HBETASIZE]={0.};
00563 double HB_energy[HBETASIZE]={0.};
00564
00565 double HE_weightedX[HEETASIZE]={0.};
00566 double HE_weightedY[HEETASIZE]={0.};
00567 double HE_energy[HEETASIZE]={0.};
00568
00569 int ieta, iphi;
00570
00571 for (HBHEiter=hbheHits.begin();
00572 HBHEiter!=hbheHits.end();
00573 ++HBHEiter)
00574 {
00575
00576
00577 if (HBHEiter->energy()<0) continue;
00578 HcalDetId id(HBHEiter->detid().rawId());
00579 ieta=id.ieta();
00580 iphi=id.iphi();
00581
00582 int index=-1;
00583 if ((HcalSubdetector)(id.subdet())==HcalBarrel)
00584 {
00585 HBtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
00586 HBtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
00587 HBtotalE+=HBHEiter->energy();
00588
00589 index=ieta+ETA_OFFSET_HB;
00590 if (index<0 || index> HBETASIZE) continue;
00591 HB_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
00592 HB_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
00593 HB_energy[index]+=HBHEiter->energy();
00594 }
00595
00596 else
00597 {
00598 HEtotalX+=HBHEiter->energy()*cos(PI*iphi/36.);
00599 HEtotalY+=HBHEiter->energy()*sin(PI*iphi/36.);
00600 HEtotalE+=HBHEiter->energy();
00601
00602 index=ieta+ETA_OFFSET_HE;
00603 if (index<0 || index> HEETASIZE) continue;
00604 HE_weightedX[index]+=HBHEiter->energy()*cos(PI*iphi/36.);
00605 HE_weightedY[index]+=HBHEiter->energy()*sin(PI*iphi/36.);
00606 HE_energy[index]+=HBHEiter->energy();
00607 }
00608 }
00609
00610
00611 int hbeta=ETA_OFFSET_HB;
00612 for (int i=-1*hbeta;i<=hbeta;++i)
00613 {
00614 if (i==0) continue;
00615 int index = i+ETA_OFFSET_HB;
00616 if (index<0 || index> HBETASIZE) continue;
00617 if (HB_energy[index]==0) continue;
00618 double moment=pow(HB_weightedX[index],2)+pow(HB_weightedY[index],2);
00619 moment=pow(moment,0.5);
00620 moment/=HB_energy[index];
00621 if (moment!=0)
00622 {
00623 if (makeDiagnostics_) HB_CenterOfEnergyRadius[index]->Fill(moment);
00624 COEradiusVSeta->Fill(i,moment);
00625 }
00626 }
00627
00628 int heeta=ETA_OFFSET_HE;
00629 for (int i=-1*heeta;i<=heeta;++i)
00630 {
00631 if (i==0) continue;
00632 if (i>-1*ETA_BOUND_HE && i <ETA_BOUND_HE) continue;
00633 int index = i + ETA_OFFSET_HE;
00634 if (index<0 || index> HEETASIZE) continue;
00635 if (HE_energy[index]==0) continue;
00636 double moment=pow(HE_weightedX[index],2)+pow(HE_weightedY[index],2);
00637 moment=pow(moment,0.5);
00638 moment/=HE_energy[index];
00639 if (moment!=0)
00640 {
00641 if (makeDiagnostics_) HE_CenterOfEnergyRadius[index]->Fill(moment);
00642 COEradiusVSeta->Fill(i,moment);
00643 }
00644 }
00645
00646 }
00647
00648
00649
00650 if(hoHits.size()>0)
00651 {
00652 double HO_weightedX[HOETASIZE]={0.};
00653 double HO_weightedY[HOETASIZE]={0.};
00654 double HO_energy[HOETASIZE]={0.};
00655 double offset;
00656
00657 int ieta, iphi;
00658 for (HOiter=hoHits.begin();
00659 HOiter!=hoHits.end();
00660 ++HOiter)
00661 {
00662
00663 if (HOiter->energy()<0) continue;
00664 HcalDetId id(HOiter->detid().rawId());
00665 ieta=id.ieta();
00666 iphi=id.iphi();
00667
00668 HOtotalX+=HOiter->energy()*cos(PI*iphi/36.);
00669 HOtotalY+=HOiter->energy()*sin(PI*iphi/36.);
00670 HOtotalE+=HOiter->energy();
00671
00672 int index=ieta+ETA_OFFSET_HO;
00673 if (index<0 || index>HOETASIZE) continue;
00674 HO_weightedX[index]+=HOiter->energy()*cos(PI*iphi/36.);
00675 HO_weightedY[index]+=HOiter->energy()*sin(PI*iphi/36.);
00676 HO_energy[index]+=HOiter->energy();
00677 }
00678
00679 for (int i=-1*ETA_OFFSET_HO;i<=ETA_OFFSET_HO;++i)
00680 {
00681 if (i==0) continue;
00682 int index = i + ETA_OFFSET_HO;
00683 if (index < 0 || index> HOETASIZE) continue;
00684 if (HO_energy[index]==0) continue;
00685 double moment=pow(HO_weightedX[index],2)+pow(HO_weightedY[index],2);
00686 moment=pow(moment,0.5);
00687 moment/=HO_energy[index];
00688
00689 offset = (i>0 ? 0.5: -0.5);
00690 if (moment!=0)
00691 {
00692 if (makeDiagnostics_) HO_CenterOfEnergyRadius[index]->Fill(moment);
00693 COEradiusVSeta->Fill(i+offset,moment);
00694 }
00695 }
00696 }
00697
00699
00700
00701 Etsum_ratio_map->Fill(-1,-1,1);
00702 {
00703 if(hfHits.size()>0)
00704 {
00705 double HF_weightedX[HFETASIZE]={0.};
00706 double HF_weightedY[HFETASIZE]={0.};
00707 double HF_energy[HFETASIZE]={0.};
00708 double offset;
00709
00710
00711 double emptytowersRing1 = ring1totalchannels_;
00712 double emptytowersRing2 = ring2totalchannels_;
00713 double ZStowersRing1 = ring1totalchannels_;
00714 double ZStowersRing2 = ring2totalchannels_;
00715
00716 int ieta, iphi;
00717 float et,eta,phi,r;
00718
00719 HFlumi_occ_LS->Fill(-1,-1,1 );
00720
00721
00722
00723 HFlumi_occ_LS->getTH2F()->SetMaximum(HFlumi_occ_LS->getBinContent(0,0));
00724
00725 double etx=0, ety=0;
00726
00727 for (HFiter=hfHits.begin();
00728 HFiter!=hfHits.end();
00729 ++HFiter)
00730 {
00731
00732 ieta = HFiter->id().ieta();
00733 iphi = HFiter->id().iphi();
00734
00735 int binieta=ieta;
00736 if (ieta<0) binieta+=41;
00737 else if (ieta>0) binieta-=15;
00738
00739
00740
00741 if (abs(ieta)>=33 && abs(ieta)<=36)
00742 {
00743
00744 if (BadCells_.find(HFiter->id())==BadCells_.end())
00745 {
00746 if ((abs(ieta)<35) && HFiter->id().depth()==1) --ZStowersRing1;
00747 else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- ZStowersRing2;
00748 }
00749 }
00750
00751 if (HFiter->energy()<0) continue;
00752
00753 eta=theHFEtaBounds[abs(ieta)-29];
00754 et=HFiter->energy()/cosh(eta)/area[abs(ieta)-29];
00755 if (abs(ieta)>=33 && abs(ieta)<=36)
00756 {
00757
00758 if (et>=occThresh_ && BadCells_.find(HFiter->id())==BadCells_.end() )
00759 {
00760 if ((abs(ieta)<35) && HFiter->id().depth()==1) --emptytowersRing1;
00761 else if ((abs(ieta)>34) && HFiter->id().depth()==2) -- emptytowersRing2;
00762 }
00763 }
00764 r=radius[abs(ieta)-29];
00765 if(HFiter->id().iphi()<37)
00766 phi=HFiter->id().iphi()*0.087266;
00767 else phi=(HFiter->id().iphi()-72)*0.087266;
00768
00769
00770 if (HFiter->id().depth()==1)
00771 {
00772 Etsum_eta_L->Fill(binieta,et);
00773 Etsum_phi_L->Fill(iphi,et);
00774 Etsum_map_L->Fill(binieta,iphi,et);
00775 Etsum_rphi_L->Fill(r,phi,et);
00776
00777 if(ieta>0) {
00778 hitsp[ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
00779 hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
00780 }
00781 else if(ieta<0) {
00782 hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();
00783 hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][0]=et;
00784 }
00785 }
00786
00787
00788 if (HFiter->id().depth()==2)
00789 {
00790 Etsum_eta_S->Fill(binieta,et);
00791 Etsum_phi_S->Fill(iphi,et);
00792 Etsum_rphi_S->Fill(r,phi,et);
00793 Etsum_map_S->Fill(binieta,iphi,et);
00794 if(ieta>0)
00795 {
00796 hitsp[ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
00797 hitsp_Et[ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
00798 }
00799 else if(ieta<0) {
00800 hitsm[-ieta-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
00801 hitsm_Et[-ieta-29][(HFiter->id().iphi()-1)/2][1]=et;
00802 }
00803
00804 }
00805 Energy_Occ->Fill(HFiter->energy());
00806
00807
00808
00809 if ((abs(ieta) == 33 || abs(ieta) == 34) && HFiter->id().depth() == 1)
00810 {
00811 etx+=et*cos(PI*iphi/36.);
00812 ety+=et*sin(PI*iphi/36.);
00813
00814 HFlumi_Et_per_channel_vs_lumiblock->Fill(currentLS,et);
00815 if (et>occThresh_)
00816 {
00817 int etabin=0;
00818 if (ieta<0)
00819 etabin=36+ieta;
00820 else
00821 etabin=ieta-29;
00822 HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
00823 }
00824 }
00825
00826 else if ((abs(ieta) == 35 || abs(ieta) == 36) && HFiter->id().depth() == 2)
00827 {
00828 etx+=et*cos(PI*iphi/36.);
00829 ety+=et*sin(PI*iphi/36.);
00830
00831 HFlumi_Et_per_channel_vs_lumiblock->Fill(currentLS,et);
00832 if (et>occThresh_)
00833 {
00834 int etabin=0;
00835 if (ieta<0)
00836 etabin=36+ieta;
00837 else
00838 etabin=ieta-29;
00839 HFlumi_occ_LS->Fill(etabin,HFiter->id().iphi());
00840 }
00841 }
00842
00843
00844
00845 int value=0;
00846 if(et>occThresh_) value=1;
00847
00848 if (HFiter->id().depth()==1)
00849 {
00850 Occ_eta_L->Fill(binieta,value);
00851 Occ_phi_L->Fill(iphi,value);
00852 Occ_map_L->Fill(binieta,iphi,value);
00853 Occ_rphi_L->Fill(r,phi,value);
00854 }
00855
00856 else if (HFiter->id().depth()==2)
00857 {
00858 Occ_eta_S->Fill(binieta,value);
00859 Occ_phi_S->Fill(iphi,value);
00860 Occ_map_S->Fill(binieta,iphi,value);
00861 Occ_rphi_S->Fill(r,phi,value);
00862 }
00863 HcalDetId id(HFiter->detid().rawId());
00864
00865 HFtotalX+=HFiter->energy()*cos(PI*iphi/36.);
00866 HFtotalY+=HFiter->energy()*sin(PI*iphi/36.);
00867 HFtotalE+=HFiter->energy();
00868
00869 int index=ieta+ETA_OFFSET_HF;
00870 if (index<0 || index>HFETASIZE) continue;
00871 HF_weightedX[index]+=HFiter->energy()*cos(PI*iphi/36.);
00872 HF_weightedY[index]+=HFiter->energy()*sin(PI*iphi/36.);
00873 HF_energy[index]+=HFiter->energy();
00874
00875 }
00876
00877
00878
00879
00880
00881
00882
00883 double logvalue=-1;
00884 if (ring1totalchannels_>0)
00885 {
00886 if (emptytowersRing1>0)
00887 logvalue=-1.*log(emptytowersRing1/ring1totalchannels_);
00888 HFlumi_Occupancy_per_channel_vs_lumiblock_RING1->Fill(currentLS,logvalue);
00889 HFlumi_Occupancy_per_channel_vs_BX_RING1->Fill(bunchCrossing,logvalue);
00890 }
00891
00892 logvalue=-1;
00893 if (ring2totalchannels_>0)
00894 {
00895 if (emptytowersRing2>0)
00896 logvalue=-1.*log(emptytowersRing2/ring2totalchannels_);
00897 HFlumi_Occupancy_per_channel_vs_lumiblock_RING2->Fill(currentLS,logvalue);
00898 HFlumi_Occupancy_per_channel_vs_BX_RING2->Fill(bunchCrossing,logvalue);
00899 }
00900
00901 HFlumi_ETsum_vs_BX->Fill(bunchCrossing,pow(etx*etx+ety*ety,0.5));
00902 int hfeta=ETA_OFFSET_HF;
00903 for (int i=-1*hfeta;i<=hfeta;++i)
00904 {
00905 if (i==0) continue;
00906 if (i>-1*ETA_BOUND_HF && i <ETA_BOUND_HF) continue;
00907 int index = i + ETA_OFFSET_HF;
00908 if (index<0 || index>HFETASIZE) continue;
00909 if (HF_energy[index]==0) continue;
00910 double moment=pow(HF_weightedX[index],2)+pow(HF_weightedY[index],2);
00911 moment=pow(moment,0.5);
00912 moment/=HF_energy[index];
00913 offset = (i>0 ? 0.5: -0.5);
00914 if (moment!=0)
00915 {
00916 if (makeDiagnostics_) HF_CenterOfEnergyRadius[index]->Fill(moment);
00917 COEradiusVSeta->Fill(i+offset,moment);
00918 }
00919 }
00920 float ratiom,ratiop;
00921
00922 for(int i=0;i<13;i++){
00923 for(int j=0;j<36;j++){
00924
00925 if(hitsp[i][j][0]==hitsp[i][j][1]) continue;
00926
00927 if (hitsp[i][j][0] < 1.2 && hitsp[i][j][1] < 1.8) continue;
00928
00929 if (((i+29) < 33) || ((i+29) > 36)) continue;
00930 ratiop=fabs((fabs(hitsp[i][j][0])-fabs(hitsp[i][j][1]))/(fabs(hitsp[i][j][0])+fabs(hitsp[i][j][1])));
00931
00932 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)){
00933 Etsum_ratio_p->Fill(ratiop);
00934 if(abs(ratiop>0.95)) Etsum_ratio_map->Fill(i,2*j+1);
00935 }
00936 }
00937 }
00938
00939 for(int p=0;p<13;p++){
00940 for(int q=0;q<36;q++){
00941
00942 if(hitsm[p][q][0]==hitsm[p][q][1]) continue;
00943
00944 if (hitsm[p][q][0] < 1.2 && hitsm[p][q][1] < 1.8) continue;
00945
00946 if (((p+29) < 33) || ((p+29) > 36)) continue;
00947 ratiom=fabs((fabs(hitsm[p][q][0])-fabs(hitsm[p][q][1]))/(fabs(hitsm[p][q][0])+fabs(hitsm[p][q][1])));
00948 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)){
00949 Etsum_ratio_m->Fill(ratiom);
00950 if(abs(ratiom>0.95)) Etsum_ratio_map->Fill(7-p,2*q+1);
00951
00952 }
00953 }
00954 }
00955 }
00956
00957 totalX=HBtotalX+HEtotalX+HOtotalX+HFtotalX;
00958 totalY=HBtotalY+HEtotalY+HOtotalY+HFtotalY;
00959 totalE=HBtotalE+HEtotalE+HOtotalE+HFtotalE;
00960
00961 double moment;
00962 if (HBtotalE>0)
00963 {
00964 moment=pow(HBtotalX*HBtotalX+HBtotalY*HBtotalY,0.5)/HBtotalE;
00965 HBCenterOfEnergyRadius->Fill(moment);
00966 HBCenterOfEnergy->Fill(HBtotalX/HBtotalE, HBtotalY/HBtotalE);
00967 }
00968 if (HEtotalE>0)
00969 {
00970 moment=pow(HEtotalX*HEtotalX+HEtotalY*HEtotalY,0.5)/HEtotalE;
00971 HECenterOfEnergyRadius->Fill(moment);
00972 HECenterOfEnergy->Fill(HEtotalX/HEtotalE, HEtotalY/HEtotalE);
00973 }
00974 if (HOtotalE>0)
00975 {
00976 moment=pow(HOtotalX*HOtotalX+HOtotalY*HOtotalY,0.5)/HOtotalE;
00977 HOCenterOfEnergyRadius->Fill(moment);
00978 HOCenterOfEnergy->Fill(HOtotalX/HOtotalE, HOtotalY/HOtotalE);
00979 }
00980 if (HFtotalE>0)
00981 {
00982 moment=pow(HFtotalX*HFtotalX+HFtotalY*HFtotalY,0.5)/HFtotalE;
00983 HFCenterOfEnergyRadius->Fill(moment);
00984 HFCenterOfEnergy->Fill(HFtotalX/HFtotalE, HFtotalY/HFtotalE);
00985 }
00986 if (totalE>0)
00987 {
00988 moment = pow(totalX*totalX+totalY*totalY,0.5)/totalE;
00989 CenterOfEnergyRadius->Fill(moment);
00990 CenterOfEnergy->Fill(totalX/totalE, totalY/totalE);
00991 }
00992
00993
00994
00995 for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
00996 const HFDataFrame digi = (const HFDataFrame)(*j);
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016 int theTStobeused = 6;
01017
01018 int mask=1;
01019 if(mask!=1) continue;
01020
01021 for (int i=0; i<digi.size(); i++) {
01022 if (i==theTStobeused) {
01023 float tmpET =0;
01024 int jadc=digi.sample(i).adc();
01025
01026
01027
01028 tmpET = jadc;
01029
01030
01031
01032 if(digi.id().ieta()>28){
01033 if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
01034 HFlumi_ETsum_perwedge->Fill(1,tmpET);
01035 if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
01036 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(1,1);
01037 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(1,1);
01038 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(1,1);
01039 }
01040 else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
01041 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(1,1);
01042 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(1,1);
01043 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(1,1);
01044 }
01045 }
01046 else {
01047 for (int iwedge=2; iwedge<19; iwedge++) {
01048 int itmp=4*(iwedge-1);
01049 if( (digi.id().iphi()==(itmp+1)) || (digi.id().iphi()==(itmp-1))) {
01050 HFlumi_ETsum_perwedge->Fill(iwedge,tmpET);
01051 if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
01052 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iwedge,1);
01053 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iwedge,1);
01054 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iwedge,1);
01055 }
01056 else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
01057 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iwedge,1);
01058 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iwedge,1);
01059 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iwedge,1);
01060 }
01061 iwedge=99;
01062 }
01063 }
01064 }
01065 }
01066 else if(digi.id().ieta()<-28){
01067 if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
01068 HFlumi_ETsum_perwedge->Fill(19,tmpET);
01069 if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
01070 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(19,1);
01071 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(19,1);
01072 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(19,1);
01073 }
01074 else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
01075 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(19,1);
01076 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(19,1);
01077 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(19,1);
01078 }
01079 }
01080 else {
01081 for (int iw=2; iw<19; iw++) {
01082 int itemp=4*(iw-1);
01083 if( (digi.id().iphi()==(itemp+1)) || (digi.id().iphi()==(itemp-1))) {
01084 HFlumi_ETsum_perwedge->Fill(iw+18,tmpET);
01085 if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
01086 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iw+18,1);
01087 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iw+18,1);
01088 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iw+18,1);
01089 }
01090 else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
01091 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iw+18,1);
01092 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iw+18,1);
01093 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iw+18,1);
01094 }
01095 iw=99;
01096 }
01097 }
01098 }
01099 }
01100 }
01101 }
01102 }
01103 return;
01104 }
01105 }
01106
01107
01108
01109 void HcalBeamMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
01110 const edm::EventSetup& c)
01111
01112 {
01113
01114
01115 if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
01116 HcalBaseDQMonitor::beginLuminosityBlock(lumiSeg,c);
01117
01118 if (lumiSeg.luminosityBlock()==lastProcessedLS_) return;
01119 ProblemsCurrentLB->Reset();
01120 HFlumi_occ_LS->Reset();
01121 std::stringstream title;
01122 title <<"HFlumi occupancy for LS # " <<currentLS;
01123 HFlumi_occ_LS->getTH2F()->SetTitle(title.str().c_str());
01124 return;
01125 }
01126
01127 void HcalBeamMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
01128 const edm::EventSetup& c)
01129 {
01130 if (debug_>1) std::cout <<"<HcalBeamMonitor::endLuminosityBlock>"<<std::endl;
01131 if (LumiInOrder(lumiSeg.luminosityBlock())==false)
01132 {
01133 if (debug_>1)
01134 std::cout <<"<HcalBeamMonitor::endLuminosityBlock> Failed LumiInOrder test!"<<std::endl;
01135 return;
01136 }
01137 lastProcessedLS_=lumiSeg.luminosityBlock();
01138 float Nentries=HFlumi_occ_LS->getBinContent(-1,-1);
01139 if (debug_>3)
01140 std::cout <<"Number of entries in this LB = "<<Nentries<<std::endl;
01141
01142 if (Nentries<minEvents_)
01143 {
01144
01145 HFlumi_Ring1Status_vs_LS->Fill(currentLS,-1);
01146 HFlumi_Ring2Status_vs_LS->Fill(currentLS,-1);
01147 if (Online_==false)
01148 return;
01149
01150 if (lumiqualitydir_.size()==0)
01151 return;
01152
01153 std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
01154 outStream<<currentLS<<"\t\t-1\t\t\t-1\t\t\t-1\t\t"<<Nentries<<std::endl;
01155 outStream.close();
01156 return;
01157 }
01158 if (Nentries==0) return;
01159
01160
01161 HFlumi_total_deadcells->Fill(-1,-1,1);
01162 HFlumi_total_hotcells->Fill(-1,-1,1);
01163 HFlumi_diag_deadcells->Fill(-1,-1,1);
01164 HFlumi_diag_hotcells->Fill(-1,-1,1);
01165
01166
01167 int ietamap[8]={-36,-35,-34,-33,33,34,35,36};
01168 int ieta=-1, iphi = -1, depth=-1;
01169 int badring1=0;
01170 int badring2=0;
01171 int ndeadcells=0;
01172 int nhotcells=0;
01173
01174
01175 for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
01176 {
01177 for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
01178 {
01179
01180
01181 if (x<=8)
01182 ieta=ietamap[x-1];
01183 else
01184 ieta=-1;
01185 iphi=2*y-1;
01186 if (abs(ieta)==33 || abs(ieta)==34) depth=1;
01187 else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
01188 else depth = -1;
01189 if (depth !=-1 && ieta!=1)
01190 {
01191 HcalDetId thisID(HcalForward, ieta, iphi, depth);
01192 if (BadCells_.find(thisID)!=BadCells_.end())
01193 continue;
01194 }
01195 double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
01196 if (Ncellhits==0)
01197 {
01198 ++ndeadcells;
01199 HFlumi_diag_deadcells->Fill(x-1,2*y-1,1);
01200 }
01201
01202 if (Ncellhits>hotrate_*Nentries)
01203 {
01204 ++nhotcells;
01205 HFlumi_diag_hotcells->Fill(x-1,2*y-1,1);
01206 }
01207 if (Ncellhits==0 || Ncellhits>hotrate_*Nentries)
01208 {
01209 if (depth==1) badring1++;
01210 else if (depth==2) badring2++;
01211 }
01212 }
01213 }
01214
01215
01216 ProblemsCurrentLB->Fill(-1,-1,levt_);
01217 if (ndeadcells+nhotcells>=minBadCells_)
01218 {
01219
01220 ProblemsCurrentLB->Fill(6,0,(ndeadcells+nhotcells)*levt_);
01221 for (int x=1;x<=HFlumi_occ_LS->getTH2F()->GetNbinsX();++x)
01222 {
01223 for (int y=1;y<=HFlumi_occ_LS->getTH2F()->GetNbinsY();++y)
01224 {
01225 if (x<=8)
01226 ieta=ietamap[x-1];
01227 else
01228 ieta=-1;
01229 iphi=2*y-1;
01230 if (abs(ieta)==33 || abs(ieta)==34) depth=1;
01231 else if (abs(ieta)==35 || abs(ieta)==36) depth =2;
01232 else depth = -1;
01233 if (depth !=-1 && ieta!=1)
01234 {
01235
01236 HcalDetId thisID(HcalForward, ieta, iphi, depth);
01237 if (BadCells_.find(thisID)!=BadCells_.end())
01238 continue;
01239 }
01240 double Ncellhits=HFlumi_occ_LS->getBinContent(x,y);
01241 if (Ncellhits==0)
01242 {
01243
01244 HFlumi_total_deadcells->Fill(x-1,2*y-1,1);
01245 }
01246
01247
01248 if (Ncellhits>hotrate_*Nentries)
01249 {
01250 HFlumi_total_hotcells->Fill(x-1,2*y-1,1);
01251 }
01252 }
01253 }
01254 }
01255
01256
01257 double ring1status=0;
01258 double ring2status=0;
01259 if (ring1totalchannels_==0)
01260 ring1status=0;
01261 else
01262 ring1status=1-1.*badring1/ring1totalchannels_;
01263 HFlumi_Ring1Status_vs_LS->Fill(currentLS,ring1status);
01264 if (ring2totalchannels_==0)
01265 ring2status=0;
01266 else
01267 ring2status=1-1.*badring2/ring2totalchannels_;
01268 HFlumi_Ring2Status_vs_LS->Fill(currentLS,ring2status);
01269
01270
01271 int totalstatus=0;
01272 if (ring1status>0.9 && ring2status>0.9)
01273 totalstatus=1;
01274 else
01275 {
01276 if (ring1status<=0.9)
01277 totalstatus-=2;
01278 if (ring2status<=0.9)
01279 totalstatus-=4;
01280 }
01281
01282 if (lumiqualitydir_.size()==0)
01283 return;
01284
01285 std::ofstream outStream(outfile_.str().c_str(),std::ios::app);
01286 outStream.precision(6);
01287 outStream<<currentLS<<"\t\t"<<ring1status<<"\t\t"<<ring2status<<"\t\t"<<totalstatus<<"\t\t"<<Nentries<<std::endl;
01288 outStream.close();
01289 return;
01290 }
01291
01292 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};
01293 const float HcalBeamMonitor::radius[]={1300,1162,975,818,686,576,483,406,340,286,240,201,169};
01294
01295 void HcalBeamMonitor::SetEtaLabels(MonitorElement * h)
01296 {
01297 h->getTH2F()->GetXaxis()->SetBinLabel(1,"-36S");
01298 h->getTH2F()->GetXaxis()->SetBinLabel(2,"-35S");
01299 h->getTH2F()->GetXaxis()->SetBinLabel(3,"-34L");
01300 h->getTH2F()->GetXaxis()->SetBinLabel(4,"-33L");
01301 h->getTH2F()->GetXaxis()->SetBinLabel(5,"33L");
01302 h->getTH2F()->GetXaxis()->SetBinLabel(6,"34L");
01303 h->getTH2F()->GetXaxis()->SetBinLabel(7,"35S");
01304 h->getTH2F()->GetXaxis()->SetBinLabel(8,"36S");
01305 return;
01306 }
01307
01308 DEFINE_FWK_MODULE(HcalBeamMonitor);
01309