CMS 3D CMS Logo

SiStripApvGainReader.cc
Go to the documentation of this file.
5 
7 
8 #include <iostream>
9 #include <cstdio>
10 #include <sys/time.h>
11 
12 using namespace cms;
13 
15  : printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", true)),
16  formatedOutput_(iConfig.getUntrackedParameter<std::string>("outputFile", "")),
17  gainType_(iConfig.getUntrackedParameter<uint32_t>("gainType", 1)),
18  tree_(nullptr) {
19  if (fs_.isAvailable()) {
20  tree_ = fs_->make<TTree>("Gains", "Gains");
21 
22  tree_->Branch("Index", &id_, "Index/I");
23  tree_->Branch("DetId", &detId_, "DetId/I");
24  tree_->Branch("APVId", &apvId_, "APVId/I");
25  tree_->Branch("Gain", &gain_, "Gain/D");
26  }
27 }
28 
30 
32  edm::ESHandle<SiStripGain> SiStripApvGain_;
33  iSetup.get<SiStripGainRcd>().get(SiStripApvGain_);
34  edm::LogInfo("SiStripApvGainReader") << "[SiStripApvGainReader::analyze] End Reading SiStripApvGain" << std::endl;
35  std::vector<uint32_t> detid;
36  SiStripApvGain_->getDetIds(detid);
37  edm::LogInfo("Number of detids ") << detid.size() << std::endl;
38 
39  FILE* pFile = nullptr;
40  if (!formatedOutput_.empty())
41  pFile = fopen(formatedOutput_.c_str(), "w");
42  for (size_t id = 0; id < detid.size(); id++) {
43  SiStripApvGain::Range range = SiStripApvGain_->getRange(detid[id], gainType_);
44  if (printdebug_) {
45  int apv = 0;
46  for (int it = 0; it < range.second - range.first; it++) {
47  edm::LogInfo("SiStripApvGainReader") << "detid " << detid[id] << " \t " << apv++ << " \t "
48  << SiStripApvGain_->getApvGain(it, range) << std::endl;
49  id_++;
50 
51  if (tree_) {
52  detId_ = detid[id];
53  apvId_ = apv;
54  gain_ = SiStripApvGain_->getApvGain(it, range);
55  tree_->Fill();
56  }
57  }
58  }
59 
60  if (pFile) {
61  fprintf(pFile, "%i ", detid[id]);
62  for (int it = 0; it < range.second - range.first; it++) {
63  fprintf(pFile, "%f ", SiStripApvGain_->getApvGain(it, range));
64  }
65  fprintf(pFile, "\n");
66  }
67  }
68 
69  if (pFile)
70  fclose(pFile);
71 }
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SiStripGainRcd
Definition: SiStripDependentRecords.h:29
electrons_cff.bool
bool
Definition: electrons_cff.py:372
SiStripGain.h
SiStripApvGainReader::id_
int id_
Definition: SiStripApvGainReader.h:38
SiStripApvGainReader::tree_
TTree * tree_
Definition: SiStripApvGainReader.h:37
SiStripApvGainReader::SiStripApvGainReader
SiStripApvGainReader(const edm::ParameterSet &)
Definition: SiStripApvGainReader.cc:14
edm::LogInfo
Definition: MessageLogger.h:254
SiStripApvGainReader.h
SiStripGainRcd.h
SiStripApvGainRcd.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
SiStripApvGainReader::gain_
double gain_
Definition: SiStripApvGainReader.h:39
SiStripApvGainReader::gainType_
uint32_t gainType_
Definition: SiStripApvGainReader.h:35
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
SiStripGain::getRange
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:71
SiStripApvGainReader::detId_
int detId_
Definition: SiStripApvGainReader.h:38
edm::ESHandle< SiStripGain >
SiStripGain::getDetIds
void getDetIds(std::vector< uint32_t > &DetIds_) const
ATTENTION: we assume the detIds are the same as those from the first gain.
Definition: SiStripGain.cc:102
SiStripApvGainReader::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripApvGainReader.cc:31
SiStripApvGain.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripGain::getApvGain
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:76
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripApvGainReader::~SiStripApvGainReader
~SiStripApvGainReader() override
Definition: SiStripApvGainReader.cc:29
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
SiStripApvGainReader::formatedOutput_
std::string formatedOutput_
Definition: SiStripApvGainReader.h:34
std
Definition: JetResolutionObject.h:76
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
SiStripApvGainReader::apvId_
int apvId_
Definition: SiStripApvGainReader.h:38
edm::Event
Definition: Event.h:73
SiStripApvGainReader::printdebug_
bool printdebug_
Definition: SiStripApvGainReader.h:33
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
SiStripApvGainReader::fs_
edm::Service< TFileService > fs_
Definition: SiStripApvGainReader.h:36
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37