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