CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripNoisesBuilder.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("SiStripNoisesBuilder") << "... creating dummy SiStripNoises 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 Noise for det detid
27  SiStripNoises::InputVector theSiStripVector;
28  for(int strip=0; strip<128*it->second.nApvs; ++strip){
29 
30  float MeanNoise = 5;
31  float RmsNoise = 1;
32  float noise = CLHEP::RandGauss::shoot(MeanNoise,RmsNoise);
33 
34  //double badStripProb = .5;
35  //bool disable = (CLHEP::RandFlat::shoot(1.) < badStripProb ? true:false);
36 
37  obj->setData(noise,theSiStripVector);
38  if (count<static_cast<int>(printdebug_))
39  edm::LogInfo("SiStripNoisesBuilder") << "detid " << it->first << " \t"
40  << " strip " << strip << " \t"
41  << noise << " \t"
42  << theSiStripVector.back()/10 << " \t"
43  << std::endl;
44  }
45 
46  if ( ! obj->put(it->first,theSiStripVector) )
47  edm::LogError("SiStripNoisesBuilder")<<"[SiStripNoisesBuilder::analyze] detid already exists"<<std::endl;
48  }
49 
50 
51  //End now write sistripnoises data in DB
53 
54  if( mydbservice.isAvailable() ){
55  if ( mydbservice->isNewTagRequest("SiStripNoisesRcd") ){
56  mydbservice->createNewIOV<SiStripNoises>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripNoisesRcd");
57  } else {
58  //mydbservice->createNewIOV<SiStripNoises>(obj,mydbservice->currentTime(),"SiStripNoisesRcd");
59  mydbservice->appendSinceTime<SiStripNoises>(obj,mydbservice->currentTime(),"SiStripNoisesRcd");
60  }
61  }else{
62  edm::LogError("SiStripNoisesBuilder")<<"Service is unavailable"<<std::endl;
63  }
64 }
65 
RunNumber_t run() const
Definition: EventID.h:42
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:44
SiStripNoisesBuilder(const edm::ParameterSet &iConfig)
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:47
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, const InputVector &input)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::EventID id() const
Definition: EventBase.h:56
std::string fullPath() const
Definition: FileInPath.cc:171
void setData(float noise_, InputVector &vped)