CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Attributes
popcon::EcalIntercalibHandler Class Reference

#include <EcalIntercalibHandler.h>

Inheritance diagram for popcon::EcalIntercalibHandler:
popcon::PopConSourceHandler< EcalIntercalibConstants >

Public Member Functions

 EcalIntercalibHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
 ~EcalIntercalibHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalIntercalibConstants >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Public Attributes

EcalCondDBInterfaceeconn
 

Private Attributes

std::string m_file_highfield
 
std::string m_file_lowfield
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_lastRun
 
std::string m_location
 
std::string m_locationsource
 
std::string m_name
 
std::string m_pass
 
std::string m_sid
 
std::string m_user
 
double m_value_highfield
 
const EcalIntercalibConstantsmyintercalib
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalIntercalibConstants >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalIntercalibConstants
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalIntercalibConstants
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalIntercalibConstants value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalIntercalibConstants >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalIntercalibConstants >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 56 of file EcalIntercalibHandler.h.

Constructor & Destructor Documentation

popcon::EcalIntercalibHandler::EcalIntercalibHandler ( edm::ParameterSet const &  ps)

Definition at line 8 of file EcalIntercalibHandler.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_file_highfield, m_file_lowfield, m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_sid, m_user, m_value_highfield, and AlCaHLTBitMon_QueryRunRegistry::string.

9  : m_name(ps.getUntrackedParameter<std::string>("name","EcalIntercalibHandler")) {
10 
11  std::cout << "EcalIntercalib Source handler constructor\n" << std::endl;
12  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
13  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
14  m_sid= ps.getParameter<std::string>("OnlineDBSID");
15  m_user= ps.getParameter<std::string>("OnlineDBUser");
16  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
17  m_locationsource= ps.getParameter<std::string>("LocationSource");
18  m_location=ps.getParameter<std::string>("Location");
19  m_gentag=ps.getParameter<std::string>("GenTag");
20  m_file_lowfield= ps.getParameter<std::string>("FileLowField");
21  m_file_highfield= ps.getParameter<std::string>("FileHighField");
22  m_value_highfield= ps.getUntrackedParameter< double >("Value_Bon");
23  // m_value_highfield= 0.75585;
24 
25 
26 
27  std::cout << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag << std::endl;
28 
29 }
tuple cout
Definition: gather_cfg.py:145
popcon::EcalIntercalibHandler::~EcalIntercalibHandler ( )

Definition at line 31 of file EcalIntercalibHandler.cc.

32 {
33 }

Member Function Documentation

void popcon::EcalIntercalibHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalIntercalibConstants >.

Definition at line 36 of file EcalIntercalibHandler.cc.

References gather_cfg::cout, createfilelist::dataset, Exception, RunDCSMagnetDat::getMagnetCurrent(), RunIOV::getRunNumber(), DetId::rawId(), EcalFloatCondObjectContainerXMLTranslator::readXML(), findQualityFiles::size, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, dumpRecoGeometry_cfg::tagInfo, and EEDetId::validDetId().

