CMS 3D CMS Logo

DTT0Handler.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2008/02/15 18:14:49 $
5  * $Revision: 1.3 $
6  * \author Paolo Ronchese INFN Padova
7  *
8  */
9 
10 //-----------------------
11 // This Class' Header --
12 //-----------------------
14 
15 //-------------------------------
16 // Collaborating Class Headers --
17 //-------------------------------
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 #include <iostream>
24 #include <fstream>
25 
26 //-------------------
27 // Initializations --
28 //-------------------
29 
30 //----------------
31 // Constructors --
32 //----------------
34  : dataTag(ps.getParameter<std::string>("tag")),
35  fileName(ps.getParameter<std::string>("file")),
36  runNumber(ps.getParameter<unsigned int>("run")) {}
37 
38 //--------------
39 // Destructor --
40 //--------------
42 
43 //--------------
44 // Operations --
45 //--------------
47  //to access the information on the tag inside the offline database:
48  cond::TagInfo_t const& ti = tagInfo();
50  std::cout << "last: " << last << std::endl;
51 
52  //to access the information on last successful log entry for this tag:
53  // cond::LogDBEntry const & lde = logDBEntry();
54 
55  //to access the lastest payload (Ref is a smart pointer)
56  // Ref payload = lastPayload();
57 
58  /*
59  int irun = event.id().run();
60  int ievt = event.id().event();
61  std::cout << "================ "
62  << irun << " " << ievt << std::endl;
63 
64  std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
65  std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
66  std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
67  std::cout << "list of all tags: " << std::endl;
68  while ( iter != iend ) {
69  std::cout << "Tag: " << iter->first
70  << " , last object valid since " << iter->second.last_since
71  << " to " << iter->second.last_till
72  << std::endl;
73  iter++;
74  }
75 
76  std::cout << "look for tag " << dataTag << std::endl;
77  std::map<std::string, popcon::PayloadIOV>::iterator itag =
78  mp.find( dataTag );
79 */
80 
81  DTT0* t0 = new DTT0(dataTag);
82 
83  int status = 0;
84  std::ifstream ifile(fileName.c_str());
85  int whe;
86  int sta;
87  int sec;
88  int qua;
89  int lay;
90  int cel;
91  float t0mean;
92  float t0rms;
93  while (ifile >> whe >> sta >> sec >> qua >> lay >> cel >> t0mean >> t0rms) {
94  status = t0->set(whe, sta, sec, qua, lay, cel, t0mean, t0rms, DTTimeUnits::counts);
95  std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << " " << t0mean << " "
96  << t0rms << " -> ";
97  std::cout << "insert status: " << status << std::endl;
98  }
99 
100  /*
101  unsigned int runf = irun;
102  unsigned int runl = 0xffffffff;
103  popcon::IOVPair iop = { runf, runl };
104  std::cout << "APPEND NEW OBJECT: "
105  << runf << " " << runl << " " << t0 << std::endl;
106  m_to_transfer->push_back( std::make_pair( t0, iop ) );
107 */
108 
109  //for each payload provide IOV information (say in this case we use since)
110  cond::Time_t snc = runNumber;
111  if (runNumber > last)
112  m_to_transfer.push_back(std::make_pair(t0, snc));
113  else {
114  std::cout << "More recent data already present - skipped" << std::endl;
115  delete t0;
116  }
117 
118  return;
119 }
120 
unsigned int runNumber
Definition: DTT0Handler.h:53
std::string dataTag
Definition: DTT0Handler.h:51
Iov_t lastInterval
Definition: Types.h:73
void getNewObjects() override
Definition: DTT0Handler.cc:46
DTT0Handler(const edm::ParameterSet &ps)
Definition: DTT0Handler.cc:33
Time_t since
Definition: Types.h:53
cond::TagInfo_t const & tagInfo() const
Definition: DTT0.h:48
unsigned long long Time_t
Definition: Time.h:14
std::vector< std::pair< DTT0 *, Time_t > > m_to_transfer
~DTT0Handler() override
Definition: DTT0Handler.cc:41
std::string fileName
Definition: DTT0Handler.h:52
std::string id() const override
Definition: DTT0Handler.cc:121