00001 #include "CPPFORT/lciof77apiext.h"
00002
00003 #include "lcio.h"
00004
00005 #include "IOIMPL/LCFactory.h"
00006 #include "IMPL/LCRunHeaderImpl.h"
00007 #include "IMPL/LCEventImpl.h"
00008 #include "IMPL/LCCollectionVec.h"
00009 #include "IMPL/SimTrackerHitImpl.h"
00010 #include "IMPL/SimCalorimeterHitImpl.h"
00011 #include "IMPL/LCTOOLS.h"
00012
00013 #include "CPPFORT/HEPEVT.h"
00014 #include "EVENT/LCIntVec.h"
00015 #include "EVENT/LCFloatVec.h"
00016 #include "EVENT/LCStrVec.h"
00017
00018 #include <string>
00019 #include <vector>
00020
00021
00022
00023 #include <iostream>
00024
00025
00026 using namespace lcio ;
00027 using namespace std ;
00028 using namespace HEPEVTIMPL ;
00029
00030
00031 static std::vector<std::string> filenamelist ;
00032
00033 int do_set_method (LCParameters& params, const char* method, const char* key, PTRTYPE vector);
00034 int do_get_method (const LCParameters& params, const char* method, const char* key, PTRTYPE vector);
00035
00036
00037 int lcrdropenchain( PTRTYPE reader, void* filenamesv , const int nfiles , const int nchfilename ){
00038
00039
00040 try {
00041
00042
00043 if ( filenamelist.size() > 0 ) filenamelist.clear() ;
00044 int elemlen = nchfilename +1 ;
00045 PTRTYPE stringpos = reinterpret_cast<PTRTYPE>( filenamesv ) ;
00046 for (int j=0;j < nfiles;j++)
00047 {
00048 char* filename = reinterpret_cast<char*>( stringpos ) ;
00049 filenamelist.push_back( filename ) ;
00050 stringpos = stringpos + elemlen ;
00051 }
00052 LCReader* lcReader = reinterpret_cast<LCReader*>( (reader) ) ;
00053 lcReader->open( filenamelist ) ;
00054 return LCIO::SUCCESS ;
00055 }catch( Exception& e1) {
00056 std::cerr << "Exception in LCRdrOpenChain: " << e1.what() << std::endl ;
00057 return LCIO::ERROR ;
00058 }
00059 }
00060
00061 int lcwriterunheader( PTRTYPE writer , const int irun , const char* detname ,
00062 const char* description , void* sdnamevec , const int nsubd,
00063 const int nchsd){
00064
00065 try {
00066 LCWriter* lcWriter = reinterpret_cast<LCWriter*>( (writer) ) ;
00067 LCRunHeaderImpl* runHdr = new LCRunHeaderImpl ;
00068 runHdr->setRunNumber( irun ) ;
00069 runHdr->setDetectorName( detname ) ;
00070 runHdr->setDescription( description ) ;
00071
00072 int elemlen = nchsd + 1 ;
00073 PTRTYPE stringpos = reinterpret_cast<PTRTYPE>( sdnamevec ) ;
00074 for (int j=0;j < nsubd;j++)
00075 {
00076 char* subdetectorname = reinterpret_cast<char*>( stringpos ) ;
00077 runHdr->addActiveSubdetector( subdetectorname ) ;
00078 stringpos = stringpos + elemlen ;
00079 }
00080 lcWriter->writeRunHeader( runHdr ) ;
00081 delete runHdr ;
00082 return LCIO::SUCCESS ;
00083 }catch( Exception& e1) {
00084 std::cerr << "Exception in LCWriteRunHeader: " << e1.what() << std::endl ;
00085 return LCIO::ERROR ;
00086 }
00087 }
00088
00089 PTRTYPE lcreadnextrunheader(PTRTYPE reader , int* irun , void* detname , void* description ,
00090 void* sdnamevec , int* nsubd , const int nchsubd){
00091
00092 LCReader* lcReader = reinterpret_cast<LCReader*>( (reader) ) ;
00093 try {
00094 LCRunHeader* runHdr = lcReader->readNextRunHeader() ;
00095 *irun = runHdr->getRunNumber() ;
00096
00097 PTRTYPE stringpos ;
00098 stringpos = reinterpret_cast<PTRTYPE>( detname ) ;
00099 char* detname = reinterpret_cast<char*>( stringpos ) ;
00100 const char* detectorname = runHdr->getDetectorName().c_str() ;
00101 strcpy(detname,detectorname) ;
00102 stringpos = reinterpret_cast<PTRTYPE>( description ) ;
00103 char* descr = reinterpret_cast<char*>( stringpos ) ;
00104 const char* rundescription = runHdr->getDescription().c_str() ;
00105 strcpy(descr,rundescription) ;
00106
00107 const std::vector<std::string>* strVec = runHdr->getActiveSubdetectors() ;
00108
00109 int elemlen = nchsubd + 1;
00110 *nsubd = strVec->size() ;
00111 stringpos = reinterpret_cast<PTRTYPE>( sdnamevec ) ;
00112 for( std::vector<std::string>::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
00113 std::string out = *name ;
00114 char* tmpname = reinterpret_cast<char*>( stringpos ) ;
00115 const char* subdname = const_cast<char*>( out.c_str() ) ;
00116 strcpy(tmpname,subdname) ;
00117 stringpos = stringpos + elemlen ;
00118 }
00119
00120 return reinterpret_cast<PTRTYPE>(runHdr) ;
00121 }catch( Exception& e1) {
00122 std::cerr << "Exception in LCReadNextRunHeader: " << e1.what() << std::endl ;
00123 return LCIO::ERROR ;
00124 }
00125 }
00126
00127
00128
00129 int lcseteventheader( PTRTYPE event, const int irun, const int ievent, const int timestamp, const char* detname ){
00130 LCEventImpl* lcEventImpl = reinterpret_cast<LCEventImpl*>( (event) ) ;
00131 lcEventImpl->setRunNumber( irun ) ;
00132 lcEventImpl->setEventNumber( ievent ) ;
00133 lcEventImpl->setTimeStamp( timestamp ) ;
00134 lcEventImpl->setDetectorName( detname ) ;
00135 return LCIO::SUCCESS ;
00136 }
00137
00138 int lcgeteventheader( PTRTYPE event, int* irun, int* ievent, int* timestamp, void* detname ){
00139 LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( (event) ) ;
00140 *irun = lcEvent->getRunNumber() ;
00141 *ievent = lcEvent->getEventNumber() ;
00142 *timestamp = lcEvent->getTimeStamp() ;
00143 PTRTYPE stringpos = reinterpret_cast<PTRTYPE>( detname ) ;
00144 char* detnam = reinterpret_cast<char*>( stringpos ) ;
00145 const char* detectorname = lcEvent->getDetectorName().c_str() ;
00146 strcpy(detnam,detectorname) ;
00147 return LCIO::SUCCESS ;
00148 }
00149 int lcdumprunheader( PTRTYPE runheader ){
00150 LCRunHeader* runhdr = reinterpret_cast<LCRunHeader*>( (runheader) ) ;
00151 LCTOOLS::dumpRunHeader( runhdr ) ;
00152 return LCIO::SUCCESS ;
00153 }
00154
00155 int lcdumpevent( PTRTYPE event ){
00156 LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( (event) ) ;
00157 LCTOOLS::dumpEvent( lcEvent ) ;
00158 return LCIO::SUCCESS ;
00159 }
00160
00161 int lcdumpeventdetailed ( PTRTYPE event ){
00162 LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( (event) ) ;
00163 LCTOOLS::dumpEventDetailed( lcEvent ) ;
00164 return LCIO::SUCCESS ;
00165 }
00166
00167
00168 int lcgetmcparticledata( PTRTYPE mcparticle, int* pdg, int* genstatus, int* simstatus
00169 , double* prodvtx, float* momentum, float* mass, float* charge,
00170 int* ndaughters ){
00171
00172 MCParticle* lcMCParticle = f2c_pointer<MCParticle,LCObject>( mcparticle ) ;
00173
00174 *pdg = lcMCParticle->getPDG() ;
00175 *genstatus = lcMCParticle->getGeneratorStatus() ;
00176 *simstatus = lcMCParticle->getSimulatorStatus() ;
00177 const double* dtmp = lcMCParticle->getVertex() ;
00178 for(int k=0;k<3;k++) *prodvtx++ = dtmp[k] ;
00179
00180
00181 const double* tmp = lcMCParticle->getMomentum() ;
00182
00183 for(int k=0;k<3;k++) *momentum++ = (float) tmp[k] ;
00184 *mass = lcMCParticle->getMass() ;
00185 *charge = lcMCParticle->getCharge() ;
00186 *ndaughters = lcMCParticle->getNumberOfDaughters() ;
00187 return LCIO::SUCCESS ;
00188 }
00189
00190
00191 int lcaddsimtrackerhit( PTRTYPE collectionvec, int cellID, double* pos, float dEdx,
00192 float time, PTRTYPE mcp ){
00193
00194 LCCollectionVec* lcCollectionVec = reinterpret_cast<LCCollectionVec*>( (collectionvec) ) ;
00195 SimTrackerHitImpl* hit = new SimTrackerHitImpl ;
00196 MCParticle* mmcp = f2c_pointer<MCParticle,LCObject>( mcp ) ;
00197
00198 hit->setCellID( cellID ) ;
00199 hit->setPosition( pos ) ;
00200 hit->setdEdx( dEdx ) ;
00201 hit->setTime( time ) ;
00202 hit->setMCParticle( mmcp ) ;
00203
00204 lcCollectionVec->push_back( hit ) ;
00205 return LCIO::SUCCESS ;
00206 }
00207
00208 int lcgetsimtrackerhit( PTRTYPE collection, int i, int* cellID, double* pos, float* dEdx, float* time, PTRTYPE* mcp ){
00209 LCCollectionVec* lcCollection = reinterpret_cast<LCCollectionVec*>( (collection) ) ;
00210 SimTrackerHit* hit = dynamic_cast<SimTrackerHit*>( lcCollection->getElementAt( i-1 ) ) ;
00211
00212 *cellID = hit->getCellID() ;
00213 const double* tmp = hit->getPosition() ;
00214 for(int k=0;k<3;k++) *pos++ = tmp[k] ;
00215 *dEdx = hit->getdEdx() ;
00216 *time = hit->getTime() ;
00217 *mcp = reinterpret_cast<PTRTYPE>( hit->getMCParticle() ) ;
00218 return LCIO::SUCCESS ;
00219 }
00220
00221
00222 PTRTYPE lcaddsimcalohit( PTRTYPE col, int cellID0, int cellID1, float energy, float* pos ) {
00223 LCCollectionVec* lcCollection = reinterpret_cast<LCCollectionVec*>( col ) ;
00224 SimCalorimeterHitImpl* lcHit = new SimCalorimeterHitImpl ;
00225 lcHit->setCellID0( cellID0 ) ;
00226 lcHit->setCellID1( cellID1 ) ;
00227 lcHit->setEnergy( energy ) ;
00228 lcHit->setPosition( pos ) ;
00229 lcCollection->addElement( lcHit ) ;
00230 return C2F_POINTER( LCObject*, lcHit ) ;
00231 }
00232
00233
00234 PTRTYPE lcgetsimcalohit( PTRTYPE collection, int i, int* cellID0, int* cellID1,
00235 float* energy, float* pos ) {
00236
00237 LCCollectionVec* lcCollection = reinterpret_cast<LCCollectionVec*>( collection ) ;
00238
00239
00240 const int Nelements = lcCollection->getNumberOfElements() ;
00241 if (i < 0 && i > Nelements-1) {
00242 std::cerr << "Exception in LCGetSimCaloHit: index " << i << " out of range" << std::endl ;
00243 return LCIO::ERROR ;
00244 }
00245
00246 SimCalorimeterHit* lcHit = dynamic_cast<SimCalorimeterHit*>( lcCollection->getElementAt( i-1 ) ) ;
00247 *cellID0 = lcHit->getCellID0() ;
00248 *cellID1 = lcHit->getCellID1() ;
00249 *energy = lcHit->getEnergy() ;
00250 const float* tmp = lcHit->getPosition() ;
00251 for(int k=0;k<3;k++) *pos++ = tmp[k] ;
00252
00253 return C2F_POINTER( LCObject*, lcHit ) ;
00254 }
00255
00256 int lcgetsimcalohitmccont( PTRTYPE hit, int i, PTRTYPE* mcp, float* energy, float* time, int* pdg ) {
00257
00258 SimCalorimeterHitImpl* lcHit = f2c_pointer<SimCalorimeterHitImpl,LCObject>( hit ) ;
00259
00260 const int Nelements = lcHit->getNMCContributions() ;
00261 if (i < 0 && i > Nelements-1) {
00262 std::cerr << "Exception in lcgetsimcalohitmccont: index " << i << " out of range" << std::endl ;
00263 return LCIO::ERROR ;
00264 }
00265
00266 *mcp = C2F_POINTER( LCObject*, lcHit->getParticleCont(i-1) ) ;
00267 *energy = lcHit->getEnergyCont( i-1 ) ;
00268 *time = lcHit->getTimeCont( i-1 ) ;
00269 *pdg = lcHit->getPDGCont( i-1 ) ;
00270 return LCIO::SUCCESS ;
00271 }
00272
00273 int hepevt2lcio( PTRTYPE evtout ){
00274 LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( evtout ) ;
00275 try {
00276 HEPEVT::fromHepEvt( lcEvent ) ;
00277 return LCIO::SUCCESS ;
00278 }catch( Exception& e1) {
00279 std::cerr << "Exception in lcio2hepevt: " << e1.what() << std::endl ;
00280 return LCIO::ERROR ;
00281 }
00282 }
00283
00284
00285 int lcio2hepevt( PTRTYPE event ){
00286 LCEvent* lcEvent = reinterpret_cast<LCEventImpl*>( event ) ;
00287 try {
00288 HEPEVT::toHepEvt( lcEvent ) ;
00289 return LCIO::SUCCESS ;
00290 }catch( Exception& e1) {
00291 std::cerr << "Exception in hepevt2lcio: " << e1.what() << std::endl ;
00292 return LCIO::ERROR ;
00293 }
00294 }
00295
00296
00297 PTRTYPE lcobjectvectorcreate( PTRTYPE* objectv, const int nobjv ){
00298 LCObjectVec* objVec = new LCObjectVec ;
00299 for(int j=0;j<nobjv;j++) {
00300 LCObject* obj = f2c_pointer<LCObject,LCObject>( objectv[j] ) ;
00301 objVec->push_back( obj ) ;
00302 }
00303 return reinterpret_cast<PTRTYPE>( objVec ) ;
00304 }
00305
00306 PTRTYPE lcintvectorcreate( int* intv, const int nintv ){
00307 LCIntVec* intVec = new LCIntVec ;
00308 for(int j=0;j<nintv;j++) intVec->push_back( intv[j] ) ;
00309 return reinterpret_cast<PTRTYPE>( intVec ) ;
00310 }
00311
00312 PTRTYPE lcfloatvectorcreate( float* floatv, const int nfloatv ){
00313 LCFloatVec* floatVec = new LCFloatVec ;
00314 for(int j=0;j<nfloatv;j++) floatVec->push_back( floatv[j] ) ;
00315 return reinterpret_cast<PTRTYPE>( floatVec ) ;
00316 }
00317
00318 PTRTYPE lcstringvectorcreate( void* stringv, const int nstringv, const int nchstringv){
00319 LCStrVec* stringVec = new LCStrVec ;
00320 int elemlen = nchstringv + 1;
00321 PTRTYPE stringpos = 0 ;
00322 stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
00323 for(int j=0;j<nstringv;j++){
00324 const std::string& mystring = reinterpret_cast<char*>( stringpos ) ;
00325 stringVec->push_back( mystring ) ;
00326 stringpos = stringpos + elemlen ;
00327 }
00328 return reinterpret_cast<PTRTYPE>( stringVec ) ;
00329 }
00330
00331 int lcgetintvector( PTRTYPE vector, int* intv, int* nintv ){
00332 LCIntVec* intVec = f2c_pointer<LCIntVec,LCObject>(vector) ;
00333 int intVecLength = 0;
00334 intVecLength = intVec->size() ;
00335 if (intVecLength > *nintv) {
00336 std::cerr << "Warning in lcgetintvector: vector size " << intVecLength
00337 << " larger then target array size " << *nintv << std::endl ;
00338 intVecLength = *nintv ;
00339 }
00340 else {
00341 *nintv = intVecLength ;
00342 }
00343 for (int j=0;j < intVecLength;j++) *intv++ = (*intVec)[j] ;
00344 return LCIO::SUCCESS ;
00345 }
00346
00347 int lcgetfloatvector( PTRTYPE vector, float* floatv, int* nfloatv ){
00348 LCFloatVec* floatVec = f2c_pointer<LCFloatVec,LCObject>(vector) ;
00349 int floatVecLength = 0 ;
00350 floatVecLength = floatVec->size() ;
00351 if (floatVecLength > *nfloatv) {
00352 std::cerr << "Warning in lcgetfloatvector: vector size " << floatVecLength
00353 << " larger then target array size " << *nfloatv << std::endl ;
00354 floatVecLength = *nfloatv ;
00355 }
00356 else {
00357 *nfloatv = floatVecLength ;
00358 }
00359 for (int j=0;j < floatVecLength;j++) *floatv++ = (*floatVec)[j] ;
00360 return LCIO::SUCCESS ;
00361 }
00362
00363
00364 int lcgetstringvector( PTRTYPE vector, void* stringv, int* nstringv, const int nchstringv){
00365 LCStrVec* stringVec = reinterpret_cast<LCStrVec*>(vector) ;
00366 int stringVecLength = 0 ;
00367 stringVecLength = stringVec->size() ;
00368 if (stringVecLength > *nstringv) {
00369 std::cerr << "Warning in lcgetstringvector: vector size " << stringVecLength
00370 << " larger then target array size " << *nstringv << std::endl ;
00371 stringVecLength = *nstringv ;
00372 }
00373 else {
00374 *nstringv = stringVecLength ;
00375 }
00376 int elemlen = nchstringv + 1;
00377 PTRTYPE stringpos = 0 ;
00378 stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
00379 for (int j=0;j < stringVecLength;j++) {
00380 char* outstring = const_cast<char*>( (*stringVec)[j].c_str() );
00381 char* tmpstring = reinterpret_cast<char*>( stringpos ) ;
00382 strcpy(tmpstring,outstring) ;
00383 stringpos = stringpos + elemlen ;
00384 }
00385 return LCIO::SUCCESS ;
00386 }
00387
00388
00389 PTRTYPE intvectorcreate( int* intv, const int nintv ){
00390 IntVec* intVec = new IntVec ;
00391 for(int j=0;j<nintv;j++) intVec->push_back( intv[j] ) ;
00392 return reinterpret_cast<PTRTYPE>( intVec ) ;
00393 }
00394
00395 int intvectordelete( PTRTYPE vector ){
00396 IntVec* intVec = reinterpret_cast<IntVec*>(vector) ;
00397 delete intVec ;
00398 return LCIO::SUCCESS ;
00399 }
00400
00401 PTRTYPE floatvectorcreate( float* floatv, const int nfloatv ){
00402 FloatVec* floatVec = new FloatVec ;
00403 for(int j=0;j<nfloatv;j++) floatVec->push_back( floatv[j] ) ;
00404 return reinterpret_cast<PTRTYPE>( floatVec ) ;
00405 }
00406
00407 int floatvectordelete( PTRTYPE vector ){
00408 FloatVec* floatVec = reinterpret_cast<FloatVec*>(vector) ;
00409 delete floatVec ;
00410 return LCIO::SUCCESS ;
00411 }
00412
00413 PTRTYPE stringvectorcreate( void* stringv, const int nstringv, const int nchstringv){
00414 StringVec* stringVec = new StringVec ;
00415 int elemlen = nchstringv + 1;
00416 PTRTYPE stringpos = 0 ;
00417 stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
00418 for(int j=0;j<nstringv;j++){
00419 const std::string& mystring = reinterpret_cast<char*>( stringpos ) ;
00420 stringVec->push_back( mystring ) ;
00421 stringpos = stringpos + elemlen ;
00422 }
00423 return reinterpret_cast<PTRTYPE>( stringVec ) ;
00424 }
00425
00426 int stringvectordelete( PTRTYPE vector ){
00427 StringVec* stringVec = reinterpret_cast<StringVec*>(vector) ;
00428 delete stringVec ;
00429 return LCIO::SUCCESS ;
00430 }
00431
00432 PTRTYPE pointervectorcreate( PTRTYPE* pointerv, const int npointerv ){
00433 PointerVec* pointerVec = new PointerVec ;
00434 for(int j=0;j<npointerv;j++) pointerVec->push_back( pointerv[j] ) ;
00435 return reinterpret_cast<PTRTYPE>( pointerVec ) ;
00436 }
00437
00438 int pointervectordelete( PTRTYPE vector ){
00439 PointerVec* pointerVec = reinterpret_cast<PointerVec*>(vector) ;
00440 delete pointerVec ;
00441 return LCIO::SUCCESS ;
00442 }
00443
00444
00445 int getintvector( PTRTYPE vector, int* intv, int* nintv ){
00446 IntVec* intVec = reinterpret_cast<IntVec*>(vector) ;
00447 int intVecLength = 0;
00448 intVecLength = intVec->size() ;
00449 if (intVecLength > *nintv) {
00450 std::cerr << "Warning in getintvector: vector size " << intVecLength
00451 << " larger then target array size " << *nintv << std::endl ;
00452 intVecLength = *nintv ;
00453 }
00454 else {
00455 *nintv = intVecLength ;
00456 }
00457 for (int j=0;j < intVecLength;j++) *intv++ = (*intVec)[j] ;
00458 return LCIO::SUCCESS ;
00459 }
00460
00461 int getfloatvector( PTRTYPE vector, float* floatv, int* nfloatv ){
00462 FloatVec* floatVec = reinterpret_cast<FloatVec*>(vector) ;
00463 int floatVecLength = 0 ;
00464 floatVecLength = floatVec->size() ;
00465 if (floatVecLength > *nfloatv) {
00466 std::cerr << "Warning in getfloatvector: vector size " << floatVecLength
00467 << " larger then target array size " << *nfloatv << std::endl ;
00468 floatVecLength = *nfloatv ;
00469 }
00470 else {
00471 *nfloatv = floatVecLength ;
00472 }
00473 for (int j=0;j < floatVecLength;j++) *floatv++ = (*floatVec)[j] ;
00474 return LCIO::SUCCESS ;
00475 }
00476
00477
00478 int getstringvector( PTRTYPE vector, void* stringv, int* nstringv, const int nchstringv){
00479 StringVec* stringVec = reinterpret_cast<StringVec*>(vector) ;
00480 int stringVecLength = 0 ;
00481 stringVecLength = stringVec->size() ;
00482 if (stringVecLength > *nstringv) {
00483 std::cerr << "Warning in getstringvector: vector size " << stringVecLength
00484 << " larger then target array size " << *nstringv << std::endl ;
00485 stringVecLength = *nstringv ;
00486 }
00487 else {
00488 *nstringv = stringVecLength ;
00489 }
00490 int elemlen = nchstringv + 1;
00491 PTRTYPE stringpos = 0 ;
00492 stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
00493 for (int j=0;j < stringVecLength;j++) {
00494 char* outstring = const_cast<char*>( (*stringVec)[j].c_str() );
00495 char* tmpstring = reinterpret_cast<char*>( stringpos ) ;
00496 strcpy(tmpstring,outstring) ;
00497 stringpos = stringpos + elemlen ;
00498 }
00499 return LCIO::SUCCESS ;
00500 }
00501
00502 int getpointervector( PTRTYPE vector, PTRTYPE* pointerv, int* npointerv ){
00503 PointerVec* pointerVec = reinterpret_cast<PointerVec*>(vector) ;
00504 int pointerVecLength = 0;
00505 pointerVecLength = pointerVec->size() ;
00506 if (pointerVecLength > *npointerv) {
00507 std::cerr << "Warning in getpointervector: vector size " << pointerVecLength
00508 << " larger then target array size " << *npointerv << std::endl ;
00509 pointerVecLength = *npointerv ;
00510 }
00511 else {
00512 *npointerv = pointerVecLength ;
00513 }
00514 for (int j=0;j < pointerVecLength;j++) *pointerv++ = (*pointerVec)[j] ;
00515 return LCIO::SUCCESS ;
00516 }
00517
00518
00519
00520 int lcsetparameters (const char* class_name, PTRTYPE classp, const char* method, const char* key, PTRTYPE vecp){
00521 const std::string & classname = class_name ;
00522 if (classname == LCIO::LCRUNHEADER) {
00523 LCRunHeaderImpl* rhd = reinterpret_cast<LCRunHeaderImpl*>(classp) ;
00524 return do_set_method (rhd->parameters(), method, key, vecp) ;
00525 }
00526 else if (classname == LCIO::LCEVENT) {
00527 LCEventImpl* evt = reinterpret_cast<LCEventImpl*>(classp) ;
00528 return do_set_method (evt->parameters(), method, key, vecp) ;
00529 }
00530 else if (classname == LCIO::LCCOLLECTION) {
00531 LCCollectionVec* col = reinterpret_cast<LCCollectionVec*>(classp) ;
00532 return do_set_method (col->parameters(), method, key, vecp) ;
00533 }
00534 else {
00535 std::cerr << "Warning in lcsetparameters: unknown class name " << classname << std::endl ;
00536 return LCIO::ERROR ;
00537 }
00538 }
00539
00540 int lcgetparameters (const char* class_name, PTRTYPE classp, const char* method, const char* key, PTRTYPE vecp){
00541 const std::string & classname = class_name ;
00542 if (classname == LCIO::LCRUNHEADER) {
00543 LCRunHeaderImpl* rhd = reinterpret_cast<LCRunHeaderImpl*>(classp) ;
00544 return do_get_method (rhd->getParameters(), method, key, vecp) ;
00545 }
00546 else if (classname == LCIO::LCEVENT) {
00547 LCEventImpl* evt = reinterpret_cast<LCEventImpl*>(classp) ;
00548 return do_get_method (evt->getParameters(), method, key, vecp) ;
00549 }
00550 else if (classname == LCIO::LCCOLLECTION) {
00551 LCCollectionVec* col = reinterpret_cast<LCCollectionVec*>(classp) ;
00552 return do_get_method (col->getParameters(), method, key, vecp) ;
00553 }
00554 else {
00555 std::cerr << "Warning in lcgetparameters: unknown class name " << classname << std::endl ;
00556 return LCIO::ERROR ;
00557 }
00558
00559 }
00560
00561 int do_set_method (LCParameters& params, const char* my_method, const char* key, PTRTYPE vector) {
00562 const std::string & method = my_method ;
00563 if (method == string("setIntValues")) {
00564 IntVec* intVec = reinterpret_cast<IntVec*>(vector) ;
00565 params.setValues(key, *intVec) ;
00566 return LCIO::SUCCESS ;
00567 }
00568 else if (method == string("setFloatValues")) {
00569 FloatVec* floatVec = reinterpret_cast<FloatVec*>(vector) ;
00570 params.setValues(key, *floatVec) ;
00571 return LCIO::SUCCESS ;
00572 }
00573 else if (method == string("setStringValues")) {
00574 StringVec* stringVec = reinterpret_cast<StringVec*>(vector) ;
00575 params.setValues(key, *stringVec) ;
00576 return LCIO::SUCCESS ;
00577 }
00578 else {
00579 std::cerr << "Warning in lcsetparameters: unknown method name " << method << std::endl ;
00580 return LCIO::ERROR ;
00581 }
00582 }
00583
00584 int do_get_method (const LCParameters& params, const char* my_method, const char* key, PTRTYPE vector) {
00585 const std::string & method = my_method ;
00586 if (method == string("getIntValues")) {
00587 IntVec* intVec = f2c_pointer<IntVec,LCObject>(vector) ;
00588 params.getIntVals(key, *intVec) ;
00589 return LCIO::SUCCESS ;
00590 }
00591 else if (method == string("getFloatValues")) {
00592 FloatVec* floatVec = f2c_pointer<FloatVec,LCObject>(vector) ;
00593 params.getFloatVals(key, *floatVec) ;
00594 return LCIO::SUCCESS ;
00595 }
00596 else if (method == string("getStringValues")) {
00597 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
00598 params.getStringVals(key, *stringVec) ;
00599 return LCIO::SUCCESS ;
00600 }
00601 else if (method == string("getIntKeys")) {
00602 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
00603 params.getIntKeys(*stringVec) ;
00604 return LCIO::SUCCESS ;
00605 }
00606 else if (method == string("getFloatKeys")) {
00607 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
00608 params.getFloatKeys(*stringVec) ;
00609 return LCIO::SUCCESS ;
00610 }
00611 else if (method == string("getStringtKeys")) {
00612 StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
00613 params.getStringKeys(*stringVec) ;
00614 return LCIO::SUCCESS ;
00615 }
00616 else {
00617 std::cerr << "Warning in lcgetparameters: unknown method name " << method << std::endl ;
00618 return LCIO::ERROR ;
00619 }
00620 }
00621
00622