37 {
38 
39  std::cout << "------- Ecal - > getNewObjects\n";
40 
41  std::ostringstream ss;
42  ss<<"ECAL ";
43 
44  unsigned int max_since=0;
45  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
46  std::cout << "max_since : " << max_since << std::endl;
47  bool something_to_transfer = false;
48  bool magnet_high = true;
49  if(tagInfo().size) {
50  Ref ped_db = lastPayload();
51 
52  // we parse the last record in the DB and check if it is low or high field
53 
54  std::cout << "retrieved last payload " << std::endl;
55 
56 
57  EcalIntercalibConstant the_cal = 0. ; // relies on it being a float.
58  // instead should perhaps
59  // protect the next if when
60  // the EEDetId isn't valid?
61 
62  int iX=50;
63  int iY=5;
64  int iZ=-1;
65 
66 
67  float the_value_high=(float)m_value_highfield;
68  std::cout << "The value for high field at EE x/y/z= 50/5/-1 is " << the_value_high << std::endl;
69 
70  if (EEDetId::validDetId(iX,iY,iZ))
71  {
72  EEDetId eedetidpos(iX,iY,iZ);
73 
74  EcalIntercalibConstants::const_iterator it =ped_db->find(eedetidpos.rawId());
75 
76 
77  the_cal = (*it);
78 
79  }
80 
81  if(the_cal!= the_value_high) magnet_high=false;
82  } // check if there is already a payload
83  else something_to_transfer = true;
84 
85  // here we connect to the online DB to check the value of the magnetic field
86  std::cout << "Connecting to ONLINE DB ... " << std::endl;
88  std::cout << "Connection done" << std::endl;
89 
90  if (!econn)
91  {
92  std::cout << " Problem with OMDS: connection parameters " <<m_sid <<"/"<<m_user<<"/"<<m_pass<<std::endl;
93  throw cms::Exception("OMDS not available");
94  }
95 
96 
97  std::cout << "Retrieving last run from ONLINE DB ... " << std::endl;
98  std::map<EcalLogicID, RunDat> rundat;
99  RunIOV rp ;
100  run_t runmax=10000000;
101  std::string location_p5="P5_Co";
102  econn->fetchValidDataSet(&rundat , &rp, location_p5 ,runmax);
103 
104  unsigned long long irun=(unsigned long long) rp.getRunNumber();
105 
106  std::cout<< "retrieved run number "<< irun <<std::endl;
107 
108  if(irun>max_since) {
109  // retrieve from last value data record
110  // always call this method at first run
111 
112  std::map<EcalLogicID, RunDCSMagnetDat> dataset;
113 
114  econn->fetchDataSet(&dataset, &rp);
115 
116  if (!dataset.size()) {
117  throw(std::runtime_error("Zero rows read back"));
118  } else {
119  std::cout<< "retrieved magnet current"<<std::endl;
120  }
121 
122 
123  float mag_cur=0;
124 
125  std::map< EcalLogicID, RunDCSMagnetDat >::iterator it;
126  for (it=dataset.begin(); it!=dataset.end(); ++it){
127 
128  RunDCSMagnetDat a_mag = (*it).second;
129  mag_cur= a_mag.getMagnetCurrent();
130 
131  }
132 
133 
135  if(tagInfo().size) {
136 
137  if(mag_cur>7000. && magnet_high ) {
138 
139  std::cout << " the magnet is ON and the constants are for magnet ON " << std::endl;
140 
141  } else if(mag_cur>7000. && !magnet_high ) {
142  something_to_transfer=true;
143  std::cout << " the magnet is ON and the constants are for magnet OFF " << std::endl;
144  std::cout << " I transfer the ON constants "<< std::endl;
145  file_=m_file_highfield;
146 
147  } else if(mag_cur<6000. && magnet_high ) {
148  something_to_transfer=true;
149  std::cout << " the magnet is OFF and the constants are for magnet ON "<< std::endl;
150  std::cout << " I transfer the OFF constants "<< std::endl;
151  file_=m_file_lowfield;
152 
153  } else if( mag_cur<6000. && !magnet_high ){
154 
155  std::cout << " the magnet is OFF and the constants are for magnet OFF "<< std::endl;
156  file_=m_file_lowfield;
157 
158  } else {
159 
160  std::cout << " the magnet is in a strange situation I do nothing ... just be patient "<< std::endl;
161 
162  }
163  }
164  else {
165  if(mag_cur>7000.)
166  std::cout <<" first payload, the magnet is ON " << std::endl;
167  else if( mag_cur<6000.) {
168  std::cout <<" first payload, the magnet is OFF " << std::endl;
169  file_=m_file_lowfield;
170  }
171  else
172  std::cout << " the magnet is in a strange situation I do nothing ... just be patient "<< std::endl;
173  }
174 
175  if(something_to_transfer){
176 
177  std::cout << "Generating popcon record for run " << irun << "..." << std::flush;
178  std::cout << "going to open file "<<file_ << std::flush;
179 
180 
181  EcalCondHeader header;
184 
185 
186  Time_t snc= (Time_t) irun ;
187 
189  std::make_pair(payload,snc));
190 
191  ss << "Run=" << irun << "_Magnet_changed_"<<std::endl;
192  m_userTextLog = ss.str()+";";
193 
194  } else {
195  std::cout << "Run " << irun << " nothing sent to the DB"<< std::endl;
196 
197  ss<< "Run=" << irun << "_Magnet_NOT_changed_"<<std::endl;
198  m_userTextLog = ss.str()+";";
199  }
200 
201  delete econn;
202  } // irun > max_since
203  else {
204  std::cout << "Run " << irun << " nothing sent to the DB"<< std::endl;
205  ss<< "Run=" << irun << "_no_new_runs_"<<std::endl;
206  m_userTextLog = ss.str()+";";
207  }
208  std::cout << "Ecal - > end of getNewObjects -----------\n";
209 }
int run_t
Definition: CaliIOV.h:11
void fetchValidDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *fillIOV, RunTag *tag, run_t run=(unsigned int)-1)
size_t size
Definition: Types.h:75
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
float getMagnetCurrent() const
cond::ValidityInterval lastInterval
Definition: Types.h:73
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< Item >::const_iterator const_iterator
run_t getRunNumber() const
Definition: RunIOV.cc:45
EcalIntercalibConstantMap EcalIntercalibConstants
tuple cout
Definition: gather_cfg.py:145
Definition: RunIOV.h:13
tuple size
Write out results.
float EcalIntercalibConstant
std::string popcon::EcalIntercalibHandler::id ( ) const
inlinevirtual

Implements popcon::PopConSourceHandler< EcalIntercalibConstants >.

Definition at line 65 of file EcalIntercalibHandler.h.

References m_name.

65 { return m_name;}

Member Data Documentation

EcalCondDBInterface* popcon::EcalIntercalibHandler::econn

Definition at line 66 of file EcalIntercalibHandler.h.

std::string popcon::EcalIntercalibHandler::m_file_highfield
private

Definition at line 84 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_file_lowfield
private

Definition at line 83 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

unsigned int popcon::EcalIntercalibHandler::m_firstRun
private

Definition at line 73 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_gentag
private

Definition at line 77 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

unsigned int popcon::EcalIntercalibHandler::m_lastRun
private

Definition at line 74 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_location
private

Definition at line 76 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_locationsource
private

Definition at line 81 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_name
private

Definition at line 82 of file EcalIntercalibHandler.h.

Referenced by id().

std::string popcon::EcalIntercalibHandler::m_pass
private

Definition at line 80 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_sid
private

Definition at line 78 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

std::string popcon::EcalIntercalibHandler::m_user
private

Definition at line 79 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

double popcon::EcalIntercalibHandler::m_value_highfield
private

Definition at line 85 of file EcalIntercalibHandler.h.

Referenced by EcalIntercalibHandler().

const EcalIntercalibConstants* popcon::EcalIntercalibHandler::myintercalib
private

Definition at line 71 of file EcalIntercalibHandler.h.