Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:48

0001 // -*- C++ -*-
0002 //
0003 // Package:   EcalSkim
0004 // Class:     EcalSkim
0005 //
0006 //class EcalSkim EcalSkim.cc
0007 //
0008 // Original Author:  Serena OGGERO
0009 //         Created:  We May 14 10:10:52 CEST 2008
0010 //        Modified:  Toyoko ORIMOTO
0011 
0012 #include <memory>
0013 #include <vector>
0014 #include <map>
0015 #include <set>
0016 
0017 // user include files
0018 #include "DPGAnalysis/Skims/interface/EcalSkim.h"
0019 
0020 #include "FWCore/Utilities/interface/InputTag.h"
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/Framework/interface/ESHandle.h"
0026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0027 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0028 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0029 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0030 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0031 
0032 using namespace edm;
0033 using namespace std;
0034 using namespace reco;
0035 
0036 EcalSkim::EcalSkim(const edm::ParameterSet& iConfig) {
0037   BarrelClusterCollection = iConfig.getParameter<edm::InputTag>("barrelClusterCollection");
0038   EndcapClusterCollection = iConfig.getParameter<edm::InputTag>("endcapClusterCollection");
0039 
0040   EnergyCutEB = iConfig.getUntrackedParameter<double>("energyCutEB");
0041   EnergyCutEE = iConfig.getUntrackedParameter<double>("energyCutEE");
0042 }
0043 
0044 EcalSkim::~EcalSkim() {}
0045 
0046 bool EcalSkim::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0047   int ievt = iEvent.id().event();
0048 
0049   edm::Handle<reco::SuperClusterCollection> bccHandle;  // barrel
0050   edm::Handle<reco::SuperClusterCollection> eccHandle;  // endcap
0051 
0052   iEvent.getByLabel("cosmicSuperClusters", "CosmicBarrelSuperClusters", bccHandle);
0053   if (!(bccHandle.isValid())) {
0054     LogWarning("EcalSkim") << BarrelClusterCollection << " not available in event " << ievt;
0055     return false;
0056   } else {
0057     //   edm::LogVerbatim("") << "I took the right barrel collection" ;
0058   }
0059   iEvent.getByLabel("cosmicSuperClusters", "CosmicEndcapSuperClusters", eccHandle);
0060 
0061   if (!(eccHandle.isValid())) {
0062     LogWarning("EcalSkim") << EndcapClusterCollection << " not available";
0063     //return false;
0064   } else {
0065     //edm::LogVerbatim("") << "I took the right endcap collection " ;
0066   }
0067 
0068   bool accepted = false;
0069   bool acceptedEB = false;
0070   bool acceptedEE = false;
0071 
0072   // barrel
0073   const reco::SuperClusterCollection* clusterCollectionEB = bccHandle.product();
0074   for (reco::SuperClusterCollection::const_iterator clus = clusterCollectionEB->begin();
0075        clus != clusterCollectionEB->end();
0076        ++clus) {
0077     if (clus->energy() >= EnergyCutEB) {
0078       acceptedEB = true;
0079       break;
0080     }
0081   }
0082 
0083   // endcap
0084   const reco::SuperClusterCollection* clusterCollectionEE = eccHandle.product();
0085   for (reco::SuperClusterCollection::const_iterator clus = clusterCollectionEE->begin();
0086        clus != clusterCollectionEE->end();
0087        ++clus) {
0088     if (clus->energy() >= EnergyCutEE) {
0089       acceptedEE = true;
0090       break;
0091     }
0092   }
0093 
0094   // if there is at least one high energy cluster in EB OR EE, accept
0095   if (acceptedEB || acceptedEE)
0096     accepted = true;
0097 
0098   return accepted;
0099 }
0100 
0101 //define this as a plug-in
0102 DEFINE_FWK_MODULE(EcalSkim);