CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripPedestalsBuilder.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 
10 
12 
13  unsigned int run=evt.id().run();
14 
15  edm::LogInfo("SiStripPedestalsBuilder") << "... creating dummy SiStripPedestals Data for Run " << run << "\n " << 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(); it != DetInfos.end(); it++){
25  count++;
26  //Generate Pedestal for det detid
27  SiStripPedestals::InputVector theSiStripVector;
28  for(int strip=0; strip<128*it->second.nApvs;++strip){
29 
30  float MeanPed = 100;
31  float RmsPed = 5;
32 
33  float ped = CLHEP::RandGauss::shoot(MeanPed,RmsPed);
34 
35  if ( count<static_cast<int>(printdebug_))
36  edm::LogInfo("SiStripPedestalsBuilder") << "detid " << it->first << " \t"
37  << " strip " << strip << " \t"
38  << ped << " \t"
39  << std::endl;
40  obj->setData(ped,theSiStripVector);
41  }
42 
43  //SiStripPedestals::Range range(theSiStripVector.begin(),theSiStripVector.end());
44  if ( ! obj->put(it->first,theSiStripVector) )
45  edm::LogError("SiStripPedestalsBuilder")<<"[SiStripPedestalsBuilder::analyze] detid already exists"<<std::endl;
46  }
47 
48 
49  //End now write sistrippedestals data in DB
51 
52  if( mydbservice.isAvailable() ){
53  if ( mydbservice->isNewTagRequest("SiStripPedestalsRcd") ){
54  mydbservice->createNewIOV<SiStripPedestals>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripPedestalsRcd");
55  } else {
56  //mydbservice->createNewIOV<SiStripPedestals>(obj,mydbservice->currentTime(),"SiStripPedestalsRcd");
57  mydbservice->appendSinceTime<SiStripPedestals>(obj,mydbservice->currentTime(),"SiStripPedestalsRcd");
58  }
59  }else{
60  edm::LogError("SiStripPedestalsBuilder")<<"Service is unavailable"<<std::endl;
61  }
62 }
63 
RunNumber_t run() const
Definition: EventID.h:39
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
std::vector< uint16_t > InputVector
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:46
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
bool put(const uint32_t &detID, InputVector &input)
edm::EventID id() const
Definition: EventBase.h:59
void setData(float ped, InputVector &vped)
std::string fullPath() const
Definition: FileInPath.cc:184
SiStripPedestalsBuilder(const edm::ParameterSet &iConfig)
virtual void analyze(const edm::Event &, const edm::EventSetup &)