CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/BeamMonitor/plugins/BeamConditionsMonitor.cc

Go to the documentation of this file.
00001 /*
00002  * \file BeamConditionsMonitor.cc
00003  * \author Geng-yuan Jeng/UC Riverside
00004  *         Francisco Yumiceva/FNAL
00005  * $Date: 2010/07/20 20:23:27 $
00006  * $Revision: 1.9 $
00007  *
00008  */
00009 
00010 #include "DQM/BeamMonitor/plugins/BeamConditionsMonitor.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "FWCore/Framework/interface/MakerMacros.h"
00013 #include "FWCore/Framework/interface/IOVSyncValue.h"
00014 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include <numeric>
00018 #include <math.h>
00019 #include <TMath.h>
00020 #include <iostream>
00021 #include "TStyle.h"
00022 
00023 using namespace std;
00024 using namespace edm;
00025 
00026 //
00027 // constructors and destructor
00028 //
00029 BeamConditionsMonitor::BeamConditionsMonitor( const ParameterSet& ps ) :
00030   countEvt_(0),countLumi_(0) {
00031 
00032   parameters_     = ps;
00033   monitorName_    = parameters_.getUntrackedParameter<string>("monitorName","YourSubsystemName");
00034   bsSrc_          = parameters_.getUntrackedParameter<InputTag>("beamSpot");
00035   debug_          = parameters_.getUntrackedParameter<bool>("Debug");
00036   
00037   dbe_            = Service<DQMStore>().operator->();
00038   
00039   if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
00040 }
00041 
00042 
00043 BeamConditionsMonitor::~BeamConditionsMonitor() {
00044 }
00045 
00046 
00047 //--------------------------------------------------------
00048 void BeamConditionsMonitor::beginJob() {
00049   
00050   // book some histograms here
00051   // create and cd into new folder
00052   dbe_->setCurrentFolder(monitorName_+"Conditions");
00053   
00054   h_x0_lumi = dbe_->book1D("x0_lumi_cond","x coordinate of beam spot vs lumi (Cond)",10,0,10);
00055   h_x0_lumi->setAxisTitle("Lumisection",1);
00056   h_x0_lumi->setAxisTitle("x_{0} (cm)",2);
00057   h_x0_lumi->getTH1()->SetOption("E1");
00058 
00059   h_y0_lumi = dbe_->book1D("y0_lumi_cond","y coordinate of beam spot vs lumi (Cond)",10,0,10);
00060   h_y0_lumi->setAxisTitle("Lumisection",1);
00061   h_y0_lumi->setAxisTitle("y_{0} (cm)",2);
00062   h_y0_lumi->getTH1()->SetOption("E1");
00063   
00064 }
00065 
00066 //--------------------------------------------------------
00067 void BeamConditionsMonitor::beginRun(const edm::Run& r, const EventSetup& context) {
00068 }
00069 
00070 //--------------------------------------------------------
00071 void BeamConditionsMonitor::beginLuminosityBlock(const LuminosityBlock& lumiSeg,
00072                                                  const EventSetup& context) {
00073   countLumi_++;
00074 }
00075 
00076 // ----------------------------------------------------------
00077 void BeamConditionsMonitor::analyze(const Event& iEvent, const EventSetup& iSetup ) {
00078 
00079   countEvt_++;  
00080   ESHandle< BeamSpotObjects > beamhandle;
00081   iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
00082   condBeamSpot = *beamhandle;
00083 
00084 }
00085 
00086 
00087 //--------------------------------------------------------
00088 void BeamConditionsMonitor::endLuminosityBlock(const LuminosityBlock& lumiSeg, 
00089                                                const EventSetup& iSetup) {
00090 
00091   LogInfo("BeamConditions") << "[BeamConditionsMonitor]:" << condBeamSpot << endl;
00092   h_x0_lumi->ShiftFillLast( condBeamSpot.GetX(), condBeamSpot.GetXError(), 1 );
00093   h_y0_lumi->ShiftFillLast( condBeamSpot.GetY(), condBeamSpot.GetYError(), 1 );
00094 
00095 }
00096 //--------------------------------------------------------
00097 void BeamConditionsMonitor::endRun(const Run& r, const EventSetup& context) {  
00098 }
00099 //--------------------------------------------------------
00100 void BeamConditionsMonitor::endJob() {
00101 }
00102 
00103 DEFINE_FWK_MODULE(BeamConditionsMonitor);