CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
corrGains.cc File Reference
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <vector>
#include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
#include "CondFormats/HcalObjects/interface/HcalGains.h"
#include "CondFormats/HcalObjects/interface/HcalRespCorrs.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 11 of file corrGains.cc.

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

11  {
12  if (argn < 3) {
13  std::cerr << "Use: " << argv[0] << " <gains to scale (.txt)> <result (.txt)> <respcorr (.txt)>" << std::endl;
14  return 1;
15  }
16  std::ifstream inStream (argv[1]);
17  std::ofstream outStream (argv[2]);
18  std::ifstream inCorr (argv[3]);
19  HcalGains gainsIn;
20  HcalDbASCIIIO::getObject (inStream, &gainsIn);
21  HcalRespCorrs corrsIn;
22  HcalDbASCIIIO::getObject (inCorr, &corrsIn);
23 
24  HcalGains gainsOut;
25  std::vector<DetId> channels = gainsIn.getAllChannels ();
26  for (unsigned i = 0; i < channels.size(); i++) {
27  DetId id = channels[i];
28  float scale = 1.;
29  if (corrsIn.exists(id)) scale = corrsIn.getValues(id)->getValue();
30  HcalGain item(id, gainsIn.getValues(id)->getValue(0) * scale, gainsIn.getValues(id)->getValue(1) * scale,
31  gainsIn.getValues(id)->getValue(2) * scale, gainsIn.getValues(id)->getValue(3) * scale);
32  gainsOut.addValues(item);
33  }
34  HcalDbASCIIIO::dumpObject (outStream, gainsOut);
35  return 0;
36 }
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
const bool exists(DetId fId) const
std::vector< DetId > getAllChannels() const
Definition: DetId.h:20
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
float getValue() const
Definition: HcalRespCorr.h:18
const Item * getValues(DetId fId) const