LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lciof77apiext.cc
Go to the documentation of this file.
2 
3 #include "lcio.h"
4 
5 #include "IOIMPL/LCFactory.h"
6 #include "IMPL/LCRunHeaderImpl.h"
7 #include "IMPL/LCEventImpl.h"
8 #include "IMPL/LCCollectionVec.h"
11 #include "IMPL/LCTOOLS.h"
12 
13 #include "CPPFORT/HEPEVT.h"
14 #include "EVENT/LCIntVec.h"
15 #include "EVENT/LCFloatVec.h"
16 #include "EVENT/LCStrVec.h"
17 
18 #include <string>
19 #include <vector>
20 
21 // typedef std::vector<std::string> LCStrVec ;
22 
23 #include <iostream>
24 
25 
26 using namespace lcio ;
27 using namespace std ;
28 using namespace HEPEVTIMPL ;
29 
30 
32 
33 int do_set_method (LCParameters& params, const char* method, const char* key, PTRTYPE vector);
34 int do_get_method (const LCParameters& params, const char* method, const char* key, PTRTYPE vector);
35 
36 
37 int lcrdropenchain( PTRTYPE reader, void* filenamesv , const int nfiles , const int nchfilename ){
38 
39 
40  try {
41 // if an old filenamelist exist clear it
42 
43  if ( filenamelist.size() > 0 ) filenamelist.clear() ;
44  int elemlen = nchfilename +1 ;
45  PTRTYPE stringpos = reinterpret_cast<PTRTYPE>( filenamesv ) ;
46  for (int j=0;j < nfiles;j++)
47  {
48  char* filename = reinterpret_cast<char*>( stringpos ) ;
49  filenamelist.push_back( filename ) ;
50  stringpos = stringpos + elemlen ;
51  }
52  LCReader* lcReader = reinterpret_cast<LCReader*>( (reader) ) ;
53  lcReader->open( filenamelist ) ;
54  return LCIO::SUCCESS ;
55  }catch( Exception& e1) {
56  std::cerr << "Exception in LCRdrOpenChain: " << e1.what() << std::endl ;
57  return LCIO::ERROR ;
58  }
59 }
60 
61 int lcwriterunheader( PTRTYPE writer , const int irun , const char* detname ,
62  const char* description , void* sdnamevec , const int nsubd,
63  const int nchsd){
64 
65  try {
66  LCWriter* lcWriter = reinterpret_cast<LCWriter*>( (writer) ) ;
67  LCRunHeaderImpl* runHdr = new LCRunHeaderImpl ;
68  runHdr->setRunNumber( irun ) ;
69  runHdr->setDetectorName( detname ) ;
70  runHdr->setDescription( description ) ;
71 
72  int elemlen = nchsd + 1 ;
73  PTRTYPE stringpos = reinterpret_cast<PTRTYPE>( sdnamevec ) ;
74  for (int j=0;j < nsubd;j++)
75  {
76  char* subdetectorname = reinterpret_cast<char*>( stringpos ) ;
77  runHdr->addActiveSubdetector( subdetectorname ) ;
78  stringpos = stringpos + elemlen ;
79  }
80  lcWriter->writeRunHeader( runHdr ) ;
81  delete runHdr ;
82  return LCIO::SUCCESS ;
83  }catch( Exception& e1) {
84  std::cerr << "Exception in LCWriteRunHeader: " << e1.what() << std::endl ;
85  return LCIO::ERROR ;
86  }
87 }
88 
89 PTRTYPE lcreadnextrunheader(PTRTYPE reader , int* irun , void* detname , void* description ,
90  void* sdnamevec , int* nsubd , const int nchsubd){
91 
92  LCReader* lcReader = reinterpret_cast<LCReader*>( (reader) ) ;
93  try {
94  LCRunHeader* runHdr = lcReader->readNextRunHeader() ;
95  *irun = runHdr->getRunNumber() ;
96 
97  PTRTYPE stringpos ;
98  stringpos = reinterpret_cast<PTRTYPE>( detname ) ;
99  char* detnam = reinterpret_cast<char*>( stringpos ) ;
100  const char* detectorname = runHdr->getDetectorName().c_str() ;
101  strcpy(detnam,detectorname) ;
102  stringpos = reinterpret_cast<PTRTYPE>( description ) ;
103  char* descr = reinterpret_cast<char*>( stringpos ) ;
104  const char* rundescription = runHdr->getDescription().c_str() ;
105  strcpy(descr,rundescription) ;
106 
107  const std::vector<std::string>* strVec = runHdr->getActiveSubdetectors() ;
108 
109  int elemlen = nchsubd + 1;
110  *nsubd = strVec->size() ;
111  stringpos = reinterpret_cast<PTRTYPE>( sdnamevec ) ;
112  for( std::vector<std::string>::const_iterator name = strVec->begin() ; name != strVec->end() ; name++){
113  std::string out = *name ;
114  char* tmpname = reinterpret_cast<char*>( stringpos ) ;
115  const char* subdname = const_cast<char*>( out.c_str() ) ;
116  strcpy(tmpname,subdname) ;
117  stringpos = stringpos + elemlen ;
118  }
119 
120  return reinterpret_cast<PTRTYPE>(runHdr) ;
121  }catch( Exception& e1) {
122  std::cerr << "Exception in LCReadNextRunHeader: " << e1.what() << std::endl ;
123  return LCIO::ERROR ;
124  }
125 }
126 
127 
128 
129 int lcseteventheader( PTRTYPE event, const int irun, const int ievent, const int timestamp, const char* detname ){
130  LCEventImpl* lcEventImpl = reinterpret_cast<LCEventImpl*>( (event) ) ;
131  lcEventImpl->setRunNumber( irun ) ;
132  lcEventImpl->setEventNumber( ievent ) ;
133  lcEventImpl->setTimeStamp( timestamp ) ;
134  lcEventImpl->setDetectorName( detname ) ;
135  return LCIO::SUCCESS ;
136 }
137 
138 int lcgeteventheader( PTRTYPE event, int* irun, int* ievent, int* timestamp, void* detname ){
139  LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( (event) ) ;
140  *irun = lcEvent->getRunNumber() ;
141  *ievent = lcEvent->getEventNumber() ;
142  *timestamp = lcEvent->getTimeStamp() ;
143  PTRTYPE stringpos = reinterpret_cast<PTRTYPE>( detname ) ;
144  char* detnam = reinterpret_cast<char*>( stringpos ) ;
145  const char* detectorname = lcEvent->getDetectorName().c_str() ;
146  strcpy(detnam,detectorname) ;
147  return LCIO::SUCCESS ;
148 }
149 int lcdumprunheader( PTRTYPE runheader ){
150  LCRunHeader* runhdr = reinterpret_cast<LCRunHeader*>( (runheader) ) ;
151  LCTOOLS::dumpRunHeader( runhdr ) ;
152  return LCIO::SUCCESS ;
153 }
154 
156  LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( (event) ) ;
157  LCTOOLS::dumpEvent( lcEvent ) ;
158  return LCIO::SUCCESS ;
159 }
160 
162  LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( (event) ) ;
163  LCTOOLS::dumpEventDetailed( lcEvent ) ;
164  return LCIO::SUCCESS ;
165 }
166 
167 
168 int lcgetmcparticledata( PTRTYPE mcparticle, int* pdg, int* genstatus, int* simstatus
169  , double* prodvtx, float* momentum, float* mass, float* charge,
170  int* ndaughters ){
171 
172  MCParticle* lcMCParticle = f2c_pointer<MCParticle,LCObject>( mcparticle ) ;
173 
174  *pdg = lcMCParticle->getPDG() ;
175  *genstatus = lcMCParticle->getGeneratorStatus() ;
176  *simstatus = lcMCParticle->getSimulatorStatus() ;
177  const double* dtmp = lcMCParticle->getVertex() ;
178  for(int k=0;k<3;k++) *prodvtx++ = dtmp[k] ;
179 
180 
181  const double* tmp = lcMCParticle->getMomentum() ;
182 
183  for(int k=0;k<3;k++) *momentum++ = (float) tmp[k] ;
184  *mass = lcMCParticle->getMass() ;
185  *charge = lcMCParticle->getCharge() ;
186  *ndaughters = lcMCParticle->getDaughters().size() ;
187  return LCIO::SUCCESS ;
188 }
189 
190 
191 int lcaddsimtrackerhit( PTRTYPE collectionvec, int cellID0, double* pos, float dEdx,
192  float time, PTRTYPE mcp ){
193 
194  LCCollectionVec* lcCollectionVec = reinterpret_cast<LCCollectionVec*>( (collectionvec) ) ;
195  SimTrackerHitImpl* hit = new SimTrackerHitImpl ;
196  MCParticle* mmcp = f2c_pointer<MCParticle,LCObject>( mcp ) ;
197 
198  hit->setCellID0( cellID0 ) ;
199  hit->setPosition( pos ) ;
200  hit->setEDep( dEdx ) ;
201  hit->setTime( time ) ;
202  hit->setMCParticle( mmcp ) ;
203 
204  lcCollectionVec->push_back( hit ) ;
205  return LCIO::SUCCESS ;
206 }
207 
208 int lcgetsimtrackerhit( PTRTYPE collection, int i, int* cellID, double* pos, float* dEdx, float* time, PTRTYPE* mcp ){
209  LCCollectionVec* lcCollection = reinterpret_cast<LCCollectionVec*>( (collection) ) ;
210  SimTrackerHit* hit = dynamic_cast<SimTrackerHit*>( lcCollection->getElementAt( i-1 ) ) ;
211 
212  *cellID = hit->getCellID() ;
213  const double* tmp = hit->getPosition() ;
214  for(int k=0;k<3;k++) *pos++ = tmp[k] ;
215  *dEdx = hit->getdEdx() ;
216  *time = hit->getTime() ;
217  *mcp = reinterpret_cast<PTRTYPE>( hit->getMCParticle() ) ;
218  return LCIO::SUCCESS ;
219 }
220 
221 
222 PTRTYPE lcaddsimcalohit( PTRTYPE col, int cellID0, int cellID1, float energy, float* pos ) {
223  LCCollectionVec* lcCollection = reinterpret_cast<LCCollectionVec*>( col ) ;
224  SimCalorimeterHitImpl* lcHit = new SimCalorimeterHitImpl ;
225  lcHit->setCellID0( cellID0 ) ;
226  lcHit->setCellID1( cellID1 ) ;
227  lcHit->setEnergy( energy ) ;
228  lcHit->setPosition( pos ) ;
229  lcCollection->addElement( lcHit ) ;
230  return C2F_POINTER( LCObject*, lcHit ) ;
231 }
232 
233 
234 PTRTYPE lcgetsimcalohit( PTRTYPE collection, int i, int* cellID0, int* cellID1,
235  float* energy, float* pos ) {
236 
237  LCCollectionVec* lcCollection = reinterpret_cast<LCCollectionVec*>( collection ) ;
238 
239  // checking on i !
240  const int Nelements = lcCollection->getNumberOfElements() ;
241  if (i < 0 && i > Nelements-1) {
242  std::cerr << "Exception in LCGetSimCaloHit: index " << i << " out of range" << std::endl ;
243  return LCIO::ERROR ;
244  }
245 
246  SimCalorimeterHit* lcHit = dynamic_cast<SimCalorimeterHit*>( lcCollection->getElementAt( i-1 ) ) ;
247  *cellID0 = lcHit->getCellID0() ;
248  *cellID1 = lcHit->getCellID1() ;
249  *energy = lcHit->getEnergy() ;
250  const float* tmp = lcHit->getPosition() ;
251  for(int k=0;k<3;k++) *pos++ = tmp[k] ;
252 
253  return C2F_POINTER( LCObject*, lcHit ) ;
254 }
255 
256 int lcgetsimcalohitmccont( PTRTYPE hit, int i, PTRTYPE* mcp, float* energy, float* time, int* pdg ) {
257 
258  SimCalorimeterHitImpl* lcHit = f2c_pointer<SimCalorimeterHitImpl,LCObject>( hit ) ;
259 // checking on i !
260  const int Nelements = lcHit->getNMCContributions() ;
261  if (i < 0 && i > Nelements-1) {
262  std::cerr << "Exception in lcgetsimcalohitmccont: index " << i << " out of range" << std::endl ;
263  return LCIO::ERROR ;
264  }
265 
266  *mcp = C2F_POINTER( LCObject*, lcHit->getParticleCont(i-1) ) ;
267  *energy = lcHit->getEnergyCont( i-1 ) ;
268  *time = lcHit->getTimeCont( i-1 ) ;
269  *pdg = lcHit->getPDGCont( i-1 ) ;
270  return LCIO::SUCCESS ;
271 }
272 
273 int hepevt2lcio( PTRTYPE evtout ){
274  LCEventImpl* lcEvent = reinterpret_cast<LCEventImpl*>( evtout ) ;
275  try {
276  HEPEVT::fromHepEvt( lcEvent ) ;
277  return LCIO::SUCCESS ;
278  }catch( Exception& e1) {
279  std::cerr << "Exception in lcio2hepevt: " << e1.what() << std::endl ;
280  return LCIO::ERROR ;
281  }
282 }
283 
284 
286  LCEvent* lcEvent = reinterpret_cast<LCEventImpl*>( event ) ;
287  try {
288  HEPEVT::toHepEvt( lcEvent ) ;
289  return LCIO::SUCCESS ;
290  }catch( Exception& e1) {
291  std::cerr << "Exception in hepevt2lcio: " << e1.what() << std::endl ;
292  return LCIO::ERROR ;
293  }
294 }
295 
296 
297 PTRTYPE lcobjectvectorcreate( PTRTYPE* objectv, const int nobjv ){
298  LCObjectVec* objVec = new LCObjectVec ;
299  for(int j=0;j<nobjv;j++) {
300  LCObject* obj = f2c_pointer<LCObject,LCObject>( objectv[j] ) ;
301  objVec->push_back( obj ) ;
302  }
303  return reinterpret_cast<PTRTYPE>( objVec ) ;
304 }
305 
306 PTRTYPE lcintvectorcreate( int* intv, const int nintv ){
307  LCIntVec* intVec = new LCIntVec ;
308  for(int j=0;j<nintv;j++) intVec->push_back( intv[j] ) ;
309  return reinterpret_cast<PTRTYPE>( intVec ) ;
310 }
311 
312 PTRTYPE lcfloatvectorcreate( float* floatv, const int nfloatv ){
313  LCFloatVec* floatVec = new LCFloatVec ;
314  for(int j=0;j<nfloatv;j++) floatVec->push_back( floatv[j] ) ;
315  return reinterpret_cast<PTRTYPE>( floatVec ) ;
316 }
317 
318 PTRTYPE lcstringvectorcreate( void* stringv, const int nstringv, const int nchstringv){
319  LCStrVec* stringVec = new LCStrVec ;
320  int elemlen = nchstringv + 1;
321  PTRTYPE stringpos = 0 ;
322  stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
323  for(int j=0;j<nstringv;j++){
324  const std::string& mystring = reinterpret_cast<char*>( stringpos ) ;
325  stringVec->push_back( mystring ) ;
326  stringpos = stringpos + elemlen ;
327  }
328  return reinterpret_cast<PTRTYPE>( stringVec ) ;
329 }
330 
331 int lcgetintvector( PTRTYPE vector, int* intv, int* nintv ){
332  LCIntVec* intVec = f2c_pointer<LCIntVec,LCObject>(vector) ;
333  int intVecLength = 0;
334  intVecLength = intVec->size() ;
335  if (intVecLength > *nintv) {
336  std::cerr << "Warning in lcgetintvector: vector size " << intVecLength
337  << " larger then target array size " << *nintv << std::endl ;
338  intVecLength = *nintv ;
339  }
340  else {
341  *nintv = intVecLength ;
342  }
343  for (int j=0;j < intVecLength;j++) *intv++ = (*intVec)[j] ;
344  return LCIO::SUCCESS ;
345 }
346 
347 int lcgetfloatvector( PTRTYPE vector, float* floatv, int* nfloatv ){
348  LCFloatVec* floatVec = f2c_pointer<LCFloatVec,LCObject>(vector) ;
349  int floatVecLength = 0 ;
350  floatVecLength = floatVec->size() ;
351  if (floatVecLength > *nfloatv) {
352  std::cerr << "Warning in lcgetfloatvector: vector size " << floatVecLength
353  << " larger then target array size " << *nfloatv << std::endl ;
354  floatVecLength = *nfloatv ;
355  }
356  else {
357  *nfloatv = floatVecLength ;
358  }
359  for (int j=0;j < floatVecLength;j++) *floatv++ = (*floatVec)[j] ;
360  return LCIO::SUCCESS ;
361 }
362 
363 
364 int lcgetstringvector( PTRTYPE vector, void* stringv, int* nstringv, const int nchstringv){
365  LCStrVec* stringVec = reinterpret_cast<LCStrVec*>(vector) ;
366  int stringVecLength = 0 ;
367  stringVecLength = stringVec->size() ;
368  if (stringVecLength > *nstringv) {
369  std::cerr << "Warning in lcgetstringvector: vector size " << stringVecLength
370  << " larger then target array size " << *nstringv << std::endl ;
371  stringVecLength = *nstringv ;
372  }
373  else {
374  *nstringv = stringVecLength ;
375  }
376  int elemlen = nchstringv + 1;
377  PTRTYPE stringpos = 0 ;
378  stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
379  for (int j=0;j < stringVecLength;j++) {
380  char* outstring = const_cast<char*>( (*stringVec)[j].c_str() );
381  char* tmpstring = reinterpret_cast<char*>( stringpos ) ;
382  strcpy(tmpstring,outstring) ;
383  stringpos = stringpos + elemlen ;
384  }
385  return LCIO::SUCCESS ;
386 }
387 
388 
389 PTRTYPE intvectorcreate( int* intv, const int nintv ){
390  IntVec* intVec = new IntVec ;
391  for(int j=0;j<nintv;j++) intVec->push_back( intv[j] ) ;
392  return reinterpret_cast<PTRTYPE>( intVec ) ;
393 }
394 
396  IntVec* intVec = reinterpret_cast<IntVec*>(vector) ;
397  delete intVec ;
398  return LCIO::SUCCESS ;
399 }
400 
401 PTRTYPE floatvectorcreate( float* floatv, const int nfloatv ){
402  FloatVec* floatVec = new FloatVec ;
403  for(int j=0;j<nfloatv;j++) floatVec->push_back( floatv[j] ) ;
404  return reinterpret_cast<PTRTYPE>( floatVec ) ;
405 }
406 
408  FloatVec* floatVec = reinterpret_cast<FloatVec*>(vector) ;
409  delete floatVec ;
410  return LCIO::SUCCESS ;
411 }
412 
413 PTRTYPE stringvectorcreate( void* stringv, const int nstringv, const int nchstringv){
414  StringVec* stringVec = new StringVec ;
415  int elemlen = nchstringv + 1;
416  PTRTYPE stringpos = 0 ;
417  stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
418  for(int j=0;j<nstringv;j++){
419  const std::string& mystring = reinterpret_cast<char*>( stringpos ) ;
420  stringVec->push_back( mystring ) ;
421  stringpos = stringpos + elemlen ;
422  }
423  return reinterpret_cast<PTRTYPE>( stringVec ) ;
424 }
425 
427  StringVec* stringVec = reinterpret_cast<StringVec*>(vector) ;
428  delete stringVec ;
429  return LCIO::SUCCESS ;
430 }
431 
432 PTRTYPE pointervectorcreate( PTRTYPE* pointerv, const int npointerv ){
433  PointerVec* pointerVec = new PointerVec ;
434  for(int j=0;j<npointerv;j++) pointerVec->push_back( pointerv[j] ) ;
435  return reinterpret_cast<PTRTYPE>( pointerVec ) ;
436 }
437 
439  PointerVec* pointerVec = reinterpret_cast<PointerVec*>(vector) ;
440  delete pointerVec ;
441  return LCIO::SUCCESS ;
442 }
443 
444 
445 int getintvector( PTRTYPE vector, int* intv, int* nintv ){
446  IntVec* intVec = reinterpret_cast<IntVec*>(vector) ;
447  int intVecLength = 0;
448  intVecLength = intVec->size() ;
449  if (intVecLength > *nintv) {
450  std::cerr << "Warning in getintvector: vector size " << intVecLength
451  << " larger then target array size " << *nintv << std::endl ;
452  intVecLength = *nintv ;
453  }
454  else {
455  *nintv = intVecLength ;
456  }
457  for (int j=0;j < intVecLength;j++) *intv++ = (*intVec)[j] ;
458  return LCIO::SUCCESS ;
459 }
460 
461 int getfloatvector( PTRTYPE vector, float* floatv, int* nfloatv ){
462  FloatVec* floatVec = reinterpret_cast<FloatVec*>(vector) ;
463  int floatVecLength = 0 ;
464  floatVecLength = floatVec->size() ;
465  if (floatVecLength > *nfloatv) {
466  std::cerr << "Warning in getfloatvector: vector size " << floatVecLength
467  << " larger then target array size " << *nfloatv << std::endl ;
468  floatVecLength = *nfloatv ;
469  }
470  else {
471  *nfloatv = floatVecLength ;
472  }
473  for (int j=0;j < floatVecLength;j++) *floatv++ = (*floatVec)[j] ;
474  return LCIO::SUCCESS ;
475 }
476 
477 
478 int getstringvector( PTRTYPE vector, void* stringv, int* nstringv, const int nchstringv){
479  StringVec* stringVec = reinterpret_cast<StringVec*>(vector) ;
480  int stringVecLength = 0 ;
481  stringVecLength = stringVec->size() ;
482  if (stringVecLength > *nstringv) {
483  std::cerr << "Warning in getstringvector: vector size " << stringVecLength
484  << " larger then target array size " << *nstringv << std::endl ;
485  stringVecLength = *nstringv ;
486  }
487  else {
488  *nstringv = stringVecLength ;
489  }
490  int elemlen = nchstringv + 1;
491  PTRTYPE stringpos = 0 ;
492  stringpos = reinterpret_cast<PTRTYPE>( stringv ) ;
493  for (int j=0;j < stringVecLength;j++) {
494  char* outstring = const_cast<char*>( (*stringVec)[j].c_str() );
495  char* tmpstring = reinterpret_cast<char*>( stringpos ) ;
496  strcpy(tmpstring,outstring) ;
497  stringpos = stringpos + elemlen ;
498  }
499  return LCIO::SUCCESS ;
500 }
501 
502 int getpointervector( PTRTYPE vector, PTRTYPE* pointerv, int* npointerv ){
503  PointerVec* pointerVec = reinterpret_cast<PointerVec*>(vector) ;
504  int pointerVecLength = 0;
505  pointerVecLength = pointerVec->size() ;
506  if (pointerVecLength > *npointerv) {
507  std::cerr << "Warning in getpointervector: vector size " << pointerVecLength
508  << " larger then target array size " << *npointerv << std::endl ;
509  pointerVecLength = *npointerv ;
510  }
511  else {
512  *npointerv = pointerVecLength ;
513  }
514  for (int j=0;j < pointerVecLength;j++) *pointerv++ = (*pointerVec)[j] ;
515  return LCIO::SUCCESS ;
516 }
517 
518 
519 
520 int lcsetparameters (const char* class_name, PTRTYPE classp, const char* method, const char* key, PTRTYPE vecp){
521  const std::string & classname = class_name ;
522  if (classname == LCIO::LCRUNHEADER) {
523  LCRunHeaderImpl* rhd = reinterpret_cast<LCRunHeaderImpl*>(classp) ;
524  return do_set_method (rhd->parameters(), method, key, vecp) ;
525  }
526  else if (classname == LCIO::LCEVENT) {
527  LCEventImpl* evt = reinterpret_cast<LCEventImpl*>(classp) ;
528  return do_set_method (evt->parameters(), method, key, vecp) ;
529  }
530  else if (classname == LCIO::LCCOLLECTION) {
531  LCCollectionVec* col = reinterpret_cast<LCCollectionVec*>(classp) ;
532  return do_set_method (col->parameters(), method, key, vecp) ;
533  }
534  else {
535  std::cerr << "Warning in lcsetparameters: unknown class name " << classname << std::endl ;
536  return LCIO::ERROR ;
537  }
538 }
539 
540 int lcgetparameters (const char* class_name, PTRTYPE classp, const char* method, const char* key, PTRTYPE vecp){
541  const std::string & classname = class_name ;
542  if (classname == LCIO::LCRUNHEADER) {
543  LCRunHeaderImpl* rhd = reinterpret_cast<LCRunHeaderImpl*>(classp) ;
544  return do_get_method (rhd->getParameters(), method, key, vecp) ;
545  }
546  else if (classname == LCIO::LCEVENT) {
547  LCEventImpl* evt = reinterpret_cast<LCEventImpl*>(classp) ;
548  return do_get_method (evt->getParameters(), method, key, vecp) ;
549  }
550  else if (classname == LCIO::LCCOLLECTION) {
551  LCCollectionVec* col = reinterpret_cast<LCCollectionVec*>(classp) ;
552  return do_get_method (col->getParameters(), method, key, vecp) ;
553  }
554  else {
555  std::cerr << "Warning in lcgetparameters: unknown class name " << classname << std::endl ;
556  return LCIO::ERROR ;
557  }
558 
559 }
560 
561 int do_set_method (LCParameters& params, const char* my_method, const char* key, PTRTYPE vector) {
562  const std::string & method = my_method ;
563  if (method == string("setIntValues")) {
564  IntVec* intVec = reinterpret_cast<IntVec*>(vector) ;
565  params.setValues(key, *intVec) ;
566  return LCIO::SUCCESS ;
567  }
568  else if (method == string("setFloatValues")) {
569  FloatVec* floatVec = reinterpret_cast<FloatVec*>(vector) ;
570  params.setValues(key, *floatVec) ;
571  return LCIO::SUCCESS ;
572  }
573  else if (method == string("setStringValues")) {
574  StringVec* stringVec = reinterpret_cast<StringVec*>(vector) ;
575  params.setValues(key, *stringVec) ;
576  return LCIO::SUCCESS ;
577  }
578  else {
579  std::cerr << "Warning in lcsetparameters: unknown method name " << method << std::endl ;
580  return LCIO::ERROR ;
581  }
582 }
583 
584 int do_get_method (const LCParameters& params, const char* my_method, const char* key, PTRTYPE vector) {
585  const std::string & method = my_method ;
586  if (method == string("getIntValues")) {
587  IntVec* intVec = f2c_pointer<IntVec,LCObject>(vector) ;
588  params.getIntVals(key, *intVec) ;
589  return LCIO::SUCCESS ;
590  }
591  else if (method == string("getFloatValues")) {
592  FloatVec* floatVec = f2c_pointer<FloatVec,LCObject>(vector) ;
593  params.getFloatVals(key, *floatVec) ;
594  return LCIO::SUCCESS ;
595  }
596  else if (method == string("getStringValues")) {
597  StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
598  params.getStringVals(key, *stringVec) ;
599  return LCIO::SUCCESS ;
600  }
601  else if (method == string("getIntKeys")) {
602  StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
603  params.getIntKeys(*stringVec) ;
604  return LCIO::SUCCESS ;
605  }
606  else if (method == string("getFloatKeys")) {
607  StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
608  params.getFloatKeys(*stringVec) ;
609  return LCIO::SUCCESS ;
610  }
611  else if (method == string("getStringtKeys")) {
612  StringVec* stringVec = f2c_pointer<StringVec,LCObject>(vector) ;
613  params.getStringKeys(*stringVec) ;
614  return LCIO::SUCCESS ;
615  }
616  else {
617  std::cerr << "Warning in lcgetparameters: unknown method name " << method << std::endl ;
618  return LCIO::ERROR ;
619  }
620 }
621 
622 
LCIO_DEPRECATED_CAPI int lcio2hepevt(PTRTYPE event)
Fill the hepevt common block with the MCParicle data in the LCIO event.
LCIO_DEPRECATED_CAPI PTRTYPE intvectorcreate(int *intv, const int nintv)
Create/Delete an int vector.
std::vector< std::string > StringVec
Vector of strings.
Definition: LCIOSTLTypes.h:16
LCIO_DEPRECATED_CAPI int lcsetparameters(const char *classname, PTRTYPE classp, const char *method, const char *key, PTRTYPE vecp)
For the set methods:
LCIO_DEPRECATED_CAPI int getintvector(PTRTYPE vector, int *intv, int *nintv)
Return the content of an int vector.
INTV CFORTRANPNTRV lcgetsimcalohit
LCIO_DEPRECATED_CAPI int lcdumpeventdetailed(PTRTYPE event)
Detailed dump of all the data in the event to stdout.
LCIO_DEPRECATED_CAPI int lcgetfloatvector(PTRTYPE vector, float *floatv, int *nfloatv)
Return the content of a LC float vector.
std::vector< LCObject * > LCObjectVec
Vector of (pointers to) LCObjects.
Definition: LCObject.h:17
INTV INT CFORTRANPNTR floatvectordelete
CFORTRANPNTR CFORTRANPNTR getfloatvector
std::vector< float > FloatVec
Vector of floats.
Definition: LCIOSTLTypes.h:18
T endl(T...args)
getpointervector
LCEvent * event
Definition: lsh.cc:80
T end(T...args)
static std::vector< std::string > filenamelist
LCIO_DEPRECATED_CAPI int getstringvector(PTRTYPE vector, void *stringv, int *nstringv, const int nchstringv)
Return the content of a string vector.
lcgetintvector
LCIO_DEPRECATED_CAPI PTRTYPE lcaddsimcalohit(PTRTYPE col, int cellID0, int cellID1, float energy, float *pos)
Add a new SimCalorimeterHit with the given data to the collection.
std::vector< std::string > LCStrVec
Header file for the f77-wrapper functions for stl vectors.
Definition: lcvec.h:17
STL class.
stringvectordelete
T push_back(T...args)
LCIO_DEPRECATED_CAPI int hepevt2lcio(PTRTYPE event)
Create an MCParticle collection from the hepevt common block and add it to the event.
lcseteventheader
INTV CFORTRANPNTRV FLOATV INT lcfloatvectorcreate
LCIO_DEPRECATED_CAPI PTRTYPE lcreadnextrunheader(PTRTYPE reader, int *irun, void *detname, void *descr, void *sdnamevec, int *nsubd, const int nchsubd)
Read the next run header and fills the return arguments with the data.
LCIO_DEPRECATED_CAPI int lcrdropenchain(PTRTYPE reader, void *filenamesv, const int nfiles, const int nchfilename)
Header file for additional f77-wrapper functions.
CFORTRANPNTR pointervectordelete
INTV INT intvectordelete
long PTRTYPE
Fortran interface - define the length of pointers this has to made machine independent ...
Definition: cpointer.h:12
LCIO_DEPRECATED_CAPI int lcgeteventheader(PTRTYPE event, int *irun, int *ievent, int *timestamp, void *detname)
Read the complete event header data from the event.
LCIO_DEPRECATED_CAPI PTRTYPE floatvectorcreate(float *floatv, const int nfloatv)
Create/Delete a float vector.
T clear(T...args)
INTV CFORTRANPNTRV FLOATV lcobjectvectorcreate
LCIO_DEPRECATED_CAPI int lcgetsimcalohitmccont(PTRTYPE hit, int i, PTRTYPE *mcp, float *energy, float *time, int *pdg)
Return the specified contribution of a MCParticle to the hit in the arguments.
T strcpy(T...args)
T size(T...args)
INTV lcgetsimtrackerhit
LCIO_DEPRECATED_CAPI int lcaddsimtrackerhit(PTRTYPE col, int cellID, double *pos, float dEdx, float time, PTRTYPE mcp)
Add a new SimTrackerHit with the given data to the collection.
std::vector< int > IntVec
Vector of ints.
Definition: LCIOSTLTypes.h:22
int do_get_method(const LCParameters &params, const char *method, const char *key, PTRTYPE vector)
T begin(T...args)
LCIO_DEPRECATED_CAPI PTRTYPE pointervectorcreate(PTRTYPE *pointerv, const int npointerv)
Create/Delete a pointer vector.
std::vector< PTRTYPE > PointerVec
Definition: cpointer.h:17
LCRunHeader * runHdr
Definition: lsh.cc:79
T c_str(T...args)
LCReader * lcReader
Definition: lsh.cc:78
INTV lcgetstringvector
LCIO_DEPRECATED_CAPI int lcdumprunheader(PTRTYPE runheader)
Dump the run header to the stdout.
LCIO_DEPRECATED_CAPI PTRTYPE lcstringvectorcreate(void *stringv, const int nstringv, const int nchstringv)
Create a LC string vector.
lcwriterunheader
int do_set_method(LCParameters &params, const char *method, const char *key, PTRTYPE vector)
LCIO_DEPRECATED_CAPI PTRTYPE lcintvectorcreate(int *intv, const int nintv)
Create an LC int vector.
void dumpEvent(EVENT::LCEvent *event)
LCIO_DEPRECATED_CAPI int lcdumpevent(PTRTYPE event)
Dump the event to the stdout - one line per collection.
INTV lcgetparameters
lcgetmcparticledata
#define C2F_POINTER(T, ptr)
Definition: cpointer.h:33
LCIO_DEPRECATED_CAPI PTRTYPE stringvectorcreate(void *stringv, const int nstringv, const int nchstringv)
Create/Delete a string vector.