CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripPopConConfigDbObjHandler.h
Go to the documentation of this file.
1 #ifndef SISTRIPPOPCON_CONFIGDB_HANDLER_H
2 #define SISTRIPPOPCON_CONFIGDB_HANDLER_H
3 
9 
13 
17 
18 #include <sstream>
19 #include <vector>
20 #include <string>
21 #include <iostream>
22 #include <typeinfo>
23 
24 namespace popcon{
25 
26  template <typename T>
28  public:
29 
30  //---------------------------------------
31  //
33  m_name(pset.getUntrackedParameter<std::string>("name","SiStripPopPopConConfigDbObjHandler")),
34  m_since(pset.getUntrackedParameter<uint32_t>("since",5)),
35  m_debugMode(pset.getUntrackedParameter<bool>("debug",false)){};
36 
37  //---------------------------------------
38  //
40 
41  //---------------------------------------
42  //
43  void getNewObjects(){
44  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[getNewObjects] for PopCon application " << m_name;
45 
46  if (m_debugMode){
47  std::stringstream ss;
48  ss << "\n\n------- " << m_name
49  << " - > getNewObjects\n";
50  if (this->tagInfo().size){
51  //check whats already inside of database
52  ss << "got offlineInfo"<<
53  this->tagInfo().name << ", size " << this->tagInfo().size << " " << this->tagInfo().token
54  << " , last object valid since "
55  << this->tagInfo().lastInterval.first << " token "
56  << this->tagInfo().lastPayloadToken << "\n\n UserText " << this->userTextLog()
57  << "\n LogDBEntry \n"
58  << this->logDBEntry().logId<< "\n"
59  << this->logDBEntry().destinationDB<< "\n"
60  << this->logDBEntry().provenance<< "\n"
61  << this->logDBEntry().usertext<< "\n"
62  << this->logDBEntry().iovtag<< "\n"
63  << this->logDBEntry().iovtimetype<< "\n"
64  << this->logDBEntry().payloadIdx<< "\n"
65  << this->logDBEntry().payloadClass<< "\n"
66  << this->logDBEntry().payloadToken<< "\n"
67  << this->logDBEntry().exectime<< "\n"
68  << this->logDBEntry().execmessage<< "\n"
69  << "\n\n-- user text " << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")) ;
70  } else {
71  ss << " First object for this tag ";
72  }
73  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << ss.str();
74  }
75  if (isTransferNeeded())
77 
78  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
79  }
80 
81 
82  //---------------------------------------
83  //
84  std::string id() const { return m_name;}
85 
86  //---------------------------------------
87  //
89 
90 
91  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[isTransferNeeded] checking for transfer: " << typeid(T).name() << std::endl;
92  std::stringstream ss_logdb, ss;
93 
94  //get log information from previous upload
95  if (this->logDBEntry().usertext!="")
96  ss_logdb << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_first_of("@"));
97  else
98  ss_logdb << "";
99 
100  std::string label="";
101  if(typeid(T)==typeid(SiStripFedCabling))
102  label="Cabling";
103 
104  if(typeid(T)==typeid(SiStripApvGain))
105  label="ApvTiming";
106 
107  if(typeid(T)==typeid(SiStripLatency))
108  label="ApvLatency";
109 
110  if(!condObjBuilder->checkForCompatibility(ss_logdb,ss,label)){
111  //string are equal, no need to do transfer
112  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler")
113  << "[isTransferNeeded] the selected conditions are already uploaded in the last iov ("
114  << this->tagInfo().lastInterval.first << ") open for the object "
115  << this->logDBEntry().payloadClass << " in the db "
116  << this->logDBEntry().destinationDB << " parameters: " << ss_logdb.str() << "\n NO TRANSFER NEEDED";
117  return false;
118  }
119 
120  this->m_userTextLog = ss.str();
121  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler")
122  << "[isTransferNeeded] the selected conditions will be uploaded: " << ss.str()
123  << "\n Going to Upload: "<< ss.str() << "\n Last Upload: " << ss_logdb.str() << "\n Fine";
124 
125  return true;
126  }
127 
128 
129  //---------------------------------------
130  //
132  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[setForTransfer] " << m_name << " getting data to be transferred " << std::endl;
133 
134  T *obj=0;
135  condObjBuilder->getValue(obj);
136 
137  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[setForTransfer] " << m_name << " got data to be transferred from condObjBuilder " << std::endl;
138 
139  if(!this->tagInfo().size)
140  m_since=1;
141  else
142  if (m_debugMode)
143  m_since=this->tagInfo().lastInterval.first+1;
144  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") <<"[setForTransfer] setting since = "<< m_since <<std::endl;
145 
146  if (obj!=0){
147 
148  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") <<"[setForTransfer] filling map m_to_transfer" <<std::endl;
149  this->m_to_transfer.push_back(std::make_pair(obj,m_since));
150  }else{
151  edm::LogError ("SiStripPopPopConConfigDbObjHandler") <<"[setForTransfer] " << m_name << " : NULL pointer of obj " << typeid(T).name() << " reported by SiStripCondObjBuilderFromDb\n Transfer aborted"<<std::endl;
152  }
153  }
154 
155  private:
156  // data members
158  unsigned long long m_since;
161  };
162 }
163 
164 #endif //SISTRIPPOPCON_CONFIGDB_HANDLER_H
std::string exectime
Definition: LogDBEntry.h:27
std::string usertext
Definition: LogDBEntry.h:20
std::string iovtimetype
Definition: LogDBEntry.h:22
std::string const & userTextLog() const
edm::Service< SiStripCondObjBuilderFromDb > condObjBuilder
unsigned int payloadIdx
Definition: LogDBEntry.h:23
std::string payloadToken
Definition: LogDBEntry.h:26
unsigned long long logId
Definition: LogDBEntry.h:17
size_t size
Definition: Types.h:72
std::string payloadClass
Definition: LogDBEntry.h:25
std::string destinationDB
Definition: LogDBEntry.h:18
SiStripPopConConfigDbObjHandler(const edm::ParameterSet &pset)
std::string name
Definition: Types.h:68
cond::LogDBEntry const & logDBEntry() const
cond::ValidityInterval lastInterval
Definition: Types.h:70
bool checkForCompatibility(std::stringstream &input, std::stringstream &output, std::string &label)
void getValue(SiStripFedCabling *&val)
std::string execmessage
Definition: LogDBEntry.h:28
std::string lastPayloadToken
Definition: Types.h:71
std::string provenance
Definition: LogDBEntry.h:19
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
volatile std::atomic< bool > shutdown_flag false
long double T
std::string iovtag
Definition: LogDBEntry.h:21
tuple size
Write out results.
std::string token
Definition: Types.h:69
cond::TagInfo_t const & tagInfo() const