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().payloadName<< "\n"
66  << this->logDBEntry().payloadToken<< "\n"
67  << this->logDBEntry().payloadContainer<< "\n"
68  << this->logDBEntry().exectime<< "\n"
69  << this->logDBEntry().execmessage<< "\n"
70  << "\n\n-- user text " << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@")) ;
71  } else {
72  ss << " First object for this tag ";
73  }
74  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << ss.str();
75  }
76  if (isTransferNeeded())
78 
79  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
80  }
81 
82 
83  //---------------------------------------
84  //
85  std::string id() const { return m_name;}
86 
87  //---------------------------------------
88  //
90 
91 
92  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[isTransferNeeded] checking for transfer: " << typeid(T).name() << std::endl;
93  std::stringstream ss_logdb, ss;
94 
95  //get log information from previous upload
96  if (this->logDBEntry().usertext!="")
97  ss_logdb << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_first_of("@"));
98  else
99  ss_logdb << "";
100 
101  std::string label="";
102  if(typeid(T)==typeid(SiStripFedCabling))
103  label="Cabling";
104 
105  if(typeid(T)==typeid(SiStripApvGain))
106  label="ApvTiming";
107 
108  if(typeid(T)==typeid(SiStripLatency))
109  label="ApvLatency";
110 
111  if(!condObjBuilder->checkForCompatibility(ss_logdb,ss,label)){
112  //string are equal, no need to do transfer
113  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler")
114  << "[isTransferNeeded] the selected conditions are already uploaded in the last iov ("
115  << this->tagInfo().lastInterval.first << ") open for the object "
116  << this->logDBEntry().payloadName << " in the db "
117  << this->logDBEntry().destinationDB << " parameters: " << ss_logdb.str() << "\n NO TRANSFER NEEDED";
118  return false;
119  }
120 
121  this->m_userTextLog = ss.str();
122  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler")
123  << "[isTransferNeeded] the selected conditions will be uploaded: " << ss.str()
124  << "\n Going to Upload: "<< ss.str() << "\n Last Upload: " << ss_logdb.str() << "\n Fine";
125 
126  return true;
127  }
128 
129 
130  //---------------------------------------
131  //
133  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[setForTransfer] " << m_name << " getting data to be transferred " << std::endl;
134 
135  T *obj=0;
136  condObjBuilder->getValue(obj);
137 
138  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") << "[setForTransfer] " << m_name << " got data to be transferred from condObjBuilder " << std::endl;
139 
140  if(!this->tagInfo().size)
141  m_since=1;
142  else
143  if (m_debugMode)
144  m_since=this->tagInfo().lastInterval.first+1;
145  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") <<"[setForTransfer] setting since = "<< m_since <<std::endl;
146 
147  if (obj!=0){
148 
149  edm::LogInfo ("SiStripPopPopConConfigDbObjHandler") <<"[setForTransfer] filling map m_to_transfer" <<std::endl;
150  this->m_to_transfer.push_back(std::make_pair(obj,m_since));
151  }else{
152  edm::LogError ("SiStripPopPopConConfigDbObjHandler") <<"[setForTransfer] " << m_name << " : NULL pointer of obj " << typeid(T).name() << " reported by SiStripCondObjBuilderFromDb\n Transfer aborted"<<std::endl;
153  }
154  }
155 
156  private:
157  // data members
158  std::string m_name;
159  unsigned long long m_since;
162  };
163 }
164 
165 #endif //SISTRIPPOPCON_CONFIGDB_HANDLER_H
std::string exectime
Definition: LogDBEntry.h:18
std::string usertext
Definition: LogDBEntry.h:10
std::string iovtimetype
Definition: LogDBEntry.h:12
std::string const & userTextLog() const
const std::string & label
Definition: MVAComputer.cc:186
edm::Service< SiStripCondObjBuilderFromDb > condObjBuilder
unsigned int payloadIdx
Definition: LogDBEntry.h:13
std::string payloadToken
Definition: LogDBEntry.h:16
unsigned long long logId
Definition: LogDBEntry.h:7
std::string payloadName
Definition: LogDBEntry.h:15
std::string destinationDB
Definition: LogDBEntry.h:8
SiStripPopConConfigDbObjHandler(const edm::ParameterSet &pset)
std::string lastPayloadToken
Definition: TagInfo.h:12
cond::TagInfo const & tagInfo() const
std::string name
Definition: TagInfo.h:9
cond::LogDBEntry const & logDBEntry() const
bool checkForCompatibility(std::stringstream &input, std::stringstream &output, std::string &label)
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
void getValue(SiStripFedCabling *&val)
std::string execmessage
Definition: LogDBEntry.h:19
tuple pset
Definition: CrabTask.py:85
size_t size
Definition: TagInfo.h:13
std::string payloadContainer
Definition: LogDBEntry.h:17
std::string token
Definition: TagInfo.h:10
std::string provenance
Definition: LogDBEntry.h:9
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
std::string iovtag
Definition: LogDBEntry.h:11
tuple size
Write out results.