CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CondDBImport.cc
Go to the documentation of this file.
1 //
2 
3 //TO DO: add the comparison between stored object and input object - bool cond::serialization::equal( obj,read_back_copy )
4 #define IMPORT_PAYLOAD_CASE( TYPENAME ) \
5  if( inputTypeName == #TYPENAME ){ \
6  match = true; \
7  const TYPENAME& obj = *static_cast<const TYPENAME*>( inputPtr ); \
8  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() ); \
9  }
10 
11 #define IGNORE_FOR_IMPORT_CASE( TYPENAME ) \
12  if( inputTypeName == #TYPENAME ){ \
13  match = true; \
14  payloadId = 0; \
15  newInsert = false; \
16  std::cout <<"WARNING: typename "<<inputTypeName<<" will be skipped in the import."<<std::endl; \
17  }
18 
19 #define FETCH_PAYLOAD_CASE( TYPENAME ) \
20  if( payloadTypeName == #TYPENAME ){ \
21  auto payload = deserialize<TYPENAME>( payloadTypeName, data, streamerInfo, isOra ); \
22  payloadPtr = payload; \
23  match = true; \
24  }
25 
33 
36 #include "CondFormats.h"
37 
38 //
39 #include <sstream>
40 
41 namespace cond {
42 
43  namespace persistency {
44 
45  cond::Hash import( const std::string& inputTypeName, const void* inputPtr, Session& destination ){
46  cond::Hash payloadId("");
47  bool newInsert = false;
48  bool match = false;
49  if( inputPtr ){
51  IMPORT_PAYLOAD_CASE( std::vector<unsigned long long> )
242  //IMPORT_PAYLOAD_CASE( PerformancePayload )
294  if( inputTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
295  match = true;
297  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
298  }
299  if( inputTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
300  match = true;
302  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
303  }
304  if( inputTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
305  match = true;
306  const std::vector<unsigned long long>& obj = *static_cast<const std::vector<unsigned long long>*>( inputPtr );
307  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
308  }
309 
310  if( ! match ) throwException( "Payload type \""+inputTypeName+"\" is unknown.","import" );
311  }
312  return payloadId;
313  }
314 
315  std::pair<std::string,boost::shared_ptr<void> > fetch( const cond::Hash& payloadId, Session& session ){
316  boost::shared_ptr<void> payloadPtr;
318  cond::Binary streamerInfo;
319  std::string payloadTypeName;
320  bool found = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
321  if( !found ) throwException( "Payload with id "+boost::lexical_cast<std::string>(payloadId)+" has not been found in the database.","fetchAndCompare" );
322  //std::cout <<"--> payload type "<<payloadTypeName<<" has blob size "<<data.size()<<std::endl;
323  bool isOra = session.isOraSession();
324  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr, isOra);
325  }
326  std::pair<std::string, boost::shared_ptr<void> > fetchOne( const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, boost::shared_ptr<void> payloadPtr, bool isOra ){
327 
328  bool match = false;
330  FETCH_PAYLOAD_CASE( std::vector<unsigned long long> )
498  //FETCH_PAYLOAD_CASE( PerformancePayload )
550 
551  //
552  if( payloadTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
553  auto payload = deserialize<PhysicsTools::Calibration::Histogram3D<double,double,double,double> >(payloadTypeName, data, streamerInfo, isOra );
554  payloadPtr = payload;
555  match = true;
556  }
557  if( payloadTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
558  auto payload = deserialize<PhysicsTools::Calibration::Histogram2D<double,double,double> >(payloadTypeName, data, streamerInfo, isOra );
559  payloadPtr = payload;
560  match = true;
561  }
562  if( payloadTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
563  auto payload = deserialize<std::vector<unsigned long long> >( payloadTypeName, data, streamerInfo, isOra );
564  payloadPtr = payload;
565  match = true;
566  }
567 
568  if( ! match ) throwException( "Payload type \""+payloadTypeName+"\" is unknown.","fetch" );
569  return std::make_pair( payloadTypeName, payloadPtr );
570  }
571 
572  }
573 }
574 
Definition: ESGain.h:7
string destination
std::pair< std::string, boost::shared_ptr< void > > fetchOne(const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, boost::shared_ptr< void > payloadPtr, bool is Ora)
#define FETCH_PAYLOAD_CASE(TYPENAME)
Definition: CondDBImport.cc:19
Definition: DTT0.h:53
QGLikelihoodObject containing valid range and entries with category, histogram and mean...
#define IMPORT_PAYLOAD_CASE(TYPENAME)
Definition: CondDBImport.cc:4
std::string Hash
Definition: Types.h:43
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:174
std::pair< std::string, boost::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
Category structure: ranges associated with QGLikelihood histograms.
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
QGLikelihoodSystematicsObject containing the parameters for the systematic smearing.
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11