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"
#include "Geometry/CaloTopology/interface/HcalTopology.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 12 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, HcalTopologyMode::LHC, and pileupReCalc_HLTpaths::scale.

12  {
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 }
int i
Definition: DBlmapReader.cc:9
Definition: DetId.h:18
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)