CMS 3D CMS Logo

DTTPGParamsWriter.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author C. Battilana CIEMAT
5  */
6 
9 
14 
15 /* C++ Headers */
16 #include <boost/algorithm/string/split.hpp>
17 #include <boost/algorithm/string_regex.hpp>
18 #include <iostream>
19 #include <sstream>
20 #include <string>
21 #include <vector>
22 
23 using namespace std;
24 using namespace edm;
25 
26 // Constructor
28  debug_ = pset.getUntrackedParameter<bool>("debug", false);
29  inputFileName_ = pset.getUntrackedParameter<string>("inputFile");
30  // Create the object to be written to DB
31  phaseMap_ = new DTTPGParameters();
32 
33  if (debug_)
34  cout << "[DTTPGParamsWriter]Constructor called!" << endl;
35 }
36 
37 // Destructor
39  if (debug_)
40  cout << "[DTTPGParamsWriter]Destructor called!" << endl;
41 }
42 
43 // Do the job
44 void DTTPGParamsWriter::analyze(const Event &event, const EventSetup &eventSetup) {
45  if (debug_)
46  cout << "[DTTPGParamsWriter]Reading data from file." << endl;
47 
48  std::ifstream inputFile_(inputFileName_.c_str());
49  int nLines = 0;
51 
52  while (std::getline(inputFile_, line)) {
53  DTChamberId chId;
54  float fine = 0.;
55  int coarse = 0;
56  pharseLine(line, chId, fine, coarse);
57  phaseMap_->set(chId, coarse, fine, DTTimeUnits::ns);
58  if (debug_) {
59  float fineDB = 0.;
60  int coarseDB = 0;
61  phaseMap_->get(chId, coarseDB, fineDB, DTTimeUnits::ns);
62  std::cout << "[DTTPGParamsWriter] Read data for chamber " << chId << ". File params -> fine: " << fine
63  << " coarse: " << coarse << ". DB params -> fine: " << fineDB << " coarse: " << coarseDB << std::endl;
64  }
65  nLines++;
66  }
67  if (debug_) {
68  std::cout << "[DTTPGParamsWriter] # of entries written the the DB: " << nLines << std::endl;
69  }
70  if (nLines != 250) {
71  std::cout << "[DTTPGParamsWriter] # of DB entries != 250. Check you input file!" << std::endl;
72  }
73 
74  inputFile_.close();
75 }
76 
77 void DTTPGParamsWriter::pharseLine(std::string &line, DTChamberId &chId, float &fine, int &coarse) {
78  std::vector<std::string> elements;
80  elements,
81  line,
82  boost::algorithm::is_any_of(string(" \t\n"))); // making string conversion explicit (needed to
83  // cope with -Warray-bounds in slc5_ia32_gcc434
84  if (elements.size() != 5) {
85  std::cout << "[DTTPGParamsWriter] wrong number of entries in line : " << line
86  << " pleas check your input file syntax!" << std::endl;
87  } else {
88  chId = DTChamberId(atoi(elements[0].c_str()), atoi(elements[1].c_str()), atoi(elements[2].c_str()));
89  fine = atof(elements[3].c_str());
90  coarse = atoi(elements[4].c_str());
91  }
92 }
93 
94 // Write objects to DB
96  if (debug_)
97  cout << "[DTTPGParamsWriter] Writing ttrig object to DB!" << endl;
98 
99  string delayRecord = "DTTPGParametersRcd";
100  DTCalibDBUtils::writeToDB(delayRecord, phaseMap_);
101 }
ESHandle.h
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTTPGParamsWriter::~DTTPGParamsWriter
~DTTPGParamsWriter() override
Destructor.
Definition: DTTPGParamsWriter.cc:38
submitDQMOfflineCAF.nLines
nLines
Definition: submitDQMOfflineCAF.py:676
DTTPGParamsWriter::endJob
void endJob() override
Write ttrig in the DB.
Definition: DTTPGParamsWriter.cc:95
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DTTPGParamsWriter::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Compute the ttrig by fiting the TB rising edge.
Definition: DTTPGParamsWriter.cc:44
DTCalibDBUtils.h
DTTPGParamsWriter::pharseLine
void pharseLine(std::string &line, DTChamberId &chId, float &fine, int &coarse)
Definition: DTTPGParamsWriter.cc:77
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
bookConverter.elements
elements
Definition: bookConverter.py:147
std
Definition: JetResolutionObject.h:76
DTTPGParamsWriter::DTTPGParamsWriter
DTTPGParamsWriter(const edm::ParameterSet &pset)
Constructor.
Definition: DTTPGParamsWriter.cc:27
L1DTConfigParams_cff.DTTPGParameters
DTTPGParameters
Definition: L1DTConfigParams_cff.py:12
EventSetup.h
DTChamberId
Definition: DTChamberId.h:14
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
mps_splice.line
line
Definition: mps_splice.py:76
DTCalibDBUtils::writeToDB
static void writeToDB(std::string record, T *payload)
Definition: DTCalibDBUtils.h:28
DTTPGParamsWriter.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27