CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DPGAnalysis/Skims/src/EcalSkim.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:   EcalSkim
00004 // Class:     EcalSkim
00005 //
00006 //class EcalSkim EcalSkim.cc
00007 //
00008 // Original Author:  Serena OGGERO
00009 //         Created:  We May 14 10:10:52 CEST 2008
00010 //        Modified:  Toyoko ORIMOTO
00011 
00012 #include <memory>
00013 #include <vector>
00014 #include <map>
00015 #include <set>
00016 
00017 // user include files
00018 #include "DPGAnalysis/Skims/interface/EcalSkim.h"
00019 
00020 #include "FWCore/Utilities/interface/InputTag.h"
00021 #include "FWCore/Framework/interface/Frameworkfwd.h"
00022 #include "FWCore/Framework/interface/EDFilter.h"
00023 #include "FWCore/Framework/interface/Event.h"
00024 #include "FWCore/Framework/interface/MakerMacros.h"
00025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00029 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00030 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00031 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00032 
00033 using namespace edm;
00034 using namespace std;
00035 using namespace reco;
00036 
00037 EcalSkim::EcalSkim(const edm::ParameterSet& iConfig)
00038 {
00039   BarrelClusterCollection = iConfig.getParameter<edm::InputTag>("barrelClusterCollection");
00040   EndcapClusterCollection = iConfig.getParameter<edm::InputTag>("endcapClusterCollection");
00041 
00042   EnergyCutEB = iConfig.getUntrackedParameter<double>("energyCutEB");
00043   EnergyCutEE = iConfig.getUntrackedParameter<double>("energyCutEE");
00044 
00045 }
00046 
00047 EcalSkim::~EcalSkim()
00048 {
00049 }
00050 
00051 bool EcalSkim::filter( edm::Event& iEvent, const edm::EventSetup& iSetup)
00052 {
00053  int ievt = iEvent.id().event();
00054 
00055  edm::Handle<reco::SuperClusterCollection> bccHandle; // barrel
00056  edm::Handle<reco::SuperClusterCollection> eccHandle; // endcap 
00057  
00058  iEvent.getByLabel("cosmicSuperClusters","CosmicBarrelSuperClusters", bccHandle);
00059  if (!(bccHandle.isValid()))
00060  {
00061    LogWarning("EcalSkim") << BarrelClusterCollection << " not available in event " << ievt;
00062    return false;
00063  }
00064  else 
00065  {
00066    //   edm::LogVerbatim("") << "I took the right barrel collection" ;
00067  }
00068  iEvent.getByLabel("cosmicSuperClusters","CosmicEndcapSuperClusters", eccHandle);
00069  
00070  if (!(eccHandle.isValid()))
00071  {
00072    LogWarning("EcalSkim") << EndcapClusterCollection << " not available";
00073    //return false;
00074  }
00075  else 
00076  {
00077    //edm::LogVerbatim("") << "I took the right endcap collection " ;
00078  }
00079 
00080  bool accepted = false;
00081  bool acceptedEB = false;
00082  bool acceptedEE = false;
00083 
00084  // barrel
00085  const reco::SuperClusterCollection *clusterCollectionEB = bccHandle.product();
00086  for (reco::SuperClusterCollection::const_iterator clus = clusterCollectionEB->begin(); clus != clusterCollectionEB->end(); ++clus)
00087    {
00088      if ( clus->energy() >= EnergyCutEB )
00089        {
00090          acceptedEB = true;
00091          break;
00092        }
00093    }
00094  
00095  // endcap
00096  const reco::SuperClusterCollection *clusterCollectionEE = eccHandle.product();
00097  for (reco::SuperClusterCollection::const_iterator clus = clusterCollectionEE->begin(); clus != clusterCollectionEE->end(); ++clus)
00098    {
00099      if ( clus->energy() >= EnergyCutEE )
00100        {
00101          acceptedEE = true;
00102          break;
00103        }
00104    }
00105  
00106  // if there is at least one high energy cluster in EB OR EE, accept
00107  if (acceptedEB||acceptedEE) accepted = true;  
00108 
00109  return accepted;
00110 
00111 }
00112 
00113 //define this as a plug-in
00114 DEFINE_FWK_MODULE(EcalSkim);