CMS 3D CMS Logo

SiStripSummaryBuilder.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  iConfig_(iConfig){}
10 
12 
13  unsigned int run=evt.id().run();
14  edm::LogInfo("SiStripSummaryBuilder") << "... creating dummy SiStripSummary Data for Run " << run << "\n " << std::endl;
15 
16 
18  obj->setRunNr(run);
19 
20 
21  //* DISCOVER SET OF HISTOGRAMS & QUANTITIES TO BE UPLOADED*//
22 
23  std::vector<std::string> userDBContent;
24  typedef std::vector<edm::ParameterSet> VParameters;
25  VParameters histoList = iConfig_.getParameter<VParameters>("histoList");
26  VParameters::iterator ithistoList = histoList.begin();
27  VParameters::iterator ithistoListEnd = histoList.end();
28 
29  for(; ithistoList != ithistoListEnd; ++ithistoList ) {
30  std::string keyName = ithistoList->getUntrackedParameter<std::string>("keyName");
31  std::vector<std::string> Quantities = ithistoList->getUntrackedParameter<std::vector<std::string> >("quantitiesToExtract");
32  for (size_t i=0;i<Quantities.size();++i){
33 
34  if ( Quantities[i] == "landau" ){
35  userDBContent.push_back(keyName+std::string("@")+std::string("landauPeak"));
36  userDBContent.push_back(keyName+std::string("@")+std::string("landauPeakErr"));
37  userDBContent.push_back(keyName+std::string("@")+std::string("landauSFWHM"));
38  userDBContent.push_back(keyName+std::string("@")+std::string("landauChi2NDF"));
39  }
40  else if ( Quantities[i] == "gauss" ){
41  userDBContent.push_back(keyName+std::string("@")+std::string("gaussMean"));
42  userDBContent.push_back(keyName+std::string("@")+std::string("gaussSigma"));
43  userDBContent.push_back(keyName+std::string("@")+std::string("gaussChi2NDF"));
44  }
45  else if ( Quantities[i] == "stat" ){
46  userDBContent.push_back(keyName+std::string("@")+std::string("entries"));
47  userDBContent.push_back(keyName+std::string("@")+std::string("mean"));
48  userDBContent.push_back(keyName+std::string("@")+std::string("rms"));
49  }
50  else{
51  edm::LogError("SiStripSummaryBuilder")
52  << "Quantity " << Quantities[i]
53  << " cannot be handled\nAllowed quantities are"
54  << "\n 'stat' that includes: entries, mean, rms"
55  << "\n 'landau' that includes: landauPeak, landauPeakErr, landauSFWHM, landauChi2NDF"
56  << "\n 'gauss' that includes: gaussMean, gaussSigma, gaussChi2NDF"
57  << std::endl;
58  }
59  }
60  }
61  obj->setUserDBContent(userDBContent);
62 
63  std::stringstream ss1;
64  ss1 << "QUANTITIES TO BE INSERTED IN DB :" << " \n";
65  std::vector<std::string> userDBContentA = obj->getUserDBContent();
66  for (size_t i=0;i<userDBContentA.size();++i) ss1 << userDBContentA[i]<< std::endl;
67  edm::LogInfo("SiStripSummaryBuilder") << ss1.str();
68 
69 
70  //* Loop over detids and create dummy data for each *//
71 
72 
73  std::stringstream ss2;
74  for (uint32_t detid=0; detid<430; detid++)
75  {
76 
78  for (unsigned int i=0; i<userDBContent.size(); i++) values.push_back((float) CLHEP::RandGauss::shoot(50.,30.));
79 
80  ss2<< "\n\tdetid " << detid;
81  for(size_t j=0;j<values.size();++j) ss2 << "\n\t\t "<< userDBContent[j] <<" "<< values[j];
82 
83  obj->put(detid,values,userDBContent);
84 
85  // See CondFormats/SiStripObjects/SiStripSummary.h for detid definitions
86 
87  if (detid == 4) detid = 10;
88  if (detid == 14) detid = 20;
89  if (detid == 26) detid = 30;
90  if (detid == 32) detid = 40;
91  if (detid == 42) detid = 310;
92  if (detid == 313) detid = 320;
93  if (detid == 323) detid = 410;
94  if (detid == 419) detid = 420;
95  }
96 
97  edm::LogInfo("SiStripSummaryBuilder") << ss2.str();
98 
99 
100 
101  //* Insert summary informations in the DB *//
102 
103 
105 
106  if( mydbservice.isAvailable() ){
107  if( mydbservice->isNewTagRequest("SiStripSummaryRcd") ){
108  mydbservice->createNewIOV<SiStripSummary>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripSummaryRcd");
109  } else {
110  mydbservice->appendSinceTime<SiStripSummary>(obj,mydbservice->currentTime(),"SiStripSummaryRcd");
111  }
112  }else{
113  edm::LogError("SiStripSummaryBuilder")<<"Service is unavailable"<<std::endl;
114  }
115 
116 
117 }
118 
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
void setRunNr(int inputRunNr)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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
SiStripSummaryBuilder(const edm::ParameterSet &iConfig)
std::vector< float > InputVector
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, std::vector< std::string > &userContent)
std::vector< std::string > getUserDBContent() const
edm::ParameterSet iConfig_
edm::EventID id() const
Definition: EventBase.h:58
HLT enums.
void setUserDBContent(const std::vector< std::string > &userDBContent)