CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTMtimeHandler.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2008/09/29 13:12:46 $
5  * $Revision: 1.4 $
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 //----------------
32 // Constructors --
33 //----------------
35  dataTag( ps.getParameter<std::string> ( "tag" ) ),
36  fileName( ps.getParameter<std::string> ( "file" ) ),
37  runNumber( ps.getParameter<unsigned int> ( "run" ) ) {
38 }
39 
40 //--------------
41 // Destructor --
42 //--------------
44 }
45 
46 //--------------
47 // Operations --
48 //--------------
50 
51  //to access the information on the tag inside the offline database:
52  cond::TagInfo const & ti = tagInfo();
53  unsigned int last = ti.lastInterval.first;
54 
55  //to access the information on last successful log entry for this tag:
56 // cond::LogDBEntry const & lde = logDBEntry();
57 
58  //to access the lastest payload (Ref is a smart pointer)
59 // Ref payload = lastPayload();
60 
61 /*
62  int irun = event.id().run();
63  int ievt = event.id().event();
64  std::cout << "================ "
65  << irun << " " << ievt << std::endl;
66 
67 // edm::Service<cond::service::PoolDBOutputService> dbservice;
68 
69  std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
70  std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
71  std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
72  std::cout << "list of all tags: " << std::endl;
73  while ( iter != iend ) {
74  std::cout << "Tag: " << iter->first
75  << " , last object valid since " << iter->second.last_since
76  << " to " << iter->second.last_till
77  << std::endl;
78  iter++;
79  }
80 
81  std::cout << "look for tag " << dataTag << std::endl;
82  std::map<std::string, popcon::PayloadIOV>::iterator itag =
83  mp.find( dataTag );
84 */
85 
86  DTMtime* mTime = new DTMtime( dataTag );
87 
88  int status = 0;
89  std::ifstream ifile( fileName.c_str() );
90  int whe;
91  int sta;
92  int sec;
93  int qua;
94  float mti;
95  float rms;
96  while ( ifile >> whe
97  >> sta
98  >> sec
99  >> qua
100  >> mti
101  >> rms ) {
102  status = mTime->set( whe, sta, sec, qua, mti, rms,
104  std::cout << whe << " "
105  << sta << " "
106  << sec << " "
107  << qua << " "
108  << mti << " "
109  << rms << " -> ";
110  std::cout << "insert status: " << status << std::endl;
111  }
112 
113 /*
114  unsigned int runf = irun;
115  unsigned int runl = 0xffffffff;
116  popcon::IOVPair iop = { runf, runl };
117  std::cout << "APPEND NEW OBJECT: "
118  << runf << " " << runl << " " << mTime << std::endl;
119  m_to_transfer->push_back( std::make_pair( mTime, iop ) );
120 */
121 
122  //for each payload provide IOV information (say in this case we use since)
123  cond::Time_t snc = runNumber;
124  if ( runNumber > last )
125  m_to_transfer.push_back( std::make_pair( mTime, snc ) );
126  else
127  std::cout << "More recent data already present - skipped" << std::endl;
128 
129  return;
130 
131 }
132 
133 
135  return dataTag;
136 }
137 
138 
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:266
unsigned int runNumber
std::string fileName
cond::TagInfo const & tagInfo() const
unsigned long long Time_t
Definition: Time.h:16
virtual ~DTMtimeHandler()
std::string dataTag
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
DTMtimeHandler(const edm::ParameterSet &ps)
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
std::string id() const