| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# NTupleInterface.cpp

Go to the documentation of this file.

    00001 #include "GaudiKernel/NTuple.h"
    00002 #include "HbookDef.h"
    00003 #include "NTupleInfo.h"
    00004 #include <climits>
    00005
    00006 #ifdef _WIN32
    00007 extern"C" {
    00008  long HBOOK_CALL_TYPE RWNTBOOK( const long& id,
    00009                                 const long& dim,
    00010                                 const char tag[512][64], long,
    00011                                 const char* rzdir, long,
    00012                                 const char* title, long);
    00013  long HBOOK_CALL_TYPE RWNTINFO( const long& id,
    00014                                 long& dim,
    00015                                 long& ents,
    00016                                 char tags[512][64], long,
    00017                                 double range[512][2],
    00018                                 char title[], long);
    00019  long HBOOK_CALL_TYPE CWNTBOOK( const long& id,
    00020                                 const char title[], long,
    00021                                 const char opt[], long);
    00022  long HBOOK_CALL_TYPE CWNTINFO( const long& id,
    00023                                 char name[512][64], long,
    00024                                 long dim[],
    00025                                 long theDim[512][5],
    00026                                 long hasIndex[],
    00027                                 char index[512][64], long,
    00028                                 char type[], long,
    00029                                 long size[],
    00030                                 long hasRange[],
    00031                                 long irange[512][2],
    00032                                 double frange[512][2],
    00033                                 char title[], long,
    00034                                 long& numVar,
    00035                                 long& numEnt,
    00036                                 char block[512][12], long);
    00037   void HBOOK_CALL_TYPE HBNAME  (const long& id,
    00038         const char* title, int,
    00039         const void* opt,
    00040         const char* form, int);
    00041
    00042   void HBOOK_CALL_TYPE HROPEN  (const long& lun,
    00043         const char*, int,
    00044         const char*, int,
    00045         const char*, int,
    00046         long&, long&);
    00047   void HBOOK_CALL_TYPE HLNEXT  (long& id,
    00048         char*, int,
    00049         char*, int,
    00050         const char*, int);
    00051   void HBOOK_CALL_TYPE HLDIR   (const char*, int,
    00052         const char*, int);
    00053   void HBOOK_CALL_TYPE HCDIR(const char*, int, const char*, int);
    00054   void HBOOK_CALL_TYPE HMDIR(const char*, int, const char*, int);
    00055 }
    00056
    00057 long RWNT_BOOK ( const NTUPLEINFO& i )  {
    00058   return ::RWNTBOOK(i.id,
    00059         i.numVar,
    00060         i.name, sizeof(i.name[0]),
    00061         i.rzdir, strlen(i.rzdir),
    00062         i.title, strlen(i.title));
    00063 }
    00064
    00065 long RWNT_INFO ( NTUPLEINFO& i ) {
    00066   long r=::RWNTINFO(i.id, i.numVar, i.numEnt, i.name, sizeof(i.name[0]), i.frange, i.title, sizeof(i.title));
    00067   for ( long j = 0; j < i.numVar; j++ )   {
    00068     i.size[j] = sizeof(float)*CHAR_BIT;
    00069     i.dim[j] = 0;
    00070     i.hasRange[j] = 0;
    00071     i.hasIndex[j] = 0;
    00072   }
    00073   memset(i.block,0,sizeof(i.block));
    00074   return r;
    00075 }
    00076
    00077 long CWNT_BOOK ( const NTUPLEINFO& i )  {
    00078   return ::CWNTBOOK(i.id, i.title, strlen(i.title)," ", 1);
    00079 }
    00080
    00081 long CWNT_INFO ( NTUPLEINFO& i ) {
    00082   long r=::CWNTINFO(i.id,
    00083                     i.name, sizeof(i.name[0]),
    00084                     i.dim,
    00085                     i.theDim,
    00086                     i.hasIndex,
    00087                     i.index, sizeof(i.index[0]),
    00088                     i.type, 1,
    00089                     i.size,
    00090                     i.hasRange,
    00091                     i.irange,
    00092                     i.frange,
    00093                     i.title,sizeof(i.title)-1,
    00094                     i.numVar,
    00095                     i.numEnt,
    00096                     i.block,sizeof(i.block[0])
    00097                     );
    00098   // Clean up ntuple block names
    00099   for (long iv=0; iv<i.numVar; ++iv) {
    00100     std::string blk = i.block[iv];
    00101     blk = blk.substr(0,8);
    00102     int ibs;
    00103     if ( (ibs = blk.find(" ")) >= 0 ) {
    00104       blk = blk.substr(0,ibs);
    00105     }
    00106     strcpy(i.block[iv],blk.c_str());
    00107   }
    00108   //  cleanForString(i.block, sizeof(i.block)-1);
    00109   cleanForString(i.title, sizeof(i.title)-1);
    00110   return r;
    00111 }
    00112
    00113 void HLNEXT(long& id, std::string& a, std::string& b, const std::string& c) {
    00114   char buff[256], typ[2] = {0,0};
    00115   memset(buff,0,sizeof(buff));
    00116   ::HLNEXT(id, typ, sizeof(typ)-1, buff, sizeof(buff), c.data(), c.length());
    00117   buff[sizeof(buff)-1] = 0;
    00118   cleanForString(buff, sizeof(buff)-1);
    00119   b = buff;
    00120   a = typ;
    00121 }
    00122
    00123 void HCDIR(const std::string& a, const std::string& b )  {
    00124   ::HCDIR(a.data(), a.length(), b.data(), b.length());
    00125 }
    00126
    00127 void HLDIR(const std::string& a, const std::string& b )  {
    00128   ::HLDIR(a.data(), a.length(), b.data(), b.length());
    00129 }
    00130
    00131 void HMDIR(const std::string& a, const std::string& b )  {
    00132   ::HMDIR(a.data(), a.length(), b.data(), b.length());
    00133 }
    00134
    00135 void HBNAME (const long& id, const std::string& a, const void* opt, const std::string& b) {
    00136   ::HBNAME(id, a.data(), a.length(), opt, b.data(), b.length());
    00137 }
    00138
    00139 void HROPEN(const long& lun, const std::string& a, const std::string& b, const std::string& c, long& i, long& j) {
    00140   ::HROPEN(lun, a.data(), a.length(), b.data(), b.length(), c.data(), c.length(), i, j);
    00141 }
    00142
    00143 #else
    00144 extern"C" {
    00145  long HBOOK_CALL_TYPE rwntbook_(const long& id,
    00146                                 const long& dim,
    00147                                 const char tag[512][64],
    00148                                 const char* rzdir,
    00149                                 const char* title, long, long, long);
    00150  long HBOOK_CALL_TYPE rwntinfo_(const long& id,
    00151                                 long& dim,
    00152                                 long& ents,
    00153                                 char tags[512][64],
    00154                                 double range[512][2],
    00155                                 char title[], long, long);
    00156  long HBOOK_CALL_TYPE cwntbook_(const long& id,
    00157                                 const char title[],
    00158                                 const char opt[], long, long);
    00159  long HBOOK_CALL_TYPE cwntinfo_(const long& id,
    00160                                 char name[512][64],
    00161                                 long dim[],
    00162                                 long theDim[512][5],
    00163                                 long hasIndex[],
    00164                                 char index[512][64],
    00165                                 char type[],
    00166                                 long size[],
    00167                                 long hasRange[],
    00168                                 long irange[512][2],
    00169                                 double frange[512][2],
    00170                                 char title[],
    00171                                 long& numVar,
    00172                                 long& numEnt,
    00173                                 char block[512][12],
    00174                                 long, long, long, long, long, long);
    00175   void HBOOK_CALL_TYPE hlnext_(long& id, char*, char*, const char*, int, int, int);
    00176   void hbname_ (const long& id, const char* title, const void* opt, const char* form, int, int);
    00177   void hropen_(const long&, const char*, const char*, const char*, long&, long&, int,int,int);
    00178   void hcdir_(const char*, const char*, int, int);
    00179   void hldir_(const char*, const char*, int, int);
    00180   void hmdir_(const char*, const char*, int, int);
    00181 }
    00182
    00183 long RWNT_BOOK(const NTUPLEINFO& i)  {
    00184   return rwntbook_(i.id,
    00185        i.numVar,
    00186        i.name,
    00187        i.rzdir,
    00188        i.title,
    00189        sizeof(i.name[0]), strlen(i.rzdir), strlen(i.title));
    00190 }
    00191
    00192 long RWNT_INFO(NTUPLEINFO& i) {
    00193   long r = rwntinfo_(i.id,
    00194          i.numVar,
    00195          i.numEnt,
    00196          i.name,
    00197          i.frange,
    00198          i.title,
    00199          sizeof(i.name[0]), sizeof(i.title));
    00200   for ( long j = 0; j < i.numVar; j++ )   {
    00201     i.size[j] = sizeof(float)*CHAR_BIT;
    00202     i.dim[j] = 0;
    00203     i.hasRange[j] = 0;
    00204     i.hasIndex[j] = 0;
    00205   }
    00206   memset(i.block,0,sizeof(i.block));
    00207   return r;
    00208 }
    00209
    00210 long CWNT_BOOK(const NTUPLEINFO& i)  {
    00211   return cwntbook_(i.id, i.title, " ", strlen(i.title), 1);
    00212 }
    00213
    00214 long CWNT_INFO(NTUPLEINFO& i) {
    00215   long r = cwntinfo_(i.id,
    00216                      i.name,
    00217                      i.dim,
    00218                      i.theDim,
    00219                      i.hasIndex,
    00220                      i.index,
    00221                      i.type,
    00222                      i.size,
    00223                      i.hasRange,
    00224                      i.irange,
    00225                      i.frange,
    00226                      i.title,
    00227                      i.numVar,
    00228                      i.numEnt,
    00229                      i.block,
    00230                      sizeof(i.name[0]), sizeof(i.index[0]), 1,
    00231                      sizeof(i.title)-1,
    00232                      sizeof(i.block[0]),sizeof(i.index[0])
    00233                      );
    00234
    00235   // Clean up ntuple block names
    00236   for (long iv=0; iv<i.numVar; ++iv) {
    00237     std::string blk = i.block[iv];
    00238     blk = blk.substr(0,8);
    00239     int ibs;
    00240     if ( (ibs = blk.find(" ")) >= 0 ) {
    00241       blk = blk.substr(0,ibs);
    00242     }
    00243     strcpy(i.block[iv],blk.c_str());
    00244   }
    00245
    00246   cleanForString(i.title, sizeof(i.title)-1);
    00247   return r;
    00248 }
    00249
    00250 void HLNEXT(long& id, std::string& a, std::string& b, const std::string& c) {
    00251   char buff[256], typ[2] = {0,0};
    00252   memset(buff,0,sizeof(buff));
    00253   hlnext_(id, typ, buff, c.c_str(), sizeof(typ)-1, sizeof(buff), c.length());
    00254   buff[sizeof(buff)-1] = 0;
    00255   cleanForString(buff, sizeof(buff)-1);
    00256   b = buff;
    00257   a = typ;
    00258 }
    00259
    00260 void HCDIR(const std::string& a, const std::string& b )  {
    00261   hcdir_(a.c_str(), b.c_str(), a.length(), b.length());
    00262 }
    00263 void HLDIR(const std::string& a, const std::string& b )  {
    00264   hldir_(a.c_str(), b.c_str(), a.length(), b.length());
    00265 }
    00266 void HMDIR(const std::string& a, const std::string& b )  {
    00267   hmdir_(a.c_str(), b.c_str(), a.length(), b.length());
    00268 }
    00269 void HBNAME (const long& id, const std::string& a, const void* opt, const std::string& b) {
    00270   hbname_(id, a.c_str(), opt, b.c_str(), a.length(), b.length());
    00271 }
    00272 void HROPEN(const long& lun, const std::string& a, const std::string& b, const std::string& c, long& i, long& j) {
    00273   hropen_(lun, a.c_str(), b.c_str(), c.c_str(), i, j, a.length(), b.length(), c.length());
    00274 }
    00275 #endif