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 
16 
17 class scaleGains : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
18 public:
19  explicit scaleGains(const edm::ParameterSet&);
20  ~scaleGains() override;
21 
22 private:
23  void beginRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
24  void analyze(edm::Event const&, edm::EventSetup const&) override;
25  void endRun(edm::Run const& iEvent, edm::EventSetup const&) override {}
27  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 }
35 
37 
38 void scaleGains::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
40  iSetup.get<HcalRecNumberingRecord>().get(htopo);
41  HcalTopology topo = (*htopo);
42 
43  HcalGains gainsIn(&topo);
44  ;
45  std::ifstream inStream(fileIn.c_str());
46  HcalDbASCIIIO::getObject(inStream, &gainsIn);
47  inStream.close();
48 
49  HcalGains gainsOut(&topo);
50  ;
51  std::vector<DetId> channels = gainsIn.getAllChannels();
52  for (unsigned i = 0; i < channels.size(); i++) {
53  DetId id = channels[i];
54  HcalGain item(id,
55  gainsIn.getValues(id)->getValue(0) * scale,
56  gainsIn.getValues(id)->getValue(1) * scale,
57  gainsIn.getValues(id)->getValue(2) * scale,
58  gainsIn.getValues(id)->getValue(3) * scale);
59  gainsOut.addValues(item);
60  }
61 
62  std::ofstream outStream(fileOut.c_str());
63  HcalDbASCIIIO::dumpObject(outStream, gainsOut);
64  outStream.close();
65 }
66 
67 //define this as a plug-in
scaleGains::beginRun
void beginRun(edm::Run const &iEvent, edm::EventSetup const &) override
Definition: scaleGains.cc:23
EDAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
ESHandle.h
HcalGain::getValue
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:21
scaleGains::~scaleGains
~scaleGains() override
Definition: scaleGains.cc:36
edm::Run
Definition: Run.h:45
scaleGains::scale
double scale
Definition: scaleGains.cc:27
scaleGains
Definition: scaleGains.cc:17
HcalTopology
Definition: HcalTopology.h:26
HcalRecNumberingRecord.h
scaleGains::fileOut
std::string fileOut
Definition: scaleGains.cc:26
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:25
scaleGains::scaleGains
scaleGains(const edm::ParameterSet &)
Definition: scaleGains.cc:30
DetId
Definition: DetId.h:17
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
scaleGains::fileIn
std::string fileIn
Definition: scaleGains.cc:26
edm::ESHandle< HcalTopology >
scaleGains::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: scaleGains.cc:38
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:57
HcalGains.h
get
#define get
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