CMS 3D CMS Logo

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