Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032
00033 #include "FWCore/Framework/interface/ESHandle.h"
00034 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00035 #include "DataFormats/DetId/interface/DetIdCollection.h"
00036
00037 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00038 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
00039
00040 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00041 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00042
00043
00044
00045
00046
00047 class HcalHitSelection : public edm::EDProducer {
00048 public:
00049 explicit HcalHitSelection(const edm::ParameterSet&);
00050 ~HcalHitSelection();
00051
00052 private:
00053 virtual void beginJob() ;
00054 virtual void produce(edm::Event&, const edm::EventSetup&);
00055 virtual void endJob() ;
00056
00057 edm::InputTag hbheTag,hoTag,hfTag;
00058 int hoSeverityLevel;
00059 std::vector<edm::InputTag> interestingDetIdCollections;
00060
00061
00062 edm::ESHandle<HcalChannelQuality> theHcalChStatus;
00063 edm::ESHandle<HcalSeverityLevelComputer> theHcalSevLvlComputer;
00064 std::set<DetId> toBeKept;
00065 template <typename CollectionType> void skim( const edm::Handle<CollectionType> & input, std::auto_ptr<CollectionType> & output,int severityThreshold=0);
00066
00067
00068 };
00069
00070 template <class CollectionType> void HcalHitSelection::skim( const edm::Handle<CollectionType> & input, std::auto_ptr<CollectionType> & output,int severityThreshold){
00071 output->reserve(input->size());
00072 typename CollectionType::const_iterator begin=input->begin();
00073 typename CollectionType::const_iterator end=input->end();
00074 typename CollectionType::const_iterator hit=begin;
00075
00076 for (;hit!=end;++hit){
00077
00078 const DetId & id = hit->detid();
00079 const uint32_t & recHitFlag = hit->flags();
00080
00081
00082 const uint32_t & dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
00083 int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
00084
00085 if (severityLevel>severityThreshold){
00086 output->push_back(*hit);
00087 }else{
00088
00089 if (toBeKept.find(id)!=toBeKept.end())
00090 output->push_back(*hit);
00091 }
00092 }
00093 }
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 HcalHitSelection::HcalHitSelection(const edm::ParameterSet& iConfig)
00108 {
00109 hbheTag=iConfig.getParameter<edm::InputTag>("hbheTag");
00110 hfTag=iConfig.getParameter<edm::InputTag>("hfTag");
00111 hoTag=iConfig.getParameter<edm::InputTag>("hoTag");
00112
00113 interestingDetIdCollections = iConfig.getParameter< std::vector<edm::InputTag> >("interestingDetIds");
00114
00115 hoSeverityLevel=iConfig.getParameter<int>("hoSeverityLevel");
00116
00117 produces<HBHERecHitCollection>(hbheTag.label());
00118 produces<HFRecHitCollection>(hfTag.label());
00119 produces<HORecHitCollection>(hoTag.label());
00120
00121 }
00122
00123
00124 HcalHitSelection::~HcalHitSelection()
00125 {
00126
00127
00128
00129
00130 }
00131
00132
00133
00134
00135
00136
00137
00138 void
00139 HcalHitSelection::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00140 {
00141 iSetup.get<HcalChannelQualityRcd>().get(theHcalChStatus);
00142 iSetup.get<HcalSeverityLevelComputerRcd>().get(theHcalSevLvlComputer);
00143
00144 edm::Handle<HBHERecHitCollection> hbhe;
00145 edm::Handle<HFRecHitCollection> hf;
00146 edm::Handle<HORecHitCollection> ho;
00147
00148 iEvent.getByLabel(hbheTag,hbhe);
00149 iEvent.getByLabel(hfTag,hf);
00150 iEvent.getByLabel(hoTag,ho);
00151
00152 toBeKept.clear();
00153 edm::Handle<DetIdCollection > detId;
00154 for( unsigned int t = 0; t < interestingDetIdCollections.size(); ++t )
00155 {
00156 iEvent.getByLabel(interestingDetIdCollections[t],detId);
00157 if (!detId.isValid()){
00158 edm::LogError("MissingInput")<<"the collection of interesting detIds:"<<interestingDetIdCollections[t]<<" is not found.";
00159 continue;
00160 }
00161 toBeKept.insert(detId->begin(),detId->end());
00162 }
00163
00164 std::auto_ptr<HBHERecHitCollection> hbhe_out(new HBHERecHitCollection());
00165 skim(hbhe,hbhe_out);
00166 iEvent.put(hbhe_out,hbheTag.label());
00167
00168 std::auto_ptr<HFRecHitCollection> hf_out(new HFRecHitCollection());
00169 skim(hf,hf_out);
00170 iEvent.put(hf_out,hfTag.label());
00171
00172 std::auto_ptr<HORecHitCollection> ho_out(new HORecHitCollection());
00173 skim(ho,ho_out,hoSeverityLevel);
00174 iEvent.put(ho_out,hoTag.label());
00175
00176 }
00177
00178
00179 void
00180 HcalHitSelection::beginJob()
00181 {
00182 }
00183
00184
00185 void
00186 HcalHitSelection::endJob() {
00187 }
00188
00189
00190 DEFINE_FWK_MODULE(HcalHitSelection);