File indexing completed on 2024-04-06 12:00:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <memory>
0011 #include <vector>
0012 #include <map>
0013 #include <set>
0014
0015
0016 #include "CaloOnlineTools/EcalTools/plugins/EcalRecHitsFilter.h"
0017
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/MakerMacros.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0026 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0027 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0028 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0029 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0030 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
0031
0032 using namespace edm;
0033 using namespace std;
0034 using namespace reco;
0035
0036
0037 EcalRecHitsFilter::EcalRecHitsFilter(const edm::ParameterSet& iConfig)
0038 : NumBadXtalsThreshold_(iConfig.getUntrackedParameter<int>("NumberXtalsThreshold")),
0039 EBRecHitCollection_(
0040 consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("EcalRecHitCollectionEB"))),
0041 EnergyCut(iConfig.getUntrackedParameter<double>("energycut")) {}
0042
0043 EcalRecHitsFilter::~EcalRecHitsFilter() {}
0044
0045 bool EcalRecHitsFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0046
0047 const Handle<EcalRecHitCollection>& EBhits = iEvent.getHandle(EBRecHitCollection_);
0048
0049 bool accepted = true;
0050 int nRecHitsGreater1GevPerEvent = 0;
0051
0052 for (EcalRecHitCollection::const_iterator hitItr = EBhits->begin(); hitItr != EBhits->end(); ++hitItr) {
0053 EcalRecHit hit = (*hitItr);
0054 EBDetId det = hit.id();
0055
0056 float ampli = hit.energy();
0057 if (ampli > EnergyCut ) {
0058 nRecHitsGreater1GevPerEvent++;
0059 nRecHitsGreater1GevPerEvent_hist_MAP->Fill(det.iphi(), det.ieta());
0060 }
0061 }
0062 nRecHitsGreater1GevPerEvent_hist->Fill(nRecHitsGreater1GevPerEvent);
0063 if (nRecHitsGreater1GevPerEvent > NumBadXtalsThreshold_)
0064 accepted = false;
0065 return accepted;
0066 }
0067
0068 void EcalRecHitsFilter::beginJob() {
0069 nRecHitsGreater1GevPerEvent_hist =
0070 new TH1F("nRecHitsGreater1GevPerEvent_hist", "nRecHitsGreater1GevPerEvent_hist", 65000, 0., 65000.);
0071 nRecHitsGreater1GevPerEvent_hist_MAP = new TH2F(
0072 "nRecHitsGreater1GevPerEvent_hist_MAP", "nRecHitsGreater1GevPerEvent_hist_MAP", 360, 1., 361., 171, -85., 86.);
0073 }
0074
0075 void EcalRecHitsFilter::endJob() {
0076 edm::LogVerbatim("EcalTools") << "------EcalRecHitsFilter EndJob------>>>>>>>>>>";
0077 file = new TFile("RecHitFilter.root", "RECREATE");
0078 file->cd();
0079 nRecHitsGreater1GevPerEvent_hist_MAP->Write();
0080 nRecHitsGreater1GevPerEvent_hist->Write();
0081 file->Close();
0082 }