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>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
8  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug",1)){}
9 
11 
12  unsigned int run=evt.id().run();
13 
14  edm::LogInfo("SiStripApvGainBuilder") << "... creating dummy SiStripApvGain Data for Run " << run << "\n " << std::endl;
15 
17 
19 
20  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos = reader.getAllData();
21 
22  int count=-1;
23  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++){
24  count++;
25  //Generate Gain for det detid
26  std::vector<float> theSiStripVector;
27  for(unsigned short j=0; j<it->second.nApvs; j++){
28  float gain= (j+1)*1000+ (CLHEP::RandFlat::shoot(1.)*100);
29  if (count<printdebug_)
30  edm::LogInfo("SiStripApvGainBuilder") << "detid " << it->first << " \t"
31  << " apv " << j << " \t"
32  << gain << " \t"
33  << std::endl;
34  theSiStripVector.push_back(gain);
35  }
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 
44  //End now write sistripnoises data in DB
46 
47  if( mydbservice.isAvailable() ){
48  if( mydbservice->isNewTagRequest("SiStripApvGainRcd") ){
49  mydbservice->createNewIOV<SiStripApvGain>(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 }
57 
RunNumber_t run() const
Definition: EventID.h:39
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:46
std::pair< ContainerIterator, ContainerIterator > Range
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::EventID id() const
Definition: EventBase.h:58
HLT enums.
std::string fullPath() const
Definition: FileInPath.cc:184
SiStripApvGainBuilder(const edm::ParameterSet &iConfig)