CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
corrGains.cc
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 
10 
11 
12 int main (int argn, char* argv []) {
13  if (argn < 3) {
14  std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <respcorr (.txt)>" << std::endl;
15  return 1;
16  }
17  std::ifstream inStream (argv[1]);
18  std::ofstream outStream (argv[2]);
19  std::ifstream inCorr (argv[3]);
21  HcalGains gainsIn(&topo);;
22  HcalDbASCIIIO::getObject (inStream, &gainsIn);
23  HcalRespCorrs corrsIn(&topo);;
24  HcalDbASCIIIO::getObject (inCorr, &corrsIn);
25 
26  HcalGains gainsOut(&topo);;
27  std::vector<DetId> channels = gainsIn.getAllChannels ();
28  for (unsigned i = 0; i < channels.size(); i++) {
29  DetId id = channels[i];
30  float scale = 1.;
31  if (corrsIn.exists(id)) scale = corrsIn.getValues(id)->getValue();
32  HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale,
33  gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
34  gainsOut.addValues(item);
35  }
36  HcalDbASCIIIO::dumpObject (outStream, gainsOut);
37  return 0;
38 }
39 
int i
Definition: DBlmapReader.cc:9
const Item * getValues(DetId fId, bool throwOnFail=true) const
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:22
const bool exists(DetId fId) const
std::vector< DetId > getAllChannels() const
Definition: DetId.h:18
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
float getValue() const
Definition: HcalRespCorr.h:20
bool addValues(const Item &myItem)