CMS 3D CMS Logo

HcalRealisticZS.cc
Go to the documentation of this file.
1 #include "HcalRealisticZS.h"
9 
10 #include <iostream>
11 
13  inputLabel_(conf.getParameter<std::string>("digiLabel")) {
14 
15  bool markAndPass=conf.getParameter<bool>("markAndPass");
16  bool useInstanceLabels=conf.getParameter<bool>("useInstanceLabels");
17 
18  // register for data access
19  tok_hbhe_ = consumes<HBHEDigiCollection>(edm::InputTag(inputLabel_));
20  tok_ho_ = consumes<HODigiCollection>(edm::InputTag(inputLabel_));
21  tok_hf_ = consumes<HFDigiCollection>(edm::InputTag(inputLabel_));
22  tok_hfQIE10_ = consumes<QIE10DigiCollection>(edm::InputTag(inputLabel_,
23  useInstanceLabels ? "HFQIE10DigiCollection" : "" ));
24  tok_hbheQIE11_ = consumes<QIE11DigiCollection>(edm::InputTag(inputLabel_,
25  useInstanceLabels ? "HBHEQIE11DigiCollection" : ""));
26 
27 
28  std::vector<int> tmp = conf.getParameter<std::vector<int> >("HBregion");
29 
30  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
31  edm::LogError("HcalZeroSuppression") << "ZS(HB) region error: "
32  << tmp[0] << ":" <<tmp[1];
33  tmp[0]=0; tmp[1]=9;
34  }
35 
36  std::pair<int,int> HBsearchTS (tmp[0],tmp[1]);
37 
38  tmp = conf.getParameter<std::vector<int> >("HEregion");
39  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
40  edm::LogError("HcalZeroSuppression") << "ZS(HE) region error: "
41  << tmp[0] << ":" <<tmp[1];
42  tmp[0]=0; tmp[1]=9;
43  }
44  std::pair<int,int> HEsearchTS (tmp[0],tmp[1]);
45 
46  tmp = conf.getParameter<std::vector<int> >("HOregion");
47  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
48  edm::LogError("HcalZeroSuppression") << "ZS(HO) region error: "
49  << tmp[0] << ":" <<tmp[1];
50  tmp[0]=0; tmp[1]=9;
51  }
52  std::pair<int,int> HOsearchTS (tmp[0],tmp[1]);
53 
54  tmp = conf.getParameter<std::vector<int> >("HFregion");
55  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
56  edm::LogError("HcalZeroSuppression") << "ZS(HF) region error: "
57  << tmp[0] << ":" <<tmp[1];
58  tmp[0]=0; tmp[1]=9;
59  }
60  std::pair<int,int> HFsearchTS (tmp[0],tmp[1]);
61 
62 
63  //this constructor will be called if useConfigZSvalues is set to 1 in
64  //HcalZeroSuppressionProducers/python/hcalDigisRealistic_cfi.py
65  //which means that channel-by-channel ZS thresholds from DB will NOT be used
66  if ( conf.getParameter<int>("useConfigZSvalues") ) {
67 
68  algo_.reset(
69  new HcalZSAlgoRealistic (markAndPass,
70  conf.getParameter<int>("HBlevel"),
71  conf.getParameter<int>("HElevel"),
72  conf.getParameter<int>("HOlevel"),
73  conf.getParameter<int>("HFlevel"),
74  HBsearchTS,
75  HEsearchTS,
76  HOsearchTS,
77  HFsearchTS
78  ));
79 
80  } else {
81 
82  algo_.reset(
83  new HcalZSAlgoRealistic(markAndPass,
84  HBsearchTS,
85  HEsearchTS,
86  HOsearchTS,
87  HFsearchTS));
88  }
89 
90  produces<HBHEDigiCollection>();
91  produces<HODigiCollection>();
92  produces<HFDigiCollection>();
93  produces<QIE10DigiCollection>("HFQIE10DigiCollection");
94  produces<QIE11DigiCollection>("HBHEQIE11DigiCollection");
95 
96 }
97 
99  algo_->clearDbService();
100 }
101 
103 {
104 
110 
111  edm::ESHandle<HcalDbService> conditions;
112  eventSetup.get<HcalDbRecord>().get(conditions);
113  algo_->setDbService(conditions.product());
114 
115  e.getByToken(tok_hbhe_,hbhe);
116 
117  // create empty output
118  std::unique_ptr<HBHEDigiCollection> zs_hbhe(new HBHEDigiCollection);
119 
120  e.getByToken(tok_ho_,ho);
121 
122  // create empty output
123  std::unique_ptr<HODigiCollection> zs_ho(new HODigiCollection);
124 
125  e.getByToken(tok_hf_,hf);
126 
127  // create empty output
128  std::unique_ptr<HFDigiCollection> zs_hf(new HFDigiCollection);
129 
130  e.getByToken(tok_hfQIE10_,hfQIE10);
131  e.getByToken(tok_hbheQIE11_,hbheQIE11);
132 
133  // create empty output
134  std::unique_ptr<HBHEDigiCollection> zs_hbheUpgrade(new HBHEDigiCollection);
135  std::unique_ptr<HFDigiCollection> zs_hfUpgrade(new HFDigiCollection);
136  std::unique_ptr<QIE10DigiCollection> zs_hfQIE10(new QIE10DigiCollection(hfQIE10->samples()));
137  std::unique_ptr<QIE11DigiCollection> zs_hbheQIE11(new QIE11DigiCollection(hbheQIE11->samples()));
138 
139  //run the algorithm
140  algo_->suppress(*(hbhe.product()),*zs_hbhe);
141  algo_->suppress(*(ho.product()),*zs_ho);
142  algo_->suppress(*(hf.product()),*zs_hf);
143  algo_->suppress(*(hfQIE10.product()),*zs_hfQIE10);
144  algo_->suppress(*(hbheQIE11.product()),*zs_hbheQIE11);
145 
146 
147  edm::LogInfo("HcalZeroSuppression") << "Suppression (HBHE) input " << hbhe->size() << " digis, output " << zs_hbhe->size() << " digis"
148  << " (HO) input " << ho->size() << " digis, output " << zs_ho->size() << " digis"
149  << " (HF) input " << hf->size() << " digis, output " << zs_hf->size() << " digis"
150  << " (HFQIE10) input " << hfQIE10->size() << " digis, output " << zs_hfQIE10->size() << " digis"
151  << " (HBHEQIE11) input " << hbheQIE11->size() << " digis, output " << zs_hbheQIE11->size() << " digis";
152 
153 
154  // return result
155  e.put(std::move(zs_hbhe));
156  e.put(std::move(zs_ho));
157  e.put(std::move(zs_hf));
158  e.put(std::move(zs_hfQIE10),"HFQIE10DigiCollection");
159  e.put(std::move(zs_hbheQIE11),"HBHEQIE11DigiCollection");
160 
161 }
T getParameter(std::string const &) const
edm::EDGetTokenT< HODigiCollection > tok_ho_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::unique_ptr< HcalZSAlgoRealistic > algo_
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
HcalDataFrameContainer< QIE10DataFrame > QIE10DigiCollection
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
std::string inputLabel_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
~HcalRealisticZS() override
HcalDataFrameContainer< QIE11DataFrame > QIE11DigiCollection
T const * product() const
Definition: Handle.h:81
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
size_type size() const
T get() const
Definition: EventSetup.h:63
edm::EDGetTokenT< QIE11DigiCollection > tok_hbheQIE11_
void produce(edm::Event &e, const edm::EventSetup &c) override
HcalRealisticZS(const edm::ParameterSet &ps)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510