CMS 3D CMS Logo

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

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

10  {
11  if (argn < 3) {
12  std::cerr << "Use: " << argv[0] << " <RespCorrs to scale (.txt)> <resultRespCorrs (.txt)> <correction-respcorr (.txt)>" << std::endl;
13  return 1;
14  }
15  std::ifstream inStream (argv[1]);
16  std::ofstream outStream (argv[2]);
17  std::ifstream inCorr (argv[3]);
18  HcalRespCorrs respIn;
19  HcalDbASCIIIO::getObject (inStream, &respIn);
20  HcalRespCorrs corrsIn;
21  HcalDbASCIIIO::getObject (inCorr, &corrsIn);
22 
23  HcalRespCorrs respOut;
24  std::vector<DetId> channels = respIn.getAllChannels ();
25  for (unsigned i = 0; i < channels.size(); i++) {
26  DetId id = channels[i];
27  float scale = 1.0;
28  if (corrsIn.exists(id)) scale = corrsIn.getValues(id)->getValue();
29  HcalRespCorr item (id, respIn.getValues(id)->getValue() * scale);
30  respOut.addValues(item);
31  }
32  HcalDbASCIIIO::dumpObject (outStream, respOut);
33  return 0;
34 }
int i
Definition: DBlmapReader.cc:9
bool addValues(const Item &myItem, bool h2mode_=false)
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