CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Validation/EcalClusters/src/EgammaBasicClusters.cc

Go to the documentation of this file.
00001 #include "Validation/EcalClusters/interface/EgammaBasicClusters.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 
00007 #include "DataFormats/Common/interface/Handle.h"
00008 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00009 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00010 #include "DQMServices/Core/interface/DQMStore.h"
00011 
00012 EgammaBasicClusters::EgammaBasicClusters( const edm::ParameterSet& ps )
00013 {
00014         outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
00015         //CMSSW_Version_ = ps.getUntrackedParameter<std::string>("CMSSW_Version", "");
00016 
00017         verboseDBE_ = ps.getUntrackedParameter<bool>("verboseDBE", false);
00018 
00019         hist_min_Size_ = ps.getParameter<double>("hist_min_Size");
00020         hist_max_Size_ = ps.getParameter<double>("hist_max_Size");
00021         hist_bins_Size_ = ps.getParameter<int>   ("hist_bins_Size");
00022 
00023         hist_min_NumRecHits_ = ps.getParameter<double>("hist_min_NumRecHits");
00024         hist_max_NumRecHits_ = ps.getParameter<double>("hist_max_NumRecHits");
00025         hist_bins_NumRecHits_ = ps.getParameter<int>   ("hist_bins_NumRecHits");
00026 
00027         hist_min_ET_ = ps.getParameter<double>("hist_min_ET");
00028         hist_max_ET_ = ps.getParameter<double>("hist_max_ET");
00029         hist_bins_ET_ = ps.getParameter<int>   ("hist_bins_ET");
00030 
00031         hist_min_Eta_ = ps.getParameter<double>("hist_min_Eta");
00032         hist_max_Eta_ = ps.getParameter<double>("hist_max_Eta");
00033         hist_bins_Eta_ = ps.getParameter<int>   ("hist_bins_Eta");
00034 
00035         hist_min_Phi_ = ps.getParameter<double>("hist_min_Phi");
00036         hist_max_Phi_ = ps.getParameter<double>("hist_max_Phi");
00037         hist_bins_Phi_ = ps.getParameter<int>   ("hist_bins_Phi");
00038 
00039         hist_min_R_ = ps.getParameter<double>("hist_min_R");
00040         hist_max_R_ = ps.getParameter<double>("hist_max_R");
00041         hist_bins_R_ = ps.getParameter<int>   ("hist_bins_R");
00042 
00043         barrelBasicClusterCollection_ = ps.getParameter<edm::InputTag>("barrelBasicClusterCollection");
00044         endcapBasicClusterCollection_ = ps.getParameter<edm::InputTag>("endcapBasicClusterCollection");
00045 }
00046 
00047 EgammaBasicClusters::~EgammaBasicClusters() {}
00048 
00049 void EgammaBasicClusters::beginJob() 
00050 {
00051         dbe_ = edm::Service<DQMStore>().operator->();                   
00052 
00053         if ( verboseDBE_ )
00054         {
00055                 dbe_->setVerbose(1);
00056                 dbe_->showDirStructure();
00057         }
00058         else 
00059                 dbe_->setVerbose(0);
00060 
00061         //dbe_->setCurrentFolder("Ecal/CMSSW_"+CMSSW_Version_+"/EcalClusters/BasicClusters/");
00062         dbe_->setCurrentFolder("EcalClusterV/EcalBasicClusters/");
00063 
00064         hist_EB_BC_Size_ 
00065                 = dbe_->book1D("hist_EB_BC_Size_","# Basic Clusters in Barrel",
00066                         hist_bins_Size_,hist_min_Size_,hist_max_Size_);
00067         hist_EE_BC_Size_ 
00068                 = dbe_->book1D("hist_EE_BC_Size_","# Basic Clusters in Endcap",
00069                         hist_bins_Size_,hist_min_Size_,hist_max_Size_);
00070 
00071         hist_EB_BC_NumRecHits_ 
00072                 = dbe_->book1D("hist_EB_BC_NumRecHits_","# of RecHits in Basic Clusters in Barrel",
00073                         hist_bins_NumRecHits_,hist_min_NumRecHits_,hist_max_NumRecHits_);
00074         hist_EE_BC_NumRecHits_ 
00075                 = dbe_->book1D("hist_EE_BC_NumRecHits_","# of RecHits in Basic Clusters in Endcap",
00076                         hist_bins_NumRecHits_,hist_min_NumRecHits_,hist_max_NumRecHits_);
00077 
00078         hist_EB_BC_ET_ 
00079                 = dbe_->book1D("hist_EB_BC_ET_","ET of Basic Clusters in Barrel",
00080                         hist_bins_ET_,hist_min_ET_,hist_max_ET_);
00081         hist_EE_BC_ET_ 
00082                 = dbe_->book1D("hist_EE_BC_ET_","ET of Basic Clusters in Endcap",
00083                         hist_bins_ET_,hist_min_ET_,hist_max_ET_);
00084 
00085         hist_EB_BC_Eta_ 
00086                 = dbe_->book1D("hist_EB_BC_Eta_","Eta of Basic Clusters in Barrel",
00087                         hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_);
00088         hist_EE_BC_Eta_ 
00089                 = dbe_->book1D("hist_EE_BC_Eta_","Eta of Basic Clusters in Endcap",
00090                         hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_);
00091 
00092         hist_EB_BC_Phi_
00093                 = dbe_->book1D("hist_EB_BC_Phi_","Phi of Basic Clusters in Barrel",
00094                         hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_);
00095         hist_EE_BC_Phi_ 
00096                 = dbe_->book1D("hist_EE_BC_Phi_","Phi of Basic Clusters in Endcap",
00097                         hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_);
00098 
00099         
00100         hist_EB_BC_ET_vs_Eta_ = dbe_->book2D( "hist_EB_BC_ET_vs_Eta_", "Basic Cluster ET versus Eta in Barrel", 
00101                                               hist_bins_ET_, hist_min_ET_, hist_max_ET_,
00102                                               hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_ );
00103 
00104         hist_EB_BC_ET_vs_Phi_ = dbe_->book2D( "hist_EB_BC_ET_vs_Phi_", "Basic Cluster ET versus Phi in Barrel", 
00105                                               hist_bins_ET_, hist_min_ET_, hist_max_ET_,
00106                                               hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_ );
00107 
00108         hist_EE_BC_ET_vs_Eta_ = dbe_->book2D( "hist_EE_BC_ET_vs_Eta_", "Basic Cluster ET versus Eta in Endcap", 
00109                                               hist_bins_ET_, hist_min_ET_, hist_max_ET_,
00110                                               hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_ );
00111 
00112         hist_EE_BC_ET_vs_Phi_ = dbe_->book2D( "hist_EE_BC_ET_vs_Phi_", "Basic Cluster ET versus Phi in Endcap", 
00113                                               hist_bins_ET_, hist_min_ET_, hist_max_ET_,
00114                                               hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_ );
00115 
00116         hist_EE_BC_ET_vs_R_ = dbe_->book2D( "hist_EE_BC_ET_vs_R_", "Basic Cluster ET versus Radius in Endcap", 
00117                                               hist_bins_ET_, hist_min_ET_, hist_max_ET_,
00118                                               hist_bins_R_,hist_min_R_,hist_max_R_ );
00119 
00120 
00121 
00122 }
00123 
00124 void EgammaBasicClusters::analyze( const edm::Event& evt, const edm::EventSetup& es )
00125 {
00126         edm::Handle<reco::BasicClusterCollection> pBarrelBasicClusters;
00127         evt.getByLabel(barrelBasicClusterCollection_, pBarrelBasicClusters);
00128         if (!pBarrelBasicClusters.isValid()) {
00129           edm::LogError("EgammaBasicClusters") << "Error! can't get collection with label " 
00130                                                << barrelBasicClusterCollection_.label();
00131         }
00132 
00133         const reco::BasicClusterCollection* barrelBasicClusters = pBarrelBasicClusters.product();
00134         hist_EB_BC_Size_->Fill(barrelBasicClusters->size());
00135 
00136         for(reco::BasicClusterCollection::const_iterator aClus = barrelBasicClusters->begin(); 
00137                 aClus != barrelBasicClusters->end(); aClus++)
00138         {
00139                 hist_EB_BC_NumRecHits_->Fill(aClus->size());
00140                 hist_EB_BC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta()));
00141                 hist_EB_BC_Eta_->Fill(aClus->position().eta());
00142                 hist_EB_BC_Phi_->Fill(aClus->position().phi());
00143                 
00144                 hist_EB_BC_ET_vs_Eta_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->eta() );
00145                 hist_EB_BC_ET_vs_Phi_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->phi() );
00146         }
00147 
00148         edm::Handle<reco::BasicClusterCollection> pEndcapBasicClusters;
00149 
00150         evt.getByLabel(endcapBasicClusterCollection_, pEndcapBasicClusters);
00151         if (!pEndcapBasicClusters.isValid()) {
00152           edm::LogError("EgammaBasicClusters") << "Error! can't get collection with label " 
00153                                                << endcapBasicClusterCollection_.label();
00154         }
00155 
00156         const reco::BasicClusterCollection* endcapBasicClusters = pEndcapBasicClusters.product();
00157         hist_EE_BC_Size_->Fill(endcapBasicClusters->size());
00158 
00159         for(reco::BasicClusterCollection::const_iterator aClus = endcapBasicClusters->begin(); 
00160                 aClus != endcapBasicClusters->end(); aClus++)
00161         {
00162                 hist_EE_BC_NumRecHits_->Fill(aClus->size());
00163                 hist_EE_BC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta()));
00164                 hist_EE_BC_Eta_->Fill(aClus->position().eta());
00165                 hist_EE_BC_Phi_->Fill(aClus->position().phi());
00166 
00167                 hist_EE_BC_ET_vs_Eta_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->eta() );
00168                 hist_EE_BC_ET_vs_Phi_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->phi() );
00169                 hist_EE_BC_ET_vs_R_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), 
00170                                            std::sqrt( std::pow(aClus->x(),2) + std::pow(aClus->y(),2) ) );
00171 
00172         }
00173 }
00174 
00175 void EgammaBasicClusters::endJob()
00176 {
00177         if (outputFile_.size() != 0 && dbe_) dbe_->save(outputFile_);
00178 }