CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
scaleGains.cc File Reference
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <vector>
#include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
#include "CondFormats/HcalObjects/interface/HcalGains.h"

Go to the source code of this file.

Functions

int main (int argn, char *argv[])
 

Function Documentation

int main ( int  argn,
char *  argv[] 
)

Definition at line 10 of file scaleGains.cc.

References HcalCondObjectContainer< Item >::addValues(), dtNoiseDBValidation_cfg::cerr, HcalDbASCIIIO::dumpObject(), HcalCondObjectContainer< Item >::getAllChannels(), HcalDbASCIIIO::getObject(), HcalGain::getValue(), HcalCondObjectContainer< Item >::getValues(), i, and pileupReCalc_HLTpaths::scale.

10  {
11  if (argn < 3) {
12  std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <scale factor>" << std::endl;
13  return 1;
14  }
15  std::ifstream inStream (argv[1]);
16  std::ofstream outStream (argv[2]);
17  double scale = atof (argv[3]);
18  HcalGains gainsIn;
19  HcalDbASCIIIO::getObject (inStream, &gainsIn);
20  HcalGains gainsOut;
21  std::vector<DetId> channels = gainsIn.getAllChannels ();
22  for (unsigned i = 0; i < channels.size(); i++) {
23  DetId id = channels[i];
24  HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale,
25  gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
26  gainsOut.addValues(item);
27  }
28  HcalDbASCIIIO::dumpObject (outStream, gainsOut);
29  return 0;
30 }
int i
Definition: DBlmapReader.cc:9
bool addValues(const Item &myItem, bool h2mode_=false)
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:20
std::vector< DetId > getAllChannels() const
Definition: DetId.h:20
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
const Item * getValues(DetId fId) const