20 std::cerr <<
"Use: " <<
argv[0] <<
" operation <gains(.txt)> <operand> <result(.txt)>" << std::endl;
21 std::cerr <<
" where operation: sadd,ssub,smult,sdiv = +-*/ of a scalar value \n";
22 std::cerr <<
" add,sub,mult,div = +-*/ of vector values (in RespCorr-format)\n";
29 std::ifstream inStream (
argv[2]);
34 std::ofstream outStream (
argv[4]);
39 s_operation =
argv[1];
40 bool vectorop =
false;
44 if ( (std::strcmp(s_operation.c_str(),
"add")==0) ||
45 (std::strcmp(s_operation.c_str(),
"sub")==0) ||
46 (std::strcmp(s_operation.c_str(),
"mult")==0) ||
47 (std::strcmp(s_operation.c_str(),
"div")==0) )
50 std::ifstream inCorr (
argv[3]);
53 else if ((std::strcmp(s_operation.c_str(),
"sadd")==0) ||
54 (std::strcmp(s_operation.c_str(),
"ssub")==0) ||
55 (std::strcmp(s_operation.c_str(),
"smult")==0) ||
56 (std::strcmp(s_operation.c_str(),
"sdiv")==0))
59 std::cerr <<
"Scalar operation: using val=" << val << std::endl;
63 std::cerr <<
"Unknown operator. Stopping. \n";
68 std::vector<DetId> channels = gainsIn.getAllChannels ();
69 std::cerr <<
"size = " << channels.size() << std::endl;
70 for (
unsigned i = 0;
i < channels.size();
i++) {
75 if ((std::strcmp(s_operation.c_str(),
"mult")==0)||(std::strcmp(s_operation.c_str(),
"div")==0)) val = 1.0;
76 if ((std::strcmp(s_operation.c_str(),
"add")==0)||(std::strcmp(s_operation.c_str(),
"sub")==0)) val = 0.0;
77 if (corrsIn.exists(
id))
79 val = corrsIn.getValues(
id)->getValue();
82 std::cerr <<
"Vector operation, " <<
i <<
"th channel: using val=" << val << std::endl;
87 if ((std::strcmp(s_operation.c_str(),
"add")==0) || (std::strcmp(s_operation.c_str(),
"sadd")==0))
88 p_item =
new HcalGain(
id, gainsIn.getValues(
id)->getValue(0) + val, gainsIn.getValues(
id)->getValue(1) + val,
89 gainsIn.getValues(
id)->getValue(2) + val, gainsIn.getValues(
id)->getValue(3) + val);
91 if ((std::strcmp(s_operation.c_str(),
"sub")==0) || (std::strcmp(s_operation.c_str(),
"ssub")==0))
92 p_item =
new HcalGain(
id, gainsIn.getValues(
id)->getValue(0) - val, gainsIn.getValues(
id)->getValue(1) - val,
93 gainsIn.getValues(
id)->getValue(2) - val, gainsIn.getValues(
id)->getValue(3) - val);
95 if ((std::strcmp(s_operation.c_str(),
"mult")==0) || (std::strcmp(s_operation.c_str(),
"smult")==0))
96 p_item =
new HcalGain(
id, gainsIn.getValues(
id)->getValue(0) * val, gainsIn.getValues(
id)->getValue(1) * val,
97 gainsIn.getValues(
id)->getValue(2) * val, gainsIn.getValues(
id)->getValue(3) * val);
99 if ((std::strcmp(s_operation.c_str(),
"div")==0) || (std::strcmp(s_operation.c_str(),
"sdiv")==0))
100 p_item =
new HcalGain(
id, gainsIn.getValues(
id)->getValue(0) / val, gainsIn.getValues(
id)->getValue(1) / val,
101 gainsIn.getValues(
id)->getValue(2) / val, gainsIn.getValues(
id)->getValue(3) / val);
106 gainsOut.addValues(*p_item);
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)