CMS 3D CMS Logo

SiPixelFakeTemplateDBObjectESSource.cc
Go to the documentation of this file.
3 #include <fstream>
4 
6  : templateCalibrations_(conf_.getParameter<vstring>("siPixelTemplateCalibrations")),
7  version_(conf_.getParameter<double>("Version")) {
8  edm::LogInfo("SiPixelFakeTemplateDBObjectESSource::SiPixelFakeTemplateDBObjectESSource");
9  //the following line is needed to tell the framework what
10  // data is being produced
11  setWhatProduced(this);
12  findingRecord<SiPixelTemplateDBObjectRcd>();
13 }
14 
16 
17 std::unique_ptr<SiPixelTemplateDBObject> SiPixelFakeTemplateDBObjectESSource::produce(
19  using namespace edm::es;
20 
21  //Mostly copied from CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.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 templates to be passed to the dbobject
30  obj->setNumOfTempl(templateCalibrations_.size());
31 
32  // Set the version of the template dbobject - this is an external parameter
33  obj->setVersion(version_);
34 
35  // open the template 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("SiPixelFakeTemplateDBObjectESSource")
44  << "Opened Template 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  // Templates 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("SiPixeFakelTemplateDBObjectESSource") << "Error opening File" << tempfile << std::endl;
88  }
89  }
90 
91  //std::cout << *obj << std::endl;
92  return std::unique_ptr<SiPixelTemplateDBObject>(obj);
93 }
94 
96  const edm::IOVSyncValue& iosv,
97  edm::ValidityInterval& oValidity) {
99  oValidity = infinity;
100 }
SiPixelFakeTemplateDBObjectESSource::produce
virtual std::unique_ptr< SiPixelTemplateDBObject > produce(const SiPixelTemplateDBObjectRcd &)
Definition: SiPixelFakeTemplateDBObjectESSource.cc:17
MessageLogger.h
SiPixelFakeTemplateDBObjectESSource::~SiPixelFakeTemplateDBObjectESSource
~SiPixelFakeTemplateDBObjectESSource() override
Definition: SiPixelFakeTemplateDBObjectESSource.cc:15
SiPixelFakeTemplateDBObjectESSource::version_
float version_
Definition: SiPixelFakeTemplateDBObjectESSource.h:28
SiPixelFakeTemplateDBObjectESSource::vstring
std::vector< std::string > vstring
Definition: SiPixelFakeTemplateDBObjectESSource.h:17
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ValidityInterval
Definition: ValidityInterval.h:28
SiPixelTemplateDBObject::char2float
Definition: SiPixelTemplateDBObject.h:111
SiPixelFakeTemplateDBObjectESSource::SiPixelFakeTemplateDBObjectESSource
SiPixelFakeTemplateDBObjectESSource(const edm::ParameterSet &)
Definition: SiPixelFakeTemplateDBObjectESSource.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
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::FileInPath
Definition: FileInPath.h:64
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
SiPixelFakeTemplateDBObjectESSource.h
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
SiPixelFakeTemplateDBObjectESSource::templateCalibrations_
vstring templateCalibrations_
Definition: SiPixelFakeTemplateDBObjectESSource.h:27
runGCPTkAlMap.in_file
in_file
Definition: runGCPTkAlMap.py:74
SiPixelFakeTemplateDBObjectESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Definition: SiPixelFakeTemplateDBObjectESSource.cc:95
edm::ParameterSet
Definition: ParameterSet.h:47
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SiPixelTemplateDBObject
Definition: SiPixelTemplateDBObject.h:16
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::es
Definition: es_Label.h:33
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
SiPixelTemplateDBObjectRcd
Definition: SiPixelTemplateDBObjectRcd.h:24
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66