CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelDynamicInefficiencyDB.cc
Go to the documentation of this file.
1 // system includes
2 #include <memory>
3 #include <string>
4 #include <iostream>
5 #include <fstream>
6 #include <limits>
7 #include <map>
8 
9 // user includes
27 
29 public:
30  explicit SiPixelDynamicInefficiencyDB(const edm::ParameterSet& conf);
31 
33  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
34 
35 private:
39 
40  typedef std::vector<edm::ParameterSet> Parameters;
46 };
47 
48 using namespace std;
49 using namespace edm;
50 
51 //Constructor
52 
54  : tkTopoToken_(esConsumes()), conf_(conf) {
55  recordName_ = conf_.getUntrackedParameter<std::string>("record", "SiPixelDynamicInefficiencyRcd");
60  theInstLumiScaleFactor_ = conf_.getUntrackedParameter<double>("theInstLumiScaleFactor");
61 }
62 
63 // Virtual destructor needed.
65 
66 // Analyzer: Functions that gets called by framework every event
67 
69  SiPixelDynamicInefficiency DynamicInefficiency;
70 
71  //Retrieve tracker topology from geometry
72  const TrackerTopology* const tTopo = &es.getData(tkTopoToken_);
73 
75  uint32_t mask;
76  uint32_t layer, LAYER = 0;
77  uint32_t ladder, LADDER = 0;
78  uint32_t module, MODULE = 0;
79  uint32_t side, SIDE = 0;
80  uint32_t disk, DISK = 0;
81  uint32_t blade, BLADE = 0;
82  uint32_t panel, PANEL = 0;
83 
84  //Put BPix masks
85  mask = tTopo->pxbDetId(max, LADDER, MODULE).rawId();
86  DynamicInefficiency.putDetIdmask(mask);
87  mask = tTopo->pxbDetId(LAYER, max, MODULE).rawId();
88  DynamicInefficiency.putDetIdmask(mask);
89  mask = tTopo->pxbDetId(LAYER, LADDER, max).rawId();
90  DynamicInefficiency.putDetIdmask(mask);
91  //Put FPix masks
92  mask = tTopo->pxfDetId(max, DISK, BLADE, PANEL, MODULE).rawId();
93  DynamicInefficiency.putDetIdmask(mask);
94  mask = tTopo->pxfDetId(SIDE, max, BLADE, PANEL, MODULE).rawId();
95  DynamicInefficiency.putDetIdmask(mask);
96  mask = tTopo->pxfDetId(SIDE, DISK, max, PANEL, MODULE).rawId();
97  DynamicInefficiency.putDetIdmask(mask);
98  mask = tTopo->pxfDetId(SIDE, DISK, BLADE, max, MODULE).rawId();
99  DynamicInefficiency.putDetIdmask(mask);
100  mask = tTopo->pxfDetId(SIDE, DISK, BLADE, PANEL, max).rawId();
101  DynamicInefficiency.putDetIdmask(mask);
102 
103  //Put PixelGeomFactors
104  for (Parameters::iterator it = thePixelGeomFactors_.begin(); it != thePixelGeomFactors_.end(); ++it) {
105  string det = it->getParameter<string>("det");
106  it->exists("layer") ? layer = it->getParameter<unsigned int>("layer") : layer = LAYER;
107  it->exists("ladder") ? ladder = it->getParameter<unsigned int>("ladder") : ladder = LADDER;
108  it->exists("module") ? module = it->getParameter<unsigned int>("module") : module = MODULE;
109  it->exists("side") ? side = it->getParameter<unsigned int>("side") : side = SIDE;
110  it->exists("disk") ? disk = it->getParameter<unsigned int>("disk") : disk = DISK;
111  it->exists("blade") ? blade = it->getParameter<unsigned int>("blade") : blade = BLADE;
112  it->exists("panel") ? panel = it->getParameter<unsigned int>("panel") : panel = PANEL;
113  double factor = it->getParameter<double>("factor");
114  if (det == "bpix") {
115  DetId detID = tTopo->pxbDetId(layer, ladder, module);
116  edm::LogPrint("SiPixelDynamicInefficiencyDB") << "Putting Pixel geom BPix layer " << layer << " ladder " << ladder
117  << " module " << module << " factor " << factor << std::endl;
118  DynamicInefficiency.putPixelGeomFactor(detID.rawId(), factor);
119  } else if (det == "fpix") {
120  DetId detID = tTopo->pxfDetId(side, disk, blade, panel, module);
121  edm::LogPrint("SiPixelDynamicInefficiencyDB")
122  << "Putting Pixel geom FPix side " << side << " disk " << disk << " blade " << blade << " panel " << panel
123  << " module " << module << " factor " << factor << std::endl;
124  DynamicInefficiency.putPixelGeomFactor(detID.rawId(), factor);
125  } else
126  edm::LogError("SiPixelDynamicInefficiencyDB")
127  << "SiPixelDynamicInefficiencyDB input detector part is neither bpix nor fpix" << std::endl;
128  }
129 
130  //Put ColumnGeomFactors
131  for (Parameters::iterator it = theColGeomFactors_.begin(); it != theColGeomFactors_.end(); ++it) {
132  string det = it->getParameter<string>("det");
133  it->exists("layer") ? layer = it->getParameter<unsigned int>("layer") : layer = LAYER;
134  it->exists("ladder") ? ladder = it->getParameter<unsigned int>("ladder") : ladder = LADDER;
135  it->exists("module") ? module = it->getParameter<unsigned int>("module") : module = MODULE;
136  it->exists("side") ? side = it->getParameter<unsigned int>("side") : side = SIDE;
137  it->exists("disk") ? disk = it->getParameter<unsigned int>("disk") : disk = DISK;
138  it->exists("blade") ? blade = it->getParameter<unsigned int>("blade") : blade = BLADE;
139  it->exists("panel") ? panel = it->getParameter<unsigned int>("panel") : panel = PANEL;
140  double factor = it->getParameter<double>("factor");
141  if (det == "bpix") {
142  DetId detID = tTopo->pxbDetId(layer, ladder, module);
143  edm::LogPrint("SiPixelDynamicInefficiencyDB")
144  << "Putting Column geom BPix layer " << layer << " ladder " << ladder << " module " << module << " factor "
145  << factor << std::endl;
146  DynamicInefficiency.putColGeomFactor(detID.rawId(), factor);
147  } else if (det == "fpix") {
148  DetId detID = tTopo->pxfDetId(side, disk, blade, panel, module);
149  edm::LogPrint("SiPixelDynamicInefficiencyDB")
150  << "Putting Column geom FPix side " << side << " disk " << disk << " blade " << blade << " panel " << panel
151  << " module " << module << " factor " << factor << std::endl;
152  DynamicInefficiency.putColGeomFactor(detID.rawId(), factor);
153  } else
154  edm::LogError("SiPixelDynamicInefficiencyDB")
155  << "SiPixelDynamicInefficiencyDB input detector part is neither bpix nor fpix" << std::endl;
156  }
157 
158  //Put ChipGeomFactors
159  for (Parameters::iterator it = theChipGeomFactors_.begin(); it != theChipGeomFactors_.end(); ++it) {
160  string det = it->getParameter<string>("det");
161  it->exists("layer") ? layer = it->getParameter<unsigned int>("layer") : layer = LAYER;
162  it->exists("ladder") ? ladder = it->getParameter<unsigned int>("ladder") : ladder = LADDER;
163  it->exists("module") ? module = it->getParameter<unsigned int>("module") : module = MODULE;
164  it->exists("side") ? side = it->getParameter<unsigned int>("side") : side = SIDE;
165  it->exists("disk") ? disk = it->getParameter<unsigned int>("disk") : disk = DISK;
166  it->exists("blade") ? blade = it->getParameter<unsigned int>("blade") : blade = BLADE;
167  it->exists("panel") ? panel = it->getParameter<unsigned int>("panel") : panel = PANEL;
168  double factor = it->getParameter<double>("factor");
169  if (det == "bpix") {
170  DetId detID = tTopo->pxbDetId(layer, ladder, module);
171  edm::LogPrint("SiPixelDynamicInefficiencyDB") << "Putting Chip geom BPix layer " << layer << " ladder " << ladder
172  << " module " << module << " factor " << factor << std::endl;
173  DynamicInefficiency.putChipGeomFactor(detID.rawId(), factor);
174  } else if (det == "fpix") {
175  DetId detID = tTopo->pxfDetId(side, disk, blade, panel, module);
176  edm::LogPrint("SiPixelDynamicInefficiencyDB")
177  << "Putting Chip geom FPix side " << side << " disk " << disk << " blade " << blade << " panel " << panel
178  << " module " << module << " factor " << factor << std::endl;
179  DynamicInefficiency.putChipGeomFactor(detID.rawId(), factor);
180  } else
181  edm::LogError("SiPixelDynamicInefficiencyDB")
182  << "SiPixelDynamicInefficiencyDB input detector part is neither bpix nor fpix" << std::endl;
183  }
184 
185  //Put PUFactors
186  for (Parameters::iterator it = thePUEfficiency_.begin(); it != thePUEfficiency_.end(); ++it) {
187  string det = it->getParameter<string>("det");
188  it->exists("layer") ? layer = it->getParameter<unsigned int>("layer") : layer = LAYER;
189  it->exists("ladder") ? ladder = it->getParameter<unsigned int>("ladder") : ladder = LADDER;
190  it->exists("module") ? module = it->getParameter<unsigned int>("module") : module = MODULE;
191  it->exists("side") ? side = it->getParameter<unsigned int>("side") : side = SIDE;
192  it->exists("disk") ? disk = it->getParameter<unsigned int>("disk") : disk = DISK;
193  it->exists("blade") ? blade = it->getParameter<unsigned int>("blade") : blade = BLADE;
194  it->exists("panel") ? panel = it->getParameter<unsigned int>("panel") : panel = PANEL;
195  std::vector<double> factor = it->getParameter<std::vector<double> >("factor");
196  if (det == "bpix") {
197  DetId detID = tTopo->pxbDetId(layer, ladder, module);
198  edm::LogPrint("SiPixelDynamicInefficiencyDB")
199  << "Putting PU efficiency BPix layer " << layer << " ladder " << ladder << " module " << module
200  << " factor size " << factor.size() << std::endl;
201  DynamicInefficiency.putPUFactor(detID.rawId(), factor);
202  } else if (det == "fpix") {
203  DetId detID = tTopo->pxfDetId(side, disk, blade, panel, module);
204  edm::LogPrint("SiPixelDynamicInefficiencyDB")
205  << "Putting PU efficiency FPix side " << side << " disk " << disk << " blade " << blade << " panel " << panel
206  << " module " << module << " factor size " << factor.size() << std::endl;
207  DynamicInefficiency.putPUFactor(detID.rawId(), factor);
208  }
209  }
210  //Put theInstLumiScaleFactor
212 
214  if (mydbservice.isAvailable()) {
215  try {
216  if (mydbservice->isNewTagRequest(recordName_)) {
218  DynamicInefficiency, mydbservice->beginOfTime(), recordName_);
219  } else {
221  DynamicInefficiency, mydbservice->currentTime(), recordName_);
222  }
223  } catch (const cond::Exception& er) {
224  edm::LogError("SiPixelDynamicInefficiencyDB") << er.what() << std::endl;
225  } catch (const std::exception& er) {
226  edm::LogError("SiPixelDynamicInefficiencyDB") << "caught std::exception " << er.what() << std::endl;
227  } catch (...) {
228  edm::LogError("SiPixelDynamicInefficiencyDB") << "Funny error" << std::endl;
229  }
230  } else {
231  edm::LogError("SiPixelDynamicInefficiencyDB") << "Service is unavailable" << std::endl;
232  }
233 }
~SiPixelDynamicInefficiencyDB() override
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const edm::EventSetup & c
Base exception class for the object to relational access.
Definition: Exception.h:11
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tkTopoToken_
bool putPUFactor(const uint32_t &, std::vector< double > &)
bool putChipGeomFactor(const uint32_t &, double &)
bool putColGeomFactor(const uint32_t &, double &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Log< level::Error, false > LogError
DetId pxfDetId(uint32_t side, uint32_t disk, uint32_t blade, uint32_t panel, uint32_t module) const
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
constexpr std::array< uint8_t, layerIndexSize > layer
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:40
char const * what() const noexceptoverride
Definition: Exception.cc:103
Log< level::Warning, true > LogPrint
Definition: DetId.h:17
SiPixelDynamicInefficiencyDB(const edm::ParameterSet &conf)
DetId pxbDetId(uint32_t layer, uint32_t ladder, uint32_t module) const
bool putPixelGeomFactor(const uint32_t &, double &)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tuple module
Definition: callgraph.py:69
std::vector< edm::ParameterSet > Parameters