CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloParamsESProducer.cc
Go to the documentation of this file.
1 
12 //
13 //
14 
15 
16 
17 
18 // system include files
19 #include <memory>
20 #include "boost/shared_ptr.hpp"
21 #include <iostream>
22 #include <fstream>
23 
24 // user include files
30 
32 
35 
36 using namespace std;
37 
38 //
39 // class declaration
40 //
41 
42 namespace l1t {
43 
45 public:
48 
49  typedef boost::shared_ptr<CaloParams> ReturnType;
50 
51  ReturnType produce(const L1TCaloParamsRcd&);
52 
53 private:
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 //
63 // static data member definitions
64 //
65 
66 //
67 // constructors and destructor
68 //
69 CaloParamsESProducer::CaloParamsESProducer(const edm::ParameterSet& conf)
70 {
71 
72  //the following line is needed to tell the framework what
73  // data is being produced
74  setWhatProduced(this);
75  //setWhatProduced(this, conf.getParameter<std::string>("label"));
76 
77  // towers
78  m_params.setTowerLsbH(conf.getParameter<double>("towerLsbH"));
79  m_params.setTowerLsbE(conf.getParameter<double>("towerLsbE"));
80  m_params.setTowerLsbSum(conf.getParameter<double>("towerLsbSum"));
81  m_params.setTowerNBitsH(conf.getParameter<int>("towerNBitsH"));
82  m_params.setTowerNBitsE(conf.getParameter<int>("towerNBitsE"));
83  m_params.setTowerNBitsSum(conf.getParameter<int>("towerNBitsSum"));
84  m_params.setTowerNBitsRatio(conf.getParameter<int>("towerNBitsRatio"));
85  m_params.setTowerEncoding(conf.getParameter<bool>("towerEncoding"));
86 
87  // regions
88  m_params.setRegionLsb(conf.getParameter<double>("regionLsb"));
89  m_params.setRegionPUSType(conf.getParameter<std::string>("regionPUSType"));
90  m_params.setRegionPUSParams(conf.getParameter<std::vector<double> >("regionPUSParams"));
91 
92  // EG
93  m_params.setEgLsb(conf.getParameter<double>("egLsb"));
94  m_params.setEgSeedThreshold(conf.getParameter<double>("egSeedThreshold"));
95  m_params.setEgNeighbourThreshold(conf.getParameter<double>("egNeighbourThreshold"));
96  m_params.setEgHcalThreshold(conf.getParameter<double>("egHcalThreshold"));
97  m_params.setEgMaxHcalEt(conf.getParameter<double>("egMaxHcalEt"));
98  m_params.setEgEtToRemoveHECut(conf.getParameter<double>("egEtToRemoveHECut"));
99  m_params.setEgRelativeJetIsolationBarrelCut(conf.getParameter<double>("egRelativeJetIsolationBarrelCut"));
100  m_params.setEgRelativeJetIsolationEndcapCut(conf.getParameter<double>("egRelativeJetIsolationEndcapCut"));
101 
102  edm::FileInPath egMaxHOverELUTFile = conf.getParameter<edm::FileInPath>("egMaxHOverELUTFile");
103  std::ifstream egMaxHOverELUTStream(egMaxHOverELUTFile.fullPath());
104  std::shared_ptr<l1t::LUT> egMaxHOverELUT( new l1t::LUT(egMaxHOverELUTStream) );
105  m_params.setEgMaxHOverELUT(egMaxHOverELUT);
106 
107  edm::FileInPath egShapeIdLUTFile = conf.getParameter<edm::FileInPath>("egShapeIdLUTFile");
108  std::ifstream egShapeIdLUTStream(egShapeIdLUTFile.fullPath());
109  std::shared_ptr<l1t::LUT> egShapeIdLUT( new l1t::LUT(egShapeIdLUTStream) );
110  m_params.setEgShapeIdLUT(egShapeIdLUT);
111 
112  m_params.setEgIsoPUSType(conf.getParameter<std::string>("egIsoPUSType"));
113 
114  edm::FileInPath egIsoLUTFile = conf.getParameter<edm::FileInPath>("egIsoLUTFile");
115  std::ifstream egIsoLUTStream(egIsoLUTFile.fullPath());
116  std::shared_ptr<l1t::LUT> egIsoLUT( new l1t::LUT(egIsoLUTStream) );
117  m_params.setEgIsolationLUT(egIsoLUT);
118 
119  m_params.setEgIsoAreaNrTowersEta(conf.getParameter<unsigned int>("egIsoAreaNrTowersEta"));
120  m_params.setEgIsoAreaNrTowersPhi(conf.getParameter<unsigned int>("egIsoAreaNrTowersPhi"));
121  m_params.setEgIsoVetoNrTowersPhi(conf.getParameter<unsigned int>("egIsoVetoNrTowersPhi"));
122  m_params.setEgIsoPUEstTowerGranularity(conf.getParameter<unsigned int>("egIsoPUEstTowerGranularity"));
123  m_params.setEgIsoMaxEtaAbsForTowerSum(conf.getParameter<unsigned int>("egIsoMaxEtaAbsForTowerSum"));
124  m_params.setEgIsoMaxEtaAbsForIsoSum(conf.getParameter<unsigned int>("egIsoMaxEtaAbsForIsoSum"));
125 
126  edm::FileInPath egCalibrationLUTFile = conf.getParameter<edm::FileInPath>("egCalibrationLUTFile");
127  std::ifstream egCalibrationLUTStream(egCalibrationLUTFile.fullPath());
128  std::shared_ptr<l1t::LUT> egCalibrationLUT( new l1t::LUT(egCalibrationLUTStream) );
129  m_params.setEgCalibrationLUT(egCalibrationLUT);
130 
131  // tau
132  m_params.setTauLsb(conf.getParameter<double>("tauLsb"));
133  m_params.setTauSeedThreshold(conf.getParameter<double>("tauSeedThreshold"));
134  m_params.setTauNeighbourThreshold(conf.getParameter<double>("tauNeighbourThreshold"));
135  m_params.setSwitchOffTauVeto(conf.getParameter<double>("switchOffTauVeto"));
136  m_params.setSwitchOffTauIso(conf.getParameter<double>("switchOffTauIso"));
137  m_params.setTauIsoPUSType(conf.getParameter<std::string>("tauIsoPUSType"));
138  m_params.setTauRelativeJetIsolationLimit(conf.getParameter<double>("tauRelativeJetIsolationLimit"));
139  m_params.setTauRelativeJetIsolationCut(conf.getParameter<double>("tauRelativeJetIsolationCut"));
140 
141  edm::FileInPath tauIsoLUTFile = conf.getParameter<edm::FileInPath>("tauIsoLUTFile");
142  std::ifstream tauIsoLUTStream(tauIsoLUTFile.fullPath());
143  std::shared_ptr<l1t::LUT> tauIsoLUT( new l1t::LUT(tauIsoLUTStream) );
144  m_params.setTauIsolationLUT(tauIsoLUT);
145 
146  edm::FileInPath tauCalibrationLUTFileBarrelA = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileBarrelA");
147  edm::FileInPath tauCalibrationLUTFileBarrelB = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileBarrelB");
148  edm::FileInPath tauCalibrationLUTFileBarrelC = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileBarrelC");
149  edm::FileInPath tauCalibrationLUTFileEndcapsA = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileEndcapsA");
150  edm::FileInPath tauCalibrationLUTFileEndcapsB = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileEndcapsB");
151  edm::FileInPath tauCalibrationLUTFileEndcapsC = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileEndcapsC");
152  edm::FileInPath tauCalibrationLUTFileEta = conf.getParameter<edm::FileInPath>("tauCalibrationLUTFileEta");
153  std::ifstream tauCalibrationLUTStreamBarrelA(tauCalibrationLUTFileBarrelA.fullPath());
154  std::ifstream tauCalibrationLUTStreamBarrelB(tauCalibrationLUTFileBarrelB.fullPath());
155  std::ifstream tauCalibrationLUTStreamBarrelC(tauCalibrationLUTFileBarrelC.fullPath());
156  std::ifstream tauCalibrationLUTStreamEndcapsA(tauCalibrationLUTFileEndcapsA.fullPath());
157  std::ifstream tauCalibrationLUTStreamEndcapsB(tauCalibrationLUTFileEndcapsB.fullPath());
158  std::ifstream tauCalibrationLUTStreamEndcapsC(tauCalibrationLUTFileEndcapsC.fullPath());
159  std::ifstream tauCalibrationLUTStreamEta(tauCalibrationLUTFileEta.fullPath());
160  std::shared_ptr<l1t::LUT> tauCalibrationLUTBarrelA( new l1t::LUT(tauCalibrationLUTStreamBarrelA) );
161  std::shared_ptr<l1t::LUT> tauCalibrationLUTBarrelB( new l1t::LUT(tauCalibrationLUTStreamBarrelB) );
162  std::shared_ptr<l1t::LUT> tauCalibrationLUTBarrelC( new l1t::LUT(tauCalibrationLUTStreamBarrelC) );
163  std::shared_ptr<l1t::LUT> tauCalibrationLUTEndcapsA( new l1t::LUT(tauCalibrationLUTStreamEndcapsA) );
164  std::shared_ptr<l1t::LUT> tauCalibrationLUTEndcapsB( new l1t::LUT(tauCalibrationLUTStreamEndcapsB) );
165  std::shared_ptr<l1t::LUT> tauCalibrationLUTEndcapsC( new l1t::LUT(tauCalibrationLUTStreamEndcapsC) );
166  std::shared_ptr<l1t::LUT> tauCalibrationLUTEta( new l1t::LUT(tauCalibrationLUTStreamEta) );
167  m_params.setTauCalibrationLUTBarrelA(tauCalibrationLUTBarrelA);
168  m_params.setTauCalibrationLUTBarrelB(tauCalibrationLUTBarrelB);
169  m_params.setTauCalibrationLUTBarrelC(tauCalibrationLUTBarrelC);
170  m_params.setTauCalibrationLUTEndcapsA(tauCalibrationLUTEndcapsA);
171  m_params.setTauCalibrationLUTEndcapsB(tauCalibrationLUTEndcapsB);
172  m_params.setTauCalibrationLUTEndcapsC(tauCalibrationLUTEndcapsC);
173  m_params.setTauCalibrationLUTEta(tauCalibrationLUTEta);
174 
175  // jets
176  m_params.setJetLsb(conf.getParameter<double>("jetLsb"));
177  m_params.setJetSeedThreshold(conf.getParameter<double>("jetSeedThreshold"));
178  m_params.setJetNeighbourThreshold(conf.getParameter<double>("jetNeighbourThreshold"));
179  m_params.setJetPUSType(conf.getParameter<std::string>("jetPUSType"));
180  m_params.setJetCalibrationType(conf.getParameter<std::string>("jetCalibrationType"));
181  m_params.setJetCalibrationParams(conf.getParameter<std::vector<double> >("jetCalibrationParams"));
182 
183  // sums
184  m_params.setEtSumLsb(conf.getParameter<double>("etSumLsb"));
185 
186  std::vector<int> etSumEtaMin = conf.getParameter<std::vector<int> >("etSumEtaMin");
187  std::vector<int> etSumEtaMax = conf.getParameter<std::vector<int> >("etSumEtaMax");
188  std::vector<double> etSumEtThreshold = conf.getParameter<std::vector<double> >("etSumEtThreshold");
189 
190  if ((etSumEtaMin.size() == etSumEtaMax.size()) && (etSumEtaMin.size() == etSumEtThreshold.size())) {
191  for (unsigned i=0; i<etSumEtaMin.size(); ++i) {
192  m_params.setEtSumEtaMin(i, etSumEtaMin.at(i));
193  m_params.setEtSumEtaMax(i, etSumEtaMax.at(i));
194  m_params.setEtSumEtThreshold(i, etSumEtThreshold.at(i));
195  }
196  }
197  else {
198  edm::LogError("l1t|calo") << "Inconsistent number of EtSum parameters" << std::endl;
199  }
200 
201 }
202 
203 
204 CaloParamsESProducer::~CaloParamsESProducer()
205 {
206 
207  // do anything here that needs to be done at desctruction time
208  // (e.g. close files, deallocate resources etc.)
209 
210 }
211 
212 
213 //
214 // member functions
215 //
216 
217 // ------------ method called to produce the data ------------
219 CaloParamsESProducer::produce(const L1TCaloParamsRcd& iRecord)
220 {
221  using namespace edm::es;
222  boost::shared_ptr<CaloParams> pCaloParams ;
223 
224  pCaloParams = boost::shared_ptr< CaloParams >(new CaloParams(m_params));
225  return pCaloParams;
226 }
227 
228 }
229 
230 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
boost::shared_ptr< CaloParams > ReturnType
tuple conf
Definition: dbtoconf.py:185
Definition: LUT.h:27
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::string fullPath() const
Definition: FileInPath.cc:165