CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
corrResps.cc
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 
9 
10 int main (int argn, char* argv []) {
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  }
16  std::ifstream inStream (argv[1]);
17  std::ofstream outStream (argv[2]);
18  std::ifstream inCorr (argv[3]);
19  HcalRespCorrs respIn(&topo);
20  HcalDbASCIIIO::getObject (inStream, &respIn);
21  HcalRespCorrs corrsIn(&topo);
22  HcalDbASCIIIO::getObject (inCorr, &corrsIn);
23 
24  HcalRespCorrs respOut(&topo);
25  std::vector<DetId> channels = respIn.getAllChannels ();
26  for (unsigned i = 0; i < channels.size(); i++) {
27  DetId id = channels[i];
28  float scale = 1.0;
29  if (corrsIn.exists(id)) scale = corrsIn.getValues(id)->getValue();
30  HcalRespCorr item (id, respIn.getValues(id)->getValue() * scale);
31  respOut.addValues(item);
32  }
33  HcalDbASCIIIO::dumpObject (outStream, respOut);
34  return 0;
35 }
36 
int i
Definition: DBlmapReader.cc:9
const Item * getValues(DetId fId, bool throwOnFail=true) const
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)