Go to the documentation of this file.00001 #include "SimCalorimetry/HcalZeroSuppressionProducers/src/HcalRealisticZS.h"
00002 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00003 #include "DataFormats/Common/interface/EDCollection.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 #include "FWCore/Framework/interface/Selector.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00011
00012 using namespace std;
00013
00014 #include <iostream>
00015
00016 HcalRealisticZS::HcalRealisticZS(edm::ParameterSet const& conf):
00017 inputLabel_(conf.getParameter<edm::InputTag>("digiLabel"))
00018 {
00019 bool markAndPass=conf.getParameter<bool>("markAndPass");
00020
00021
00022 std::vector<int> tmp = conf.getParameter<std::vector<int> >("HBregion");
00023
00024 if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
00025 edm::LogError("HcalZeroSuppression") << "ZS(HB) region error: "
00026 << tmp[0] << ":" <<tmp[1];
00027 tmp[0]=0; tmp[1]=9;
00028 }
00029
00030 std::pair<int,int> HBsearchTS (tmp[0],tmp[1]);
00031
00032 tmp = conf.getParameter<std::vector<int> >("HEregion");
00033 if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
00034 edm::LogError("HcalZeroSuppression") << "ZS(HE) region error: "
00035 << tmp[0] << ":" <<tmp[1];
00036 tmp[0]=0; tmp[1]=9;
00037 }
00038 std::pair<int,int> HEsearchTS (tmp[0],tmp[1]);
00039
00040 tmp = conf.getParameter<std::vector<int> >("HOregion");
00041 if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
00042 edm::LogError("HcalZeroSuppression") << "ZS(HO) region error: "
00043 << tmp[0] << ":" <<tmp[1];
00044 tmp[0]=0; tmp[1]=9;
00045 }
00046 std::pair<int,int> HOsearchTS (tmp[0],tmp[1]);
00047
00048 tmp = conf.getParameter<std::vector<int> >("HFregion");
00049 if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
00050 edm::LogError("HcalZeroSuppression") << "ZS(HF) region error: "
00051 << tmp[0] << ":" <<tmp[1];
00052 tmp[0]=0; tmp[1]=9;
00053 }
00054 std::pair<int,int> HFsearchTS (tmp[0],tmp[1]);
00055
00056
00057
00058
00059
00060 if ( conf.getParameter<int>("useConfigZSvalues") ) {
00061
00062 algo_=std::auto_ptr<HcalZSAlgoRealistic>
00063 (new HcalZSAlgoRealistic (markAndPass,
00064 conf.getParameter<int>("HBlevel"),
00065 conf.getParameter<int>("HElevel"),
00066 conf.getParameter<int>("HOlevel"),
00067 conf.getParameter<int>("HFlevel"),
00068 HBsearchTS,
00069 HEsearchTS,
00070 HOsearchTS,
00071 HFsearchTS
00072 ));
00073
00074 }
00075 else {
00076
00077 algo_=std::auto_ptr<HcalZSAlgoRealistic>
00078 (new HcalZSAlgoRealistic(markAndPass,
00079 HBsearchTS,
00080 HEsearchTS,
00081 HOsearchTS,
00082 HFsearchTS));
00083 }
00084
00085 produces<HBHEDigiCollection>();
00086 produces<HODigiCollection>();
00087 produces<HFDigiCollection>();
00088
00089 }
00090
00091 HcalRealisticZS::~HcalRealisticZS() {
00092 algo_->clearDbService();
00093 }
00094
00095 void HcalRealisticZS::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00096 {
00097
00098 edm::Handle<HBHEDigiCollection> hbhe;
00099 edm::Handle<HODigiCollection> ho;
00100 edm::Handle<HFDigiCollection> hf;
00101
00102 edm::ESHandle<HcalDbService> conditions;
00103 eventSetup.get<HcalDbRecord>().get(conditions);
00104 algo_->setDbService(conditions.product());
00105
00106 e.getByLabel(inputLabel_,hbhe);
00107
00108
00109 std::auto_ptr<HBHEDigiCollection> zs_hbhe(new HBHEDigiCollection);
00110
00111 e.getByLabel(inputLabel_,ho);
00112
00113
00114 std::auto_ptr<HODigiCollection> zs_ho(new HODigiCollection);
00115
00116 e.getByLabel(inputLabel_,hf);
00117
00118
00119 std::auto_ptr<HFDigiCollection> zs_hf(new HFDigiCollection);
00120
00121
00122
00123 algo_->suppress(*(hbhe.product()),*zs_hbhe);
00124 algo_->suppress(*(ho.product()),*zs_ho);
00125 algo_->suppress(*(hf.product()),*zs_hf);
00126
00127
00128 edm::LogInfo("HcalZeroSuppression") << "Suppression (HBHE) input " << hbhe->size() << " digis, output " << zs_hbhe->size() << " digis"
00129 << " (HO) input " << ho->size() << " digis, output " << zs_ho->size() << " digis"
00130 << " (HF) input " << hf->size() << " digis, output " << zs_hf->size() << " digis";
00131
00132
00133
00134 e.put(zs_hbhe);
00135 e.put(zs_ho);
00136 e.put(zs_hf);
00137
00138 }