CMS 3D CMS Logo

scaleGains.cc
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 
15 
16 class scaleGains : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
17 public:
18  explicit scaleGains(const edm::ParameterSet&);
19  ~scaleGains() override;
20 
21 private:
22  void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
23  void analyze(edm::Event const&, edm::EventSetup const&) override;
24  void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
26  double scale;
28 };
29 
31  fileIn = iConfig.getUntrackedParameter<std::string>("FileIn");
32  fileOut = iConfig.getUntrackedParameter<std::string>("FileOut");
33  scale = iConfig.getUntrackedParameter<double>("Scale");
34  tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
35 }
36 
38 
39 void scaleGains::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
40  HcalTopology topo = iSetup.getData(tok_htopo_);
41 
42  HcalGains gainsIn(&topo);
43  ;
44  std::ifstream inStream(fileIn.c_str());
45  HcalDbASCIIIO::getObject(inStream, &gainsIn);
46  inStream.close();
47 
48  HcalGains gainsOut(&topo);
49  ;
50  std::vector<DetId> channels = gainsIn.getAllChannels();
51  for (unsigned i = 0; i < channels.size(); i++) {
52  DetId id = channels[i];
53  HcalGain item(id,
54  gainsIn.getValues(id)->getValue(0) * scale,
55  gainsIn.getValues(id)->getValue(1) * scale,
56  gainsIn.getValues(id)->getValue(2) * scale,
57  gainsIn.getValues(id)->getValue(3) * scale);
58  gainsOut.addValues(item);
59  }
60 
61  std::ofstream outStream(fileOut.c_str());
62  HcalDbASCIIIO::dumpObject(outStream, gainsOut);
63  outStream.close();
64 }
65 
66 //define this as a plug-in
scaleGains::beginRun
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: scaleGains.cc:22
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
HcalGain::getValue
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:21
scaleGains::~scaleGains
~scaleGains() override
Definition: scaleGains.cc:37
edm::Run
Definition: Run.h:45
scaleGains::scale
double scale
Definition: scaleGains.cc:26
scaleGains
Definition: scaleGains.cc:16
scaleGains::tok_htopo_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
Definition: scaleGains.cc:27
HcalTopology
Definition: HcalTopology.h:26
HcalRecNumberingRecord.h
scaleGains::fileOut
std::string fileOut
Definition: scaleGains.cc:25
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
scaleGains::endRun
void endRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: scaleGains.cc:24
scaleGains::scaleGains
scaleGains(const edm::ParameterSet &)
Definition: scaleGains.cc:30
DetId
Definition: DetId.h:17
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
scaleGains::fileIn
std::string fileIn
Definition: scaleGains.cc:25
scaleGains::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: scaleGains.cc:39
HcalGain
Definition: HcalGain.h:16
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HcalCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: HcalCondObjectContainer.h:312
iEvent
int iEvent
Definition: GenABIO.cc:224
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:58
HcalGains.h
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
HcalTopology.h
HcalDbASCIIIO.h
Frameworkfwd.h
HcalDbASCIIIO::getObject
bool getObject(std::istream &fInput, HcalPedestals *fObject)
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
HcalGains
Definition: HcalGains.h:17
HcalCondObjectContainer::addValues
bool addValues(const Item &myItem)
Definition: HcalCondObjectContainer.h:234
ParameterSet.h
edm::Event
Definition: Event.h:73