CMS 3D CMS Logo

SiStripApvGainBuilder.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include <fstream>
5 
7  : fp_(iConfig.getUntrackedParameter<edm::FileInPath>(
8  "file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
9  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)) {}
10 
12  unsigned int run = evt.id().run();
13 
14  edm::LogInfo("SiStripApvGainBuilder") << "... creating dummy SiStripApvGain Data for Run " << run << "\n "
15  << std::endl;
16 
18 
20 
21  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>& DetInfos = reader.getAllData();
22 
23  int count = -1;
24  for (std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator it = DetInfos.begin();
25  it != DetInfos.end();
26  it++) {
27  count++;
28  //Generate Gain for det detid
29  std::vector<float> theSiStripVector;
30  for (unsigned short j = 0; j < it->second.nApvs; j++) {
31  float gain = (j + 1) * 1000 + (CLHEP::RandFlat::shoot(1.) * 100);
32  if (count < printdebug_)
33  edm::LogInfo("SiStripApvGainBuilder") << "detid " << it->first << " \t"
34  << " apv " << j << " \t" << gain << " \t" << std::endl;
35  theSiStripVector.push_back(gain);
36  }
37 
38  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
39  if (!obj->put(it->first, range))
40  edm::LogError("SiStripApvGainBuilder") << "[SiStripApvGainBuilder::analyze] detid already exists" << std::endl;
41  }
42 
43  //End now write sistripnoises data in DB
45 
46  if (mydbservice.isAvailable()) {
47  if (mydbservice->isNewTagRequest("SiStripApvGainRcd")) {
48  mydbservice->createNewIOV<SiStripApvGain>(
49  obj, mydbservice->beginOfTime(), mydbservice->endOfTime(), "SiStripApvGainRcd");
50  } else {
51  mydbservice->appendSinceTime<SiStripApvGain>(obj, mydbservice->currentTime(), "SiStripApvGainRcd");
52  }
53  } else {
54  edm::LogError("SiStripApvGainBuilder") << "Service is unavailable" << std::endl;
55  }
56 }
RunNumber_t run() const
Definition: EventID.h:38
void analyze(const edm::Event &, const edm::EventSetup &) override
reader
Definition: DQM.py:105
bool put(const uint32_t &detID, Range input)
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:40
std::pair< ContainerIterator, ContainerIterator > Range
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
std::string fullPath() const
Definition: FileInPath.cc:163
SiStripApvGainBuilder(const edm::ParameterSet &iConfig)