CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DQMOffline/Ecal/src/ESRecoSummary.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    ESRecoSummary
00004 // Class:      ESRecoSummary
00005 // Original Author:  Martina Malberti
00006 // 
00007 // system include files
00008 #include <memory>
00009 
00010 // user include files
00011 #include "FWCore/Framework/interface/Frameworkfwd.h"
00012 #include "FWCore/Framework/interface/EDAnalyzer.h"
00013 
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "FWCore/Common/interface/EventBase.h"
00017 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
00018 
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020 #include "FWCore/ServiceRegistry/interface/Service.h"
00021 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00022 
00023 
00024 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00025 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00026 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00027 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00028 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00029 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00030 #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
00031 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
00032 
00033 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00034 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00035 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00036 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00037 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00038 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00039 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00040 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00041 #include "DataFormats/EgammaReco/interface/PreshowerCluster.h"
00042 #include "DataFormats/EgammaReco/interface/PreshowerClusterFwd.h"
00043 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
00044 #include "RecoEcal/EgammaCoreTools/interface/EcalTools.h"
00045 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00046 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalCleaningAlgo.h"
00047 #include "RecoEcal/EgammaCoreTools/interface/EcalRecHitLess.h"
00048 
00049 #include "DataFormats/TrackReco/interface/Track.h"
00050 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00051 
00052 #include "DataFormats/JetReco/interface/CaloJet.h"
00053 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00054 
00055 #include "DQMOffline/Ecal/interface/ESRecoSummary.h"
00056 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00057 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00058 #include "MagneticField/Engine/interface/MagneticField.h"
00059 
00060 #include "TVector3.h"
00061 
00062 #include <iostream>
00063 #include <cmath>
00064 #include <fstream>
00065 
00066 //
00067 // constructors and destructor
00068 //
00069 ESRecoSummary::ESRecoSummary(const edm::ParameterSet& ps)
00070 {
00071 
00072   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00073 
00074   //now do what ever initialization is needed
00075   esRecHitCollection_        = ps.getParameter<edm::InputTag>("recHitCollection_ES");
00076   esClusterCollectionX_      = ps.getParameter<edm::InputTag>("ClusterCollectionX_ES");
00077   esClusterCollectionY_      = ps.getParameter<edm::InputTag>("ClusterCollectionY_ES");
00078 
00079   dqmStore_ = edm::Service<DQMStore>().operator->();
00080 
00081   // Monitor Elements (ex THXD)
00082   dqmStore_->setCurrentFolder(prefixME_ + "/ESRecoSummary"); // to organise the histos in folders
00083 
00084   superClusterCollection_EE_ = ps.getParameter<edm::InputTag>("superClusterCollection_EE");
00085      
00086   // Preshower ----------------------------------------------
00087   h_recHits_ES_energyMax      = dqmStore_->book1D("recHits_ES_energyMax","recHits_ES_energyMax",200,0.,0.01);
00088   h_recHits_ES_time           = dqmStore_->book1D("recHits_ES_time","recHits_ES_time",200,-100.,100.);
00089 
00090   h_esClusters_energy_plane1 = dqmStore_->book1D("esClusters_energy_plane1","esClusters_energy_plane1",200,0.,0.01);
00091   h_esClusters_energy_plane2 = dqmStore_->book1D("esClusters_energy_plane2","esClusters_energy_plane2",200,0.,0.01);
00092   h_esClusters_energy_ratio  = dqmStore_->book1D("esClusters_energy_ratio","esClusters_energy_ratio",200,0.,20.);
00093 
00094 }
00095 
00096 
00097 
00098 ESRecoSummary::~ESRecoSummary()
00099 {
00100         // do anything here that needs to be done at desctruction time
00101         // (e.g. close files, deallocate resources etc.)
00102 }
00103 
00104 
00105 //
00106 // member functions
00107 //
00108 
00109 // ------------ method called to for each event  ------------
00110 void ESRecoSummary::analyze(const edm::Event& ev, const edm::EventSetup& iSetup)
00111 {
00112   
00113   //Get the magnetic field
00114   edm::ESHandle<MagneticField> theMagField;
00115   iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
00116 
00117   //Preshower RecHits
00118   edm::Handle<ESRecHitCollection> recHitsES;
00119   ev.getByLabel (esRecHitCollection_, recHitsES) ;
00120   const ESRecHitCollection* thePreShowerRecHits = recHitsES.product () ;
00121 
00122   if ( ! recHitsES.isValid() ) {
00123     std::cerr << "ESRecoSummary::analyze --> recHitsES not found" << std::endl; 
00124   }
00125 
00126   float maxRecHitEnergyES = -999.;
00127 
00128   for (ESRecHitCollection::const_iterator esItr = thePreShowerRecHits->begin(); esItr != thePreShowerRecHits->end(); ++esItr) 
00129     {
00130       
00131       h_recHits_ES_time   -> Fill(esItr->time()); 
00132       if (esItr -> energy() > maxRecHitEnergyES ) maxRecHitEnergyES = esItr -> energy() ;
00133 
00134     } // end loop over ES rec Hits
00135 
00136   h_recHits_ES_energyMax -> Fill(maxRecHitEnergyES ); 
00137 
00138   // ES clusters in X plane
00139   edm::Handle<reco::PreshowerClusterCollection> esClustersX;
00140   ev.getByLabel( esClusterCollectionX_, esClustersX);
00141   const reco::PreshowerClusterCollection *ESclustersX = esClustersX.product();
00142 
00143   // ES clusters in Y plane
00144   edm::Handle<reco::PreshowerClusterCollection> esClustersY;
00145   ev.getByLabel( esClusterCollectionY_, esClustersY);
00146   const reco::PreshowerClusterCollection *ESclustersY = esClustersY.product(); 
00147   
00148 
00149   // ... endcap
00150   edm::Handle<reco::SuperClusterCollection> superClusters_EE_h;
00151   ev.getByLabel( superClusterCollection_EE_, superClusters_EE_h );
00152   const reco::SuperClusterCollection* theEndcapSuperClusters = superClusters_EE_h.product () ;
00153   if ( ! superClusters_EE_h.isValid() ) {
00154     std::cerr << "EcalRecHitSummary::analyze --> superClusters_EE_h not found" << std::endl; 
00155   }
00156 
00157   // loop over all super clusters
00158   for (reco::SuperClusterCollection::const_iterator itSC = theEndcapSuperClusters->begin(); 
00159        itSC != theEndcapSuperClusters->end(); ++itSC ) {
00160     
00161     if ( fabs(itSC->eta()) < 1.65 || fabs(itSC->eta()) > 2.6 ) continue;
00162 
00163     // Loop over all ECAL Basic clusters in the supercluster
00164     for (reco::CaloCluster_iterator ecalBasicCluster = itSC->clustersBegin(); ecalBasicCluster!= itSC->clustersEnd(); 
00165          ecalBasicCluster++) {
00166       const reco::CaloClusterPtr ecalBasicClusterPtr = *(ecalBasicCluster);
00167       
00168       float ESenergyPlane1 = -999.;
00169       float ESenergyPlane2 = -999.;
00170       
00171       for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersX->begin(); iESClus != ESclustersX->end(); 
00172            ++iESClus) {
00173         const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
00174         const reco::PreshowerCluster *esCluster = &*iESClus;
00175         if (preshBasicCluster == ecalBasicClusterPtr) {
00176           ESenergyPlane1 = esCluster->energy();
00177           h_esClusters_energy_plane1 ->Fill(esCluster->energy());
00178         }
00179       }  // end of x loop
00180       
00181       for (reco::PreshowerClusterCollection::const_iterator iESClus = ESclustersY->begin(); iESClus != ESclustersY->end(); 
00182            ++iESClus) {
00183         const reco::CaloClusterPtr preshBasicCluster = iESClus->basicCluster();
00184         const reco::PreshowerCluster *esCluster = &*iESClus;
00185         if (preshBasicCluster == ecalBasicClusterPtr) {
00186           ESenergyPlane2 = esCluster->energy();
00187           h_esClusters_energy_plane2 -> Fill(esCluster->energy());
00188         }
00189       } // end of y loop
00190       
00191       if ( ESenergyPlane1 != -999. && ESenergyPlane2 != -999. ) 
00192         h_esClusters_energy_ratio -> Fill(ESenergyPlane1/ESenergyPlane2);
00193       
00194       
00195     } // end loop over all basic clusters in the supercluster
00196   }// end loop over superclusters
00197 
00198 }
00199 
00200 
00201 // ------------ method called once each job just before starting event loop  ------------
00202         void 
00203 ESRecoSummary::beginJob()
00204 {
00205 }
00206 
00207 // ------------ method called once each job just after ending the event loop  ------------
00208 void 
00209 ESRecoSummary::endJob() 
00210 {}
00211 
00212 //define this as a plug-in
00213 DEFINE_FWK_MODULE(ESRecoSummary);