CMS 3D CMS Logo

SiPixelFakeGenErrorDBObjectESSource.cc
Go to the documentation of this file.
3 #include <fstream>
4 
6  : GenErrorCalibrations_(conf_.getParameter<vstring>("siPixelGenErrorCalibrations")),
7  version_(conf_.getParameter<double>("Version")) {
8  edm::LogInfo("SiPixelFakeGenErrorDBObjectESSource::SiPixelFakeGenErrorDBObjectESSource");
9  //the following line is needed to tell the framework what
10  // data is being produced
11  setWhatProduced(this);
12  findingRecord<SiPixelGenErrorDBObjectRcd>();
13 }
14 
16 
17 std::unique_ptr<SiPixelGenErrorDBObject> SiPixelFakeGenErrorDBObjectESSource::produce(
19  using namespace edm::es;
20 
21  //Mostly copied from CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.cc
22  //--- Make the POOL-ORA object to store the database object
24 
25  // Local variables
26  const char* tempfile;
27  int m;
28 
29  // Set the number of GenErrors to be passed to the dbobject
30  obj->setNumOfTempl(GenErrorCalibrations_.size());
31 
32  // Set the version of the GenError dbobject - this is an external parameter
33  obj->setVersion(version_);
34 
35  // open the GenError file(s)
36  for (m = 0; m < obj->numOfTempl(); ++m) {
38  tempfile = (file.fullPath()).c_str();
39 
40  std::ifstream in_file(tempfile, std::ios::in);
41 
42  if (in_file.is_open()) {
43  edm::LogInfo("SiPixelFakeGenErrorDBObjectESSource")
44  << "Opened GenError File: " << file.fullPath().c_str() << std::endl;
45 
46  // Local variables
47  char title_char[80], c;
49  float tempstore;
50  unsigned int iter;
51 
52  // GenErrors contain a header char - we must be clever about storing this
53  for (iter = 0; (c = in_file.get()) != '\n' && iter < 79; ++iter) {
54  title_char[iter] = c;
55  }
56  if (iter == 79) {
57  title_char[iter] = '\n';
58  } else {
59  unsigned int ilast = 3 - (iter % 4);
60  for (unsigned int it = 0; it != ilast; it++) {
61  title_char[iter] = ' ';
62  iter++;
63  }
64  title_char[iter] = '\n';
65  }
66 
67  for (unsigned int j = 0; j <= iter; j += 4) {
68  temp.c[0] = title_char[j];
69  temp.c[1] = title_char[j + 1];
70  temp.c[2] = title_char[j + 2];
71  temp.c[3] = title_char[j + 3];
72  obj->push_back(temp.f);
73  obj->setMaxIndex(obj->maxIndex() + 1);
74  }
75 
76  // Fill the dbobject
77  in_file >> tempstore;
78  while (!in_file.eof()) {
79  obj->setMaxIndex(obj->maxIndex() + 1);
80  obj->push_back(tempstore);
81  in_file >> tempstore;
82  }
83 
84  in_file.close();
85  } else {
86  // If file didn't open, report this
87  edm::LogError("SiPixeFakelGenErrorDBObjectESSource") << "Error opening File" << tempfile << std::endl;
88  }
89  }
90 
91  //std::cout << *obj << std::endl;
92  return std::unique_ptr<SiPixelGenErrorDBObject>(obj);
93 }
94 
96  const edm::IOVSyncValue& iosv,
97  edm::ValidityInterval& oValidity) {
99  oValidity = infinity;
100 }
SiPixelFakeGenErrorDBObjectESSource.h
MessageLogger.h
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ValidityInterval
Definition: ValidityInterval.h:28
SiPixelFakeGenErrorDBObjectESSource::GenErrorCalibrations_
vstring GenErrorCalibrations_
Definition: SiPixelFakeGenErrorDBObjectESSource.h:27
SiPixelFakeGenErrorDBObjectESSource::~SiPixelFakeGenErrorDBObjectESSource
~SiPixelFakeGenErrorDBObjectESSource() override
Definition: SiPixelFakeGenErrorDBObjectESSource.cc:15
SiPixelFakeGenErrorDBObjectESSource::SiPixelFakeGenErrorDBObjectESSource
SiPixelFakeGenErrorDBObjectESSource(const edm::ParameterSet &)
Definition: SiPixelFakeGenErrorDBObjectESSource.cc:5
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
infinity
const double infinity
Definition: CSCChamberFitter.cc:10
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
SiPixelFakeGenErrorDBObjectESSource::produce
virtual std::unique_ptr< SiPixelGenErrorDBObject > produce(const SiPixelGenErrorDBObjectRcd &)
Definition: SiPixelFakeGenErrorDBObjectESSource.cc:17
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::FileInPath
Definition: FileInPath.h:61
SiPixelFakeGenErrorDBObjectESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Definition: SiPixelFakeGenErrorDBObjectESSource.cc:95
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
SiPixelGenErrorDBObjectRcd
Definition: SiPixelGenErrorDBObjectRcd.h:24
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
SiPixelGenErrorDBObject::char2float
Definition: SiPixelGenErrorDBObject.h:69
runGCPTkAlMap.in_file
in_file
Definition: runGCPTkAlMap.py:74
geometryDiff.file
file
Definition: geometryDiff.py:13
edm::ParameterSet
Definition: ParameterSet.h:47
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SiPixelFakeGenErrorDBObjectESSource::vstring
std::vector< std::string > vstring
Definition: SiPixelFakeGenErrorDBObjectESSource.h:17
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixelFakeGenErrorDBObjectESSource::version_
float version_
Definition: SiPixelFakeGenErrorDBObjectESSource.h:28
edm::es
Definition: es_Label.h:33
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
SiPixelGenErrorDBObject
Definition: SiPixelGenErrorDBObject.h:16
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66