Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:40

0001 #include "HLTEcalPhiSymFilter.h"
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 #include "Calibration/Tools/interface/EcalRingCalibrationTools.h"
0009 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0010 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0011 
0012 HLTEcalPhiSymFilter::HLTEcalPhiSymFilter(const edm::ParameterSet& config)
0013     : ecalChannelStatusRcdToken_(esConsumes()),
0014       caloGeometryRecordToken_(esConsumes()),
0015       barrelDigisToken_(consumes<EBDigiCollection>(config.getParameter<edm::InputTag>("barrelDigiCollection"))),
0016       endcapDigisToken_(consumes<EEDigiCollection>(config.getParameter<edm::InputTag>("endcapDigiCollection"))),
0017       barrelUncalibHitsToken_(
0018           consumes<EcalUncalibratedRecHitCollection>(config.getParameter<edm::InputTag>("barrelUncalibHitCollection"))),
0019       endcapUncalibHitsToken_(
0020           consumes<EcalUncalibratedRecHitCollection>(config.getParameter<edm::InputTag>("endcapUncalibHitCollection"))),
0021       barrelHitsToken_(consumes<EBRecHitCollection>(config.getParameter<edm::InputTag>("barrelHitCollection"))),
0022       endcapHitsToken_(consumes<EERecHitCollection>(config.getParameter<edm::InputTag>("endcapHitCollection"))),
0023       phiSymBarrelDigis_(config.getParameter<std::string>("phiSymBarrelDigiCollection")),
0024       phiSymEndcapDigis_(config.getParameter<std::string>("phiSymEndcapDigiCollection")),
0025       ampCut_barlP_(config.getParameter<std::vector<double> >("ampCut_barrelP")),
0026       ampCut_barlM_(config.getParameter<std::vector<double> >("ampCut_barrelM")),
0027       ampCut_endcP_(config.getParameter<std::vector<double> >("ampCut_endcapP")),
0028       ampCut_endcM_(config.getParameter<std::vector<double> >("ampCut_endcapM")),
0029       statusThreshold_(config.getParameter<uint32_t>("statusThreshold")),
0030       useRecoFlag_(config.getParameter<bool>("useRecoFlag")) {
0031   //register your products
0032   produces<EBDigiCollection>(phiSymBarrelDigis_);
0033   produces<EEDigiCollection>(phiSymEndcapDigis_);
0034 }
0035 
0036 HLTEcalPhiSymFilter::~HLTEcalPhiSymFilter() = default;
0037 
0038 void HLTEcalPhiSymFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0039   edm::ParameterSetDescription desc;
0040   desc.add<edm::InputTag>("barrelDigiCollection", edm::InputTag("ecalDigis", "ebDigis"));
0041   desc.add<edm::InputTag>("endcapDigiCollection", edm::InputTag("ecalDigis", "eeDigis"));
0042   desc.add<edm::InputTag>("barrelUncalibHitCollection", edm::InputTag("ecalUncalibHit", "EcalUncalibRecHitsEB"));
0043   desc.add<edm::InputTag>("endcapUncalibHitCollection", edm::InputTag("ecalUncalibHit", "EcalUncalibRecHitsEE"));
0044   desc.add<edm::InputTag>("barrelHitCollection", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
0045   desc.add<edm::InputTag>("endcapHitCollection", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
0046   desc.add<unsigned int>("statusThreshold", 3);
0047   desc.add<bool>("useRecoFlag", false);
0048   desc.add<std::vector<double> >(
0049       "ampCut_barrelP", {8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.,
0050                          8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.,
0051                          8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.,
0052                          8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.});
0053   desc.add<std::vector<double> >(
0054       "ampCut_barrelM", {8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.,
0055                          8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.,
0056                          8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.,
0057                          8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.});
0058   desc.add<std::vector<double> >("ampCut_endcapP", {12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12.,
0059                                                     12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12.,
0060                                                     12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12.});
0061   desc.add<std::vector<double> >("ampCut_endcapM", {12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12.,
0062                                                     12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12.,
0063                                                     12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12., 12.});
0064   desc.add<std::string>("phiSymBarrelDigiCollection", "phiSymEcalDigisEB");
0065   desc.add<std::string>("phiSymEndcapDigiCollection", "phiSymEcalDigisEE");
0066   descriptions.add("hltEcalPhiSymFilter", desc);
0067 }
0068 
0069 // ------------ method called to produce the data  ------------
0070 bool HLTEcalPhiSymFilter::filter(edm::StreamID, edm::Event& event, const edm::EventSetup& setup) const {
0071   using namespace edm;
0072   using namespace std;
0073 
0074   // Get ChannelStatus from DB
0075   edm::ESHandle<EcalChannelStatus> csHandle;
0076   if (!useRecoFlag_)
0077     csHandle = setup.getHandle(ecalChannelStatusRcdToken_);
0078   const EcalChannelStatus& channelStatus = *csHandle;
0079 
0080   // Get iRing-geometry
0081   auto const& geoHandle = setup.getHandle(caloGeometryRecordToken_);
0082   EcalRingCalibrationTools::setCaloGeometry(geoHandle.product());
0083   EcalRingCalibrationTools CalibRing;
0084 
0085   static const short N_RING_BARREL = EcalRingCalibrationTools::N_RING_BARREL;
0086   static const short N_RING_ENDCAP = EcalRingCalibrationTools::N_RING_ENDCAP;
0087 
0088   Handle<EBDigiCollection> barrelDigisHandle;
0089   Handle<EEDigiCollection> endcapDigisHandle;
0090   Handle<EcalUncalibratedRecHitCollection> barrelUncalibRecHitsHandle;
0091   Handle<EcalUncalibratedRecHitCollection> endcapUncalibRecHitsHandle;
0092   Handle<EBRecHitCollection> barrelRecHitsHandle;
0093   Handle<EERecHitCollection> endcapRecHitsHandle;
0094 
0095   event.getByToken(barrelDigisToken_, barrelDigisHandle);
0096   event.getByToken(endcapDigisToken_, endcapDigisHandle);
0097   event.getByToken(barrelUncalibHitsToken_, barrelUncalibRecHitsHandle);
0098   event.getByToken(endcapUncalibHitsToken_, endcapUncalibRecHitsHandle);
0099   event.getByToken(barrelHitsToken_, barrelRecHitsHandle);
0100   event.getByToken(endcapHitsToken_, endcapRecHitsHandle);
0101 
0102   //Create empty output collections
0103   std::unique_ptr<EBDigiCollection> phiSymEBDigiCollection(new EBDigiCollection);
0104   std::unique_ptr<EEDigiCollection> phiSymEEDigiCollection(new EEDigiCollection);
0105 
0106   const EBDigiCollection* EBDigis = barrelDigisHandle.product();
0107   const EEDigiCollection* EEDigis = endcapDigisHandle.product();
0108   const EBRecHitCollection* EBRechits = barrelRecHitsHandle.product();
0109   const EERecHitCollection* EERechits = endcapRecHitsHandle.product();
0110 
0111   //Select interesting EcalDigis (barrel)
0112   EcalUncalibratedRecHitCollection::const_iterator itunb;
0113   for (itunb = barrelUncalibRecHitsHandle->begin(); itunb != barrelUncalibRecHitsHandle->end(); itunb++) {
0114     EcalUncalibratedRecHit hit = (*itunb);
0115     EBDetId hitDetId = hit.id();
0116     uint16_t statusCode = 0;
0117     if (useRecoFlag_)
0118       statusCode = EBRechits->find(hitDetId)->recoFlag();
0119     else
0120       statusCode = channelStatus[itunb->id().rawId()].getStatusCode();
0121     int iRing = CalibRing.getRingIndex(hitDetId);
0122     float ampCut = 0.;
0123     if (hitDetId.ieta() < 0)
0124       ampCut = ampCut_barlM_[iRing];
0125     else if (hitDetId.ieta() > 0)
0126       ampCut = ampCut_barlP_[iRing - N_RING_BARREL / 2];
0127     float amplitude = hit.amplitude();
0128     if (statusCode <= statusThreshold_ && amplitude > ampCut) {
0129       const auto digiIt = EBDigis->find(hitDetId);
0130       if (digiIt != EBDigis->end()) {
0131         phiSymEBDigiCollection->push_back(digiIt->id(), digiIt->begin());
0132       } else {
0133         throw cms::Exception("DetIdNotFound") << "The detector ID " << hitDetId.rawId()
0134                                               << " is not in the EB digis collection or the collection is not sorted.";
0135       }
0136     }
0137   }
0138 
0139   //Select interesting EcalDigis (endcaps)
0140   EcalUncalibratedRecHitCollection::const_iterator itune;
0141   for (itune = endcapUncalibRecHitsHandle->begin(); itune != endcapUncalibRecHitsHandle->end(); itune++) {
0142     EcalUncalibratedRecHit hit = (*itune);
0143     EEDetId hitDetId = hit.id();
0144     uint16_t statusCode = 0;
0145     if (useRecoFlag_)
0146       statusCode = EERechits->find(hitDetId)->recoFlag();
0147     else
0148       statusCode = channelStatus[itune->id().rawId()].getStatusCode();
0149     int iRing = CalibRing.getRingIndex(hitDetId);
0150     float ampCut = 0.;
0151     if (hitDetId.zside() < 0)
0152       ampCut = ampCut_endcM_[iRing - N_RING_BARREL];
0153     else if (hitDetId.zside() > 0)
0154       ampCut = ampCut_endcP_[iRing - N_RING_BARREL - N_RING_ENDCAP / 2];
0155     float amplitude = hit.amplitude();
0156     if (statusCode <= statusThreshold_ && amplitude > ampCut) {
0157       const auto digiIt = EEDigis->find(hitDetId);
0158       if (digiIt != EEDigis->end()) {
0159         phiSymEEDigiCollection->push_back(digiIt->id(), digiIt->begin());
0160       } else {
0161         throw cms::Exception("DetIdNotFound") << "The detector ID " << hitDetId.rawId()
0162                                               << " is not in the EE digis collection or the collection is not sorted.";
0163       }
0164     }
0165   }
0166 
0167   if ((phiSymEBDigiCollection->empty()) && (phiSymEEDigiCollection->empty()))
0168     return false;
0169 
0170   //Put selected information in the event
0171   event.put(std::move(phiSymEBDigiCollection), phiSymBarrelDigis_);
0172   event.put(std::move(phiSymEEDigiCollection), phiSymEndcapDigis_);
0173 
0174   return true;
0175 }
0176 
0177 // declare this class as a framework plugin
0178 #include "FWCore/Framework/interface/MakerMacros.h"
0179 DEFINE_FWK_MODULE(HLTEcalPhiSymFilter);