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