CMS 3D CMS Logo

HcalBeamMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalBeamMonitor.h"
00002 // define sizes of ieta arrays for each subdetector
00003 
00004 #define PI        3.1415926535897932
00005 #define HBETASIZE 34  // one more bin than needed, I think
00006 #define HEETASIZE 60  // ""
00007 #define HOETASIZE 32  // ""
00008 #define HFETASIZE 84  // ""
00009 
00010 using namespace std;
00011 /*  Task calculates various moments of Hcal recHits 
00012 
00013     v1.0
00014     16 August 2008
00015     by Jeff Temple
00016 
00017 */
00018 
00019 
00020 // constructor
00021 HcalBeamMonitor::HcalBeamMonitor():
00022   ETA_OFFSET_HB(16),
00023   ETA_OFFSET_HE(29),
00024   ETA_BOUND_HE(17),
00025   ETA_OFFSET_HO(15),
00026   ETA_OFFSET_HF(41),
00027   ETA_BOUND_HF(29)
00028 {occThresh_ = 1;}
00029 
00030 HcalBeamMonitor::~HcalBeamMonitor() {}
00031 
00032 void HcalBeamMonitor::reset() {}
00033 
00034 void HcalBeamMonitor::clearME()
00035 {
00036   if (m_dbe) 
00037     {
00038       m_dbe->setCurrentFolder(baseFolder_);
00039       m_dbe->removeContents();
00040     } // if (m_dbe)
00041   meEVT_=0;
00042 } // void HcalBeamMonitor::clearME()
00043 
00044 
00045 void HcalBeamMonitor::setup(const edm::ParameterSet& ps, DQMStore* dbe)
00046 {
00047   HcalBaseMonitor::setup(ps,dbe);  // perform setups of base class
00048 
00049   ievt_=0; // event counter
00050   baseFolder_ = rootFolder_ + "BeamMonitor_Hcal";
00051   if (fVerbosity) cout <<"<HcalBeamMonitor::setup> Setup in progress"<<endl;
00052 
00053   beammon_makeDiagnostics_ = ps.getUntrackedParameter<bool>("BeamMonitor_makeDiagnosticPlots",makeDiagnostics);
00054   // These two variables aren't yet in use
00055   beammon_checkNevents_    = ps.getUntrackedParameter<int>("BeamMonitor_checkNevents",checkNevents_);
00056   beammon_minErrorFlag_    = ps.getUntrackedParameter<double>("BeamMonitor_minErrorFlag",0.);
00057 
00058   if (m_dbe)
00059     {
00060       m_dbe->setCurrentFolder(baseFolder_);
00061       char* type;
00062       type = "BeamMonitor Event Number";
00063       meEVT_ = m_dbe->bookInt(type);
00064     
00065       // Basic Problem Cells
00066       ProblemBeamCells=m_dbe->book2D(" ProblemBeamCells",
00067                                      " Problem Beam Cell Rate for all HCAL",
00068                                      etaBins_,etaMin_,etaMax_,
00069                                      phiBins_,phiMin_,phiMax_);
00070       ProblemBeamCells->setAxisTitle("i#eta",1);
00071       ProblemBeamCells->setAxisTitle("i#phi",2);
00072       // Only show problem cells that are above problem threshold
00073       //(ProblemBeamCells->getTH2F())->SetMinimum(beammon_minErrorFlag_);
00074       (ProblemBeamCells->getTH2F())->SetMinimum(0);
00075       (ProblemBeamCells->getTH2F())->SetMaximum(1.);
00076       
00077       // Overall Problem plot appears in main directory; plots by depth appear \in subdirectory
00078       m_dbe->setCurrentFolder(baseFolder_+"/problem_beammonitor");
00079       setupDepthHists2D(ProblemBeamCellsByDepth, " Problem BeamMonitor Rate","");
00080 
00081       //jason's
00082       m_dbe->setCurrentFolder(baseFolder_);
00083       CenterOfEnergyRadius = m_dbe->book1D("CenterOfEnergyRadius",
00084                                    "Center Of Energy radius",
00085                                    200,0,1);
00086       
00087       CenterOfEnergyRadius->setAxisTitle("(normalized) radius",1);
00088 
00089       CenterOfEnergy = m_dbe->book2D("CenterOfEnergy",
00090                                      "Center of Energy",
00091                                      200,-1,1,
00092                                      200,-1,1);
00093       CenterOfEnergy->setAxisTitle("normalized x coordinate",1);
00094       CenterOfEnergy->setAxisTitle("normalized y coordinate",2);
00095 
00096       COEradiusVSeta = m_dbe->bookProfile("COEradiusVSeta",
00097                                           "Center of Energy radius vs i#eta",
00098                                           172,-43,43,
00099                                           200,0,1);
00100       COEradiusVSeta->setAxisTitle("i#eta",1);
00101       COEradiusVSeta->setAxisTitle("(normalized) radius",2);
00102       
00103       std::stringstream histname;
00104       std::stringstream histtitle;
00105       m_dbe->setCurrentFolder(baseFolder_+"/HB");
00106       HBCenterOfEnergyRadius = m_dbe->book1D("HBCenterOfEnergyRadius",
00107                                              "HB Center Of Energy radius",
00108                                              200,0,1);
00109       HBCenterOfEnergy = m_dbe->book2D("HBCenterOfEnergy",
00110                                        "HB Center of Energy",
00111                                        200,-1,1,
00112                                        200,-1,1);
00113       if (beammon_makeDiagnostics_)
00114         {
00115           for (int i=-16;i<=16;++i)
00116             {
00117               if (i==0) continue;
00118               histname.str("");
00119               histtitle.str("");
00120               histname<<"HB_CenterOfEnergyRadius_ieta"<<i;
00121               histtitle<<"HB Center Of Energy ieta = "<<i;
00122               HB_CenterOfEnergyRadius[i+ETA_OFFSET_HB]=m_dbe->book1D(histname.str().c_str(),
00123                                                           histtitle.str().c_str(),
00124                                                           200,0,1);
00125             } // end of HB loop
00126         }
00127       m_dbe->setCurrentFolder(baseFolder_+"/HE");
00128       HECenterOfEnergyRadius = m_dbe->book1D("HECenterOfEnergyRadius",
00129                                              "HE Center Of Energy radius",
00130                                              200,0,1);
00131       HECenterOfEnergy = m_dbe->book2D("HECenterOfEnergy",
00132                                        "HE Center of Energy",
00133                                        200,-1,1,
00134                                        200,-1,1);
00135       if (beammon_makeDiagnostics_)
00136         {
00137           for (int i=-29;i<=29;++i)
00138             {
00139               if (abs(i)<ETA_BOUND_HE) continue;
00140               histname.str("");
00141               histtitle.str("");
00142               histname<<"HE_CenterOfEnergyRadius_ieta"<<i;
00143               histtitle<<"HE Center Of Energy ieta = "<<i;
00144               HE_CenterOfEnergyRadius[i+ETA_OFFSET_HE]=m_dbe->book1D(histname.str().c_str(),
00145                                                           histtitle.str().c_str(),
00146                                                           200,0,1);
00147             } // end of HE loop
00148         }
00149       m_dbe->setCurrentFolder(baseFolder_+"/HO");
00150       HOCenterOfEnergyRadius = m_dbe->book1D("HOCenterOfEnergyRadius",
00151                                              "HO Center Of Energy radius",
00152                                              200,0,1);
00153       HOCenterOfEnergy = m_dbe->book2D("HOCenterOfEnergy",
00154                                        "HO Center of Energy",
00155                                        200,-1,1,
00156                                        200,-1,1);
00157       if (beammon_makeDiagnostics_)
00158         {
00159           for (int i=-15;i<=15;++i)
00160             {
00161               if (i==0) continue;
00162               histname.str("");
00163               histtitle.str("");
00164               histname<<"HO_CenterOfEnergyRadius_ieta"<<i;
00165               histtitle<<"HO Center Of Energy radius ieta = "<<i;
00166               HO_CenterOfEnergyRadius[i+ETA_OFFSET_HO]=m_dbe->book1D(histname.str().c_str(),
00167                                                                      histtitle.str().c_str(),
00168                                                                      200,0,1);
00169             } // end of HO loop
00170         }
00171       m_dbe->setCurrentFolder(baseFolder_+"/HF");
00172       HFCenterOfEnergyRadius = m_dbe->book1D("HFCenterOfEnergyRadius",
00173                                              "HF Center Of Energy radius",
00174                                              200,0,1);
00175       HFCenterOfEnergy = m_dbe->book2D("HFCenterOfEnergy",
00176                                        "HF Center of Energy",
00177                                        200,-1,1,
00178                                        200,-1,1);
00179       if (beammon_makeDiagnostics_)
00180         {
00181           for (int i=-41;i<=41;++i)
00182             {
00183               if (abs(i)<ETA_BOUND_HF) continue;
00184               histname.str("");
00185               histtitle.str("");
00186               histname<<"HF_CenterOfEnergyRadius_ieta"<<i;
00187               histtitle<<"HF Center Of Energy radius ieta = "<<i;
00188               HF_CenterOfEnergyRadius[i+ETA_OFFSET_HF]=m_dbe->book1D(histname.str().c_str(),
00189                                                                      histtitle.str().c_str(),
00190                                                                      200,0,1);
00191             } // end of HF loop
00192         }
00193       
00194       m_dbe->setCurrentFolder(baseFolder_+"/Lumi");
00195       // Wenhan's 
00196       Etsum_eta_L=m_dbe->bookProfile("Et Sum vs Eta Long Fiber","Et Sum per Area vs Eta Long Fiber",120,-6,6,200,0,2000);
00197       Etsum_eta_S=m_dbe->bookProfile("Et Sum vs Eta Short Fiber","Et Sum per Area vs Eta Short Fiber",120,-4,4,200,0,2000);
00198       Etsum_phi_L=m_dbe->bookProfile("Et Sum vs Phi Long Fiber","Et Sum per Area vs Phi Long Fiber",100,-4,4,200,0,2000);
00199       Etsum_phi_S=m_dbe->bookProfile("Et Sum vs Phi Short Fiber","Et Sum per Area crossing vs Phi Short Fiber",100,-4,4,200,0,2000);
00200       Etsum_ratio_p=m_dbe->book1D("Occ vs fm HF+","Energy difference of Long and Short Fiber HF+",105,-1.05,1.05);
00201       Energy_Occ=m_dbe->book1D("Occ vs Energy","Occupancy vs Energy",200,0,2000);
00202       Etsum_ratio_m=m_dbe->book1D("Occ vs fm HF-","Energy difference of Long and Short Fiber HF-",105,-1.05,1.05);
00203       Etsum_map_L=m_dbe->book2D("EtSum 2D phi and eta Long Fiber","Et Sum 2D phi and eta Long Fiber",120,-6,6,100,-4,4);
00204       Etsum_map_S=m_dbe->book2D("EtSum 2D phi and eta Short Fiber","Et Sum 2D phi and eta Short Fiber",120,-6,6,100,-4,4);
00205       Etsum_rphi_S=m_dbe->book2D("EtSum 2D phi and radius Short Fiber","Et Sum 2D phi and radius Short Fiber",100,0,1500,100,-4,4);
00206       Etsum_rphi_L=m_dbe->book2D("EtSum 2D phi and radius Long Fiber","Et Sum 2D phi and radius Long Fiber",100,0,1500,100,-4,4);
00207       Etsum_ratio_map=m_dbe->book2D("Abnormal fm","Abnormal fm",84,-42,42,72,0,72);
00208       
00209       Occ_rphi_S=m_dbe->book2D("Occ 2D phi and radius Short Fiber","Occupancy 2D phi and radius Short Fiber",100,0,1500,100,-4,4);
00210       Occ_rphi_L=m_dbe->book2D("Occ 2D phi and radius Long Fiber","Occupancy 2D phi and radius Long Fiber",100,0,1500,100,-4,4);
00211       Occ_eta_S=m_dbe->bookProfile("Occ vs Eta Short Fiber","Occ per Bunch crossing vs Eta Short Fiber",120,-6,6,200,0,2000);
00212       Occ_eta_L=m_dbe->bookProfile("Occ vs Eta Long Fiber","Occ per Bunch crossing vs Eta Long Fiber",120,-6,6,200,0,2000);
00213       
00214       Occ_phi_L=m_dbe->bookProfile("Occ vs Phi Long Fiber","Occ per Bunch crossing vs Phi Long Fiber",100,-4,4,200,0,2000);
00215       
00216       Occ_phi_S=m_dbe->bookProfile("Occ vs Phi Short Fiber","Occ per Bunch crossing vs Phi Short Fiber",100,-4,4,200,0,2000);
00217       
00218       Occ_map_L=m_dbe->book2D("Occ_map Long Fiber","Occ Map long Fiber",120,-6,6,100,-4,4);
00219       Occ_map_S=m_dbe->book2D("Occ_map Short Fiber","Occ Map Short Fiber",120,-6,6,100,-4,4);
00220       
00221       //HFlumi plots
00222       HFlumi_ETsum_perwedge =  m_dbe->book1D("HF lumi ET-sum per wedge","HF lumi ET-sum per wedge",36,1,37);
00223       
00224       HFlumi_Occupancy_above_thr_r1 =  m_dbe->book1D("HF lumi Occupancy above threshold ring1","HF lumi Occupancy above threshold ring1",36,1,37);
00225       HFlumi_Occupancy_between_thrs_r1 = m_dbe->book1D("HF lumi Occupancy between thresholds ring1","HF lumi Occupancy between thresholds ring1",36,1,37);
00226       HFlumi_Occupancy_below_thr_r1 = m_dbe->book1D("HF lumi Occupancy below threshold ring1","HF lumi Occupancy below threshold ring1",36,1,37);
00227       HFlumi_Occupancy_above_thr_r2 = m_dbe->book1D("HF lumi Occupancy above threshold ring2","HF lumi Occupancy above threshold ring2",36,1,37);
00228       HFlumi_Occupancy_between_thrs_r2 = m_dbe->book1D("HF lumi Occupancy between thresholds ring2","HF lumi Occupancy between thresholds ring2",36,1,37);
00229       HFlumi_Occupancy_below_thr_r2 = m_dbe->book1D("HF lumi Occupancy below threshold ring2","HF lumi Occupancy below threshold ring2",36,1,37);
00230       
00231       
00232     } // if (m_dbe)
00233   return;
00234 
00235 } // void HcalBeamMonitor::setup()
00236 
00237 void HcalBeamMonitor::processEvent(const HBHERecHitCollection& hbheHits,
00238                                    const HORecHitCollection& hoHits,
00239                                    const HFRecHitCollection& hfHits,
00240                                    const HFDigiCollection& hf
00241                                      // const ZDCRecHitCollection & zdcHits // include this once we see ZDC rec hits read out
00242                                    )
00243   
00244 {
00245   if (!m_dbe)
00246     {
00247       if (fVerbosity) cout <<"HcalBeamMonitor::processEvent   DQMStore not instantiated!!!"<<endl;
00248       return;
00249     }
00250 
00251   if (showTiming)
00252     {
00253       cpu_timer.reset(); cpu_timer.start();
00254     }
00255   
00256   ievt_++;
00257   meEVT_->Fill(ievt_);
00258 
00259   HBHERecHitCollection::const_iterator HBHEiter;
00260   HORecHitCollection::const_iterator HOiter;
00261   HFRecHitCollection::const_iterator HFiter;
00262 
00263   double totalX=0;
00264   double totalY=0;
00265   double totalE=0;
00266 
00267   double HBtotalX=0;
00268   double HBtotalY=0;
00269   double HBtotalE=0;
00270   double HEtotalX=0;
00271   double HEtotalY=0;
00272   double HEtotalE=0;
00273   double HOtotalX=0;
00274   double HOtotalY=0;
00275   double HOtotalE=0;
00276   double HFtotalX=0;
00277   double HFtotalY=0;
00278   double HFtotalE=0;
00279    float etaBounds[13] = { 2.853, 2.964, 3.139, 3.314, 3.489, 3.664, 3.839, 4.013, 4.191, 4.363, 4.538, 4.716, 4.889};
00280   float area[13]={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};
00281   float radius[13]={1300,1162,975,818,686,576,483,406,340,286,240,201,169};
00282 
00283      
00284   float hitsp[13][36][2];
00285   float hitsm[13][36][2];
00286   
00287   for(int m=0;m<13;m++){
00288     for(int n=0;n<36;n++){
00289       hitsp[m][n][0]=0;
00290       hitsp[m][n][1]=0; 
00291       hitsm[m][n][0]=0;
00292       hitsm[m][n][1]=0;
00293     }
00294   }
00295   if (showTiming)
00296     {
00297       cpu_timer.stop(); std::cout << " TIMER::HcalBeamMonitor BEAMMON analyze pre-process-> " << cpu_timer.cpuTime() << std::endl;
00298       cpu_timer.reset(); cpu_timer.start();
00299     } // if (showTiming)
00300 
00301   try
00302     {
00303       if(hbheHits.size()>0)
00304         {
00305           double HB_weightedX[HBETASIZE]={0.};
00306           double HB_weightedY[HBETASIZE]={0.};
00307           double HB_energy[HBETASIZE]={0.};
00308 
00309           double HE_weightedX[HEETASIZE]={0.};
00310           double HE_weightedY[HEETASIZE]={0.};
00311           double HE_energy[HEETASIZE]={0.};
00312 
00313           int ieta, iphi;
00314 
00315           for (HBHEiter=hbheHits.begin(); 
00316                HBHEiter!=hbheHits.end(); 
00317                ++HBHEiter) 
00318             { 
00319 
00320               // loop over all hits
00321               if (HBHEiter->energy()<0) continue; // don't consider negative-energy cells
00322               HcalDetId id(HBHEiter->detid().rawId());
00323               ieta=id.ieta();
00324               iphi=id.iphi();
00325 
00326               unsigned int index;
00327               if ((HcalSubdetector)(id.subdet())==HcalBarrel)
00328                 {
00329                   HBtotalX+=HBHEiter->energy()*cos(2*PI*iphi/72);
00330                   HBtotalY+=HBHEiter->energy()*sin(2*PI*iphi/72);
00331                   HBtotalE+=HBHEiter->energy();
00332 
00333                   index=ieta+ETA_OFFSET_HB;
00334                   HB_weightedX[index]+=HBHEiter->energy()*cos(2.*PI*iphi/72);
00335                   HB_weightedY[index]+=HBHEiter->energy()*sin(2.*PI*iphi/72);
00336                   HB_energy[index]+=HBHEiter->energy();
00337                 } // if id.subdet()==HcalBarrel
00338 
00339               else
00340                 {
00341                   HEtotalX+=HBHEiter->energy()*cos(2*PI*iphi/72);
00342                   HEtotalY+=HBHEiter->energy()*sin(2*PI*iphi/72);
00343                   HEtotalE+=HBHEiter->energy();
00344 
00345                   index=ieta+ETA_OFFSET_HE;
00346                   HE_weightedX[index]+=HBHEiter->energy()*cos(2.*PI*iphi/72);
00347                   HE_weightedY[index]+=HBHEiter->energy()*sin(2.*PI*iphi/72);
00348                   HE_energy[index]+=HBHEiter->energy();
00349                 }
00350             } // for (HBHEiter=hbheHits.begin()...
00351           // Fill each histogram
00352 
00353           int hbeta=ETA_OFFSET_HB;
00354           for (int i=-1*hbeta;i<=hbeta;++i)
00355             {
00356               if (i==0) continue;
00357               int index = i+ETA_OFFSET_HB;
00358               if (HB_energy[index]==0) continue;
00359               double moment=pow(HB_weightedX[index],2)+pow(HB_weightedY[index],2);
00360               //cout <<"index = "<<i<<"  X = "<<HB_weightedX[index]<<"  Y = "<<HB_weightedY[index]<<" Energy = "<<HB_energy[index]<<endl;
00361               moment=pow(moment,0.5);
00362               moment/=HB_energy[index];
00363               //cout <<"\tMOMENT = "<<moment<<endl;
00364               if (moment!=0)
00365                 {
00366                   if (beammon_makeDiagnostics_) HB_CenterOfEnergyRadius[index]->Fill(moment);
00367                   COEradiusVSeta->Fill(i,moment);
00368                 }
00369             } // for (int i=-1*hbeta;i<=hbeta;++i)
00370 
00371           int heeta=ETA_OFFSET_HE;
00372           for (int i=-1*heeta;i<=heeta;++i)
00373             {
00374               if (i==0) continue;
00375               if (i>-1*ETA_BOUND_HE && i <ETA_BOUND_HE) continue;
00376               int index = i + ETA_OFFSET_HE;
00377               if (HE_energy[index]==0) continue;
00378               double moment=pow(HE_weightedX[index],2)+pow(HE_weightedY[index],2);
00379               moment=pow(moment,0.5);
00380               moment/=HE_energy[index];
00381               if (moment!=0)
00382                 {
00383                   if (beammon_makeDiagnostics_) HE_CenterOfEnergyRadius[index]->Fill(moment);
00384                   COEradiusVSeta->Fill(i,moment);
00385                 }
00386             } // for (int i=-1*heeta;i<=heeta;++i)
00387 
00388         } // if (hbheHits.size()>0)
00389     } // try
00390   catch (...)
00391     {
00392       if (fVerbosity) cout <<"HcalBeamMonitor::processEvent   Error in HBHE RecHit loop"<<endl;
00393     } // catch
00394   
00395   if (showTiming)
00396     {
00397       cpu_timer.stop(); std::cout << " TIMER::HcalBeamMonitor BEAMMON HBHE-> " << cpu_timer.cpuTime() << std::endl;
00398       cpu_timer.reset(); cpu_timer.start();
00399     } // if (showTiming)
00400   
00401    // HO loop
00402   try
00403     {
00404       if(hoHits.size()>0)
00405         {
00406           double HO_weightedX[HOETASIZE]={0.};
00407           double HO_weightedY[HOETASIZE]={0.};
00408           double HO_energy[HOETASIZE]={0.};
00409           double offset;
00410 
00411           int ieta, iphi;
00412           for (HOiter=hoHits.begin(); 
00413                HOiter!=hoHits.end(); 
00414                ++HOiter) 
00415             { 
00416               // loop over all cells
00417               if (HOiter->energy()<0) continue;  // don't include negative-energy cells?
00418               HcalDetId id(HOiter->detid().rawId());
00419               ieta=id.ieta();
00420               iphi=id.iphi();
00421 
00422               HOtotalX+=HOiter->energy()*cos(2.*PI*iphi/72);
00423               HOtotalY+=HOiter->energy()*sin(2.*PI*iphi/72);
00424               HOtotalE+=HOiter->energy();
00425 
00426               unsigned int index;
00427               index=ieta+ETA_OFFSET_HO;
00428               HO_weightedX[index]+=HOiter->energy()*cos(2.*PI*iphi/72);
00429               HO_weightedY[index]+=HOiter->energy()*sin(2.*PI*iphi/72);
00430               HO_energy[index]+=HOiter->energy();
00431             } // for (HOiter=hoHits.begin();...)
00432           
00433           for (int i=-1*ETA_OFFSET_HO;i<=ETA_OFFSET_HO;++i)
00434             {
00435               if (i==0) continue;
00436               int index = i + ETA_OFFSET_HO;
00437               if (HO_energy[index]==0) continue;
00438               double moment=pow(HO_weightedX[index],2)+pow(HO_weightedY[index],2);
00439               moment=pow(moment,0.5);
00440               moment/=HO_energy[index];
00441               // Shift HO values by 0.5 units in eta relative to HB
00442               offset = (i>0 ? 0.5: -0.5);
00443               if (moment!=0)
00444                 {
00445                   if (beammon_makeDiagnostics_) HO_CenterOfEnergyRadius[index]->Fill(moment);
00446                   COEradiusVSeta->Fill(i+offset,moment);
00447                 }
00448             } // for (int i=-1*hoeta;i<=hoeta;++i)
00449         } // if (hoHits.size()>0)
00450     } // try (HO loop)
00451   catch (...)
00452     {
00453       if (fVerbosity) cout <<"HcalBeamMonitor::processEvent   Error in HO RecHit loop"<<endl;
00454     } // catch
00455   
00456   if (showTiming)
00457     {
00458       cpu_timer.stop(); std::cout << " TIMER::HcalBeamMonitor BEAMMON HO-> " << cpu_timer.cpuTime() << std::endl;
00459       cpu_timer.reset(); cpu_timer.start();
00460     } // if (showTiming)
00461 
00463   // HF loop
00464   try
00465     {
00466       if(hfHits.size()>0)
00467         {
00468           double HF_weightedX[HFETASIZE]={0.};
00469           double HF_weightedY[HFETASIZE]={0.};
00470           double HF_energy[HFETASIZE]={0.};
00471           double offset;
00472 
00473           int ieta, iphi;
00474           float et,eta,phi,r;
00475           for (HFiter=hfHits.begin(); 
00476                HFiter!=hfHits.end(); 
00477                ++HFiter) 
00478             { 
00479               if (HFiter->energy()<0) continue;  // don't include negative-energy cells?
00480 
00481            eta=etaBounds[abs(HFiter->id().ieta())-29];
00482            et=HFiter->energy()/cosh(eta)/area[abs(HFiter->id().ieta())-29];
00483            r=radius[abs(HFiter->id().ieta())-29];
00484            if(HFiter->id().iphi()<37)
00485            phi=HFiter->id().iphi()*0.087266;
00486            else phi=(HFiter->id().iphi()-72)*0.087266;
00487            
00488           if (HFiter->id().depth()==1){
00489             
00490             
00491             if(HFiter->id().ieta()>0) {
00492             
00493             Etsum_eta_L->Fill(eta,et);
00494             Etsum_phi_L->Fill(phi,et);
00495             Etsum_map_L->Fill(eta,phi,et);
00496             Etsum_rphi_L->Fill(r,phi,et);
00497             hitsp[HFiter->id().ieta()-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();}
00498             if(HFiter->id().ieta()<0) {
00499             Etsum_eta_L->Fill(-eta,et);
00500             Etsum_phi_L->Fill(phi,et);
00501             Etsum_rphi_L->Fill(r,phi,et);
00502             Etsum_map_L->Fill(-eta,phi,et);
00503             hitsm[-HFiter->id().ieta()-29][(HFiter->id().iphi()-1)/2][0]=HFiter->energy();          
00504             }
00505           }
00506          
00507           //Fill 3 histos for Short Fibers :
00508           if (HFiter->id().depth()==2){
00509             if(HFiter->id().ieta()>0)  {
00510               Etsum_eta_S->Fill(eta,et);
00511               Etsum_phi_S->Fill(phi,et);
00512               Etsum_rphi_S->Fill(r,phi,et); 
00513               Etsum_map_S->Fill(eta,phi,et);
00514               hitsp[HFiter->id().ieta()-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();
00515             }
00516             if(HFiter->id().ieta()<0)  {  Etsum_eta_S->Fill(-eta,et);
00517               Etsum_map_S->Fill(-eta,phi,et);
00518               Etsum_phi_S->Fill(phi,et);
00519               Etsum_rphi_S->Fill(r,phi,et); 
00520               hitsm[-HFiter->id().ieta()-29][(HFiter->id().iphi()-1)/2][1]=HFiter->energy();}
00521           
00522           }
00523           Energy_Occ->Fill(HFiter->energy()); 
00524             
00525           //HF: no non-threshold occupancy map is filled?
00526                    
00527           if(HFiter->energy()>occThresh_){
00528             
00529             if (HFiter->id().depth()==1){
00530               if(HFiter->id().ieta()>0)  
00531                 { Occ_eta_L->Fill(eta,1);
00532                   Occ_phi_L->Fill(phi,1);
00533                   Occ_map_L->Fill(eta,phi,1);
00534                   Occ_rphi_L->Fill(r,phi,1);
00535                 }
00536 
00537               if(HFiter->id().ieta()<0)   { 
00538                   Occ_eta_L->Fill(-eta,1);
00539                   Occ_phi_L->Fill(phi,1);
00540                   Occ_map_L->Fill(-eta,phi,1);
00541                  Occ_rphi_L->Fill(r,phi,1);
00542               }}
00543 
00544             if (HFiter->id().depth()==2){
00545             if(HFiter->id().ieta()>0) { 
00546                   Occ_eta_S->Fill(eta,1);
00547                   Occ_phi_S->Fill(phi,1);
00548                   Occ_map_S->Fill(eta,phi,1);
00549                   Occ_rphi_S->Fill(r,phi,1);
00550             }  
00551             
00552             if(HFiter->id().ieta()<0) { 
00553                   Occ_eta_S->Fill(-eta,1);
00554                   Occ_map_S->Fill(-eta,phi,1);
00555                   Occ_phi_S->Fill(phi,1);
00556                   Occ_rphi_S->Fill(r,phi,1);
00557             }  
00558             }
00559    
00560           }
00561            
00562           else { if (HFiter->id().depth()==1){ 
00563               if(HFiter->id().ieta()>0)  
00564                 { Occ_eta_L->Fill(eta,0);
00565                   Occ_map_L->Fill(eta,phi,0);
00566                   Occ_phi_L->Fill(phi,0); 
00567                   Occ_rphi_L->Fill(r,phi,0);}
00568               if(HFiter->id().ieta()<0)   { 
00569                   Occ_eta_L->Fill(-eta,0);
00570                   Occ_map_L->Fill(-eta,phi,0);
00571                   Occ_phi_L->Fill(phi,0);
00572                   Occ_rphi_L->Fill(r,phi,0);}
00573             }
00574 
00575             if (HFiter->id().depth()==2){
00576             if(HFiter->id().ieta()>0) { 
00577                   Occ_eta_S->Fill(eta,0);
00578                   Occ_map_S->Fill(eta,phi,0);
00579                   Occ_phi_S->Fill(phi,0);
00580                   Occ_rphi_S->Fill(r,phi,0);}  
00581             
00582             if(HFiter->id().ieta()<0) { 
00583                   Occ_eta_S->Fill(-eta,0);
00584                   Occ_map_S->Fill(-eta,phi,0);
00585                   Occ_phi_S->Fill(phi,0);
00586                   Occ_rphi_S->Fill(r,phi,0);}  
00587             }
00588           }//else
00589               HcalDetId id(HFiter->detid().rawId());
00590               ieta=id.ieta();
00591               iphi=id.iphi();
00592 
00593               HFtotalX+=HFiter->energy()*cos(2.*PI*iphi/72);
00594               HFtotalY+=HFiter->energy()*sin(2.*PI*iphi/72);
00595               HFtotalE+=HFiter->energy();
00596 
00597               unsigned int index;
00598               index=ieta+ETA_OFFSET_HF;
00599               HF_weightedX[index]+=HFiter->energy()*cos(2.*PI*iphi/72);
00600               HF_weightedY[index]+=HFiter->energy()*sin(2.*PI*iphi/72);
00601               HF_energy[index]+=HFiter->energy();
00602             } // for (HFiter=hfHits.begin();...)
00603           
00604           int hfeta=ETA_OFFSET_HF;
00605           for (int i=-1*hfeta;i<=hfeta;++i)
00606             {
00607               if (i==0) continue;
00608               if (i>-1*ETA_BOUND_HF && i <ETA_BOUND_HF) continue;
00609               int index = i + ETA_OFFSET_HF;
00610               if (HF_energy[index]==0) continue;
00611               double moment=pow(HF_weightedX[index],2)+pow(HF_weightedY[index],2);
00612               moment=pow(moment,0.5);
00613               moment/=HF_energy[index];
00614               offset = (i>0 ? 0.5: -0.5);
00615               if (moment!=0)
00616                 {
00617                   if (beammon_makeDiagnostics_) HF_CenterOfEnergyRadius[index]->Fill(moment);
00618                   COEradiusVSeta->Fill(i+offset,moment);
00619                 }
00620             } // for (int i=-1*hfeta;i<=hfeta;++i)
00621           float ratiom,ratiop;
00622           
00623           for(int i=0;i<13;i++){
00624             for(int j=0;j<36;j++){
00625               
00626               if(hitsp[i][j][0]==hitsp[i][j][1]) continue;
00627               
00628               ratiop=(hitsp[i][j][0]-hitsp[i][j][1])/(hitsp[i][j][0]+hitsp[i][j][1]);
00629           //cout<<ratiop<<endl;
00630               Etsum_ratio_p->Fill(ratiop);
00631               if(abs(ratiop>0.85))
00632                 Etsum_ratio_map->Fill(i+29,2*j+1); 
00633             }
00634           }
00635           
00636           for(int p=0;p<13;p++){
00637             for(int q=0;q<36;q++){
00638               
00639               if(hitsm[p][q][0]==hitsm[p][q][1]) continue;
00640               ratiom=(hitsm[p][q][0]-hitsm[p][q][1])/(hitsm[p][q][0]+hitsm[p][q][1]);         
00641               Etsum_ratio_m->Fill(ratiom);
00642               if(abs(ratiom>0.85))
00643                 Etsum_ratio_map->Fill(-p-29,2*q+1);
00644             }
00645           } 
00646         } // if (hfHits.size()>0)
00647     } // try (HF loop)
00648   catch (...)
00649     {
00650       if (fVerbosity) cout <<"HcalBeamMonitor::processEvent   Error in HF RecHit loop"<<endl;
00651     } // catch
00652   
00653   if (showTiming)
00654     {
00655       cpu_timer.stop(); std::cout << " TIMER::HcalBeamMonitor BEAMMON HF-> " << cpu_timer.cpuTime() << std::endl;
00656     } // if (showTiming)
00657 
00658   totalX=HBtotalX+HEtotalX+HOtotalX+HFtotalX;
00659   totalY=HBtotalY+HEtotalY+HOtotalY+HFtotalY;
00660   totalE=HBtotalE+HEtotalE+HOtotalE+HFtotalE;
00661 
00662   double moment;
00663   if (HBtotalE>0)
00664     {
00665       moment=pow(HBtotalX*HBtotalX+HBtotalY*HBtotalY,0.5)/HBtotalE;
00666       HBCenterOfEnergyRadius->Fill(moment);
00667       HBCenterOfEnergy->Fill(HBtotalX/HBtotalE, HBtotalY/HBtotalE);
00668     }
00669   if (HEtotalE>0)
00670     {
00671       moment=pow(HEtotalX*HEtotalX+HEtotalY*HEtotalY,0.5)/HEtotalE;
00672       HECenterOfEnergyRadius->Fill(moment);
00673       HECenterOfEnergy->Fill(HEtotalX/HEtotalE, HEtotalY/HEtotalE);
00674     }
00675   if (HOtotalE>0)
00676     {
00677       moment=pow(HOtotalX*HOtotalX+HOtotalY*HOtotalY,0.5)/HOtotalE;
00678       HOCenterOfEnergyRadius->Fill(moment);
00679       HOCenterOfEnergy->Fill(HOtotalX/HOtotalE, HOtotalY/HOtotalE);
00680     }
00681   if (HFtotalE>0)
00682     {
00683       moment=pow(HFtotalX*HFtotalX+HFtotalY*HFtotalY,0.5)/HFtotalE;
00684       HFCenterOfEnergyRadius->Fill(moment);
00685       HFCenterOfEnergy->Fill(HFtotalX/HFtotalE, HFtotalY/HFtotalE);
00686     }
00687   if (totalE>0)
00688     {
00689       moment = pow(totalX*totalX+totalY*totalY,0.5)/totalE;
00690       // cout <<"MOMENT = "<<moment<<endl;
00691       CenterOfEnergyRadius->Fill(moment);
00692       CenterOfEnergy->Fill(totalX/totalE, totalY/totalE);
00693     }
00694 
00695 
00696     
00697     for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
00698       const HFDataFrame digi = (const HFDataFrame)(*j);
00699      //  calibs_= cond.getHcalCalibrations(digi.id());  // Old method was made private. 
00700 //       float en=0;
00701 //       float ts =0; float bs=0;
00702 //       int maxi=0; float maxa=0;
00703 //       for(int i=sigS0_; i<=sigS1_; i++){
00704 //      if(digi.sample(i).adc()>maxa){maxa=digi.sample(i).adc(); maxi=i;}
00705 //       }
00706 //       for(int i=sigS0_; i<=sigS1_; i++){       
00707 //      float tmp1 =0;   
00708 //         int j1=digi.sample(i).adc();
00709 //         tmp1 = (LedMonAdc2fc[j1]+0.5);         
00710 //      en += tmp1-calibs_.pedestal(digi.sample(i).capid());
00711 //      if(i>=(maxi-1) && i<=maxi+1){
00712 //        ts += i*(tmp1-calibs_.pedestal(digi.sample(i).capid()));
00713 //        bs += tmp1-calibs_.pedestal(digi.sample(i).capid());
00714 //      }
00715 //       }
00716 
00717       //---HFlumiplots
00718       int theTStobeused = 6;
00719       // will have masking later:
00720       int mask=1; 
00721       if(mask!=1) continue;
00722       //if we want to sum the 10 TS instead of just taking one:
00723       for (int i=0; i<digi.size(); i++) {
00724         if (i==theTStobeused) {
00725           float tmpET =0;
00726           int jadc=digi.sample(i).adc();
00727           //NOW LUT used in HLX are only identy LUTs, so Et filled
00728           //with unlinearised adc, ie tmpET = jadc
00729           //      tmpET = (adc2fc[jadc]+0.5);
00730           tmpET = jadc;
00731 
00732           //-find which wedge we are in
00733           //  ETsum and Occupancy will be summed for both L and S
00734           if(digi.id().ieta()>28){
00735             if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
00736               HFlumi_ETsum_perwedge->Fill(1,tmpET);
00737               if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
00738                 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(1,1);
00739                 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(1,1);
00740                 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(1,1);
00741               }
00742               else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
00743                 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(1,1);
00744                 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(1,1);
00745                 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(1,1);
00746               }
00747             }
00748             else {
00749               for (int iwedge=2; iwedge<19; iwedge++) {
00750                 int itmp=4*(iwedge-1);
00751                 if( (digi.id().iphi()==(itmp+1)) || (digi.id().iphi()==(itmp-1))) {
00752                   HFlumi_ETsum_perwedge->Fill(iwedge,tmpET);
00753                   if((digi.id().ieta()==33)||(digi.id().ieta()==34)) {
00754                     if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iwedge,1);
00755                     if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iwedge,1);
00756                     if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iwedge,1);
00757                   }
00758                   else if((digi.id().ieta()==35)||(digi.id().ieta()==36)) {
00759                     if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iwedge,1);
00760                     if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iwedge,1);
00761                     if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iwedge,1);
00762                   }
00763                   iwedge=99;
00764                 }
00765               }
00766             }
00767           }  //--endif ieta in HF+
00768           else if(digi.id().ieta()<-28){
00769             if((digi.id().iphi()==1)||(digi.id().iphi()==71)){
00770               HFlumi_ETsum_perwedge->Fill(19,tmpET);
00771               if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
00772                 if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(19,1);
00773                 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(19,1);
00774                 if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(19,1);
00775               }
00776               else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
00777                 if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(19,1);
00778                 if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(19,1);
00779                 if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(19,1);
00780               }
00781             }
00782             else {
00783               for (int iw=2; iw<19; iw++) {
00784                 int itemp=4*(iw-1);
00785                 if( (digi.id().iphi()==(itemp+1)) || (digi.id().iphi()==(itemp-1))) {
00786                   HFlumi_ETsum_perwedge->Fill(iw+18,tmpET);
00787                   if((digi.id().ieta()==-33)||(digi.id().ieta()==-34)) {
00788                     if(jadc>100) HFlumi_Occupancy_above_thr_r1->Fill(iw+18,1);
00789                     if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r1->Fill(iw+18,1);
00790                     if(jadc<10) HFlumi_Occupancy_below_thr_r1->Fill(iw+18,1);
00791                   }
00792                   else if((digi.id().ieta()==-35)||(digi.id().ieta()==-36)) {
00793                     if(jadc>100) HFlumi_Occupancy_above_thr_r2->Fill(iw+18,1);
00794                     if((jadc>=10)&&(jadc<=100)) HFlumi_Occupancy_between_thrs_r2->Fill(iw+18,1);
00795                     if(jadc<10) HFlumi_Occupancy_below_thr_r2->Fill(iw+18,1);
00796                   }
00797                   iw=99;
00798                 }
00799               }
00800             }
00801           }//---endif ieta inHF-
00802         }//---endif TS=nr6
00803       } 
00804     }//------end loop over TS for lumi
00805   return;
00806 }
00807 
00808  // void HcalBeamMonitor::processEvent(const HBHERecHit Collection&hbheHits; ...)
00809 

Generated on Tue Jun 9 17:33:00 2009 for CMSSW by  doxygen 1.5.4