4 #include "HGCal/CondObjects/interface/HGCalCondObjectTextIO.h"
5 #include "HGCal/DataFormats/interface/HGCalTBDetId.h"
6 #include "HGCal/DataFormats/interface/HGCalTBElectronicsId.h"
8 static HGCalTBDetId tb_detid_load(
const char* buffer,
int& ptr)
10 int v1, v2, v3, v4, v5, v6;
11 int found = sscanf(buffer,
"%d %d %d %d %d %d %n ", &v1, &v2, &v3, &v4, &v5, &v6, &ptr);
18 fprintf(f,
"%08x %5d %9d %9d %3d %3d %4d ",
id.rawId(),
id.layer()*
id.zside(),
id.sensorIU(),
id.sensorIV(),
id.iu(),
id.iv(),
id.cellType());
23 FILE* f = fopen(filename.c_str(),
"r");
25 fprintf(stderr,
"Unable to open '%s'\n", filename.c_str());
33 fgets(buffer, 100, f);
34 if (sscanf(buffer,
"SCHEME_CODE %lu", &code) != 1) {
35 fprintf(stderr,
"Expected 'SCHEME_CODE <value>' on first line of file\n");
44 fgets(buffer, 100, f);
46 char* p_comment = index(buffer,
'#');
47 if (p_comment != 0) *p_comment = 0;
51 const char* process = buffer;
52 int found = sscanf(process,
"%d %n ", &dummy, &ptr);
60 float value = atof(process);
69 FILE* f = fopen(filename.c_str(),
"w");
70 if (f == 0)
return false;
72 fprintf(f,
"SCHEME_CODE %lu\n", cont.
schemeCode());
73 fprintf(f,
"# CODE LAYER SENSOR_IU SENSOR_IV IU IV TYPE VALUE\n");
74 for (
size_t i = 0; i < cont.
size(); i++) {
75 if (cont.
get(i).id.null())
continue;
77 fprintf(f,
" %.6g\n", cont.
get(i).value);
86 FILE* f = fopen(filename.c_str(),
"r");
88 fprintf(stderr,
"Unable to open '%s'\n", filename.c_str());
95 fgets(buffer, 100, f);
97 char* p_comment = index(buffer,
'#');
98 if (p_comment != 0) *p_comment = 0;
104 const char* process = buffer;
105 int found = sscanf(process,
"%d %d %n", &iskiroc, &icell, &ptr);
121 FILE* f = fopen(filename.c_str(),
"w");
122 if (f == 0)
return false;
124 fprintf(f,
"# SKIROC CHAN | LAYER SENSOR_IU SENSOR_IV IU IV TYPE \n");
125 for (
size_t i = 0; i < emap.
size(); i++) {
128 fprintf(f,
" %6d %4d %5d %9d %9d %3d %3d %4d\n", eid.iskiroc(), eid.ichan(),
129 did.layer()*did.zside(), did.sensorIU(), did.sensorIV(), did.iu(), did.iv(), did.cellType());
bool store(const std::string &filename, const HGCalCondObjectContainer< float > &)
saves condition to file
bool load(const std::string &filename, HGCalCondObjectContainer< float > &)
load conditions from file
uint64_t schemeCode() const
void insert(uint32_t, DetId did)
const Item * get(DetId id) const
uint32_t eidAt(size_t i) const
DetId didAt(size_t i) const
void set(DetId id, const Payload &value)
provides the conversion between electronics Id to DetId