CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTPGParamsWriter.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2013/03/27 17:30:04 $
5  * $Revision: 1.6 $
6  * \author C. Battilana CIEMAT
7  */
8 
11 
16 
17 /* C++ Headers */
18 #include <vector>
19 #include <iostream>
20 #include <string>
21 #include <sstream>
22 #include <boost/algorithm/string/split.hpp>
23 #include <boost/algorithm/string_regex.hpp>
24 
25 using namespace std;
26 using namespace edm;
27 
28 
29 // Constructor
31 
32  debug_ = pset.getUntrackedParameter<bool>("debug", false);
33  inputFileName_ = pset.getUntrackedParameter<string>("inputFile");
34  // Create the object to be written to DB
35  phaseMap_ = new DTTPGParameters();
36 
37  if(debug_)
38  cout << "[DTTPGParamsWriter]Constructor called!" << endl;
39 
40 }
41 
42 
43 
44 // Destructor
46 
47  if(debug_)
48  cout << "[DTTPGParamsWriter]Destructor called!" << endl;
49 
50 }
51 
52 // Do the job
53 void DTTPGParamsWriter::analyze(const Event & event, const EventSetup& eventSetup) {
54 
55  if(debug_)
56  cout << "[DTTPGParamsWriter]Reading data from file." << endl;
57 
58  std::ifstream inputFile_(inputFileName_.c_str());
59  int nLines=0;
61 
62  while(std::getline(inputFile_, line)) {
63  DTChamberId chId;
64  float fine = 0.;
65  int coarse = 0;
66  pharseLine(line,chId,fine,coarse);
67  phaseMap_->set(chId,coarse,fine,DTTimeUnits::ns);
68  if (debug_) {
69  float fineDB = 0.;
70  int coarseDB = 0;
71  phaseMap_->get(chId,coarseDB,fineDB,DTTimeUnits::ns);
72  std::cout << "[DTTPGParamsWriter] Read data for chamber " << chId
73  << ". File params -> fine: " << fine << " coarse: " << coarse
74  << ". DB params -> fine: " << fineDB << " coarse: " << coarseDB << std::endl;
75  }
76  nLines++;
77  }
78  if (debug_) {
79  std::cout << "[DTTPGParamsWriter] # of entries written the the DB: " << nLines << std::endl;
80  }
81  if (nLines!=250) {
82  std::cout << "[DTTPGParamsWriter] # of DB entries != 250. Check you input file!" << std::endl;
83  }
84 
85 
86  inputFile_.close();
87 
88 
89 }
90 
91 void DTTPGParamsWriter::pharseLine(std::string &line, DTChamberId& chId, float &fine, int &coarse) {
92 
93  std::vector<std::string> elements;
94  boost::algorithm::split(elements,line,boost::algorithm::is_any_of(string(" \t\n"))); // making string conversion explicit (needed to cope with -Warray-bounds in slc5_ia32_gcc434
95  if (elements.size() != 5) {
96  std::cout << "[DTTPGParamsWriter] wrong number of entries in line : " << line << " pleas check your input file syntax!" << std::endl;
97  } else {
98  chId = DTChamberId(atoi(elements[0].c_str()),atoi(elements[1].c_str()),atoi(elements[2].c_str()));
99  fine = atof(elements[3].c_str());
100  coarse = atoi(elements[4].c_str());
101  }
102 
103 }
104 
105 // Write objects to DB
107  if(debug_)
108  cout << "[DTTPGParamsWriter] Writing ttrig object to DB!" << endl;
109 
110  string delayRecord = "DTTPGParametersRcd";
111  DTCalibDBUtils::writeToDB(delayRecord, phaseMap_);
112 
113 }
T getUntrackedParameter(std::string const &, T const &) const
list elements
Definition: asciidump.py:414
void pharseLine(std::string &line, DTChamberId &chId, float &fine, int &coarse)
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
Compute the ttrig by fiting the TB rising edge.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual ~DTTPGParamsWriter()
Destructor.
void endJob()
Write ttrig in the DB.
tuple cout
Definition: gather_cfg.py:121
static void writeToDB(std::string record, T *payload)
double split
Definition: MVATrainer.cc:139
DTTPGParamsWriter(const edm::ParameterSet &pset)
Constructor.