CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripApvGainReader.cc
Go to the documentation of this file.
5 
7 
8 #include <iostream>
9 #include <stdio.h>
10 #include <sys/time.h>
11 
12 
13 using namespace cms;
14 
16  printdebug_(iConfig.getUntrackedParameter<bool>("printDebug",true)),
17  formatedOutput_(iConfig.getUntrackedParameter<std::string>("outputFile","")),
18  gainType_ (iConfig.getUntrackedParameter<uint32_t>("gainType",1))
19  {}
20 
22 
24 
25  edm::ESHandle<SiStripGain> SiStripApvGain_;
26  iSetup.get<SiStripGainRcd>().get(SiStripApvGain_);
27  edm::LogInfo("SiStripApvGainReader") << "[SiStripApvGainReader::analyze] End Reading SiStripApvGain" << std::endl;
28 
29  std::vector<uint32_t> detid;
30  SiStripApvGain_->getDetIds(detid);
31  edm::LogInfo("Number of detids ") << detid.size() << std::endl;
32 
33  FILE* pFile=NULL;
34  if(formatedOutput_!="")pFile=fopen(formatedOutput_.c_str(), "w");
35 
36  for (size_t id=0;id<detid.size();id++){
37  SiStripApvGain::Range range=SiStripApvGain_->getRange(detid[id], gainType_);
38  if(printdebug_){
39  int apv=0;
40  for(int it=0;it<range.second-range.first;it++){
41  edm::LogInfo("SiStripApvGainReader") << "detid " << detid[id] << " \t " << apv++ << " \t " << SiStripApvGain_->getApvGain(it,range) << std::endl;
42  }
43  }
44 
45  if(pFile){
46  fprintf(pFile,"%i ",detid[id]);
47  for(int it=0;it<range.second-range.first;it++){
48  fprintf(pFile,"%f ", SiStripApvGain_->getApvGain(it,range) );
49  }fprintf(pFile, "\n");
50  }
51 
52  }
53 
54  if(pFile)fclose(pFile);
55 }
#define NULL
Definition: scimark2.h:8
std::pair< ContainerIterator, ContainerIterator > Range
void analyze(const edm::Event &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:56
SiStripApvGainReader(const edm::ParameterSet &)