CMS 3D CMS Logo

HcalRealisticZS.cc
Go to the documentation of this file.
1 
19 
20 #include <iostream>
21 #include <memory>
22 #include <string>
23 
25 public:
26  explicit HcalRealisticZS(const edm::ParameterSet &ps);
27  ~HcalRealisticZS() override;
28  void produce(edm::Event &e, const edm::EventSetup &c) override;
29 
30 private:
31  std::unique_ptr<HcalZSAlgoRealistic> algo_;
39 };
40 
42  : inputLabel_(conf.getParameter<std::string>("digiLabel")) {
43  bool markAndPass = conf.getParameter<bool>("markAndPass");
44  bool useInstanceLabels = conf.getParameter<bool>("useInstanceLabels");
45 
46  // register for data access
47  tok_hbhe_ = consumes<HBHEDigiCollection>(edm::InputTag(inputLabel_));
48  tok_ho_ = consumes<HODigiCollection>(edm::InputTag(inputLabel_));
49  tok_hf_ = consumes<HFDigiCollection>(edm::InputTag(inputLabel_));
50  tok_hfQIE10_ =
51  consumes<QIE10DigiCollection>(edm::InputTag(inputLabel_, useInstanceLabels ? "HFQIE10DigiCollection" : ""));
53  consumes<QIE11DigiCollection>(edm::InputTag(inputLabel_, useInstanceLabels ? "HBHEQIE11DigiCollection" : ""));
54  tok_dbService_ = esConsumes<HcalDbService, HcalDbRecord>();
55 
56  bool use1ts_ = conf.getParameter<bool>("use1ts");
57 
58  std::vector<int> tmp = conf.getParameter<std::vector<int>>("HBregion");
59 
60  if (tmp[0] < 0 || tmp[0] > 9 || tmp[1] < 0 || tmp[1] > 9 || tmp[0] > tmp[1]) {
61  edm::LogError("HcalZeroSuppression") << "ZS(HB) region error: " << tmp[0] << ":" << tmp[1];
62  tmp[0] = 0;
63  tmp[1] = 9;
64  }
65 
66  std::pair<int, int> HBsearchTS(tmp[0], tmp[1]);
67 
68  tmp = conf.getParameter<std::vector<int>>("HEregion");
69  if (tmp[0] < 0 || tmp[0] > 9 || tmp[1] < 0 || tmp[1] > 9 || tmp[0] > tmp[1]) {
70  edm::LogError("HcalZeroSuppression") << "ZS(HE) region error: " << tmp[0] << ":" << tmp[1];
71  tmp[0] = 0;
72  tmp[1] = 9;
73  }
74  std::pair<int, int> HEsearchTS(tmp[0], tmp[1]);
75 
76  tmp = conf.getParameter<std::vector<int>>("HOregion");
77  if (tmp[0] < 0 || tmp[0] > 9 || tmp[1] < 0 || tmp[1] > 9 || tmp[0] > tmp[1]) {
78  edm::LogError("HcalZeroSuppression") << "ZS(HO) region error: " << tmp[0] << ":" << tmp[1];
79  tmp[0] = 0;
80  tmp[1] = 9;
81  }
82  std::pair<int, int> HOsearchTS(tmp[0], tmp[1]);
83 
84  tmp = conf.getParameter<std::vector<int>>("HFregion");
85  if (tmp[0] < 0 || tmp[0] > 9 || tmp[1] < 0 || tmp[1] > 9 || tmp[0] > tmp[1]) {
86  edm::LogError("HcalZeroSuppression") << "ZS(HF) region error: " << tmp[0] << ":" << tmp[1];
87  tmp[0] = 0;
88  tmp[1] = 9;
89  }
90  std::pair<int, int> HFsearchTS(tmp[0], tmp[1]);
91 
92  // this constructor will be called if useConfigZSvalues is set to 1 in
93  // HcalZeroSuppressionProducers/python/hcalDigisRealistic_cfi.py
94  // which means that channel-by-channel ZS thresholds from DB will NOT be used
95  if (conf.getParameter<int>("useConfigZSvalues")) {
96  algo_ = std::make_unique<HcalZSAlgoRealistic>(markAndPass,
97  use1ts_,
98  conf.getParameter<int>("HBlevel"),
99  conf.getParameter<int>("HElevel"),
100  conf.getParameter<int>("HOlevel"),
101  conf.getParameter<int>("HFlevel"),
102  HBsearchTS,
103  HEsearchTS,
104  HOsearchTS,
105  HFsearchTS);
106 
107  } else {
108  algo_ = std::make_unique<HcalZSAlgoRealistic>(markAndPass, use1ts_, HBsearchTS, HEsearchTS, HOsearchTS, HFsearchTS);
109  }
110 
111  produces<HBHEDigiCollection>();
112  produces<HODigiCollection>();
113  produces<HFDigiCollection>();
114  produces<QIE10DigiCollection>("HFQIE10DigiCollection");
115  produces<QIE11DigiCollection>("HBHEQIE11DigiCollection");
116 }
117 
118 HcalRealisticZS::~HcalRealisticZS() { algo_->clearDbService(); }
119 
126 
128  algo_->setDbService(conditions.product());
129 
130  e.getByToken(tok_hbhe_, hbhe);
131 
132  // create empty output
133  std::unique_ptr<HBHEDigiCollection> zs_hbhe(new HBHEDigiCollection);
134 
135  e.getByToken(tok_ho_, ho);
136 
137  // create empty output
138  std::unique_ptr<HODigiCollection> zs_ho(new HODigiCollection);
139 
140  e.getByToken(tok_hf_, hf);
141 
142  // create empty output
143  std::unique_ptr<HFDigiCollection> zs_hf(new HFDigiCollection);
144 
145  e.getByToken(tok_hfQIE10_, hfQIE10);
146  e.getByToken(tok_hbheQIE11_, hbheQIE11);
147 
148  // create empty output
149  std::unique_ptr<HBHEDigiCollection> zs_hbheUpgrade(new HBHEDigiCollection);
150  std::unique_ptr<HFDigiCollection> zs_hfUpgrade(new HFDigiCollection);
151  std::unique_ptr<QIE10DigiCollection> zs_hfQIE10(new QIE10DigiCollection(hfQIE10->samples()));
152  std::unique_ptr<QIE11DigiCollection> zs_hbheQIE11(new QIE11DigiCollection(hbheQIE11->samples()));
153 
154  // run the algorithm
155  algo_->suppress(*(hbhe.product()), *zs_hbhe);
156  algo_->suppress(*(ho.product()), *zs_ho);
157  algo_->suppress(*(hf.product()), *zs_hf);
158  algo_->suppress(*(hfQIE10.product()), *zs_hfQIE10);
159  algo_->suppress(*(hbheQIE11.product()), *zs_hbheQIE11);
160 
161  edm::LogInfo("HcalZeroSuppression") << "Suppression (HBHE) input " << hbhe->size() << " digis, output "
162  << zs_hbhe->size() << " digis"
163  << " (HO) input " << ho->size() << " digis, output " << zs_ho->size() << " digis"
164  << " (HF) input " << hf->size() << " digis, output " << zs_hf->size() << " digis"
165  << " (HFQIE10) input " << hfQIE10->size() << " digis, output "
166  << zs_hfQIE10->size() << " digis"
167  << " (HBHEQIE11) input " << hbheQIE11->size() << " digis, output "
168  << zs_hbheQIE11->size() << " digis";
169 
170  // return result
171  e.put(std::move(zs_hbhe));
172  e.put(std::move(zs_ho));
173  e.put(std::move(zs_hf));
174  e.put(std::move(zs_hfQIE10), "HFQIE10DigiCollection");
175  e.put(std::move(zs_hbheQIE11), "HBHEQIE11DigiCollection");
176 }
177 
180 
edm::EDGetTokenT< HODigiCollection > tok_ho_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< HcalDbService, HcalDbRecord > tok_dbService_
std::unique_ptr< HcalZSAlgoRealistic > algo_
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
Log< level::Error, false > LogError
HcalDataFrameContainer< QIE10DataFrame > QIE10DigiCollection
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string inputLabel_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
~HcalRealisticZS() override
HcalDataFrameContainer< QIE11DataFrame > QIE11DigiCollection
Log< level::Info, false > LogInfo
edm::EDGetTokenT< QIE11DigiCollection > tok_hbheQIE11_
void produce(edm::Event &e, const edm::EventSetup &c) override
tmp
align.sh
Definition: createJobs.py:716
HcalRealisticZS(const edm::ParameterSet &ps)
def move(src, dest)
Definition: eostools.py:511