CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_hbheUpgrade_ = consumes<HBHEUpgradeDigiCollection>(edm::InputTag(inputLabel_, "HBHEUpgradeDigiCollection"));
22  tok_hfUpgrade_ = consumes<HFUpgradeDigiCollection>(edm::InputTag(inputLabel_, "HFUpgradeDigiCollection"));
23  tok_hfQIE10_ = consumes<QIE10DigiCollection>(edm::InputTag(inputLabel_, "HFQIE10DigiCollection"));
24 
25 
26  std::vector<int> tmp = conf.getParameter<std::vector<int> >("HBregion");
27 
28  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
29  edm::LogError("HcalZeroSuppression") << "ZS(HB) region error: "
30  << tmp[0] << ":" <<tmp[1];
31  tmp[0]=0; tmp[1]=9;
32  }
33 
34  std::pair<int,int> HBsearchTS (tmp[0],tmp[1]);
35 
36  tmp = conf.getParameter<std::vector<int> >("HEregion");
37  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
38  edm::LogError("HcalZeroSuppression") << "ZS(HE) region error: "
39  << tmp[0] << ":" <<tmp[1];
40  tmp[0]=0; tmp[1]=9;
41  }
42  std::pair<int,int> HEsearchTS (tmp[0],tmp[1]);
43 
44  tmp = conf.getParameter<std::vector<int> >("HOregion");
45  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
46  edm::LogError("HcalZeroSuppression") << "ZS(HO) region error: "
47  << tmp[0] << ":" <<tmp[1];
48  tmp[0]=0; tmp[1]=9;
49  }
50  std::pair<int,int> HOsearchTS (tmp[0],tmp[1]);
51 
52  tmp = conf.getParameter<std::vector<int> >("HFregion");
53  if(tmp[0]<0 || tmp[0]>9 || tmp[1]<0 || tmp[1]>9 || tmp[0]>tmp[1]) {
54  edm::LogError("HcalZeroSuppression") << "ZS(HF) region error: "
55  << tmp[0] << ":" <<tmp[1];
56  tmp[0]=0; tmp[1]=9;
57  }
58  std::pair<int,int> HFsearchTS (tmp[0],tmp[1]);
59 
60 
61  //this constructor will be called if useConfigZSvalues is set to 1 in
62  //HcalZeroSuppressionProducers/python/hcalDigisRealistic_cfi.py
63  //which means that channel-by-channel ZS thresholds from DB will NOT be used
64  if ( conf.getParameter<int>("useConfigZSvalues") ) {
65 
66  algo_.reset(
67  new HcalZSAlgoRealistic (markAndPass,
68  conf.getParameter<int>("HBlevel"),
69  conf.getParameter<int>("HElevel"),
70  conf.getParameter<int>("HOlevel"),
71  conf.getParameter<int>("HFlevel"),
72  HBsearchTS,
73  HEsearchTS,
74  HOsearchTS,
75  HFsearchTS
76  ));
77 
78  } else {
79 
80  algo_.reset(
81  new HcalZSAlgoRealistic(markAndPass,
82  HBsearchTS,
83  HEsearchTS,
84  HOsearchTS,
85  HFsearchTS));
86  }
87 
88  produces<HBHEDigiCollection>();
89  produces<HODigiCollection>();
90  produces<HFDigiCollection>();
91  produces<HBHEUpgradeDigiCollection>("HBHEUpgradeDigiCollection");
92  produces<HFUpgradeDigiCollection>("HFUpgradeDigiCollection");
93  produces<QIE10DigiCollection>("HFQIE10DigiCollection");
94 
95 }
96 
98  algo_->clearDbService();
99 }
100 
102 {
103 
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::auto_ptr<HBHEDigiCollection> zs_hbhe(new HBHEDigiCollection);
119 
120  e.getByToken(tok_ho_,ho);
121 
122  // create empty output
123  std::auto_ptr<HODigiCollection> zs_ho(new HODigiCollection);
124 
125  e.getByToken(tok_hf_,hf);
126 
127  // create empty output
128  std::auto_ptr<HFDigiCollection> zs_hf(new HFDigiCollection);
129 
130  e.getByToken(tok_hbheUpgrade_,hbheUpgrade);
131  e.getByToken(tok_hfUpgrade_,hfUpgrade);
132  e.getByToken(tok_hfQIE10_,hfQIE10);
133 
134  // create empty output
135  std::auto_ptr<HBHEUpgradeDigiCollection> zs_hbheUpgrade(new HBHEUpgradeDigiCollection);
136  std::auto_ptr<HFUpgradeDigiCollection> zs_hfUpgrade(new HFUpgradeDigiCollection);
137  std::auto_ptr<QIE10DigiCollection> zs_hfQIE10(new QIE10DigiCollection);
138 
139  //run the algorithm
140 
141  algo_->suppress(*(hbhe.product()),*zs_hbhe);
142  algo_->suppress(*(ho.product()),*zs_ho);
143  algo_->suppress(*(hf.product()),*zs_hf);
144  algo_->suppress(*(hbheUpgrade.product()),*zs_hbheUpgrade);
145  algo_->suppress(*(hfUpgrade.product()),*zs_hfUpgrade);
146  algo_->suppress(*(hfQIE10.product()),*zs_hfQIE10);
147 
148 
149  edm::LogInfo("HcalZeroSuppression") << "Suppression (HBHE) input " << hbhe->size() << " digis, output " << zs_hbhe->size() << " digis"
150  << " (HO) input " << ho->size() << " digis, output " << zs_ho->size() << " digis"
151  << " (HF) input " << hf->size() << " digis, output " << zs_hf->size() << " digis"
152  << " (HBHEUpgrade) input " << hbheUpgrade->size() << " digis, output " << zs_hbheUpgrade->size() << " digis"
153  << " (HFUpgrade) input " << hfUpgrade->size() << " digis, output " << zs_hfUpgrade->size() << " digis"
154  << " (HFQIE10) input " << hfQIE10->size() << " digis, output " << zs_hfQIE10->size() << " digis";
155 
156 
157  // return result
158  e.put(zs_hbhe);
159  e.put(zs_ho);
160  e.put(zs_hf);
161  e.put(zs_hbheUpgrade,"HBHEUpgradeDigiCollection");
162  e.put(zs_hfUpgrade,"HFUpgradeDigiCollection");
163  e.put(zs_hfQIE10,"HFQIE10DigiCollection");
164 
165 }
T getParameter(std::string const &) const
edm::EDGetTokenT< HODigiCollection > tok_ho_
virtual ~HcalRealisticZS()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::unique_ptr< HcalZSAlgoRealistic > algo_
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
edm::EDGetTokenT< HFUpgradeDigiCollection > tok_hfUpgrade_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
edm::EDGetTokenT< HBHEUpgradeDigiCollection > tok_hbheUpgrade_
std::string inputLabel_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
HcalRealisticZS(const edm::ParameterSet &ps)